Trying to LOAD multiple .LAYOUTS

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

Chewe
Just popping in
Just popping in
Posts: 14
Joined: Tue Jun 13, 2006 18:09

Trying to LOAD multiple .LAYOUTS

Postby Chewe » Thu Jun 15, 2006 18:59

Hi all.

I'm trying to preload multiple layouts for a MENU.

Let's say i've got two: Main.layout, Options.layout

From this posts, i've been able to grow a bit.

http://www.cegui.org.uk/phpBB2/viewtopi ... ght=layout

http://www.cegui.org.uk/phpBB2/viewtopi ... ight=sheet

So i wrote this code

Code: Select all


  // CEGUI Setup
     mGUIRenderer = new CEGUI::OgreCEGUIRenderer(mWindow,
         Ogre::RENDER_QUEUE_OVERLAY, false, 3000, mSceneMgr);
      mGUISystem = new CEGUI::System(mGUIRenderer);
      CEGUI::Logger::getSingleton().setLoggingLevel(CEGUI::Informative);

  // load scheme and set up defaults
      CEGUI::SchemeManager::getSingleton().loadScheme(
         (CEGUI::utf8*)"TaharezLookSkin.scheme");
     mGUISystem->setDefaultMouseCursor(
      (CEGUI::utf8*)"TaharezLook", (CEGUI::utf8*)"MouseArrow");
      mGUISystem->setDefaultFont((CEGUI::utf8*)"BlueHighway-12");

// Sheet root?
     CEGUI::Window* sheet = CEGUI::WindowManager::getSingleton().createWindow( (CEGUI::utf8*)"DefaultWindow", (CEGUI::utf8*)"root_wnd" );
     CEGUI::System::getSingleton().setGUISheet( sheet );

// Ready to load layouts

   using namespace CEGUI;
   WindowManager& wMgr = WindowManager::getSingleton();
   Window* main = wMgr.getWindow((utf8*)"root_wnd");
    main->addChildWindow( CEGUI::WindowManager::getSingleton().loadWindowLayout((CEGUI::utf8*)"main.layout") );
   main->setVisible(false);

// From here it crashes, let's say that would be options.layout
   
   WindowManager& wMgr = WindowManager::getSingleton();
   Window* main2 = wMgr.getWindow((utf8*)"root_wnd");
   main2->addChildWindow( CEGUI::WindowManager::getSingleton().loadWindowLayout((CEGUI::utf8*)"main2.layout") );
   main2->setVisible(true);



I'm quite stuck right now. How would be the correct syntax to preload multiple layouts? :oops:

User avatar
lindquist
CEGUI Team (Retired)
Posts: 770
Joined: Mon Jan 24, 2005 21:20
Location: Copenhagen, Denmark

Postby lindquist » Thu Jun 15, 2006 19:09

try posting the log, the code seems to fine

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

Postby Rackle » Thu Jun 15, 2006 19:29

What are the first three lines of your .layout files? I suspect:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<GUILayout>
<Window Type="DefaultWindow" Name="Root" >

When loading your .layout files the program would attempt to create the "Root" window multiple times. Since windows must have unique names...you're in trouble unless you rename those "Root" windows.

Chewe
Just popping in
Just popping in
Posts: 14
Joined: Tue Jun 13, 2006 18:09

Postby Chewe » Thu Jun 15, 2006 21:32

AMAZING!

Two Tips in one. As Rackle said i've got the same names on both layouts, easily recognisible if i read CEGUI log as lindquist pointed.

So Cheers both of you.

Moving forward day by day thanks to WIKI Forum.

PD: Is it possible to share the same button (QUIT) on both layouts and call it once on eventshandler?

Chewe
Just popping in
Just popping in
Posts: 14
Joined: Tue Jun 13, 2006 18:09

Postby Chewe » Fri Jun 16, 2006 11:37

I'm back with my ignorance...

Code: Select all

   using namespace CEGUI;
   WindowManager& wMgr = WindowManager::getSingleton();
   Window* main = wMgr.getWindow((utf8*)"root_wnd");
    main->addChildWindow( CEGUI::WindowManager::getSingleton().loadWindowLayout((CEGUI::utf8*)"main.layout") );
   main->setVisible(true);
   
//   WindowManager& wMgr = WindowManager::getSingleton();
   Window* main2 = wMgr.getWindow((utf8*)"root_wnd");
   main2->addChildWindow( CEGUI::WindowManager::getSingleton().loadWindowLayout((CEGUI::utf8*)"main2.layout") );
   main2->setVisible(false);


