(RARCH_CONSOLE) Some refactorings to reduce dependencies on

g_console being there
This commit is contained in:
Twinaphex 2012-07-28 19:17:34 +02:00
parent 383be7bd29
commit fb85f5950e
7 changed files with 17 additions and 15 deletions

View File

@ -551,7 +551,7 @@ HRESULT CRetroArchFileBrowser::OnNotifyPress( HXUIOBJ hObjPressed, BOOL& bHandle
if(path_file_exists(browser->current_dir.list->elems[index].data))
{
snprintf(path, sizeof(path), "%s\\%s", filebrowser_get_current_dir(browser), strbuffer);
rarch_console_load_game_wrap(path, S_DELAY_45);
rarch_console_load_game_wrap(path, g_console.zip_extract_mode, S_DELAY_45);
}
else if(browser->current_dir.list->elems[index].attr.b)
{

View File

@ -38,7 +38,7 @@ static void rarch_console_load_game(const char *path)
rarch_settings_change(S_START_RARCH);
}
void rarch_console_load_game_wrap(const char *path, unsigned delay)
void rarch_console_load_game_wrap(const char *path, unsigned extract_zip_mode, unsigned delay)
{
const char *game_to_load;
#ifdef HAVE_ZLIB
@ -65,7 +65,12 @@ void rarch_console_load_game_wrap(const char *path, unsigned delay)
if(extract_zip_cond)
{
rarch_extract_directory(dir_path_temp, rom_path_temp, sizeof(dir_path_temp));
rarch_extract_zipfile(rom_path_temp, dir_path_temp, first_file, sizeof(first_file));
rarch_extract_zipfile(rom_path_temp, dir_path_temp, first_file, sizeof(first_file), extract_zip_mode);
#ifndef GEKKO
if(g_console.info_msg_enable)
#endif
rarch_settings_msg(S_MSG_EXTRACTED_ZIPFILE, S_DELAY_180);
}
#endif
@ -90,7 +95,7 @@ void rarch_console_load_game_wrap(const char *path, unsigned delay)
rarch_console_load_game(game_to_load);
#ifndef GEKKO
if (g_console.info_msg_enable)
if(g_console.info_msg_enable)
#endif
rarch_settings_msg(S_MSG_LOADING_ROM, delay);
}

View File

@ -17,7 +17,7 @@
#ifndef RARCH_ROM_EXT_H__
#define RARCH_ROM_EXT_H__
void rarch_console_load_game_wrap(const char *path, unsigned delay);
void rarch_console_load_game_wrap(const char *path, unsigned extract_zip_mode, unsigned delay);
// Get rom extensions for current library.
// Returns NULL if library doesn't have any preferences in particular.

View File

@ -26,7 +26,7 @@
#include "rarch_console_rzlib.h"
static int rarch_extract_currentfile_in_zip(unzFile uf, const char *current_dir, char *slash, char *write_filename, size_t write_filename_size)
static int rarch_extract_currentfile_in_zip(unzFile uf, const char *current_dir, char *slash, char *write_filename, size_t write_filename_size, unsigned extract_zip_mode)
{
char filename_inzip[PATH_MAX];
FILE *file_out = NULL;
@ -50,7 +50,7 @@ static int rarch_extract_currentfile_in_zip(unzFile uf, const char *current_dir,
return UNZ_INTERNALERROR;
}
switch(g_console.zip_extract_mode)
switch(extract_zip_mode)
{
case ZIP_EXTRACT_TO_CURRENT_DIR:
case ZIP_EXTRACT_TO_CURRENT_DIR_AND_LOAD_FIRST_FILE:
@ -116,7 +116,7 @@ static int rarch_extract_currentfile_in_zip(unzFile uf, const char *current_dir,
return err;
}
int rarch_extract_zipfile(const char *zip_path, const char *current_dir, char *first_file, size_t first_file_size)
int rarch_extract_zipfile(const char *zip_path, const char *current_dir, char *first_file, size_t first_file_size, unsigned extract_zip_mode)
{
bool found_first_file = false;
(void)found_first_file;
@ -136,7 +136,7 @@ int rarch_extract_zipfile(const char *zip_path, const char *current_dir, char *f
#else
snprintf(slash, sizeof(slash), "/");
#endif
if (rarch_extract_currentfile_in_zip(uf, current_dir, slash, write_filename, sizeof(write_filename)) != UNZ_OK)
if (rarch_extract_currentfile_in_zip(uf, current_dir, slash, write_filename, sizeof(write_filename), extract_zip_mode) != UNZ_OK)
{
RARCH_ERR("Failed to extract current file from ZIP archive.\n");
break;
@ -165,8 +165,5 @@ int rarch_extract_zipfile(const char *zip_path, const char *current_dir, char *f
}
}
if(g_console.info_msg_enable)
rarch_settings_msg(S_MSG_EXTRACTED_ZIPFILE, S_DELAY_180);
return 0;
}

View File

@ -28,6 +28,6 @@ enum
ZIP_EXTRACT_TO_CACHE_DIR
};
int rarch_extract_zipfile(const char *zip_path, const char *current_dir, char *first_file, size_t first_file_size);
int rarch_extract_zipfile(const char *zip_path, const char *current_dir, char *first_file, size_t first_file_size, unsigned extract_zip_mode);
#endif

View File

@ -1710,7 +1710,7 @@ static void menu_romselect_iterate(filebrowser_t *filebrowser, menu_romselect_ac
filebrowser_iterate(filebrowser, FILEBROWSER_ACTION_OK);
}
else
rarch_console_load_game_wrap(filebrowser_get_current_path(filebrowser), S_DELAY_45);
rarch_console_load_game_wrap(filebrowser_get_current_path(filebrowser), g_console.zip_extract_mode, S_DELAY_45);
break;
case MENU_ROMSELECT_ACTION_GOTO_SETTINGS:
menu_stack_increment();

View File

@ -633,7 +633,7 @@ const char *rgui_iterate(rgui_handle_t *rgui, rgui_action_t action)
else
{
snprintf(rgui->path_buf, sizeof(rgui->path_buf), "%s/%s", dir, path);
rarch_console_load_game_wrap(rgui->path_buf, S_DELAY_1);
rarch_console_load_game_wrap(rgui->path_buf, g_console.zip_extract_mode, S_DELAY_1);
found = true;
}
break;