added "Check for Update" button to HelpDialog (see #407)

This commit is contained in:
Thomas Jentzsch 2021-08-25 22:19:41 +02:00
parent d7b34387bd
commit 66233326b6
2 changed files with 25 additions and 5 deletions

View File

@ -33,7 +33,8 @@ HelpDialog::HelpDialog(OSystem& osystem, DialogContainer& parent,
fontHeight = Dialog::fontHeight(), fontHeight = Dialog::fontHeight(),
fontWidth = Dialog::fontWidth(), fontWidth = Dialog::fontWidth(),
buttonHeight = Dialog::buttonHeight(), buttonHeight = Dialog::buttonHeight(),
buttonWidth = Dialog::buttonWidth("Previous"), buttonWidth = Dialog::buttonWidth(" << "),
closeButtonWidth = Dialog::buttonWidth("Close"),
VBORDER = Dialog::vBorder(), VBORDER = Dialog::vBorder(),
HBORDER = Dialog::hBorder(), HBORDER = Dialog::hBorder(),
VGAP = Dialog::vGap(); VGAP = Dialog::vGap();
@ -48,19 +49,27 @@ HelpDialog::HelpDialog(OSystem& osystem, DialogContainer& parent,
xpos = HBORDER; ypos = _h - buttonHeight - VBORDER; xpos = HBORDER; ypos = _h - buttonHeight - VBORDER;
myPrevButton = myPrevButton =
new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight, new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight,
"Previous", GuiObject::kPrevCmd); "<<", GuiObject::kPrevCmd);
myPrevButton->clearFlags(Widget::FLAG_ENABLED); myPrevButton->clearFlags(Widget::FLAG_ENABLED);
wid.push_back(myPrevButton); wid.push_back(myPrevButton);
xpos += buttonWidth + fontWidth; xpos += buttonWidth + fontWidth;
myNextButton = myNextButton =
new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight, new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight,
"Next", GuiObject::kNextCmd); ">>", GuiObject::kNextCmd);
wid.push_back(myNextButton); wid.push_back(myNextButton);
xpos = _w - buttonWidth - HBORDER; xpos += buttonWidth + fontWidth;
int updButtonWidth = Dialog::buttonWidth("Check for Update" + ELLIPSIS);
myUpdateButton =
new ButtonWidget(this, font, xpos, ypos, updButtonWidth, buttonHeight,
"Check for Update" + ELLIPSIS, kUpdateCmd);
wid.push_back(myUpdateButton);
xpos = _w - closeButtonWidth - HBORDER;
ButtonWidget* b = ButtonWidget* b =
new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight, new ButtonWidget(this, font, xpos, ypos, closeButtonWidth, buttonHeight,
"Close", GuiObject::kCloseCmd); "Close", GuiObject::kCloseCmd);
wid.push_back(b); wid.push_back(b);
addCancelWidget(b); addCancelWidget(b);
@ -229,6 +238,11 @@ void HelpDialog::handleCommand(CommandSender* sender, int cmd,
displayInfo(); displayInfo();
break; break;
case kUpdateCmd:
MediaFactory::openURL("https://stella-emu.github.io/downloads.html?version="
+ instance().settings().getString("stella.version"));
break;
case StaticTextWidget::kOpenUrlCmd: case StaticTextWidget::kOpenUrlCmd:
{ {
const string url = myDesc[id]->getUrl(); const string url = myDesc[id]->getUrl();

View File

@ -43,6 +43,7 @@ class HelpDialog : public Dialog
static constexpr uInt32 LINES_PER_PAGE = 10; static constexpr uInt32 LINES_PER_PAGE = 10;
ButtonWidget* myNextButton{nullptr}; ButtonWidget* myNextButton{nullptr};
ButtonWidget* myPrevButton{nullptr}; ButtonWidget* myPrevButton{nullptr};
ButtonWidget* myUpdateButton{nullptr};
StaticTextWidget* myTitle; StaticTextWidget* myTitle;
std::array<StaticTextWidget*, LINES_PER_PAGE> myKey{nullptr}; std::array<StaticTextWidget*, LINES_PER_PAGE> myKey{nullptr};
@ -53,6 +54,11 @@ class HelpDialog : public Dialog
uInt8 myPage{1}; uInt8 myPage{1};
uInt8 myNumPages{5}; uInt8 myNumPages{5};
enum {
kUpdateCmd = 'upCm'
};
private: private:
// Following constructors and assignment operators not supported // Following constructors and assignment operators not supported
HelpDialog() = delete; HelpDialog() = delete;