Skip to content

Commit

Permalink
Add loc method
Browse files Browse the repository at this point in the history
  • Loading branch information
Limiana committed Sep 24, 2024
1 parent 83fbc0e commit e4bcf9b
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Splatoon/Splatoon.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Authors>NightmareXIV</Authors>
<Version>3.7.0.9</Version>
<Version>3.7.1.1</Version>
</PropertyGroup>

<PropertyGroup>
Expand Down
23 changes: 23 additions & 0 deletions Splatoon/SplatoonScripting/SplatoonScript.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#nullable enable
using Dalamud.Game;
using Dalamud.Interface.Colors;
using ECommons;
using ECommons.Hooks;
Expand Down Expand Up @@ -203,6 +204,28 @@ public virtual void OnGainBuffEffect(uint sourceId, List<uint> gainBuffIds) { }
/// <param name="removeBuffIds">Array of removed buff IDs.</param>
public virtual void OnRemoveBuffEffect(uint sourceId, List<uint> removeBuffIds) { }

/// <summary>
/// Returns appropriate string depending on current game language. If not defined for current language, will return first defined string.
/// </summary>
/// <param name="en"></param>
/// <param name="jp"></param>
/// <param name="de"></param>
/// <param name="fr"></param>
/// <param name="cn"></param>
/// <returns></returns>
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 ?? "<null>";
}

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());
Expand Down
33 changes: 33 additions & 0 deletions SplatoonScripts/Tests/GenericTest7.cs
Original file line number Diff line number Diff line change
@@ -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<uint>? 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"));
}
}

0 comments on commit e4bcf9b

Please sign in to comment.