From 56e4982590b2b6597db1698bbc57607daf20d758 Mon Sep 17 00:00:00 2001 From: Tanasart Date: Wed, 11 Sep 2024 16:56:41 +0700 Subject: [PATCH] - popup dialog 1 --- PixelComposer.yyp | 1 - datafiles/data/Theme.zip | Bin 2185231 -> 2185231 bytes objects/_p_dialog/Create_0.gml | 35 ++++++++------- objects/_p_dialog/Destroy_0.gml | 3 +- objects/_p_dialog/Step_1.gml | 4 +- objects/o_dialog_menubox/Create_0.gml | 40 +++++++++++++++--- objects/o_dialog_menubox/Destroy_0.gml | 3 +- objects/o_dialog_menubox/Draw_64.gml | 40 ++++++++++++------ objects/o_dialog_menubox/Step_1.gml | 12 +++--- objects/o_dialog_preference/Create_0.gml | 38 +++++++++-------- objects/o_dialog_splash/Create_0.gml | 2 +- .../contextMenu_controller.gml | 4 -- scripts/draw_UI_scale/draw_UI_scale.gml | 2 +- scripts/globals/globals.gml | 10 +++-- scripts/mouse_input/mouse_input.gml | 24 +++++------ scripts/theme_definition/theme_definition.gml | 2 +- scripts/windowManager/windowManager.gml | 40 +++++++++--------- scripts/winwin_extras/winwin_extras.gml | 18 ++++++++ 18 files changed, 171 insertions(+), 107 deletions(-) diff --git a/PixelComposer.yyp b/PixelComposer.yyp index 6f782f5e6..758c36f4d 100644 --- a/PixelComposer.yyp +++ b/PixelComposer.yyp @@ -681,7 +681,6 @@ {"$GMIncludedFile":"","%Name":"Canvas.pxc","CopyToMask":-1,"filePath":"datafiles/Welcome files/Templates","name":"Canvas.pxc","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"Welcome files.zip","CopyToMask":-1,"filePath":"datafiles/Welcome files","name":"Welcome files.zip","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"winwin.html","CopyToMask":-1,"filePath":"datafiles","name":"winwin.html","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, - {"$GMIncludedFile":"","%Name":"winwin.html","CopyToMask":-1,"filePath":"datafiles","name":"winwin.html","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, ], "isEcma":false, "LibraryEmitters":[], diff --git a/datafiles/data/Theme.zip b/datafiles/data/Theme.zip index 05b32010d547a9b8c02b950a0d04c43718230426..cfe1f8dcee8fecad1eb65f27151274b0ae6c5d8d 100644 GIT binary patch delta 625 zcmeC*(8|~k#1kqwqRX`-MV{@F+}QA%h0%0!4y#=K%jMg*+@E^sLP5#=wL%TPe%D+q zx7{_8y}cz-ZTj_{eG#j4i`)WLwSV0()mt!eS$68u#F**ZmmXH_6iu()ZDnyJ(kkuU zZi`>io~ut?v|6ljUHFe)L5xb2FY9WH$lUkJ+a@c^YaM#F-7Q;FaCXV7maC*+bZ95c3#1vqpgu@S3@R0er6-VxpA@X&YzPX zaJ5u9>^_uLUwmNoJJ}0!IG3Kk6A;AS`EYMcdE&ztycgY%#uwIzsOS~it?Rj0S}U^g-A=Y|w)F?fe>s*suY2Mc ze zNUgk5-oa@TJ4HDm)@E<_R?%Gk%QD7V=HBzR%dUMSS2O9kWJLX^5Bs%m$20AaNln?8 zut@smO-t#X_pj~Vlx}>d+;g_vz9TszJL`z{r6bqHrWy)7Us)!$rT@H?5yRP>@{-{6 zocsG6+?Oi~9$jmyuf~+6e#-k=2an=TwF>^`oArPH{F85XV{dn3X9QvH#WRxVa%JH!zx$*?Lzde_gR zJ8x!R?k$7Kr(ego>s%GHT)bkEXzd#*@e3Z8w{E&*uDs(6R#xVbj;!(b zSed`QOG2M!%nh9KnzK&aLQiPzvZl~EYqotCynS*azi8s;=*3&7bojbfro8y5{JwQV z%)Cv@4(~i%F6>_)w$pFZnaQ_zpXOTUu>KbR!8Cu1i;oWJOwL+$vandLr{%`QX?Om3 z7O*YV$jZsq??oVpZZpxF{aPR zDBj>=@0&Msc#nNAmH)OY;=ACnXV&&d4A+>NJ`&A*l-+$wqT_RjHTSLK>AaE+Y1^!K ztu)@2AHQJn*/ { hk_editing = selecting_menu; keyboard_lastchar = hk_editing.hoykeyObject.key; }), ]; - item_selecting = submenuCall(_dat, context_menu_settings); - item_selecting.remove_parents = false; - array_push(children, item_selecting.id); + item_sel_submenu = submenuCall(_dat, context_menu_settings); + item_sel_submenu.remove_parents = false; } } } else if(cc != c_white) - draw_sprite_stretched_ext(THEME.textbox, 3, dialog_x, yy, dialog_w, _h, cc, 0.5); + draw_sprite_stretched_ext(THEME.textbox, 3, dialog_x, yy, dialog_w, _h, cc); var _hx = dialog_x + dialog_w - ui(16); var _hy = yy + hght / 2 + ui(2); @@ -170,7 +178,10 @@ if(!ready) exit; if(mouse_press(mb_left, sFOCUS)) { _submenu[1](_dat); + + DIALOG_POSTDRAW instance_destroy(o_dialog_menubox); + exit; } } @@ -252,8 +263,11 @@ if(!ready) exit; if(keyboard_check_pressed(vk_down)) selecting = safe_mod(selecting + 1, array_length(menu)); - if(keyboard_check_pressed(vk_escape)) + if(keyboard_check_pressed(vk_escape)) { + DIALOG_POSTDRAW instance_destroy(); + exit; + } } draw_sprite_stretched(THEME.s_box_r2_clr, 1, dialog_x, dialog_y, dialog_w, dialog_h); @@ -270,4 +284,6 @@ if(!ready) exit; draw_set_text(f_p0, fa_left, fa_bottom); draw_text(dialog_x, dialog_y - ui(2), menu_id); } -#endregion \ No newline at end of file +#endregion + +DIALOG_POSTDRAW \ No newline at end of file diff --git a/objects/o_dialog_menubox/Step_1.gml b/objects/o_dialog_menubox/Step_1.gml index fb4773559..b6ee0faf7 100644 --- a/objects/o_dialog_menubox/Step_1.gml +++ b/objects/o_dialog_menubox/Step_1.gml @@ -1,12 +1,14 @@ /// @description Insert description here event_inherited(); -var hov = point_in(mouse_mx, mouse_my); - -for( var i = 0, n = array_length(children); i < n; i++ ) { - if(!instance_exists(children[i])) continue; - hov |= children[i].point_in(mouse_mx, mouse_my); +if(item_sel_submenu) { + if(!instance_exists(item_sel_submenu)) + item_sel_submenu = noone; + exit; } + +var hov = point_in(mouse_raw_x, mouse_raw_y); +if(submenu) hov |= submenu.point_in(mouse_raw_x, mouse_raw_y); _hovering_ch = hov; if(!hov && mouse_press(mb_left)) instance_destroy(); \ No newline at end of file diff --git a/objects/o_dialog_preference/Create_0.gml b/objects/o_dialog_preference/Create_0.gml index aa76e2757..9edab624b 100644 --- a/objects/o_dialog_preference/Create_0.gml +++ b/objects/o_dialog_preference/Create_0.gml @@ -10,6 +10,8 @@ event_inherited(); destroy_on_escape = false; should_restart = false; + + font = f_p2; #endregion #region size @@ -592,9 +594,9 @@ event_inherited(); sb_theme.align = fa_left; sp_colors = new scrollPane(panel_width, panel_height - ui(40), function(_y, _m, _r) { - draw_clear_alpha(COLORS.panel_bg_clear, 0); + draw_clear_alpha(COLORS.panel_bg_clear_inner, 1); var hh = 0; - var th = line_get_height(f_p0); + var th = line_get_height(font); var x1 = sp_colors.surface_w; var yy = _y + ui(8); var padd = ui(6); @@ -623,7 +625,7 @@ event_inherited(); category = cat; var _sect = string_title(category); - draw_set_text(f_p0b, fa_left, fa_top, COLORS._main_text_sub); + draw_set_text(f_p1, fa_left, fa_top, COLORS._main_text_sub); draw_text_add(ui(8), yy - ui(4), _sect); array_push(sect, [ _sect, sp_colors, hh + ui(12) ]); @@ -642,7 +644,7 @@ event_inherited(); keyStr = string_replace(keyStr, cat + " ", ""); keyStr = string_title(keyStr); - draw_set_text(f_p1, fa_left, fa_center, COLORS._main_text); + draw_set_text(font, fa_left, fa_center, COLORS._main_text); draw_text_add(ui(24), yy + th / 2, keyStr); var b = buttonInstant(THEME.button_def, cx, yy + cp, cw, ch, _m, sFOCUS, sHOVER && sp_colors.hover); @@ -663,8 +665,8 @@ event_inherited(); addChildren(dialog); } - yy += th + padd + ui(8); - hh += th + padd + ui(8); + yy += th + padd + ui(6); + hh += th + padd + ui(6); ind++; } @@ -739,7 +741,7 @@ event_inherited(); hk_scroll.align = fa_left; sp_hotkey = new scrollPane(panel_width, hotkey_height, function(_y, _m) { - draw_clear_alpha(COLORS.panel_bg_clear, 0); + draw_clear_alpha(COLORS.panel_bg_clear_inner, 1); draw_set_text(f_p2, fa_left, fa_top); var padd = ui(6); @@ -852,9 +854,9 @@ event_inherited(); current_list = pref_global; sp_pref = new scrollPane(panel_width, panel_height, function(_y, _m, _r) { - draw_clear_alpha(COLORS.panel_bg_clear, 0); + draw_clear_alpha(COLORS.panel_bg_clear_inner, 1); var hh = 0; - var th = TEXTBOX_HEIGHT; + var th = line_get_height(font, 6); var x1 = sp_pref.surface_w; var yy = _y + ui(8); var padd = ui(6); @@ -875,10 +877,9 @@ event_inherited(); for(var i = 0; i < ds_list_size(current_list); i++) { var _pref = current_list[| i]; - var th = TEXTBOX_HEIGHT; if(is_string(_pref)) { - draw_set_text(f_p0b, fa_left, fa_top, COLORS._main_text_sub); + draw_set_text(f_p1, fa_left, fa_top, COLORS._main_text_sub); draw_text_add(ui(8), yy, _pref); array_push(sect, [ _pref, sp_pref, hh + ui(12) ]); @@ -900,7 +901,7 @@ event_inherited(); if(ind % 2 == 0) draw_sprite_stretched_ext(THEME.ui_panel_bg, 0, 0, yy - padd, sp_pref.surface_w, max(_pref.editWidget.h, th) + padd * 2, COLORS.dialog_preference_prop_bg, 1); - draw_set_text(f_p1, fa_left, fa_center, COLORS._main_text); + draw_set_text(font, fa_left, fa_center, COLORS._main_text); draw_text_add(ui(24), yy + th / 2, name); if(_pref.is_patreon) { @@ -930,18 +931,19 @@ event_inherited(); if(_pref.getDefault != noone) widget_w -= ui(32 + 8); - var params = new widgetParam(widget_x, widget_y, widget_w, widget_h, data, {}, _m, _r[0], _r[1]); - params.s = ui(30); + var params = new widgetParam(widget_x, widget_y, widget_w, widget_h, data, {}, _m, _r[0], _r[1]); + params.s = th; + params.font = font; if(instanceof(_pref.editWidget) == "checkBox") params.halign = fa_center; - var th = _pref.editWidget.drawParam(params) ?? 0; + var wdh = _pref.editWidget.drawParam(params) ?? 0; if(_pref.editWidget.inBBOX(_m)) sp_pref.hover_content = true; if(_pref.getDefault != noone) { var _defVal = is_method(_pref.getDefault)? _pref.getDefault() : _pref.getDefault; var _bs = ui(32); var _bx = x1 - ui(4) - _bs; - var _by = yy + th / 2 - _bs / 2; + var _by = yy + wdh / 2 - _bs / 2; if(isEqual(data, _defVal)) draw_sprite_ext(THEME.refresh_16, 0, _bx + _bs / 2, _by + _bs / 2, 1, 1, 0, COLORS._main_icon_dark); @@ -951,8 +953,8 @@ event_inherited(); } } - yy += th + padd + ui(8); - hh += th + padd + ui(8); + yy += wdh + padd + ui(6); + hh += wdh + padd + ui(6); ind++; } diff --git a/objects/o_dialog_splash/Create_0.gml b/objects/o_dialog_splash/Create_0.gml index e26ec1b08..98d4f0427 100644 --- a/objects/o_dialog_splash/Create_0.gml +++ b/objects/o_dialog_splash/Create_0.gml @@ -42,7 +42,7 @@ event_inherited(); var y1 = dialog_y + dialog_h - ui(16); sp_recent = new scrollPane(x1 - x0 - ui(12), y1 - y0, function(_y, _m) { #region - draw_clear_alpha(COLORS.panel_bg_clear_inner, 0); + draw_clear_alpha(COLORS.panel_bg_clear, 1); var expand = PREFERENCES.splash_expand_recent; var ww = ui(264); var hh = ui(8); diff --git a/scripts/contextMenu_controller/contextMenu_controller.gml b/scripts/contextMenu_controller/contextMenu_controller.gml index 90c78e5e5..5ceb83cca 100644 --- a/scripts/contextMenu_controller/contextMenu_controller.gml +++ b/scripts/contextMenu_controller/contextMenu_controller.gml @@ -15,10 +15,6 @@ function menuCall(menu_id = "", menu = [], _x = 0, _y = 0, align = fa_left, cont var dia = dialogCall(o_dialog_menubox, _x, _y); - // if(WINDOW_ACTIVE != noone) { - // dia.window = WINDOW_ACTIVE; - // } - if(menu_id != "" && ds_map_exists(CONTEXT_MENU_CALLBACK, menu_id)) { var callbacks = CONTEXT_MENU_CALLBACK[? menu_id]; diff --git a/scripts/draw_UI_scale/draw_UI_scale.gml b/scripts/draw_UI_scale/draw_UI_scale.gml index 9ff15ee68..6996b872f 100644 --- a/scripts/draw_UI_scale/draw_UI_scale.gml +++ b/scripts/draw_UI_scale/draw_UI_scale.gml @@ -21,7 +21,7 @@ function line_get_width(txt, font = noone, offset = 0) { } #region global - #macro TEXTBOX_HEIGHT line_get_height(f_p1, 8) + #macro TEXTBOX_HEIGHT line_get_height(f_p1, 6) #macro BUTTON_HEIGHT line_get_height(f_p1, 12) function ui(val) { diff --git a/scripts/globals/globals.gml b/scripts/globals/globals.gml index 59fb2855f..db77610c4 100644 --- a/scripts/globals/globals.gml +++ b/scripts/globals/globals.gml @@ -41,7 +41,7 @@ LATEST_VERSION = 1_17_00; VERSION = 1_17_12_0; SAVE_VERSION = 1_17_10_0; - VERSION_STRING = MAC? "1.18.002m" : "1.18.rc1.003"; + VERSION_STRING = MAC? "1.18.002m" : "1.18.rc1.004"; BUILD_NUMBER = 1_17_12_0; HOTKEYS = ds_map_create(); @@ -87,6 +87,8 @@ #macro NOT_LOAD !LOADING && !APPENDING + #macro WIN_X window_get_x() + #macro WIN_Y window_get_y() #macro WIN_W window_get_width() #macro WIN_H window_get_height() @@ -95,8 +97,8 @@ #macro UI_SCALE PREFERENCES.display_scaling - #macro mouse_mx (PEN_USE? PEN_X : (WINDOW_ACTIVE == noone? device_mouse_x_to_gui(0) : winwin_mouse_get_x(WINDOW_ACTIVE))) - #macro mouse_my (PEN_USE? PEN_Y : (WINDOW_ACTIVE == noone? device_mouse_y_to_gui(0) : winwin_mouse_get_y(WINDOW_ACTIVE))) + #macro mouse_mx (PEN_USE? PEN_X : winwin_mouse_get_x_safe(WINDOW_ACTIVE)) + #macro mouse_my (PEN_USE? PEN_Y : winwin_mouse_get_y_safe(WINDOW_ACTIVE)) #macro mouse_mxs (FILE_IS_DROPPING? FILE_DROPPING_X : mouse_mx) #macro mouse_mys (FILE_IS_DROPPING? FILE_DROPPING_Y : mouse_my) @@ -106,7 +108,7 @@ #macro mouse_ui [device_mouse_x_to_gui(0), device_mouse_y_to_gui(0)] #macro sFOCUS (FOCUS == self.id) - #macro sHOVER (!CURSOR_IS_LOCK && (HOVER == self.id || (WINDOW_ACTIVE != noone && winwin_mouse_is_over(WINDOW_ACTIVE)))) + #macro sHOVER (!CURSOR_IS_LOCK && (HOVER == self.id || (WINDOW_ACTIVE != noone && winwin_mouse_is_over_safe(WINDOW_ACTIVE)))) #macro DELTA_TIME delta_time / 1_000_000 diff --git a/scripts/mouse_input/mouse_input.gml b/scripts/mouse_input/mouse_input.gml index a848d451b..53dde9e00 100644 --- a/scripts/mouse_input/mouse_input.gml +++ b/scripts/mouse_input/mouse_input.gml @@ -30,7 +30,7 @@ function mouse_click(mouse, focus = true) { if(PEN_RIGHT_CLICK) return mouse == mb_right; - return WINDOW_ACTIVE == noone? mouse_check_button(mouse) : winwin_mouse_check_button(WINDOW_ACTIVE, mouse); + return WINDOW_ACTIVE == noone? mouse_check_button(mouse) : winwin_mouse_check_button_safe(WINDOW_ACTIVE, mouse); } function mouse_press(mouse, focus = true) { @@ -41,9 +41,9 @@ function mouse_press(mouse, focus = true) { if(PEN_RIGHT_PRESS) return mouse == mb_right; if(WINDOW_ACTIVE == noone) return mouse_check_button_pressed(mouse); - if(mouse != mb_any) return winwin_mouse_check_button_pressed(WINDOW_ACTIVE, mouse); + if(mouse != mb_any) return winwin_mouse_check_button_pressed_safe(WINDOW_ACTIVE, mouse); - return winwin_mouse_check_button_pressed(WINDOW_ACTIVE, mb_left) || winwin_mouse_check_button_pressed(WINDOW_ACTIVE, mb_right); + return winwin_mouse_check_button_pressed_safe(WINDOW_ACTIVE, mb_left) || winwin_mouse_check_button_pressed_safe(WINDOW_ACTIVE, mb_right); } function mouse_release(mouse, focus = true) { @@ -52,7 +52,7 @@ function mouse_release(mouse, focus = true) { if(PEN_RIGHT_RELEASE) return mouse == mb_right; - var rl = WINDOW_ACTIVE == noone? mouse_check_button_released(mouse) : winwin_mouse_check_button_released(WINDOW_ACTIVE, mouse); + var rl = WINDOW_ACTIVE == noone? mouse_check_button_released(mouse) : winwin_mouse_check_button_released_safe(WINDOW_ACTIVE, mouse); return rl || ((mouse == mb_left || mouse == mb_any) && PEN_RELEASED); } @@ -62,7 +62,7 @@ function mouse_lclick(focus = true) { if(!focus) return false; if(PEN_RIGHT_CLICK || PEN_RIGHT_RELEASE) return false; - return WINDOW_ACTIVE == noone? mouse_check_button(mb_left) : winwin_mouse_check_button(WINDOW_ACTIVE, mb_left); + return WINDOW_ACTIVE == noone? mouse_check_button(mb_left) : winwin_mouse_check_button_safe(WINDOW_ACTIVE, mb_left); } function mouse_lpress(focus = true) { @@ -71,7 +71,7 @@ function mouse_lpress(focus = true) { if(!focus) return false; if(PEN_RIGHT_PRESS) return false; - return WINDOW_ACTIVE == noone? mouse_check_button_pressed(mb_left) : winwin_mouse_check_button_pressed(WINDOW_ACTIVE, mb_left); + return WINDOW_ACTIVE == noone? mouse_check_button_pressed(mb_left) : winwin_mouse_check_button_pressed_safe(WINDOW_ACTIVE, mb_left); } function mouse_lrelease(focus = true) { @@ -80,7 +80,7 @@ function mouse_lrelease(focus = true) { if(PEN_RIGHT_RELEASE) return false; if(PEN_RELEASED) return true; - return WINDOW_ACTIVE == noone? mouse_check_button_released(mb_left) : winwin_mouse_check_button_released(WINDOW_ACTIVE, mb_left); + return WINDOW_ACTIVE == noone? mouse_check_button_released(mb_left) : winwin_mouse_check_button_released_safe(WINDOW_ACTIVE, mb_left); } function mouse_rclick(focus = true) { @@ -89,7 +89,7 @@ function mouse_rclick(focus = true) { if(!focus) return false; if(PEN_RIGHT_CLICK) return true; - return WINDOW_ACTIVE == noone? mouse_check_button(mb_right) : winwin_mouse_check_button(WINDOW_ACTIVE, mb_right); + return WINDOW_ACTIVE == noone? mouse_check_button(mb_right) : winwin_mouse_check_button_safe(WINDOW_ACTIVE, mb_right); } function mouse_rpress(focus = true) { @@ -98,7 +98,7 @@ function mouse_rpress(focus = true) { if(!focus) return false; if(PEN_RIGHT_PRESS) return true; - return WINDOW_ACTIVE == noone? mouse_check_button_pressed(mb_right) : winwin_mouse_check_button_pressed(WINDOW_ACTIVE, mb_right); + return WINDOW_ACTIVE == noone? mouse_check_button_pressed(mb_right) : winwin_mouse_check_button_pressed_safe(WINDOW_ACTIVE, mb_right); } function mouse_rrelease(focus = true) { @@ -106,7 +106,7 @@ function mouse_rrelease(focus = true) { if(!focus) return false; if(PEN_RIGHT_RELEASE) return true; - return WINDOW_ACTIVE == noone? mouse_check_button_released(mb_right) : winwin_mouse_check_button_released(WINDOW_ACTIVE, mb_right); + return WINDOW_ACTIVE == noone? mouse_check_button_released(mb_right) : winwin_mouse_check_button_released_safe(WINDOW_ACTIVE, mb_right); } function mouse_lock(mx = CURSOR_LOCK_X, my = CURSOR_LOCK_Y) { @@ -119,5 +119,5 @@ function mouse_lock(mx = CURSOR_LOCK_X, my = CURSOR_LOCK_Y) { window_mouse_set(CURSOR_LOCK_X, CURSOR_LOCK_Y); } -function mouse_wheel_up_override() { return WINDOW_ACTIVE == noone? __mouse_wheel_up() : winwin_mouse_wheel_up(WINDOW_ACTIVE); } -function mouse_wheel_down_override() { return WINDOW_ACTIVE == noone? __mouse_wheel_down() : winwin_mouse_wheel_down(WINDOW_ACTIVE); } \ No newline at end of file +function mouse_wheel_up_override() { return (WINDOW_ACTIVE != noone && winwin_exists(WINDOW_ACTIVE))? winwin_mouse_wheel_up(WINDOW_ACTIVE) : __mouse_wheel_up(); } +function mouse_wheel_down_override() { return (WINDOW_ACTIVE != noone && winwin_exists(WINDOW_ACTIVE))? winwin_mouse_wheel_down(WINDOW_ACTIVE) : __mouse_wheel_down(); } \ No newline at end of file diff --git a/scripts/theme_definition/theme_definition.gml b/scripts/theme_definition/theme_definition.gml index a61ba317a..3421c461c 100644 --- a/scripts/theme_definition/theme_definition.gml +++ b/scripts/theme_definition/theme_definition.gml @@ -513,7 +513,7 @@ function ThemeColor() constructor { panel_animation_dope_blend_default = merge_color(CDEF.blue, CDEF.main_dkblack, 0.5); panel_animation_dope_blend = CDEF.main_dkblack; - panel_bg_clear_inner = CDEF.main_dkblack; + panel_bg_clear_inner = CDEF.main_mdblack; panel_bg_clear = CDEF.main_black; panel_frame = CDEF.main_dkgrey; panel_prop_bg = CDEF.main_ltgrey; diff --git a/scripts/windowManager/windowManager.gml b/scripts/windowManager/windowManager.gml index e8b81693e..635b62db4 100644 --- a/scripts/windowManager/windowManager.gml +++ b/scripts/windowManager/windowManager.gml @@ -27,7 +27,7 @@ function winManInit() { #region window_preminimize_rect = [ 0, 0, 1, 1 ]; } #endregion -function winMan_getData(curr = true) { #region +function winMan_getData(curr = true) { INLINE var _monitors = display_measure_all(); if(!is_array(_monitors) || array_empty(_monitors)) @@ -52,23 +52,23 @@ function winMan_getData(curr = true) { #region } return _monitors[0]; -} #endregion +} -function winMan_setRect(_x, _y, _w, _h) { #region +function winMan_setRect(_x, _y, _w, _h) { INLINE _w = max(window_min_w, _w); _h = max(window_min_h, _h); window_set_rectangle(_x, _y, _w, _h); -} #endregion +} -function winMan_isMinimized() { #region +function winMan_isMinimized() { INLINE if(OS == os_macosx) return false; return gameframe_is_natively_minimized(); -} #endregion +} -function winMan_Maximize() { #region +function winMan_Maximize() { INLINE if(gameframe_is_natively_minimized()) return; window_is_maximized = true; @@ -76,9 +76,9 @@ function winMan_Maximize() { #region var _mon = winMan_getData(); winMan_setRect(_mon[4], _mon[5], _mon[6], _mon[7]); gameframe_set_shadow(false); -} #endregion +} -function winMan_Unmaximize() { #region +function winMan_Unmaximize() { INLINE if(gameframe_is_natively_minimized()) return; window_is_maximized = false; @@ -92,15 +92,15 @@ function winMan_Unmaximize() { #region window_minimize_size[1] ); gameframe_set_shadow(true); -} #endregion +} -function winMan_Minimize() { #region +function winMan_Minimize() { INLINE if(gameframe_is_natively_minimized()) return; gameframe_syscommand(61472); -} #endregion +} -function winMan_initDrag(_index) { #region +function winMan_initDrag(_index) { window_drag_status = _index; window_drag_hold = 0; window_drag_mx = mouse_raw_x; @@ -109,9 +109,9 @@ function winMan_initDrag(_index) { #region window_drag_sy = window_get_y(); window_drag_sw = window_get_width(); window_drag_sh = window_get_height(); -} #endregion +} -function winMan_setFullscreen(full) { #region +function winMan_setFullscreen(full) { if(full == window_is_fullscreen) return; window_is_fullscreen = full; @@ -125,9 +125,9 @@ function winMan_setFullscreen(full) { #region } run_in(5, function() { DISPLAY_REFRESH }); -} #endregion +} -function winManStep() { #region +function winManStep() { if(OS == os_macosx) { if(__win_to_dock) { _window_set_showborder(window_handle(), true); @@ -214,9 +214,9 @@ function winManStep() { #region window_minimize_size = [ sw, sh ]; window_drag_status = 0; } -} #endregion +} -function winManDraw() { #region +function winManDraw() { if(window_is_maximized || window_is_fullscreen) return; var pd = window_resize_padding; @@ -269,4 +269,4 @@ function winManDraw() { #region if(hv > -1 && mouse_press(mb_left)) winMan_initDrag(hv); -} #endregion \ No newline at end of file +} \ No newline at end of file diff --git a/scripts/winwin_extras/winwin_extras.gml b/scripts/winwin_extras/winwin_extras.gml index 53d799f29..e6ac9b633 100644 --- a/scripts/winwin_extras/winwin_extras.gml +++ b/scripts/winwin_extras/winwin_extras.gml @@ -20,3 +20,21 @@ function winwin_config() constructor { static owner = undefined; } +#macro __ww_valid (ww != noone && winwin_exists(ww)) + +function winwin_get_x_safe(ww) { return __ww_valid? winwin_get_x(ww) : window_get_x(); } +function winwin_get_y_safe(ww) { return __ww_valid? winwin_get_y(ww) : window_get_y(); } + +function winwin_get_width_safe(ww) { return __ww_valid? winwin_get_width(ww) : window_get_width(); } +function winwin_get_height_safe(ww) { return __ww_valid? winwin_get_height(ww) : window_get_height(); } + +function winwin_set_position_safe(ww, _x, _y) { if(__ww_valid) winwin_set_position(ww, _x, _y); } +function winwin_set_size_safe(ww, _w, _h) { if(__ww_valid) winwin_set_size(ww, _w, _h); } + +function winwin_mouse_get_x_safe(ww) { return __ww_valid? winwin_mouse_get_x(ww) : device_mouse_x_to_gui(0); } +function winwin_mouse_get_y_safe(ww) { return __ww_valid? winwin_mouse_get_y(ww) : device_mouse_y_to_gui(0); } + +function winwin_mouse_is_over_safe(ww) { return __ww_valid? winwin_mouse_is_over(ww) : false; } +function winwin_mouse_check_button_safe(ww, bb) { return __ww_valid? winwin_mouse_check_button(ww, bb) : mouse_check_button(bb); } +function winwin_mouse_check_button_pressed_safe(ww, bb) { return __ww_valid? winwin_mouse_check_button_pressed(ww, bb) : mouse_check_button_pressed(bb); } +function winwin_mouse_check_button_released_safe(ww, bb) { return __ww_valid? winwin_mouse_check_button_released(ww, bb) : mouse_check_button_released(bb); } \ No newline at end of file