Przeglądaj źródła

Add window_title boot configuration

Daniele Bartolini 9 lat temu
rodzic
commit
d195584aa6
3 zmienionych plików z 12 dodań i 3 usunięć
  1. 6 1
      src/device/boot_config.cpp
  2. 4 2
      src/device/boot_config.h
  3. 2 0
      src/device/device.cpp

+ 6 - 1
src/device/boot_config.cpp

@@ -4,6 +4,7 @@
  */
 
 #include "boot_config.h"
+#include "dynamic_string.h"
 #include "json_object.h"
 #include "map.h"
 #include "platform.h"
@@ -12,9 +13,10 @@
 
 namespace crown
 {
-BootConfig::BootConfig()
+BootConfig::BootConfig(Allocator& a)
 	: boot_script_name(u64(0))
 	, boot_package_name(u64(0))
+	, window_title(a)
 	, window_w(CROWN_DEFAULT_WINDOW_WIDTH)
 	, window_h(CROWN_DEFAULT_WINDOW_HEIGHT)
 	, aspect_ratio(-1.0f)
@@ -32,6 +34,9 @@ bool BootConfig::parse(const char* json)
 	boot_script_name  = sjson::parse_resource_id(cfg["boot_script"]);
 	boot_package_name = sjson::parse_resource_id(cfg["boot_package"]);
 
+	if (json_object::has(cfg, "window_title"))
+		sjson::parse_string(cfg["window_title"], window_title);
+
 	// Platform-specific configs
 	if (json_object::has(cfg, CROWN_PLATFORM_NAME))
 	{

+ 4 - 2
src/device/boot_config.h

@@ -5,8 +5,9 @@
 
 #pragma once
 
-#include "types.h"
+#include "dynamic_string.h"
 #include "string_id.h"
+#include "types.h"
 
 namespace crown
 {
@@ -17,12 +18,13 @@ struct BootConfig
 {
 	StringId64 boot_script_name;
 	StringId64 boot_package_name;
+	DynamicString window_title;
 	u16 window_w;
 	u16 window_h;
 	float aspect_ratio;
 	bool vsync;
 
-	BootConfig();
+	BootConfig(Allocator& a);
 	bool parse(const char* json);
 };
 

+ 2 - 0
src/device/device.cpp

@@ -143,6 +143,7 @@ private:
 Device::Device(const DeviceOptions& opts)
 	: _allocator(default_allocator(), MAX_SUBSYSTEMS_HEAP)
 	, _device_options(opts)
+	, _boot_config(default_allocator())
 	, _console_server(NULL)
 	, _data_compiler(NULL)
 	, _bundle_filesystem(NULL)
@@ -440,6 +441,7 @@ void Device::run()
 			, _boot_config.window_h
 			, _device_options._parent_window
 			);
+		_window->set_title(_boot_config.window_title.c_str());
 		_window->bgfx_setup();
 
 		bgfx::init(bgfx::RendererType::Count