Skip to content

Commit 6be69bd

Browse files
committed
modify Menu System to use a global control handler
1 parent 38b99f5 commit 6be69bd

File tree

10 files changed

+23
-40
lines changed

10 files changed

+23
-40
lines changed

current-scripts/Demos/useful-scripts/objects/obj_demo_title/Create_0.gml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ menu.menu_init({
3232
cursor_move_sfx: snd_menu_move,
3333
cursor_change_sfx: -1,
3434
cursor_confirm_sfx: -1,
35-
control_handler: "menu_demo_control_handler"
3635
});
3736
menu.line_spacing = 16;
3837

current-scripts/Demos/useful-scripts/objects/obj_demo_title/obj_demo_title.yy

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

current-scripts/Demos/useful-scripts/objects/obj_menu_demo/Create_0.gml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ menu.menu_init({
55
cursor_move_sfx: snd_menu_move,
66
cursor_change_sfx: snd_menu_move,
77
cursor_confirm_sfx: -1,
8-
control_handler: "menu_demo_control_handler"
98
});
109

1110
menu.add_menu_selectable({

current-scripts/Demos/useful-scripts/objects/obj_menu_demo/obj_menu_demo.yy

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

current-scripts/Demos/useful-scripts/scripts/menu_demo_control_handlers/menu_demo_control_handlers.gml

Lines changed: 0 additions & 13 deletions
This file was deleted.

current-scripts/Demos/useful-scripts/scripts/menu_demo_control_handlers/menu_demo_control_handlers.yy

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
function menu_demo_on_confirm(_args) {
2-
print(":O ", _args[0]);
2+
show_message(":O ", _args[0]);
33
}

current-scripts/Demos/useful-scripts/scripts/menu_functions/menu_functions.gml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1+
/// @func add_menu_selectable(config)
2+
/// @param config
3+
// - font
4+
// - cursor_spr
5+
// - cursor_move_sfx
6+
// - cursor_change_sfx
7+
// - cursor_confirm_sfx
18
function menu_init(_config) {
29
menu_font = _config.font;
310
cursor_spr = _config.cursor_spr;
411
cursor_padding = sprite_get_width(cursor_spr) + 16;
512
cursor_move_sfx = _config.cursor_move_sfx;
613
cursor_change_sfx = _config.cursor_change_sfx;
714
cursor_confirm_sfx = _config.cursor_confirm_sfx;
8-
9-
var _handler = asset_get_index(_config.control_handler);
10-
control_state.control_handler = _handler;
1115
}
1216

1317
/// @func add_menu_selectable(config)

current-scripts/Demos/useful-scripts/scripts/menu_structs/menu_structs.gml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,24 @@ enum MENU_CONTROLS {
1111
function MenuControlState() constructor {
1212
pressed_state = [];
1313
held_state = [];
14-
control_handler = -1;
1514

1615
for (var i=0; i< MENU_CONTROLS.MAX; i++) {
1716
pressed_state[i] = false;
1817
held_state[i] = false;
1918
}
2019

2120
function poll_input() {
22-
if (control_handler != -1) {
23-
script_execute(control_handler);
24-
}
21+
pressed_state[MENU_CONTROLS.UP] = keyboard_check_pressed(vk_up);
22+
pressed_state[MENU_CONTROLS.DOWN] = keyboard_check_pressed(vk_down);
23+
pressed_state[MENU_CONTROLS.LEFT] = keyboard_check_pressed(vk_left);
24+
pressed_state[MENU_CONTROLS.RIGHT] = keyboard_check_pressed(vk_right);
25+
pressed_state[MENU_CONTROLS.CONFIRM] = keyboard_check_pressed(vk_enter);
26+
27+
held_state[MENU_CONTROLS.UP] = keyboard_check(vk_up);
28+
held_state[MENU_CONTROLS.DOWN] = keyboard_check(vk_down);
29+
held_state[MENU_CONTROLS.LEFT] = keyboard_check_pressed(vk_left);
30+
held_state[MENU_CONTROLS.RIGHT] = keyboard_check_pressed(vk_right);
31+
held_state[MENU_CONTROLS.CONFIRM] = keyboard_check(vk_enter);
2532
}
2633
}
2734

current-scripts/Demos/useful-scripts/useful-scripts.yyp

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)