Add script tags to map editor actor properties.
This commit is contained in:
committed by
Gustas Kažukauskas
parent
53f959e4bf
commit
0fac8d0d31
@@ -51,6 +51,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
readonly Widget checkboxOptionTemplate;
|
||||
readonly Widget sliderOptionTemplate;
|
||||
readonly Widget dropdownOptionTemplate;
|
||||
readonly Widget textFieldOptionTemplate;
|
||||
|
||||
ActorIDStatus actorIDStatus = ActorIDStatus.Normal;
|
||||
ActorIDStatus nextActorIDStatus = ActorIDStatus.Normal;
|
||||
@@ -85,6 +86,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
checkboxOptionTemplate = initContainer.Get("CHECKBOX_OPTION_TEMPLATE");
|
||||
sliderOptionTemplate = initContainer.Get("SLIDER_OPTION_TEMPLATE");
|
||||
dropdownOptionTemplate = initContainer.Get("DROPDOWN_OPTION_TEMPLATE");
|
||||
textFieldOptionTemplate = initContainer.Get("TEXTFIELD_OPTION_TEMPLATE");
|
||||
initContainer.RemoveChildren();
|
||||
|
||||
var deleteButton = actorEditPanel.Get<ButtonWidget>("DELETE_BUTTON");
|
||||
@@ -320,6 +322,31 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
initContainer.AddChild(dropdownContainer);
|
||||
}
|
||||
else if (o is EditorActorTextField tfo)
|
||||
{
|
||||
var textFieldContainer = textFieldOptionTemplate.Clone();
|
||||
textFieldContainer.Bounds.Y = initContainer.Bounds.Height;
|
||||
initContainer.Bounds.Height += textFieldContainer.Bounds.Height;
|
||||
textFieldContainer.Get<LabelWidget>("LABEL").GetText = () => tfo.Name;
|
||||
|
||||
var editorActionHandle = new EditorActorOptionActionHandle<string>(tfo.OnChange, tfo.GetValue(SelectedActor));
|
||||
editActorPreview.Add(editorActionHandle);
|
||||
|
||||
var textField = textFieldContainer.Get<TextFieldWidget>("OPTION");
|
||||
textField.Text = tfo.GetValue(SelectedActor);
|
||||
|
||||
textField.OnTextEdited = () =>
|
||||
{
|
||||
tfo.OnChange(SelectedActor, textField.Text);
|
||||
editorActionHandle.OnChange(textField.Text);
|
||||
};
|
||||
|
||||
textField.OnEscKey = _ => { textField.YieldKeyboardFocus(); return true; };
|
||||
textField.OnEnterKey = _ => { textField.YieldKeyboardFocus(); return true; };
|
||||
typableFields.Add(textField);
|
||||
|
||||
initContainer.AddChild(textFieldContainer);
|
||||
}
|
||||
}
|
||||
|
||||
buttonContainer.Bounds.Y += initContainer.Bounds.Height - oldInitHeight;
|
||||
|
||||
Reference in New Issue
Block a user