mirror of https://github.com/stella-emu/stella.git
added detected bezel name to GameInfoDialog
This commit is contained in:
parent
07f5957294
commit
ecdacfb924
|
@ -22,6 +22,7 @@
|
||||||
#include "EventHandler.hxx"
|
#include "EventHandler.hxx"
|
||||||
#include "FBSurface.hxx"
|
#include "FBSurface.hxx"
|
||||||
#include "PNGLibrary.hxx"
|
#include "PNGLibrary.hxx"
|
||||||
|
#include "PropsSet.hxx"
|
||||||
|
|
||||||
#include "Bezel.hxx"
|
#include "Bezel.hxx"
|
||||||
|
|
||||||
|
@ -33,13 +34,35 @@ Bezel::Bezel(OSystem& osystem)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
string Bezel::getName(int& index) const
|
string Bezel::getName(const string& path, const Properties& props)
|
||||||
|
{
|
||||||
|
string imageName;
|
||||||
|
int index = 1; // skip property name
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
imageName = getName(props, index);
|
||||||
|
if(imageName != EmptyString)
|
||||||
|
{
|
||||||
|
// Note: JPG does not support transparency
|
||||||
|
const string imagePath = path + imageName + ".png";
|
||||||
|
const FSNode node(imagePath);
|
||||||
|
if(node.exists())
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} while(index != -1);
|
||||||
|
|
||||||
|
return imageName;
|
||||||
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
string Bezel::getName(const Properties& props, int& index)
|
||||||
{
|
{
|
||||||
if(++index == 1)
|
if(++index == 1)
|
||||||
return myOSystem.console().properties().get(PropType::Bezel_Name);
|
return props.get(PropType::Bezel_Name);
|
||||||
|
|
||||||
// Try to generate bezel name from cart name
|
// Try to generate bezel name from cart name
|
||||||
const string& cartName = myOSystem.console().properties().get(PropType::Cart_Name);
|
const string& cartName = props.get(PropType::Cart_Name);
|
||||||
size_t pos = cartName.find_first_of('(');
|
size_t pos = cartName.find_first_of('(');
|
||||||
if(pos == std::string::npos)
|
if(pos == std::string::npos)
|
||||||
pos = cartName.length() + 1;
|
pos = cartName.length() + 1;
|
||||||
|
@ -68,6 +91,12 @@ string Bezel::getName(int& index) const
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
string Bezel::getName(int& index) const
|
||||||
|
{
|
||||||
|
return getName(myOSystem.console().properties(), index);
|
||||||
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt32 Bezel::borderSize(uInt32 x, uInt32 y, uInt32 size, Int32 step) const
|
uInt32 Bezel::borderSize(uInt32 x, uInt32 y, uInt32 size, Int32 step) const
|
||||||
{
|
{
|
||||||
|
@ -141,7 +170,6 @@ bool Bezel::load()
|
||||||
if(settings.getBool("bezel.win.auto"))
|
if(settings.getBool("bezel.win.auto"))
|
||||||
{
|
{
|
||||||
// Determine transparent window inside bezel image
|
// Determine transparent window inside bezel image
|
||||||
|
|
||||||
const uInt32 xCenter = w >> 1;
|
const uInt32 xCenter = w >> 1;
|
||||||
top = borderSize(xCenter, 0, h, w);
|
top = borderSize(xCenter, 0, h, w);
|
||||||
bottom = h - 1 - borderSize(xCenter, h - 1, h, -w);
|
bottom = h - 1 - borderSize(xCenter, h - 1, h, -w);
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
class OSystem;
|
class OSystem;
|
||||||
class FBSurface;
|
class FBSurface;
|
||||||
class FrameBuffer;
|
class FrameBuffer;
|
||||||
|
class Properties;
|
||||||
|
|
||||||
#include "Rect.hxx"
|
#include "Rect.hxx"
|
||||||
|
|
||||||
|
@ -109,7 +110,17 @@ class Bezel
|
||||||
*/
|
*/
|
||||||
void render();
|
void render();
|
||||||
|
|
||||||
|
/*
|
||||||
|
Generate bezel file name.
|
||||||
|
*/
|
||||||
|
static string getName(const string& path, const Properties& props);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/*
|
||||||
|
Generate bezel file name.
|
||||||
|
*/
|
||||||
|
static string getName(const Properties& props, int& index);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Generate bezel file name.
|
Generate bezel file name.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -421,6 +421,7 @@ void GameInfoDialog::addControllersTab()
|
||||||
void GameInfoDialog::addCartridgeTab()
|
void GameInfoDialog::addCartridgeTab()
|
||||||
{
|
{
|
||||||
// 4) Cartridge properties
|
// 4) Cartridge properties
|
||||||
|
const GUI::Font& ifont = instance().frameBuffer().infoFont();
|
||||||
const int lineHeight = Dialog::lineHeight(),
|
const int lineHeight = Dialog::lineHeight(),
|
||||||
fontHeight = Dialog::fontHeight(),
|
fontHeight = Dialog::fontHeight(),
|
||||||
VBORDER = Dialog::vBorder(),
|
VBORDER = Dialog::vBorder(),
|
||||||
|
@ -495,6 +496,10 @@ void GameInfoDialog::addCartridgeTab()
|
||||||
bw, myBezelName->getHeight(), ELLIPSIS, kBezelFilePressed);
|
bw, myBezelName->getHeight(), ELLIPSIS, kBezelFilePressed);
|
||||||
wid.push_back(myBezelButton);
|
wid.push_back(myBezelButton);
|
||||||
|
|
||||||
|
ypos += lineHeight + VGAP;
|
||||||
|
myBezelDetected = new StaticTextWidget(myTab, ifont, xpos + lwidth, ypos,
|
||||||
|
"'1234567890123456789012345678901234567' selected");
|
||||||
|
|
||||||
// Add items for tab 3
|
// Add items for tab 3
|
||||||
addToFocusList(wid, myTab, tabID);
|
addToFocusList(wid, myTab, tabID);
|
||||||
|
|
||||||
|
@ -883,7 +888,23 @@ void GameInfoDialog::loadCartridgeProperties(const Properties& props)
|
||||||
myRarity->setText(props.get(PropType::Cart_Rarity));
|
myRarity->setText(props.get(PropType::Cart_Rarity));
|
||||||
myNote->setText(props.get(PropType::Cart_Note));
|
myNote->setText(props.get(PropType::Cart_Note));
|
||||||
myUrl->setText(props.get(PropType::Cart_Url));
|
myUrl->setText(props.get(PropType::Cart_Url));
|
||||||
myBezelName->setText(props.get(PropType::Bezel_Name));
|
|
||||||
|
bool autoSelected = false;
|
||||||
|
string bezelName = props.get(PropType::Bezel_Name);
|
||||||
|
if(bezelName.empty())
|
||||||
|
{
|
||||||
|
bezelName = Bezel::getName(instance().bezelDir().getPath(), props);
|
||||||
|
if(bezelName != "default")
|
||||||
|
autoSelected = true;
|
||||||
|
else
|
||||||
|
bezelName = "";
|
||||||
|
}
|
||||||
|
myBezelName->setText(bezelName);
|
||||||
|
|
||||||
|
if(autoSelected)
|
||||||
|
myBezelDetected->setLabel("auto-selected");
|
||||||
|
else
|
||||||
|
myBezelDetected->setLabel("");
|
||||||
|
|
||||||
updateLink();
|
updateLink();
|
||||||
}
|
}
|
||||||
|
@ -1000,7 +1021,11 @@ void GameInfoDialog::saveProperties()
|
||||||
myGameProperties.set(PropType::Cart_Rarity, myRarity->getText());
|
myGameProperties.set(PropType::Cart_Rarity, myRarity->getText());
|
||||||
myGameProperties.set(PropType::Cart_Note, myNote->getText());
|
myGameProperties.set(PropType::Cart_Note, myNote->getText());
|
||||||
myGameProperties.set(PropType::Cart_Url, myUrl->getText());
|
myGameProperties.set(PropType::Cart_Url, myUrl->getText());
|
||||||
myGameProperties.set(PropType::Bezel_Name, myBezelName->getText());
|
// avoid saving auto-selected bezel names:
|
||||||
|
if(myBezelName->getText() == Bezel::getName(instance().bezelDir().getPath(), myGameProperties))
|
||||||
|
myGameProperties.reset(PropType::Bezel_Name);
|
||||||
|
else
|
||||||
|
myGameProperties.set(PropType::Bezel_Name, myBezelName->getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -1591,7 +1616,10 @@ void GameInfoDialog::handleCommand(CommandSender* sender, int cmd,
|
||||||
BrowserDialog::Mode::FileLoadNoDirs,
|
BrowserDialog::Mode::FileLoadNoDirs,
|
||||||
[this](bool OK, const FSNode& node) {
|
[this](bool OK, const FSNode& node) {
|
||||||
if(OK)
|
if(OK)
|
||||||
|
{
|
||||||
myBezelName->setText(node.getNameWithExt(""));
|
myBezelName->setText(node.getNameWithExt(""));
|
||||||
|
myBezelDetected->setLabel("");
|
||||||
|
}
|
||||||
},
|
},
|
||||||
[](const FSNode& node) {
|
[](const FSNode& node) {
|
||||||
return BSPF::endsWithIgnoreCase(node.getName(), ".png");
|
return BSPF::endsWithIgnoreCase(node.getName(), ".png");
|
||||||
|
|
|
@ -141,6 +141,7 @@ class GameInfoDialog : public Dialog, public CommandSender
|
||||||
ButtonWidget* myUrlButton{nullptr};
|
ButtonWidget* myUrlButton{nullptr};
|
||||||
EditTextWidget* myBezelName{nullptr};
|
EditTextWidget* myBezelName{nullptr};
|
||||||
ButtonWidget* myBezelButton{nullptr};
|
ButtonWidget* myBezelButton{nullptr};
|
||||||
|
StaticTextWidget* myBezelDetected{nullptr};
|
||||||
|
|
||||||
// High Scores properties
|
// High Scores properties
|
||||||
CheckboxWidget* myHighScores{nullptr};
|
CheckboxWidget* myHighScores{nullptr};
|
||||||
|
|
Loading…
Reference in New Issue