added support for default image in ROM info viewer (resolves #601)

This commit is contained in:
thrust26 2020-12-07 11:41:06 +01:00
parent 3eec0defce
commit 08dfe1fe86
5 changed files with 52 additions and 26 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -15,14 +15,17 @@
<body bgcolor="#FFFFFF">
<center><b><font size="7">Stella</font></b></center>
<br><br>
<center><h2><b>A multi-platform Atari 2600 VCS emulator</b></h2></center>
<center>
<b><font size="7">Stella</font></b>
<br><br>
<img src="graphics/stella_icon.png">
<h2><b>A multi-platform Atari 2600 VCS emulator</b></h2>
<center><h4><b>Release 6.4</b></h4></center>
<br><br>
<h4><b>Release 6.4</b></h4>
<br>
<center><h2><b>User's Guide</b></h2></center>
<h2><b>User's Guide</b></h2>
</center>
<br>
<h2>Contents</h2>
@ -570,9 +573,10 @@
The path of the first ROM you play automatically defines the default ROM path. You
can change it later in the <b><a href="#ROMInfo">ROM Launcher</a></b> dialog.</p>
<p>At this point, you may want to set the locations for snapshots. This is described in more detail in <b>Advanced Configuration - <a href="#Snapshots">Snapshot Settings</a></b>.
These settings are optional, and can be left at the defaults if you won't be using
snapshots in the ROM launcher.</p>
<p>At this point, you may want to set the locations for snapshot images. This
is described in more detail in <b><a href="#ROMInfo">ROM Launcher</a></b>.
These settings are optional, and can be left at the defaults if you won't be
using snapshots in the ROM launcher. </p>
<p>You can start emulation by selecting a ROM and pressing 'Enter' or clicking 'Select',
or double-clicking a ROM. Note that some games require you to 'Reset' the console
@ -3722,20 +3726,22 @@
<p>Several options are configurable in the ROM launcher. The size of the
launcher and fonts, as well as the 'ROM Info Viewer' can be changed in
<b>UI Settings - Launcher</b> dialog, as shown below:</p>
the <b>UI Settings - Launcher</b> dialog, as shown below:</p>
<img src="graphics/options_ui.png">
<p>Most of the options are self-explanatory, except for the 'ROM info
width', which is described below.</p>
width' and 'Image path...', which are described below.</p>
<h3><b><a name="ROMInfoViewer">ROM Info Viewer</a></b></h3>
<p>Stella supports viewing snapshots and ROM properties of the currently
selected ROM in the ROM launcher. Support is automatic, as long as your
snapshot directory contains snapshots in the appropriate format. An
image directory contains snapshots in the appropriate format. An
archive of updated snapshots will be available on the Stella webpage.
This archive may be updated periodically as new ROMs are found, and also
for each new release of Stella. Note that the snapshots can be any size
generated by Stella; they will be resized accordingly.</p>
for each new release of Stella. In case no snapshot is found, you can
provide a default image named 'default_snapshot.png'.
Note that the snapshots can be any size (e.g. generated by Stella); they
will be resized accordingly.</p>
The ROM Info Viewer's width can be defined between 0% (off) and 100%. The
value is relative to the launcher width. For too small or too large values,

View File

@ -108,20 +108,13 @@ void RomInfoWidget::parseProperties(const FilesystemNode& node)
myProperties.get(PropType::Cart_Name) + ".png";
// Read the PNG file
try
{
instance().png().loadImage(filename, *mySurface);
mySurfaceIsValid = loadPng(filename);
// Scale surface to available image area
const Common::Rect& src = mySurface->srcRect();
float scale = std::min(float(myAvail.w) / src.w(), float(myAvail.h) / src.h()) *
instance().frameBuffer().hidpiScaleFactor();
mySurface->setDstSize(uInt32(src.w() * scale), uInt32(src.h() * scale));
mySurfaceIsValid = true;
}
catch(const runtime_error& e)
// Try to load a default image if not ROM image exists
if(!mySurfaceIsValid)
{
mySurfaceErrorMsg = e.what();
mySurfaceIsValid = loadPng(instance().snapshotLoadDir().getPath() +
"default_snapshot.png");
}
#else
mySurfaceErrorMsg = "PNG image loading not supported";
@ -176,6 +169,30 @@ void RomInfoWidget::parseProperties(const FilesystemNode& node)
setDirty();
}
#ifdef PNG_SUPPORT
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool RomInfoWidget::loadPng(const string& filename)
{
try
{
instance().png().loadImage(filename, *mySurface);
// Scale surface to available image area
const Common::Rect& src = mySurface->srcRect();
float scale = std::min(float(myAvail.w) / src.w(), float(myAvail.h) / src.h()) *
instance().frameBuffer().hidpiScaleFactor();
mySurface->setDstSize(uInt32(src.w() * scale), uInt32(src.h() * scale));
return true;
}
catch(const runtime_error& e)
{
mySurfaceErrorMsg = e.what();
}
return false;
}
#endif
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void RomInfoWidget::drawWidget(bool hilite)
{

View File

@ -44,6 +44,9 @@ class RomInfoWidget : public Widget
private:
void parseProperties(const FilesystemNode& node);
#ifdef PNG_SUPPORT
bool loadPng(const string& filename);
#endif
private:
// Surface pointer holding the PNG image