Skip to content

Commit

Permalink
Rename UseCountries to IsRA2YR
Browse files Browse the repository at this point in the history
  • Loading branch information
ZivDero committed May 7, 2024
1 parent 44e1d82 commit 08998fb
Show file tree
Hide file tree
Showing 23 changed files with 58 additions and 57 deletions.
5 changes: 3 additions & 2 deletions src/TSMapEditor/Config/Constants.ini
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ AdvancedFacingsHack=true
; Is NewTheater generic fallback (letter G) available?
NewTheaterGenericBuilding=false

; Should the editor read and use RA2/YR Countries rather than TS HouseTypes?
UseCountries=false
; Should the editor assume that it is used for RA2/YR, as opposed to TS?
; This includes, but is not limited to reading and using RA2/YR Countries rather than TS HouseTypes.
IsRA2YR=false

; Maximum allowed dimensions of generated map previews.
MapPreviewMaxWidth=400
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ Text=Free Radar
$X=getX(chkOfficial)
$Y=getBottom(chkFreeRadar) + VERTICAL_SPACING
Text=Enhanced Mode
$Enabled=1 - USE_COUNTRIES
$Enabled=1 - IS_RA2YR

; Apply button

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ $Y=getBottom(btnSingleplayer) + (VERTICAL_SPACING * 2)
$Width=100
$X=horizontalCenterOnParent()
Text=Multiplayer
$Enabled=1 - USE_COUNTRIES
$Enabled=1 - IS_RA2YR

[btnCoOp]
$Y=getBottom(btnMultiplayer) + (VERTICAL_SPACING * 2)
$Width=100
$X=horizontalCenterOnParent()
Text=Co-Op
$Enabled=1 - USE_COUNTRIES
$Enabled=1 - IS_RA2YR

[lblCountriesNotice]
$Y=getY(btnMultiplayer)
$X=EMPTY_SPACE_SIDES
Text=Yuri's Revenge does not benefit from houses in multiplayer.
$Enabled=USE_COUNTRIES
$Enabled=IS_RA2YR
[btnCancel]
$Y=getBottom(btnCoOp) + (VERTICAL_SPACING * 2)
Expand Down
12 changes: 6 additions & 6 deletions src/TSMapEditor/Config/UI/Windows/HousesWindow.ini
Original file line number Diff line number Diff line change
Expand Up @@ -141,25 +141,25 @@ Text=Side:
$X=getX(ddIQ)
$Width=getWidth(ddIQ)
$Y=getBottom(ddSide) + VERTICAL_SPACING
$Enabled=1 - USE_COUNTRIES ; enable only if we are not using Countries
$Enabled=1 - IS_RA2YR ; enable only if we are not using Countries
[lblActsLike]
$X=getX(lblIQ)
$Y=getY(ddActsLike) + 1
Text=Acts Like:
$Enabled=1 - USE_COUNTRIES ; enable only if we are not using Countries
$Enabled=1 - IS_RA2YR ; enable only if we are not using Countries
[ddCountry]
$X=getX(ddIQ)
$Width=getWidth(ddIQ)
$Y=getY(ddActsLike)
$Enabled=USE_COUNTRIES
$Enabled=IS_RA2YR
[lblCountry]
$X=getX(lblIQ)
$Y=getY(lblActsLike)
Text=Country:
$Enabled=USE_COUNTRIES
$Enabled=IS_RA2YR
[ddColor]
$X=getX(ddIQ)
Expand Down Expand Up @@ -240,12 +240,12 @@ $X=getX(lblSpecialActions)
$Width=getWidth(ddHouseOfHumanPlayer)
$Y=getBottom(lblSpecialActions) + VERTICAL_SPACING
Text=Edit HouseType
$Enabled=USE_COUNTRIES
$Enabled=IS_RA2YR
[btnMakeHouseRepairBuildings]
$X=getX(lblSpecialActions)
$Width=getWidth(ddHouseOfHumanPlayer)
$Y=VERTICAL_SPACING + ((USE_COUNTRIES * getBottom(btnEditHouseType)) + ((1 - USE_COUNTRIES) * getBottom(lblSpecialActions)))
$Y=VERTICAL_SPACING + ((IS_RA2YR * getBottom(btnEditHouseType)) + ((1 - IS_RA2YR) * getBottom(lblSpecialActions)))
Text=Enable Building Repair
[btnMakeHouseNotRepairBuildings]
Expand Down
4 changes: 2 additions & 2 deletions src/TSMapEditor/Config/UI/Windows/LightingSettingsWindow.ini
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ $CCn11=lblGreenDominator:XNALabel
$CCn12=tbBlueDominator:EditorNumberTextBox
$CCn13=lblBlueDominator:XNALabel
$Height=getBottom(tbGroundDominator) + EMPTY_SPACE_BOTTOM
$Enabled=USE_COUNTRIES
$Enabled=IS_RA2YR

