Added: Lua functions for group child debugging

--HG--
branch : develop
This commit is contained in:
Nimetu 2019-05-10 08:27:25 +03:00
parent 215d7bda99
commit 85a806ec44
2 changed files with 53 additions and 21 deletions

View file

@ -211,6 +211,11 @@ namespace NLGUI
int luaGetNumGroups(CLuaState &ls); int luaGetNumGroups(CLuaState &ls);
int luaGetGroup(CLuaState &ls); int luaGetGroup(CLuaState &ls);
// debug functions
int luaDumpSize(CLuaState &ls);
int luaDumpEltsOrder(CLuaState &ls);
int luaDumpGroups(CLuaState &ls);
void setMaxSizeRef(const std::string &maxSizeRef); void setMaxSizeRef(const std::string &maxSizeRef);
std::string getMaxSizeRefAsString() const; std::string getMaxSizeRefAsString() const;
@ -223,6 +228,9 @@ namespace NLGUI
REFLECT_LUA_METHOD("delGroup", luaDelGroup); REFLECT_LUA_METHOD("delGroup", luaDelGroup);
REFLECT_LUA_METHOD("getNumGroups", luaGetNumGroups); REFLECT_LUA_METHOD("getNumGroups", luaGetNumGroups);
REFLECT_LUA_METHOD("getGroup", luaGetGroup); REFLECT_LUA_METHOD("getGroup", luaGetGroup);
REFLECT_LUA_METHOD("dumpSize", luaDumpSize);
REFLECT_LUA_METHOD("dumpEltsOrder", luaDumpEltsOrder);
REFLECT_LUA_METHOD("dumpGroups", luaDumpGroups);
REFLECT_STRING ("left_click", getLeftClickHandler, setLeftClickHandler); REFLECT_STRING ("left_click", getLeftClickHandler, setLeftClickHandler);
REFLECT_STRING ("right_click", getRightClickHandler, setRightClickHandler); REFLECT_STRING ("right_click", getRightClickHandler, setRightClickHandler);
REFLECT_STRING ("left_click_params", getLeftClickHandlerParams, setLeftClickHandlerParams); REFLECT_STRING ("left_click_params", getLeftClickHandlerParams, setLeftClickHandlerParams);
@ -274,8 +282,8 @@ namespace NLGUI
sint getInsertionOrder(CViewBase *vb) const; sint getInsertionOrder(CViewBase *vb) const;
// for debug only // for debug only
void dumpGroups(); void dumpGroups() const;
void dumpEltsOrder(); void dumpEltsOrder() const;
virtual void renderWiredQuads(CInterfaceElement::TRenderWired type, const std::string &uiFilter); virtual void renderWiredQuads(CInterfaceElement::TRenderWired type, const std::string &uiFilter);

View file

