I need help to implement crazy eddies gui

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

User avatar
SAMDestroy
Just popping in
Just popping in
Posts: 2
Joined: Wed Jan 12, 2005 12:06

I need help to implement crazy eddies gui

Postby SAMDestroy » Tue Jun 08, 2004 12:13

Hello there,

first i must say: this gui is amzing... its look so great thats im only want to use THIS gui... there are no other option for me ;-)
i want to use "TaharezLook" Window2 and i want it as ingame menue for my project.
my problem is: i dont have any clue how to implement this to my project... it would be really nice if someone can help me with this.
maybe anyone can catch me over msn? octalus_c@hotmail.com

cya
SAMDestroy

ps: sorry for my bad english... im from germany

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

I need help to implement crazy eddies gui

Postby CrazyEddie » Tue Jun 08, 2004 12:54

Hi,

Glad you like the look of the system :)

Firstly you need to consider the fact that there are now essentially two versions on the system; the mk-1 version which has seen three alpha releases, or the mk-2 version that is now in development. The mk-1 system is certainly usable, it's easy(er) to compile and get into using, though you may hit problems when it comes to window management and event messaging, plus there's no documentation for it! The mk-2 system is still in development, so some parts are missing and depending upon your experience, the mk-2 library may a bit more difficult to compile straight off (especially due to the fact you have to get the source out of CVS and it also has some dependency on external libraries), though once it's compiling you'll find the mk-2 system much easier to use and manage - plus most of the classes are documented :) Obviously, I am now pushing the merits of the Mk-2 system, though mk-1 is still a viable option, especially if you're targetting DirectX on Win32 and want a more minimalistic base system.

Which compiler are you using? and which rendering API and OS are you looking to target?


Whichever version of the system you go for, the first job is to get the source code and compile the CEGUI library project (so either get the latest Mk-1 source download: http://crazy-eddie.myby.co.uk/files/crayzedsgui-source.zip, or get the cegui_mk2 module from the CVS server (info here: http://sourceforge.net/cvs/?group_id=93749). Once one of these projects are compiled okay, you need to set up your own project to use the GUI system. As with any other library, this typically involves including the appropriate header files and linking with the .lib file for the GUI system. Once you get to this stage, the first job is to create a Renderer object and setup the system, for mk 1 you pass the renderer object to the Utils::setRenderer static method, for mk-2 you pass the Renderer object as a parameter when you create the initial System object, after this it's really just a matter of creating the required windows and widgets, and setting up the actions you want them to perform.

For the Mk-1 system, the best way to learn is to look at the source code for the example applications. For mk-2 the only examples (so far) are the ones I've been posting to the Ogre site (see the forum thread here: http://www.ogre3d.org/phpBB2/viewtopic.php?t=4522), but again, looking through the example code is the best way to see how the system operates.

I hope this gives a few ideas about what you need to do to integrate the system into your project :)

User avatar
SAMDestroy
Just popping in
Just popping in
Posts: 2
Joined: Wed Jan 12, 2005 12:06

I need help to implement crazy eddies gui

Postby SAMDestroy » Tue Jun 08, 2004 13:11

ok, i forgot to say thats im too noobish for thats... i got the "crayzedsgui-0.300.000-source.zip" source from your site and i got a look on the demos.
im really not able to integrate this to my project... but i think im able to tweak an integegrated gui.
my project is an d3d8 project, im using visual studio 2003 and my source is about 350kb.
can you please catch me over icq? maybe you can take a look at my source?

cya
SAMDestroy

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

I need help to implement crazy eddies gui

Postby CrazyEddie » Tue Jun 08, 2004 18:33

Firstly, I don't usually take requests to ICQ people - and in your case, I'm not going to make an exception :D (Just a little joke - don't take it personaly or seriously, I used to be on ICQ a lot more, but got bogged down by everyone who thought I was their own personal code monkey :roll: As such, I'm generally not on ICQ that much any more :().

I can't personally integrate the system with your project (see above), since if I started doing this, I'd spend most of my limited free time working on other peoples projects instead of my own :o

As far as getting the system working with your project... Okay, you have the 0.300 version, so you don't have to deal with the Renderer object (and you don't get alpha blending with this version because of it). Anyway...

Job number one is to compile the system. Add the gui system include folder to your VC++ includes directories list in the main VC++ options dialog (Menu: Tools>Options... Then select: Projects>VC++ Directories).

Since you have one of the supported compilers, all you have to do now is load the solution and hit the build button.

Once that's done, in your own project you'll need add the base system libs directory either to your project (via the project properties) or add them to the library directories lists as you did for the includes above. You'll also need to add the crayzedguibase_d.lib (for debug build) & crayzedguibase.lib (for release build) files to your project via the linker options.

Now you need to add all the Taharez widget files to your project. Just right-click on the project in solution explorer and select add->existing item, select all the .cpp and .h files in Source/TaharezLookDemo/Widgets

I assume that you already have your project running with Direct3D. So now you're ready to roll.

The main include you'll need is the Utils one (at least until you stat adding windows).

Code: Select all

#include "CrayZEdGUIBase/GUILib/Utils.h"


