GUI: Fix some GUI hacks, add some comments, etc.
* Rename LauncherDialog::selectGame() to selectTarget() * Get rid of the 'temp_selection' ConfMan entry hack * Add some Doxygen comments * Turn a printf(...) into a debug(1,...) * Don't scroll around if 'Mass Add' is cancelled svn-id: r46380
This commit is contained in:
parent
f692015301
commit
605037342b
4 changed files with 52 additions and 18 deletions
|
@ -538,7 +538,7 @@ LauncherDialog::LauncherDialog()
|
||||||
|
|
||||||
// Restore last selection
|
// Restore last selection
|
||||||
String last(ConfMan.get("lastselectedgame", ConfigManager::kApplicationDomain));
|
String last(ConfMan.get("lastselectedgame", ConfigManager::kApplicationDomain));
|
||||||
selectGame(last);
|
selectTarget(last);
|
||||||
|
|
||||||
// En-/disable the buttons depending on the list selection
|
// En-/disable the buttons depending on the list selection
|
||||||
updateButtons();
|
updateButtons();
|
||||||
|
@ -550,12 +550,12 @@ LauncherDialog::LauncherDialog()
|
||||||
_loadDialog = new SaveLoadChooser("Load game:", "Load");
|
_loadDialog = new SaveLoadChooser("Load game:", "Load");
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherDialog::selectGame(const String &name) {
|
void LauncherDialog::selectTarget(const String &target) {
|
||||||
if (!name.empty()) {
|
if (!target.empty()) {
|
||||||
int itemToSelect = 0;
|
int itemToSelect = 0;
|
||||||
StringList::const_iterator iter;
|
StringList::const_iterator iter;
|
||||||
for (iter = _domains.begin(); iter != _domains.end(); ++iter, ++itemToSelect) {
|
for (iter = _domains.begin(); iter != _domains.end(); ++iter, ++itemToSelect) {
|
||||||
if (name == *iter) {
|
if (target == *iter) {
|
||||||
_list->setSelected(itemToSelect);
|
_list->setSelected(itemToSelect);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -657,19 +657,17 @@ void LauncherDialog::addGame() {
|
||||||
if (alert.runModal() == GUI::kMessageOK && _browser->runModal() > 0) {
|
if (alert.runModal() == GUI::kMessageOK && _browser->runModal() > 0) {
|
||||||
MassAddDialog massAddDlg(_browser->getResult());
|
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();
|
massAddDlg.runModal();
|
||||||
|
|
||||||
// Update the ListWidget and force a redraw
|
// Update the ListWidget and force a redraw
|
||||||
updateListing();
|
|
||||||
|
|
||||||
// Set cursor to first detected game
|
// If new target(s) were added, update the ListWidget and move
|
||||||
selectGame(ConfMan.get("temp_selection", ConfigManager::kApplicationDomain));
|
// the selection to to first newly detected game.
|
||||||
ConfMan.removeKey("temp_selection", ConfigManager::kApplicationDomain);
|
Common::String newTarget = massAddDlg.getFirtAddedTarget();
|
||||||
|
if (!newTarget.empty()) {
|
||||||
|
updateListing();
|
||||||
|
selectTarget(newTarget);
|
||||||
|
}
|
||||||
|
|
||||||
draw();
|
draw();
|
||||||
}
|
}
|
||||||
|
@ -750,7 +748,7 @@ void LauncherDialog::addGame() {
|
||||||
|
|
||||||
// Update the ListWidget, select the new item, and force a redraw
|
// Update the ListWidget, select the new item, and force a redraw
|
||||||
updateListing();
|
updateListing();
|
||||||
selectGame(editDialog.getDomain());
|
selectTarget(editDialog.getDomain());
|
||||||
draw();
|
draw();
|
||||||
} else {
|
} else {
|
||||||
// User aborted, remove the the new domain again
|
// 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
|
// Update the ListWidget, reselect the edited game and force a redraw
|
||||||
updateListing();
|
updateListing();
|
||||||
selectGame(editDialog.getDomain());
|
selectTarget(editDialog.getDomain());
|
||||||
draw();
|
draw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -923,7 +921,7 @@ void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
|
||||||
case kStartCmd:
|
case kStartCmd:
|
||||||
case kListItemActivatedCmd:
|
case kListItemActivatedCmd:
|
||||||
case kListItemDoubleClickedCmd:
|
case kListItemDoubleClickedCmd:
|
||||||
// Print out what was selected
|
// Start the selected game.
|
||||||
assert(item >= 0);
|
assert(item >= 0);
|
||||||
ConfMan.setActiveDomain(_domains[item]);
|
ConfMan.setActiveDomain(_domains[item]);
|
||||||
close();
|
close();
|
||||||
|
@ -940,9 +938,11 @@ void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
|
||||||
close();
|
close();
|
||||||
break;
|
break;
|
||||||
case kSearchCmd:
|
case kSearchCmd:
|
||||||
|
// Update the active search filter.
|
||||||
_list->setFilter(_searchWidget->getEditString());
|
_list->setFilter(_searchWidget->getEditString());
|
||||||
break;
|
break;
|
||||||
case kSearchClearCmd:
|
case kSearchClearCmd:
|
||||||
|
// Reset the active search filter, thus showing all games again
|
||||||
_searchWidget->setEditString("");
|
_searchWidget->setEditString("");
|
||||||
_list->setFilter("");
|
_list->setFilter("");
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -72,17 +72,44 @@ protected:
|
||||||
|
|
||||||
virtual void reflowLayout();
|
virtual void reflowLayout();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fill the list widget with all currently configured targets, and trigger
|
||||||
|
* a redraw.
|
||||||
|
*/
|
||||||
void updateListing();
|
void updateListing();
|
||||||
|
|
||||||
void updateButtons();
|
void updateButtons();
|
||||||
|
|
||||||
void open();
|
void open();
|
||||||
void close();
|
void close();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle "Add game..." button.
|
||||||
|
*/
|
||||||
virtual void addGame();
|
virtual void addGame();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle "Remove game..." button.
|
||||||
|
*/
|
||||||
void removeGame(int item);
|
void removeGame(int item);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle "Edit game..." button.
|
||||||
|
*/
|
||||||
void editGame(int item);
|
void editGame(int item);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle "Load..." button.
|
||||||
|
*/
|
||||||
void loadGame(int item);
|
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
|
} // End of namespace GUI
|
||||||
|
|
|
@ -139,7 +139,7 @@ void MassAddDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data
|
||||||
sort(_games.begin(), _games.end(), GameTargetLess());
|
sort(_games.begin(), _games.end(), GameTargetLess());
|
||||||
// Add all the detected games to the config
|
// Add all the detected games to the config
|
||||||
for (GameList::iterator iter = _games.begin(); iter != _games.end(); ++iter) {
|
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)["gameid"].c_str(),
|
||||||
(*iter)["description"].c_str());
|
(*iter)["description"].c_str());
|
||||||
(*iter)["gameid"] = addGameToConf(*iter);
|
(*iter)["gameid"] = addGameToConf(*iter);
|
||||||
|
@ -157,6 +157,7 @@ void MassAddDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data
|
||||||
close();
|
close();
|
||||||
} else if (cmd == kCancelCmd) {
|
} else if (cmd == kCancelCmd) {
|
||||||
// User cancelled, so we don't do anything and just leave.
|
// User cancelled, so we don't do anything and just leave.
|
||||||
|
_games.clear();
|
||||||
close();
|
close();
|
||||||
} else {
|
} else {
|
||||||
Dialog::handleCommand(sender, cmd, data);
|
Dialog::handleCommand(sender, cmd, data);
|
||||||
|
|
|
@ -44,6 +44,12 @@ public:
|
||||||
void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
|
void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
|
||||||
void handleTickle();
|
void handleTickle();
|
||||||
|
|
||||||
|
Common::String getFirtAddedTarget() const {
|
||||||
|
if (!_games.empty())
|
||||||
|
return _games.front().gameid();
|
||||||
|
return Common::String();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Common::Stack<Common::FSNode> _scanStack;
|
Common::Stack<Common::FSNode> _scanStack;
|
||||||
GameList _games;
|
GameList _games;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue