Provide the option to suppress lua call in setText

This commit is contained in:
BenDol 2014-04-03 05:20:35 +13:00
parent d45fbcb10f
commit 1074b6b787
4 changed files with 24 additions and 8 deletions

View File

@ -14,7 +14,8 @@ function init()
onSpellGroupCooldown = onSpellGroupCooldown, onSpellGroupCooldown = onSpellGroupCooldown,
onSpellCooldown = onSpellCooldown }) onSpellCooldown = onSpellCooldown })
cooldownButton = modules.client_topmenu.addRightGameToggleButton('cooldownButton', tr('Cooldowns'), '/images/topbuttons/cooldowns', toggle) cooldownButton = modules.client_topmenu.addRightGameToggleButton('cooldownButton',
tr('Cooldowns'), '/images/topbuttons/cooldowns', toggle)
cooldownButton:setOn(true) cooldownButton:setOn(true)
cooldownButton:hide() cooldownButton:hide()
@ -47,6 +48,7 @@ end
function loadIcon(iconId) function loadIcon(iconId)
local spell, profile, spellName = Spells.getSpellByIcon(iconId) local spell, profile, spellName = Spells.getSpellByIcon(iconId)
if not spellName then return end if not spellName then return end
if not profile then return end
clientIconId = Spells.getClientId(spellName) clientIconId = Spells.getClientId(spellName)
if not clientIconId then return end if not clientIconId then return end
@ -57,8 +59,13 @@ function loadIcon(iconId)
icon:setId(iconId) icon:setId(iconId)
end end
icon:setImageSource(SpelllistSettings[profile].iconFile) local spellSettings = SpelllistSettings[profile]
if spellSettings then
icon:setImageSource(spellSettings.iconFile)
icon:setImageClip(Spells.getImageClip(clientIconId, profile)) icon:setImageClip(Spells.getImageClip(clientIconId, profile))
else
icon = nil
end
return icon return icon
end end
@ -133,7 +140,10 @@ function updateCooldown(progressRect, duration)
if progressRect:getPercent() < 100 then if progressRect:getPercent() < 100 then
removeEvent(progressRect.event) removeEvent(progressRect.event)
progressRect.event = scheduleEvent(function() progressRect.callback[ProgressCallback.update]() end, 100)
progressRect.event = scheduleEvent(function()
progressRect.callback[ProgressCallback.update]()
end, 100)
else else
progressRect.callback[ProgressCallback.finish]() progressRect.callback[ProgressCallback.finish]()
end end

View File

@ -403,5 +403,8 @@ function Spells.getSpellProfileByName(spellName)
end end
function Spells.getImageClip(id, profile) function Spells.getImageClip(id, profile)
return (((id-1)%12)*SpelllistSettings[profile].iconSize.width) .. ' ' .. ((math.ceil(id/12)-1)*SpelllistSettings[profile].iconSize.height) .. ' ' .. SpelllistSettings[profile].iconSize.width .. ' ' .. SpelllistSettings[profile].iconSize.height return (((id-1)%12)*SpelllistSettings[profile].iconSize.width) .. ' '
.. ((math.ceil(id/12)-1)*SpelllistSettings[profile].iconSize.height) .. ' '
.. SpelllistSettings[profile].iconSize.width .. ' '
.. SpelllistSettings[profile].iconSize.height
end end

View File

@ -492,7 +492,7 @@ public:
void resizeToText() { setSize(getTextSize()); } void resizeToText() { setSize(getTextSize()); }
void clearText() { setText(""); } void clearText() { setText(""); }
void setText(std::string text); void setText(std::string text, bool fireLuaCall = true);
void setTextAlign(Fw::AlignmentFlag align) { m_textAlign = align; updateText(); } void setTextAlign(Fw::AlignmentFlag align) { m_textAlign = align; updateText(); }
void setTextOffset(const Point& offset) { m_textOffset = offset; updateText(); } void setTextOffset(const Point& offset) { m_textOffset = offset; updateText(); }
void setTextWrap(bool textWrap) { m_textWrap = textWrap; updateText(); } void setTextWrap(bool textWrap) { m_textWrap = textWrap; updateText(); }

View File

@ -112,7 +112,7 @@ void UIWidget::onFontChange(const std::string& font)
callLuaField("onFontChange", font); callLuaField("onFontChange", font);
} }
void UIWidget::setText(std::string text) void UIWidget::setText(std::string text, bool fireLuaCall)
{ {
if(m_textOnlyUpperCase) if(m_textOnlyUpperCase)
stdext::toupper(text); stdext::toupper(text);
@ -125,8 +125,11 @@ void UIWidget::setText(std::string text)
updateText(); updateText();
text = m_text; text = m_text;
if(fireLuaCall) {
onTextChange(text, oldText); onTextChange(text, oldText);
} }
}
void UIWidget::setFont(const std::string& fontName) void UIWidget::setFont(const std::string& fontName)
{ {