public void Load(string filename) { if (filename == cachedVideo) { return; } image = null; video = null; prevSprite = null; if (filename.Contains("WSA")) { if (filename.Contains("INTRO")) { LoadPalette(); } else { LoadPaletteWSA(); } anim1.ChangeSequenceGroup(filename.Replace(".", "")); anim1.Play("play"); SetSize(anim1.Image.Size.XY.ToInt2().X, anim1.Image.Size.XY.ToInt2().Y); } else { //var video1 = new CpsD2Loader(filename); //cachedVideo = filename; //Open(video1); } }
public void Open(CpsD2Loader video) { this.image = video; stopped = true; paused = true; //onComplete = () => { }; TypeDictionary metadata; ImmutablePalette cpspalette; using (var stream = Game.ModData.DefaultFileSystem.Open(image.SpriteFilename)) { video.TryParseSpritePlusPalette(stream, out imageSprite, out metadata, out cpspalette); if (cpspalette != null) { LoadPalette(cpspalette, image.SpriteFilename); } } var imwidth = imageSprite[0].FrameSize.Width; var imheight = imageSprite[0].FrameSize.Height; var size = Math.Max(imwidth, imheight); var textureSize = Exts.NextPowerOf2(size); var scale = Math.Min((float)RenderBounds.Width / imwidth, (float)RenderBounds.Height / imheight * AspectRatio); videoOrigin = new float2( RenderBounds.X + (RenderBounds.Width - scale * imwidth) / 2, RenderBounds.Y + (RenderBounds.Height - scale * imheight * AspectRatio) / 2); // Round size to integer pixels. Round up to be consistent with the scale calculation. videoSize = new float2((int)Math.Ceiling(imwidth * scale), (int)Math.Ceiling(imheight * AspectRatio * scale)); }
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); } }
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); } }