1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
/* 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"
#include "common/config-file.h"
#include "common/engine.h"
#include "common/gameDetector.h"
enum {
kStartCmd = 'STRT',
kOptionsCmd = 'OPTN',
kAddGameCmd = 'ADDG',
kConfigureGameCmd = 'CONF',
kQuitCmd = 'QUIT'
};
/*
* 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
* - ...
*/
LauncherDialog::LauncherDialog(NewGui *gui, GameDetector &detector)
: Dialog(gui, 0, 0, 320, 200), _detector(detector)
{
Widget *bw;
// Show game name
new StaticTextWidget(this, 10, 8, 300, kLineHeight,
"ScummVM "SCUMMVM_VERSION " (" SCUMMVM_CVS ")",
kTextAlignCenter);
// Add three buttons at the bottom
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');
_startButton->setEnabled(false);
// Add list with game titles
_list = new ListWidget(this, 10, 28, 300, 112);
_list->setEditable(false);
_list->setNumberingMode(kListNumberingOff);
const VersionSettings *v = version_settings;
ScummVM::StringList l;
// TODO - maybe only display those games for which settings are known
// (i.e. a path to the game data was set and is accesible) ?
char domains[255][100];
int count = g_config->get_domains(domains);
//printf("First domain is %s, out of %d\n", domains[0], count);
while (v->filename && v->gamename) {
if (g_config->has_domain(v->filename)) {
String name;
char *txtname;
int pos = 0, size = l.size();
if ((txtname = (char*)g_config->get("description", v->filename))) {
name = txtname;
} else {
name = v->gamename;
}
while (pos < size && (name > l[pos]))
pos++;
l.insert_at(pos, name);
_filenames.insert_at(pos, v->filename);
}
v++;
}
if (l.size() > 0)
_list->setList(l);
// TODO - make a default selection (maybe the game user played last?)
//_list->setSelected(0);
// Two more buttons directly below the list box
bw = new ButtonWidget(this, 10, 144, 80, 16, "Add Game...", kAddGameCmd, 'A');
bw->setEnabled(false);
bw = new ButtonWidget(this, 320-90, 144, 80, 16, "Configure...", kConfigureGameCmd, 'C');
bw->setEnabled(false);
}
void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data)
{
int item;
switch (cmd) {
case kAddGameCmd:
// TODO: Allow user to add a new game to the list.
// 1) show a file selection dialog (to be implemented!) which lets
// the user pick the directory the game data resides in.
// 2) show the user a list of games to pick from. Initially just show
// all known games. But ideally, we would refine this list by checking
// which choices are possible. E.g. if we don't find atlantis.000 in that
// directory, then it's not FOA etc.
break;
case kConfigureGameCmd:
// Set game specifc options. Most of these should be "optional", i.e. by
// default set nothing and use the global ScummVM settings. E.g. the user
// can set here an optional alternate music volume, or for specific games
// a different music driver etc.
// This is useful because e.g. MonkeyVGA needs Adlib music to have decent
// music support etc.
break;
case kOptionsCmd:
// TODO - show up a generic options dialog, loosely based upon the one
// we have in scumm/dialogs.cpp. So we will be modifying the settings
// in _detector, like which music engine to use, volumes, etc.
//
// We also allow the global save game path to be set here.
break;
case kStartCmd:
case kListItemDoubleClickedCmd:
// Print out what was selected
item = _list->getSelected();
assert(item >= 0);
_detector.setGame(_filenames[item].c_str());
close();
break;
case kListSelectionChangedCmd:
_startButton->setEnabled(_list->getSelected() >= 0);
_startButton->draw();
break;
case kQuitCmd:
g_system->quit();
break;
default:
Dialog::handleCommand(sender, cmd, data);
}
}
|