Jump to content
  • Advertisement
  • entries
    707
  • comments
    1173
  • views
    435840

Sadness ensues

Sign in to follow this  
Programmer16

84 views

I took Metorical's advise and coded up a little example for my GUI other than just randomly place widgets. I also took some time to update a few things:

  • ListBox scrollbars are no longer visible when there are too few items
  • TextBoxes can now be read-only
  • Added an Image class
  • Added a console system
  • Modified the WidgetManager render loop so that all Images are rendered second-to-last (causing less SetTexture() calls.)
  • Modified the WidgetManager render loop so that all Labels are rendered last.

(Yes, I realize that a z-sorting system would solve this, but it's not my top priority at the moment.)

I still need to add RadioButtons, GroupBoxes, Tabs, and maybe a CollapsableList.

I'm going to start working on a layout and skin editor soon.

Anyway, here is a screenshot of the example:


And the source:

Widget* pWidget = m_WidgetMgr.AddWidget(new Image(0, "Graphics\\Backdrop.png", 0, 0, 800, 600, BackdropImageID));

pWidget = m_WidgetMgr.AddWidget(new TextBox(0, "Ho there wanderer!\n\nBefore you can pass into the city, I\nneed to record some of your information.", 15 + 200, 8, 357, 115, MessageBoxID));
((TextBox*)pWidget)->EnableReadOnly(true);
pWidget = m_WidgetMgr.AddWidget(new Label(0, "Name: ", 15 + 215, 140, LabelID));
pWidget = m_WidgetMgr.AddWidget(new TextBox(0, "", 15 + 215, 155, 150, 24, NameTextBoxID, 32));

pWidget = m_WidgetMgr.AddWidget(new Label(0, "Gender: ", 196 + 215, 130, LabelID));
pWidget = m_WidgetMgr.AddWidget(new ListBox(0, 196 + 215, 145, 176, 70, GenderListBoxID));
pWidget->AddChild(new ListBox::ListBoxItem(pWidget, "Male", 24));
pWidget->AddChild(new ListBox::ListBoxItem(pWidget, "Female", 24));

pWidget = m_WidgetMgr.AddWidget(new Label(0, "Race: ", 15 + 215, 230, LabelID));
pWidget = m_WidgetMgr.AddWidget(new ListBox(0, 15 + 215, 245, 176, 150, RaceListBoxID));
pWidget->AddChild(new ListBox::ListBoxItem(pWidget, "Human", 24));
pWidget->AddChild(new ListBox::ListBoxItem(pWidget, "Elf", 24));
pWidget->AddChild(new ListBox::ListBoxItem(pWidget, "Dwarf", 24));
pWidget->AddChild(new ListBox::ListBoxItem(pWidget, "Ogre", 24));

pWidget = m_WidgetMgr.AddWidget(new Label(0, "Class: ", 196 + 215, 230, LabelID));
pWidget = m_WidgetMgr.AddWidget(new ListBox(0, 196 + 215, 245, 176, 150, ClassListBoxID));
pWidget->AddChild(new ListBox::ListBoxItem(pWidget, "Fighter", 24));
pWidget->AddChild(new ListBox::ListBoxItem(pWidget, "Ranger", 24));
pWidget->AddChild(new ListBox::ListBoxItem(pWidget, "Mage", 24));
pWidget->AddChild(new ListBox::ListBoxItem(pWidget, "Theif", 24));

// Frame()
m_WidgetMgr.Render();

// EventHandler()
int nResults = m_WidgetMgr.EventHandler(Event);




Sorry for the crappy background, I just threw it in to test the Image class. The cool thing is that I can now have background images for different widgets just by adding it as a child to something. I'm going to need to add a fill-dock feature to a couple of the widgets though (like TextBox and Image) so that they resize with the parent.

The textbox at the top ("Ho there wanderer...") is a TextBox with the read-only flag set to true.

(lol, I just noticed that my Labels in DevShot23 aren't being displayed, so I had to modify the rendering loop again and uploaded DevShot24, shown above.)

So, if I have time over the weekend, I'll be adding the RadioButtons, GroupBoxes, and Tabs. I might do CollapsibleList, but I'm not sure yet. It is a really good way to show skills and such, but it might be a pain to code.

Actually, now that I think of it, it should be rather easy. Widgets are already defined in relative space (relative to their parents). All I would have to do is set it up so that the items are in a separate class and have a pointer to the last item (not the VERY last item, but the item added before it, regardless of level) and have them be defined relative to that controls point. Then, when collapsing just slide all subitems up and hide them.

So, in the following, each item has a pointer to the item directly above it, and would be positioned based on that:

Item1 (Parent null, LastItem null)
SubItem1 (Parent Item1, LastItem Item1)
SubItem2 (Parent Item1, LastItem SubItem1)
SubItem3 (Parent Item1, LastItem SubItem2)
SubItem4 (Parent Item1, LastItem SubItem3)
SubItem5 (Parent Item1, LastItem SubItem4)
SubItem6 (Parent Item1, LastItem SubItem5)
Item2 (Parent Item1, LastItem SubItem6)
SubItem7 (Parent Item2, LastItem Item2)
SubItem8 (Parent Item2, LastItem SubItem7)
SubItem9 (Parent Item2, LastItem SubItem8)
Item3 (Parent Item2, LastItem SubItem9)

Hmm, problem with that is that it'll turn out looking like a tree (if I use an offset system, where each child is offset by like 5,15):

Item1
SubItem1
Item2
SubItem2
Item3
etc


I don't know, I'm still not certain that it'd be very useful.

Edit:
Heh, my example screenshot isn't very "selling." I just don't have the time to work on something that is at the moment. Malathedra's Sept1 milestone is approaching and I need to focus most of my energy on that.

On monday I'll code up one of the systems for my contest entry. That should be a lot more "selling."

Edit 2: I forgot to mention that I'm going to be adding a per-widget skinless rendering flag. Why? Because I can. Seriously though, I'm just that cool. Wait, no, I meant I'll explain more when I'm done with it (that way I can show you a screenshot.)

Edit 3:
Ok, I've decided to go a different route with my contest entry. It'll still be mouse controlled and such, but I'm going to do more of a Pokemon type of game (graphically, not gameplay wise.) It fits more into the style of graphics that I can fire out, whereas a BG style game would require a lot of time (which I don't have at the moment.) The cool part is that I can keep the same pathfinding and I'll only have to change 1 line:

for(int nDir = 0; nDir < DIR_COUNT; ++nDir)
to
for(int nDir = 0; nDir < 4; ++nDir)

My directions are enumerated (W = 0, N = 1, E, S, NW, NE, SE, SW) and values are calculated via GetNeighbor() which takes a starting point and a dir.

AGH, I'm still wasting precious time[sad].
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

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!