add overscan option to StellaSettingsDialog

fix dialog position when overscan is enabled
This commit is contained in:
thrust26 2019-05-15 20:05:17 +02:00
parent 1e7ff8974f
commit 91e46faddf
6 changed files with 74 additions and 39 deletions

View File

@ -1014,7 +1014,6 @@ FrameBuffer::VideoMode::VideoMode(uInt32 iw, uInt32 ih, uInt32 sw, uInt32 sh,
if(fsIndex != -1)
{
//double overscan = 1 - myOSystem.settings().getInt("tia.fs_overscan") / 100.0;
switch(stretch)
{
case Stretch::Preserve:

View File

@ -167,14 +167,17 @@ void Dialog::center()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Dialog::positionAt(uInt32 pos)
{
const bool fullscreen = instance().settings().getBool("fullscreen");
const double overscan = fullscreen ? instance().settings().getInt("tia.fs_overscan") / 200.0 : 0.0;
const Common::Size& screen = instance().frameBuffer().screenSize();
const Common::Rect& dst = _surface->dstRect();
// shift stacked dialogs
uInt32 gap = (screen.w >> 6) * _layer;
int top = std::min(screen.h - dst.height(), gap);
int btm = std::min(screen.h - dst.height(), screen.h - dst.height() - gap);
int left = std::min(screen.w - dst.width(), gap);
int right = std::min(screen.w - dst.width(), screen.w - dst.width() - gap);
Int32 hgap = (screen.w >> 6) * _layer + screen.w * overscan;
Int32 vgap = (screen.w >> 6) * _layer + screen.h * overscan;
int top = std::min(std::max(0, Int32(screen.h - dst.height())), vgap);
int btm = std::max(0, Int32(screen.h - dst.height() - vgap));
int left = std::min(std::max(0, Int32(screen.w - dst.width())), hgap);
int right = std::max(0, Int32(screen.w - dst.width() - hgap));
switch (pos)
{

View File

@ -47,7 +47,7 @@ StellaSettingsDialog::StellaSettingsDialog(OSystem& osystem, DialogContainer& pa
VariantList items;
// Set real dimensions
setSize(33 * fontWidth + HBORDER * 2 + 3, 15 * (lineHeight + VGAP) + VGAP * 9 + 6 + _th, max_w, max_h);
setSize(35 * fontWidth + HBORDER * 2 + 3, 14 * (lineHeight + VGAP) + VGAP * 9 + 10 + _th, max_w, max_h);
xpos = HBORDER;
ypos = VBORDER + _th;
@ -96,7 +96,7 @@ void StellaSettingsDialog::addUIOptions(WidgetArray& wid, int& xpos, int& ypos,
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 ");
myThemePopup = new PopUpWidget(this, font, xpos, ypos, pwidth, lineHeight, items, "UI theme ");
wid.push_back(myThemePopup);
ypos += lineHeight + VGAP;
@ -108,7 +108,7 @@ void StellaSettingsDialog::addUIOptions(WidgetArray& wid, int& xpos, int& ypos,
VarList::push_back(items, "Right bottom", 3);
VarList::push_back(items, "Left bottom", 4);
myPositionPopup = new PopUpWidget(this, font, xpos, ypos, pwidth, lineHeight,
items, "Dialogs position ");
items, "Dialogs position ");
wid.push_back(myPositionPopup);
ypos += lineHeight + VGAP;
}
@ -123,7 +123,7 @@ void StellaSettingsDialog::addVideoOptions(WidgetArray& wid, int& xpos, int& ypo
VariantList items;
// TV effects options
int swidth = font.getMaxCharWidth() * 8 - 4;
int swidth = font.getMaxCharWidth() * 11;
// TV Mode
items.clear();
@ -132,37 +132,37 @@ void StellaSettingsDialog::addVideoOptions(WidgetArray& wid, int& xpos, int& ypo
VarList::push_back(items, "S-Video", static_cast<uInt32>(NTSCFilter::Preset::SVIDEO));
VarList::push_back(items, "Composite", static_cast<uInt32>(NTSCFilter::Preset::COMPOSITE));
VarList::push_back(items, "Bad adjust", static_cast<uInt32>(NTSCFilter::Preset::BAD));
int lwidth = font.getStringWidth("TV mode ");
int pwidth = font.getStringWidth("Bad adjust");
int pwidth = font.getStringWidth("Right bottom");
int lwidth = font.getStringWidth("Scanline intensity ");
myTVMode = new PopUpWidget(this, font, xpos, ypos, pwidth, lineHeight,
items, "TV mode ");
items, "TV mode ");
wid.push_back(myTVMode);
ypos += lineHeight + VGAP * 2;
lwidth = font.getStringWidth("Intensity ");
swidth = font.getMaxCharWidth() * 10;
ypos += lineHeight + VGAP;
// Scanline intensity
myTVScanlines = new StaticTextWidget(this, font, xpos, ypos + 1, "Scanlines:");
ypos += lineHeight;
myTVScanIntense = new SliderWidget(this, font, xpos + INDENT, ypos-1, swidth, lineHeight,
"Intensity ", lwidth, kScanlinesChanged, fontWidth * 2);
myTVScanIntense = new SliderWidget(this, font, xpos, ypos-1, swidth, lineHeight,
"Scanline intensity", lwidth, kScanlinesChanged, fontWidth * 3);
myTVScanIntense->setMinValue(0); myTVScanIntense->setMaxValue(10);
myTVScanIntense->setTickmarkIntervals(2);
wid.push_back(myTVScanIntense);
ypos += lineHeight + VGAP;
// TV Phosphor effect
new StaticTextWidget(this, font, xpos, ypos + 1, "Phosphor effect:");
ypos += lineHeight;
// TV Phosphor blend level
myTVPhosLevel = new SliderWidget(this, font, xpos + INDENT, ypos-1, swidth, lineHeight,
"Blend ", lwidth, kPhosphorChanged, fontWidth * 2);
myTVPhosLevel = new SliderWidget(this, font, xpos, ypos-1, swidth, lineHeight,
"Phosphor blend ", lwidth, kPhosphorChanged, fontWidth * 3);
myTVPhosLevel->setMinValue(0); myTVPhosLevel->setMaxValue(10);
myTVPhosLevel->setTickmarkIntervals(2);
wid.push_back(myTVPhosLevel);
ypos += lineHeight + VGAP;
// FS overscan
myTVOverscan = new SliderWidget(this, font, xpos, ypos - 1, swidth, lineHeight,
"Overscan ", lwidth, kOverscanChanged, fontWidth * 3);
myTVOverscan->setMinValue(0); myTVOverscan->setMaxValue(10);
myTVOverscan->setTickmarkIntervals(2);
wid.push_back(myTVOverscan);
ypos += lineHeight + VGAP;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -227,6 +227,11 @@ void StellaSettingsDialog::loadConfig()
// TV phosphor blend
myTVPhosLevel->setValue(valueToLevel(settings.getInt("tv.phosblend")));
// TV overscan
myTVOverscan->setValue(settings.getInt("tia.fs_overscan"));
handleOverscanChange();
// Controllers
Properties props;
@ -270,6 +275,9 @@ void StellaSettingsDialog::saveConfig()
instance().settings().setValue("tv.scanlines",
levelToValue(myTVScanIntense->getValue()));
// TV overscan
instance().settings().setValue("tia.fs_overscan", myTVOverscan->getValueLabel());
// Controller properties
myGameProperties.set(PropType::Controller_Left, myLeftPort->getSelectedTag().toString());
myGameProperties.set(PropType::Controller_Right, myRightPort->getSelectedTag().toString());
@ -302,6 +310,8 @@ void StellaSettingsDialog::setDefaults()
myTVScanIntense->setValue(3); // 18
// TV phosphor blend
myTVPhosLevel->setValue(6); // = 45
// TV overscan
myTVOverscan->setValue(0);
// Load the default game properties
Properties defaultProperties;
@ -358,12 +368,29 @@ void StellaSettingsDialog::handleCommand(CommandSender* sender, int cmd,
myTVPhosLevel->setValueLabel("Off");
break;
case kOverscanChanged:
handleOverscanChange();
break;
default:
Dialog::handleCommand(sender, cmd, data, 0);
break;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void StellaSettingsDialog::handleOverscanChange()
{
if (myTVOverscan->getValue() == 0)
{
myTVOverscan->setValueLabel("Off");
myTVOverscan->setValueUnit("");
}
else
myTVOverscan->setValueUnit("%");
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void StellaSettingsDialog::switchSettingsMode()
{

View File

@ -54,6 +54,7 @@ class StellaSettingsDialog : public Dialog
void addGameOptions(WidgetArray& wid, int& xpos, int& ypos, const GUI::Font& font);
void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
void handleOverscanChange();
// switch to advanced settings after user confirmation
void switchSettingsMode();
@ -82,6 +83,9 @@ class StellaSettingsDialog : public Dialog
// TV phosphor effect
SliderWidget* myTVPhosLevel;
// TV Overscan
SliderWidget* myTVOverscan;
// Controller properties
StaticTextWidget* myGameSettings;
@ -110,7 +114,8 @@ class StellaSettingsDialog : public Dialog
kConfirmSwitchCmd = 'SScf',
kHelp = 'SShl',
kScanlinesChanged = 'SSsc',
kPhosphorChanged = 'SSph'
kPhosphorChanged = 'SSph',
kOverscanChanged = 'SSov'
};
// Game properties for currently loaded ROM

View File

@ -196,11 +196,11 @@ VideoDialog::VideoDialog(OSystem& osystem, DialogContainer& parent,
ypos += lineHeight + VGAP;
// FS overscan
myUseOverscan = new SliderWidget(myTab, font, xpos + INDENT, ypos - 1, swidth, lineHeight,
myTVOverscan = new SliderWidget(myTab, font, xpos + INDENT, ypos - 1, swidth, lineHeight,
"Overscan", font.getStringWidth("Overscan "), kOverscanChanged, fontWidth * 3, "%");
myUseOverscan->setMinValue(0); myUseOverscan->setMaxValue(10);
myUseOverscan->setTickmarkIntervals(2);
wid.push_back(myUseOverscan);
myTVOverscan->setMinValue(0); myTVOverscan->setMaxValue(10);
myTVOverscan->setTickmarkIntervals(2);
wid.push_back(myTVOverscan);
ypos += (lineHeight + VGAP) * 2;
// Skip progress load bars for SuperCharger ROMs
@ -370,7 +370,8 @@ void VideoDialog::loadConfig()
// Fullscreen stretch setting
myUseStretch->setState(instance().settings().getBool("tia.fs_stretch"));
// Fullscreen overscan setting
myUseOverscan->setValue(instance().settings().getInt("tia.fs_overscan"));
myTVOverscan->setValue(instance().settings().getInt("tia.fs_overscan"));
handleFullScreenChange();
// Use sync to vertical blank
myUseVSync->setState(instance().settings().getBool("vsync"));
@ -443,7 +444,7 @@ void VideoDialog::saveConfig()
// Fullscreen stretch setting
instance().settings().setValue("tia.fs_stretch", myUseStretch->getState());
// Fullscreen overscan
instance().settings().setValue("tia.fs_overscan", myUseOverscan->getValueLabel());
instance().settings().setValue("tia.fs_overscan", myTVOverscan->getValueLabel());
// Use sync to vertical blank
instance().settings().setValue("vsync", myUseVSync->getState());
@ -586,19 +587,19 @@ void VideoDialog::handleFullScreenChange()
{
bool enable = myFullscreen->getState();
myUseStretch->setEnabled(enable);
myUseOverscan->setEnabled(enable);
myTVOverscan->setEnabled(enable);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void VideoDialog::handleOverscanChange()
{
if (myUseOverscan->getValue() == 0)
if (myTVOverscan->getValue() == 0)
{
myUseOverscan->setValueLabel("Off");
myUseOverscan->setValueUnit("");
myTVOverscan->setValueLabel("Off");
myTVOverscan->setValueUnit("");
}
else
myUseOverscan->setValueUnit("%");
myTVOverscan->setValueUnit("%");
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -65,7 +65,7 @@ class VideoDialog : public Dialog
CheckboxWidget* myFullscreen;
//PopUpWidget* myFullScreenMode;
CheckboxWidget* myUseStretch;
SliderWidget* myUseOverscan;
SliderWidget* myTVOverscan;
CheckboxWidget* myUseVSync;
CheckboxWidget* myUIMessages;
CheckboxWidget* myCenter;