Display the HDD size correctly

This commit is contained in:
wiidev 2023-01-01 17:00:21 +00:00
parent e0e6815b8f
commit ec5ed33c3b
2 changed files with 22 additions and 29 deletions

View File

@ -40,7 +40,6 @@
#include "sys.h" #include "sys.h"
struct discHdr *dvdheader = NULL; struct discHdr *dvdheader = NULL;
static bool Exiting = false;
GameBrowseMenu::GameBrowseMenu() GameBrowseMenu::GameBrowseMenu()
: GuiWindow(screenwidth, screenheight) : GuiWindow(screenwidth, screenheight)
@ -48,7 +47,6 @@ GameBrowseMenu::GameBrowseMenu()
returnMenu = MENU_NONE; returnMenu = MENU_NONE;
gameSelectedOld = -1; gameSelectedOld = -1;
lastrawtime = 0; lastrawtime = 0;
Exiting = false;
show_searchwindow = false; show_searchwindow = false;
gameBrowser = NULL; gameBrowser = NULL;
searchBar = NULL; searchBar = NULL;
@ -115,6 +113,8 @@ GameBrowseMenu::GameBrowseMenu()
usedSpaceTxt = new GuiText(" ", 18, thColor("r=55 g=190 b=237 a=255 - hdd info color")); usedSpaceTxt = new GuiText(" ", 18, thColor("r=55 g=190 b=237 a=255 - hdd info color"));
usedSpaceTxt->SetAlignment(thAlign("center - hdd info align hor"), thAlign("top - hdd info align ver")); usedSpaceTxt->SetAlignment(thAlign("center - hdd info align hor"), thAlign("top - hdd info align ver"));
usedSpaceTxt->SetPosition(thInt("0 - hdd info pos x"), thInt("400 - hdd info pos y")); usedSpaceTxt->SetPosition(thInt("0 - hdd info pos x"), thInt("400 - hdd info pos y"));
usedSpaceTxt->SetVisible(false);
SetFreeSpace(0.0f, 0.0f);
gamecntTxt = new GuiText((char *) NULL, 18, thColor("r=55 g=190 b=237 a=255 - game count color")); gamecntTxt = new GuiText((char *) NULL, 18, thColor("r=55 g=190 b=237 a=255 - game count color"));
gamecntBtn = new GuiButton(100, 18); gamecntBtn = new GuiButton(100, 18);
@ -366,7 +366,6 @@ GameBrowseMenu::GameBrowseMenu()
GameBrowseMenu::~GameBrowseMenu() GameBrowseMenu::~GameBrowseMenu()
{ {
Exiting = true;
ResumeGui(); ResumeGui();
SetEffect(EFFECT_FADE, -20); SetEffect(EFFECT_FADE, -20);
@ -850,6 +849,8 @@ void GameBrowseMenu::ReloadBrowser()
Append(usedSpaceTxt); Append(usedSpaceTxt);
if (thInt("1 - show game count: 1 for on and 0 for off") == 1) //force show game cnt info if (thInt("1 - show game count: 1 for on and 0 for off") == 1) //force show game cnt info
Append(gamecntBtn); Append(gamecntBtn);
if (!Settings.ShowGameCount)
Remove(gamecntBtn);
if (Settings.godmode || !(Settings.ParentalBlocks & BLOCK_SD_RELOAD_BUTTON)) if (Settings.godmode || !(Settings.ParentalBlocks & BLOCK_SD_RELOAD_BUTTON))
Append(sdcardBtn); Append(sdcardBtn);
Append(poweroffBtn); Append(poweroffBtn);
@ -1685,32 +1686,23 @@ void GameBrowseMenu::UpdateCallback(void * e)
} }
} }
void GameBrowseMenu::UpdateFreeSpace(void * arg) void GameBrowseMenu::SetFreeSpace(float freespace, float used)
{ {
char spaceinfo[30]; if (strcmp(Settings.db_language, "JA") == 0)
spaceinfo[0] = 0; usedSpaceTxt->SetText(fmt("%.2fGB %s %.2fGB %s", freespace + used, tr( "of" ), freespace, tr( "free" )));
else
if(Settings.ShowFreeSpace) usedSpaceTxt->SetText(fmt("%.2fGB %s %.2fGB %s", freespace, tr( "of" ), freespace + used, tr( "free" )));
{ }
float freespace = 0.0, used = 0.0;
int ret = WBFS_DiskSpace(&used, &freespace); void GameBrowseMenu::UpdateFreeSpace(void * arg)
if(ret >= 0) {
{ if (Settings.ShowFreeSpace)
if (strcmp(Settings.db_language, "JA") == 0) {
{ float freespace = 0.0, used = 0.0;
// needs to be "total...used" for Japanese usedSpaceTxt->SetVisible(true);
snprintf(spaceinfo, sizeof(spaceinfo), "%.2fGB %s %.2fGB %s", (freespace + used), tr( "of" ), freespace, tr( "free" )); int ret = WBFS_DiskSpace(&used, &freespace);
} if (ret >= 0)
else SetFreeSpace(freespace, used);
{ }
snprintf(spaceinfo, sizeof(spaceinfo), "%.2fGB %s %.2fGB %s", freespace, tr( "of" ), (freespace + used), tr( "free" ));
}
}
}
if(Exiting)
return;
usedSpaceTxt->SetText(spaceinfo);
} }

View File

@ -21,6 +21,7 @@ class GameBrowseMenu : public GuiWindow
void LoadCover(struct discHdr *header); void LoadCover(struct discHdr *header);
void CheckDiscSlotUpdate(); void CheckDiscSlotUpdate();
void UpdateFreeSpace(void *arg); void UpdateFreeSpace(void *arg);
void SetFreeSpace(float freespace, float used);
void UpdateClock(); void UpdateClock();
static void UpdateCallback(void * e); static void UpdateCallback(void * e);