fix uiprogressbar assert
This commit is contained in:
parent
5784644701
commit
654fb1f3ea
|
@ -51,7 +51,14 @@ function Game.onManaChange(mana, maxMana)
|
|||
label:setText(mana .. ' / ' .. maxMana)
|
||||
|
||||
local manaBar = healthManaPanel:getChildById('manaBar')
|
||||
manaBar:setPercent(mana / maxMana * 100)
|
||||
|
||||
local percent
|
||||
if maxMana == 0 then
|
||||
percent = 100
|
||||
else
|
||||
percent = mana / maxMana * 100
|
||||
end
|
||||
manaBar:setPercent(percent)
|
||||
end
|
||||
|
||||
connect(Game, { onLogin = HealthMana.create,
|
||||
|
|
|
@ -50,10 +50,8 @@ local function onWidgetHoverChange(widget, hovered)
|
|||
end
|
||||
|
||||
local function onWidgetStyleApply(widget, style)
|
||||
if not style or not style.tooltip then return end
|
||||
print(style.tooltip)
|
||||
if not style then return end
|
||||
widget.tooltip = style.tooltip
|
||||
table.dump(style)
|
||||
end
|
||||
|
||||
connect(UIWidget, { onStyleApply = onWidgetStyleApply,
|
||||
|
|
|
@ -48,6 +48,7 @@ void UIProgressBar::render()
|
|||
|
||||
void UIProgressBar::setPercent(double percent)
|
||||
{
|
||||
assert(percent >= 0 && percent <= 100);
|
||||
m_percent = percent;
|
||||
if(percent == NAN)
|
||||
percent = 0;
|
||||
m_percent = std::min(std::max(percent, 0.0), 100.0);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue