diff --git a/client/gui/InterfaceObjectConfigurable.cpp b/client/gui/InterfaceObjectConfigurable.cpp index 60bdacbda..f70ca35a5 100644 --- a/client/gui/InterfaceObjectConfigurable.cpp +++ b/client/gui/InterfaceObjectConfigurable.cpp @@ -565,6 +565,8 @@ std::shared_ptr InterfaceObjectConfigurable::buildTextInput(const Js result->setText(readText(config["text"])); if(!config["callback"].isNull()) result->cb += callbacks_string.at(config["callback"].String()); + if(!config["help"].isNull()) + result->helpBox = readText(config["help"]); return result; } diff --git a/client/lobby/OptionsTab.cpp b/client/lobby/OptionsTab.cpp index 0280189ba..4f726904c 100644 --- a/client/lobby/OptionsTab.cpp +++ b/client/lobby/OptionsTab.cpp @@ -61,7 +61,7 @@ OptionsTab::OptionsTab() : humanPlayers(0) auto parseTimerString = [](const std::string & str){ auto sc = str.find(":"); if(sc == std::string::npos) - return std::stoi(str); + return str.empty() ? 0 : std::stoi(str); auto l = str.substr(0, sc); auto r = str.substr(sc + 1, std::string::npos); @@ -75,6 +75,8 @@ OptionsTab::OptionsTab() : humanPlayers(0) r.insert(r.begin(), l.back()); l.pop_back(); } + else if(r.empty()) + r = "0"; int sec = std::stoi(r); if(sec >= 60) diff --git a/client/widgets/TextControls.cpp b/client/widgets/TextControls.cpp index 5401f0f64..591a8d4dd 100644 --- a/client/widgets/TextControls.cpp +++ b/client/widgets/TextControls.cpp @@ -17,6 +17,7 @@ #include "../gui/CGuiHandler.h" #include "../gui/Shortcut.h" #include "../windows/CMessage.h" +#include "../windows/InfoWindows.h" #include "../adventureMap/CInGameConsole.h" #include "../renderSDL/SDL_Extensions.h" #include "../render/Canvas.h" @@ -495,7 +496,7 @@ CTextInput::CTextInput(const Rect & Pos, EFonts font, const CFunctionList(bgName, bgOffset.x, bgOffset.y); - addUsedEvents(LCLICK | KEYBOARD | TEXTINPUT); + addUsedEvents(LCLICK | SHOW_POPUP | KEYBOARD | TEXTINPUT); #if !defined(VCMI_MOBILE) giveFocus(); @@ -604,6 +605,13 @@ void CTextInput::keyPressed(EShortcut key) } } +void CTextInput::showPopupWindow(const Point & cursorPosition) +{ + if(helpBox.size()) //there is no point to show window with nothing inside... + CRClickPopup::createAndPush(helpBox); +} + + void CTextInput::setText(const std::string & nText) { setText(nText, false); diff --git a/client/widgets/TextControls.h b/client/widgets/TextControls.h index bc67e8abf..14b8f6b13 100644 --- a/client/widgets/TextControls.h +++ b/client/widgets/TextControls.h @@ -213,6 +213,8 @@ protected: std::string visibleText() override; public: + std::string helpBox; //for right-click help + CFunctionList cb; CFunctionList filters; void setText(const std::string & nText) override; @@ -224,6 +226,7 @@ public: void clickPressed(const Point & cursorPosition) override; void keyPressed(EShortcut key) override; + void showPopupWindow(const Point & cursorPosition) override; //bool captureThisKey(EShortcut key) override;