public void HideAndSavePanel() { // save config here //DebugOutputPanel.AddMessage(ColossalFramework.Plugins.PluginManager.MessageType.Message, "Saving ChirpBanner config file."); MyConfig.Serialize("ChirpBannerConfig.xml", ChirpyBanner.CurrentConfig); this.isVisible = false; }
public void CheckTransparency(float c) { MyConfig.ConfigHolder.Config.BackgroundAlpha = c; MyConfig.SaveConfig(); if (ChirpyBanner.theBannerPanel != null) { ChirpyBanner.theBannerPanel.opacity = MyConfig.ConfigHolder.Config.BackgroundAlpha; } }
public static void Serialize(string filename, MyConfig config) { try { var serializer = new XmlSerializer(typeof(MyConfig)); using (var writer = new StreamWriter(filename)) { serializer.Serialize(writer, config); } } catch { } }
public void CheckHideChirper(bool c) { MyConfig.ConfigHolder.Config.DestroyBuiltinChirper = c; MyConfig.SaveConfig(); if (ChirpyBanner.theBannerPanel != null) { if (c) { ChirpyBanner.BuiltinChirper.ShowBuiltinChirper(false); } else { ChirpyBanner.BuiltinChirper.ShowBuiltinChirper(true); } } }
public void OnCreated(IChirper chirper) { // read config file for settings string configName = "ChirpBannerConfig.xml"; CurrentConfig = MyConfig.Deserialize(configName); if (CurrentConfig == null) { CurrentConfig = new MyConfig(); MyConfig.Serialize(configName, CurrentConfig); } // if old version, update with new else if (CurrentConfig.version == 0 || CurrentConfig.version < 4) // update this when we add any new settings { CurrentConfig.version = 4; MyConfig.Serialize(configName, CurrentConfig); } BuiltinChirper = chirper; if (CurrentConfig.DestroyBuiltinChirper) { chirper.ShowBuiltinChirper(false); } CreateBannerConfigUI(); CreateBannerUI(); if (mmb == null) { UIView uiv = UIView.GetAView(); if (uiv != null && uiv.gameObject != null) { mmb = uiv.gameObject.AddComponent <MyMonoB>(); mmb.transform.parent = uiv.transform; } } }
public static MyConfig Deserialize(string filename) { var serializer = new XmlSerializer(typeof(MyConfig)); try { using (var reader = new StreamReader(filename)) { MyConfig config = (MyConfig)serializer.Deserialize(reader); // sanity checks if (config.ScrollSpeed < 1) { config.ScrollSpeed = 1; } if (config.ScrollSpeed > 200) { config.ScrollSpeed = 200; } if (config.TextSize < 1 || config.TextSize > 100) { config.TextSize = 20; } if (config.BackgroundAlpha < 0.02f) { config.BackgroundAlpha = 0.02f; } else if (config.BackgroundAlpha > 0.98f) { config.BackgroundAlpha = 0.98f; } return(config); } } catch { } return(null); }
public void CheckChirpMsgColor(string c) { string fullc; // Check if we forgot the # if (!c.StartsWith("#")) { fullc = "#" + c; } else { fullc = c; } // Check length, if it doesn't validate, set it to default if (fullc.Length != 9) // ie: #001122FF { MyConfig.ConfigHolder.Config.MessageColor = "#FFFFFFFF"; } else { MyConfig.ConfigHolder.Config.MessageColor = fullc; } MyConfig.SaveConfig(); }
public void CheckColorChirper(bool c) { MyConfig.ConfigHolder.Config.ColorChirps = c; MyConfig.SaveConfig(); }