Merge pull request #11 from xPumaa/loc

ToS Localization
This commit is contained in:
rootdarkarchon
2022-07-24 00:45:11 +02:00
committed by GitHub
7 changed files with 294 additions and 35 deletions

View File

@@ -0,0 +1,68 @@
using CheapLoc;
namespace MareSynchronos.Localization
{
public static class Strings
{
public class ToSStrings
{
public readonly string LanguageLabel = Loc.Localize("LanguageLabel", "Language");
public readonly string AgreementLabel = Loc.Localize("AgreementLabel", "Agreement of Usage of Service");
public readonly string ReadLabel = Loc.Localize("ReadLabel", "READ THIS CAREFULLY");
public readonly string Paragraph1 = Loc.Localize("Paragraph1",
"All of the mod files currently active on your character as well as your current character state will be uploaded to the service you registered yourself at automatically. " +
"The plugin will exclusively upload the necessary mod files and not the whole mod.");
public readonly string Paragraph2 = Loc.Localize("Paragraph2",
"If you are on a data capped internet connection, higher fees due to data usage depending on the amount of downloaded and uploaded mod files might occur. " +
"Mod files will be compressed on up- and download to save on bandwidth usage. Due to varying up- and download speeds, changes in characters might not be visible immediately. " +
"Files present on the service that already represent your active mod files will not be uploaded again.");
public readonly string Paragraph3 = Loc.Localize("Paragraph3",
"The mod files you are uploading are confidential and will not be distributed to parties other than the ones who are requesting the exact same mod files. " +
"Please think about who you are going to pair since it is unavoidable that they will receive and locally cache the necessary mod files that you have currently in use. " +
"Locally cached mod files will have arbitrary file names to discourage attempts at replicating the original mod.");
public readonly string Paragraph4 = Loc.Localize("Paragraph4",
"The plugin creator tried their best to keep you secure. However, there is no guarantee for 100% security. Do not blindly pair your client with everyone.");
public readonly string Paragraph5 = Loc.Localize("Paragraph5",
"Mod files that are saved on the service will remain on the service as long as there are requests for the files from clients. " +
"After a period of not being used, the mod files will be automatically deleted. " +
"You will also be able to wipe all the files you have personally uploaded on request. " +
"The service holds no information about which mod files belong to which mod.");
public readonly string Paragraph6 = Loc.Localize("Paragraph6",
"This service is provided as-is. In case of abuse, contact darkarchon#4313 on Discord or join the Mare Synchronos Discord. " +
"To accept those conditions hold CTRL while clicking 'I agree'");
public readonly string AgreeLabel = Loc.Localize("AgreeLabel", "I agree");
public readonly string RemainingLabel = Loc.Localize("RemainingLabel", "remaining");
public readonly string FailedLabel = Loc.Localize("FailedLabel",
"Congratulations. You have failed to read the agreements.");
public readonly string TimeoutLabel = Loc.Localize("TimeoutLabel",
"I'm going to give you 1 minute to read the agreements carefully again. If you fail once more you will have to solve an annoying puzzle.");
public readonly string FailedAgainLabel = Loc.Localize("FailedAgainLabel",
"Congratulations. You have failed to read the agreements. Again.");
public readonly string PuzzleLabel = Loc.Localize("PuzzleLabel",
"I did warn you. Here's your annoying puzzle:");
public readonly string PuzzleDescLabel = Loc.Localize("PuzzleDescLabel",
"Enter the following 3 words from the agreement exactly as described without punctuation to make the \"I agree\" button visible again.");
public readonly string ParagraphLabel = Loc.Localize("ParagraphLabel", "Paragraph");
public readonly string SentenceLabel = Loc.Localize("SentenceLabel", "Sentence");
public readonly string WordLabel = Loc.Localize("WordLabel", "Word");
}
public static ToSStrings ToS { get; set; } = new();
}
}

View File

