Pages: 1
  Print  
Author Topic: Am I using the BasicGUI extension correctly?  (Read 2903 times)
Offline (Unknown gender) Isana
Posted on: February 22, 2015, 09:22:41 pm

Member
Joined: Feb 2015
Posts: 2

View Profile
Recently got back into using ENIGMA; shortly after getting everything set up, I noticed that there is now a BasicGUI extension.
I decided to whip up a quick example on it's usage for the community while I learn to use it myself, but I'm a bit rusty and I'm not sure if I'm really using it correctly as there is no documentation (as far as I am aware).

So here's what I've done in about 5 minutes while referencing the extension's source code as necessary. If I'm going about this the wrong way, please let me know.
Oh, and maybe I missed something (wouldn't be the first time), but while I have set a callback for this button, it doesn't seem to do anything. Maybe the callback isn't what I think it is, in which case feel free to have a bit of a laugh at my expense, heh.


(Yeah, the button looks really lame, but I'm not worried about that at the moment.)
« Last Edit: February 22, 2015, 09:25:52 pm by Isana » Logged
Offline (Unknown gender) TheExDeus
Reply #1 Posted on: February 23, 2015, 05:05:05 am

Developer
Joined: Apr 2008
Posts: 1860

View Profile
Yeah, I haven't made doc's yet, because I haven't finished the extension. I want to add textboxes, scroll bars and stuff like that.

You are doing everything correctly as far as I can see. Callback is just a script that is called. When you left click the button, the script should be executed.  It should also pass arguments to it identifying the event, button id and so on. I haven't found a better way to do this, as don't support Lambda functions or the like. The extension is far more advanced in the branch here: https://github.com/enigma-dev/enigma-dev/tree/GL3.3NormalMatrix

I am saying that, because I can make you an example, but it will only work in that branch, as many things have changed. For example, in the callback function you can actually specify the event (right now it can be pressed, released or hover). Or the windows can be resized.

I have attached a simple example. It shows how many elements work, including toggles, buttons, windows, groups, sliders, styles, skins and callbacks.

I would appreciate feedback on how to progress with it. Originally I took Unity3D as reference, but because of the way EGL/GML works I was quite limited. For example, I cannot create one function window_add_element which adds buttons, toggles, other windows etc. I have to create a function for every element type. Callbacks calling scripts is also the only way I know how they could work. But as everything is calculated in _draw function, then the callback calls the script inside that object as well. So if you want a button to do something for another object, you have to do "with (obj_){}" inside the callback. None of this is particularly ugly, as that is how GM done it for years, so most people got used to it. But I personally want this to be prettier.

Another thing I want to do is allow "texture" to be set as image or as content. So you can have the regular button style, but the content is not text, but another image. I want this so I could add surfaces as backgrounds. Right now you have _set_sprite, which uses a sprite. If I want to use backgrounds, I will need to add  _set_background, for surfaces _set_surface. It multiplies the number of functions for no good reason. I could add _set_texture which would replace all of the functions, but then you would have to call _set_texture(sprite_get_texture(spr_button, 0)) which is not pretty again. And sprites can be animated, which is not possible with textures without you incrementing the second argument explicitly.

Here is screenshot for  the example:

I put an ugly ass ghost image in the background to check transparency. I should probably replace it.
« Last Edit: February 23, 2015, 05:08:07 am by TheExDeus » Logged
Offline (Unknown gender) Isana
Reply #2 Posted on: February 24, 2015, 02:54:51 am

Member
Joined: Feb 2015
Posts: 2

View Profile
Yeah, I haven't made doc's yet, because I haven't finished the extension. I want to add textboxes, scroll bars and stuff like that.
Ah, well that makes sense and yeah, those would be some really useful additions. That aside, it's not really a huge deal or anything; I just wanted to make sure I was headed in the right direction with this before continuing.

You are doing everything correctly as far as I can see. Callback is just a script that is called. When you left click the button, the script should be executed.  It should also pass arguments to it identifying the event, button id and so on. I haven't found a better way to do this, as don't support Lambda functions or the like. The extension is far more advanced in the branch here: https://github.com/enigma-dev/enigma-dev/tree/GL3.3NormalMatrix
I figured that's what the callback was, but after testing I wasn't entirely certain since the script I passed to the function was never executed. I guess I'll have to debug that, but I think I'll check out the branch you linked me to first. For the time being, the current solution gets the job down though and I personally don't find it to be an inconvenience.

I am saying that, because I can make you an example, but it will only work in that branch, as many things have changed. For example, in the callback function you can actually specify the event (right now it can be pressed, released or hover). Or the windows can be resized.
That's actually pretty awesome, haha. As I mentioned earlier, I'll definitely be checking out this branch so I look forward to testing this extension further.

I have attached a simple example. It shows how many elements work, including toggles, buttons, windows, groups, sliders, styles, skins and callbacks.
Nice, I'll check it out; I appreciate it!

I would appreciate feedback on how to progress with it. Originally I took Unity3D as reference, but because of the way EGL/GML works I was quite limited. For example, I cannot create one function window_add_element which adds buttons, toggles, other windows etc. I have to create a function for every element type. Callbacks calling scripts is also the only way I know how they could work. But as everything is calculated in _draw function, then the callback calls the script inside that object as well. So if you want a button to do something for another object, you have to do "with (obj_){}" inside the callback. None of this is particularly ugly, as that is how GM done it for years, so most people got used to it. But I personally want this to be prettier.
I've actually not used Unity, so I wouldn't notice if aspects of this extension were, in a sense, falling short of what you set out to accomplish so thanks for providing some examples; since you're looking for feedback, this sort of information should really come in handy. Yeah it definitely gets the job done, but there's nothing wrong with trying to improve upon it, so I agree. After I spend some more time with it and read over the extension's code more thoroughly, I'll try to provide you with some useful feedback. 

Another thing I want to do is allow "texture" to be set as image or as content. So you can have the regular button style, but the content is not text, but another image. I want this so I could add surfaces as backgrounds. Right now you have _set_sprite, which uses a sprite. If I want to use backgrounds, I will need to add  _set_background, for surfaces _set_surface. It multiplies the number of functions for no good reason. I could add _set_texture which would replace all of the functions, but then you would have to call _set_texture(sprite_get_texture(spr_button, 0)) which is not pretty again. And sprites can be animated, which is not possible with textures without you incrementing the second argument explicitly.
This would be pretty nice too, haha. I'll let you know if anything comes to mind that may help with the implementation of this idea. Getting back into ENIGMA is kind of weird since I've been doing all of my work in C++ and Vala for the past couple of years, but hopefully it'll come back to me pretty quickly, heh.

Logged
Offline (Unknown gender) FroggestSpirit
Reply #3 Posted on: September 03, 2015, 04:10:34 pm

Member
Joined: Mar 2013
Posts: 79

View Profile
Has there been any documentation on this yet?
Logged
This isn't easy to say, but…
Offline (Unknown gender) TheExDeus
Reply #4 Posted on: September 03, 2015, 06:05:47 pm

Developer
Joined: Apr 2008
Posts: 1860

View Profile
No, not yet, sorry. There are currently 262 BasicGUI functions. Even if I document them all I don't know if that will make using it any easier. I think need to create a lot of examples first. A person will be able to learn a lot more by looking at code than at the docs.
Logged
Pages: 1
  Print