Page 1 of 1
I'm looking for a lightweight GUI/control pack
Posted: Fri Dec 02, 2022 7:55 am
by togFox
I've used SLAB and it's great but I don't need an entire framework. I need a text box, I guess a button, perhaps a 'spinner' (up/down buttons). IDK what else yet. Just checking if anyone has something that's not a full-blown framework. I'm also happy to 'rip and fit' from existing code if ppl have samples that is not in a tidy module.
Cheers n beers.
Re: I'm looking for a lightweight GUI/control pack
Posted: Fri Dec 02, 2022 2:40 pm
by darkfrei
Can you make the small GUI by yourself?
Just several objects with x, y positions and width and height, by hovering change the active gui element an by clicking check the position and return the clicked gui element.
Re: I'm looking for a lightweight GUI/control pack
Posted: Fri Dec 02, 2022 5:08 pm
by knorke
I attached clickbuttons. It is clickable buttons. You can use mouse or arrow keys up/up and return key.
There are also "toggle" buttons, if you click them they cycle through pre-defined toggles.
(like a difficulty button and it each click it changes from "easy" to "medium" to "advanced" to "hard")
It is used in this game:
viewtopic.php?p=250233#p250233
except not as a seperate module but inside main.lua where it says -- BUTTONS ---
You fill the buttons table like this:
Code: Select all
add_button (buttons, res_w/2-220, res_h-60, 400, 20, "back to menu", "button_to_menu")
you read the clicks like
Code: Select all
local clicked_button_name, clicked_button_i = clicked_button (buttons)
if (clicked_button_name == "button_to_menu") then change_gamestatus ("MENU") end
and draw the buttons like
There are some global variables like
mouse_was_down and
active_button (the button that is currently selected by keyboard) etc
Wow, this code is just the best.
Re: I'm looking for a lightweight GUI/control pack
Posted: Sat Dec 03, 2022 12:17 am
by togFox
Thanks. I wasn't expecting a module and I'm happy to extract from your code.
I could do this myself but I've no experience and it'd take me a while to fumble through it.
Someone else here has 'textinput' I'll also look into.
Cheers!
Re: I'm looking for a lightweight GUI/control pack
Posted: Sat Dec 03, 2022 12:47 am
by BrotSagtMist
What text input are you planning/looking for?
I have a full editor box with marking/copypaste/mouse/tabs/highlight etc. with only 500 lines size.
I just kinda stalled working on it midway and forgot how it works. Not sure if i can turn this into a module to be randomly deployed in other peoples projects.
Re: I'm looking for a lightweight GUI/control pack
Posted: Sat Dec 03, 2022 1:01 am
by togFox
I'm after basic controls for my OPTIONS screen. You know - the usual - check boxes for music, maybe a text box to enter player name, an OKAY button to exit. Perhaps up/down arrows to adjust bot difficulty. Normal stuff. Nothing demanding.
If you agree - there is no harm in sharing. I'll either use it or I won't.
Re: I'm looking for a lightweight GUI/control pack
Posted: Sat Dec 03, 2022 1:11 am
by BrotSagtMist
Nah, this is total overkill. Its a code editor, the work needed to adjust it for "player names" is probably more than just rewriting it.
Re: I'm looking for a lightweight GUI/control pack
Posted: Sat Dec 03, 2022 6:46 am
by pgimeno
Gspöt is quite lightweight (single file, albeit somewhat big). It's what I use for simple things like what you're describing.
Re: I'm looking for a lightweight GUI/control pack
Posted: Sun Dec 04, 2022 1:50 am
by togFox
pgimeno wrote: ↑Sat Dec 03, 2022 6:46 am
Gspöt is quite lightweight (single file, albeit somewhat big). It's what I use for simple things like what you're describing.
I took your suggestion and I'm trying it now. I like it.
I have to use the example code + the old docs because the example alone doesn't demonstrate everything (not surprising). For example, I had to read the docs to see how to :hide() and :show() buttons. (Not complaining - just saying - the docs have SOME value).
This has absolutely got me started with my basic GUI. Thanks!!