Просмотр исходного кода

Re-enable Device's filesystem, now is possible to load games from arbitrary directories specified through CL option

Daniele Bartolini 12 лет назад
Родитель
Сommit
02e5d0e969
3 измененных файлов с 23 добавлено и 3 удалено
  1. 18 3
      src/Device.cpp
  2. 3 0
      src/Device.h
  3. 2 0
      src/Filesystem.h

+ 18 - 3
src/Device.cpp

@@ -51,6 +51,7 @@ Device::Device() :
 	m_is_init(false),
 	m_is_running(false),
 
+	m_filesystem(NULL),
 	m_input_manager(NULL),
 	m_renderer(NULL)
 {
@@ -81,7 +82,7 @@ bool Device::init(int argc, char** argv)
 	Log::I("Initializing Crown Engine %d.%d.%d...", CROWN_VERSION_MAJOR, CROWN_VERSION_MINOR, CROWN_VERSION_MICRO);
 
 	// Set the root path
-	// GetFilesystem()->Init(m_preferred_root_path.c_str(), m_preferred_user_path.c_str());
+	m_filesystem = new Filesystem(m_preferred_root_path);
 
 	m_input_manager = new InputManager();
 
@@ -101,8 +102,9 @@ bool Device::init(int argc, char** argv)
 	Log::I("Crown Engine initialized.");
 
 	Log::I("Initializing Game...");
-	// FIXME Should we maintain a fixed name library?
-	m_game_library = os::open_library("libgame.so");
+
+	const char* game_library_path = m_filesystem->build_os_path(m_filesystem->root_path(), "libgame.so");
+	m_game_library = os::open_library(game_library_path);
 
 	if (m_game_library == NULL)
 	{
@@ -147,6 +149,13 @@ void Device::shutdown()
 		delete m_renderer;
 	}
 
+	Log::I("Releasing Filesystem...");
+
+	if (m_filesystem)
+	{
+		delete m_filesystem;
+	}
+
 	m_is_init = false;
 }
 
@@ -156,6 +165,12 @@ bool Device::is_init() const
 	return m_is_init;
 }
 
+//-----------------------------------------------------------------------------
+Filesystem* Device::filesystem()
+{
+	return m_filesystem;
+}
+
 //-----------------------------------------------------------------------------
 InputManager* Device::input_manager()
 {

+ 3 - 0
src/Device.h

@@ -31,6 +31,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 {
 
+class Filesystem;
 class Renderer;
 class InputManager;
 class Game;
@@ -54,6 +55,7 @@ public:
 
 	void					frame();
 
+	Filesystem*				filesystem();
 	InputManager*			input_manager();
 	Renderer*				renderer();
 
@@ -76,6 +78,7 @@ private:
 	bool					m_is_running	: 1;
 
 	// Subsystems
+	Filesystem*				m_filesystem;
 	InputManager*			m_input_manager;
 	Renderer*				m_renderer;
 

+ 2 - 0
src/Filesystem.h

@@ -141,6 +141,8 @@ private:
 						// Disable copying
 						Filesystem(const Filesystem&);
 	Filesystem&			operator=(const Filesystem&);
+
+	friend class		Device;
 };
 
 } // namespace crown