Browse Source

Pass ConfigSettings instead

Daniele Bartolini 10 năm trước cách đây
mục cha
commit
ef1214156a
3 tập tin đã thay đổi với 11 bổ sung8 xóa
  1. 1 1
      engine/crown.cpp
  2. 6 5
      engine/device.cpp
  3. 4 2
      engine/device.h

+ 1 - 1
engine/crown.cpp

@@ -188,7 +188,7 @@ bool init(Filesystem& fs, const ConfigSettings& cs)
 	physics_globals::init();
 	bgfx::init();
 	lua_globals::init();
-	device_globals::init(fs, cs.boot_package, cs.boot_script);
+	device_globals::init(cs, fs);
 	device()->init();
 	return true;
 }

+ 6 - 5
engine/device.cpp

@@ -21,7 +21,7 @@
 
 namespace crown
 {
-Device::Device(Filesystem& fs, StringId64 boot_package, StringId64 boot_script)
+Device::Device(const ConfigSettings& cs, Filesystem& fs)
 	: _allocator(default_allocator(), MAX_SUBSYSTEMS_HEAP)
 	, _width(0)
 	, _height(0)
@@ -33,9 +33,10 @@ Device::Device(Filesystem& fs, StringId64 boot_package, StringId64 boot_script)
 	, _current_time(0)
 	, _last_delta_time(0.0f)
 	, _time_since_start(0.0)
+	, _cs(cs)
 	, _fs(fs)
-	, _boot_package_id(boot_package)
-	, _boot_script_id(boot_script)
+	, _boot_package_id(cs.boot_package)
+	, _boot_script_id(cs.boot_script)
 	, _boot_package(NULL)
 	, _lua_environment(NULL)
 	, _resource_manager(NULL)
@@ -215,10 +216,10 @@ namespace device_globals
 	char _buffer[sizeof(Device)];
 	Device* _device = NULL;
 
-	void init(Filesystem& fs, StringId64 boot_package, StringId64 boot_script)
+	void init(const ConfigSettings& cs, Filesystem& fs)
 	{
 		CE_ASSERT(_device == NULL, "Crown already initialized");
-		_device = new (_buffer) Device(fs, boot_package, boot_script);
+		_device = new (_buffer) Device(cs, fs);
 	}
 
 	void shutdown()

+ 4 - 2
engine/device.h

@@ -13,6 +13,7 @@
 #include "lua_types.h"
 #include "filesystem_types.h"
 #include "array.h"
+#include "crown.h"
 
 namespace crown
 {
@@ -25,7 +26,7 @@ namespace crown
 /// @ingroup Device
 struct Device
 {
-	Device(Filesystem& fs, StringId64 boot_package, StringId64 boot_script);
+	Device(const ConfigSettings& cs, Filesystem& fs);
 
 	void init();
 
@@ -122,6 +123,7 @@ private:
 	float _last_delta_time;
 	double _time_since_start;
 
+	const ConfigSettings& _cs;
 	Filesystem& _fs;
 	StringId64 _boot_package_id;
 	StringId64 _boot_script_id;
@@ -141,7 +143,7 @@ private:
 
 namespace device_globals
 {
-	void init(Filesystem& fs, StringId64 boot_package, StringId64 boot_script);
+	void init(const ConfigSettings& cs, Filesystem& fs);
 	void shutdown();
 } // namespace device_globals