//////////////// private void ApplyDefaultFiltersAsync(UIState modBrowserUi) { CustomLoadHooks.AddHook(GetModTags.TagsReceivedHookValidator, (args) => { Timers.SetTimer("ModBrowserDefaultTagStates", 15, () => { bool isLoading; if (!ReflectionHelpers.Get(modBrowserUi, "loading", out isLoading)) { LogHelpers.Warn("ModBrowserTagsMenuContext - No 'loading'."); return(false); } if (isLoading) { return(true); } else { //UITagButton button = this.TagButtons["Misleading Info"]; //button.SetTagState( -1 ); return(false); } }); return(true); }); }
//////////////// /// <summary> /// Checks if the mod has new versions available from the mod browser, then updates it's overlay accordingly. /// </summary> public void CheckForNewVersionAsync() { CustomLoadHooks.AddHook(GetModInfo.ModInfoListLoadHookValidator, (args) => { if (args.Found && args.ModInfo.ContainsKey(this.Mod.Name)) { this.LatestAvailableVersion = args.ModInfo[this.Mod.Name].Version; } else { if (ModHelpersMod.Config.DebugModeNetInfo) { LogHelpers.Log("Error retrieving version number of '" + this.Mod.DisplayName + "'"); //+ "': " + reason ); } } return(false); }); /*Action<Version> onSuccess = delegate ( Version vers ) { * this.LatestAvailableVersion = vers; * }; * Action<string> onFail = delegate ( string reason ) { * if( ModHelpersMod.Instance.Config.DebugModeNetInfo ) { * LogHelpers.Log( "Error retrieving version number of '" + this.Mod.DisplayName + "': " + reason ); * } * }; * * GetModVersion.GetLatestKnownVersionAsync( this.Mod, onSuccess, onFail );*/ }
//////////////// internal void UpdateMode(bool isEditing) { if (!isEditing) { return; } CustomLoadHooks.AddHook(GetModInfo.BadModsListLoadHookValidator, (modInfoArgs) => { this.ApplyDefaultEditModeTags(modInfoArgs.ModInfo); return(false); }); }
//////////////// public void SetCurrentModAsync(string modName) { CustomLoadHooks.AddHook(GetModTags.TagsReceivedHookValidator, (args) => { if (!args.Found) { LogHelpers.Warn(); return(false); } this.SetCurrentMod(modName, args.Found, args.ModTags); return(false); }); }
/// <param name="theme">Visual appearance.</param> /// <param name="idx">ID number assigned to this element in its list.</param> /// <param name="mod">Mod represented by this element.</param> /// <param name="willDrawOwnHoverElements">Indicates if this element draws its own mouse-hover elements.</param> public UIModData(UITheme theme, int?idx, Mod mod, bool willDrawOwnHoverElements = true) : base(theme, true) { this.InitializeMe(idx, mod, willDrawOwnHoverElements); CustomLoadHooks.AddHook(GetModTags.TagsReceivedHookValidator, (args) => { ISet <string> modTags = args.ModTags?.GetOrDefault(mod.Name); this.ModTags = modTags ?? this.ModTags; return(false); }); this.RefreshTheme(); }
//////////////// private void FilterModsAsync(UIState _menuUi, IList <string> modNames, FilteredModsHandler callback) { CustomLoadHooks.AddHook(GetModTags.TagsReceivedHookValidator, (args) => { if (!args.Found) { this.SetInfoText("Could not acquire mod data."); callback(_menuUi, false, new List <string>(), 0, 0); return(false); } this.FilterMods(_menuUi, modNames, args.ModTags, callback); return(false); }); }
//////////////// public override void Show(UIState ui) { base.Show(ui); Timers.SetTimer("ModHelpersUpdatesLoaderPause", 5, () => { CustomLoadHooks.AddHook(GetModInfo.ModInfoListLoadHookValidator, (args) => { if (args != null) { this.DisplayModListVersions(ui, args.ModInfo); } return(false); }); return(false); }); }
private static void CacheAllModInfoAsync() { var mymod = ModHelpersMod.Instance; var modInfoArgs = new ModInfoListLoadHookArguments(); GetModInfo.RetrieveAllModInfoAsync((found, modInfo) => { modInfoArgs.ModInfo = modInfo; modInfoArgs.Found = found; Timers.SetTimer("CacheAllModInfoAsyncFailsafe", 2, () => { if (GetModInfo.ModInfoListLoadHookValidator == null) { return(true); } CustomLoadHooks.TriggerHook( GetModInfo.ModInfoListLoadHookValidator, GetModInfo.LoadHookValidatorKey, modInfoArgs ); return(false); }); }); CustomLoadHooks.AddHook(GetModInfo.ModInfoListLoadHookValidator, (modInfoArgs2) => { Thread.Sleep(2000); if (modInfoArgs2.Found) { GetModInfo.RetrieveBadModsAsync((found, badMods) => { if (found) { GetModInfo.RegisterBadMods(modInfoArgs2, badMods); } CustomLoadHooks.TriggerHook( GetModInfo.BadModsListLoadHookValidator, GetModInfo.LoadHookValidatorKey, modInfoArgs2 ); }); } return(true); }); }
public override void Load() { LoadHooks.AddWorldLoadEachHook(delegate { this.CurrentNetMode = Main.netMode; }); CustomLoadHooks.AddHook(ResetModeMod.WorldExitValidator, (_) => { this.CurrentNetMode = -1; return(true); }); this.Session.OnModLoad(); DataDumper.SetDumpSource("ResetMode", () => { return(ResetModeMod.Instance.Session.Data.ToString()); }); }
/// <summary> /// Reports whether a given mod (by the given internal name), once loaded, is "properly presented": Has a valid /// description, homepage, and any other needed checks (in future considerations). /// </summary> /// <param name="modName"></param> /// <param name="callback"></param> public static void IsListModProperlyPresented(string modName, Action <bool> callback) { CustomLoadHooks.AddHook(GetModInfo.ModInfoListLoadHookValidator, (args) => { if (args.Found && args.ModInfo.ContainsKey(modName)) { BasicModInfo modInfo = args.ModInfo[modName]; bool isProper = ModIdentityHelpers.IsProperlyPresented(modInfo); callback(isProper); } else { if (ModHelpersMod.Config.DebugModeNetInfo) { LogHelpers.Log("Error retrieving mod data for '" + modName + "'"); //+ "': " + reason ); } } return(false); }); }
//////////////// public override void SetDefaults() { int mytype = this.Type; this.DisplayName.SetDefault("Encumbered"); this.Description.SetDefault("You're weighted down" + '\n' + "More items = more burden"); Main.debuff[mytype] = true; if (!Main.dedServ && EncumberedDebuff.IconTex1 == null) { EncumberedDebuff.IconTex1 = EncumbranceMod.Instance.GetTexture("Buffs/EncumberedDebuff_1"); EncumberedDebuff.IconTex2 = EncumbranceMod.Instance.GetTexture("Buffs/EncumberedDebuff_2"); EncumberedDebuff.IconTex3 = EncumbranceMod.Instance.GetTexture("Buffs/EncumberedDebuff_3"); EncumberedDebuff.IconTex4 = EncumbranceMod.Instance.GetTexture("Buffs/EncumberedDebuff_4"); if (!EncumberedDebuff.HasSetPromise) { EncumberedDebuff.HasSetPromise = true; CustomLoadHooks.AddHook(EncumbrancePlayer.PlayerMovementPromiseValidator, (whoAmI) => { Player plr = Main.player[whoAmI]; if (plr != null && plr.active && plr.HasBuff(mytype)) { EncumberedDebuff.ApplyMovementHinderance(plr); } return(true); }); } LoadHooks.AddModUnloadHook(() => { EncumberedDebuff.IconTex1 = null; EncumberedDebuff.IconTex2 = null; EncumberedDebuff.IconTex3 = null; EncumberedDebuff.IconTex4 = null; }); } }