Now this code works, but oddly it doesn't display the first layout. If i state false on the main.layout and true on main2 it displays perfectly but not otherwise.

Here is what cegui log states:

Code: Select all

[...]
16/06/2006 13:35:06 (InfL1)   ---- Successfully completed loading of GUI layout from 'main.layout' ----
16/06/2006 13:35:06 (InfL2)   ---- Beginning loading of GUI layout from 'main2.layout' ----
16/06/2006 13:35:06 (InfL2)   Window 'Root2' of type 'DefaultWindow' has been created.
16/06/2006 13:35:06 (InfL2)   Window 'Main2' of type 'TaharezLook/StaticImage' has been created.
16/06/2006 13:35:06 (InfL2)   Assigning LookNFeel 'TaharezLook/StaticImage' to window 'Main2'.
16/06/2006 13:35:06 (InfL2)   Window 'Play2' of type 'TaharezLook/Button' has been created.
16/06/2006 13:35:06 (InfL2)   Assigning LookNFeel 'TaharezLook/Button' to window 'Play2'.
16/06/2006 13:35:06 (InfL2)   Window 'Quit2' of type 'TaharezLook/Button' has been created.
16/06/2006 13:35:06 (InfL2)   Assigning LookNFeel 'TaharezLook/Button' to window 'Quit2'.
16/06/2006 13:35:06 (InfL1)   ---- Successfully completed loading of GUI layout from 'main2.layout' ----
16/06/2006 13:35:27 (InfL1)   ---- Begining CEGUI System destruction ----
16/06/2006 13:35:27 (InfL2)   Window 'Play' has been added to dead pool.
16/06/2006 13:35:27 (InfL2)   Window 'Options' has been added to dead pool.
16/06/2006 13:35:27 (InfL2)   Window 'Quit' has been added to dead pool.
16/06/2006 13:35:27 (InfL2)   Window 'Main' has been added to dead pool.
16/06/2006 13:35:27 (InfL2)   Window 'Play2' has been added to dead pool.
16/06/2006 13:35:27 (InfL2)   Window 'Quit2' has been added to dead pool.
16/06/2006 13:35:27 (InfL2)   Window 'Main2' has been added to dead pool.
16/06/2006 13:35:27 (InfL2)   Window 'Root' has been added to dead pool.
16/06/2006 13:35:27 (InfL2)   Window 'Root2' has been added to dead pool.
16/06/2006 13:35:27 (InfL2)   Window 'root_wnd' has been added to dead pool.
16/06/2006 13:35:27 (InfL1)   ---- Begining cleanup of GUI Scheme system ----
16/06/2006 13:35:27 (InfL2)   ---- Begining resource cleanup for GUI scheme 'TaharezLookSkin' ----
16/06/2006 13:35:27 (InfL2)   Imageset 'BlueHighway-12_auto_glyph_images' has been destroyed.
16/06/2006 13:35:27 (InfL1)   Font 'BlueHighway-12' has been destroyed.
16/06/2006 13:35:27 (InfL2)   Imageset 'BlueHighway-10_auto_glyph_images' has been destroyed.
16/06/2006 13:35:27 (InfL1)   Font 'BlueHighway-10' has been destroyed.
16/06/2006 13:35:27 (InfL2)   Imageset 'BlueHighway-8_auto_glyph_images' has been destroyed.
16/06/2006 13:35:27 (InfL1)   Font 'BlueHighway-8' has been destroyed.
16/06/2006 13:35:27 (InfL2)   Imageset 'TaharezLook' has been destroyed.
16/06/2006 13:35:27 (InfL2)   ---- Resource cleanup for GUI scheme 'TaharezLookSkin' completed ----
16/06/2006 13:35:27 (InfL2)   GUI scheme 'TaharezLookSkin' has been unloaded.
16/06/2006 13:35:27 (InfL1)   Scheme 'TaharezLookSkin' has been unloaded.
16/06/2006 13:35:27 (InfL1)   CEGUI::SchemeManager singleton destroyed.
16/06/2006 13:35:27 (InfL1)   CEGUI::WindowManager singleton destroyed
16/06/2006 13:35:27 (InfL1)   CEGUI::WindowFactoryManager singleton destroyed
16/06/2006 13:35:27 (InfL1)   CEGUI::WidgetLookManager singleton destroyed.
16/06/2006 13:35:27 (InfL1)   ---- Begining cleanup of Font system ----
16/06/2006 13:35:27 (InfL1)   CEGUI::FontManager singleton destroyed.
16/06/2006 13:35:27 (InfL1)   CEGUI::MouseCursor singleton destroyed.
16/06/2006 13:35:27 (InfL1)   ---- Begining cleanup of Imageset system ----
16/06/2006 13:35:27 (InfL2)   Imageset 'Old-paper' has been destroyed.
16/06/2006 13:35:27 (InfL1)   CEGUI::ImagesetManager singleton destroyed
16/06/2006 13:35:27 (InfL1)   CEGUI::GlobalEventSet singleton destroyed.
16/06/2006 13:35:27 (InfL1)   CEGUI::System singleton destroyed.
16/06/2006 13:35:27 (InfL1)   ---- CEGUI System destruction completed ----
16/06/2006 13:35:27 (InfL1)   CEGUI::Logger singleton destroyed.

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

