From a50689a88570fc339e330e0e4755b8d6d1164c57 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Tue, 1 Mar 2016 22:30:05 +0200 Subject: [PATCH 1/9] Changed: Use multiline text for http errors --HG-- branch : develop --- code/nel/src/gui/group_html.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index f72198ec7..205499e07 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -3550,6 +3550,7 @@ namespace NLGUI CViewText *viewText = new CViewText ("", (string("Error : ")+msg).c_str()); viewText->setColor (ErrorColor); viewText->setModulateGlobalColor(ErrorColorGlobalColor); + viewText->setMultiLine (true); getParagraph()->addChild (viewText); if(!_TitlePrefix.empty()) setTitle (_TitlePrefix); From e2fca3a8f36ce24abb9bd3e40935a53cf9c95a34 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Tue, 23 Feb 2016 10:52:24 +0200 Subject: [PATCH 2/9] Added: http-equiv refresh --HG-- branch : develop --- code/nel/include/nel/gui/group_html.h | 4 ++ code/nel/src/gui/group_html.cpp | 63 ++++++++++++++++++++++++++- 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/code/nel/include/nel/gui/group_html.h b/code/nel/include/nel/gui/group_html.h index 5cc632a4e..7a09b8281 100644 --- a/code/nel/include/nel/gui/group_html.h +++ b/code/nel/include/nel/gui/group_html.h @@ -409,6 +409,10 @@ namespace NLGUI double _TimeoutValue; // the timeout in seconds double _ConnectingTimeout; sint _RedirectsRemaining; + // Automatic page refresh + double _LastRefreshTime; + double _NextRefreshTime; + std::string _RefreshUrl; // minimal embeded lua script support // Note : any embeded script is executed immediately after the closing diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index 205499e07..51e8e3850 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -1137,6 +1137,40 @@ namespace NLGUI } } break; + case HTML_META: + if (_ReadingHeadTag) + { + bool httpEquiv = present[HTML_META_HTTP_EQUIV] && value[HTML_META_HTTP_EQUIV]; + bool httpContent = present[HTML_META_CONTENT] && value[HTML_META_CONTENT]; + if (httpEquiv && httpContent) + { + // only first http-equiv="refresh" should be handled + if (_RefreshUrl.empty() && toLower(value[HTML_META_HTTP_EQUIV]) == "refresh") + { + const CWidgetManager::SInterfaceTimes × = CWidgetManager::getInstance()->getInterfaceTimes(); + double timeSec = times.thisFrameMs / 1000.0f; + string content(value[HTML_META_CONTENT]); + + string::size_type pos = content.find_first_of(";"); + if (pos == string::npos) + { + fromString(content, _NextRefreshTime); + _RefreshUrl = _URL; + } + else + { + fromString(content.substr(0, pos), _NextRefreshTime); + + pos = toLower(content).find("url="); + if (pos != string::npos) + _RefreshUrl = content.substr(pos + 4); + } + + _NextRefreshTime += timeSec; + } + } + } + break; case HTML_A: { CStyleParams style; @@ -2422,6 +2456,9 @@ namespace NLGUI _GroupListAdaptor = NULL; _DocumentUrl = ""; _UrlFragment.clear(); + _RefreshUrl.clear(); + _NextRefreshTime = 0.0; + _LastRefreshTime = 0.0; // Register CWidgetManager::getInstance()->registerClockMsgTarget(this); @@ -3413,8 +3450,15 @@ namespace NLGUI // Handle now handle (); } + if (systemEvent.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::activecalledonparent) + { + if (!((NLGUI::CEventDescriptorActiveCalledOnParent &) systemEvent).getActive()) + { + // stop refresh when window gets hidden + _NextRefreshTime = 0; + } + } } - return traited; } @@ -4410,6 +4454,21 @@ namespace NLGUI // handle curl downloads checkDownloads(); + // handle refresh timer + if (_NextRefreshTime > 0 && _NextRefreshTime <= (times.thisFrameMs / 1000.0f) ) + { + // there might be valid uses for 0sec refresh, but two in a row is probably a mistake + if (_NextRefreshTime - _LastRefreshTime >= 1.0) + { + _LastRefreshTime = _NextRefreshTime; + doBrowse(_RefreshUrl.c_str()); + } + else + nlwarning("Ignore second 0sec http-equiv refresh in a row (url '%s')", _URL.c_str()); + + _NextRefreshTime = 0; + } + if (_Connecting) { // Check timeout if needed @@ -4783,6 +4842,8 @@ namespace NLGUI // _Browsing = true; _DocumentUrl = _URL; + _NextRefreshTime = 0; + _RefreshUrl.clear(); // clear content beginBuild(); From a95c887534594501a838251bffc6b6792d529595 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Tue, 23 Feb 2016 10:52:21 +0200 Subject: [PATCH 3/9] Changed: Implement multi-row select box --HG-- branch : develop --- code/nel/include/nel/gui/group_html.h | 20 ++ code/nel/include/nel/gui/group_menu.h | 1 + code/nel/src/gui/group_html.cpp | 192 +++++++++++++++++- code/nel/src/gui/group_menu.cpp | 11 + .../gamedev/interfaces_v3/login_widgets.xml | 19 ++ .../data/gamedev/interfaces_v3/widgets.xml | 20 ++ 6 files changed, 253 insertions(+), 10 deletions(-) diff --git a/code/nel/include/nel/gui/group_html.h b/code/nel/include/nel/gui/group_html.h index 7a09b8281..635136220 100644 --- a/code/nel/include/nel/gui/group_html.h +++ b/code/nel/include/nel/gui/group_html.h @@ -34,6 +34,7 @@ namespace NLGUI class CCtrlButton; class CCtrlScroll; class CGroupList; + class CGroupMenu; class CDBGroupComboBox; class CGroupParagraph; @@ -189,6 +190,7 @@ namespace NLGUI std::string DefaultFormTextGroup; std::string DefaultFormTextAreaGroup; std::string DefaultFormSelectGroup; + std::string DefaultFormSelectBoxMenuGroup; std::string DefaultCheckBoxBitmapNormal; std::string DefaultCheckBoxBitmapPushed; std::string DefaultCheckBoxBitmapOver; @@ -345,6 +347,7 @@ namespace NLGUI // Add a combo box in the current paragraph CDBGroupComboBox *addComboBox(const std::string &templateName, const char *name); + CGroupMenu *addSelectBox(const std::string &templateName, const char *name); // Add a button in the current paragraph. actionHandler, actionHandlerParams and tooltip can be NULL. CCtrlButton *addButton(CCtrlButton::EType type, const std::string &name, const std::string &normalBitmap, const std::string &pushedBitmap, @@ -630,6 +633,10 @@ namespace NLGUI TextArea = NULL; Checkbox = NULL; ComboBox = NULL; + SelectBox = NULL; + sbRBRef = NULL; + sbMultiple = false; + sbOptionDisabled = -1; InitialSelection = 0; } @@ -648,6 +655,19 @@ namespace NLGUI // Combobox group CDBGroupComboBox *ComboBox; + // Combobox with multiple selection or display size >= 2 + CGroupMenu *SelectBox; + + // Single or multiple selections for SelectBox + bool sbMultiple; + + // Marks OPTION element as disabled + // Only valid when parsing html + sint sbOptionDisabled; + + // First radio button in SelectBox if single selection + CCtrlBaseButton *sbRBRef; + // select values (for the