From 5031159126eb56175756ba8b74686a44066a13ff Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 3 Jul 2015 00:16:46 +0200 Subject: [PATCH] Refactors --- command_event.c | 24 ++++++++++++++++-------- config.features.h | 6 ------ intl/english.h | 2 -- intl/msg_hash_us.c | 6 ++++++ msg_hash.h | 5 +++++ retroarch.c | 28 ++++++++++++++++------------ system.c | 6 +++--- 7 files changed, 46 insertions(+), 31 deletions(-) diff --git a/command_event.c b/command_event.c index 7c65030799..6516789a6e 100644 --- a/command_event.c +++ b/command_event.c @@ -24,7 +24,6 @@ #include "dynamic.h" #include "content.h" #include "screenshot.h" -#include "intl/intl.h" #include "msg_hash.h" #include "retroarch.h" #include "dir_list_special.h" @@ -910,7 +909,9 @@ static void event_save_state(const char *path, if (!save_state(path)) { - snprintf(s, len, "Failed to save state to \"%s\".", path); + snprintf(s, len, "%s \"%s\".", + msg_hash_to_str(MSG_FAILED_TO_SAVE_STATE_TO), + path); return; } @@ -1336,7 +1337,9 @@ bool event_command(enum event_command cmd) event_command(EVENT_CMD_HISTORY_DEINIT); if (!settings->history_list_enable) return false; - RARCH_LOG("Loading history file: [%s].\n", settings->content_history_path); + RARCH_LOG("%s: [%s].\n", + msg_hash_to_str(MSG_LOADING_HISTORY_FILE), + settings->content_history_path); g_defaults.history = content_playlist_init( settings->content_history_path, settings->content_history_size); @@ -1505,7 +1508,8 @@ bool event_command(enum event_command cmd) dir_list_sort(global->shader_dir.list, false); for (i = 0; i < global->shader_dir.list->size; i++) - RARCH_LOG("Found shader \"%s\"\n", + RARCH_LOG("%s \"%s\"\n", + msg_hash_to_str(MSG_FOUND_SHADER), global->shader_dir.list->elems[i].data); break; case EVENT_CMD_SAVEFILES: @@ -1527,7 +1531,8 @@ bool event_command(enum event_command cmd) ; if (!global->use_sram) - RARCH_LOG("SRAM will not be saved.\n"); + RARCH_LOG("%s\n", + msg_hash_to_str(MSG_SRAM_WILL_NOT_BE_SAVED)); if (global->use_sram) event_command(EVENT_CMD_AUTOSAVE_INIT); @@ -1642,7 +1647,8 @@ bool event_command(enum event_command cmd) event_check_disk_eject(control); } else - rarch_main_msg_queue_push_new(MSG_CORE_DOES_NOT_SUPPORT_DISK_OPTIONS, + rarch_main_msg_queue_push_new( + MSG_CORE_DOES_NOT_SUPPORT_DISK_OPTIONS, 1, 120, true); break; case EVENT_CMD_DISK_NEXT: @@ -1661,7 +1667,8 @@ bool event_command(enum event_command cmd) event_check_disk_next(control); } else - rarch_main_msg_queue_push_new(MSG_CORE_DOES_NOT_SUPPORT_DISK_OPTIONS, + rarch_main_msg_queue_push_new( + MSG_CORE_DOES_NOT_SUPPORT_DISK_OPTIONS, 1, 120, true); break; case EVENT_CMD_DISK_PREV: @@ -1680,7 +1687,8 @@ bool event_command(enum event_command cmd) event_check_disk_prev(control); } else - rarch_main_msg_queue_push_new(MSG_CORE_DOES_NOT_SUPPORT_DISK_OPTIONS, + rarch_main_msg_queue_push_new( + MSG_CORE_DOES_NOT_SUPPORT_DISK_OPTIONS, 1, 120, true); break; case EVENT_CMD_RUMBLE_STOP: diff --git a/config.features.h b/config.features.h index 140833311f..4596c480b2 100644 --- a/config.features.h +++ b/config.features.h @@ -304,10 +304,4 @@ static const bool _avfoundation_supp = false; #endif #endif -#ifdef _WIN32 -#define RARCH_DEFAULT_CONF_PATH_STR "\n\t\tDefaults to retroarch.cfg in same directory as retroarch.exe.\n\t\tIf a default config is not found, " RETRO_FRONTEND " will attempt to create one." -#else -#define RARCH_DEFAULT_CONF_PATH_STR "\n\t\tBy default looks for config in $XDG_CONFIG_HOME/retroarch/retroarch.cfg,\n\t\t$HOME/.config/retroarch/retroarch.cfg,\n\t\tand $HOME/.retroarch.cfg.\n\t\tIf a default config is not found, " RETRO_FRONTEND " will attempt to create one based on the skeleton config (" GLOBAL_CONFIG_DIR "/retroarch.cfg)." -#endif - #endif diff --git a/intl/english.h b/intl/english.h index 1278c19b2b..0c06806af2 100644 --- a/intl/english.h +++ b/intl/english.h @@ -17,8 +17,6 @@ #ifndef __INTL_ENGLISH_H #define __INTL_ENGLISH_H -#define RETRO_FRONTEND "RetroArch" - #define RETRO_LBL_JOYPAD_B "RetroPad B Button" #define RETRO_LBL_JOYPAD_Y "RetroPad Y Button" #define RETRO_LBL_JOYPAD_SELECT "RetroPad Select Button" diff --git a/intl/msg_hash_us.c b/intl/msg_hash_us.c index 20b0feb3f2..7fe45b3391 100644 --- a/intl/msg_hash_us.c +++ b/intl/msg_hash_us.c @@ -20,6 +20,8 @@ const char *msg_hash_to_str_us(uint32_t hash) { switch (hash) { + case MSG_PROGRAM: + return "RetroArch"; case MSG_MOVIE_RECORD_STOPPED: return "Stopping movie record."; case MSG_MOVIE_PLAYBACK_ENDED: @@ -118,6 +120,10 @@ const char *msg_hash_to_str_us(uint32_t hash) return "Failed to save SRAM"; case MSG_STATE_SIZE: return "State size"; + case MSG_FOUND_SHADER: + return "Found shader"; + case MSG_SRAM_WILL_NOT_BE_SAVED: + return "SRAM will not be saved."; case MSG_BLOCKING_SRAM_OVERWRITE: return "Blocking SRAM Overwrite"; case MSG_CORE_DOES_NOT_SUPPORT_SAVESTATES: diff --git a/msg_hash.h b/msg_hash.h index cea1706008..8f0ea738d8 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -22,6 +22,11 @@ #include #define MSG_UNKNOWN 0x3a834e55U +#define MSG_PROGRAM 0xc339565dU +#define MSG_FOUND_SHADER 0x817f42b7U + +#define MSG_LOADING_HISTORY_FILE 0x865210d3U +#define MSG_SRAM_WILL_NOT_BE_SAVED 0x16f17d61U #define MSG_RECEIVED 0xfe0c06acU diff --git a/retroarch.c b/retroarch.c index eb1054b84e..3d51b58326 100644 --- a/retroarch.c +++ b/retroarch.c @@ -49,7 +49,6 @@ #include "system.h" #include "git_version.h" -#include "intl/intl.h" #ifdef HAVE_MENU #include "menu/menu.h" @@ -146,10 +145,9 @@ static void print_version(void) { char str[PATH_MAX_LENGTH] = {0}; + fprintf(stderr, "%s: Frontend for libretro -- v%s", msg_hash_to_str(MSG_PROGRAM), PACKAGE_VERSION); #ifdef HAVE_GIT_VERSION - printf(RETRO_FRONTEND ": Frontend for libretro -- v" PACKAGE_VERSION " -- %s --\n", rarch_git_version); -#else - puts(RETRO_FRONTEND ": Frontend for libretro -- v" PACKAGE_VERSION " --"); + printf(" -- %s --\n", rarch_git_version); #endif rarch_info_get_capabilities(RARCH_CAPABILITIES_COMPILER, str, sizeof(str)); fprintf(stdout, "%s", str); @@ -171,16 +169,22 @@ static void print_help(const char *arg0) puts(" -h, --help Show this help message."); puts(" -v, --verbose Verbose logging."); - puts(" --log-file=FILE Log " RETRO_FRONTEND " messages to FILE."); - puts(" --version Show " RETRO_FRONTEND " version."); - puts(" --features Prints available features compiled into " RETRO_FRONTEND "."); + puts(" --log-file=FILE Log messages to FILE."); + puts(" --version Show version."); + puts(" --features Prints available features compiled into program."); puts(" --menu Do not require content or libretro core to be loaded,\n" " starts directly in menu. If no arguments are passed to\n" - " " RETRO_FRONTEND ", it is equivalent to using --menu as only argument."); + " the program, it is equivalent to using --menu as only argument."); puts(" -s, --save=PATH Path for save files (*.srm)."); puts(" -S, --savestate=PATH Path for the save state files (*.state)."); - puts(" -f, --fullscreen Start " RETRO_FRONTEND " in fullscreen regardless of config settings."); - puts(" -c, --config=FILE Path for config file." RARCH_DEFAULT_CONF_PATH_STR); + puts(" -f, --fullscreen Start the program in fullscreen regardless of config settings."); + puts(" -c, --config=FILE Path for config file." +#ifdef _WIN32 + "\n\t\tDefaults to retroarch.cfg in same directory as retroarch.exe.\n\t\tIf a default config is not found, the program will attempt to create one." +#else + "\n\t\tBy default looks for config in $XDG_CONFIG_HOME/retroarch/retroarch.cfg,\n\t\t$HOME/.config/retroarch/retroarch.cfg,\n\t\tand $HOME/.retroarch.cfg.\n\t\tIf a default config is not found, the program will attempt to create one based on the skeleton config (" GLOBAL_CONFIG_DIR "/retroarch.cfg)." +#endif + ); puts(" --appendconfig=FILE\n" " Extra config files are loaded in, and take priority over\n" " config selected in -c (or default). Multiple configs are\n" @@ -219,7 +223,7 @@ static void print_help(const char *arg0) #endif puts(" --nick=NICK Picks a username (for use with netplay). Not mandatory."); #if defined(HAVE_NETWORK_CMD) && defined(HAVE_NETPLAY) - puts(" --command Sends a command over UDP to an already running " RETRO_FRONTEND " process."); + puts(" --command Sends a command over UDP to an already running program process."); puts(" Available commands are listed if command is invalid."); #endif @@ -231,7 +235,7 @@ static void print_help(const char *arg0) puts(" --bps=FILE Specifies path for BPS patch that will be applied to content."); puts(" --ips=FILE Specifies path for IPS patch that will be applied to content."); puts(" --no-patch Disables all forms of content patching."); - puts(" -D, --detach Detach " RETRO_FRONTEND " from the running console. Not relevant for all platforms."); + puts(" -D, --detach Detach program from the running console. Not relevant for all platforms."); puts(" --max-frames=NUMBER\n" " Runs for the specified number of frames, then exits.\n"); } diff --git a/system.c b/system.c index a62f811758..0c09d93973 100644 --- a/system.c +++ b/system.c @@ -18,7 +18,6 @@ #include "system.h" #include "dynamic.h" #include "msg_hash.h" -#include "intl/intl.h" #ifdef HAVE_ZLIB #define DEFAULT_EXT "zip" @@ -75,8 +74,9 @@ void rarch_system_info_init(void) system->info.library_version = "v0"; #ifndef RARCH_CONSOLE - snprintf(system->title_buf, sizeof(system->title_buf), - RETRO_FRONTEND " : "); + strlcpy(system->title_buf, + msg_hash_to_str(MSG_PROGRAM), sizeof(system->title_buf)); + strlcat(system->title_buf, " : ", sizeof(system->title_buf)); #endif strlcat(system->title_buf, system->info.library_name, sizeof(system->title_buf)); strlcat(system->title_buf, " ", sizeof(system->title_buf));