Jump to content
Sign in to follow this  
  • entries
    557
  • comments
    1237
  • views
    423444

Widgets galore

Sign in to follow this  
Evil Steve

88 views

So, I started work on my GUI system yesterday, and it's coming along quite well. Everyone seems to be doing GUI stuff just now, such as Programmer16 and ravuya.

My GUI system isn't really anything special. The highest level element is a window, and all windows are managed by the GUI manager. A window contains several widgets, and input is handled by the GUI managager, which is ticked once per frame.

I'm also going to have the ability to load a window from a schema, which I've semi-decided is going to be an ini-like file (since I have code for that already). So a sample GUI schema would look something like:

[Text]
X = 0
Y = 0
Alignment = Left
Text = I am a sample test string

[Button]
X = 0
Y = 20
Width = 30
Text = I R Teh Button

Width and Height will default to the size of the object (Size of the text, for instance). Now I think about this, I might be better off with XML, so I can nest stuff. Hrm...

I'm currently doing text stuff, which is a lot neater than I thought. There's a SOText scene object, which you create and add to the scene as normal. You can set the text string, the font, the colour, etc here. When you change the font, it allocates a new CFont from the font manager. A CFont is really just a wrapper around ID3DXFont, but the D3D device manages a list of them and resets them when the device gets lost. The font manager caches fonts, so two requests for the same font won't allocate two objects. It also keeps hold of an ID3DXSprite for font rendering.
When the scene graph comes to render everything, because it sorts the objects, I can just call ID3DXSprite::Begin() in FirstRender(), using the font manager's sprite, draw the text for all objects, and then call ID3DXSprite::End() in LastRender().

So, the text is set on the scene object, meaning it can be set once and forgotten about, and everything is cached, sorted and rendered nicely. Hooray!

All of that is untested of course (I'll give it a go during my lunch break, it's nearly compilable). So far only text is done (And the GUI manager and window classes).
Sign in to follow this  


3 Comments


Recommended Comments

Shit, man. I could only tell you how much time I've wasted writing my own fucking config loader when I could've just dropped in TinyXML.

Seriously, Freezer 2 and Glow and CSRPG2 -- all of 'em would have been out a month earlier if it weren't for my damnable configuration file format. It's gone in my next game.

TinyXML: flawless parser, vetted by several people in and out of industry writing many different projects.
Ravuya's Big Fun Configuration Loader: pure shit.

Share this comment


Link to comment
I agree with Rad. Use the XML. Not only will it save you time, it makes it easier to structure. Good luck.

Share this comment


Link to comment
Yeah, I used TinyXML briefly before and thought it was pretty neat. I'll use it I think.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!