Jump to content
  • Advertisement
  • entries
  • comments
  • views

Gui goodness

Sign in to follow this  


Well, I reworked all of the GUI classes today and have a more general GUI. I got tired of copying and pasting and then modifying code from one class to another.

So, instead of:

- Button
- LoadGameDialog
- PasswordDialog
// continue with game specific dialog boxes

I have:

+- Widget
|-- Label
|-- Button
|-- TextBox
|-- SliderBar

+- Container
|-- LoadGameDialog
|-- PasswordDialog

- WidgetManager

At the moment it isn't using a texture, but it is setup to be able to (I'd have to change all of the classes' rendering code, but none of my other code would have to change.)

Anyway, enough talk. Try out the demo[grin]: GuiDemo.zip (1.52mb)

Password Mode off

Password Mode on

New Game button - Does nothing
Password button - Changes the long textbox in the middle to password mode; all characters are replaced with the character in the short text box in the middle.
Quit button - dur dur
Top slider - changes background's red component
Middle slider - Changes the background's green component
Bottom slider - Changes the background's blue component
Top text box - lets you type as many characters (sorry, not autoscrolling yet [sad].)
Bottom text box - sets the top text box's password character

Only thing I know that is off is the slider bars. My calculation is off or something. When the bar stops on the left, there's about 10 left and when it stops on the right there's about 10 left. Also, they have to be the right size or they're even more off (for example, if one of the sliders in the demo was 100 wide instead of 255, when it reached the right it would be at about 90 instead of 255.) Here's the code that I'm using at the moment:

if(m_bDragging && m_bCanDrag)
((SliderBar*)m_pParent)->SetValue(((SliderBar*)m_pParent)->GetValue() + (((((SliderBar*)m_pParent)->GetWidth() / ((SliderBar*)m_pParent)->GetMaxValue()) * ((SliderBar*)m_pParent)->GetStepSize()) * Event.m_RelMousePos.x));
if(((SliderBar*)m_pParent)->GetValue() < ((SliderBar*)m_pParent)->GetMinValue())
else if(((SliderBar*)m_pParent)->GetValue() > ((SliderBar*)m_pParent)->GetMaxValue())
MoveRel(((((SliderBar*)m_pParent)->GetWidth() / ((SliderBar*)m_pParent)->GetMaxValue()) * ((SliderBar*)m_pParent)->GetStepSize()) * Event.m_RelMousePos.x, 0.0f, 0.0f);

if(m_Position.x < 0.0f)
m_Position.x = 0.0f;
if(m_Position.x > (((SliderBar*)m_pParent)->GetWidth() - m_nWidth - 2))
m_Position.x = (((SliderBar*)m_pParent)->GetWidth() - m_nWidth) - 2;

(Note to those that will complain about it: I convert my m_pParent pointer to SliderBar because the parent has to be SliderBar, no other class has access to this one.)

It uses DirectInput and I don't have it setup right, so alt-tabbing doesn't work at the moment (well it works, but when you come back you won't have control.)

I'd really appreciate some feedback!

Edit: The SettingsApp.exe will allow you to change your settings, but I botched the hardware/software and windowed/fullscreen settings. So, if you want to change those, go into settings.ini and change them (Vertex Processing Type can be either software or hardware and windowed can be either true or false.) Don't change the 'Settings Chosen' value.

Edit2: I'm going to continue listing stuff here as I add it. So, this list SHOULD grow for the next few hours.

  • Widget
  • Button
  • CheckBox (added 1:00am)
  • TextBox
  • SliderBar
  • Tally (added 2:00am)
  • Counter (added 2:15am)
  • non-scrolling ListBox (added 3:18am)
Sign in to follow this  

1 Comment

Recommended Comments

Ok, bedtime. I added a couple new features (see the bottom of the main entry.) Here is a new screenshot and a new link (the first link points to the same thing):

Updated GUI


Not bad for 3 hours worth of work, huh?

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!