• 9
• 9
• 11
• 12
• 9
• entries
707
1173
• views
435199

# Gui goodness

100 views

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.

- 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)

Information:
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())		((SliderBar*)m_pParent)->SetValue(((SliderBar*)m_pParent)->GetMinValue());	else if(((SliderBar*)m_pParent)->GetValue() > ((SliderBar*)m_pParent)->GetMaxValue())		((SliderBar*)m_pParent)->SetValue(((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
• TextBox
• SliderBar

## 1 Comment

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

GuiDemo.zip(1.56mb)

Not bad for 3 hours worth of work, huh?