Radio Button Text Colors

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

User avatar
Gf11speed
Not too shy to talk
Not too shy to talk
Posts: 22
Joined: Mon Jun 13, 2005 17:51
Contact:

Radio Button Text Colors

Postby Gf11speed » Wed Jul 05, 2006 16:19

I am trying to modify the color of the text for my radio buttons, but I do not want all of them to be the same in my game.

I know I can edit the game's looknfeel file and add this under the radio button section in order to change the colors:

Code: Select all

...
<WidgetLook name="GameLook/RadioButton">
<Property name="NormalTextColour" value="FF6600CC " />
<Property name="HoverTextColour" value="FF4F5F18" />
<Property name="PushedTextColour" value="FFFFFFFF" />
...


However, I want to it to be different for different parts of my game. Basically I want to be able to do it in the same way as text:

Code: Select all

...
<Window Type="GameLook/StaticText" Name="Text" >
<Property Name="Text" Value="text here" />
<Property Name="TextColours" Value="tl:FF330099 tr:FF330099 bl:FF000000 br:FF000000 " />
...


Instead with radio buttons, perhaps something like this:

Code: Select all

<Window Type="GameLook/RadioButton" Name="RadioButton" >
<Property Name="Text" Value="text here" />
<Property Name="TextColours" Value="tl:FF330099 tr:FF330099 bl:FF000000 br:FF000000 " />


Is this possible?
Syntasoft Games
www.syntasoft.com

User avatar
Gf11speed
Not too shy to talk
Not too shy to talk
Posts: 22
Joined: Mon Jun 13, 2005 17:51
Contact:

Postby Gf11speed » Tue Jul 11, 2006 18:21

Can't be done?
Syntasoft Games

www.syntasoft.com

Rackle
CEGUI Team (Retired)
Posts: 534
Joined: Mon Jan 16, 2006 11:59
Location: Montréal

Postby Rackle » Tue Jul 11, 2006 18:49

I would think something like this could work:

Radiobutton* rb = static_cast<Radiobutton*>(getWindow("MyRadiobutton"));
Color color(red, green, blue, alpha);
rb->setNormalTextColour(color);

User avatar
lindquist
CEGUI Team (Retired)
Posts: 770
Joined: Mon Jan 24, 2005 21:20
Location: Copenhagen, Denmark

Postby lindquist » Tue Jul 11, 2006 19:36

Make the look'n'feel use a ColourRect property instead.

Rackle
CEGUI Team (Retired)
Posts: 534
Joined: Mon Jan 16, 2006 11:59
Location: Montréal

Postby Rackle » Tue Jul 11, 2006 20:25

Second attempt...

This might be what lindquist was saying:

rb->setProperty("TextColours", "tl:FFFF0000 tr:FFFF0000 bl:FFFF0000 br:FFFF0000");

The sad thing is that this code comes from this post from myself...where oh where is my memory going!

User avatar
lindquist
CEGUI Team (Retired)
Posts: 770
Joined: Mon Jan 24, 2005 21:20
Location: Copenhagen, Denmark

Postby lindquist » Wed Jul 12, 2006 01:46

If the looknfeel defines the TextColours property and uses it as a ColourRect then yes.

User avatar
Gf11speed
Not too shy to talk
Not too shy to talk
Posts: 22
Joined: Mon Jun 13, 2005 17:51
Contact:

Postby Gf11speed » Wed Jul 12, 2006 02:57

I'm not sure exactly what you mean by making the look'n'feel use a ColourRect property. Is this simple to do?

I'd certainly prefer to specify the colors in the look'n'feel and layout files instead of modifying any C++ code, if this is possible.
Syntasoft Games

www.syntasoft.com

Rackle
CEGUI Team (Retired)
Posts: 534
Joined: Mon Jan 16, 2006 11:59
Location: Montréal

Postby Rackle » Wed Jul 12, 2006 11:51

Within TaharezLook.looknfeel, under the TaharezLook/RadioButton section:

Code: Select all

