-
-
Notifications
You must be signed in to change notification settings - Fork 42
Allow script actions to use window for parameter selection #176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Rampastring
merged 1 commit into
CnCNet:master
from
Starkku:feature/script-param-window
Jul 28, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/TSMapEditor/Config/Default/UI/Windows/SelectScriptActionPresetOptionWindow.ini
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| [SelectScriptActionPresetOptionWindow] | ||
| $Width=350 | ||
| $Height=RESOLUTION_HEIGHT - 100 | ||
| $CC0=lblDescription:XNALabel | ||
| $CC1=tbSearch:EditorSuggestionTextBox | ||
| $CC2=btnSelect:EditorButton | ||
| $CC3=lbObjectList:EditorListBox | ||
|
|
||
| [lblDescription] | ||
| $X=EMPTY_SPACE_SIDES | ||
| $Y=EMPTY_SPACE_TOP | ||
| FontIndex=1 | ||
| Text=Select parameter value: | ||
|
|
||
| [tbSearch] | ||
| $X=EMPTY_SPACE_SIDES | ||
| $Y=getBottom(lblDescription) + EMPTY_SPACE_TOP | ||
| $Width=getWidth(SelectScriptActionPresetOptionWindow) - (EMPTY_SPACE_SIDES * 2) | ||
| Suggestion=Search parameter values... | ||
|
|
||
| [btnSelect] | ||
| $Width=100 | ||
| $X=(getWidth(SelectScriptActionPresetOptionWindow) - getWidth(btnSelect)) / 2 | ||
| $Y=getHeight(SelectScriptActionPresetOptionWindow) - EMPTY_SPACE_BOTTOM - getHeight(btnSelect) | ||
| Text=Select | ||
|
|
||
| [lbObjectList] | ||
| $X=EMPTY_SPACE_SIDES | ||
| $Y=getBottom(tbSearch) + VERTICAL_SPACING | ||
| $Width=getWidth(tbSearch) | ||
| $Height=getY(btnSelect) - getY(lbObjectList) - EMPTY_SPACE_TOP | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
src/TSMapEditor/UI/Windows/SelectScriptActionPresetOptionWindow.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| using Microsoft.Xna.Framework; | ||
| using Rampastring.XNAUI; | ||
| using Rampastring.XNAUI.XNAControls; | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using TSMapEditor.CCEngine; | ||
| using TSMapEditor.Models; | ||
| using TSMapEditor.Models.Enums; | ||
|
|
||
| namespace TSMapEditor.UI.Windows | ||
| { | ||
| public class SelectScriptActionPresetOptionWindow : SelectObjectWindow<ScriptActionPresetOption> | ||
| { | ||
| public SelectScriptActionPresetOptionWindow(WindowManager windowManager, Map map) : base(windowManager) | ||
| { | ||
| this.map = map; | ||
| } | ||
|
|
||
| private Map map; | ||
| public List<ScriptActionPresetOption> presetOptions { get; } = new List<ScriptActionPresetOption>(0); | ||
|
|
||
| public override void Initialize() | ||
| { | ||
| Name = nameof(SelectScriptActionPresetOptionWindow); | ||
| base.Initialize(); | ||
| } | ||
|
|
||
| protected override void LbObjectList_SelectedIndexChanged(object sender, EventArgs e) | ||
| { | ||
| if (lbObjectList.SelectedItem == null) | ||
| { | ||
| SelectedObject = null; | ||
| return; | ||
| } | ||
|
|
||
| SelectedObject = (ScriptActionPresetOption)lbObjectList.SelectedItem.Tag; | ||
| } | ||
|
|
||
| protected override void ListObjects() | ||
| { | ||
| lbObjectList.Clear(); | ||
|
|
||
| foreach (ScriptActionPresetOption presetOption in presetOptions) | ||
| { | ||
| var item = new XNAListBoxItem() { Text = $"{presetOption.GetOptionText()}", Tag = presetOption }; | ||
|
|
||
| lbObjectList.AddItem(item); | ||
|
|
||
| if (presetOption == SelectedObject) | ||
| lbObjectList.SelectedIndex = lbObjectList.Items.Count - 1; | ||
| } | ||
| } | ||
|
|
||
| public string FillPresetOptions(ScriptActionEntry entry, ScriptAction action) | ||
| { | ||
| presetOptions.Clear(); | ||
| presetOptions.AddRange(action.PresetOptions); | ||
|
|
||
| var fittingItem = presetOptions.Find(item => item.Text.StartsWith(entry.Argument.ToString())); | ||
|
|
||
| if (fittingItem != null) | ||
| return fittingItem.Text; | ||
|
|
||
| return null; | ||
| } | ||
|
|
||
| public ScriptActionPresetOption GetMatchingItem(string text) | ||
| { | ||
| return presetOptions.Find(item => item.GetOptionText().Equals(text, StringComparison.Ordinal)); | ||
| } | ||
|
|
||
| public string GetSelectedItemText() | ||
| { | ||
| if (SelectedObject != null) | ||
| return SelectedObject.GetOptionText(); | ||
|
|
||
| return string.Empty; | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.