2002-09-27 23:27:14 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
|
|
|
* Copyright (C) 2002 The ScummVM project
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* $Header$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "launcher.h"
|
|
|
|
#include "newgui.h"
|
|
|
|
#include "ListWidget.h"
|
|
|
|
|
2002-09-30 00:55:47 +00:00
|
|
|
#include "common/config-file.h"
|
2002-09-27 23:27:14 +00:00
|
|
|
#include "common/engine.h"
|
|
|
|
#include "common/gameDetector.h"
|
|
|
|
|
|
|
|
enum {
|
2002-09-30 00:55:47 +00:00
|
|
|
kStartCmd = 'STRT',
|
|
|
|
kOptionsCmd = 'OPTN',
|
2002-10-13 11:51:48 +00:00
|
|
|
kAddGameCmd = 'ADDG',
|
2002-09-27 23:27:14 +00:00
|
|
|
kQuitCmd = 'QUIT'
|
|
|
|
};
|
2002-09-30 00:55:47 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* TODO list
|
|
|
|
* - add an text entry widget
|
|
|
|
* - add an "Add Game..." button that opens a dialog where new games can be
|
|
|
|
* configured and added to the list of games
|
|
|
|
* - add an "Edit Game..." button that opens a dialog that allows to edit game
|
|
|
|
* settings, i.e. the datapath/savepath/sound driver/... for that game
|
|
|
|
* - add an "options" dialog
|
|
|
|
* - ...
|
|
|
|
*/
|
2002-09-27 23:27:14 +00:00
|
|
|
|
2002-09-30 00:55:47 +00:00
|
|
|
LauncherDialog::LauncherDialog(NewGui *gui, GameDetector &detector)
|
|
|
|
: Dialog(gui, 0, 0, 320, 200), _detector(detector)
|
2002-09-27 23:27:14 +00:00
|
|
|
{
|
2002-10-13 11:51:48 +00:00
|
|
|
Widget *bw;
|
|
|
|
|
|
|
|
// Show game name
|
|
|
|
new StaticTextWidget(this, 10, 8, 300, kLineHeight,
|
|
|
|
"ScummVM "SCUMMVM_VERSION " (" SCUMMVM_CVS ")",
|
|
|
|
kTextAlignCenter);
|
|
|
|
|
2002-09-27 23:27:14 +00:00
|
|
|
// Add three buttons at the bottom
|
2002-10-13 11:51:48 +00:00
|
|
|
bw = addButton(1*(_w - kButtonWidth)/6, _h - 24, "Quit", kQuitCmd, 'Q');
|
|
|
|
bw = addButton(3*(_w - kButtonWidth)/6, _h - 24, "Options", kOptionsCmd, 'O');
|
|
|
|
bw->setEnabled(false);
|
|
|
|
_startButton = addButton(5*(_w - kButtonWidth)/6, _h - 24, "Start", kStartCmd, 'S');
|
2002-10-01 23:11:19 +00:00
|
|
|
_startButton->setEnabled(false);
|
2002-09-27 23:27:14 +00:00
|
|
|
|
|
|
|
// Add list with game titles
|
2002-10-13 11:51:48 +00:00
|
|
|
_list = new ListWidget(this, 10, 28, 300, 112);
|
2002-09-30 12:56:59 +00:00
|
|
|
_list->setEditable(false);
|
2002-09-30 00:55:47 +00:00
|
|
|
_list->setNumberingMode(kListNumberingOff);
|
2002-09-27 23:27:14 +00:00
|
|
|
|
|
|
|
const VersionSettings *v = version_settings;
|
|
|
|
ScummVM::StringList l;
|
|
|
|
|
2002-10-13 11:51:48 +00:00
|
|
|
// TODO - sort by name ?
|
2002-09-30 00:55:47 +00:00
|
|
|
// TODO - maybe only display those games for which settings are known
|
|
|
|
// (i.e. a path to the game data was set and is accesible) ?
|
2002-09-27 23:27:14 +00:00
|
|
|
while (v->filename && v->gamename) {
|
2002-09-30 00:55:47 +00:00
|
|
|
if (g_config->has_domain(v->filename)) {
|
|
|
|
l.push_back(v->gamename);
|
|
|
|
_filenames.push_back(v->filename);
|
|
|
|
}
|
2002-09-27 23:27:14 +00:00
|
|
|
v++;
|
|
|
|
}
|
|
|
|
|
2002-09-30 00:55:47 +00:00
|
|
|
_list->setList(l);
|
|
|
|
// _list->setSelected(0);
|
2002-10-13 11:51:48 +00:00
|
|
|
|
|
|
|
// Two more buttons directly below the list box
|
|
|
|
bw = new ButtonWidget(this, 10, 144, 80, 16, "Add Game...", kAddGameCmd, 'A');
|
|
|
|
bw->setEnabled(false);
|
|
|
|
// addButton(20 + 4 + kButtonWidth, 144, "Change Setting...");
|
2002-09-27 23:27:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data)
|
|
|
|
{
|
2002-09-30 00:55:47 +00:00
|
|
|
int item;
|
|
|
|
|
2002-09-27 23:27:14 +00:00
|
|
|
switch (cmd) {
|
2002-09-30 00:55:47 +00:00
|
|
|
case kStartCmd:
|
2002-09-27 23:27:14 +00:00
|
|
|
case kListItemDoubleClickedCmd:
|
2002-09-30 00:55:47 +00:00
|
|
|
// Print out what was selected
|
|
|
|
item = _list->getSelected();
|
2002-10-01 23:11:19 +00:00
|
|
|
assert(item >= 0);
|
|
|
|
_detector.setGame(_filenames[item].c_str());
|
|
|
|
close();
|
|
|
|
break;
|
|
|
|
case kListSelectionChangedCmd:
|
|
|
|
_startButton->setEnabled(_list->getSelected() >= 0);
|
|
|
|
_startButton->draw();
|
2002-09-27 23:27:14 +00:00
|
|
|
break;
|
|
|
|
case kQuitCmd:
|
|
|
|
g_system->quit();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Dialog::handleCommand(sender, cmd, data);
|
|
|
|
}
|
|
|
|
}
|