From 83a0363257bc9419f7fcb777f86973570f071e35 Mon Sep 17 00:00:00 2001 From: Shush Date: Fri, 26 Dec 2025 19:09:00 +0200 Subject: [PATCH 1/2] Add default repairable mechanism --- .../Config/Default/UI/Windows/HousesWindow.ini | 2 +- src/TSMapEditor/Models/House.cs | 1 + .../Mutations/Classes/PlaceBuildingMutation.cs | 1 + src/TSMapEditor/UI/Windows/HousesWindow.cs | 16 ++++++++++++---- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/TSMapEditor/Config/Default/UI/Windows/HousesWindow.ini b/src/TSMapEditor/Config/Default/UI/Windows/HousesWindow.ini index c1398a863..c895f7fdc 100644 --- a/src/TSMapEditor/Config/Default/UI/Windows/HousesWindow.ini +++ b/src/TSMapEditor/Config/Default/UI/Windows/HousesWindow.ini @@ -287,7 +287,7 @@ Text=Power; dynamically generated [lblStatsObjectsCount] $X=getX(lblStatsHeader) $Y=getBottom(lblStatsPower) + VERTICAL_SPACING -Text=Aircraft:@Infantry:@Vehicles:Buildings@AI repairable:@not AI repairable; dynamically generated +Text=Aircraft:@Infantry:@Vehicles:Buildings@AI Repairable by default:@AI repairable:@not AI repairable; dynamically generated [lblStatsAllianceMutualAlliance] $X=getX(lblStatsHeader) diff --git a/src/TSMapEditor/Models/House.cs b/src/TSMapEditor/Models/House.cs index 5f1610ca5..c803532e6 100644 --- a/src/TSMapEditor/Models/House.cs +++ b/src/TSMapEditor/Models/House.cs @@ -94,6 +94,7 @@ public House(string iniName, HouseType houseType) : this(iniName) public int TechLevel { get; set; } public int PercentBuilt { get; set; } public bool PlayerControl { get; set; } + public bool DefaultRepairableStructures { get; set; } = false; [INI(false)] public int ID { get; set; } diff --git a/src/TSMapEditor/Mutations/Classes/PlaceBuildingMutation.cs b/src/TSMapEditor/Mutations/Classes/PlaceBuildingMutation.cs index e70bf1297..de6662488 100644 --- a/src/TSMapEditor/Mutations/Classes/PlaceBuildingMutation.cs +++ b/src/TSMapEditor/Mutations/Classes/PlaceBuildingMutation.cs @@ -35,6 +35,7 @@ public override void Perform() var structure = new Structure(buildingType); structure.Owner = MutationTarget.ObjectOwner; structure.Position = cellCoords; + structure.AIRepairable = structure.Owner.DefaultRepairableStructures; MutationTarget.Map.PlaceBuilding(structure); MutationTarget.AddRefreshPoint(cellCoords); diff --git a/src/TSMapEditor/UI/Windows/HousesWindow.cs b/src/TSMapEditor/UI/Windows/HousesWindow.cs index 3ff2d6eb6..61f7d780e 100644 --- a/src/TSMapEditor/UI/Windows/HousesWindow.cs +++ b/src/TSMapEditor/UI/Windows/HousesWindow.cs @@ -309,12 +309,14 @@ private void BtnMakeHouseRepairBuildings_LeftClick(object sender, EventArgs e) var dialog = EditorMessageBox.Show(WindowManager, Translate(this, "EnableAIRepairs.Title", "Are you sure?"), - Translate(this, "EnableAIRepairs.Description", "This enables the \"AI Repairs\" flag on all buildings of the house, which makes the AI repair them." + Environment.NewLine + Environment.NewLine + + Translate(this, "EnableAIRepairs.Description", "This enables the \"AI Repairs\" flag on all buildings of the house, which makes the AI repair them." + Environment.NewLine + + "Additionally, this will cause the \"AI Repairs\" flag to be automatically enabled for all buildings you place for this house." + Environment.NewLine + Environment.NewLine + "No un-do is available. Do you wish to continue?"), MessageBoxButtons.YesNo); dialog.YesClickedAction = _ => { map.Structures.FindAll(s => s.Owner == editedHouse).ForEach(b => b.AIRepairable = true); + editedHouse.DefaultRepairableStructures = true; RefreshHouseInfo(); }; } @@ -332,12 +334,14 @@ private void BtnMakeHouseNotRepairBuildings_LeftClick(object sender, EventArgs e var dialog = EditorMessageBox.Show(WindowManager, Translate(this, "DisableAIRepairs.Title", "Are you sure?"), - Translate(this, "DisableAIRepairs.Description", "This disables the \"AI Repairs\" flag on all buildings of the house, which makes the AI NOT repair them." + Environment.NewLine + Environment.NewLine + + Translate(this, "DisableAIRepairs.Description", "This disables the \"AI Repairs\" flag on all buildings of the house, which makes the AI NOT repair them." + Environment.NewLine + + "Additionally, this will cause the \"AI Repairs\" flag to be automatically disabled for all buildings you place for this house." + Environment.NewLine + Environment.NewLine + "No un-do is available. Do you wish to continue?"), MessageBoxButtons.YesNo); dialog.YesClickedAction = _ => { map.Structures.FindAll(s => s.Owner == editedHouse).ForEach(b => b.AIRepairable = false); + editedHouse.DefaultRepairableStructures = false; RefreshHouseInfo(); }; } @@ -588,8 +592,12 @@ private void RefreshHouseStats() objectCountStats += Translate(this, "HouseStats.Infantry", "Infantry: ") + map.Infantry.Count(s => s.Owner == editedHouse) + Environment.NewLine; objectCountStats += Translate(this, "HouseStats.Vehicles", "Vehicles: ") + map.Units.Count(s => s.Owner == editedHouse) + Environment.NewLine; objectCountStats += Translate(this, "HouseStats.Buildings", "Buildings: ") + map.Structures.Count(s => s.Owner == editedHouse) + Environment.NewLine; - objectCountStats += Translate(this, "HouseStats.AIRepairable", " AI repairable: ") + map.Structures.Count(s => s.Owner == editedHouse && s.AIRepairable) + Environment.NewLine; - objectCountStats += Translate(this, "HouseStats.NotAIRepairable", " not AI repairable: ") + map.Structures.Count(s => s.Owner == editedHouse && !s.AIRepairable); + objectCountStats += Translate(this, "HouseStats.DefaultRepairable", " AI Repairable by default: ") + + (editedHouse.DefaultRepairableStructures ? + Translate(this, "HouseStats.DefaultRepairableYes", "Yes") : + Translate(this, "HouseStats.DefaultRepairableNo", "No")) + Environment.NewLine; + objectCountStats += Translate(this, "HouseStats.AIRepairable", " AI Repairable: ") + map.Structures.Count(s => s.Owner == editedHouse && s.AIRepairable) + Environment.NewLine; + objectCountStats += Translate(this, "HouseStats.NotAIRepairable", " not AI Repairable: ") + map.Structures.Count(s => s.Owner == editedHouse && !s.AIRepairable) + Environment.NewLine; lblStatsObjectsCount.Text = objectCountStats; From 68d0f94b5e77b8f3c5e00b694f422ad311d04423 Mon Sep 17 00:00:00 2001 From: Shush Date: Sat, 27 Dec 2025 08:21:13 +0200 Subject: [PATCH 2/2] Align AI Repairable flag name in text --- src/TSMapEditor/UI/Windows/HousesWindow.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/TSMapEditor/UI/Windows/HousesWindow.cs b/src/TSMapEditor/UI/Windows/HousesWindow.cs index 61f7d780e..252152c74 100644 --- a/src/TSMapEditor/UI/Windows/HousesWindow.cs +++ b/src/TSMapEditor/UI/Windows/HousesWindow.cs @@ -309,8 +309,8 @@ private void BtnMakeHouseRepairBuildings_LeftClick(object sender, EventArgs e) var dialog = EditorMessageBox.Show(WindowManager, Translate(this, "EnableAIRepairs.Title", "Are you sure?"), - Translate(this, "EnableAIRepairs.Description", "This enables the \"AI Repairs\" flag on all buildings of the house, which makes the AI repair them." + Environment.NewLine + - "Additionally, this will cause the \"AI Repairs\" flag to be automatically enabled for all buildings you place for this house." + Environment.NewLine + Environment.NewLine + + Translate(this, "EnableAIRepairs.Description", "This enables the \"AI Repairable\" flag on all buildings of the house, which makes the AI repair them." + Environment.NewLine + + "Additionally, this will cause the \"AI Repairable\" flag to be automatically enabled for all buildings you place for this house." + Environment.NewLine + Environment.NewLine + "No un-do is available. Do you wish to continue?"), MessageBoxButtons.YesNo); dialog.YesClickedAction = _ => @@ -334,8 +334,8 @@ private void BtnMakeHouseNotRepairBuildings_LeftClick(object sender, EventArgs e var dialog = EditorMessageBox.Show(WindowManager, Translate(this, "DisableAIRepairs.Title", "Are you sure?"), - Translate(this, "DisableAIRepairs.Description", "This disables the \"AI Repairs\" flag on all buildings of the house, which makes the AI NOT repair them." + Environment.NewLine + - "Additionally, this will cause the \"AI Repairs\" flag to be automatically disabled for all buildings you place for this house." + Environment.NewLine + Environment.NewLine + + Translate(this, "DisableAIRepairs.Description", "This disables the \"AI Repairable\" flag on all buildings of the house, which makes the AI NOT repair them." + Environment.NewLine + + "Additionally, this will cause the \"AI Repairable\" flag to be automatically disabled for all buildings you place for this house." + Environment.NewLine + Environment.NewLine + "No un-do is available. Do you wish to continue?"), MessageBoxButtons.YesNo); dialog.YesClickedAction = _ =>