<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://cegui.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Doubleyou</id>
		<title>CEGUI Wiki - Crazy Eddie's GUI System (Open Source) - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="http://cegui.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Doubleyou"/>
		<link rel="alternate" type="text/html" href="http://cegui.org/wiki/Special:Contributions/Doubleyou"/>
		<updated>2026-04-06T04:40:54Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.24.1</generator>

	<entry>
		<id>http://cegui.org/wiki/index.php?title=CEGUI_In_Practice_-_A_Game_Console&amp;diff=4574</id>
		<title>CEGUI In Practice - A Game Console</title>
		<link rel="alternate" type="text/html" href="http://cegui.org/wiki/index.php?title=CEGUI_In_Practice_-_A_Game_Console&amp;diff=4574"/>
				<updated>2011-07-14T04:45:52Z</updated>
		
		<summary type="html">&lt;p&gt;Doubleyou: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{VersionBadge|0.7}}&lt;br /&gt;
{{Series|CEGUI In Practice|6}}&lt;br /&gt;
&lt;br /&gt;
== CEGUI InPractice 6 ==&lt;br /&gt;
&lt;br /&gt;
Welcome back! This tutorial we will put together the knowledge from the past few chapters to create a functioning Console window. The last few tutorials have given us the basics. Now its time to put that knowledge to use and make something we can use in our game.&lt;br /&gt;
&lt;br /&gt;
==== Game Plan ====&lt;br /&gt;
&lt;br /&gt;
Okay, now lets look at what we need to do. We will want to be able to type in commands, press the send button, and have them output into the text box. We will also probably want to acknowledge when enter is pressed as thats the 'normal' feel of typing into a chat.&lt;br /&gt;
&lt;br /&gt;
We discussed earlier how to send input to CEGUI ([[CEGUI In Practice - Managing input]]), so we will have to assume that you have that working (and probably built the application structure behind it). We will also assume you used the previous tutorial's layout file and naming for the console window ( [[CEGUI In Practice - Using .layout files]]).&lt;br /&gt;
&lt;br /&gt;
Due to the fact that we are getting to a slightly more advanced implementation of CEGUI here, and because we may want the ConsoleWindow to do other more useful things (like parsing strings for /say commands) I'm going to create a class to encompass the CEGUI ConsoleWindow.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
class GameConsoleWindow&lt;br /&gt;
{&lt;br /&gt;
    public:&lt;br /&gt;
       GameConsoleWindow();                   // Constructor&lt;br /&gt;
    private:&lt;br /&gt;
       void CreateCEGUIWindow();                                  // The function which will load in the CEGUI Window and register event handlers&lt;br /&gt;
       void RegisterHandlers();                                   // Register our handler functions&lt;br /&gt;
       bool Handle_TextSubmitted(const CEGUI::EventArgs &amp;amp;e);      // Handle when we press Enter after typing&lt;br /&gt;
       bool Handle_SendButtonPressed(const CEGUI::EventArgs &amp;amp;e);  // Handle when we press the Send button         &lt;br /&gt;
       void ParseText(CEGUI::String inMsg);                       // Parse the text the user submitted.&lt;br /&gt;
       void OutputText(CEGUI::String inMsg,                       // Post the message to the ChatHistory listbox.&lt;br /&gt;
              CEGUI::colour colour = CEGUI::colour( 0xFFFFFFFF)); //   with a white color default&lt;br /&gt;
       &lt;br /&gt;
       CEGUI::Window *m_ConsoleWindow;                            // This will be a pointer to the ConsoleRoot window.&lt;br /&gt;
       CEGUI::String sNamePrefix;                                  // This will be the prefix name we give the layout&lt;br /&gt;
       static int iInstanceNumber;                                 // This will be the instance number for this class. &lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alright, so that will be our class. It might look daunting, but don't worry it will all make sense in the end.&lt;br /&gt;
&lt;br /&gt;
==== The Constructor ====&lt;br /&gt;
&lt;br /&gt;
I'm going to use the constructor as the main point of automation here. And while I believe it is normally bad practice to call functions which could potentially fail within a constructor, i'm going to anyway for ease of this tutorial. We will have it Initialize some variables, and then call the CreateCEGUIWindow function.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
GameConsoleWindow::GameConsoleWindow()&lt;br /&gt;
{&lt;br /&gt;
   m_ConsoleWindow = NULL;       // Always good practice to initialize a pointer to a NULL value, helps when switching to Release Builds.&lt;br /&gt;
   iInstanceNumber = 0;&lt;br /&gt;
   sNamePrefix = &amp;quot;&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
==== Setting up the Window ====&lt;br /&gt;
&lt;br /&gt;
Now we need to setup the window. We have done this before in the .layout tutorial so we will do it again here. However, we mentioned before that you could use a prefix when loading a .layout to avoid name conflicts if you load multiple layouts. So we need to account for that. Will we need multiple consoles? Who knows, might as well build it in while we're designing it right?&lt;br /&gt;
&lt;br /&gt;
Lets write the CreateCEGUIWindow function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void GameConsoleWindow::CreateCEGUIWindow()&lt;br /&gt;
{&lt;br /&gt;
	// Get a local pointer to the CEGUI Window Manager, Purely for convenience to reduce typing&lt;br /&gt;
	CEGUI::WindowManager *pWindowManager = CEGUI::WindowManager::getSingletonPtr();&lt;br /&gt;
&lt;br /&gt;
        // Now before we load anything, lets increase our instance number to ensure no conflicts.  &lt;br /&gt;
        // I like the format #_ConsoleRoot so thats how i'm gonna make the prefix.  This simply&lt;br /&gt;
        // Increments the iInstanceNumber then puts it + a _ into the sNamePrefix string. &lt;br /&gt;
        sNamePrefix = ++iInstanceNumber + &amp;quot;_&amp;quot;;&lt;br /&gt;
        &lt;br /&gt;
        // Now that we can ensure that we have a safe prefix, and won't have any naming conflicts lets create the window&lt;br /&gt;
        // and assign it to our member window pointer m_ConsoleWindow&lt;br /&gt;
        m_ConsoleWindow = pWindowManager-&amp;gt;loadWindowLayout(inLayoutName,sNamePrefix);&lt;br /&gt;
&lt;br /&gt;
        // Being a good programmer, its a good idea to ensure that we got a valid window back. &lt;br /&gt;
        if (m_ConsoleWindow)&lt;br /&gt;
        {&lt;br /&gt;
            // Lets add our new window to the Root GUI Window&lt;br /&gt;
            CEGUI::System::getSingleton().getGUISheet()-&amp;gt;addChildWindow(m_ConsoleWindow);&lt;br /&gt;
            // Now register the handlers for the events (Clicking, typing, etc)&lt;br /&gt;
            (this)-&amp;gt;RegisterHandlers();&lt;br /&gt;
        }&lt;br /&gt;
        else&lt;br /&gt;
        {&lt;br /&gt;
            // Something bad happened and we didn't successfully create the window lets output the information&lt;br /&gt;
            CEGUI::Logger::getSingleton().logEvent(&amp;quot;Error: Unable to load the ConsoleWindow from .layout&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alright so that created the window. And after the window was created, we Registered its handlers. Lets look at how we go about&lt;br /&gt;
registering those handlers. Below is the RegisterHandlers function, it will probably look familiar if you have been reading along:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void GameConsoleWindow::RegisterHandlers()&lt;br /&gt;
{&lt;br /&gt;
    // Alright now we need to register the handlers.  We mentioned above we want to acknowledge when the user presses Enter, and &lt;br /&gt;
      // when they click the 'Send' button.  So we need to register each of those events&lt;br /&gt;
&lt;br /&gt;
    // First lets register the Send button.  Our buttons name is &amp;quot;ConsoleRoot/SendButton&amp;quot;, but don't forget we prepended a name to      &lt;br /&gt;
      // all the windows which were loaded.  So we need to take that into account here.&lt;br /&gt;
    m_ConsoleWindow-&amp;gt;getChild(sNamePrefix + &amp;quot;ConsoleRoot/SendButton&amp;quot;)-&amp;gt;subscribeEvent(&lt;br /&gt;
                        CEGUI::PushButton::EventClicked,    // If we recall our button was of type CEGUI::PushButton in the .scheme&lt;br /&gt;
                                                            // and we want to acknowledge the EventClicked action.&lt;br /&gt;
                        CEGUI::Event::Subscriber(           // What function to call when this is clicked.  Remember, all functions &lt;br /&gt;
                                                            // are contained within (this) class.&lt;br /&gt;
                        &amp;amp;GameConsoleWindow::Handle_SendButtonPressed,  // Call Handle_SendButtonPressed member of GameConsoleWindow&lt;br /&gt;
                        this));                             // Using (this) instance we're in right now&lt;br /&gt;
&lt;br /&gt;
    // Now for the TextSubmitted, we will be registering the event on the edit box, which is where the users cursor will be when   &lt;br /&gt;
      //they press Enter.  I'm not going to break this down as much, because I believe that is very ugly to read, but was a good  &lt;br /&gt;
      //way of expressing it.  Here is the function call.&lt;br /&gt;
    m_ConsoleWindow-&amp;gt;getChild(sNamePrefix + &amp;quot;ConsoleRoot/EditBox&amp;quot;)-&amp;gt;subscribeEvent(CEGUI::Editbox::EventMouseClick,&lt;br /&gt;
                        CEGUI::Event::Subscriber(&amp;amp;GameConsoleWindow::Handle_TextSubmitted,this));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
That last line looks pretty ugly, but remember if you include namespace CEGUI; you won't have all those Ugly CEGUI:: prefixing all the code. As you can see, once you get the hang of registering events its pretty easy. One thing to note, is there are more than one way to account for certain actions. On the button, you could also have registered for:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    CEGUI::PushButton::EventMouseClick&lt;br /&gt;
    CEGUI::PushButton::EventMouseButtonDown&lt;br /&gt;
    CEGUI::PushButton::EventMouseButtonUp&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Depending on what result you were looking for, and where you wanted the action to take place. For example, windows interfaces usually react on the MouseButtonUp, allowing the user to click it, and then slide off the mouse if it wasn't what they really wanted to press.&lt;br /&gt;
&lt;br /&gt;
==== The Handlers ====&lt;br /&gt;
&lt;br /&gt;
Now that we have registered the events, we need to actually write the functions which will handle those events. We need to handle both the Text Submitted, and the SendButton's event. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool GameConsoleWindow::Handle_TextSubmitted(const CEGUI::EventArgs &amp;amp;e)&lt;br /&gt;
{&lt;br /&gt;
    // The following line of code is not really needed in this particular example, but is good to show.  The EventArgs by itself &lt;br /&gt;
     // only has limited uses. You will find it more useful to cast this to another type of Event.  In this case WindowEventArgs&lt;br /&gt;
     // could be much more useful as we are dealing with a CEGUI::Window.  Notably, this will allow you access to the .window&lt;br /&gt;
     // member of the argument, which will have a pointer to the window which called the event.  You can imagine that would be&lt;br /&gt;
     // useful!&lt;br /&gt;
    const CEGUI::WindowEventArgs* args = static_cast&amp;lt;const CEGUI::WindowEventArgs*&amp;gt;(&amp;amp;e);&lt;br /&gt;
&lt;br /&gt;
    // Now we need to get the text that is in the edit box right now.&lt;br /&gt;
    CEGUI::String Msg = mWindow-&amp;gt;getChild(sNamePrefix + &amp;quot;ConsoleRoot/EditBox&amp;quot;)-&amp;gt;getText();&lt;br /&gt;
&lt;br /&gt;
    // Since we have that string, lets send it to the TextParser which will handle it from here&lt;br /&gt;
    (this)-&amp;gt;ParseText(Msg);&lt;br /&gt;
&lt;br /&gt;
    // Now that we've finished with the text, we need to ensure that we clear out the EditBox.  This is what we would expect&lt;br /&gt;
      // To happen after we press enter&lt;br /&gt;
    m_ConsoleWindow-&amp;gt;getChild(sNamePrefix + &amp;quot;ConsoleRoot/EditBox&amp;quot;)-&amp;gt;setText(&amp;quot;&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    return true;&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you might be wondering why we didn't just Parse the text in here? Well If the user presses Enter, or presses the Send button the text will either way have to be parsed, and it will be parsed in the same manner. So why write the same code twice?&lt;br /&gt;
&lt;br /&gt;
Below is the code for handling the SendButton being pressed. I know I just harped on rewriting code, and this will ironically look alot like the Code for when text has been submitted. But thats because we don't really need the button to do much. We probably could have just had the ButtonPress trigger the Handle_TextSubmitted above when we registered the handlers, but what if we wanted a clicking noise to be played when the player pressed the button? Then we would need a seperate handler for the Send button. Anyway 'nuff said, lets show the code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool GameConsoleWindow::Handle_SendButtonPressed(const CEGUI::EventArgs &amp;amp;e)&lt;br /&gt;
{&lt;br /&gt;
    CEGUI::String Msg = mWindow-&amp;gt;getChild(sNamePrefix + &amp;quot;ConsoleRoot/EditBox&amp;quot;)-&amp;gt;getText();&lt;br /&gt;
    (this)-&amp;gt;ParseText(Msg);&lt;br /&gt;
    m_ConsoleWindow-&amp;gt;getChild(sNamePrefix + &amp;quot;ConsoleRoot/EditBox&amp;quot;)-&amp;gt;setText(&amp;quot;&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    return true;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Parsing that Text ====&lt;br /&gt;
&lt;br /&gt;
This portion is not going to be so much CEGUI Related as it will be string manipulation. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
void GameConsoleWindow::ParseText(CEGUI::String inMsg)&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
       // I personally like working with std::string. So i'm going to convert it here.&lt;br /&gt;
       std::string inString = inMsg.c_str();&lt;br /&gt;
&lt;br /&gt;
	if (inString.length() &amp;gt;= 1) // Be sure we got a string longer than 0&lt;br /&gt;
	{&lt;br /&gt;
		if (inString.at(0) == '/') // Check if the first letter is a 'command'&lt;br /&gt;
		{&lt;br /&gt;
			std::string::size_type commandEnd = inString.find(&amp;quot; &amp;quot;, 1);&lt;br /&gt;
			std::string command = inString.substr(1, commandEnd - 1);&lt;br /&gt;
			std::string commandArgs = inString.substr(commandEnd + 1, inString.length() - (commandEnd + 1));&lt;br /&gt;
			//convert command to lower case&lt;br /&gt;
			for(std::string::size_type i=0; i &amp;lt; command.length(); i++)&lt;br /&gt;
			{&lt;br /&gt;
				command[i] = tolower(command[i]);&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			// Begin processing&lt;br /&gt;
&lt;br /&gt;
			if (command == &amp;quot;say&amp;quot;)&lt;br /&gt;
			{&lt;br /&gt;
				std::string outString = &amp;quot;You:&amp;quot; + inString; // Append our 'name' to the message we'll display in the list&lt;br /&gt;
                         	mConsole-&amp;gt;OutputMessage(outString);&lt;br /&gt;
			}&lt;br /&gt;
			else if (command == &amp;quot;quit&amp;quot;)&lt;br /&gt;
			{&lt;br /&gt;
				// do a /quit &lt;br /&gt;
			}&lt;br /&gt;
			else if (command == &amp;quot;help&amp;quot;)&lt;br /&gt;
			{&lt;br /&gt;
				// do a /help&lt;br /&gt;
			}&lt;br /&gt;
			else&lt;br /&gt;
			{&lt;br /&gt;
				std::string outString = &amp;quot;&amp;lt;&amp;quot; + inString + &amp;quot;&amp;gt; is an invalid command.&amp;quot;;&lt;br /&gt;
				(this)-&amp;gt;OutputText(outString,CEGUI::colour(1.0f,0.0f,0.0f)); // With red ANGRY colors!&lt;br /&gt;
			}&lt;br /&gt;
		} // End if /&lt;br /&gt;
		else&lt;br /&gt;
		{&lt;br /&gt;
	 (this)-&amp;gt;OutputText(inString); // no commands, just output what they wrote&lt;br /&gt;
		}&lt;br /&gt;
	} &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Phew, thats kinda an annoying function isn't it? Well, the point to note is that it checks for a forward slash, if it finds one then it enters the if/else conditions to see if it found an applicable command. If it does it does something. In this example it handles the actions right there, if you were to write it a little more advanced, it could goto a (this)-&amp;gt;ShowHelp() or (this)-&amp;gt;QuitGame(). &lt;br /&gt;
&lt;br /&gt;
The point to note is the OutputText. That will add the items to the ListBox of Chat history. We will work on that function now.&lt;br /&gt;
&lt;br /&gt;
==== OutputText ====&lt;br /&gt;
&lt;br /&gt;
A point to note here. A CEGUI::Listbox window doesn't naturally word wrap. And wordwrapping is a very nice thing to have in a chat window, as everyone has different resolutions on their screens, and some people REALLY like to ramble! (But not this magnificant author of course!). So we will use a Custom created widget which is available on the forums [http://www.cegui.org.uk/phpBB2/viewtopic.php?f=10&amp;amp;t=4322]. you could use a normal listbox, but you wouldn't get word-wrapping.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt; &lt;br /&gt;
void GameConsoleWindow::OutputText(std::string message, CEGUI::colour colour)&lt;br /&gt;
{&lt;br /&gt;
	&lt;br /&gt;
	// Get a pointer to the ChatBox so we don't have to use this ugly getChild function everytime.&lt;br /&gt;
	CEGUI::Listbox *outputWindow = static_cast&amp;lt;CEGUI::Listbox*&amp;gt;(m_ConsoleWindow-&amp;gt;getChild(&amp;quot;ConsoleRoot/ChatBox&amp;quot;));&lt;br /&gt;
	&lt;br /&gt;
	CEGUI::FormattedListboxTextItem *newItem=0; // This will hold the actual text and will be the listbox segment / item&lt;br /&gt;
&lt;br /&gt;
	newItem = new CEGUI::FormattedListboxTextItem(message,CEGUI::HTF_WORDWRAP_LEFT_ALIGNED); // Instance the Item with Left&lt;br /&gt;
                                                                                                   //   wordwrapped alignment&lt;br /&gt;
	newItem-&amp;gt;setTextColours(colour); // Set the text color&lt;br /&gt;
	outputWindow-&amp;gt;addItem(newItem); // Add the new ListBoxTextItem to the ListBox&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Conclusion ====&lt;br /&gt;
&lt;br /&gt;
And that ladies and gentleman, is our Console box. Not too terrible was it? Now of course, remember there are many ways to skin the proverbial cat. This is just an example of ways to do things. If you would like some homework, you could investigate why the SendButton does weird things when you drag and resize the window. I'll give you a hint, look at the way we're defining how big the ConsoleRoot is and where its child windows are placed... and what implications we might have by using relative scales for things.. Okay, i guess that was a big hint wasn't it! &lt;br /&gt;
&lt;br /&gt;
Till next time...&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Doubleyou</name></author>	</entry>

	<entry>
		<id>http://cegui.org/wiki/index.php?title=CEGUI_In_Practice_-_A_Game_Console&amp;diff=4573</id>
		<title>CEGUI In Practice - A Game Console</title>
		<link rel="alternate" type="text/html" href="http://cegui.org/wiki/index.php?title=CEGUI_In_Practice_-_A_Game_Console&amp;diff=4573"/>
				<updated>2011-07-14T04:35:19Z</updated>
		
		<summary type="html">&lt;p&gt;Doubleyou: /* Parsing that Text */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{VersionBadge|0.7}}&lt;br /&gt;
{{Series|CEGUI In Practice|6}}&lt;br /&gt;
&lt;br /&gt;
== CEGUI InPractice 6 ==&lt;br /&gt;
&lt;br /&gt;
Welcome back! This tutorial we will put together the knowledge from the past few chapters to create a functioning Console window. The last few tutorials have given us the basics. Now its time to put that knowledge to use and make something we can use in our game.&lt;br /&gt;
&lt;br /&gt;
==== Game Plan ====&lt;br /&gt;
&lt;br /&gt;
Okay, now lets look at what we need to do. We will want to be able to type in commands, press the send button, and have them output into the text box. We will also probably want to acknowledge when enter is pressed as thats the 'normal' feel of typing into a chat.&lt;br /&gt;
&lt;br /&gt;
We discussed earlier how to send input to CEGUI ([[CEGUI In Practice - Managing input]]), so we will have to assume that you have that working (and probably built the application structure behind it). We will also assume you used the previous tutorial's layout file and naming for the console window ( [[CEGUI In Practice - Using .layout files]]).&lt;br /&gt;
&lt;br /&gt;
Due to the fact that we are getting to a slightly more advanced implementation of CEGUI here, and because we may want the ConsoleWindow to do other more useful things (like parsing strings for /say commands) I'm going to create a class to encompass the CEGUI ConsoleWindow.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
class GameConsoleWindow&lt;br /&gt;
{&lt;br /&gt;
    public:&lt;br /&gt;
       GameConsoleWindow();                   // Constructor&lt;br /&gt;
    private:&lt;br /&gt;
       void CreateCEGUIWindow();                                  // The function which will load in the CEGUI Window and register event handlers&lt;br /&gt;
       void RegisterHandlers();                                   // Register our handler functions&lt;br /&gt;
       bool Handle_TextSubmitted(const CEGUI::EventArgs &amp;amp;e);      // Handle when we press Enter after typing&lt;br /&gt;
       bool Handle_SendButtonPressed(const CEGUI::EventArgs &amp;amp;e);  // Handle when we press the Send button         &lt;br /&gt;
       void ParseText(CEGUI::String inMsg);                       // Parse the text the user submitted.&lt;br /&gt;
       void OutputText(CEGUI::String inMsg,                       // Post the message to the ChatHistory listbox.&lt;br /&gt;
              CEGUI::Colour colour = CEGUI::Colour( 0xFFFFFFFF)); //   with a white color default&lt;br /&gt;
       &lt;br /&gt;
       CEGUI::Window *m_ConsoleWindow;                            // This will be a pointer to the ConsoleRoot window.&lt;br /&gt;
       CEGUI::String sNamePrefix;                                  // This will be the prefix name we give the layout&lt;br /&gt;
       static int iInstanceNumber;                                 // This will be the instance number for this class. &lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alright, so that will be our class. It might look daunting, but don't worry it will all make sense in the end.&lt;br /&gt;
&lt;br /&gt;
==== The Constructor ====&lt;br /&gt;
&lt;br /&gt;
I'm going to use the constructor as the main point of automation here. And while I believe it is normally bad practice to call functions which could potentially fail within a constructor, i'm going to anyway for ease of this tutorial. We will have it Initialize some variables, and then call the CreateCEGUIWindow function.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
GameConsoleWindow::GameConsoleWindow()&lt;br /&gt;
{&lt;br /&gt;
   m_ConsoleWindow = NULL;       // Always good practice to initialize a pointer to a NULL value, helps when switching to Release Builds.&lt;br /&gt;
   iInstanceNumber = 0;&lt;br /&gt;
   sNamePrefix = &amp;quot;&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
==== Setting up the Window ====&lt;br /&gt;
&lt;br /&gt;
Now we need to setup the window. We have done this before in the .layout tutorial so we will do it again here. However, we mentioned before that you could use a prefix when loading a .layout to avoid name conflicts if you load multiple layouts. So we need to account for that. Will we need multiple consoles? Who knows, might as well build it in while we're designing it right?&lt;br /&gt;
&lt;br /&gt;
Lets write the CreateCEGUIWindow function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void GameConsoleWindow::CreateCEGUIWindow()&lt;br /&gt;
{&lt;br /&gt;
	// Get a local pointer to the CEGUI Window Manager, Purely for convenience to reduce typing&lt;br /&gt;
	CEGUI::WindowManager *pWindowManager = CEGUI::WindowManager::getSingletonPtr();&lt;br /&gt;
&lt;br /&gt;
        // Now before we load anything, lets increase our instance number to ensure no conflicts.  &lt;br /&gt;
        // I like the format #_ConsoleRoot so thats how i'm gonna make the prefix.  This simply&lt;br /&gt;
        // Increments the iInstanceNumber then puts it + a _ into the sNamePrefix string. &lt;br /&gt;
        sNamePrefix = ++iInstanceNumber + &amp;quot;_&amp;quot;;&lt;br /&gt;
        &lt;br /&gt;
        // Now that we can ensure that we have a safe prefix, and won't have any naming conflicts lets create the window&lt;br /&gt;
        // and assign it to our member window pointer m_ConsoleWindow&lt;br /&gt;
        m_ConsoleWindow = pWindowManager-&amp;gt;loadWindowLayout(inLayoutName,sNamePrefix);&lt;br /&gt;
&lt;br /&gt;
        // Being a good programmer, its a good idea to ensure that we got a valid window back. &lt;br /&gt;
        if (m_ConsoleWindow)&lt;br /&gt;
        {&lt;br /&gt;
            // Lets add our new window to the Root GUI Window&lt;br /&gt;
            CEGUI::System::getSingleton().getGUISheet()-&amp;gt;addChildWindow(m_ConsoleWindow);&lt;br /&gt;
            // Now register the handlers for the events (Clicking, typing, etc)&lt;br /&gt;
            (this)-&amp;gt;RegisterHandlers();&lt;br /&gt;
        }&lt;br /&gt;
        else&lt;br /&gt;
        {&lt;br /&gt;
            // Something bad happened and we didn't successfully create the window lets output the information&lt;br /&gt;
            CEGUI::Logger::getSingleton().logEvent(&amp;quot;Error: Unable to load the ConsoleWindow from .layout&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alright so that created the window. And after the window was created, we Registered its handlers. Lets look at how we go about&lt;br /&gt;
registering those handlers. Below is the RegisterHandlers function, it will probably look familiar if you have been reading along:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void GameConsoleWindow::RegisterHandlers()&lt;br /&gt;
{&lt;br /&gt;
    // Alright now we need to register the handlers.  We mentioned above we want to acknowledge when the user presses Enter, and &lt;br /&gt;
      // when they click the 'Send' button.  So we need to register each of those events&lt;br /&gt;
&lt;br /&gt;
    // First lets register the Send button.  Our buttons name is &amp;quot;ConsoleRoot/SendButton&amp;quot;, but don't forget we prepended a name to      &lt;br /&gt;
      // all the windows which were loaded.  So we need to take that into account here.&lt;br /&gt;
    m_ConsoleWindow-&amp;gt;getChild(sNamePrefix + &amp;quot;ConsoleRoot/SendButton&amp;quot;)-&amp;gt;subscribeEvent(&lt;br /&gt;
                        CEGUI::PushButton::EventClicked,    // If we recall our button was of type CEGUI::PushButton in the .scheme&lt;br /&gt;
                                                            // and we want to acknowledge the EventClicked action.&lt;br /&gt;
                        CEGUI::Event::Subscriber(           // What function to call when this is clicked.  Remember, all functions &lt;br /&gt;
                                                            // are contained within (this) class.&lt;br /&gt;
                        &amp;amp;GameConsoleWindow::Handle_SendButtonPressed,  // Call Handle_SendButtonPressed member of GameConsoleWindow&lt;br /&gt;
                        this));                             // Using (this) instance we're in right now&lt;br /&gt;
&lt;br /&gt;
    // Now for the TextSubmitted, we will be registering the event on the edit box, which is where the users cursor will be when   &lt;br /&gt;
      //they press Enter.  I'm not going to break this down as much, because I believe that is very ugly to read, but was a good  &lt;br /&gt;
      //way of expressing it.  Here is the function call.&lt;br /&gt;
    m_ConsoleWindow-&amp;gt;getChild(sNamePrefix + &amp;quot;ConsoleRoot/EditBox&amp;quot;)-&amp;gt;subscribeEvent(CEGUI::Editbox::EventMouseClick,&lt;br /&gt;
                        CEGUI::Event::Subscriber(&amp;amp;GameConsoleWindow::Handle_TextSubmitted,this));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
That last line looks pretty ugly, but remember if you include namespace CEGUI; you won't have all those Ugly CEGUI:: prefixing all the code. As you can see, once you get the hang of registering events its pretty easy. One thing to note, is there are more than one way to account for certain actions. On the button, you could also have registered for:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    CEGUI::PushButton::EventMouseClick&lt;br /&gt;
    CEGUI::PushButton::EventMouseButtonDown&lt;br /&gt;
    CEGUI::PushButton::EventMouseButtonUp&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Depending on what result you were looking for, and where you wanted the action to take place. For example, windows interfaces usually react on the MouseButtonUp, allowing the user to click it, and then slide off the mouse if it wasn't what they really wanted to press.&lt;br /&gt;
&lt;br /&gt;
==== The Handlers ====&lt;br /&gt;
&lt;br /&gt;
Now that we have registered the events, we need to actually write the functions which will handle those events. We need to handle both the Text Submitted, and the SendButton's event. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool GameConsoleWindow::Handle_TextSubmitted(const CEGUI::EventArgs &amp;amp;e)&lt;br /&gt;
{&lt;br /&gt;
    // The following line of code is not really needed in this particular example, but is good to show.  The EventArgs by itself &lt;br /&gt;
     // only has limited uses. You will find it more useful to cast this to another type of Event.  In this case WindowEventArgs&lt;br /&gt;
     // could be much more useful as we are dealing with a CEGUI::Window.  Notably, this will allow you access to the .window&lt;br /&gt;
     // member of the argument, which will have a pointer to the window which called the event.  You can imagine that would be&lt;br /&gt;
     // useful!&lt;br /&gt;
    const CEGUI::WindowEventArgs* args = static_cast&amp;lt;const CEGUI::WindowEventArgs*&amp;gt;(&amp;amp;e);&lt;br /&gt;
&lt;br /&gt;
    // Now we need to get the text that is in the edit box right now.&lt;br /&gt;
    CEGUI::String Msg = mWindow-&amp;gt;getChild(sNamePrefix + &amp;quot;ConsoleRoot/EditBox&amp;quot;)-&amp;gt;getText();&lt;br /&gt;
&lt;br /&gt;
    // Since we have that string, lets send it to the TextParser which will handle it from here&lt;br /&gt;
    (this)-&amp;gt;ParseText(Msg);&lt;br /&gt;
&lt;br /&gt;
    // Now that we've finished with the text, we need to ensure that we clear out the EditBox.  This is what we would expect&lt;br /&gt;
      // To happen after we press enter&lt;br /&gt;
    m_ConsoleWindow-&amp;gt;getChild(sNamePrefix + &amp;quot;ConsoleRoot/EditBox&amp;quot;)-&amp;gt;setText(&amp;quot;&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    return true;&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you might be wondering why we didn't just Parse the text in here? Well If the user presses Enter, or presses the Send button the text will either way have to be parsed, and it will be parsed in the same manner. So why write the same code twice?&lt;br /&gt;
&lt;br /&gt;
Below is the code for handling the SendButton being pressed. I know I just harped on rewriting code, and this will ironically look alot like the Code for when text has been submitted. But thats because we don't really need the button to do much. We probably could have just had the ButtonPress trigger the Handle_TextSubmitted above when we registered the handlers, but what if we wanted a clicking noise to be played when the player pressed the button? Then we would need a seperate handler for the Send button. Anyway 'nuff said, lets show the code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool GameConsoleWindow::Handle_SendButtonPressed(const CEGUI::EventArgs &amp;amp;e)&lt;br /&gt;
{&lt;br /&gt;
    CEGUI::String Msg = mWindow-&amp;gt;getChild(sNamePrefix + &amp;quot;ConsoleRoot/EditBox&amp;quot;)-&amp;gt;getText();&lt;br /&gt;
    (this)-&amp;gt;ParseText(Msg);&lt;br /&gt;
    m_ConsoleWindow-&amp;gt;getChild(sNamePrefix + &amp;quot;ConsoleRoot/EditBox&amp;quot;)-&amp;gt;setText(&amp;quot;&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    return true;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Parsing that Text ====&lt;br /&gt;
&lt;br /&gt;
This portion is not going to be so much CEGUI Related as it will be string manipulation. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
void GameConsoleWindow::ParseText(CEGUI::String inMsg)&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
       // I personally like working with std::string. So i'm going to convert it here.&lt;br /&gt;
       std::string inString = inMsg.c_str();&lt;br /&gt;
&lt;br /&gt;
	if (inString.length() &amp;gt;= 1) // Be sure we got a string longer than 0&lt;br /&gt;
	{&lt;br /&gt;
		if (inString.at(0) == '/') // Check if the first letter is a 'command'&lt;br /&gt;
		{&lt;br /&gt;
			std::string::size_type commandEnd = inString.find(&amp;quot; &amp;quot;, 1);&lt;br /&gt;
			std::string command = inString.substr(1, commandEnd - 1);&lt;br /&gt;
			std::string commandArgs = inString.substr(commandEnd + 1, inString.length() - (commandEnd + 1));&lt;br /&gt;
			//convert command to lower case&lt;br /&gt;
			for(std::string::size_type i=0; i &amp;lt; command.length(); i++)&lt;br /&gt;
			{&lt;br /&gt;
				command[i] = tolower(command[i]);&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			// Begin processing&lt;br /&gt;
&lt;br /&gt;
			if (command == &amp;quot;say&amp;quot;)&lt;br /&gt;
			{&lt;br /&gt;
				std::string outString = &amp;quot;You:&amp;quot; + inString; // Append our 'name' to the message we'll display in the list&lt;br /&gt;
                         	mConsole-&amp;gt;OutputMessage(outString);&lt;br /&gt;
			}&lt;br /&gt;
			else if (command == &amp;quot;quit&amp;quot;)&lt;br /&gt;
			{&lt;br /&gt;
				// do a /quit &lt;br /&gt;
			}&lt;br /&gt;
			else if (command == &amp;quot;help&amp;quot;)&lt;br /&gt;
			{&lt;br /&gt;
				// do a /help&lt;br /&gt;
			}&lt;br /&gt;
			else&lt;br /&gt;
			{&lt;br /&gt;
				std::string outString = &amp;quot;&amp;lt;&amp;quot; + inString + &amp;quot;&amp;gt; is an invalid command.&amp;quot;;&lt;br /&gt;
				(this)-&amp;gt;OutputText(outString,CEGUI::Colour(1.0f,0.0f,0.0f)); // With red ANGRY colors!&lt;br /&gt;
			}&lt;br /&gt;
		} // End if /&lt;br /&gt;
		else&lt;br /&gt;
		{&lt;br /&gt;
	 (this)-&amp;gt;OutputText(inString); // no commands, just output what they wrote&lt;br /&gt;
		}&lt;br /&gt;
	} &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Phew, thats kinda an annoying function isn't it? Well, the point to note is that it checks for a forward slash, if it finds one then it enters the if/else conditions to see if it found an applicable command. If it does it does something. In this example it handles the actions right there, if you were to write it a little more advanced, it could goto a (this)-&amp;gt;ShowHelp() or (this)-&amp;gt;QuitGame(). &lt;br /&gt;
&lt;br /&gt;
The point to note is the OutputText. That will add the items to the ListBox of Chat history. We will work on that function now.&lt;br /&gt;
&lt;br /&gt;
==== OutputText ====&lt;br /&gt;
&lt;br /&gt;
A point to note here. A CEGUI::Listbox window doesn't naturally word wrap. And wordwrapping is a very nice thing to have in a chat window, as everyone has different resolutions on their screens, and some people REALLY like to ramble! (But not this magnificant author of course!). So we will use a Custom created widget which is available on the forums [http://www.cegui.org.uk/phpBB2/viewtopic.php?f=10&amp;amp;t=4322]. you could use a normal listbox, but you wouldn't get word-wrapping.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt; &lt;br /&gt;
void GameConsoleWindow::OutputText(std::string message, CEGUI::Colour colour)&lt;br /&gt;
{&lt;br /&gt;
	&lt;br /&gt;
	// Get a pointer to the ChatBox so we don't have to use this ugly getChild function everytime.&lt;br /&gt;
	CEGUI::Listbox *outputWindow = static_cast&amp;lt;CEGUI::Listbox*&amp;gt;(m_ConsoleWindow-&amp;gt;getChild(&amp;quot;ConsoleRoot/ChatBox&amp;quot;));&lt;br /&gt;
	&lt;br /&gt;
	CEGUI::FormattedListboxTextItem *newItem=0; // This will hold the actual text and will be the listbox segment / item&lt;br /&gt;
&lt;br /&gt;
	newItem = new CEGUI::FormattedListboxTextItem(message,CEGUI::HTF_WORDWRAP_LEFT_ALIGNED); // Instance the Item with Left&lt;br /&gt;
                                                                                                   //   wordwrapped alignment&lt;br /&gt;
	newItem-&amp;gt;setTextColours(colour); // Set the text color&lt;br /&gt;
	outputWindow-&amp;gt;addItem(newItem); // Add the new ListBoxTextItem to the ListBox&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Conclusion ====&lt;br /&gt;
&lt;br /&gt;
And that ladies and gentleman, is our Console box. Not too terrible was it? Now of course, remember there are many ways to skin the proverbial cat. This is just an example of ways to do things. If you would like some homework, you could investigate why the SendButton does weird things when you drag and resize the window. I'll give you a hint, look at the way we're defining how big the ConsoleRoot is and where its child windows are placed... and what implications we might have by using relative scales for things.. Okay, i guess that was a big hint wasn't it! &lt;br /&gt;
&lt;br /&gt;
Till next time...&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Doubleyou</name></author>	</entry>

	<entry>
		<id>http://cegui.org/wiki/index.php?title=CEGUI_In_Practice_-_Introduction&amp;diff=4542</id>
		<title>CEGUI In Practice - Introduction</title>
		<link rel="alternate" type="text/html" href="http://cegui.org/wiki/index.php?title=CEGUI_In_Practice_-_Introduction&amp;diff=4542"/>
				<updated>2011-06-20T09:14:17Z</updated>
		
		<summary type="html">&lt;p&gt;Doubleyou: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{VersionBadge|0.7}}&lt;br /&gt;
{{Series|CEGUI In Practice|1}}&lt;br /&gt;
&lt;br /&gt;
== CEGUI In-Practice ==&lt;br /&gt;
&lt;br /&gt;
Welcome to the first in a series of tutorials based on how to use CEGUI.  The majority of the tutorials will be done in code.  I may attempt to sprinkle in uses of .layouts throughout the tutorial.  But once you understand how to use many of the Widgets in code it becomes easy to use them via script.&lt;br /&gt;
&lt;br /&gt;
[Please note, I am an Ogre3d user, so the initial setup will be how to bootstrap and start with ogre3d.]&lt;br /&gt;
&lt;br /&gt;
=== Introducing CEGUI ===&lt;br /&gt;
First notes, CEGUI uses a number of Singleton classes.  These, if not experienced with singletons, allow global access to a Class globally in the code, while ensuring only a 'single'ton instance is ever created.  The following are the Singletons we will be using&lt;br /&gt;
in this example.&lt;br /&gt;
&lt;br /&gt;
'''CEGUI::{{DoxygenClass|System|0.7}}''' - The big Kahuna.  This contains many of the functions for setting and getting defaults.  &amp;lt;br /&amp;gt;&lt;br /&gt;
'''CEGUI::{{DoxygenClass|WindowManager|0.7}}''' - Manages the windows of CEGUI.  If a new window is going to be created or Deleted WindowManager is gonna be your class.&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''CEGUI::{{DoxygenClass|SchemeManager|0.7}}''' - Manages Schemes. &amp;lt;br /&amp;gt;&lt;br /&gt;
'''CEGUI::{{DoxygenClass|FontManager|0.7}}''' - Manages the different fonts you will use in your application. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Getting Started ====&lt;br /&gt;
&lt;br /&gt;
Let's jump in and get some stuff setup.  The first thing we need to do is get the system up and running.  Since I am an Ogre user, I will show the code to get the system up and running with ogre. There are methods of getting it started for numerous other Rendering systems.  Shown here [[The Beginner Guide to Getting CEGUI Rendering]]. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Ogre3d Method is shown here:&lt;br /&gt;
&lt;br /&gt;
===== Including necessary headers =====&lt;br /&gt;
&amp;lt;tabs&amp;gt;&lt;br /&gt;
&amp;lt;tab title=&amp;quot;C++&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;CEGUI.h&amp;quot;&lt;br /&gt;
#include &amp;quot;RendererModules/Ogre/CEGUIOgreRenderer.h&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/tab&amp;gt;&lt;br /&gt;
&amp;lt;tab title=&amp;quot;Python&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
import PyCEGUI&lt;br /&gt;
import PyCEGUIOgreRenderer&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/tab&amp;gt;&lt;br /&gt;
&amp;lt;/tabs&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Bootstrapping CEGUI =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabs&amp;gt;&lt;br /&gt;
&amp;lt;tab title=&amp;quot;C++&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;CEGUI::OgreRenderer* renderer = &amp;amp;CEGUI::OgreRenderer::bootstrapSystem();&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/tab&amp;gt;&lt;br /&gt;
&amp;lt;tab title=&amp;quot;Python&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;renderer = PyCEGUIOgreRenderer.OgreRenderer.bootstrapSystem()&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/tab&amp;gt;&lt;br /&gt;
&amp;lt;/tabs&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[Note: This is a newer method using the bootstrapSystem, this was introduced in CEGUI 0.7.1.  There are examples on this wiki using older versions of CEGUI.  Please make note of which version you are using] &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above code creates an instance of the Ogre3d Render interface between Ogre3d and CEGUI.  You will not need to deal with this much after the above code has been run.  This creates the link which Ogre will use to render CEGUI.  Please note, you will want to call this if Ogre is auto-creating the render window ( pretty common ).  If you are manually creating the Ogre3d window, you will need to use the ''CEGUI::OgreRenderer::bootstrapSystem(Ogre::RenderWindow *)'' overload. &lt;br /&gt;
&lt;br /&gt;
An additional point to mention is that the bootstrapSystem() will create an instance of CEGUI::System.  This is important, as if you already have created CEGUI::System, an exception will be thrown.&lt;br /&gt;
&lt;br /&gt;
==== Oh there will be scripts ====&lt;br /&gt;
&lt;br /&gt;
Now that we've called the very meager function above.  We need to cover some very basic information about CEGUI before we proceed.&lt;br /&gt;
&lt;br /&gt;
CEGUI is a VERY heavily scripted library.  Much of what defines the artistic content of CEGUI is defined in various .xml files.  The beginning script we will mention is the '''Scheme''' (*.scheme).  Every widget you will use in your GUI will be defined in the .scheme file. It will also contain information for about subscripts which will be used, described below. Later tutorials will describe this file in greater detail. Below is an example if you run across one:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;GUIScheme Name=&amp;quot;TaharezLook&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;Imageset Filename=&amp;quot;TaharezLook.imageset&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Font Filename=&amp;quot;DejaVuSans-10.font&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;LookNFeel Filename=&amp;quot;TaharezLook.looknfeel&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;WindowRendererSet Filename=&amp;quot;CEGUIFalagardWRBase&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;FalagardMapping WindowType=&amp;quot;TaharezLook/Button&amp;quot;      TargetType=&amp;quot;CEGUI/PushButton&amp;quot;  Renderer=&amp;quot;Falagard/Button&amp;quot;       LookNFeel=&amp;quot;TaharezLook/Button&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;FalagardMapping WindowType=&amp;quot;TaharezLook/Checkbox&amp;quot;    TargetType=&amp;quot;CEGUI/Checkbox&amp;quot;    Renderer=&amp;quot;Falagard/ToggleButton&amp;quot; LookNFeel=&amp;quot;TaharezLook/Checkbox&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/GUIScheme&amp;gt;&amp;lt;/source&amp;gt; &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The next script we will mention is the '''Layouts''' (*.layout).  This is also an xml file, which defines the layout (obviously!) of the window we want to display on the screen.  For example, if we wanted a to create a Chat window, we would probably have a ChatWindow.layout file somewhere. This would describe how the window looks (How big, where on the screen its displayed, etc), where the typing box would be located within this window, and where the button to 'send' the chat message would be.  Below is a quick example of what a .layout file looks like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;GUILayout &amp;gt;&lt;br /&gt;
    &amp;lt;Window Type=&amp;quot;TaharezLook/FrameWindow&amp;quot; Name=&amp;quot;ConsoleRoot&amp;quot; &amp;gt;&lt;br /&gt;
        &amp;lt;Property Name=&amp;quot;Text&amp;quot; Value=&amp;quot;Chat Window&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;Property Name=&amp;quot;TitlebarFont&amp;quot; Value=&amp;quot;DejaVuSans-10&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;Property Name=&amp;quot;TitlebarEnabled&amp;quot; Value=&amp;quot;True&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;Property Name=&amp;quot;UnifiedAreaRect&amp;quot; Value=&amp;quot;{{0.114991,0},{0.358182,0},{0.519469,0},{0.775455,0}}&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;Window Type=&amp;quot;TaharezLook/Editbox&amp;quot; Name=&amp;quot;ConsoleRoot/EditBox&amp;quot; &amp;gt;&lt;br /&gt;
            &amp;lt;Property Name=&amp;quot;MaxTextLength&amp;quot; Value=&amp;quot;1073741823&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;Property Name=&amp;quot;UnifiedAreaRect&amp;quot; Value=&amp;quot;{{0.0201637,0},{0.787097,0},{0.694549,0},{0.957693,0}}&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;Property Name=&amp;quot;TextParsingEnabled&amp;quot; Value=&amp;quot;False&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;/Window&amp;gt;&lt;br /&gt;
&amp;lt;/GUILayout&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another script which is useful to mention is a '''Font''' (*.font). This describes fonts which will be used in cegui. Below is an example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;Font Name=&amp;quot;DejaVuSans-10&amp;quot; Filename=&amp;quot;DejaVuSans.ttf&amp;quot; Type=&amp;quot;FreeType&amp;quot; Size=&amp;quot;10&amp;quot; NativeHorzRes=&amp;quot;800&amp;quot; NativeVertRes=&amp;quot;600&amp;quot; AutoScaled=&amp;quot;true&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another important script is the '''Imageset''' (*.imageset). This is the file which determines the visuals of each widget. In CEGUI the visual part of a widget which the user see's is a small X/Y coordinate on a larger texture file. For example, a basic Button will have the graphics defined in a .imageset to be a certain position on a texture image (*.png, *.bmp, *.jpg, etc) with a certain height and width. It may be located at Pixel 100x320 and be 50x50 in size. This will be defined in the imageset. Below is an example.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;Imageset Name=&amp;quot;TaharezLook&amp;quot; Imagefile=&amp;quot;TaharezLook.tga&amp;quot; NativeHorzRes=&amp;quot;800&amp;quot; NativeVertRes=&amp;quot;600&amp;quot; AutoScaled=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;Image Name=&amp;quot;MouseArrow&amp;quot; XPos=&amp;quot;138&amp;quot; YPos=&amp;quot;127&amp;quot; Width=&amp;quot;31&amp;quot; Height=&amp;quot;25&amp;quot; XOffset=&amp;quot;0&amp;quot; YOffset=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/Imageset&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lastly, '''LookNFeel''' (*.looknfeel). This is a fairly evil looking file, and to save everyone from nightmarish horrors, I will not post an example (and to save space). This is the file which determines how every widget (CEGUI speak for window/object/item) looks and acts. For example, what it looks like when you mouse over a button, or how to build the border and background of a Window. Each scheme will generally have its own LookNFeel to allow more customization of the basic construction of CEGUI Widgets.&lt;br /&gt;
&lt;br /&gt;
==== Back to Getting Started ====&lt;br /&gt;
&lt;br /&gt;
Now that we have a minimal idea about what scripts CEGUI uses (and don't worry, they make more sense and are less intimidating as you proceede. You will likely use .layout the most in the beginning) lets start doing something useful!&lt;br /&gt;
&lt;br /&gt;
Where we left off, CEGUI was just started. But in and of itself, it doesn't know what you want to do. First thing we should do is tell it what Scheme we want to use. As mentioned above, a .Scheme contains a listing of Widget and Other scripts to include, a Scheme can include an Imageset, lookNFeel, and font to use. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabs&amp;gt;&lt;br /&gt;
&amp;lt;tab title=&amp;quot;C++&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Load the scheme&lt;br /&gt;
CEGUI::SchemeManager::getSingleton().create( &amp;quot;TaharezLook.scheme&amp;quot; );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/tab&amp;gt;&lt;br /&gt;
&amp;lt;tab title=&amp;quot;Python&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# Load the scheme&lt;br /&gt;
PyCEGUI.SchemeManager.getSingleton().create( &amp;quot;TaharezLook.scheme&amp;quot; )&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/tab&amp;gt;&lt;br /&gt;
&amp;lt;/tabs&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you wanted to use an imageset or Font which is not designated in the .Scheme file its easy to do. Simply use the associated manager to load them. Since i'm trying my best to keep this as an introductory tutorial, I'll keep to the mission and explain these managers in a later tutorial.&lt;br /&gt;
&lt;br /&gt;
Next up, lets define a few defaults:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabs&amp;gt;&lt;br /&gt;
&amp;lt;tab title=&amp;quot;C++&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Set the defaults&lt;br /&gt;
CEGUI::System::getSingleton().setDefaultFont( &amp;quot;DejaVuSans-10&amp;quot; );&lt;br /&gt;
CEGUI::System::getSingleton().setDefaultMouseCursor( &amp;quot;TaharezLook&amp;quot;, &amp;quot;MouseArrow&amp;quot; );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/tab&amp;gt;&lt;br /&gt;
&amp;lt;tab title=&amp;quot;Python&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# Set the defaults&lt;br /&gt;
PyCEGUI.System.getSingleton().setDefaultFont( &amp;quot;DejaVuSans-10&amp;quot; )&lt;br /&gt;
PyCEGUI.System.getSingleton().setDefaultMouseCursor( &amp;quot;TaharezLook&amp;quot;, &amp;quot;MouseArrow&amp;quot; )&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/tab&amp;gt;&lt;br /&gt;
&amp;lt;/tabs&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These calls will summon the CEGUI::System from global scope and set the DefaultFont, and the default Mouse Cursor. If you reference TaharezLook.scheme (located in the cegui/datafiles/schemes folder). You will see that it loaded a font named DejaVuSans-10.font with the &amp;lt;font&amp;gt; tag in the .scheme. The MouseArrow is found inside the imageset called &amp;quot;TharezLook&amp;quot; under the tag of &amp;quot;MouseArrow&amp;quot;. Pretty self explanetory I'd hope.&lt;br /&gt;
&lt;br /&gt;
Alright, now CEGUI knows about some basic defaults we want to use. Lets create a window which will be the Root window we will put everything on from here on out.&lt;br /&gt;
&lt;br /&gt;
CEGUI uses a Parent/Child system for organizing the windows. So the first useful thing to do is create a parent which all other windows will be the child&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabs&amp;gt;&lt;br /&gt;
&amp;lt;tab title=&amp;quot;C++&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
CEGUI::Window* myRoot = CEGUI::WindowManager::getSingleton().createWindow( &amp;quot;DefaultWindow&amp;quot;, &amp;quot;_MasterRoot&amp;quot; );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/tab&amp;gt;&lt;br /&gt;
&amp;lt;tab title=&amp;quot;Python&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
myRoot = PyCEGUI.WindowManager.getSingleton().createWindow( &amp;quot;DefaultWindow&amp;quot;, &amp;quot;_MasterRoot&amp;quot; )&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/tab&amp;gt;&lt;br /&gt;
&amp;lt;/tabs&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The above function calls upon the WindowManager singleton, and creates a window of type &amp;quot;DefaultWindow&amp;quot; named &amp;quot;_MasterRoot&amp;quot;. The default window is just that. a default window, which is blank (or transparent). You can give the root window any name you like, however, i like using _MasterRoot as its unlikely any other window I ever use will have the name. &lt;br /&gt;
&lt;br /&gt;
Now that we have created the window, we need to set it as the root window.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabs&amp;gt;&lt;br /&gt;
&amp;lt;tab title=&amp;quot;C++&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
CEGUI::System::getSingleton().setGUISheet( myRoot );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/tab&amp;gt;&lt;br /&gt;
&amp;lt;tab title=&amp;quot;Python&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
PyCEGUI.System.getSingleton().setGUISheet( myRoot )&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/tab&amp;gt;&lt;br /&gt;
&amp;lt;/tabs&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This calls upon the system, and assigns myRoot as the default window. Recall myRoot was created above with the name &amp;quot;_MasterRoot&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Conclusion ====&lt;br /&gt;
&lt;br /&gt;
While not a super exciting tutorial. At this point CEGUI is now setup, and we could begin adding windows and doing such GUI shenanigans as making windows, buttons, clicking, and fun. Later tutorials will demonstrate how to have CEGUI Recognize clicking, dragging of windows, typing, and more! Thanks for reading!&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Doubleyou</name></author>	</entry>

	<entry>
		<id>http://cegui.org/wiki/index.php?title=CEGUI_In_Practice_-_Introduction&amp;diff=4541</id>
		<title>CEGUI In Practice - Introduction</title>
		<link rel="alternate" type="text/html" href="http://cegui.org/wiki/index.php?title=CEGUI_In_Practice_-_Introduction&amp;diff=4541"/>
				<updated>2011-06-20T08:55:44Z</updated>
		
		<summary type="html">&lt;p&gt;Doubleyou: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{VersionBadge|0.7}}&lt;br /&gt;
{{Series|CEGUI In Practice|1}}&lt;br /&gt;
&lt;br /&gt;
== CEGUI In-Practice ==&lt;br /&gt;
&lt;br /&gt;
Welcome to the first in a series of tutorials based on how to use CEGUI.  The majority of the tutorials will be done in code.  I may attempt to sprinkle in uses of .layouts throughout the tutorial.  But once you understand how to use many of the Widgets in code it becomes easy to use them via script.&lt;br /&gt;
&lt;br /&gt;
[Please note, I am an Ogre3d user, so the initial setup will be how to bootstrap and start with ogre3d.]&lt;br /&gt;
&lt;br /&gt;
=== Introducing CEGUI ===&lt;br /&gt;
First notes, CEGUI uses a number of Singleton classes.  These, if not experienced with singletons, allow global access to a Class globally in the code, while ensuring only a 'single'ton instance is ever created.  The following are the Singletons we will be using&lt;br /&gt;
in this example.&lt;br /&gt;
&lt;br /&gt;
'''CEGUI::{{DoxygenClass|System|0.7}}''' - The big Kahuna.  This contains many of the functions for setting and getting defaults.  &amp;lt;br /&amp;gt;&lt;br /&gt;
'''CEGUI::{{DoxygenClass|WindowManager|0.7}}''' - Manages the windows of CEGUI.  If a new window is going to be created or Deleted WindowManager is gonna be your class.&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''CEGUI::{{DoxygenClass|SchemeManager|0.7}}''' - Manages Schemes. &amp;lt;br /&amp;gt;&lt;br /&gt;
'''CEGUI::{{DoxygenClass|FontManager|0.7}}''' - Manages the different fonts you will use in your application. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Getting Started ====&lt;br /&gt;
&lt;br /&gt;
Let's jump in and get some stuff setup.  The first thing we need to do is get the system up and running.  Since I am an Ogre user, I will show the code to get the system up and running with ogre. There are methods of getting it started for numerous other Rendering systems.  Shown here [[The Beginner Guide to Getting CEGUI Rendering]]. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Ogre3d Method is shown here:&lt;br /&gt;
&lt;br /&gt;
===== Including necessary headers =====&lt;br /&gt;
&amp;lt;tabs&amp;gt;&lt;br /&gt;
&amp;lt;tab title=&amp;quot;C++&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;CEGUI.h&amp;quot;&lt;br /&gt;
#include &amp;quot;RendererModules/Ogre/CEGUIOgreRenderer.h&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/tab&amp;gt;&lt;br /&gt;
&amp;lt;tab title=&amp;quot;Python&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
import PyCEGUI&lt;br /&gt;
import PyCEGUIOgreRenderer&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/tab&amp;gt;&lt;br /&gt;
&amp;lt;/tabs&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Bootstrapping CEGUI =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabs&amp;gt;&lt;br /&gt;
&amp;lt;tab title=&amp;quot;C++&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;CEGUI::OgreRenderer* renderer = &amp;amp;CEGUI::OgreRenderer::bootstrapSystem();&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/tab&amp;gt;&lt;br /&gt;
&amp;lt;tab title=&amp;quot;Python&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;renderer = PyCEGUIOgreRenderer.OgreRenderer.bootstrapSystem()&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/tab&amp;gt;&lt;br /&gt;
&amp;lt;/tabs&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[Note: This is a newer method using the bootstrapSystem, this was introduced in CEGUI 0.7.1.  There are examples on this wiki using older versions of CEGUI.  Please make note of which version you are using] &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above code creates an instance of the Ogre3d Render interface between Ogre3d and CEGUI.  You will not need to deal with this much after the above code has been run.  This creates the link which Ogre will use to render CEGUI.  Please note, you will want to call this if Ogre is auto-creating the render window ( pretty common ).  If you are manually creating the Ogre3d window, you will need to use the ''CEGUI::OgreRenderer::bootstrapSystem(Ogre::RenderWindow *)'' overload. &lt;br /&gt;
&lt;br /&gt;
An additional point to mention is that the bootstrapSystem() will create an instance of CEGUI::System.  This is important, as if you already have created CEGUI::System, an exception will be thrown.&lt;br /&gt;
&lt;br /&gt;
==== Oh there will be scripts ====&lt;br /&gt;
&lt;br /&gt;
Now that we've called the very meager function above.  We need to cover some very basic information about CEGUI before we proceed.&lt;br /&gt;
&lt;br /&gt;
CEGUI is a VERY heavily scripted library.  Much of what defines the artistic content of CEGUI is defined in various .xml files.  The beginning script we will mention is the '''Scheme''' (*.scheme).  Every widget you will use in your GUI will be defined in the .scheme file. It will also contain information for about subscripts which will be used, described below. Later tutorials will describe this file in greater detail. Below is an example if you run across one:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;GUIScheme Name=&amp;quot;TaharezLook&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;Imageset Filename=&amp;quot;TaharezLook.imageset&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Font Filename=&amp;quot;DejaVuSans-10.font&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;LookNFeel Filename=&amp;quot;TaharezLook.looknfeel&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;WindowRendererSet Filename=&amp;quot;CEGUIFalagardWRBase&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;FalagardMapping WindowType=&amp;quot;TaharezLook/Button&amp;quot;      TargetType=&amp;quot;CEGUI/PushButton&amp;quot;  Renderer=&amp;quot;Falagard/Button&amp;quot;       LookNFeel=&amp;quot;TaharezLook/Button&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;FalagardMapping WindowType=&amp;quot;TaharezLook/Checkbox&amp;quot;    TargetType=&amp;quot;CEGUI/Checkbox&amp;quot;    Renderer=&amp;quot;Falagard/ToggleButton&amp;quot; LookNFeel=&amp;quot;TaharezLook/Checkbox&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/GUIScheme&amp;gt;&amp;lt;/source&amp;gt; &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The next script we will mention is the '''Layouts''' (*.layout).  This is also an xml file, which defines the layout (obviously!) of the window we want to display on the screen.  For example, if we wanted a to create a Chat window, we would probably have a ChatWindow.layout file somewhere. This would describe how the window looks (How big, where on the screen its displayed, etc), where the typing box would be located within this window, and where the button to 'send' the chat message would be.  Below is a quick example of what a .layout file looks like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;GUILayout &amp;gt;&lt;br /&gt;
    &amp;lt;Window Type=&amp;quot;TaharezLook/FrameWindow&amp;quot; Name=&amp;quot;ConsoleRoot&amp;quot; &amp;gt;&lt;br /&gt;
        &amp;lt;Property Name=&amp;quot;Text&amp;quot; Value=&amp;quot;Chat Window&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;Property Name=&amp;quot;TitlebarFont&amp;quot; Value=&amp;quot;DejaVuSans-10&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;Property Name=&amp;quot;TitlebarEnabled&amp;quot; Value=&amp;quot;True&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;Property Name=&amp;quot;UnifiedAreaRect&amp;quot; Value=&amp;quot;{{0.114991,0},{0.358182,0},{0.519469,0},{0.775455,0}}&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;Window Type=&amp;quot;TaharezLook/Editbox&amp;quot; Name=&amp;quot;ConsoleRoot/EditBox&amp;quot; &amp;gt;&lt;br /&gt;
            &amp;lt;Property Name=&amp;quot;MaxTextLength&amp;quot; Value=&amp;quot;1073741823&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;Property Name=&amp;quot;UnifiedAreaRect&amp;quot; Value=&amp;quot;{{0.0201637,0},{0.787097,0},{0.694549,0},{0.957693,0}}&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;Property Name=&amp;quot;TextParsingEnabled&amp;quot; Value=&amp;quot;False&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;/Window&amp;gt;&lt;br /&gt;
&amp;lt;/GUILayout&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another script which is useful to mention is a '''Font''' (*.font). This describes fonts which will be used in cegui. Below is an example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;Font Name=&amp;quot;DejaVuSans-10&amp;quot; Filename=&amp;quot;DejaVuSans.ttf&amp;quot; Type=&amp;quot;FreeType&amp;quot; Size=&amp;quot;10&amp;quot; NativeHorzRes=&amp;quot;800&amp;quot; NativeVertRes=&amp;quot;600&amp;quot; AutoScaled=&amp;quot;true&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another important script is the '''Imageset''' (*.imageset). This is the file which determines the visuals of each widget. In CEGUI the visual part of a widget which the user see's is a small X/Y coordinate on a larger texture file. For example, a basic Button will have the graphics defined in a .imageset to be a certain position on a texture image (*.png, *.bmp, *.jpg, etc) with a certain height and width. It may be located at Pixel 100x320 and be 50x50 in size. This will be defined in the imageset. Below is an example.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;Imageset Name=&amp;quot;TaharezLook&amp;quot; Imagefile=&amp;quot;TaharezLook.tga&amp;quot; NativeHorzRes=&amp;quot;800&amp;quot; NativeVertRes=&amp;quot;600&amp;quot; AutoScaled=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;Image Name=&amp;quot;MouseArrow&amp;quot; XPos=&amp;quot;138&amp;quot; YPos=&amp;quot;127&amp;quot; Width=&amp;quot;31&amp;quot; Height=&amp;quot;25&amp;quot; XOffset=&amp;quot;0&amp;quot; YOffset=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/Imageset&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lastly, '''LookNFeel''' (*.looknfeel). This is a fairly evil looking file, and to save everyone from nightmarish horrors, I will not post an example (and to save space). This is the file which determines how every widget (CEGUI speak for window/object/item) looks and acts. For example, what it looks like when you mouse over a button, or how to build the border and background of a Window. Each scheme will generally have its own LookNFeel to allow more customization of the basic construction of CEGUI Widgets.&lt;br /&gt;
&lt;br /&gt;
==== Back to Getting Started ====&lt;br /&gt;
&lt;br /&gt;
Now that we have a minimal idea about what scripts CEGUI uses (and don't worry, they make more sense and are less intimidating as you proceede. You will likely use .layout the most in the beginning) lets start doing something useful!&lt;br /&gt;
&lt;br /&gt;
Where we left off, CEGUI was just started. But in and of itself, it doesn't know what you want to do. First thing we should do is tell it what Scheme we want to use. As mentioned above, a .Scheme contains a listing of Widget and Other scripts to include. a Scheem can include an Imageset, looknFeel, and font to use. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabs&amp;gt;&lt;br /&gt;
&amp;lt;tab title=&amp;quot;C++&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Load the scheme&lt;br /&gt;
CEGUI::SchemeManager::getSingleton().create( &amp;quot;TaharezLook.scheme&amp;quot; );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/tab&amp;gt;&lt;br /&gt;
&amp;lt;tab title=&amp;quot;Python&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# Load the scheme&lt;br /&gt;
PyCEGUI.SchemeManager.getSingleton().create( &amp;quot;TaharezLook.scheme&amp;quot; )&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/tab&amp;gt;&lt;br /&gt;
&amp;lt;/tabs&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you wanted to use an imageset or Font which is not designated in the .Scheme file its easy to do. Simply use the associated manager to load them. Since i'm trying my best to keep this as an introductory tutorial, I'll keep to the mission and explain these managers in a later tutorial.&lt;br /&gt;
&lt;br /&gt;
Next up, lets define a few defaults:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabs&amp;gt;&lt;br /&gt;
&amp;lt;tab title=&amp;quot;C++&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Set the defaults&lt;br /&gt;
CEGUI::System::getSingleton().setDefaultFont( &amp;quot;DejaVuSans-10&amp;quot; );&lt;br /&gt;
CEGUI::System::getSingleton().setDefaultMouseCursor( &amp;quot;TaharezLook&amp;quot;, &amp;quot;MouseArrow&amp;quot; );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/tab&amp;gt;&lt;br /&gt;
&amp;lt;tab title=&amp;quot;Python&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# Set the defaults&lt;br /&gt;
PyCEGUI.System.getSingleton().setDefaultFont( &amp;quot;DejaVuSans-10&amp;quot; )&lt;br /&gt;
PyCEGUI.System.getSingleton().setDefaultMouseCursor( &amp;quot;TaharezLook&amp;quot;, &amp;quot;MouseArrow&amp;quot; )&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/tab&amp;gt;&lt;br /&gt;
&amp;lt;/tabs&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These calls will summon the CEGUI::System from global scope and set the DefaultFont, and the default Mouse Cursor. If you reference TaharezLook.scheme (located in the cegui/datafiles/schemes folder). You will see that it loaded a font named DejaVuSans-10.font with the &amp;lt;font&amp;gt; tag in the .scheme. The MouseArrow is found inside the imageset called &amp;quot;TharezLook&amp;quot; under the tag of &amp;quot;MouseArrow&amp;quot;. Pretty self explanetory I'd hope.&lt;br /&gt;
&lt;br /&gt;
Alright, now CEGUI knows about some basic defaults we want to use. Lets create a window which will be the Root window we will put everything on from here on out.&lt;br /&gt;
&lt;br /&gt;
CEGUI uses a Parent/Child system for organizing the windows. So the first useful thing to do is create a parent which all other windows will be the child&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabs&amp;gt;&lt;br /&gt;
&amp;lt;tab title=&amp;quot;C++&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
CEGUI::Window* myRoot = CEGUI::WindowManager::getSingleton().createWindow( &amp;quot;DefaultWindow&amp;quot;, &amp;quot;_MasterRoot&amp;quot; );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/tab&amp;gt;&lt;br /&gt;
&amp;lt;tab title=&amp;quot;Python&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
myRoot = PyCEGUI.WindowManager.getSingleton().createWindow( &amp;quot;DefaultWindow&amp;quot;, &amp;quot;_MasterRoot&amp;quot; )&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/tab&amp;gt;&lt;br /&gt;
&amp;lt;/tabs&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The above function calls upon the WindowManager singleton, and creates a window of type &amp;quot;DefaultWindow&amp;quot; named &amp;quot;_MasterRoot&amp;quot;. The default window is just that. a default window, which is blank (or transparent). You can give the root window any name you like, however, i like using _MasterRoot as its unlikely any other window I ever use will have the name. &lt;br /&gt;
&lt;br /&gt;
Now that we have created the window, we need to set it as the root window.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabs&amp;gt;&lt;br /&gt;
&amp;lt;tab title=&amp;quot;C++&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
CEGUI::System::getSingleton().setGUISheet( myRoot );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/tab&amp;gt;&lt;br /&gt;
&amp;lt;tab title=&amp;quot;Python&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
PyCEGUI.System.getSingleton().setGUISheet( myRoot )&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/tab&amp;gt;&lt;br /&gt;
&amp;lt;/tabs&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This calls upon the system, and assigns myRoot as the default window. Recall myRoot was created above with the name &amp;quot;_MasterRoot&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Conclusion ====&lt;br /&gt;
&lt;br /&gt;
While not a super exciting tutorial. At this point CEGUI is now setup, and we could begin adding windows and doing such GUI shenanigans as making windows, buttons, clicking, and fun. Later tutorials will demonstrate how to have CEGUI Recognize clicking, dragging of windows, typing, and more! Thanks for reading!&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Doubleyou</name></author>	</entry>

	</feed>