@@ -710,6 +710,8 @@ private void SetParameterEntryText(ScriptActionEntry scriptActionEntry, ScriptAc
710710 return ;
711711 }
712712
713+ lbActions . SelectedItem . Text = GetActionEntryText ( scriptActionEntry . Action , scriptActionEntry ) ;
714+
713715 if ( action . ParamType == TriggerParamType . BuildingWithProperty )
714716 {
715717 tbParameterValue . Text = GetBuildingWithPropertyText ( scriptActionEntry . Argument ) ;
@@ -944,11 +946,72 @@ private void EditScript(Script script)
944946
945947 private string GetActionEntryText ( int index , ScriptActionEntry entry )
946948 {
949+ string actionEntryText ;
950+ string textDetails = null ;
951+
947952 ScriptAction action = GetScriptAction ( entry . Action ) ;
948953 if ( action == null )
949- return "#" + index + " - Unknown (" + entry . Argument . ToString ( CultureInfo . InvariantCulture ) + ")" ;
954+ {
955+ actionEntryText = $ "#{ index } - Unknown";
956+ textDetails = $ "({ entry . Argument . ToString ( CultureInfo . InvariantCulture ) } )";
957+ }
958+ else
959+ {
960+ actionEntryText = $ "#{ index } - { action . Name } ";
961+ int presetOptionIndex = action . PresetOptions . FindIndex ( presetOption => presetOption . Value == entry . Argument ) ;
962+ bool hasValidPresetOption = presetOptionIndex > - 1 ;
963+
964+ switch ( action . ParamType )
965+ {
966+ case TriggerParamType . BuildingWithProperty :
967+ var ( buildingTypeIndex , property ) = SplitBuildingWithProperty ( entry . Argument ) ;
968+ string propertyDescription = property . ToDescription ( ) ;
969+ BuildingType buildingType = map . Rules . BuildingTypes . GetElementIfInRange ( buildingTypeIndex ) ;
970+
971+ if ( buildingType != null )
972+ textDetails = $ "({ buildingType . Index } - { buildingType . GetEditorDisplayName ( ) } - { propertyDescription } )";
973+ break ;
974+
975+ case TriggerParamType . LocalVariable :
976+ var localVar = map . LocalVariables . GetElementIfInRange ( entry . Argument ) ;
977+ if ( localVar != null )
978+ textDetails = $ "({ localVar . Index } - { localVar . Name } )";
979+ break ;
980+
981+ case TriggerParamType . HouseType :
982+ var houseType = map . Houses . GetElementIfInRange ( entry . Argument ) ;
983+ if ( houseType != null )
984+ textDetails = $ "({ houseType . ID } - { houseType . ININame } )";
985+ break ;
986+
987+ case TriggerParamType . Animation :
988+ var animation = map . Rules . AnimTypes . GetElementIfInRange ( entry . Argument ) ;
989+ if ( animation != null )
990+ textDetails = $ "({ animation . Index } - { animation . ININame } )";
991+ break ;
992+
993+ case TriggerParamType . Unknown :
994+ // special handling: script actions that have no type but still have presets should be handled by showing the preset value
995+ // otherwise we'll show no text after the name of the action
996+ if ( hasValidPresetOption )
997+ goto default ;
998+
999+ textDetails = null ;
1000+ break ;
1001+
1002+ default :
1003+ if ( hasValidPresetOption )
1004+ textDetails = $ "({ presetOptionIndex } - { action . PresetOptions [ presetOptionIndex ] . Text } )";
1005+ else
1006+ textDetails = $ "({ entry . Argument . ToString ( CultureInfo . InvariantCulture ) } )";
1007+ break ;
1008+ }
1009+ }
1010+
1011+ if ( string . IsNullOrEmpty ( textDetails ) )
1012+ return actionEntryText ;
9501013
951- return "#" + index + " - " + action . Name + " (" + entry . Argument . ToString ( CultureInfo . InvariantCulture ) + ") ";
1014+ return $ " { actionEntryText } { textDetails } ";
9521015 }
9531016
9541017 private string GetActionNameFromIndex ( int index )
0 commit comments