public ResourcePatcher( ResourceFetcher fetcher )
 {
     jarClassic = fetcher.jarClassic;
     jar162 = fetcher.jar162;
     pngTerrainPatch = fetcher.pngTerrainPatch;
     pngGuiPatch = fetcher.pngGuiPatch;
 }
        public void FetchFiles( string baseUrl, string altBaseUrl, ResourceFetcher fetcher )
        {
            identifiers = new string[files.Length];
            for( int i = 0; i < files.Length; i++ )
                identifiers[i] = prefix + files[i].Substring( 1 );

            for( int i = 0; i < files.Length; i++ ) {
                string loc = files[i][0] == 'A' ? baseUrl : altBaseUrl;
                string url = loc + files[i].Substring( 1 ) + ".ogg";
                fetcher.downloader.DownloadData( url, false, identifiers[i] );
            }
        }
示例#3
0
        void DownloadResources(int mouseX, int mouseY)
        {
            if (game.Downloader == null)
            {
                game.Downloader = new AsyncDownloader("null");
            }
            if (fetcher != null)
            {
                return;
            }

            fetcher = game.fetcher;
            fetcher.DownloadItems(game.Downloader, SetStatus);
            selectedWidget = null;
            Resize();
        }
        public bool CheckDownloaded( ResourceFetcher fetcher, Action<string> setStatus )
        {
            if( Done ) return true;
            for( int i = 0; i < identifiers.Length; i++ ) {
                DownloadedItem item;
                if( fetcher.downloader.TryGetItem( identifiers[i], out item ) ) {
                    Console.WriteLine( "got sound " + identifiers[i] );
                    if( item.Data == null ) {
                        setStatus( "&cFailed to download " + identifiers[i] );
                        return false;
                    }
                    DecodeSound( files[i].Substring( 1 ), (byte[])item.Data );

                    // TODO: setStatus( next );
                    if( i == identifiers.Length - 1 ) {
                        Done = true;
                        setStatus( fetcher.MakeNext( nextAction ) );
                    } else {
                        setStatus( fetcher.MakeNext( identifiers[i + 1] ) );
                    }
                }
            }
            return true;
        }
        public override void Tick()
        {
            if( fetcher == null || failed ) return;
            CheckCurrentProgress();

            if( !fetcher.Check( SetStatus ) )
                failed = true;

            if( fetcher.Done ) {
                if( !fetcher.defaultZipExists ) {
                    ResourcePatcher patcher = new ResourcePatcher( fetcher );
                    patcher.Run();
                }
                fetcher = null;
                GC.Collect();
                game.TryLoadTexturePack();
                GotoNextMenu();
            }
        }
        void DownloadResources( int mouseX, int mouseY )
        {
            if( game.Downloader == null )
                game.Downloader = new AsyncDownloader( "null" );
            if( fetcher != null ) return;

            fetcher = game.fetcher;
            fetcher.DownloadItems( game.Downloader, SetStatus );
            selectedWidget = null;
            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.Init( Window.WindowInfo );

            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 || Screen.Dirty )
                    Display();
                Thread.Sleep( 1 );
            }

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

            if( ShouldUpdate )
                Updater.Patcher.LaunchUpdateScript();
            if( Window.Exists )
                Window.Close();
        }
示例#8
0
        public void Run()
        {
            Window = new NativeWindow(640, 400, Program.AppName,
                                      GraphicsMode.Default, DisplayDevice.Primary);
            Window.Visible = true;
            Drawer         = new GdiPlusDrawer2D();
            Init();
            TryLoadTexturePack();
            platformDrawer.info = Window.WindowInfo;
            platformDrawer.Init();

            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();
            }
        }
示例#9
0
 void DisplayResourcesDialog( object sender, EventArgs e )
 {
     // TODO: async fetching
     ResourceFetcher fetcher = new ResourceFetcher();
     if( !fetcher.CheckAllResourcesExist() ) {
         DialogResult result = MessageBox.Show(
             "Some required resources weren't found. Would you like to download them now?", "Missing resources",
             MessageBoxButtons.OKCancel );
         if( result == DialogResult.OK ) {
             fetcher.Run( this );
             Text = AppName;
         }
     }
 }
示例#10
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();
            }
        }