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. * Added option to change pitch of Pitfall II music.
* ROM Info Launcher can now display multiple lines per property and * 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 * In file listings, you can now select directories by holding 'Shift' on
the first character entered. Entering characters in lowercase still the first character entered. Entering characters in lowercase still

View File

@ -351,7 +351,6 @@ void Settings::validate()
i = getInt("romviewer"); i = getInt("romviewer");
if(i < 0) setValue("romviewer", "0"); if(i < 0) setValue("romviewer", "0");
else if(i > 2) setValue("romviewer", "2");
i = getInt("loglevel"); i = getInt("loglevel");
if(i < int(Logger::Level::MIN) || i > int(Logger::Level::MAX)) if(i < int(Logger::Level::MIN) || i > int(Logger::Level::MAX))

View File

@ -37,6 +37,7 @@
#include "Props.hxx" #include "Props.hxx"
#include "PropsSet.hxx" #include "PropsSet.hxx"
#include "RomInfoWidget.hxx" #include "RomInfoWidget.hxx"
#include "TIAConstants.hxx"
#include "Settings.hxx" #include "Settings.hxx"
#include "Widget.hxx" #include "Widget.hxx"
#include "Font.hxx" #include "Font.hxx"
@ -123,15 +124,11 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent,
// Add list with game titles // Add list with game titles
// Before we add the list, we need to know the size of the RomInfoWidget // Before we add the list, we need to know the size of the RomInfoWidget
xpos = HBORDER; ypos += lineHeight + 4; float imgZoom = getRomInfoZoom();
int romWidth = 0; int romWidth = imgZoom * TIAConstants::viewableWidth;
int romSize = instance().settings().getInt("romviewer"); if(romWidth > 0) romWidth += 10;
if(romSize > 1 && w >= 1000 && h >= 720)
romWidth = 660;
else if(romSize > 0 && w >= 640 && h >= 480)
romWidth = 365;
int listWidth = _w - (romWidth > 0 ? romWidth+8 : 0) - 20; int listWidth = _w - (romWidth > 0 ? romWidth+8 : 0) - 20;
xpos = HBORDER; ypos += lineHeight + 4;
myList = new FileListWidget(this, font, xpos, ypos, myList = new FileListWidget(this, font, xpos, ypos,
listWidth, _h - 43 - bheight - fontHeight - lineHeight); listWidth, _h - 43 - bheight - fontHeight - lineHeight);
myList->setEditable(false); myList->setEditable(false);
@ -142,10 +139,17 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent,
if(romWidth > 0) if(romWidth > 0)
{ {
xpos += myList->getWidth() + 8; xpos += myList->getWidth() + 8;
myRomInfoWidget = new RomInfoWidget(this,
romWidth < 660 ? instance().frameBuffer().smallFont() : // Initial surface size is the same as the viewable area
instance().frameBuffer().infoFont(), Common::Size imgSize(TIAConstants::viewableWidth*imgZoom,
xpos, ypos, romWidth, myList->getHeight()); 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 // Add textfield to show current directory
@ -207,8 +211,7 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent,
// Create (empty) context menu for ROM list options // Create (empty) context menu for ROM list options
myMenu = make_unique<ContextMenu>(this, osystem.frameBuffer().font(), EmptyVarList); myMenu = make_unique<ContextMenu>(this, osystem.frameBuffer().font(), EmptyVarList);
// Create global props dialog, which is used to temporarily override
// Create global props dialog, which is used to temporarily overrride
// ROM properties // ROM properties
myGlobalProps = make_unique<GlobalPropsDialog>(this, myGlobalProps = make_unique<GlobalPropsDialog>(this,
myUseMinimalUI ? osystem.frameBuffer().launcherFont() : osystem.frameBuffer().font()); 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() void LauncherDialog::loadRomInfo()
{ {

View File

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

View File

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

View File

@ -31,7 +31,8 @@ class RomInfoWidget : public Widget
{ {
public: public:
RomInfoWidget(GuiObject *boss, const GUI::Font& font, 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; virtual ~RomInfoWidget() = default;
void setProperties(const Properties& props, const FilesystemNode& node); void setProperties(const Properties& props, const FilesystemNode& node);