Problems coloring Progres Bars...

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

dredogol
Not too shy to talk
Not too shy to talk
Posts: 41
Joined: Sat Apr 18, 2009 20:43

Problems coloring Progres Bars...

Postby dredogol » Sat May 02, 2009 18:04

Okay, I managed to get the Progress bar to show thanks to Eddie...

Now I'm having problems changing the color of it in game.
It should be pretty easy to change the color of it, because in the looknfeel file, there is this for it:

Code: Select all

        <StateImagery name="EnabledProgress">
            <Layer>
                <Section section="progress_lights">
                    <Colours topLeft="FF2222FF" topRight="FF2222FF" bottomLeft="FF2222FF" bottomRight="FF2222FF" />
                </Section>
            </Layer>
        </StateImagery>

Now, I tried to do something like this in my code:

Code: Select all

CEGUI::colour colorHP(1.0, 0.0, 0.0, 1.0);
wMgr->getWindow("playerHP")->setProperty("SelectionColour", CEGUI::PropertyHelper::colourToString(colorHP));

This does not work, because "SelectionColour" is not a valid property type for the Progress Bar.

The only ones I found for the Progress Bar were these:
http://www.cegui.org.uk/wiki/index.php/SetProperty_(WindowsLook)#ProgressBar

No where in that list does it have anything to change the colors of the progress bar.
I read another post about this, but it's modification of the LooknFeel flie... which I don't really want to do:
http://www.cegui.org.uk/phpBB2/viewtopic.php?f=2&t=1497&hilit=progress+bar+colour

Please tell me there is an easy way to change the color of the progress bar within my code, and not having to modify the looknfeel file.

--------------------------

Also, I'm having problems setting text colors for a static text.
It seems easy, but I'm getting an error saying:

Code: Select all

cannot convert paramter 2 from 'CEGUI::colour' to 'const CEGUI::String&'
Reason: cannot convert from 'CEGUI::colour' to 'const CEGUI::String'

This is what I wrote:

Code: Select all

CEGUI::String color = "tl:ff000000 tr:ff000000 bl:ff000000 br:ff000000";
wMgr->getWindow("minimap_title")->setProperty("TextColours", CEGUI::PropertyHelper::stringToColour(color))

I don't THINK the Tl,Tr,Bl,Br is of type color, so I'm guessing that's what wrong with this...
I also noticed for the TextColours in the SetProperty reference page, this specific item is colored Orange...
Is this something specific to Falagard, and do I need to do something different?

I've set colors before for a ListboxItem, but I had to Create new ones and set their SelectionColour, not TextColour for existing items.
Last edited by dredogol on Mon May 04, 2009 14:25, edited 1 time in total.

lcy03406
Not too shy to talk
Not too shy to talk
Posts: 26
Joined: Fri Apr 24, 2009 01:18

Re: Is there simple way to color Progres Bars?

Postby lcy03406 » Sun May 03, 2009 02:31

You can use <PropertyDim> to define a property and use <ColourRectProperty> in the StateImagery of EnabledProgress to assign the property to the bar.

That error is, the property value is a "String", you should use CEGUI::PropertyHelper::colourRectToString to biuld the string first.

dredogol
Not too shy to talk
Not too shy to talk
Posts: 41
Joined: Sat Apr 18, 2009 20:43

Re: Is there simple way to color Progres Bars?

Postby dredogol » Sun May 03, 2009 18:14

lcy03406 wrote:You can use <PropertyDim> to define a property and use <ColourRectProperty> in the StateImagery of EnabledProgress to assign the property to the bar.
That error is, the property value is a "String", you should use CEGUI::PropertyHelper::colourRectToString to biuld the string first.

I took your advice and looked at the TaharezLook.looknfeel file for a better example, and I found something that SHOULD have worked...
However, when I tried to implement it, it did not...

The result is a Progress bar which is a WHITE default color, and when I try to change the color in my CODE, it does nothing.
There are no compile / run-time errors...

