diff options
Diffstat (limited to 'gui')
-rw-r--r-- | gui/launcher.cpp | 32 | ||||
-rw-r--r-- | gui/launcher.h | 29 | ||||
-rw-r--r-- | gui/massadd.cpp | 3 | ||||
-rw-r--r-- | gui/massadd.h | 6 |
4 files changed, 52 insertions, 18 deletions
diff --git a/gui/launcher.cpp b/gui/launcher.cpp index 1ab4728072..28f00f84ff 100644 --- a/gui/launcher.cpp +++ b/gui/launcher.cpp @@ -538,7 +538,7 @@ LauncherDialog::LauncherDialog() // Restore last selection String last(ConfMan.get("lastselectedgame", ConfigManager::kApplicationDomain)); - selectGame(last); + selectTarget(last); // En-/disable the buttons depending on the list selection updateButtons(); @@ -550,12 +550,12 @@ LauncherDialog::LauncherDialog() _loadDialog = new SaveLoadChooser("Load game:", "Load"); } -void LauncherDialog::selectGame(const String &name) { - if (!name.empty()) { +void LauncherDialog::selectTarget(const String &target) { + if (!target.empty()) { int itemToSelect = 0; StringList::const_iterator iter; for (iter = _domains.begin(); iter != _domains.end(); ++iter, ++itemToSelect) { - if (name == *iter) { + if (target == *iter) { _list->setSelected(itemToSelect); break; } @@ -657,19 +657,17 @@ void LauncherDialog::addGame() { if (alert.runModal() == GUI::kMessageOK && _browser->runModal() > 0) { MassAddDialog massAddDlg(_browser->getResult()); - if (_list->getSelected() != -1) { - // Save current game position, so on cancel cursor will move back - ConfMan.set("temp_selection", _domains[_list->getSelected()], ConfigManager::kApplicationDomain); - } - massAddDlg.runModal(); // Update the ListWidget and force a redraw - updateListing(); - // Set cursor to first detected game - selectGame(ConfMan.get("temp_selection", ConfigManager::kApplicationDomain)); - ConfMan.removeKey("temp_selection", ConfigManager::kApplicationDomain); + // If new target(s) were added, update the ListWidget and move + // the selection to to first newly detected game. + Common::String newTarget = massAddDlg.getFirtAddedTarget(); + if (!newTarget.empty()) { + updateListing(); + selectTarget(newTarget); + } draw(); } @@ -750,7 +748,7 @@ void LauncherDialog::addGame() { // Update the ListWidget, select the new item, and force a redraw updateListing(); - selectGame(editDialog.getDomain()); + selectTarget(editDialog.getDomain()); draw(); } else { // User aborted, remove the the new domain again @@ -840,7 +838,7 @@ void LauncherDialog::editGame(int item) { // Update the ListWidget, reselect the edited game and force a redraw updateListing(); - selectGame(editDialog.getDomain()); + selectTarget(editDialog.getDomain()); draw(); } } @@ -923,7 +921,7 @@ void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat case kStartCmd: case kListItemActivatedCmd: case kListItemDoubleClickedCmd: - // Print out what was selected + // Start the selected game. assert(item >= 0); ConfMan.setActiveDomain(_domains[item]); close(); @@ -940,9 +938,11 @@ void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat close(); break; case kSearchCmd: + // Update the active search filter. _list->setFilter(_searchWidget->getEditString()); break; case kSearchClearCmd: + // Reset the active search filter, thus showing all games again _searchWidget->setEditString(""); _list->setFilter(""); break; diff --git a/gui/launcher.h b/gui/launcher.h index d482f26faf..ceb44d9e8e 100644 --- a/gui/launcher.h +++ b/gui/launcher.h @@ -72,17 +72,44 @@ protected: virtual void reflowLayout(); + /** + * Fill the list widget with all currently configured targets, and trigger + * a redraw. + */ void updateListing(); + void updateButtons(); void open(); void close(); + + /** + * Handle "Add game..." button. + */ virtual void addGame(); + + /** + * Handle "Remove game..." button. + */ void removeGame(int item); + + /** + * Handle "Edit game..." button. + */ void editGame(int item); + + /** + * Handle "Load..." button. + */ void loadGame(int item); - void selectGame(const String &name); + /** + * Select the target with the given name in the launcher game list. + * Also scrolls the list so that the newly selected item is visible. + * + * @target name of target to select + */ + void selectTarget(const String &target); }; } // End of namespace GUI diff --git a/gui/massadd.cpp b/gui/massadd.cpp index 57ac9fc01f..8a1206ee31 100644 --- a/gui/massadd.cpp +++ b/gui/massadd.cpp @@ -139,7 +139,7 @@ void MassAddDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data sort(_games.begin(), _games.end(), GameTargetLess()); // Add all the detected games to the config for (GameList::iterator iter = _games.begin(); iter != _games.end(); ++iter) { - printf(" Added gameid '%s', desc '%s'\n", + debug(1, " Added gameid '%s', desc '%s'\n", (*iter)["gameid"].c_str(), (*iter)["description"].c_str()); (*iter)["gameid"] = addGameToConf(*iter); @@ -157,6 +157,7 @@ void MassAddDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data close(); } else if (cmd == kCancelCmd) { // User cancelled, so we don't do anything and just leave. + _games.clear(); close(); } else { Dialog::handleCommand(sender, cmd, data); diff --git a/gui/massadd.h b/gui/massadd.h index 106b285a64..006972e642 100644 --- a/gui/massadd.h +++ b/gui/massadd.h @@ -44,6 +44,12 @@ public: void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); void handleTickle(); + Common::String getFirtAddedTarget() const { + if (!_games.empty()) + return _games.front().gameid(); + return Common::String(); + } + private: Common::Stack<Common::FSNode> _scanStack; GameList _games; |