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 / TopGUI - Open source immediate mode GUI

Author
Message
Gunslinger
16
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 17th Aug 2011 18:59 Edited at: 17th Aug 2011 19:02
Is there a way to remove the scrollbars from a created window?

But very nice work, keep on it

edit: Got it. Damn dude, thats awesome. Thank you very much.
Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 18th Aug 2011 00:24
Quote: "I'm thinking of having two types of modal dialog:"


What the heck is modal??? I never understood it in BBBGUI either.

Clonkex

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 18th Aug 2011 00:31
Modal means that it blocks interaction with other controls. Most dialog boxes such as the open/save file dialogs and message boxes are modal. When one is displayed, you can no longer interact with the window owning them until they are closed.

[b]
Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 18th Aug 2011 00:40 Edited at: 18th Aug 2011 00:42
Oh. I understand now.

Quote: "When one is displayed, you can no longer interact with the window owning them until they are closed."


And if you try it goes "DONK!"

EDIT: Come to think of it, I did actually work out what it meant many months ago- and then forgot.

Clonkex

WorldBot
12
Years of Service
User Offline
Joined: 5th Aug 2011
Location: In a Worms game
Posted: 18th Aug 2011 17:24
Little question.

I have made a little login screen, so for password i added a function to show **** instead of text

in my code :


and i added a PassboxFunction (copied from the guiTextbox in the TopGui_Textbox.dba file)


It work like a charm (no problem with it) but i'm a noob (very very noob in DBP)
So: is the WHILE / ENDWHILE is a good way to show "***" instead of the typed text or there is a better way ?

Thanks.
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 18th Aug 2011 19:58
That works fine, but you can improve perfomance a bit:


[b]
WorldBot
12
Years of Service
User Offline
Joined: 5th Aug 2011
Location: In a Worms game
Posted: 18th Aug 2011 20:07
Many thanks Diggsey
Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 19th Aug 2011 00:33 Edited at: 19th Aug 2011 00:48
Quote: "fast len(text$)"


WorldBot, this code requires you have the Matrix1Utils plugin. If you're getting errors in compiling just change it to "len(text$)" without the quotes.

Clonkex

WorldBot
12
Years of Service
User Offline
Joined: 5th Aug 2011
Location: In a Worms game
Posted: 19th Aug 2011 10:32
Quote: "WorldBot, this code requires you have the Matrix1Utils plugin. If you're getting errors in compiling just change it to "len(text$)" without the quotes.
"


TopGUI require the Matrix1Utils plugins, so he can assume i have installed it to use TopGUI

But thanks Clonkex
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 21st Aug 2011 12:33
My latest problem, which will be down to misunderstanding how this works...

In the code below, I have a number of spinners. The first and last spinner corrupt one another - if I change spinner 1 (Font Size), it updates itself and also spinner number 4 (constant). Likewise, spinner 4 updates spinner 1. They even force the opposite spinner to update outside of it's min/max boundaries.

If I rearrange the spinners in the code - for example make Zoom the 4th spinner, the problem occurs between spinner 1 and 4, in the code sequence that they are created. Position on screen is irrelevant.



Rich Dersheimer
AGK Developer
14
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 21st Aug 2011 13:32
@Batvink - You're setting the GUI up to only update if a change has been made to certain controls?

I'm not 100% sure, but I think you should have the return variable the same as the one in the parameter list.

Like this...



BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 21st Aug 2011 15:17
Thanks Rich. I think your code has the same result as my code, just in a different order. I've tried it out, and the problem is still there.

I wonder if the problem is with GEN_ID, but this is where Diggsey has done some clever voodoo with ASM so I don't know what is actually happening!

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 21st Aug 2011 16:42
I haven't been able to reproduce it yet. Does it still happen if you comment out the code for the other controls?

I can't imagine it would have anything to do with GEN_ID, it's just a function which returns a unique value. It must give the same ID every time when called from the same place in the code, but never return the same ID to two different places in the code. The value it uses is based on the instruction pointer. This behaves similarly to the line number, but is more accurate, so it doesn't matter if you use GEN_ID multiple times on the same line, it will still be able to distinguish between them.

It seems to be either a bug with spinners that only occurs in certain circumstances, or there is some other part of your code causing the changes. It's actually impossible for a spinner to return a value outside it's min/max range, because almost the last line in "guiSpinnerLogic" is "value# = clamp(index*step#+min#, min#, max#)", but it is possible for the textbox to show a value outside the range (since you have to be able to finish typing before the answer is validated)

[b]
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 21st Aug 2011 18:16
I've attached a standalone version that should allow you to see it. As far as I can see, it's not doing anything outside of the Gui creation to mess with the values.

Attachments

Login to view attachments
zenassem
21
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 21st Aug 2011 18:25
Downloaded your project folder, added the necessary plug-ins,, when I open and try compiling your Tester project I get a different Error than above. Not sure what I am doing wrong, or what I'm missing.

Error is in the Tester.dba file
Subscript must be Integer or DWORD when referencing an array at line 69.

The line Synergy highlites is.


Your signature has been erased by a mod please reduce it to 600 x 120.
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 21st Aug 2011 19:34 Edited at: 21st Aug 2011 19:36
@BatVink
I've fixed the problem. You can get the new version from SVN or the first post. You were right about it being related to GEN_ID. Although GEN_ID itself was working fine, the spinner has an embedded textbox in it, and so uses CHILD_ID to get an ID for that. CHILD_ID was using two few bits from the original ID so that if two IDs were exactly a multiple of 16 apart, they would give the same CHILD_ID if CHILD_ID was used from the same place (in this case by the spinner control).

@zenassem
A few possibilities:
- You don't have the latest matrix1utils, or it's not installed correctly.
- You have a new version of Tester.dba but an old version of the other files. Try deleting all the old files and download a fresh version from the first post.
- You opened the project by opening Tester.dba. The project must be opened using the project file or it will not have the include files.
- Synergy for some reason doesn't like the project file. Try CodeSurge, or create a new project in Synergy with Tester.dba as the main source file and manually add the include files.

Let me know which of these was the problem so I can avoid it in future.

[b]
zenassem
21
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 21st Aug 2011 20:06
@Diggsey,
Thanks.I must have been missing some files and/or older version of the Matrix1utils. All is working well now even under Synergy. I'll take a look at codesurge... I remember using that.

This really looks nice. Can't wait to try some things out. Much appreciated.

Your signature has been erased by a mod please reduce it to 600 x 120.
Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 22nd Aug 2011 08:39
Ok, new problems:

1) Using TopGUI with transparent objects seems to break it. The as far as I can remember the windows were unfocusing.

2) You should remove the code that makes it so you can press space to click a focused button. Space is one of the most used keys in games.

3) Is it possible to detect whether a textbox has focus or not?

4) Is it possible to change the focus of textboxes, buttons, etc?

Clonkex

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 22nd Aug 2011 12:53
Quote: "1) Using TopGUI with transparent objects seems to break it. The as far as I can remember the windows were unfocusing."


I'll take a look.

Quote: "2) You should remove the code that makes it so you can press space to click a focused button. Space is one of the most used keys in games."


No, you should take the focus when the user is interacting with the game. I'll add a function to make this easier.

Quote: "3) Is it possible to detect whether a textbox has focus or not?"


Yes, you just need to know the ID of the textbox, and compare it to the ID returned by guiGetFocus().

Quote: "4) Is it possible to change the focus of textboxes, buttons, etc?"


Yes, guiSetFocus() should do it.

[b]
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 22nd Aug 2011 12:55
Quote: "@BatVink
I've fixed the problem....related to GEN_ID"


Thanks Diggsey! There was no way I was going to workout what was happening there.


Quote: "2) You should remove the code that makes it so you can press space to click a focused button. Space is one of the most used keys in games."


It's acting like a GUI and following the accepted standards. If the button is focused, then you are in "GUI Mode", not "Game Mode".

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 22nd Aug 2011 21:13
Quote: "1) Using TopGUI with transparent objects seems to break it. The as far as I can remember the windows were unfocusing."


I've tested TopGUI with transparent objects and there appear to be no conflicts. Unless you can provide more information about how to reproduce it, I can't do anything about it.

Quote: "2) You should remove the code that makes it so you can press space to click a focused button. Space is one of the most used keys in games."


I've added a new control, called a game control. It's just an invisible control that does nothing except get the focus when you click it or tab to it. Put a game control behind everything else, and make it the size of the screen. While the user is playing the game this control will be focused and so no user input will reach the rest of the GUI. Tester.dba uses it in the main loop.

[b]
Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 23rd Aug 2011 01:14
Quote: "Yes, you just need to know the ID of the textbox, and compare it to the ID returned by guiGetFocus().

Yes, guiSetFocus() should do it."


Thanks, it can be hard to know what commands are available sometimes. I often have to go searching through the include files and I usually don't know where to look

Quote: "It's acting like a GUI and following the accepted standards. If the button is focused, then you are in "GUI Mode", not "Game Mode"."


I know, but I was not able to find any commands to un-focus the button, so I couldn't get back to "Game Mode".

Quote: "I've tested TopGUI with transparent objects and there appear to be no conflicts. Unless you can provide more information about how to reproduce it, I can't do anything about it."


