whether "staticimage" can load 2 images and 2 texts or not?

Forum for general chit-chat or off-topic discussion.

Moderators: CEGUI MVP, CEGUI Team

haibo19981984
Just popping in
Just popping in
Posts: 10
Joined: Wed May 06, 2009 06:37

whether "staticimage" can load 2 images and 2 texts or not?

Postby haibo19981984 » Wed May 06, 2009 08:03

Hello, i have a simple question.
I want "staticimage" to load 2 images and 2 texts:
background // skill image
fontground // effect image
text1 // shortcut key
text2 // level
my .looknfeel:

Code: Select all

 <!--
    ***************************************************
        Test/StaticImage
    ***************************************************
    -->
    <WidgetLook name="Test/StaticImage">
         <PropertyDefinition name="ImageColours" initialValue="tl:FFFFFFFF tr:FFFFFFFF bl:FFFFFFFF br:FFFFFFFF" redrawOnWrite="true" />
         <PropertyDefinition name="FrameColours" initialValue="tl:FFFFFFFF tr:FFFFFFFF bl:FFFFFFFF br:FFFFFFFF" redrawOnWrite="true" />
         <PropertyDefinition name="BackgroundColours" initialValue="tl:FFFFFFFF tr:FFFFFFFF bl:FFFFFFFF br:FFFFFFFF" redrawOnWrite="true" />
        <PropertyDefinition name="VertFormatting" initialValue="Stretched" redrawOnWrite="true" />
        <PropertyDefinition name="HorzFormatting" initialValue="Stretched" redrawOnWrite="true" />
        <Property name="BackgroundEnabled" value="True" />
        <Property name="FrameEnabled" value="True" />
        <PropertyDefinition name="VertLabelFormatting" initialValue="BottomAligned" />
        <PropertyDefinition name="HorzLabelFormatting" initialValue="RightAligned" />
        <PropertyDefinition name="TextColour" initialValue="FFFFFFFF" redrawOnWrite="true" />
        <PropertyDefinition name="image2" initialValue="" redrawOnWrite="true" />
        <ImagerySection name="label">
            <TextComponent>
                <Area>
                    <Dim type="LeftEdge"><AbsoluteDim value="-2" /></Dim>
                    <Dim type="TopEdge"><AbsoluteDim value="-2" /></Dim>
                    <Dim type="Width"><UnifiedDim scale="1" type="Width" /></Dim>
                    <Dim type="Height"><UnifiedDim scale="1" type="Height" /></Dim>
                </Area>
                <ColourProperty name="TextColour" />
                <VertFormatProperty name="VertLabelFormatting" />
                <HorzFormatProperty name="HorzLabelFormatting" />
            </TextComponent>
        </ImagerySection>
        <ImagerySection name="image_noframe2">
            <ImageryComponent>
                <Area>
      <Dim type="LeftEdge" ><AbsoluteDim value="0" /></Dim>
      <Dim type="TopEdge" ><AbsoluteDim value="0" /></Dim>
      <Dim type="Width" ><UnifiedDim scale="1" type="Width" /></Dim>
      <Dim type="Height" ><UnifiedDim scale="1" type="Height" /></Dim>
   </Area>
                <ImageProperty name="Image2" />
                <ColourRectProperty name="ImageColours" />
                <VertFormatProperty name="VertFormatting" />
                <HorzFormatProperty name="HorzFormatting" />
            </ImageryComponent>
        </ImagerySection>
        <ImagerySection name="image_withframe">
            <ImageryComponent>
                  <Area>
      <Dim type="LeftEdge" ><ImageDim imageset="TaharezLook" image="StaticLeft" dimension="Width" /></Dim>
      <Dim type="TopEdge" ><ImageDim imageset="TaharezLook" image="StaticTop" dimension="Height" /></Dim>
      <Dim type="RightEdge" >
                     <UnifiedDim scale="1" type="RightEdge">
            <DimOperator op="Subtract">
               <ImageDim imageset="Test" image="StaticRight" dimension="Width" />
            </DimOperator>
         </UnifiedDim>
      </Dim>
      <Dim type="BottomEdge" >
         <UnifiedDim scale="1" type="BottomEdge">
            <DimOperator op="Subtract">
               <ImageDim imageset="Test" image="StaticBottom" dimension="Height" />
            </DimOperator>
         </UnifiedDim>
      </Dim>
   </Area>
                <ImageProperty name="Image" />
                <ColourRectProperty name="ImageColours" />
                <VertFormatProperty name="VertFormatting" />
                <HorzFormatProperty name="HorzFormatting" />
            </ImageryComponent>
        </ImagerySection>
        <ImagerySection name="image_noframe">
            <ImageryComponent>
                <Area>
      <Dim type="LeftEdge" ><AbsoluteDim value="0" /></Dim>
      <Dim type="TopEdge" ><AbsoluteDim value="0" /></Dim>
      <Dim type="Width" ><UnifiedDim scale="1" type="Width" /></Dim>
      <Dim type="Height" ><UnifiedDim scale="1" type="Height" /></Dim>
   </Area>
                <ImageProperty name="Image" />
                <ColourRectProperty name="ImageColours" />
                <VertFormatProperty name="VertFormatting" />
                <HorzFormatProperty name="HorzFormatting" />
            </ImageryComponent>
        </ImagerySection>
        <StateImagery name="Enabled" />
        <StateImagery name="Disabled" />
        <StateImagery name="EnabledFrame">
            <Layer>
                <Section look="Test/StaticShared" section="frame" />
            </Layer>
        </StateImagery>
        <StateImagery name="DisabledFrame">
            <Layer>
                <Section look="Test/StaticShared" section="frame" />
            </Layer>
        </StateImagery>
        <StateImagery name="WithFrameEnabledBackground">
            <Layer>
                <Section look="Test/StaticShared" section="background" />
            </Layer>
        </StateImagery>
        <StateImagery name="WithFrameDisabledBackground">
            <Layer>
                <Section look="Test/StaticShared" section="background" />
            </Layer>
        </StateImagery>
        <StateImagery name="NoFrameEnabledBackground">
            <Layer>
                <Section look="Test/StaticShared" section="background_noframe" />
            </Layer>
        </StateImagery>
        <StateImagery name="NoFrameDisabledBackground">
            <Layer>
                <Section look="Test/StaticShared" section="background_noframe" />
            </Layer>
        </StateImagery>
        <StateImagery name="WithFrameImage">
            <Layer>
                <Section section="image_withframe" />
                                <Section section="label" />
            </Layer>
        </StateImagery>
        <StateImagery name="NoFrameImage">
            <Layer>
                <Section section="image_noframe" />
                               <Section section="image_noframe2" />
                               <Section section="label" />
            </Layer>
        </StateImagery>
    </WidgetLook>

