/// <summary> /// Loads the mod browser menu. /// </summary> public static void OpenModBrowserMenu() { Type interfaceType = ReflectionLibraries.GetMainAssembly() .GetType("Terraria.ModLoader.UI.Interface"); int modBrowserMenuMode; if (!ReflectionLibraries.Get(interfaceType, null, "modBrowserID", out modBrowserMenuMode)) { LogLibraries.Warn("Could not switch to mod browser menu context."); return; } Main.PlaySound(SoundID.MenuTick); Main.menuMode = modBrowserMenuMode; UIState modBrowserUi; if (!ReflectionLibraries.Get(interfaceType, null, "modBrowser", out modBrowserUi)) { LogLibraries.Warn("Could not acquire mod browser UI."); return; } Timers.SetTimer("ModLibsModDownloadPrompt", 5, true, () => { if (MenuContextService.GetCurrentMenuUI()?.GetType().Name != "UIModBrowser") { return(false); } bool isLoading; if (!ReflectionLibraries.Get(modBrowserUi, "loading", out isLoading)) { return(false); } if (isLoading) { return(true); } ModMenuLibraries.ApplyModBrowserFilter("", false, new List <string>()); return(false); }); }
/// <summary> /// Loads the mod browser menu with a given set of mods to one-click bulk download /// (via. `ModMenuLibaries.ApplyModBrowserFilter(...)`). /// </summary> /// <param name="packTitle">Name of the set.</param> /// <param name="modNames">Mod (internal) names of the set.</param> public static void OpenModBrowserWithDownloadList(string packTitle, List <string> modNames) { Type interfaceType = ReflectionLibraries.GetMainAssembly() .GetType("Terraria.ModLoader.UI.Interface"); int modBrowserMenuMode; if (!ReflectionLibraries.Get(interfaceType, null, "modBrowserID", out modBrowserMenuMode)) { LogLibraries.Warn("Could not switch to mod browser menu context."); return; } Main.PlaySound(SoundID.MenuTick); Main.menuMode = modBrowserMenuMode; UIState modBrowserUi; if (!ReflectionLibraries.Get(interfaceType, null, "modBrowser", out modBrowserUi)) { LogLibraries.Warn("Could not acquire mod browser UI."); return; } Timers.SetTimer("ModLibsModDownloadPrompt", 5, true, () => { if (MenuContextService.GetCurrentMenuUI()?.GetType().Name != "UIModBrowser") { return(false); } bool isLoading; if (!ReflectionLibraries.Get(modBrowserUi, "loading", out isLoading)) { return(false); } if (isLoading) { return(true); } ModMenuLibraries.ApplyModBrowserFilter(packTitle, true, modNames); return(false); }); /*Assembly tmlAsm = typeof( ModLoader ).Assembly; * Type interfaceType = tmlAsm.GetType( "Interface" ); * * Type uiModDlType = tmlAsm.GetType( "UIModDownloadItem" ); * object uiModDl = Activator.CreateInstance( uiModDlType, "ModName", "0.0.0", "hamstar", "", ModSide.Both, "", "http://javid.ddns.net/tModLoader/download.php?Down=mods/ModLibsUI.tmod", 0, 0, "", false, false, null ); * //UIModDownloadItem modItem = new UIModDownloadItem( displayname, name, version, author, modreferences, modside, modIconURL, download, downloads, hot, timeStamp, update, updateIsDowngrade, installed ); * items.Add( modItem ); * * Interface.downloadMods.SetDownloading( packTitle ); * Interface.downloadMods.SetModsToDownload( modFilter, items ); * Interface.modBrowser.updateNeeded = true; * * int menuMode; * if( !ReflectionLibaries.GetField<int>( interfaceType, null, "downloadModsID", out menuMode ) ) { * LogLibaries.Log( "Could not switch to downloads menu." ); * return; * } * Main.PlaySound( SoundID.MenuTick ); * Main.menuMode = menuMode;*/ }