Some more debug functions moved, see #43

This commit is contained in:
kaetemi 2013-06-27 03:04:40 +02:00
parent d919591093
commit 1e461ec4f3
2 changed files with 221 additions and 203 deletions

View file

@ -2536,6 +2536,9 @@ bool mainLoop()
frameToSkip--;
}
///////////////
// FAR_TP -> //
///////////////
// Enter a network loop during the FarTP process, without doing the whole real main loop.
// This code must remain at the very end of the main loop.
if(LoginSM.getCurrentState() == CLoginStateMachine::st_enter_far_tp_main_loop)
@ -2619,7 +2622,10 @@ bool mainLoop()
connectionState = NetMngr.getConnectionState();
CLuaManager::getInstance().executeLuaScript("game:onFarTpEnd()");
}
}
///////////////
// <- FAR_TP //
///////////////
} // end of main loop
@ -2687,208 +2693,6 @@ bool mainLoop()
return ryzom_exit || (Driver == NULL) || (!Driver->isActive ());
}// mainLoop //
//---------------------------------------------------
// displayDebug :
// Display some debug infos.
//---------------------------------------------------
void displayDebugFps()
{
float lineStep = ClientCfg.DebugLineStep;
float line;
// Initialize Pen //
//----------------//
// Create a shadow when displaying a text.
TextContext->setShaded(true);
// Set the font size.
TextContext->setFontSize(ClientCfg.DebugFontSize);
// Set the text color
TextContext->setColor(ClientCfg.DebugFontColor);
// TOP LEFT //
//----------//
TextContext->setHotSpot(UTextContext::TopLeft);
line = 0.9f;
// Ms per frame
{
float spf = smoothFPS.getSmoothValue ();
// Ms per frame
TextContext->printfAt(0.1f, line, "FPS %.1f ms - %.1f fps", spf*1000, 1.f/spf);
line-= lineStep;
// More Smoothed Ms per frame
spf = moreSmoothFPS.getSmoothValue ();
TextContext->printfAt(0.1f, line, "Smoothed FPS %.1f ms - %.1f fps", spf*1000, 1.f/spf);
line-= lineStep;
}
}
static NLMISC::CRefPtr<CInterfaceElement> HighlightedDebugUI;
// displayDebug :
// Display information about ui elements that are under the mouse
//---------------------------------------------------
void displayDebugUIUnderMouse()
{
float lineStep = ClientCfg.DebugLineStep;
float line;
// Initialize Pen //
//----------------//
// Create a shadow when displaying a text.
TextContext->setShaded(true);
// Set the font size.
TextContext->setFontSize(ClientCfg.DebugFontSize);
// TOP LEFT //
//----------//
TextContext->setHotSpot(UTextContext::TopLeft);
line = 0.9f;
CInterfaceManager *pIM = CInterfaceManager::getInstance();
// for now only accessible with R2ED
if (ClientCfg.R2EDEnabled)
{
TextContext->setColor(CRGBA::Cyan);
TextContext->printfAt(0.1f, line, "Press default key (ctrl+shift+A) to cycle prev");
line-= lineStep;
TextContext->printfAt(0.1f, line, "Press default key (ctrl+shift+Q) to cycle next");
line-= lineStep;
TextContext->printfAt(0.1f, line, "Press default key (ctrl+shift+W) to inspect element");
line-= 2 * lineStep;
}
//
const vector<CCtrlBase *> &rICL = CWidgetManager::getInstance()->getCtrlsUnderPointer ();
const vector<CInterfaceGroup *> &rIGL = CWidgetManager::getInstance()->getGroupsUnderPointer ();
// If previous highlighted element is found in the list, then keep it, else reset to first element
if (std::find(rICL.begin(), rICL.end(), HighlightedDebugUI) == rICL.end() &&
std::find(rIGL.begin(), rIGL.end(), HighlightedDebugUI) == rIGL.end())
{
if (!rICL.empty())
{
HighlightedDebugUI = rICL[0];
}
else
if (!rIGL.empty())
{
HighlightedDebugUI = rIGL[0];
}
else
{
HighlightedDebugUI = NULL;
}
}
//
TextContext->setColor(CRGBA::Green);
TextContext->printfAt(0.1f, line, "Controls under cursor ");
line -= lineStep * 1.4f;
TextContext->printfAt(0.1f, line, "----------------------");
line -= lineStep;
for(uint k = 0; k < rICL.size(); ++k)
{
if (rICL[k])
{
TextContext->setColor(rICL[k] != HighlightedDebugUI ? ClientCfg.DebugFontColor : CRGBA::Red);
TextContext->printfAt(0.1f, line, "id = %s, address = 0x%p, parent = 0x%p", rICL[k]->getId().c_str(), rICL[k], rICL[k]->getParent());
}
else
{
TextContext->setColor(CRGBA::Blue);
TextContext->printfAt(0.1f, line, "<NULL> control found !!!");
}
line-= lineStep;
}
//
TextContext->setColor(CRGBA::Green);
TextContext->printfAt(0.1f, line, "Groups under cursor ");
line -= lineStep * 1.4f;
TextContext->printfAt(0.1f, line, "----------------------");
line-= lineStep;
for(uint k = 0; k < rIGL.size(); ++k)
{
if (rIGL[k])
{
TextContext->setColor(rIGL[k] != HighlightedDebugUI ? ClientCfg.DebugFontColor : CRGBA::Red);
TextContext->printfAt(0.1f, line, "id = %s, address = 0x%p, parent = 0x%p", rIGL[k]->getId().c_str(), rIGL[k], rIGL[k]->getParent());
}
else
{
TextContext->setColor(CRGBA::Blue);
TextContext->printfAt(0.1f, line, "<NULL> group found !!!");
}
line-= lineStep;
}
}
// get all element under the mouse in a single vector
static void getElementsUnderMouse(vector<CInterfaceElement *> &ielem)
{
CInterfaceManager *pIM = CInterfaceManager::getInstance();
const vector<CCtrlBase *> &rICL = CWidgetManager::getInstance()->getCtrlsUnderPointer();
const vector<CInterfaceGroup *> &rIGL = CWidgetManager::getInstance()->getGroupsUnderPointer();
ielem.clear();
ielem.insert(ielem.end(), rICL.begin(), rICL.end());
ielem.insert(ielem.end(), rIGL.begin(), rIGL.end());
}
class CHandlerDebugUiPrevElementUnderMouse : public IActionHandler
{
virtual void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */)
{
vector<CInterfaceElement *> ielem;
getElementsUnderMouse(ielem);
for(uint k = 0; k < ielem.size(); ++k)
{
if (HighlightedDebugUI == ielem[k])
{
HighlightedDebugUI = ielem[k == 0 ? ielem.size() - 1 : k - 1];
return;
}
}
}
};
REGISTER_ACTION_HANDLER( CHandlerDebugUiPrevElementUnderMouse, "debug_ui_prev_element_under_mouse");
class CHandlerDebugUiNextElementUnderMouse : public IActionHandler
{
virtual void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */)
{
vector<CInterfaceElement *> ielem;
getElementsUnderMouse(ielem);
for(uint k = 0; k < ielem.size(); ++k)
{
if (HighlightedDebugUI == ielem[k])
{
HighlightedDebugUI = ielem[(k + 1) % ielem.size()];
return;
}
}
}
};
REGISTER_ACTION_HANDLER( CHandlerDebugUiNextElementUnderMouse, "debug_ui_next_element_under_mouse");
class CHandlerDebugUiDumpElementUnderMouse : public IActionHandler
{
virtual void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */)
{
if (HighlightedDebugUI == NULL) return;
CLuaState *lua = CLuaManager::getInstance().getLuaState();
if (!lua) return;
CLuaStackRestorer lsr(lua, 0);
CLuaIHM::pushUIOnStack(*lua, HighlightedDebugUI);
lua->pushGlobalTable();
CLuaObject env(*lua);
env["inspect"].callNoThrow(1, 0);
}
};
REGISTER_ACTION_HANDLER( CHandlerDebugUiDumpElementUnderMouse, "debug_ui_inspect_element_under_mouse");
//---------------------------------------------------
// Just Display some text with ... anim at some place.
//---------------------------------------------------

