Saturday, March 31, 2007

XNA WindowSystem Source Code

Tomorrow I'm moving back to England, and won't be able to work on the project for a little while, so I thought this was as good a time as any to release an early version of my GUI for XNA. For screenshots, see my previous post.

Download Source Code

Features
  • Input events
  • Individual control transparency
  • Controls can have multiple skins, representing different states (hover, pressed etc.)
  • Skinnable at the GUI level through static calls, or at the control level
  • GUI and input event system implemented as game components
  • Custom mouse cursors
  • Modal windows
High-Level Controls
  • Check boxes
  • Combo boxes
  • Dialogs
  • Display settings dialog
  • Icons
  • Images
  • Image buttons
  • Text buttons
  • Labels
  • Menus
  • Context menus
  • Message boxes
  • Radio buttons
  • Radio groups
  • Vertical scrollbars
  • Text boxes
  • Windows
Future Plans
  • Flexible system for control animations
  • Possibly a settings file for customizing skins
  • Possibly bring the GUI into 3D for cooler animations
  • Context menus for any control, currently has to be done manually for each case
  • More complete textbox, with text selection and copy/paste
  • Horizontal scrollbars
Most of those features wouldn't be that hard to implement, it's just a matter of time.

The code is in a pretty stable state at the moment, but I'm sure there's hundreds of bugs to be found in there. Please feel free to contact me regarding any bugs, questions, or suggestions.

One know issue is that hideous amounts of temporary textures are created while resizing windows. I know the reason, but am waiting to find a graceful solution. Basically the GUI draws each control to it's own texture, allowing simple clipping and transparencies. While resizing windows, the control texture is recreated many times a second, sometimes using up all available texture memory. The simple fix in place at the moment, is that the garbage collector is called whenever this happens. Not pretty, but it doesn't crash. Everything goes back to normal when resizing ends.

This project uses code based on the Event Based Input System of the XNA5D library, and to a lesser extent the GUI components. The XNA5D library is by John Sedlak, and is available at jsedlak.org/Xna5D.

The library also uses the BitmapFont portion of XNAExtras for text rendering. To add new fonts to your projects, use the BMFontGen tool which part of the same project. XNAExtras is by Gary Kacmarcik, and is available at blogs.msdn.com/garykac/articles/749188.aspx.

Finally, although I drew the complete graphical skin, the message box icons are by Ken Saunders, and are available at mouserunner.com/Spheres_ColoCons1_Free_Icons.html.

Sometime soon I will post an overview of the system, and possibly a few quick tutorials on how to use it. It's pretty well documented, so this shouldn't pose too much of a problem for most of you.

In addition, I'll be releasing the source code of my first project to actually use the GUI, a tile map editor. It's already in a pretty usable state, but is very much a work in progress.

Oh yeah, and I need a name for the project. At the moment I'm just using WindowSystem for XNA, which is really just a description. Any ideas would be appreciated.

Thursday, March 29, 2007

XNA WindowSystem Screenshots

It's been a while since my last post, but I've been working hard on my GUI for the XNA Framework. There's a couple already available for free on the web, but I was really going for more of a complete window system, that could be used for game tools as well as game interfaces.


These screenshots show most of the controls available, and examples of them in use. As part of the development process, I've been working on a tile map editor to test out how the GUI should be used, and to uncover bugs.


Friday, March 2, 2007

XNA Framework

I started using the XNA Framework about a month ago, and thought I would share some of my opinions with you.

The first game I wrote was a version of Pong in Pascal at college, just as I was learning to program. I thought that if I really wanted to program games, I should start near the beginning. Shortly after I got a working version of Tetris up and running, which felt incredible at the time. In the second year we moved onto C++, and my one true love, object oriented programming! I spent that final year learning as much as possible, finally handing in a tile map demo as my final project. At university I was using DirectX to write 2D and 3D games, as well as simple online games in Java.

Now back to the XNA Framework. Considering my background in C++ and DirectX, I was reluctant to even give it a try. I'm sure lots of people feel the same, that they would lose control over their high performance game engine, and that C# could never compare to the speed offered by C++. I have to admit, I was very wrong.

The average hobbyist isn't going to be creating incredibly complex games, that would make the speed difference a serious issue. It's even been speculated that XNA games can be comparable in performance to a C++/DirectX equivalent. Regardless of whether that's true or not, the fact remains that this is a great platform for people who want to learn to make games, without having to handle all the technical details from day one.

From my perspective, I was sick of having to deal with every low-level technical detail required by game engines. Game studios have large teams working to achieve similar things. Can one person working part-time on a project reproduce that much work? Sometimes, but not often.

XNA allows programmers to concentrate more on the actual game, rather than developing the complex libraries used to traditionally program games. The integrated content pipeline is sheer genius, making game assets just as much a part of the project as the source files. I haven't dealt much with this side of the framework yet, but loading textures is a breeze!

I would recommend anybody thinking of learning game programming to give C# and the XNA Framework a try. It can take a lot of the complicated stuff out of the picture, but provide more advanced features if they are required, mainly though shaders.

I have a warning for people who might think that XNA makes programming games easy, like a click and play game creator. It doesn't. You still have to learn most of the same theory, and have a fair amount of experience with object oriented programming. Having said that, C# is a good place to start learning good object oriented design. For some reason C++ lures people into writing bad C-style code.

I think I'm rambling now, but I'd just like to say that people with games programming experience should also give it a try. If it can make you more productive by removing unnecessary details, think of what you could produce in the amount of time a C++ project might take. As a learning project I've been working on an XNA GUI for several weeks. I'm really pleased with the results, but can't wait to start making some games!