Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions core/config/project_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1578,6 +1578,8 @@ ProjectSettings::ProjectSettings() {
GLOBAL_DEF("application/config/auto_accept_quit", true);
GLOBAL_DEF("application/config/quit_on_go_back", true);

GLOBAL_DEF_BASIC("application/boot_splash/bg_color", Color(0.14, 0.14, 0.14));

GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "accessibility/general/accessibility_support", PROPERTY_HINT_ENUM, "Auto (When Screen Reader is Running),Always Active,Disabled"), 0);
GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "accessibility/general/updates_per_second", PROPERTY_HINT_RANGE, "1,100,1"), 60);

Expand Down
3 changes: 1 addition & 2 deletions doc/classes/ProjectSettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@
If [code]true[/code], [AnimationMixer] prints the warning of no matching object of the track path in the scene.
</member>
<member name="application/boot_splash/bg_color" type="Color" setter="" getter="" default="Color(0.14, 0.14, 0.14, 1)">
Background color for the boot splash.
</member>
<member name="application/boot_splash/fullsize" type="bool" setter="" getter="" default="true">
If [code]true[/code], scale the boot splash image to the full window size (preserving the aspect ratio) when the engine starts. If [code]false[/code], the engine will leave it at the default pixel size.
Expand Down Expand Up @@ -2800,7 +2799,7 @@
<member name="rendering/driver/threads/thread_model" type="int" setter="" getter="" default="1" experimental="This setting has several known bugs which can lead to crashing, especially when using particles or resizing the window. Not recommended for use in production at this stage.">
The thread model to use for rendering. Rendering on a thread may improve performance, but synchronizing to the main thread can cause a bit more jitter.
</member>
<member name="rendering/environment/defaults/default_clear_color" type="Color" setter="" getter="" default="Color(0.128, 0.128, 0.128, 1)">
<member name="rendering/environment/defaults/default_clear_color" type="Color" setter="" getter="" default="Color(0.14, 0.14, 0.14, 1)">
Default background clear color. Overridable per [Viewport] using its [Environment]. See [member Environment.background_mode] and [member Environment.background_color] in particular. To change this default color programmatically, use [method RenderingServer.set_default_clear_color].
</member>
<member name="rendering/environment/defaults/default_environment" type="String" setter="" getter="" default="&quot;&quot;">
Expand Down
53 changes: 52 additions & 1 deletion editor/settings/editor_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include "core/os/keyboard.h"
#include "core/os/os.h"
#include "core/string/translation_server.h"
#include "core/variant/variant_parser.h"
#include "core/version.h"
#include "editor/editor_node.h"
#include "editor/file_system/editor_paths.h"
Expand Down Expand Up @@ -582,7 +583,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
EDITOR_SETTING_BASIC(Variant::STRING, PROPERTY_HINT_ENUM, "interface/theme/preset", "Default", "Default,Breeze Dark,Godot,Godot 2,Gray,Light,Solarized (Dark),Solarized (Light),Black (OLED),Indigo,Custom")
EDITOR_SETTING_BASIC(Variant::STRING, PROPERTY_HINT_ENUM, "interface/theme/spacing_preset", "Default", "Compact,Default,Spacious,Custom")
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "interface/theme/icon_and_font_color", 0, "Auto,Dark,Light")
EDITOR_SETTING_BASIC(Variant::COLOR, PROPERTY_HINT_NONE, "interface/theme/base_color", Color(0.2, 0.23, 0.31), "")
EDITOR_SETTING_BASIC(Variant::COLOR, PROPERTY_HINT_NONE, "interface/theme/base_color", get_default_base_color(), "")
EDITOR_SETTING_BASIC(Variant::COLOR, PROPERTY_HINT_NONE, "interface/theme/accent_color", Color(0.41, 0.61, 0.91), "")
EDITOR_SETTING_BASIC(Variant::BOOL, PROPERTY_HINT_NONE, "interface/theme/use_system_accent_color", false, "")
EDITOR_SETTING_BASIC(Variant::FLOAT, PROPERTY_HINT_RANGE, "interface/theme/contrast", 0.3, "-1,1,0.01")
Expand Down Expand Up @@ -1239,6 +1240,56 @@ String EditorSettings::get_existing_settings_path() {
return config_dir.path_join(filename);
}

static Error _parse_direct_resource_dummy(void *p_data, VariantParser::Stream *p_stream, Ref<Resource> &r_res, int &line, String &r_err_str) {
return OK;
}

Variant EditorSettings::get_setting_directly(const String &p_setting, const Variant &p_default) {
if (!EditorPaths::get_singleton() || !EditorPaths::get_singleton()->are_paths_valid()) {
return p_default;
}

String config_file_path = get_existing_settings_path();
if (config_file_path.is_empty() || !FileAccess::exists(config_file_path)) {
return p_default;
}

Ref<FileAccess> f = FileAccess::open(config_file_path, FileAccess::READ);
if (f.is_null()) {
return p_default;
}

VariantParser::StreamFile stream;
stream.f = f;
String assign;
Variant value;
VariantParser::Tag next_tag;
int lines = 0;
String error_text;
VariantParser::ResourceParser rp_new;
rp_new.ext_func = _parse_direct_resource_dummy;
rp_new.sub_func = _parse_direct_resource_dummy;

while (true) {
assign = Variant();
next_tag.fields.clear();
next_tag.name = String();
Error err = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, &rp_new, true, true);
if (err == ERR_FILE_EOF) {
break;
}
if (err == OK && !assign.is_empty() && assign == p_setting) {
return value;
}
}

return p_default;
}

Color EditorSettings::get_default_base_color() {
return Color(0.06, 0.09, 0.14);
}

String EditorSettings::get_newest_settings_path() {
const String config_file_name = vformat("editor_settings-%d.%d.tres", REDOT_VERSION_MAJOR, REDOT_VERSION_MINOR);
return EditorPaths::get_singleton()->get_config_dir().path_join(config_file_name);
Expand Down
2 changes: 2 additions & 0 deletions editor/settings/editor_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ class EditorSettings : public Resource {
static EditorSettings *get_singleton();
static String get_existing_settings_path();
static String get_newest_settings_path();
static Variant get_setting_directly(const String &p_setting, const Variant &p_default = Variant());
static Color get_default_base_color();

static void create();
void setup_language();
Expand Down
114 changes: 22 additions & 92 deletions main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,6 @@

#include "modules/modules_enabled.gen.h" // For mono.

// Fallback definition for missing editor splash color
#if defined(TOOLS_ENABLED) && !defined(NO_EDITOR_SPLASH)
static const Color boot_splash_editor_bg_color = Color(0.06, 0.09, 0.14);
#endif

#if defined(MODULE_MONO_ENABLED) && defined(TOOLS_ENABLED)
#include "modules/mono/editor/bindings_generator.h"
#endif
Expand Down Expand Up @@ -3170,48 +3165,8 @@ Error Main::setup2(bool p_show_boot_logo) {
window_position = &position;
}

Color boot_bg_color;
#ifdef TOOLS_ENABLED
if (editor) {
// Read base color directly from settings file since EditorSettings isn't available yet
boot_bg_color = Color(0.06, 0.09, 0.14); // Default fallback
if (EditorPaths::get_singleton() && EditorPaths::get_singleton()->are_paths_valid()) {
String config_file_path = EditorSettings::get_existing_settings_path();
if (FileAccess::exists(config_file_path)) {
Ref<FileAccess> f = FileAccess::open(config_file_path, FileAccess::READ);
if (f.is_valid()) {
VariantParser::StreamFile stream;
stream.f = f;
String assign;
Variant value;
VariantParser::Tag next_tag;
int lines = 0;
String error_text;
VariantParser::ResourceParser rp_new;
rp_new.ext_func = _parse_resource_dummy;
rp_new.sub_func = _parse_resource_dummy;
while (true) {
assign = Variant();
next_tag.fields.clear();
next_tag.name = String();
Error err = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, &rp_new, true);
if (err == ERR_FILE_EOF) {
break;
}
if (err == OK && !assign.is_empty() && assign == "interface/theme/base_color") {
boot_bg_color = value;
break;
}
}
}
}
}
} else {
boot_bg_color = GLOBAL_DEF_BASIC("application/boot_splash/bg_color", boot_splash_bg_color);
}
#else
boot_bg_color = GLOBAL_DEF_BASIC("application/boot_splash/bg_color", boot_splash_bg_color);
#endif
GLOBAL_DEF(PropertyInfo(Variant::COLOR, "application/boot_splash/bg_color"), Color(0.14, 0.14, 0.14));
Color boot_bg_color = get_boot_splash_bg_color();
DisplayServer::set_early_window_clear_color_override(true, boot_bg_color);

DisplayServer::Context context;
Expand Down Expand Up @@ -3526,7 +3481,7 @@ Error Main::setup2(bool p_show_boot_logo) {
}
}

Color clear = GLOBAL_DEF_BASIC("rendering/environment/defaults/default_clear_color", Color(0.128, 0.128, 0.128));
Color clear = GLOBAL_DEF_BASIC("rendering/environment/defaults/default_clear_color", get_boot_splash_bg_color());
RenderingServer::get_singleton()->set_default_clear_color(clear);

if (p_show_boot_logo) {
Expand Down Expand Up @@ -3807,6 +3762,19 @@ Error Main::setup2(bool p_show_boot_logo) {
return OK;
}

Color Main::get_boot_splash_bg_color() {
#if defined(TOOLS_ENABLED)
if (editor || project_manager) {
if (EditorSettings::get_singleton()) {
return EditorSettings::get_singleton()->get_setting("interface/theme/base_color");
}
return EditorSettings::get_setting_directly("interface/theme/base_color", EditorSettings::get_default_base_color());
}
#endif

return GLOBAL_GET("application/boot_splash/bg_color");
}

void Main::setup_boot_logo() {
MAIN_PRINT("Main: Load Boot Image");

Expand Down Expand Up @@ -3852,49 +3820,8 @@ void Main::setup_boot_logo() {
boot_logo->set_pixel(0, 0, Color(0, 0, 0, 0));
}

Color boot_bg_color;
#ifdef TOOLS_ENABLED
if (editor) {
// Read base color directly from settings file since EditorSettings isn't available yet
boot_bg_color = Color(0.06, 0.09, 0.14); // Default fallback
if (EditorPaths::get_singleton() && EditorPaths::get_singleton()->are_paths_valid()) {
String config_file_path = EditorSettings::get_existing_settings_path();
if (FileAccess::exists(config_file_path)) {
Ref<FileAccess> f = FileAccess::open(config_file_path, FileAccess::READ);
if (f.is_valid()) {
VariantParser::StreamFile stream;
stream.f = f;
String assign;
Variant value;
VariantParser::Tag next_tag;
int lines = 0;
String error_text;
VariantParser::ResourceParser rp_new;
rp_new.ext_func = _parse_resource_dummy;
rp_new.sub_func = _parse_resource_dummy;
while (true) {
assign = Variant();
next_tag.fields.clear();
next_tag.name = String();
Error err = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, &rp_new, true);
if (err == ERR_FILE_EOF) {
break;
}
if (err == OK && !assign.is_empty() && assign == "interface/theme/base_color") {
boot_bg_color = value;
break;
}
}
}
}
}
} else {
boot_bg_color = GLOBAL_DEF_BASIC("application/boot_splash/bg_color", boot_splash_bg_color);
}
#else
boot_bg_color = GLOBAL_DEF_BASIC("application/boot_splash/bg_color", boot_splash_bg_color);
#endif
if (boot_logo.is_valid()) {
Color boot_bg_color = get_boot_splash_bg_color();
RenderingServer::get_singleton()->set_boot_image(boot_logo, boot_bg_color, boot_logo_scale, boot_logo_filter);

} else {
Expand All @@ -3907,6 +3834,7 @@ void Main::setup_boot_logo() {
#endif

MAIN_PRINT("Main: ClearColor");
Color boot_bg_color = get_boot_splash_bg_color();
RenderingServer::get_singleton()->set_default_clear_color(boot_bg_color);
MAIN_PRINT("Main: Image");
RenderingServer::get_singleton()->set_boot_image(splash, boot_bg_color, false);
Expand All @@ -3920,8 +3848,10 @@ void Main::setup_boot_logo() {
}
#endif
}
RenderingServer::get_singleton()->set_default_clear_color(
GLOBAL_GET("rendering/environment/defaults/default_clear_color"));
if (!editor && !project_manager) {
RenderingServer::get_singleton()->set_default_clear_color(
GLOBAL_GET("rendering/environment/defaults/default_clear_color"));
}
}

String Main::get_rendering_driver_name() {
Expand Down
2 changes: 2 additions & 0 deletions main/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

template <typename T>
class Vector;
struct Color;

class Main {
enum CLIOptionAvailability {
Expand Down Expand Up @@ -74,6 +75,7 @@ class Main {
static Error setup2(bool p_show_boot_logo = true); // The thread calling setup2() will effectively become the main thread.
static String get_rendering_driver_name();
static void setup_boot_logo();
static Color get_boot_splash_bg_color();
#ifdef TESTS_ENABLED
static Error test_setup();
static void test_cleanup();
Expand Down
3 changes: 2 additions & 1 deletion servers/rendering/renderer_viewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "core/config/project_settings.h"
#include "core/math/transform_interpolator.h"
#include "core/object/worker_thread_pool.h"
#include "main/main.h"
#include "renderer_canvas_cull.h"
#include "renderer_scene_cull.h"
#include "rendering_server_globals.h"
Expand Down Expand Up @@ -746,7 +747,7 @@ void RendererViewport::draw_viewports(bool p_swap_buffers) {
#endif // XR_DISABLED

if (Engine::get_singleton()->is_editor_hint()) {
RSG::texture_storage->set_default_clear_color(GLOBAL_GET_CACHED(Color, "rendering/environment/defaults/default_clear_color"));
RSG::texture_storage->set_default_clear_color(Main::get_boot_splash_bg_color());
}

if (sorted_active_viewports_dirty) {
Expand Down
Loading