diff --git a/code/ryzom/client/src/interface_v3/group_map.cpp b/code/ryzom/client/src/interface_v3/group_map.cpp index e9864b61b..2df88fe1e 100644 --- a/code/ryzom/client/src/interface_v3/group_map.cpp +++ b/code/ryzom/client/src/interface_v3/group_map.cpp @@ -1207,41 +1207,76 @@ void CGroupMap::checkCoords() // **** retrieve pos of respawn and update it, or hide it if there's no target uint i; - if (_RespawnPos.size() < _RespawnLM.size()) + + + if (_ArkPoints.empty()) // Ark points replace Respawn Points { - for (i = (uint)_RespawnPos.size(); i < _RespawnLM.size(); i++) + if (_RespawnPos.size() < _RespawnLM.size()) { - delCtrl(_RespawnLM[i]); - _RespawnLM[i] = NULL; + for (i = (uint)_RespawnPos.size(); i < _RespawnLM.size(); i++) + { + delCtrl(_RespawnLM[i]); + _RespawnLM[i] = NULL; + } } - } - _RespawnLM.resize(_RespawnPos.size(), NULL); - for(i = 0; i < _RespawnPos.size(); ++i) - { - if (_RespawnLM[i] == NULL) + + _RespawnLM.resize(_RespawnPos.size(), NULL); + for(i = 0; i < _RespawnPos.size(); ++i) { - _RespawnLM[i] = createLandMarkButton(_RespawnLMOptions); - _RespawnLM[i]->setId(this->getId() + ":rplm_" + NLMISC::toString(i)); - _RespawnLM[i]->setParent(this); - if (_MapMode == MapMode_SpawnSquad) - _RespawnLM[i]->setDefaultContextHelp(NLMISC::CI18N::get("uiSquadSpawnPoint") + NLMISC::toString(" %u", i+1)); - else + if (_RespawnLM[i] == NULL) { - if (isIsland()) - { - _RespawnLM[i]->setDefaultContextHelp(NLMISC::CI18N::get("uiR2EntryPoint")); - } + _RespawnLM[i] = createLandMarkButton(_RespawnLMOptions); + _RespawnLM[i]->setId(this->getId() + ":rplm_" + NLMISC::toString(i)); + _RespawnLM[i]->setParent(this); + if (_MapMode == MapMode_SpawnSquad) + _RespawnLM[i]->setDefaultContextHelp(NLMISC::CI18N::get("uiSquadSpawnPoint") + NLMISC::toString(" %u", i+1)); else { - _RespawnLM[i]->setDefaultContextHelp(NLMISC::CI18N::get("uiRespawnPoint")); + if (isIsland()) + { + _RespawnLM[i]->setDefaultContextHelp(NLMISC::CI18N::get("uiR2EntryPoint")); + } + else + { + _RespawnLM[i]->setDefaultContextHelp(NLMISC::CI18N::get("uiRespawnPoint")); + } + _RespawnLM[i]->HandleEvents = R2::getEditor().getMode() != R2::CEditor::EditionMode; } - _RespawnLM[i]->HandleEvents = R2::getEditor().getMode() != R2::CEditor::EditionMode; + addCtrl(_RespawnLM[i]); + } + if (_RespawnLM[i]) + updateLMPosFromDBPos(_RespawnLM[i], _RespawnPos[i].x, _RespawnPos[i].y); + } + } + else + { + if (_ArkPoints.size() < _RespawnLM.size()) + { + for (i = (uint)_ArkPoints.size(); i < _RespawnLM.size(); i++) + { + delCtrl(_RespawnLM[i]); + _RespawnLM[i] = NULL; + } + } + + _RespawnLM.resize(_ArkPoints.size(), NULL); + for(i = 0; i < _ArkPoints.size(); i++) + { + if (_RespawnLM[i] == NULL) + { + _RespawnLM[i] = createArkPointButton(_ArkPoints[i]); + _RespawnLM[i]->setId(this->getId() + ":arklm_" + NLMISC::toString(i)); + _RespawnLM[i]->setParent(this); + ucstring title; + title.fromUtf8(_ArkPoints[i].Title); + _RespawnLM[i]->setDefaultContextHelp(title); + _RespawnLM[i]->HandleEvents = true; + addCtrl(_RespawnLM[i]); + updateLMPosFromDBPos(_RespawnLM[i], _ArkPoints[i].x, _ArkPoints[i].y); } - addCtrl(_RespawnLM[i]); } - if (_RespawnLM[i]) - updateLMPosFromDBPos(_RespawnLM[i], _RespawnPos[i].x, _RespawnPos[i].y); } + if ((_MapMode == MapMode_Death) || (_MapMode == MapMode_SpawnSquad)) { if (_RespawnPosReseted) @@ -1599,7 +1634,7 @@ void CGroupMap::draw() if (_FrustumView) { - if (R2::getEditor().getMode() == R2::CEditor::EditionMode) + if (getArkPowoMode() == "editor" || R2::getEditor().getMode() == R2::CEditor::EditionMode) { static volatile bool wantFrustum = true; if (wantFrustum) @@ -1647,7 +1682,7 @@ void CGroupMap::draw() Driver->setScissor(newScissor); - if (R2::getEditor().getMode() != R2::CEditor::EditionMode) + if (getArkPowoMode() == "editor" || R2::getEditor().getMode() != R2::CEditor::EditionMode) { // Draw the player TODO : replace with a CViewQuad if (!_PlayerPosLoadFailure) @@ -1688,7 +1723,7 @@ void CGroupMap::draw() // draw border of frustum if (_FrustumView) { - if (R2::getEditor().getMode() == R2::CEditor::EditionMode) + if (getArkPowoMode() == "editor" || R2::getEditor().getMode() == R2::CEditor::EditionMode) { if (_FrustumMaterial.empty()) { @@ -2448,6 +2483,14 @@ void CGroupMap::removeLandMarks(TLandMarkButtonVect &lm) lm.clear(); } + +//============================================================================================================ +void CGroupMap::removeUserLandMarks() +{ + removeLandMarks(_UserLM); +} + + //============================================================================================================ void CGroupMap::createLMWidgets(const std::vector &lms) { @@ -2658,6 +2701,30 @@ CGroupMap::CLandMarkButton *CGroupMap::createLandMarkButton(const CLandMarkOptio lmb->setPosRef(Hotspot_MM); return lmb; } + +//============================================================================================================ +CGroupMap::CLandMarkButton *CGroupMap::createArkPointButton(const CArkPoint &point) +{ + CLandMarkButton *lmb = new CLandMarkButton(CViewBase::TCtorParam()); + static int statFool = 0; + lmb->setId(this->getId()+":lm"+toString(statFool++)); + lmb->setTexture(point.Texture); + lmb->setTextureOver(point.Texture); + lmb->setTexturePushed(point.Texture); + lmb->setType(CCtrlButton::PushButton); + lmb->setActionOnLeftClick(point.LeftClickAction); + lmb->setParamsOnLeftClick(point.LeftClickParam); + lmb->setActionOnRightClick(point.RightClickAction); + lmb->setParamsOnRightClick(point.RightClickParam); + lmb->setColor(point.Color); + lmb->setColorOver(point.Color); + lmb->setColorPushed(point.Color); + lmb->setModulateGlobalColorAll(false); + + lmb->setPosRef(Hotspot_MM); + return lmb; +} + //============================================================================================================ void CGroupMap::updateLandMarkButton(CLandMarkButton *lmb, const CLandMarkOptions &options) { @@ -2698,6 +2765,50 @@ void CGroupMap::addLandMark(TLandMarkButtonVect &destList, const NLMISC::CVector addCtrl(lmb); } +//============================================================================================================ +void CGroupMap::addUserLandMark(const NLMISC::CVector2f &pos, const ucstring &title, NLMISC::CRGBA color) +{ + if (_CurContinent == NULL) return; + + CUserLandMark ulm; + mapToWorld(ulm.Pos, pos); + ulm.Title = title; + ulm.Type = 5; + _CurContinent->UserLandMarks.push_back(ulm); + + CLandMarkOptions options(_UserLMOptions); + options.ColorNormal = options.ColorOver = options.ColorPushed = color; + // create a new button and add it to the list + CLandMarkButton *lmb = createLandMarkButton(options); + lmb->setParent(this); + lmb->Pos = pos; + lmb->setDefaultContextHelp(title); + _UserLM.push_back(lmb); + addCtrl(lmb); + invalidateCoords(); +} + +//============================================================================================================ +void CGroupMap::delArkPoints() +{ + for (uint i = 0; i < _RespawnLM.size(); i++) + { + delCtrl(_RespawnLM[i]); + _RespawnLM[i] = NULL; + } + _ArkPoints.clear(); +} + +//============================================================================================================ +void CGroupMap::addUserRespawnPoint(const NLMISC::CVector2f &pos) +{ + CRespawnPointsMsg rpm; + rpm.NeedToReset = false; + rpm.RespawnPoints.push_back(CRespawnPointsMsg::SRespawnPoint(pos.x*1000,pos.y*1000)); + addRespawnPoints(rpm); +} + + //============================================================================================================ CCtrlButton *CGroupMap::addUserLandMark(const NLMISC::CVector2f &pos, const ucstring &title, const CUserLandMark::EUserLandMarkType lmType) { @@ -3279,6 +3390,38 @@ void CGroupMap::addRespawnPoints(const CRespawnPointsMsg &rpm) } } +//========================================================================================================= +void CGroupMap::addArkPoint(const CArkPoint &point) { + _ArkPoints.push_back(point); + + if (_MapMode != MapMode_Death) return; + if (_ArkPoints.empty()) return; + + CWorldSheet *pWS = dynamic_cast(SheetMngr.get(CSheetId("ryzom.world"))); + if (pWS == NULL) return; + + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + if (pIM == NULL) return; + + NLMISC::CVector2f rpWorldPos(point.x * 0.001f, point.y * 0.001f); + + for (uint32 i = 0; i < pWS->Maps.size(); ++i) + { + SMap &rMap = pWS->Maps[i]; + if (rMap.ContinentName.empty()) continue; + + if ((rpWorldPos.x >= rMap.MinX) && + (rpWorldPos.x <= rMap.MaxX) && + (rpWorldPos.y >= rMap.MinY) && + (rpWorldPos.y <= rMap.MaxY)) + { + setMap(rMap.Name); + break; + } + } +} + + //========================================================================================================= void CGroupMap::serialConfig(NLMISC::IStream &f) { @@ -3726,7 +3869,10 @@ class CAHWorldMapRightClick : public IActionHandler } else { - CAHManager::getInstance()->runActionHandler("active_menu", pCaller, "menu=ui:interface:map_menu_island"); + if (gm->getArkPowoMode() == "editor") + CAHManager::getInstance()->runActionHandler("active_menu", pCaller, "menu="+gm->getArkPowoMapMenu()); + else + CAHManager::getInstance()->runActionHandler("active_menu", pCaller, "menu=ui:interface:map_menu_island"); } } }; diff --git a/code/ryzom/client/src/interface_v3/group_map.h b/code/ryzom/client/src/interface_v3/group_map.h index baf273779..57ccdcd7b 100644 --- a/code/ryzom/client/src/interface_v3/group_map.h +++ b/code/ryzom/client/src/interface_v3/group_map.h @@ -81,6 +81,27 @@ public: } }; +class CArkPoint +{ +public: + sint32 x, y; + std::string Texture; + NLMISC::CRGBA Color; + std::string Title; + std::string LeftClickAction; + std::string LeftClickParam; + std::string RightClickAction; + std::string RightClickParam; + +public: + CArkPoint() + { + Color = NLMISC::CRGBA::White; + x = 0; + y = 0; + } +}; + /** * Display of map and landmarks. * @@ -100,6 +121,7 @@ public: class CGroupMap : public CInterfaceGroup { public: + // external element to be displayed on the map struct IDeco { @@ -196,7 +218,12 @@ public: void getLandmarkPosition(const CCtrlButton *lm, NLMISC::CVector2f &worldPos); //Remove and re-create UserLandMarks + void removeUserLandMarks(); void updateUserLandMarks(); + void addUserLandMark(const NLMISC::CVector2f &pos, const ucstring &title, NLMISC::CRGBA color); + void addUserRespawnPoint(const NLMISC::CVector2f &pos); + void delArkPoints(); + // set landmarks visibility based text query void setLandmarkFilter(const std::string &s); @@ -245,6 +272,14 @@ public: // Server set all valid respawn points void addRespawnPoints(const CRespawnPointsMsg &rpm); + // add Ark landscape point + void addArkPoint(const CArkPoint &point); + + std::string getArkPowoMode() const { return _ArkPowoMode; } + void setArkPowoMode(const std::string &mode) { _ArkPowoMode = mode; } + std::string getArkPowoMapMenu() const { return _ArkPowoMapMenu; } + void setArkPowoMapMenu(const std::string &menu) { _ArkPowoMapMenu = menu; } + bool isInDeathMode() { return _MapMode == MapMode_Death; } sint32 getRespawnSelected() const; @@ -399,6 +434,8 @@ private: sint32 _MapW; sint32 _MapH; + std::string _ArkPowoMode; + std::string _ArkPowoMapMenu; NLMISC::CRGBA _FrustumViewColor; NLMISC::CRGBA _FrustumViewColorOver; float _FrustumOverBlendFactor; @@ -505,6 +542,7 @@ private: }; TMapMode _MapMode; + std::vector _ArkPoints; CLandMarkOptions _RespawnLMOptions; // landmark for respawn TLandMarkButtonVect _RespawnLM; @@ -546,6 +584,9 @@ private: void addLandMark(TLandMarkButtonVect &destList, const NLMISC::CVector2f &pos, const ucstring &title, const CLandMarkOptions &options); // Create a landmark button, but do not add it to this group CLandMarkButton *createLandMarkButton(const CLandMarkOptions &options); + // Create a Ark landmark button, but do not add it to this group + CLandMarkButton *createArkPointButton(const CArkPoint &point); + // update a landmark button void updateLandMarkButton(CLandMarkButton *lmb, const CLandMarkOptions &options); diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index f749d9227..c2f79e04d 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -93,6 +93,7 @@ #include "../zone_util.h" #include "../motion/user_controls.h" #include "group_html_cs.h" +#include "group_map.h" #include "bonus_malus.h" #include "nel/gui/group_editbox.h" #include "../entities.h" @@ -482,7 +483,13 @@ void CLuaIHMRyzom::RegisterRyzomFunctions(NLGUI::CLuaState &ls) ls.registerFunc("getShapeColOrient", getShapeColOrient); ls.registerFunc("deleteShape", deleteShape); ls.registerFunc("setupShape", setupShape); - + ls.registerFunc("removeLandMarks", removeLandMarks); + ls.registerFunc("addLandMark", addLandMark); + ls.registerFunc("updateUserLandMarks", updateUserLandMarks); + ls.registerFunc("delArkPoints", delArkPoints); + ls.registerFunc("addRespawnPoint", addRespawnPoint); + ls.registerFunc("setArkPowoOptions", setArkPowoOptions); + lua_State *L = ls.getStatePointer(); LUABIND_ENUM(PVP_CLAN::TPVPClan, "game.TPVPClan", PVP_CLAN::NbClans, PVP_CLAN::toString); @@ -3807,6 +3814,101 @@ bool CLuaIHMRyzom::isTargetInPVPMode() return (target->getPvpMode() & PVP_MODE::PvpFaction || target->getPvpMode() & PVP_MODE::PvpFactionFlagged || target->getPvpMode() & PVP_MODE::PvpZoneFaction) != 0; } + +// *************************************************************************** +int CLuaIHMRyzom::removeLandMarks(CLuaState &ls) +{ + CGroupMap *pMap = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:actual_map")); + if (pMap != NULL) + pMap->removeUserLandMarks(); + return 0; +} + +// *************************************************************************** +// addLandMark(10000, -4000, "Hello Atys!", "ico_over_homin.tga","","","","") +int CLuaIHMRyzom::addLandMark(CLuaState &ls) +{ + const char* funcName = "addLandMark"; + CLuaIHM::checkArgMin(ls, funcName, 4); + CLuaIHM::checkArgMax(ls, funcName, 9); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); // x + CLuaIHM::checkArgType(ls, funcName, 2, LUA_TNUMBER); // y + CLuaIHM::checkArgType(ls, funcName, 3, LUA_TSTRING); // title + CLuaIHM::checkArgType(ls, funcName, 4, LUA_TSTRING); // texture + CLuaIHM::checkArgType(ls, funcName, 5, LUA_TSTRING); // left click action + CLuaIHM::checkArgType(ls, funcName, 6, LUA_TSTRING); // left click param + CLuaIHM::checkArgType(ls, funcName, 7, LUA_TSTRING); // right click action + CLuaIHM::checkArgType(ls, funcName, 8, LUA_TSTRING); // right click params + + CArkPoint point; + point.x = (sint32)(ls.toNumber(1)*1000.f); + point.y = (sint32)(ls.toNumber(2)*1000.f); + point.Title = ls.toString(3); + point.Texture = ls.toString(4); + point.LeftClickAction = ls.toString(5); + point.LeftClickParam = ls.toString(6); + point.RightClickAction = ls.toString(7); + point.RightClickParam = ls.toString(8); + + point.Color = CRGBA(255,255,255,255); + + if (ls.getTop() >= 9) + CLuaIHM::pop(ls, point.Color); + + CGroupMap *pMap = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:actual_map")); + if (pMap != NULL) + pMap->addArkPoint(point); + return 0; +} + +// *************************************************************************** +int CLuaIHMRyzom::delArkPoints(CLuaState &ls) +{ + CGroupMap *pMap = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:actual_map")); + if (pMap != NULL) + pMap->delArkPoints(); + return 0; +} + +// *************************************************************************** +int CLuaIHMRyzom::addRespawnPoint(CLuaState &ls) +{ + const char* funcName = "addRespawnPoint"; + CLuaIHM::checkArgMin(ls, funcName, 2); + float x = (float) ls.toNumber(1); + float y = (float) ls.toNumber(2); + CVector2f pos(x, y); + + CGroupMap *pMap = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:actual_map")); + if (pMap != NULL) + pMap->addUserRespawnPoint(pos); + return 0; +} + +// *************************************************************************** +int CLuaIHMRyzom::updateUserLandMarks(CLuaState &ls) +{ + CGroupMap *pMap = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:actual_map")); + if (pMap != NULL) + pMap->updateUserLandMarks(); + return 0; +} + +// *************************************************************************** +int CLuaIHMRyzom::setArkPowoOptions(CLuaState &ls) +{ + const char* funcName = "setArkPowoOptions"; + CLuaIHM::checkArgMin(ls, funcName, 2); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); + CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); + CGroupMap *pMap = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:actual_map")); + if (pMap != NULL) { + pMap->setArkPowoMode(ls.toString(1)); + pMap->setArkPowoMapMenu(ls.toString(2)); + } + return 0; +} + // *************************************************************************** std::string CLuaIHMRyzom::createGotoFileButtonTag(const char *fileName, uint line) { diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h index 7a733f7aa..e27c7ee2e 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h @@ -223,6 +223,15 @@ private: static int getShapeIdAt(CLuaState &ls); static int setupShape(CLuaState &ls); static void setMouseCursor(const std::string &texture); + + static int removeLandMarks(CLuaState &ls); + static int addLandMark(CLuaState &ls); + static int updateUserLandMarks(CLuaState &ls); + static int addRespawnPoint(CLuaState &ls); + static int delArkPoints(CLuaState &ls); + static int setArkPowoOptions(CLuaState &ls); + + // open the window to do a tell to 'player', if 'msg' is not empty, then the message will be sent immediatly // else, current command of the chat window will be replaced with tell 'player' static void tell(const ucstring &player, const ucstring &msg);