diff --git a/Core/Util/GameManager.cpp b/Core/Util/GameManager.cpp index eb2ac44cba..46f71f8824 100644 --- a/Core/Util/GameManager.cpp +++ b/Core/Util/GameManager.cpp @@ -51,7 +51,7 @@ bool GameManager::DownloadAndInstall(std::string storeZipUrl) { } std::string filename = GetTempFilename(); - curDownload_ = downloader_.StartDownload(storeZipUrl, filename); + curDownload_ = g_DownloadManager.StartDownload(storeZipUrl, filename); return true; } @@ -93,8 +93,8 @@ void GameManager::Update() { // Doesn't matter if the install succeeds or not, we delete the temp file to not squander space. // TODO: Handle disk full? deleteFile(zipName.c_str()); - curDownload_.reset(); } + curDownload_.reset(); } } @@ -162,7 +162,6 @@ void GameManager::InstallGame(std::string zipfile) { // Note that we do NOT write files that are not in a directory, to avoid random // README files etc. if (strstr(fn, "/") != 0) { - INFO_LOG(HLE, "File: %i: %s", i, fn); struct zip_stat zstat; int x = zip_stat_index(z, i, 0, &zstat); size_t size = zstat.size; @@ -174,7 +173,9 @@ void GameManager::InstallGame(std::string zipfile) { std::string outFilename = pspGame + fn; bool isDir = outFilename.back() == '/'; if (!isDir) { - INFO_LOG(HLE, "Writing %i bytes to %s", (int)size, outFilename.c_str()); + if (i < 10) { + INFO_LOG(HLE, "Writing %i bytes to %s", (int)size, outFilename.c_str()); + } FILE *f = fopen(outFilename.c_str(), "wb"); if (f) { fwrite(buffer, 1, size, f); @@ -186,6 +187,7 @@ void GameManager::InstallGame(std::string zipfile) { } } } + INFO_LOG(HLE, "Extracted %i files.", numFiles); zip_close(z); } diff --git a/Core/Util/GameManager.h b/Core/Util/GameManager.h index 30b9513aee..27836b277c 100644 --- a/Core/Util/GameManager.h +++ b/Core/Util/GameManager.h @@ -37,8 +37,6 @@ public: private: void InstallGame(std::string zipfile); std::string GetTempFilename() const; - - http::Downloader downloader_; std::shared_ptr curDownload_; }; diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index e3282c41f3..d316f07b6a 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -189,28 +189,24 @@ std::string boot_filename = ""; void NativeHost::InitSound(PMixer *mixer) { g_mixer = mixer; - #ifdef IOS - iOSCoreAudioInit(); + iOSCoreAudioInit(); #endif } void NativeHost::ShutdownSound() { #ifdef IOS - iOSCoreAudioShutdown(); + iOSCoreAudioShutdown(); #endif - g_mixer = 0; } int NativeMix(short *audio, int num_samples) { - // ILOG("Entering mixer"); if (g_mixer) { num_samples = g_mixer->Mix(audio, num_samples); } else { memset(audio, 0, num_samples * 2 * sizeof(short)); } - // ILOG("Leaving mixer"); return num_samples; } @@ -305,7 +301,7 @@ void NativeInit(int argc, const char *argv[], #ifdef ANDROID // On Android, create a PSP directory tree in the external_directory, - // to hopefully reduce confusion a bit. + // to hopefully reduce confusion a bit. ILOG("Creating %s", (g_Config.memCardDirectory + "PSP").c_str()); mkDir((g_Config.memCardDirectory + "PSP").c_str()); mkDir((g_Config.memCardDirectory + "PSP/SAVEDATA").c_str()); @@ -388,12 +384,12 @@ void NativeInit(int argc, const char *argv[], if (!gfxLog) logman->SetLogLevel(LogTypes::G3D, LogTypes::LERROR); INFO_LOG(BOOT, "Logger inited."); -#endif +#endif i18nrepo.LoadIni(g_Config.sLanguageIni); I18NCategory *d = GetI18NCategory("DesktopUI"); - // Note to translators: do not translate this/add this to PPSSPP-lang's files. - // It's intended to be custom for every user. + // Note to translators: do not translate this/add this to PPSSPP-lang's files. + // It's intended to be custom for every user. // Only add it to your own personal copies of PPSSPP. #ifdef _WIN32 // TODO: Could allow a setting to specify a font file to load? @@ -407,9 +403,7 @@ void NativeInit(int argc, const char *argv[], g_gameInfoCache.Init(); - screenManager = new ScreenManager(); - if (skipLogo) { screenManager->switchScreen(new EmuScreen(boot_filename)); } else { @@ -550,10 +544,9 @@ void TakeScreenshot() { memcpy(flipbuffer + y * pixel_xres * 4, buffer + (pixel_yres - y - 1) * pixel_xres * 4, pixel_xres * 4); } - if(g_Config.bScreenshotsAsPNG) + if (g_Config.bScreenshotsAsPNG) { stbi_write_png(temp, pixel_xres, pixel_yres, 4, flipbuffer, pixel_xres * 4); - else - { + } else { jpge::params params; params.m_quality = 90; compress_image_to_jpeg_file(temp, pixel_xres, pixel_yres, 4, flipbuffer, params); @@ -566,6 +559,33 @@ void TakeScreenshot() { #endif } +void DrawDownloadsOverlay(UIContext &ctx) { + // Thin bar at the top of the screen like Chrome. + std::vector progress = g_DownloadManager.GetCurrentProgress(); + if (progress.empty()) { + return; + } + + static const uint32_t colors[4] = { + 0xFFFFFFFF, + 0xFFCCCCCC, + 0xFFAAAAAA, + 0xFF777777, + }; + + ctx.Begin(); + int h = 5; + for (int i = 0; i < progress.size(); i++) { + float barWidth = 10 + (dp_xres - 10) * progress[i]; + Bounds bounds(0, h * i, barWidth, h); + INFO_LOG(HLE, "Bar"); + UI::Drawable solid(colors[i & 3]); + ctx.FillRect(solid, bounds); + } + ctx.End(); + ctx.Flush(); +} + void NativeRender() { g_GameManager.Update(); @@ -589,6 +609,8 @@ void NativeRender() { screenManager->getUIContext()->Text()->OncePerFrame(); } + DrawDownloadsOverlay(*screenManager->getUIContext()); + if (g_TakeScreenshot) { TakeScreenshot(); } diff --git a/UI/Store.cpp b/UI/Store.cpp index 0dbee972fc..5e08db06f0 100644 --- a/UI/Store.cpp +++ b/UI/Store.cpp @@ -112,18 +112,18 @@ StoreScreen::StoreScreen() : loading_(true), connectionError_(false) { std::string indexPath = storeBaseUrl + "index.json"; - listing_ = downloader_.StartDownload(indexPath, ""); + listing_ = g_DownloadManager.StartDownload(indexPath, ""); } StoreScreen::~StoreScreen() { - downloader_.CancelAll(); + g_DownloadManager.CancelAll(); } // Handle async download tasks void StoreScreen::update(InputState &input) { UIDialogScreenWithBackground::update(input); - downloader_.Update(); + g_DownloadManager.Update(); if (listing_.get() != 0 && listing_->Done()) { if (listing_->ResultCode() == 200) { diff --git a/UI/Store.h b/UI/Store.h index 387349da0d..f5814e084a 100644 --- a/UI/Store.h +++ b/UI/Store.h @@ -77,8 +77,6 @@ private: std::string GetStoreJsonURL(std::string storePath) const; std::string GetTranslatedString(const json_value *json, std::string key, const char *fallback = 0) const; - http::Downloader downloader_; - std::shared_ptr listing_; std::shared_ptr image_;