Explorar o código

Use new LuaEnvironment API to load and execute Lua resources

Daniele Bartolini %!s(int64=12) %!d(string=hai) anos
pai
achega
3b5a7d4378
Modificáronse 2 ficheiros con 26 adicións e 9 borrados
  1. 19 9
      engine/Device.cpp
  2. 7 0
      engine/Device.h

+ 19 - 9
engine/Device.cpp

@@ -81,6 +81,7 @@ Device::Device() :
 
 	m_is_init(false),
 	m_is_running(false),
+	m_is_paused(true),
 
 	m_frame_count(0),
 
@@ -203,11 +204,12 @@ bool Device::init(int argc, char** argv)
 	m_is_init = true;
 	start();
 
-	ResourceId luagame_id = m_resource_manager->load("lua", m_boot_file);
-	m_resource_manager->flush();
-	m_lua_environment->load((LuaResource*) m_resource_manager->data(luagame_id));
+	// Execute lua boot file
+	m_lua_environment->load_and_execute(m_boot_file);
 	m_lua_environment->call_global("init", 0);
-	m_resource_manager->unload(luagame_id);
+
+	// Show main window
+	m_window->show();
 
 	if (m_quit_after_init == 1)
 	{
@@ -215,9 +217,6 @@ bool Device::init(int argc, char** argv)
 		shutdown();
 	}
 
-	// Show main window
-	m_window->show();
-
 	return true;
 }
 
@@ -386,6 +385,18 @@ void Device::stop()
 	m_is_running = false;
 }
 
+//-----------------------------------------------------------------------------
+void Device::pause()
+{
+	m_is_paused = true;
+}
+
+//-----------------------------------------------------------------------------
+void Device::unpause()
+{
+	m_is_paused = false;
+}
+
 //-----------------------------------------------------------------------------
 bool Device::is_running() const
 {
@@ -415,10 +426,9 @@ void Device::frame()
 
 	m_window->frame();
 	m_input_manager->frame(frame_count());
+	
 	m_lua_environment->call_global("frame", 1, ARGUMENT_FLOAT, last_delta_time());
 
-	// m_console_server->execute();
-
 	m_debug_renderer->draw_all();
 	m_renderer->frame();
 

+ 7 - 0
engine/Device.h

@@ -92,6 +92,12 @@ public:
 	/// and normally terminates the program.
 	void					stop();
 
+	/// Pauses the engine
+	void					pause();
+
+	/// Unpauses the engine
+	void					unpause();
+
 	/// Updates all the subsystems
 	void					frame();
 
@@ -152,6 +158,7 @@ private:
 
 	bool					m_is_init		: 1;
 	bool					m_is_running	: 1;
+	bool					m_is_paused		: 1;
 
 	uint64_t				m_frame_count;