<PropertyDefinition name="NormalTextColour" initialValue="FFFFFFFF" redrawOnWrite="true" />
<PropertyDefinition name="HoverTextColour" initialValue="FFFFFFFF" redrawOnWrite="true" />
<PropertyDefinition name="PushedTextColour" initialValue="FFFFFFFF" redrawOnWrite="true" />
<PropertyDefinition name="DisabledTextColour" initialValue="FF7F7F7F" redrawOnWrite="true" />


which means that we can use:

Code: Select all

rb->setProperty("NormalTextColour", "FFFF0000"); // AARRGGBB

User avatar
Gf11speed
Not too shy to talk
Not too shy to talk
Posts: 22
Joined: Mon Jun 13, 2005 17:51
Contact:

Postby Gf11speed » Fri Jul 14, 2006 16:12

Rackle wrote:Within TaharezLook.looknfeel, under the TaharezLook/RadioButton section:

Code: Select all

<PropertyDefinition name="NormalTextColour" initialValue="FFFFFFFF" redrawOnWrite="true" />
<PropertyDefinition name="HoverTextColour" initialValue="FFFFFFFF" redrawOnWrite="true" />
<PropertyDefinition name="PushedTextColour" initialValue="FFFFFFFF" redrawOnWrite="true" />
<PropertyDefinition name="DisabledTextColour" initialValue="FF7F7F7F" redrawOnWrite="true" />


which means that we can use:

Code: Select all

rb->setProperty("NormalTextColour", "FFFF0000"); // AARRGGBB


When I add the <propertyDefinition...> tags, I get an error that says it already exists within the system. Here is what my RadioButton looks like:

Code: Select all

 <!--
    ***************************************************
        GameLook/RadioButton
    ***************************************************
    -->
    <WidgetLook name="GameLook/RadioButton">
   <PropertyDefinition name="NormalTextColour" initialValue="FFFFFFFF" redrawOnWrite="true" />
   <PropertyDefinition name="HoverTextColour" initialValue="FFFFFFFF" redrawOnWrite="true" />
   <PropertyDefinition name="PushedTextColour" initialValue="FFFFFFFF" redrawOnWrite="true" />
   <PropertyDefinition name="DisabledTextColour" initialValue="FF7F7F7F" redrawOnWrite="true" />

        <ImagerySection name="label">
            <TextComponent>
                <Area>
                    <Dim type="LeftEdge" >
                        <ImageDim imageset="GameLook" image="RadioButtonNormal" dimension="Width">
                            <DimOperator op="Add">
                                <AbsoluteDim value="3" />
                            </DimOperator>
                        </ImageDim>
                    </Dim>
                    <Dim type="TopEdge" ><AbsoluteDim value="0" /></Dim>
                    <Dim type="RightEdge" ><UnifiedDim scale="1" type="Width" /></Dim>
                    <Dim type="Height" ><UnifiedDim scale="1" type="Height" /></Dim>
                </Area>
                <VertFormat type="CentreAligned" />
                <HorzFormat type="LeftAligned" />
            </TextComponent>
        </ImagerySection>
        <ImagerySection name="normal">
            <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="GameLook" image="RadioButtonNormal" />
                <VertFormat type="CentreAligned" />
                <HorzFormat type="LeftAligned" />
            </ImageryComponent>
        </ImagerySection>
        <ImagerySection name="hover">
            <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="GameLook" image="RadioButtonHover" />
                <VertFormat type="CentreAligned" />
                <HorzFormat type="LeftAligned" />
            </ImageryComponent>
        </ImagerySection>
        <ImagerySection name="select_mark">
            <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="GameLook" image="RadioButtonMark" />
                <VertFormat type="CentreAligned" />
                <HorzFormat type="LeftAligned" />
            </ImageryComponent>
        </ImagerySection>
        <StateImagery name="Normal">
            <Layer>
                <Section section="normal" />
                <Section section="label">
                    <ColourProperty name="NormalTextColour" />
                </Section>
            </Layer>
        </StateImagery>
        <StateImagery name="Hover">
            <Layer>
                <Section section="hover" />
                <Section section="label">
                    <ColourProperty name="HoverTextColour" />
                </Section>
            </Layer>
        </StateImagery>
        <StateImagery name="Disabled">
            <Layer>
                <Section section="normal">
                    <Colours topLeft="FF7F7F7F" topRight="FF7F7F7F" bottomLeft="FF7F7F7F" bottomRight="FF7F7F7F" />
                </Section>
                <Section section="label">
                    <ColourProperty name="DisabledTextColour" />
                </Section>
            </Layer>
        </StateImagery>
        <StateImagery name="SelectedNormal">
            <Layer>
                <Section section="normal" />
                <Section section="select_mark" />
                <Section section="label">
                    <ColourProperty name="NormalTextColour" />
                </Section>
            </Layer>
        </StateImagery>
        <StateImagery name="SelectedHover">
            <Layer>
                <Section section="hover" />
                <Section section="select_mark" />
                <Section section="label">
                    <ColourProperty name="HoverTextColour" />
                </Section>
            </Layer>
        </StateImagery>
        <StateImagery name="SelectedDisabled">
            <Layer>
                <Section section="normal">
                    <Colours topLeft="FF7F7F7F" topRight="FF7F7F7F" bottomLeft="FF7F7F7F" bottomRight="FF7F7F7F" />
                </Section>
                <Section section="select_mark">
                    <Colours topLeft="FF7F7F7F" topRight="FF7F7F7F" bottomLeft="FF7F7F7F" bottomRight="FF7F7F7F" />
                </Section>
                <Section section="label">
                    <ColourProperty name="DisabledTextColour" />
                </Section>
            </Layer>
        </StateImagery>
    </WidgetLook>
   


