From 9c27995a5086fbfeb9337551b0705619a3e2b375 Mon Sep 17 00:00:00 2001 From: "fix94.1" Date: Thu, 30 May 2013 17:35:03 +0000 Subject: [PATCH] -added a new plugin argument, {name_no_ext}, it will get replaced by the filename, just without its extension (issue 186) --- source/menu/menu_game.cpp | 5 ++++- source/plugin/plugin.cpp | 6 ++++-- source/plugin/plugin.hpp | 3 ++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/source/menu/menu_game.cpp b/source/menu/menu_game.cpp index 75063ac2..76c29fc8 100644 --- a/source/menu/menu_game.cpp +++ b/source/menu/menu_game.cpp @@ -823,6 +823,7 @@ void CMenu::_launch(const dir_discHdr *hdr) u8 plugin_dol_len = strlen(plugin_dol_name); char title[101]; memset(&title, 0, sizeof(title)); + u32 title_len_no_ext = 0; const char *path = NULL; if(strchr(launchHdr.path, ':') != NULL) { @@ -833,6 +834,8 @@ void CMenu::_launch(const dir_discHdr *hdr) return; } strncpy(title, strrchr(launchHdr.path, '/') + 1, 100); + if(strchr(launchHdr.path, '.') != NULL) + title_len_no_ext = strlen(title) - strlen(strrchr(title, '.')); *strrchr(launchHdr.path, '/') = '\0'; path = strchr(launchHdr.path, '/') + 1; } @@ -845,7 +848,7 @@ void CMenu::_launch(const dir_discHdr *hdr) const char *device = (currentPartition == 0 ? "sd" : (DeviceHandle.GetFSType(currentPartition) == PART_FS_NTFS ? "ntfs" : "usb")); const char *loader = fmt("%s:/%s/WiiFlowLoader.dol", device, strchr(m_pluginsDir.c_str(), '/') + 1); - vector arguments = m_plugin.CreateArgs(device, path, title, loader, launchHdr.settings[0]); + vector arguments = m_plugin.CreateArgs(device, path, title, loader, title_len_no_ext, launchHdr.settings[0]); const char *plugin_file = plugin_dol_name; /* try full path */ if(strchr(plugin_file, ':') == NULL || !fsop_FileExist(plugin_file)) /* try universal plugin folder */ { diff --git a/source/plugin/plugin.cpp b/source/plugin/plugin.cpp index 155bbd02..a79f4f52 100644 --- a/source/plugin/plugin.cpp +++ b/source/plugin/plugin.cpp @@ -225,8 +225,8 @@ vector Plugin::ParseScummvmINI(Config &ini, const char *Device, u32 return gameHeader; } -vector Plugin::CreateArgs(const char *device, const char *path, - const char *title, const char *loader, u32 magic) +vector Plugin::CreateArgs(const char *device, const char *path, + const char *title, const char *loader, u32 title_len_no_ext, u32 magic) { vector args; Plugin_Pos = GetPluginPosition(magic); @@ -244,6 +244,8 @@ vector Plugin::CreateArgs(const char *device, const char *path, Argument.replace(Argument.find(PLUGIN_NAME), strlen(PLUGIN_NAME), title); if(Argument.find(PLUGIN_LDR) != string::npos) Argument.replace(Argument.find(PLUGIN_LDR), strlen(PLUGIN_LDR), loader); + if(Argument.find(PLUGIN_NOEXT) != string::npos) + Argument.replace(Argument.find(PLUGIN_NOEXT), strlen(PLUGIN_NOEXT), title, title_len_no_ext); args.push_back(Argument); } return args; diff --git a/source/plugin/plugin.hpp b/source/plugin/plugin.hpp index 3ff3e526..78590716 100644 --- a/source/plugin/plugin.hpp +++ b/source/plugin/plugin.hpp @@ -35,6 +35,7 @@ using namespace std; #define PLUGIN_DEV "{device}" #define PLUGIN_PATH "{path}" #define PLUGIN_NAME "{name}" +#define PLUGIN_NOEXT "{name_no_ext}" #define PLUGIN_LDR "{loader}" struct PluginOptions @@ -65,7 +66,7 @@ public: void SetEnablePlugin(Config &cfg, u8 pos, u8 ForceMode = 0); const vector &GetEnabledPlugins(Config &cfg); vector CreateArgs(const char *device, const char *path, - const char *title, const char *loader, u32 magic); + const char *title, const char *loader, u32 title_len_no_ext, u32 magic); void init(const string& m_pluginsDir); void Cleanup(); void EndAdd();