2 questions about progress bar

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
rogerdv
Quite a regular
Quite a regular
Posts: 62
Joined: Thu Mar 31, 2005 23:21
Contact:

2 questions about progress bar

Postby rogerdv » Mon Aug 22, 2011 18:16

I want to use a couple of progress bars to show hp and mana in my game, but I found two problems: the progress bars jumps from full to empty when I call setProgress() and neither can set a tooltip to figure out the current value. Here is my layout definition:

Code: Select all

 <Window Type="TaharezLook/ProgressBar" Name="MsgWin/hpbar" >

                <Property Name="StepSize" Value="0.01" />

                <Property Name="InheritsAlpha" Value="False" />

                <Property Name="CurrentProgress" Value="0" />

                <Property Name="UnifiedAreaRect" Value="{{0.0207031,0},{0.625013,0},{0.230664,0},{0.875013,0}}" />

            </Window>

            <Window Type="TaharezLook/ProgressBar" Name="MsgWin/mpbar" >

                <Property Name="StepSize" Value="0.01" />

                <Property Name="InheritsAlpha" Value="False" />

                <Property Name="CurrentProgress" Value="0" />

                <Property Name="UnifiedAreaRect" Value="{{0.770898,0},{0.636011,0},{0.980859,0},{0.886011,0}}" />

            </Window>


Here is the code that sets progress percent:

Code: Select all

float perc = test->hp/test->hpmax;
    hp->setProgress(perc);
    //hp->setTooltipText(StringConverter::toString(test->hp)+"/"+StringConverter::toString(test->hpmax));
    hp->setProperty("Tooltip",StringConverter::toString(test->hp)+"/"+StringConverter::toString(test->hpmax));


As you can see, I have tried two ways to set the tooltip, none works. Any idea?

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

Re: 2 questions about progress bar

Postby Jamarr » Mon Aug 22, 2011 19:26

I do not see anything particularly wrong with your use of CEGUI.

rogerdv wrote:the progress bars jumps from full to empty when I call setProgress()


If your .layout defines the current progress to be 0, then how/where is it being set to full? And when you attempt to set your progress in the code-snippet above, what is the value of perc? Have you tried debugging / stepping-into your code to make sure it is not 0?

and neither can set a tooltip to figure out the current value. I have tried two ways to set the tooltip, none works. Any idea?


Are you using System::InjectTimePulse and System::InjectMouseMove (or System::InjectMousePosition) correctly? Have you set the system's default tooltip, eg System::setDefaultToolTip?
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!

User avatar
rogerdv
Quite a regular
Quite a regular
Posts: 62
Joined: Thu Mar 31, 2005 23:21
Contact:

Re: 2 questions about progress bar

Postby rogerdv » Tue Aug 23, 2011 12:52

Fixed the progress problem. perc was float, but the values used to calculate it were int, always producing 0. Casted them to float and now Im getting the right value. But still cant make the tooltip work.

radical-dev
Not too shy to talk
Not too shy to talk
Posts: 24
Joined: Mon Jul 27, 2009 09:53
Location: Germany
Contact:

Re: 2 questions about progress bar

Postby radical-dev » Wed Aug 24, 2011 08:26

As Jamarr said: System::InjectTimePulse is the funtion needed. Call it in every approach on your loop with the time elapsed since the last call of the loop and everything should work fine.

Best regards

radical-dev

User avatar
rogerdv
Quite a regular
Quite a regular
Posts: 62
Joined: Thu Mar 31, 2005 23:21
Contact:

Re: 2 questions about progress bar

Postby rogerdv » Wed Aug 24, 2011 15:06

solved!


Return to “Help”

Who is online

Users browsing this forum: Google [Bot] and 19 guests