Skip to content

Commit

Permalink
2.1 update: game 1.15 compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
algernon-A committed Sep 14, 2022
1 parent d97f469 commit 584fd33
Show file tree
Hide file tree
Showing 12 changed files with 240 additions and 59 deletions.
3 changes: 3 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Version 2.1 -

- Compatibility updates for game version 1.15
- Implement AlgernonCommons


Expand Down
183 changes: 146 additions & 37 deletions Code/GUI/BuildingDetailsPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,44 +294,153 @@ private FastList<object> GenerateFastList()
ItemClass.Service service = item.GetService();
ItemClass.SubService subService = item.GetSubService();

// Laid out this way for clear visibility.
if (subService == ItemClass.SubService.ResidentialLow && _filterBar.CategoryToggles[(int)BuildingPanelFilter.BuildingCategories.ResidentialLow].isChecked)
switch (service)
{
}
else if (subService == ItemClass.SubService.ResidentialHigh && _filterBar.CategoryToggles[(int)BuildingPanelFilter.BuildingCategories.ResidentialHigh].isChecked)
{
}
else if (subService == ItemClass.SubService.CommercialLow && _filterBar.CategoryToggles[(int)BuildingPanelFilter.BuildingCategories.CommercialLow].isChecked)
{
}
else if (subService == ItemClass.SubService.CommercialHigh && _filterBar.CategoryToggles[(int)BuildingPanelFilter.BuildingCategories.CommercialHigh].isChecked)
{
}
else if (service == ItemClass.Service.Office && _filterBar.CategoryToggles[(int)BuildingPanelFilter.BuildingCategories.Office].isChecked)
{
}
else if (service == ItemClass.Service.Industrial && _filterBar.CategoryToggles[(int)BuildingPanelFilter.BuildingCategories.Industrial].isChecked)
{
}
else if (subService == ItemClass.SubService.CommercialTourist && _filterBar.CategoryToggles[(int)BuildingPanelFilter.BuildingCategories.Tourism].isChecked)
{
}
else if (subService == ItemClass.SubService.CommercialLeisure && _filterBar.CategoryToggles[(int)BuildingPanelFilter.BuildingCategories.Leisure].isChecked)
{
}
else if (subService == ItemClass.SubService.CommercialEco && _filterBar.CategoryToggles[(int)BuildingPanelFilter.BuildingCategories.Organic].isChecked)
{
}
else if ((subService == ItemClass.SubService.ResidentialLowEco || subService == ItemClass.SubService.ResidentialHighEco) && _filterBar.CategoryToggles[(int)BuildingPanelFilter.BuildingCategories.Selfsufficient].isChecked)
{
}
else if (service == ItemClass.Service.Education && _filterBar.CategoryToggles[(int)BuildingPanelFilter.BuildingCategories.Education].isChecked && item.GetClassLevel() < ItemClass.Level.Level3)
{
}
else
{
// If we've gotten here, then we've matched no categories; move on to next item.
continue;
case ItemClass.Service.Residential:
switch (subService)
{
case ItemClass.SubService.ResidentialLow:
if (!_filterBar.CategoryToggles[(int)BuildingPanelFilter.BuildingCategories.ResidentialLow].isChecked)
{
continue;
}

break;

default:
case ItemClass.SubService.ResidentialHigh:
if (!_filterBar.CategoryToggles[(int)BuildingPanelFilter.BuildingCategories.ResidentialHigh].isChecked)
{
continue;
}

break;

case ItemClass.SubService.ResidentialWallToWall:
if (!_filterBar.CategoryToggles[(int)BuildingPanelFilter.BuildingCategories.ResidentialWallToWall].isChecked)
{
continue;
}

break;

case ItemClass.SubService.ResidentialLowEco:
case ItemClass.SubService.ResidentialHighEco:
if (!_filterBar.CategoryToggles[(int)BuildingPanelFilter.BuildingCategories.Selfsufficient].isChecked)
{
continue;
}

break;
}

break;

case ItemClass.Service.Commercial:
switch (subService)
{
case ItemClass.SubService.CommercialLow:
if (!_filterBar.CategoryToggles[(int)BuildingPanelFilter.BuildingCategories.CommercialLow].isChecked)
{
continue;
}

break;

default:
case ItemClass.SubService.CommercialHigh:
if (!_filterBar.CategoryToggles[(int)BuildingPanelFilter.BuildingCategories.CommercialHigh].isChecked)
{
continue;
}

break;

case ItemClass.SubService.CommercialWallToWall:
if (!_filterBar.CategoryToggles[(int)BuildingPanelFilter.BuildingCategories.CommercialWallToWall].isChecked)
{
continue;
}

break;

case ItemClass.SubService.CommercialTourist:
if (!_filterBar.CategoryToggles[(int)BuildingPanelFilter.BuildingCategories.Tourism].isChecked)
{
continue;
}

break;

case ItemClass.SubService.CommercialLeisure:
if (!_filterBar.CategoryToggles[(int)BuildingPanelFilter.BuildingCategories.Leisure].isChecked)
{
continue;
}

break;

case ItemClass.SubService.CommercialEco:
if (!_filterBar.CategoryToggles[(int)BuildingPanelFilter.BuildingCategories.Organic].isChecked)
{
continue;
}

break;
}

break;

case ItemClass.Service.Office:
switch (subService)
{
default:
case ItemClass.SubService.OfficeGeneric:
if (!_filterBar.CategoryToggles[(int)BuildingPanelFilter.BuildingCategories.OfficeGeneric].isChecked)
{
continue;
}

break;

case ItemClass.SubService.OfficeWallToWall:
if (!_filterBar.CategoryToggles[(int)BuildingPanelFilter.BuildingCategories.OfficeWallToWall].isChecked)
{
continue;
}

break;

case ItemClass.SubService.OfficeHightech:
if (!_filterBar.CategoryToggles[(int)BuildingPanelFilter.BuildingCategories.OfficeHighTech].isChecked)
{
continue;
}

break;
}

break;

case ItemClass.Service.Industrial:
if (!_filterBar.CategoryToggles[(int)BuildingPanelFilter.BuildingCategories.Industrial].isChecked)
{
continue;
}

break;

case ItemClass.Service.Education:
if (!(_filterBar.CategoryToggles[(int)BuildingPanelFilter.BuildingCategories.Education].isChecked && item.GetClassLevel() < ItemClass.Level.Level3))
{
continue;
}

break;

default:
// No service match - move on to next item.
continue;
}

// Filter by name.
Expand Down
50 changes: 45 additions & 5 deletions Code/GUI/BuildingPanelFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@ internal class BuildingPanelFilter : UIPanel
{
ItemClass.Service.Residential,
ItemClass.Service.Residential,
ItemClass.Service.Residential,
ItemClass.Service.Commercial,
ItemClass.Service.Commercial,
ItemClass.Service.Commercial,
ItemClass.Service.Office,
ItemClass.Service.Office,
ItemClass.Service.Office,
ItemClass.Service.Industrial,
ItemClass.Service.Commercial,
ItemClass.Service.Commercial,
Expand All @@ -50,9 +54,13 @@ internal class BuildingPanelFilter : UIPanel
{
ItemClass.SubService.ResidentialLow,
ItemClass.SubService.ResidentialHigh,
ItemClass.SubService.ResidentialWallToWall,
ItemClass.SubService.CommercialLow,
ItemClass.SubService.CommercialHigh,
ItemClass.SubService.None,
ItemClass.SubService.CommercialWallToWall,
ItemClass.SubService.OfficeGeneric,
ItemClass.SubService.OfficeWallToWall,
ItemClass.SubService.OfficeHightech,
ItemClass.SubService.None,
ItemClass.SubService.CommercialTourist,
ItemClass.SubService.CommercialLeisure,
Expand All @@ -74,6 +82,10 @@ internal class BuildingPanelFilter : UIPanel
"Thumbnails",
"Thumbnails",
"Thumbnails",
"Thumbnails",
"Thumbnails",
"Thumbnails",
"Thumbnails",
"Ingame",
};

Expand All @@ -82,9 +94,13 @@ internal class BuildingPanelFilter : UIPanel
{
"ZoningResidentialLow",
"ZoningResidentialHigh",
"DistrictSpecializationResidentialWallToWall",
"ZoningCommercialLow",
"ZoningCommercialHigh",
"DistrictSpecializationCommercialWallToWall",
"ZoningOffice",
"DistrictSpecializationOfficeWallToWall",
"DistrictSpecializationHightech",
"ZoningIndustrial",
"DistrictSpecializationTourist",
"DistrictSpecializationLeisure",
Expand All @@ -98,9 +114,13 @@ internal class BuildingPanelFilter : UIPanel
{
"RPR_CAT_RLO",
"RPR_CAT_RHI",
"RPR_CAT_RW2",
"RPR_CAT_CLO",
"RPR_CAT_CHI",
"RPR_CAT_CW2",
"RPR_CAT_OFF",
"RPR_CAT_OW2",
"RPR_CAT_ITC",
"RPR_CAT_IND",
"RPR_CAT_TOU",
"RPR_CAT_LEI",
Expand Down Expand Up @@ -135,7 +155,7 @@ internal BuildingPanelFilter()
// Catgegory buttons.
_categoryToggles = new UICheckBox[(int)BuildingCategories.NumCategories];

for (int i = 0; i < (int)BuildingCategories.NumCategories; i++)
for (int i = 0; i < (int)BuildingCategories.NumCategories; ++i)
{
// Basic setup.
_categoryToggles[i] = UICheckBoxes.AddIconToggle(this, 40 * i, 0f, _atlases[i], _spriteNames[i], _spriteNames[i] + "Disabled", tooltip: Translations.Translate(_tooltips[i]));
Expand Down Expand Up @@ -163,7 +183,7 @@ internal BuildingPanelFilter()
}

// 'All categories' button.
_allCategories = UIButtons.AddButton(this, 445f, 0f, Translations.Translate("RPR_CAT_ALL"), 200f);
_allCategories = UIButtons.AddButton(this, (40 * (int)BuildingCategories.NumCategories) + 10f, 0f, Translations.Translate("RPR_CAT_ALL"), 200f);

// All categories event handler.
_allCategories.eventClick += (c, p) =>
Expand Down Expand Up @@ -268,6 +288,11 @@ internal enum BuildingCategories
/// </summary>
ResidentialHigh,

/// <summary>
/// Wall-to-wall residential buildings.
/// </summary>
ResidentialWallToWall,

/// <summary>
/// Low-density commercial buildings.
/// </summary>
Expand All @@ -279,9 +304,24 @@ internal enum BuildingCategories
CommercialHigh,

/// <summary>
/// Office buildings.
/// Wall-to-wall commercial buildings.
/// </summary>
CommercialWallToWall,

/// <summary>
/// Generic office buildings.
/// </summary>
OfficeGeneric,

/// <summary>
/// Wall-to-wall office buildings.
/// </summary>
OfficeWallToWall,

/// <summary>
/// IT cluster (hightech office) buildings.
/// </summary>
Office,
OfficeHighTech,

/// <summary>
/// Industrial buildings.
Expand Down
6 changes: 6 additions & 0 deletions Code/Mod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

namespace RealPop2
{
using AlgernonCommons.Notifications;
using AlgernonCommons.Patching;
using AlgernonCommons.Translation;
using ICities;
Expand All @@ -29,6 +30,11 @@ public sealed class Mod : PatcherMod<OptionsPanel, Patcher>, IUserMod
/// </summary>
public string Description => Translations.Translate("RPR_DESC");

/// <summary>
/// Gets the mod's what's new message array.
/// </summary>
public override WhatsNewMessage[] WhatsNewMessages => new WhatsNewMessageListing().Messages;

/// <summary>
/// Called by the game when the mod is enabled.
/// </summary>
Expand Down
14 changes: 13 additions & 1 deletion Code/Serialization/RealPopSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
namespace RealPop2
{
using AlgernonCommons;
using AlgernonCommons.XML;
using ColossalFramework.IO;

/// <summary>
Expand All @@ -29,6 +30,9 @@ public void Serialize(DataSerializer serializer)
serializer.WriteUInt8((byte)ModSettings.ThisSaveDefaultCom);
serializer.WriteUInt8((byte)ModSettings.ThisSaveDefaultInd);
serializer.WriteUInt8((byte)ModSettings.ThisSaveDefaultOff);

// Write embedded config file.
// serializer.WriteByteArray(XMLFileUtils.SerializeBinary<XMLSettingsFile>());
}

/// <summary>
Expand All @@ -46,7 +50,7 @@ public void Deserialize(DataSerializer serializer)
Logging.Message("read data version ", dataVersion);

// Make sure we have a matching data version.
if (dataVersion == 7)
if (dataVersion >= 7)
{
// Replaces 'using legacy' bool flags.
ModSettings.ThisSaveDefaultRes = (DefaultMode)serializer.ReadUInt8();
Expand Down Expand Up @@ -113,6 +117,14 @@ public void Deserialize(DataSerializer serializer)
// Record that we've successfully deserialized savegame data.
ModSettings.IsRealPop2Save = true;
}

/*
if (dataVersion == 8)
{
// Read embedded config file.
XMLFileUtils.DeserializeBinary<XMLSettingsFile>(serializer.ReadByteArray());
}
*/
}
catch
{
Expand Down
Loading

0 comments on commit 584fd33

Please sign in to comment.