Update window titles on language change
This commit is contained in:
parent
c7b8e69732
commit
0bec8cf759
13
Pal.Client/ILanguageChanged.cs
Normal file
13
Pal.Client/ILanguageChanged.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Pal.Client
|
||||||
|
{
|
||||||
|
internal interface ILanguageChanged
|
||||||
|
{
|
||||||
|
void LanguageChanged();
|
||||||
|
}
|
||||||
|
}
|
@ -26,6 +26,7 @@ using System.Text.RegularExpressions;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Pal.Client.Extensions;
|
using Pal.Client.Extensions;
|
||||||
using Pal.Client.Properties;
|
using Pal.Client.Properties;
|
||||||
|
using ECommons;
|
||||||
|
|
||||||
namespace Pal.Client
|
namespace Pal.Client
|
||||||
{
|
{
|
||||||
@ -250,7 +251,10 @@ namespace Pal.Client
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void LanguageChanged(string langcode)
|
private void LanguageChanged(string langcode)
|
||||||
=> Localization.Culture = new CultureInfo(langcode);
|
{
|
||||||
|
Localization.Culture = new CultureInfo(langcode);
|
||||||
|
Service.WindowSystem?.Windows.OfType<ILanguageChanged>().Each(w => w.LanguageChanged());
|
||||||
|
}
|
||||||
|
|
||||||
private void OnFrameworkUpdate(Framework framework)
|
private void OnFrameworkUpdate(Framework framework)
|
||||||
{
|
{
|
||||||
|
@ -7,11 +7,12 @@ using Pal.Client.Properties;
|
|||||||
|
|
||||||
namespace Pal.Client.Windows
|
namespace Pal.Client.Windows
|
||||||
{
|
{
|
||||||
internal class AgreementWindow : Window
|
internal class AgreementWindow : Window, ILanguageChanged
|
||||||
{
|
{
|
||||||
|
private const string WindowId = "###PalPalaceAgreement";
|
||||||
private int _choice;
|
private int _choice;
|
||||||
|
|
||||||
public AgreementWindow() : base($"{Localization.Palace_Pal}###PalPalaceAgreement")
|
public AgreementWindow() : base(WindowId)
|
||||||
{
|
{
|
||||||
Flags = ImGuiWindowFlags.NoCollapse;
|
Flags = ImGuiWindowFlags.NoCollapse;
|
||||||
Size = new Vector2(500, 500);
|
Size = new Vector2(500, 500);
|
||||||
@ -26,6 +27,9 @@ namespace Pal.Client.Windows
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void LanguageChanged()
|
||||||
|
=> WindowName = $"{Localization.Palace_Pal}{WindowId}";
|
||||||
|
|
||||||
public override void OnOpen()
|
public override void OnOpen()
|
||||||
{
|
{
|
||||||
_choice = -1;
|
_choice = -1;
|
||||||
|
@ -24,6 +24,7 @@ namespace Pal.Client.Windows
|
|||||||
{
|
{
|
||||||
internal class ConfigWindow : Window
|
internal class ConfigWindow : Window
|
||||||
{
|
{
|
||||||
|
private const string WindowId = "###PalPalaceConfig";
|
||||||
private int _mode;
|
private int _mode;
|
||||||
private int _renderer;
|
private int _renderer;
|
||||||
private bool _showTraps;
|
private bool _showTraps;
|
||||||
@ -45,10 +46,10 @@ namespace Pal.Client.Windows
|
|||||||
private FileDialogManager _importDialog;
|
private FileDialogManager _importDialog;
|
||||||
private FileDialogManager _exportDialog;
|
private FileDialogManager _exportDialog;
|
||||||
|
|
||||||
public ConfigWindow() : base($"{Localization.Palace_Pal}###PalPalaceConfig")
|
public ConfigWindow() : base(WindowId)
|
||||||
{
|
{
|
||||||
var version = typeof(Plugin).Assembly.GetName().Version!.ToString(2);
|
LanguageChanged();
|
||||||
WindowName = $"{Localization.Palace_Pal} v{version}###PalPalaceConfig";
|
|
||||||
Size = new Vector2(500, 400);
|
Size = new Vector2(500, 400);
|
||||||
SizeCondition = ImGuiCond.FirstUseEver;
|
SizeCondition = ImGuiCond.FirstUseEver;
|
||||||
Position = new Vector2(300, 300);
|
Position = new Vector2(300, 300);
|
||||||
@ -58,6 +59,12 @@ namespace Pal.Client.Windows
|
|||||||
_exportDialog = new FileDialogManager { AddedWindowFlags = ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoDocking };
|
_exportDialog = new FileDialogManager { AddedWindowFlags = ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoDocking };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void LanguageChanged()
|
||||||
|
{
|
||||||
|
var version = typeof(Plugin).Assembly.GetName().Version!.ToString(2);
|
||||||
|
WindowName = $"{Localization.Palace_Pal} v{version}{WindowId}";
|
||||||
|
}
|
||||||
|
|
||||||
public override void OnOpen()
|
public override void OnOpen()
|
||||||
{
|
{
|
||||||
var config = Service.Configuration;
|
var config = Service.Configuration;
|
||||||
|
@ -14,12 +14,15 @@ using Pal.Client.Properties;
|
|||||||
|
|
||||||
namespace Pal.Client.Windows
|
namespace Pal.Client.Windows
|
||||||
{
|
{
|
||||||
internal class StatisticsWindow : Window
|
internal class StatisticsWindow : Window, ILanguageChanged
|
||||||
{
|
{
|
||||||
|
private const string WindowId = "###PalacePalStats";
|
||||||
private SortedDictionary<ETerritoryType, TerritoryStatistics> _territoryStatistics = new();
|
private SortedDictionary<ETerritoryType, TerritoryStatistics> _territoryStatistics = new();
|
||||||
|
|
||||||
public StatisticsWindow() : base($"{Localization.Palace_Pal} - {Localization.Statistics}###PalacePalStats")
|
public StatisticsWindow() : base(WindowId)
|
||||||
{
|
{
|
||||||
|
LanguageChanged();
|
||||||
|
|
||||||
Size = new Vector2(500, 500);
|
Size = new Vector2(500, 500);
|
||||||
SizeCondition = ImGuiCond.FirstUseEver;
|
SizeCondition = ImGuiCond.FirstUseEver;
|
||||||
Flags = ImGuiWindowFlags.AlwaysAutoResize;
|
Flags = ImGuiWindowFlags.AlwaysAutoResize;
|
||||||
@ -30,6 +33,9 @@ namespace Pal.Client.Windows
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void LanguageChanged()
|
||||||
|
=> WindowName = $"{Localization.Palace_Pal} - {Localization.Statistics}{WindowId}";
|
||||||
|
|
||||||
public override void Draw()
|
public override void Draw()
|
||||||
{
|
{
|
||||||
if (ImGui.BeginTabBar("Tabs"))
|
if (ImGui.BeginTabBar("Tabs"))
|
||||||
|
Loading…
Reference in New Issue
Block a user