Ok, I will upload the latest version of Rift. It has the bug, but I found it's not related to transparent objects. It seems that calling guiWindowListNames with one array, then not calling it, then calling it with a different array (all the while updating the gui with guiUpdate), makes the text in the titlebar of the window disappear. Then, as far as I can see, TopGui tries to delete the cached text image but it doesn't exist and crashes it. Anyway I will upload with instructions on how to break it in a few minutes.

Quote: "I've added a new control, called a game control. It's just an invisible control that does nothing except get the focus when you click it or tab to it. Put a game control behind everything else, and make it the size of the screen. While the user is playing the game this control will be focused and so no user input will reach the rest of the GUI."


Oh, good. I will use that. Save me having to modify the TopGui code again

Clonkex

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 25th Aug 2011 16:57
My Spinners are now working perfectly in the latest update,thanks Diggsey

Yodaman Jer
User Banned
Posted: 4th Sep 2011 10:06
Diggsey, this looks amazing!

I'm going to have to try this out VERY soon! I'll probably play with the code a bit too, just to see what I can do with it!


^ Click for my Deviant page!
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 8th Sep 2011 13:52 Edited at: 8th Sep 2011 13:53
Do you know if there's any technical reason why ths doesn't work as planned...I'm rendering my TopGui elements to an image. The window works fine, but the text (Window Title and TextBox) doesn't render...





Attachments

Login to view attachments
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 8th Sep 2011 18:49
I've also tried to work this using only a2Text and a2BoxText, neither of which want to work. But I know that a2Text has worked for me previously on render targets.



Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 8th Sep 2011 20:45
It might be something to do with either the blend mode or the clipping region. I'll see if I can reproduce it...

[b]
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 8th Sep 2011 23:05
Thanks Diggsey. It could be a nightmare to try and reproduce, the previous code I sent you for the numbered balls and the GEN_ID bug is essentially the same but doesn't exhibit the same problems. The main difference in this new scenario is that I'm deep in the middle of allsorts of other processes - Box2D creations and deletions, numerous Plains being created and deleted, the numbered balls we spoke of are being generated using multiple render targets (which also get corrupted by this problem immediately after). The code above is run uninterrupted though.

Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 9th Sep 2011 21:26
@ Diggsey,

