Added: home propertie of html group (so lua scripts can setup the home)

Fixed: adding new landmarks with lua don't remove respawn points if player is not in an island

--HG--
branch : compatibility-develop
hg/compatibility-develop
Ulukyn 6 years ago
parent 7d9b1f58f0
commit c582964448

@ -264,6 +264,8 @@ namespace NLGUI
// Browser home
std::string Home;
// Get Home URL
virtual std::string home();
// Undo browse: Browse the precedent url browsed. no op if none
void browseUndo ();
@ -281,6 +283,8 @@ namespace NLGUI
std::string getHTML() const { return _DocumentHtml; }
void setHTML(const std::string &html);
void setHome(const std::string &home);
int luaClearRefresh(CLuaState &ls);
int luaClearUndoRedo(CLuaState &ls);
int luaBrowse(CLuaState &ls);
@ -313,6 +317,7 @@ namespace NLGUI
REFLECT_LUA_METHOD("setBackground", luaSetBackground)
REFLECT_STRING("url", getURL, setURL)
REFLECT_STRING("html", getHTML, setHTML)
REFLECT_STRING("home", home, setHome)
REFLECT_FLOAT("timeout", getTimeout, setTimeout)
REFLECT_EXPORT_END
@ -354,9 +359,6 @@ namespace NLGUI
void htmlElement(xmlNode *node, int element_number);
void htmlWalkDOM(xmlNode *a_node);
// Get Home URL
virtual std::string home();
// Clear style stack and restore default style
void resetCssStyle();

@ -6271,6 +6271,10 @@ namespace NLGUI
renderHtmlString(html);
}
void CGroupHTML::setHome(const std::string &home)
{
Home = home;
}
// ***************************************************************************
inline bool isDigit(ucchar c, uint base = 16)

@ -32,6 +32,7 @@
#include "nel/gui/action_handler.h"
#include "../dummy_progress.h"
#include "group_compas.h"
#include "group_html_cs.h"
#include "../connection.h"
#include "../net_manager.h"
#include "people_interraction.h" // for MaxNumPeopleInTeam
@ -1207,22 +1208,54 @@ void CGroupMap::checkCoords()
// **** retrieve pos of respawn and update it, or hide it if there's no target
uint i;
uint offset = 0;
if (!_ArkPoints.empty())
{
offset = _ArkPoints.size();
if (_ArkPoints.size() < _RespawnLM.size())
{
for (i = (uint)_ArkPoints.size(); i < _RespawnLM.size(); i++)
{
delCtrl(_RespawnLM[i]);
_RespawnLM[i] = NULL;
}
}
if (_ArkPoints.empty()) // Ark points replace Respawn Points
_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);
}
}
}
if (_ArkPoints.empty() || !isIsland())
{
if (_RespawnPos.size() < _RespawnLM.size())
if (offset + _RespawnPos.size() < _RespawnLM.size())
{
for (i = (uint)_RespawnPos.size(); i < _RespawnLM.size(); i++)
for (i = offset + _RespawnPos.size(); i < _RespawnLM.size(); i++)
{
delCtrl(_RespawnLM[i]);
_RespawnLM[i] = NULL;
}
}
_RespawnLM.resize(_RespawnPos.size(), NULL);
for(i = 0; i < _RespawnPos.size(); ++i)
_RespawnLM.resize(offset + _RespawnPos.size(), NULL);
for(int j = 0; j < _RespawnPos.size(); ++j)
{
i = offset + j;
if (_RespawnLM[i] == NULL)
{
_RespawnLM[i] = createLandMarkButton(_RespawnLMOptions);
@ -1245,37 +1278,10 @@ void CGroupMap::checkCoords()
addCtrl(_RespawnLM[i]);
}
if (_RespawnLM[i])
updateLMPosFromDBPos(_RespawnLM[i], _RespawnPos[i].x, _RespawnPos[i].y);
updateLMPosFromDBPos(_RespawnLM[i], _RespawnPos[j].x, _RespawnPos[j].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);
}
}
}
if ((_MapMode == MapMode_Death) || (_MapMode == MapMode_SpawnSquad))
{
@ -2271,6 +2277,21 @@ void CGroupMap::setMap(SMap *map)
invalidateCoords();
createContinentLandMarks();
nlinfo("setMap (%f,%f) (%f,%f)", _CurMap->MinX, _CurMap->MinY, _CurMap->MaxX, _CurMap->MaxY);
delArkPoints();
CGroupHTML *groupHtml = dynamic_cast<CGroupHTML*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:lm_events:html"));
if (groupHtml)
{
groupHtml->setHome(groupHtml->Home+toString("&min_x=%f&min_y=%f&max_x=%f&max_y=%f", _CurMap->MinX, _CurMap->MinY, _CurMap->MaxX, _CurMap->MaxY));
if (groupHtml->isBrowsing())
groupHtml->stopBrowse();
groupHtml->browse(groupHtml->Home.c_str());
}
if (_CurContinent != NULL)
_MapMaterial.setTexture(1, _CurContinent->FoW.Tx);
else

Loading…
Cancel
Save