// constructor gets instantiated before any extensions are called public ModCorral() { try { ModCorralConfig.SetInstance(ModCorralConfig.Deserialize("ModCorralConfig.xml")); // determine if we are enabled or not if (PluginManager.instance == null || PluginManager.instance.GetPluginsInfo() == null) { Log.Message("ModCorral quitting, PluginManager.instance is null."); return; } // the very first thing we need to do is check if we're enabled. This constructor // is called even if we're marked as not to be loaded, so if not enabled, don't do anything PluginManager.PluginInfo myPluginInfo = null; foreach (PluginManager.PluginInfo info in PluginManager.instance.GetPluginsInfo()) { if (info.name == "ModCorral" || info.publishedFileID.AsUInt64 == 419090722) { myPluginInfo = info; break; } } if (myPluginInfo == null) { Log.Error("ModCorral PluginInfo not found, exiting."); return; } //// we need to be notified if our mod is enabled or disabled //PluginManager.instance.eventPluginsChanged += () => { this.EvaluateStatus(); }; //PluginManager.instance.eventPluginsStateChanged += () => { this.EvaluateStatus(); }; if (!myPluginInfo.isEnabled) { Log.Warning("ModCorral is disabled."); return; } Log.Message("ModCorral initializing."); // create our corral monobehaviour UIView uiv = UIView.GetAView(); if (uiv != null && uiv.gameObject != null) { CorralRegistration creg = CorralRegistration.instance; } } catch (Exception ex) { Log.Error("ModCorral() Exception: " + ex.Message); } }
public static void ClearNewCount() { if (mcButton != null && !string.IsNullOrEmpty(mcButton.text)) { mcButton.text = string.Empty; mcButton.tooltip = "Open Mod Corral"; // save ModCorralConfig.instance.LastNumberModButtons = CorralRegistration.RegisteredMods.Count; ModCorralConfig.Serialize("ModCorralConfig.xml", ModCorralConfig.instance); } }
public static void UpdateNewCount() { int count = CorralRegistration.RegisteredMods.Count; // total buttons now in list int lastcount = ModCorralConfig.instance.LastNumberModButtons; if ((count > lastcount) && mcButton != null) { // put red count in main button mcButton.text = string.Format("+{0}", count - lastcount); mcButton.textColor = Color.red; mcButton.hoveredTextColor = Color.red; mcButton.textScale = 0.85f; mcButton.textHorizontalAlignment = UIHorizontalAlignment.Right; mcButton.textVerticalAlignment = UIVerticalAlignment.Top; mcButton.tooltip = string.Format("Open Mod Corral ({0} new mods have registered)", count - lastcount); } else if (count < lastcount) { ModCorralConfig.instance.LastNumberModButtons = count; ModCorralConfig.Serialize("ModCorralConfig.xml", ModCorralConfig.instance); } }