Postby Rackle » Fri Jun 16, 2006 12:15

I'm using Cegui within Ogre:

Code: Select all

using namespace CEGUI;
mGUIRenderer = new CEGUI::OgreCEGUIRenderer(mWindow, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, mSceneManager); // add the parameter "mSceneManager" when using ST_EXTERIOR_CLOSE
mGUISystem = new CEGUI::System(mGUIRenderer, (const CEGUI::utf8*) "Player_Data/Logs/CEGUI_Interface.log");
CEGUI::Logger::getSingleton().setLoggingLevel(CEGUI::Informative); // Standard, Errors, Informative, Insane

CEGUI::SchemeManager::getSingleton().loadScheme((CEGUI::utf8*) "TaharezLook.scheme");

CEGUI::Font* guiFont = CEGUI::FontManager::getSingletonPtr()->createFont("Arial", "c:/windows/fonts/arial.ttf", 10, CEGUI::Default);
guiFont->defineFontGlyphs(0x0020, 0x0323); // Latin character set
mGUISystem->setDefaultFont(guiFont);

mGUISystem->setDefaultMouseCursor((CEGUI::utf8*) "TaharezLook", (CEGUI::utf8*) "MouseArrow");

mEditorGuiSheet = WindowManager::getSingleton().createWindow((CEGUI::utf8*)"DefaultWindow", (CEGUI::utf8*) "Sheet");
mGUISystem->setGUISheet(mEditorGuiSheet);

try
{
   CEGUI::WindowManager& winMgr = CEGUI::WindowManager::getSingleton();

    CEGUI::Window* chatBox = winMgr.loadWindowLayout((CEGUI::utf8*)"ChatBox.layout");
    mEditorGuiSheet->addChildWindow(chatBox);
    CEGUI::Window* editBoxWindow = winMgr.getWindow((CEGUI::utf8*)"/Chat/Wnd/Edit");
    BIND_CEGUI_EVENT(editBoxWindow, CEGUI::Editbox::EventTextAccepted, OgreApplication::ChatBoxText)

   CEGUI::Window* cargo = winMgr.loadWindowLayout("Cargo.layout");
   mEditorGuiSheet->addChildWindow(cargo);

   CEGUI::Window* merchant = winMgr.loadWindowLayout("Merchant.layout");
   mEditorGuiSheet->addChildWindow(merchant);

   mDialogConfigurations.loadConfigurations("Player_Data/DialogConfigurations.xml", "DialogConfigurations.xsd");
   mDialogConfigurations.addDialog("Cargo");
   mDialogConfigurations.addDialog("Merchant");
mEditorGuiSheet->addChildWindow(winMgr.loadWindowLayout("ManufactureSchematic.layout"));
mEditorGuiSheet->addChildWindow(winMgr.loadWindowLayout("ManufacturingStatus.layout"));
}
catch(CEGUI::Exception &e)
{
    OGRE_EXCEPT(Ogre::Exception::ERR_INTERNAL_ERROR, e.getMessage().c_str(), ".layout");
}


As you can see I'm loading 5 .layout files.