The sections of code I altered are commented...

Code: Select all

    <!--
    ***************************************************
        WindowsLook/ProgressBar
    ***************************************************
    -->
    <WidgetLook name="WindowsLook/ProgressBar">

<!--### CUSTOM CODE ###-->
<PropertyDefinition name="CustomRectColor" initialValue="tl:FF000000 tr:FF000000 bl:FF000000 br:FF000000" redrawOnWrite="true" />

        <NamedArea name="ProgressArea">
            <Area>
                <Dim type="LeftEdge" >
                    <ImageDim imageset="WindowsLook" image="StaticFrameLeft" dimension="Width" />
                </Dim>
                <Dim type="TopEdge" >
                    <ImageDim imageset="WindowsLook" image="StaticFrameTop" dimension="Height" />
                </Dim>
                <Dim type="RightEdge" >
                    <UnifiedDim scale="1.0" type="RightEdge">
                        <DimOperator op="Subtract">
                            <ImageDim imageset="WindowsLook" image="StaticFrameRight" dimension="Width" />
                        </DimOperator>
                    </UnifiedDim>
                </Dim>
                <Dim type="BottomEdge" >
                    <UnifiedDim scale="1.0" type="BottomEdge">
                        <DimOperator op="Subtract">
                            <ImageDim imageset="WindowsLook" image="StaticFrameBottom" dimension="Height" />
                        </DimOperator>
                    </UnifiedDim>
                </Dim>
            </Area>
        </NamedArea>
        <ImagerySection name="frame">
            <FrameComponent>
                <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>
                <Image type="TopLeftCorner" imageset="WindowsLook" image="StaticFrameTopLeft" />
                <Image type="TopRightCorner" imageset="WindowsLook" image="StaticFrameTopRight" />
                <Image type="BottomLeftCorner" imageset="WindowsLook" image="StaticFrameBottomLeft" />
                <Image type="BottomRightCorner" imageset="WindowsLook" image="StaticFrameBottomRight" />
                <Image type="LeftEdge" imageset="WindowsLook" image="StaticFrameLeft" />
                <Image type="TopEdge" imageset="WindowsLook" image="StaticFrameTop" />
                <Image type="RightEdge" imageset="WindowsLook" image="StaticFrameRight" />
                <Image type="BottomEdge" imageset="WindowsLook" image="StaticFrameBottom" />
            </FrameComponent>
            <ImageryComponent>
                <Area>
                    <Dim type="LeftEdge">
                        <ImageDim imageset="WindowsLook" image="StaticFrameLeft" dimension="Width" />
                    </Dim>
                    <Dim type="TopEdge">
                        <ImageDim imageset="WindowsLook" image="StaticFrameTop" dimension="Height" />
                    </Dim>
                    <Dim type="RightEdge">
                        <UnifiedDim scale="1" type="RightEdge">
                            <DimOperator op="Subtract">
                                <ImageDim imageset="WindowsLook" image="StaticFrameRight" dimension="Width" />
                            </DimOperator>
                        </UnifiedDim>
                    </Dim>
                    <Dim type="BottomEdge">
                        <UnifiedDim scale="1" type="BottomEdge">
                            <DimOperator op="Subtract">
                                <ImageDim imageset="WindowsLook" image="StaticFrameBottom" dimension="Height" />
                            </DimOperator>
                        </UnifiedDim>
                    </Dim>
                </Area>
                <Image imageset="WindowsLook" image="Background" />
                <Colours topLeft="FFDFDFDF" topRight="FFDFDFDF" bottomLeft="FFDFDFDF" bottomRight="FFDFDFDF" />
                <VertFormat type="Stretched" />
                <HorzFormat type="Stretched" />
            </ImageryComponent>
        </ImagerySection>
        <ImagerySection name="progress_lights" >
            <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>
                <Image imageset="WindowsLook" image="Background" />

