diff --git a/src/TSMapEditor/Config/Default/ScriptActions.ini b/src/TSMapEditor/Config/Default/ScriptActions.ini index f27d62ec..d8d1d31e 100644 --- a/src/TSMapEditor/Config/Default/ScriptActions.ini +++ b/src/TSMapEditor/Config/Default/ScriptActions.ini @@ -143,12 +143,10 @@ ParamType=Waypoint [ChangeScript] Name=Change Script Description=Instructs the team to execute another script. -ParamType=ScriptType [ChangeTeam] Name=Change Team Description=Instructs the TaskForce to join another TeamType. -ParamType=TeamType [Panic] Name=Panic diff --git a/src/TSMapEditor/UI/Windows/ScriptsWindow.cs b/src/TSMapEditor/UI/Windows/ScriptsWindow.cs index 4ec781e8..959f5308 100644 --- a/src/TSMapEditor/UI/Windows/ScriptsWindow.cs +++ b/src/TSMapEditor/UI/Windows/ScriptsWindow.cs @@ -710,6 +710,8 @@ private void SetParameterEntryText(ScriptActionEntry scriptActionEntry, ScriptAc return; } + lbActions.SelectedItem.Text = GetActionEntryText(scriptActionEntry.Action, scriptActionEntry); + if (action.ParamType == TriggerParamType.BuildingWithProperty) { tbParameterValue.Text = GetBuildingWithPropertyText(scriptActionEntry.Argument); @@ -944,11 +946,72 @@ private void EditScript(Script script) private string GetActionEntryText(int index, ScriptActionEntry entry) { + string actionEntryText; + string textDetails = null; + ScriptAction action = GetScriptAction(entry.Action); if (action == null) - return "#" + index + " - Unknown (" + entry.Argument.ToString(CultureInfo.InvariantCulture) + ")"; + { + actionEntryText = $"#{index} - Unknown"; + textDetails = $"({ entry.Argument.ToString(CultureInfo.InvariantCulture)})"; + } + else + { + actionEntryText = $"#{index} - {action.Name}"; + int presetOptionIndex = action.PresetOptions.FindIndex(presetOption => presetOption.Value == entry.Argument); + bool hasValidPresetOption = presetOptionIndex > -1; + + switch (action.ParamType) + { + case TriggerParamType.BuildingWithProperty: + var (buildingTypeIndex, property) = SplitBuildingWithProperty(entry.Argument); + string propertyDescription = property.ToDescription(); + BuildingType buildingType = map.Rules.BuildingTypes.GetElementIfInRange(buildingTypeIndex); + + if (buildingType != null) + textDetails = $"({buildingType.Index} - {buildingType.GetEditorDisplayName()} - {propertyDescription})"; + break; + + case TriggerParamType.LocalVariable: + var localVar = map.LocalVariables.GetElementIfInRange(entry.Argument); + if (localVar != null) + textDetails = $"({localVar.Index} - {localVar.Name})"; + break; + + case TriggerParamType.HouseType: + var houseType = map.Houses.GetElementIfInRange(entry.Argument); + if (houseType != null) + textDetails = $"({houseType.ID} - {houseType.ININame})"; + break; + + case TriggerParamType.Animation: + var animation = map.Rules.AnimTypes.GetElementIfInRange(entry.Argument); + if (animation != null) + textDetails = $"({animation.Index} - {animation.ININame})"; + break; + + case TriggerParamType.Unknown: + // special handling: script actions that have no type but still have presets should be handled by showing the preset value + // otherwise we'll show no text after the name of the action + if (hasValidPresetOption) + goto default; + + textDetails = null; + break; + + default: + if (hasValidPresetOption) + textDetails = $"({presetOptionIndex} - {action.PresetOptions[presetOptionIndex].Text})"; + else + textDetails = $"({entry.Argument.ToString(CultureInfo.InvariantCulture)})"; + break; + } + } + + if (string.IsNullOrEmpty(textDetails)) + return actionEntryText; - return "#" + index + " - " + action.Name + " (" + entry.Argument.ToString(CultureInfo.InvariantCulture) + ")"; + return $"{actionEntryText} {textDetails}"; } private string GetActionNameFromIndex(int index)