public RefreshLanguageService()
        {
            _instance = this;
            items     = new List <WeakReference>();

            _harmony = HarmonyInstance.Create(nameof(RefreshLanguageService));
            _harmony.Patch(typeof(ModItem).GetConstructors()[0], null, NoroHelper.HarmonyMethod(() => OnModItemCtor(null)));
        }
Example #2
0
        public Localizer()
        {
            Instance        = this;
            LoadedLocalizer = new LoadedModWrapper("Terraria.ModLoader.Core.AssemblyManager".Type().ValueOf("loadedMods").Invoke("get_Item", "!Localizer"));
            this.SetField("<File>k__BackingField", LoadedLocalizer.File);
            this.SetField("<Code>k__BackingField", LoadedLocalizer.Code);
            Log = LogManager.GetLogger(nameof(Localizer));

            Harmony = HarmonyInstance.Create(nameof(Localizer));
            Harmony.Patch("Terraria.ModLoader.Core.AssemblyManager", "Instantiate",
                          prefix: NoroHelper.HarmonyMethod(() => AfterLocalizerCtorHook(null)));

            State    = OperationTiming.BeforeModCtor;
            TmodFile = Instance.ValueOf <TmodFile>("File");
            Init();
            _initiated = true;
        }
Example #3
0
        public static void Patch()
        {
            ReloadRequired = false;
            frameCounter   = 0;
            if (ModsExtraInfo == null)
            {
                ModsExtraInfo = new Dictionary <string, string>();
            }

            var refHolder = false;

            Localizer.Harmony.Patch("Terraria.ModLoader.Config.ConfigManager", "ModNeedsReload",
                                    postfix: NoroHelper.HarmonyMethod(() => ModNeedsReloadPostfix(ref refHolder)));

            Localizer.Harmony.Patch("Terraria.ModLoader.UI.UIModItem", "OnInitialize",
                                    postfix: NoroHelper.HarmonyMethod(() => UIModItemPostfix(null)));

            Localizer.Harmony.Patch("Terraria.ModLoader.UI.UIModItem", "DrawSelf",
                                    postfix: NoroHelper.HarmonyMethod(() => DrawSelfPostfix(null, null)));

            Localizer.Harmony.Patch("Terraria.ModLoader.UI.ModBrowser.UIModBrowser", "PopulateFromJson",
                                    prefix: NoroHelper.HarmonyMethod(() => PopulateFromJsonPrefix()),
                                    postfix: NoroHelper.HarmonyMethod(() => PopulateFromJsonPostfix()));
        }
Example #4
0
        public static void Patch()
        {
            Utils.LogInfo($"Patching ModBrowser, tML version: {ModLoader.version}");

            HarmonyInstance = HarmonyInstance.Create(nameof(Patches));

            if (LanguageManager.Instance.ActiveCulture == GameCulture.Chinese)
            {
                try
                {
                    #region Download Mod List
                    if (!string.IsNullOrEmpty(GetModListURL()))
                    {
                        HarmonyInstance.Patch("Terraria.ModLoader.UI.ModBrowser.UIModBrowser", "<PopulateModBrowser>",
                                              exactMatch: false,
                                              transpiler: NoroHelper.HarmonyMethod(() => PopulateModBrowserTranspiler(null)));
                        Utils.LogInfo("PopulateModBrowser Patched");
                    }
                    #endregion

                    #region Get Mod Download URL
                    if (!string.IsNullOrEmpty(GetModDownloadURL()))
                    {
                        HarmonyInstance.Patch("Terraria.ModLoader.UI.ModBrowser.UIModDownloadItem", "FromJson",
                                              transpiler: NoroHelper.HarmonyMethod(() => FromJSONTranspiler(null)));
                        Utils.LogInfo("FromJson Patched");

                        if (!string.IsNullOrEmpty(GetModDescURL()))
                        {
                            HarmonyInstance.Patch("Terraria.ModLoader.UI.UIModInfo", "<OnActivate>",
                                                  exactMatch: false,
                                                  transpiler: NoroHelper.HarmonyMethod(() => OnActivateTranspiler(null)));
                            Utils.LogInfo("OnActivate Patched");
                        }
                    }
                    #endregion

                    #region List My Mods
                    // Terraria.ModLoader.UI.UIManagePublished.OnActivate
                    // "http://javid.ddns.net/tModLoader/listmymods.php"
                    #endregion

                    #region Publish Mod
                    // Terraria.ModLoader.UI.UIModSourceItem.PublishMod
                    // "http://javid.ddns.net/tModLoader/publishmod.php"
                    #endregion

                    #region Unpublish Mod
                    // Terraria.ModLoader.UI.UIModManageItem.UnpublishMod
                    // "http://javid.ddns.net/tModLoader/unpublishmymod.php"
                    #endregion

                    #region Register Link
                    // Terraria.ModLoader.UI.UIEnterPassphraseMenu.VisitRegisterWebpage
                    // Terraria.ModLoader.UI.UIEnterSteamIDMenu.VisitRegisterWebpage
                    // "http://javid.ddns.net/tModLoader/register.php"
                    #endregion

                    #region Direct Mod Listing
                    // Terraria.ModLoader.UI.ModBrowser.UIModBrowser.<>c.<ShowOfflineTroubleshootingMessage>
                    // "http://javid.ddns.net/tModLoader/DirectModDownloadListing.php"
                    HarmonyInstance.Patch("Terraria.ModLoader.UI.ModBrowser.UIModBrowser.<>c", "<ShowOfflineTroubleshootingMessage>",
                                          exactMatch: false,
                                          transpiler: NoroHelper.HarmonyMethod(() => DirectModListingTranspiler(null)));
                    Utils.LogInfo("DirectModListing Patched");
                    #endregion

                    #region Query Mod Download URL
                    // Terraria.ModLoader.Interface.ServerModBrowserMenu
                    // "http://javid.ddns.net/tModLoader/tools/querymoddownloadurl.php?modname="
                    #endregion

                    #region Error Report
                    // No plan
                    #endregion

                    #region ModCompile
                    HarmonyInstance.Patch("Terraria.ModLoader.UI.UIDeveloperModeHelp", "DownloadModCompile",
                                          transpiler: NoroHelper.HarmonyMethod(() => ModCompileTranspiler(null)));
                    Utils.LogInfo("DownloadModCompile Patched");
                    #endregion

                    #region Mod Update
                    HarmonyInstance.Patch("Terraria.ModLoader.UI.DownloadManager.DownloadModFile", "PreCopy",
                                          prefix: NoroHelper.HarmonyMethod(() => PreCopyPrefix(null)));
                    Utils.LogInfo("PreCopy Patched");
                    #endregion

                    Utils.LogInfo("ModBrowser Patched");
                }
                catch (Exception e)
                {
                    Utils.LogInfo($"ModBrowser Patch exception: {e}");
                }
            }

            try
            {
                HarmonyInstance.Patch("Terraria.ModLoader.UI.DownloadManager.DownloadFile", "SetupDownloadRequest",
                                      postfix: NoroHelper.HarmonyMethod(() => PostSetupDownloadRequest(null)));
                Utils.LogInfo("SetupDownloadRequest Patched");
            }
            catch (Exception e)
            {
                Utils.LogInfo($"ModBrowser Patch exception: {e}");
            }
        }