~ubuntu-branches/debian/squeeze/stella/squeeze

« back to all changes in this revision

Viewing changes to src/gui/OptionsDialog.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Luca Falavigna, Franczen Attila, Luca Falavigna
  • Date: 2008-11-08 12:04:12 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20081108120412-w6xq87vzgokstfey
Tags: 2.6.1-0ubuntu1
[ Franczen Attila ]
* New upstream release (LP: #183571).
* Updated policy to 3.8.0.

[ Luca Falavigna ]
* debian/patches/gcc-4.3: fix FTBFS with gcc-4.3 compiler.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
//  SS  SS   tt   ee      ll   ll  aa  aa
9
9
//   SSSS     ttt  eeeee llll llll  aaaaa
10
10
//
11
 
// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team
 
11
// Copyright (c) 1995-2008 by Bradford W. Mott and the Stella team
12
12
//
13
13
// See the file "license" for information on usage and redistribution of
14
14
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
15
15
//
16
 
// $Id: OptionsDialog.cxx,v 1.38 2006/04/05 12:28:39 stephena Exp $
 
16
// $Id: OptionsDialog.cxx,v 1.69 2008/03/23 16:22:46 stephena Exp $
17
17
//
18
18
//   Based on code from ScummVM - Scumm Interpreter
19
19
//   Copyright (C) 2002-2004 The ScummVM project
27
27
#include "VideoDialog.hxx"
28
28
#include "AudioDialog.hxx"
29
29
#include "InputDialog.hxx"
 
30
#include "UIDialog.hxx"
 
31
#include "FileSnapDialog.hxx"
 
32
#include "RomAuditDialog.hxx"
30
33
#include "GameInfoDialog.hxx"
31
34
#include "HelpDialog.hxx"
32
35
#include "AboutDialog.hxx"
33
36
#include "OptionsDialog.hxx"
 
37
#include "Launcher.hxx"
34
38
 
35
39
#ifdef CHEATCODE_SUPPORT
36
40
  #include "CheatCodeDialog.hxx"
38
42
 
39
43
#include "bspf.hxx"
40
44
 
41
 
enum {
42
 
  kVidCmd   = 'VIDO',
43
 
  kAudCmd   = 'AUDO',
44
 
  kInptCmd  = 'INPT',
45
 
  kInfoCmd  = 'INFO',
46
 
  kHelpCmd  = 'HELP',
47
 
  kAboutCmd = 'ABOU',
48
 
  kExitCmd  = 'EXIM',
49
 
  kCheatCmd = 'CHET'
50
 
};
51
 
 
52
 
enum {
53
 
  kRowHeight      = 22,
54
 
  kBigButtonWidth = 90,
55
 
  kMainMenuWidth  = (kBigButtonWidth + 2 * 8),
56
 
  kMainMenuHeight = 8 * kRowHeight + 10,
57
 
};
58
 
 
59
 
#define addBigButton(label, cmd, hotkey) \
60
 
        new ButtonWidget(this, font, xoffset, yoffset, kBigButtonWidth, 18, label, cmd, hotkey); yoffset += kRowHeight
 
45
#define addBigButton(label, cmd) \
 
46
  new ButtonWidget(this, font, xoffset, yoffset, buttonWidth, buttonHeight, label, cmd); yoffset += rowHeight
61
47
 
62
48
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
63
 
OptionsDialog::OptionsDialog(OSystem* osystem, DialogContainer* parent)
64
 
  : Dialog(osystem, parent, 0, 0, kMainMenuWidth, kMainMenuHeight),
 
49
OptionsDialog::OptionsDialog(OSystem* osystem, DialogContainer* parent,
 
50
                             GuiObject* boss, bool global)
 
51
  : Dialog(osystem, parent, 0, 0, 1, 1),
65
52
    myVideoDialog(NULL),
66
53
    myAudioDialog(NULL),
67
54
    myInputDialog(NULL),
 
55
    myUIDialog(NULL),
 
56
    myFileSnapDialog(NULL),
68
57
    myGameInfoDialog(NULL),
69
58
    myCheatCodeDialog(NULL),
70
59
    myHelpDialog(NULL),
71
 
    myAboutDialog(NULL)
 
60
    myAboutDialog(NULL),
 
61
    myIsGlobal(global)
72
62
{
73
 
  // Set actual dialog dimensions
74
 
  _x = (osystem->frameBuffer().baseWidth() - kMainMenuWidth) / 2;
75
 
  _y = (osystem->frameBuffer().baseHeight() - kMainMenuHeight) / 2;
76
 
 
77
 
  int yoffset = 7;
78
 
  const int xoffset = (_w - kBigButtonWidth) / 2;
79
 
  const GUI::Font& font = instance()->font(); // FIXME - change reference to optionsFont()
 
63
  const GUI::Font& font = instance()->font();
 
64
  const int buttonWidth = font.getStringWidth("Game Properties") + 20,
 
65
            buttonHeight = font.getLineHeight() + 6,
 
66
            rowHeight = font.getLineHeight() + 10;
 
67
 
 
68
  _w = 2 * buttonWidth + 30;
 
69
  _h = 6 * rowHeight + 15;
 
70
 
 
71
  int xoffset = 10, yoffset = 10;
 
72
  WidgetArray wid;
80
73
  ButtonWidget* b = NULL;
81
74
 
82
 
  b = addBigButton("Video Settings", kVidCmd, 0);
83
 
#ifdef SOUND_SUPPORT
84
 
  addBigButton("Audio Settings", kAudCmd, 0);
85
 
#else
86
 
  b = addBigButton("Audio Settings", kAudCmd, 0);
87
 
  b->clearFlags(WIDGET_ENABLED);
88
 
#endif
89
 
  addBigButton("Input Settings", kInptCmd, 0);
90
 
  addBigButton("Game Properties", kInfoCmd, 0);
91
 
#ifdef CHEATCODE_SUPPORT
92
 
  addBigButton("Cheat Code", kCheatCmd, 0);
93
 
#else
94
 
  b = addBigButton("Cheat Code", kCheatCmd, 0);
95
 
  b->clearFlags(WIDGET_ENABLED);
96
 
#endif
97
 
  addBigButton("Help", kHelpCmd, 0);
98
 
  addBigButton("About", kAboutCmd, 0);
99
 
  addBigButton("Exit Menu", kExitCmd, 0);
 
75
  myVideoSettingsButton = addBigButton("Video Settings", kVidCmd);
 
76
  wid.push_back(myVideoSettingsButton);
 
77
 
 
78
  myAudioSettingsButton = addBigButton("Audio Settings", kAudCmd);
 
79
#ifndef SOUND_SUPPORT
 
80
  myAudioSettingsButton->clearFlags(WIDGET_ENABLED);
 
81
#endif
 
82
  wid.push_back(myAudioSettingsButton);
 
83
 
 
84
  b = addBigButton("Input Settings", kInptCmd);
 
85
  wid.push_back(b);
 
86
 
 
87
  myUIButton = addBigButton("UI Settings", kUsrIfaceCmd);
 
88
  wid.push_back(myUIButton);
 
89
 
 
90
  myFileSnapButton = addBigButton("Config Files", kFileSnapCmd);
 
91
  wid.push_back(myFileSnapButton);
 
92
 
 
93
  myRomAuditButton = addBigButton("Audit ROMs", kAuditCmd);
 
94
  wid.push_back(myRomAuditButton);
 
95
 
 
96
  // Move to second column
 
97
  xoffset += buttonWidth + 10;  yoffset = 10;
 
98
 
 
99
  myGameInfoButton = addBigButton("Game Properties", kInfoCmd);
 
100
  wid.push_back(myGameInfoButton);
 
101
 
 
102
  myCheatCodeButton = addBigButton("Cheat Code", kCheatCmd);
 
103
#ifndef CHEATCODE_SUPPORT
 
104
  myCheatCodeButton->clearFlags(WIDGET_ENABLED);
 
105
#endif
 
106
  wid.push_back(myCheatCodeButton);
 
107
 
 
108
  myHelpButton = addBigButton("Help", kHelpCmd);
 
109
  wid.push_back(myHelpButton);
 
110
 
 
111
  myAboutButton = addBigButton("About", kAboutCmd);
 
112
  wid.push_back(myAboutButton);
 
113
 
 
114
  b = addBigButton("Exit Menu", kExitCmd);
 
115
  wid.push_back(b);
 
116
  addCancelWidget(b);
100
117
 
101
118
  // Set some sane values for the dialog boxes
102
 
  int fbWidth  = osystem->frameBuffer().baseWidth();
103
 
  int fbHeight = osystem->frameBuffer().baseHeight();
104
 
  int x, y, w, h;
 
119
  int x = 0, y = 0, w, h;
105
120
 
106
121
  // Now create all the dialogs attached to each menu button
107
 
  w = 230; h = 135;
108
 
  checkBounds(fbWidth, fbHeight, &x, &y, &w, &h);
 
122
  w = 240; h = 185;
109
123
  myVideoDialog = new VideoDialog(myOSystem, parent, font, x, y, w, h);
110
124
 
111
 
  w = 200; h = 110;
112
 
  checkBounds(fbWidth, fbHeight, &x, &y, &w, &h);
 
125
  w = 200; h = 140;
113
126
  myAudioDialog = new AudioDialog(myOSystem, parent, font, x, y, w, h);
114
127
 
 
128
#ifdef _WIN32_WCE
 
129
  // we scale the input dialog down a bit in low res devices.
 
130
  // looks only a little ugly, but the functionality is very welcome
 
131
  if(myOSystem->desktopWidth() < 320) { w = 220; h = 176; }
 
132
  else                                { w = 230; h = 185; }
 
133
#else
115
134
  w = 230; h = 185;
116
 
  checkBounds(fbWidth, fbHeight, &x, &y, &w, &h);
 
135
#endif
117
136
  myInputDialog = new InputDialog(myOSystem, parent, font, x, y, w, h);
118
137
 
119
 
  w = 255; h = 175;
120
 
  checkBounds(fbWidth, fbHeight, &x, &y, &w, &h);
 
138
  w = 200; h = 155;
 
139
  myUIDialog = new UIDialog(myOSystem, parent, font, x, y, w, h);
 
140
 
 
141
  w = 280; h = 180;
 
142
  myFileSnapDialog = new FileSnapDialog(myOSystem, parent, font,
 
143
                                        boss, x, y, w, h);
 
144
 
 
145
  w = 240; h = 115;
 
146
  myRomAuditDialog = new RomAuditDialog(myOSystem, parent, font, x, y, w, h);
 
147
 
 
148
  w = 255; h = 190;
121
149
  myGameInfoDialog = new GameInfoDialog(myOSystem, parent, font, this, x, y, w, h);
122
150
 
123
151
#ifdef CHEATCODE_SUPPORT
124
152
  w = 230; h = 150;
125
 
  checkBounds(fbWidth, fbHeight, &x, &y, &w, &h);
126
153
  myCheatCodeDialog = new CheatCodeDialog(myOSystem, parent, font, x, y, w, h);
127
154
#endif
128
155
 
129
156
  w = 255; h = 150;
130
 
  checkBounds(fbWidth, fbHeight, &x, &y, &w, &h);
131
157
  myHelpDialog = new HelpDialog(myOSystem, parent, font, x, y, w, h);
132
158
 
133
159
  w = 255; h = 150;
134
 
  checkBounds(fbWidth, fbHeight, &x, &y, &w, &h);
135
160
  myAboutDialog = new AboutDialog(myOSystem, parent, font, x, y, w, h);
 
161
 
 
162
  addToFocusList(wid);
 
163
 
 
164
  // Certain buttons are disabled depending on mode
 
165
  if(myIsGlobal)
 
166
  {
 
167
    myCheatCodeButton->clearFlags(WIDGET_ENABLED);
 
168
  }
 
169
  else
 
170
  {
 
171
    myRomAuditButton->clearFlags(WIDGET_ENABLED);
 
172
  }
 
173
#ifdef _WIN32_WCE
 
174
  myAudioSettingsButton->clearFlags(WIDGET_ENABLED);  // not honored in wince port
 
175
#endif
 
176
  if(myOSystem->desktopWidth() < 320)
 
177
  {
 
178
    // These cannot be displayed in low res devices
 
179
    myVideoSettingsButton->clearFlags(WIDGET_ENABLED);
 
180
    myFileSnapButton->clearFlags(WIDGET_ENABLED);
 
181
    myGameInfoButton->clearFlags(WIDGET_ENABLED);
 
182
    myHelpButton->clearFlags(WIDGET_ENABLED);
 
183
    myAboutButton->clearFlags(WIDGET_ENABLED);
 
184
  }
136
185
}
137
186
 
138
187
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
141
190
  delete myVideoDialog;
142
191
  delete myAudioDialog;
143
192
  delete myInputDialog;
 
193
  delete myUIDialog;
 
194
  delete myFileSnapDialog;
 
195
  delete myRomAuditDialog;
144
196
  delete myGameInfoDialog;
145
197
#ifdef CHEATCODE_SUPPORT
146
198
  delete myCheatCodeDialog;
150
202
}
151
203
 