View file

@ -18,6 +18,7 @@
#include "main_loop_debug.h"
#include <nel/3d/u_text_context.h>
#include <nel/gui/lua_ihm.h>
#include "game_share/ryzom_version.h"
@ -40,9 +41,12 @@
#include "client_sheets/weather_function_params_sheet.h"
#include "weather_manager_client.h"
#include "fog_map.h"
#include "misc.h"
#include "interface_v3/interface_manager.h"
using namespace NLMISC;
using namespace NL3D;
using namespace NLGUI;
// ********************************************************************
// ********************************************************************
@ -54,6 +58,7 @@ extern std::set<std::string> LodCharactersNotFound;
extern uint32 NbDatabaseChanges;
extern CFogState MainFogState;
extern CPing Ping;
extern bool Filter3D[RYZOM_MAX_FILTER_3D];
//namespace /* anonymous */ {
@ -473,6 +478,215 @@ void displayDebug()
// ********************************************************************
// ********************************************************************
//---------------------------------------------------
// displayDebug :
// Display some debug infos.
//---------------------------------------------------
void displayDebugFps()
{
float lineStep = ClientCfg.DebugLineStep;
float line;
// Initialize Pen //
//----------------//
// Create a shadow when displaying a text.
TextContext->setShaded(true);
// Set the font size.
TextContext->setFontSize(ClientCfg.DebugFontSize);
// Set the text color
TextContext->setColor(ClientCfg.DebugFontColor);
// TOP LEFT //
//----------//
TextContext->setHotSpot(UTextContext::TopLeft);
line = 0.9f;
// Ms per frame
{
float spf = smoothFPS.getSmoothValue ();
// Ms per frame
TextContext->printfAt(0.1f, line, "FPS %.1f ms - %.1f fps", spf*1000, 1.f/spf);
line-= lineStep;
// More Smoothed Ms per frame
spf = moreSmoothFPS.getSmoothValue ();
TextContext->printfAt(0.1f, line, "Smoothed FPS %.1f ms - %.1f fps", spf*1000, 1.f/spf);
line-= lineStep;
}
}
// ********************************************************************
// ********************************************************************
// ********************************************************************
// ********************************************************************
// ********************************************************************
static NLMISC::CRefPtr<CInterfaceElement> HighlightedDebugUI;
// displayDebug :
// Display information about ui elements that are under the mouse
//---------------------------------------------------
void displayDebugUIUnderMouse()
{
float lineStep = ClientCfg.DebugLineStep;
float line;
// Initialize Pen //
//----------------//
// Create a shadow when displaying a text.
TextContext->setShaded(true);
// Set the font size.
TextContext->setFontSize(ClientCfg.DebugFontSize);
// TOP LEFT //
//----------//
TextContext->setHotSpot(UTextContext::TopLeft);
line = 0.9f;
CInterfaceManager *pIM = CInterfaceManager::getInstance();
// for now only accessible with R2ED
if (ClientCfg.R2EDEnabled)
{
TextContext->setColor(CRGBA::Cyan);
TextContext->printfAt(0.1f, line, "Press default key (ctrl+shift+A) to cycle prev");
line-= lineStep;
TextContext->printfAt(0.1f, line, "Press default key (ctrl+shift+Q) to cycle next");
line-= lineStep;
TextContext->printfAt(0.1f, line, "Press default key (ctrl+shift+W) to inspect element");
line-= 2 * lineStep;
}
//
const std::vector<CCtrlBase *> &rICL = CWidgetManager::getInstance()->getCtrlsUnderPointer ();
const std::vector<CInterfaceGroup *> &rIGL = CWidgetManager::getInstance()->getGroupsUnderPointer ();
// If previous highlighted element is found in the list, then keep it, else reset to first element
if (std::find(rICL.begin(), rICL.end(), HighlightedDebugUI) == rICL.end() &&
std::find(rIGL.begin(), rIGL.end(), HighlightedDebugUI) == rIGL.end())
{
if (!rICL.empty())
{
HighlightedDebugUI = rICL[0];
}
else
if (!rIGL.empty())
{
HighlightedDebugUI = rIGL[0];
}
else
{
HighlightedDebugUI = NULL;
}
}
//
TextContext->setColor(CRGBA::Green);
TextContext->printfAt(0.1f, line, "Controls under cursor ");
line -= lineStep * 1.4f;
TextContext->printfAt(0.1f, line, "----------------------");
line -= lineStep;
for(uint k = 0; k < rICL.size(); ++k)
{
if (rICL[k])
{
TextContext->setColor(rICL[k] != HighlightedDebugUI ? ClientCfg.DebugFontColor : CRGBA::Red);
TextContext->printfAt(0.1f, line, "id = %s, address = 0x%p, parent = 0x%p", rICL[k]->getId().c_str(), rICL[k], rICL[k]->getParent());
}
else
{
TextContext->setColor(CRGBA::Blue);
TextContext->printfAt(0.1f, line, "<NULL> control found !!!");
}
line-= lineStep;
}
//
TextContext->setColor(CRGBA::Green);
TextContext->printfAt(0.1f, line, "Groups under cursor ");
line -= lineStep * 1.4f;
TextContext->printfAt(0.1f, line, "----------------------");
line-= lineStep;
for(uint k = 0; k < rIGL.size(); ++k)
{
if (rIGL[k])
{
TextContext->setColor(rIGL[k] != HighlightedDebugUI ? ClientCfg.DebugFontColor : CRGBA::Red);
TextContext->printfAt(0.1f, line, "id = %s, address = 0x%p, parent = 0x%p", rIGL[k]->getId().c_str(), rIGL[k], rIGL[k]->getParent());
}
else
{
TextContext->setColor(CRGBA::Blue);
TextContext->printfAt(0.1f, line, "<NULL> group found !!!");
}
line-= lineStep;
}
}
// get all element under the mouse in a single vector
static void getElementsUnderMouse(std::vector<CInterfaceElement *> &ielem)
{
CInterfaceManager *pIM = CInterfaceManager::getInstance();
const std::vector<CCtrlBase *> &rICL = CWidgetManager::getInstance()->getCtrlsUnderPointer();
const std::vector<CInterfaceGroup *> &rIGL = CWidgetManager::getInstance()->getGroupsUnderPointer();
ielem.clear();
ielem.insert(ielem.end(), rICL.begin(), rICL.end());
ielem.insert(ielem.end(), rIGL.begin(), rIGL.end());
}
class CHandlerDebugUiPrevElementUnderMouse : public IActionHandler
{
virtual void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */)
{
std::vector<CInterfaceElement *> ielem;
getElementsUnderMouse(ielem);
for(uint k = 0; k < ielem.size(); ++k)
{
if (HighlightedDebugUI == ielem[k])
{
HighlightedDebugUI = ielem[k == 0 ? ielem.size() - 1 : k - 1];
return;
}
}
}
};
REGISTER_ACTION_HANDLER( CHandlerDebugUiPrevElementUnderMouse, "debug_ui_prev_element_under_mouse");
class CHandlerDebugUiNextElementUnderMouse : public IActionHandler
{
virtual void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */)
{
std::vector<CInterfaceElement *> ielem;
getElementsUnderMouse(ielem);
for(uint k = 0; k < ielem.size(); ++k)
{
if (HighlightedDebugUI == ielem[k])
{
HighlightedDebugUI = ielem[(k + 1) % ielem.size()];
return;
}
}
}
};
REGISTER_ACTION_HANDLER( CHandlerDebugUiNextElementUnderMouse, "debug_ui_next_element_under_mouse");
class CHandlerDebugUiDumpElementUnderMouse : public IActionHandler
{
virtual void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */)
{
if (HighlightedDebugUI == NULL) return;
CLuaState *lua = CLuaManager::getInstance().getLuaState();
if (!lua) return;
CLuaStackRestorer lsr(lua, 0);
CLuaIHM::pushUIOnStack(*lua, HighlightedDebugUI);
lua->pushGlobalTable();
CLuaObject env(*lua);
env["inspect"].callNoThrow(1, 0);
}
};
REGISTER_ACTION_HANDLER( CHandlerDebugUiDumpElementUnderMouse, "debug_ui_inspect_element_under_mouse");
// ********************************************************************
// ********************************************************************
// ********************************************************************
// ********************************************************************
// ********************************************************************
//-----------------------------------------------
// Macro to Display a Text
//-----------------------------------------------