- Software now remember the monitor it's closed on.

This commit is contained in:
Tanasart 2024-05-07 13:09:38 +07:00
parent a581d4fbe1
commit b8918d21fb
2 changed files with 41 additions and 11 deletions

View file

@ -9,6 +9,7 @@
PREFERENCES.window_width = 1600;
PREFERENCES.window_height = 800;
PREFERENCES.window_maximize = false;
PREFERENCES.window_monitor = "";
PREFERENCES.theme = "default";
PREFERENCES.local = "en";
@ -99,7 +100,6 @@
PREFERENCES.collection_scale = 1;
PREFERENCES.pan_mouse_key = mb_middle;
#endregion
#region //////////////////////////////////////////////////////////////////////// WIDGET ////////////////////////////////////////////////////////////////////////
@ -219,6 +219,7 @@
PREFERENCES.window_maximize = window_is_maximized;
PREFERENCES.window_width = max(960, window_minimize_size[0]);
PREFERENCES.window_height = max(600, window_minimize_size[1]);
PREFERENCES.window_monitor = window_monitor;
map.preferences = PREFERENCES;
@ -276,18 +277,32 @@
else setException();
if(OS != os_macosx && !LOADING) {
if(PREFERENCES.window_maximize) {
winMan_Maximize();
} else {
var _monitors = display_measure_all();
var _monitor = noone;
if(is_array(_monitors))
for( var i = 0, n = array_length(_monitors); i < n; i++ ) {
var _m = _monitors[i];
if(!is_array(_m) || array_length(_m) < 10) continue;
if(PREFERENCES.window_monitor == _m[9])
_monitor = _m;
}
var ww = PREFERENCES.window_width;
var hh = PREFERENCES.window_height;
window_minimize_size = [ ww, hh ];
window_set_position(display_get_width() / 2 - ww / 2, display_get_height() / 2 - hh / 2);
window_set_size(ww, hh);
if(is_array(_monitor) && array_length(_monitor) >= 8)
window_set_rectangle(_monitor[0] + _monitor[2] / 2 - ww / 2, _monitor[1] + _monitor[3] / 2 - hh / 2, ww, hh);
else
window_set_rectangle(display_get_width() / 2 - ww / 2, display_get_height() / 2 - hh / 2, ww, hh);
if(PREFERENCES.window_maximize)
winMan_Maximize();
gameframe_set_shadow(true);
}
}
window_refresh();
game_set_speed(PREFERENCES.ui_framerate, gamespeed_fps);

View file

@ -11,6 +11,7 @@
globalvar window_drag_sy; window_drag_sy = 0;
globalvar window_drag_sw; window_drag_sw = 0;
globalvar window_drag_sh; window_drag_sh = 0;
globalvar window_monitor; window_monitor = 0;
globalvar window_min_w; window_min_w = 960;
globalvar window_min_h; window_min_h = 600;
@ -138,6 +139,20 @@ function winManStep() { #region
}
}
window_monitor = 0;
var _monitors = display_measure_all();
var _x = window_get_x() + WIN_W / 2;
var _y = window_get_y() + WIN_H / 2;
if(is_array(_monitors))
for( var i = 0, n = array_length(_monitors); i < n; i++ ) {
var _monitor = _monitors[i];
if(!is_array(_monitor) || array_length(_monitor) < 10) continue;
if(point_in_rectangle(_x, _y, _monitor[0], _monitor[1], _monitor[0] + _monitor[2], _monitor[1] + _monitor[3]))
window_monitor = _monitor[9];
}
if(window_drag_status == 0) return;
var _mx = window_drag_mx;
var _my = window_drag_my;