creating a debug window

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

jchmack
Just popping in
Just popping in
Posts: 12
Joined: Tue Mar 27, 2007 15:13

creating a debug window

Postby jchmack » Mon Jun 25, 2007 08:43

Hi im really new to CEGUI so please forgive my inexperience.

Im trying to create a debug window that will contain alot of my Debug
information. FPS, IP adress, number of poly's ETC.

Im using the ogre3d graphics engine btw.

I can initialize CEGUI fine:

Code: Select all

void game4::InitializeCEGUI()
{
   //create CEGUI
   mGUIRenderer = new CEGUI::OgreCEGUIRenderer(mWindow, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, mSceneMgr);
   mGUISystem = new CEGUI::System(mGUIRenderer);

   //Set Logging
   CEGUI::Logger::getSingleton().setLoggingLevel(CEGUI::Informative);

   //CEGUI settings
   CEGUI::SchemeManager::getSingleton().loadScheme((CEGUI::utf8*)"TaharezLookSkin.scheme");
   mGUISystem->setDefaultFont((CEGUI::utf8*)"BlueHighway-12");
   mEditorGuiSheet= CEGUI::WindowManager::getSingleton().createWindow((CEGUI::utf8*)"DefaultWindow", (CEGUI::utf8*)"Sheet"); 
   mGUISystem->setGUISheet(mEditorGuiSheet);

   //Setup mouse
   mGUISystem->setDefaultMouseCursor((CEGUI::utf8*)"TaharezLook", (CEGUI::utf8*)"MouseArrow");
   CEGUI::MouseCursor::getSingleton().setImage("TaharezLook", "MouseMoveCursor");
   
   unsigned int WindowWidth   = Ogre::StringConverter::parseUnsignedInt(settings["width"].data());
   unsigned int WindowHeight   = Ogre::StringConverter::parseUnsignedInt(settings["height"].data());

   CEGUI::MouseCursor::getSingleton().setPosition(CEGUI::Point(
      (mWindow->getWidth() / 2) - 16,
      (mWindow->getHeight() / 2) - 16)
      );

   //Create button
   quitButton = (CEGUI::PushButton*)CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/Button", (CEGUI::utf8*)"HP");
   mEditorGuiSheet->addChildWindow(quitButton);
   quitButton->setPosition( CEGUI::UVector2(cegui_reldim(0.1f), cegui_reldim( 0.1f)));
    quitButton->setSize( CEGUI::UVector2(cegui_reldim(0.1f), cegui_reldim( 0.1f)));
   quitButton->setText("Click Here To See Your HP");

   //Register for events
   CEGUI::WindowManager& wmgr = CEGUI::WindowManager::getSingleton();
   wmgr.getWindow((CEGUI::utf8*)"HP")->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&game4::GUIButtonPressed, this));
   
}


and i can create my debug window fine:

Code: Select all

void game4::UseDebugWindow()
{
   DebugWindow = (CEGUI::Window*) CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/FrameWindow", (CEGUI::utf8*)"Debug");
   mEditorGuiSheet->addChildWindow(DebugWindow);
   DebugWindow->setPosition( CEGUI::UVector2(cegui_reldim(0.25f), cegui_reldim( 0.25f)));
   DebugWindow->setSize( CEGUI::UVector2(cegui_reldim(0.5f), cegui_reldim( 0.5f)));
   DebugWindow->setText("Debug Window");
   
   DebugListBox = (CEGUI::Listbox*) CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/Listbox", (CEGUI::utf8*)"Listbox");
   DebugListBox->setPosition(CEGUI::UVector2(cegui_reldim(0.1f), cegui_reldim( 0.1f)));
   DebugListBox->setSize( CEGUI::UVector2(cegui_reldim(0.8f), cegui_reldim( 0.8f)));
   DebugListBox->setText("DebugListBox setText");
   DebugListBox->setShowVertScrollbar(true);

   DebugTime = new CEGUI::ListboxTextItem("TEST TEXT");
   DebugListBox->addItem(DebugTime);

   DebugFPS = new CEGUI::ListboxTextItem("TEST TEXT2");
   DebugListBox->addItem(DebugFPS);

   DebugWindow->addChildWindow(DebugListBox);
}


the problem comes when i try to update my elements in my debug window:

Code: Select all

void game4::UpdateDebugWindow(float _time)
{
   cout << "UpdateDebugWindow is being called" << endl;

   static float time = 0;
   time+=_time;
   DebugTime->setText("Time: " + Ogre::StringConverter::toString(time));

   DebugFPS->setText("FPS: " + Ogre::StringConverter::toString( mWindow->getLastFPS() ));

   DebugWindow->update(_time);
   DebugListBox->update(_time);
}


The information only updates when i click each item individually. I believe i am injecting inputs properly.

And i have been putting these lines everywhere to try to fix my problem:

DebugWindow->update(_time);
DebugListBox->update(_time);

Why isnt my info updating? Im pretty sure that the update function is being called every frame.

I apologize for the long post. Thx to all who help in advance =)

