• entries
    743
  • comments
    1924
  • views
    580414

GUI updates

Sign in to follow this  

89 views



Further to the GUI, I've just finished implementing the "selector" control as seen in the rough-out of the graphics options above.

The arrows either side of each option light up on mouse-over and allow you to scroll up and down the options. The options are requested from the main program when the window is opened and the selected index is also requested.

I haven't yet implemented querying the GUI for the current index of a selector, for example for when you click "Apply" or "OK" in the screen above, but it should be pretty trivial.

Further to rip-off's comments on the last post, the windows are now staying screen centre and it actually looks even cooler now than when they were flying around the screen (in my humble opinion [smile]).

Getting a bit nearer to being able to release a playable demo now.

[LATER]

The graphics options screen above now works fully now, allows you to actually change the options, can detect whether the set of options changed require a device reset or not and will restore any options you "Apply" when you press "Cancel". Options are only properly committed when you press "OK".

The game has been writing out its display configuration to a config file in the current user's local application data directory for a while so keeping these options persistent was already happening.

Plan for first-time-run is to try 1024x768 and if that fails, try 640x480, both with the lock aspect, vsync and linear filtering options on. Once in the game, the user can then tweak this to their hearts content.

Reckon I'll have a playable demo up by the end of the week.

[LATER]

This GUI system is working beautifully. I decided that I wanted the main Pause menu's Exit option to pop up an "Are you sure? Confirm/Cancel" type dialog before exiting the program instead of just dumping you straight out.

I was able to implement this change purely by modifying gui.xcs and without touching or recompiling the game code in any way at all.

I just defined the "confirm_exit" window in the file, changed the existing Exit button's Command property to "goto confirm_exit", then set the Confirm and Cancel buttons in the confirm_exit window to have the Command's "signal exit_game" (already responded to by the program itself) and "root" respectively. I also set the Escape property of the confirm_exit window to "root" so pressing escape cancels the window.

This is the current state of gui.xcs with some actual real stuff in rather than testing stuff:


font="Resource\\font.spf";
glyphs="Resource\\gui.spr";

game_ops
{
pos=centre;
size="200,300";

escape="close";

controls
{
control { type="label"; text="Paused"; pos="0,14"; size="200,30"; }

control { type="textbtn"; text="Continue"; pos="0,60"; size="200,30"; command="close"; }
control { type="textbtn"; text="Graphics"; pos="0,84"; size="200,30"; command="goto graphics"; }
control { type="textbtn"; text="Exit"; pos="0,108"; size="200,30"; command="goto confirm_exit"; }
}
}

graphics
{
pos=centre;
size="500,300";

escape="root";

controls
{
control { type="label"; text="Graphics"; pos="0,14"; size="500,30"; }

control { type="label"; text="Resolution"; pos="32,80"; }
control { id="res_select"; type="selector"; pos="248,80"; size="220,24"; }

control { type="label"; text="Lock Aspect Ratio"; pos="32,110"; }
control { id="aspect_lock_select"; type="selector"; pos="248,110"; size="220,24"; }

control { type="label"; text="Filter"; pos="32,140"; }
control { id="filter_select"; type="selector"; pos="248,140"; size="220,24"; }

control { type="label"; text="Vertical Sync"; pos="32,170"; }
control { id="vsync_select"; type="selector"; pos="248,170"; size="220,24"; }

control { type="textbtn"; text="OK"; pos="336,262"; command="signal gfx_ok"; }
control { type="textbtn"; text="Apply"; pos="370,262"; command="signal gfx_apply"; }
control { type="textbtn"; text="Cancel"; pos="422,262"; command="signal gfx_cancel"; }
}
}

confirm_exit
{
pos=centre;
size="300,160";

escape="root";

controls
{
control { type="label"; text="Are you sure you want to"; pos="0,14"; size="300,30"; }
control { type="label"; text="exit the game?"; pos="0,38"; size="300,30"; }

control { type="textbtn"; text="Confirm"; pos="0,80"; size="300,30"; command="signal exit_game"; }
control { type="textbtn"; text="Cancel"; pos="0,104"; size="300,30"; command="root"; }
}
}



Another minor feature upgrade is being able to specify "centre" rather than a position for each window, so that it automatically calculates the screen centre position for the window.

Also, specifying a "size" property for labels and textbtns means that they are automatically centred inside the rectangle defined by pos and size, but the mouseovers and clicks still only apply to the actual text. If no size property is specified, the control is just top-left anchored at its pos.

I think when this project is completed or dies the death, I might see if I can write the Pod-style GUI as a separate library that I can just drop into any other project.

My GraphicsDevice et al library have stabilised now for 2D games pretty much, so I guess I would go down the route of writing my "graphics.h" as a static library, then write a "gui.h" that depended just on "graphics.h" as another static lib.

It's a thought for the future, but I suspect I might end up with writing-an-engine-itis if I pursue it too far.
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