LUA code can be executed through the LUA console GUI window.
API methods added: SetWindowSize, Log.Gui_Panel_Refactor
parent
1ee5fe5b1f
commit
f5aea4216f
@ -0,0 +1,61 @@
|
||||
/******************************************************************************
|
||||
* File - coreAPI.cpp
|
||||
* Author - Joey Pollack
|
||||
* Date - 2021/09/23 (y/m/d)
|
||||
* Mod Date - 2021/09/23 (y/m/d)
|
||||
* Description - class with all static methods that expose core functionality to LUA
|
||||
* Need an init function that takes a reference to a LUA state so that it
|
||||
* can expose the static functions to LUA.
|
||||
******************************************************************************/
|
||||
|
||||
#include "coreAPI.h"
|
||||
#include "scriptManager.h"
|
||||
#include <core/core.h>
|
||||
#include <utils/logger.h>
|
||||
|
||||
namespace lunarium
|
||||
{
|
||||
|
||||
CoreAPI* CoreAPI::mpInstance = nullptr;
|
||||
CoreAPI& CoreAPI::GetInstance()
|
||||
{
|
||||
if (mpInstance == nullptr)
|
||||
{
|
||||
mpInstance = new CoreAPI;
|
||||
}
|
||||
|
||||
return *mpInstance;
|
||||
}
|
||||
|
||||
void CoreAPI::FreeInstance()
|
||||
{
|
||||
delete mpInstance;
|
||||
mpInstance = nullptr;
|
||||
}
|
||||
|
||||
OpRes CoreAPI::Initialize(ScriptManager& sman)
|
||||
{
|
||||
mCat = sman.mCat;
|
||||
|
||||
// Register methods
|
||||
sman.mState["SetWindowSize"] = &CoreAPI::SetWindowSize;
|
||||
sman.mState["Log"] = &CoreAPI::Log;
|
||||
|
||||
// return OpRes::Fail("CoreAPI::Initialize not implemented yet!");
|
||||
return OpRes::OK();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// API
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
void CoreAPI::SetWindowSize(int w, int h)
|
||||
{
|
||||
Core::MainWindow().Resize(w, h);
|
||||
}
|
||||
|
||||
void CoreAPI::Log(int level, const char* msg)
|
||||
{
|
||||
Logger::Log(mpInstance->mCat, level, msg);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue