added basic engine info display to main component
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include "wiInputManager.h"
|
||||
#include "wiBackLog.h"
|
||||
#include "MainComponent_BindLua.h"
|
||||
#include "WickedEngine.h"
|
||||
|
||||
MainComponent::MainComponent()
|
||||
{
|
||||
@@ -19,6 +20,8 @@ MainComponent::MainComponent()
|
||||
setFrameSkip(true);
|
||||
setTargetFrameRate(60);
|
||||
setApplicationControlLostThreshold(10);
|
||||
|
||||
infoDisplay = InfoDisplayer();
|
||||
}
|
||||
|
||||
|
||||
@@ -102,6 +105,26 @@ void MainComponent::Compose()
|
||||
{
|
||||
getActiveComponent()->Compose();
|
||||
|
||||
|
||||
if (infoDisplay.active)
|
||||
{
|
||||
stringstream ss("");
|
||||
if (infoDisplay.watermark)
|
||||
{
|
||||
ss << string("Wicked Engine ") + string(WICKED_ENGINE_VERSION) << endl;
|
||||
}
|
||||
if (infoDisplay.fpsinfo)
|
||||
{
|
||||
ss.precision(2);
|
||||
ss << fixed << wiFrameRate::FPS() << " FPS" << endl;
|
||||
}
|
||||
if (infoDisplay.cpuinfo)
|
||||
{
|
||||
ss << "CPU: " << wiCpuInfo::GetCpuPercentage() << "%" << endl;
|
||||
}
|
||||
wiFont(ss.str(), wiFontProps(0, 0, infoDisplay.size, WIFALIGN_LEFT, WIFALIGN_TOP, infoDisplay.size)).Draw();
|
||||
}
|
||||
|
||||
wiBackLog::Draw();
|
||||
}
|
||||
|
||||
|
||||
@@ -49,5 +49,24 @@ public:
|
||||
bool setWindow(Windows::UI::Core::CoreWindow^ window);
|
||||
#endif
|
||||
|
||||
|
||||
struct InfoDisplayer
|
||||
{
|
||||
// activate the whole display
|
||||
bool active;
|
||||
// display engine version number
|
||||
bool watermark;
|
||||
// display framerate
|
||||
bool fpsinfo;
|
||||
// display cpu utilization
|
||||
bool cpuinfo;
|
||||
// text size
|
||||
float size;
|
||||
|
||||
InfoDisplayer() :active(false), watermark(true), fpsinfo(true), cpuinfo(true), size(-7.f)
|
||||
{}
|
||||
};
|
||||
// display all-time engine information text
|
||||
InfoDisplayer infoDisplay;
|
||||
};
|
||||
|
||||
|
||||
@@ -14,6 +14,10 @@ Luna<MainComponent_BindLua>::FunctionType MainComponent_BindLua::methods[] = {
|
||||
lunamethod(MainComponent_BindLua, GetActiveComponent),
|
||||
lunamethod(MainComponent_BindLua, SetActiveComponent),
|
||||
lunamethod(MainComponent_BindLua, SetFrameSkip),
|
||||
lunamethod(MainComponent_BindLua, SetInfoDisplay),
|
||||
lunamethod(MainComponent_BindLua, SetWatermarkDisplay),
|
||||
lunamethod(MainComponent_BindLua, SetFPSDisplay),
|
||||
lunamethod(MainComponent_BindLua, SetCPUDisplay),
|
||||
{ NULL, NULL }
|
||||
};
|
||||
Luna<MainComponent_BindLua>::PropertyType MainComponent_BindLua::properties[] = {
|
||||
@@ -179,6 +183,70 @@ int MainComponent_BindLua::SetFrameSkip(lua_State *L)
|
||||
wiLua::SError(L, "SetFrameSkip(bool enabled) not enought arguments!");
|
||||
return 0;
|
||||
}
|
||||
int MainComponent_BindLua::SetInfoDisplay(lua_State *L)
|
||||
{
|
||||
if (component == nullptr)
|
||||
{
|
||||
wiLua::SError(L, "SetInfoDisplay() component is empty!");
|
||||
return 0;
|
||||
}
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
if (argc > 0)
|
||||
{
|
||||
component->infoDisplay.active = wiLua::SGetBool(L, 1);
|
||||
}
|
||||
else
|
||||
wiLua::SError(L, "SetInfoDisplay(bool active) not enough arguments!");
|
||||
return 0;
|
||||
}
|
||||
int MainComponent_BindLua::SetWatermarkDisplay(lua_State *L)
|
||||
{
|
||||
if (component == nullptr)
|
||||
{
|
||||
wiLua::SError(L, "SetWatermarkDisplay() component is empty!");
|
||||
return 0;
|
||||
}
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
if (argc > 0)
|
||||
{
|
||||
component->infoDisplay.watermark = wiLua::SGetBool(L, 1);
|
||||
}
|
||||
else
|
||||
wiLua::SError(L, "SetWatermarkDisplay(bool active) not enough arguments!");
|
||||
return 0;
|
||||
}
|
||||
int MainComponent_BindLua::SetFPSDisplay(lua_State *L)
|
||||
{
|
||||
if (component == nullptr)
|
||||
{
|
||||
wiLua::SError(L, "SetFPSDisplay() component is empty!");
|
||||
return 0;
|
||||
}
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
if (argc > 0)
|
||||
{
|
||||
component->infoDisplay.fpsinfo = wiLua::SGetBool(L, 1);
|
||||
}
|
||||
else
|
||||
wiLua::SError(L, "SetFPSDisplay(bool active) not enough arguments!");
|
||||
return 0;
|
||||
}
|
||||
int MainComponent_BindLua::SetCPUDisplay(lua_State *L)
|
||||
{
|
||||
if (component == nullptr)
|
||||
{
|
||||
wiLua::SError(L, "SetCPUDisplay() component is empty!");
|
||||
return 0;
|
||||
}
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
if (argc > 0)
|
||||
{
|
||||
component->infoDisplay.cpuinfo = wiLua::SGetBool(L, 1);
|
||||
}
|
||||
else
|
||||
wiLua::SError(L, "SetCPUDisplay(bool active) not enough arguments!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void MainComponent_BindLua::Bind()
|
||||
{
|
||||
|
||||
@@ -20,6 +20,10 @@ public:
|
||||
int GetActiveComponent(lua_State *L);
|
||||
int SetActiveComponent(lua_State *L);
|
||||
int SetFrameSkip(lua_State *L);
|
||||
int SetInfoDisplay(lua_State *L);
|
||||
int SetWatermarkDisplay(lua_State *L);
|
||||
int SetFPSDisplay(lua_State *L);
|
||||
int SetCPUDisplay(lua_State *L);
|
||||
|
||||
static void Bind();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user