Exemplo n.º 1
0
 public PaletteReference(string name, int index, IPalette palette, HardwarePalette hardwarePalette)
 {
     Name                 = name;
     Palette              = palette;
     this.index           = index;
     this.hardwarePalette = hardwarePalette;
 }
Exemplo n.º 2
0
        public override void Init(ModData modData, Dictionary <string, string> info)
        {
            base.Init(modData, info);

            // Avoid standard loading mechanisms so we
            // can display the loadscreen as early as possible
            r = Game.Renderer;
            if (r == null)
            {
                return;
            }

            if (info.ContainsKey("Text"))
            {
                messages = info["Text"].Split(',');
            }

            if (info.ContainsKey("Palette"))
            {
                using (var stream = modData.DefaultFileSystem.Open(info["Palette"]))
                {
                    palette = new ImmutablePalette(stream, new int[] { });
                }

                hardwarePalette = new HardwarePalette();
                hardwarePalette.AddPalette("loadscreen", palette, false);
                hardwarePalette.Initialize();
                r.SetPalette(hardwarePalette);
            }

            if (info.ContainsKey("Image"))
            {
                using (var stream = modData.DefaultFileSystem.Open(info["Image"]))
                {
                    CpsD2Loader loader = new CpsD2Loader();
                    if (!loader.TryParseSprite(stream, out frames))
                    {
                        return;
                    }
                }

                if (frames.Length == 0)
                {
                    return;
                }

                sheetBuilder = new SheetBuilder(SheetType.Indexed, 512);
                logo         = sheetBuilder.Add(frames[0]);

                logoPos = new float2((r.Resolution.Width - logo.Size.X) / 2, (r.Resolution.Height - logo.Size.Y) / 2);
            }
        }
Exemplo n.º 3
0
        void LoadPalette()
        {
            using (var stream = Game.ModData.DefaultFileSystem.Open("IBM.PAL"))
                palette = new ImmutablePalette(stream, new int[] { });

            hardwarePalette = new HardwarePalette();
            hardwarePalette.AddPalette("chrome", palette, false);
            hardwarePalette.Initialize();
            Game.Renderer.SetPalette(hardwarePalette);
            var pal = hardwarePalette.GetPalette("chrome");

            pr = new PaletteReference("chromeref", hardwarePalette.GetPaletteIndex("chrome"), pal, hardwarePalette);
        }
Exemplo n.º 4
0
        public void SetPalette(HardwarePalette palette)
        {
            if (palette.Texture == currentPaletteTexture)
            {
                return;
            }

            Flush();
            currentPaletteTexture = palette.Texture;

            SpriteRenderer.SetPalette(currentPaletteTexture);
            WorldSpriteRenderer.SetPalette(currentPaletteTexture);
            WorldModelRenderer.SetPalette(currentPaletteTexture);
        }
Exemplo n.º 5
0
        public void SetPalette(HardwarePalette palette)
        {
            // if (palette.Texture == currentPaletteTexture)
            //  return;

            // Flush();
            // currentPaletteTexture = palette.Texture;

            // RgbaSpriteRenderer.SetPalette(currentPaletteTexture);
            // SpriteRenderer.SetPalette(currentPaletteTexture);
            // WorldSpriteRenderer.SetPalette(currentPaletteTexture);
            // WorldRgbaSpriteRenderer.SetPalette(currentPaletteTexture);
            // WorldModelRenderer.SetPalette(currentPaletteTexture);
        }
Exemplo n.º 6
0
        public void SetPalette(HardwarePalette palette)
        {
            // Note: palette.Texture and palette.ColorShifts are updated at the same time
            // so we only need to check one of the two to know whether we must update the textures
            if (palette.Texture == currentPaletteTexture)
            {
                return;
            }

            Flush();
            currentPaletteTexture = palette.Texture;

            SpriteRenderer.SetPalette(currentPaletteTexture, palette.ColorShifts);
            WorldSpriteRenderer.SetPalette(currentPaletteTexture, palette.ColorShifts);
            WorldModelRenderer.SetPalette(currentPaletteTexture);
        }
Exemplo n.º 7
0
        public void LoadInitialAssets()
        {
            // all this manipulation of static crap here is nasty and breaks
            // horribly when you use ModData in unexpected ways.

            FileSystem.UnmountAll();
            foreach (var dir in Manifest.Folders)
            {
                FileSystem.Mount(dir);
            }

            AvailableMaps = FindMaps(Manifest.Mods);

            Palette = new HardwarePalette();
            ChromeMetrics.Initialize(Manifest.ChromeMetrics);
            ChromeProvider.Initialize(Manifest.Chrome);
            SheetBuilder = new SheetBuilder(TextureChannel.Red);
            SpriteLoader = new SpriteLoader(new string[] { ".shp" }, SheetBuilder);
            CursorProvider.Initialize(Manifest.Cursors);
            Palette.Update(new IPaletteModifier[] { });
        }
Exemplo n.º 8
0
        public override void Init(ModData modData, Dictionary <string, string> info)
        {
            base.Init(modData, info);

            this.modData = modData;
            this.info    = info;

            /*
             * Unpack files needed, because in some PAK files, some VOC files can have prefix 'Z'
             * Unpacking files will unpack such files and rename. so no modifications in yaml needed.
             * LoadScreen.Init, possibly not the best place to do this, but need to do that early, before
             * data will be used. and do this in LoadScreen.Init just works fine.
             */
            if (D2UnpackContent.UnpackFiles(modData, info) > 0)
            {
                // Some files unpacked. need to reload mod packages
                modData.ModFiles.LoadFromManifest(modData.Manifest);
            }

            /*
             * Like for unpack files, OpenRA engine do not have proper place for import maps.
             * And can't import in LoadScreen.Init, because engine not ready.
             * but Game.OnShellmapLoaded just works.
             */
            Game.OnShellmapLoaded += ImportOriginalMaps;

            // Avoid standard loading mechanisms so we
            // can display the loadscreen as early as possible
            r = Game.Renderer;
            if (r == null)
            {
                return;
            }

            if (info.ContainsKey("Text"))
            {
                messages = info["Text"].Split(',');
            }

            if (info.ContainsKey("Palette"))
            {
                using (var stream = modData.DefaultFileSystem.Open(info["Palette"]))
                    palette = new ImmutablePalette(stream, new int[] { });

                hardwarePalette = new HardwarePalette();
                hardwarePalette.AddPalette("loadscreen", palette, false);
                hardwarePalette.Initialize();
                r.SetPalette(hardwarePalette);
                var pal = hardwarePalette.GetPalette("loadscreen");
                pr = new PaletteReference("loadscreenref", hardwarePalette.GetPaletteIndex("loadscreen"), pal, hardwarePalette);
            }

            if (info.ContainsKey("Image"))
            {
                using (var stream = modData.DefaultFileSystem.Open(info["Image"]))
                {
                    CpsD2Loader    loader = new CpsD2Loader();
                    TypeDictionary metadata;

                    if (!loader.TryParseSprite(stream, out frames, out metadata))
                    {
                        return;
                    }
                }

                if (frames.Length == 0)
                {
                    return;
                }

                sheetBuilder = new SheetBuilder(SheetType.Indexed, 512);
                logo         = sheetBuilder.Add(frames[0]);

                logoPos = new float2((r.Resolution.Width - logo.Size.X) / 2, (r.Resolution.Height - logo.Size.Y) / 2);
            }
        }