48 lines
1.2 KiB
C++
48 lines
1.2 KiB
C++
#pragma once
|
|
#include "Sqr_CommonFunc.hpp"
|
|
#include "EngineFrame/Render/RenderManager.h"
|
|
#include "json.hpp"
|
|
|
|
static SQInteger SQR_OutPutTable(HSQUIRRELVM v)
|
|
{
|
|
const SQChar *Str;
|
|
sq_getstring(v, 2, &Str);
|
|
|
|
nlohmann::json ex1 = nlohmann::json::parse(Str);
|
|
std::string formattedJson = ex1.dump(4);
|
|
SDL_Log(formattedJson.c_str());
|
|
return 0;
|
|
}
|
|
|
|
static SQInteger SQR_GetDebugInfo(HSQUIRRELVM v)
|
|
{
|
|
|
|
sq_newtable(v);
|
|
struct TableEntry
|
|
{
|
|
const SQChar *key;
|
|
SQInteger value;
|
|
} entries[] = {
|
|
{_SC("fps"), Game::GetInstance().m_fps},
|
|
{_SC("frametime"), Game::GetInstance().m_frameTime_ms},
|
|
{_SC("rendercount"), Game::GetInstance().GetRenderer()->_frameRenderCount},
|
|
{_SC("nodecount"), Game::GetInstance().m_nodeCount}};
|
|
|
|
for (const auto &entry : entries)
|
|
{
|
|
sq_pushstring(v, entry.key, -1);
|
|
sq_pushinteger(v, entry.value);
|
|
sq_newslot(v, -3, SQFalse);
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
static void RegisterSystem()
|
|
{
|
|
HSQUIRRELVM v = SquirrelEx::GetInstance().GetSquirrelVM();
|
|
|
|
// 打印表
|
|
RegisterNutApi(_SC("sq_OutPutTable"), SQR_OutPutTable, v);
|
|
// 获取调试信息表
|
|
RegisterNutApi(_SC("sq_GetDebugInfo"), SQR_GetDebugInfo, v);
|
|
} |