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.

DarkBASIC Professional Discussion / Pre-defined locations for "GUI" items?

Author
Message
Yodaman Jer
User Banned
Posted: 16th Apr 2010 21:26
Hi all,

it's been months since I've last programmed with DBPro. My last project (which I am now re-programming) was a small platform-style game with a 3D level editor to make my job of designing levels a bit easier. I also wanted to give the user a chance at designing their own levels with a dumbed-down version of the editor that uses hand-made bitmap "GUI" elements (I'll just be using keyboard buttons for my editor). Now, when I was writing the code for the GUI elements last year, I had the images pre-loaded (of course), and then from the main program loop I called the GUI subroutine. It looked something like this:



I know that's incredibly sloppy, and a programmer's nightmare because I have to keep coding something similar for EVERY darned function of the program, but I really have no idea how else to accomplish anything similar. But that is not what this post is about (although I welcome any advice on the matter! ); I'm asking if it's somehow possible to store the X and Y values of the GUI images so that I don't have to keep writing the values for every mouse-hover check. This way, I can easily make it so that the user can choose which resolution to run the program in, and I can just use the pre-defined image locations to check if the mouse is over any menu items and elements.

So...has anybody done this before, and is it possible without having to write my own actual GUI functions?

Thanks to any and all who respond!
-CoffeeCoder


Check out my videos!
luskos
19
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 16th Apr 2010 22:45
I`m using BBB plugin and it`s very good for my editor.You can try it.Search "BBB" in the forums, the thread will show.

Where there is a will, there is a way.
I often edit my posts, that`s who i am
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 16th Apr 2010 22:59
Assuming you are familiar with the workings of it (just ask otherwise );


Yodaman Jer
User Banned
Posted: 16th Apr 2010 23:43
Quote: "I`m using BBB plugin and it`s very good for my editor"


I've been looking at that as well and it does look incredibly good. I have an old version of it in my plugins folder...I just never got around to learning it.

Maybe I will though...I'd like to use actual GUI elements that are already coded! xD

@Rudolpho:

Thanks, that looks pretty interesting (and a little overwhelming because I haven't used arrays and types that much yet). But why do I have to use -1 for the guiElemCount variable? Is it just better to start out that way?


Check out my videos!
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 17th Apr 2010 02:04
At first the array is empty. When it has a single element, that one is at index 0. Hence there are no gui elements if elemCount < 0 and the approach inc elemCount will always work in the addGuiElement function. If the variable was not initially set it would default to zero, hence requiring some other means of determining whether the array was empty or had one element (ie. array count() >= 0), so it's less code that way.

Yodaman Jer
User Banned
Posted: 17th Apr 2010 03:34
Okee doke. I may just give all that a shot then! Thanks!


Check out my videos!

Login to post a reply

Server time is: 2026-07-26 07:35:42
Your offset time is: 2026-07-26 07:35:42