Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/TSMapEditor/Config/Default/UI/Windows/HousesWindow.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/TSMapEditor/Models/House.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
1 change: 1 addition & 0 deletions src/TSMapEditor/Mutations/Classes/PlaceBuildingMutation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
16 changes: 12 additions & 4 deletions src/TSMapEditor/UI/Windows/HousesWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 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 = _ =>
{
map.Structures.FindAll(s => s.Owner == editedHouse).ForEach(b => b.AIRepairable = true);
editedHouse.DefaultRepairableStructures = true;
RefreshHouseInfo();
};
}
Expand All @@ -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 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 = _ =>
{
map.Structures.FindAll(s => s.Owner == editedHouse).ForEach(b => b.AIRepairable = false);
editedHouse.DefaultRepairableStructures = false;
RefreshHouseInfo();
};
}
Expand Down Expand Up @@ -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;

Expand Down
Loading