public void InitializeFonts(ModData modData) { if (Fonts != null) { foreach (var font in Fonts.Values) { font.Dispose(); } } using (new PerfTimer("SpriteFonts")) { if (fontSheetBuilder != null) { fontSheetBuilder.Dispose(); } fontSheetBuilder = new SheetBuilder(SheetType.BGRA); Fonts = modData.Manifest.Fonts.ToDictionary(x => x.Key, x => new SpriteFont(x.Value.First, modData.DefaultFileSystem.Open(x.Value.First).ReadAllBytes(), x.Value.Second, Device.WindowScale, fontSheetBuilder)).AsReadOnly(); } Device.OnWindowScaleChanged += (before, after) => { foreach (var f in Fonts) { f.Value.SetScale(after); } }; }
public void InitializeFonts(ModData modData) { if (Fonts != null) { foreach (var font in Fonts.Values) { font.Dispose(); } } using (new PerfTimer("SpriteFonts")) { fontSheetBuilder?.Dispose(); fontSheetBuilder = new SheetBuilder(SheetType.BGRA, 512); Fonts = modData.Manifest.Get <Fonts>().FontList.ToDictionary(x => x.Key, x => new SpriteFont(x.Value.Font, modData.DefaultFileSystem.Open(x.Value.Font).ReadAllBytes(), x.Value.Size, x.Value.Ascender, Window.EffectiveWindowScale, fontSheetBuilder)).AsReadOnly(); } Window.OnWindowScaleChanged += (oldNative, oldEffective, newNative, newEffective) => { Game.RunAfterTick(() => { ChromeProvider.SetDPIScale(newEffective); foreach (var f in Fonts) { f.Value.SetScale(newEffective); } }); }; }
public void InitializeFonts(Manifest m) { using (new Support.PerfTimer("SpriteFonts")) { if (fontSheetBuilder != null) { fontSheetBuilder.Dispose(); } fontSheetBuilder = new SheetBuilder(SheetType.BGRA); Fonts = m.Fonts.ToDictionary(x => x.Key, x => new SpriteFont(Platform.ResolvePath(x.Value.First), x.Value.Second, fontSheetBuilder)).AsReadOnly(); } }
void LoadMod(ModMetadata mod) { if (!modPrerequisitesFulfilled[mod.Id]) { var widgetArgs = new WidgetArgs { { "modId", mod.Id } }; Ui.OpenWindow("INSTALL_MOD_PANEL", widgetArgs); return; } if (!modInstallStatus[mod]) { var widgetArgs = new WidgetArgs { { "continueLoading", () => Game.RunAfterTick(() => Game.InitializeMod(Game.Settings.Game.Mod, new Arguments())) }, { "mirrorListUrl", mod.Content.PackageMirrorList }, { "modId", mod.Id } }; Ui.OpenWindow("INSTALL_PANEL", widgetArgs); return; } Game.RunAfterTick(() => { Ui.CloseWindow(); sheetBuilder.Dispose(); Game.InitializeMod(mod.Id, null); }); }
void LoadMod(ModMetadata mod) { if (!Game.IsModInstalled(mod.Id)) { var widgetArgs = new WidgetArgs { { "modId", mod.Id } }; Ui.OpenWindow("INSTALL_MOD_PANEL", widgetArgs); return; } if (!IsModInstalled(mod)) { var widgetArgs = new WidgetArgs { { "continueLoading", () => Game.RunAfterTick(() => Game.InitializeMod(mod.Id, new Arguments())) }, { "modId", mod.Id } }; Ui.OpenWindow("CONTENT_PROMPT_PANEL", widgetArgs); return; } Game.RunAfterTick(() => { Ui.CloseWindow(); sheetBuilder.Dispose(); Game.InitializeMod(mod.Id, null); }); }
public void Dispose() { if (previewLoaderThread == null) { sheetBuilder.Dispose(); return; } foreach (var p in previews.Values) { p.Dispose(); } foreach (var t in mapDirectoryTrackers) { t.Dispose(); } // We need to let the loader thread exit before we can dispose our sheet builder. // Ideally we should dispose our resources before returning, but we don't to block waiting on the loader thread to exit. // Instead, we'll queue disposal to be run once it has exited. ThreadPool.QueueUserWorkItem(_ => { previewLoaderThread.Join(); Game.RunAfterTick(sheetBuilder.Dispose); }); }
public void Dispose() { if (vertexBuffer != null) { vertexBuffer.Dispose(); } sheetBuilder.Dispose(); }
void LoadMod(ModMetadata mod) { Game.RunAfterTick(() => { Ui.CloseWindow(); sheetBuilder.Dispose(); Game.InitializeMod(mod.Id, null); }); }
protected override void Dispose(bool disposing) { if (disposing && sheetBuilder != null) { sheetBuilder.Dispose(); } if (disposing && hardwarePalette != null) { hardwarePalette.Dispose(); } base.Dispose(disposing); }
/// <summary> /// 初始化字体 /// </summary> /// <param name="modData"></param> public void InitializeFont(ModData modData) { if (Fonts != null) { foreach (var font in Fonts.Values) { font.Dispose(); } } using (new PerfTimer("SpriteFonts")) { if (fontSheetBuilder != null) { fontSheetBuilder.Dispose(); } fontSheetBuilder = new SheetBuilder(SheetT.BGRA, 512); Fonts = modData.Manifest.Fonts.ToDictionary(x => x.Key, x => new SpriteFont(x.Value.First, modData.DefaultFileSystem.Open(x.Value.First).ReadAllBytes(), x.Value.Second, 1.0f, fontSheetBuilder)).AsReadOnly(); } }
void LoadMod(Manifest mod) { var modId = mod.Id; if (!Game.IsModInstalled(modId)) { var widgetArgs = new WidgetArgs { { "mod", selectedMod }, { "content", content[selectedMod] }, }; Ui.OpenWindow("INSTALL_MOD_PANEL", widgetArgs); return; } if (!IsModInstalled(mod)) { var widgetArgs = new WidgetArgs { { "continueLoading", () => Game.RunAfterTick(() => Game.InitializeMod(modId, new Arguments())) }, { "mod", selectedMod }, { "content", content[selectedMod] }, }; Ui.OpenWindow("CONTENT_PROMPT_PANEL", widgetArgs); return; } Game.RunAfterTick(() => { Ui.CloseWindow(); sheetBuilder.Dispose(); Game.InitializeMod(modId, null); }); }
public void Dispose() { sheetBuilder.Dispose(); }