1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-13 13:31:48 +00:00

Added OS::center_window to center the window precisely on desktop platforms

This commit is contained in:
marcelofg55
2017-12-02 16:48:14 -03:00
committed by Marcelo Fernandez
parent 7983fb95b0
commit 129e0f34d0
10 changed files with 62 additions and 1 deletions

View File

@@ -546,6 +546,17 @@ Dictionary OS::get_engine_version() const {
return dict;
}
void OS::center_window() {
if (is_window_fullscreen()) return;
Size2 scr = get_screen_size(get_current_screen());
Size2 wnd = get_real_window_size();
int x = scr.width / 2 - wnd.width / 2;
int y = scr.height / 2 - wnd.height / 2;
set_window_position(Vector2(x, y));
}
OS::OS() {
last_error = NULL;
frames_drawn = 0;