Added: setUserLandMark command to show/hide user map markers

fix-media-player
Nimetu 5 years ago
parent 2f635117f7
commit ec1dfca0c5

@ -437,6 +437,7 @@ CGroupMap::CGroupMap(const TCtorParam &param)
_HomeLM = NULL; _HomeLM = NULL;
_LandmarkFilter.clear(); _LandmarkFilter.clear();
_MatchedLandmarks.clear(); _MatchedLandmarks.clear();
_UserLandMarkVisible = true;
// //
_ScaleMax = 8.f; _ScaleMax = 8.f;
_ScaleMaxR2 = 8.f; _ScaleMaxR2 = 8.f;
@ -2700,7 +2701,7 @@ void CGroupMap::updateUserLandMarks()
addLandMark(_UserLM, mapPos, _CurContinent->UserLandMarks[k].Title, getUserLandMarkOptions(k)); addLandMark(_UserLM, mapPos, _CurContinent->UserLandMarks[k].Title, getUserLandMarkOptions(k));
// hide landmark if not matching filter // hide landmark if not matching filter
if (!filterLandmark(_CurContinent->UserLandMarks[k].Title)) if (!_UserLandMarkVisible || !filterLandmark(_CurContinent->UserLandMarks[k].Title))
_UserLM.back()->setActive(false); _UserLM.back()->setActive(false);
} }
invalidateCoords(); 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() void CGroupMap::updatePlayerPos()
@ -3765,6 +3775,9 @@ void CGroupMap::updateClosestLandMarkMenu(const std::string &menu, const NLMISC:
// no continent selected (ie world map view) // no continent selected (ie world map view)
if (!_CurContinent) return; if (!_CurContinent) return;
// user markers not visible
if (!_UserLandMarkVisible) return;
// sort landmarks, keep indices // sort landmarks, keep indices
typedef std::pair<uint, float> TSortedDistPair; typedef std::pair<uint, float> TSortedDistPair;
std::vector<TSortedDistPair> sortedIndices; std::vector<TSortedDistPair> sortedIndices;
@ -4306,6 +4319,33 @@ class CUpdateLandMarksColor : public IActionHandler{public: virtual void execute
REGISTER_ACTION_HANDLER (CUpdateLandMarksColor, "update_landmarks_color"); 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<CGroupMap*>(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 // // DEBUG COMMANDS //
//////////////////// ////////////////////

@ -299,6 +299,10 @@ public:
void updateClosestLandMarkMenu(const std::string &menu, const NLMISC::CVector2f &pos) const; 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: private:
// A non rectangular button to click on zone of the map // A non rectangular button to click on zone of the map
@ -473,6 +477,9 @@ private:
// LANDMARKS // // LANDMARKS //
/////////////// ///////////////
// if false, user landmarks are not drawn
bool _UserLandMarkVisible;
// landmarks of continent // landmarks of continent
TLandMarkButtonVect _ContinentLM; TLandMarkButtonVect _ContinentLM;
TLandMarkTextVect _ContinentText; TLandMarkTextVect _ContinentText;

Loading…
Cancel
Save