Implement FR#2707442: "GUI: Improve Mass Add dialog"
svn-id: r41263
This commit is contained in:
parent
41505a00d0
commit
f2547eb62c
7 changed files with 63 additions and 5 deletions
|
@ -133,6 +133,11 @@ void ListWidget::setList(const StringList &list) {
|
||||||
scrollBarRecalc();
|
scrollBarRecalc();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ListWidget::append(const String &s) {
|
||||||
|
_list.push_back(s);
|
||||||
|
scrollBarRecalc();
|
||||||
|
}
|
||||||
|
|
||||||
void ListWidget::scrollTo(int item) {
|
void ListWidget::scrollTo(int item) {
|
||||||
int size = _list.size();
|
int size = _list.size();
|
||||||
if (item >= size)
|
if (item >= size)
|
||||||
|
@ -445,6 +450,18 @@ void ListWidget::scrollToCurrent() {
|
||||||
_scrollBar->recalc();
|
_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() {
|
void ListWidget::startEditMode() {
|
||||||
if (_editable && !_editMode && _selectedItem >= 0) {
|
if (_editable && !_editMode && _selectedItem >= 0) {
|
||||||
_editMode = true;
|
_editMode = true;
|
||||||
|
|
|
@ -81,6 +81,7 @@ public:
|
||||||
virtual Widget *findWidget(int x, int y);
|
virtual Widget *findWidget(int x, int y);
|
||||||
|
|
||||||
void setList(const StringList &list);
|
void setList(const StringList &list);
|
||||||
|
void append(const String &s);
|
||||||
const StringList &getList() const { return _list; }
|
const StringList &getList() const { return _list; }
|
||||||
int getSelected() const { return _selectedItem; }
|
int getSelected() const { return _selectedItem; }
|
||||||
void setSelected(int item);
|
void setSelected(int item);
|
||||||
|
@ -89,6 +90,7 @@ public:
|
||||||
bool isEditable() const { return _editable; }
|
bool isEditable() const { return _editable; }
|
||||||
void setEditable(bool editable) { _editable = editable; }
|
void setEditable(bool editable) { _editable = editable; }
|
||||||
void scrollTo(int item);
|
void scrollTo(int item);
|
||||||
|
void scrollToEnd();
|
||||||
|
|
||||||
virtual void handleTickle();
|
virtual void handleTickle();
|
||||||
virtual void handleMouseDown(int x, int y, int button, int clickCount);
|
virtual void handleMouseDown(int x, int y, int button, int clickCount);
|
||||||
|
|
|
@ -630,8 +630,14 @@ void LauncherDialog::addGame() {
|
||||||
"This could potentially add a huge number of games.", "Yes", "No");
|
"This could potentially add a huge number of games.", "Yes", "No");
|
||||||
if (alert.runModal() == GUI::kMessageOK && _browser->runModal() > 0) {
|
if (alert.runModal() == GUI::kMessageOK && _browser->runModal() > 0) {
|
||||||
MassAddDialog massAddDlg(_browser->getResult());
|
MassAddDialog massAddDlg(_browser->getResult());
|
||||||
|
|
||||||
|
ConfMan.set("temp_selection", _domains[_list->getSelected()], ConfigManager::kApplicationDomain);
|
||||||
|
|
||||||
massAddDlg.runModal();
|
massAddDlg.runModal();
|
||||||
|
|
||||||
|
selectGame(ConfMan.get("temp_selection", ConfigManager::kApplicationDomain));
|
||||||
|
ConfMan.removeKey("temp_selection", ConfigManager::kApplicationDomain);
|
||||||
|
|
||||||
// Update the ListWidget and force a redraw
|
// Update the ListWidget and force a redraw
|
||||||
updateListing();
|
updateListing();
|
||||||
draw();
|
draw();
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include "gui/massadd.h"
|
#include "gui/massadd.h"
|
||||||
#include "gui/GuiManager.h"
|
#include "gui/GuiManager.h"
|
||||||
#include "gui/widget.h"
|
#include "gui/widget.h"
|
||||||
|
#include "gui/ListWidget.h"
|
||||||
|
|
||||||
|
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
@ -65,6 +66,8 @@ MassAddDialog::MassAddDialog(const Common::FSNode &startDir)
|
||||||
_dirProgressText(0),
|
_dirProgressText(0),
|
||||||
_gameProgressText(0) {
|
_gameProgressText(0) {
|
||||||
|
|
||||||
|
Common::StringList l;
|
||||||
|
|
||||||
// The dir we start our scan at
|
// The dir we start our scan at
|
||||||
_scanStack.push(startDir);
|
_scanStack.push(startDir);
|
||||||
|
|
||||||
|
@ -80,6 +83,11 @@ MassAddDialog::MassAddDialog(const Common::FSNode &startDir)
|
||||||
_dirProgressText->setAlign(Graphics::kTextAlignCenter);
|
_dirProgressText->setAlign(Graphics::kTextAlignCenter);
|
||||||
_gameProgressText->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 = new ButtonWidget(this, "MassAdd.Ok", "OK", kOkCmd, Common::ASCII_RETURN);
|
||||||
_okButton->setEnabled(false);
|
_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 {
|
bool operator()(const GameDescriptor &x, const GameDescriptor &y) const {
|
||||||
return x.preferredtarget().compareToIgnoreCase(y.preferredtarget()) < 0;
|
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) {
|
void MassAddDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
|
||||||
// FIXME: It's a really bad thing that we use two arbitrary constants
|
// FIXME: It's a really bad thing that we use two arbitrary constants
|
||||||
if (cmd == kOkCmd) {
|
if (cmd == kOkCmd) {
|
||||||
// Sort the detected games. This is not strictly necessary, but nice for
|
// 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.
|
// 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
|
// 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",
|
printf(" Added gameid '%s', desc '%s'\n",
|
||||||
(*iter)["gameid"].c_str(),
|
(*iter)["gameid"].c_str(),
|
||||||
(*iter)["description"].c_str());
|
(*iter)["description"].c_str());
|
||||||
addGameToConf(*iter);
|
(*iter)["gameid"] = addGameToConf(*iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write everything to disk
|
// Write everything to disk
|
||||||
ConfMan.flushToDisk();
|
ConfMan.flushToDisk();
|
||||||
|
|
||||||
|
// And scroll to first detected game
|
||||||
|
sort(_games.begin(), _games.end(), GameDescLess());
|
||||||
|
ConfMan.set("temp_selection", _games.front().gameid());
|
||||||
|
|
||||||
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.
|
||||||
|
@ -196,6 +214,8 @@ void MassAddDialog::handleTickle() {
|
||||||
}
|
}
|
||||||
result["path"] = path;
|
result["path"] = path;
|
||||||
_games.push_back(result);
|
_games.push_back(result);
|
||||||
|
|
||||||
|
_list->append(result.description());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -231,6 +251,10 @@ void MassAddDialog::handleTickle() {
|
||||||
_gameProgressText->setLabel(buf);
|
_gameProgressText->setLabel(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_games.size() > 0) {
|
||||||
|
_list->scrollToEnd();
|
||||||
|
}
|
||||||
|
|
||||||
drawDialog();
|
drawDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,8 @@ private:
|
||||||
Widget *_okButton;
|
Widget *_okButton;
|
||||||
StaticTextWidget *_dirProgressText;
|
StaticTextWidget *_dirProgressText;
|
||||||
StaticTextWidget *_gameProgressText;
|
StaticTextWidget *_gameProgressText;
|
||||||
|
|
||||||
|
ListWidget *_list;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -721,7 +721,14 @@
|
||||||
width = '250'
|
width = '250'
|
||||||
height = 'Globals.Line.Height'
|
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'>
|
<layout type = 'horizontal' padding = '8, 8, 8, 8'>
|
||||||
<widget name = 'Ok'
|
<widget name = 'Ok'
|
||||||
type = 'Button'
|
type = 'Button'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue