diff --git a/ECommons b/ECommons index b0cd8607..756cf91c 160000 --- a/ECommons +++ b/ECommons @@ -1 +1 @@ -Subproject commit b0cd860713418d72d7229bb7e8a9a80d4973eef7 +Subproject commit 756cf91cb2424ad4e460d1cf42433d5f391fea58 diff --git a/Splatoon/Splatoon.csproj b/Splatoon/Splatoon.csproj index 51ad0d8b..af7d04ba 100644 --- a/Splatoon/Splatoon.csproj +++ b/Splatoon/Splatoon.csproj @@ -2,7 +2,7 @@ NightmareXIV - 3.7.0.9 + 3.7.1.1 diff --git a/Splatoon/SplatoonScripting/SplatoonScript.cs b/Splatoon/SplatoonScripting/SplatoonScript.cs index 47dc58c5..bc8fc30e 100644 --- a/Splatoon/SplatoonScripting/SplatoonScript.cs +++ b/Splatoon/SplatoonScripting/SplatoonScript.cs @@ -1,4 +1,5 @@ #nullable enable +using Dalamud.Game; using Dalamud.Interface.Colors; using ECommons; using ECommons.Hooks; @@ -203,6 +204,28 @@ public virtual void OnGainBuffEffect(uint sourceId, List gainBuffIds) { } /// Array of removed buff IDs. public virtual void OnRemoveBuffEffect(uint sourceId, List removeBuffIds) { } + /// + /// Returns appropriate string depending on current game language. If not defined for current language, will return first defined string. + /// + /// + /// + /// + /// + /// + /// + public string Loc(string? en = null, string? jp = null, string? de = null, string? fr = null, string? cn = null) + { + return Svc.Data.Language switch + { + ClientLanguage.English => en, + ClientLanguage.Japanese => jp, + ClientLanguage.German => de, + ClientLanguage.French => fr, + (ClientLanguage)4 => cn, + _ => null, + } ?? en ?? jp ?? de ?? fr ?? cn ?? ""; + } + internal void DrawRegisteredElements() { ImGuiEx.TextWrapped(ImGuiColors.DalamudRed, $"Non-restricted editing access. Any incorrectly performed changes may cause script to stop working completely. Use reset function if it happens. \n- In general, only edit color, thickness, text, size. \n- If script has it's own color settings, they will be prioritized.\n- Not all script will take whatever you edit here into account.".Loc()); diff --git a/SplatoonScripts/Tests/GenericTest7.cs b/SplatoonScripts/Tests/GenericTest7.cs new file mode 100644 index 00000000..cf38f6ea --- /dev/null +++ b/SplatoonScripts/Tests/GenericTest7.cs @@ -0,0 +1,33 @@ +using ECommons; +using ECommons.ImGuiMethods; +using ECommons.Reflection; +using ImGuiNET; +using Splatoon.SplatoonScripting; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SplatoonScriptsOfficial.Tests; +public class GenericTest7 : SplatoonScript +{ + public override HashSet? ValidTerritories { get; } + + public override void OnSettingsDraw() + { + if(ImGui.Button("Try add")) + { + try + { + DalamudReflector.AddRepo("https://127.0.0.1/", true); + } + catch(Exception ex) + { + ex.Log(); + } + } + ImGuiEx.Text(Loc(en: "Mechanic in English", jp: "Mechanic in Japanese")); + ImGuiEx.Text(Loc(jp: "Only JP text")); + } +}