<!--### CUSTOM CODE ###-->
<ColorRectProperty name="CustomRectColor" />

                <VertFormat type="Stretched" />
                <HorzFormat type="Stretched" />
            </ImageryComponent>
        </ImagerySection>
        <StateImagery name="Enabled">
            <Layer>
                <Section section="frame" />
            </Layer>
        </StateImagery>
        <StateImagery name="Disabled">
            <Layer>
                <Section section="frame" />
            </Layer>
        </StateImagery>
        <StateImagery name="EnabledProgress">
            <Layer>
                <Section section="progress_lights">

<!-- <Colours topLeft="FF2222FF" topRight="FF2222FF" bottomLeft="FF2222FF" bottomRight="FF2222FF" /> -->
<!--### CUSTOM CODE ###-->
<ColorRectProperty name="CustomRectColor" />

                </Section>
            </Layer>
        </StateImagery>
        <StateImagery name="DisabledProgress">
            <Layer>
                <Section section="progress_lights">

<!-- <Colours topLeft="FF2222FF" topRight="FF2222FF" bottomLeft="FF2222FF" bottomRight="FF2222FF" /> -->
<!--### CUSTOM CODE ###-->
<ColorRectProperty name="CustomRectColor" />

                </Section>
            </Layer>
        </StateImagery>
    </WidgetLook>

Here is my code:

Code: Select all

void GameplayState::updatePlayerHP (float hp)
{
   // Update HP Progress Bar...
   CEGUI::colour c(1.0, 0.0, 0.0, 1.0);   // R,G,B,A...
   CEGUI::ColourRect colorHP(c);         // Set colors for all 4 corners of rectangle...
   wMgr->getWindow("gameGui_HP")->setProperty("CustomRectColor", CEGUI::PropertyHelper::colourRectToString(colorHP));
   wMgr->getWindow("gameGui_HP")->setProperty("CurrentProgress", CEGUI::PropertyHelper::floatToString(hp));
}

Am I doing something wrong, because I thought doing it this way should have worked :?:

-------------------------------------------

As far as the Static Text color is concerned, I fixed that:

Code: Select all

   CEGUI::colour c(0.0, 0.0, 0.0, 1.0);      // R,G,B,A...
   wMgr->getWindow("minimap_title")->setProperty("TextColours", CEGUI::PropertyHelper::colourToString(c));

lcy03406
Not too shy to talk
Not too shy to talk
Posts: 26
Joined: Fri Apr 24, 2009 01:18

Re: Is there simple way to color Progres Bars?

Postby lcy03406 » Mon May 04, 2009 03:04

yes it should work. is your GameplayState::updatePlayerHP actually called once the game started?

dredogol
Not too shy to talk
Not too shy to talk
Posts: 41
Joined: Sat Apr 18, 2009 20:43

Re: Is there simple way to color Progres Bars?

Postby dredogol » Mon May 04, 2009 14:25

OMFG... I'm so retarded...

I spent over 1-day trying to figure out what was wrong.....

it's COLOUR ... not COLOR! :evil:

lcy03406
Not too shy to talk
Not too shy to talk
Posts: 26
Joined: Fri Apr 24, 2009 01:18

Re: Problems coloring Progres Bars...

Postby lcy03406 » Tue May 05, 2009 04:19

:shock:

Jamarr
CEGUI MVP
CEGUI MVP
Posts: 812
Joined: Tue Jun 03, 2008 23:59
Location: USA

Re: Problems coloring Progres Bars...

Postby Jamarr » Wed May 06, 2009 19:42

I think this has bitten everyone at leats once...at least the Americans. Damn that CE and his british spelling! :lol:
If somebody helps you by replying to your thread, upvote him/her as a thanks! Make sure to include your CEGUI.log and everything you tried when posting! And remember that we are not magicians!


Return to “Help”

Who is online

Users browsing this forum: No registered users and 19 guests