|
|
@@ -50,6 +50,7 @@ OTHER DEALINGS IN THE SOFTWARE.
|
|
|
#include "DiskFile.h"
|
|
|
#include "Memory.h"
|
|
|
#include "Game.h"
|
|
|
+#include "LuaEnvironment.h"
|
|
|
|
|
|
namespace crown
|
|
|
{
|
|
|
@@ -76,13 +77,12 @@ Device::Device() :
|
|
|
|
|
|
m_filesystem(NULL),
|
|
|
m_input_manager(NULL),
|
|
|
+ m_lua_environment(NULL),
|
|
|
m_renderer(NULL),
|
|
|
m_debug_renderer(NULL),
|
|
|
|
|
|
m_resource_manager(NULL),
|
|
|
- m_resource_bundle(NULL),
|
|
|
-
|
|
|
- m_game_library(NULL)
|
|
|
+ m_resource_bundle(NULL)
|
|
|
{
|
|
|
// Select executable dir by default
|
|
|
string::strncpy(m_preferred_root_path, os::get_cwd(), MAX_PATH_LENGTH);
|
|
|
@@ -120,6 +120,8 @@ bool Device::init(int argc, char** argv)
|
|
|
|
|
|
create_debug_renderer();
|
|
|
|
|
|
+ create_lua_environment();
|
|
|
+
|
|
|
read_engine_settings();
|
|
|
|
|
|
Log::i("Crown Engine initialized.");
|
|
|
@@ -152,7 +154,14 @@ void Device::shutdown()
|
|
|
|
|
|
// Shutdowns the game
|
|
|
crown::shutdown();
|
|
|
-
|
|
|
+
|
|
|
+ Log::i("Releasing LuaEnvironment...");
|
|
|
+ if (m_lua_environment)
|
|
|
+ {
|
|
|
+ CE_DELETE(m_allocator, m_lua_environment);
|
|
|
+ }
|
|
|
+
|
|
|
+ Log::i("Releasing InputManager...");
|
|
|
if (m_input_manager)
|
|
|
{
|
|
|
CE_DELETE(m_allocator, m_input_manager);
|
|
|
@@ -224,6 +233,12 @@ InputManager* Device::input_manager()
|
|
|
return m_input_manager;
|
|
|
}
|
|
|
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
+LuaEnvironment* Device::lua_environment()
|
|
|
+{
|
|
|
+ return m_lua_environment;
|
|
|
+}
|
|
|
+
|
|
|
//-----------------------------------------------------------------------------
|
|
|
OsWindow* Device::window()
|
|
|
{
|
|
|
@@ -313,6 +328,7 @@ float Device::last_delta_time() const
|
|
|
//-----------------------------------------------------------------------------
|
|
|
void Device::frame()
|
|
|
{
|
|
|
+ Log::i("this is a test");
|
|
|
m_current_time = os::microseconds();
|
|
|
m_last_delta_time = (m_current_time - m_last_time) / 1000000.0f;
|
|
|
m_last_time = m_current_time;
|
|
|
@@ -430,6 +446,18 @@ void Device::create_debug_renderer()
|
|
|
Log::d("Debug renderer created.");
|
|
|
}
|
|
|
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
+void Device::create_lua_environment()
|
|
|
+{
|
|
|
+ lua_State* L = luaL_newstate();
|
|
|
+
|
|
|
+ m_lua_environment = CE_NEW(m_allocator, LuaEnvironment)(L);
|
|
|
+
|
|
|
+ m_lua_environment->init();
|
|
|
+
|
|
|
+ Log::d("Lua environment created.");
|
|
|
+}
|
|
|
+
|
|
|
//-----------------------------------------------------------------------------
|
|
|
void Device::parse_command_line(int argc, char** argv)
|
|
|
{
|