mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-03 15:41:41 +00:00
added a chooser sub dialog used by 'Add Game'
svn-id: r5651
This commit is contained in:
parent
d76627abac
commit
e5257ac4fe
@ -29,6 +29,66 @@
|
||||
#include "common/engine.h"
|
||||
#include "common/gameDetector.h"
|
||||
|
||||
enum {
|
||||
kChooseCmd = 'Chos'
|
||||
};
|
||||
|
||||
/*
|
||||
* A dialog that allows the user to choose between a selection of items
|
||||
*/
|
||||
|
||||
class ChooserDialog : public Dialog {
|
||||
typedef ScummVM::String String;
|
||||
typedef ScummVM::StringList StringList;
|
||||
public:
|
||||
ChooserDialog(NewGui *gui, const StringList& list);
|
||||
|
||||
virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
|
||||
|
||||
protected:
|
||||
ListWidget *_list;
|
||||
ButtonWidget *_chooseButton;
|
||||
};
|
||||
|
||||
ChooserDialog::ChooserDialog(NewGui *gui, const StringList& list)
|
||||
: Dialog(gui, 40, 30, 320-2*40, 200-2*30)
|
||||
{
|
||||
// Headline
|
||||
new StaticTextWidget(this, 10, 8, _w-2*10, kLineHeight,
|
||||
"Pick the game:", kTextAlignCenter);
|
||||
|
||||
// Add choice list
|
||||
_list = new ListWidget(this, 10, 22, _w-2*10, _h-22-24-10);
|
||||
_list->setNumberingMode(kListNumberingOff);
|
||||
_list->setList(list);
|
||||
|
||||
// Buttons
|
||||
addButton(_w-2*(kButtonWidth+10), _h-24, "Cancel", kCloseCmd, 0);
|
||||
_chooseButton = addButton(_w-(kButtonWidth+10), _h-24, "Choose", kChooseCmd, 0);
|
||||
_chooseButton->setEnabled(false);
|
||||
|
||||
// Result = -1 -> no choice was made
|
||||
setResult(-1);
|
||||
}
|
||||
|
||||
void ChooserDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data)
|
||||
{
|
||||
int item = _list->getSelected();
|
||||
switch (cmd) {
|
||||
case kChooseCmd:
|
||||
case kListItemDoubleClickedCmd:
|
||||
setResult(item);
|
||||
close();
|
||||
break;
|
||||
case kListSelectionChangedCmd:
|
||||
_chooseButton->setEnabled(item >= 0);
|
||||
_chooseButton->draw();
|
||||
break;
|
||||
default:
|
||||
Dialog::handleCommand(sender, cmd, data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
enum {
|
||||
kStartCmd = 'STRT',
|
||||
@ -213,11 +273,16 @@ void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
|
||||
// Exact match
|
||||
v = candidates[0];
|
||||
} else {
|
||||
// TODO - display candidates to the user and let him pick one
|
||||
printf("Found these candidates: ");
|
||||
for (int i = 0; i < candidates.size(); i++)
|
||||
printf("%s, ", candidates[i]->filename);
|
||||
printf("\n");
|
||||
// Display the candidates to the user and let her/him pick one
|
||||
StringList list;
|
||||
int i;
|
||||
for (i = 0; i < candidates.size(); i++)
|
||||
list.push_back(candidates[i]->gamename);
|
||||
|
||||
ChooserDialog dialog(_gui, list);
|
||||
i = dialog.runModal();
|
||||
if (0 <= i && i < candidates.size())
|
||||
v = candidates[i];
|
||||
}
|
||||
|
||||
if (v != 0) {
|
||||
@ -263,7 +328,7 @@ void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
|
||||
close();
|
||||
break;
|
||||
case kListSelectionChangedCmd:
|
||||
_startButton->setEnabled(_list->getSelected() >= 0);
|
||||
_startButton->setEnabled(data >= 0);
|
||||
_startButton->draw();
|
||||
break;
|
||||
case kQuitCmd:
|
||||
|
Loading…
Reference in New Issue
Block a user