aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorEugene Sandulenko2009-06-06 17:49:59 +0000
committerEugene Sandulenko2009-06-06 17:49:59 +0000
commitf2547eb62c3ab6a4085f6341a66d304287f39d6f (patch)
tree629ec751dcc637854b3c4b1a7d66ab225023ff01 /gui
parent41505a00d0d70a9344969c2126417a3dfb6621c8 (diff)
downloadscummvm-rg350-f2547eb62c3ab6a4085f6341a66d304287f39d6f.tar.gz
scummvm-rg350-f2547eb62c3ab6a4085f6341a66d304287f39d6f.tar.bz2
scummvm-rg350-f2547eb62c3ab6a4085f6341a66d304287f39d6f.zip
Implement FR#2707442: "GUI: Improve Mass Add dialog"
svn-id: r41263
Diffstat (limited to 'gui')
-rw-r--r--gui/ListWidget.cpp17
-rw-r--r--gui/ListWidget.h2
-rw-r--r--gui/launcher.cpp6
-rw-r--r--gui/massadd.cpp32
-rw-r--r--gui/massadd.h2
-rw-r--r--gui/themes/scummmodern.zipbin150287 -> 150435 bytes
-rw-r--r--gui/themes/scummmodern/scummmodern_layout.stx9
7 files changed, 63 insertions, 5 deletions
diff --git a/gui/ListWidget.cpp b/gui/ListWidget.cpp
index 06cbcdcbd9..f534c14d1e 100644
--- a/gui/ListWidget.cpp
+++ b/gui/ListWidget.cpp
@@ -133,6 +133,11 @@ void ListWidget::setList(const StringList &list) {
scrollBarRecalc();
}
+void ListWidget::append(const String &s) {
+ _list.push_back(s);
+ scrollBarRecalc();
+}
+
void ListWidget::scrollTo(int item) {
int size = _list.size();
if (item >= size)
@@ -445,6 +450,18 @@ void ListWidget::scrollToCurrent() {
_scrollBar->recalc();
}
+void ListWidget::scrollToEnd() {
+ if (_currentPos + _entriesPerPage < (int)_list.size()) {
+ _currentPos = _list.size() - _entriesPerPage;
+ } else {
+ return;
+ }
+
+ _scrollBar->_currentPos = _currentPos;
+ _scrollBar->recalc();
+ _scrollBar->draw();
+}
+
void ListWidget::startEditMode() {
if (_editable && !_editMode && _selectedItem >= 0) {
_editMode = true;
diff --git a/gui/ListWidget.h b/gui/ListWidget.h
index 23bcc3c1a7..5b73f42a1c 100644
--- a/gui/ListWidget.h
+++ b/gui/ListWidget.h
@@ -81,6 +81,7 @@ public:
virtual Widget *findWidget(int x, int y);
void setList(const StringList &list);
+ void append(const String &s);
const StringList &getList() const { return _list; }
int getSelected() const { return _selectedItem; }
void setSelected(int item);
@@ -89,6 +90,7 @@ public:
bool isEditable() const { return _editable; }
void setEditable(bool editable) { _editable = editable; }
void scrollTo(int item);
+ void scrollToEnd();
virtual void handleTickle();
virtual void handleMouseDown(int x, int y, int button, int clickCount);
diff --git a/gui/launcher.cpp b/gui/launcher.cpp
index 126ef1f978..c1adc307b6 100644
--- a/gui/launcher.cpp
+++ b/gui/launcher.cpp
@@ -630,8 +630,14 @@ void LauncherDialog::addGame() {
"This could potentially add a huge number of games.", "Yes", "No");
if (alert.runModal() == GUI::kMessageOK && _browser->runModal() > 0) {
MassAddDialog massAddDlg(_browser->getResult());
+
+ ConfMan.set("temp_selection", _domains[_list->getSelected()], ConfigManager::kApplicationDomain);
+
massAddDlg.runModal();
+ selectGame(ConfMan.get("temp_selection", ConfigManager::kApplicationDomain));
+ ConfMan.removeKey("temp_selection", ConfigManager::kApplicationDomain);
+
// Update the ListWidget and force a redraw
updateListing();
draw();
diff --git a/gui/massadd.cpp b/gui/massadd.cpp
index 1b1f3f7ff0..4e43d342cb 100644
--- a/gui/massadd.cpp
+++ b/gui/massadd.cpp
@@ -32,6 +32,7 @@
#include "gui/massadd.h"
#include "gui/GuiManager.h"
#include "gui/widget.h"
+#include "gui/ListWidget.h"
namespace GUI {
@@ -65,6 +66,8 @@ MassAddDialog::MassAddDialog(const Common::FSNode &startDir)
_dirProgressText(0),
_gameProgressText(0) {
+ Common::StringList l;
+
// The dir we start our scan at
_scanStack.push(startDir);
@@ -80,6 +83,11 @@ MassAddDialog::MassAddDialog(const Common::FSNode &startDir)
_dirProgressText->setAlign(Graphics::kTextAlignCenter);
_gameProgressText->setAlign(Graphics::kTextAlignCenter);
+ _list = new ListWidget(this, "MassAdd.GameList");
+ _list->setEditable(false);
+ _list->setNumberingMode(kListNumberingOff);
+ _list->setList(l);
+
_okButton = new ButtonWidget(this, "MassAdd.Ok", "OK", kOkCmd, Common::ASCII_RETURN);
_okButton->setEnabled(false);
@@ -110,30 +118,40 @@ MassAddDialog::MassAddDialog(const Common::FSNode &startDir)
}
}
-struct GameDescLess {
+struct GameTargetLess {
bool operator()(const GameDescriptor &x, const GameDescriptor &y) const {
return x.preferredtarget().compareToIgnoreCase(y.preferredtarget()) < 0;
}
};
+struct GameDescLess {
+ bool operator()(const GameDescriptor &x, const GameDescriptor &y) const {
+ return x.description().compareToIgnoreCase(y.description()) < 0;
+ }
+};
+
void MassAddDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
// FIXME: It's a really bad thing that we use two arbitrary constants
if (cmd == kOkCmd) {
// Sort the detected games. This is not strictly necessary, but nice for
// people who want to edit their config file by hand after a mass add.
- sort(_games.begin(), _games.end(), GameDescLess());
+ sort(_games.begin(), _games.end(), GameTargetLess());
// Add all the detected games to the config
- for (GameList::const_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",
(*iter)["gameid"].c_str(),
(*iter)["description"].c_str());
- addGameToConf(*iter);
+ (*iter)["gameid"] = addGameToConf(*iter);
}
// Write everything to disk
ConfMan.flushToDisk();
+ // And scroll to first detected game
+ sort(_games.begin(), _games.end(), GameDescLess());
+ ConfMan.set("temp_selection", _games.front().gameid());
+
close();
} else if (cmd == kCancelCmd) {
// User cancelled, so we don't do anything and just leave.
@@ -196,6 +214,8 @@ void MassAddDialog::handleTickle() {
}
result["path"] = path;
_games.push_back(result);
+
+ _list->append(result.description());
}
@@ -231,6 +251,10 @@ void MassAddDialog::handleTickle() {
_gameProgressText->setLabel(buf);
}
+ if (_games.size() > 0) {
+ _list->scrollToEnd();
+ }
+
drawDialog();
}
diff --git a/gui/massadd.h b/gui/massadd.h
index c2a0eff2ba..106b285a64 100644
--- a/gui/massadd.h
+++ b/gui/massadd.h
@@ -60,6 +60,8 @@ private:
Widget *_okButton;
StaticTextWidget *_dirProgressText;
StaticTextWidget *_gameProgressText;
+
+ ListWidget *_list;
};
diff --git a/gui/themes/scummmodern.zip b/gui/themes/scummmodern.zip
index 64653ab44d..845d2aa1b9 100644
--- a/gui/themes/scummmodern.zip
+++ b/gui/themes/scummmodern.zip
Binary files differ
diff --git a/gui/themes/scummmodern/scummmodern_layout.stx b/gui/themes/scummmodern/scummmodern_layout.stx
index c9cad774f9..91db687575 100644
--- a/gui/themes/scummmodern/scummmodern_layout.stx
+++ b/gui/themes/scummmodern/scummmodern_layout.stx
@@ -721,7 +721,14 @@
width = '250'
height = 'Globals.Line.Height'
/>
- <space size = '32' />
+ <widget name = 'GameProgressText'
+ width = '250'
+ height = 'Globals.Line.Height'
+ />
+ <widget name = 'GameList'
+ width = '480'
+ height = '250'
+ />
<layout type = 'horizontal' padding = '8, 8, 8, 8'>
<widget name = 'Ok'
type = 'Button'