jchmack
Just popping in
Just popping in
Posts: 12
Joined: Tue Mar 27, 2007 15:13

Postby jchmack » Tue Jun 26, 2007 14:04

what exactly causes CEGUI to update an element... Ive been working on and off for about 2 days on this and it still doesn't make sense. Im calling the setText every frame... So im pretty sure that CEGUI is either not updating the information or just not rendering it. Sigh...

User avatar
scriptkid
Home away from home
Home away from home
Posts: 1178
Joined: Wed Jan 12, 2005 12:06
Location: The Hague, The Netherlands
Contact:

Postby scriptkid » Tue Jun 26, 2007 15:15

I was typing something else when i noticed the problem in your code :)

Listboxes require you to tell them when you change their items. For the listbox you should call 'DebugListBox->handleUpdatedItemData()' at the end of your 'UpdateDebugWindow' method.

When you click an item, this request is probably called by cegui itself. That's why you see the change on a click.

HTH.

jchmack
Just popping in
Just popping in
Posts: 12
Joined: Tue Mar 27, 2007 15:13

Postby jchmack » Wed Jun 27, 2007 00:21

scriptkid wrote:I was typing something else when i noticed the problem in your code :)

Listboxes require you to tell them when you change their items. For the listbox you should call 'DebugListBox->handleUpdatedItemData()' at the end of your 'UpdateDebugWindow' method.

When you click an item, this request is probably called by cegui itself. That's why you see the change on a click.

HTH.


Thank you very much Script. Works exactly the way i need it :D. But im also wondering something. If CEGUI doesn't automatically update the listbox im guessing it's because the listbox wasn't designed for each element to be changing alot. It seems more suited for something like a chatbox. What kind of window or CEGUI element would you reccomend for text information that is very dynamic like FPS.

User avatar
scriptkid
Home away from home
Home away from home
Posts: 1178
Joined: Wed Jan 12, 2005 12:06
Location: The Hague, The Netherlands
Contact:

Postby scriptkid » Wed Jun 27, 2007 07:10

Good to hear that you got it too work :) You are right about the reason for this: if you have very dynamic text, you might choose StaticText widgets. For example in your situation:

Code: Select all

//Create FPS stat
fpsText = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticText", (CEGUI::utf8*)"FPS");
// Hide the border and background to make it look like text-only
fptText->setProperty("BackgroundEnabled", "False");
fptText->setProperty("FrameEnabled", "False");


After that just call 'setText' on it. See that i don't cast 'fpsText' to anything, since StaticText is 'just' (mapped to) a DefaultWindow.

Good luck :)

Pompei2
Home away from home
Home away from home
Posts: 489
Joined: Tue May 23, 2006 16:31

Postby Pompei2 » Wed Jun 27, 2007 12:38

scriptkid wrote:if you have very dynamic text, you might choose StaticText widgets.

funny paradox sentence :) but it's true :P

User avatar
scriptkid
Home away from home
Home away from home
Posts: 1178
Joined: Wed Jan 12, 2005 12:06
Location: The Hague, The Netherlands
Contact:

Postby scriptkid » Wed Jun 27, 2007 14:10

LOL :)

Rackle
CEGUI Team (Retired)
Posts: 534
Joined: Mon Jan 16, 2006 11:59
Location: Montréal

Postby Rackle » Wed Jun 27, 2007 14:37

I've updated WidgetGalore's Listbox section with this information; it's not an obvious solution.

jchmack
Just popping in
Just popping in
Posts: 12
Joined: Tue Mar 27, 2007 15:13

Postby jchmack » Fri Jun 29, 2007 05:05

One more question guys is there somewhere on the wiki or in the source that i can find a list of the many properties that can be set by the setProperty() function? I cant navigate the wiki very well yet :oops: .

edit: i found this:

http://www.cegui.org.uk/wiki/index.php/ ... owsLook%29

and am satisfied. But i would be open to anymore lists.

User avatar
scriptkid
Home away from home
Home away from home
Posts: 1178
Joined: Wed Jan 12, 2005 12:06
Location: The Hague, The Netherlands
Contact:

Postby scriptkid » Fri Jun 29, 2007 08:19

Well that list is very complete :) The coloured values come from the looknfeel definitions. This is the same list for the Taharez look:
http://www.cegui.org.uk/wiki/index.php/SetProperty

HTH.

Rackle
CEGUI Team (Retired)
Posts: 534
Joined: Mon Jan 16, 2006 11:59
Location: Montréal

Postby Rackle » Fri Jun 29, 2007 17:48

I've added links to/from the TaharezLook and the WindowsLook list of properties as well as to my message board post; should make it easier to locate this information. I should have done this initially but I thought that peeps would create an executable and use PropertyFinder rather than consulting the Wiki pages.

One day I'll look into adding more information to the Property class, such as the type of data (boolean, float, integer, string), numeric bounds (maxint/minint) or string format (think of a colorect). These should prove useful to toolmakers, although I guess they could always check the effect of setProperty() to determine whether the specified value was valid.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 12 guests