From 5058a6688d741bff6bd68cc4c53248847a175527 Mon Sep 17 00:00:00 2001 From: dimok321 <15055714+dimok789@users.noreply.github.com> Date: Mon, 28 Dec 2009 16:05:16 +0000 Subject: [PATCH] *Added a prompt after a theme was downloaded which asks if you want to apply the downloaded theme *Changed GuiDrawThread priority to maximum. This seems to take care of the vanishing WiiMotePointer problem (let's see if it works. If anyone notices a slowdown of any process caused by this revision, please report.) --- HBC/META.XML | 4 +-- gui.pnproj | 2 +- source/listfiles.c | 38 +++++++++++++++++++++ source/listfiles.h | 1 + source/menu.cpp | 20 +++++------ source/themes/Theme_Downloader.cpp | 53 +++++++++++++++++++++++------- source/video.cpp | 3 +- 7 files changed, 95 insertions(+), 26 deletions(-) diff --git a/HBC/META.XML b/HBC/META.XML index 3d524ff3..eef9f596 100644 --- a/HBC/META.XML +++ b/HBC/META.XML @@ -2,8 +2,8 @@ USB Loader GX USB Loader GX Team - 1.0 r876 - 200912271958 + 1.0 r877 + 200912281318 Loads games from USB-devices USB Loader GX is a libwiigui based USB iso loader with a wii-like GUI. You can install games to your HDDs and boot them with shorter loading times. The interactive GUI is completely controllable with WiiMote, Classic Controller or GC Controller. diff --git a/gui.pnproj b/gui.pnproj index 2dc3d5f6..3d2444ec 100644 --- a/gui.pnproj +++ b/gui.pnproj @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/source/listfiles.c b/source/listfiles.c index 8537a789..d016b581 100644 --- a/source/listfiles.c +++ b/source/listfiles.c @@ -139,8 +139,46 @@ bool checkfile(char * path) { return false; } +bool SearchFile(const char * searchpath, const char * searched_filename, char * outfilepath) +{ + struct stat st; + DIR_ITER *dir = NULL; + bool result = false; + char filename[1024]; + char pathptr[strlen(searchpath)+1]; + snprintf(pathptr, sizeof(pathptr), "%s", searchpath); + if(pathptr[strlen(pathptr)-1] == '/') + { + pathptr[strlen(pathptr)-1] = '\0'; + } + dir = diropen(pathptr); + if(!dir) + return false; + while (dirnext(dir,filename,&st) == 0 && result == false) + { + if(strcasecmp(filename, searched_filename) == 0) + { + if(outfilepath) + { + sprintf(outfilepath, "%s/%s", pathptr, filename); + } + result = true; + } + else if((st.st_mode & S_IFDIR) != 0) + { + if(strcmp(filename, ".") != 0 && strcmp(filename, "..") != 0) + { + char newpath[1024]; + snprintf(newpath, sizeof(newpath), "%s/%s", pathptr, filename); + result = SearchFile(newpath, searched_filename, outfilepath); + } + } + } + dirclose(dir); + return result; +} diff --git a/source/listfiles.h b/source/listfiles.h index 01b3e39b..e36ef114 100644 --- a/source/listfiles.h +++ b/source/listfiles.h @@ -10,6 +10,7 @@ extern "C" { int GetAllDirFiles(char * filespath); bool subfoldercreate(const char * fullpath); bool checkfile(char * path); + bool SearchFile(const char * searchpath, const char * searched_filename, char * outfilepath); #ifdef __cplusplus } diff --git a/source/menu.cpp b/source/menu.cpp index 3094e59d..a9945a98 100644 --- a/source/menu.cpp +++ b/source/menu.cpp @@ -110,7 +110,7 @@ static void * UpdateGUI (void *arg) { while (1) { if (guiHalt) { LWP_SuspendThread(guithread); - } + } else { if (!ExitRequested) { mainWindow->Draw(); @@ -179,7 +179,7 @@ static void * UpdateGUI (void *arg) { * Startup GUI threads ***************************************************************************/ void InitGUIThreads() { - LWP_CreateThread(&guithread, UpdateGUI, NULL, NULL, 0, 75); + LWP_CreateThread(&guithread, UpdateGUI, NULL, NULL, 0, LWP_PRIO_HIGHEST); InitProgressThread(); InitNetworkThread(); @@ -252,7 +252,7 @@ int MainMenu(int menu) { currentMenu = menu; char imgPath[100]; - + //if (strcmp(headlessID,"")!=0)HaltGui(); //WindowPrompt("Can you see me now",0,"ok"); @@ -287,7 +287,7 @@ int MainMenu(int menu) { bgMusic->Load(Settings.ogg_path); } bgMusic->Play(); - + while (currentMenu != MENU_EXIT) { bgMusic->SetVolume(Settings.volume); @@ -373,11 +373,11 @@ int MainMenu(int menu) { else if (boothomebrew == 1) { gprintf("\nBootHomebrew"); BootHomebrew(Settings.selected_homebrew); - } + } else if (boothomebrew == 2) { gprintf("\nBootHomebrewFromMenu"); BootHomebrewFromMem(); - } + } else { gprintf("\n\tSettings.partition:%d",Settings.partition); struct discHdr *header = NULL; @@ -411,8 +411,8 @@ int MainMenu(int menu) { } } } - - + + int ret = 0; header = (mountMethod?dvdheader:&gameList[gameSelected]); @@ -491,7 +491,7 @@ int MainMenu(int menu) { gprintf("\nSetting fragment list..."); ret = set_frag_list(header->id); gprintf("%d\n", ret); - + ret = Disc_SetUSB(header->id); if (ret < 0) Sys_BackToLoader(); gprintf("\n\tUSB set to game"); @@ -519,7 +519,7 @@ int MainMenu(int menu) { mload_close(); } } - + u8 errorfixer002 = 0; switch (fix002) { case on: diff --git a/source/themes/Theme_Downloader.cpp b/source/themes/Theme_Downloader.cpp index a5c779b9..b1d00630 100644 --- a/source/themes/Theme_Downloader.cpp +++ b/source/themes/Theme_Downloader.cpp @@ -36,10 +36,10 @@ extern u8 shutdown; extern u8 reset; -bool DownloadTheme(const char *url, const char *title) +int DownloadTheme(const char *url, const char *title) { if(!url) - return false; + return 0; char filename[255]; memset(filename, 0, sizeof(filename)); @@ -49,7 +49,7 @@ bool DownloadTheme(const char *url, const char *title) if(filesize <= 0) { WindowPrompt(tr("Download request failed."), 0, tr("OK")); - return false; + return 0; } char path[300]; @@ -65,7 +65,7 @@ bool DownloadTheme(const char *url, const char *title) if(!file) { WindowPrompt(tr("Download failed."), tr("Can't create file"), tr("OK")); - return false; + return 0; } u32 done = 0; @@ -89,7 +89,7 @@ bool DownloadTheme(const char *url, const char *title) remove(path); ProgressStop(); WindowPrompt(tr("Download failed."), tr("Transfer failed."), tr("OK")); - return false; + return 0; } else if (ret == 0) break; @@ -108,16 +108,37 @@ bool DownloadTheme(const char *url, const char *title) { remove(filepath); WindowPrompt(tr("Download failed."), tr("Connection lost..."), tr("OK")); - return false; + return 0; } ZipFile zipfile(filepath); - bool result = zipfile.ExtractAll(path); + int result = zipfile.ExtractAll(path); if(result) { remove(filepath); - WindowPrompt(tr("Successfully extracted theme"), title, tr("OK")); + int choice = WindowPrompt(tr("Successfully extracted theme."), tr("Do you want to apply it now?"), tr("Yes"), tr("No")); + if(choice) + { + char real_themepath[1024]; + sprintf(real_themepath, "%s", CFG.theme_path); + if(SearchFile(path, "GXtheme.cfg", real_themepath) == true) + { + char *ptr = strrchr(real_themepath, '/'); + if(ptr) + { + ptr++; + ptr[0] = '\0'; + } + snprintf(CFG.theme_path, sizeof(CFG.theme_path), "%s", real_themepath); + cfg_save_global(); + CFG_Load(); + CFG_LoadGlobal(); + result = 2; + } + else + WindowPrompt(tr("ERROR: Can't set up theme."), tr("GXtheme.cfg not found in any subfolder."), tr("OK")); + } } else WindowPrompt(tr("Failed to extract."), tr("Unsupported format, try to extract manually."), tr("OK")); @@ -126,10 +147,11 @@ bool DownloadTheme(const char *url, const char *title) } -static void Theme_Prompt(const char *title, const char *author, GuiImageData *thumbimageData, const char *downloadlink) +static int Theme_Prompt(const char *title, const char *author, GuiImageData *thumbimageData, const char *downloadlink) { gprintf("\nTheme_Prompt(%s ,%s, , %s)",title,author,downloadlink); bool leave = false; + int result = 0; GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, Settings.sfxvolume); // because destroy GuiSound must wait while sound playing is finished, we use a global sound @@ -233,7 +255,9 @@ static void Theme_Prompt(const char *title, const char *author, GuiImageData *th int choice = WindowPrompt(tr("Do you want to download this theme?"), title, tr("Yes"), tr("Cancel")); if(choice) { - DownloadTheme(downloadlink, title); + result = DownloadTheme(downloadlink, title); + if(result == 2) + leave = true; } mainWindow->SetState(STATE_DISABLED); promptWindow.SetState(STATE_DEFAULT); @@ -254,6 +278,8 @@ static void Theme_Prompt(const char *title, const char *author, GuiImageData *th mainWindow->Remove(&promptWindow); mainWindow->SetState(STATE_DEFAULT); ResumeGui(); + + return result; } @@ -600,8 +626,13 @@ int Theme_Downloader() if(MainButton[i]->GetState() == STATE_CLICKED) { snprintf(url, sizeof(url), "%s", Theme->GetDownloadLink(currenttheme+i)); - Theme_Prompt(Theme->GetThemeTitle(currenttheme+i), Theme->GetThemeAuthor(currenttheme+i), ImageData[i], url); + int ret = Theme_Prompt(Theme->GetThemeTitle(currenttheme+i), Theme->GetThemeAuthor(currenttheme+i), ImageData[i], url); MainButton[i]->ResetState(); + if(ret == 2) + { + listchanged = true; + menu = MENU_THEMEDOWNLOADER; + } } } } diff --git a/source/video.cpp b/source/video.cpp index 8b8cbf4d..c82226cc 100644 --- a/source/video.cpp +++ b/source/video.cpp @@ -242,12 +242,12 @@ void StopGX() { * Renders everything current sent to GX, and flushes video ***************************************************************************/ void Menu_Render() { - GX_DrawDone (); whichfb ^= 1; // flip framebuffer GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE); GX_SetColorUpdate(GX_TRUE); GX_CopyDisp(xfb[whichfb],GX_TRUE); + GX_DrawDone (); VIDEO_SetNextFramebuffer(xfb[whichfb]); VIDEO_Flush(); VIDEO_WaitVSync(); @@ -499,4 +499,3 @@ s32 TakeScreenshot(const char *path) gprintf(":%d", ret); return 1; } -