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.

Code Snippets / [DBC] Media-Less GUI Function Collection

Author
Message
TDK
Retired Moderator
18
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 18th Jan 2008 20:41 Edited at: 23rd Jan 2008 19:38
This collection of functions for DB Classic (V1.2 but should work fine in V1.13) does not use a dll or external media so can be used with all versions of DBC.

It includes:

* Message Box - Display a simple message with OK button.
* Alert Box - Confirmation with Yes/No buttons, with or without icon.
* Input Box - Easily allow users to enter/edit text and numbers.
* Colour Picker - Allows users to select a colour (inc RGB tool-tip).


Usage:

Place the "Alerts.dba" file in the same folder as your main DBA file and add the line:

#Include "Alerts.dba"

[Edit] Note: Updated (2nd) version now called GUI.dba instead of Alerts.dba.

as the first line of your program. The demo program included in the attached zip (5K) shows how the functions are used.

Reports on problems, additions etc. welcome.

TDK_Man

Attachments

Login to view attachments
Sinani201
13
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 19th Jan 2008 00:48
Cool!

Seriously, how do you make the little blue text come up below your message?
TDK
Retired Moderator
18
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 19th Jan 2008 23:49 Edited at: 19th Jan 2008 23:52
Following a little update to my Fileselector function, it occurred to me that it should be part of this little set of GUI functions.

So, it's now included and to avoid confusion with the first version, the #Include file is now called GUI.dba.

New version of the demo program also included in the attached zip file (now 10K).

And, as I forgot in the first post, here's a series of screen snapshots of what you get on the screen from each function:



TDK_Man

Attachments

Login to view attachments
Jmahmood
13
Years of Service
User Offline
Joined: 3rd Apr 2007
Location: not sure
Posted: 21st Jan 2008 16:56
the color picker is just what i was looking for R.T.M.
Thanks TDK

Zombie 20
14
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 21st Jan 2008 20:49
Wow thank you very much TDK , very nice of you.


Coffee coffee coffee coffee coffee coffee cappacino, JAVA!
Kohaku
16
Years of Service
User Offline
Joined: 3rd May 2004
Location: The not very United Kingdom
Posted: 23rd Jan 2008 23:45
Very nice!

I only use DBP nowadays but you make the original DB look awesome; I almost miss it.


You are not alone.
TDK
Retired Moderator
18
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 1st Feb 2008 02:42
Version 1.3 Update:

Now called GUI.dba, the #Include file now has a MemoBox function.



It can display multiple lines of formatted text (non-editable) in a window, complete with scroll bar to view lines not visible and an OK button.

Text is automatically word wrapped to fit the box.

All you do is supply the width and height of the required text box - and of course the text itself, which can even be a text file!

Zip file (12K) can be downloaded here.

Includes updated demo program.

TDK_Man

Zotoaster
16
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 1st Feb 2008 02:53
This is really impressive. Nice work man

Your signature has been erased by a mod
Blood Of The Prophets
13
Years of Service
User Offline
Joined: 6th Nov 2007
Location:
Posted: 7th Feb 2008 18:39
Very impressive. I'm halfway through converting your code to the DarkGDK commands at the minute. But from what i can see in DBPro it would be very easy for me to add new controls like check boxes and radio buttons.
TDK
Retired Moderator
18
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 8th Feb 2008 15:26
Quote: "in DBPro it would be very easy for me to add new controls like check boxes and radio buttons."


Yes, it's not difficult in DBC either - I have an incomplete GUI Component Designer in DBC that lets you add things like that to panels - similar to the way that Delphi works when you create a form.

TDK_Man

LBFN
13
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 11th Feb 2008 03:41
Very cool TDK! Nice work.

LB
Libervurto
14
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 12th Feb 2008 19:57
Looking good TDK
Glad to see you still working on this.
Excuse me for asking what is probably an obvious question, but (assuming you will make forms with check boxes and radio buttons etc) how will the user's choice be returned?

TDK
Retired Moderator
18
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 13th Feb 2008 06:25
First of all, to keep it simple, normal buttons and radio buttons won't be combined on the same form.

For example, the ButtonBar lets you easily create a row, column or grid of buttons on a panel. When you click on one, the number of the button is returned.

Whether it acts as a radio button or a normal button isn't relevant to anything other than how the button behaves on the screen. (Stays down while the previously selected one pops back up - or it pops back up automatically when you release the mouse button).

The same goes for multiple choice radio selectors - you know the type where you have small circles in which a black dot appears in the middle when you select one. When you make your choice, the number of the one selected when you click on the OK button is returned from the function.

Anyway...

Version Release 1.4:

Now including the ButtonBar function. Actually, there are two functions - one to create the ButtonBar:

ButtonBar_Create(ButtonBarPosX,ButtonBarPosY,ButtonsAcross,ButtonsDown,32,32,"Keypad",101,201)

..and the other to poll it which is placed in your main program loop:

ButtonPressed = ButtonBar_Poll(ButtonBarPosX,ButtonBarPosY,ButtonsAcross,ButtonsDown,32,32,Radio)

See the demo program for more details.



Download here.

TDK_Man

Robert The Robot
14
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 15th Feb 2008 10:34
Wow!! This is absolutely Fantastic! Thanks TDK!!!

Did you hear about the two criminals who crashed their getaway car into a cement mixer? Police are looking for two hardened criminals...
TDK
Retired Moderator
18
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 9th Mar 2008 08:41
The latest version now also has a TriInputBox function which allows you to enter three values at the same time.

This is for situations like entering R, G and B values or X, Y and Z co-ordinates/angles but at the same time - rather than using the InputBox function three times.

I've also decided to rewrite the functions using sprites as I've discovered they aren't too clever when used in a 3D environment. I'll post the new update in the next few days.

