//////////////// public static bool IsLoadedModProperlyPresented(string modName) { Mod mod = ModLoader.GetMod(modName); if (mod == null) { LogHelpers.Alert("Invalid mod " + modName); return(false); } IDictionary <string, Services.Tml.BuildPropertiesEditor> modInfos = ModListHelpers.GetLoadedModNamesWithBuildProps(); if (!modInfos.ContainsKey(modName)) { LogHelpers.Alert("Missing mod " + modName); return(false); } var modInfo = new BasicModInfoEntry(mod.DisplayName, modInfos[modName].Author.Split(',').SafeSelect(a => a.Trim()), mod.Version, modInfos[modName].Description, modInfos[modName].Homepage ); return(ModIdentityHelpers.IsProperlyPresented(modInfo)); }
//////////////// public void CheckVersion(string modName, BasicModInfoEntry modInfo, UIList modList, Version modVersion) { //LogHelpers.Log( "modInfo.Count:"+modInfo.Count+ ", name:"+name+", vers:"+vers); if (modInfo.Version == modVersion) { return; } UIPanel uiModItem = null; TmodFile tmod = null; foreach (UIElement modItem in modList._items) { object mod; ReflectionHelpers.Get(modItem, "mod", out mod); ReflectionHelpers.Get(mod, "modFile", out tmod); if (tmod.name == modName) { uiModItem = (UIPanel)modItem; break; } } if (uiModItem != null) { Version newModVersion = modInfo.Version; string msg = newModVersion.ToString() + " On Mod Browser"; //LogHelpers.Log( " name: "+name+", uiModItem: " + uiModItem.GetOuterDimensions().ToRectangle() ); var txt = new UIText(msg, 0.8f, true); txt.Top.Set(24f, 0f); txt.Left.Set(-184f, 0.5f); if (newModVersion > modVersion) { txt.TextColor = Color.Gold; } else { txt.SetText(msg, 0.6f, true); txt.TextColor = Color.Gray; } uiModItem.Append(txt); uiModItem.Recalculate(); uiModItem.Parent?.Recalculate(); uiModItem.Parent?.Parent?.Recalculate(); uiModItem.Parent?.Parent?.Parent?.Recalculate(); } }
public static void IsListModProperlyPresented(string modName, Action <bool> callback) { Promises.AddValidatedPromise <ModInfoListPromiseArguments>(GetModInfo.ModInfoListPromiseValidator, (args) => { if (args.Found && args.ModInfo.ContainsKey(modName)) { BasicModInfoEntry modInfo = args.ModInfo[modName]; bool isProper = ModIdentityHelpers.IsProperlyPresented(modInfo); callback(isProper); } else { if (ModHelpersMod.Instance.Config.DebugModeNetInfo) { LogHelpers.Log("Error retrieving mod data for '" + modName + "'"); //+ "': " + reason ); } } return(false); }); }
//// public static bool IsProperlyPresented(BasicModInfoEntry modInfo) { if (modInfo.Description != null && modInfo.Description.Length < 16) { return(false); } if (modInfo.Homepage.Length < 10) { return(false); } if (modInfo.Description.Contains("Learn how to mod with tModLoader by exploring the source code for this mod.")) { return(false); } if (modInfo.Description.Contains("Modify this file with a description of your mod.")) { return(false); } string homepage = modInfo.Homepage.ToLower(); //if( homepage.Contains( "discord.gg/" ) ) { return false; } // Go away, url shorteners foreach (string url in WebHelpers.UrlShorteners) { if (homepage.Contains("/" + url + "/")) { return(false); } if (homepage.Contains("." + url + "/")) { return(false); } } return(true); }