public override void Draw() { var name = GetImageName(); var collection = GetImageCollection(); var paletteName = GetPaletteName(); if (paletteName == null || paletteName.Length == 0) { paletteName = "player" + world.LocalPlayer.InternalName; } PaletteReference p = null; if (paletteName != null) { p = worldRenderer.Palette(paletteName); } var sprite = D2ChromeProvider.GetImage(collection, name, p); if (sprite == null) { throw new ArgumentException("Sprite {0}/{1} was not found.".F(collection, name)); } if (FillBackground) { for (var y = 0; y < Bounds.Height; y += sprite.Bounds.Height) { for (var x = 0; x < Bounds.Width; x += sprite.Bounds.Width) { WidgetUtils.DrawRGBA(sprite, RenderOrigin + new int2(x, y)); } } } else { WidgetUtils.DrawRGBA(sprite, RenderOrigin); } }
public override void Init(ModData modData, Dictionary <string, string> info) { base.Init(modData, info); Game.OnQuit += Done; this.modData = modData; this.info = info; // Can't find better place for initialization D2ChromeProvider.Initialize(modData); /* * 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 it possible to 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); } }
void Done() { D2ChromeProvider.Deinitialize(); }