[lblDominator]
$X=EMPTY_SPACE_SIDES
Expand Down Expand Up @@ -337,7 +337,7 @@ Text=Blue:

[lblLightingPreview]
$X=EMPTY_SPACE_SIDES
$Y=(getBottom(panelDominator) * USE_COUNTRIES) + (getBottom(panelIonStorm) * (1 - USE_COUNTRIES)) + EMPTY_SPACE_TOP + 1
$Y=(getBottom(panelDominator) * IS_RA2YR) + (getBottom(panelIonStorm) * (1 - IS_RA2YR)) + EMPTY_SPACE_TOP + 1
Text=Lighting Preview:

[ddLightingPreview]
Expand Down
10 changes: 5 additions & 5 deletions src/TSMapEditor/Config/UI/Windows/TeamTypesWindow.ini
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ Text=Tech Level:
$X=getX(tbName)
$Width=getWidth(tbName)
$Y=getBottom(tbTechLevel) + VERTICAL_SPACING
$Enabled=USE_COUNTRIES
$Enabled=IS_RA2YR
Option0=None
Option1=Add to Team
Option2=Send to Grinder
Expand All @@ -162,7 +162,7 @@ Option5=Do Nothing
$X=getX(lblName)
$Y=getY(ddMindControlDecision) + 1
Text=On Mind Control:
$Enabled=USE_COUNTRIES
$Enabled=IS_RA2YR

; *************
; Second column
Expand Down Expand Up @@ -243,20 +243,20 @@ Text=Tag:
$X=getX(tbGroup)
$Width=getWidth(tbGroup)
$Y=getY(tbTechLevel)
$Enabled=USE_COUNTRIES
$Enabled=IS_RA2YR

[lblTransportWaypoint]
$X=getX(lblGroup)
$Y=getY(lblTechLevel)
Text=Transport Wpt:
$Enabled=USE_COUNTRIES
$Enabled=IS_RA2YR

; **************
; Check boxes get generated dynamically on the area of panelBooleans
; **************

[panelBooleans]
$X=getX(lblSelectedTeamType)
$Y=(getBottom(ddMindControlDecision) * USE_COUNTRIES) + (getBottom(tbTechLevel) * (1 - USE_COUNTRIES)) + VERTICAL_SPACING
$Y=(getBottom(ddMindControlDecision) * IS_RA2YR) + (getBottom(tbTechLevel) * (1 - IS_RA2YR)) + VERTICAL_SPACING
$Width=getWidth(TeamTypesWindow) - getX(panelBooleans) - EMPTY_SPACE_SIDES
$Height=getHeight(TeamTypesWindow) - getY(panelBooleans) - EMPTY_SPACE_BOTTOM
4 changes: 2 additions & 2 deletions src/TSMapEditor/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static class Constants
public static bool VoxelsAffectedByLighting = false;
public static bool NewTheaterGenericBuilding = false;
public static bool DrawBuildingAnimationShadows = false;
public static bool UseCountries = false;
public static bool IsRA2YR = false;
public static bool WarnOfTooManyTriggerActions = true;
public static bool DefaultPreview = false;

Expand Down Expand Up @@ -126,7 +126,7 @@ public static void Init()
VoxelsAffectedByLighting = constantsIni.GetBooleanValue(ConstantsSectionName, nameof(VoxelsAffectedByLighting), VoxelsAffectedByLighting);
NewTheaterGenericBuilding = constantsIni.GetBooleanValue(ConstantsSectionName, nameof(NewTheaterGenericBuilding), NewTheaterGenericBuilding);
DrawBuildingAnimationShadows = constantsIni.GetBooleanValue(ConstantsSectionName, nameof(DrawBuildingAnimationShadows), DrawBuildingAnimationShadows);
UseCountries = constantsIni.GetBooleanValue(ConstantsSectionName, nameof(UseCountries), UseCountries);
IsRA2YR = constantsIni.GetBooleanValue(ConstantsSectionName, nameof(IsRA2YR), IsRA2YR);
WarnOfTooManyTriggerActions = constantsIni.GetBooleanValue(ConstantsSectionName, nameof(WarnOfTooManyTriggerActions), WarnOfTooManyTriggerActions);
DefaultPreview = constantsIni.GetBooleanValue(ConstantsSectionName, nameof(DefaultPreview), DefaultPreview);

Expand Down
10 changes: 5 additions & 5 deletions src/TSMapEditor/Initialization/MapLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1035,9 +1035,9 @@ public static void ReadAITriggerTypes(IMap map, IniFile mapIni)

