Esempio n. 1
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);
            }
        }
Esempio n. 2
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);
        }
Esempio n. 3
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);
            }
        }