Exemple #1
0
        internal void TryLoadTexturePack()
        {
            Options.Load();
            LauncherSkin.LoadFromOptions();
            ClassicMode = Options.GetBool("mode-classic", false);
            string texDir  = Path.Combine(Program.AppDirectory, "texpacks");
            string texPack = Options.Get(OptionsKey.DefaultTexturePack) ?? "default.zip";

            texPack = Path.Combine(texDir, texPack);

            if (!File.Exists(texPack))
            {
                texPack = Path.Combine(texDir, "default.zip");
            }
            if (!File.Exists(texPack))
            {
                return;
            }

            using (Stream fs = new FileStream(texPack, FileMode.Open, FileAccess.Read, FileShare.Read)) {
                ZipReader reader = new ZipReader();

                reader.ShouldProcessZipEntry = (f) => f == "default.png" || f == "terrain.png";
                reader.ProcessZipEntry       = ProcessZipEntry;
                reader.Extract(fs);
            }
        }
        internal void TryLoadTexturePack()
        {
            fontPng = false; terrainPng = false;
            Options.Load();
            LauncherSkin.LoadFromOptions();
            if (Options.Get("nostalgia-classicbg") != null)
            {
                ClassicBackground = Options.GetBool("nostalgia-classicbg", false);
            }
            else
            {
                ClassicBackground = Options.GetBool("mode-classic", false);
            }

            string texDir  = Path.Combine(Program.AppDirectory, "texpacks");
            string texPack = Options.Get(OptionsKey.DefaultTexturePack) ?? "default.zip";

            texPack = Path.Combine(texDir, texPack);

            if (!File.Exists(texPack))
            {
                texPack = Path.Combine(texDir, "default.zip");
            }
            if (!File.Exists(texPack))
            {
                return;
            }

            ExtractTexturePack(texPack);
            if (!fontPng || !terrainPng)
            {
                texPack = Path.Combine(texDir, "default.zip");
                ExtractTexturePack(texPack);
            }
        }
Exemple #3
0
        internal void TryLoadTexturePack()
        {
            fontPng = false; terrainPng = false;
            Options.Load();
            LauncherSkin.LoadFromOptions();

            if (Options.Get("nostalgia-classicbg", null) != null)
            {
                ClassicBackground = Options.GetBool("nostalgia-classicbg", false);
            }
            else
            {
                ClassicBackground = Options.GetBool(OptionsKey.ClassicMode, false);
            }

            string texPack = Options.Get(OptionsKey.DefaultTexturePack, "default.zip");
            string texPath = Path.Combine("texpacks", texPack);

            if (!Platform.FileExists(texPath))
            {
                texPath = Path.Combine("texpacks", "default.zip");
            }
            if (!Platform.FileExists(texPath))
            {
                return;
            }

            ExtractTexturePack(texPath);
            // user selected texture pack is missing some required .png files
            if (!fontPng || !terrainPng)
            {
                texPath = Path.Combine("texpacks", "default.zip");
                ExtractTexturePack(texPath);
            }
        }
Exemple #4
0
        public void Run()
        {
            Window = new NativeWindow(640, 400, Program.AppName, 0,
                                      GraphicsMode.Default, DisplayDevice.Default);
            Window.Visible = true;
            Drawer         = new GdiPlusDrawer2D(null);
            Init();
            TryLoadTexturePack();
            platformDrawer.Init(Window.WindowInfo);

            fetcher = new ResourceFetcher();
            fetcher.CheckResourceExistence();
            checkTask = new UpdateCheckTask();
            checkTask.CheckForUpdatesAsync();
            if (!fetcher.AllResourcesExist)
            {
                SetScreen(new ResourcesScreen(this));
            }
            else
            {
                SetScreen(new MainScreen(this));
            }

            while (true)
            {
                Window.ProcessEvents();
                if (!Window.Exists)
                {
                    break;
                }
                if (ShouldExit)
                {
                    if (Screen != null)
                    {
                        Screen.Dispose();
                    }
                    break;
                }

                Screen.Tick();
                if (Dirty || Screen.Dirty)
                {
                    Display();
                }
                Thread.Sleep(1);
            }

            if (Options.Load())
            {
                LauncherSkin.SaveToOptions();
                Options.Save();
            }
            if (ShouldUpdate)
            {
                Updater.Patcher.LaunchUpdateScript();
            }
            Window.Close();
        }
        void ResetColours()
        {
            LauncherSkin.ResetToDefault();
            widgetIndex = 0;
            MakeAllRGBTriplets(true);

            using ( drawer ) {
                drawer.SetBitmap(game.Framebuffer);
                RedrawAll();
            }
            widgetIndex = widgets.Length;
            game.MakeBackground();
            Resize();
        }
        public void Run()
        {
            Window = new NativeWindow(640, 400, Program.AppName, 0,
                                      GraphicsMode.Default, DisplayDevice.Default);
            Window.Visible = true;
            Drawer         = new GdiPlusDrawer2D(null);
            Init();
            TryLoadTexturePack();
            platformDrawer.info = Window.WindowInfo;
            platformDrawer.Init();

            string audioPath = Path.Combine(Program.AppDirectory, "audio");

            BinUnpacker.Unpack(audioPath, "dig");
            BinUnpacker.Unpack(audioPath, "step");

            fetcher = new ResourceFetcher();
            fetcher.CheckResourceExistence();
            checkTask = new UpdateCheckTask();
            checkTask.CheckForUpdatesAsync();

            if (!fetcher.AllResourcesExist)
            {
                SetScreen(new ResourcesScreen(this));
            }
            else
            {
                SetScreen(new MainScreen(this));
            }

            while (true)
            {
                Window.ProcessEvents();
                if (!Window.Exists)
                {
                    break;
                }
                if (ShouldExit)
                {
                    if (Screen != null)
                    {
                        Screen.Dispose();
                    }
                    break;
                }

                Screen.Tick();
                if (Dirty)
                {
                    Display();
                }
                Thread.Sleep(10);
            }

            if (Options.Load())
            {
                LauncherSkin.SaveToOptions();
                Options.Save();
            }

            if (ShouldUpdate)
            {
                Updater.Applier.ApplyUpdate();
            }
            if (Window.Exists)
            {
                Window.Close();
            }
        }
Exemple #7
0
        public void Run()
        {
            Window = Factory.CreateWindow(640, 400, Program.AppName,
                                          GraphicsMode.Default, DisplayDevice.Default);
            Window.Visible = true;
            Drawer         = new GdiPlusDrawer2D();
            UpdateClientSize();

            Init();
            TryLoadTexturePack();
            platformDrawer.window = Window;
            platformDrawer.Init();

            Downloader = new AsyncDownloader(Drawer);
            Downloader.Init("");
            Downloader.Cookies   = new CookieContainer();
            Downloader.KeepAlive = true;

            fetcher = new ResourceFetcher();
            fetcher.CheckResourceExistence();
            checkTask = new UpdateCheckTask();
            checkTask.RunAsync(this);

            if (!fetcher.AllResourcesExist)
            {
                SetScreen(new ResourcesScreen(this));
            }
            else
            {
                SetScreen(new MainScreen(this));
            }

            while (true)
            {
                Window.ProcessEvents();
                if (!Window.Exists)
                {
                    break;
                }
                if (ShouldExit)
                {
                    if (Screen != null)
                    {
                        Screen.Dispose();
                        Screen = null;
                    }
                    break;
                }

                checkTask.Tick();
                Screen.Tick();
                if (Dirty)
                {
                    Display();
                }
                Thread.Sleep(10);
            }

            if (Options.Load())
            {
                LauncherSkin.SaveToOptions();
                Options.Save();
            }

            if (ShouldUpdate)
            {
                Updater.Applier.ApplyUpdate();
            }
            if (Window.Exists)
            {
                Window.Close();
            }
        }