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
|
|
|
|
//
|
2005-06-16 00:56:00 +00:00
|
|
|
// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team
|
2005-03-10 22:59:40 +00:00
|
|
|
//
|
|
|
|
// See the file "license" for information on usage and redistribution of
|
|
|
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
|
|
|
//
|
2005-07-05 15:25:45 +00:00
|
|
|
// $Id: OptionsDialog.cxx,v 1.21 2005-07-05 15:25:44 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 "Dialog.hxx"
|
2005-05-10 19:20:45 +00:00
|
|
|
#include "DialogContainer.hxx"
|
2005-03-11 23:36:30 +00:00
|
|
|
#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-05-16 00:02:32 +00:00
|
|
|
#include "AboutDialog.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',
|
|
|
|
kInfoCmd = 'INFO',
|
|
|
|
kHelpCmd = 'HELP',
|
2005-06-14 12:18:37 +00:00
|
|
|
kAboutCmd = 'ABOU',
|
|
|
|
kExitCmd = 'EXIM'
|
2005-03-10 22:59:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
2005-03-13 03:38:41 +00:00
|
|
|
kRowHeight = 22,
|
2005-05-16 00:02:32 +00:00
|
|
|
kBigButtonWidth = 90,
|
2005-03-11 23:36:30 +00:00
|
|
|
kMainMenuWidth = (kBigButtonWidth + 2 * 8),
|
2005-06-14 12:18:37 +00:00
|
|
|
kMainMenuHeight = 7 * 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-05-10 19:20:45 +00:00
|
|
|
OptionsDialog::OptionsDialog(OSystem* osystem, DialogContainer* parent)
|
|
|
|
: Dialog(osystem, parent,
|
|
|
|
(osystem->frameBuffer().baseWidth() - kMainMenuWidth) / 2,
|
|
|
|
(osystem->frameBuffer().baseHeight() - kMainMenuHeight)/2,
|
|
|
|
kMainMenuWidth, kMainMenuHeight),
|
2005-05-16 00:02:32 +00:00
|
|
|
myVideoDialog(NULL),
|
|
|
|
myAudioDialog(NULL),
|
|
|
|
myEventMappingDialog(NULL),
|
|
|
|
myGameInfoDialog(NULL),
|
|
|
|
myHelpDialog(NULL),
|
|
|
|
myAboutDialog(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-05-16 00:02:32 +00:00
|
|
|
addBigButton("Video Settings", kVidCmd, 0);
|
2005-05-01 18:57:21 +00:00
|
|
|
#ifdef SOUND_SUPPORT
|
2005-05-16 00:02:32 +00:00
|
|
|
addBigButton("Audio Settings", kAudCmd, 0);
|
2005-05-01 18:57:21 +00:00
|
|
|
#else
|
2005-05-16 00:02:32 +00:00
|
|
|
ButtonWidget* b = addBigButton("Audio Settings", kAudCmd, 0);
|
2005-05-01 18:57:21 +00:00
|
|
|
b->setEnabled(false);
|
|
|
|
#endif
|
2005-05-16 00:02:32 +00:00
|
|
|
addBigButton("Event Mapping", kEMapCmd, 0);
|
|
|
|
addBigButton("Game Information", kInfoCmd, 0);
|
|
|
|
addBigButton("Help", kHelpCmd, 0);
|
|
|
|
addBigButton("About", kAboutCmd, 0);
|
2005-06-14 12:18:37 +00:00
|
|
|
addBigButton("Exit Menu", kExitCmd, 0);
|
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-05-13 18:28:06 +00:00
|
|
|
int fbWidth = osystem->frameBuffer().baseWidth();
|
|
|
|
int fbHeight = osystem->frameBuffer().baseHeight();
|
|
|
|
int x, y, w, h;
|
2005-03-14 04:08:15 +00:00
|
|
|
|
2005-03-11 23:36:30 +00:00
|
|
|
// Now create all the dialogs attached to each menu button
|
2005-04-29 19:05:06 +00:00
|
|
|
w = 230; h = 130;
|
2005-03-26 19:26:48 +00:00
|
|
|
checkBounds(fbWidth, fbHeight, &x, &y, &w, &h);
|
2005-05-10 19:20:45 +00:00
|
|
|
myVideoDialog = new VideoDialog(myOSystem, parent, 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-05-10 19:20:45 +00:00
|
|
|
myAudioDialog = new AudioDialog(myOSystem, parent, x, y, w, h);
|
2005-03-14 04:08:15 +00:00
|
|
|
|
2005-05-16 00:02:32 +00:00
|
|
|
w = 230; h = 170;
|
2005-04-04 02:19:22 +00:00
|
|
|
checkBounds(fbWidth, fbHeight, &x, &y, &w, &h);
|
2005-05-10 19:20:45 +00:00
|
|
|
myEventMappingDialog = new EventMappingDialog(myOSystem, parent, x, y, w, h);
|
2005-04-04 02:19:22 +00:00
|
|
|
|
2005-03-27 03:07:34 +00:00
|
|
|
w = 255; h = 150;
|
|
|
|
checkBounds(fbWidth, fbHeight, &x, &y, &w, &h);
|
2005-05-10 19:20:45 +00:00
|
|
|
myGameInfoDialog = new GameInfoDialog(myOSystem, parent, x, y, w, h);
|
2005-03-27 03:07:34 +00:00
|
|
|
|
|
|
|
w = 255; h = 150;
|
|
|
|
checkBounds(fbWidth, fbHeight, &x, &y, &w, &h);
|
2005-05-10 19:20:45 +00:00
|
|
|
myHelpDialog = new HelpDialog(myOSystem, parent, x, y, w, h);
|
2005-05-16 00:02:32 +00:00
|
|
|
|
|
|
|
w = 255; h = 150;
|
|
|
|
checkBounds(fbWidth, fbHeight, &x, &y, &w, &h);
|
|
|
|
myAboutDialog = new AboutDialog(myOSystem, parent, 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-11 23:36:30 +00:00
|
|
|
delete myGameInfoDialog;
|
|
|
|
delete myHelpDialog;
|
2005-05-16 00:02:32 +00:00
|
|
|
delete myAboutDialog;
|
2005-03-10 22:59:40 +00:00
|
|
|
}
|
|
|
|
|
2005-03-26 19:26:48 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2005-05-13 18:28:06 +00:00
|
|
|
void OptionsDialog::checkBounds(int width, int height,
|
|
|
|
int* x, int* y, int* w, int* h)
|
2005-03-26 19:26:48 +00:00
|
|
|
{
|
|
|
|
if(*w > width) *w = width;
|
|
|
|
if(*h > height) *h = height;
|
|
|
|
*x = (width - *w) / 2;
|
|
|
|
*y = (height - *h) / 2;
|
|
|
|
}
|
|
|
|
|
2005-05-16 15:37:30 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void OptionsDialog::reset()
|
|
|
|
{
|
|
|
|
myVideoDialog->reset();
|
|
|
|
myAudioDialog->reset();
|
|
|
|
myEventMappingDialog->reset();
|
|
|
|
myGameInfoDialog->reset();
|
|
|
|
myHelpDialog->reset();
|
|
|
|
myAboutDialog->reset();
|
|
|
|
}
|
|
|
|
|
2005-03-26 19:26:48 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2005-07-05 15:25:45 +00:00
|
|
|
void OptionsDialog::handleCommand(CommandSender* sender, int cmd,
|
|
|
|
int data, int id)
|
2005-03-11 23:36:30 +00:00
|
|
|
{
|
|
|
|
switch(cmd)
|
|
|
|
{
|
|
|
|
case kVidCmd:
|
2005-05-10 19:20:45 +00:00
|
|
|
parent()->addDialog(myVideoDialog);
|
2005-03-11 23:36:30 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case kAudCmd:
|
2005-05-10 19:20:45 +00:00
|
|
|
parent()->addDialog(myAudioDialog);
|
2005-03-11 23:36:30 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case kEMapCmd:
|
2005-05-10 19:20:45 +00:00
|
|
|
parent()->addDialog(myEventMappingDialog);
|
2005-03-11 23:36:30 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case kInfoCmd:
|
2005-05-10 19:20:45 +00:00
|
|
|
parent()->addDialog(myGameInfoDialog);
|
2005-03-11 23:36:30 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case kHelpCmd:
|
2005-05-10 19:20:45 +00:00
|
|
|
parent()->addDialog(myHelpDialog);
|
2005-03-11 23:36:30 +00:00
|
|
|
break;
|
|
|
|
|
2005-05-16 00:02:32 +00:00
|
|
|
case kAboutCmd:
|
|
|
|
parent()->addDialog(myAboutDialog);
|
|
|
|
break;
|
|
|
|
|
2005-06-14 12:18:37 +00:00
|
|
|
case kExitCmd:
|
|
|
|
instance()->eventHandler().leaveMenuMode();
|
|
|
|
break;
|
|
|
|
|
2005-03-11 23:36:30 +00:00
|
|
|
default:
|
2005-07-05 15:25:45 +00:00
|
|
|
Dialog::handleCommand(sender, cmd, data, 0);
|
2005-03-11 23:36:30 +00:00
|
|
|
}
|
2005-03-10 22:59:40 +00:00
|
|
|
}
|