Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add game client system directories to Game Settings window

  • Loading branch information...
commit b395ec1c75c81752f3ba55bbee097a5fbb284e0b 1 parent 80be090
@garbear authored
View
10 language/English/strings.po
@@ -6032,12 +6032,13 @@ msgid "Emulator setup"
msgstr ""
#: xbmc/games/GameClient.cpp
-#: xbmc/games/libretro/LibretroEnvironment.cpp
+#: xbmc/settings/windows/GUIWindowSettingsCategory.cpp
msgctxt "#15034"
msgid "External system directory"
msgstr ""
#: xbmc/games/libretro/LibretroEnvironment.cpp
+#: xbmc/settings/windows/GUIWindowSettingsCategory.cpp
msgctxt "#15035"
msgid "Choose system directory"
msgstr ""
@@ -6047,7 +6048,12 @@ msgctxt "#15036"
msgid "Skip and try game directory"
msgstr ""
-#empty strings from id 15037 to 15051
+#: xbmc/settings/windows/GUIWindowSettingsCategory.cpp
+msgctxt "#15037"
+msgid "Directories"
+msgstr ""
+
+#empty strings from id 15038 to 15051
msgctxt "#15052"
msgid "Password"
View
4 xbmc/games/libretro/LibretroEnvironment.cpp
@@ -234,8 +234,8 @@ bool CLibretroEnvironment::EnvironmentCallback(unsigned int cmd, void *data)
// Always append local drives
g_mediaManager.GetLocalDrives(shares);
- // "External system directory"
- if (CGUIDialogFileBrowser::ShowAndGetDirectory(shares, g_localizeStrings.Get(15034), m_systemDirectory))
+ // "Choose system directory"
+ if (CGUIDialogFileBrowser::ShowAndGetDirectory(shares, g_localizeStrings.Get(15035), m_systemDirectory))
m_activeClient->UpdateSetting("systemdirectory", m_systemDirectory);
else
m_bAbort = true;
View
3  xbmc/settings/GUISettings.cpp
@@ -1037,11 +1037,14 @@ void CGUISettings::Initialize()
AddBool(gamesGen, "games.autosave", 15025, true); // Save game state every 30 seconds
AddSeparator(gamesGen, "games.sep1");
AddString(gamesGen, "games.manageaddons", 24025, "", BUTTON_CONTROL_STANDARD); // Manage emulators...
+
CSettingsCategory* gamesDebug = AddCategory(SETTINGS_GAMES, "gamesdebug", 14092); // Debugging
AddBool(gamesDebug, "gamesdebug.prefervfs", 15018, true); // Prefer loading files from memory (debug)
// Some emulators crash when loading .zip files. If the emulator allows XBMC to
// load from memory (VFS), XBMC can still safely load games from within zips.
AddBool(gamesDebug, "gamesdebug.allowzip", 15020, true); // Allow emulators to load .zip files (debug)
+
+ // The "Directories" category is populated dynamically in CGUIWindowSettingsCategory
}
CGUISettings::~CGUISettings(void)
View
93 xbmc/settings/windows/GUIWindowSettingsCategory.cpp
@@ -119,6 +119,8 @@ using namespace ADDON;
using namespace PVR;
using namespace PERIPHERALS;
+#define SETTINGS_GAMES WINDOW_SETTINGS_MYGAMES - WINDOW_SETTINGS_START
+
#define CONTROL_GROUP_BUTTONS 0
#define CONTROL_GROUP_SETTINGS 1
#define CONTROL_SETTINGS_LABEL 2
@@ -320,6 +322,11 @@ void CGUIWindowSettingsCategory::SetupControls()
// get a list of different sections
CSettingsGroup *pSettingsGroup = g_guiSettings.GetGroup(m_iScreen);
if (!pSettingsGroup) return ;
+
+ // If we are on the Game Settings window, add the Directories tab
+ if (m_iScreen == SETTINGS_GAMES)
+ FillInGameDirs(pSettingsGroup);
+
// update the screen string
SET_CONTROL_LABEL(CONTROL_SETTINGS_LABEL, pSettingsGroup->GetLabelID());
// get the categories we need
@@ -1011,6 +1018,28 @@ void CGUIWindowSettingsCategory::UpdateSettings()
if (pControl)
pControl->SetEnabled(g_guiSettings.GetBool("games.enablerewind"));
}
+ else if (strSetting.Left(14) == "gamesdir.name.")
+ {
+ // A label wasn't provided on setting creation
+ // Fill in the label with add-on name now
+ CGUIControl *cpControl = const_cast<CGUIControl*>(GetControl(pSettingControl->GetID()));
+ CGUIButtonControl *pControl = dynamic_cast<CGUIButtonControl*>(cpControl);
+ if (pControl && pControl->GetLabel().empty())
+ {
+ CStdString gameClientId = strSetting.substr(14); // ID follows
+ AddonPtr gameClient;
+ if (CAddonMgr::Get().GetAddon(gameClientId, gameClient))
+ pControl->SetLabel(gameClient->Name());
+ }
+ }
+ else if (strSetting.Left(13) == "gamesdir.dir.")
+ {
+ // Minor cosmetic, prefix the system directory selection label with a " - "
+ CGUIControl *cpControl = const_cast<CGUIControl*>(GetControl(pSettingControl->GetID()));
+ CGUIButtonControl *pControl = dynamic_cast<CGUIButtonControl*>(cpControl);
+ if (pControl && pControl->GetLabel().Left(3) != " - ")
+ pControl->SetLabel(" - " + pControl->GetLabel());
+ }
}
g_guiSettings.SetChanged();
@@ -1967,6 +1996,33 @@ void CGUIWindowSettingsCategory::OnSettingChanged(BaseSettingControlPtr pSetting
params.push_back("addons://all/xbmc.gameclient");
g_windowManager.ActivateWindow(WINDOW_ADDON_BROWSER, params);
}
+ else if (strSetting.Left(13) == "gamesdir.dir.")
+ {
+ CSettingString *pSettingString = (CSettingString*)pSettingControl->GetSetting();
+ //CStdString path = g_guiSettings.GetString(strSetting, false);
+ CStdString gameClientId = strSetting.substr(13); // ID follows
+ AddonPtr gameClient;
+ if (CAddonMgr::Get().GetAddon(gameClientId, gameClient))
+ {
+ // Setup the shares, system files might be located with game files so start there
+ VECSOURCES shares;
+ VECSOURCES *pGameShares = g_settings.GetSourcesFromType("games");
+ if (pGameShares)
+ shares = *pGameShares;
+
+ // Always append local drives
+ g_mediaManager.GetLocalDrives(shares);
+
+ CStdString strDir = gameClient->GetSetting("systemdirectory");
+ // "External system directory"
+ if (CGUIDialogFileBrowser::ShowAndGetDirectory(shares, g_localizeStrings.Get(pSettingString->m_iHeadingString), strDir))
+ {
+ pSettingString->SetData(strDir);
+ gameClient->UpdateSetting("systemdirectory", strDir);
+ gameClient->SaveSettings();
+ }
+ }
+ }
UpdateSettings();
}
@@ -2892,6 +2948,43 @@ void CGUIWindowSettingsCategory::FillInAudioDevices(CSetting* pSetting, bool Pas
pControl->SetValue(selectedValue);
}
+void CGUIWindowSettingsCategory::FillInGameDirs(CSettingsGroup *pSettingsGroup)
+{
+ CSettingsCategory *gamesdir = pSettingsGroup->AddCategory("gamesdir", 15037); // Directories
+ if (!gamesdir)
+ return;
+
+ int i = 0; // Setting order
+ VECADDONS gameclients;
+ CAddonMgr::Get().GetAddons(ADDON_GAMEDLL, gameclients);
+ for (VECADDONS::const_iterator it = gameclients.begin(); it != gameclients.end(); it++)
+ {
+ if ((*it)->GetSetting("showingamesettings") != "true")
+ continue;
+
+ CStdString id = (*it)->ID();
+ CStdString dir = (*it)->GetSetting("systemdirectory");
+
+ if (i != 0)
+ {
+ CSetting *sep = new CSettingSeparator(i++, "gamesdir.sep." + id);
+ if (sep)
+ gamesdir->m_settings.push_back(sep);
+ }
+
+ // Use -1 here, label is generated by extracting id from setting name in UpdateSettings()
+ CSetting *name = new CSettingString(i++, "gamesdir.name." + id, -1, "", BUTTON_CONTROL_STANDARD, false, -1);
+ if (name)
+ gamesdir->m_settings.push_back(name);
+
+ // 15034: "External system directory"
+ // 15035: "Choose system directory"
+ CSetting *path = new CSettingPath(i++, "gamesdir.dir." + id, 15034, dir.c_str(), BUTTON_CONTROL_PATH_INPUT, true, 15035);
+ if (path)
+ gamesdir->m_settings.push_back(path);
+ }
+}
+
void CGUIWindowSettingsCategory::NetworkInterfaceChanged(void)
{
#if 0
View
2  xbmc/settings/windows/GUIWindowSettingsCategory.h
@@ -69,6 +69,8 @@ class CGUIWindowSettingsCategory :
void FillInAudioDevices(CSetting* pSetting, bool Passthrough = false);
+ void FillInGameDirs(CSettingsGroup *pSettingsGroup);
+
virtual void SetupControls();
CGUIControl* AddIntBasedSpinControl(CSetting *pSetting, float groupWidth, int &iControlID);
void CreateSettings();
Please sign in to comment.
Something went wrong with that request. Please try again.