Any possibilities of further TopGUI gadgets? (yes, I'm being greedy)

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 10th Sep 2011 01:52
Yeah sorry about no updates recently. I've been very busy (doing an internship at Lionhead, moving accomodation and getting ready to go to university all at the same time)

[b]
Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 12th Sep 2011 00:16
Quote: "doing an internship at Lionhead"


Lionhead studios?

Clonkex

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 12th Sep 2011 11:12
Yeah

[b]
Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 15th Sep 2011 08:10
That's really cool! I've played heaps of games (--TWANG!!-- ok, one or two ) made by Lionhead Studios! So what are you doing there?

Clonkex

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 15th Sep 2011 11:15 Edited at: 15th Sep 2011 11:16
I've worked on two games so far. One was almost complete tbe other is very early on in development. Can't say anything about them as they're both top secret, but maybe you'll see my name in the credits some day Neither of them are "Fable: The journey" though! (They're working on that upstairs)

[b]
Blobby 101
17
Years of Service
User Offline
Joined: 17th Jun 2006
Location: England, UK
Posted: 9th Oct 2011 21:20
Hey, a bit of a bump but i'm getting "declaration is not valid" on this line: "type guiContextType" in the TopGUI.dba file. I haven't changed the file since I last used it and it worked fine then :S Any ideas?

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 10th Oct 2011 00:33
Make sure you are not including the file twice in your project.

[b]
Blobby 101
17
Years of Service
User Offline
Joined: 17th Jun 2006
Location: England, UK
Posted: 10th Oct 2011 01:17
afraid not :/ I've included all the dbas once.

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 10th Oct 2011 13:47
Just to clarify: you should use either "#include" or include it using the editor, but not both. If that's not the problem can you post the contents of the .dbpro file?

[b]
Blobby 101
17
Years of Service
User Offline
Joined: 17th Jun 2006
Location: England, UK
Posted: 10th Oct 2011 18:22 Edited at: 10th Oct 2011 18:23
Sure, thanks for helping I'm not using #include btw, just the in-editor includes thing.

this is the .dbpro:


just ask if you need the .dba as well.

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 10th Oct 2011 19:50
All the lines starting "Line***" are AFAIK non-standard and seem to support some feature of Synergy. My guess is that something has gone wrong with that feature. Deleting just those lines from the .dbpro file should reset it.

[b]
Blobby 101
17
Years of Service
User Offline
Joined: 17th Jun 2006
Location: England, UK
Posted: 10th Oct 2011 19:58 Edited at: 10th Oct 2011 19:59
hmm.. ok, i'l try that thanks. (I'm using the default editor btw, I think it's based on Synergy though)

edit: no, sorry - still getting that error

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 10th Oct 2011 21:44
Hmm, try opening the full source dump (DBPro/TEMP/FullSourceDump.dba) and check that it looks like valid code and compiles.

You could also try using another IDE such as CodeSurge, just to see if that works.

Aside from that the only things I can think of relate to the editor line continuation character, unusual white-space characters, etc.

[b]
GlenNU
12
Years of Service
User Offline
Joined: 10th Oct 2011
Location:
Posted: 22nd Nov 2011 15:07
how can i create a modal window?

-
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 23rd Nov 2011 00:15 Edited at: 25th Nov 2011 03:51
**IGNORE THIS POST***

Modal dialogs are not currently built in. You can code them one of two ways.

- Make a copy of the screen bitmap and then enter a new loop which draws a window using normal TopGui commands on top of the copy of the old screen. Only leave the loop and return when the dialog is closed. This is very easy to do but things in the background won't update at all.

- Have some sort of modal stack and only allow interaction with the window on top of the stack. This would probably require significant changes to TopGui itself.

I suggest you go with the top one. It's far easier both to implement and to use, so unless it's essential that the background still updates it makes more sense.

[b]
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 24th Nov 2011 03:25 Edited at: 30th Nov 2011 04:27
Ignore my last post, I've now implemented modal dialogs properly into TopGui. You can get the latest version from the first post.

You give TopGui a function to call which will do the modal part of the UI, by calling guiOpenModal or guiOpenModalName. TopGui will call it every loop and automatically block input to the parent window (or the rest of the gui if the parent was zero). There is also a global variable you can use from your function called "guiModal" which just makes it a bit easier to store the dialog's position and size. See Tester.dba for an example. This variable is automatically saved and restored by TopGui so you don't have to worry about interfering with other dialogs.

There is also a new ID generater specifically for dialogs called RND_ID which doesn't bother being consistent, since it doesn't matter if it's different (in fact it's beneficial if it's different) each time the dialog is opened.

edit:
Added a few more controls: progress bars (horizontal and vertical), group boxes, password boxes.

edit2:
Added support for layouts. There are four layouts now supported:
- Default layout
This is the default and works as TopGui has always worked. You specify the position and size directly.

- Dock layout
The position you specify for each control will determine its docking. ie. (-1, 0) will dock to the left, whereas (0, 0) will dock to fill the container.

- Flow layout
This layout will automatically position each control so that it is immediately after the one before either horizontally or vertically, wrapping to a new row or column when it runs out of space.

- Grid layout
The position and size of each control specifies cells on an imaginary grid which it should occupy.

The first tab page in the tester program demonstrates how to use the grid layout.

edit3:
Added treeview control!

edit4:
Fixed bug with setting UDTs containing strings using the args library.

[b]
GlenNU
12
Years of Service
User Offline
Joined: 10th Oct 2011
Location:
Posted: 3rd Dec 2011 02:55
thank you Diggsey..

the texts are blurred.. how to fix it?


-

Attachments

Login to view attachments
Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 5th Dec 2011 20:26
Nice library Diggsey, I scrapped my own gui and somewhat started my project again because your system covers so much more of the interface issues and is customizable. Looking forward to grasping it well enough to add some cool effects and special controls.

Now, why do the wierdest of wierd bugs always come to me and bite me?

Do not ask me why, but when you pass an empty string in an array, into the caption$ parameter of guiScrollWindowBegin() or guiWindowBegin() it causes a crash. This is the case in my project and in Tester.dbpro. Declaring an empty string array like; MyArray$(1) without a value, and refering to it in the window function calls causes the problem.

Using a variable, instead of an array, also causes the problem.An empty literal does not cause a problem; so having an untitled window isn't an issue; using an empty variable is.

I did not intend to create an untitled window, I simply forgot to add my string value to an array and eventually found out where the crash occured and why. My project uses arrays for all the text because it will support different languages.

The problem did not occur with guiButton(), and I have not tested the problem on the other controls.

It will obviously happen with message boxes aswell. Let me know if you need more info.

MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 9th Dec 2011 13:25
hoping to use this maybe... just adding myself to the post mails for now...

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 10th Dec 2011 19:29
@GlenNU
I'm not sure why that should be. Make sure your graphics drivers are up to date.

@Chris Tate
This should be fixed in r51.

[b]
GlenNU
12
Years of Service
User Offline
Joined: 10th Oct 2011
Location:
Posted: 13th Dec 2011 11:32
thanks again..
so it was just because of nvidia optimus tech..

-

Login to post a reply

Server time is: 2024-04-27 00:49:33
Your offset time is: 2024-04-27 00:49:33