@ -829,7 +829,7 @@ namespace NLGUI
const std::map< uint32, SLinkData > &linkMap = const std::map< uint32, SLinkData > &linkMap =
CWidgetManager::getInstance()->getParser()->getLinkMap(); CWidgetManager::getInstance()->getParser()->getLinkMap();
xmlNodePtr node = NULL; xmlNodePtr node = NULL;
std::map< uint32, SLinkData >::const_iterator itr; std::map< uint32, SLinkData >::const_iterator itr;
@ -847,17 +847,17 @@ namespace NLGUI
xmlAddChild( parentNode, node ); xmlAddChild( parentNode, node );
xmlSetProp( node, BAD_CAST "expr", BAD_CAST data.expr.c_str() ); xmlSetProp( node, BAD_CAST "expr", BAD_CAST data.expr.c_str() );
if( !data.target.empty() ) if( !data.target.empty() )
xmlSetProp( node, BAD_CAST "target", BAD_CAST data.target.c_str() ); xmlSetProp( node, BAD_CAST "target", BAD_CAST data.target.c_str() );
if( !data.action.empty() ) if( !data.action.empty() )
{ {
xmlSetProp( node, BAD_CAST "action", BAD_CAST data.action.c_str() ); xmlSetProp( node, BAD_CAST "action", BAD_CAST data.action.c_str() );
if( !data.params.empty() ) if( !data.params.empty() )
xmlSetProp( node, BAD_CAST "params", BAD_CAST data.params.c_str() ); xmlSetProp( node, BAD_CAST "params", BAD_CAST data.params.c_str() );
if( !data.cond.empty() ) if( !data.cond.empty() )
xmlSetProp( node, BAD_CAST "cond", BAD_CAST data.cond.c_str() ); xmlSetProp( node, BAD_CAST "cond", BAD_CAST data.cond.c_str() );
} }
@ -1792,7 +1792,7 @@ namespace NLGUI
CInterfaceGroup *pChild = *itg; CInterfaceGroup *pChild = *itg;
if (pChild->getActive()) if (pChild->getActive())
{ {
// bool bUnder = // bool bUnder =
pChild->getViewsUnder (x, y, clipX, clipY, clipW, clipH, vVB); pChild->getViewsUnder (x, y, clipX, clipY, clipW, clipH, vVB);
// if (bUnder && !vICL.empty()) // if (bUnder && !vICL.empty())
// return true; // return true;
@ -1847,7 +1847,7 @@ namespace NLGUI
CInterfaceGroup *pChild = *itg; CInterfaceGroup *pChild = *itg;
if (pChild->getActive()) if (pChild->getActive())
{ {
// bool bUnder = // bool bUnder =
pChild->getCtrlsUnder (x, y, clipX, clipY, clipW, clipH, vICL); pChild->getCtrlsUnder (x, y, clipX, clipY, clipW, clipH, vICL);
// if (bUnder && !vICL.empty()) // if (bUnder && !vICL.empty())
// return true; // return true;
@ -1903,7 +1903,7 @@ namespace NLGUI
CInterfaceGroup *pChild = *itg; CInterfaceGroup *pChild = *itg;
if (pChild->getActive()) if (pChild->getActive())
{ {
// bool bUnder = // bool bUnder =
pChild->getGroupsUnder (x, y, clipX, clipY, clipW, clipH, vIGL); pChild->getGroupsUnder (x, y, clipX, clipY, clipW, clipH, vIGL);
// if (bUnder && !vICL.empty()) // if (bUnder && !vICL.empty())
// return true; // return true;
@ -2149,7 +2149,34 @@ namespace NLGUI
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void CInterfaceGroup::dumpGroups() int CInterfaceGroup::luaDumpSize(CLuaState &ls)
{
const char *funcName = "dumpSize";
CLuaIHM::checkArgCount(ls, funcName, 0);
dumpSize();
return 0;
}
// ------------------------------------------------------------------------------------------------
int CInterfaceGroup::luaDumpEltsOrder(CLuaState &ls)
{
const char *funcName = "dumpEltsOrder";
CLuaIHM::checkArgCount(ls, funcName, 0);
dumpEltsOrder();
return 0;
}
// ------------------------------------------------------------------------------------------------
int CInterfaceGroup::luaDumpGroups(CLuaState &ls)
{
const char *funcName = "dumpGroups";
CLuaIHM::checkArgCount(ls, funcName, 0);
dumpGroups();
return 0;
}
// ------------------------------------------------------------------------------------------------
void CInterfaceGroup::dumpGroups() const
{ {
nlinfo("Num groups = %d", (int) _ChildrenGroups.size()); nlinfo("Num groups = %d", (int) _ChildrenGroups.size());
for(uint k = 0; k < _ChildrenGroups.size(); ++k) for(uint k = 0; k < _ChildrenGroups.size(); ++k)
@ -2166,21 +2193,18 @@ namespace NLGUI
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void CInterfaceGroup::dumpEltsOrder() void CInterfaceGroup::dumpEltsOrder() const
{ {
nlinfo("Num elements = %d", (int) _EltOrder.size()); nlinfo("Num elements = %d, num groups = %d", (int) _EltOrder.size(), _ChildrenGroups.size());
for(uint k = 0; k < _EltOrder.size(); ++k) for(uint k = 0; k < _EltOrder.size(); ++k)
{ {
std::string typeName = "???";
if (_ChildrenGroups[k])
{
NLGUI::CViewBase *view = _EltOrder[k];
const type_info &ti = typeid(*view);
typeName = ti.name();
}
CInterfaceElement *el = _EltOrder[k]; CInterfaceElement *el = _EltOrder[k];
if (el) if (el)
{ {
std::string typeName;
NLGUI::CViewBase *view = _EltOrder[k];
const type_info &ti = typeid(*view);
typeName = ti.name();
nlinfo("Element %d, name = %s, type=%s, x=%d, y=%d, parent_name=%s parentposname=%s xreal=%d, yreal=%d, wreal=%d, hreal=%d", nlinfo("Element %d, name = %s, type=%s, x=%d, y=%d, parent_name=%s parentposname=%s xreal=%d, yreal=%d, wreal=%d, hreal=%d",
k, el->getId().c_str(), typeName.c_str(), el->getX(), el->getY(), el->getParent() ? el->getParent()->getId().c_str() : "no parent", k, el->getId().c_str(), typeName.c_str(), el->getX(), el->getY(), el->getParent() ? el->getParent()->getId().c_str() : "no parent",
el->getParentPos() ? el->getParentPos()->getId().c_str() : "parent", el->getParentPos() ? el->getParentPos()->getId().c_str() : "parent",
@ -2595,7 +2619,7 @@ namespace NLGUI
e->setSizeRef(""); e->setSizeRef("");
e->setParent(p); e->setParent(p);
e->setParentPos(p); e->setParentPos(p);
e->setParentSize(p); e->setParentSize(p);
e->alignTo(p); e->alignTo(p);