@@ -0,0 +1,78 @@
{
"LanguageLabel": {
"message": "Language",
"description": "ToSStrings..ctor"
},
"AgreementLabel": {
"message": "Agreement of Usage of Service",
"description": "ToSStrings..ctor"
},
"ReadLabel": {
"message": "READ THIS CAREFULLY",
"description": "ToSStrings..ctor"
},
"Paragraph1": {
"message": "All of the mod files currently active on your character as well as your current character state will be uploaded to the service you registered yourself at automatically. The plugin will exclusively upload the necessary mod files and not the whole mod.",
"description": "ToSStrings..ctor"
},
"Paragraph2": {
"message": "If you are on a data capped internet connection, higher fees due to data usage depending on the amount of downloaded and uploaded mod files might occur. Mod files will be compressed on up- and download to save on bandwidth usage. Due to varying up- and download speeds, changes in characters might not be visible immediately. Files present on the service that already represent your active mod files will not be uploaded again.",
"description": "ToSStrings..ctor"
},
"Paragraph3": {
"message": "The mod files you are uploading are confidential and will not be distributed to parties other than the ones who are requesting the exact same mod files. Please think about who you are going to pair since it is unavoidable that they will receive and locally cache the necessary mod files that you have currently in use. Locally cached mod files will have arbitrary file names to discourage attempts at replicating the original mod.",
"description": "ToSStrings..ctor"
},
"Paragraph4": {
"message": "The plugin creator tried their best to keep you secure. However, there is no guarantee for 100% security. Do not blindly pair your client with everyone.",
"description": "ToSStrings..ctor"
},
"Paragraph5": {
"message": "Mod files that are saved on the service will remain on the service as long as there are requests for the files from clients. After a period of not being used, the mod files will be automatically deleted. You will also be able to wipe all the files you have personally uploaded on request. The service holds no information about which mod files belong to which mod.",
"description": "ToSStrings..ctor"
},
"Paragraph6": {
"message": "This service is provided as-is. In case of abuse, contact darkarchon#4313 on Discord or join the Mare Synchronos Discord. To accept those conditions hold CTRL while clicking 'I agree'",
"description": "ToSStrings..ctor"
},
"AgreeLabel": {
"message": "I agree",
"description": "ToSStrings..ctor"
},
"RemainingLabel": {
"message": "remaining",
"description": "ToSStrings..ctor"
},
"FailedLabel": {
"message": "Congratulations. You have failed to read the agreements.",
"description": "ToSStrings..ctor"
},
"TimeoutLabel": {
"message": "I'm going to give you 1 minute to read the agreements carefully again. If you fail once more you will have to solve an annoying puzzle.",
"description": "ToSStrings..ctor"
},
"FailedAgainLabel": {
"message": "Congratulations. You have failed to read the agreements. Again.",
"description": "ToSStrings..ctor"
},
"PuzzleLabel": {
"message": "I did warn you. Here's your annoying puzzle:",
"description": "ToSStrings..ctor"
},
"PuzzleDescLabel": {
"message": "Enter the following 3 words from the agreement exactly as described without punctuation to make the \"I agree\" button visible again.",
"description": "ToSStrings..ctor"
},
"ParagraphLabel": {
"message": "Paragraph",
"description": "ToSStrings..ctor"
},
"SentenceLabel": {
"message": "Sentence",
"description": "ToSStrings..ctor"
},
"WordLabel": {
"message": "Word",
"description": "ToSStrings..ctor"
}
}

View File

