Squid GUI is a UI framework by IONSTAR Studios. It provides functionality for a number of common controls like buttons, check boxes, labels, drop down lists, and much more. You can even expand on it by creating your own custom controls. For information regarding the Squid GUI library, please refer to their website here: http://www.ionstar.org/?page_id=4
A simple layout system has been created to make developing your GUIs as easy as possible. Keep in mind that this is fairly bare-bones and will be expanded upon over time.
You can download a sample project here: Download
This sample project includes several things:
Graphics for the controls provided by IONSTAR's SquidGUI package
An Arial10 Spritefont
A sample XML layout
Code which handles most of the internal plumbing of getting the UI to draw on the screen.
A sample "GUI Logic" entity which demonstrates how to hook your GUI interaction events back to your screen.
This sample project will let you dive right in and see how everything works. However, if you need a more hands-on tutorial please keep reading to learn how this all works.
There's essentially three steps to creating a GUI:
Create the XML layout
Create the GUI interaction logic class
Add the interaction class to your screen
This guide will take you through each of these steps with a simple example. To start, we'll create a window with an "Exit Button" inside it. When this button is clicked, a confirmation box will appear. If the user confirms, the entire application will shut down.
Each layout must contain at least one window. Components such as buttons, check boxes, and labels are contained inside of the window.
We'll use this layout for this example.
This sample layout will create a window with a button labeled "Exit". The button will be 425 pixels wide and 40 pixels tall.
When working with position, it's important to keep in mind that all controls start at the origin of its parent window. So in this case, the button will be 50 pixels down from the center of the window.
Here's a screenshot of how the screen should look:
These are the currently supported component types:
Window
Label
Textbox
Button
Checkbox
Note that you can add additional types to the SquidLayoutManager class file.
Now that we have a layout, we need to provide interaction logic to the UI. In other words, when the user clicks the "Exit Button" we want a pop-up to appear.
To start, let's look at the class called MainMenuLogic in the example project.
This class is deriving from GUIDrawableBatch, which is used for all GUI interaction classes. This abstracts all of the lower level drawing and input logic, so you can focus on making the UI actually do stuff.
Let's look at the constructor.
It's very important to note the constructor is passing "MainMenu" into the base constructor. This is actually a reference to the file name of the layout which is MainMenu.xml
Next, refer to the LoadControls() method.
Here, we're loading the window and button into memory based on the component's "Name" field which is defined in the XML layout.
The rest is fairly straightforward. The HookEvents subscribes the method ExitButton_MouseClick to the MouseClick event provided by Squid. This calls a pop-up message box.
Finally, when the pop up menu's "Yes" button is clicked, it will fire the ExitConfirmClicked method which shuts down the game.
Now that we have the interaction class created, we need to instantiate it on the screen. For the example project, we're using the screen named "DemoScreen".
This next part is super easy - check out our DemoScreen code.
And that's all there is to it! You could start doing some more complicated things like raising events from the MainMenuLogic class and responding to them from the screen. However, that is outside the scope of this guide.
Squid GUI offers a great way to develop user interfaces in FlatRedBall. You can really do a lot with its simple XML configuration and it can be expanded upon fairly easily.