Fixes build on linux

Fixes bug that prevented panels from being opened from the menu
master
Joey Pollack 4 years ago
parent 595adb717c
commit d55d28fe1b

@ -62,7 +62,7 @@ namespace lunarium
void PanelManager::OpenPanel(uint32_t id) void PanelManager::OpenPanel(uint32_t id)
{ {
if (mPanels.size() >= id || id < 0) if (id >= mPanels.size() || id < 0)
return; return;
mPanels[id]->SetOpen(true); mPanels[id]->SetOpen(true);

@ -64,6 +64,7 @@ namespace lunarium
std::cout << "\033[0m"; std::cout << "\033[0m";
} }
#if defined(LPLATFORM_WINDOWS)
OpRes Terminal::InitWindowsTerm() OpRes Terminal::InitWindowsTerm()
{ {
// This code is from microsoft docs: // This code is from microsoft docs:
@ -131,4 +132,5 @@ namespace lunarium
SetConsoleMode(hOut, WinPrevOutMode); SetConsoleMode(hOut, WinPrevOutMode);
SetConsoleMode(hIn, WinPrevInMode); SetConsoleMode(hIn, WinPrevInMode);
} }
#endif // defined(LPLATFORM_WINDOWS)
} }

@ -188,7 +188,8 @@ namespace lunarium { namespace editor
return OpRes::Fail("Could not save asset meta data for file: %s", pAsset->GetFileLocation().string().c_str()); return OpRes::Fail("Could not save asset meta data for file: %s", pAsset->GetFileLocation().string().c_str());
} }
c.push_back(asset); //c.push_back(asset);
c.emplace_back(asset);
} }
std::ofstream ofs = std::ofstream(mContentFile.string().c_str(), std::ios_base::trunc); std::ofstream ofs = std::ofstream(mContentFile.string().c_str(), std::ios_base::trunc);

@ -13,7 +13,7 @@
#include "content_manager.h" #include "content_manager.h"
#include <filesystem> #include <filesystem>
#include <string> #include <string>
#include <utils\op_res.h> #include <utils/op_res.h>
namespace lunarium { namespace editor namespace lunarium { namespace editor
{ {

@ -38,8 +38,8 @@ namespace lunarium
mCat = sman.mCat; mCat = sman.mCat;
// Register methods // Register methods
sman.mState["SetWindowSize"] = &CoreAPI::SetWindowSize; // sman.mState["SetWindowSize"] = &CoreAPI::SetWindowSize;
sman.mState["Log"] = &CoreAPI::Log; // sman.mState["Log"] = &CoreAPI::Log;
// return OpRes::Fail("CoreAPI::Initialize not implemented yet!"); // return OpRes::Fail("CoreAPI::Initialize not implemented yet!");
return OpRes::OK(); return OpRes::OK();

@ -33,10 +33,8 @@ namespace lunarium
OpRes ScriptManager::Initialize() OpRes ScriptManager::Initialize()
{ {
mCat = Logger::RegisterCategory("LUA"); mCat = Logger::RegisterCategory("SCRIPT");
mState.open_libraries(sol::lib::base, sol::lib::package);
// mState.script("print('test puppy says: bark bark bark!')");
return OpRes::OK(); return OpRes::OK();
} }
@ -49,18 +47,7 @@ namespace lunarium
} }
// TODO: Use the state to run the script and check for errors // TODO: Use the state to run the script and check for errors
auto result = mpInstance->mState.script(code, [](lua_State*, sol::protected_function_result pfr) {
return pfr;
});
if (!result.valid())
{
sol::error err = result;
Logger::Warn(mpInstance->mCat, "LUA script has errors");
std::ostringstream oss;
oss << "LUA code has error. CODE:\n" << code << "\nEND CODE -- ERROR: " << err.what();
return OpRes::Fail(oss.str().c_str());
}
return OpRes::OK(); return OpRes::OK();
} }

@ -3,7 +3,7 @@
* Author - Joey Pollack * Author - Joey Pollack
* Date - 2021/08/30 (y/m/d) * Date - 2021/08/30 (y/m/d)
* Mod Date - 2021/09/02 (y/m/d) * Mod Date - 2021/09/02 (y/m/d)
* Description - Manage the main LUA state, Run given scripts and check for * Description - Manage the main wren state, Run given scripts and check for
* errors. Report errors in the debug log. Also keep a * errors. Report errors in the debug log. Also keep a
* history of errors that can be queried. * history of errors that can be queried.
******************************************************************************/ ******************************************************************************/
@ -11,7 +11,6 @@
#ifndef SCRIPT_MANAGER_H_ #ifndef SCRIPT_MANAGER_H_
#define SCRIPT_MANAGER_H_ #define SCRIPT_MANAGER_H_
#include <sol/sol.hpp>
#include <utils/op_res.h> #include <utils/op_res.h>
namespace lunarium namespace lunarium
@ -27,7 +26,6 @@ namespace lunarium
private: private:
static ScriptManager* mpInstance; static ScriptManager* mpInstance;
sol::state mState;
uint32_t mCat; uint32_t mCat;
friend class CoreAPI; friend class CoreAPI;

Loading…
Cancel
Save