Skip to content

Commit 5718845

Browse files
committed
Merge pull request godotengine#101576 from bruvzg/pm_size_fix
Fix project manager window size when `EDSCALE` is not 1.0.
2 parents a79e30a + 934668a commit 5718845

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

editor/project_manager.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ void ProjectManager::_build_icon_type_cache(Ref<Theme> p_theme) {
149149

150150
// Main layout.
151151

152-
void ProjectManager::_update_size_limits() {
152+
void ProjectManager::_update_size_limits(bool p_custom_res) {
153153
const Size2 minimum_size = Size2(720, 450) * EDSCALE;
154154
const Size2 default_size = Size2(DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT) * EDSCALE;
155155

@@ -159,20 +159,21 @@ void ProjectManager::_update_size_limits() {
159159
// Calling Window methods this early doesn't sync properties with DS.
160160
w->set_min_size(minimum_size);
161161
DisplayServer::get_singleton()->window_set_min_size(minimum_size);
162-
if (DisplayServer::get_singleton()->window_get_size() == default_size) {
162+
if (!p_custom_res) {
163163
// Only set window size if it currently matches the default, which is defined in `main/main.cpp`.
164164
// This allows CLI arguments to override the window size.
165165
w->set_size(default_size);
166166
DisplayServer::get_singleton()->window_set_size(default_size);
167167
}
168168
}
169+
Size2 real_size = DisplayServer::get_singleton()->window_get_size();
169170

170171
Rect2i screen_rect = DisplayServer::get_singleton()->screen_get_usable_rect(DisplayServer::get_singleton()->window_get_current_screen());
171172
if (screen_rect.size != Vector2i()) {
172173
// Center the window on the screen.
173174
Vector2i window_position;
174-
window_position.x = screen_rect.position.x + (screen_rect.size.x - default_size.x) / 2;
175-
window_position.y = screen_rect.position.y + (screen_rect.size.y - default_size.y) / 2;
175+
window_position.x = screen_rect.position.x + (screen_rect.size.x - real_size.x) / 2;
176+
window_position.y = screen_rect.position.y + (screen_rect.size.y - real_size.y) / 2;
176177
DisplayServer::get_singleton()->window_set_position(window_position);
177178

178179
// Limit popup menus to prevent unusably long lists.
@@ -1158,7 +1159,7 @@ void ProjectManager::_titlebar_resized() {
11581159

11591160
// Object methods.
11601161

1161-
ProjectManager::ProjectManager() {
1162+
ProjectManager::ProjectManager(bool p_custom_res) {
11621163
singleton = this;
11631164

11641165
set_translation_domain("godot.editor");
@@ -1746,7 +1747,7 @@ ProjectManager::ProjectManager() {
17461747
title_bar->connect(SceneStringName(item_rect_changed), callable_mp(this, &ProjectManager::_titlebar_resized));
17471748
}
17481749

1749-
_update_size_limits();
1750+
_update_size_limits(p_custom_res);
17501751
}
17511752

17521753
ProjectManager::~ProjectManager() {

editor/project_manager.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class ProjectManager : public Control {
7070

7171
Ref<Theme> theme;
7272

73-
void _update_size_limits();
73+
void _update_size_limits(bool p_custom_res);
7474
void _update_theme(bool p_skip_creation = false);
7575
void _titlebar_resized();
7676

@@ -262,7 +262,7 @@ class ProjectManager : public Control {
262262

263263
void add_new_tag(const String &p_tag);
264264

265-
ProjectManager();
265+
ProjectManager(bool p_custom_res);
266266
~ProjectManager();
267267
};
268268

main/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ static bool init_use_custom_pos = false;
230230
static bool init_use_custom_screen = false;
231231
static Vector2 init_custom_pos;
232232
static int64_t init_embed_parent_window_id = 0;
233+
static bool use_custom_res = true;
234+
static bool force_res = false;
233235

234236
// Debug
235237

@@ -1019,8 +1021,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
10191021
String remotefs_pass;
10201022

10211023
Vector<String> breakpoints;
1022-
bool use_custom_res = true;
1023-
bool force_res = false;
10241024
bool delta_smoothing_override = false;
10251025

10261026
String default_renderer = "";
@@ -4318,7 +4318,7 @@ int Main::start() {
43184318
translation_server->get_editor_domain()->set_pseudolocalization_enabled(true);
43194319
}
43204320

4321-
ProjectManager *pmanager = memnew(ProjectManager);
4321+
ProjectManager *pmanager = memnew(ProjectManager(force_res || use_custom_res));
43224322
ProgressDialog *progress_dialog = memnew(ProgressDialog);
43234323
pmanager->add_child(progress_dialog);
43244324

0 commit comments

Comments
 (0)