Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
 public void CheckTransparency(float c)
 {
     MyConfig.ConfigHolder.Config.BackgroundAlpha = c;
     MyConfig.SaveConfig();
     if (ChirpyBanner.theBannerPanel != null)
     {
         ChirpyBanner.theBannerPanel.opacity = MyConfig.ConfigHolder.Config.BackgroundAlpha;
     }
 }
Exemplo n.º 3
0
        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 { }
        }
Exemplo n.º 4
0
 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);
         }
     }
 }
Exemplo n.º 5
0
        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;
                }
            }
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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();
        }
Exemplo n.º 8
0
 public void CheckColorChirper(bool c)
 {
     MyConfig.ConfigHolder.Config.ColorChirps = c;
     MyConfig.SaveConfig();
 }