What am I doing wrong?
Syntasoft Games

www.syntasoft.com

Rackle
CEGUI Team (Retired)
Posts: 534
Joined: Mon Jan 16, 2006 11:59
Location: Montréal

Postby Rackle » Fri Jul 14, 2006 16:29

I have not played with looknfeel yet so can't help you much. But what happens if you do not add these first 4 lines to your looknfeel, can you use rb->setProperty("NormalTextColour", "FFFF0000") nonetheless?

User avatar
Gf11speed
Not too shy to talk
Not too shy to talk
Posts: 22
Joined: Mon Jun 13, 2005 17:51
Contact:

Postby Gf11speed » Fri Jul 14, 2006 16:38

When I call the following, it just sets to the default white radio button color:

<Property name="NormalTextColour" value="FFFFF444" />


So basically it just ignores the call. This is what it looks like:

Code: Select all


<Window Type="GameLook/RadioButton" Name="Radio10" >
<Property name="NormalTextColour" value="FFFFF444" />
<Property Name="Font" Value="Tahoma-10" />
<Property Name="Text" Value="radio text" />
<Property Name="UnifiedAreaRect" Value="{{0.380000,0.000000},{0.800000,0.000000},{0.630000,0.000000},{0.850000,0.000000}}" />
<Property Name="UnifiedMaxSize" Value="{{1.000000,0.000000},{1.000000,0.000000}}" />
</Window>
Syntasoft Games

www.syntasoft.com

User avatar
Gf11speed
Not too shy to talk
Not too shy to talk
Posts: 22
Joined: Mon Jun 13, 2005 17:51
Contact:

Postby Gf11speed » Fri Jul 14, 2006 17:00

I'm not sure how to use ColourRect properly for what lindquist is referring to. Do you know how to do that?
Syntasoft Games

www.syntasoft.com

User avatar
Gf11speed
Not too shy to talk
Not too shy to talk
Posts: 22
Joined: Mon Jun 13, 2005 17:51
Contact:

Postby Gf11speed » Tue Jul 18, 2006 02:07

Ok I fixed it. The problem was that my .imageset file was missing some stuff, and for some reason it prevented me from changing radio button text colors.

So now I can change their color like so:

Code: Select all

<Window Type="GameLook/RadioButton" Name="Radio_Race1">
<Property Name="HoverTextColour" Value="FFFF0000" />
<Property Name="Font" Value="Tahoma-10" />
<Property Name="Text" Value="Yay it works!" />
</Window>
Syntasoft Games

www.syntasoft.com


Return to “Help”

Who is online

Users browsing this forum: No registered users and 29 guests