From 3616cb3fdd15f01b40308e3195dfb5e0ead7c366 Mon Sep 17 00:00:00 2001 From: setupwitch <165732903+setupwitch@users.noreply.github.com> Date: Tue, 17 Feb 2026 02:14:56 -0500 Subject: [PATCH 1/3] rewrite entire input system i did that yeah --- CompleteCook.resource_order | 5 +- CompleteCook.yyp | 6 +- objects/obj_bossgate/Create_0.gml | 3 +- objects/obj_bossgate/Step_0.gml | 2 +- objects/obj_door/Collision_obj_player.gml | 2 +- objects/obj_door/Create_0.gml | 3 +- objects/obj_inputcontroller/Create_0.gml | 54 ++++ objects/obj_inputcontroller/Other_75.gml | 26 ++ objects/obj_inputcontroller/Step_1.gml | 12 + .../obj_inputcontroller.yy | 37 +++ objects/obj_keyconfig/CleanUp_0.gml | 2 + objects/obj_keyconfig/Create_0.gml | 35 +- objects/obj_keyconfig/Step_0.gml | 37 +-- objects/obj_menuhandler/CleanUp_0.gml | 1 + objects/obj_menuhandler/Create_0.gml | 32 +- objects/obj_menuhandler/Draw_0.gml | 4 +- objects/obj_menuhandler/Step_0.gml | 9 +- objects/obj_menuhandler/obj_menuhandler.yy | 1 + objects/obj_options/Create_0.gml | 24 +- objects/obj_options/Step_0.gml | 8 +- objects/obj_pause/CleanUp_0.gml | 1 + objects/obj_pause/Create_0.gml | 26 +- objects/obj_pause/Step_0.gml | 62 +++- objects/obj_pause/Step_1.gml | 57 ---- objects/obj_pause/obj_pause.yy | 2 +- objects/obj_pizzabox/Create_0.gml | 7 +- objects/obj_pizzabox/Step_0.gml | 4 +- objects/obj_player/CleanUp_0.gml | 1 + objects/obj_player/Create_0.gml | 32 +- objects/obj_player/Step_0.gml | 12 +- objects/obj_player/obj_player.yy | 1 + objects/obj_startgate/CleanUp_0.gml | 2 + objects/obj_startgate/Create_0.gml | 4 +- objects/obj_startgate/Step_0.gml | 2 +- objects/obj_windowmodeconfirm/CleanUp_0.gml | 1 + objects/obj_windowmodeconfirm/Create_0.gml | 22 +- objects/obj_windowmodeconfirm/Step_0.gml | 5 +- .../obj_windowmodeconfirm.yy | 1 + rooms/loadingroom/loadingroom.yy | 4 +- .../generic_functions_util.gml | 95 ++++-- scripts/input_util/input_util.gml | 232 -------------- scripts/scr_input/scr_input.gml | 302 ++++++++++++++++++ .../input_util.yy => scr_input/scr_input.yy} | 8 +- .../scr_inputdeclarations.gml | 29 ++ .../scr_inputdeclarations.yy} | 8 +- scripts/scr_savesystem/scr_savesystem.gml | 218 ------------- 46 files changed, 768 insertions(+), 673 deletions(-) create mode 100644 objects/obj_inputcontroller/Create_0.gml create mode 100644 objects/obj_inputcontroller/Other_75.gml create mode 100644 objects/obj_inputcontroller/Step_1.gml create mode 100644 objects/obj_inputcontroller/obj_inputcontroller.yy create mode 100644 objects/obj_menuhandler/CleanUp_0.gml create mode 100644 objects/obj_pause/CleanUp_0.gml delete mode 100644 objects/obj_pause/Step_1.gml create mode 100644 objects/obj_player/CleanUp_0.gml create mode 100644 objects/obj_windowmodeconfirm/CleanUp_0.gml delete mode 100644 scripts/input_util/input_util.gml create mode 100644 scripts/scr_input/scr_input.gml rename scripts/{input_util/input_util.yy => scr_input/scr_input.yy} (56%) create mode 100644 scripts/scr_inputdeclarations/scr_inputdeclarations.gml rename scripts/{scr_savesystem/scr_savesystem.yy => scr_inputdeclarations/scr_inputdeclarations.yy} (51%) delete mode 100644 scripts/scr_savesystem/scr_savesystem.gml diff --git a/CompleteCook.resource_order b/CompleteCook.resource_order index 59829e84c..5de09bd90 100644 --- a/CompleteCook.resource_order +++ b/CompleteCook.resource_order @@ -4,6 +4,7 @@ {"name":"Extensions","order":11,"path":"folders/Extensions.yy",}, {"name":"Gameframe","order":1,"path":"folders/Extensions/Gameframe.yy",}, {"name":"Fonts","order":4,"path":"folders/Fonts.yy",}, + {"name":"InputSystem","order":16,"path":"folders/InputSystem.yy",}, {"name":"Notes","order":10,"path":"folders/Notes.yy",}, {"name":"Objects","order":6,"path":"folders/Objects.yy",}, {"name":"Boss","order":8,"path":"folders/Objects/Boss.yy",}, @@ -261,7 +262,6 @@ {"name":"gameframe_macros","order":1,"path":"scripts/gameframe_macros/gameframe_macros.yy",}, {"name":"generic_functions_util","order":2,"path":"scripts/generic_functions_util/generic_functions_util.yy",}, {"name":"hud_get_visible","order":20,"path":"scripts/hud_get_visible/hud_get_visible.yy",}, - {"name":"input_util","order":1,"path":"scripts/input_util/input_util.yy",}, {"name":"key_util","order":14,"path":"scripts/key_util/key_util.yy",}, {"name":"particle_util","order":7,"path":"scripts/particle_util/particle_util.yy",}, {"name":"player_actor","order":13,"path":"scripts/player_actor/player_actor.yy",}, @@ -295,9 +295,10 @@ {"name":"player_taunt","order":11,"path":"scripts/player_taunt/player_taunt.yy",}, {"name":"player_tumble","order":4,"path":"scripts/player_tumble/player_tumble.yy",}, {"name":"player_util","order":6,"path":"scripts/player_util/player_util.yy",}, + {"name":"scr_input","order":1,"path":"scripts/scr_input/scr_input.yy",}, + {"name":"scr_inputdeclarations","order":2,"path":"scripts/scr_inputdeclarations/scr_inputdeclarations.yy",}, {"name":"scr_pattern_utilities","order":4,"path":"scripts/scr_pattern_utilities/scr_pattern_utilities.yy",}, {"name":"scr_retro_pal_swapper_utilities","order":1,"path":"scripts/scr_retro_pal_swapper_utilities/scr_retro_pal_swapper_utilities.yy",}, - {"name":"scr_savesystem","order":16,"path":"scripts/scr_savesystem/scr_savesystem.yy",}, {"name":"shell_commands","order":11,"path":"scripts/shell_commands/shell_commands.yy",}, {"name":"sound_util","order":10,"path":"scripts/sound_util/sound_util.yy",}, {"name":"text_util","order":17,"path":"scripts/text_util/text_util.yy",}, diff --git a/CompleteCook.yyp b/CompleteCook.yyp index 503bd78e9..76e2ce31e 100644 --- a/CompleteCook.yyp +++ b/CompleteCook.yyp @@ -16,6 +16,7 @@ {"$GMFolder":"","%Name":"Extensions","folderPath":"folders/Extensions.yy","name":"Extensions","resourceType":"GMFolder","resourceVersion":"2.0",}, {"$GMFolder":"","%Name":"Gameframe","folderPath":"folders/Extensions/Gameframe.yy","name":"Gameframe","resourceType":"GMFolder","resourceVersion":"2.0",}, {"$GMFolder":"","%Name":"Fonts","folderPath":"folders/Fonts.yy","name":"Fonts","resourceType":"GMFolder","resourceVersion":"2.0",}, + {"$GMFolder":"","%Name":"InputSystem","folderPath":"folders/InputSystem.yy","name":"InputSystem","resourceType":"GMFolder","resourceVersion":"2.0",}, {"$GMFolder":"","%Name":"Notes","folderPath":"folders/Notes.yy","name":"Notes","resourceType":"GMFolder","resourceVersion":"2.0",}, {"$GMFolder":"","%Name":"Objects","folderPath":"folders/Objects.yy","name":"Objects","resourceType":"GMFolder","resourceVersion":"2.0",}, {"$GMFolder":"","%Name":"Boss","folderPath":"folders/Objects/Boss.yy","name":"Boss","resourceType":"GMFolder","resourceVersion":"2.0",}, @@ -179,6 +180,7 @@ {"id":{"name":"obj_hallway","path":"objects/obj_hallway/obj_hallway.yy",},}, {"id":{"name":"obj_hudhpdebris","path":"objects/obj_hudhpdebris/obj_hudhpdebris.yy",},}, {"id":{"name":"obj_hurtbox","path":"objects/obj_hurtbox/obj_hurtbox.yy",},}, + {"id":{"name":"obj_inputcontroller","path":"objects/obj_inputcontroller/obj_inputcontroller.yy",},}, {"id":{"name":"obj_key","path":"objects/obj_key/obj_key.yy",},}, {"id":{"name":"obj_keyconfig","path":"objects/obj_keyconfig/obj_keyconfig.yy",},}, {"id":{"name":"obj_keydoor","path":"objects/obj_keydoor/obj_keydoor.yy",},}, @@ -315,7 +317,6 @@ {"id":{"name":"gameframe","path":"scripts/gameframe/gameframe.yy",},}, {"id":{"name":"generic_functions_util","path":"scripts/generic_functions_util/generic_functions_util.yy",},}, {"id":{"name":"hud_get_visible","path":"scripts/hud_get_visible/hud_get_visible.yy",},}, - {"id":{"name":"input_util","path":"scripts/input_util/input_util.yy",},}, {"id":{"name":"key_util","path":"scripts/key_util/key_util.yy",},}, {"id":{"name":"particle_util","path":"scripts/particle_util/particle_util.yy",},}, {"id":{"name":"player_actor","path":"scripts/player_actor/player_actor.yy",},}, @@ -350,10 +351,11 @@ {"id":{"name":"player_taunt","path":"scripts/player_taunt/player_taunt.yy",},}, {"id":{"name":"player_tumble","path":"scripts/player_tumble/player_tumble.yy",},}, {"id":{"name":"player_util","path":"scripts/player_util/player_util.yy",},}, + {"id":{"name":"scr_input","path":"scripts/scr_input/scr_input.yy",},}, + {"id":{"name":"scr_inputdeclarations","path":"scripts/scr_inputdeclarations/scr_inputdeclarations.yy",},}, {"id":{"name":"scr_pattern_utilities","path":"scripts/scr_pattern_utilities/scr_pattern_utilities.yy",},}, {"id":{"name":"scr_retro_pal_swapper_utilities","path":"scripts/scr_retro_pal_swapper_utilities/scr_retro_pal_swapper_utilities.yy",},}, {"id":{"name":"scr_retro_pal_swapper","path":"scripts/scr_retro_pal_swapper/scr_retro_pal_swapper.yy",},}, - {"id":{"name":"scr_savesystem","path":"scripts/scr_savesystem/scr_savesystem.yy",},}, {"id":{"name":"shell_commands","path":"scripts/shell_commands/shell_commands.yy",},}, {"id":{"name":"sound_util","path":"scripts/sound_util/sound_util.yy",},}, {"id":{"name":"text_util","path":"scripts/text_util/text_util.yy",},}, diff --git a/objects/obj_bossgate/Create_0.gml b/objects/obj_bossgate/Create_0.gml index ef89686c4..2289d111e 100644 --- a/objects/obj_bossgate/Create_0.gml +++ b/objects/obj_bossgate/Create_0.gml @@ -1,5 +1,4 @@ -enter_door = new Input(global.keybinds.up); - +enter_door = false; bg_surf = -1 image_speed = 0 diff --git a/objects/obj_bossgate/Step_0.gml b/objects/obj_bossgate/Step_0.gml index 452e90130..4e7113886 100644 --- a/objects/obj_bossgate/Step_0.gml +++ b/objects/obj_bossgate/Step_0.gml @@ -1,4 +1,4 @@ -enter_door.update(global.keybinds.up); +enter_door = obj_player.input.up; // update input if (place_meeting(x, y, obj_player) && scr_can_enter_door(obj_player.state) && enter_door.check && obj_player.grounded) { diff --git a/objects/obj_door/Collision_obj_player.gml b/objects/obj_door/Collision_obj_player.gml index 7580f81df..c04bd6847 100644 --- a/objects/obj_door/Collision_obj_player.gml +++ b/objects/obj_door/Collision_obj_player.gml @@ -1,4 +1,4 @@ -enter_door.update(global.keybinds.up); +enter_door = obj_player.input.up; // update input if (other.bbox_bottom <= bbox_bottom + 1 && other.bbox_bottom >= bbox_bottom - 1 && enter_door.check && scr_can_enter_door(other.state)) { diff --git a/objects/obj_door/Create_0.gml b/objects/obj_door/Create_0.gml index f14056a99..fc210fb59 100644 --- a/objects/obj_door/Create_0.gml +++ b/objects/obj_door/Create_0.gml @@ -1,2 +1,3 @@ depth = 50 -enter_door = new Input(global.keybinds.up); \ No newline at end of file + +enter_door = false; \ No newline at end of file diff --git a/objects/obj_inputcontroller/Create_0.gml b/objects/obj_inputcontroller/Create_0.gml new file mode 100644 index 000000000..51e5e9134 --- /dev/null +++ b/objects/obj_inputcontroller/Create_0.gml @@ -0,0 +1,54 @@ +/* + + Put me in the init room! + +*/ + +// ensure only one of me exists +if (instance_number(obj_inputcontroller) > 1) +{ + instance_destroy(); + exit; +} + +devices = []; // the devices that are used for input, this can be controllers, keyboard input, etc. +handler_instances = []; // the instances of InputHandlers that will be updated at begin step. + +// jsdoc inside of the anonymous functions because of event naming issues + +device_add = function(_input_device) +{ + ///@description Add a device + ///@param {Struct.InputDevice} _input_device The InputDevice to push to the devices. + array_push(devices, _input_device); +} + +device_remove = function(_index) +{ + ///@description Remove a device + ///@param {Real} _index The index of the array to delete. + array_delete(devices, _index, 1); +} + +gamepad_find = function(_gamepad_id) +{ + ///@description Finds the position of a gamepad in the devices + ///@param {Real} _gamepad_id The gamepad index to look for. + for (var i = 0; i < array_length(devices); i++) + { + var _device = devices[i]; + if (_device.index == _gamepad_id && _device.input_type == INPUT_TYPE.CONTROLLER) + return i; + } + return -1; +} + +// add a device for the main keyboard input +keyboard_device = new InputDevice(); // always at index 0 +device_add(keyboard_device); + +// always add main gamepad so it can be referenced immediately in other parts +main_gamepad = new InputDevice(INPUT_TYPE.CONTROLLER, 0); +device_add(main_gamepad); + + diff --git a/objects/obj_inputcontroller/Other_75.gml b/objects/obj_inputcontroller/Other_75.gml new file mode 100644 index 000000000..dfa48bf13 --- /dev/null +++ b/objects/obj_inputcontroller/Other_75.gml @@ -0,0 +1,26 @@ +var _type = async_load[? "event_type"]; +var _index; + +if (_type == "gamepad discovered") +{ + _index = async_load[? "pad_index"]; + + // if theres no gamepad connected yet, we use the one created earlier + // handles cases where the gamepad is at a weird index + if (!gamepad_is_connected(main_gamepad.index)) + { + main_gamepad.index = _index; + gamepad_set_axis_deadzone(_index, DEADZONE); + } + else + { + // if the main gamepad is occupied add this as a new device + if (gamepad_find(_index) == -1) + device_add(new InputDevice(INPUT_TYPE.CONTROLLER, _index)); + } +} +else if (_type == "gamepad lost") +{ + _index = async_load[? "pad_index"]; + device_remove(gamepad_find(_index)); +} \ No newline at end of file diff --git a/objects/obj_inputcontroller/Step_1.gml b/objects/obj_inputcontroller/Step_1.gml new file mode 100644 index 000000000..d3e12e8a6 --- /dev/null +++ b/objects/obj_inputcontroller/Step_1.gml @@ -0,0 +1,12 @@ +for (var i = 0; i < array_length(handler_instances); i++) +{ + var _handler = handler_instances[i]; + if (_handler.to_cleanup) + { + delete _handler; + array_delete(handler_instances, i--, 1); + continue; + } + _handler.update(); +} + diff --git a/objects/obj_inputcontroller/obj_inputcontroller.yy b/objects/obj_inputcontroller/obj_inputcontroller.yy new file mode 100644 index 000000000..4197e81a0 --- /dev/null +++ b/objects/obj_inputcontroller/obj_inputcontroller.yy @@ -0,0 +1,37 @@ +{ + "$GMObject":"", + "%Name":"obj_inputcontroller", + "eventList":[ + {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":75,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":3,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + ], + "managed":true, + "name":"obj_inputcontroller", + "overriddenProperties":[], + "parent":{ + "name":"InputSystem", + "path":"folders/InputSystem.yy", + }, + "parentObjectId":null, + "persistent":true, + "physicsAngularDamping":0.1, + "physicsDensity":0.5, + "physicsFriction":0.2, + "physicsGroup":1, + "physicsKinematic":false, + "physicsLinearDamping":0.1, + "physicsObject":false, + "physicsRestitution":0.1, + "physicsSensor":false, + "physicsShape":1, + "physicsShapePoints":[], + "physicsStartAwake":true, + "properties":[], + "resourceType":"GMObject", + "resourceVersion":"2.0", + "solid":false, + "spriteId":null, + "spriteMaskId":null, + "visible":true, +} \ No newline at end of file diff --git a/objects/obj_keyconfig/CleanUp_0.gml b/objects/obj_keyconfig/CleanUp_0.gml index 0d03b63e0..64fb33b05 100644 --- a/objects/obj_keyconfig/CleanUp_0.gml +++ b/objects/obj_keyconfig/CleanUp_0.gml @@ -4,3 +4,5 @@ var keybindBuf = write_struct_to_buffer(global.keybinds) buffer_save(keybindBuf, global.keybinds_filename) buffer_delete(keybindBuf) + +input_handler.Cleanup(); \ No newline at end of file diff --git a/objects/obj_keyconfig/Create_0.gml b/objects/obj_keyconfig/Create_0.gml index 8a9c23c6f..60d6ea4ac 100644 --- a/objects/obj_keyconfig/Create_0.gml +++ b/objects/obj_keyconfig/Create_0.gml @@ -1,14 +1,27 @@ // declare input -ui_input = +input_handler = new InputHandler(obj_inputcontroller.main_gamepad).AddInput(["ui_up", "ui_down", "ui_accept", "ui_deny", "addbind", "clearbind", "resetallbinds"]).Finalize(); + +ui_input = +{ + up: false, + down: false, + accept: false, + deny: false, + addbind: false, + clearbind: false, + resetallbinds: false +} + +update_input = function() { - up: new Input(global.keybinds.ui_up), - down: new Input(global.keybinds.ui_down), - accept: new Input(global.keybinds.ui_accept), - deny: new Input(global.keybinds.ui_deny), - addbind: new Input("Z"), - clearbind: new Input("C"), - resetallbinds: new Input(vk_f1) -}; + ui_input.up = input_handler.get_input("ui_up"); + ui_input.down = input_handler.get_input("ui_down"); + ui_input.accept = input_handler.get_input("ui_accept"); + ui_input.deny = input_handler.get_input("ui_deny"); + ui_input.addbind = input_handler.get_input("addbind"); + ui_input.clearbind = input_handler.get_input("clearbind"); + ui_input.resetallbinds = input_handler.get_input("resetallbinds"); +} depth = -3000 binds = [ @@ -26,8 +39,8 @@ binds = [ {input: global.keybinds.ui_right, image_index: 2, name: "Menu Right", globalname: "ui_right", defaultbind: vk_right}, {input: global.keybinds.ui_up, image_index: 0, name: "Menu Up", globalname: "ui_up", defaultbind: vk_up}, {input: global.keybinds.ui_down, image_index: 1, name: "Menu Down", globalname: "ui_down", defaultbind: vk_down}, - {input: global.keybinds.ui_accept, image_index: 7, name: "Accept", globalname: "ui_accept", defaultbind: [vk_enter, vk_space, "Z"]}, - {input: global.keybinds.ui_deny, image_index: 8, name: "Deny", globalname: "ui_deny", defaultbind: [vk_escape, vk_backspace, "X"]} + {input: global.keybinds.ui_accept, image_index: 7, name: "Accept", globalname: "ui_accept", defaultbind: "Z"}, + {input: global.keybinds.ui_deny, image_index: 8, name: "Deny", globalname: "ui_deny", defaultbind: "X"} ] //dont mind these warnings c_x = 0 diff --git a/objects/obj_keyconfig/Step_0.gml b/objects/obj_keyconfig/Step_0.gml index f9a712794..d0ea0598a 100644 --- a/objects/obj_keyconfig/Step_0.gml +++ b/objects/obj_keyconfig/Step_0.gml @@ -1,11 +1,4 @@ -// update input -ui_input.up.update(global.keybinds.ui_up); -ui_input.down.update(global.keybinds.ui_down); -ui_input.accept.update(global.keybinds.ui_accept); -ui_input.deny.update(global.keybinds.ui_deny); -ui_input.addbind.update("Z"); -ui_input.clearbind.update("C"); -ui_input.resetallbinds.update(vk_f1); +update_input(); if !binding selected = clamp(selected + (-ui_input.up.pressed + ui_input.down.pressed), -1, array_length(binds) - 1) @@ -28,33 +21,35 @@ if binding else { if is_real(global.keybinds[$ bindname]) - global.keybinds[$ bindname] = [global.keybinds[$ bindname]] //convert it to array + global.keybinds[$ bindname] = global.keybinds[$ bindname]; else if is_string(global.keybinds[$ bindname]) - global.keybinds[$ bindname] = [ord(global.keybinds[$ bindname])] + global.keybinds[$ bindname] = ord(global.keybinds[$ bindname]); - if !array_contains(global.keybinds[$ bindname], keyboard_key) //check if the key isnt set already - array_push(global.keybinds[$ bindname], keyboard_key) //then add the key } - binds[selected].input = global.keybinds[$ bindname] - binding = false + binds[selected].input = global.keybinds[$ bindname]; + binding = false; + + update_binds(); } } else { if ui_input.addbind.pressed - binding = true + binding = true; else if ui_input.clearbind.pressed { - global.keybinds[$ bindname] = vk_nokey - binds[selected].input = global.keybinds[$ bindname] + global.keybinds[$ bindname] = vk_nokey; + binds[selected].input = global.keybinds[$ bindname]; } else if ui_input.resetallbinds.pressed { - array_foreach(binds, function(_element) { - _element.input = _element.defaultbind - global.keybinds[$ _element.globalname] = _element.defaultbind - }) + array_foreach(binds, function(_element) + { + _element.input = _element.defaultbind; + global.keybinds[$ _element.globalname] = _element.defaultbind; + }); + update_binds(); } if ui_input.deny.pressed instance_destroy() diff --git a/objects/obj_menuhandler/CleanUp_0.gml b/objects/obj_menuhandler/CleanUp_0.gml new file mode 100644 index 000000000..7cad908b5 --- /dev/null +++ b/objects/obj_menuhandler/CleanUp_0.gml @@ -0,0 +1 @@ +input_handler.Cleanup(); \ No newline at end of file diff --git a/objects/obj_menuhandler/Create_0.gml b/objects/obj_menuhandler/Create_0.gml index a43d51686..de6006523 100644 --- a/objects/obj_menuhandler/Create_0.gml +++ b/objects/obj_menuhandler/Create_0.gml @@ -1,25 +1,23 @@ -// declare input -special_keybind_deny = variable_clone(global.keybinds.ui_deny) //special conflicting input removal - -if is_array(special_keybind_deny) -{ - var _d_ix = array_get_index(special_keybind_deny, ord("X")) - - if _d_ix != -1 - array_delete(special_keybind_deny, _d_ix, 1) -} - -show_debug_message(special_keybind_deny) +input_handler = new InputHandler(obj_inputcontroller.main_gamepad).AddInput(["ui_left", "ui_right", "grab", "ui_accept", "menuhandler_deny"]).Finalize(); input = { - left: new Input(global.keybinds.ui_left), - right: new Input(global.keybinds.ui_right), - grab: new Input(global.keybinds.grab), - accept: new Input(global.keybinds.ui_accept), - deny: new Input(special_keybind_deny) + left: false, + right: false, + grab: false, + accept: false, + deny: false }; +update_input = function() +{ + input.left = input_handler.get_input("ui_left"); + input.right = input_handler.get_input("ui_right"); + input.grab = input_handler.get_input("grab"); + input.accept = input_handler.get_input("ui_accept"); + input.deny = input_handler.get_input("menuhandler_deny"); +} + tvs = [new ini_menu_tv_inst(103, 0, spr_menutv1_off, spr_menutv1_whitenoise, diff --git a/objects/obj_menuhandler/Draw_0.gml b/objects/obj_menuhandler/Draw_0.gml index 3aedf7b46..928cc1c0b 100644 --- a/objects/obj_menuhandler/Draw_0.gml +++ b/objects/obj_menuhandler/Draw_0.gml @@ -33,9 +33,9 @@ draw_set_alpha(optionsalpha) draw_set_align(fa_center, fa_middle) draw_sprite(spr_menuquit, 0, 0, 0); -cc_draw_key_arr(63, 115, global.keybinds.grab) +cc_draw_key_arr(63, 115, global.keybinds.grab[INPUT_TYPE.KEYBOARD]); draw_sprite(spr_menupause, 0, 819, 84); -cc_draw_key_arr(745, 65, special_keybind_deny) +cc_draw_key_arr(745, 65, global.keybinds.menuhandler_deny[INPUT_TYPE.KEYBOARD]); draw_reset_color(1) diff --git a/objects/obj_menuhandler/Step_0.gml b/objects/obj_menuhandler/Step_0.gml index 5c7355644..af731870f 100644 --- a/objects/obj_menuhandler/Step_0.gml +++ b/objects/obj_menuhandler/Step_0.gml @@ -1,15 +1,10 @@ -// update input -input.left.update(global.keybinds.ui_left); -input.right.update(global.keybinds.ui_right); -input.grab.update(global.keybinds.grab); -input.accept.update(global.keybinds.ui_accept); -input.deny.update(special_keybind_deny); +update_input(); var abletoinput = !instance_exists(obj_options) && !instance_exists(obj_quitgame) && state == 0 if menu_dark { - if keyboard_check_pressed(vk_anykey) && dark_state == 0 + if input.accept.pressed && dark_state == 0 { scr_sound(sfx_menulight) audio_sound_loop_end(mu, audio_sound_length(mu_mainmenu)) diff --git a/objects/obj_menuhandler/obj_menuhandler.yy b/objects/obj_menuhandler/obj_menuhandler.yy index c60f2ac1a..043298943 100644 --- a/objects/obj_menuhandler/obj_menuhandler.yy +++ b/objects/obj_menuhandler/obj_menuhandler.yy @@ -10,6 +10,7 @@ {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":2,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":2,"eventType":2,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":3,"eventType":2,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":12,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, ], "managed":true, "name":"obj_menuhandler", diff --git a/objects/obj_options/Create_0.gml b/objects/obj_options/Create_0.gml index 66577b80c..d463de6b9 100644 --- a/objects/obj_options/Create_0.gml +++ b/objects/obj_options/Create_0.gml @@ -1,14 +1,26 @@ // declare input +input_handler = new InputHandler(obj_inputcontroller.main_gamepad).AddInput(["ui_left", "ui_right", "ui_up", "ui_down", "ui_accept", "ui_deny"]).Finalize(); + ui_input = { - left: new Input(global.keybinds.ui_left), - right: new Input(global.keybinds.ui_right), - up: new Input(global.keybinds.ui_up), - down: new Input(global.keybinds.ui_down), - accept: new Input(global.keybinds.ui_accept), - deny: new Input(global.keybinds.ui_deny) + left: false, + right: false, + up: false, + down: false, + accept: false, + deny: false }; +update_input = function() +{ + ui_input.left = input_handler.get_input("ui_left"); + ui_input.right = input_handler.get_input("ui_right"); + ui_input.up = input_handler.get_input("ui_up"); + ui_input.down = input_handler.get_input("ui_down"); + ui_input.accept = input_handler.get_input("ui_accept"); + ui_input.deny = input_handler.get_input("ui_deny"); +} + depth = -100 optionselected = 0 diff --git a/objects/obj_options/Step_0.gml b/objects/obj_options/Step_0.gml index d4b4880ce..c955cf1a5 100644 --- a/objects/obj_options/Step_0.gml +++ b/objects/obj_options/Step_0.gml @@ -10,13 +10,7 @@ if inputbuffer > 0 exit; } -// update input -ui_input.left.update(global.keybinds.ui_left); -ui_input.right.update(global.keybinds.ui_right); -ui_input.up.update(global.keybinds.ui_up); -ui_input.down.update(global.keybinds.ui_down); -ui_input.accept.update(global.keybinds.ui_accept); -ui_input.deny.update(global.keybinds.ui_deny); +update_input(); var _back_arr = [-1, 0, 0, 0, 0, 2] //array of indexes to get based on list index _back_arr[64] = 0 diff --git a/objects/obj_pause/CleanUp_0.gml b/objects/obj_pause/CleanUp_0.gml new file mode 100644 index 000000000..7cad908b5 --- /dev/null +++ b/objects/obj_pause/CleanUp_0.gml @@ -0,0 +1 @@ +input_handler.Cleanup(); \ No newline at end of file diff --git a/objects/obj_pause/Create_0.gml b/objects/obj_pause/Create_0.gml index c48c84403..57fa2cd1f 100644 --- a/objects/obj_pause/Create_0.gml +++ b/objects/obj_pause/Create_0.gml @@ -20,17 +20,31 @@ create_pause_screen_asset = function(_spr, _startx = 0, _starty = 0, _endx = 0, image_yscale = _yscale } +input_handler = new InputHandler(obj_inputcontroller.main_gamepad).AddInput(["ui_left", "ui_right", "ui_up", "ui_down", "ui_accept", "ui_deny", "pause"]).Finalize(); + // declare input ui_input = { - left: new Input(global.keybinds.ui_left), - right: new Input(global.keybinds.ui_right), - up: new Input(global.keybinds.ui_up), - down: new Input(global.keybinds.ui_down), - accept: new Input(global.keybinds.ui_accept), - deny: new Input(global.keybinds.ui_deny) + left: false, + right: false, + up: false, + down: false, + accept: false, + deny: false, + pause: false }; +update_input = function() +{ + ui_input.left = input_handler.get_input("ui_left"); + ui_input.right = input_handler.get_input("ui_right"); + ui_input.up = input_handler.get_input("ui_up"); + ui_input.down = input_handler.get_input("ui_down"); + ui_input.accept = input_handler.get_input("ui_accept"); + ui_input.deny = input_handler.get_input("ui_deny"); + ui_input.pause = input_handler.get_input("pause"); +} + depth = 0 create_image = false diff --git a/objects/obj_pause/Step_0.gml b/objects/obj_pause/Step_0.gml index a5d872dfe..154c9d932 100644 --- a/objects/obj_pause/Step_0.gml +++ b/objects/obj_pause/Step_0.gml @@ -1,5 +1,62 @@ +if room == mainmenu || room == rank_room || room == rm_timesup || instance_exists(obj_technicaldifficulty) || (instance_exists(obj_shell) && obj_shell.isOpen) + exit; + +if instance_exists(obj_options) +{ + inputbuffer = 2 + exit; +} +else if inputbuffer > 0 +{ + inputbuffer-- + exit; +} + +// update input +update_input(); + +#region pause and unpausing + +if ui_input.pause.pressed || (((optionselected == 0 && ui_input.accept.pressed) || ui_input.deny.pressed) && pause) +{ + if !pause + { + pause = true + pause_image = make_pause_image() + instance_deactivate_all(true) + instance_activate_object(obj_pause_angel) + instance_activate_object(obj_screensizer) + instance_activate_object(obj_shakytext) + instance_activate_object(obj_inputcontroller); + if global.option_timerspeedrun + instance_activate_object(obj_timer) + audio_pause_all() + var mu = scr_sound(mu_pause, true) + audio_sound_gain(mu, 0, 0) + audio_sound_gain(mu, 1, 1000) + cursor.x = -60 + cursor.y = -300 + options = [] + for (var i = 0; i < array_length(baseoptions); i++) + { + var cur_option = baseoptions[i] + if (!global.in_level && cur_option.o_type == optiontypes.hub) + || (global.in_level && cur_option.o_type == optiontypes.level) + || cur_option.o_type == optiontypes.both + array_push(options, cur_option) + } + } + else + do_unpause() +} + +#endregion + + + if !pause || room == mainmenu exit; + else if instance_exists(obj_shell) { if obj_shell.isOpen @@ -16,11 +73,6 @@ else if inputbuffer > 0 inputbuffer-- exit; } - -ui_input.up.update(global.keybinds.ui_up); -ui_input.down.update(global.keybinds.ui_down); -ui_input.accept.update(global.keybinds.ui_accept); -ui_input.deny.update(global.keybinds.ui_deny); var movev = -ui_input.up.pressed + ui_input.down.pressed diff --git a/objects/obj_pause/Step_1.gml b/objects/obj_pause/Step_1.gml deleted file mode 100644 index 91fac8cd9..000000000 --- a/objects/obj_pause/Step_1.gml +++ /dev/null @@ -1,57 +0,0 @@ -if room == mainmenu || room == rank_room || room == rm_timesup || instance_exists(obj_technicaldifficulty) || (instance_exists(obj_shell) && obj_shell.isOpen) - exit; - -if instance_exists(obj_options) -{ - inputbuffer = 2 - exit; -} -else if inputbuffer > 0 -{ - inputbuffer-- - exit; -} - -// update input -//ui_input.left.update(global.keybinds.ui_left); -//ui_input.right.update(global.keybinds.ui_right); -ui_input.up.update(global.keybinds.ui_up); -ui_input.down.update(global.keybinds.ui_down); -ui_input.accept.update(global.keybinds.ui_accept); -ui_input.deny.update(global.keybinds.ui_deny); - -#region pause and unpausing - -if keyboard_check_pressed(vk_escape) || (((optionselected == 0 && ui_input.accept.pressed) || ui_input.deny.pressed) && pause) -{ - if !pause - { - pause = true - pause_image = make_pause_image() - instance_deactivate_all(true) - instance_activate_object(obj_pause_angel) - instance_activate_object(obj_screensizer) - instance_activate_object(obj_shakytext) - if global.option_timerspeedrun - instance_activate_object(obj_timer) - audio_pause_all() - var mu = scr_sound(mu_pause, true) - audio_sound_gain(mu, 0, 0) - audio_sound_gain(mu, 1, 1000) - cursor.x = -60 - cursor.y = -300 - options = [] - for (var i = 0; i < array_length(baseoptions); i++) - { - var cur_option = baseoptions[i] - if (!global.in_level && cur_option.o_type == optiontypes.hub) - || (global.in_level && cur_option.o_type == optiontypes.level) - || cur_option.o_type == optiontypes.both - array_push(options, cur_option) - } - } - else - do_unpause() -} - -#endregion diff --git a/objects/obj_pause/obj_pause.yy b/objects/obj_pause/obj_pause.yy index 9ec4a391b..175088076 100644 --- a/objects/obj_pause/obj_pause.yy +++ b/objects/obj_pause/obj_pause.yy @@ -3,9 +3,9 @@ "%Name":"obj_pause", "eventList":[ {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":64,"eventType":8,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":3,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":3,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":12,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, ], "managed":true, "name":"obj_pause", diff --git a/objects/obj_pizzabox/Create_0.gml b/objects/obj_pizzabox/Create_0.gml index 5fee48299..7efded48c 100644 --- a/objects/obj_pizzabox/Create_0.gml +++ b/objects/obj_pizzabox/Create_0.gml @@ -1,5 +1,6 @@ -// declare input -key_up = new Input(global.keybinds.up); -key_down = new Input(global.keybinds.down); +key_up = false; +key_down = false; + + live = 0 \ No newline at end of file diff --git a/objects/obj_pizzabox/Step_0.gml b/objects/obj_pizzabox/Step_0.gml index aba322c14..d6ca01456 100644 --- a/objects/obj_pizzabox/Step_0.gml +++ b/objects/obj_pizzabox/Step_0.gml @@ -1,6 +1,6 @@ // update input -key_up.update(global.keybinds.up); -key_down.update(global.keybinds.down); +key_up = obj_player.input.up; +key_down = obj_player.input.down; var up = key_up.check var down = key_down.check diff --git a/objects/obj_player/CleanUp_0.gml b/objects/obj_player/CleanUp_0.gml new file mode 100644 index 000000000..7cad908b5 --- /dev/null +++ b/objects/obj_player/CleanUp_0.gml @@ -0,0 +1 @@ +input_handler.Cleanup(); \ No newline at end of file diff --git a/objects/obj_player/Create_0.gml b/objects/obj_player/Create_0.gml index 6bc31093e..758e22bdf 100644 --- a/objects/obj_player/Create_0.gml +++ b/objects/obj_player/Create_0.gml @@ -1,19 +1,31 @@ // player related macros #macro p_move (-input.left.check + input.right.check) +input_handler = new InputHandler(obj_inputcontroller.main_gamepad).AddInput(["left", "right", "up", "down", "jump", "grab", "dash", "taunt", "superjump", "groundpound"]).Finalize(); + + + // initialize input input = { - left: new Input(global.keybinds.left), - right: new Input(global.keybinds.right), - up: new Input(global.keybinds.up), - down: new Input(global.keybinds.down), - jump: new Input(global.keybinds.jump), - grab: new Input(global.keybinds.grab), - dash: new Input(global.keybinds.dash), - taunt: new Input(global.keybinds.taunt), - superjump: new Input(global.keybinds.superjump), - groundpound: new Input(global.keybinds.groundpound) + left: false, + right: false, + up: false, + down: false, + jump: false, + grab: false, + dash: false, + taunt: false, + superjump: false, + groundpound: false +} + +update_input = function() +{ + struct_foreach(input, function(_name, _value) + { + input[$ _name] = input_handler.get_input(_name); + }); } collide_init() diff --git a/objects/obj_player/Step_0.gml b/objects/obj_player/Step_0.gml index 045853e8c..77a5270e0 100644 --- a/objects/obj_player/Step_0.gml +++ b/objects/obj_player/Step_0.gml @@ -1,20 +1,10 @@ // update all of the inputs -// TODO: helper function? if !pausestopframe { if !IS_DEBUG || !obj_shell.isOpen { - input.left.update(global.keybinds.left); - input.right.update(global.keybinds.right); - input.up.update(global.keybinds.up); - input.down.update(global.keybinds.down); - input.jump.update(global.keybinds.jump); - input.grab.update(global.keybinds.grab); - input.dash.update(global.keybinds.dash); - input.taunt.update(global.keybinds.taunt); - input.superjump.update(global.keybinds.superjump); - input.groundpound.update(global.keybinds.groundpound); + update_input(); } input_buffers.grab = max(input_buffers.grab - 1, 0) diff --git a/objects/obj_player/obj_player.yy b/objects/obj_player/obj_player.yy index 136cfebf0..d8d7fdaf6 100644 --- a/objects/obj_player/obj_player.yy +++ b/objects/obj_player/obj_player.yy @@ -8,6 +8,7 @@ {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":8,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":112,"eventType":9,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":57,"eventType":9,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":12,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, ], "managed":true, "name":"obj_player", diff --git a/objects/obj_startgate/CleanUp_0.gml b/objects/obj_startgate/CleanUp_0.gml index cbb6e8554..81147eb1f 100644 --- a/objects/obj_startgate/CleanUp_0.gml +++ b/objects/obj_startgate/CleanUp_0.gml @@ -1,2 +1,4 @@ surface_free(bg_surf) sprite_delete(subtract_spr) + +input_handler.Cleanup(); \ No newline at end of file diff --git a/objects/obj_startgate/Create_0.gml b/objects/obj_startgate/Create_0.gml index 52cf7762f..996c8a297 100644 --- a/objects/obj_startgate/Create_0.gml +++ b/objects/obj_startgate/Create_0.gml @@ -1,5 +1,7 @@ +input_handler = new InputHandler(obj_inputcontroller.main_gamepad).AddInput("up").Finalize(); + // initialize input variables. -key_up = new Input(global.keybinds.up); +key_up = false; bg_surf = -1 image_speed = 0 diff --git a/objects/obj_startgate/Step_0.gml b/objects/obj_startgate/Step_0.gml index 7a97055d7..ea030d447 100644 --- a/objects/obj_startgate/Step_0.gml +++ b/objects/obj_startgate/Step_0.gml @@ -1,5 +1,5 @@ // update input -key_up.update(global.keybinds.up); +key_up = input_handler.get_input("up"); if surface_exists(bg_surf) { diff --git a/objects/obj_windowmodeconfirm/CleanUp_0.gml b/objects/obj_windowmodeconfirm/CleanUp_0.gml new file mode 100644 index 000000000..7cad908b5 --- /dev/null +++ b/objects/obj_windowmodeconfirm/CleanUp_0.gml @@ -0,0 +1 @@ +input_handler.Cleanup(); \ No newline at end of file diff --git a/objects/obj_windowmodeconfirm/Create_0.gml b/objects/obj_windowmodeconfirm/Create_0.gml index c9d82868b..3d81e2c00 100644 --- a/objects/obj_windowmodeconfirm/Create_0.gml +++ b/objects/obj_windowmodeconfirm/Create_0.gml @@ -1,10 +1,20 @@ depth = -3000 -ui_accept = new Input(global.keybinds.ui_accept) -ui_deny = new Input(global.keybinds.ui_deny) -left = new Input(global.keybinds.ui_left) -right = new Input(global.keybinds.ui_right) +input_handler = new InputHandler(obj_inputcontroller.main_gamepad).AddInput(["ui_accept", "ui_deny", "ui_left", "ui_right"]).Finalize(); -timer = 300 // 5 seconds +update_input = function() +{ + ui_accept = input_handler.get_input("ui_accept"); + ui_deny = input_handler.get_input("ui_deny"); + left = input_handler.get_input("ui_left"); + right = input_handler.get_input("ui_right"); +} -confirm = false +ui_accept = false; +ui_deny = false; +left = false; +right = false; + +timer = 60 * 5; // 5 seconds + +confirm = false; diff --git a/objects/obj_windowmodeconfirm/Step_0.gml b/objects/obj_windowmodeconfirm/Step_0.gml index 637608642..d8b5799a7 100644 --- a/objects/obj_windowmodeconfirm/Step_0.gml +++ b/objects/obj_windowmodeconfirm/Step_0.gml @@ -1,7 +1,4 @@ -ui_accept.update(global.keybinds.ui_accept) -ui_deny.update(global.keybinds.ui_deny) -left.update(global.keybinds.ui_left) -right.update(global.keybinds.ui_right) +update_input(); if left.pressed || right.pressed { diff --git a/objects/obj_windowmodeconfirm/obj_windowmodeconfirm.yy b/objects/obj_windowmodeconfirm/obj_windowmodeconfirm.yy index 07bc46e8d..7affa1f92 100644 --- a/objects/obj_windowmodeconfirm/obj_windowmodeconfirm.yy +++ b/objects/obj_windowmodeconfirm/obj_windowmodeconfirm.yy @@ -6,6 +6,7 @@ {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":64,"eventType":8,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":3,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":10,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":12,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, ], "managed":true, "name":"obj_windowmodeconfirm", diff --git a/rooms/loadingroom/loadingroom.yy b/rooms/loadingroom/loadingroom.yy index 5b82fbe95..24614603c 100644 --- a/rooms/loadingroom/loadingroom.yy +++ b/rooms/loadingroom/loadingroom.yy @@ -8,13 +8,15 @@ "instanceCreationOrder":[ {"name":"inst_482BC041","path":"rooms/loadingroom/loadingroom.yy",}, {"name":"inst_18E77C22","path":"rooms/loadingroom/loadingroom.yy",}, + {"name":"inst_C7B585","path":"rooms/loadingroom/loadingroom.yy",}, ], "isDnd":false, "layers":[ {"$GMRAssetLayer":"","%Name":"Assets_1","assets":[],"depth":0,"effectEnabled":true,"effectType":null,"gridX":32,"gridY":32,"hierarchyFrozen":false,"inheritLayerDepth":false,"inheritLayerSettings":false,"inheritSubLayers":true,"inheritVisibility":true,"layers":[],"name":"Assets_1","properties":[],"resourceType":"GMRAssetLayer","resourceVersion":"2.0","userdefinedDepth":false,"visible":true,}, {"$GMRInstanceLayer":"","%Name":"Instances","depth":100,"effectEnabled":true,"effectType":null,"gridX":32,"gridY":32,"hierarchyFrozen":false,"inheritLayerDepth":false,"inheritLayerSettings":false,"inheritSubLayers":true,"inheritVisibility":true,"instances":[ - {"$GMRInstance":"v4","%Name":"inst_482BC041","colour":4294967295,"frozen":false,"hasCreationCode":false,"ignore":false,"imageIndex":0,"imageSpeed":1.0,"inheritCode":false,"inheritedItemId":null,"inheritItemSettings":false,"isDnd":false,"name":"inst_482BC041","objectId":{"name":"obj_loading","path":"objects/obj_loading/obj_loading.yy",},"properties":[],"resourceType":"GMRInstance","resourceVersion":"2.0","rotation":0.0,"scaleX":1.0,"scaleY":1.0,"x":0.0,"y":0.0,}, + {"$GMRInstance":"v4","%Name":"inst_482BC041","colour":4294967295,"frozen":false,"hasCreationCode":true,"ignore":false,"imageIndex":0,"imageSpeed":1.0,"inheritCode":false,"inheritedItemId":null,"inheritItemSettings":false,"isDnd":false,"name":"inst_482BC041","objectId":{"name":"obj_loading","path":"objects/obj_loading/obj_loading.yy",},"properties":[],"resourceType":"GMRInstance","resourceVersion":"2.0","rotation":0.0,"scaleX":1.0,"scaleY":1.0,"x":0.0,"y":0.0,}, {"$GMRInstance":"v4","%Name":"inst_18E77C22","colour":4294967295,"frozen":false,"hasCreationCode":false,"ignore":false,"imageIndex":0,"imageSpeed":1.0,"inheritCode":false,"inheritedItemId":null,"inheritItemSettings":false,"isDnd":false,"name":"inst_18E77C22","objectId":{"name":"obj_screensizer","path":"objects/obj_screensizer/obj_screensizer.yy",},"properties":[],"resourceType":"GMRInstance","resourceVersion":"2.0","rotation":0.0,"scaleX":1.0,"scaleY":1.0,"x":0.0,"y":32.0,}, + {"$GMRInstance":"v4","%Name":"inst_C7B585","colour":4294967295,"frozen":false,"hasCreationCode":false,"ignore":false,"imageIndex":0,"imageSpeed":1.0,"inheritCode":false,"inheritedItemId":null,"inheritItemSettings":false,"isDnd":false,"name":"inst_C7B585","objectId":{"name":"obj_inputcontroller","path":"objects/obj_inputcontroller/obj_inputcontroller.yy",},"properties":[],"resourceType":"GMRInstance","resourceVersion":"2.0","rotation":0.0,"scaleX":1.0,"scaleY":1.0,"x":0.0,"y":64.0,}, ],"layers":[],"name":"Instances","properties":[],"resourceType":"GMRInstanceLayer","resourceVersion":"2.0","userdefinedDepth":false,"visible":true,}, {"$GMRBackgroundLayer":"","%Name":"Background","animationFPS":15.0,"animationSpeedType":0,"colour":4278190080,"depth":200,"effectEnabled":true,"effectType":null,"gridX":32,"gridY":32,"hierarchyFrozen":false,"hspeed":0.0,"htiled":false,"inheritLayerDepth":false,"inheritLayerSettings":false,"inheritSubLayers":true,"inheritVisibility":true,"layers":[],"name":"Background","properties":[],"resourceType":"GMRBackgroundLayer","resourceVersion":"2.0","spriteId":null,"stretch":false,"userdefinedAnimFPS":false,"userdefinedDepth":false,"visible":true,"vspeed":0.0,"vtiled":false,"x":0,"y":0,}, ], diff --git a/scripts/generic_functions_util/generic_functions_util.gml b/scripts/generic_functions_util/generic_functions_util.gml index cc860a300..183fbcb3d 100644 --- a/scripts/generic_functions_util/generic_functions_util.gml +++ b/scripts/generic_functions_util/generic_functions_util.gml @@ -210,29 +210,14 @@ function set_globals() global.savestring = $"saves/saveData{global.savefile}.ini" global.keybinds_filename = "keybinds.ccsav" //complete cook save :) - global.keybinds = { //create keybind struct - left: vk_left, - right: vk_right, - up: vk_up, - down: vk_down, - dash: vk_shift, - jump: "Z", - grab: "X", - taunt: "C", - superjump: vk_nokey, - groundpound: vk_nokey, - ui_left: vk_left, - ui_right: vk_right, - ui_up: vk_up, - ui_down: vk_down, - ui_accept: [vk_enter, vk_space, "Z"], - ui_deny: [vk_escape, vk_backspace, "X"] - } + reset_binds(); if !file_exists(global.keybinds_filename) { - var keybindBuf = write_struct_to_buffer(global.keybinds) //store the struct as a buffer + var keybindBuf = buffer_create(buffer_grow, 1, 1) //store the struct as a buffer + buffer_write(keybindBuf, buffer_text, json_stringify(global.keybinds)); + buffer_save(keybindBuf, global.keybinds_filename) //save the buffer externally buffer_delete(keybindBuf) //prevent memory leak @@ -241,20 +226,76 @@ function set_globals() { try { - var loadedBuf = buffer_load(global.keybinds_filename) //have the saved external buffer loaded + var loadedBuf = buffer_load(global.keybinds_filename); + var _json = buffer_read(loadedBuf, buffer_text); // read json file + buffer_delete(loadedBuf); // prevent memory leak + + var _new_binds = json_parse(_json); + + var _old_names = struct_get_names(global.keybinds); + var _new_names = struct_get_names(_new_binds); + + array_sort(_old_names, true); + array_sort(_new_names, true); - global.keybinds = read_struct_from_buffer(loadedBuf) //parse the saved buffer as a struct, set the global keybinds to whats saved - - buffer_delete(loadedBuf) //prevent memory leak + if (!array_equals(_old_names, _new_names)) + throw "Missing Save element!"; + + struct_foreach(global.keybinds, function(_name, _value) + { + if (!is_array(_value)) + throw "Value is not an array!"; + }); + + //global.keybinds = _new_binds; } catch(_exception) { - show_message("ERROR!\n\nKeybind data is corrupted, input set to defaults.") - show_debug_message(_exception.longMessage); - show_debug_message(_exception.script); - show_debug_message(_exception.stacktrace); + show_message("ERROR!\n\nKeybind data is corrupted, input set to defaults."); + file_delete(global.keybinds_filename); } } + update_binds(); + +} + +function update_binds() +{ + struct_foreach(global.keybinds, function(_key, _value) + { + declare_input(_key, global.keybinds[$ _key]); + }); +} + +function reset_binds() +{ + global.keybinds = { //create keybind struct + left: construct_input_array([vk_left], [stick_left_left, gp_padl]), + right: construct_input_array([vk_right], [stick_left_right, gp_padr]), + up: construct_input_array([vk_up], [stick_left_up, gp_padu]), + down: construct_input_array([vk_down], [stick_left_down, gp_padd]), + dash: construct_input_array([vk_shift], [gp_shoulderrb]), + jump: construct_input_array([ord("Z")], [gp_face1]), + grab: construct_input_array([ord("X")], [gp_face2]), + taunt: construct_input_array([ord("C")], [gp_face4]), + superjump: construct_input_array(), + groundpound: construct_input_array(), + ui_left: construct_input_array([vk_left], [stick_left_left, gp_padl]), + ui_right: construct_input_array([vk_right], [stick_left_right, gp_padr]), + ui_up: construct_input_array([vk_up], [stick_left_up, gp_padu]), + ui_down: construct_input_array([vk_down], [stick_left_down, gp_padd]), + ui_accept: construct_input_array([ord("Z"), vk_enter, vk_escape], [gp_face1]), + ui_deny: construct_input_array([ord("X"), vk_escape, vk_backspace], [gp_face2]), + + // obj_keyconfig + addbind: construct_input_array([ord("Z")], [gp_face1]), + clearbind: construct_input_array([ord("C")], [gp_face2]), + resetallbinds: construct_input_array([vk_f1], [gp_select]), + // obj_menuhandler + menuhandler_deny: construct_input_array([vk_escape, vk_backspace], [gp_face2]), + // obj_pause + pause: construct_input_array([vk_escape], [gp_start]) + } } function bbox_in_camera() diff --git a/scripts/input_util/input_util.gml b/scripts/input_util/input_util.gml deleted file mode 100644 index 006064881..000000000 --- a/scripts/input_util/input_util.gml +++ /dev/null @@ -1,232 +0,0 @@ -/* - - Quick usage tutorial: - - in the create event, construct the Input object like this: - key_up = new Input(global.keybinds.up); - - if you want it to update with global.keybinds, run: - key_up.update(global.keybinds.up); - - the array can store multiple input keys, controller support is not implemented as of now. - -*/ - -enum INPUT_TYPE -{ - KEYBOARD, - CONTROLLER, - MOUSE -} - -/// @summary Initializes an input key. -function Input(_keyname_array, _input_type = INPUT_TYPE.KEYBOARD, _device = 0) constructor -{ - device = _device; // the gamepad to check. - type = _input_type; - input = []; // will contain all of the raw ASCII values. - - check = false; - pressed = false; - released = false; - - // function is called in step so keybinds get refreshed. - static update = function(_keyname_array) - { - var _inputarr = []; - // process _keyname_array into ASCII values. - - if !is_array(_keyname_array) //if not an array, make it a single one - _keyname_array = [_keyname_array]; - - for (var i = 0; i < array_length(_keyname_array); i++) - { - var _keyname = _keyname_array[i]; - // see if its a number value or not. - if (is_real(_keyname)) - array_push(_inputarr, _keyname); - else if (is_string(_keyname)) - array_push(_inputarr, ord(_keyname)); - } - if (!array_equals(input, _inputarr)) - input = _inputarr; - - // since this uses an update method, we can actually just private all of the check methods and run them here. - - check = __check(); - pressed = __pressed(); - released = __released(); - } - - update(_keyname_array); - - // check methods - static __check = function() - { - switch (type) - { - case INPUT_TYPE.KEYBOARD: - { - for (var i = 0; i < array_length(input); i++) - { - if input[i] == vk_nokey //making sure a blank key is invalid - continue; - if (keyboard_check(input[i])) - return true; - } - return false; - } - case INPUT_TYPE.CONTROLLER: - { - // TODO: handle controller input - } - case INPUT_TYPE.MOUSE: - { - for (var i = 0; i < array_length(input); i++) - { - if (mouse_check_button(input[i])) - return true; - } - return false; - } - } - - } - - static __pressed = function() - { - switch (type) - { - case INPUT_TYPE.KEYBOARD: - { - for (var i = 0; i < array_length(input); i++) - { - if input[i] == vk_nokey - continue; - if (keyboard_check_pressed(input[i])) - return true; - } - return false; - } - case INPUT_TYPE.CONTROLLER: - { - // TODO: handle controller input - } - case INPUT_TYPE.MOUSE: - { - for (var i = 0; i < array_length(input); i++) - { - if (mouse_check_button_pressed(input[i])) - return true; - } - return false; - } - } - } - - static __released = function() - { - switch (type) - { - case INPUT_TYPE.KEYBOARD: - { - for (var i = 0; i < array_length(input); i++) - { - if input[i] == vk_nokey - continue; - if (keyboard_check_released(input[i])) - return true; - } - return false; - } - case INPUT_TYPE.CONTROLLER: - { - // TODO: handle controller input - } - case INPUT_TYPE.MOUSE: - { - for (var i = 0; i < array_length(input); i++) - { - if (mouse_check_button_released(input[i])) - return true; - } - return false; - } - } - } -} - - -/// @deprecated -function get_input() -{ - /*var keybinds = { - left: vk_left, - right: vk_right, - up: vk_up, - down: vk_down, - jump: ord("Z"), - grab: ord("X"), - dash: vk_shift, - taunt: ord("C"), - ui_left: vk_left, - ui_right: vk_right, - ui_up: vk_up, - ui_down: vk_down, - ui_accept: [vk_enter, vk_space, ord("Z")], - ui_deny: [vk_backspace, vk_escape, ord("X")] - }*/ - - key_left = setkey(global.keybinds.left) - key_right = setkey(global.keybinds.right) - key_up = setkey(global.keybinds.up) - key_down = setkey(global.keybinds.down) - key_jump = setkey(global.keybinds.jump) - key_grab = setkey(global.keybinds.grab) - key_dash = setkey(global.keybinds.dash) - key_taunt = setkey(global.keybinds.taunt) - - uikey_left = setkey(global.keybinds.ui_left) - uikey_right = setkey(global.keybinds.ui_right) - uikey_up = setkey(global.keybinds.ui_up) - uikey_down = setkey(global.keybinds.ui_down) - uikey_accept = setkey(global.keybinds.ui_accept) - uikey_deny = setkey(global.keybinds.ui_deny) -} -/// @deprecated -function setkey(keybind) -{ - var k = { - down: false, - pressed: false, - released: false - } - - if is_array(keybind) - { - for (var i = 0; i < array_length(keybind); i++) { - var noneedtocheck = false - if keyboard_check(keybind[i]) - { - k.down = true - noneedtocheck = true - } - if keyboard_check_pressed(keybind[i]) - k.pressed = true - if keyboard_check_released(keybind[i]) - k.released = true - - if noneedtocheck - break; - } - } - else - { - k = { - down: keyboard_check(keybind), - pressed: keyboard_check_pressed(keybind), - released: keyboard_check_released(keybind) - } - } - return k -} \ No newline at end of file diff --git a/scripts/scr_input/scr_input.gml b/scripts/scr_input/scr_input.gml new file mode 100644 index 000000000..91f39c07a --- /dev/null +++ b/scripts/scr_input/scr_input.gml @@ -0,0 +1,302 @@ +#macro DEADZONE 0.2 // the deadzone for analog input + +// the type of input +enum INPUT_TYPE +{ + KEYBOARD, + CONTROLLER, + MOUSE +} + +// flags for choosing what ways to check input. +enum INPUT_FLAGS +{ + CHECK = 1, + PRESSED = 2, + RELEASED = 4, + VALUE = 8, // for analog + + ALL = INPUT_FLAGS.CHECK | INPUT_FLAGS.PRESSED | INPUT_FLAGS.RELEASED | INPUT_FLAGS.VALUE +} + +// analog stick constants +#macro stick_left_up 20001 +#macro stick_left_down 20002 +#macro stick_left_left 20003 +#macro stick_left_right 20004 + +#macro stick_right_up 20005 +#macro stick_right_down 20006 +#macro stick_right_left 20007 +#macro stick_right_right 20008 + +global.input_map = ds_map_create(); + +///@description Constructs an input array. +///@param {Array.Real} _input_keyboard The keyboard values to check for input. e.g: keyboard_check(_input_keyboard) +///@param {Array.Real} _input_controller The gamepad values to check for input. e.g: gamepad_button_check(_device, _input_controller) +///@param {Array.Real} _input_mouse The mouse values to check for input. e.g: mouse_check_button(_input_mouse) +function construct_input_array(_input_keyboard = [], _input_controller = [], _input_mouse = []) +{ + var _input = array_create(3, undefined); + _input[INPUT_TYPE.KEYBOARD] = _input_keyboard; + _input[INPUT_TYPE.CONTROLLER] = _input_controller; + _input[INPUT_TYPE.MOUSE] = _input_mouse; + + return _input; +} + +///@description Declares an input constant +///@param {String} _input_name The name of the input, when adding this as an input to an InputHandler, this will be the name you refer to it as. +///@param {Array.Real} _input_keyboard The keyboard values to check for input. e.g: keyboard_check(_input_keyboard) +///@param {Array.Real} _input_controller The gamepad values to check for input. e.g: gamepad_button_check(_device, _input_controller) +///@param {Array.Real} _input_mouse The mouse values to check for input. e.g: mouse_check_button(_input_mouse) +function declare_input(_input_name, _input_array = construct_input_array()) +{ + global.input_map[? _input_name] = _input_array; +} + +///@description Change an input key declared by declare_input(). +///@param {String} _input_name The name (key) of the input. +///@param {Real} _input The value to change. +///@param {Real} _type The type of the input, see INPUT_TYPE. +function change_input(_input_name, _input, _type) +{ + global.input_map[? _input_name][_type] = _input; +} + +///@description A device used for input. +///@param {Real} _input_type The type of input the device uses, see INPUT_FLAGS. +///@param {Real} _index The index of the input device, if it has one. +function InputDevice(_input_type = INPUT_TYPE.KEYBOARD, _index = -1) constructor +{ + input_type = _input_type; + index = _index; + // set deadzone + if (input_type == INPUT_TYPE.CONTROLLER) + gamepad_set_axis_deadzone(index, DEADZONE); +} + +///@description Data about the current input +///@param {Bool} _check Whether a _check function returned true. +///@param {Bool} _pressed Whether a _check_pressed function returned true. +///@param {Bool} _released Whether a _check_released function returned true. +///@param {Bool} _value The current positional data for the analog stick. +function InputData(_check, _pressed, _released, _value) constructor +{ + check = _check; + pressed = _pressed; + released = _released; + value = _value; +} + +///@description The handler for inputs. +///@param {Struct.InputDevice} _device Information about the target input device. +function InputHandler(_device = obj_inputcontroller.keyboard_device) constructor +{ + device = _device; + inputs = {}; + + // for GC + to_cleanup = false; + + ///@description Gets data about the input + ///@returns {Struct.InputData} The current state of the input + static get_input = function(_input_name) + { + with (inputs[$ _input_name]) + return new InputData(check, pressed, released, value); + } + + ///@description Update every Input instance inside of inputs. + static update = function() + { + var _names = struct_get_names(inputs); + for (var i = 0; i < array_length(_names); i++) + inputs[$ _names[i]].update(); + } + + ///@description Used for checking inputs on a specific key. + ///@param {String} _input_name The name of the input, declared by declare_input(). + ///@param {Struct.InputDevice} _device Information about the input device. + ///@param {Real} _flags Flags for what to actually check input for, see INPUT_FLAGS. + static Input = function(_input_name, _device, _flags) constructor + { + input_name = _input_name; + device = _device; + flags = _flags; + + // declare input values + check = false; + pressed = false; + released = false; + value = 0; // -1 to 1 + pad_check = false; // this is specifically to get release to work + + ///@description Check input + static update = function() + { + // store previous to emulate pressed and released on analog + var _prev_check = check; + var _prev_pad_check = pad_check; + + // reset + check = false; + pressed = false; + released = false; + value = 0; + pad_check = false; + + var _mapping = global.input_map[? input_name]; + if (_mapping == undefined) + { + return; + } + + // keyboard + var _kb_keys = _mapping[INPUT_TYPE.KEYBOARD]; + if (_kb_keys != undefined) + { + for (var i = 0; i < array_length(_kb_keys); i++) + { + var _k = _kb_keys[i]; + if (flags & INPUT_FLAGS.CHECK) + check = check || keyboard_check(_k); + if (flags & INPUT_FLAGS.PRESSED) + pressed = pressed || keyboard_check_pressed(_k); + if (flags & INPUT_FLAGS.RELEASED) + released = released || keyboard_check_released(_k); + } + // spoof analog + value = max(value, real(check)); + } + + // mouse + var _ms_keys = _mapping[INPUT_TYPE.MOUSE]; + if (_ms_keys != undefined) + { + for (var i = 0; i < array_length(_ms_keys); i++) + { + var _m = _ms_keys[i]; + if (flags & INPUT_FLAGS.CHECK) + check = check || mouse_check_button(_m); + if (flags & INPUT_FLAGS.PRESSED) + pressed = pressed || mouse_check_button_pressed(_m); + if (flags & INPUT_FLAGS.RELEASED) + released = released || mouse_check_button_released(_m); + } + // spoof analog + value = max(value, real(check)); + } + + // gamepad + if (device.input_type == INPUT_TYPE.CONTROLLER) + { + var _pad_keys = _mapping[INPUT_TYPE.CONTROLLER]; + if (_pad_keys != undefined) + { + var _pad_index = device.index; + + for (var i = 0; i < array_length(_pad_keys); i++) + { + var _p = _pad_keys[i]; // The specific button/axis to check + var _axis_val = 0; + var _is_directional_axis = false; + + var _current_pad_check = false; + var _current_pad_pressed = false; + var _current_pad_released = false; + var _current_pad_val = 0; + + switch (_p) + { + case stick_left_up: _axis_val = -gamepad_axis_value(_pad_index, gp_axislv); _is_directional_axis = true; break; + case stick_left_down: _axis_val = gamepad_axis_value(_pad_index, gp_axislv); _is_directional_axis = true; break; + case stick_left_left: _axis_val = -gamepad_axis_value(_pad_index, gp_axislh); _is_directional_axis = true; break; + case stick_left_right: _axis_val = gamepad_axis_value(_pad_index, gp_axislh); _is_directional_axis = true; break; + + case stick_right_up: _axis_val = -gamepad_axis_value(_pad_index, gp_axisrv); _is_directional_axis = true; break; + case stick_right_down: _axis_val = gamepad_axis_value(_pad_index, gp_axisrv); _is_directional_axis = true; break; + case stick_right_left: _axis_val = -gamepad_axis_value(_pad_index, gp_axisrh); _is_directional_axis = true; break; + case stick_right_right: _axis_val = gamepad_axis_value(_pad_index, gp_axisrh); _is_directional_axis = true; break; + } + + if (_is_directional_axis) + { + if (flags & INPUT_FLAGS.VALUE) + _current_pad_val = max(0, _axis_val); + if (flags & INPUT_FLAGS.CHECK) + _current_pad_check = _current_pad_val > gamepad_get_axis_deadzone(_pad_index); + + // calculate pressed and released + if (flags & INPUT_FLAGS.PRESSED) + _current_pad_pressed = (_current_pad_check && !_prev_pad_check); + if (flags & INPUT_FLAGS.RELEASED) + _current_pad_released = (!_current_pad_check && _prev_pad_check); + } + else if (_p >= gp_axislh && _p <= gp_axisrv) + { + // fallback + if (flags & INPUT_FLAGS.VALUE) + _current_pad_val = gamepad_axis_value(_pad_index, _p); + if (flags & INPUT_FLAGS.CHECK) + _current_pad_check = abs(_current_pad_val) > 0.2; + } + else + { + // the normal buttons + if (flags & INPUT_FLAGS.CHECK) + _current_pad_check = gamepad_button_check(_pad_index, _p); + if (flags & INPUT_FLAGS.PRESSED) + _current_pad_pressed = gamepad_button_check_pressed(_pad_index, _p); + if (flags & INPUT_FLAGS.RELEASED) + _current_pad_released = gamepad_button_check_released(_pad_index, _p); + + _current_pad_val = real(_current_pad_check); + } + + // Accumulate the checks for multibinds + pad_check = pad_check || _current_pad_check; + check = check || _current_pad_check; + pressed = pressed || _current_pad_pressed; + released = released || _current_pad_released; + value = max(value, _current_pad_val); + } + } + } + } + } + + ///@description Adds an input to the inputs array. + ///@param {String} _input_name The name of the input, declared by declare_input(). Optionally supports an array of names. + ///@param {Real} _flags Flags for what to actually check input for, see INPUT_FLAGS. + static AddInput = function(_input_name, _flags = INPUT_FLAGS.ALL) + { + // if its an array, then iterate through all + if (is_array(_input_name)) + { + for (var i = 0; i < array_length(_input_name); i++) + AddInput(_input_name[i], _flags); + } + else + { + inputs[$ _input_name] = new Input(_input_name, self.device, _flags); + } + + return self; + } + + ///@description Finalize the InputHandler, pushes it to obj_inputcontroller. + static Finalize = function() + { + array_push(obj_inputcontroller.handler_instances, self); + return self; + } + + ///@description Mark the InputHandler for garbage collection on the next frame. + static Cleanup = function() + { + to_cleanup = true; + } + +} diff --git a/scripts/input_util/input_util.yy b/scripts/scr_input/scr_input.yy similarity index 56% rename from scripts/input_util/input_util.yy rename to scripts/scr_input/scr_input.yy index 23dffc632..5ee02caea 100644 --- a/scripts/input_util/input_util.yy +++ b/scripts/scr_input/scr_input.yy @@ -1,12 +1,12 @@ { "$GMScript":"v1", - "%Name":"input_util", + "%Name":"scr_input", "isCompatibility":false, "isDnD":false, - "name":"input_util", + "name":"scr_input", "parent":{ - "name":"Scripts", - "path":"folders/Scripts.yy", + "name":"InputSystem", + "path":"folders/InputSystem.yy", }, "resourceType":"GMScript", "resourceVersion":"2.0", diff --git a/scripts/scr_inputdeclarations/scr_inputdeclarations.gml b/scripts/scr_inputdeclarations/scr_inputdeclarations.gml new file mode 100644 index 000000000..9f7491869 --- /dev/null +++ b/scripts/scr_inputdeclarations/scr_inputdeclarations.gml @@ -0,0 +1,29 @@ +/* + + Declare your inputs here! + +*/ +/* +declare_input("up", construct_input_array([vk_up], [stick_left_up])); +declare_input("down", construct_input_array([vk_down], [stick_left_down])); +declare_input("left", construct_input_array([vk_left], [stick_left_left])); +declare_input("right", construct_input_array([vk_right], [stick_left_right])); +declare_input("jump", construct_input_array([ord("Z")], [gp_face1])); +declare_input("grab", construct_input_array([ord("X")], [gp_face2])); +declare_input("dash", construct_input_array([vk_shift], [gp_shoulderrb])); +declare_input("taunt", construct_input_array([ord("C")], [gp_face4])); +declare_input("superjump", construct_input_array([vk_nokey])); +declare_input("groundpound", construct_input_array([vk_nokey])); +declare_input("ui_up", construct_input_array([vk_up], [stick_left_up])); +declare_input("ui_down", construct_input_array([vk_down], [stick_left_down])); +declare_input("ui_left", construct_input_array([vk_left], [stick_left_left])); +declare_input("ui_right", construct_input_array([vk_right], [stick_left_right])); +declare_input("ui_accept", construct_input_array([ord("Z"), vk_enter, vk_escape], [gp_face1])); +declare_input("ui_deny", construct_input_array([ord("X"), vk_escape, vk_backspace], [gp_face2])); + + +// static binds, should not be changed +// obj_keyconfig +declare_input("addbind", construct_input_array([ord("Z")], [gp_face1])); +declare_input("clearbind", construct_input_array([ord("C")], [gp_face2])); +declare_input("resetallbinds", construct_input_array([vk_f1], [gp_select])); diff --git a/scripts/scr_savesystem/scr_savesystem.yy b/scripts/scr_inputdeclarations/scr_inputdeclarations.yy similarity index 51% rename from scripts/scr_savesystem/scr_savesystem.yy rename to scripts/scr_inputdeclarations/scr_inputdeclarations.yy index 3b7b294d0..6277566ae 100644 --- a/scripts/scr_savesystem/scr_savesystem.yy +++ b/scripts/scr_inputdeclarations/scr_inputdeclarations.yy @@ -1,12 +1,12 @@ { "$GMScript":"v1", - "%Name":"scr_savesystem", + "%Name":"scr_inputdeclarations", "isCompatibility":false, "isDnD":false, - "name":"scr_savesystem", + "name":"scr_inputdeclarations", "parent":{ - "name":"Scripts", - "path":"folders/Scripts.yy", + "name":"InputSystem", + "path":"folders/InputSystem.yy", }, "resourceType":"GMScript", "resourceVersion":"2.0", diff --git a/scripts/scr_savesystem/scr_savesystem.gml b/scripts/scr_savesystem/scr_savesystem.gml deleted file mode 100644 index 25f524ca4..000000000 --- a/scripts/scr_savesystem/scr_savesystem.gml +++ /dev/null @@ -1,218 +0,0 @@ -enum DATA_TYPE -{ - STRING = 1, - BOOL = 2, - INT32 = 3, - INT64 = 4, - STRUCT = 5, - UNDEFINED = 6, - ARRAY = 7, - NUMBER = 8, - REF = 9, - METHOD = 10, - -}; - -function write_struct_to_buffer(_struct) -{ - var names = struct_get_names(_struct); - array_sort(names, true); - - var stringBuffer = buffer_create(1, buffer_grow, 1); - buffer_seek(stringBuffer, buffer_seek_start, 0); - // lets write all of the strings - for (var i = 0; i < array_length(names); i++) - { - var currentName = names[i]; - - buffer_write(stringBuffer, buffer_string, currentName); - } - - // create the main buffer - var dataBuffer = buffer_create(1, buffer_grow, 1); - buffer_seek(dataBuffer, buffer_seek_start, 0); - - - // Reserve 4 bytes for the string chunk offset / size of data chunk - buffer_write(dataBuffer, buffer_u32, 0); - - // write the total number of values inside the struct - buffer_write(dataBuffer, buffer_u16, array_length(names)); - - - for (var i = 0; i < array_length(names); i++) - { - // write the index of the name - buffer_write(dataBuffer, buffer_u16, i); - // the value of the data - save_value_to_buffer(dataBuffer, _struct[$ names[i]]); - } - - var currentSeekPosition = buffer_get_size(dataBuffer); - - // put length of data chunk at start of file - buffer_seek(dataBuffer, buffer_seek_start, 0); - buffer_write(dataBuffer, buffer_u32, currentSeekPosition); - - - buffer_seek(dataBuffer, buffer_seek_end, 0); - buffer_copy(stringBuffer, 0, buffer_get_size(stringBuffer), dataBuffer, buffer_tell(dataBuffer)); - - // kill the buffer - buffer_delete(stringBuffer); - - buffer_seek(dataBuffer, buffer_seek_start, 0); - return dataBuffer; -} - -function read_struct_from_buffer(_buffer) -{ - buffer_seek(_buffer, buffer_seek_start, 0); - // read data chunk length - var stringChunkLocation = buffer_read(_buffer, buffer_u32); - // read struct value count - var nameCount = buffer_read(_buffer, buffer_u16); - - var savedPosition = buffer_tell(_buffer); - - // go to the string chunk - buffer_seek(_buffer, buffer_seek_start, stringChunkLocation); - - // read all of the struct field names - var names = []; - while (buffer_tell(_buffer) < buffer_get_size(_buffer)) - { - array_push(names, buffer_read(_buffer, buffer_string)); - } - // go to the saved position so we can actually go and read the data now! - buffer_seek(_buffer, buffer_seek_start, savedPosition); - // loop through and read all of the data - var struct = {}; - for (var i = 0; i < nameCount; i++) - { - var nameIndex = buffer_read(_buffer, buffer_u16); - var currentName = names[nameIndex]; - struct[$ currentName] = read_value_from_buffer(_buffer); - } - - buffer_delete(_buffer); - - return struct; -} - -function save_value_to_buffer(_buffer, _value) -{ - var _type = typeof(_value) - switch (_type) - { - case "number": - buffer_write(_buffer, buffer_u8, DATA_TYPE.NUMBER); - buffer_write(_buffer, buffer_f64, _value); - break; - case "string": - buffer_write(_buffer, buffer_u8, DATA_TYPE.STRING); - buffer_write(_buffer, buffer_string, _value); - break; - case "array": - buffer_write(_buffer, buffer_u8, DATA_TYPE.ARRAY); - // write length - buffer_write(_buffer, buffer_u16, array_length(_value)); - for (var i = 0; i < array_length(_value); i++) - save_value_to_buffer(_buffer, _value[i]); - break; - case "bool": - buffer_write(_buffer, buffer_u8, DATA_TYPE.BOOL); - buffer_write(_buffer, buffer_bool, _value); - break; - case "int32": - buffer_write(_buffer, buffer_u8, DATA_TYPE.INT32); - buffer_write(_buffer, buffer_s32, _value); - break; - case "int64": - buffer_write(_buffer, buffer_u8, DATA_TYPE.INT64); - buffer_write(_buffer, buffer_f64, _value); // s64 doesnt exist - break; - case "struct": - buffer_write(_buffer, buffer_u8, DATA_TYPE.STRUCT); - var buf = write_struct_to_buffer(_value); - buffer_write(_buffer, buffer_u32, buffer_get_size(buf)); // write length - buffer_copy(buf, 0, buffer_get_size(buf), _buffer, buffer_tell(_buffer)); - buffer_seek(_buffer, buffer_seek_start, buffer_tell(_buffer) + buffer_get_size(buf)); - buffer_delete(buf); - break; - case "undefined": - buffer_write(_buffer, buffer_s8, DATA_TYPE.UNDEFINED); - buffer_write(_buffer, buffer_s8, _value); - break; - case "ref": - buffer_write(_buffer, buffer_s8, DATA_TYPE.REF); - buffer_write(_buffer, buffer_string, asset_from_ref(string(_value))); - break; - case "method": - buffer_write(_buffer, buffer_s8, DATA_TYPE.METHOD); - buffer_write(_buffer, buffer_s8, noone); - break; - default: - return show_error($"unimplemented case: \"{_type}\".", true); - } -} -function read_value_from_buffer(_buffer) -{ - var type = buffer_read(_buffer, buffer_u8); - var _value = 0; - - switch (type) - { - case DATA_TYPE.NUMBER: return buffer_read(_buffer, buffer_f64); - case DATA_TYPE.STRING: return buffer_read(_buffer, buffer_string); - - case DATA_TYPE.ARRAY: - var arrayLength = buffer_read(_buffer, buffer_u16); - var array = array_create(arrayLength, undefined); - for (var i = 0; i < arrayLength; i++) - { - array[i] = read_value_from_buffer(_buffer); - } - return array; - - case DATA_TYPE.BOOL: return buffer_read(_buffer, buffer_bool); - case DATA_TYPE.INT32: return buffer_read(_buffer, buffer_s32); - case DATA_TYPE.INT64: return buffer_read(_buffer, buffer_f64); - - case DATA_TYPE.STRUCT: - var size = buffer_read(_buffer, buffer_u32); - var temp_buf = buffer_create(size, buffer_fixed, 1); - buffer_copy(_buffer, buffer_tell(_buffer), size, temp_buf, 0); - buffer_seek(_buffer, buffer_seek_relative, size); - return read_struct_from_buffer(temp_buf); - - case DATA_TYPE.UNDEFINED: return buffer_read(_buffer, buffer_s8); - case DATA_TYPE.REF: return asset_get_index(buffer_read(_buffer, buffer_string)); - case DATA_TYPE.METHOD: return buffer_read(_buffer, buffer_s8); - } - return _value; -} - -function asset_from_ref(_ref) -{ - if (!is_string(_ref)) - _ref = string(_ref); - var data = string_split(_ref, " ", true); - // ref {assetname} {id} - var assetType = data[1]; - var index = data[2] - switch (assetType) - { - case "object": return object_get_name(real(index)); - case "sprite": return sprite_get_name(real(index)); - case "room": return room_get_name(real(index)); - case "path": return path_get_name(real(index)); - case "script": return script_get_name(real(index)); - case "shader": return shader_get_name(real(index)); - case "font": return font_get_name(real(index)); - case "audio": return audio_get_name(real(index)); - case "tileset": return tileset_get_name(real(index)); - case "timeline": return timeline_get_name(real(index)); - default: return show_error($"unimplemented case: {data[2]}.", true); - } -} \ No newline at end of file From 857316006e832f88545365eb7730c10c0cb1d425 Mon Sep 17 00:00:00 2001 From: setupwitch <165732903+setupwitch@users.noreply.github.com> Date: Tue, 17 Feb 2026 05:43:29 -0500 Subject: [PATCH 2/3] Fix memory leak and some optimizations --- objects/obj_inputcontroller/Step_1.gml | 1 - objects/obj_options/CleanUp_0.gml | 1 + objects/obj_options/obj_options.yy | 1 + .../generic_functions_util.gml | 2 +- scripts/scr_input/scr_input.gml | 86 +++++++++---------- 5 files changed, 42 insertions(+), 49 deletions(-) create mode 100644 objects/obj_options/CleanUp_0.gml diff --git a/objects/obj_inputcontroller/Step_1.gml b/objects/obj_inputcontroller/Step_1.gml index d3e12e8a6..34ab672d1 100644 --- a/objects/obj_inputcontroller/Step_1.gml +++ b/objects/obj_inputcontroller/Step_1.gml @@ -3,7 +3,6 @@ for (var i = 0; i < array_length(handler_instances); i++) var _handler = handler_instances[i]; if (_handler.to_cleanup) { - delete _handler; array_delete(handler_instances, i--, 1); continue; } diff --git a/objects/obj_options/CleanUp_0.gml b/objects/obj_options/CleanUp_0.gml new file mode 100644 index 000000000..7cad908b5 --- /dev/null +++ b/objects/obj_options/CleanUp_0.gml @@ -0,0 +1 @@ +input_handler.Cleanup(); \ No newline at end of file diff --git a/objects/obj_options/obj_options.yy b/objects/obj_options/obj_options.yy index e54f689fd..2dd706ce5 100644 --- a/objects/obj_options/obj_options.yy +++ b/objects/obj_options/obj_options.yy @@ -5,6 +5,7 @@ {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":3,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":64,"eventType":8,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":12,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, ], "managed":true, "name":"obj_options", diff --git a/scripts/generic_functions_util/generic_functions_util.gml b/scripts/generic_functions_util/generic_functions_util.gml index 183fbcb3d..75da76c15 100644 --- a/scripts/generic_functions_util/generic_functions_util.gml +++ b/scripts/generic_functions_util/generic_functions_util.gml @@ -292,7 +292,7 @@ function reset_binds() clearbind: construct_input_array([ord("C")], [gp_face2]), resetallbinds: construct_input_array([vk_f1], [gp_select]), // obj_menuhandler - menuhandler_deny: construct_input_array([vk_escape, vk_backspace], [gp_face2]), + menuhandler_deny: construct_input_array([vk_escape, vk_backspace], [gp_start]), // obj_pause pause: construct_input_array([vk_escape], [gp_start]) } diff --git a/scripts/scr_input/scr_input.gml b/scripts/scr_input/scr_input.gml index 91f39c07a..3c635cfc5 100644 --- a/scripts/scr_input/scr_input.gml +++ b/scripts/scr_input/scr_input.gml @@ -30,7 +30,7 @@ enum INPUT_FLAGS #macro stick_right_left 20007 #macro stick_right_right 20008 -global.input_map = ds_map_create(); +global.input_map = {}; ///@description Constructs an input array. ///@param {Array.Real} _input_keyboard The keyboard values to check for input. e.g: keyboard_check(_input_keyboard) @@ -53,7 +53,7 @@ function construct_input_array(_input_keyboard = [], _input_controller = [], _in ///@param {Array.Real} _input_mouse The mouse values to check for input. e.g: mouse_check_button(_input_mouse) function declare_input(_input_name, _input_array = construct_input_array()) { - global.input_map[? _input_name] = _input_array; + global.input_map[$ _input_name] = _input_array; } ///@description Change an input key declared by declare_input(). @@ -62,7 +62,7 @@ function declare_input(_input_name, _input_array = construct_input_array()) ///@param {Real} _type The type of the input, see INPUT_TYPE. function change_input(_input_name, _input, _type) { - global.input_map[? _input_name][_type] = _input; + global.input_map[$ _input_name][_type] = _input; } ///@description A device used for input. @@ -104,16 +104,16 @@ function InputHandler(_device = obj_inputcontroller.keyboard_device) constructor ///@returns {Struct.InputData} The current state of the input static get_input = function(_input_name) { - with (inputs[$ _input_name]) - return new InputData(check, pressed, released, value); + return inputs[$ _input_name]; } ///@description Update every Input instance inside of inputs. static update = function() { - var _names = struct_get_names(inputs); - for (var i = 0; i < array_length(_names); i++) - inputs[$ _names[i]].update(); + struct_foreach(inputs, function(_name, _value) + { + _value.update(); + }); } ///@description Used for checking inputs on a specific key. @@ -126,64 +126,65 @@ function InputHandler(_device = obj_inputcontroller.keyboard_device) constructor device = _device; flags = _flags; + __mapping_ref = global.input_map[$ input_name]; + // declare input values check = false; pressed = false; released = false; value = 0; // -1 to 1 - pad_check = false; // this is specifically to get release to work + __pad_check = false; // this is specifically to get release to work + + __flag_do_check = (flags & INPUT_FLAGS.CHECK); + __flag_do_pressed = (flags & INPUT_FLAGS.PRESSED); + __flag_do_released = (flags & INPUT_FLAGS.RELEASED); + __flag_do_analog = (flags & INPUT_FLAGS.VALUE); ///@description Check input static update = function() { // store previous to emulate pressed and released on analog var _prev_check = check; - var _prev_pad_check = pad_check; + var _prev_pad_check = __pad_check; // reset check = false; pressed = false; released = false; value = 0; - pad_check = false; - var _mapping = global.input_map[? input_name]; - if (_mapping == undefined) + __pad_check = false; + + if (__mapping_ref == undefined) { return; } // keyboard - var _kb_keys = _mapping[INPUT_TYPE.KEYBOARD]; + var _kb_keys = __mapping_ref[INPUT_TYPE.KEYBOARD]; if (_kb_keys != undefined) { for (var i = 0; i < array_length(_kb_keys); i++) { var _k = _kb_keys[i]; - if (flags & INPUT_FLAGS.CHECK) - check = check || keyboard_check(_k); - if (flags & INPUT_FLAGS.PRESSED) - pressed = pressed || keyboard_check_pressed(_k); - if (flags & INPUT_FLAGS.RELEASED) - released = released || keyboard_check_released(_k); + if (__flag_do_check) check = check || keyboard_check(_k); + if (__flag_do_pressed) pressed = pressed || keyboard_check_pressed(_k); + if (__flag_do_released) released = released || keyboard_check_released(_k); } // spoof analog value = max(value, real(check)); } // mouse - var _ms_keys = _mapping[INPUT_TYPE.MOUSE]; + var _ms_keys = __mapping_ref[INPUT_TYPE.MOUSE]; if (_ms_keys != undefined) { for (var i = 0; i < array_length(_ms_keys); i++) { var _m = _ms_keys[i]; - if (flags & INPUT_FLAGS.CHECK) - check = check || mouse_check_button(_m); - if (flags & INPUT_FLAGS.PRESSED) - pressed = pressed || mouse_check_button_pressed(_m); - if (flags & INPUT_FLAGS.RELEASED) - released = released || mouse_check_button_released(_m); + if (__flag_do_check) check = check || mouse_check_button(_m); + if (__flag_do_pressed) pressed = pressed || mouse_check_button_pressed(_m); + if (__flag_do_released) released = released || mouse_check_button_released(_m); } // spoof analog value = max(value, real(check)); @@ -192,7 +193,7 @@ function InputHandler(_device = obj_inputcontroller.keyboard_device) constructor // gamepad if (device.input_type == INPUT_TYPE.CONTROLLER) { - var _pad_keys = _mapping[INPUT_TYPE.CONTROLLER]; + var _pad_keys = __mapping_ref[INPUT_TYPE.CONTROLLER]; if (_pad_keys != undefined) { var _pad_index = device.index; @@ -223,40 +224,31 @@ function InputHandler(_device = obj_inputcontroller.keyboard_device) constructor if (_is_directional_axis) { - if (flags & INPUT_FLAGS.VALUE) - _current_pad_val = max(0, _axis_val); - if (flags & INPUT_FLAGS.CHECK) - _current_pad_check = _current_pad_val > gamepad_get_axis_deadzone(_pad_index); + if (__flag_do_analog) _current_pad_val = max(0, _axis_val); + if (__flag_do_check) _current_pad_check = _current_pad_val > gamepad_get_axis_deadzone(_pad_index); // calculate pressed and released - if (flags & INPUT_FLAGS.PRESSED) - _current_pad_pressed = (_current_pad_check && !_prev_pad_check); - if (flags & INPUT_FLAGS.RELEASED) - _current_pad_released = (!_current_pad_check && _prev_pad_check); + if (__flag_do_pressed) _current_pad_pressed = (_current_pad_check && !_prev_pad_check); + if (__flag_do_released) _current_pad_released = (!_current_pad_check && _prev_pad_check); } else if (_p >= gp_axislh && _p <= gp_axisrv) { // fallback - if (flags & INPUT_FLAGS.VALUE) - _current_pad_val = gamepad_axis_value(_pad_index, _p); - if (flags & INPUT_FLAGS.CHECK) - _current_pad_check = abs(_current_pad_val) > 0.2; + if (__flag_do_analog) _current_pad_val = gamepad_axis_value(_pad_index, _p); + if (__flag_do_check) _current_pad_check = abs(_current_pad_val) > 0.2; } else { // the normal buttons - if (flags & INPUT_FLAGS.CHECK) - _current_pad_check = gamepad_button_check(_pad_index, _p); - if (flags & INPUT_FLAGS.PRESSED) - _current_pad_pressed = gamepad_button_check_pressed(_pad_index, _p); - if (flags & INPUT_FLAGS.RELEASED) - _current_pad_released = gamepad_button_check_released(_pad_index, _p); + if (__flag_do_check) _current_pad_check = gamepad_button_check(_pad_index, _p); + if (__flag_do_pressed) _current_pad_pressed = gamepad_button_check_pressed(_pad_index, _p); + if (__flag_do_released) _current_pad_released = gamepad_button_check_released(_pad_index, _p); _current_pad_val = real(_current_pad_check); } // Accumulate the checks for multibinds - pad_check = pad_check || _current_pad_check; + __pad_check = __pad_check || _current_pad_check; check = check || _current_pad_check; pressed = pressed || _current_pad_pressed; released = released || _current_pad_released; From 2c86ca0db543d04bdb7ae95cc782bd44cc4090f6 Mon Sep 17 00:00:00 2001 From: setupwitch <165732903+setupwitch@users.noreply.github.com> Date: Sun, 22 Feb 2026 22:57:39 -0500 Subject: [PATCH 3/3] fix bugs --- objects/obj_keyconfig/CleanUp_0.gml | 3 +- objects/obj_pause/Step_0.gml | 59 +------------------ objects/obj_pause/Step_1.gml | 53 +++++++++++++++++ objects/obj_pause/obj_pause.yy | 1 + .../generic_functions_util.gml | 2 +- sounds/sfx_collectbig/sfx_collectbig.yy | 2 +- 6 files changed, 61 insertions(+), 59 deletions(-) create mode 100644 objects/obj_pause/Step_1.gml diff --git a/objects/obj_keyconfig/CleanUp_0.gml b/objects/obj_keyconfig/CleanUp_0.gml index 64fb33b05..e23fce1ae 100644 --- a/objects/obj_keyconfig/CleanUp_0.gml +++ b/objects/obj_keyconfig/CleanUp_0.gml @@ -1,5 +1,6 @@ //resave the keybind struct, more info at the bottom of function set_globals -var keybindBuf = write_struct_to_buffer(global.keybinds) +var keybindBuf = buffer_create(1, buffer_grow, 1); +buffer_write(keybindBuf, buffer_text, json_stringify(global.keybinds)); buffer_save(keybindBuf, global.keybinds_filename) diff --git a/objects/obj_pause/Step_0.gml b/objects/obj_pause/Step_0.gml index 154c9d932..ac04ceff5 100644 --- a/objects/obj_pause/Step_0.gml +++ b/objects/obj_pause/Step_0.gml @@ -1,59 +1,3 @@ -if room == mainmenu || room == rank_room || room == rm_timesup || instance_exists(obj_technicaldifficulty) || (instance_exists(obj_shell) && obj_shell.isOpen) - exit; - -if instance_exists(obj_options) -{ - inputbuffer = 2 - exit; -} -else if inputbuffer > 0 -{ - inputbuffer-- - exit; -} - -// update input -update_input(); - -#region pause and unpausing - -if ui_input.pause.pressed || (((optionselected == 0 && ui_input.accept.pressed) || ui_input.deny.pressed) && pause) -{ - if !pause - { - pause = true - pause_image = make_pause_image() - instance_deactivate_all(true) - instance_activate_object(obj_pause_angel) - instance_activate_object(obj_screensizer) - instance_activate_object(obj_shakytext) - instance_activate_object(obj_inputcontroller); - if global.option_timerspeedrun - instance_activate_object(obj_timer) - audio_pause_all() - var mu = scr_sound(mu_pause, true) - audio_sound_gain(mu, 0, 0) - audio_sound_gain(mu, 1, 1000) - cursor.x = -60 - cursor.y = -300 - options = [] - for (var i = 0; i < array_length(baseoptions); i++) - { - var cur_option = baseoptions[i] - if (!global.in_level && cur_option.o_type == optiontypes.hub) - || (global.in_level && cur_option.o_type == optiontypes.level) - || cur_option.o_type == optiontypes.both - array_push(options, cur_option) - } - } - else - do_unpause() -} - -#endregion - - - if !pause || room == mainmenu exit; @@ -74,6 +18,9 @@ else if inputbuffer > 0 exit; } +// update input +update_input(); + var movev = -ui_input.up.pressed + ui_input.down.pressed if movev != 0 diff --git a/objects/obj_pause/Step_1.gml b/objects/obj_pause/Step_1.gml new file mode 100644 index 000000000..110ef23d3 --- /dev/null +++ b/objects/obj_pause/Step_1.gml @@ -0,0 +1,53 @@ +if room == mainmenu || room == rank_room || room == rm_timesup || instance_exists(obj_technicaldifficulty) || (instance_exists(obj_shell) && obj_shell.isOpen) + exit; + +if instance_exists(obj_options) +{ + inputbuffer = 2 + exit; +} +else if inputbuffer > 0 +{ + inputbuffer-- + exit; +} + +// update input +update_input(); + +#region pause and unpausing + +if ui_input.pause.pressed || (((optionselected == 0 && ui_input.accept.pressed) || ui_input.deny.pressed) && pause) +{ + if !pause + { + pause = true + pause_image = make_pause_image() + instance_deactivate_all(true) + instance_activate_object(obj_pause_angel) + instance_activate_object(obj_screensizer) + instance_activate_object(obj_shakytext) + instance_activate_object(obj_inputcontroller); + if global.option_timerspeedrun + instance_activate_object(obj_timer) + audio_pause_all() + var mu = scr_sound(mu_pause, true) + audio_sound_gain(mu, 0, 0) + audio_sound_gain(mu, 1, 1000) + cursor.x = -60 + cursor.y = -300 + options = [] + for (var i = 0; i < array_length(baseoptions); i++) + { + var cur_option = baseoptions[i] + if (!global.in_level && cur_option.o_type == optiontypes.hub) + || (global.in_level && cur_option.o_type == optiontypes.level) + || cur_option.o_type == optiontypes.both + array_push(options, cur_option) + } + } + else + do_unpause() +} + +#endregion diff --git a/objects/obj_pause/obj_pause.yy b/objects/obj_pause/obj_pause.yy index 175088076..fd57025d4 100644 --- a/objects/obj_pause/obj_pause.yy +++ b/objects/obj_pause/obj_pause.yy @@ -6,6 +6,7 @@ {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":3,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":12,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":3,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, ], "managed":true, "name":"obj_pause", diff --git a/scripts/generic_functions_util/generic_functions_util.gml b/scripts/generic_functions_util/generic_functions_util.gml index 75da76c15..b77e6eee8 100644 --- a/scripts/generic_functions_util/generic_functions_util.gml +++ b/scripts/generic_functions_util/generic_functions_util.gml @@ -284,7 +284,7 @@ function reset_binds() ui_right: construct_input_array([vk_right], [stick_left_right, gp_padr]), ui_up: construct_input_array([vk_up], [stick_left_up, gp_padu]), ui_down: construct_input_array([vk_down], [stick_left_down, gp_padd]), - ui_accept: construct_input_array([ord("Z"), vk_enter, vk_escape], [gp_face1]), + ui_accept: construct_input_array([ord("Z"), vk_enter], [gp_face1]), ui_deny: construct_input_array([ord("X"), vk_escape, vk_backspace], [gp_face2]), // obj_keyconfig diff --git a/sounds/sfx_collectbig/sfx_collectbig.yy b/sounds/sfx_collectbig/sfx_collectbig.yy index 4beb0a1fc..042aa90b7 100644 --- a/sounds/sfx_collectbig/sfx_collectbig.yy +++ b/sounds/sfx_collectbig/sfx_collectbig.yy @@ -10,7 +10,7 @@ "compression":2, "compressionQuality":4, "conversionMode":0, - "duration":3.9260318, + "duration":3.9266667, "exportDir":"", "name":"sfx_collectbig", "parent":{