Skip to content

Commit

Permalink
Add BuildingName TriggerParamType
Browse files Browse the repository at this point in the history
Fixes #208
  • Loading branch information
Rampastring committed Nov 9, 2024
1 parent 47f7dd4 commit 13f8d14
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/TSMapEditor/Models/Enums/TriggerParamType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public enum TriggerParamType
TeamType,
Techno,
Building,
BuildingName,
BuildingWithProperty,
Aircraft,
Infantry,
Expand Down
18 changes: 17 additions & 1 deletion src/TSMapEditor/UI/Windows/TriggersWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,7 @@ private void BtnEventParameterValuePreset_LeftClick(object sender, EventArgs e)
paramValue = Conversions.IntFromString(triggerEvent.Parameters[paramIndex], -1);
BuildingType existingBuilding = paramValue < 0 || paramValue >= map.Rules.BuildingTypes.Count ? null : map.Rules.BuildingTypes[paramValue];
selectBuildingTypeWindow.IsForEvent = true;
selectBuildingTypeWindow.Tag = TriggerParamType.Building;
selectBuildingTypeWindow.Open(existingBuilding);
break;
case TriggerParamType.Techno:
Expand Down Expand Up @@ -1051,6 +1052,12 @@ private void BtnActionParameterValuePreset_LeftClick(object sender, EventArgs e)
: map.Rules.Sounds.Get(Conversions.IntFromString(triggerAction.Parameters[paramIndex], -1));
selectSoundWindow.Open(sound);
break;
case TriggerParamType.BuildingName:
selectBuildingTypeWindow.IsForEvent = false;
selectBuildingTypeWindow.Tag = TriggerParamType.BuildingName;
BuildingType buildingType = map.Rules.BuildingTypes.Find(bt => bt.ININame == triggerAction.Parameters[paramIndex]);
selectBuildingTypeWindow.Open(buildingType);
break;
default:
break;
}
Expand Down Expand Up @@ -1127,7 +1134,10 @@ private void BuildingTypeWindowDarkeningPanel_Hidden(object sender, EventArgs e)
if (selectBuildingTypeWindow.SelectedObject == null)
return;

AssignParamValue(selectBuildingTypeWindow.IsForEvent, selectBuildingTypeWindow.SelectedObject.Index);
if ((TriggerParamType)selectBuildingTypeWindow.Tag == TriggerParamType.BuildingName)
AssignParamValue(selectBuildingTypeWindow.IsForEvent, selectBuildingTypeWindow.SelectedObject.ININame);
else
AssignParamValue(selectBuildingTypeWindow.IsForEvent, selectBuildingTypeWindow.SelectedObject.Index);
}

private void ThemeDarkeningPanel_Hidden(object sender, EventArgs e)
Expand Down Expand Up @@ -2159,6 +2169,12 @@ private string GetParamValueText(string paramValue, TriggerParamType paramType,
return paramValue + " " + trigger.Name;
case TriggerParamType.Building:
return GetObjectValueText(RTTIType.Building, map.Rules.BuildingTypes, paramValue);
case TriggerParamType.BuildingName:
BuildingType buildingType = map.Rules.BuildingTypes.Find(bt => bt.ININame == paramValue);
if (buildingType == null)
return paramValue;

return paramValue + " (" + buildingType.GetEditorDisplayName() + ")";
case TriggerParamType.Aircraft:
return GetObjectValueText(RTTIType.Aircraft, map.Rules.AircraftTypes, paramValue);
case TriggerParamType.Infantry:
Expand Down

0 comments on commit 13f8d14

Please sign in to comment.