[SOLVED] Help loading an Image button

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

noatom
Just popping in
Just popping in
Posts: 17
Joined: Sat Oct 04, 2014 23:37

[SOLVED] Help loading an Image button

Postby noatom » Mon Oct 06, 2014 17:53

So, I tried to create an image button by following this:

http://cegui.org.uk/wiki/Create_ImageButtons

But when I tried to run the code, I got an exception saying that the imageset and layout are in obsolete code. So I tried to look at the other imageset/layouts and get mine fixed, but I'm not sure how well I did.

Right now there are no errors, and a button appears, however the image is blacked, and looks nothing like the original image. What is the problem?

EDIT:

I took a look at the log of CEGUI, apparently there is an exception, link to log: http://pastebin.com/e2DZAeGA
Exception: CEGUI::UnknownObjectException in function 'class CEGUI::Image &__thiscall CEGUI::ImageManager::get(const class CEGUI::String &) const' (..\..\..\cegui\src\ImageManager.cpp:261) : Image not defined: set:loginButton image:btnNormal


loginButton.layout

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<GUILayout version="4" >
<Window name="btnLogin" type="TaharezLook/Button">
                    <Property name="Position" value="{{0,0},{0,0}}" />
                    <Property name="MaxSize" value="{{1,0},{1,0}}" />
                    <Property name="Size" value="{{0.3,0},{0.15,0}}" />
               <Property name="NormalImage"     value="set:loginButton image:btnNormal" />
</Window>
</GUILayout>
                   



loginButton.imageset

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>

<Imageset version="2" name="LoginButton" imagefile="loginButton.png" nativeHorzRes="1280" nativeVertRes="720" autoScaled="vertical" >
<Image height="42" name="ClientBrush" width="96" xPos="0" yPos="0" />
</Imageset>




And this is the code I use to load the button:

Code: Select all

CEGUI::ImageManager::getSingleton().loadImageset("loginButton.imageset");
CEGUI::Window *newWindow = NULL;
newWindow = CEGUI::WindowManager::getSingleton().loadLayoutFromFile("loginButton.layout");
newWindow->setPosition(CEGUI::UVector2(CEGUI::UDim(0.5, 0), CEGUI::UDim(0.50, 0)));
newWindow->activate();
CEGUI::System::getSingleton().getDefaultGUIContext().getRootWindow()->addChild(newWindow);


Last edited by noatom on Tue Oct 07, 2014 09:44, edited 1 time in total.

User avatar
Ident
CEGUI Team
Posts: 1995
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Help loading an Image button

Postby Ident » Tue Oct 07, 2014 06:55

The above tutorial must be written for 0.7 or 0.6. The new syntax is "loginButton/btnNormal". I added a version badge to the wiki article. Try my suggestion please
CrazyEddie: "I don't like GUIs"

noatom
Just popping in
Just popping in
Posts: 17
Joined: Sat Oct 04, 2014 23:37

Re: Help loading an Image button

Postby noatom » Tue Oct 07, 2014 09:15

The new syntax is "loginButton/btnNormal". I added a version badge to the wiki article. Try my suggestion please


I didn't quite catch where and what to change to fix the problem.

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: Help loading an Image button

Postby Kulik » Tue Oct 07, 2014 09:24

Use:

Code: Select all

<Property name="NormalImage"     value="loginButton/btnNormal" />


We have completely changed the image API in 0.8 to be more flexible. Images can now be sourced from other places than just imagesets. See porting tips for 0.8 for more details.

noatom
Just popping in
Just popping in
Posts: 17
Joined: Sat Oct 04, 2014 23:37

Re: Help loading an Image button

Postby noatom » Tue Oct 07, 2014 09:30

SOLVED:



loginButton.imageset

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<Imageset autoScaled="vertical" imagefile="loginButton.png" name="loginButton" nativeHorzRes="96" nativeVertRes="42" version="2">
<Image height="42" name="btnNormal" width="96" xPos="0" yPos="0" />
</Imageset>



loginButton.layout

Code: Select all


<?xml version="1.0" encoding="UTF-8" ?>
<GUILayout version="4" >
<Window type="TaharezLook/Button" name="btnLogin" >
                    <Property name="Position" value="{{0,0},{0,0}}" />
                    <Property name="MaxSize" value="{{1,0},{1,0}}" />
                    <Property name="Size" value="{{0.3,0},{0.15,0}}" />
               <Property name="NormalImage"     value="loginButton/btnNormal" />
</Window>
</GUILayout>
                   





Return to “Help”

Who is online

Users browsing this forum: Bing [Bot] and 28 guests