Disallowed Save Map without Title and Author Input

This commit is contained in:
Zachary Schirm
2022-09-13 11:21:45 -04:00
committed by Gustas
parent d95c6e821c
commit 1339faa5f4

View File

@@ -160,6 +160,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var filename = widget.Get<TextFieldWidget>("FILENAME"); var filename = widget.Get<TextFieldWidget>("FILENAME");
filename.Text = map.Package == null ? "" : mapIsUnpacked ? Path.GetFileName(map.Package.Name) : Path.GetFileNameWithoutExtension(map.Package.Name); filename.Text = map.Package == null ? "" : mapIsUnpacked ? Path.GetFileName(map.Package.Name) : Path.GetFileNameWithoutExtension(map.Package.Name);
if (string.IsNullOrEmpty(filename.Text))
filename.TakeKeyboardFocus();
var fileType = mapIsUnpacked ? MapFileType.Unpacked : MapFileType.OraMap; var fileType = mapIsUnpacked ? MapFileType.Unpacked : MapFileType.OraMap;
var fileTypes = new Dictionary<MapFileType, MapFileTypeInfo>() var fileTypes = new Dictionary<MapFileType, MapFileTypeInfo>()
@@ -231,11 +234,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
}; };
var save = widget.Get<ButtonWidget>("SAVE_BUTTON"); var save = widget.Get<ButtonWidget>("SAVE_BUTTON");
save.IsDisabled = () => string.IsNullOrWhiteSpace(filename.Text) || string.IsNullOrWhiteSpace(title.Text) || string.IsNullOrWhiteSpace(author.Text);
save.OnClick = () => save.OnClick = () =>
{ {
if (string.IsNullOrEmpty(filename.Text))
return;
var combinedPath = Platform.ResolvePath(Path.Combine(selectedDirectory.Folder.Name, filename.Text + fileTypes[fileType].Extension)); var combinedPath = Platform.ResolvePath(Path.Combine(selectedDirectory.Folder.Name, filename.Text + fileTypes[fileType].Extension));
if (map.Package?.Name != combinedPath) if (map.Package?.Name != combinedPath)