public static void ReadHouseTypes(IMap map, IniFile mapIni)
{
Logger.Log("Reading HouseTypes. Using countries: " + Constants.UseCountries);
Logger.Log("Reading HouseTypes. Using countries: " + Constants.IsRA2YR);

var section = mapIni.GetSection(Constants.UseCountries ? "Countries" : "Houses");
var section = mapIni.GetSection(Constants.IsRA2YR ? "Countries" : "Houses");
if (section == null)
return;

Expand All @@ -1048,7 +1048,7 @@ public static void ReadHouseTypes(IMap map, IniFile mapIni)

// HouseTypes can't be redefined, check if the HouseType already exists.
// If it does and we are using countries, still read the HouseType's properties.
if (Constants.UseCountries)
if (Constants.IsRA2YR)
{
var existingHouseType = map.FindHouseType(kvp.Value);
if (existingHouseType != null)
Expand All @@ -1069,7 +1069,7 @@ public static void ReadHouseTypes(IMap map, IniFile mapIni)
}

var houseType = new HouseType(kvp.Value);
houseType.Index = id + (Constants.UseCountries ? map.Rules.RulesHouseTypes.Count : 0);
houseType.Index = id + (Constants.IsRA2YR ? map.Rules.RulesHouseTypes.Count : 0);
id++;

if (houseTypeSection != null)
Expand Down Expand Up @@ -1137,7 +1137,7 @@ public static void ReadHouses(IMap map, IniFile mapIni)
house.BaseNodes.Remove(bn);
});

