move code into a module structure
This commit is contained in:
parent
6461a56e17
commit
32aac45162
10 changed files with 64 additions and 30 deletions
51
src/core/include/pw/core/script.hpp
Normal file
51
src/core/include/pw/core/script.hpp
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
#ifndef PW_SCRIPT_HPP
|
||||||
|
#define PW_SCRIPT_HPP
|
||||||
|
|
||||||
|
#include <lua.hpp>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
|
||||||
|
#include <pw/core/scripting.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
namespace pw {
|
||||||
|
|
||||||
|
|
||||||
|
class script;
|
||||||
|
|
||||||
|
class main_loop {
|
||||||
|
|
||||||
|
script &_s;
|
||||||
|
bool _stop = false;
|
||||||
|
|
||||||
|
main_loop(script& s);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class script {
|
||||||
|
protected:
|
||||||
|
|
||||||
|
scripting::state _lua;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
script();
|
||||||
|
~script();
|
||||||
|
|
||||||
|
bool update();
|
||||||
|
|
||||||
|
bool load(const std::string &s);
|
||||||
|
|
||||||
|
int run(const std::string& s);
|
||||||
|
|
||||||
|
void load(sol::table &ns);
|
||||||
|
|
||||||
|
friend class main_loop;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
13
src/core/include/pw/core/scripting.hpp
Normal file
13
src/core/include/pw/core/scripting.hpp
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#ifndef PW_SCRIPTING_HPP
|
||||||
|
#define PW_SCRIPTING_HPP
|
||||||
|
|
||||||
|
#include "sol.hpp"
|
||||||
|
|
||||||
|
namespace pw {
|
||||||
|
|
||||||
|
// include external namespace of sol
|
||||||
|
namespace scripting = sol;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -27,7 +27,6 @@ public:
|
||||||
window();
|
window();
|
||||||
~window();
|
~window();
|
||||||
|
|
||||||
|
|
||||||
bool update();
|
bool update();
|
||||||
|
|
||||||
void set_title(const char* t);
|
void set_title(const char* t);
|
|
@ -1,29 +0,0 @@
|
||||||
#ifndef PW_SCRIPT_HPP
|
|
||||||
#define PW_SCRIPT_HPP
|
|
||||||
|
|
||||||
#include <lua.hpp>
|
|
||||||
#include <memory>
|
|
||||||
#include <sol.hpp>
|
|
||||||
|
|
||||||
namespace pw {
|
|
||||||
|
|
||||||
class script {
|
|
||||||
|
|
||||||
sol::state _lua;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
script();
|
|
||||||
~script();
|
|
||||||
|
|
||||||
bool update();
|
|
||||||
|
|
||||||
void run(const char* s);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
Loading…
Add table
Add a link
Reference in a new issue