TDK_Man

Sasuke
15
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 13th Mar 2008 15:28 Edited at: 13th Mar 2008 15:29
Great work as usual TDK, can't wait to see what you come up with next
Data
16
Years of Service
User Offline
Joined: 26th Nov 2004
Location: Winnipeg,Canada
Posted: 14th Mar 2008 02:50 Edited at: 14th Mar 2008 03:05
EDIT: I got this working and everything, however, if I use it to display alert messages in a game that uses 3d objects it doesn't show up however it suspends the program, any way around this? Or could it be that Im using DBPRO?

TDK
Retired Moderator
18
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 15th Mar 2008 07:03 Edited at: 15th Mar 2008 07:09
There's no way round the program stopping while you wait for the user to click on a component button in this version, but a quick fix for 3D is to use:

Set Camera View 0,0,1,1

on the line before calling the function and

Set Camera View 0,0,Screen Width(),Screen Height()

on the line following the function call.

This is one of the reasons I'm rewriting the functions. (Currently being tested with this: http://forum.thegamecreators.com/?m=forum_view&t=125358&b=10)

TDK_Man

Data
16
Years of Service
User Offline
Joined: 26th Nov 2004
Location: Winnipeg,Canada
Posted: 17th Mar 2008 23:02 Edited at: 18th Mar 2008 00:05
Edit: it doesn't seem to want to work could it be because I'm using DBPro?

TDK
Retired Moderator
18
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 19th Mar 2008 03:33
Probably yes.

What is it doing (out of interest)?

TDK_Man

Data
16
Years of Service
User Offline
Joined: 26th Nov 2004
Location: Winnipeg,Canada
Posted: 26th Mar 2008 23:29
it simply refuses to display anything...

TDK
Retired Moderator
18
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 28th Mar 2008 01:33
Even if you do what I said a couple of posts above?

TDK_Man

Data
16
Years of Service
User Offline
Joined: 26th Nov 2004
Location: Winnipeg,Canada
Posted: 28th Mar 2008 02:47 Edited at: 28th Mar 2008 04:02
actually it appears to work now although..now I have the problem of deciding whether to use these GUI functions or the ones posted under "More Windows!!!!" thread.

edit: I just noticed the colour picker zooms in extremely close when picking a colour. Is this supposed to happen? Also, this is just a nooby question , is it possible to change the colour of the GUI functions?

TDK
Retired Moderator
18
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 28th Mar 2008 17:33
Quote: "the colour picker zooms in extremely close when picking a colour. Is this supposed to happen?"


Sorry - don't know what you mean with that one...

Quote: "is it possible to change the colour of the GUI functions?"


Yes - just change the RGB lines.

TDK_Man

Data
16
Years of Service
User Offline
Joined: 26th Nov 2004
Location: Winnipeg,Canada
Posted: 28th Mar 2008 23:13
Quote: "Quote: "the colour picker zooms in extremely close when picking a colour. Is this supposed to happen?"

Sorry - don't know what you mean with that one..."


Ok, I'll post a screenshot when I get home.


Quote: "Quote: "is it possible to change the colour of the GUI functions?"

Yes - just change the RGB lines."


Oh! lol. Much simpler then I though .

Thanks for the help,
Data

Data
16
Years of Service
User Offline
Joined: 26th Nov 2004
Location: Winnipeg,Canada
Posted: 2nd Apr 2008 07:00
o nvm! it seems to have worked now

Data
16
Years of Service
User Offline
Joined: 26th Nov 2004
Location: Winnipeg,Canada
Posted: 25th May 2008 01:08
Hi TDK,

I've been using all these functions and I must say they're absolutely great! However, lately, when I attempted to use the file browser function for the first time (never needed that one until now) it comes up with an error message that says 'Array out of bounds'. Any idea what I could be doing wrong?

Also, a perhaps less urgent question, is there any possible way to launch two of these functions at the same time? For instance, the memo box and a input box at the same time?

Thanks
Data

TDK
Retired Moderator
18
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 25th May 2008 22:40
Without multitasking that would be a little difficult. Being functions, it's the nature of things in DB that once called they must complete and return a value (or not) before the next line of your program is executed.

You would need to turn the functions into procedures which exit without doing anything and write a handler routine to call them if required once each time around the main loop.

Sounds like a lot of work to me...

As for the error, are you using DBC or Pro, as I seem to remember that problem cropping up for DBP users and it was fixed. Try this version:

http://www.computechtenerife.com/zips/fileselectv2b.zip

If it works OK, simply delete the fileselector function in the GUI collection Include file and #Include the new one you download.

TDK_Man

Data
16
Years of Service
User Offline
Joined: 26th Nov 2004
Location: Winnipeg,Canada
Posted: 27th May 2008 02:27
Thanks! the new one appears to work as I was using DBP.

Invincibob 8
13
Years of Service
User Offline
Joined: 4th Feb 2008
Location: Some Place Somewhere
Posted: 3rd Jul 2008 19:09 Edited at: 3rd Jul 2008 22:27
I keep getting a window that shows up like this. I did what the example and the actual functions file said, but it still happened.

Attachments

Login to view attachments
TheComet
13
Years of Service
Recently Online
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 14th Jul 2008 21:58
This is sooooooo cool!!! You used these functions in your Level maker, didn`t you?

Fantastic job, TDK!

TheComet

TheComet
13
Years of Service
Recently Online
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 18th Jul 2008 19:10 Edited at: 26th Jul 2008 14:00
Sorry for double posting, but you have an error with the "TDK`s funky MemoBox":

Runtime Error, cannot divide by zero!

Your signature has been erased by a mod - Please reduce it to 600x120 maximum size

Login to post a reply

Server time is: 2021-03-05 10:28:42
Your offset time is: 2021-03-05 10:28:42