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 : patches-from-atys
hg/hotfix/patches-from-atys
Ulukyn 6 years ago
parent c0037fc55a
commit 36036faffd

@ -228,6 +228,8 @@ namespace NLGUI
std::string getHTML() const { return _DocumentHtml; } std::string getHTML() const { return _DocumentHtml; }
void setHTML(const std::string &html); void setHTML(const std::string &html);
void setHome(const std::string &home);
int luaClearRefresh(CLuaState &ls); int luaClearRefresh(CLuaState &ls);
int luaClearUndoRedo(CLuaState &ls); int luaClearUndoRedo(CLuaState &ls);
int luaBrowse(CLuaState &ls); int luaBrowse(CLuaState &ls);
@ -256,6 +258,7 @@ namespace NLGUI
REFLECT_LUA_METHOD("setBackground", luaSetBackground) REFLECT_LUA_METHOD("setBackground", luaSetBackground)
REFLECT_STRING("url", getURL, setURL) REFLECT_STRING("url", getURL, setURL)
REFLECT_STRING("html", getHTML, setHTML) REFLECT_STRING("html", getHTML, setHTML)
REFLECT_STRING("home", home, setHome)
REFLECT_FLOAT("timeout", getTimeout, setTimeout) REFLECT_FLOAT("timeout", getTimeout, setTimeout)
REFLECT_STRING("title", getTitle, setTitle) REFLECT_STRING("title", getTitle, setTitle)
REFLECT_EXPORT_END REFLECT_EXPORT_END

@ -4639,6 +4639,11 @@ namespace NLGUI
renderHtmlString(html); renderHtmlString(html);
} }
void CGroupHTML::setHome(const std::string &home)
{
Home = home;
}
// *************************************************************************** // ***************************************************************************
void CGroupHTML::parseStylesheetFile(const std::string &fname) void CGroupHTML::parseStylesheetFile(const std::string &fname)
{ {

@ -32,6 +32,7 @@
#include "nel/gui/action_handler.h" #include "nel/gui/action_handler.h"
#include "../dummy_progress.h" #include "../dummy_progress.h"
#include "group_compas.h" #include "group_compas.h"
#include "group_html_cs.h"
#include "../connection.h" #include "../connection.h"
#include "../net_manager.h" #include "../net_manager.h"
#include "people_interraction.h" // for MaxNumPeopleInTeam #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 // **** retrieve pos of respawn and update it, or hide it if there's no target
uint i; 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 (_RespawnPos.size() < _RespawnLM.size()) if (_RespawnLM[i] == NULL)
{ {
for (i = (uint)_RespawnPos.size(); i < _RespawnLM.size(); i++) _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 (offset + _RespawnPos.size() < _RespawnLM.size())
{
for (i = offset + _RespawnPos.size(); i < _RespawnLM.size(); i++)
{ {
delCtrl(_RespawnLM[i]); delCtrl(_RespawnLM[i]);
_RespawnLM[i] = NULL; _RespawnLM[i] = NULL;
} }
} }
_RespawnLM.resize(_RespawnPos.size(), NULL); _RespawnLM.resize(offset + _RespawnPos.size(), NULL);
for(i = 0; i < _RespawnPos.size(); ++i) for(int j = 0; j < _RespawnPos.size(); ++j)
{ {
i = offset + j;
if (_RespawnLM[i] == NULL) if (_RespawnLM[i] == NULL)
{ {
_RespawnLM[i] = createLandMarkButton(_RespawnLMOptions); _RespawnLM[i] = createLandMarkButton(_RespawnLMOptions);
@ -1245,37 +1278,10 @@ void CGroupMap::checkCoords()
addCtrl(_RespawnLM[i]); addCtrl(_RespawnLM[i]);
} }
if (_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)) if ((_MapMode == MapMode_Death) || (_MapMode == MapMode_SpawnSquad))
{ {
@ -2271,6 +2277,21 @@ void CGroupMap::setMap(SMap *map)
invalidateCoords(); invalidateCoords();
createContinentLandMarks(); 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) if (_CurContinent != NULL)
_MapMaterial.setTexture(1, _CurContinent->FoW.Tx); _MapMaterial.setTexture(1, _CurContinent->FoW.Tx);
else else

Loading…
Cancel
Save