Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Work in Progress / Button System for DBP

Author
Message
Coldfire
15
Years of Service
User Offline
Joined: 22nd Oct 2008
Location: Indiana
Posted: 25th Jul 2009 19:25 Edited at: 25th Jul 2009 21:18
Well, I've been pretty busy with real life stuff, but i had a couple late night programming sessions, and started working on something I've been wanting to work on for a while.. a button system to allow for easy creation of menus.

The long term plan is to set up a system that allows both images and buttons to be assigned to different groups which can then be activated and deactivated. This would allow you to assign buttons and images for a 'mainmenu' group as well as images(that can be altered in realtime) to be displayed in another group such as a 'ingamehud' group. However, that is the long term goal, and I still have a ways to go before I get to that point.

What I have so far, however, is a fairly robust(yet very dirty ) button system that uses images for the default button graphic as well as hover and clicked graphics. I also have fairly simplified methods for setting buttons as spinners or as single click style buttons.

It also features a spiffy justification method as long as cUpdateRes()(edit: cUpdateRes() is called during cInit()) is called prior to positioning buttons.

I do not have much time to document all of the functions yet, however I will attach a demo that is fairly readable... I dont claim the same readability for the 'cButton.dba' include file however.

Screenshot:



And a current list of useable functions:



To use the demo, open the 'gui.dbpro' and compile.

Even in this simple state, I have noticed a simple bug that if you are already clicking down off a button and then hover over a button it still registers as being clicked.

Also in the demo, I have text labels set up for the buttons. This uses DBP font commands and drastically drops the frame rate. For a comparison, The demo with text labels runs at ~57 frames per second while the demo without runs at ~5,500 frames per second. This is most likely due to me constantly changing the font multiple times per frame. I have heard the DBP fonts are slow though...

Anyways, without further rambling, the first demo:


Edit:
Source for demo to show its simplicity:

Attachments

Login to view attachments
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 25th Jul 2009 21:05 Edited at: 25th Jul 2009 21:06
You should wait for button release before you allow button presses to fix the bug. So a flag for button press, and button release.

Coldfire
15
Years of Service
User Offline
Joined: 22nd Oct 2008
Location: Indiana
Posted: 25th Jul 2009 21:17
Good thinking... thanks for the idea! I will give that a try.

Also grouping was nowhere near as difficult as I thought it could be. I do want to clean it up a bit. I will post an example of a menu tree using the grouping system.
Coldfire
15
Years of Service
User Offline
Joined: 22nd Oct 2008
Location: Indiana
Posted: 25th Jul 2009 23:25
Alright got another demo up showing how this can be used with groups to create tree style menus.

There is quite a bit of code for creating one, but it can make navigating your program so much easier if setup right.





Attachments

Login to view attachments
paul5147
18
Years of Service
User Offline
Joined: 11th Jan 2006
Location: Hot & Sunny
Posted: 30th Jul 2009 13:06
A very nice button system you have there,have a you looked through the code in my post "simple GUI(paul5147)",you may be able to add your button code to it as another class of gadget and have a full GUI system?
Coldfire
15
Years of Service
User Offline
Joined: 22nd Oct 2008
Location: Indiana
Posted: 31st Jul 2009 19:49
Oh wow! How did I miss that? That's real cool Paul. I'm busy at work right now but I'll take a look at the code later when I'm off. I could imagine it would make setup alot easier. I assume you have some kind of event handling going on? Thats one thing I have been trying to get a grasp of myself...

Login to post a reply

Server time is: 2024-05-20 03:05:07
Your offset time is: 2024-05-20 03:05:07