Changed 'romviewer' option to be treated as a multiplier for the zoom level of snapshots.

Old settings will still work (0 means off, 1 or 2 mean 1x and 2x zoom).  Floats are now supported too,
so we get fractional scaling.

Still TODO is update the UI to modify this setting.
This commit is contained in:
Stephen Anthony 2020-03-11 18:33:12 -02:30
parent 64dc9dde86
commit a89188722e
6 changed files with 62 additions and 26 deletions

View File

@ -120,7 +120,8 @@
* Added option to change pitch of Pitfall II music.
* ROM Info Launcher can now display multiple lines per property and
bank switching type.
bank switching type. Related to this, added fractional (25% increments)
snapshot zooms.
* In file listings, you can now select directories by holding 'Shift' on
the first character entered. Entering characters in lowercase still

View File

@ -350,8 +350,7 @@ void Settings::validate()
setValue("dbg.fontsize", "medium");
i = getInt("romviewer");
if(i < 0) setValue("romviewer", "0");
else if(i > 2) setValue("romviewer", "2");
if(i < 0) setValue("romviewer", "0");
i = getInt("loglevel");
if(i < int(Logger::Level::MIN) || i > int(Logger::Level::MAX))

View File

@ -37,6 +37,7 @@
#include "Props.hxx"
#include "PropsSet.hxx"
#include "RomInfoWidget.hxx"
#include "TIAConstants.hxx"
#include "Settings.hxx"
#include "Widget.hxx"
#include "Font.hxx"
@ -123,15 +124,11 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent,
// Add list with game titles
// Before we add the list, we need to know the size of the RomInfoWidget
xpos = HBORDER; ypos += lineHeight + 4;
int romWidth = 0;
int romSize = instance().settings().getInt("romviewer");
if(romSize > 1 && w >= 1000 && h >= 720)
romWidth = 660;
else if(romSize > 0 && w >= 640 && h >= 480)
romWidth = 365;
float imgZoom = getRomInfoZoom();
int romWidth = imgZoom * TIAConstants::viewableWidth;
if(romWidth > 0) romWidth += 10;
int listWidth = _w - (romWidth > 0 ? romWidth+8 : 0) - 20;
xpos = HBORDER; ypos += lineHeight + 4;
myList = new FileListWidget(this, font, xpos, ypos,
listWidth, _h - 43 - bheight - fontHeight - lineHeight);
myList->setEditable(false);
@ -142,10 +139,17 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent,
if(romWidth > 0)
{
xpos += myList->getWidth() + 8;
myRomInfoWidget = new RomInfoWidget(this,
romWidth < 660 ? instance().frameBuffer().smallFont() :
instance().frameBuffer().infoFont(),
xpos, ypos, romWidth, myList->getHeight());
// Initial surface size is the same as the viewable area
Common::Size imgSize(TIAConstants::viewableWidth*imgZoom,
TIAConstants::viewableHeight*imgZoom);
// Calculate font area, and in the process the font that can be used
Common::Size fontArea(romWidth, myList->getHeight() - imgSize.h);
const GUI::Font& rominfoFont = getRomInfoFont(fontArea);
myRomInfoWidget = new RomInfoWidget(this, rominfoFont,
xpos, ypos, romWidth, myList->getHeight(), imgSize);
}
// Add textfield to show current directory
@ -197,7 +201,7 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent,
wid.push_back(myStartButton);
#endif
}
if (myUseMinimalUI) // Highlight 'Rom Listing'
if(myUseMinimalUI) // Highlight 'Rom Listing'
mySelectedItem = 0;
else
mySelectedItem = 2;
@ -207,8 +211,7 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent,
// Create (empty) context menu for ROM list options
myMenu = make_unique<ContextMenu>(this, osystem.frameBuffer().font(), EmptyVarList);
// Create global props dialog, which is used to temporarily overrride
// Create global props dialog, which is used to temporarily override
// ROM properties
myGlobalProps = make_unique<GlobalPropsDialog>(this,
myUseMinimalUI ? osystem.frameBuffer().launcherFont() : osystem.frameBuffer().font());
@ -325,6 +328,36 @@ void LauncherDialog::applyFiltering()
);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
float LauncherDialog::getRomInfoZoom()
{
// The ROM info area is some multiple of the minimum TIA image size
// However, it can't exceed 70% of the total dialog width, nor less than
// the base size of the TIA image
float zoom = instance().settings().getFloat("romviewer");
if(zoom < 1.F)
return 0.F;
else if(zoom * TIAConstants::viewableWidth > _w * 0.7F)
return (_w * 0.7F) / TIAConstants::viewableWidth;
else
return zoom;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const GUI::Font& LauncherDialog::getRomInfoFont(const Common::Size& area)
{
// TODO: Perhaps offer a setting to override the font used?
// Try to pick a font that works best, based on the available area
if(area.h / instance().frameBuffer().launcherFont().getLineHeight() >= 8)
return instance().frameBuffer().launcherFont();
else if(area.h / instance().frameBuffer().infoFont().getLineHeight() >= 8 &&
area.w / instance().frameBuffer().infoFont().getMaxCharWidth() >= 80)
return instance().frameBuffer().infoFont();
else
return instance().frameBuffer().smallFont();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void LauncherDialog::loadRomInfo()
{

View File

@ -98,6 +98,9 @@ class LauncherDialog : public Dialog
void updateUI();
void applyFiltering();
float getRomInfoZoom();
const GUI::Font& getRomInfoFont(const Common::Size& area);
void loadRom();
void loadRomInfo();
void handleContextMenu();

View File

@ -29,16 +29,14 @@
#include "PNGLibrary.hxx"
#include "Rect.hxx"
#include "Widget.hxx"
#include "TIAConstants.hxx"
#include "RomInfoWidget.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RomInfoWidget::RomInfoWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int w, int h)
int x, int y, int w, int h,
const Common::Size& imgSize)
: Widget(boss, font, x, y, w, h),
myAvail(w > 400 ?
Common::Size(TIAConstants::viewableWidth*2, TIAConstants::viewableHeight*2) :
Common::Size(TIAConstants::viewableWidth, TIAConstants::viewableHeight))
myAvail(imgSize)
{
_flags = Widget::FLAG_ENABLED;
_bgcolor = kDlgColor;
@ -87,7 +85,7 @@ void RomInfoWidget::parseProperties(const FilesystemNode& node)
if(mySurface == nullptr)
{
mySurface = instance().frameBuffer().allocateSurface(
TIAConstants::viewableWidth*2, TIAConstants::viewableHeight*2, FrameBuffer::ScalingInterpolation::blur);
myAvail.w, myAvail.h, FrameBuffer::ScalingInterpolation::blur);
mySurface->applyAttributes();
dialog().addSurface(mySurface);
@ -205,11 +203,12 @@ void RomInfoWidget::drawWidget(bool hilite)
s.drawString(font, mySurfaceErrorMsg, x, y, _w - 10, onTop ? _textcolor : _shadowcolor);
}
int xpos = _x + 8, ypos = _y + yoff + 10;
int xpos = _x + 8, ypos = _y + yoff + 5;
for(const auto& info: myRomInfo)
{
int lines = s.drawString(_font, info, xpos, ypos, _w - 16, _font.getFontHeight() * 3,
onTop ? _textcolor : _shadowcolor);
if(ypos >= _h) break;
ypos += _font.getLineHeight() + (lines - 1) * _font.getFontHeight();
}
}

View File

@ -31,7 +31,8 @@ class RomInfoWidget : public Widget
{
public:
RomInfoWidget(GuiObject *boss, const GUI::Font& font,
int x, int y, int w, int h);
int x, int y, int w, int h,
const Common::Size& imgSize);
virtual ~RomInfoWidget() = default;
void setProperties(const Properties& props, const FilesystemNode& node);