using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using HtF.Shared; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("HtF.ConfigMenu")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+76aa5112a8a5b0c9897d3f3557b28a045762e8aa")] [assembly: AssemblyProduct("HtF.ConfigMenu")] [assembly: AssemblyTitle("HtF.ConfigMenu")] [assembly: AssemblyVersion("1.0.0.0")] namespace HtF.Shared { public enum Language { Auto, Chinese, English } public static class Loc { private sealed class Entry { internal string NameZh; internal string NameEn; internal string DescZh; internal string DescEn; } private const string OwnerGuid = "htf.configmenu"; private const string OwnerSection = "介面"; private const string OwnerKey = "語言"; private static readonly Dictionary Entries = new Dictionary(StringComparer.Ordinal); public static Func LocalChoice; private static ConfigEntryBase _remote; private static string _remoteChoice; private static float _nextRemoteRead; public static bool IsEnglish { get; private set; } public static ConfigEntry Bind(ConfigFile file, string section, string key, T defaultValue, string nameEn, string descZh, string descEn = null, AcceptableValueBase range = null) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown Add(key, null, nameEn, descZh, descEn); return file.Bind(section, key, defaultValue, new ConfigDescription(CfgDesc(key), range, Array.Empty())); } public static void Section(string section, string nameEn) { Add(section, null, nameEn, null, null); } public static void EnumValue(object value, string nameZh, string nameEn) { if (value != null) { Add("enum." + value, nameZh, nameEn, null, null); } } public static void Add(string key, string nameZh, string nameEn, string descZh, string descEn) { if (!string.IsNullOrEmpty(key)) { Entries[key] = new Entry { NameZh = nameZh, NameEn = nameEn, DescZh = descZh, DescEn = descEn }; } } public static string Term(string key, bool english, bool wantDesc) { if (key == null || !Entries.TryGetValue(key, out var value)) { return null; } if (wantDesc) { if (!english) { return value.DescZh; } return value.DescEn; } if (!english) { return value.NameZh; } return value.NameEn; } public static string CfgDesc(string key) { if (key == null || !Entries.TryGetValue(key, out var value) || value.DescZh == null) { return ""; } if (value.DescEn != null) { return value.DescZh + "\n" + value.DescEn; } return value.DescZh; } public static void Resolve() { string text = ((LocalChoice != null) ? LocalChoice() : RemoteChoice()); if (text == "English") { IsEnglish = true; } else if (text == "Chinese") { IsEnglish = false; } else { IsEnglish = !GameSpeaksChinese(); } } private static string RemoteChoice() { if (Time.unscaledTime < _nextRemoteRead) { return _remoteChoice; } _nextRemoteRead = Time.unscaledTime + 0.5f; try { if (_remote == null) { if (!Chainloader.PluginInfos.TryGetValue("htf.configmenu", out var value)) { return _remoteChoice = null; } if (value == null || (Object)(object)value.Instance == (Object)null || value.Instance.Config == null) { return _remoteChoice = null; } ConfigEntryBase[] configEntries = value.Instance.Config.GetConfigEntries(); foreach (ConfigEntryBase val in configEntries) { if (val.Definition.Section == "介面" && val.Definition.Key == "語言") { _remote = val; break; } } if (_remote == null) { return _remoteChoice = null; } } _remoteChoice = _remote.BoxedValue?.ToString(); } catch (Exception) { _remoteChoice = null; } return _remoteChoice; } private static bool GameSpeaksChinese() { try { int curLanguage = LocalizationManager.CurLanguage; return curLanguage == 2 || curLanguage == 3; } catch (Exception) { return false; } } public static string P(string zh, string en) { if (!IsEnglish) { return zh; } return en; } } } namespace HtF.ConfigMenu { internal static class L { internal const string SecUi = "介面"; internal const string SecButton = "選單按鈕"; internal const string KeyLanguage = "語言"; internal const string KeyToggle = "開關鍵"; internal const string KeyScale = "縮放"; internal const string KeyFont = "字型"; internal const string KeyRaw = "顯示原始值"; internal const string KeyPause = "暫停選單顯示按鈕"; internal const string KeyMenu = "主選單顯示按鈕"; internal const string KeyLabel = "按鈕文字"; internal const string KeySlot = "按鈕位置"; internal const string KeyDump = "診斷:印出按鈕分組"; internal static string WindowTitle => Loc.P("模組設定", "Mod Settings"); internal static string ButtonLabelDefault => Loc.P("模組設定", "Mod Settings"); internal static string Search => Loc.P("搜尋", "Search"); internal static string Rescan => Loc.P("重新掃描", "Rescan"); internal static string Close => Loc.P("關閉", "Close"); internal static string ResetAll => Loc.P("全部重設", "Reset All"); internal static string SaveFile => Loc.P("寫入檔案", "Save File"); internal static string NoPlugins => Loc.P("沒有找到任何有設定的插件", "No plugins with settings found"); internal static string NoMatches => Loc.P("沒有符合的設定", "No settings match the search"); internal static string NoneSelected => Loc.P("(無)", "(none)"); internal static string On => Loc.P("開", "On"); internal static string Off => Loc.P("關", "Off"); internal static string PressAKey => Loc.P("按下按鍵…", "Press a key…"); internal static void Register() { Loc.Section("介面", "Interface"); Loc.Section("選單按鈕", "Menu Button"); Loc.EnumValue(Language.Auto, "自動(跟隨遊戲)", "Auto (follow game)"); Loc.EnumValue(Language.Chinese, "中文", "Chinese"); Loc.EnumValue(Language.English, "英文", "English"); Loc.EnumValue(ButtonSlot.AboveLast, "最後一顆的上面", "Above the last button"); Loc.EnumValue(ButtonSlot.Bottom, "整欄最下面", "Bottom of the column"); Loc.EnumValue(ButtonSlot.Top, "整欄最上面", "Top of the column"); } } internal enum ButtonSlot { AboveLast, Bottom, Top } internal static class MenuButtons { private sealed class Column { internal Transform Parent; internal List