summaryrefslogtreecommitdiff
path: root/Thronefall_1_57/Decompile/I2.Loc/TermData.cs
diff options
context:
space:
mode:
authorchai <215380520@qq.com>2024-05-19 16:05:58 +0800
committerchai <215380520@qq.com>2024-05-19 16:05:58 +0800
commit8e13e7e2874adc8982e16d1d2ed2e28d7480b45f (patch)
tree63ef85c460288891f5a593d69afeca16cba050b3 /Thronefall_1_57/Decompile/I2.Loc/TermData.cs
parentc5f145786f4c6d2fe4bea831dfc16e52228920a5 (diff)
+1.57
Diffstat (limited to 'Thronefall_1_57/Decompile/I2.Loc/TermData.cs')
-rw-r--r--Thronefall_1_57/Decompile/I2.Loc/TermData.cs123
1 files changed, 123 insertions, 0 deletions
diff --git a/Thronefall_1_57/Decompile/I2.Loc/TermData.cs b/Thronefall_1_57/Decompile/I2.Loc/TermData.cs
new file mode 100644
index 0000000..6827525
--- /dev/null
+++ b/Thronefall_1_57/Decompile/I2.Loc/TermData.cs
@@ -0,0 +1,123 @@
+using System;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace I2.Loc;
+
+[Serializable]
+public class TermData
+{
+ public string Term = string.Empty;
+
+ public eTermType TermType;
+
+ [NonSerialized]
+ public string Description;
+
+ public string[] Languages = Array.Empty<string>();
+
+ public byte[] Flags = Array.Empty<byte>();
+
+ [SerializeField]
+ private string[] Languages_Touch;
+
+ public string GetTranslation(int idx, string specialization = null, bool editMode = false)
+ {
+ string text = Languages[idx];
+ if (text != null)
+ {
+ text = SpecializationManager.GetSpecializedText(text, specialization);
+ if (!editMode)
+ {
+ text = text.Replace("[i2nt]", "").Replace("[/i2nt]", "");
+ }
+ }
+ return text;
+ }
+
+ public void SetTranslation(int idx, string translation, string specialization = null)
+ {
+ Languages[idx] = SpecializationManager.SetSpecializedText(Languages[idx], translation, specialization);
+ }
+
+ public void RemoveSpecialization(string specialization)
+ {
+ for (int i = 0; i < Languages.Length; i++)
+ {
+ RemoveSpecialization(i, specialization);
+ }
+ }
+
+ public void RemoveSpecialization(int idx, string specialization)
+ {
+ string text = Languages[idx];
+ if (!(specialization == "Any") && text.Contains("[i2s_" + specialization + "]"))
+ {
+ Dictionary<string, string> specializations = SpecializationManager.GetSpecializations(text);
+ specializations.Remove(specialization);
+ Languages[idx] = SpecializationManager.SetSpecializedText(specializations);
+ }
+ }
+
+ public bool IsAutoTranslated(int idx, bool IsTouch)
+ {
+ return (Flags[idx] & 2) > 0;
+ }
+
+ public void Validate()
+ {
+ int num = Mathf.Max(Languages.Length, Flags.Length);
+ if (Languages.Length != num)
+ {
+ Array.Resize(ref Languages, num);
+ }
+ if (Flags.Length != num)
+ {
+ Array.Resize(ref Flags, num);
+ }
+ if (Languages_Touch == null)
+ {
+ return;
+ }
+ for (int i = 0; i < Mathf.Min(Languages_Touch.Length, num); i++)
+ {
+ if (string.IsNullOrEmpty(Languages[i]) && !string.IsNullOrEmpty(Languages_Touch[i]))
+ {
+ Languages[i] = Languages_Touch[i];
+ Languages_Touch[i] = null;
+ }
+ }
+ Languages_Touch = null;
+ }
+
+ public bool IsTerm(string name, bool allowCategoryMistmatch)
+ {
+ if (!allowCategoryMistmatch)
+ {
+ return name == Term;
+ }
+ return name == LanguageSourceData.GetKeyFromFullTerm(Term);
+ }
+
+ public bool HasSpecializations()
+ {
+ for (int i = 0; i < Languages.Length; i++)
+ {
+ if (!string.IsNullOrEmpty(Languages[i]) && Languages[i].Contains("[i2s_"))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public List<string> GetAllSpecializations()
+ {
+ List<string> list = new List<string>();
+ for (int i = 0; i < Languages.Length; i++)
+ {
+ SpecializationManager.AppendSpecializations(Languages[i], list);
+ }
+ return list;
+ }
+}