public ToolStripSkinColorTable(SystemContext InSystem)
 {
     CurrentSystem = InSystem;
 }
Example #2
0
        public void LoadFromDisk(SystemContext InSystemContext)
        {
            var fs = InSystemContext.GetFilesystem();

            if (!fs.DirectoryExists("/Shiftum42/Skins/Loaded") || !fs.FileExists("/Shiftum42/Skins/Loaded/data.dat"))
            {
                fs.CreateDirectory("/Shiftum42/Skins/Loaded");

                _skin       = new Skin();
                _skinimages = new Dictionary <string, Image>();

                Console.WriteLine("No existing skin found. Writing default skin as Michael skin format...");

                fs.WriteAllText("/Shiftum42/Skins/Loaded/data.dat", JsonConvert.SerializeObject(_skin));
            }
            else
            {
                _skinimages.Clear();

                Console.WriteLine("Existing skin found.");
                Console.WriteLine("Opening skin data...");

                using (var stream = fs.OpenText("/Shiftum42/Skins/Loaded/data.dat"))
                {
                    Console.WriteLine(" --> Determining skin format...");

                    // Michael format is JSON, Phil format is not. JSON must start with a "{".
                    if (stream.Peek() == '{')
                    {
                        Console.WriteLine(" --> Detected Michael-formatted skin.");

                        _skin = JsonConvert.DeserializeObject <Skin>(stream.ReadToEnd());

                        Console.WriteLine(" --> JSON skin data loaded.");
                    }
                    else
                    {
                        Console.WriteLine(" --> Detected Philip Skin.");
                        Console.WriteLine(" --> Ladies and gentlemen, fasten your seatbelts. This is gonna f*****g suck.");

                        LoadPhilipSkin(fs, stream);
                    }
                }

                Console.WriteLine(" --> Done loading skin data file.");

                if (_skinimages.Keys.Count == 0)
                {
                    Console.WriteLine(" --> Loading images...");


                    foreach (var path in fs.GetFiles("/Shiftum42/Skins/Loaded"))
                    {
                        if (!path.EndsWith("data.dat"))
                        {
                            var image = fs.LoadImage(path);

                            string filenameWithoutExtension = Path.GetFileNameWithoutExtension(path);

                            Console.WriteLine(" --> Loaded: {0}", path);
                            Console.WriteLine(" --> Storing as: {0}", filenameWithoutExtension);

                            _skinimages.Add(filenameWithoutExtension, image);
                        }
                    }
                }
            }
        }
 public ToolStripSkinRenderer(SystemContext InSystem) : base(new ToolStripSkinColorTable(InSystem))
 {
     CurrentSystem = InSystem;
 }