Change YStart and Display widgets in GameInfoDialog to be sliders

instead of textboxes.  This allows to eliminate error checking,
since the widget will only allow sane values.

Added YStart/Display min/max variables to FrameManager, and
refactor for other parts of the codebase to use these variables.
This commit is contained in:
Stephen Anthony 2017-01-13 22:49:38 -03:30
parent 6c33dda9dd
commit bf1ff1aae0
9 changed files with 73 additions and 32 deletions

View File

@ -486,7 +486,7 @@ void Console::changeYStart(int direction)
if(direction == +1) // increase YStart
{
if(ystart >= 64)
if(ystart >= FrameManager::maxYStart)
{
myOSystem.frameBuffer().showMessage("YStart at maximum");
return;
@ -495,7 +495,7 @@ void Console::changeYStart(int direction)
}
else if(direction == -1) // decrease YStart
{
if(ystart == 0)
if(ystart == FrameManager::minYStart-1)
{
myOSystem.frameBuffer().showMessage("YStart at minimum");
return;
@ -510,6 +510,9 @@ void Console::changeYStart(int direction)
ostringstream val;
val << ystart;
if(ystart == FrameManager::minYStart-1)
myOSystem.frameBuffer().showMessage("YStart autodetected");
else
myOSystem.frameBuffer().showMessage("YStart " + val.str());
myProperties.set(Display_YStart, val.str());
}
@ -523,8 +526,7 @@ void Console::changeHeight(int direction)
if(direction == +1) // increase Height
{
height++;
if (height < 210) height = 210;
if(height > 256 || height > dheight)
if(height > FrameManager::maxViewableHeight || height > dheight)
{
myOSystem.frameBuffer().showMessage("Height at maximum");
return;
@ -533,7 +535,7 @@ void Console::changeHeight(int direction)
else if(direction == -1) // decrease Height
{
height--;
if(height < 210) height = 0;
if(height < FrameManager::minViewableHeight) height = 0;
}
else
return;
@ -551,12 +553,12 @@ void Console::changeHeight(int direction)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::setTIAProperties()
{
// TODO - query these values directly from the TIA if value is 'AUTO'
uInt32 ystart = atoi(myProperties.get(Display_YStart).c_str());
if(ystart > 64) ystart = 64;
if(ystart != 0)
ystart = BSPF::clamp(ystart, FrameManager::minYStart, FrameManager::maxYStart);
uInt32 height = atoi(myProperties.get(Display_Height).c_str());
if(height < 210 && height != 0) height = 210;
else if(height > 256) height = 256;
if(height != 0)
height = BSPF::clamp(height, FrameManager::minViewableHeight, FrameManager::maxViewableHeight);
myTIA->autodetectTvMode(false);

View File

@ -654,7 +654,7 @@ void FrameBuffer::setAvailableVidModes(uInt32 baseWidth, uInt32 baseHeight)
// Figure our the smallest zoom level we can use
uInt32 firstZoom = 2;
if(myDesktopSize.w < 640 || myDesktopSize.h < 480)
if(myDesktopSize.w < kFBMinW || myDesktopSize.h < kFBMinH)
firstZoom = 1;
for(uInt32 zoom = firstZoom; zoom <= maxZoom; ++zoom)
{

View File

@ -33,6 +33,7 @@ namespace GUI {
#include "Variant.hxx"
#include "FBSurface.hxx"
#include "TIASurface.hxx"
#include "FrameManager.hxx"
#include "bspf.hxx"
// Return values for initialization of framebuffer window
@ -129,7 +130,7 @@ class FrameBuffer
{
public:
enum {
kTIAMinW = 320u, kTIAMinH = 210u,
kTIAMinW = 320u, kTIAMinH = FrameManager::minViewableHeight,
kFBMinW = 640u, kFBMinH = 480u
};

View File

@ -441,7 +441,7 @@ bool OSystem::createLauncher(const string& startdir)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string OSystem::getROMInfo(const FilesystemNode& romfile)
{
string md5, type, id, result = "";
string md5, type, id;
unique_ptr<Console> console;
try
{
@ -454,8 +454,7 @@ string OSystem::getROMInfo(const FilesystemNode& romfile)
return buf.str();
}
result = getROMInfo(*console);
return result;
return getROMInfo(*console);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -194,7 +194,7 @@ void Properties::writeQuotedString(ostream& out, const string& s)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Properties::operator == (const Properties& properties) const
bool Properties::operator==(const Properties& properties) const
{
for(int i = 0; i < LastPropType; ++i)
if(myProperties[i] != properties.myProperties[i])
@ -204,13 +204,13 @@ bool Properties::operator == (const Properties& properties) const
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Properties::operator != (const Properties& properties) const
bool Properties::operator!=(const Properties& properties) const
{
return !(*this == properties);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Properties& Properties::operator = (const Properties& properties)
Properties& Properties::operator=(const Properties& properties)
{
// Do the assignment only if this isn't a self assignment
if(this != &properties)

View File

@ -84,8 +84,9 @@ class FrameManager : public Serializable
string name() const override { return "TIA_FrameManager"; }
public:
static constexpr uInt32 frameBufferHeight = 320;
static constexpr uInt32 minYStart = 1, maxYStart = 64;
static constexpr uInt32 minViewableHeight = 210, maxViewableHeight = 256;
private:

View File

@ -26,6 +26,7 @@
#include "Props.hxx"
#include "PropsSet.hxx"
#include "TabWidget.hxx"
#include "FrameManager.hxx"
#include "Widget.hxx"
#include "GameInfoDialog.hxx"
@ -317,16 +318,27 @@ GameInfoDialog::GameInfoDialog(
ypos += lineHeight + 5;
new StaticTextWidget(myTab, font, xpos, ypos+1, lwidth, fontHeight,
"YStart:", kTextAlignLeft);
myYStart = new EditTextWidget(myTab, font, xpos+lwidth, ypos,
4*fontWidth, fontHeight, "");
myYStart = new SliderWidget(myTab, font, xpos+lwidth, ypos, 8*fontWidth, lineHeight,
"", 0, kYStartChanged);
myYStart->setMinValue(FrameManager::minYStart-1);
myYStart->setMaxValue(FrameManager::maxYStart);
wid.push_back(myYStart);
myYStartLabel = new StaticTextWidget(myTab, font, xpos+lwidth+myYStart->getWidth() + 4,
ypos+1, 5*fontWidth, fontHeight, "", kTextAlignLeft);
myYStartLabel->setFlags(WIDGET_CLEARBG);
ypos += lineHeight + 5;
new StaticTextWidget(myTab, font, xpos, ypos+1, lwidth, fontHeight,
"Height:", kTextAlignLeft);
myHeight = new EditTextWidget(myTab, font, xpos+lwidth, ypos,
4*fontWidth, fontHeight, "");
myHeight = new SliderWidget(myTab, font, xpos+lwidth, ypos, 8*fontWidth, lineHeight,
"", 0, kHeightChanged);
myHeight->setMinValue(FrameManager::minViewableHeight-1);
myHeight->setMaxValue(FrameManager::maxViewableHeight);
wid.push_back(myHeight);
myHeightLabel = new StaticTextWidget(myTab, font, xpos+lwidth+myHeight->getWidth() + 4,
ypos+1, 5*fontWidth, fontHeight, "", kTextAlignLeft);
myHeightLabel->setFlags(WIDGET_CLEARBG);
ypos += lineHeight + 5;
pwidth = font.getStringWidth("Yes");
@ -462,8 +474,14 @@ void GameInfoDialog::loadView()
// Display properties
myFormat->setSelected(myGameProperties.get(Display_Format), "AUTO");
myYStart->setText(myGameProperties.get(Display_YStart));
myHeight->setText(myGameProperties.get(Display_Height));
const string& ystart = myGameProperties.get(Display_YStart);
myYStart->setValue(atoi(ystart.c_str()));
myYStartLabel->setLabel(ystart == "0" ? "Auto" : ystart);
const string& height = myGameProperties.get(Display_Height);
myHeight->setValue(atoi(height.c_str()));
myHeightLabel->setLabel(height == "0" ? "Auto" : height);
const string& phos = myGameProperties.get(Display_Phosphor);
myPhosphor->setSelected(phos, "NO");
@ -516,8 +534,9 @@ void GameInfoDialog::saveConfig()
// Display properties
myGameProperties.set(Display_Format, myFormat->getSelectedTag().toString());
myGameProperties.set(Display_YStart, myYStart->getText());
myGameProperties.set(Display_Height, myHeight->getText());
myGameProperties.set(Display_YStart, myYStartLabel->getLabel());
myGameProperties.set(Display_Height, myHeightLabel->getLabel() == "Auto" ? "0" :
myHeightLabel->getLabel());
myGameProperties.set(Display_Phosphor, myPhosphor->getSelectedTag().toString());
myGameProperties.set(Display_PPBlend, myPPBlendLabel->getLabel());
@ -577,6 +596,20 @@ void GameInfoDialog::handleCommand(CommandSender* sender, int cmd,
break;
}
case kYStartChanged:
if(myYStart->getValue() == FrameManager::minYStart-1)
myYStartLabel->setLabel("Auto");
else
myYStartLabel->setValue(myYStart->getValue());
break;
case kHeightChanged:
if(myHeight->getValue() == FrameManager::minViewableHeight-1)
myHeightLabel->setLabel("Auto");
else
myHeightLabel->setValue(myHeight->getValue());
break;
case kPPBlendChanged:
myPPBlendLabel->setValue(myPPBlend->getValue());
break;

View File

@ -77,8 +77,10 @@ class GameInfoDialog : public Dialog, public CommandSender
// Display properties
PopUpWidget* myFormat;
EditTextWidget* myYStart;
EditTextWidget* myHeight;
SliderWidget* myYStart;
StaticTextWidget* myYStartLabel;
SliderWidget* myHeight;
StaticTextWidget* myHeightLabel;
PopUpWidget* myPhosphor;
SliderWidget* myPPBlend;
StaticTextWidget* myPPBlendLabel;
@ -87,6 +89,8 @@ class GameInfoDialog : public Dialog, public CommandSender
kLeftCChanged = 'LCch',
kRightCChanged = 'RCch',
kMRangeChanged = 'MRch',
kYStartChanged = 'YSch',
kHeightChanged = 'HTch',
kPhosphorChanged = 'PPch',
kPPBlendChanged = 'PBch',
kMCtrlChanged = 'MCch'

View File

@ -28,7 +28,8 @@ RomInfoWidget::RomInfoWidget(GuiObject* boss, const GUI::Font& font,
: Widget(boss, font, x, y, w, h),
mySurfaceIsValid(false),
myHaveProperties(false),
myAvail(w > 400 ? GUI::Size(640, 512) : GUI::Size(320, 256))
myAvail(w > 400 ? GUI::Size(640, FrameManager::maxViewableHeight*2) :
GUI::Size(320, FrameManager::maxViewableHeight))
{
_flags = WIDGET_ENABLED;
_bgcolor = _bgcolorhi = kWidColor;
@ -75,7 +76,7 @@ void RomInfoWidget::parseProperties()
// only draw certain parts of it
if(mySurface == nullptr)
{
mySurface = instance().frameBuffer().allocateSurface(320*2, 256*2);
mySurface = instance().frameBuffer().allocateSurface(320*2, FrameManager::maxViewableHeight*2);
mySurface->attributes().smoothing = true;
mySurface->applyAttributes();