mirror of https://github.com/stella-emu/stella.git
redesigned RomInfoWidget link display
enhanced AboutDialog with more links
This commit is contained in:
parent
8371fbe98a
commit
e463ef2fb4
|
@ -350,7 +350,7 @@ int FBSurface::drawString(const GUI::Font& font, const string& s,
|
|||
int x, int y, int w, int h,
|
||||
ColorId color, TextAlign align,
|
||||
int deltax, bool useEllipsis, ColorId shadowColor,
|
||||
size_t linkStart, int linkLen, bool underline)
|
||||
size_t linkStart, size_t linkLen, bool underline)
|
||||
{
|
||||
int lines = 0;
|
||||
|
||||
|
@ -389,7 +389,7 @@ void FBSurface::drawString(const GUI::Font& font, const string& s,
|
|||
int x, int y, int w,
|
||||
ColorId color, TextAlign align,
|
||||
int deltax, bool useEllipsis, ColorId shadowColor,
|
||||
size_t linkStart, int linkLen, bool underline)
|
||||
size_t linkStart, size_t linkLen, bool underline)
|
||||
{
|
||||
#ifdef GUI_SUPPORT
|
||||
const string ELLIPSIS = "\x1d"; // "..."
|
||||
|
@ -446,13 +446,13 @@ void FBSurface::drawString(const GUI::Font& font, const string& s,
|
|||
x1 = x + w;
|
||||
|
||||
drawChar(font, str[i], x, y,
|
||||
(i >= linkStart && i < linkStart + linkLen) ? kTextColorEm : color,
|
||||
(i >= linkStart && i < linkStart + linkLen) ? kTextColorLink : color,
|
||||
shadowColor);
|
||||
}
|
||||
x += w;
|
||||
}
|
||||
if(underline && x1 > 0)
|
||||
hLine(x0, y + font.getFontHeight() - 1, x1, kTextColorEm);
|
||||
hLine(x0, y + font.getFontHeight() - 1, x1, kTextColorLink);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -231,7 +231,8 @@ class FBSurface
|
|||
virtual int drawString(const GUI::Font& font, const string& s, int x, int y, int w, int h,
|
||||
ColorId color, TextAlign align = TextAlign::Left,
|
||||
int deltax = 0, bool useEllipsis = true, ColorId shadowColor = kNone,
|
||||
size_t linkStart = string::npos, int linkLen = 0, bool underline = false);
|
||||
size_t linkStart = string::npos, size_t linkLen = string::npos,
|
||||
bool underline = false);
|
||||
|
||||
/**
|
||||
This method should be called to draw the specified string.
|
||||
|
@ -254,7 +255,8 @@ class FBSurface
|
|||
virtual void drawString(const GUI::Font& font, const string& s, int x, int y, int w,
|
||||
ColorId color, TextAlign align = TextAlign::Left,
|
||||
int deltax = 0, bool useEllipsis = true, ColorId shadowColor = kNone,
|
||||
size_t linkStart = string::npos, int linkLen = 0, bool underline = false);
|
||||
size_t linkStart = string::npos, size_t linkLen = string::npos,
|
||||
bool underline = false);
|
||||
|
||||
/**
|
||||
Splits a given string to a given width considering whitespaces.
|
||||
|
|
|
@ -1419,6 +1419,7 @@ void FrameBuffer::toggleGrabMouse(bool toggle)
|
|||
kTextColorHi Highlighted text color
|
||||
kTextColorEm Emphasized text color
|
||||
kTextColorInv Color for selected text
|
||||
kTextColorLink Color for links
|
||||
*** UI elements (dialog and widgets) ***
|
||||
kDlgColor Dialog background
|
||||
kWidColor Widget background
|
||||
|
@ -1454,7 +1455,7 @@ void FrameBuffer::toggleGrabMouse(bool toggle)
|
|||
*/
|
||||
UIPaletteArray FrameBuffer::ourStandardUIPalette = {
|
||||
{ 0x686868, 0x000000, 0xa38c61, 0xdccfa5, 0x404040, // base
|
||||
0x000000, 0xac3410, 0x9f0000, 0xf0f0cf, // text
|
||||
0x000000, 0xac3410, 0x9f0000, 0xf0f0cf, 0xac3410, // text
|
||||
0xc9af7c, 0xf0f0cf, 0xd55941, 0xc80000, // UI elements
|
||||
0xac3410, 0xd55941, 0x686868, 0xdccfa5, 0xf0f0cf, 0xf0f0cf, // buttons
|
||||
0xac3410, // checkbox
|
||||
|
@ -1467,7 +1468,7 @@ UIPaletteArray FrameBuffer::ourStandardUIPalette = {
|
|||
|
||||
UIPaletteArray FrameBuffer::ourClassicUIPalette = {
|
||||
{ 0x686868, 0x000000, 0x404040, 0x404040, 0x404040, // base
|
||||
0x20a020, 0x00ff00, 0xc80000, 0x000000, // text
|
||||
0x20a020, 0x00ff00, 0xc80000, 0x000000, 0x00ff00, // text
|
||||
0x000000, 0x000000, 0x00ff00, 0xc80000, // UI elements
|
||||
0x000000, 0x000000, 0x686868, 0x00ff00, 0x20a020, 0x00ff00, // buttons
|
||||
0x20a020, // checkbox
|
||||
|
@ -1480,7 +1481,7 @@ UIPaletteArray FrameBuffer::ourClassicUIPalette = {
|
|||
|
||||
UIPaletteArray FrameBuffer::ourLightUIPalette = {
|
||||
{ 0x808080, 0x000000, 0xc0c0c0, 0xe1e1e1, 0x333333, // base
|
||||
0x000000, 0xBDDEF9, 0x0078d7, 0x000000, // text
|
||||
0x000000, 0xBDDEF9, 0x0078d7, 0x000000, 0x005aa1, // text
|
||||
0xf0f0f0, 0xffffff, 0x0078d7, 0x0f0f0f, // UI elements
|
||||
0xe1e1e1, 0xe5f1fb, 0x808080, 0x0078d7, 0x000000, 0x000000, // buttons
|
||||
0x333333, // checkbox
|
||||
|
@ -1493,7 +1494,7 @@ UIPaletteArray FrameBuffer::ourLightUIPalette = {
|
|||
|
||||
UIPaletteArray FrameBuffer::ourDarkUIPalette = {
|
||||
{ 0x646464, 0xc0c0c0, 0x3c3c3c, 0x282828, 0x989898, // base
|
||||
0xc0c0c0, 0x1567a5, 0x0059a3, 0xc0c0c0, // text
|
||||
0xc0c0c0, 0x1567a5, 0x0059a3, 0xc0c0c0, 0x1567a5, // text
|
||||
0x202020, 0x000000, 0x0059a3, 0xb0b0b0, // UI elements
|
||||
0x282828, 0x00467f, 0x646464, 0x0059a3, 0xc0c0c0, 0xc0c0c0, // buttons
|
||||
0x989898, // checkbox
|
||||
|
|
|
@ -77,39 +77,40 @@ static constexpr ColorId
|
|||
kTextColorHi = 262,
|
||||
kTextColorEm = 263,
|
||||
kTextColorInv = 264,
|
||||
kTextColorLink = 265,
|
||||
// *** UI elements(dialog and widgets) ***
|
||||
kDlgColor = 265,
|
||||
kWidColor = 266,
|
||||
kWidColorHi = 267,
|
||||
kWidFrameColor = 268,
|
||||
kDlgColor = 266,
|
||||
kWidColor = 267,
|
||||
kWidColorHi = 268,
|
||||
kWidFrameColor = 269,
|
||||
// *** Button colors ***
|
||||
kBtnColor = 269,
|
||||
kBtnColorHi = 270,
|
||||
kBtnBorderColor = 271,
|
||||
kBtnBorderColorHi = 272,
|
||||
kBtnTextColor = 273,
|
||||
kBtnTextColorHi = 274,
|
||||
kBtnColor = 270,
|
||||
kBtnColorHi = 271,
|
||||
kBtnBorderColor = 272,
|
||||
kBtnBorderColorHi = 273,
|
||||
kBtnTextColor = 274,
|
||||
kBtnTextColorHi = 275,
|
||||
// *** Checkbox colors ***
|
||||
kCheckColor = 275,
|
||||
kCheckColor = 276,
|
||||
// *** Scrollbar colors ***
|
||||
kScrollColor = 276,
|
||||
kScrollColorHi = 277,
|
||||
kScrollColor = 277,
|
||||
kScrollColorHi = 278,
|
||||
// *** Debugger colors ***
|
||||
kDbgChangedColor = 278,
|
||||
kDbgChangedTextColor = 279,
|
||||
kDbgColorHi = 280,
|
||||
kDbgColorRed = 281, // Note: this must be < 0x11e (286)! (see PromptWidget::putcharIntern)
|
||||
kDbgChangedColor = 279,
|
||||
kDbgChangedTextColor = 280,
|
||||
kDbgColorHi = 281,
|
||||
kDbgColorRed = 282, // Note: this must be < 0x11e (286)! (see PromptWidget::putcharIntern)
|
||||
// *** Slider colors ***
|
||||
kSliderColor = 282,
|
||||
kSliderColorHi = 283,
|
||||
kSliderBGColor = 284,
|
||||
kSliderBGColorHi = 285,
|
||||
kSliderBGColorLo = 286,
|
||||
kSliderColor = 283,
|
||||
kSliderColorHi = 284,
|
||||
kSliderBGColor = 285,
|
||||
kSliderBGColorHi = 286,
|
||||
kSliderBGColorLo = 287,
|
||||
// *** Other colors ***
|
||||
kColorInfo = 287,
|
||||
kColorTitleBar = 288,
|
||||
kColorTitleText = 289,
|
||||
kNumColors = 290,
|
||||
kColorInfo = 288,
|
||||
kColorTitleBar = 289,
|
||||
kColorTitleText = 290,
|
||||
kNumColors = 291,
|
||||
kNone = 0 // placeholder to represent default/no color
|
||||
;
|
||||
|
||||
|
|
|
@ -163,9 +163,8 @@ void AboutDialog::updateStrings(int page, int lines, string& title)
|
|||
|
||||
case 4:
|
||||
title = "Cast of thousands";
|
||||
ADD_ATEXT("\\L\\c0""Special thanks to AtariAge for introducing the");
|
||||
ADD_ATEXT("\\L\\c0""Special thanks to <AtariAge> for introducing the");
|
||||
ADD_ATEXT("\\L\\c0""Atari 2600 to a whole new generation.");
|
||||
ADD_ATEXT("\\L http://www.atariage.com");
|
||||
ADD_ALINE();
|
||||
ADD_ATEXT("\\L\\c0""Finally, a huge thanks to the original Atari 2600");
|
||||
ADD_ATEXT("\\L\\c0""VCS team for giving us the magic, and to the");
|
||||
|
@ -245,7 +244,24 @@ void AboutDialog::displayInfo()
|
|||
myDesc[i]->setAlign(align);
|
||||
myDesc[i]->setTextColor(color);
|
||||
myDesc[i]->setLabel(str);
|
||||
myDesc[i]->setUrl(); // extract URL from label
|
||||
// add some labeled links
|
||||
if(BSPF::containsIgnoreCase(str, "see manual"))
|
||||
myDesc[i]->setUrl("https://stella-emu.github.io/docs/index.html#License", "manual");
|
||||
else if(BSPF::containsIgnoreCase(str, "Stephen Anthony"))
|
||||
myDesc[i]->setUrl("http://minbar.org", "Stephen Anthony");
|
||||
else if(BSPF::containsIgnoreCase(str, "Bradford W. Mott"))
|
||||
myDesc[i]->setUrl("www.intellimedia.ncsu.edu/people/bwmott", "Bradford W. Mott");
|
||||
else if(BSPF::containsIgnoreCase(str, "ScummVM project"))
|
||||
myDesc[i]->setUrl("www.scummvm.org", "ScummVM");
|
||||
else if(BSPF::containsIgnoreCase(str, "Ian Bogost"))
|
||||
myDesc[i]->setUrl("http://bogost.com", "Ian Bogost");
|
||||
else if(BSPF::containsIgnoreCase(str, "CRT Simulation"))
|
||||
myDesc[i]->setUrl("http://blargg.8bitalley.com/libs/ntsc.html", "CRT Simulation effects");
|
||||
else if(BSPF::containsIgnoreCase(str, "<AtariAge>"))
|
||||
myDesc[i]->setUrl("www.atariage.com", "AtariAge", "<AtariAge>");
|
||||
else
|
||||
// extract URL from label
|
||||
myDesc[i]->setUrl();
|
||||
}
|
||||
|
||||
// Redraw entire dialog
|
||||
|
|
|
@ -127,6 +127,8 @@ void RomInfoWidget::parseProperties(const FilesystemNode& node)
|
|||
if(mySurface)
|
||||
mySurface->setVisible(mySurfaceIsValid);
|
||||
|
||||
myUrl = myProperties.get(PropType::Cart_Url);
|
||||
|
||||
// Now add some info for the message box below the image
|
||||
myRomInfo.push_back("Name: " + myProperties.get(PropType::Cart_Name));
|
||||
|
||||
|
@ -178,8 +180,6 @@ void RomInfoWidget::parseProperties(const FilesystemNode& node)
|
|||
|
||||
if (bsDetected != "")
|
||||
myRomInfo.push_back("Type: " + Bankswitch::typeToDesc(Bankswitch::nameToType(bsDetected)));
|
||||
if((value = myProperties.get(PropType::Cart_Url)) != EmptyString)
|
||||
myRomInfo.push_back("Link: " + value);
|
||||
|
||||
setDirty();
|
||||
}
|
||||
|
@ -235,7 +235,11 @@ void RomInfoWidget::drawWidget(bool hilite)
|
|||
s.frameRect(_x, _y, _w, _h, kColor);
|
||||
s.frameRect(_x, _y+yoff, _w, _h-yoff, kColor);
|
||||
|
||||
if(!myHaveProperties) return;
|
||||
if(!myHaveProperties)
|
||||
{
|
||||
clearDirty();
|
||||
return;
|
||||
}
|
||||
|
||||
if(mySurfaceIsValid)
|
||||
{
|
||||
|
@ -274,11 +278,12 @@ void RomInfoWidget::drawWidget(bool hilite)
|
|||
}
|
||||
|
||||
int lines;
|
||||
if(BSPF::startsWithIgnoreCase(info, "Link: "))
|
||||
|
||||
if(BSPF::startsWithIgnoreCase(info, "Name: ") && myUrl != EmptyString)
|
||||
{
|
||||
lines = s.drawString(_font, info, xpos, ypos, _w - 16, _font.getFontHeight() * 3,
|
||||
_textcolor, TextAlign::Left, 0, true, kNone,
|
||||
6, 2000, hilite);
|
||||
6, info.length() - 6, hilite);
|
||||
}
|
||||
else
|
||||
lines = s.drawString(_font, info, xpos, ypos, _w - 16, _font.getFontHeight() * 3,
|
||||
|
|
|
@ -46,7 +46,7 @@ class RomInfoWidget : public Widget, public CommandSender
|
|||
|
||||
void resetSurfaces();
|
||||
|
||||
const string& getUrl() const { return myProperties.get(PropType::Cart_Url); }
|
||||
const string& getUrl() const { return myUrl; }
|
||||
|
||||
protected:
|
||||
void drawWidget(bool hilite) override;
|
||||
|
@ -74,6 +74,9 @@ class RomInfoWidget : public Widget, public CommandSender
|
|||
// Indicates if the current properties should actually be used
|
||||
bool myHaveProperties{false};
|
||||
|
||||
// Optional cart link URL
|
||||
string myUrl;
|
||||
|
||||
// Indicates if an error occurred in creating/displaying the surface
|
||||
string mySurfaceErrorMsg;
|
||||
|
||||
|
|
|
@ -516,14 +516,19 @@ void StaticTextWidget::setLink(size_t start, int len, bool underline)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool StaticTextWidget::setUrl(const string& url, const string& label)
|
||||
bool StaticTextWidget::setUrl(const string& url, const string& label,
|
||||
const string& placeHolder)
|
||||
{
|
||||
#ifndef RETRON77
|
||||
size_t start = string::npos, len = 0;
|
||||
const string& text = label != EmptyString ? label : url;
|
||||
|
||||
if(text != EmptyString)
|
||||
{
|
||||
// determine position of label
|
||||
if(placeHolder != EmptyString)
|
||||
BSPF::replaceAll(_label, placeHolder, text);
|
||||
|
||||
// determine position of link
|
||||
if((start = BSPF::findIgnoreCase(_label, text)) != string::npos)
|
||||
{
|
||||
len = text.size();
|
||||
|
@ -575,6 +580,9 @@ bool StaticTextWidget::setUrl(const string& url, const string& label)
|
|||
_url = EmptyString;
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -219,7 +219,8 @@ class StaticTextWidget : public Widget, public CommandSender
|
|||
bool isEditable() const { return _editable; }
|
||||
|
||||
void setLink(size_t start = string::npos, int len = 0, bool underline = false);
|
||||
bool setUrl(const string& url = EmptyString, const string& label = EmptyString);
|
||||
bool setUrl(const string& url = EmptyString, const string& label = EmptyString,
|
||||
const string& placeHolder = EmptyString);
|
||||
const string& getUrl() const { return _url; }
|
||||
|
||||
protected:
|
||||
|
|
|
@ -2118,4 +2118,4 @@
|
|||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
|
@ -2294,4 +2294,4 @@
|
|||
<Filter>Resource Files</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
Loading…
Reference in New Issue