Allow saving maps with multiple visibility options
This commit is contained in:
@@ -52,24 +52,30 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var author = widget.Get<TextFieldWidget>("AUTHOR");
|
var author = widget.Get<TextFieldWidget>("AUTHOR");
|
||||||
author.Text = map.Author;
|
author.Text = map.Author;
|
||||||
|
|
||||||
// TODO: This should use a multi-selection dropdown once they exist
|
var visibilityPanel = Ui.LoadWidget("MAP_SAVE_VISIBILITY_PANEL", null, new WidgetArgs());
|
||||||
var visibilityDropdown = widget.Get<DropDownButtonWidget>("VISIBILITY_DROPDOWN");
|
var visOptionTemplate = visibilityPanel.Get<CheckboxWidget>("VISIBILITY_TEMPLATE");
|
||||||
{
|
visibilityPanel.RemoveChildren();
|
||||||
var mapVisibility = new List<string>(Enum.GetNames(typeof(MapVisibility)));
|
|
||||||
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) =>
|
|
||||||
{
|
|
||||||
var item = ScrollItemWidget.Setup(template,
|
|
||||||
() => visibilityDropdown.Text == option,
|
|
||||||
() => { visibilityDropdown.Text = option; });
|
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => option;
|
|
||||||
return item;
|
|
||||||
};
|
|
||||||
|
|
||||||
visibilityDropdown.Text = Enum.GetName(typeof(MapVisibility), map.Visibility);
|
foreach (MapVisibility visibilityOption in Enum.GetValues(typeof(MapVisibility)))
|
||||||
visibilityDropdown.OnClick = () =>
|
{
|
||||||
visibilityDropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 210, mapVisibility, setupItem);
|
// To prevent users from breaking the game only show the 'Shellmap' option when it is already set.
|
||||||
|
if (visibilityOption == MapVisibility.Shellmap && !map.Visibility.HasFlag(visibilityOption))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var checkbox = (CheckboxWidget)visOptionTemplate.Clone();
|
||||||
|
checkbox.GetText = () => visibilityOption.ToString();
|
||||||
|
checkbox.IsChecked = () => map.Visibility.HasFlag(visibilityOption);
|
||||||
|
checkbox.OnClick = () => map.Visibility ^= visibilityOption;
|
||||||
|
visibilityPanel.AddChild(checkbox);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var visibilityDropdown = widget.Get<DropDownButtonWidget>("VISIBILITY_DROPDOWN");
|
||||||
|
visibilityDropdown.OnMouseDown = _ =>
|
||||||
|
{
|
||||||
|
visibilityDropdown.RemovePanel();
|
||||||
|
visibilityDropdown.AttachPanel(visibilityPanel);
|
||||||
|
};
|
||||||
|
|
||||||
var writableDirectories = new List<SaveDirectory>();
|
var writableDirectories = new List<SaveDirectory>();
|
||||||
SaveDirectory selectedDirectory = null;
|
SaveDirectory selectedDirectory = null;
|
||||||
|
|
||||||
@@ -157,7 +163,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
map.Title = title.Text;
|
map.Title = title.Text;
|
||||||
map.Author = author.Text;
|
map.Author = author.Text;
|
||||||
map.Visibility = (MapVisibility)Enum.Parse(typeof(MapVisibility), visibilityDropdown.Text);
|
|
||||||
|
|
||||||
if (actorDefinitions != null)
|
if (actorDefinitions != null)
|
||||||
map.ActorDefinitions = actorDefinitions;
|
map.ActorDefinitions = actorDefinitions;
|
||||||
|
|||||||
@@ -134,6 +134,7 @@ Background@SAVE_MAP_PANEL:
|
|||||||
Y: 85
|
Y: 85
|
||||||
Width: 220
|
Width: 220
|
||||||
Height: 25
|
Height: 25
|
||||||
|
Text: Map Visibility
|
||||||
Font: Regular
|
Font: Regular
|
||||||
Label@DIRECTORY_LABEL:
|
Label@DIRECTORY_LABEL:
|
||||||
X: 10
|
X: 10
|
||||||
@@ -181,6 +182,16 @@ Background@SAVE_MAP_PANEL:
|
|||||||
Text: Save
|
Text: Save
|
||||||
Font: Bold
|
Font: Bold
|
||||||
|
|
||||||
|
ScrollPanel@MAP_SAVE_VISIBILITY_PANEL:
|
||||||
|
Width: 220
|
||||||
|
Height: 64
|
||||||
|
Children:
|
||||||
|
Checkbox@VISIBILITY_TEMPLATE:
|
||||||
|
X: 5
|
||||||
|
Width: PARENT_RIGHT - 29
|
||||||
|
Height: 20
|
||||||
|
Font: Regular
|
||||||
|
|
||||||
Container@EDITOR_ROOT:
|
Container@EDITOR_ROOT:
|
||||||
Logic: LoadMapEditorLogic
|
Logic: LoadMapEditorLogic
|
||||||
Children:
|
Children:
|
||||||
|
|||||||
@@ -127,6 +127,7 @@ Background@SAVE_MAP_PANEL:
|
|||||||
Y: 130
|
Y: 130
|
||||||
Width: 220
|
Width: 220
|
||||||
Height: 25
|
Height: 25
|
||||||
|
Text: Map Visibility
|
||||||
Label@DIRECTORY_LABEL:
|
Label@DIRECTORY_LABEL:
|
||||||
X: 10
|
X: 10
|
||||||
Y: 164
|
Y: 164
|
||||||
@@ -172,6 +173,16 @@ Background@SAVE_MAP_PANEL:
|
|||||||
Font: Bold
|
Font: Bold
|
||||||
Key: escape
|
Key: escape
|
||||||
|
|
||||||
|
ScrollPanel@MAP_SAVE_VISIBILITY_PANEL:
|
||||||
|
Width: 220
|
||||||
|
Height: 64
|
||||||
|
Children:
|
||||||
|
Checkbox@VISIBILITY_TEMPLATE:
|
||||||
|
X: 5
|
||||||
|
Width: PARENT_RIGHT - 29
|
||||||
|
Height: 20
|
||||||
|
Font: Regular
|
||||||
|
|
||||||
Container@EDITOR_ROOT:
|
Container@EDITOR_ROOT:
|
||||||
Logic: LoadMapEditorLogic
|
Logic: LoadMapEditorLogic
|
||||||
Children:
|
Children:
|
||||||
|
|||||||
Reference in New Issue
Block a user