Home > FuchsGUI, Games Programming, Graphics, Programming, XNA > XNA FuchsGUI part V

XNA FuchsGUI part V


1-Introduction to the GUI.
2-Hello control :D.
3-Hello form.
4-Exporting forms easily from Microsoft Visual Studio Designer to FuchsGUI :D.
5-The future of FuchsGUI & some notes.


This part of the tutorial is the last part of the series..

I don’t know how to organize this post since it’s not a tutorial 😉 so I’ll start with some notes on FuchsGUI.


A post without an image is a dull post 🙂

Textures & Fonts:

As you saw each control takes a Texture2D parameter in the constructor, well… having many textures might have a bad impact on performance, because if you first draw a Button and then a TextBox the GPU will have to change textures.

A better solution is to put textures of all controls inside a single sprite sheet, and when first initializing FuchsGUI through a static manager class you set the sprite sheet to a static field of type Texture2D (exists within the static manager class), this way you draw all your FuchsGUI controls without having the GPU to switch textures, & each control will have a static Rectangle that specifies what part of the sprite sheet belongs to this kind of control.

This way you can have different themes for the GUI that can be set at runtime ;).

But what if I wanted a specific button to have a unique texture? That can be arranged :).


I don’t think that I’m gonna program a designer, but I might write a parser that takes a Form file…This way instead of opening a pre-made visual studio solution, you just open an exe then select the file that contains the code for the form…more efficient of course, but writing a parser might not be that easy.


As a GUI dedicated to simulations\games, no need to program too many controls…

I’m hopping that I’ll improve the TextBox to make it a multi line TextBox, maybe add some text selection features..

I’m thinking about adding controls like : ProgressBar, Slider, ScrollBar, A Timer maybe??

I’ll add some static events like Button._onMouseEnter , in many cases you need to make a sound whenever the mouse cursor enters the button, so instead of wiring the event onMouseEnter for each button, you simply wire one event..

One thing is bothering me is the text drawn over the GUI, some places it’s clear, other places it’s blurry, I don’t know why but I hope I’ll fix it.


I’ve tested my GUI a LOT! & fixed many bugs, most of them were minor bugs…

If you intend to use my GUI then use it at your own risk, I’m not responsible for any application failure.

Sorry for being a little aggressive in the last line :(, I’m not saying that your hard disk will explode because of my GUI but you know I’m only one man! & my code isn’t perfect, there might be a bug or two that I didn’t notice…

If you plan to use my GUI please just let me know & I’ll be very happy 😀

Source Code:

Don’t bother yourself with reflecting FuchsGUI.dll, Here’s the full solution for FuchGUI:

FuchsGUI Source Code (VS2010 + XNA4.0)

Update: Blurry text is now fixed, Thanks to a guy named Fab who told me how to fix it 🙂

FuchsGUI v1.1 Source Bin XNA4 (Blurry Text Fixed)


FuchsGUI Source Code (VS2008 + XNA3.1)

Update 6/5/2012: the code is now available at codeplex: http://fuchsgui.codeplex.com/ ( Project created by LoneCoder).

The code is about 509 line of code ( According to Code Metrics in Microsoft Visual Studio )
There’s a class called KeyboardUtils, it’s not mine, I took it from one of the XNA samples..

Feel free to copy\modify any part of the code just please don’t claim it for yourself :(, Despite how small one’s work is, he hates to see it stolen.

The solution contains two projects:

1-FuchsGUI : This is the project of the GUI library, If you want to modify\add a control this is the place to do it…

2-FuchsGUILab : This is where I tested & debugged my controls, a lab where I try different GUI scenarios.

Final Words:

I first programmed this GUI for personal use, but why keep it for myself? other people might find it useful, so I thought writing a tutorial is the way!…

Programming the GUI increased my experience not only in XNA but also in how GUIs are programmed.

Now whenever I need a simple GUI for a framework other that XNA I can simply make some modifications to the code and it’s ready :).

Maybe some day I’ll right my own framework based on XNA 🙂

For any notes please use the comments below or contact me : ghoshehsoft@live.com

See you later :D.

  1. Zach
    17/01/2014 at 6:32 am

    Oh thank you so much.

    I’m writing a GUI for my game (“Off To Vega!”), I’ve previously made a gameState based system (MainMenu, Game, GamePause, Map, Inventory, etc), where all GUI elements were rendered by being given a parentGameState, and a huge switch-case statement in my GUI manager determined in a non-modular way what each button did. I knew from the start that this system wouldn’t last and was not very good.

    I wanted to create a panel (form) based GUI that was modular, but my main problem was how to have each form object perform a certain (hard coded) task.
    I felt like there were no good ways to tell an instance of a modular button specifically what it’s supposed to do.
    It seems like Delegates are the way to go, but they have always been the hardest for me to understand.

    I still plan to make my own GUI, you can understand the internal need to write your own functioning code rather than use someone else’s, even if theirs works great, but I’m going to use your code to understand how this system should work, and learn from it to make my own system.

    Thanks a lot for the code, but ALSO for the blog posts, this is the first good explanation of how a system like this works, and it has helped me a ton.

    • Fuchs
      18/01/2014 at 12:20 pm

      Hi Zack 🙂 , I totally understand how good it feels to write your own code, I hope you get it working :).

  1. 16/02/2011 at 11:39 pm
  2. 16/02/2011 at 11:41 pm
  3. 16/02/2011 at 11:41 pm
  4. 16/02/2011 at 11:42 pm

What do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: