/****************************************************************************** * 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 #include 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); } }