2005-03-10 22:59:40 +00:00
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// SSSS tt lll lll
|
|
|
|
// SS SS tt ll ll
|
|
|
|
// SS tttttt eeee ll ll aaaa
|
|
|
|
// SSSS tt ee ee ll ll aa
|
|
|
|
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
|
|
|
|
// SS SS tt ee ll ll aa aa
|
|
|
|
// SSSS ttt eeeee llll llll aaaaa
|
|
|
|
//
|
|
|
|
// Copyright (c) 1995-2005 by Bradford W. Mott
|
|
|
|
//
|
|
|
|
// See the file "license" for information on usage and redistribution of
|
|
|
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
|
|
|
//
|
2005-04-28 19:28:33 +00:00
|
|
|
// $Id: OptionsDialog.cxx,v 1.11 2005-04-28 19:28:33 stephena Exp $
|
2005-03-10 22:59:40 +00:00
|
|
|
//
|
|
|
|
// Based on code from ScummVM - Scumm Interpreter
|
|
|
|
// Copyright (C) 2002-2004 The ScummVM project
|
|
|
|
//============================================================================
|
|
|
|
|
2005-03-11 23:36:30 +00:00
|
|
|
#include "OSystem.hxx"
|
|
|
|
#include "Menu.hxx"
|
|
|
|
#include "Dialog.hxx"
|
|
|
|
#include "Widget.hxx"
|
|
|
|
#include "Control.hxx"
|
2005-03-14 04:08:15 +00:00
|
|
|
#include "VideoDialog.hxx"
|
2005-03-26 19:26:48 +00:00
|
|
|
#include "AudioDialog.hxx"
|
2005-04-04 02:19:22 +00:00
|
|
|
#include "EventMappingDialog.hxx"
|
2005-03-27 03:07:34 +00:00
|
|
|
#include "GameInfoDialog.hxx"
|
|
|
|
#include "HelpDialog.hxx"
|
2005-03-11 23:36:30 +00:00
|
|
|
#include "OptionsDialog.hxx"
|
2005-03-10 22:59:40 +00:00
|
|
|
|
2005-03-11 23:36:30 +00:00
|
|
|
#include "bspf.hxx"
|
2005-03-10 22:59:40 +00:00
|
|
|
|
|
|
|
enum {
|
2005-03-11 23:36:30 +00:00
|
|
|
kVidCmd = 'VIDO',
|
|
|
|
kAudCmd = 'AUDO',
|
|
|
|
kEMapCmd = 'EMAP',
|
|
|
|
kMiscCmd = 'MISC',
|
|
|
|
kInfoCmd = 'INFO',
|
|
|
|
kHelpCmd = 'HELP',
|
2005-03-10 22:59:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
2005-03-13 03:38:41 +00:00
|
|
|
kRowHeight = 22,
|
|
|
|
kBigButtonWidth = 100,
|
2005-03-11 23:36:30 +00:00
|
|
|
kMainMenuWidth = (kBigButtonWidth + 2 * 8),
|
2005-03-12 01:47:15 +00:00
|
|
|
kMainMenuHeight = 6 * kRowHeight + 10,
|
2005-03-10 22:59:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define addBigButton(label, cmd, hotkey) \
|
2005-03-14 04:08:15 +00:00
|
|
|
new ButtonWidget(this, xoffset, yoffset, kBigButtonWidth, 18, label, cmd, hotkey); yoffset += kRowHeight
|
2005-03-10 22:59:40 +00:00
|
|
|
|
2005-03-26 19:26:48 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2005-03-11 23:36:30 +00:00
|
|
|
OptionsDialog::OptionsDialog(OSystem* osystem)
|
2005-03-28 00:04:54 +00:00
|
|
|
// FIXME - we have to initialize the video system at least once *before*
|
|
|
|
// creating a new console. For now, just use predefined values.
|
|
|
|
// Eventually, this subsystem will have to take into account screen size changes
|
|
|
|
: Dialog(osystem, (osystem->frameBuffer().baseWidth() - kMainMenuWidth) / 2,
|
|
|
|
(osystem->frameBuffer().baseHeight() - kMainMenuHeight)/2,
|
2005-03-14 04:08:15 +00:00
|
|
|
kMainMenuWidth, kMainMenuHeight),
|
|
|
|
myVideoDialog(NULL)
|
2005-03-11 23:36:30 +00:00
|
|
|
{
|
2005-03-14 04:08:15 +00:00
|
|
|
int yoffset = 7;
|
|
|
|
const int xoffset = (_w - kBigButtonWidth) / 2;
|
2005-03-10 22:59:40 +00:00
|
|
|
|
2005-03-12 01:47:15 +00:00
|
|
|
addBigButton("Video Settings", kVidCmd, 'V');
|
|
|
|
addBigButton("Audio Settings", kAudCmd, 'A');
|
2005-03-11 23:36:30 +00:00
|
|
|
addBigButton("Event Remapping", kEMapCmd, 'E');
|
2005-03-12 01:47:15 +00:00
|
|
|
addBigButton("Miscellaneous", kMiscCmd, 'M');
|
|
|
|
addBigButton("Game Information", kInfoCmd, 'I');
|
2005-03-11 23:36:30 +00:00
|
|
|
addBigButton("Help", kHelpCmd, 'H');
|
2005-03-10 22:59:40 +00:00
|
|
|
|
2005-03-14 04:08:15 +00:00
|
|
|
// Set some sane values for the dialog boxes
|
2005-03-28 00:04:54 +00:00
|
|
|
uInt16 fbWidth = osystem->frameBuffer().baseWidth();
|
|
|
|
uInt16 fbHeight = osystem->frameBuffer().baseHeight();
|
2005-03-14 04:08:15 +00:00
|
|
|
uInt16 x, y, w, h;
|
|
|
|
|
2005-03-11 23:36:30 +00:00
|
|
|
// Now create all the dialogs attached to each menu button
|
2005-04-28 19:28:33 +00:00
|
|
|
w = 230; h = 150;
|
2005-03-26 19:26:48 +00:00
|
|
|
checkBounds(fbWidth, fbHeight, &x, &y, &w, &h);
|
|
|
|
myVideoDialog = new VideoDialog(myOSystem, x, y, w, h);
|
2005-03-14 04:08:15 +00:00
|
|
|
|
2005-04-28 19:28:33 +00:00
|
|
|
w = 200; h = 100;
|
2005-03-26 19:26:48 +00:00
|
|
|
checkBounds(fbWidth, fbHeight, &x, &y, &w, &h);
|
2005-03-27 03:07:34 +00:00
|
|
|
myAudioDialog = new AudioDialog(myOSystem, x, y, w, h);
|
2005-03-14 04:08:15 +00:00
|
|
|
|
2005-04-05 00:40:55 +00:00
|
|
|
w = 280; h = 170;
|
2005-04-04 02:19:22 +00:00
|
|
|
checkBounds(fbWidth, fbHeight, &x, &y, &w, &h);
|
|
|
|
myEventMappingDialog = new EventMappingDialog(myOSystem, x, y, w, h);
|
|
|
|
|
|
|
|
// w = 250; h = 150;
|
|
|
|
// checkBounds(fbWidth, fbHeight, &x, &y, &w, &h);
|
|
|
|
// myMiscDialog = new MiscDialog(myOSystem, x, y, w, h);
|
|
|
|
|
2005-03-27 03:07:34 +00:00
|
|
|
w = 255; h = 150;
|
|
|
|
checkBounds(fbWidth, fbHeight, &x, &y, &w, &h);
|
|
|
|
myGameInfoDialog = new GameInfoDialog(myOSystem, x, y, w, h);
|
|
|
|
|
|
|
|
w = 255; h = 150;
|
|
|
|
checkBounds(fbWidth, fbHeight, &x, &y, &w, &h);
|
|
|
|
myHelpDialog = new HelpDialog(myOSystem, x, y, w, h);
|
2005-03-10 22:59:40 +00:00
|
|
|
}
|
|
|
|
|
2005-03-26 19:26:48 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2005-03-11 23:36:30 +00:00
|
|
|
OptionsDialog::~OptionsDialog()
|
|
|
|
{
|
|
|
|
delete myVideoDialog;
|
|
|
|
delete myAudioDialog;
|
2005-04-04 02:19:22 +00:00
|
|
|
delete myEventMappingDialog;
|
2005-03-27 03:07:34 +00:00
|
|
|
// delete myMiscDialog;
|
2005-03-11 23:36:30 +00:00
|
|
|
delete myGameInfoDialog;
|
|
|
|
delete myHelpDialog;
|
2005-03-10 22:59:40 +00:00
|
|
|
}
|
|
|
|
|
2005-03-26 19:26:48 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2005-03-28 00:04:54 +00:00
|
|
|
void OptionsDialog::checkBounds(uInt16 width, uInt16 height,
|
2005-03-26 19:26:48 +00:00
|
|
|
uInt16* x, uInt16* y, uInt16* w, uInt16* h)
|
|
|
|
{
|
|
|
|
if(*w > width) *w = width;
|
|
|
|
if(*h > height) *h = height;
|
|
|
|
*x = (width - *w) / 2;
|
|
|
|
*y = (height - *h) / 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2005-03-11 23:36:30 +00:00
|
|
|
void OptionsDialog::handleCommand(CommandSender* sender, uInt32 cmd, uInt32 data)
|
|
|
|
{
|
|
|
|
switch(cmd)
|
|
|
|
{
|
|
|
|
case kVidCmd:
|
2005-03-14 04:08:15 +00:00
|
|
|
instance()->menu().addDialog(myVideoDialog);
|
2005-03-11 23:36:30 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case kAudCmd:
|
2005-03-26 19:26:48 +00:00
|
|
|
instance()->menu().addDialog(myAudioDialog);
|
2005-03-11 23:36:30 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case kEMapCmd:
|
2005-04-04 02:19:22 +00:00
|
|
|
instance()->menu().addDialog(myEventMappingDialog);
|
2005-03-11 23:36:30 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case kMiscCmd:
|
|
|
|
// instance()->menu().addDialog(myMiscDialog);
|
|
|
|
cerr << "push MiscDialog to top of stack\n";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kInfoCmd:
|
2005-03-27 03:07:34 +00:00
|
|
|
instance()->menu().addDialog(myGameInfoDialog);
|
2005-03-11 23:36:30 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case kHelpCmd:
|
2005-03-27 03:07:34 +00:00
|
|
|
instance()->menu().addDialog(myHelpDialog);
|
2005-03-11 23:36:30 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
Dialog::handleCommand(sender, cmd, data);
|
|
|
|
}
|
2005-03-10 22:59:40 +00:00
|
|
|
}
|