From 68cc32252c613ac41bb8efe90ecdd236be33494e Mon Sep 17 00:00:00 2001 From: Tanasart Date: Tue, 28 Nov 2023 12:50:54 +0700 Subject: [PATCH] WinMan --- PixelComposer.resource_order | 4 +- PixelComposer.yyp | 6 +- objects/o_crash_handler/Create_0.gml | 3 - objects/o_crash_handler/Draw_64.gml | 2 - objects/o_main/Create_0.gml | 22 +- objects/o_main/Draw_64.gml | 32 +- objects/o_main/Draw_75.gml | 2 +- objects/o_main/Step_0.gml | 3 +- objects/o_main/Step_1.gml | 9 +- scripts/__surface/__surface.gml | 18 + .../addon_lua_function/addon_lua_function.gml | 3 +- scripts/append_function/append_function.gml | 2 + scripts/display_refresh/display_refresh.gml | 6 +- scripts/gameframe/Gameframe.yy._ | 0 scripts/gameframe/gameframe.gml | 1335 ----------------- scripts/gameframe_macros/gameframe_macros.gml | 36 - scripts/gameframe_macros/gameframe_macros.yy | 11 - scripts/globals/globals.gml | 6 +- scripts/mac_window_init/mac_window_init.gml | 4 +- scripts/mac_window_step/mac_window_step.gml | 4 +- scripts/node_path/node_path.gml | 1 + scripts/node_path_array/node_path_array.gml | 17 +- .../node_path_builder/node_path_builder.gml | 3 + .../node_render_sprite_sheet.gml | 2 +- scripts/node_scatter/node_scatter.gml | 101 +- scripts/panel_graph/panel_graph.gml | 39 +- scripts/panel_menu/panel_menu.gml | 90 +- scripts/preferences/preferences.gml | 11 +- scripts/windowManager/windowManager.gml | 233 +++ .../windowManager.yy} | 6 +- 30 files changed, 450 insertions(+), 1561 deletions(-) delete mode 100644 scripts/gameframe/Gameframe.yy._ delete mode 100644 scripts/gameframe/gameframe.gml delete mode 100644 scripts/gameframe_macros/gameframe_macros.gml delete mode 100644 scripts/gameframe_macros/gameframe_macros.yy create mode 100644 scripts/windowManager/windowManager.gml rename scripts/{gameframe/gameframe.yy => windowManager/windowManager.yy} (56%) diff --git a/PixelComposer.resource_order b/PixelComposer.resource_order index 3601175ba..61ab066c7 100644 --- a/PixelComposer.resource_order +++ b/PixelComposer.resource_order @@ -291,6 +291,7 @@ {"name":"s_node_frame","order":1,"path":"sprites/s_node_frame/s_node_frame.yy",}, {"name":"node_active_canvas","order":22,"path":"scripts/node_active_canvas/node_active_canvas.yy",}, {"name":"s_node_fluidSim_turbulence","order":10,"path":"sprites/s_node_fluidSim_turbulence/s_node_fluidSim_turbulence.yy",}, + {"name":"windowManager","order":1,"path":"scripts/windowManager/windowManager.yy",}, {"name":"node_pb_fx_hash","order":7,"path":"scripts/node_pb_fx_hash/node_pb_fx_hash.yy",}, {"name":"sh_pb_draw_mask","order":8,"path":"shaders/sh_pb_draw_mask/sh_pb_draw_mask.yy",}, {"name":"node_blur_radial","order":7,"path":"scripts/node_blur_radial/node_blur_radial.yy",}, @@ -1032,6 +1033,7 @@ {"name":"node_3d_uv_remap","order":5,"path":"scripts/node_3d_uv_remap/node_3d_uv_remap.yy",}, {"name":"fd_rectangle_get_initial_value_pressure","order":7,"path":"scripts/fd_rectangle_get_initial_value_pressure/fd_rectangle_get_initial_value_pressure.yy",}, {"name":"node_timeline_preview","order":2,"path":"scripts/node_timeline_preview/node_timeline_preview.yy",}, + {"name":"display_measure","order":2,"path":"extensions/display_measure/display_measure.yy",}, {"name":"__polygon","order":2,"path":"scripts/__polygon/__polygon.yy",}, {"name":"o_dialog_fontscrollbox","order":5,"path":"objects/o_dialog_fontscrollbox/o_dialog_fontscrollbox.yy",}, {"name":"sh_d3d_normal_blur","order":25,"path":"shaders/sh_d3d_normal_blur/sh_d3d_normal_blur.yy",}, @@ -1040,7 +1042,6 @@ {"name":"node_fluid_render_output","order":11,"path":"scripts/node_fluid_render_output/node_fluid_render_output.yy",}, {"name":"s_node_vfx_output","order":11,"path":"sprites/s_node_vfx_output/s_node_vfx_output.yy",}, {"name":"sh_greyscale","order":13,"path":"shaders/sh_greyscale/sh_greyscale.yy",}, - {"name":"gameframe_native","order":2,"path":"extensions/gameframe_native/gameframe_native.yy",}, {"name":"s_node_pb_box_mirror","order":21,"path":"sprites/s_node_pb_box_mirror/s_node_pb_box_mirror.yy",}, {"name":"__node_shader_generator","order":22,"path":"scripts/__node_shader_generator/__node_shader_generator.yy",}, {"name":"node_global","order":3,"path":"scripts/node_global/node_global.yy",}, @@ -1452,7 +1453,6 @@ {"name":"draw_set_blend_mode","order":1,"path":"scripts/draw_set_blend_mode/draw_set_blend_mode.yy",}, {"name":"d3d_gizmo_line_dashed","order":3,"path":"scripts/d3d_gizmo_line_dashed/d3d_gizmo_line_dashed.yy",}, {"name":"s_node_3d_camera_set","order":24,"path":"sprites/s_node_3d_camera_set/s_node_3d_camera_set.yy",}, - {"name":"gameframe_macros","order":1,"path":"scripts/gameframe_macros/gameframe_macros.yy",}, {"name":"s_node_trigger_bool","order":4,"path":"sprites/s_node_trigger_bool/s_node_trigger_bool.yy",}, {"name":"panel_color","order":1,"path":"scripts/panel_color/panel_color.yy",}, {"name":"s_copy","order":3,"path":"sprites/s_copy/s_copy.yy",}, diff --git a/PixelComposer.yyp b/PixelComposer.yyp index 417c37b11..bc254bf73 100644 --- a/PixelComposer.yyp +++ b/PixelComposer.yyp @@ -39,7 +39,7 @@ {"resourceType":"GMFolder","resourceVersion":"1.0","name":"CRUD","folderPath":"folders/_extensions/FireBase/Firebase Firestore/Testing/CRUD.yy",}, {"resourceType":"GMFolder","resourceVersion":"1.0","name":"Query","folderPath":"folders/_extensions/FireBase/Firebase Firestore/Testing/Query.yy",}, {"resourceType":"GMFolder","resourceVersion":"1.0","name":"Firebase Utils","folderPath":"folders/_extensions/FireBase/Firebase Utils.yy",}, - {"resourceType":"GMFolder","resourceVersion":"1.0","name":"Gameframe","folderPath":"folders/_extensions/Gameframe.yy",}, + {"resourceType":"GMFolder","resourceVersion":"1.0","name":"WinMan","folderPath":"folders/_extensions/WinMan.yy",}, {"resourceType":"GMFolder","resourceVersion":"1.0","name":"GMD3D11","folderPath":"folders/_extensions/GMD3D11.yy",}, {"resourceType":"GMFolder","resourceVersion":"1.0","name":"MAC","folderPath":"folders/_extensions/MAC.yy",}, {"resourceType":"GMFolder","resourceVersion":"1.0","name":"patreon","folderPath":"folders/_extensions/patreon.yy",}, @@ -862,6 +862,7 @@ {"id":{"name":"s_node_frame","path":"sprites/s_node_frame/s_node_frame.yy",},}, {"id":{"name":"node_active_canvas","path":"scripts/node_active_canvas/node_active_canvas.yy",},}, {"id":{"name":"s_node_fluidSim_turbulence","path":"sprites/s_node_fluidSim_turbulence/s_node_fluidSim_turbulence.yy",},}, + {"id":{"name":"windowManager","path":"scripts/windowManager/windowManager.yy",},}, {"id":{"name":"node_pb_fx_hash","path":"scripts/node_pb_fx_hash/node_pb_fx_hash.yy",},}, {"id":{"name":"sh_pb_draw_mask","path":"shaders/sh_pb_draw_mask/sh_pb_draw_mask.yy",},}, {"id":{"name":"node_blur_radial","path":"scripts/node_blur_radial/node_blur_radial.yy",},}, @@ -1707,6 +1708,7 @@ {"id":{"name":"node_3d_uv_remap","path":"scripts/node_3d_uv_remap/node_3d_uv_remap.yy",},}, {"id":{"name":"fd_rectangle_get_initial_value_pressure","path":"scripts/fd_rectangle_get_initial_value_pressure/fd_rectangle_get_initial_value_pressure.yy",},}, {"id":{"name":"node_timeline_preview","path":"scripts/node_timeline_preview/node_timeline_preview.yy",},}, + {"id":{"name":"display_measure","path":"extensions/display_measure/display_measure.yy",},}, {"id":{"name":"__polygon","path":"scripts/__polygon/__polygon.yy",},}, {"id":{"name":"sh_morph_surface","path":"shaders/sh_morph_surface/sh_morph_surface.yy",},}, {"id":{"name":"o_dialog_fontscrollbox","path":"objects/o_dialog_fontscrollbox/o_dialog_fontscrollbox.yy",},}, @@ -2188,7 +2190,6 @@ {"id":{"name":"draw_set_blend_mode","path":"scripts/draw_set_blend_mode/draw_set_blend_mode.yy",},}, {"id":{"name":"d3d_gizmo_line_dashed","path":"scripts/d3d_gizmo_line_dashed/d3d_gizmo_line_dashed.yy",},}, {"id":{"name":"s_node_3d_camera_set","path":"sprites/s_node_3d_camera_set/s_node_3d_camera_set.yy",},}, - {"id":{"name":"gameframe_macros","path":"scripts/gameframe_macros/gameframe_macros.yy",},}, {"id":{"name":"s_node_trigger_bool","path":"sprites/s_node_trigger_bool/s_node_trigger_bool.yy",},}, {"id":{"name":"panel_color","path":"scripts/panel_color/panel_color.yy",},}, {"id":{"name":"s_copy","path":"sprites/s_copy/s_copy.yy",},}, @@ -2539,7 +2540,6 @@ {"id":{"name":"node_shadow_cast","path":"scripts/node_shadow_cast/node_shadow_cast.yy",},}, {"id":{"name":"node_strand_render","path":"scripts/node_strand_render/node_strand_render.yy",},}, {"id":{"name":"s_node_3d_obj_combine","path":"sprites/s_node_3d_obj_combine/s_node_3d_obj_combine.yy",},}, - {"id":{"name":"gameframe","path":"scripts/gameframe/gameframe.yy",},}, {"id":{"name":"s_node_wav_file_read","path":"sprites/s_node_wav_file_read/s_node_wav_file_read.yy",},}, {"id":{"name":"o_dialog_assetbox","path":"objects/o_dialog_assetbox/o_dialog_assetbox.yy",},}, {"id":{"name":"node_lerp","path":"scripts/node_lerp/node_lerp.yy",},}, diff --git a/objects/o_crash_handler/Create_0.gml b/objects/o_crash_handler/Create_0.gml index e9e205bb5..9d6c523b6 100644 --- a/objects/o_crash_handler/Create_0.gml +++ b/objects/o_crash_handler/Create_0.gml @@ -1,7 +1,4 @@ /// @description -gameframe_init(); -gameframe_button_array = []; - #region setup window_set_size(640, 480); display_set_gui_size(640, 480); diff --git a/objects/o_crash_handler/Draw_64.gml b/objects/o_crash_handler/Draw_64.gml index 5f5a0d785..99ff67b52 100644 --- a/objects/o_crash_handler/Draw_64.gml +++ b/objects/o_crash_handler/Draw_64.gml @@ -1,6 +1,4 @@ /// @description -gameframe_update(); - draw_clear(#1c1c23); var w = 640; var h = 480; diff --git a/objects/o_main/Create_0.gml b/objects/o_main/Create_0.gml index e8c7cd486..e0b5d99a8 100644 --- a/objects/o_main/Create_0.gml +++ b/objects/o_main/Create_0.gml @@ -14,17 +14,7 @@ window_set_min_width(960); window_set_min_height(600); - if(OS == os_windows) { - gameframe_init(); - gameframe_set_cursor = false; - gameframe_caption_height_normal = ui(40); - gameframe_caption_height_maximized = ui(40); - - gameframe_button_array = [ - game_frame_button_create("", s_kenney, 0, function() {}), - game_frame_button_create("", s_kenney, 0, function() {}), - ]; - } else if(OS == os_macosx) + if(OS == os_macosx) mac_window_init(); depth = 0; @@ -57,9 +47,6 @@ panelInit(); - //show_debug_overlay(true); - //display_set_timing_method(tm_sleep); - addHotkey("", "New file", "N", MOD_KEY.ctrl, NEW); if(!DEMO) { addHotkey("", "Save", "S", MOD_KEY.ctrl, SAVE ); @@ -76,12 +63,7 @@ addHotkey("", "Open notification", vk_f12, MOD_KEY.none, function() { dialogPanelCall(new Panel_Notification()); }); - addHotkey("", "Fullscreen", vk_f11, MOD_KEY.none, function() { - if(gameframe_is_fullscreen_window()) - gameframe_set_fullscreen(0); - else - gameframe_set_fullscreen(2); - }); + addHotkey("", "Fullscreen", vk_f11, MOD_KEY.none, function() { winMan_setFullscreen(!window_is_fullscreen); }); addHotkey("", "Render all", vk_f5, MOD_KEY.none, function() { RENDER_ALL_REORDER }); diff --git a/objects/o_main/Draw_64.gml b/objects/o_main/Draw_64.gml index 4ab4bc59a..e871c267f 100644 --- a/objects/o_main/Draw_64.gml +++ b/objects/o_main/Draw_64.gml @@ -1,13 +1,11 @@ /// @description init draw_clear(COLORS.bg); -#region gameframe - if(OS == os_windows && gameframe_is_minimized()) { - //gameframe_update(); +#region windows init + if(OS == os_windows && winMan_isMinimized()) exit; - } else if(OS == os_macosx) { + else if(OS == os_macosx) mac_window_step(); - } #endregion #region widget scroll @@ -45,8 +43,6 @@ draw_clear(COLORS.bg); } panelDraw(); - - gameframe_update(); #endregion #region notes @@ -55,25 +51,5 @@ draw_clear(COLORS.bg); #endregion #region window - var pd = gameframe_resize_padding; - - if(mouse_mx > 0 && mouse_mx < pd && mouse_my > 0 && mouse_my < WIN_H) - CURSOR = cr_size_we; - if(mouse_mx > WIN_W - pd && mouse_mx < WIN_W && mouse_my > 0 && mouse_my < WIN_H) - CURSOR = cr_size_we; - - if(mouse_mx > 0 && mouse_mx < WIN_W && mouse_my > 0 && mouse_my < pd) - CURSOR = cr_size_ns; - if(mouse_mx > 0 && mouse_mx < WIN_W && mouse_my > WIN_H - pd && mouse_my < WIN_H) - CURSOR = cr_size_ns; - - if(mouse_mx > 0 && mouse_mx < pd && mouse_my > 0 && mouse_my < pd) - CURSOR = cr_size_nwse; - if(mouse_mx > WIN_W - pd && mouse_mx < WIN_W && mouse_my > WIN_H - pd && mouse_my < WIN_H) - CURSOR = cr_size_nwse; - - if(mouse_mx > 0 && mouse_mx < pd && mouse_my > WIN_H - pd && mouse_my < WIN_H) - CURSOR = cr_size_nesw; - if(mouse_mx > WIN_W - pd && mouse_mx < WIN_W && mouse_my > 0 && mouse_my < pd) - CURSOR = cr_size_nesw; + winManDraw(); #endregion \ No newline at end of file diff --git a/objects/o_main/Draw_75.gml b/objects/o_main/Draw_75.gml index 0399d8089..ec73f3d52 100644 --- a/objects/o_main/Draw_75.gml +++ b/objects/o_main/Draw_75.gml @@ -1,5 +1,5 @@ /// @description tooltip filedrop -if(OS == os_windows && gameframe_is_minimized()) exit; +if(OS == os_windows && winMan_isMinimized()) exit; #region tooltip if(is_struct(TOOLTIP)) { diff --git a/objects/o_main/Step_0.gml b/objects/o_main/Step_0.gml index a4248dce6..bf21c196f 100644 --- a/objects/o_main/Step_0.gml +++ b/objects/o_main/Step_0.gml @@ -1,5 +1,6 @@ /// @description init -if(OS == os_windows && gameframe_is_minimized()) exit; +if(OS == os_windows && winMan_isMinimized()) exit; +winManStep() //print("===== Step start ====="); if(PROJECT.active && !PROJECT.safeMode) { #region diff --git a/objects/o_main/Step_1.gml b/objects/o_main/Step_1.gml index 4e392296b..5bfb1f045 100644 --- a/objects/o_main/Step_1.gml +++ b/objects/o_main/Step_1.gml @@ -6,7 +6,7 @@ HOVERING_ELEMENT = _HOVERING_ELEMENT; _HOVERING_ELEMENT = noone; #region minimize - if(OS == os_windows && gameframe_is_minimized()) { + if(OS == os_windows && winMan_isMinimized()) { if(!minimized) game_set_speed(1, gamespeed_fps); minimized = true; @@ -28,13 +28,6 @@ _HOVERING_ELEMENT = noone; } CURSOR = cr_default; - - if(!gameframe_is_minimized() && (win_wp != WIN_W || win_hp != WIN_H) && (WIN_W > 1 && WIN_H > 1)) { - if(!win_resize) CURRENT_PANEL = panelSerialize(); - display_refresh(); - win_resize = true; - } else - win_resize = false; #endregion #region focus diff --git a/scripts/__surface/__surface.gml b/scripts/__surface/__surface.gml index 01726fb46..c0926c137 100644 --- a/scripts/__surface/__surface.gml +++ b/scripts/__surface/__surface.gml @@ -15,6 +15,24 @@ function SurfaceAtlas(surface, _x = 0, _y = 0, rot = 0, sx = 1, sy = 1, blend = oriSurf_w = w; oriSurf_h = h; + static set = function(surface, _x = 0, _y = 0, rot = 0, sx = 1, sy = 1, blend = c_white, alpha = 1) { + INLINE + + self.surface = new Surface(surface); + self.x = _x; + self.y = _y; + self.rotation = rot; + self.sx = sx; + self.sy = sy; + self.blend = blend; + self.alpha = alpha; + + w = surface_get_width_safe(surface); + h = surface_get_height_safe(surface); + + return self; + } + static setOrginalSurface = function(surf) { INLINE diff --git a/scripts/addon_lua_function/addon_lua_function.gml b/scripts/addon_lua_function/addon_lua_function.gml index 5468fe78c..f423442da 100644 --- a/scripts/addon_lua_function/addon_lua_function.gml +++ b/scripts/addon_lua_function/addon_lua_function.gml @@ -358,10 +358,9 @@ [ "window_mouse_set", window_mouse_set ], [ "window_set_caption", window_set_caption ], [ "window_set_colour", window_set_colour ], - [ "window_set_fullscreen", window_set_fullscreen ], + [ "winMan_setFullscreen", winMan_setFullscreen ], [ "window_set_position", window_set_position ], [ "window_set_size", window_set_size ], - [ "gameframe_drag_set_rect", gameframe_drag_set_rect ], [ "window_set_cursor", window_set_cursor ], [ "window_set_min_width", window_set_min_width ], [ "window_set_max_width", window_set_max_width ], diff --git a/scripts/append_function/append_function.gml b/scripts/append_function/append_function.gml index 356efc35c..321c28ecb 100644 --- a/scripts/append_function/append_function.gml +++ b/scripts/append_function/append_function.gml @@ -78,6 +78,8 @@ function __APPEND_MAP(_map, context = PANEL_GRAPH.getCurrentContext()) { #region appended_list[| i].preConnect(); for(var i = 0; i < ds_list_size(appended_list); i++) appended_list[| i].connect(); + for(var i = 0; i < ds_list_size(appended_list); i++) + appended_list[| i].postConnect(); } catch(e) { log_warning("APPEND, connect", exception_print(e)); } diff --git a/scripts/display_refresh/display_refresh.gml b/scripts/display_refresh/display_refresh.gml index 017f3a76d..60dea3815 100644 --- a/scripts/display_refresh/display_refresh.gml +++ b/scripts/display_refresh/display_refresh.gml @@ -1,10 +1,14 @@ -function display_refresh() { +function window_refresh() { o_main.win_wp = WIN_W; o_main.win_hp = WIN_H; room_width = WIN_W; room_height = WIN_H; display_set_gui_size(WIN_SW, WIN_SH); +} + +function display_refresh() { + window_refresh(); clearPanel(); resetPanel(); diff --git a/scripts/gameframe/Gameframe.yy._ b/scripts/gameframe/Gameframe.yy._ deleted file mode 100644 index e69de29bb..000000000 diff --git a/scripts/gameframe/gameframe.gml b/scripts/gameframe/gameframe.gml deleted file mode 100644 index 074ab17ae..000000000 --- a/scripts/gameframe/gameframe.gml +++ /dev/null @@ -1,1335 +0,0 @@ -// Generated at 2022-12-14 10:28:54 (1226ms) for v2.3.7+ -/// @lint nullToAny true -// Feather disable all -#region prototypes -globalvar mq_game_frame_button; mq_game_frame_button = [undefined, /* 1:name */undefined, /* 2:custom */undefined, /* 3:icon */undefined, /* 4:subimg */0, /* 5:margin_left */0, /* 6:margin_right */0, /* 7:hover */undefined, /* 8:pressed */undefined, /* 9:enabled */undefined, /* 10:fade */0, /* 11:click */undefined, /* 12:get_width */0, /* 13:update */undefined, /* 14:draw_underlay */undefined, /* 15:draw_icon */undefined]; -globalvar mq_gameframe_delayed_item; mq_gameframe_delayed_item = [undefined, /* 1:func */undefined, /* 2:time */0, /* 3:arg0 */undefined, /* 4:arg1 */undefined, /* 5:arg2 */undefined, /* 6:arg3 */undefined]; -#endregion -#region metatype -globalvar gameframe_std_haxe_type_markerValue; gameframe_std_haxe_type_markerValue = []; -globalvar mt_game_frame_button; -globalvar mt_gameframe_delayed_item; -globalvar mt_gameframe_std_haxe_class; -(function() { -mt_game_frame_button = new gameframe_std_haxe_class(7, "game_frame_button"); -mt_gameframe_delayed_item = new gameframe_std_haxe_class(8, "gameframe_delayed_item"); -mt_gameframe_std_haxe_class = new gameframe_std_haxe_class(-1, "gameframe_std_haxe_class"); -})(); -#endregion - -#region gameframe - -function gameframe_log(_args1) { - // gameframe_log(args:haxe_Rest) - if (!gameframe_debug) exit; - var _s = "[Gameframe]"; - var __g = 0; - while (__g < argument_count) { - var _arg = argument[__g]; - __g++; - _s += " " + gameframe_std_Std_stringify(_arg); - } - show_debug_message(_s); -} - -function gameframe_update() { - /// gameframe_update() - /// @returns {void} - if (!gameframe_is_ready) exit; - gameframe_effective_scale = display_get_dpi_x() / 96 / gameframe_dpi_scale; - gameframe_mouse_over_frame = false; - gameframe_delayed_update(); - gameframe_cover_ensure(); - if (window_get_fullscreen() || gameframe_isFullscreen_hx) { - gameframe_tools_keyctl_reset(); - exit; - } - gameframe_tools_keyctl_update(); - if (!gameframe_isMaximized_hx && gameframe_has_native_extension && gameframe_delayed_frame_index > 3 && !gameframe_get_shadow()) gameframe_set_shadow(true); - var _mx = (window_mouse_get_x() | 0); - var _my = (window_mouse_get_y() | 0); - var _gw = window_get_width(); - var _gh = window_get_height(); - var __borderWidth = (gameframe_isMaximized_hx ? 0 : gameframe_border_width); - var __titleHeight = gameframe_caption_get_height(); - var __buttons_x = gameframe_button_get_combined_offset(_gw); - var __flags = 0; - var __titleHit = false; - var __hitSomething = true; - var _resizePadding = gameframe_resize_padding; - if (!point_in_rectangle(_mx, _my, __buttons_x, __borderWidth, _gw - __borderWidth - ((gameframe_isMaximized_hx ? 0 : _resizePadding)), __borderWidth + __titleHeight)) { - if (!gameframe_isMaximized_hx && gameframe_can_resize && !point_in_rectangle(_mx, _my, _resizePadding, _resizePadding, _gw - _resizePadding, _gh - _resizePadding)) { - if (_mx < _resizePadding) __flags |= 1; - if (_my < _resizePadding) __flags |= 2; - if (_mx >= _gw - _resizePadding) __flags |= 4; - if (_my >= _gh - _resizePadding) __flags |= 8; - } else if (point_in_rectangle(_mx, _my, 0, 0, _gw, __titleHeight)) { - __titleHit = true; - } else __hitSomething = false; - } - gameframe_mouse_over_frame = __hitSomething; - if (gameframe_drag_flags == 0) { - var __cursor = gameframe_default_cursor; - if (gameframe_can_input && gameframe_can_resize) switch (__flags) { - case 1: case 4: __cursor = cr_size_we; break; - case 2: case 8: __cursor = cr_size_ns; break; - case 3: case 12: __cursor = cr_size_nwse; break; - case 6: case 9: __cursor = cr_size_nesw; break; - } - gameframe_set_window_cursor(__cursor); - } - gameframe_button_update(__buttons_x, __borderWidth, __titleHeight, _mx, _my); - if (gameframe_can_input && mouse_check_button_pressed(1)) { - if (__titleHit) { - var __now = current_time; - if (__now < gameframe_last_title_click_at + gameframe_double_click_time) { - //if (gameframe_isMaximized_hx) gameframe_restore(); else gameframe_maximize(); - } else { - gameframe_last_title_click_at = __now; - if (gameframe_isMaximized_hx) { - gameframe_drag_start(32); - } else { - gameframe_drag_start(16); - } - } - } else if (__flags != 0 && gameframe_can_resize) { - gameframe_drag_start(__flags); - } - } - if (gameframe_can_input) { - if (mouse_check_button_released(1)) gameframe_drag_stop(); else gameframe_drag_update(); - } else if (gameframe_drag_flags != 0) { - gameframe_drag_stop(); - } -} - -function gameframe_init() { - /// gameframe_init() - /// @returns {void} - gameframe_is_ready = true; - gameframe_has_native_extension = gameframe_check_native_extension(); - gameframe_double_click_time = (gameframe_has_native_extension ? gameframe_get_double_click_time() : 500); - gameframe_init_native(); - gameframe_tools_rect_get_window_rect(gameframe_restoreRect_hx); - gameframe_button_add_defaults(); - gameframe_set_shadow(true); -} - -#endregion - -#region game_frame_button - -function game_frame_button_create(_name, _icon, _subimg, _onClick) { - /// game_frame_button_create(name:string, icon:sprite, subimg:int, onClick:function) - /// @param {string} name - /// @param {sprite} icon - /// @param {int} subimg - /// @param {function} onClick - /// @returns {game_frame_button} - var _this = [mt_game_frame_button]; - array_copy(_this, 1, mq_game_frame_button, 1, 15); - /// @typedef {tuple,get_width:function,update:function,draw_underlay:function,draw_icon:function>} game_frame_button - _this[@15/* draw_icon */] = game_frame_button_draw_icon_default; - _this[@14/* draw_underlay */] = game_frame_button_draw_underlay_default; - _this[@13/* update */] = game_frame_button_update_default; - _this[@12/* get_width */] = game_frame_button_get_width_default; - _this[@10/* fade */] = 0.; - _this[@9/* enabled */] = true; - _this[@8/* pressed */] = false; - _this[@7/* hover */] = false; - _this[@6/* margin_right */] = 0; - _this[@5/* margin_left */] = 0; - _this[@1/* name */] = _name; - _this[@3/* icon */] = _icon; - _this[@4/* subimg */] = _subimg; - _this[@11/* click */] = _onClick; - return _this; -} - -function game_frame_button_get_width_default(_b) { - // game_frame_button_get_width_default(b:game_frame_button)->int - return sprite_get_width(_b[3/* icon */]); -} - -function game_frame_button_update_default(_b) { - // game_frame_button_update_default(b:game_frame_button) - -} - -function game_frame_button_draw_underlay_default(_b, _x, _y, _width, _height) { - // game_frame_button_draw_underlay_default(b:game_frame_button, x:number, y:number, width:number, height:number) - var _alpha1; - if (_b[9/* enabled */]) { - if (_b[8/* pressed */]) { - _alpha1 = 0.7; - _b[@10/* fade */] = 1; - } else { - var _dt = delta_time / 1000000; - if (_b[7/* hover */]) { - if (_b[10/* fade */] < 1) _b[@10/* fade */] = min(_b[10/* fade */] + _dt / gameframe_button_fade_time, 1); - } else if (_b[10/* fade */] > 0) { - _b[@10/* fade */] = max(_b[10/* fade */] - _dt / gameframe_button_fade_time, 0); - } - _alpha1 = _b[10/* fade */] * 0.3; - } - } else _alpha1 = 0.; - draw_sprite_stretched_ext(gameframe_spr_pixel, 0, _x, _y, _width, _height, gameframe_blend, gameframe_alpha * _alpha1); -} - -function game_frame_button_draw_icon_default(_b, _x, _y, _width, _height) { - // game_frame_button_draw_icon_default(b:game_frame_button, x:number, y:number, width:number, height:number) - var _icon = _b[3/* icon */]; - var _scale = gameframe_effective_scale; - draw_sprite_ext(_icon, _b[4/* subimg */], (_x + ((_width - sprite_get_width(_icon) * _scale) div 2) + (sprite_get_xoffset(_icon) * _scale | 0)), _y + ((_height - sprite_get_height(_icon) * _scale) div 2) + (sprite_get_yoffset(_icon) * _scale | 0), _scale, _scale, 0, gameframe_blend, gameframe_alpha * ((_b[9/* enabled */] ? 1 : 0.3))); -} - -function game_frame_button_set_name(_this, _value) { - /// game_frame_button_set_name(this:game_frame_button, value:string) - /// @param {game_frame_button} this - /// @param {string} value - /// @returns {void} - _this[@1/* name */] = _value; -} - -function game_frame_button_get_name(_this) { - /// game_frame_button_get_name(this:game_frame_button)->string - /// @param {game_frame_button} this - /// @returns {string} - return _this[1/* name */]; -} - -function game_frame_button_set_custom(_this, _value) { - /// game_frame_button_set_custom(this:game_frame_button, value:any) - /// @param {game_frame_button} this - /// @param {any} value - /// @returns {void} - _this[@2/* custom */] = _value; -} - -function game_frame_button_get_custom(_this) { - /// game_frame_button_get_custom(this:game_frame_button)->any - /// @param {game_frame_button} this - /// @returns {any} - return _this[2/* custom */]; -} - -function game_frame_button_set_icon(_this, _value) { - /// game_frame_button_set_icon(this:game_frame_button, value:sprite) - /// @param {game_frame_button} this - /// @param {sprite} value - /// @returns {void} - _this[@3/* icon */] = _value; -} - -function game_frame_button_get_icon(_this) { - /// game_frame_button_get_icon(this:game_frame_button)->sprite - /// @param {game_frame_button} this - /// @returns {sprite} - return _this[3/* icon */]; -} - -function game_frame_button_set_subimg(_this, _value) { - /// game_frame_button_set_subimg(this:game_frame_button, value:int) - /// @param {game_frame_button} this - /// @param {int} value - /// @returns {void} - _this[@4/* subimg */] = _value; -} - -function game_frame_button_get_subimg(_this) { - /// game_frame_button_get_subimg(this:game_frame_button)->int - /// @param {game_frame_button} this - /// @returns {int} - return _this[4/* subimg */]; -} - -function game_frame_button_set_margin_left(_this, _value) { - /// game_frame_button_set_margin_left(this:game_frame_button, value:int) - /// @param {game_frame_button} this - /// @param {int} value - /// @returns {void} - _this[@5/* margin_left */] = _value; -} - -function game_frame_button_get_margin_left(_this) { - /// game_frame_button_get_margin_left(this:game_frame_button)->int - /// @param {game_frame_button} this - /// @returns {int} - return _this[5/* margin_left */]; -} - -function game_frame_button_set_margin_right(_this, _value) { - /// game_frame_button_set_margin_right(this:game_frame_button, value:int) - /// @param {game_frame_button} this - /// @param {int} value - /// @returns {void} - _this[@6/* margin_right */] = _value; -} - -function game_frame_button_get_margin_right(_this) { - /// game_frame_button_get_margin_right(this:game_frame_button)->int - /// @param {game_frame_button} this - /// @returns {int} - return _this[6/* margin_right */]; -} - -function game_frame_button_set_hover(_this, _value) { - /// game_frame_button_set_hover(this:game_frame_button, value:bool) - /// @param {game_frame_button} this - /// @param {bool} value - /// @returns {void} - _this[@7/* hover */] = _value; -} - -function game_frame_button_get_hover(_this) { - /// game_frame_button_get_hover(this:game_frame_button)->bool - /// @param {game_frame_button} this - /// @returns {bool} - return _this[7/* hover */]; -} - -function game_frame_button_set_pressed(_this, _value) { - /// game_frame_button_set_pressed(this:game_frame_button, value:bool) - /// @param {game_frame_button} this - /// @param {bool} value - /// @returns {void} - _this[@8/* pressed */] = _value; -} - -function game_frame_button_get_pressed(_this) { - /// game_frame_button_get_pressed(this:game_frame_button)->bool - /// @param {game_frame_button} this - /// @returns {bool} - return _this[8/* pressed */]; -} - -function game_frame_button_set_enabled(_this, _value) { - /// game_frame_button_set_enabled(this:game_frame_button, value:bool) - /// @param {game_frame_button} this - /// @param {bool} value - /// @returns {void} - _this[@9/* enabled */] = _value; -} - -function game_frame_button_get_enabled(_this) { - /// game_frame_button_get_enabled(this:game_frame_button)->bool - /// @param {game_frame_button} this - /// @returns {bool} - return _this[9/* enabled */]; -} - -function game_frame_button_set_fade(_this, _value) { - /// game_frame_button_set_fade(this:game_frame_button, value:number) - /// @param {game_frame_button} this - /// @param {number} value - /// @returns {void} - _this[@10/* fade */] = _value; -} - -function game_frame_button_get_fade(_this) { - /// game_frame_button_get_fade(this:game_frame_button)->number - /// @param {game_frame_button} this - /// @returns {number} - return _this[10/* fade */]; -} - -function game_frame_button_set_click(_this, _value) { - /// game_frame_button_set_click(this:game_frame_button, value:function) - /// @param {game_frame_button} this - /// @param {function} value - /// @returns {void} - _this[@11/* click */] = _value; -} - -function game_frame_button_get_click(_this) { - /// game_frame_button_get_click(this:game_frame_button)->function - /// @param {game_frame_button} this - /// @returns {function} - return _this[11/* click */]; -} - -function game_frame_button_set_get_width(_this, _value) { - /// game_frame_button_set_get_width(this:game_frame_button, value:function) - /// @param {game_frame_button} this - /// @param {function} value - /// @returns {void} - _this[@12/* get_width */] = _value; -} - -function game_frame_button_get_get_width(_this) { - /// game_frame_button_get_get_width(this:game_frame_button)->function - /// @param {game_frame_button} this - /// @returns {function} - return _this[12/* get_width */]; -} - -function game_frame_button_set_update(_this, _value) { - /// game_frame_button_set_update(this:game_frame_button, value:function) - /// @param {game_frame_button} this - /// @param {function} value - /// @returns {void} - _this[@13/* update */] = _value; -} - -function game_frame_button_get_update(_this) { - /// game_frame_button_get_update(this:game_frame_button)->function - /// @param {game_frame_button} this - /// @returns {function} - return _this[13/* update */]; -} - -function game_frame_button_set_draw_underlay(_this, _value) { - /// game_frame_button_set_draw_underlay(this:game_frame_button, value:function) - /// @param {game_frame_button} this - /// @param {function} value - /// @returns {void} - _this[@14/* draw_underlay */] = _value; -} - -function game_frame_button_get_draw_underlay(_this) { - /// game_frame_button_get_draw_underlay(this:game_frame_button)->function - /// @param {game_frame_button} this - /// @returns {function} - return _this[14/* draw_underlay */]; -} - -function game_frame_button_set_draw_icon(_this, _value) { - /// game_frame_button_set_draw_icon(this:game_frame_button, value:function) - /// @param {game_frame_button} this - /// @param {function} value - /// @returns {void} - _this[@15/* draw_icon */] = _value; -} - -function game_frame_button_get_draw_icon(_this) { - /// game_frame_button_get_draw_icon(this:game_frame_button)->function - /// @param {game_frame_button} this - /// @returns {function} - return _this[15/* draw_icon */]; -} - -#endregion - -#region gameframe_button - -function gameframe_button_get_combined_width() { - /// gameframe_button_get_combined_width()->int - /// @returns {int} - var _w = 0; - var __g = 0; - var __g1 = gameframe_button_array; - while (__g < array_length(__g1)) { - var _b = __g1[__g]; - __g++; - _w += _b[5/* margin_left */] + _b[12/* get_width */](_b) + _b[6/* margin_right */]; - } - return ceil(_w * gameframe_effective_scale); -} - -function gameframe_button_get_combined_offset(_windowWidth) { - /// gameframe_button_get_combined_offset(windowWidth:int)->int - /// @param {int} windowWidth - /// @returns {int} - return _windowWidth - ((gameframe_isMaximized_hx ? 0 : gameframe_border_width)) - gameframe_button_get_combined_width(); -} - -function gameframe_button_reset() { - /// gameframe_button_reset() - /// @returns {void} - var __g = 0; - var __g1 = gameframe_button_array; - while (__g < array_length(__g1)) { - var _b = __g1[__g]; - __g++; - _b[@7/* hover */] = false; - _b[@10/* fade */] = 0.; - _b[@8/* pressed */] = false; - } -} - -function gameframe_button_update(_x, _y, _height, _mx, _my) { - // gameframe_button_update(x:number, y:number, height:int, mx:int, my:int) - var _over_row = _mx >= _y && _my < _y + _height; - if (_over_row) { - if (gameframe_has_native_extension) { - _over_row = gameframe_mouse_in_window(); - } else { - var _wx = window_get_x(); - var _wy = window_get_y(); - var _dmx = display_mouse_get_x(); - var _dmy = display_mouse_get_y(); - _over_row = _dmx >= _wx && _dmy >= _wy && _dmx < _wx + window_get_width() && _dmy < _wy + window_get_height(); - } - } - if (gameframe_button_wait_for_movement) { - if (_mx != gameframe_button_wait_for_movement_x || _my != gameframe_button_wait_for_movement_y) gameframe_button_wait_for_movement = false; else _over_row = false; - } - var _dpiScale = gameframe_effective_scale; - var _pressed = mouse_check_button_pressed(1); - var _released = mouse_check_button_released(1); - var _disable = gameframe_drag_flags != 0 || !gameframe_can_input; - var _i = 0; - for (var __g1 = array_length(gameframe_button_array); _i < __g1; _i++) { - var _button = gameframe_button_array[_i]; - _button[13/* update */](_button); - _x += _button[5/* margin_left */] * _dpiScale; - var _width = _button[12/* get_width */](_button) * _dpiScale; - if (_disable || !_button[9/* enabled */]) { - _button[@7/* hover */] = false; - _button[@8/* pressed */] = false; - } else if (_over_row && _mx >= _x && _mx < _x + _width) { - _button[@7/* hover */] = true; - if (_pressed) _button[@8/* pressed */] = true; - } else _button[@7/* hover */] = false; - if (_released && _button[8/* pressed */] && _button[7/* hover */]) { - _button[@8/* pressed */] = false; - _button[11/* click */](_button); - } - _x += _width + _button[6/* margin_right */] * _dpiScale; - } -} - -function gameframe_button_draw(_x, _y, _height) { - // gameframe_button_draw(x:number, y:number, height:int) - var _dpiScale = gameframe_effective_scale; - var _i = 0; - for (var __g1 = array_length(gameframe_button_array); _i < __g1; _i++) { - var _button = gameframe_button_array[_i]; - _x += _button[5/* margin_left */] * _dpiScale; - var _width = _button[12/* get_width */](_button) * _dpiScale; - _button[14/* draw_underlay */](_button, _x, _y, _width, _height); - _button[15/* draw_icon */](_button, _x, _y, _width, _height); - _x += _width + _button[6/* margin_right */] * _dpiScale; - } -} - -function gameframe_button_add_defaults() { - // gameframe_button_add_defaults() - gameframe_button_array = []; - var _minimize = game_frame_button_create("minimize", gameframe_spr_buttons, 0, function(_button) { - gameframe_minimize() - }); - if (!gameframe_has_native_extension) _minimize[@9/* enabled */] = false; - array_push(gameframe_button_array, _minimize); - var _maxrest = game_frame_button_create("maxrest", gameframe_spr_buttons, 1, function(_button) { - if (gameframe_isMaximized_hx) gameframe_restore(); else gameframe_maximize(); - gameframe_button_reset(); - }); - _maxrest[@13/* update */] = function(_b) { - _b[@4/* subimg */] = (gameframe_isMaximized_hx ? 2 : 1); - _b[@9/* enabled */] = gameframe_can_resize; - } - array_push(gameframe_button_array, _maxrest); - var _close = game_frame_button_create("close", gameframe_spr_buttons, 3, function(__) { - game_end() - }); - _close[@14/* draw_underlay */] = function(_b, __x, __y, __width, __height) { - var __alpha = 0.; - if (_b[8/* pressed */]) { - __alpha = 0.7; - _b[@10/* fade */] = 1; - } else { - var _dt = delta_time / 1000000; - if (_b[7/* hover */]) { - if (_b[10/* fade */] < 1) { - _b[@10/* fade */] = max(_b[10/* fade */], 0.5); - _b[@10/* fade */] = min(_b[10/* fade */] + _dt / gameframe_button_fade_time, 1); - } - } else if (_b[10/* fade */] > 0) { - _b[@10/* fade */] = max(_b[10/* fade */] - _dt / gameframe_button_fade_time, 0); - } - __alpha = gameframe_alpha * _b[10/* fade */]; - } - draw_sprite_stretched_ext(gameframe_spr_pixel, 0, __x, __y, __width, __height, 2298344, __alpha); - } - array_push(gameframe_button_array, _close); -} - -#endregion - -#region gameframe_tools_rect - -function gameframe_tools_rect__new(_x, _y, _w, _h) { - // gameframe_tools_rect__new(...:int)->gameframe_tools_rect - _x ??= 0; - _y ??= 0; - _w ??= 0; - _h ??= 0; - if (false) show_debug_message(argument[3]); - return [/* x: */_x, /* y: */_y, /* width: */_w, /* height: */_h]; -} - -function gameframe_tools_rect_get_window_rect(_this1) { - // gameframe_tools_rect_get_window_rect(this:tools_GfRectImpl) - _this1[@0/* x */] = window_get_x(); - _this1[@1/* y */] = window_get_y(); - _this1[@2/* width */] = window_get_width(); - _this1[@3/* height */] = window_get_height(); -} - -function gameframe_tools_rect_set_window_rect(_this1) { - // gameframe_tools_rect_set_window_rect(this:tools_GfRectImpl) - gameframe_drag_set_rect(_this1[0/* x */], _this1[1/* y */], _this1[2/* width */], _this1[3/* height */]); -} - -function gameframe_tools_rect_equals(_this1, _o) { - // gameframe_tools_rect_equals(this:tools_GfRectImpl, o:gameframe_tools_rect)->bool - return _this1[0/* x */] == _o[0/* x */] && _this1[1/* y */] == _o[1/* y */] && _this1[2/* width */] == _o[2/* width */] && _this1[3/* height */] == _o[3/* height */]; -} - -function gameframe_tools_rect_set_to(_this1, _o) { - // gameframe_tools_rect_set_to(this:tools_GfRectImpl, o:gameframe_tools_rect) - _this1[@0/* x */] = _o[0/* x */]; - _this1[@1/* y */] = _o[1/* y */]; - _this1[@2/* width */] = _o[2/* width */]; - _this1[@3/* height */] = _o[3/* height */]; -} - -#endregion - -#region gameframe - -function gameframe_minimize() { - gameframe_drag_flags = 0; - /// gameframe_minimize() - /// @returns {void} - if (gameframe_is_natively_minimized()) exit; - gameframe_button_reset(); - gameframe_delayed_call_impl(function() { - gameframe_button_wait_for_movement = true; - gameframe_button_wait_for_movement_x = window_mouse_get_x(); - gameframe_button_wait_for_movement_y = window_mouse_get_y(); - gameframe_syscommand(61472); - }, 1, undefined, undefined, undefined, undefined); -} - -function gameframe_minimise() { - // gameframe_minimise() - if (!gameframe_is_natively_minimized()) { - gameframe_button_reset(); - gameframe_delayed_call_impl(function() { - gameframe_button_wait_for_movement = true; - gameframe_button_wait_for_movement_x = window_mouse_get_x(); - gameframe_button_wait_for_movement_y = window_mouse_get_y(); - gameframe_syscommand(61472); - }, 1, undefined, undefined, undefined, undefined); - } -} - -function gameframe_is_minimized() { - /// gameframe_is_minimized()->bool - /// @returns {bool} - return gameframe_is_natively_minimized(); -} - -function gameframe_is_minimised() { - // gameframe_is_minimised()->bool - return gameframe_is_natively_minimized(); -} - -function gameframe_maximize() { - /// gameframe_maximize() - /// @returns {void} - if (gameframe_isMaximized_hx || gameframe_isFullscreen_hx || window_get_fullscreen()) exit; - gameframe_isMaximized_hx = true; - gameframe_store_rect(); - gameframe_maximize_1(); -} - -function gameframe_maximise() { - // gameframe_maximise() - if (!(gameframe_isMaximized_hx || gameframe_isFullscreen_hx || window_get_fullscreen())) { - gameframe_isMaximized_hx = true; - gameframe_store_rect(); - gameframe_maximize_1(); - } -} - -function gameframe_is_maximized() { - /// gameframe_is_maximized()->bool - /// @returns {bool} - return gameframe_isMaximized_hx; -} - -function gameframe_is_maximised() { - // gameframe_is_maximised()->bool - return gameframe_isMaximized_hx; -} - -function gameframe_maximize_1() { - // gameframe_maximize_1() - var __work = gameframe_tools_mon_get_active()[1/* workspace */]; - if (gameframe_debug) gameframe_log("maximize: ", __work); - gameframe_tools_rect_set_window_rect(__work); - gameframe_set_shadow(false); -} - -function gameframe_store_rect() { - // gameframe_store_rect() - gameframe_tools_rect_get_window_rect(gameframe_restoreRect_hx); - if (gameframe_debug) gameframe_log("storeRect: ", gameframe_restoreRect_hx); -} - -function gameframe_restore(__force) { - /// gameframe_restore(_force:bool = false) - /// @param {bool} [_force=false] - /// @returns {void} - __force ??= false; - if (false) show_debug_message(argument[0]); - if (window_get_fullscreen()) { - window_set_fullscreen(false); - gameframe_delayed_call_impl(function() { - gameframe_restore() - }, 1, undefined, undefined, undefined, undefined); - exit; - } - if (!__force && !gameframe_isMaximized_hx && !gameframe_isFullscreen_hx) exit; - gameframe_isMaximized_hx = false; - gameframe_isFullscreen_hx = false; - var __rect = gameframe_restoreRect_hx; - if (gameframe_debug) gameframe_log("restore: ", __rect); - gameframe_tools_rect_set_window_rect(__rect); - gameframe_set_shadow(true); -} - -function gameframe_set_fullscreen(_mode) { - /// gameframe_set_fullscreen(mode:int) - /// @param {int} mode - /// @returns {void} - gameframe_set_fullscreen_1(_mode); -} - -function gameframe_get_fullscreen() { - /// gameframe_get_fullscreen()->int - /// @returns {int} - if (window_get_fullscreen()) return 1; - if (gameframe_isFullscreen_hx) return 2; else return 0; -} - -function gameframe_is_fullscreen_window() { - /// gameframe_is_fullscreen_window()->bool - /// @returns {bool} - return !window_get_fullscreen() && gameframe_isFullscreen_hx; -} - -function gameframe_set_fullscreen_1(__mode, __wasFullscreen) { - // gameframe_set_fullscreen_1(_mode:int, _wasFullscreen:bool = false) - if (__wasFullscreen == undefined) __wasFullscreen = false; - if (false) show_debug_message(argument[1]); - if (gameframe_debug) gameframe_log("setFullscreen(mode:", __mode, ", wasfs:", __wasFullscreen, ")"); - if (__mode == 1 || __mode == 2) { - gameframe_button_reset(); - gameframe_drag_stop(); - } - switch (__mode) { - case 1: - if (window_get_fullscreen()) exit; - if (gameframe_isFullscreen_hx) { - gameframe_restore(); - gameframe_delayed_call_impl(function() { - gameframe_set_fullscreen_1(1) - }, 1, undefined, undefined, undefined, undefined); - exit; - } else gameframe_store_rect(); - window_set_fullscreen(true); - break; - case 2: - if (window_get_fullscreen()) { - window_set_fullscreen(false); - gameframe_delayed_call_impl(function() { - gameframe_set_fullscreen_1(2, true) - }, 10, undefined, undefined, undefined, undefined); - exit; - } - if (gameframe_isFullscreen_hx) exit; - gameframe_isFullscreen_hx = true; - if (!gameframe_isMaximized_hx && !__wasFullscreen) gameframe_store_rect(); - gameframe_tools_rect_set_window_rect(gameframe_tools_mon_get_active()[0/* screen */]); - gameframe_set_shadow(false); - break; - default: - if (window_get_fullscreen() && gameframe_isFullscreen_hx) { - window_set_fullscreen(false); - gameframe_delayed_call_impl(function() { - gameframe_set_fullscreen_1(0) - }, 1, undefined, undefined, undefined, undefined); - exit; - } - if (window_get_fullscreen()) { - gameframe_restore(); - } else if (gameframe_isMaximized_hx) { - gameframe_isFullscreen_hx = false; - gameframe_maximize_1(); - } else gameframe_restore(); - } -} - -function gameframe_set_window_cursor(_cr1) { - // gameframe_set_window_cursor(cr:window_cursor) - gameframe_current_cursor = _cr1; - if (gameframe_set_cursor) { - if (window_get_cursor() != _cr1) window_set_cursor(_cr1); - } -} - -function gameframe_get_border_width() { - // gameframe_get_border_width()->int - if (gameframe_isMaximized_hx) return 0; else return gameframe_border_width; -} - -function gameframe_get_drag_flags() { - /// gameframe_get_drag_flags()->int - /// @returns {int} - return gameframe_drag_flags; -} - -#endregion - -#region gameframe_caption - -function gameframe_caption_get_height() { - /// gameframe_caption_get_height()->int - /// @returns {int} - var _h = (gameframe_isMaximized_hx ? gameframe_caption_height_maximized : gameframe_caption_height_normal); - if (_h > 0) return (_h | 0); - return round(-_h * sprite_get_height(gameframe_spr_caption) * gameframe_effective_scale); -} - -function gameframe_caption_get_overlap() { - /// gameframe_caption_get_overlap()->number - /// @returns {number} - if (window_get_fullscreen() || gameframe_isFullscreen_hx) return 0.; - var _h = gameframe_caption_get_height(); - var _rect = application_get_position(); - return max(0, _h - _rect[1]) / ((_rect[2] - _rect[0]) / surface_get_width_safe(application_surface)); -} - -function gameframe_caption_draw_border_default(__x, __y, __width, __height) { - // gameframe_caption_draw_border_default(_x:int, _y:int, _width:int, _height:int) - draw_sprite_stretched_ext(gameframe_spr_border, (window_has_focus() ? 1 : 0), __x, __y, __width, __height, gameframe_blend, gameframe_alpha); -} - -function gameframe_caption_draw_caption_rect_default(__x, __y, __width, __height, __buttons_x) { - // gameframe_caption_draw_caption_rect_default(_x:int, _y:int, _width:int, _height:int, _buttons_x:int) - draw_sprite_stretched_ext(gameframe_spr_caption, (window_has_focus() ? 1 : 0), __x, __y, __width, __height, gameframe_blend, gameframe_alpha * gameframe_caption_alpha); -} - -function gameframe_caption_draw_caption_text_default(__x, __y, __width, __height) { - // gameframe_caption_draw_caption_text_default(_x:number, _y:number, _width:number, _height:int) - var _dpiScale = gameframe_effective_scale; - var __right = __x + __width; - __x += gameframe_caption_margin * _dpiScale; - var _icon = gameframe_caption_icon; - if (_icon != -1) { - draw_sprite_ext(_icon, -1, (__x + sprite_get_xoffset(_icon) * _dpiScale | 0), __y + ((__height - sprite_get_height(_icon) * _dpiScale) div 2) + sprite_get_yoffset(_icon) * _dpiScale, _dpiScale, _dpiScale, 0, 16777215, gameframe_caption_alpha * gameframe_alpha); - __x += (sprite_get_width(_icon) + gameframe_caption_icon_margin) * _dpiScale; - } - var _text = gameframe_caption_text; - if (_text == "") exit; - var __newFont = gameframe_caption_font; - var __h = draw_get_halign(); - var __v = draw_get_valign(); - var __oldFont; - if (__newFont != -1) { - __oldFont = draw_get_font(); - draw_set_font(__newFont); - } else __oldFont = -1; - draw_set_halign(gameframe_caption_text_align); - draw_set_valign(0); - var __alpha = draw_get_alpha(); - var __textWidth = __right - __x; - draw_set_alpha((gameframe_alpha * gameframe_caption_alpha)); - __draw_text_ext_transformed((__x + ((gameframe_caption_text_align * __textWidth) div 2)), __y + ((__height - string_height_ext(_text, -1, __textWidth) * _dpiScale) div 2), _text, -1, __textWidth, _dpiScale, _dpiScale, 0); - draw_set_alpha(__alpha); - if (__newFont != -1) draw_set_font(__oldFont); - draw_set_halign(__h); - draw_set_valign(__v); -} - -#endregion - -#region gameframe_cover - -function gameframe_cover_ensure() { - // gameframe_cover_ensure() - var __just_changed = gameframe_cover_check_for_success; - if (__just_changed) gameframe_cover_check_for_success = false; - var __target_rect; - if (window_get_fullscreen()) { - gameframe_cover_can_ignore = false; - exit; - } else if (gameframe_isFullscreen_hx) { - __target_rect = gameframe_tools_mon_get_active()[0/* screen */]; - } else if (gameframe_isMaximized_hx) { - __target_rect = gameframe_tools_mon_get_active()[1/* workspace */]; - } else { - gameframe_cover_can_ignore = false; - exit; - } - gameframe_tools_rect_get_window_rect(gameframe_cover_curr_rect); - if (!gameframe_tools_rect_equals(gameframe_cover_curr_rect, __target_rect)) { - if (__just_changed) { - gameframe_cover_can_ignore = true; - gameframe_tools_rect_set_to(gameframe_cover_ignore_rect, __target_rect); - if (gameframe_debug) gameframe_log("[cover] Resize failed - ignoring"); - exit; - } - if (gameframe_cover_can_ignore && gameframe_tools_rect_equals(__target_rect, gameframe_cover_ignore_rect)) exit; - if (gameframe_debug) gameframe_log("[cover] Adjusting window rectangle to", __target_rect); - gameframe_tools_rect_set_window_rect(__target_rect); - gameframe_cover_check_for_success = true; - } -} - -#endregion - -#region gameframe_delayed - -function gameframe_delayed_call_impl(_func, _delay, _arg0, _arg1, _arg2, _arg3) { - // gameframe_delayed_call_impl(func:any, delay:int, arg:any, arg:any, arg:any, arg:any) - var _item; - if (ds_stack_empty(gameframe_delayed_pool)) _item = gameframe_delayed_item_create(); else _item = ds_stack_pop(gameframe_delayed_pool); - _item[@1/* func */] = _func; - _item[@2/* time */] = gameframe_delayed_frame_index + _delay; - _item[@3/* arg0 */] = _arg0; - _item[@4/* arg1 */] = _arg1; - _item[@5/* arg2 */] = _arg2; - _item[@6/* arg3 */] = _arg3; - ds_queue_enqueue(gameframe_delayed_queue, _item); -} - -function gameframe_delayed_update() { - // gameframe_delayed_update() - gameframe_delayed_frame_index += 1; - var _f; - while (!ds_queue_empty(gameframe_delayed_queue)) { - var _head = ds_queue_head(gameframe_delayed_queue); - if (_head[2/* time */] > gameframe_delayed_frame_index) break; - ds_queue_dequeue(gameframe_delayed_queue); - _f = _head[1/* func */]; - _f(_head[3/* arg0 */], _head[4/* arg1 */], _head[5/* arg2 */], _head[6/* arg3 */]); - _head[@1/* func */] = undefined; - _head[@3/* arg0 */] = undefined; - _head[@4/* arg1 */] = undefined; - _head[@5/* arg2 */] = undefined; - _head[@6/* arg3 */] = undefined; - ds_stack_push(gameframe_delayed_pool, _head); - } -} - -#endregion - -#region gameframe_delayed_item - -function gameframe_delayed_item_create() { - // gameframe_delayed_item_create() - var _this = [mt_gameframe_delayed_item]; - array_copy(_this, 1, mq_gameframe_delayed_item, 1, 6); - /// @typedef {tuple} gameframe_delayed_item - - return _this; -} - -#endregion - -#region gameframe_drag - -function gameframe_drag_start(__flags) { - // gameframe_drag_start(_flags:int) - gameframe_drag_init = 0; - gameframe_drag_flags = __flags; - gameframe_drag_mx = (display_mouse_get_x() | 0); - gameframe_drag_my = (display_mouse_get_y() | 0); - gameframe_drag_left = window_get_x(); - gameframe_drag_top = window_get_y(); - gameframe_drag_right = gameframe_drag_left + window_get_width(); - gameframe_drag_bottom = gameframe_drag_top + window_get_height(); -} - -function gameframe_drag_stop() { - // gameframe_drag_stop() - - if(gameframe_drag_flags == 16) { - if(display_mouse_get_y() <= gameframe_resize_padding) - gameframe_maximize(); - } - - gameframe_drag_flags = 0; -} - -function gameframe_drag_set_rect(_x, _y, _w, _h) { - // gameframe_drag_set_rect(x:int, y:int, w:int, h:int) - window_set_rectangle(_x, _y, max(960, _w), max(600, _h)); -} - -function gameframe_drag_update() { - // gameframe_drag_update() - if (gameframe_drag_flags == 0) exit; - var __mx = (display_mouse_get_x() | 0); - var __my = (display_mouse_get_y() | 0); - switch (gameframe_drag_flags) { - case 16: - if(gameframe_drag_init == 0) { - var dist = point_distance(gameframe_drag_mx, gameframe_drag_my, __mx, __my); - if(dist > 8) { - gameframe_drag_init = 1; - //gameframe_drag_mx = __mx; - //gameframe_drag_my = __my; - } - } else - window_set_position(__mx - (gameframe_drag_mx - gameframe_drag_left), __my - (gameframe_drag_my - gameframe_drag_top)); - break; - case 32: - if (point_distance(__mx, __my, gameframe_drag_mx, gameframe_drag_my) > 5) { - var __x; - var __y = gameframe_drag_my - gameframe_drag_top; - if (gameframe_drag_mx - gameframe_drag_left < (gameframe_drag_right - gameframe_drag_left) / 2) __x = min(gameframe_drag_mx - gameframe_drag_left, (gameframe_restoreRect_hx[2/* width */] >> 1)); else __x = max(gameframe_restoreRect_hx[2/* width */] + gameframe_drag_mx - gameframe_drag_right, (gameframe_restoreRect_hx[2/* width */] >> 1)); - gameframe_isMaximized_hx = false; - gameframe_drag_set_rect(__mx - __x, __my - __y, gameframe_restoreRect_hx[2/* width */], gameframe_restoreRect_hx[3/* height */]); - gameframe_drag_start(16); - } - break; - case 1: - var __x = __mx - (gameframe_drag_mx - gameframe_drag_left); - gameframe_drag_set_rect(__x, gameframe_drag_top, gameframe_drag_right - __x, gameframe_drag_bottom - gameframe_drag_top); - break; - case 2: - var __y = __my - (gameframe_drag_my - gameframe_drag_top); - gameframe_drag_set_rect(gameframe_drag_left, __y, gameframe_drag_right - gameframe_drag_left, gameframe_drag_bottom - __y); - break; - case 4: gameframe_drag_set_rect(gameframe_drag_left, gameframe_drag_top, gameframe_drag_right - gameframe_drag_left - gameframe_drag_mx + __mx, gameframe_drag_bottom - gameframe_drag_top); break; - case 8: gameframe_drag_set_rect(gameframe_drag_left, gameframe_drag_top, gameframe_drag_right - gameframe_drag_left, gameframe_drag_bottom - gameframe_drag_top - gameframe_drag_my + __my); break; - case 3: - var __x = __mx - (gameframe_drag_mx - gameframe_drag_left); - var __y = __my - (gameframe_drag_my - gameframe_drag_top); - gameframe_drag_set_rect(__x, __y, gameframe_drag_right - __x, gameframe_drag_bottom - __y); - break; - case 9: - var __x = __mx - (gameframe_drag_mx - gameframe_drag_left); - gameframe_drag_set_rect(__x, gameframe_drag_top, gameframe_drag_right - __x, gameframe_drag_bottom - gameframe_drag_top - gameframe_drag_my + __my); - break; - case 6: - var __y = __my - (gameframe_drag_my - gameframe_drag_top); - gameframe_drag_set_rect(gameframe_drag_left, __y, gameframe_drag_right - gameframe_drag_left - gameframe_drag_mx + __mx, gameframe_drag_bottom - __y); - break; - case 12: gameframe_drag_set_rect(gameframe_drag_left, gameframe_drag_top, gameframe_drag_right - gameframe_drag_left - gameframe_drag_mx + __mx, gameframe_drag_bottom - gameframe_drag_top - gameframe_drag_my + __my); break; - } -} - -#endregion - -#region gameframe.tools.keyctl - -function gameframe_tools_keyctl_create_key(_keyCode) { - // gameframe_tools_keyctl_create_key(keyCode:gml_input_KeyCode)->GfKeyboardKey - return [/* keyCode: */_keyCode, /* down: */false, /* pressed: */false]; -} - -function gameframe_tools_keyctl_update_key(_key) { - // gameframe_tools_keyctl_update_key(key:GfKeyboardKey) - var _down0 = _key[1/* down */]; - var _down1 = keyboard_check_direct(_key[0/* keyCode */]) != 0; - _key[@2/* pressed */] = !_down0 && _down1; - _key[@1/* down */] = _down1; -} - -function gameframe_tools_keyctl_reset() { - // gameframe_tools_keyctl_reset() - var _i = 0; - for (var __g1 = array_length(gameframe_tools_keyctl_keys); _i < __g1; _i++) { - //gameframe_tools_keyctl_keys[_i][@1/* down */] = false; - } -} - -function gameframe_tools_keyctl_update() { - // gameframe_tools_keyctl_update() - if (!(window_has_focus() && (keyboard_check_direct(91) != 0 || keyboard_check_direct(92) != 0))) { - gameframe_tools_keyctl_reset(); - exit; - } - var _i = 0; - for (var __g1 = array_length(gameframe_tools_keyctl_keys); _i < __g1; _i++) { - gameframe_tools_keyctl_update_key(gameframe_tools_keyctl_keys[_i]); - } - - if (gameframe_tools_keyctl_up[2/* pressed */]) { - if (gameframe_can_resize) gameframe_maximize(); - } else if (gameframe_tools_keyctl_down[2/* pressed */]) { - if (gameframe_isMaximized_hx) { - if (gameframe_can_resize) gameframe_restore(); - } else gameframe_minimize(); - } -} - -#endregion - -#region gameframe_draw - -function gameframe_draw() { - /// gameframe_draw() - /// @returns {void} - if (!gameframe_is_ready) exit; - if (window_get_fullscreen() || gameframe_isFullscreen_hx) exit; - var _gw = window_get_width(); - var _gh = window_get_height(); - __display_set_gui_maximise_base(browser_width / _gw, browser_height / _gh, _gw % 2 / -2, _gh % 2 / -2); - var __borderWidth = (gameframe_isMaximized_hx ? 0 : gameframe_border_width); - var __titlebarHeight = gameframe_caption_get_height(); - var __buttons_x = gameframe_button_get_combined_offset(_gw); - if (!gameframe_isMaximized_hx) gameframe_caption_draw_border(0, 0, _gw, _gh); - gameframe_caption_draw_background(__borderWidth, __borderWidth, _gw - __borderWidth * 2, __titlebarHeight, __buttons_x); - gameframe_caption_draw_text(__borderWidth, __borderWidth, __buttons_x - __borderWidth, __titlebarHeight); - gameframe_button_draw(__buttons_x, __borderWidth, __titlebarHeight); - __display_gui_restore(); -} - -#endregion - -#region gameframe_std.Std - -function gameframe_std_Std_stringify(_value) { - // gameframe_std_Std_stringify(value:any)->string - if (_value == undefined) return "null"; - if (is_string(_value)) return _value; - var _n, _i, _s; - if (is_struct(_value)) { - var _e = _value[$"__enum__"]; - if (_e == undefined) return string(_value); - var _ects = _e._constructor; - if (_ects != undefined) { - _i = _value.__enumIndex__; - if (_i >= 0 && _i < array_length(_ects)) _s = _ects[_i]; else _s = "?"; - } else { - _s = instanceof(_value); - if (string_copy(_s, 1, 3) == "mc_") _s = string_delete(_s, 1, 3); - _n = string_length(_e.name); - if (string_copy(_s, 1, _n) == _e.name) _s = string_delete(_s, 1, _n + 1); - } - _s += "("; - var _fields = _value.__enumParams__; - _n = array_length(_fields); - for (_i = -1; ++_i < _n; _s += gameframe_std_Std_stringify(_value[$ _fields[_i]])) { - if (_i > 0) _s += ", "; - } - return _s + ")"; - } - if (is_real(_value)) { - _s = string_format(_value, 0, 16); - if (os_browser != browser_not_a_browser) { - _n = string_length(_s); - _i = _n; - while (_i > 0) { - switch (string_ord_at(_s, _i)) { - case 48: - _i--; - continue; - case 46: _i--; break; - } - break; - } - } else { - _n = string_byte_length(_s); - _i = _n; - while (_i > 0) { - switch (string_byte_at(_s, _i)) { - case 48: - _i--; - continue; - case 46: _i--; break; - } - break; - } - } - return string_copy(_s, 1, _i); - } - return string(_value); -} - -#endregion - -#region gameframe_std.haxe.class - -function gameframe_std_haxe_class(_id, _name) constructor { - // gameframe_std_haxe_class(id:int, name:string) - static superClass = undefined; /// @is {haxe_class} - static marker = undefined; /// @is {any} - static index = undefined; /// @is {int} - static name = undefined; /// @is {string} - self.superClass = undefined; - self.marker = gameframe_std_haxe_type_markerValue; - self.index = _id; - self.name = _name; - static __class__ = "class"; -} - -#endregion - -#region gameframe_tools_mon - -function gameframe_tools_mon_get_active() { - // gameframe_tools_mon_get_active()->tools_GfMonInfo - var __list = gameframe_tools_mon_get_active_list; - if (__list == undefined) { - __list = ds_list_create(); - gameframe_tools_mon_get_active_list = __list; - } - var __count = gameframe_get_monitors(__list); - var __cx1 = window_get_x() + (window_get_width() div 2); - var __cy1 = window_get_y() + (window_get_height() div 2); - var _i = 0; - for (var __g1 = __count; _i < __g1; _i++) { - var __item = __list[|_i]; - var __mntr = __item[0/* screen */]; - if (__cx1 >= __mntr[0/* x */] && __cy1 >= __mntr[1/* y */] && __cx1 < __mntr[0/* x */] + __mntr[2/* width */] && __cy1 < __mntr[1/* y */] + __mntr[3/* height */]) return __item; - } - var __item = __list[|0]; - if (__item == undefined) { - __item = gameframe_tools_mon_dummy; - if (__item == undefined) { - __item = [/* screen: */gameframe_tools_rect__new(0, 0, display_get_width(), display_get_height()), /* workspace: */gameframe_tools_rect__new(0, 0, display_get_width(), display_get_height() - 40), /* flags: */0]; - gameframe_tools_mon_dummy = __item; - } - __list[|0] = __item; - } - return __item; -} - -#endregion - -// gameframe: -globalvar gameframe_is_ready; /// @is {bool} -gameframe_is_ready = false; -globalvar gameframe_double_click_time; /// @is {number} -globalvar gameframe_last_title_click_at; /// @is {int} -gameframe_last_title_click_at = -5000; -// gameframe_button: -globalvar gameframe_button_array; /// @is {array} -gameframe_button_array = []; -globalvar gameframe_button_fade_time; /// @is {number} -gameframe_button_fade_time = 0.2; -globalvar gameframe_button_wait_for_movement; /// @is {bool} -gameframe_button_wait_for_movement = false; -globalvar gameframe_button_wait_for_movement_x; /// @is {number} -gameframe_button_wait_for_movement_x = 0.; -globalvar gameframe_button_wait_for_movement_y; /// @is {number} -gameframe_button_wait_for_movement_y = 0.; -// gameframe: -globalvar gameframe_debug; /// @is {bool} -gameframe_debug = false; -globalvar gameframe_blend; /// @is {int} -gameframe_blend = 16777215; -globalvar gameframe_alpha; /// @is {number} -gameframe_alpha = 1.0; -globalvar gameframe_can_input; /// @is {bool} -gameframe_can_input = true; -globalvar gameframe_can_resize; /// @is {bool} -gameframe_can_resize = true; -globalvar gameframe_resize_padding; /// @is {int} -gameframe_resize_padding = 6; -globalvar gameframe_border_width; /// @is {int} -gameframe_border_width = 2; -globalvar gameframe_spr_border; /// @is {sprite} -gameframe_spr_border = asset_get_index("spr_gameframe_border"); -globalvar gameframe_spr_caption; /// @is {sprite} -gameframe_spr_caption = asset_get_index("spr_gameframe_caption"); -globalvar gameframe_spr_buttons; /// @is {sprite} -gameframe_spr_buttons = asset_get_index("spr_gameframe_buttons"); -globalvar gameframe_spr_pixel; /// @is {sprite} -gameframe_spr_pixel = asset_get_index("spr_gameframe_pixel"); -globalvar gameframe_default_cursor; /// @is {window_cursor} -gameframe_default_cursor = cr_arrow; -globalvar gameframe_set_cursor; /// @is {bool} -gameframe_set_cursor = true; -globalvar gameframe_current_cursor; /// @is {window_cursor} -gameframe_current_cursor = cr_arrow; -globalvar gameframe_dpi_scale; /// @is {number} -gameframe_dpi_scale = 1.; -// gameframe: -globalvar gameframe_effective_scale; /// @is {number} -gameframe_effective_scale = 1.; -globalvar gameframe_has_native_extension; /// @is {bool} -gameframe_has_native_extension = false; -globalvar gameframe_mouse_over_frame; /// @is {bool} -gameframe_mouse_over_frame = false; -globalvar gameframe_isMaximized_hx; /// @is {bool} -gameframe_isMaximized_hx = false; -globalvar gameframe_isFullscreen_hx; /// @is {bool} -gameframe_isFullscreen_hx = false; -globalvar gameframe_restoreRect_hx; /// @is {gameframe_tools_rect} -gameframe_restoreRect_hx = gameframe_tools_rect__new(); -// gameframe_caption: -globalvar gameframe_caption_text; /// @is {string} -gameframe_caption_text = window_get_caption(); -globalvar gameframe_caption_alpha; /// @is {number} -gameframe_caption_alpha = 1; -globalvar gameframe_caption_font; /// @is {font} -gameframe_caption_font = -1; -globalvar gameframe_caption_text_align; /// @is {gml_gpu_TextAlign} -gameframe_caption_text_align = 0; -globalvar gameframe_caption_icon; /// @is {sprite} -gameframe_caption_icon = -1; -globalvar gameframe_caption_margin; /// @is {int} -gameframe_caption_margin = 6; -globalvar gameframe_caption_icon_margin; /// @is {int} -gameframe_caption_icon_margin = 4; -globalvar gameframe_caption_height_normal; /// @is {number} -gameframe_caption_height_normal = -1; -globalvar gameframe_caption_height_maximized; /// @is {number} -gameframe_caption_height_maximized = -0.66667; -globalvar gameframe_caption_draw_border; /// @is {function} -gameframe_caption_draw_border = gameframe_caption_draw_border_default; -globalvar gameframe_caption_draw_background; /// @is {function} -gameframe_caption_draw_background = gameframe_caption_draw_caption_rect_default; -globalvar gameframe_caption_draw_text; /// @is {function} -gameframe_caption_draw_text = gameframe_caption_draw_caption_text_default; -// gameframe_cover: -globalvar gameframe_cover_check_for_success; /// @is {bool} -gameframe_cover_check_for_success = false; -globalvar gameframe_cover_ignore_rect; /// @is {gameframe_tools_rect} -gameframe_cover_ignore_rect = gameframe_tools_rect__new(); -globalvar gameframe_cover_can_ignore; /// @is {bool} -gameframe_cover_can_ignore = false; -globalvar gameframe_cover_curr_rect; /// @is {gameframe_tools_rect} -gameframe_cover_curr_rect = gameframe_tools_rect__new(); -// gameframe_delayed: -globalvar gameframe_delayed_queue; /// @is {ds_queue} -gameframe_delayed_queue = ds_queue_create(); -globalvar gameframe_delayed_pool; /// @is {ds_stack} -gameframe_delayed_pool = ds_stack_create(); -globalvar gameframe_delayed_frame_index; /// @is {int} -gameframe_delayed_frame_index = 0; -// gameframe_drag: -globalvar gameframe_drag_flags; /// @is {int} -gameframe_drag_flags = 0; -globalvar gameframe_drag_init; /// @is {int} -gameframe_drag_init = 0; -globalvar gameframe_drag_mx; /// @is {int} -gameframe_drag_mx = 0; -globalvar gameframe_drag_my; /// @is {int} -gameframe_drag_my = 0; -globalvar gameframe_drag_left; /// @is {int} -gameframe_drag_left = 0; -globalvar gameframe_drag_top; /// @is {int} -gameframe_drag_top = 0; -globalvar gameframe_drag_right; /// @is {int} -gameframe_drag_right = 0; -globalvar gameframe_drag_bottom; /// @is {int} -gameframe_drag_bottom = 0; -// gameframe.tools.keyctl: -globalvar gameframe_tools_keyctl_up; /// @is {GfKeyboardKey} -gameframe_tools_keyctl_up = gameframe_tools_keyctl_create_key(38); -globalvar gameframe_tools_keyctl_down; /// @is {GfKeyboardKey} -gameframe_tools_keyctl_down = gameframe_tools_keyctl_create_key(40); -globalvar gameframe_tools_keyctl_keys; /// @is {array} -gameframe_tools_keyctl_keys = [gameframe_tools_keyctl_up, gameframe_tools_keyctl_down]; -// gameframe_tools_mon: -globalvar gameframe_tools_mon_get_active_list; /// @is {ds_list} -gameframe_tools_mon_get_active_list = undefined; -globalvar gameframe_tools_mon_dummy; /// @is {tools_GfMonInfo} -gameframe_tools_mon_dummy = undefined; - - -/// @typedef {any} tools_GfRectImpl -/// @typedef {any} gameframe_tools_rect -/// @typedef {any} tools_GfMonInfo -/// @typedef {any} GfKeyboardKey \ No newline at end of file diff --git a/scripts/gameframe_macros/gameframe_macros.gml b/scripts/gameframe_macros/gameframe_macros.gml deleted file mode 100644 index 8dcc07baa..000000000 --- a/scripts/gameframe_macros/gameframe_macros.gml +++ /dev/null @@ -1,36 +0,0 @@ -global.__display_gui_args = [0, 0, 0, 0, 0]; - -#macro __display_set_gui_size_base display_set_gui_size -#macro display_set_gui_size __display_set_gui_size_hook -function __display_set_gui_size_hook(_width, _height) { - __display_set_gui_size_base(_width, _height); - global.__display_gui_args[@0] = -1; - global.__display_gui_args[@1] = _width; - global.__display_gui_args[@2] = _height; - global.__display_gui_args[@3] = 0; - global.__display_gui_args[@4] = 0; -} - -#macro __display_set_gui_maximize_base display_set_gui_maximize -#macro __display_set_gui_maximise_base display_set_gui_maximise -#macro display_set_gui_maximize __display_set_gui_maximize_hook -#macro display_set_gui_maximise __display_set_gui_maximize_hook -function __display_set_gui_maximize_hook() { - global.__display_gui_args[@0] = argument_count; - var i = 0; - for (; i < argument_count; i++) global.__display_gui_args[@i + 1] = argument[i]; - for (; i < 4; i++) global.__display_gui_args[@i + 1] = 0; -} - -function __display_gui_restore() { - var _args = global.__display_gui_args; - switch (_args[0]) { - case -1: __display_set_gui_size_base(_args[1], _args[2]); break; - case 0: __display_set_gui_maximise_base(); break; - case 1: __display_set_gui_maximise_base(_args[1]); break; - case 2: __display_set_gui_maximise_base(_args[1], _args[2]); break; - case 3: __display_set_gui_maximise_base(_args[1], _args[2], _args[3]); break; - case 4: __display_set_gui_maximise_base(_args[1], _args[2], _args[3], _args[4]); break; - } -} - diff --git a/scripts/gameframe_macros/gameframe_macros.yy b/scripts/gameframe_macros/gameframe_macros.yy deleted file mode 100644 index b5cd4257a..000000000 --- a/scripts/gameframe_macros/gameframe_macros.yy +++ /dev/null @@ -1,11 +0,0 @@ -{ - "resourceType": "GMScript", - "resourceVersion": "1.0", - "name": "gameframe_macros", - "isCompatibility": false, - "isDnD": false, - "parent": { - "name": "Gameframe", - "path": "folders/_extensions/Gameframe.yy", - }, -} \ No newline at end of file diff --git a/scripts/globals/globals.gml b/scripts/globals/globals.gml index 52154b78a..8bf105c08 100644 --- a/scripts/globals/globals.gml +++ b/scripts/globals/globals.gml @@ -25,10 +25,10 @@ globalvar VERSION, SAVE_VERSION, VERSION_STRING, BUILD_NUMBER, LATEST_VERSION; LATEST_VERSION = 11500; - VERSION = 11585; + VERSION = 11586; SAVE_VERSION = 11600; - VERSION_STRING = "1.16rc5"; - BUILD_NUMBER = 11585; + VERSION_STRING = "1.16rc6"; + BUILD_NUMBER = 11586; globalvar APPEND_MAP; APPEND_MAP = ds_map_create(); diff --git a/scripts/mac_window_init/mac_window_init.gml b/scripts/mac_window_init/mac_window_init.gml index 32ea01d8f..8b6a5e44d 100644 --- a/scripts/mac_window_init/mac_window_init.gml +++ b/scripts/mac_window_init/mac_window_init.gml @@ -41,7 +41,7 @@ function mac_window_maximize() { room_height = _h; display_set_gui_size(_w, _h); - gameframe_drag_set_rect(0, 0, _w, _h); + winMan_setRect(0, 0, _w, _h); display_refresh(); } @@ -51,6 +51,6 @@ function mac_window_minimize() { __win_is_maximized = false; - gameframe_drag_set_rect(__win_min_x, __win_min_y, __win_min_w, __win_min_h); + winMan_setRect(__win_min_x, __win_min_y, __win_min_w, __win_min_h); display_refresh(); } \ No newline at end of file diff --git a/scripts/mac_window_step/mac_window_step.gml b/scripts/mac_window_step/mac_window_step.gml index 757718983..c22a948ee 100644 --- a/scripts/mac_window_step/mac_window_step.gml +++ b/scripts/mac_window_step/mac_window_step.gml @@ -9,7 +9,7 @@ function mac_window_step() { window_set_position(__win_drag_sx + (_mx - __win_drag_mx), __win_drag_sy + (_my - __win_drag_my)); else { if((__win_is_dragging & WINDOW_DRAG_MODE.resize_n) != 0) { - gameframe_drag_set_rect( + winMan_setRect( __win_drag_sx, __win_drag_sy + (_my - __win_drag_my), __win_drag_sw, @@ -22,7 +22,7 @@ function mac_window_step() { ); if((__win_is_dragging & WINDOW_DRAG_MODE.resize_w) != 0) { - gameframe_drag_set_rect( + winMan_setRect( __win_drag_sx + (_mx - __win_drag_mx), __win_drag_sy, __win_drag_sw - (_mx - __win_drag_mx), diff --git a/scripts/node_path/node_path.gml b/scripts/node_path/node_path.gml index 5be466760..eb139809b 100644 --- a/scripts/node_path/node_path.gml +++ b/scripts/node_path/node_path.gml @@ -41,6 +41,7 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { outputs[| 1] = nodeValue("Path data", self, JUNCTION_CONNECT.output, VALUE_TYPE.pathnode, self); outputs[| 2] = nodeValue("Anchors", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, []) + .setVisible(false) .setArrayDepth(1); tool_pathDrawer = new NodeTool( "Draw path", THEME.path_tools_draw ) diff --git a/scripts/node_path_array/node_path_array.gml b/scripts/node_path_array/node_path_array.gml index 6502798e6..916f7ce15 100644 --- a/scripts/node_path_array/node_path_array.gml +++ b/scripts/node_path_array/node_path_array.gml @@ -90,24 +90,24 @@ function Node_Path_Array(_x, _y, _group = noone) : Node(_x, _y, _group) construc return 0; } #endregion - static get__vec2Ratio = function(_rat, ind = 0) { #region + static getPointRatio = function(_rat, ind = 0) { #region for( var i = input_fix_len; i < ds_list_size(inputs) - 1; i += data_length ) { var _path = getInputData(i); var lc = struct_has(_path, "getLineCount")? _path.getLineCount() : 1; - if(ind < lc) return _path.get__vec2Ratio(_rat, ind).clone(); + if(ind < lc) return _path.getPointRatio(_rat, ind).clone(); ind -= lc; } return new __vec2(); } #endregion - static get__vec2Distance = function(_dist, ind = 0) { #region + static getPointDistance = function(_dist, ind = 0) { #region for( var i = input_fix_len; i < ds_list_size(inputs) - 1; i += data_length ) { var _path = getInputData(i); var lc = struct_has(_path, "getLineCount")? _path.getLineCount() : 1; - if(ind < lc) return _path.get__vec2Distance(_dist, ind).clone(); + if(ind < lc) return _path.getPointDistance(_dist, ind).clone(); ind -= lc; } @@ -126,6 +126,15 @@ function Node_Path_Array(_x, _y, _group = noone) : Node(_x, _y, _group) construc return 0; } #endregion + static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { #region + for( var i = input_fix_len; i < ds_list_size(inputs) - 1; i += data_length ) { + var _path = getInputData(i); + if(!struct_has(_path, "drawOverlay")) continue; + + _path.drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny); + } + } #endregion + static update = function(frame = CURRENT_FRAME) { #region outputs[| 0].setValue(self); } #endregion diff --git a/scripts/node_path_builder/node_path_builder.gml b/scripts/node_path_builder/node_path_builder.gml index 8fc0c6de7..df83e4bb4 100644 --- a/scripts/node_path_builder/node_path_builder.gml +++ b/scripts/node_path_builder/node_path_builder.gml @@ -26,6 +26,9 @@ function Node_Path_Builder(_x, _y, _group = noone) : Node(_x, _y, _group) constr draw_line(_x + p0[0] * _s, _y + p0[1] * _s, _x + p1[0] * _s, _y + p1[1] * _s); + + if(j == 1) draw_circle(_x + p0[0] * _s, _y + p0[1] * _s, 4, false); + draw_circle(_x + p1[0] * _s, _y + p1[1] * _s, 4, false); } } } #endregion diff --git a/scripts/node_render_sprite_sheet/node_render_sprite_sheet.gml b/scripts/node_render_sprite_sheet/node_render_sprite_sheet.gml index 6f9e283e3..b206ff6c2 100644 --- a/scripts/node_render_sprite_sheet/node_render_sprite_sheet.gml +++ b/scripts/node_render_sprite_sheet/node_render_sprite_sheet.gml @@ -199,7 +199,7 @@ function Node_Render_Sprite_Sheet(_x, _y, _group = noone) : Node(_x, _y, _group) var _h = surface_get_height_safe(inpt[i]); surface_set_target(oo); - BLEND_OVERRIDE; + BLEND_OVERRIDE switch(pack) { case SPRITE_STACK.horizontal : diff --git a/scripts/node_scatter/node_scatter.gml b/scripts/node_scatter/node_scatter.gml index b991e19cc..35b17679f 100644 --- a/scripts/node_scatter/node_scatter.gml +++ b/scripts/node_scatter/node_scatter.gml @@ -1,3 +1,12 @@ +enum NODE_SCATTER_DIST { + area, + border, + map, + data, + path, + tile +} + function Node_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor { name = "Scatter"; dimension_index = 1; @@ -115,7 +124,6 @@ function Node_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c static processData = function(_outSurf, _data, _output_index, _array_index) { #region if(_output_index == 1) return scatter_data; - if(_output_index == 0 && _array_index == 0) scatter_data = []; var _inSurf = _data[0]; if(_inSurf == 0) @@ -158,6 +166,23 @@ function Node_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c var _posDist = []; if(_dist == 2 && is_surface(_distMap)) _posDist = get_points_from_dist(_distMap, _amount, seed); + + if(_dist == 4) { + var path_valid = path != noone && struct_has(path, "getPointRatio"); + + if(!path_valid) return _outSurf; + + var _pathProgress = 0; + var path_amount = struct_has(path, "getLineCount")? path.getLineCount() : 1; + var _pre_amount = _amount; + _amount *= path_amount; + + var path_line_index = 0; + } + + var _sed = seed; + var _sct = array_create(_amount); + var _sct_len = 0; surface_set_target(_outSurf); DRAW_CLEAR @@ -171,45 +196,37 @@ function Node_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c break; } - var _pathProgress = 0; - var _sed = seed; - var res_index = 0, bg = 0; - for(var i = 0; i < _amount; i++) { var sp = noone, _x = 0, _y = 0; var _v = noone; - if(_dist < 2) { + if(_dist == NODE_SCATTER_DIST.area || _dist == NODE_SCATTER_DIST.border) { sp = area_get_random_point(_area, _dist, _scat, i, _amount, _sed); _sed += 20; _x = sp[0]; _y = sp[1]; - } else if(_dist == 2) { + } else if(_dist == NODE_SCATTER_DIST.data) { sp = array_safe_get(_posDist, i); if(!is_array(sp)) continue; _x = _area[0] + _area[2] * (sp[0] * 2 - 1.); _y = _area[1] + _area[3] * (sp[1] * 2 - 1.); - } else if(_dist == 3) { + } else if(_dist == NODE_SCATTER_DIST.map) { sp = array_safe_get(_distData, i); if(!is_array(sp)) continue; _x = array_safe_get(sp, 0); _y = array_safe_get(sp, 1); _v = array_safe_get(sp, 2, noone); - } else if(_dist == 4) { - if(path != noone && struct_has(path, "getPointRatio")) { - _pathProgress = _scat? random_seed(1, _sed) : i / max(1, _amount); _sed++; - _pathProgress = frac((_pathProgress + pathShf) * 0.9999); - - var pp = path.getPointRatio(_pathProgress); - _x = pp.x + random_range_seed(-pathDis, pathDis, _sed); _sed++; - _y = pp.y + random_range_seed(-pathDis, pathDis, _sed); _sed++; - } - } else if(_dist == 5) { + } else if(_dist == NODE_SCATTER_DIST.path) { + _pathProgress = _scat? random_seed(1, _sed) : i / max(1, _pre_amount); _sed++; + _pathProgress = frac((_pathProgress + pathShf) * 0.9999); + + var pp = path.getPointRatio(_pathProgress, path_line_index); + _x = pp.x + random_range_seed(-pathDis, pathDis, _sed); _sed++; + _y = pp.y + random_range_seed(-pathDis, pathDis, _sed); _sed++; + } else if(_dist == NODE_SCATTER_DIST.tile) { _x = random_range_seed(0, _dim[0], _sed); _sed++; _y = random_range_seed(0, _dim[1], _sed); _sed++; - - //print(string(_x) + ", " + string(_y)); } var posS = _dist < 4? seed + _y * _dim[0] + _x : seed + i * 100; @@ -222,14 +239,14 @@ function Node_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c _scy *= _v; } - var _r = (_pint? point_direction(_area[0], _area[1], _x, _y) : 0) + angle_random_eval(_rota, posS); posS++; + var _r = (_pint? point_direction(_area[0], _area[1], _x, _y) : 0) + angle_random_eval(_rota, posS); posS++; if(vRot && _v != noone) _r *= _v; - if(_dist == 4 && path != noone && pathRot) { - var p0 = path.getPointRatio(clamp(_pathProgress - 0.001, 0, 0.9999)); - var p1 = path.getPointRatio(clamp(_pathProgress + 0.001, 0, 0.9999)); + if(_dist == NODE_SCATTER_DIST.path && pathRot) { + var p0 = path.getPointRatio(clamp(_pathProgress - 0.001, 0, 0.9999), path_line_index); + var p1 = path.getPointRatio(clamp(_pathProgress + 0.001, 0, 0.9999), path_line_index); var dirr = point_direction(p0.x, p0.y, p1.x, p1.y); _r += dirr; @@ -248,7 +265,7 @@ function Node_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c var sw = surface_get_width_safe(surf); var sh = surface_get_height_safe(surf); - if(_dist != AREA_DISTRIBUTION.area || _scat != AREA_SCATTER.uniform) { + if(_dist != NODE_SCATTER_DIST.area || _scat != AREA_SCATTER.uniform) { var p = point_rotate(-sw / 2 * _scx, -sh * _scy / 2, 0, 0, _r); _x += p[0]; _y += p[1]; @@ -261,31 +278,37 @@ function Node_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c var clr = color.eval(grSamp); var alp = random_range_seed(alpha[0], alpha[1], posS); posS++; - array_push(scatter_data, new SurfaceAtlas(surf, _x, _y, _r, _scx, _scy, clr, alp)); + var _atl = array_safe_get(scatter_data, _sct_len); + if(!is_instanceof(_atl, SurfaceAtlas)) + _atl = new SurfaceAtlas(surf, _x, _y, _r, _scx, _scy, clr, alp); + else + _atl.set(surf, _x, _y, _r, _scx, _scy, clr, alp); + _sct[_sct_len] = _atl; + _sct_len++; + draw_surface_ext_safe(surf, _x, _y, _scx, _scy, _r, clr, alp); - if(_dist == 5) { + if(_dist == NODE_SCATTER_DIST.path) { + path_line_index = floor(i / _pre_amount); + } else if(_dist == NODE_SCATTER_DIST.tile) { var _sw = surface_get_width_safe(surf) * _scx; var _sh = surface_get_height_safe(surf) * _scy; - if(_x < _sw) - draw_surface_ext_safe(surf, _dim[0] + _x, _y, _scx, _scy, _r, clr, alp); - if(_y < _sh) - draw_surface_ext_safe(surf, _x, _dim[1] + _y, _scx, _scy, _r, clr, alp); - if(_x < _sw && _y < _sh) - draw_surface_ext_safe(surf, _dim[0] + _x, _dim[1] + _y, _scx, _scy, _r, clr, alp); + if(_x < _sw) draw_surface_ext_safe(surf, _dim[0] + _x, _y, _scx, _scy, _r, clr, alp); + if(_y < _sh) draw_surface_ext_safe(surf, _x, _dim[1] + _y, _scx, _scy, _r, clr, alp); + if(_x < _sw && _y < _sh) draw_surface_ext_safe(surf, _dim[0] + _x, _dim[1] + _y, _scx, _scy, _r, clr, alp); - if(_x > _dim[0] - _sw) - draw_surface_ext_safe(surf, _x - _dim[0], _y, _scx, _scy, _r, clr, alp); - if(_y > _dim[1] - _sh) - draw_surface_ext_safe(surf, _x, _y - _dim[1], _scx, _scy, _r, clr, alp); - if(_x > _dim[0] - _sw || _y > _dim[1] - _sh) - draw_surface_ext_safe(surf, _x - _dim[0], _y - _dim[1], _scx, _scy, _r, clr, alp); + if(_x > _dim[0] - _sw) draw_surface_ext_safe(surf, _x - _dim[0], _y, _scx, _scy, _r, clr, alp); + if(_y > _dim[1] - _sh) draw_surface_ext_safe(surf, _x, _y - _dim[1], _scx, _scy, _r, clr, alp); + if(_x > _dim[0] - _sw || _y > _dim[1] - _sh) draw_surface_ext_safe(surf, _x - _dim[0], _y - _dim[1], _scx, _scy, _r, clr, alp); } } BLEND_NORMAL; surface_reset_target(); + array_resize(_sct, _sct_len); + scatter_data = _sct; + return _outSurf; } #endregion diff --git a/scripts/panel_graph/panel_graph.gml b/scripts/panel_graph/panel_graph.gml index fb2a5d89d..408d3aa73 100644 --- a/scripts/panel_graph/panel_graph.gml +++ b/scripts/panel_graph/panel_graph.gml @@ -1731,7 +1731,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { } cx = cx + 160; cy = round(cy / array_length(nodes_selecting) / 32) * 32; - + var _blend = new Node_Blend(cx, cy, getCurrentContext()); var index = 0; for( var i = 0; i < array_length(nodes_selecting); i++ ) { @@ -1776,26 +1776,35 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { function doArray() { #region if(array_empty(nodes_selecting)) return; - var cx = nodes_selecting[0].x; - var cy = 0; - - for(var i = 0; i < array_length(nodes_selecting); i++) { - var _node = nodes_selecting[i]; - cx = max(cx, _node.x); - cy += _node.y; - } - cx = cx + 160; - cy = round(cy / array_length(nodes_selecting) / 32) * 32; - - var _array = nodeBuild("Node_Array", cx, cy); - - for( var i = 0; i < array_length(nodes_selecting); i++ ) { + var cx = nodes_selecting[0].x; + var cy = 0; + var pr = ds_priority_create(); + var amo = array_length(nodes_selecting); + var len = 0; + + for(var i = 0; i < amo; i++) { var _node = nodes_selecting[i]; if(ds_list_size(_node.outputs) == 0) continue; + + cx = max(cx, _node.x); + cy += _node.y; + + ds_priority_add(pr, _node, _node.y); + len++; + } + + cx = cx + 160; + cy = round(cy / len / 32) * 32; + + var _array = nodeBuild("Node_Array", cx, cy); + + repeat(len) { + var _node = ds_priority_delete_min(pr); _array.addInput(_node.outputs[| 0]); } nodes_selecting = []; + ds_priority_destroy(pr); } #endregion function doGroup() { #region diff --git a/scripts/panel_menu/panel_menu.gml b/scripts/panel_menu/panel_menu.gml index 35c0bf0be..351028e2b 100644 --- a/scripts/panel_menu/panel_menu.gml +++ b/scripts/panel_menu/panel_menu.gml @@ -76,15 +76,10 @@ function Panel_Menu() : PanelContent() constructor { return submenuCall(_dat, arr); }, THEME.addon_icon ).setIsShelf(), -1, - menuItem(__txt("Fullscreen"), function() { - if(gameframe_is_fullscreen_window()) - gameframe_set_fullscreen(0); - else - gameframe_set_fullscreen(2); - },, ["", "Fullscreen"]), + menuItem(__txt("Fullscreen"), function() { winMan_setFullscreen(!window_is_fullscreen); },, ["", "Fullscreen"]), menuItem(__txt("Close current project"), function() { PANEL_GRAPH.close(); },, [ "", "Close file" ]), - menuItem(__txt("Close all projects"), function() { for( var i = array_length(PROJECTS) - 1; i >= 0; i-- ) closeProject(PROJECTS[i]); },, [ "", "Close all" ]), - menuItem(__txt("Close program"), function() { window_close(); },, [ "", "Close program" ]), + menuItem(__txt("Close all projects"), function() { for( var i = array_length(PROJECTS) - 1; i >= 0; i-- ) closeProject(PROJECTS[i]); },, [ "", "Close all" ]), + menuItem(__txt("Close program"), function() { window_close(); },, [ "", "Close program" ]), ]; if(!DEMO) menu_file = array_append(menu_file_nondemo, menu_file); @@ -321,7 +316,8 @@ function Panel_Menu() : PanelContent() constructor { } #endregion function drawContent(panel) { #region - var _right = PREFERENCES.panel_menu_right_control; + var _right = PREFERENCES.panel_menu_right_control; + var _draggable = pFOCUS; draw_clear_alpha(COLORS.panel_bg_clear, 1); menus[6][1] = STEAM_ENABLED? menu_help_steam : menu_help; @@ -343,9 +339,10 @@ function Panel_Menu() : PanelContent() constructor { var bx = xx; if(!PREFERENCES.panel_menu_right_control) bx = w - ui(24); - + draw_sprite_ui_uniform(THEME.icon_24, 0, bx, h / 2, 1, c_white); if(pHOVER && point_in_rectangle(mx, my, bx - ui(16), 0, bx + ui(16), ui(32))) { + _draggable = false; if(mouse_press(mb_left, pFOCUS)) dialogCall(o_dialog_about); } @@ -355,6 +352,7 @@ function Panel_Menu() : PanelContent() constructor { draw_sprite_ui_uniform(THEME.icon_24, 0, bx, by, 1, c_white); if(pHOVER && point_in_rectangle(mx, my, bx - ui(16), by - ui(16), bx + ui(16), by + ui(16))) { + _draggable = false; if(mouse_press(mb_left, pFOCUS)) dialogCall(o_dialog_about); } @@ -419,6 +417,7 @@ function Panel_Menu() : PanelContent() constructor { } if(pHOVER && point_in_rectangle(mx, my, x0, y0, x1, y1)) { + _draggable = false; draw_sprite_stretched(THEME.menu_button, 0, x0, y0, x1 - x0, y1 - y0); if((mouse_press(mb_left, pFOCUS)) || instance_exists(o_dialog_menubox)) { @@ -479,6 +478,7 @@ function Panel_Menu() : PanelContent() constructor { var cc = merge_color(c_white, noti_flash_color, ev); if(pHOVER && point_in_rectangle(mx, my, nx0, ny0 - nh / 2, nx0 + nw, ny0 + nh / 2)) { + _draggable = false; draw_sprite_stretched_ext(THEME.menu_button, 0, nx0, ny0 - nh / 2, nw, nh, cc, 1); if(mouse_press(mb_left, pFOCUS)) { var dia = dialogPanelCall(new Panel_Notification(), nx0, ny0 + nh / 2 + ui(4)); @@ -520,6 +520,7 @@ function Panel_Menu() : PanelContent() constructor { var ww = hori? string_width(name) + ui(40) : w - ui(16); if(pHOVER && point_in_rectangle(mx, my, nx0, ny0 - wh / 2, nx0 + ww, ny0 + wh / 2)) { + _draggable = false; TOOLTIP = __txt("Addons"); draw_sprite_stretched(THEME.menu_button, 1, nx0, ny0 - wh / 2, ww, wh); if(mouse_press(mb_left, pFOCUS)) @@ -544,23 +545,29 @@ function Panel_Menu() : PanelContent() constructor { switch(action) { case "exit": - if(buttonInstant(THEME.button_hide_fill, x1 - bs, ui(6), bs, bs, [mx, my], pFOCUS, pHOVER,, THEME.window_exit, 0, COLORS._main_accent) == 2) - window_close(); + var b = buttonInstant(THEME.button_hide_fill, x1 - bs, ui(6), bs, bs, [mx, my], pFOCUS, pHOVER,, THEME.window_exit, 0, COLORS._main_accent); + if(b) _draggable = false; + if(b == 2) window_close(); break; case "maximize": - var win_max = gameframe_is_maximized() || gameframe_is_fullscreen_window(); + var win_max = window_is_maximized || window_is_fullscreen; if(OS == os_macosx) win_max = __win_is_maximized; - if(buttonInstant(THEME.button_hide_fill, x1 - bs, ui(6), bs, bs, [mx, my], pFOCUS, pHOVER,, THEME.window_maximize, win_max, [ COLORS._main_icon, CDEF.lime ]) == 2) { + var b = buttonInstant(THEME.button_hide_fill, x1 - bs, ui(6), bs, bs, [mx, my], pFOCUS, pHOVER,, THEME.window_maximize, win_max, [ COLORS._main_icon, CDEF.lime ]); + if(b) _draggable = false; + if(b == 2) { if(OS == os_windows) { - if(gameframe_is_fullscreen_window()) { - gameframe_set_fullscreen(0); - gameframe_restore(); - } else if(gameframe_is_maximized()) - gameframe_restore(); - else - gameframe_maximize(); + if(window_is_fullscreen) { + winMan_setFullscreen(false); + winMan_Unmaximize(); + } else if(window_is_maximized) { + winMan_Unmaximize(); + DISPLAY_REFRESH + } else { + winMan_Maximize(); + DISPLAY_REFRESH + } } else if(OS == os_macosx) { if(__win_is_maximized) mac_window_minimize(); else mac_window_maximize(); @@ -568,30 +575,35 @@ function Panel_Menu() : PanelContent() constructor { } break; case "minimize": - if(OS == os_windows) - if(buttonInstant(THEME.button_hide_fill, x1 - bs, ui(6), bs, bs, [mx, my], pFOCUS, pHOVER,, THEME.window_minimize, 0, [ COLORS._main_icon, CDEF.yellow ]) == -2) { - if(OS == os_windows) - gameframe_minimize(); - else if(OS == os_macosx) { + if(OS == os_windows) { + var b = buttonInstant(THEME.button_hide_fill, x1 - bs, ui(6), bs, bs, [mx, my], pFOCUS, pHOVER,, THEME.window_minimize, 0, [ COLORS._main_icon, CDEF.yellow ]); + if(b) _draggable = false; + if(b == -2) { + if(OS == os_windows) + winMan_Minimize(); + else if(OS == os_macosx) { + } } } - if(OS == os_macosx) { - buttonInstant(THEME.button_hide, x1 - bs, ui(6), bs, bs, [mx, my], pFOCUS, pHOVER,, THEME.window_minimize, 0, [ COLORS._main_icon, COLORS._main_icon ]); - } + //if(OS == os_macosx) { + // buttonInstant(THEME.button_hide, x1 - bs, ui(6), bs, bs, [mx, my], pFOCUS, pHOVER,, THEME.window_minimize, 0, [ COLORS._main_icon, COLORS._main_icon ]); + //} break; case "fullscreen": - var win_full = OS == os_windows? gameframe_is_fullscreen_window() : window_get_fullscreen(); - if(buttonInstant(THEME.button_hide_fill, x1 - bs, ui(6), bs, bs, [mx, my], pFOCUS, pHOVER,, THEME.window_fullscreen, win_full, [ COLORS._main_icon, CDEF.cyan ]) == 2) { + var win_full = window_is_fullscreen; + var b = buttonInstant(THEME.button_hide_fill, x1 - bs, ui(6), bs, bs, [mx, my], pFOCUS, pHOVER,, THEME.window_fullscreen, win_full, [ COLORS._main_icon, CDEF.cyan ]); + if(b) _draggable = false; + if(b == 2) { if(OS == os_windows) - gameframe_set_fullscreen(gameframe_is_fullscreen_window()? 0 : 2); + winMan_setFullscreen(!win_full); else if(OS == os_macosx) { - if(window_get_fullscreen()) { - window_set_fullscreen(false); + if(win_full) { + winMan_setFullscreen(false); mac_window_minimize(); } else - window_set_fullscreen(true); + winMan_setFullscreen(true); } } break; @@ -621,6 +633,7 @@ function Panel_Menu() : PanelContent() constructor { var _y1 = h - ui(6); if(pHOVER && point_in_rectangle(mx, my, _x0, _y0, _x1, _y1)) { + _draggable = false; draw_sprite_stretched_ext(THEME.button_hide_fill, 1, _x0, _y0, _x1 - _x0, _y1 - _y0, sc, 1); if(mouse_press(mb_left, pFOCUS)) @@ -639,6 +652,7 @@ function Panel_Menu() : PanelContent() constructor { draw_set_text(f_p0, fa_left, fa_center, tc); var ww = string_width(txt) + ui(12); if(pHOVER && point_in_rectangle(mx, my, _xx1, y1 - ui(16), _xx1 + ww, y1 + ui(16))) { + _draggable = false; draw_sprite_stretched_ext(THEME.button_hide_fill, 1, _xx1, y1 - ui(16), ww, ui(32), sc, 1); if(mouse_press(mb_left, pFOCUS)) @@ -705,6 +719,7 @@ function Panel_Menu() : PanelContent() constructor { var _b = buttonInstant(THEME.button_hide_fill, tbx0, tby0, tw, th, [mx, my], pFOCUS, pHOVER); var _hov = _b > 0; + if(_b) _draggable = false; if(_b == 2) { _hov = true; var arr = []; @@ -755,5 +770,10 @@ function Panel_Menu() : PanelContent() constructor { draw_sprite_ext(s_patreon_supporter, 1, _cx, _cy, 1, 1, 0, _ib, 1); } #endregion + + #region drag + if(mouse_press(mb_left, _draggable)) + winMan_initDrag(0b10000); + #endregion } #endregion } \ No newline at end of file diff --git a/scripts/preferences/preferences.gml b/scripts/preferences/preferences.gml index 66d3743fa..3a58a7007 100644 --- a/scripts/preferences/preferences.gml +++ b/scripts/preferences/preferences.gml @@ -164,9 +164,9 @@ map.key = save_l; - PREFERENCES.window_maximize = gameframe_is_maximized(); - PREFERENCES.window_width = max(960, WIN_W); - PREFERENCES.window_height = max(600, WIN_H); + PREFERENCES.window_maximize = window_is_maximized; + PREFERENCES.window_width = max(960, window_minimize_size[0]); + PREFERENCES.window_height = max(600, window_minimize_size[1]); map.preferences = PREFERENCES; @@ -215,15 +215,18 @@ if(OS != os_macosx && !LOADING) { if(PREFERENCES.window_maximize) { - gameframe_maximize(); + winMan_Maximize(); } else { 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); } } + + window_refresh(); game_set_speed(PREFERENCES.ui_framerate, gamespeed_fps); var grav = struct_try_get(PREFERENCES, "physics_gravity", [ 0, 10 ]); diff --git a/scripts/windowManager/windowManager.gml b/scripts/windowManager/windowManager.gml new file mode 100644 index 000000000..47e9f616c --- /dev/null +++ b/scripts/windowManager/windowManager.gml @@ -0,0 +1,233 @@ +#region defines + globalvar window_resize_padding; window_resize_padding = 6; + globalvar window_minimize_size; window_minimize_size = [ 1920, 1080 ]; + globalvar window_is_maximized; window_is_maximized = false; + globalvar window_is_fullscreen; window_is_fullscreen = false; + globalvar window_drag_status; window_drag_status = 0; + globalvar window_drag_hold; window_drag_hold = 0; + globalvar window_drag_mx; window_drag_mx = 0; + globalvar window_drag_my; window_drag_my = 0; + globalvar window_drag_sx; window_drag_sx = 0; + 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_min_w; window_min_w = 960; + globalvar window_min_h; window_min_h = 600; + + #macro DISPLAY_REFRESH CURRENT_PANEL = panelSerialize(); display_refresh(); +#endregion + +function winMan_getData(curr = true) { #region + INLINE + var _monitors = display_measure_all(); + var _x = window_get_x(); + var _y = window_get_y(); + + for( var i = 0, n = array_length(_monitors); i < n; i++ ) { + var _monitor = _monitors[i]; + if(!is_array(_monitor) || array_length(_monitor) < 8) continue; + + if(point_in_rectangle( + _x + WIN_W / 2, + _y + WIN_H / 2, + _monitor[0], + _monitor[1], + _monitor[0] + _monitor[2], + _monitor[1] + _monitor[3] + )) return _monitor; + } + + if(!is_array(_monitor) || array_length(_monitor) < 8) + return [ 0, 0, display_get_width(), display_get_height(), + 0, 0, display_get_width(), display_get_height(), ]; + return _monitors[0]; +} #endregion + +function winMan_setRect(_x, _y, _w, _h) { #region + 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 + INLINE + return gameframe_is_natively_minimized(); +} #endregion + +function winMan_Maximize() { #region + INLINE + if(gameframe_is_natively_minimized()) return; + window_is_maximized = true; + + var _mon = winMan_getData(); + winMan_setRect(_mon[4], _mon[5], _mon[6], _mon[7]); + gameframe_set_shadow(false); +} #endregion + +function winMan_Unmaximize() { #region + INLINE + if(gameframe_is_natively_minimized()) return; + window_is_maximized = false; + + var _mon = winMan_getData(); + + winMan_setRect( + _mon[4] + _mon[6] / 2 - window_minimize_size[0] / 2, + _mon[5] + _mon[7] / 2 - window_minimize_size[1] / 2, + window_minimize_size[0], + window_minimize_size[1] + ); + gameframe_set_shadow(true); +} #endregion + +function winMan_Minimize() { #region + INLINE + if(gameframe_is_natively_minimized()) return; + gameframe_syscommand(61472); +} #endregion + +function winMan_initDrag(_index) { #region + window_drag_status = _index; + window_drag_hold = 0; + window_drag_mx = mouse_raw_x; + window_drag_my = mouse_raw_y; + window_drag_sx = window_get_x(); + window_drag_sy = window_get_y(); + window_drag_sw = window_get_width(); + window_drag_sh = window_get_height(); +} #endregion + +function winMan_setFullscreen(full) { #region + if(full == window_is_fullscreen) return; + window_is_fullscreen = full; + + var _mon = winMan_getData(); + if(full) { + winMan_setRect(_mon[0], _mon[1], _mon[2], _mon[3]); + gameframe_set_shadow(false); + } else { + if(window_is_maximized) winMan_Maximize(); + else winMan_Unmaximize(); + } + + run_in(5, function() { DISPLAY_REFRESH }); +} #endregion + +function winManStep() { #region + if(window_drag_status == 0) return; + var _mx = window_drag_mx; + var _my = window_drag_my; + var _sx = window_drag_sx; + var _sy = window_drag_sy; + var _sw = window_drag_sw; + var _sh = window_drag_sh; + + var mx = mouse_raw_x; + var my = mouse_raw_y; + var sx = _sx; + var sy = _sy; + var sw = _sw; + var sh = _sh; + + if(window_drag_status & 0b10000) { + if(window_drag_hold == 0 && window_is_maximized) { + if(point_distance(mx, my, _mx, _my) > 8) + window_drag_hold = 1; + } else if(window_drag_hold == 1) { + if(window_is_maximized) { + winMan_Unmaximize(); + window_drag_sw = window_minimize_size[0]; + window_drag_sh = window_minimize_size[1]; + } else { + sx = _sx + (mx - _mx); + sy = _sy + (my - _my); + + winMan_setRect(sx, sy, sw, sh); + } + } + } else { + if(window_drag_status & 0b0001) { + sw = _sw + (mx - _mx); + } + + if(window_drag_status & 0b0010) { + sh = max(window_min_h, _sh - (my - _my)); + sy = _sy + (_sh - sh); + } + + if(window_drag_status & 0b0100) { + sw = max(window_min_w, _sw - (mx - _mx)); + sx = _sx + (_sw - sw); + } + + if(window_drag_status & 0b1000) { + sh = _sh + (my - _my); + } + + winMan_setRect(sx, sy, sw, sh); + } + + if(mouse_release(mb_left)) { + window_minimize_size = [ sw, sh ]; + window_drag_status = 0; + DISPLAY_REFRESH + } +} #endregion + +function winManDraw() { #region + if(window_is_maximized || window_is_fullscreen) return; + + var pd = window_resize_padding; + var hv = -1; + + var l = mouse_mx > 0 && mouse_mx < pd && mouse_my > 0 && mouse_my < WIN_H; + var r = mouse_mx > WIN_W - pd && mouse_mx < WIN_W && mouse_my > 0 && mouse_my < WIN_H; + var u = mouse_mx > 0 && mouse_mx < WIN_W && mouse_my > 0 && mouse_my < pd; + var d = mouse_mx > 0 && mouse_mx < WIN_W && mouse_my > WIN_H - pd && mouse_my < WIN_H; + + if(r) { + CURSOR = cr_size_we; + hv = 0b0001; + } + + if(u) { + CURSOR = cr_size_ns; + hv = 0b0010; + } + + if(l) { + CURSOR = cr_size_we; + hv = 0b0100; + } + + if(d) { + CURSOR = cr_size_ns; + hv = 0b1000; + } + + if(l && u) { + CURSOR = cr_size_nwse; + hv = 0b0110; + } + + if(r && d) { + CURSOR = cr_size_nwse; + hv = 0b1001; + } + + if(l && d) { + CURSOR = cr_size_nesw; + hv = 0b1100; + } + + if(r && u) { + CURSOR = cr_size_nesw; + hv = 0b0011; + } + + if(hv > -1 && mouse_press(mb_left)) + winMan_initDrag(hv); +} #endregion \ No newline at end of file diff --git a/scripts/gameframe/gameframe.yy b/scripts/windowManager/windowManager.yy similarity index 56% rename from scripts/gameframe/gameframe.yy rename to scripts/windowManager/windowManager.yy index 09fc8ff93..527163758 100644 --- a/scripts/gameframe/gameframe.yy +++ b/scripts/windowManager/windowManager.yy @@ -1,11 +1,11 @@ { "resourceType": "GMScript", "resourceVersion": "1.0", - "name": "gameframe", + "name": "windowManager", "isCompatibility": false, "isDnD": false, "parent": { - "name": "Gameframe", - "path": "folders/_extensions/Gameframe.yy", + "name": "WinMan", + "path": "folders/_extensions/WinMan.yy", }, } \ No newline at end of file