enhanced help with optional direct URL

This commit is contained in:
thrust26 2021-04-18 08:24:59 +02:00
parent c68871ec68
commit 8249411ffa
4 changed files with 30 additions and 5 deletions

View File

@ -811,7 +811,7 @@ PhysicalKeyboardHandler::DefaultMenuMapping = {
{Event::UITabNext, KBDK_BACKSPACE}, // back (FRY) {Event::UITabNext, KBDK_BACKSPACE}, // back (FRY)
#else // defining duplicate keys must be avoided! #else // defining duplicate keys must be avoided!
{Event::UIPrevDir, KBDK_BACKSPACE}, {Event::UIPrevDir, KBDK_BACKSPACE},
{Event::UIHelp, KBDK_F1}, {Event::UIHelp, KBDK_F1},
#endif #endif
}; };

View File

@ -87,6 +87,8 @@ AboutDialog::AboutDialog(OSystem& osystem, DialogContainer& parent,
} }
addToFocusList(wid); addToFocusList(wid);
setHelpURL("https://stella-emu.github.io/index.html");
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -146,21 +146,21 @@ void Dialog::setTitle(const string& title)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Dialog::setHelpAnchor(const string& helpAnchor, bool debugger) void Dialog::initHelp()
{ {
#ifndef RETRON77 #ifndef RETRON77
_helpAnchor = helpAnchor;
_debuggerHelp = debugger;
if(hasTitle()) if(hasTitle())
{ {
if(_helpWidget == nullptr) if(_helpWidget == nullptr)
{ {
string key = instance().eventHandler().getMappingDesc(Event::UIHelp, EventMode::kMenuMode);
_helpWidget = new ButtonWidget(this, _font, _w - _font.getMaxCharWidth() * 3.5, 0, _helpWidget = new ButtonWidget(this, _font, _w - _font.getMaxCharWidth() * 3.5, 0,
_font.getMaxCharWidth() * 3.5 + 0.5, buttonHeight(), "?", _font.getMaxCharWidth() * 3.5 + 0.5, buttonHeight(), "?",
kHelpCmd); kHelpCmd);
_helpWidget->setBGColor(kColorTitleBar); _helpWidget->setBGColor(kColorTitleBar);
_helpWidget->setTextColor(kColorTitleText); _helpWidget->setTextColor(kColorTitleText);
_helpWidget->setToolTip("Click or press " + key + " for help.");
} }
if(hasHelp()) if(hasHelp())
@ -171,9 +171,29 @@ void Dialog::setHelpAnchor(const string& helpAnchor, bool debugger)
#endif #endif
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Dialog::setHelpAnchor(const string& helpAnchor, bool debugger)
{
_helpAnchor = helpAnchor;
_debuggerHelp = debugger;
initHelp();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Dialog::setHelpURL(const string& helpURL)
{
_helpURL = helpURL;
initHelp();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const string Dialog::getHelpURL() const string Dialog::getHelpURL()
{ {
if(!_helpURL.empty())
return _helpURL;
if(!_helpAnchor.empty()) if(!_helpAnchor.empty())
{ {
if(_debuggerHelp) if(_debuggerHelp)

View File

@ -98,6 +98,7 @@ class Dialog : public GuiObject
bool hasTitle() { return !_title.empty(); } bool hasTitle() { return !_title.empty(); }
void setHelpAnchor(const string& helpAnchor, bool debugger = false); void setHelpAnchor(const string& helpAnchor, bool debugger = false);
void setHelpURL(const string& helpURL);
virtual bool isShading() const { return true; } virtual bool isShading() const { return true; }
@ -209,6 +210,7 @@ class Dialog : public GuiObject
bool handleNavEvent(Event::Type e, bool repeated = false); bool handleNavEvent(Event::Type e, bool repeated = false);
void getTabIdForWidget(Widget* w); void getTabIdForWidget(Widget* w);
bool cycleTab(int direction); bool cycleTab(int direction);
void initHelp();
const string getHelpURL(); const string getHelpURL();
bool hasHelp() { return !getHelpURL().empty(); } bool hasHelp() { return !getHelpURL().empty(); }
void openHelp(); void openHelp();
@ -231,6 +233,7 @@ class Dialog : public GuiObject
int _layer{0}; int _layer{0};
unique_ptr<ToolTip> _toolTip; unique_ptr<ToolTip> _toolTip;
string _helpAnchor; string _helpAnchor;
string _helpURL;
bool _debuggerHelp{false}; bool _debuggerHelp{false};
ButtonWidget* _helpWidget{nullptr}; ButtonWidget* _helpWidget{nullptr};