@@ -0,0 +1,78 @@
{
"LanguageLabel": {
"message": "Language",
"description": "ToSStrings..ctor"
},
"AgreementLabel": {
"message": "Agreement of Usage of Service",
"description": "ToSStrings..ctor"
},
"ReadLabel": {
"message": "READ THIS CAREFULLY",
"description": "ToSStrings..ctor"
},
"Paragraph1": {
"message": "All of the mod files currently active on your character as well as your current character state will be uploaded to the service you registered yourself at automatically. The plugin will exclusively upload the necessary mod files and not the whole mod.",
"description": "ToSStrings..ctor"
},
"Paragraph2": {
"message": "If you are on a data capped internet connection, higher fees due to data usage depending on the amount of downloaded and uploaded mod files might occur. Mod files will be compressed on up- and download to save on bandwidth usage. Due to varying up- and download speeds, changes in characters might not be visible immediately. Files present on the service that already represent your active mod files will not be uploaded again.",
"description": "ToSStrings..ctor"
},
"Paragraph3": {
"message": "The mod files you are uploading are confidential and will not be distributed to parties other than the ones who are requesting the exact same mod files. Please think about who you are going to pair since it is unavoidable that they will receive and locally cache the necessary mod files that you have currently in use. Locally cached mod files will have arbitrary file names to discourage attempts at replicating the original mod.",
"description": "ToSStrings..ctor"
},
"Paragraph4": {
"message": "The plugin creator tried their best to keep you secure. However, there is no guarantee for 100% security. Do not blindly pair your client with everyone.",
"description": "ToSStrings..ctor"
},
"Paragraph5": {
"message": "Mod files that are saved on the service will remain on the service as long as there are requests for the files from clients. After a period of not being used, the mod files will be automatically deleted. You will also be able to wipe all the files you have personally uploaded on request. The service holds no information about which mod files belong to which mod.",
"description": "ToSStrings..ctor"
},
"Paragraph6": {
"message": "This service is provided as-is. In case of abuse, contact darkarchon#4313 on Discord or join the Mare Synchronos Discord. To accept those conditions hold CTRL while clicking 'I agree'",
"description": "ToSStrings..ctor"
},
"AgreeLabel": {
"message": "I agree",
"description": "ToSStrings..ctor"
},
"RemainingLabel": {
"message": "remaining",
"description": "ToSStrings..ctor"
},
"FailedLabel": {
"message": "Congratulations. You have failed to read the agreements.",
"description": "ToSStrings..ctor"
},
"TimeoutLabel": {
"message": "I'm going to give you 1 minute to read the agreements carefully again. If you fail once more you will have to solve an annoying puzzle.",
"description": "ToSStrings..ctor"
},
"FailedAgainLabel": {
"message": "Congratulations. You have failed to read the agreements. Again.",
"description": "ToSStrings..ctor"
},
"PuzzleLabel": {
"message": "I did warn you. Here's your annoying puzzle:",
"description": "ToSStrings..ctor"
},
"PuzzleDescLabel": {
"message": "Enter the following 3 words from the agreement exactly as described without punctuation to make the \"I agree\" button visible again.",
"description": "ToSStrings..ctor"
},
"ParagraphLabel": {
"message": "Paragraph",
"description": "ToSStrings..ctor"
},
"SentenceLabel": {
"message": "Sentence",
"description": "ToSStrings..ctor"
},
"WordLabel": {
"message": "Word",
"description": "ToSStrings..ctor"
}
}

View File

@@ -65,6 +65,10 @@
<HintPath>$(DalamudLibPath)Lumina.Excel.dll</HintPath> <HintPath>$(DalamudLibPath)Lumina.Excel.dll</HintPath>
<Private>false</Private> <Private>false</Private>
</Reference> </Reference>
<Reference Include="CheapLoc">
<HintPath>$(DalamudLibPath)CheapLoc.dll</HintPath>
<Private>false</Private>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@@ -74,6 +78,8 @@
<None Update="images\icon.png"> <None Update="images\icon.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<EmbeddedResource Include="Localization\de.json" />
<EmbeddedResource Include="Localization\fr.json" />
</ItemGroup> </ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent"> <Target Name="PostBuild" AfterTargets="PostBuildEvent">

View File