At some stage after you have initialised Direct3D, you need to tell the GUI system which D3DDevice it's supposed to be using, so...

Code: Select all

CEGUI::Utils::setD3DDevice(your3DDevice);


you'll also need to set some render states that the GUI relies on, like this:

Code: Select all

   your3DDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
   your3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, true);
   your3DDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATER);
   your3DDevice->SetRenderState(D3DRS_ALPHAREF, 0x7F);


Now the rendering side of the system is ready to roll. In order to actually get the syetm to render, you need to add the following between your BeginScene and EndScene calls, typically the GUI is the last thing on screen, so make the call just before EndScene:

Code: Select all

CEGUI::Utils::instance()->renderFullGUI();



Now, since you're using Taharez images, these are loaded as the default by the system. Though you will need to set-up a default font:

Code: Select all

CEGUI::Utils::instance()->getDefaultFont()->createFromOSFont("Arial", 8, 0);


You also need a function to change the cursor for you, the one out of the demos is jus what you need, which is this:

Code: Select all

bool cursorChanger(CEGUI::Utils::Cursor cursor)
{
   switch(cursor) {
      case Utils::Cursor::SIZING_LEFTRIGHT:
         SetCursor(LoadCursor(NULL, IDC_SIZEWE));   
         break;

      case Utils::Cursor::SIZING_UPDOWN:
         SetCursor(LoadCursor(NULL, IDC_SIZENS));   
         break;

      case Utils::Cursor::SIZING_NESW:
         SetCursor(LoadCursor(NULL, IDC_SIZENESW));   
         break;

      case Utils::Cursor::SIZING_NWSE:
         SetCursor(LoadCursor(NULL, IDC_SIZENWSE));   
         break;

      case Utils::Cursor::NORMAL:
         SetCursor(LoadCursor(NULL, IDC_ARROW));   
         break;

      case Utils::Cursor::MOVING:
         SetCursor(LoadCursor(NULL, IDC_SIZEALL));   
         break;

      case Utils::Cursor::TEXT_BEAM:
         SetCursor(LoadCursor(NULL, IDC_IBEAM));
         break;

   default:
      return false;
   }

   return true;
}


Then you need to tell the GUI system to use this function for changing cursors:

Code: Select all

CEGUI::Utils::instance()->setCursorChangeHandler(cursorChanger);


Now you have to get the root window and 'show' it so that the GUI becomes visible:

Code: Select all

CEGUI::Window* rootWnd = CEGUI::Utils::instance()->getRootWindow();
rootWnd->show();


Then you just add the widgets you need, position them, set their size and what have you.
So, to add a button (for that menu of yours), you'd do this...

add the include:

Code: Select all

#include "MyButton.h"


Code: Select all

CEGUI::MyButton* button = new CEGUI::MyButton;
button->initialise();
CEGUI::Utils::instance()->getRootWindow()->addChildWindow(*button);
button->setPosition(250,100);
button->setSize(300, 24);
button->setText("Start New Game");
button->show();


This adds a new push button, with size 300 x 24 at position 250,100 - with the label 'Start New Game'.

The system also needs to know about inputs. If you're using Win32 messages, the best bet is to use the code out of the demo application as an example. If you're using DirectInput, then the approach is similar, all you're doing is taking the inputs and pumping them into the GUI via the 'CEGUI::Utils:: on<whatever>' methods. So for mouse movements:

Code: Select all

CEGUI::Utils::instance()->onMouseMove(xDelta, yDelta, sysKeys);


'sysKeys' is a flags value that tells the system which of the system keys (like control and shift) were pressed.

This should get you started, by being able to add some widgets to the display. Getting events back out of the system is even more fun :D You have to create a command object class derived from CEGUI::Command. This class has a virtual function 'execute' which should be overridden to perform whatever action you want. Then you have to attach this command object to the widget, so for our button example, if you had a command object called 'StartGameHandler' you could do this:

Code: Select all

StartGameHandler* sgh = new StartGameHandler;
button->setClickedCommand(sgh);


This will invoke sgh->execute() whenever the button is clicked.

I have intentionally skipped over some required management you must do - that is, keeping track of all the windows you create, and the command objects. Since when your application shuts down, or whenever you need to clean-up the GUI, you'll need to delete these objects to prevent resource leakage.

This is a big overview of what you need to integrate the system. It seems a lot of stuff you have to do, and some areas are fairly complex. But with this article, the example applications, and some time & patience, you should have all the information needed to get you started.

Hope this helps.

CE.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

I need help to implement crazy eddies gui

Postby CrazyEddie » Wed Jun 09, 2004 17:22

Hi ed.

I replied to you on the Ogre forums as you probably saw, but I'll reply here too so it doesn't look like I've missed or ignored your post :)

The demo you downloaded from the link on Ogre forums requires the cegui Mk-2 code from CVS to compile, this is why you can't find the cegui.h file. However, at the moment there are some known issues when compiling the Mk-2 base system using the VC++ 6 compiler. Fixes for these issues will be made, though at present I can't give an estimate as to when this work will be complete - though I would say it is likely to be a couple of weeks or so, rather than months - so fairly soon :)

Hope this helps.


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 17 guests