[Scummvm-cvs-logs] CVS: scummvm/gui ListWidget.cpp,1.37,1.38 ListWidget.h,1.22,1.23 launcher.cpp,1.99,1.100 launcher.h,1.18,1.19
Max Horn
fingolfin at users.sourceforge.net
Fri Oct 1 14:19:11 CEST 2004
Update of /cvsroot/scummvm/scummvm/gui
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32675
Modified Files:
ListWidget.cpp ListWidget.h launcher.cpp launcher.h
Log Message:
Patch #896096 (Restoring last selected game selection) with some personal modifications
Index: ListWidget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/ListWidget.cpp,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- ListWidget.cpp 28 Sep 2004 20:19:26 -0000 1.37
+++ ListWidget.cpp 1 Oct 2004 21:12:17 -0000 1.38
@@ -53,6 +53,28 @@
ListWidget::~ListWidget() {
}
+void ListWidget::setSelected(int item) {
+ assert(item >= -1 && item < (int)_list.size());
+
+ if (isEnabled() && _selectedItem != item) {
+ int oldSelectedItem = _selectedItem;
+ _selectedItem = item;
+
+ if (_editMode) {
+ // undo any changes made
+ _list[oldSelectedItem] = _backupString;
+ _editMode = false;
+ drawCaret(true);
+ }
+
+ sendCommand(kListSelectionChangedCmd, _selectedItem);
+
+ _currentPos = _selectedItem - _entriesPerPage / 2;
+ scrollToCurrent();
+ draw();
+ }
+}
+
void ListWidget::setList(const StringList &list) {
if (_editMode && _caretVisible)
drawCaret(true);
@@ -379,6 +401,8 @@
if (_currentPos < 0)
_currentPos = 0;
+ else if (_currentPos + _entriesPerPage > (int)_list.size())
+ _currentPos = _list.size() - _entriesPerPage;
_scrollBar->_currentPos = _currentPos;
_scrollBar->recalc();
Index: ListWidget.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/ListWidget.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- ListWidget.h 21 Jul 2004 14:28:57 -0000 1.22
+++ ListWidget.h 1 Oct 2004 21:12:18 -0000 1.23
@@ -69,6 +69,7 @@
void setList(const StringList& list);
const StringList& getList() const { return _list; }
int getSelected() const { return _selectedItem; }
+ void setSelected(int item);
const String& getSelectedString() const { return _list[_selectedItem]; }
void setNumberingMode(NumberingMode numberingMode) { _numberingMode = numberingMode; }
bool isEditable() const { return _editable; }
Index: launcher.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/launcher.cpp,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -d -r1.99 -r1.100
--- launcher.cpp 26 Aug 2004 00:27:51 -0000 1.99
+++ launcher.cpp 1 Oct 2004 21:12:18 -0000 1.100
@@ -421,9 +421,19 @@
// 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 @@
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 @@
updateButtons();
break;
case kQuitCmd:
-#ifdef __PALM_OS__
close();
-#endif
g_system->quit();
break;
default:
Index: launcher.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/launcher.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- launcher.h 5 Feb 2004 11:59:04 -0000 1.18
+++ launcher.h 1 Oct 2004 21:12:18 -0000 1.19
@@ -52,6 +52,7 @@
void updateListing();
void updateButtons();
+ void close();
virtual void addGame();
void removeGame(int item);
void editGame(int item);
More information about the Scummvm-git-logs
mailing list