Thank you!
ome6a1717
Creator of
Recent community posts
I've found scope to be very difficult to figure out in GML when using script_execute, to be honest. For instance, what you did will work fine for windows/macos export, but if you export to HTML5, it will sometimes throw an error that it is unable to find your element.
It's generally just best practice to pass in all objects you use or reference for safety:
my_button = auto_button(/* data */);
my_button.set_click_func(function(_obj, _btn) {
_btn.color = c_white; // eg.
_obj.variable = 2; // eg.
}, [self, my_button]);CHANGES TO BE AWARE OF
- The grouping of the script/notes/examples are now in Tools > AutoUi instead of their respective Scripts/Notes/Etc. folders
NEW ELEMENTS
- New ELEMENT: (auto_nine_slice) - a simple nine-slice sprite that flexes it's w/h to the parent container
UPDATES
- (auto_lifebar) - set_value() now has an optional added parameter, _instant (instantly sets the value instead of lerping)
- (auto_label) - now has an optional index frame for nine_slice_background (set using set_nine_slice_frame())
- .set_visible() sets hovering to false on call (if you were hovering and called set visible, it would keep true indefinitely)
BUG FIXES
- Minor bug fixes
- Stack's set_visible() now correctly affects all children
- Auto-complete will now provide all of the variables and methods for each element
Really glad you're finding it useful, and thanks so much for the kind words!
I thought about doing a video regarding this since I had to figure it out in my recent game, but for now here is the method I used:
1. Create a 'select' index variable, radiogroup, and function in your object that creates the "structure" of your selection (in the create event):
radiogroup = auto_radiogroup();
select = 0; // the index currently selected
options = []; // we'll add this later
menu_option = function(_name) {
var _btn = auto_button_checkable_center(120, 40, _name, font, bgsprite, false, radiogroup);
return _btn;
};
2. Add all of your options
options[0] = menu_option("Start");
options[1] = menu_option("Load");
options[2] = menu_option("Quit");
// add to your main container3. Then in the step event:
if control_is_pressed("down") {
select = (select+1) mod array_length(options); // set to next index
options[select].set_checked(true, true); // checks this button and unchecks the rest of the radiogroup
}
if control_is_pressed("up") {
select = (select+array_length(options)-1) mod array_length(options);
options[select].set_checked(true, true); // checks this button and unchecks the rest of the radiogroup
}
if control_is_pressed("select") {
switch(select) {
case 0: startgame(); break;
case 1: loadgame(); break;
case 2: game_end(); break;
}
}Obviously this is a relatively rudimentary version of this, but again - I might do a video going into further detail.
Now, if you're like me and need to display more than just a button (eg. you want to have the "container" selectable), for now, you can kind of hack this by using a button as the background (with text set to ""), and place that and all of your elements in a stack.
Hopefully that should point you in the right direction!
Thank you so much!
While it doesn't explicitly support gamepad, there are many ways you can do it:
--- CREATE EVENT ---
index = 0; // your current selected index
c = auto_container_v(80, 8); // width/spacing
radiogroup = auto_radiogroup();
/// @desc Returns a struct of a new button element, index, and select function
new_button = function(_text, _index, _select_func) {
// Create the button
var _btn = auto_button_checkable_center(80, 32, _text, FONTS.px_6x6, s_tt_btn_purple, _index == 0, radiogroup);
// Set the hovering function, passing in this object and the index
_btn.set_hovering_func(function(_obj, _index) {
// Set this button to be "checked", and uncheck all other buttons in the radio group
set_checked(true, true);
_obj.index = _index; // set the obj's index correctly
}, [self, _index]);
// Assign the click function
_btn.set_click_func(function(_select_func) {
_select_func();
}, [_select_func]);
// Returning a struct of the button, index and select function
return {
button: _btn,
index: _index,
select: _select_func
}
}
// Here is our struct data where we create our buttons
button_data = [
new_button("New Game", 0, function() { show_debug_message("START NEW GAME"); }),
new_button("Load Game", 1, function() { show_debug_message("LOAD GAME"); }),
new_button("Quit Game", 2, function() { game_end(); })
]
// And don't forget to add the button to the main container
for (var i = 0; i < array_length(button_data); i++) { c.add(button_data[i].button); }
--- STEP EVENT ---
c.step(5, 5);
// EZ check if you press up or down (uses AutoInput; replace with gamepad_button_check etc.)
var _ydir = control_is_pressed("menu_down", 0) - control_is_pressed("menu_up", 0);
// If a button was pressed...
if _ydir != 0 {
// Set the index
index = (index + array_length(button_data) + _ydir) mod array_length(button_data);
// And make sure to set checked to true
button_data[index].button.set_checked(true, true);
}
// If select, run function
if control_is_pressed("menu_select", 0) { button_data[index].select(); }
And then run c.draw() in your draw event! Now it handles BOTH mouse and gamepad.
Hopefully that helps - it's not quite as cut and dry, but because some people have their own input systems (eg. AutoTools' AutoInput!), I didn't want to put too much of that in AutoUi.
I'll probably add this to an example in the package, though - thanks for the suggestion!
UPDATES
- New setter methods for AutoUiStack (align_elements_<left, right, center, top, bottom, top_left, top_right, bottom_left, and bottom_right>)
- New Stack example object
- New helpers methods for AutoUiStack (auto_stack_<placement>)
BUG FIXES
- Had a wrong method in AutoUiRow (len() instead of array_length())
- get_offset_y now returns the correct offset value
- The method for determining if the scroller's scrollbar visibility had the wrong bool check calculation
- TextEdit paste function no longer adds wrong edit index
Some small bug fixes:
UPDATES
- New helper methods for container (auto_container_h_zero, auto_container_v_zero) for zero padding
- (auto_button) set_checked now has an optional "uncheck_radio_group_buttons" parameter defaulted to false
- (auto_button) New Method: '.uncheck_radio_group()'
- (auto_lifebar) New Methods: 'set_width()' and 'set_height()'
BUG FIXES
- Fixed error in auto_button_checkable_sprite() method
- Fixed mouse positioning again...(aui_get_gui_x/y)
I think that's due to my get_gui methods...It's fixed in the next update which isn't released just yet, but you can copy the fix here and paste it in for now:
function aui_get_gui_x(_x) {
return window_mouse_get_x()/window_get_width() * display_get_gui_width();
}
function aui_get_gui_y(_y) {
return window_mouse_get_y()/window_get_height() * display_get_gui_height();
}
Copy that code and paste it into AutoUiShortcuts (the functions should be at line 112 - just replace them)
If that doesn't work...do you have any camera resizing in your game? You can also try setting the <element>.hover_type = AuiHoverType.DRAW or DRAW_GUI and see if that fixes it.



























