Skip to content

Commit

Permalink
Localization and cleanup for global FM stats
Browse files Browse the repository at this point in the history
  • Loading branch information
FenPhoenix committed Sep 30, 2020
1 parent fd5c030 commit 35414db
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 11 deletions.
11 changes: 11 additions & 0 deletions AngelLoader/Common/DataClasses/LocalizationData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ internal sealed class LText_Class
internal readonly AlertMessages_Class AlertMessages = new AlertMessages_Class();
internal readonly MainMenu_Class MainMenu = new MainMenu_Class();
internal readonly GameVersionsWindow_Class GameVersionsWindow = new GameVersionsWindow_Class();
internal readonly GlobalFMStats_Class GlobalFMStats = new GlobalFMStats_Class();
internal readonly FMDeletion_Class FMDeletion = new FMDeletion_Class();
internal readonly Difficulties_Class Difficulties = new Difficulties_Class();
internal readonly FilterBar_Class FilterBar = new FilterBar_Class();
Expand Down Expand Up @@ -186,6 +187,7 @@ internal sealed class MainMenu_Class
{
internal readonly string MainMenuToolTip = "Main menu";
internal readonly string GameVersions = "Game versions...";
internal readonly string GlobalFMStats = "Global FM stats...";
}

internal sealed class GameVersionsWindow_Class
Expand Down Expand Up @@ -217,6 +219,15 @@ internal sealed class GameVersionsWindow_Class
internal readonly string Error_GameVersionNotFound = "Version not found";
}

internal sealed class GlobalFMStats_Class
{
internal readonly string TitleText = "Global FM stats";
internal readonly string FMsInDatabase = "FMs in database:";
internal readonly string AvailableFMs = "Available FMs:";
internal readonly string Unscanned = "Unscanned:";
internal readonly string Unsupported = "Invalid or unsupported:";
}

internal sealed class FMDeletion_Class
{
internal readonly string ArchiveNotFound = "This FM's archive could not be found. To delete this FM permanently, simply uninstall it.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ internal static class MainLLMenu

internal static ContextMenuStrip Menu = null!;
private static ToolStripMenuItem GameVersionsMenuItem = null!;
private static ToolStripMenuItem FMsListStatsMenuItem = null!;
private static ToolStripMenuItem GlobalFMStatsMenuItem = null!;

internal static void Construct(MainForm form, IContainer components)
{
Expand All @@ -20,11 +20,11 @@ internal static void Construct(MainForm form, IContainer components)
Menu.Items.AddRange(new ToolStripItem[]
{
GameVersionsMenuItem = new ToolStripMenuItem(),
FMsListStatsMenuItem = new ToolStripMenuItem()
GlobalFMStatsMenuItem = new ToolStripMenuItem()
});

GameVersionsMenuItem.Click += form.MainMenu_GameVersionsMenuItem_Click;
FMsListStatsMenuItem.Click += form.FMsListStatsMenuItem_Click;
GlobalFMStatsMenuItem.Click += form.GlobalFMStatsMenuItem_Click;

_constructed = true;

Expand All @@ -36,6 +36,7 @@ internal static void Localize()
if (!_constructed) return;

GameVersionsMenuItem.Text = LText.MainMenu.GameVersions;
GlobalFMStatsMenuItem.Text = LText.MainMenu.GlobalFMStats;
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,31 @@

namespace AngelLoader.Forms
{
public sealed partial class FMsListStatsForm : Form
public sealed partial class GlobalFMStatsForm : Form
{
public FMsListStatsForm()
public GlobalFMStatsForm()
{
InitializeComponent();

CalculateStats();

Localize();
}

private void Localize()
{
Text = LText.GlobalFMStats.TitleText;

FMsInDatabaseLabel.Text = LText.GlobalFMStats.FMsInDatabase;
AvailableFMsLabel.Text = LText.GlobalFMStats.AvailableFMs;
T1Label.Text = LText.Global.Thief1_Colon;
T2Label.Text = LText.Global.Thief2_Colon;
T3Label.Text = LText.Global.Thief3_Colon;
SS2Label.Text = LText.Global.SystemShock2_Colon;
UnscannedLabel.Text = LText.GlobalFMStats.Unscanned;
UnsupportedLabel.Text = LText.GlobalFMStats.Unsupported;

OKButton.Text = LText.Global.OK;
}

private void CalculateStats()
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions AngelLoader/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1534,9 +1534,9 @@ internal void MainMenu_GameVersionsMenuItem_Click(object sender, EventArgs e)
}

[SuppressMessage("ReSharper", "MemberCanBeMadeStatic.Global")]
internal void FMsListStatsMenuItem_Click(object sender, EventArgs e)
internal void GlobalFMStatsMenuItem_Click(object sender, EventArgs e)
{
using var f = new FMsListStatsForm();
using var f = new GlobalFMStatsForm();
f.ShowDialog();
}

Expand Down
28 changes: 28 additions & 0 deletions AngelLoader/Ini/LocalizationIni.Generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ internal static LText_Class ReadLocalizationIni(string file)
{
GameVersionsWindow_Dict.Add(f.Name, f);
}
var globalFMStatsFields = typeof(LText_Class.GlobalFMStats_Class).GetFields(_bfLText);
var GlobalFMStats_Dict = new Dictionary<string, FieldInfo>(globalFMStatsFields.Length);
foreach (var f in globalFMStatsFields)
{
GlobalFMStats_Dict.Add(f.Name, f);
}
var fMDeletionFields = typeof(LText_Class.FMDeletion_Class).GetFields(_bfLText);
var FMDeletion_Dict = new Dictionary<string, FieldInfo>(fMDeletionFields.Length);
foreach (var f in fMDeletionFields)
Expand Down Expand Up @@ -328,6 +334,28 @@ internal static LText_Class ReadLocalizationIni(string file)
i++;
}
}
else if (lineT == "[GlobalFMStats]")
{
while (i < linesLength - 1)
{
int ltLength;
string lt = lines[i + 1].TrimStart();
int eqIndex = lt.IndexOf('=');
if (eqIndex > -1)
{
string key = lt.Substring(0, eqIndex);
if (GlobalFMStats_Dict.TryGetValue(key, out FieldInfo value))
{
value.SetValue(ret.GlobalFMStats, lt.Substring(eqIndex + 1));
}
}
else if ((ltLength = lt.Length) > 0 && lt[0] == '[' && lt[ltLength - 1] == ']')
{
break;
}
i++;
}
}
else if (lineT == "[FMDeletion]")
{
while (i < linesLength - 1)
Expand Down
8 changes: 8 additions & 0 deletions AngelLoader/Languages/English.ini
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ Help_UnableToOpenHelpFile=Unable to open help file.
[MainMenu]
MainMenuToolTip=Main menu
GameVersions=Game versions...
GlobalFMStats=Global FM stats...
[GameVersionsWindow]
; This is where game versions are displayed.
Expand All @@ -145,6 +146,13 @@ Error_SneakyDllNotFound=Sneaky.dll not found
; A version could not be found inside the .exe/.dll file.
Error_GameVersionNotFound=Version not found
[GlobalFMStats]
TitleText=Global FM stats
FMsInDatabase=FMs in database:
AvailableFMs=Available FMs:
Unscanned=Unscanned:
Unsupported=Invalid or unsupported:
[FMDeletion]
ArchiveNotFound=This FM's archive could not be found. To delete this FM permanently, simply uninstall it.
AboutToDelete=The following FM archive is about to be deleted from disk:
Expand Down

0 comments on commit 35414db

Please sign in to comment.