Page 1 of 1

2 questions about progress bar

Posted: Mon Aug 22, 2011 18:16
by rogerdv
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?

Re: 2 questions about progress bar

Posted: Mon Aug 22, 2011 19:26
by Jamarr
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?

Re: 2 questions about progress bar

Posted: Tue Aug 23, 2011 12:52
by rogerdv
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.

Re: 2 questions about progress bar

Posted: Wed Aug 24, 2011 08:26
by radical-dev
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

Re: 2 questions about progress bar

Posted: Wed Aug 24, 2011 15:06
by rogerdv
solved!