Skip to content

Commit

Permalink
Update translation framework.
Browse files Browse the repository at this point in the history
  • Loading branch information
algernon-A committed Jul 25, 2022
1 parent 4d51916 commit e27850f
Show file tree
Hide file tree
Showing 33 changed files with 1,037 additions and 922 deletions.
8 changes: 8 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@

- Ensure manual population changes always force eviction of households if required
- Don't force-update buildings on default changes
= Clear visitplace cache on global commercial changes
- Refactor per-floor population preview calcs
- Update translation framework


Version 2.0.4.2 -

- Fix initial calculation mode vanilla choice sometimes not ensuring vanilla maximum populations
Expand Down
2 changes: 1 addition & 1 deletion Code/GUI/UILegacyCalcs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ public void SelectionChanged(BuildingInfo building)
}

// Check to see if Ploppable RICO Revisited is controlling this building's population.
if (ModUtils.CheckRICOPopControl(building))
if (AssemblyUtils.CheckRICOPopControl(building))
{
messageLabel.text = Translations.Translate("RPR_CAL_RICO");
messageLabel.Show();
Expand Down
2 changes: 1 addition & 1 deletion Code/GUI/UITitleBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void Setup()
// Titlebar label.
titleLabel = AddUIComponent<UILabel>();
titleLabel.relativePosition = new Vector2(50, 13);
titleLabel.text = RealPopMod.ModName;
titleLabel.text = Mod.ModName;

// Close button.
closeButton = AddUIComponent<UIButton>();
Expand Down
2 changes: 1 addition & 1 deletion Code/GUI/UIVanillaCalcs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ internal void SelectionChanged(BuildingInfo building)
}

