Commit 6f51b603 authored by thrust26's avatar thrust26
Browse files

renamed and refined StellaSettingsDialog

added to OptionsDialog for testing
parent 785f7dc4
......@@ -60,6 +60,7 @@ class OSystem
{
friend class EventHandler;
friend class VideoDialog;
friend class StellaSettingsDialog;
friend class DeveloperDialog;
public:
......
......@@ -32,6 +32,7 @@
#include "GameInfoDialog.hxx"
#include "LoggerDialog.hxx"
#include "DeveloperDialog.hxx"
#include "StellaSettingsDialog.hxx"
#include "HelpDialog.hxx"
#include "AboutDialog.hxx"
#include "OptionsDialog.hxx"
......@@ -88,7 +89,11 @@ OptionsDialog::OptionsDialog(OSystem& osystem, DialogContainer& parent,
b = ADD_OD_BUTTON("Snapshots" + ELLIPSIS, kSnapCmd);
wid.push_back(b);
yoffset += rowHeight;
//yoffset += rowHeight;
// R77 TEST
b = ADD_OD_BUTTON("Stella Options" + ELLIPSIS, kStellaOptionsCmd);
wid.push_back(b);
b = ADD_OD_BUTTON("Developer" + ELLIPSIS, kDevelopCmd);
wid.push_back(b);
......@@ -127,6 +132,7 @@ OptionsDialog::OptionsDialog(OSystem& osystem, DialogContainer& parent,
myInputDialog = make_unique<InputDialog>(osystem, parent, _font, max_w, max_h);
myUIDialog = make_unique<UIDialog>(osystem, parent, _font, boss, max_w, max_h);
mySnapshotDialog = make_unique<SnapshotDialog>(osystem, parent, _font, max_w, max_h);
myStellaOptionsDialog = make_unique<StellaSettingsDialog>(osystem, parent, _font, max_w, max_h);
myDeveloperDialog = make_unique<DeveloperDialog>(osystem, parent, _font, max_w, max_h);
myGameInfoDialog = make_unique<GameInfoDialog>(osystem, parent, _font, this, max_w, max_h);
#ifdef CHEATCODE_SUPPORT
......@@ -251,6 +257,21 @@ void OptionsDialog::handleCommand(CommandSender* sender, int cmd,
break;
}
case kStellaOptionsCmd:
{
// This dialog is resizable under certain conditions, so we need
// to re-create it as necessary
uInt32 w = 0, h = 0;
if (myStellaOptionsDialog == nullptr || myStellaOptionsDialog->shouldResize(w, h))
{
myStellaOptionsDialog = make_unique<StellaSettingsDialog>(instance(), parent(),
instance().frameBuffer().font(), w, h);
}
myStellaOptionsDialog->open();
break;
}
case kInfoCmd:
{
// This dialog is resizable under certain conditions, so we need
......
......@@ -39,6 +39,7 @@ class LoggerDialog;
#include "Dialog.hxx"
class DeveloperDialog;
class StellaSettingsDialog;
class OptionsDialog : public Dialog
{
......@@ -61,6 +62,7 @@ class OptionsDialog : public Dialog
unique_ptr<UIDialog> myUIDialog;
unique_ptr<SnapshotDialog> mySnapshotDialog;
unique_ptr<DeveloperDialog> myDeveloperDialog;
unique_ptr<StellaSettingsDialog> myStellaOptionsDialog;
unique_ptr<GameInfoDialog> myGameInfoDialog;
#ifdef CHEATCODE_SUPPORT
unique_ptr<CheatCodeDialog> myCheatCodeDialog;
......@@ -88,6 +90,7 @@ class OptionsDialog : public Dialog
kCheatCmd = 'CHET',
kLoggerCmd = 'LOGG',
kDevelopCmd = 'DEVL',
kStellaOptionsCmd = 'STOP',
kHelpCmd = 'HELP',
kAboutCmd = 'ABOU',
kExitCmd = 'EXIM'
......
//============================================================================
//
// 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-2019 by Bradford W. Mott, Stephen Anthony
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================
#include "NTSCFilter.hxx"
#include "PopUpWidget.hxx"
#include "StellaOptionsDialog.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
StellaOptionsDialog::StellaOptionsDialog(OSystem& osystem, DialogContainer& parent,
const GUI::Font& font, int max_w, int max_h)
: Dialog(osystem, parent, font, "Stella options")
{
const int VGAP = 4;
const int VBORDER = 8*2;
const int HBORDER = 10*2;
const int INDENT = 20;
const int lineHeight = font.getLineHeight(),
fontWidth = font.getMaxCharWidth(),
buttonHeight = font.getLineHeight() + 4;
int xpos, ypos;
WidgetArray wid;
VariantList items;
// Set real dimensions
setSize(33 * fontWidth + HBORDER * 2, 11 * (lineHeight + VGAP) + _th, max_w, max_h);
xpos = HBORDER;
ypos = VBORDER + _th;
addUIOptions(wid, xpos, ypos, font);
ypos += VGAP * 5;
addVideoOptions(wid, xpos, ypos, font);
ypos += VGAP * 4;
addSoundOptions(wid, xpos, ypos, font);
addToFocusList(wid);
wid.clear();
addDefaultsOKCancelBGroup(wid, font);
addBGroupToFocusList(wid);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void StellaOptionsDialog::addUIOptions(WidgetArray wid, int& xpos, int& ypos, const GUI::Font& font)
{
const int VGAP = 4;
const int lineHeight = font.getLineHeight(),
fontWidth = font.getMaxCharWidth();
VariantList items;
int pwidth = font.getStringWidth("Bad adjust");
ypos += 1;
VarList::push_back(items, "Standard", "standard");
VarList::push_back(items, "Classic", "classic");
VarList::push_back(items, "Light", "light");
myThemePopup = new PopUpWidget(this, font, xpos, ypos, pwidth, lineHeight, items, "UI Theme ");
wid.push_back(myThemePopup);
ypos += lineHeight;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void StellaOptionsDialog::addVideoOptions(WidgetArray wid, int& xpos, int& ypos, const GUI::Font& font)
{
const int VGAP = 4;
const int INDENT = 20;
const int lineHeight = font.getLineHeight(),
fontWidth = font.getMaxCharWidth();
VariantList items;
// TV effects options
int swidth = font.getMaxCharWidth() * 8 - 4;
// TV Mode
items.clear();
VarList::push_back(items, "Disabled", NTSCFilter::PRESET_OFF);
VarList::push_back(items, "RGB", NTSCFilter::PRESET_RGB);
VarList::push_back(items, "S-Video", NTSCFilter::PRESET_SVIDEO);
VarList::push_back(items, "Composite", NTSCFilter::PRESET_COMPOSITE);
VarList::push_back(items, "Bad adjust", NTSCFilter::PRESET_BAD);
int lwidth = font.getStringWidth("TV Mode ");
int pwidth = font.getStringWidth("Bad adjust");
myTVMode = new PopUpWidget(this, font, xpos, ypos, pwidth, lineHeight,
items, "TV mode ", lwidth, kTVModeChanged);
wid.push_back(myTVMode);
ypos += lineHeight + VGAP * 2;
#define CREATE_CUSTOM_SLIDERS(obj, desc) \
myTV ## obj = \
new SliderWidget(this, font, xpos, ypos-1, swidth, lineHeight, \
desc, lwidth, 0, fontWidth*4, "%"); \
myTV ## obj->setMinValue(0); myTV ## obj->setMaxValue(100); \
myTV ## obj->setTickmarkInterval(2); \
myTV ## obj->setStepValue(10); \
wid.push_back(myTV ## obj); \
ypos += lineHeight + VGAP;
lwidth = font.getStringWidth("Intensity ");
swidth = font.getMaxCharWidth() * 10;
// Scanline intensity
myTVScanlines = new CheckboxWidget(this, font, xpos, ypos + 1, "Scanlines", kScanlinesChanged);
ypos += lineHeight;
xpos += INDENT;
CREATE_CUSTOM_SLIDERS(ScanIntense, "Intensity ")
xpos -= INDENT;
// TV Phosphor effect
myTVPhosphor = new CheckboxWidget(this, font, xpos, ypos + 1, "Phosphor effect", kPhosphorChanged);
wid.push_back(myTVPhosphor);
ypos += lineHeight;
// TV Phosphor blend level
xpos += INDENT;
CREATE_CUSTOM_SLIDERS(PhosLevel, "Blend ")
xpos -= INDENT;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void StellaOptionsDialog::addSoundOptions(WidgetArray wid, int& xpos, int& ypos, const GUI::Font& font)
{
const int VGAP = 4;
const int lineHeight = font.getLineHeight();
// Stereo sound
myStereoSoundCheckbox = new CheckboxWidget(this, font, xpos, ypos + 1,
"Stereo sound");
wid.push_back(myStereoSoundCheckbox);
ypos += lineHeight;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void StellaOptionsDialog::loadConfig()
{
//myTab->loadConfig();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void StellaOptionsDialog::saveConfig()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void StellaOptionsDialog::setDefaults()
{
}
//============================================================================
//
// 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-2019 by Bradford W. Mott, Stephen Anthony
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================
#ifndef STELLA_OPTIONS_DIALOG_HXX
#define STELLA_OPTIONS_DIALOG_HXX
class PopUpWidget;
#include "Dialog.hxx"
namespace GUI {
class Font;
}
class StellaOptionsDialog :
public Dialog
{
public:
StellaOptionsDialog(OSystem& osystem, DialogContainer& parent,
const GUI::Font& font, int max_w, int max_h);
virtual ~StellaOptionsDialog() = default;
private:
void loadConfig() override;
void saveConfig() override;
void setDefaults() override;
void addVideoOptions(WidgetArray wid, int& xpos, int& ypos, const GUI::Font& font);
void addSoundOptions(WidgetArray wid, int& xpos, int& ypos, const GUI::Font& font);
void addUIOptions(WidgetArray wid, int& xpos, int& ypos, const GUI::Font& font);
TabWidget* myTab;
// TV effects adjustables (custom mode)
PopUpWidget* myTVMode;
SliderWidget* myTVSharp;
SliderWidget* myTVHue;
SliderWidget* myTVRes;
SliderWidget* myTVArtifacts;
SliderWidget* myTVFringe;
SliderWidget* myTVBleed;
SliderWidget* myTVBright;
SliderWidget* myTVContrast;
SliderWidget* myTVSatur;
SliderWidget* myTVGamma;
// TV phosphor effect
CheckboxWidget* myTVPhosphor;
SliderWidget* myTVPhosLevel;
// TV scanline intensity and interpolation
CheckboxWidget* myTVScanlines;
SliderWidget* myTVScanIntense;
// TV effects adjustables presets (custom mode)
ButtonWidget* myCloneComposite;
ButtonWidget* myCloneSvideo;
ButtonWidget* myCloneRGB;
ButtonWidget* myCloneBad;
ButtonWidget* myCloneCustom;
// Audio options
CheckboxWidget* myStereoSoundCheckbox;
// UI theme
PopUpWidget* myThemePopup;
enum {
kTVModeChanged = 'VDtv',
kCloneCompositeCmd = 'CLcp',
kCloneSvideoCmd = 'CLsv',
kCloneRGBCmd = 'CLrb',
kCloneBadCmd = 'CLbd',
kCloneCustomCmd = 'CLcu',
kPhosphorChanged = 'VDph',
kScanlinesChanged = 'VDsc',
kSoundEnableChanged = 'ADse',
};
// Following constructors and assignment operators not supported
StellaOptionsDialog() = delete;
StellaOptionsDialog(const StellaOptionsDialog&) = delete;
StellaOptionsDialog(StellaOptionsDialog&&) = delete;
StellaOptionsDialog& operator=(const StellaOptionsDialog&) = delete;
StellaOptionsDialog& operator=(StellaOptionsDialog&&) = delete;
};
#endif
//============================================================================
//
// 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-2019 by Bradford W. Mott, Stephen Anthony
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================
#include "Console.hxx"
#include "EventHandler.hxx"
#include "Launcher.hxx"
#include "PropsSet.hxx"
#include "ControllerDetector.hxx"
#include "NTSCFilter.hxx"
#include "PopUpWidget.hxx"
#include "StellaSettingsDialog.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
StellaSettingsDialog::StellaSettingsDialog(OSystem& osystem, DialogContainer& parent,
const GUI::Font& font, int max_w, int max_h)
: Dialog(osystem, parent, font, "Stella settings")
{
const int VGAP = 4;
const int VBORDER = 8;
const int HBORDER = 10;
const int INDENT = 20;
const int lineHeight = font.getLineHeight(),
fontWidth = font.getMaxCharWidth();
int xpos, ypos;
WidgetArray wid;
VariantList items;
// Set real dimensions
setSize(33 * fontWidth + HBORDER * 2, 15 * (lineHeight + VGAP) + _th, max_w, max_h);
xpos = HBORDER;
ypos = VBORDER + _th;
new StaticTextWidget(this, font, xpos, ypos + 1, "Global settings:");
xpos += INDENT;
ypos += lineHeight + VGAP;
addUIOptions(wid, xpos, ypos, font);
ypos += VGAP * 4;
addVideoOptions(wid, xpos, ypos, font);
ypos += VGAP * 4;
xpos -= INDENT;
myGameSettings = new StaticTextWidget(this, font, xpos, ypos + 1, "Game settings:");
xpos += INDENT;
ypos += lineHeight + VGAP;
addGameOptions(wid, xpos, ypos, font);
// Add Defaults, OK and Cancel buttons
addDefaultsOKCancelBGroup(wid, font);
addToFocusList(wid);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void StellaSettingsDialog::addUIOptions(WidgetArray& wid, int& xpos, int& ypos, const GUI::Font& font)
{
const int VGAP = 4;
const int lineHeight = font.getLineHeight(),
fontWidth = font.getMaxCharWidth();
VariantList items;
int pwidth = font.getStringWidth("Bad adjust");
ypos += 1;
VarList::push_back(items, "Standard", "standard");
VarList::push_back(items, "Classic", "classic");
VarList::push_back(items, "Light", "light");
myThemePopup = new PopUpWidget(this, font, xpos, ypos, pwidth, lineHeight, items, "UI theme ");
wid.push_back(myThemePopup);
ypos += lineHeight + VGAP;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void StellaSettingsDialog::addVideoOptions(WidgetArray& wid, int& xpos, int& ypos, const GUI::Font& font)
{
const int VGAP = 4;
const int INDENT = 20;
const int lineHeight = font.getLineHeight(),
fontWidth = font.getMaxCharWidth();
VariantList items;
// TV effects options
int swidth = font.getMaxCharWidth() * 8 - 4;
// TV Mode
items.clear();
VarList::push_back(items, "Disabled", NTSCFilter::PRESET_OFF);
VarList::push_back(items, "RGB", NTSCFilter::PRESET_RGB);
VarList::push_back(items, "S-Video", NTSCFilter::PRESET_SVIDEO);
VarList::push_back(items, "Composite", NTSCFilter::PRESET_COMPOSITE);
VarList::push_back(items, "Bad adjust", NTSCFilter::PRESET_BAD);
int lwidth = font.getStringWidth("TV mode ");
int pwidth = font.getStringWidth("Bad adjust");
myTVMode = new PopUpWidget(this, font, xpos, ypos, pwidth, lineHeight,
items, "TV mode ", lwidth, kTVModeChanged);
wid.push_back(myTVMode);
ypos += lineHeight + VGAP * 2;
#define CREATE_CUSTOM_SLIDERS(obj, desc) \
myTV ## obj = \
new SliderWidget(this, font, xpos, ypos-1, swidth, lineHeight, \
desc, lwidth, 0, fontWidth*4, "%"); \
myTV ## obj->setMinValue(0); myTV ## obj->setMaxValue(100); \
myTV ## obj->setTickmarkInterval(2); \
myTV ## obj->setStepValue(10); \
wid.push_back(myTV ## obj); \
ypos += lineHeight + VGAP;
lwidth = font.getStringWidth("Intensity ");
swidth = font.getMaxCharWidth() * 10;
// Scanline intensity
myTVScanlines = new StaticTextWidget(this, font, xpos, ypos + 1, "Scanlines:");
ypos += lineHeight;
xpos += INDENT;
CREATE_CUSTOM_SLIDERS(ScanIntense, "Intensity ")
xpos -= INDENT;
// TV Phosphor effect
myTVPhosphor = new CheckboxWidget(this, font, xpos, ypos + 1, "Phosphor effect", kPhosphorChanged);
wid.push_back(myTVPhosphor);
ypos += lineHeight;
// TV Phosphor blend level
xpos += INDENT;
CREATE_CUSTOM_SLIDERS(PhosLevel, "Blend ")
xpos -= INDENT;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void StellaSettingsDialog::addGameOptions(WidgetArray& wid, int& xpos, int& ypos, const GUI::Font& font)
{
const int VGAP = 4;
const int lineHeight = font.getLineHeight(),
fontWidth = font.getMaxCharWidth();
const GUI::Font& ifont = instance().frameBuffer().infoFont();
VariantList ctrls;
ctrls.clear();
VarList::push_back(ctrls, "Auto-detect", "AUTO");
VarList::push_back(ctrls, "Joystick", "JOYSTICK");
VarList::push_back(ctrls, "Paddles", "PADDLES");
VarList::push_back(ctrls, "BoosterGrip", "BOOSTERGRIP");
VarList::push_back(ctrls, "Driving", "DRIVING");
VarList::push_back(ctrls, "Keyboard", "KEYBOARD");
VarList::push_back(ctrls, "AmigaMouse", "AMIGAMOUSE");
VarList::push_back(ctrls, "AtariMouse", "ATARIMOUSE");
VarList::push_back(ctrls, "Trakball", "TRAKBALL");
VarList::push_back(ctrls, "Sega Genesis", "GENESIS");
int pwidth = font.getStringWidth("Sega Genesis");
myLeftPortLabel = new StaticTextWidget(this, font, xpos, ypos + 1, "Left port ");
myLeftPort = new PopUpWidget(this, font, myLeftPortLabel->getRight(),
myLeftPortLabel->getTop() - 1, pwidth, lineHeight, ctrls, "");
wid.push_back(myLeftPort);
ypos += lineHeight + VGAP;
myLeftPortDetected = new StaticTextWidget(this, ifont, myLeftPort->getLeft(), ypos,
"Sega Genesis detected");
ypos += ifont.getLineHeight() + VGAP;
myRightPortLabel = new StaticTextWidget(this, font, xpos, ypos + 1, "Right port ");
myRightPort = new PopUpWidget(this, font, myRightPortLabel->getRight(),
myRightPortLabel->getTop() - 1, pwidth, lineHeight, ctrls, "");
wid.push_back(myRightPort);
ypos += lineHeight + VGAP;
myRightPortDetected = new StaticTextWidget(this, ifont, myRightPort->getLeft(), ypos,
"Sega Genesis detected");
ypos += ifont.getLineHeight() + VGAP;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void StellaSettingsDialog::loadConfig()
{
const Settings& settings = instance().settings();
// UI palette
const string& theme = settings.getString("uipalette");
myThemePopup->setSelected(theme, "standard");
// TV Mode
myTVMode->setSelected(
settings.getString("tv.filter"), "0");
// TV scanline intensity and interpolation
myTVScanIntense->setValue(settings.getInt("tv.scanlines"));
handleTVModeChange();
// TV phosphor mode
myTVPhosphor->setState(settings.getString("tv.phosphor") == "always");
// TV phosphor blend
myTVPhosLevel->setValue(settings.getInt("tv.phosblend"));
handlePhosphorChange();
// Controllers
Properties props;
if (instance().hasConsole())
{
myGameProperties = instance().console().properties();
}
else
{
const string& md5 = instance().launcher().selectedRomMD5();
instance().propSet().getMD5(md5, myGameProperties);
}
loadControllerProperties(myGameProperties);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void StellaSettingsDialog::saveConfig()
{
Settings& settings = instance().settings();
// UI palette
settings.setValue("uipalette",
myThemePopup->getSelectedTag().toString());
instance().frameBuffer().setUIPalette();
// TV Mode
instance().settings().setValue("tv.filter",
myTVMode->getSelectedTag().toString());
// TV phosphor mode
instance().settings().setValue("tv.phosphor",
myTVPhosphor->getState() ? "always" : "byrom");
// TV phosphor blend
instance().settings().setValue("tv.phosblend", myTVPhosLevel->getValueLabel());
// TV scanline intensity and interpolation
instance().settings().setValue("tv.scanlines", myTVScanIntense->getValueLabel());
// Controller properties
myGameProperties.set(Controller_Left, myLeftPort->getSelectedTag().toString());
myGameProperties.set(Controller_Right, myRightPort->getSelectedTag().toString());
// Always insert; if the properties are already present, nothing will happen
instance().propSet().insert(myGameProperties);
instance().saveConfig();
// In any event, inform the Console
if (instance().hasConsole())
{