@@ -36,6 +36,7 @@ namespace MareSynchronos
private readonly FileDialogManager _fileDialogManager; private readonly FileDialogManager _fileDialogManager;
private readonly CompactUi _compactUi; private readonly CompactUi _compactUi;
private readonly UiShared _uiSharedComponent; private readonly UiShared _uiSharedComponent;
private readonly Dalamud.Localization _localization;
public Plugin(DalamudPluginInterface pluginInterface, CommandManager commandManager, public Plugin(DalamudPluginInterface pluginInterface, CommandManager commandManager,
@@ -48,6 +49,9 @@ namespace MareSynchronos
_configuration = PluginInterface.GetPluginConfig() as Configuration ?? new Configuration(); _configuration = PluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
_configuration.Initialize(PluginInterface); _configuration.Initialize(PluginInterface);
_configuration.Migrate(); _configuration.Migrate();
_localization = new Dalamud.Localization("MareSynchronos.Localization.", "", true);
_localization.SetupWithLangCode("en");
_windowSystem = new WindowSystem("MareSynchronos"); _windowSystem = new WindowSystem("MareSynchronos");
@@ -63,7 +67,7 @@ namespace MareSynchronos
_fileDialogManager = new FileDialogManager(); _fileDialogManager = new FileDialogManager();
_uiSharedComponent = _uiSharedComponent =
new UiShared(_ipcManager, _apiController, _fileCacheManager, _fileDialogManager, _configuration, _dalamudUtil, PluginInterface); new UiShared(_ipcManager, _apiController, _fileCacheManager, _fileDialogManager, _configuration, _dalamudUtil, PluginInterface, _localization);
_settingsUi = new SettingsUi(_windowSystem, _uiSharedComponent, _configuration, _apiController); _settingsUi = new SettingsUi(_windowSystem, _uiSharedComponent, _configuration, _apiController);
_compactUi = new CompactUi(_windowSystem, _uiSharedComponent, _configuration, _apiController); _compactUi = new CompactUi(_windowSystem, _uiSharedComponent, _configuration, _apiController);

View File

@@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Numerics; using System.Numerics;
@@ -8,6 +9,7 @@ using Dalamud.Interface.Windowing;
using ImGuiNET; using ImGuiNET;
using MareSynchronos.Managers; using MareSynchronos.Managers;
using MareSynchronos.Utils; using MareSynchronos.Utils;
using MareSynchronos.Localization;
namespace MareSynchronos.UI namespace MareSynchronos.UI
{ {
@@ -21,24 +23,7 @@ namespace MareSynchronos.UI
public event SwitchUi? SwitchToMainUi; public event SwitchUi? SwitchToMainUi;
private readonly string[] TosParagraphs = new[] private string[] TosParagraphs;
{
"All of the mod files currently active on your character as well as your current character state will be uploaded to the service you registered yourself at automatically. " +
"The plugin will exclusively upload the necessary mod files and not the whole mod.",
"If you are on a data capped internet connection, higher fees due to data usage depending on the amount of downloaded and uploaded mod files might occur. " +
"Mod files will be compressed on up- and download to save on bandwidth usage. Due to varying up- and download speeds, changes in characters might not be visible immediately. " +
"Files present on the service that already represent your active mod files will not be uploaded again.",
"The mod files you are uploading are confidential and will not be distributed to parties other than the ones who are requesting the exact same mod files. " +
"Please think about who you are going to pair since it is unavoidable that they will receive and locally cache the necessary mod files that you have currently in use. " +
"Locally cached mod files will have arbitrary file names to discourage attempts at replicating the original mod.",
"The plugin creator tried their best to keep you secure. However, there is no guarantee for 100% security. Do not blindly pair your client with everyone.",
"Mod files that are saved on the service will remain on the service as long as there are requests for the files from clients. " +
"After a period of not being used, the mod files will be automatically deleted. " +
"You will also be able to wipe all the files you have personally uploaded on request. " +
"The service holds no information about which mod files belong to which mod.",
"This service is provided as-is. In case of abuse, contact darkarchon#4313 on Discord or join the Mare Synchronos Discord. " +
"To accept those conditions hold CTRL while clicking 'I agree'"
};
private Tuple<string, string> _darkSoulsCaptcha1 = new(string.Empty, string.Empty); private Tuple<string, string> _darkSoulsCaptcha1 = new(string.Empty, string.Empty);
private Tuple<string, string> _darkSoulsCaptcha2 = new(string.Empty, string.Empty); private Tuple<string, string> _darkSoulsCaptcha2 = new(string.Empty, string.Empty);
@@ -51,6 +36,9 @@ namespace MareSynchronos.UI
private Task _timeoutTask; private Task _timeoutTask;
private string _timeoutTime; private string _timeoutTime;
private Dictionary<string, string> _languages = new() { { "English", "en" }, { "Deutsch", "de" }, { "Français", "fr" } };
private int _currentLanguage;
private bool DarkSoulsCaptchaValid => _darkSoulsCaptcha1.Item2 == _enteredDarkSoulsCaptcha1 private bool DarkSoulsCaptchaValid => _darkSoulsCaptcha1.Item2 == _enteredDarkSoulsCaptcha1
&& _darkSoulsCaptcha2.Item2 == _enteredDarkSoulsCaptcha2 && _darkSoulsCaptcha2.Item2 == _enteredDarkSoulsCaptcha2
&& _darkSoulsCaptcha3.Item2 == _enteredDarkSoulsCaptcha3; && _darkSoulsCaptcha3.Item2 == _enteredDarkSoulsCaptcha3;
@@ -78,10 +66,7 @@ namespace MareSynchronos.UI
MaximumSize = new Vector2(600, 2000) MaximumSize = new Vector2(600, 2000)
}; };
if (_pluginConfiguration.DarkSoulsAgreement) GetToSLocalization();
{
GenerateDarkSoulsAgreementCaptcha();
}
_windowSystem.AddWindow(this); _windowSystem.AddWindow(this);
} }
@@ -111,12 +96,28 @@ namespace MareSynchronos.UI
else if (!_pluginConfiguration.AcceptedAgreement && _readFirstPage) else if (!_pluginConfiguration.AcceptedAgreement && _readFirstPage)
{ {
if (_uiShared.UidFontBuilt) ImGui.PushFont(_uiShared.UidFont); if (_uiShared.UidFontBuilt) ImGui.PushFont(_uiShared.UidFont);
ImGui.TextUnformatted("Agreement of Usage of Service"); var textSize = ImGui.CalcTextSize(Strings.ToS.LanguageLabel);
ImGui.TextUnformatted(Strings.ToS.AgreementLabel);
if (_uiShared.UidFontBuilt) ImGui.PopFont(); if (_uiShared.UidFontBuilt) ImGui.PopFont();
ImGui.SameLine();
var languageSize = ImGui.CalcTextSize(Strings.ToS.LanguageLabel);
ImGui.SetCursorPosX(ImGui.GetWindowContentRegionMax().X - ImGui.GetWindowContentRegionMin().X - languageSize.X - 80);
ImGui.SetCursorPosY(ImGui.GetCursorPosY() + textSize.Y / 2 - languageSize.Y / 2);
ImGui.TextUnformatted(Strings.ToS.LanguageLabel);
ImGui.SameLine();
ImGui.SetCursorPosY(ImGui.GetCursorPosY() + textSize.Y / 2 - (languageSize.Y + ImGui.GetStyle().FramePadding.Y) / 2);
ImGui.SetNextItemWidth(80);
if (ImGui.Combo("", ref _currentLanguage, _languages.Keys.ToArray(), _languages.Count))
{
GetToSLocalization(_currentLanguage);
}
ImGui.Separator(); ImGui.Separator();
ImGui.SetWindowFontScale(1.5f); ImGui.SetWindowFontScale(1.5f);
string readThis = "READ THIS CAREFULLY"; string readThis = Strings.ToS.ReadLabel;
var textSize = ImGui.CalcTextSize(readThis); textSize = ImGui.CalcTextSize(readThis);
ImGui.SetCursorPosX(ImGui.GetWindowSize().X / 2 - textSize.X / 2); ImGui.SetCursorPosX(ImGui.GetWindowSize().X / 2 - textSize.X / 2);
UiShared.ColorText(readThis, ImGuiColors.DalamudRed); UiShared.ColorText(readThis, ImGuiColors.DalamudRed);
ImGui.SetWindowFontScale(1.0f); ImGui.SetWindowFontScale(1.0f);
@@ -133,7 +134,7 @@ namespace MareSynchronos.UI
ImGui.Separator(); ImGui.Separator();
if ((!_pluginConfiguration.DarkSoulsAgreement || DarkSoulsCaptchaValid) && (_timeoutTask?.IsCompleted ?? true)) if ((!_pluginConfiguration.DarkSoulsAgreement || DarkSoulsCaptchaValid) && (_timeoutTask?.IsCompleted ?? true))
{ {
if (ImGui.Button("I agree##toSetup")) if (ImGui.Button(Strings.ToS.AgreeLabel + "##toSetup"))
{ {
_enteredDarkSoulsCaptcha1 = string.Empty; _enteredDarkSoulsCaptcha1 = string.Empty;
_enteredDarkSoulsCaptcha2 = string.Empty; _enteredDarkSoulsCaptcha2 = string.Empty;
@@ -153,7 +154,7 @@ namespace MareSynchronos.UI
{ {
for (int i = 60; i > 0; i--) for (int i = 60; i > 0; i--)
{ {
_timeoutTime = $"{i}s remaining"; _timeoutTime = $"{i}s " + Strings.ToS.RemainingLabel;
Logger.Debug(_timeoutTime); Logger.Debug(_timeoutTime);
await Task.Delay(TimeSpan.FromSeconds(1)); await Task.Delay(TimeSpan.FromSeconds(1));
} }
@@ -172,15 +173,15 @@ namespace MareSynchronos.UI
{ {
if (_failedOnce && (!_timeoutTask?.IsCompleted ?? true)) if (_failedOnce && (!_timeoutTask?.IsCompleted ?? true))
{ {
UiShared.ColorTextWrapped("Congratulations. You have failed to read the agreements.", ImGuiColors.DalamudYellow); UiShared.ColorTextWrapped(Strings.ToS.FailedLabel, ImGuiColors.DalamudYellow);
UiShared.TextWrapped("I'm going to give you 1 minute to read the agreements carefully again. If you fail once more you will have to solve an annoying puzzle."); UiShared.TextWrapped(Strings.ToS.TimeoutLabel);
UiShared.TextWrapped(_timeoutTime); UiShared.TextWrapped(_timeoutTime);
} }
else else
{ {
UiShared.ColorTextWrapped("Congratulations. You have failed to read the agreements. Again.", ImGuiColors.DalamudYellow); UiShared.ColorTextWrapped(Strings.ToS.FailedAgainLabel, ImGuiColors.DalamudYellow);
UiShared.TextWrapped("I did warn you. Here's your annoying puzzle:"); UiShared.TextWrapped(Strings.ToS.PuzzleLabel);
UiShared.TextWrapped("Enter the following 3 words from the agreement exactly as described without punctuation to make the \"I agree\" button visible again."); UiShared.TextWrapped(Strings.ToS.PuzzleDescLabel);
ImGui.SetNextItemWidth(100); ImGui.SetNextItemWidth(100);
ImGui.InputText(_darkSoulsCaptcha1.Item1, ref _enteredDarkSoulsCaptcha1, 255); ImGui.InputText(_darkSoulsCaptcha1.Item1, ref _enteredDarkSoulsCaptcha1, 255);
ImGui.SetNextItemWidth(100); ImGui.SetNextItemWidth(100);
@@ -269,6 +270,21 @@ namespace MareSynchronos.UI
} }
} }
private void GetToSLocalization(int changeLanguageTo = -1)
{
if (changeLanguageTo != -1)
{
_uiShared.LoadLocalization(_languages.ElementAt(changeLanguageTo).Value);
}
TosParagraphs = new[] { Strings.ToS.Paragraph1, Strings.ToS.Paragraph2, Strings.ToS.Paragraph3, Strings.ToS.Paragraph4, Strings.ToS.Paragraph5, Strings.ToS.Paragraph6 };
if (_pluginConfiguration.DarkSoulsAgreement)
{
GenerateDarkSoulsAgreementCaptcha();
}
}
private void GenerateDarkSoulsAgreementCaptcha() private void GenerateDarkSoulsAgreementCaptcha()
{ {
_darkSoulsCaptcha1 = GetCaptchaTuple(); _darkSoulsCaptcha1 = GetCaptchaTuple();
@@ -284,7 +300,7 @@ namespace MareSynchronos.UI
var sentenceIdx = random.Next(splitParagraph.Length); var sentenceIdx = random.Next(splitParagraph.Length);
var splitSentence = splitParagraph[sentenceIdx].Split(" ").Select(c => c.Trim()).Select(c => c.Replace(".", "").Replace(",", "").Replace("'", "")).ToArray(); var splitSentence = splitParagraph[sentenceIdx].Split(" ").Select(c => c.Trim()).Select(c => c.Replace(".", "").Replace(",", "").Replace("'", "")).ToArray();
var wordIdx = random.Next(splitSentence.Length); var wordIdx = random.Next(splitSentence.Length);
return new($"Paragraph {paragraphIdx + 1}, Sentence {sentenceIdx + 1}, Word {wordIdx + 1}", splitSentence[wordIdx]); return new($"{Strings.ToS.ParagraphLabel} {paragraphIdx + 1}, {Strings.ToS.SentenceLabel} {sentenceIdx + 1}, {Strings.ToS.WordLabel} {wordIdx + 1}", splitSentence[wordIdx]);
} }
} }
} }

View File

@@ -11,6 +11,7 @@ using Dalamud.Interface.ImGuiFileDialog;
using Dalamud.Plugin; using Dalamud.Plugin;
using Dalamud.Utility; using Dalamud.Utility;
using ImGuiNET; using ImGuiNET;
using MareSynchronos.Localization;
using MareSynchronos.Managers; using MareSynchronos.Managers;
using MareSynchronos.Utils; using MareSynchronos.Utils;
using MareSynchronos.WebAPI; using MareSynchronos.WebAPI;
@@ -29,6 +30,7 @@ namespace MareSynchronos.UI
private readonly Configuration _pluginConfiguration; private readonly Configuration _pluginConfiguration;
private readonly DalamudUtil _dalamudUtil; private readonly DalamudUtil _dalamudUtil;
private readonly DalamudPluginInterface _pluginInterface; private readonly DalamudPluginInterface _pluginInterface;
private readonly Dalamud.Localization _localization;
public long FileCacheSize => _fileCacheManager.FileCacheSize; public long FileCacheSize => _fileCacheManager.FileCacheSize;
public bool ShowClientSecret = true; public bool ShowClientSecret = true;
public string PlayerName => _dalamudUtil.PlayerName; public string PlayerName => _dalamudUtil.PlayerName;
@@ -39,7 +41,7 @@ namespace MareSynchronos.UI
public static bool CtrlPressed() => (GetKeyState(0xA2) & 0x8000) != 0 || (GetKeyState(0xA3) & 0x8000) != 0; public static bool CtrlPressed() => (GetKeyState(0xA2) & 0x8000) != 0 || (GetKeyState(0xA3) & 0x8000) != 0;
public UiShared(IpcManager ipcManager, ApiController apiController, FileCacheManager fileCacheManager, FileDialogManager fileDialogManager, Configuration pluginConfiguration, DalamudUtil dalamudUtil, DalamudPluginInterface pluginInterface) public UiShared(IpcManager ipcManager, ApiController apiController, FileCacheManager fileCacheManager, FileDialogManager fileDialogManager, Configuration pluginConfiguration, DalamudUtil dalamudUtil, DalamudPluginInterface pluginInterface, Dalamud.Localization localization)
{ {
_ipcManager = ipcManager; _ipcManager = ipcManager;
_apiController = apiController; _apiController = apiController;
@@ -48,6 +50,7 @@ namespace MareSynchronos.UI
_pluginConfiguration = pluginConfiguration; _pluginConfiguration = pluginConfiguration;
_dalamudUtil = dalamudUtil; _dalamudUtil = dalamudUtil;
_pluginInterface = pluginInterface; _pluginInterface = pluginInterface;
_localization = localization;
_isDirectoryWritable = IsDirectoryWritable(_pluginConfiguration.CacheFolder); _isDirectoryWritable = IsDirectoryWritable(_pluginConfiguration.CacheFolder);
_pluginInterface.UiBuilder.BuildFonts += BuildFont; _pluginInterface.UiBuilder.BuildFonts += BuildFont;
@@ -204,6 +207,12 @@ namespace MareSynchronos.UI
public static Vector4 UploadColor((long, long) data) => data.Item1 == 0 ? ImGuiColors.DalamudGrey : public static Vector4 UploadColor((long, long) data) => data.Item1 == 0 ? ImGuiColors.DalamudGrey :
data.Item1 == data.Item2 ? ImGuiColors.ParsedGreen : ImGuiColors.DalamudYellow; data.Item1 == data.Item2 ? ImGuiColors.ParsedGreen : ImGuiColors.DalamudYellow;
public void LoadLocalization(string languageCode)
{
_localization.SetupWithLangCode(languageCode);
Strings.ToS = new Strings.ToSStrings();
}
public static uint Color(byte r, byte g, byte b, byte a) public static uint Color(byte r, byte g, byte b, byte a)
{ uint ret = a; ret <<= 8; ret += b; ret <<= 8; ret += g; ret <<= 8; ret += r; return ret; } { uint ret = a; ret <<= 8; ret += b; ret <<= 8; ret += g; ret <<= 8; ret += r; return ret; }