Ejemplo n.º 1
0
 public ResourcePatcher( ResourceFetcher fetcher )
 {
     jarClassic = fetcher.jarClassic;
     jar162 = fetcher.jar162;
     pngTerrainPatch = fetcher.pngTerrainPatch;
     pngGuiPatch = fetcher.pngGuiPatch;
 }
Ejemplo n.º 2
0
        public void FetchFiles( string baseUrl, string altBaseUrl, 
            ResourceFetcher fetcher, bool allExist)
        {
            if( allExist ) { Done = true; return; }

            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] );
            }
        }
Ejemplo n.º 3
0
        public void FetchFiles(ResourceFetcher fetcher, bool allExist)
        {
            if (allExist)
            {
                Done = true; return;
            }

            identifiers = new string[files.Length];
            for (int i = 0; i < files.Length; i++)
            {
                identifiers[i] = prefix + files[i];
            }

            for (int i = 0; i < files.Length; i++)
            {
                string url = ResourceFetcher.assetsUri + hashes[i];
                fetcher.QueueItem(url, identifiers[i]);
            }
        }
Ejemplo n.º 4
0
        public void FetchFiles(string baseUrl, string altBaseUrl,
                               ResourceFetcher fetcher, bool allExist)
        {
            if (allExist)
            {
                Done = true; return;
            }

            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.QueueItem(url, identifiers[i]);
            }
        }
Ejemplo n.º 5
0
        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;
        }
Ejemplo n.º 6
0
        public override void Tick()
        {
            if( fetcher == null || failed ) return;
            CheckCurrentProgress();

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

            if( fetcher.Done ) {
                if( ResourceList.Files.Count > 0 ) {
                    ResourcePatcher patcher = new ResourcePatcher( fetcher );
                    patcher.Run();
                }
                fetcher = null;
                GC.Collect();
                game.TryLoadTexturePack();
                GotoNextMenu();
            }
        }
Ejemplo n.º 7
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();
        }