diff --git a/include/iosupport.h b/include/iosupport.h index f502024b7..f92b39366 100644 --- a/include/iosupport.h +++ b/include/iosupport.h @@ -138,6 +138,8 @@ typedef struct _item_list_t config_set_t *(*itemGetConfig)(item_list_t *itemList, int id); + int (*itemGetSize)(item_list_t *itemList, int id); + int (*itemGetImage)(item_list_t *itemList, char *folder, int isRelative, char *value, char *suffix, GSTEXTURE *resultTex, short psm); void (*itemCleanUp)(item_list_t *itemList, int exception); diff --git a/include/supportbase.h b/include/supportbase.h index 4c4c1d09e..19d01a92d 100644 --- a/include/supportbase.h +++ b/include/supportbase.h @@ -49,6 +49,7 @@ void sbCreatePath(const base_game_info_t *game, char *path, const char *prefix, void sbDelete(base_game_info_t **list, const char *prefix, const char *sep, int gamecount, int id); void sbRename(base_game_info_t **list, const char *prefix, const char *sep, int gamecount, int id, char *newname); config_set_t *sbPopulateConfig(base_game_info_t *game, const char *prefix, const char *sep); +int sbCalcGameSize(base_game_info_t *game, const char *prefix, const char *sep); void sbCreateFolders(const char *path, int createDiscImgFolders); // ISO9660 filesystem management functions. diff --git a/src/appsupport.c b/src/appsupport.c index 443a7bf5f..18995b563 100644 --- a/src/appsupport.c +++ b/src/appsupport.c @@ -455,6 +455,11 @@ static config_set_t *appGetConfig(item_list_t *itemList, int id) return config; } +static int appGetSize(item_list_t *itemList, int id) +{ + return 0; +} + static int appGetImage(item_list_t *itemList, char *folder, int isRelative, char *value, char *suffix, GSTEXTURE *resultTex, short psm) { char device[8], *startup; @@ -500,4 +505,4 @@ static void appShutdown(item_list_t *itemList) static item_list_t appItemList = { APP_MODE, -1, 0, MODE_FLAG_NO_COMPAT | MODE_FLAG_NO_UPDATE, MENU_MIN_INACTIVE_FRAMES, APP_MODE_UPDATE_DELAY, NULL, NULL, &appGetTextId, NULL, &appInit, &appNeedsUpdate, &appUpdateItemList, &appGetItemCount, NULL, &appGetItemName, &appGetItemNameLength, &appGetItemStartup, &appDeleteItem, &appRenameItem, &appLaunchItem, - &appGetConfig, &appGetImage, &appCleanUp, &appShutdown, NULL, &appGetIconId}; + &appGetConfig, &appGetSize, &appGetImage, &appCleanUp, &appShutdown, NULL, &appGetIconId}; diff --git a/src/bdmsupport.c b/src/bdmsupport.c index 2fd42ddfb..4b3f55398 100644 --- a/src/bdmsupport.c +++ b/src/bdmsupport.c @@ -596,6 +596,12 @@ static config_set_t *bdmGetConfig(item_list_t *itemList, int id) return sbPopulateConfig(&pDeviceData->bdmGames[id], pDeviceData->bdmPrefix, "/"); } +static int bdmGetSize(item_list_t *itemList, int id) +{ + bdm_device_data_t *pDeviceData = (bdm_device_data_t *)itemList->priv; + return sbCalcGameSize(&pDeviceData->bdmGames[id], pDeviceData->bdmPrefix, "/"); +} + static int bdmGetImage(item_list_t *itemList, char *folder, int isRelative, char *value, char *suffix, GSTEXTURE *resultTex, short psm) { char path[256]; @@ -701,7 +707,7 @@ static char *bdmGetPrefix(item_list_t *itemList) static item_list_t bdmGameList = { BDM_MODE, 2, 0, 0, MENU_MIN_INACTIVE_FRAMES, BDM_MODE_UPDATE_DELAY, NULL, NULL, &bdmGetTextId, &bdmGetPrefix, &bdmInit, &bdmNeedsUpdate, &bdmUpdateGameList, &bdmGetGameCount, &bdmGetGame, &bdmGetGameName, &bdmGetGameNameLength, &bdmGetGameStartup, &bdmDeleteGame, &bdmRenameGame, - &bdmLaunchGame, &bdmGetConfig, &bdmGetImage, &bdmCleanUp, &bdmShutdown, &bdmCheckVMC, &bdmGetIconId}; + &bdmLaunchGame, &bdmGetConfig, &bdmGetSize, &bdmGetImage, &bdmCleanUp, &bdmShutdown, &bdmCheckVMC, &bdmGetIconId}; void bdmInitSemaphore() { diff --git a/src/ethsupport.c b/src/ethsupport.c index f0462fa42..24094678d 100644 --- a/src/ethsupport.c +++ b/src/ethsupport.c @@ -719,6 +719,11 @@ static config_set_t *ethGetConfig(item_list_t *itemList, int id) return sbPopulateConfig(ðGames[id], ethPrefix, "\\"); } +static int ethGetSize(item_list_t *itemList, int id) +{ + return sbCalcGameSize(ðGames[id], ethPrefix, "\\"); +} + static int ethGetImage(item_list_t *itemList, char *folder, int isRelative, char *value, char *suffix, GSTEXTURE *resultTex, short psm) { char path[256]; @@ -789,7 +794,7 @@ static char *ethGetPrefix(item_list_t *itemList) static item_list_t ethGameList = { ETH_MODE, 1, 0, 0, MENU_MIN_INACTIVE_FRAMES, ETH_MODE_UPDATE_DELAY, NULL, NULL, ðGetTextId, ðGetPrefix, ðInit, ðNeedsUpdate, ðUpdateGameList, ðGetGameCount, ðGetGame, ðGetGameName, ðGetGameNameLength, ðGetGameStartup, ðDeleteGame, ðRenameGame, - ðLaunchGame, ðGetConfig, ðGetImage, ðCleanUp, ðShutdown, ðCheckVMC, ðGetIconId}; + ðLaunchGame, ðGetConfig, ðGetSize, ðGetImage, ðCleanUp, ðShutdown, ðCheckVMC, ðGetIconId}; static int ethReadNetConfig(void) { diff --git a/src/hddsupport.c b/src/hddsupport.c index c9d47bff0..074ea2a66 100644 --- a/src/hddsupport.c +++ b/src/hddsupport.c @@ -650,6 +650,11 @@ static config_set_t *hddGetConfig(item_list_t *itemList, int id) return config; } +static int hddGetSize(item_list_t *itemList, int id) +{ + return 0; +} + static int hddGetImage(item_list_t *itemList, char *folder, int isRelative, char *value, char *suffix, GSTEXTURE *resultTex, short psm) { char path[256]; @@ -837,4 +842,4 @@ static char *hddGetPrefix(item_list_t *itemList) static item_list_t hddGameList = { HDD_MODE, 0, 0, MODE_FLAG_COMPAT_DMA, MENU_MIN_INACTIVE_FRAMES, HDD_MODE_UPDATE_DELAY, NULL, NULL, &hddGetTextId, &hddGetPrefix, &hddInit, &hddNeedsUpdate, &hddUpdateGameList, &hddGetGameCount, &hddGetGame, &hddGetGameName, &hddGetGameNameLength, &hddGetGameStartup, &hddDeleteGame, &hddRenameGame, - &hddLaunchGame, &hddGetConfig, &hddGetImage, &hddCleanUp, &hddShutdown, &hddCheckVMC, &hddGetIconId}; + &hddLaunchGame, &hddGetConfig, &hddGetSize, &hddGetImage, &hddCleanUp, &hddShutdown, &hddCheckVMC, &hddGetIconId}; diff --git a/src/opl.c b/src/opl.c index 3075da544..d3305879c 100644 --- a/src/opl.c +++ b/src/opl.c @@ -317,8 +317,13 @@ static void itemExecCircle(struct menu_item *curMenu) static void itemExecSquare(struct menu_item *curMenu) { - if (curMenu->current && gTheme->infoElems.first) + if (curMenu->current && gTheme->infoElems.first) { + item_list_t *support = curMenu->userdata; + if (support->itemGetSize(support, curMenu->current->item.id)) + menuLoadConfig(); + guiSwitchScreen(GUI_SCREEN_INFO); + } } static void itemExecTriangle(struct menu_item *curMenu) diff --git a/src/supportbase.c b/src/supportbase.c index 242f0a758..e9a13b35a 100644 --- a/src/supportbase.c +++ b/src/supportbase.c @@ -304,8 +304,6 @@ static int scanForISO(char *path, char type, struct game_list_t **glist) int cacheLoaded = loadISOGameListCache(path, &cache) == 0; if ((dir = opendir(path)) != NULL) { - //struct stat statbuf; - size_t base_path_len = strlen(path); strcpy(fullpath, path); fullpath[base_path_len] = '/'; @@ -363,12 +361,7 @@ static int scanForISO(char *path, char type, struct game_list_t **glist) game->parts = 1; game->media = type; game->format = format; - - - /*if (stat(fullpath, &statbuf) == 0) { - game->sizeMB = statbuf.st_size >> 20; - } else {*/ - game->sizeMB = 0; + game->sizeMB = 0; // Get size at cfg populate.. its only used for info page count++; } @@ -778,22 +771,6 @@ config_set_t *sbPopulateConfig(base_game_info_t *game, const char *prefix, const config_set_t *config = configAlloc(0, NULL, path); configRead(config); // Does not matter if the config file could be loaded or not. - char gamepath[256]; - // Get game size if not already set - if (game->sizeMB == 0) { - if (game->format == GAME_FORMAT_OLD_ISO) - snprintf(gamepath, sizeof(gamepath), "%s%s%s%s%s%s", prefix, sep, game->media == SCECdPS2CD ? "CD" : "DVD", sep, game->startup, game->extension); - else - snprintf(gamepath, sizeof(gamepath), "%s%s%s%s%s%s", prefix, sep, game->media == SCECdPS2CD ? "CD" : "DVD", sep, game->name, game->extension); - - if (stat(gamepath, &st) == 0) - game->sizeMB = st.st_size >> 20; - else - game->sizeMB = 0; - } - - LOG("GAMEPATH=%s\n", gamepath); - configSetStr(config, CONFIG_ITEM_NAME, game->name); configSetInt(config, CONFIG_ITEM_SIZE, game->sizeMB); @@ -811,6 +788,26 @@ config_set_t *sbPopulateConfig(base_game_info_t *game, const char *prefix, const return config; } +int sbCalcGameSize(base_game_info_t *game, const char *prefix, const char *sep) +{ + if ((game->sizeMB == 0) && (game->format != GAME_FORMAT_OLD_ISO)) { + char gamepath[256]; + struct stat st; + + snprintf(gamepath, sizeof(gamepath), "%s%s%s%s%s%s", prefix, sep, game->media == SCECdPS2CD ? "CD" : "DVD", sep, game->name, game->extension); + + if (stat(gamepath, &st) == 0) { + game->sizeMB = st.st_size >> 20; + return 1; + } else { + game->sizeMB = 0; + LOG("Failed to stat file: %s\n", gamepath); + } + } + + return 0; +} + static void sbCreateFoldersFromList(const char *path, const char **folders) { int i;