From e463ef2fb4ae2f41599c80e750cabd2d47223166 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Sat, 24 Apr 2021 11:53:26 +0200 Subject: [PATCH] redesigned RomInfoWidget link display enhanced AboutDialog with more links --- src/emucore/FBSurface.cxx | 8 ++--- src/emucore/FBSurface.hxx | 6 ++-- src/emucore/FrameBuffer.cxx | 9 ++--- src/emucore/FrameBufferConstants.hxx | 53 ++++++++++++++-------------- src/gui/AboutDialog.cxx | 22 ++++++++++-- src/gui/RomInfoWidget.cxx | 15 +++++--- src/gui/RomInfoWidget.hxx | 5 ++- src/gui/Widget.cxx | 12 +++++-- src/gui/Widget.hxx | 3 +- src/windows/Stella.vcxproj | 2 +- src/windows/Stella.vcxproj.filters | 2 +- 11 files changed, 87 insertions(+), 50 deletions(-) diff --git a/src/emucore/FBSurface.cxx b/src/emucore/FBSurface.cxx index 9ed4d7971..e4dff77c3 100644 --- a/src/emucore/FBSurface.cxx +++ b/src/emucore/FBSurface.cxx @@ -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 } diff --git a/src/emucore/FBSurface.hxx b/src/emucore/FBSurface.hxx index f1ebbdd80..1024a4a37 100644 --- a/src/emucore/FBSurface.hxx +++ b/src/emucore/FBSurface.hxx @@ -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. diff --git a/src/emucore/FrameBuffer.cxx b/src/emucore/FrameBuffer.cxx index d9ff97f3a..439ee4005 100644 --- a/src/emucore/FrameBuffer.cxx +++ b/src/emucore/FrameBuffer.cxx @@ -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 diff --git a/src/emucore/FrameBufferConstants.hxx b/src/emucore/FrameBufferConstants.hxx index f2355fa55..af81313b4 100644 --- a/src/emucore/FrameBufferConstants.hxx +++ b/src/emucore/FrameBufferConstants.hxx @@ -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 ; diff --git a/src/gui/AboutDialog.cxx b/src/gui/AboutDialog.cxx index 75d759118..f26695a6c 100644 --- a/src/gui/AboutDialog.cxx +++ b/src/gui/AboutDialog.cxx @@ -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 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, "")) + myDesc[i]->setUrl("www.atariage.com", "AtariAge", ""); + else + // extract URL from label + myDesc[i]->setUrl(); } // Redraw entire dialog diff --git a/src/gui/RomInfoWidget.cxx b/src/gui/RomInfoWidget.cxx index 938ef92ed..93ba83a88 100644 --- a/src/gui/RomInfoWidget.cxx +++ b/src/gui/RomInfoWidget.cxx @@ -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, diff --git a/src/gui/RomInfoWidget.hxx b/src/gui/RomInfoWidget.hxx index 3cb1392b9..095c32e54 100644 --- a/src/gui/RomInfoWidget.hxx +++ b/src/gui/RomInfoWidget.hxx @@ -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; diff --git a/src/gui/Widget.cxx b/src/gui/Widget.cxx index 2ace0896d..f5ab9231f 100644 --- a/src/gui/Widget.cxx +++ b/src/gui/Widget.cxx @@ -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 } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/Widget.hxx b/src/gui/Widget.hxx index 8497c2f89..a1b1a0253 100644 --- a/src/gui/Widget.hxx +++ b/src/gui/Widget.hxx @@ -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: diff --git a/src/windows/Stella.vcxproj b/src/windows/Stella.vcxproj index f53521a82..42ead3e44 100644 --- a/src/windows/Stella.vcxproj +++ b/src/windows/Stella.vcxproj @@ -2118,4 +2118,4 @@ - + \ No newline at end of file diff --git a/src/windows/Stella.vcxproj.filters b/src/windows/Stella.vcxproj.filters index ade41fd00..857f49276 100644 --- a/src/windows/Stella.vcxproj.filters +++ b/src/windows/Stella.vcxproj.filters @@ -2294,4 +2294,4 @@ Resource Files - + \ No newline at end of file