Page 1 of 1

How to change GUI skin dynamically

Posted: Wed Jul 19, 2006 09:54
by iversion
I have two xxxlookskin.scheme files. And I let users select which skin for the GUI. I try to use the CEGUI::SkinManager's member methods. But I got a exception.
How to achieve that ? Should I just restart the program to reload the new skin files? But I don't know how to restart it.
Can anybody give me an answer or a better solution?
Thank you! :)

Posted: Wed Jul 19, 2006 09:56
by spannerman
Please post details of the exception (what is the message? Where in the code does it occur?).

Posted: Wed Jul 19, 2006 11:33
by iversion
I create a list to let user to choose different skins.
And in the class TestApplication which inherit the ExampleApplication , I use handleSkinSelection to handle the selection of user.

Code: Select all

   bool handleSkinSelection(const CEGUI::EventArgs& e)
    {
        const CEGUI::WindowEventArgs& windowEventArgs = static_cast<const CEGUI::WindowEventArgs&>(e);
        CEGUI::ListboxItem* item = static_cast<CEGUI::Combobox*>(windowEventArgs.window)->getSelectedItem();
      int skinId=item->getID();

            switch(skinId)
      {
      case 0:
         if(!CEGUI::SchemeManager::getSingleton().isSchemePresent((CEGUI::utf8*)"TaharezLookSkin.scheme"))
         {
            CEGUI::SchemeManager::getSingleton().loadScheme((CEGUI::utf8*)"TaharezLookSkin.scheme"); 
         }
         break;
      case 1:
         
         if(!CEGUI::SchemeManager::getSingleton().isSchemePresent((CEGUI::utf8*)"NewLookSkin.scheme"))
         {
            CEGUI::SchemeManager::getSingleton().getScheme((CEGUI::utf8*)"NewLookSkin.scheme"); 
         }
         break;
      default:
         break;
      }

        return true;
    }
 


When I select the TaharezLook in the listbox, then there goes the exception:

Microsoft C++ exception: CEGUI::UknownObjectException

Does my way go wrong? If it does, could you give a solution?