After some more tests I noticed a problem with the way my .layout were created. If I leave the "root" window (renaming each in the different layouts to avoid name conflict) then I cannot access the widgets from the other layouts; the root "DefaultWindow" is on top/covering the widgets from the other layouts. However if I remove that window (manually edit the .layout file, without forgetting the closing </window> at the bottom of the file) then everything works as I expect:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<GUILayout>
<Window Type="DefaultWindow" Name="ManufactureSchematic" >
<Property Name="UnifiedAreaRect" Value="{{0.000000,0.000000},{0.000000,0.000000},{1.000000,0.000000},{1.000000,0.000000}}" />
<Property Name="UnifiedMaxSize" Value="{{1.000000,0.000000},{1.000000,0.000000}}" />
<Window Type="TaharezLook/FrameWindow" Name="ManufactureSchematic/Window" >
...
</Window>
</Window>
</GUILayout>

versus

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<GUILayout>
<Window Type="TaharezLook/FrameWindow" Name="ManufactureSchematic/Window" >
...
</Window>
</GUILayout>

Chewe
Just popping in
Just popping in
Posts: 14
Joined: Tue Jun 13, 2006 18:09

Postby Chewe » Sat Jun 17, 2006 12:00

Dear Rackle.

Your code is a piece of cake to learn from, nice and clean, but i'm worried that i will need a few days to understand some more c++ basis and cegui commands. :oops:

But i have to confess that by the first read you solved one of the questions that i was also trying to solve. Getting latin codes on cegui 0.4. I can't express my satisfaction when i saved my layout in notepad using UTF8 and checking my country specific char on it!!!! ç :D

Thanks you so much for your post.

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

Postby Rackle » Sat Jun 17, 2006 12:25

Maybe I should have cleaned it up a little more. The basic steps are to initialize Cegui (everything before the try), and then calling winMgr.loadWindowLayout() and mEditorGuiSheet->addChildWindow() for each .layout file.

mDialogConfigurations comes from DialogConfigurations to save/restore the position of the dialogs.

Chewe
Just popping in
Just popping in
Posts: 14
Joined: Tue Jun 13, 2006 18:09

Postby Chewe » Sun Jun 18, 2006 16:44

In fact this is my second program ever. My first was 6 months ago based on VB and ServoControllers.

Afterall my problem was as simple to fix as that one solution you pointed by handcaring correctly window tags on layout files.

Code: Select all


CEGUI::WindowManager::getSingleton().getWindow("options/Root")-> setVisible(false);
     CEGUI::WindowManager::getSingleton().getWindow("main/Root")-> setVisible(true);



Now everything works as expected while all layouts remain preloaded.

I think mDialog tutorial is a bit far from me at this point, but i'm starting to think that it's what i'm going to need to solve options.layout dialogs. Could it be possible?

I want to adjust resolution and fullscreen options from ogreStartup application (ogre.cfg) inside options.layout.

Any advise on this next step?

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

Postby Rackle » Mon Jun 19, 2006 00:17

DialogConfigurations should be pretty easy to implement; you basically need to specify a file where the configurations are read from, specify the name of each FrameWindow you want to save the configuration of, and finally call the save function when you shutdown your application. However it's not for every program. I need it since I'll display numerous dialogs and want the users to be able to position these as they please and the next time they start the program find their dialogs/FrameWindows where they left them.

>>I want to adjust resolution and fullscreen options from ogreStartup application (ogre.cfg) inside options.layout.

The only difficulty is that you have to restart Ogre in order to apply these settings; destroying and recreating Ogre::Root. This question is better suited for the Ogre forums however.

Chewe
Just popping in
Just popping in
Posts: 14
Joined: Tue Jun 13, 2006 18:09

Postby Chewe » Mon Jun 19, 2006 11:04

As you said reading ogre.cfg would be an ogre wiki post.

I've found this post that should help me to understand it..

http://www.ogre3d.org/phpBB2/viewtopic. ... t=ogre+cfg

and

http://www.ogre3d.org/phpBB2/viewtopic.php?t=21344

I'm mostly sure that from here i should be able to move forward, but my c++ skills are quite on the abc level.

My first objective right now is to read ogre::system::resolutions and populate a cegui::ComboBox from inside application, from you can choose which resolution to apply next time application restarts.

From application wizard i've found the code to skip ogre configuration dialog.

Code: Select all

virtual bool configure(void)
    {
        // Show the configuration dialog and initialise the system
        // You can skip this and use root.restoreConfig() to load configuration
        // settings if you were sure there are valid ones saved in ogre.cfg
      if(mRoot->restoreConfig() || mRoot->showConfigDialog())
        {
            // If returned true, user clicked OK so initialise
            // Here we choose to let the system create a default rendering window by passing 'true'
            mWindow = mRoot->initialise(true);
            return true;
        }
        else
        {
            return false;
        }
    }


and from CEGUI Demo7 Sample i've summarized that combobox should be populate something like

Code: Select all

// combobox widget
    Combobox* cbobox = static_cast<Combobox*>(winMgr.createWindow("TaharezLook/Combobox", "Demo7/Window2/Combobox"));
    fwnd2->addChildWindow(cbobox);
    cbobox->setMaximumSize(Size(1.0f, 1.0f));
    cbobox->setPosition(Point(0.5f, 0.25f));
    cbobox->setSize(Size(0.42f, 0.45f));
[...]
// add items to the combobox list
    cbobox->addItem(new MyListItem("Combobox Item 1"));
    cbobox->addItem(new MyListItem("Combobox Item 2"));
    cbobox->addItem(new MyListItem("Combobox Item 3"));
    cbobox->addItem(new MyListItem("Combobox Item 4"));
    cbobox->addItem(new MyListItem("Combobox Item 5"));
    cbobox->addItem(new MyListItem("Combobox Item 6"));
    cbobox->addItem(new MyListItem("Combobox Item 7"));



Right now i know that first i should read ogre.cfg on a system public variables so after i choose resolution i can store it on a new ogre.cfg. From here i should read somehow system:resoptions and populate this info into combobox.

two big battlefronts for a newbie like me. Can you point me how to read system::resolutions to point them on a combobox?

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

Postby Rackle » Mon Jun 19, 2006 14:56

For a newbie I recommend looking at WidgetGalore to see each widget in action (I apparently missed the menu widget).

Have a look at Ogre's Intermediate Tutorial #5 to enumerate the rendering devices (OpenGL, DirectX) as well as the various display options (800x600x16, 800x600x32, 1024x768x16, ...). Beware of the last line of that tutorial: This is buggy and outdated- even with cleaning up there are over 150 leaks. Can anyone fix this up

Chewe
Just popping in
Just popping in
Posts: 14
Joined: Tue Jun 13, 2006 18:09

Postby Chewe » Mon Jun 19, 2006 16:03

Nice pointer.

hope to get results :D

Chewe
Just popping in
Just popping in
Posts: 14
Joined: Tue Jun 13, 2006 18:09

Postby Chewe » Wed Jun 21, 2006 14:17

Hi all, after three weeks learning from CEGUI, now i'm stuck trying to getConfigOptions to populate CEGUI combobox.

I've checked Ogre's Intermediate tutorial5. And after a while, i've been able to mix that code on mine(based on exampleapp). I've got to modify exampleapplication on configure() options, and now i can set fullResolution and save it on display.cfg.

But here i am, now trying to understand why i cannot getConfigOptions.

i've got main.cpp and main.h calling on exampleApp.

On main.h, after createscene void i tried to mix the code from

http://www.ogre3d.org/phpBB2/viewtopic.php?t=21344

But i cannot get it run.

Code: Select all

// Just override the mandatory create scene method
   virtual void createScene(void)
   {

       m_system_caps = Singletons::Instance().OgreRoot()->getRenderSystem()->getConfigOptions();

         CEGUI::Combobox * cbox_item;

         Ogre::ConfigOptionMap::iterator itr = m_system_caps.begin();

         while(itr != m_system_caps.end())
         {
            if((itr)->first == "Video Mode")
            {
               Ogre::StringVector possible_values = (itr)->second.possibleValues;
               Ogre::StringVector::iterator pv_itr = possible_values.begin();
               while(pv_itr != possible_values.end())
               {
                  list_box_item = new CEGUI::Combobox((*pv_itr));
                  m_resolution_list->addItem(cbox_item);
                  pv_itr ++;
               }
            }
            itr ++;
         }

   // setup GUI system
[...]



With this code it doesn't compile, getting errors like getOptionsConfig() must point to class/struct/union, among other errors.

If i change the first line of the above code to

m_system_caps->getConfigOptions();

.. i don't get the first point errors. But it stills getting me errors like

"left of .begin must have class/struct/uniontype"
"left of .end must have class/struct/uniontype"

Any advise ?

:oops:

User avatar
lindquist
CEGUI Team (Retired)
Posts: 770
Joined: Mon Jan 24, 2005 21:20
Location: Copenhagen, Denmark

Postby lindquist » Wed Jun 21, 2006 15:32

new CEGUI::Combobox == bad, the Combobox is not a listbox item


Return to “Help”

Who is online

Users browsing this forum: No registered users and 13 guests