0.4.x => 0.5.0 upgrade questions..

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

phoenixy
Just popping in
Just popping in
Posts: 14
Joined: Tue Feb 27, 2007 01:18

0.4.x => 0.5.0 upgrade questions..

Postby phoenixy » Fri Mar 02, 2007 19:05

Hi,
I'm trying to upgrade my program from CEGUI 0.4.x to 0.5.0..

I think lots of members(classes) have disappeared.

I found somewhere in this forum that I can replace StaticText or StaticImage to DefaultWindow, but then, how can I replace many members of Static*?

There're no such members in DefaultWindow.

For example,
StaticText had setHorizontalFormatting, setVerticalFormatting member function, but it isn't in DefaultWindow.

I think I can use setProperty function to set these values, but I can't find references that I can use in setProperty.

Where can I find them?

Please help~

Thanks in advance,
Todd.

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

Postby Rackle » Fri Mar 02, 2007 20:09

WidgetGalore has the answer you are looking for, or you can go through the source code to find the available properties.

phoenixy
Just popping in
Just popping in
Posts: 14
Joined: Tue Feb 27, 2007 01:18

Postby phoenixy » Tue Mar 06, 2007 00:48

Thanks, Rackle.

I have some more questions..(Please excuse if the question doesn't make sense :( I'm a novice in game programming )

According to the WidgetGalore,
to make the same effect with StaticText in 0.4.X,
I need to use DefaultWindow.

And from the code [http://www.cegui.org.uk/wiki/index.php/WidgetGalore#WidgetGalore.h widgetgalore.h] in that page,

it seems that "StaticText" has property named "TextColours".

Code: Select all

         /* StaticText */
         DefaultWindow* staticText = static_cast<DefaultWindow*>(winMgr.getWindow("StaticText"));
         staticText->setText("Red Static Text");
         staticText->setProperty("TextColours", "tl:FFFF0000 tr:FFFF0000 bl:FFFF0000 br:FFFF0000"); // aarrggbb in Hexadecimal
            // tl: top left,  tr: top right,  bl: bottom left,  br: bottom right
         staticText->setProperty("VertFormatting", "VertCentred"); // TopAligned, BottomAligned, VertCentred
         staticText->setProperty("HorzFormatting", "HorzCentred"); // LeftAligned, RightAligned, HorzCentred
            // HorzJustified, WordWrapLeftAligned, WordWrapRightAligned, WordWrapCentred, WordWrapJustified
         staticText->setTooltipText("This is a StaticText widget");


What I am trying to do is to create a widget type called "BubbleStaticText" which inherits from DefaultWindow(originally from StaticText in 0.4.x)

I tried to set property values "FrameEnabled", "BackgroundEnabled", "FrameEnabled" in the constructor of BubbleStaticText, but what I get is "Exception: There is no Property named 'FrameEnabled' available in the set.".
However, these worked in 0.4.x version because there were methods setFrameEnabled, setBackgroundEnabled, setTextColours in StaticText class.


Many articles in the forum show example codes like the one above but the only difference that I can find is they're using WindowManager::getWindow instead of WindowManager::createWindow (which means they're using layout xml file and I'm not..)

Can you or anybody help me, please?

phoenixy
Just popping in
Just popping in
Posts: 14
Joined: Tue Feb 27, 2007 01:18

Postby phoenixy » Tue Mar 06, 2007 01:51

Correcting my question..

I tried in various ways.. and found out something.
Since I wanted to have custom class that inherited from DefaultWindow, I needed a factory.
To make cegui WindowManager to use that factory, I need a custom window type (which I named "BubbleStaticText").

When I give "BubbleStaticText" to WindowManager::createWindow, it calls my own factory and in turn, it tries to create an instance of BubbleStaticText.
In the constructor of BubbleStaticText, it tries to set properties such as "FrameEnabled", "BackgroundEnabled", ... which fails.

So, I tried some other things.
I gave "DefaultWindow" to WindowManager::createWindow ==> Exception occurred when i tried to set properties.
I gave "WindowsLook/StaticText" to WindowManager::createWindow ==> Passed without exception!

So, what I want to know is..

How can I make my own class/factory that inherits(?) WindowsLook/StaticText.

Please, help~

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

Postby Rackle » Tue Mar 06, 2007 04:21

Use this bit of code with the main.cpp from WidgetGalore:

Code: Select all

#include "CEGuiSample.h"
#include "CEGUI.h"

class DemoSample : public CEGuiSample
{
public:
   bool initialiseSample()
   {
      using namespace CEGUI;
      // Retrieve the window manager
      WindowManager& winMgr = WindowManager::getSingleton();

      // Load the TaharezLook scheme and set up the default mouse cursor and font
      SchemeManager::getSingleton().loadScheme("TaharezLook.scheme");
      System::getSingleton().setDefaultMouseCursor("TaharezLook", "MouseArrow");
      FontManager::getSingleton().createFont("Commonwealth-10.font");

      // Set the GUI Sheet
      Window* sheet = winMgr.createWindow("DefaultWindow", "root_wnd");
      System::getSingleton().setGUISheet(sheet);

      DefaultWindow* BubbleStaticText = static_cast<DefaultWindow*>(winMgr.createWindow("TaharezLook/StaticText", "BubbleStaticText"));
      sheet->addChildWindow(BubbleStaticText);
      BubbleStaticText->setPosition(UVector2(cegui_reldim(0.0f), cegui_reldim(0.0f))); // Top-left corner
      BubbleStaticText->setSize(UVector2(cegui_reldim(0.4f), cegui_reldim(0.2f))); // Some width and height
      BubbleStaticText->setText("My BubbleStatic text"); // Displayed text
      BubbleStaticText->setProperty("FrameEnabled", "false"); // Display border or not
      BubbleStaticText->setProperty("BackgroundEnabled", "false"); // Background clips other widgets or not
      return true;
   }

   void cleanupSample(void)
   {
   }
};


I looked through my WidgetGalore.layout to figure out how the static text widget was created and noticed "TaharezLook/StaticText" as the type, which I then used in the createWindow() function. Then I looked in the TaharezLook.looknfeel and saw that both the FrameEnabled and the BackgroundEnabled properties are set to true by default, so changed them to false in code to see what would happen.

All in all I prefer the .layout approach to the programming approach; I prefer to click options to create a layout than to code it all and then try to figure out the coordinates to position the widgets as well as figuring out their width and height. But hey, that's just me.

Hope this helps.

phoenixy
Just popping in
Just popping in
Posts: 14
Joined: Tue Feb 27, 2007 01:18

Postby phoenixy » Tue Mar 06, 2007 18:13

Thanks, Rackle.

I think I've got the solution (I'm not sure it's correct, though)

I added a custom type to the scheme file (currently, I tested it by adding to the windowslook.scheme)

Code: Select all

   <FalagardMapping WindowType="MyGui/BubbleStaticText"  TargetType="DefaultWindow" Renderer="Falagard/StaticText"  LookNFeel="WindowsLook/StaticText" />


When I called the windowmanager's createwindow with "MyGui/BubbleStaticText" custom type, it called my factory! and it's based on the Falagard/StaticText which has "FrameEnabled", "BackgroundEnabled" and so on.

So it works as my intention.

Thanks for your help.

LennyH
Quite a regular
Quite a regular
Posts: 92
Joined: Thu Nov 30, 2006 20:50

Postby LennyH » Mon Mar 12, 2007 13:33

Could you post an entire working example of what you did?

I pursued creating my own widgets for a time, but found documentation on doing so to be lacking, and help here to be non-forthcoming. Due to time constraints, I took a different approach to solve my problems, but am still quite curious to figure out what piece I was missing, since I did also have a factory, entries in the scheme, etc.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 21 guests