mirror of https://github.com/stella-emu/stella.git
Improved error handling when loading bezels
This commit is contained in:
parent
7d7d574bcd
commit
b3a5d04544
|
@ -56,6 +56,11 @@ const string Bezel::getName(int& index) const
|
||||||
}
|
}
|
||||||
|
|
||||||
if(index == 10)
|
if(index == 10)
|
||||||
|
{
|
||||||
|
return "Atari-2600";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(index == 11)
|
||||||
{
|
{
|
||||||
index = -1;
|
index = -1;
|
||||||
return "default";
|
return "default";
|
||||||
|
@ -88,6 +93,7 @@ bool Bezel::load()
|
||||||
{
|
{
|
||||||
const Settings& settings = myOSystem.settings();
|
const Settings& settings = myOSystem.settings();
|
||||||
bool isValid = false;
|
bool isValid = false;
|
||||||
|
string imageName = "";
|
||||||
|
|
||||||
#ifdef IMAGE_SUPPORT
|
#ifdef IMAGE_SUPPORT
|
||||||
const bool show = myOSystem.eventHandler().inTIAMode() &&
|
const bool show = myOSystem.eventHandler().inTIAMode() &&
|
||||||
|
@ -102,22 +108,21 @@ bool Bezel::load()
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const string& path = myOSystem.bezelDir().getPath();
|
const string& path = myOSystem.bezelDir().getPath();
|
||||||
string imageName;
|
|
||||||
VariantList metaData;
|
VariantList metaData;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
const string& name = getName(index);
|
imageName = getName(index);
|
||||||
if(name != EmptyString)
|
if(imageName != EmptyString)
|
||||||
{
|
{
|
||||||
// Note: JPG does not support transparency
|
// Note: JPG does not support transparency
|
||||||
imageName = path + name + ".png";
|
const string imagePath = path + imageName + ".png";
|
||||||
FSNode node(imageName);
|
FSNode node(imagePath);
|
||||||
if(node.exists())
|
if(node.exists())
|
||||||
{
|
{
|
||||||
isValid = true;
|
isValid = true;
|
||||||
myOSystem.png().loadImage(imageName, *mySurface, metaData);
|
myOSystem.png().loadImage(imagePath, *mySurface, metaData);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -160,14 +165,24 @@ bool Bezel::load()
|
||||||
// << double((int)(right - left + 1)) / double((int)(bottom - top + 1));
|
// << double((int)(right - left + 1)) / double((int)(bottom - top + 1));
|
||||||
|
|
||||||
// Disable bezel is no transparent window was found
|
// Disable bezel is no transparent window was found
|
||||||
if (left < right && top < bottom)
|
if(left < right && top < bottom)
|
||||||
myInfo = Info(Common::Size(w, h), Common::Rect(left, top, right, bottom));
|
myInfo = Info(Common::Size(w, h), Common::Rect(left, top, right, bottom));
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if(mySurface)
|
||||||
|
myFB.deallocateSurface(mySurface);
|
||||||
|
mySurface = nullptr;
|
||||||
myInfo = Info();
|
myInfo = Info();
|
||||||
|
myFB.showTextMessage("Invalid bezel image ('" + imageName + "')!");
|
||||||
|
isValid = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
myInfo = Info();
|
myInfo = Info();
|
||||||
|
if(show)
|
||||||
|
myFB.showTextMessage("No bezel image found");
|
||||||
|
}
|
||||||
return isValid;
|
return isValid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1283,7 +1283,6 @@ void FrameBuffer::toggleBezel(bool toggle)
|
||||||
if(!myBezel->load() && enabled)
|
if(!myBezel->load() && enabled)
|
||||||
{
|
{
|
||||||
myOSystem.settings().setValue("bezel.show", !enabled);
|
myOSystem.settings().setValue("bezel.show", !enabled);
|
||||||
myOSystem.frameBuffer().showTextMessage("No bezel image found");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1489,7 +1488,7 @@ void FrameBuffer::toggleGrabMouse(bool toggle)
|
||||||
kBGColor Normal background color (non-text)
|
kBGColor Normal background color (non-text)
|
||||||
kBGColorLo Disabled background color dark (non-text)
|
kBGColorLo Disabled background color dark (non-text)
|
||||||
kBGColorHi Disabled background color light (non-text)
|
kBGColorHi Disabled background color light (non-text)
|
||||||
kShadowColor Item is disabled
|
kShadowColor Item is disabled (unused)
|
||||||
*** Text colors ***
|
*** Text colors ***
|
||||||
kTextColor Normal text color
|
kTextColor Normal text color
|
||||||
kTextColorHi Highlighted text color
|
kTextColorHi Highlighted text color
|
||||||
|
@ -1577,6 +1576,6 @@ UIPaletteArray FrameBuffer::ourDarkUIPalette = {
|
||||||
0x3c3c3c, 0x646464, // scrollbar
|
0x3c3c3c, 0x646464, // scrollbar
|
||||||
0x7f2020, 0xc0c0c0, 0xe00000, 0xc00000, // debugger
|
0x7f2020, 0xc0c0c0, 0xe00000, 0xc00000, // debugger
|
||||||
0x989898, 0x0059a3, 0x3c3c3c, 0x000000, 0x3c3c3c, // slider
|
0x989898, 0x0059a3, 0x3c3c3c, 0x000000, 0x3c3c3c, // slider
|
||||||
0x000000, 0x989898, 0x202020 // other
|
0x000000, 0x404040, 0xc0c0c0 // other
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue