Creating staticimage in Runtime

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

jaguillard
Just popping in
Just popping in
Posts: 12
Joined: Wed Jun 04, 2008 21:24

Creating staticimage in Runtime

Postby jaguillard » Tue Jul 01, 2008 18:59

I'm making something like a mini-map, with dots representing objects in the world. I need to create StaticImage windows during runtime for each object in the scene. Now the WindowManager class can get me the window, but I can't figure out how to set the image into it. While the XML has the Image property, it isn't showing up in code.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Tue Jul 01, 2008 19:16

Hi,

You might consider a creating custom widget instead - having lots of little static image windows sound expensive to me ;)

Anyway, to answer your question - you still use the property from code:

Code: Select all

myStaticImage->setProperty( "Image", "set:MiniMapObjects image:Whatever" );


HTH

CE.

jaguillard
Just popping in
Just popping in
Posts: 12
Joined: Wed Jun 04, 2008 21:24

Postby jaguillard » Tue Jul 01, 2008 21:20

So far I've yet to get the staticimage to appear. I've debugged through and the size and position are right, but the window won't appear. I must be missing a step in creating it at runtime.

Code: Select all

CEGUI::Window* contact = CEGUI::WindowManager::getSingleton().createWindow("WaveloreGUI/StaticImage", "GreenBlipIcon");
mGuiWindow->getChild("SceneMapImage")->addChildWindow(contact);
contact->setProperty("Image", "set:GreenBlipImage image:full_image");
contact->setVisible(true);
contact->setMaxSize(CEGUI::UVector2(CEGUI::UDim(1,0), CEGUI::UDim(1,0)));
contact->setWidth(CEGUI::UDim(0, 50));
contact->setHeight(CEGUI::UDim(0, 50));
contact->setPosition(position);
contact->moveToFront();


That's basically what I have for the window, but nothing will appear. Even tried adding a font and text.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Wed Jul 02, 2008 08:30

Hi,

Are there any errors in the log file?

Failing that, can you post any relevant scheme entries and LookNFeel definitions used for the "WaveloreGUI/StaticImage" type?

CE.

jaguillard
Just popping in
Just popping in
Posts: 12
Joined: Wed Jun 04, 2008 21:24

Postby jaguillard » Wed Jul 02, 2008 14:21

No errors in the log.

Code: Select all

<FalagardMapping WindowType="WaveloreGUI/StaticImage" TargetType="DefaultWindow" Renderer="Falagard/StaticImage" LookNFeel="WaveloreGUI/StaticImage" />

Code: Select all

  <WidgetLook name="WaveloreGUI/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="False" />
    <Property name="FrameEnabled" value="False" />
    <ImagerySection name="image_withframe">
      <ImageryComponent>
        <Area>
          <Dim type="LeftEdge" >
            <ImageDim imageset="WaveloreGUI" image="Border_Left" dimension="Width" />
          </Dim>
          <Dim type="TopEdge" >
            <ImageDim imageset="WaveloreGUI" image="Border_Top" dimension="Height" />
          </Dim>
          <Dim type="RightEdge" >
            <UnifiedDim scale="1" type="RightEdge">
              <DimOperator op="Subtract">
                <ImageDim imageset="WaveloreGUI" image="Border_Right" dimension="Width" />
              </DimOperator>
            </UnifiedDim>
          </Dim>
          <Dim type="BottomEdge" >
            <UnifiedDim scale="1" type="BottomEdge">
              <DimOperator op="Subtract">
                <ImageDim imageset="WaveloreGUI" image="Border_Bottom" 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="WaveloreGUI/StaticShared" section="frame" />
      </Layer>
    </StateImagery>
    <StateImagery name="DisabledFrame">
      <Layer>
        <Section look="WaveloreGUI/StaticShared" section="frame" />
      </Layer>
    </StateImagery>
    <StateImagery name="WithFrameEnabledBackground">
      <Layer>
        <Section look="WaveloreGUI/StaticShared" section="background" />
      </Layer>
    </StateImagery>
    <StateImagery name="WithFrameDisabledBackground">
      <Layer>
        <Section look="WaveloreGUI/StaticShared" section="background" />
      </Layer>
    </StateImagery>
    <StateImagery name="NoFrameEnabledBackground">
      <Layer>
        <Section look="WaveloreGUI/StaticShared" section="background_noframe" />
      </Layer>
    </StateImagery>
    <StateImagery name="NoFrameDisabledBackground">
      <Layer>
        <Section look="WaveloreGUI/StaticShared" section="background_noframe" />
      </Layer>
    </StateImagery>
    <StateImagery name="WithFrameImage">
      <Layer>
        <Section section="image_withframe" />
      </Layer>
    </StateImagery>
    <StateImagery name="NoFrameImage">
      <Layer>
        <Section section="image_noframe" />
      </Layer>
    </StateImagery>
  </WidgetLook>


I haven't had any issues with StaticImage windows created through XML. This is the only situation. I've tested the imageset and image on other StaticImage windows and had no problems. Tried different sizes and positions. Tried making it a child of the root.


The only thing I can think is the createWindow function isn't working right. I checked the .cpp for the function and noticed that it should call the logger to write that a window was created. That message isn't in the log. I just had to assume that the "type" was a type define in the Scheme, as putting in just "Window" or "StaticImage" caused a crash.

jaguillard
Just popping in
Just popping in
Posts: 12
Joined: Wed Jun 04, 2008 21:24

Postby jaguillard » Wed Jul 02, 2008 16:47

Problem solved. The position variable being passed to the window's setPosition() was the problem. I set the offset, but didn't check that the scale wasn't initialized. Without setting it to zero, the value was chode and the position was completely borked.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Wed Jul 02, 2008 17:49

ah! I'm glad you managed to solve it :) (It's always the simple thing you never think of!)

CE.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 11 guests