if (Constants.UseCountries)
if (Constants.IsRA2YR)
{
if (house.Country != null)
houseType = map.FindHouseType(house.Country);
Expand Down
6 changes: 3 additions & 3 deletions src/TSMapEditor/Initialization/MapWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ public static void WriteHouseTypes(IMap map, IniFile mapIni)
{
var houseTypes = map.HouseTypes;

string sectionName = Constants.UseCountries ? "Countries" : "Houses";
string sectionName = Constants.IsRA2YR ? "Countries" : "Houses";
mapIni.RemoveSection(sectionName);

if (map.HouseTypes.Count == 0)
Expand All @@ -380,7 +380,7 @@ public static void WriteHouseTypes(IMap map, IniFile mapIni)
houseType.WriteToIniSection(houseTypeSection);
}

if (Constants.UseCountries)
if (Constants.IsRA2YR)
{
// Write Rules house types that have been modified in the map
for (int i = 0; i < map.Rules.RulesHouseTypes.Count; i++)
Expand Down Expand Up @@ -413,7 +413,7 @@ public static void WriteHouses(IMap map, IniFile mapIni)
housesSection.SetStringValue(house.ID > -1 ? house.ID.ToString() : i.ToString(), house.ININame);

// When countries are not in use, the section is already removed by WriteHouseTypes
if (Constants.UseCountries)
if (Constants.IsRA2YR)
{
// Only remove the section if no similarly-named modified HouseType exists - if one does,
// the section was possibly already removed by WriteHouseTypes
Expand Down
8 changes: 4 additions & 4 deletions src/TSMapEditor/Models/Map.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public MapTile GetTile(int x, int y)
public List<HouseType> HouseTypes { get; protected set; } = new List<HouseType>();
public List<HouseType> GetHouseTypes()
{
if (Constants.UseCountries)
if (Constants.IsRA2YR)
{
if (HouseTypes.Count > 0)
return Rules.RulesHouseTypes.Concat(HouseTypes).ToList();
Expand Down Expand Up @@ -842,7 +842,7 @@ public bool DeleteHouseType(HouseType houseType)
if (HouseTypes.Remove(houseType))
{
for (int i = 0; i < HouseTypes.Count; i++)
HouseTypes[i].Index = i + (Constants.UseCountries ? Rules.RulesHouseTypes.Count : 0);
HouseTypes[i].Index = i + (Constants.IsRA2YR ? Rules.RulesHouseTypes.Count : 0);

return true;
}
Expand Down Expand Up @@ -1602,7 +1602,7 @@ public House HouseFromHouseType(HouseType houseType)
var house = new House(houseType.ININame, houseType);
house.XNAColor = houseType.XNAColor;

if (!Constants.UseCountries)
if (!Constants.IsRA2YR)
house.ActsLike = houseType.Index;
else
house.Country = houseType.ININame;
Expand Down Expand Up @@ -1850,7 +1850,7 @@ public List<string> CheckForIssues()
48 // Destroyed by anything
};

if (!Constants.UseCountries)
if (!Constants.IsRA2YR)
objectSpecificEventIndexes.Add(55); // Limpet attached - Firestorm only, not in RA2/YR

foreach (var trigger in Triggers)
Expand Down
2 changes: 1 addition & 1 deletion src/TSMapEditor/Models/Rules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void InitFromINI(IniFile iniFile, IInitializer initializer, bool isMapIni

if (!isMapIni)
{
if (Constants.UseCountries)
if (Constants.IsRA2YR)
InitFromTypeSection(iniFile, "Countries", RulesHouseTypes);
else
InitFromTypeSection(iniFile, "Houses", RulesHouseTypes);
Expand Down
2 changes: 1 addition & 1 deletion src/TSMapEditor/Models/TeamType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public string GetHintText()

stringBuilder.Append("Waypoint: " + (string.IsNullOrWhiteSpace(Waypoint) ? Constants.NoneValue2 : Helpers.GetWaypointNumberFromAlphabeticalString(Waypoint)));

if (Constants.UseCountries)
if (Constants.IsRA2YR)
{
stringBuilder.Append("TransportWaypoint: " + (string.IsNullOrWhiteSpace(TransportWaypoint) ? Constants.NoneValue2 : Helpers.GetWaypointNumberFromAlphabeticalString(TransportWaypoint)));
}
Expand Down
2 changes: 1 addition & 1 deletion src/TSMapEditor/Rendering/ObjectRenderers/VxlRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ private static void RenderVoxel(Vector3 position, Color color, int vertexIndexCo

private static byte[] PreCalculateLighting(Vector3[] normalsTable, int normalsMode, float rotation)
{
Vector3 light = Constants.UseCountries ?
Vector3 light = Constants.IsRA2YR ?
Vector3.Transform(YRLight, Matrix.CreateRotationZ(rotation - MathHelper.ToRadians(45))) :
Vector3.Transform(TSLight, Matrix.CreateRotationZ(rotation - MathHelper.ToRadians(45)));

Expand Down
2 changes: 1 addition & 1 deletion src/TSMapEditor/UI/Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public Parser(WindowManager windowManager)
globalConstants.Add("HORIZONTAL_SPACING", Constants.UIHorizontalSpacing);
globalConstants.Add("VERTICAL_SPACING", Constants.UIVerticalSpacing);
globalConstants.Add("BUTTON_HEIGHT", Constants.UIButtonHeight);
globalConstants.Add("USE_COUNTRIES", Constants.UseCountries ? 1 : 0);
globalConstants.Add("IS_RA2YR", Constants.IsRA2YR ? 1 : 0);
globalConstants.Add("OBJECT_HEALTH_MAX", Constants.ObjectHealthMax);
globalConstants.Add("IS_FLAT_WORLD", Constants.IsFlatWorld ? 1 : 0);

Expand Down
2 changes: 1 addition & 1 deletion src/TSMapEditor/UI/TopBar/TopBarMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public override void Initialize()
viewContextMenu.AddItem(" ", null, () => false, null, null);
viewContextMenu.AddItem("No Lighting", () => mapView.EditorState.LightingPreviewState = LightingPreviewMode.NoLighting);
viewContextMenu.AddItem("Normal Lighting", () => mapView.EditorState.LightingPreviewState = LightingPreviewMode.Normal);
if (Constants.UseCountries)
if (Constants.IsRA2YR)
{
viewContextMenu.AddItem("Lightning Storm Lighting", () => mapView.EditorState.LightingPreviewState = LightingPreviewMode.IonStorm);
viewContextMenu.AddItem("Dominator Lighting", () => mapView.EditorState.LightingPreviewState = LightingPreviewMode.Dominator);
Expand Down
2 changes: 1 addition & 1 deletion src/TSMapEditor/UI/Windows/BasicSectionConfigWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private void BtnApply_LeftClick(object sender, System.EventArgs e)
map.Basic.IceGrowthEnabled = chkGrowingIce.Checked;
map.Basic.TiberiumDeathToVisceroid = chkTiberiumDeathToVisceroid.Checked;
map.Basic.FreeRadar = chkFreeRadar.Checked;
if (!Constants.UseCountries)
if (!Constants.IsRA2YR)
{
map.Basic.RequiredAddOn = chkRequiredAddOn.Checked ? 1 : 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/TSMapEditor/UI/Windows/EditHouseTypeWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public override void Initialize()
foreach (RulesColor rulesColor in map.Rules.Colors.OrderBy(c => c.Name))
ddColor.AddItem(rulesColor.Name, rulesColor.XNAColor);

if (Constants.UseCountries)
if (Constants.IsRA2YR)
{
foreach (var property in typeof(HouseType).GetProperties())
{
Expand Down
2 changes: 1 addition & 1 deletion src/TSMapEditor/UI/Windows/GenerateStandardHousesWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private void AddHousesFromEditorRulesSectionAndHide(string sectionName)
house.Allies = house.ININame;
house.TechLevel = 7;

if (!Constants.UseCountries)
if (!Constants.IsRA2YR)
{
var houseType = new HouseType(house.ININame);
houseType.Index = i;
Expand Down

0 comments on commit 08998fb

Please sign in to comment.