![]() |
|
allegro gui |
julian_boolean
Member #8,201
January 2007
|
Can anyone tell me if this is even near right?
Edit: I'm guessing I'll also need to throw MSG_IDLE in there, somewhere. |
CGamesPlay
Member #2,559
July 2002
![]() |
Yeah, for the most part. You don't need to check mouse_b in MSG_LRELEASE, because you wouldn't have gotten the message otherwise. Also, make sure you get both a MSG_LPRESS and a MSG_LRELEASE. Otherwise, I can hold down the mouse button over nothing, drag to over the button, and release the mouse button, and the button would feel it had been pressed. [append] -- Ryan Patterson - <http://cgamesplay.com/> |
julian_boolean
Member #8,201
January 2007
|
How about this:
And what did you mean by "Also, make sure you get both a MSG_LPRESS and a MSG_LRELEASE"?.. I still don't understand how I'm suppose to use this function, like this (exit->logic(MSG_LPRESS))? |
CGamesPlay
Member #2,559
July 2002
![]() |
Quote: How about this: Good, do the same for the MSG_LPRESS... and remove that crazy, invalid if statement. Quote: I still don't understand how I'm suppose to use this function, like this (exit->logic(MSG_LPRESS))? Err, you pass it to an Allegro dialog in the proc field. -- Ryan Patterson - <http://cgamesplay.com/> |
julian_boolean
Member #8,201
January 2007
|
Proc field eh. And which crazy invalid if statement? |
Thomas Fjellstrom
Member #476
June 2000
![]() |
Quote: and remove that crazy, invalid if statement. If you mean the one I think you mean, its not invalid. It is crazy though You can mix statements in with a switch iirc. its used with loop unrolling lots. edit, maybe I'm wrong, since Duff's Device seems to start after the first label.. Meh. -- |
julian_boolean
Member #8,201
January 2007
|
The if(is_mouse_over) you mean? |
CGamesPlay
Member #2,559
July 2002
![]() |
Yes. Besides, you won't get a MSG_LPRESS if the mouse is over a different control. -- Ryan Patterson - <http://cgamesplay.com/> |
julian_boolean
Member #8,201
January 2007
|
If I move it outside the switch how can I draw the button graphics when the user isn't touching it? |
CGamesPlay
Member #2,559
July 2002
![]() |
I think you should remove the if statement entirely. Why would you get a MSG_LPRESS if the mouse wasn't over the object? -- Ryan Patterson - <http://cgamesplay.com/> |
julian_boolean
Member #8,201
January 2007
|
Well I just don't understand how it knows. So more need of the "mouse_status" stuff? |
CGamesPlay
Member #2,559
July 2002
![]() |
Allegro only calls your update function with MSG_LPRESS when the current control receives a click. -- Ryan Patterson - <http://cgamesplay.com/> |
julian_boolean
Member #8,201
January 2007
|
Yes but how does it know what the user is clicking on, is there some kinda bounds checking already made? |
CGamesPlay
Member #2,559
July 2002
![]() |
Yes, the Allegro GUI automatically handles that. It wouldn't be very useful if it didn't lessen your work load, would it? -- Ryan Patterson - <http://cgamesplay.com/> |
julian_boolean
Member #8,201
January 2007
|
That's sweet
Why does this look too simple/good to be true? |
CGamesPlay
Member #2,559
July 2002
![]() |
Not quite. MSG_IDLE will happen regardless of the mouse button's state. So that means that for 1 frame your button will have the DRAW_FRAME_DOWN image, then it will switch back to DRAW_FRAME_OFF. You need to check that !(mouse_b & 1) in the MSG_IDLE handler -- Ryan Patterson - <http://cgamesplay.com/> |
Steve Terry
Member #1,989
March 2002
![]() |
coding doesn't have to be complicated, most great programs are written elegantly such that it is coherent and easy to understand even if you didn't code it. One step further would be to register a callback in your button so that when you click you set your variables. This makes it more flexible and not hard coded to your sound player. Then you can reuse your button for anything you need. It's really very simple as: (*(button_callback))(params);
___________________________________ |
julian_boolean
Member #8,201
January 2007
|
That's not so bad. Will I have to make different messange handlers for different objects or can I just have one.. To rule them all. Not really sure what you mean about the callback thing.. |
ImLeftFooted
Member #3,935
October 2003
![]() |
|
julian_boolean
Member #8,201
January 2007
|
Thanks |
Steve Terry
Member #1,989
March 2002
![]() |
Another way to handle callbacks with C++ is to have a virtual method inside your main button widget that is called on button press. This can be overloaded in a new button class which is derived from the main button widget. Then inside the overloaded method you do what you need to do. Quote: bool shit;
___________________________________ |
nonnus29
Member #2,606
August 2002
![]() |
julian_boolean
Member #8,201
January 2007
|
I was actually reading that awhile ago. So I'll need something like this? // Copied from a random example DIALOG the_dialog[] = { /* (dialog proc) (x) (y) (w) (h) (fg)(bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */ { d_clear_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }, { d_text_proc, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, (void*)"enter number", NULL, NULL }, { d_edit_proc, 160, 10, 160, 8, 0, 0, 0, D_EXIT, 64, 0, (void*)the_string, NULL, NULL }, { d_button_proc, 328, 6, 160, 16, 0, 0, 0, D_EXIT, 0, 0, (void*)"OK", NULL, NULL }, { d_yield_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }, { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL } }; I still don't understand how this works exactly, and how it will work with the graphics I want to use.. |
ImLeftFooted
Member #3,935
October 2003
![]() |
You'll have to make your own widgets if you want to use custom graphics. This is a lot of work. If you're looking to take the next step and use custom graphics I would recommend the agup library. While we're at I might as well throw in a plug for the unfinished XUI gui scripting project. |
julian_boolean
Member #8,201
January 2007
|
I already have my own widget classes made. I just wanted to find a cleaner way to handle them without using someone elses library. Is there any way to handle my classes with the Allegro gui or do I HAVE to scrap it and use their ugly buttons? |
|
|