Example #1
0
        public override void UpdateFromSettings(Settings settings)
        {
            // TODO: Update entity definitions too. Will probably require
            // hanging on to a copy of the input map's raw string for reparsing,
            // or at least the path to the original file.

            var textures = new Dictionary <string, TextureDictionary>();

            var placeholders = new TextureDictionary
            {
                // Cyan stands out nicely against the instance highlight yellow.
                { TextureGenerator.MissingTextureName, TextureGenerator.GenerateGrid(Colors.Cyan) }
            };

            textures.Add(TextureGenerator.MissingTextureName, placeholders);

            Stream stream;

            if (settings.Local.UsingCustomPalette)
            {
                stream = File.OpenRead(settings.Local.LastCustomPalette.LocalPath);
            }
            else
            {
                string name = $"palette-{settings.Roaming.LastBuiltInPalette.ToLower()}.lmp";

                stream = Assembly.GetAssembly(typeof(MainForm)).GetResourceStream(name);
            }

            using (stream)
            {
                Palette palette = new Palette().LoadQuakePalette(stream);

                foreach (string path in settings.Local.TextureDictionaryPaths)
                {
                    textures.Add(path, Loader.LoadTextureDictionary(path, palette));
                }
            }

            Textures = textures.Values.ToList().Stack();

            base.UpdateFromSettings(settings);
        }