// Check to see if Ploppable RICO Revisited is controlling this building's population.
if (ModUtils.CheckRICOPopControl(building))
if (AssemblyUtils.CheckRICOPopControl(building))
{
messageLabel.text = Translations.Translate("RPR_CAL_RICO");
messageLabel.Show();
Expand Down
2 changes: 1 addition & 1 deletion Code/GUI/UIVolumetricPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ internal void CalculateVolumetric(BuildingInfo building, LevelData levelData, Fl
}

// Show override labels if population is being overriden (population message text will clobber any previous floor override message, which is by design).
if (ModUtils.CheckRICOPopControl(building))
if (AssemblyUtils.CheckRICOPopControl(building))
{
// Overridden by Ploppable RICO Revisited.
overridePopLabel.Show();
Expand Down
8 changes: 4 additions & 4 deletions Code/Loading.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public override void OnCreated(ILoading loading)
}

// Check for mod conflicts.
if (ModUtils.IsModConflict())
if (AssemblyUtils.IsModConflict())
{
// Conflict detected.
conflictingMod = true;
Expand All @@ -64,13 +64,13 @@ public override void OnCreated(ILoading loading)
if (!isModEnabled)
{
isModEnabled = true;
Logging.KeyMessage("version v", RealPopMod.Version, " loading");
Logging.KeyMessage("version v", Mod.Version, " loading");

// Perform legacy datastore setup.
XMLUtilsWG.Setup();

// Check for Ploppable RICO Revisited.
ModUtils.RICOReflection();
AssemblyUtils.RICOReflection();

// Initialise volumetric datastores.
EmploymentData.Setup();
Expand Down Expand Up @@ -118,7 +118,7 @@ public override void OnLevelLoaded(LoadMode mode)
modConflictBox.AddParas(Translations.Translate("ERR_CON0"), Translations.Translate("RPR_ERR_CON0"), Translations.Translate("RPR_ERR_FAT"), Translations.Translate("ERR_CON1"));

// Add conflicting mod name(s).
modConflictBox.AddList(ModUtils.conflictingModNames.ToArray());
modConflictBox.AddList(AssemblyUtils.conflictingModNames.ToArray());

// Closing para.
modConflictBox.AddParas(Translations.Translate("RPR_ERR_CON1"));
Expand Down
4 changes: 2 additions & 2 deletions Code/Logging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ internal static void LogException(Exception exception, params object[] messages)
// Use StringBuilder for efficiency since we're doing a lot of manipulation here.
// Start with mod name (to easily identify relevant messages), followed by colon to indicate start of actual message.
message.Length = 0;
message.Append(RealPopMod.ModName);
message.Append(Mod.ModName);
message.Append(": ");

// Add each message parameter.
Expand Down Expand Up @@ -94,7 +94,7 @@ private static void WriteMessage(string prefix, params object[] messages)
// Use StringBuilder for efficiency since we're doing a lot of manipulation here.
// Start with mod name (to easily identify relevant messages), followed by colon to indicate start of actual message.
message.Length = 0;
message.Append(RealPopMod.ModName);
message.Append(Mod.ModName);
message.Append(": ");

// Append prefix.
Expand Down
4 changes: 2 additions & 2 deletions Code/Mod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

namespace RealPop2
{
public class RealPopMod : IUserMod
public class Mod : IUserMod
{
// Public mod name and description.
public string Name => ModName + " " + Version;
public string Description => Translations.Translate("RPR_DESC");

// Internal and private name and version components.
internal static string ModName => "Realistic Population 2";
internal static string Version => "2.0.4.2";
internal static string Version => AssemblyUtils.CurrentVersion;


/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Code/Notifications/ListMessageBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class ListMessageBox : MessageBoxBase
public ListMessageBox()
{
// Set title.
Title = RealPopMod.ModName;
Title = Mod.ModName;

// Add buttons.
AddButtons();
Expand Down
2 changes: 1 addition & 1 deletion Code/Notifications/WhatsNew.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ internal static void ShowWhatsNew()
{
// Show messagebox.
WhatsNewMessageBox messageBox = MessageBoxBase.ShowModal<WhatsNewMessageBox>();
messageBox.Title = RealPopMod.ModName + " " + RealPopMod.Version;
messageBox.Title = Mod.ModName + " " + Mod.Version;
messageBox.DSAButton.eventClicked += (component, clickEvent) => DontShowAgain();
messageBox.SetMessages(whatsNewVersion, WhatsNewMessages);
}
Expand Down
2 changes: 1 addition & 1 deletion Code/Notifications/WhatsNewMessageBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public VersionMessage()
public void SetText(WhatsNewMessage message)
{
// Set version header and message text.
versionTitle = RealPopMod.ModName + " " + message.version.ToString(message.version.Build > 0 ? 3 : 2) + message.versionHeader;
versionTitle = Mod.ModName + " " + message.version.ToString(message.version.Build > 0 ? 3 : 2) + message.versionHeader;

// Add message elements as separate list items.
for (int i = 0; i < message.messages.Length; ++i)
Expand Down
2 changes: 1 addition & 1 deletion Code/Patches/Patcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ internal static void PatchABLC()
if (HarmonyHelper.IsHarmonyInstalled)
{
// Try to get ABLC method.
MethodInfo ablcCustomUpgraded = ModUtils.ABLCCustomUpgraded();
MethodInfo ablcCustomUpgraded = AssemblyUtils.ABLCCustomUpgraded();
if (ablcCustomUpgraded != null)
{
// Got method - apply patch.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ protected override void Apply(UIComponent control, UIMouseEventParameter mouseEv
PopData.instance.visitplaceCache.Clear();

// Clear RICO cache.
if (ModUtils.ricoClearAllWorkplaces != null)
if (AssemblyUtils.ricoClearAllWorkplaces != null)
{
ModUtils.ricoClearAllWorkplaces.Invoke(null, null);
AssemblyUtils.ricoClearAllWorkplaces.Invoke(null, null);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Code/Settings/ModSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,9 @@ private static void ClearWorkplaceCaches()
PopData.instance.visitplaceCache.Clear();

// Clear RICO cache too.
if (ModUtils.ricoClearAllWorkplaces != null)
if (AssemblyUtils.ricoClearAllWorkplaces != null)
{
ModUtils.ricoClearAllWorkplaces.Invoke(null, null);
AssemblyUtils.ricoClearAllWorkplaces.Invoke(null, null);
}
}
}
Expand Down
11 changes: 5 additions & 6 deletions Code/TranslationFramework/Language.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,17 @@ namespace RealPop2
/// </summary>
public class Language
{
// Translation file keywords - language code and readable name.
public static readonly string CodeKey = "CODE";
public static readonly string NameKey = "NAME";
// Translation file keywords - readable name.
public static readonly string NameKey = "LANGUAGE";


// Dictionary of translations for this language.
public Dictionary<string, string> translationDictionary = new Dictionary<string, string>();

// Language unique name.
public string uniqueName = null;
// Language code.
public string code = null;

// Language human-readable name.
// Language human-readable display name.
public string readableName = null;
}
}
Loading

0 comments on commit e27850f

Please sign in to comment.