Esempio n. 1
0
        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);
                }
            };
        }
Esempio n. 2
0
        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);
                    }
                });
            };
        }
Esempio n. 3
0
 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();
     }
 }
Esempio n. 4
0
        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);
            });
        }
Esempio n. 5
0
        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);
            });
        }
Esempio n. 6
0
        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);
            });
        }
Esempio n. 7
0
 public void Dispose()
 {
     if (vertexBuffer != null)
     {
         vertexBuffer.Dispose();
     }
     sheetBuilder.Dispose();
 }
Esempio n. 8
0
 void LoadMod(ModMetadata mod)
 {
     Game.RunAfterTick(() =>
     {
         Ui.CloseWindow();
         sheetBuilder.Dispose();
         Game.InitializeMod(mod.Id, null);
     });
 }
Esempio n. 9
0
        protected override void Dispose(bool disposing)
        {
            if (disposing && sheetBuilder != null)
            {
                sheetBuilder.Dispose();
            }

            if (disposing && hardwarePalette != null)
            {
                hardwarePalette.Dispose();
            }

            base.Dispose(disposing);
        }
Esempio n. 10
0
        /// <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();
            }
        }
Esempio n. 11
0
        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);
            });
        }
Esempio n. 12
0
 public void Dispose()
 {
     sheetBuilder.Dispose();
 }