my imageset:

Code: Select all

<?xml version="1.0" ?>
<Imageset Name="Test" Imagefile="Test.tga" NativeHorzRes="800" NativeVertRes="600" AutoScaled="true">
               .......
   <Image Name="Goods" XPos="61" YPos="192" Width="31" Height="31" />
   <Image Name="Goods2" XPos="100" YPos="192" Width="31" Height="31" />
</Imageset>

my code:

Code: Select all

CEGUI::Window *goods = winMgr.createWindow((CEGUI::utf8*)"Test/StaticImage","goods");
goods->setPosition(CEGUI::UVector2(CEGUI::UDim(0.5f,0), CEGUI::UDim(0.5f,0)));
goods->setSize(CEGUI::UVector2(CEGUI::UDim(0.0f,31), CEGUI::UDim(0.0f,31)));
goods->setProperty("FrameEnabled","false");
goods->setProperty("BackgroundEnabled","false");
CEGUI::Imageset* imgset = CEGUI::ImagesetManager::getSingleton().getImageset((CEGUI::utf8*)"Test");
goods->setProperty("Image", CEGUI::PropertyHelper::imageToString(&imgset->getImage((CEGUI::utf8*)"Goods")));
goods->setProperty("Image2", CEGUI::PropertyHelper::imageToString(&imgset->getImage((CEGUI::utf8*)"Goods2")));
goods->setText("123");

At first,I think it is easy to realize 2 texts.But I fail to do it.
Because I cannot find where to set the text by the name of text.
So I only realize 1 text .
Then, I also want to realize 2 images.The same question appears.
And the error is occur at "Image2".
It seems that "staticimage" accepts only 1 image and 1 text.
At last, I have to appeal the forum.
I want to konw whether "staticimage" can realize what I say or not.
Sorry my English.

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

Re: whether "staticimage" can load 2 images and 2 texts or not?

Postby LennyH » Fri May 15, 2009 19:58

I know for a fact you can load more than one image, since we do so in a project I am working on. However, it has been nearly three years since I have looked at that part of the project. I have not used PropertyHelper before, so I also cannot judge if your usage is correct.

However, you could try:
goods->setProperty("Image", "set:Test image:Goods");
goods->setProperty("Image2", "set:Test image:Goods2");

And do be sure your scheme file actually references your test imageset. I realize you're loading the imageset via code, but, as I said...our code is three years old. But it works, so, hopefully it gives you a starting point.

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:

Re: whether "staticimage" can load 2 images and 2 texts or not?

Postby scriptkid » Sat May 16, 2009 14:06

Also, i think that the property names might be case sensitive (you use "Image2" instead of "image2").

And the error is occur at "Image2".


What is the error? Can you post the line of your Cegui.log file?

Thanks,
HTH.
Check out my released snake game using Cegui!

haibo19981984
Just popping in
Just popping in
Posts: 10
Joined: Wed May 06, 2009 06:37

Re: whether "staticimage" can load 2 images and 2 texts or not?

Postby haibo19981984 » Tue May 19, 2009 05:55

At first,thanks for your replay.
After 2 week of study CEGUI,I had resulted the problem.
The error in my fontal project is "There is no property named 'Image2' ".
The cause is that the property receives only "Image" in the class of "staticimge".
It is clear In sound code of Cegui. So if you want an added property,you must write it youself.
My method is to extend CEGUI.In fact,I create a new widget that looks like "staticimge".
It can load 2 images and 2 texts.
The important part is that how to create the new widget's class.
Luckily, we can find some In sound code of Cegui.
Sorry my English.


Return to “Offtopic Discussion”

Who is online

Users browsing this forum: No registered users and 10 guests