152
204
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
153
 
void OptionsDialog::checkBounds(int width, int height,
154
 
                                int* x, int* y, int* w, int* h)
 
205
void OptionsDialog::loadConfig()
155
206
{
156
 
  if(*w > width) *w = width;
157
 
  if(*h > height) *h = height;
158
 
  *x = (width - *w) / 2;
159
 
  *y = (height - *h) / 2;
 
207
  // Determine whether we should show the 'Game Information' button
 
208
  // We always show it in emulation mode, or if a valid ROM is selected
 
209
  // in launcher mode
 
210
  switch(instance()->eventHandler().state())
 
211
  {
 
212
    case EventHandler::S_EMULATE:
 
213
      myGameInfoButton->setFlags(WIDGET_ENABLED);
 
214
      break;
 
215
    case EventHandler::S_LAUNCHER:
 
216
      if(instance()->launcher().selectedRomMD5() != "")
 
217
        myGameInfoButton->setFlags(WIDGET_ENABLED);
 
218
      else
 
219
        myGameInfoButton->clearFlags(WIDGET_ENABLED);
 
220
      break;
 
221
    default:
 
222
      break;
 
223
  }
160
224
}
161
225
 
162
226
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
177
241
      parent()->addDialog(myInputDialog);
178
242
      break;
179
243
 
 
244
    case kUsrIfaceCmd:
 
245
      parent()->addDialog(myUIDialog);
 
246
      break;
 
247
 
 
248
    case kFileSnapCmd:
 
249
      parent()->addDialog(myFileSnapDialog);
 
250
      break;
 
251
 
 
252
    case kAuditCmd:
 
253
      parent()->addDialog(myRomAuditDialog);
 
254
      break;
 
255
 
180
256
    case kInfoCmd:
181
257
      parent()->addDialog(myGameInfoDialog);
182
258
      break;
196
272
      break;
197
273
 
198
274
    case kExitCmd:
199
 
      instance()->eventHandler().leaveMenuMode();
 
275
      if(myIsGlobal)
 
276
        close();
 
277
      else
 
278
        instance()->eventHandler().leaveMenuMode();
200
279
      break;
201
280
 
202
281
    default: