You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-26 15:46:23 +00:00
EditorSettings: Factor code to compute auto display scale
Also fixes typo introduced in https://github.com/godotengine/godot/pull/48597/files#r652636544.
This commit is contained in:
@@ -5689,36 +5689,10 @@ EditorNode::EditorNode() {
|
||||
int display_scale = EditorSettings::get_singleton()->get("interface/editor/display_scale");
|
||||
|
||||
switch (display_scale) {
|
||||
case 0: {
|
||||
case 0:
|
||||
// Try applying a suitable display scale automatically.
|
||||
// The code below is adapted in `editor/editor_settings.cpp` and `editor/project_manager.cpp`.
|
||||
// Make sure to update those when modifying the code below.
|
||||
#ifdef OSX_ENABLED
|
||||
editor_set_scale(DisplayServer::get_singleton()->screen_get_max_scale());
|
||||
#else
|
||||
const int screen = DisplayServer::get_singleton()->window_get_current_screen();
|
||||
// Use the smallest dimension to use a correct display scale on portait displays.
|
||||
const int smallest_dimension = MIN(DisplayServer::get_singleton()->screen_get_size(screen).x, DisplayServer::get_singleton()->screen_get_size(screen).y);
|
||||
float scale;
|
||||
if (DisplayServer::get_singleton()->screen_get_dpi(screen) >= 192 && smallest_dimension >= 1400) {
|
||||
// hiDPI display.
|
||||
scale = 2.0;
|
||||
} else if (smallest_dimension >= 1700) {
|
||||
// Likely a hiDPI display, but we aren't certain due to the returned DPI.
|
||||
// Use an intermediate scale to handle this situation.
|
||||
scale = 1.5;
|
||||
} else if (smallest_dimension <= 800) {
|
||||
// Small loDPI display. Use a smaller display scale so that editor elements fit more easily.
|
||||
// Icons won't look great, but this is better than having editor elements overflow from its window.
|
||||
scale = 0.75;
|
||||
} else {
|
||||
scale = 1.0;
|
||||
}
|
||||
|
||||
editor_set_scale(scale);
|
||||
#endif
|
||||
} break;
|
||||
|
||||
editor_set_scale(EditorSettings::get_singleton()->get_auto_display_scale());
|
||||
break;
|
||||
case 1:
|
||||
editor_set_scale(0.75);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user