From ee3158cb8ca8b05d7c1a474f09ade8ac91209fbc Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 1 Oct 2004 21:12:18 +0000 Subject: Patch #896096 (Restoring last selected game selection) with some personal modifications svn-id: r15372 --- gui/launcher.cpp | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'gui/launcher.cpp') diff --git a/gui/launcher.cpp b/gui/launcher.cpp index 54fc742268..23764fda90 100644 --- a/gui/launcher.cpp +++ b/gui/launcher.cpp @@ -421,9 +421,19 @@ LauncherDialog::LauncherDialog(GameDetector &detector) // Populate the list updateListing(); - // TODO - make a default selection (maybe the game user played last?) - //_list->setSelected(0); - + // Restore last selection + String last = ConfMan.get(String("lastselectedgame"), ConfigManager::kApplicationDomain); + if (!last.isEmpty()) { + int itemToSelect = 0; + StringList::const_iterator iter; + for (iter = _domains.begin(); iter != _domains.end(); ++iter, ++itemToSelect) { + if (last == *iter) { + _list->setSelected(itemToSelect); + break; + } + } + } + // En-/Disable the buttons depending on the list selection updateButtons(); @@ -435,6 +445,18 @@ LauncherDialog::~LauncherDialog() { delete _browser; } +void LauncherDialog::close() { + // Save last selection + const int sel = _list->getSelected(); + if (sel >= 0) + ConfMan.set(String("lastselectedgame"), _domains[sel], ConfigManager::kApplicationDomain); + else + ConfMan.removeKey(String("lastselectedgame"), ConfigManager::kApplicationDomain); + + ConfMan.flushToDisk(); + Dialog::close(); +} + void LauncherDialog::updateListing() { Common::StringList l; @@ -654,9 +676,7 @@ void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat updateButtons(); break; case kQuitCmd: -#ifdef __PALM_OS__ close(); -#endif g_system->quit(); break; default: -- cgit v1.2.3