From 2f635117f7221505d3e41a3fcc022346b88f06c7 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Tue, 10 Mar 2020 13:39:10 +0200 Subject: [PATCH 1/8] Changed: Require confirmation when removing landmark --- code/ryzom/client/src/interface_v3/group_map.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/group_map.cpp b/code/ryzom/client/src/interface_v3/group_map.cpp index a5d0c4470..2dea63983 100644 --- a/code/ryzom/client/src/interface_v3/group_map.cpp +++ b/code/ryzom/client/src/interface_v3/group_map.cpp @@ -3926,9 +3926,9 @@ REGISTER_ACTION_HANDLER(CAHLandMarkSelected, "land_mark_selected"); // Remove a user landmark class CAHRemoveUserLandMark : public IActionHandler { - virtual void execute (CCtrlBase *pCaller, const string &/* params */) + virtual void execute (CCtrlBase * /* pCaller */, const string &/* params */) { - CCtrlButton *button = dynamic_cast(pCaller); + CCtrlButton *button = dynamic_cast(CWidgetManager::getInstance()->getCtrlLaunchingModal()); if (!button) return; CGroupMap *map = dynamic_cast(button->getParent()); if (!map) return; @@ -3936,6 +3936,8 @@ class CAHRemoveUserLandMark : public IActionHandler // close the rename window & create window closeLandMarkNameDialog(); LastSelectedLandMark = NULL; + // close confirmation + CAHManager::getInstance()->runActionHandler("leave_modal", NULL); } }; REGISTER_ACTION_HANDLER(CAHRemoveUserLandMark, "remove_user_landmark"); From ec1dfca0c5d739d8693207d7ae9b363635eb698a Mon Sep 17 00:00:00 2001 From: Nimetu Date: Thu, 12 Mar 2020 12:58:38 +0200 Subject: [PATCH 2/8] Added: setUserLandMark command to show/hide user map markers --- .../client/src/interface_v3/group_map.cpp | 42 ++++++++++++++++++- .../ryzom/client/src/interface_v3/group_map.h | 7 ++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/code/ryzom/client/src/interface_v3/group_map.cpp b/code/ryzom/client/src/interface_v3/group_map.cpp index 2dea63983..0e83c3cc2 100644 --- a/code/ryzom/client/src/interface_v3/group_map.cpp +++ b/code/ryzom/client/src/interface_v3/group_map.cpp @@ -437,6 +437,7 @@ CGroupMap::CGroupMap(const TCtorParam ¶m) _HomeLM = NULL; _LandmarkFilter.clear(); _MatchedLandmarks.clear(); + _UserLandMarkVisible = true; // _ScaleMax = 8.f; _ScaleMaxR2 = 8.f; @@ -2700,7 +2701,7 @@ void CGroupMap::updateUserLandMarks() addLandMark(_UserLM, mapPos, _CurContinent->UserLandMarks[k].Title, getUserLandMarkOptions(k)); // hide landmark if not matching filter - if (!filterLandmark(_CurContinent->UserLandMarks[k].Title)) + if (!_UserLandMarkVisible || !filterLandmark(_CurContinent->UserLandMarks[k].Title)) _UserLM.back()->setActive(false); } invalidateCoords(); @@ -2979,6 +2980,15 @@ CLandMarkOptions CGroupMap::getUserLandMarkOptions(uint32 lmindex) const } +//============================================================================================================ +void CGroupMap::setUserLandMarkVisible(bool state) +{ + if (_UserLandMarkVisible != state) + { + _UserLandMarkVisible = state; + updateUserLandMarks(); + } +} //============================================================================================================ void CGroupMap::updatePlayerPos() @@ -3765,6 +3775,9 @@ void CGroupMap::updateClosestLandMarkMenu(const std::string &menu, const NLMISC: // no continent selected (ie world map view) if (!_CurContinent) return; + // user markers not visible + if (!_UserLandMarkVisible) return; + // sort landmarks, keep indices typedef std::pair TSortedDistPair; std::vector sortedIndices; @@ -4306,6 +4319,33 @@ class CUpdateLandMarksColor : public IActionHandler{public: virtual void execute REGISTER_ACTION_HANDLER (CUpdateLandMarksColor, "update_landmarks_color"); +//========================================================================================================= +// toggle user landmarks visibility +// no arguments - toggle show/hide +// 0 - hide +// 1 - show (any non "0" value) +NLMISC_COMMAND( showHideUserLandMark, "Show/Hide user landmarks", "0|1") +{ + const std::string mapId("ui:interface:map:content:map_content:actual_map"); + + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + CGroupMap *map = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(mapId)); + if (!map) + { + nlwarning("Unable to find map element '%s'", mapId.c_str()); + return false; + } + + bool state; + if (args.size() == 0) + state = !map->getUserLandMarkVisible(); + else + state = !(args[0] == "0"); + + map->setUserLandMarkVisible(state); + return true; +} + //////////////////// // DEBUG COMMANDS // //////////////////// diff --git a/code/ryzom/client/src/interface_v3/group_map.h b/code/ryzom/client/src/interface_v3/group_map.h index 2bc112c5b..bc0cc2d6a 100644 --- a/code/ryzom/client/src/interface_v3/group_map.h +++ b/code/ryzom/client/src/interface_v3/group_map.h @@ -299,6 +299,10 @@ public: void updateClosestLandMarkMenu(const std::string &menu, const NLMISC::CVector2f &pos) const; + // show/hide all user landmarks + void setUserLandMarkVisible(bool state); + bool getUserLandMarkVisible() const { return _UserLandMarkVisible; }; + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private: // A non rectangular button to click on zone of the map @@ -473,6 +477,9 @@ private: // LANDMARKS // /////////////// + // if false, user landmarks are not drawn + bool _UserLandMarkVisible; + // landmarks of continent TLandMarkButtonVect _ContinentLM; TLandMarkTextVect _ContinentText; From 7cb5c817a67d35cd29ddc01f5ac7dfc1b2564db7 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Thu, 12 Mar 2020 17:53:47 +0200 Subject: [PATCH 3/8] Fixed: Switching continents ignored user landmark show/hide state --- code/ryzom/client/src/interface_v3/group_map.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/code/ryzom/client/src/interface_v3/group_map.cpp b/code/ryzom/client/src/interface_v3/group_map.cpp index 0e83c3cc2..8e91af2c6 100644 --- a/code/ryzom/client/src/interface_v3/group_map.cpp +++ b/code/ryzom/client/src/interface_v3/group_map.cpp @@ -2627,7 +2627,11 @@ void CGroupMap::createContinentLandMarks() CLandMarkOptions options = getUserLandMarkOptions(k); addLandMark(_UserLM, mapPos, _CurContinent->UserLandMarks[k].Title, options); - if (_LandmarkFilter.size() > 0) + if (!_UserLandMarkVisible) + { + _UserLM.back()->setActive(false); + } + else if (_LandmarkFilter.size() > 0) { if (filterLandmark(_CurContinent->UserLandMarks[k].Title)) { From ca20d582b390b92cd644d48445d732cc571a9ffa Mon Sep 17 00:00:00 2001 From: Nimetu Date: Thu, 12 Mar 2020 17:46:19 +0200 Subject: [PATCH 4/8] Changed: Remove char limit from displaying icon label --- .../client/src/interface_v3/dbctrl_sheet.cpp | 20 +++++++++---------- .../client/src/interface_v3/dbctrl_sheet.h | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index a5a07420f..fd21c20b2 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -1293,10 +1293,10 @@ void CDBCtrlSheet::setupItem () // special icon text if( _NeedSetup || _ItemSheet->getIconText() != _OptString ) { - // compute from OptString. Allow only 1 line and 4 chars + // compute from OptString. Allow only 1 line (-2 for padding) _OptString= _ItemSheet->getIconText(); // Display Top Left - setupCharBitmaps(40, 1, 6, true); + setupCharBitmaps(40-2, 1, true); } // Special Item requirement @@ -1410,8 +1410,8 @@ void CDBCtrlSheet::setupMacro() { if (!_NeedSetup) return; - // compute from OptString - setupCharBitmaps(26, 4, 5); + // compute from OptString (-2 for padding) + setupCharBitmaps(26-2, 4); _NeedSetup = false; @@ -1713,8 +1713,8 @@ void CDBCtrlSheet::setupDisplayAsPhrase(const std::vector &bri { // recompute text _OptString= iconName; - // compute from OptString. Allow only 1 line and 5 chars - setupCharBitmaps(26, 1, 5); + // compute from OptString. Allow only 1 line (-2 for padding) + setupCharBitmaps(26-2, 1); } } } @@ -1840,10 +1840,10 @@ void CDBCtrlSheet::setupOutpostBuilding() // special icon text if (pOBSheet->getIconText() != _OptString) { - // compute from OptString. Allow only 1 line and 4 chars + // compute from OptString. Allow only 1 line, (-2 for padding) _OptString= pOBSheet->getIconText(); // Display Top Left - setupCharBitmaps(40, 1, 6, true); + setupCharBitmaps(40-2, 1, true); } } else @@ -1886,7 +1886,7 @@ void CDBCtrlSheet::resetCharBitmaps() } // *************************************************************************** -void CDBCtrlSheet::setupCharBitmaps(sint32 maxW, sint32 maxLine, sint32 maxWChar, bool topDown) +void CDBCtrlSheet::setupCharBitmaps(sint32 maxW, sint32 maxLine, bool topDown) { // Use the optString for the Macro name _OptString = toLower(_OptString); @@ -1907,7 +1907,7 @@ void CDBCtrlSheet::setupCharBitmaps(sint32 maxW, sint32 maxLine, sint32 maxWChar { char c = _OptString[i]; sint32 w = rVR.getTypoTextureW(c); - if ((curLineSize + w) > maxW || (sint32)xChar>=maxWChar) + if ((curLineSize + w) > maxW) { lineNb ++; if (lineNb == maxLine) break; diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.h b/code/ryzom/client/src/interface_v3/dbctrl_sheet.h index 4abc16f4b..7de3dd03b 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.h +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.h @@ -815,7 +815,7 @@ private: // remove enchant and buff markers from item icon void clearIconBuffs(); - void setupCharBitmaps(sint32 maxW, sint32 maxLine, sint32 maxWChar= 1000, bool topDown= false); + void setupCharBitmaps(sint32 maxW, sint32 maxLine, bool topDown= false); void resetCharBitmaps(); void displayCharBitmaps(sint32 rdrLayer, sint32 x, sint32 y, NLMISC::CRGBA color); From 586e49282f2ade864801dfa733089994b2ce9cb2 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Thu, 12 Mar 2020 18:16:26 +0200 Subject: [PATCH 5/8] Changed: Translate icon text if starts with uiit --- .../client/src/interface_v3/dbctrl_sheet.cpp | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index fd21c20b2..d6b521672 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -1888,24 +1888,30 @@ void CDBCtrlSheet::resetCharBitmaps() // *************************************************************************** void CDBCtrlSheet::setupCharBitmaps(sint32 maxW, sint32 maxLine, bool topDown) { - // Use the optString for the Macro name - _OptString = toLower(_OptString); - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = *CViewRenderer::getInstance(); - _CharBitmaps.clear(); + if(maxLine<=0) return; - if(maxLine<=0) - return; + std::string text(_OptString); + if (_Type != SheetType_Macro && text.size() > 4) + { + // check for icon text 'uiitLabel' + if (text[0] == 'u' && text[1] == 'i' && text[2] == 'i' && text[3] == 't' && CI18N::hasTranslation(text)) + { + // NOTE: translated text is expected to be us-ascii only + text = CI18N::get(text).toUtf8(); + } + } + + CViewRenderer &rVR = *CViewRenderer::getInstance(); uint h = rVR.getTypoTextureH('a'); sint lineNb = 0; sint curLineSize = 0; uint i; uint xChar= 0; - for (i = 0; i < _OptString.size(); ++i) + for (i = 0; i < text.size(); ++i) { - char c = _OptString[i]; + char c = text[i]; sint32 w = rVR.getTypoTextureW(c); if ((curLineSize + w) > maxW) { From 94873c3d3f97255706e24d26e623ca6adea36644 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Thu, 12 Mar 2020 18:17:33 +0200 Subject: [PATCH 6/8] Changed: Preserve icon text case as is --- code/ryzom/client/src/client_sheets/item_sheet.cpp | 1 - code/ryzom/client/src/client_sheets/outpost_building_sheet.cpp | 1 - 2 files changed, 2 deletions(-) diff --git a/code/ryzom/client/src/client_sheets/item_sheet.cpp b/code/ryzom/client/src/client_sheets/item_sheet.cpp index b55382660..715fd4df0 100644 --- a/code/ryzom/client/src/client_sheets/item_sheet.cpp +++ b/code/ryzom/client/src/client_sheets/item_sheet.cpp @@ -271,7 +271,6 @@ void CItemSheet::build(const NLGEORGES::UFormElm &item) string IconText; if(!item.getValueByName (IconText, "3d.text overlay")) debug("key '3d.text overlay' not found."); - IconText = toLower(IconText); IdIconText = ClientSheetsStrings.add(IconText); // See if this item can be hiden when equipped diff --git a/code/ryzom/client/src/client_sheets/outpost_building_sheet.cpp b/code/ryzom/client/src/client_sheets/outpost_building_sheet.cpp index 841a57aad..db7e9e55a 100644 --- a/code/ryzom/client/src/client_sheets/outpost_building_sheet.cpp +++ b/code/ryzom/client/src/client_sheets/outpost_building_sheet.cpp @@ -131,7 +131,6 @@ void COutpostBuildingSheet::build(const NLGEORGES::UFormElm &root) string IconText; if(!root.getValueByName (IconText, "text overlay")) debug("key 'text overlay' not found."); - IconText = toLower(IconText); IdIconText = ClientSheetsStrings.add(IconText); } From e99b7e257d57a9e949006d5d8ab479b004852fa9 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Thu, 12 Mar 2020 18:27:40 +0200 Subject: [PATCH 7/8] Fixed: Icon text must be in lowercase for bitmap icons --- code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index d6b521672..531987f74 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -1901,6 +1901,7 @@ void CDBCtrlSheet::setupCharBitmaps(sint32 maxW, sint32 maxLine, bool topDown) text = CI18N::get(text).toUtf8(); } } + text = toLower(text); CViewRenderer &rVR = *CViewRenderer::getInstance(); From 4d9aa3e6843e76c85e389d2aab68b8c2daaac97a Mon Sep 17 00:00:00 2001 From: Nimetu Date: Thu, 12 Mar 2020 18:36:00 +0200 Subject: [PATCH 8/8] Changed: refactor --- code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index 531987f74..852a94930 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -1892,14 +1892,11 @@ void CDBCtrlSheet::setupCharBitmaps(sint32 maxW, sint32 maxLine, bool topDown) if(maxLine<=0) return; std::string text(_OptString); - if (_Type != SheetType_Macro && text.size() > 4) + // check for icon text 'uiitLabel' + if (text.size() > 4 && text[0] == 'u' && text[1] == 'i' && text[2] == 'i' && text[3] == 't' && CI18N::hasTranslation(text)) { - // check for icon text 'uiitLabel' - if (text[0] == 'u' && text[1] == 'i' && text[2] == 'i' && text[3] == 't' && CI18N::hasTranslation(text)) - { - // NOTE: translated text is expected to be us-ascii only - text = CI18N::get(text).toUtf8(); - } + // NOTE: translated text is expected to be us-ascii only + text = CI18N::get(text).toUtf8(); } text = toLower(text);