Fix #235 and other changes
This commit is contained in:
parent
2fd3c643c4
commit
4b1db2bcd6
|
@ -4,6 +4,7 @@ TextList < UIScrollArea
|
||||||
border-color: #1d222b
|
border-color: #1d222b
|
||||||
background-color: #222833
|
background-color: #222833
|
||||||
padding: 1
|
padding: 1
|
||||||
|
auto-focus: none
|
||||||
|
|
||||||
HorizontalList < UIScrollArea
|
HorizontalList < UIScrollArea
|
||||||
layout: horizontalBox
|
layout: horizontalBox
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
CharacterWidget < UIWidget
|
CharacterWidget < UIWidget
|
||||||
height: 14
|
height: 14
|
||||||
focusable: true
|
|
||||||
background-color: alpha
|
background-color: alpha
|
||||||
@onFocusChange: |
|
&updateOnStates: |
|
||||||
|
function(self)
|
||||||
local children = self:getChildren()
|
local children = self:getChildren()
|
||||||
for i=1,#children do
|
for i=1,#children do
|
||||||
children[i]:setOn(self:isFocused())
|
children[i]:setOn(self:isFocused())
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
@onFocusChange: self:updateOnStates()
|
||||||
|
@onSetup: self:updateOnStates()
|
||||||
|
|
||||||
$focus:
|
$focus:
|
||||||
background-color: #ffffff22
|
background-color: #ffffff22
|
||||||
|
@ -60,6 +63,7 @@ MainWindow
|
||||||
padding: 1
|
padding: 1
|
||||||
focusable: false
|
focusable: false
|
||||||
vertical-scrollbar: characterListScrollBar
|
vertical-scrollbar: characterListScrollBar
|
||||||
|
auto-focus: first
|
||||||
|
|
||||||
VerticalScrollBar
|
VerticalScrollBar
|
||||||
id: characterListScrollBar
|
id: characterListScrollBar
|
||||||
|
|
|
@ -4,8 +4,8 @@ contentsPanel = nil
|
||||||
spellCooldownPanel = nil
|
spellCooldownPanel = nil
|
||||||
|
|
||||||
function init()
|
function init()
|
||||||
connect(g_game, { onGameStart = show,
|
connect(g_game, { onGameStart = online,
|
||||||
onGameEnd = hide,
|
onGameEnd = offline,
|
||||||
onSpellGroupCooldown = onSpellGroupCooldown,
|
onSpellGroupCooldown = onSpellGroupCooldown,
|
||||||
onSpellCooldown = onSpellCooldown })
|
onSpellCooldown = onSpellCooldown })
|
||||||
|
|
||||||
|
@ -21,13 +21,13 @@ function init()
|
||||||
spellCooldownPanel = contentsPanel:getChildById('spellCooldownPanel')
|
spellCooldownPanel = contentsPanel:getChildById('spellCooldownPanel')
|
||||||
|
|
||||||
if g_game.isOnline() then
|
if g_game.isOnline() then
|
||||||
show()
|
online()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function terminate()
|
function terminate()
|
||||||
disconnect(g_game, { onGameStart = show,
|
disconnect(g_game, { onGameStart = online,
|
||||||
onGameEnd = hide,
|
onGameEnd = offline,
|
||||||
onSpellGroupCooldown = onSpellGroupCooldown,
|
onSpellGroupCooldown = onSpellGroupCooldown,
|
||||||
onSpellCooldown = onSpellCooldown })
|
onSpellCooldown = onSpellCooldown })
|
||||||
|
|
||||||
|
@ -49,18 +49,16 @@ function toggle()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function show()
|
function online()
|
||||||
if g_game.getFeature(GameSpellList) then
|
if g_game.getFeature(GameSpellList) then
|
||||||
cooldownWindow:show()
|
|
||||||
cooldownButton:show()
|
cooldownButton:show()
|
||||||
else
|
else
|
||||||
hide()
|
cooldownButton:hide()
|
||||||
|
cooldownWindow:close()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function hide()
|
function offline()
|
||||||
cooldownWindow:hide()
|
|
||||||
cooldownButton:hide()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function updateProgressRect(progressRect, interval, init)
|
function updateProgressRect(progressRect, interval, init)
|
||||||
|
|
|
@ -352,6 +352,8 @@ function refreshTradeItems()
|
||||||
end
|
end
|
||||||
|
|
||||||
function refreshPlayerGoods()
|
function refreshPlayerGoods()
|
||||||
|
if not g_game.isOnline() then return end
|
||||||
|
|
||||||
moneyLabel:setText(playerMoney .. ' ' .. CURRENCY)
|
moneyLabel:setText(playerMoney .. ' ' .. CURRENCY)
|
||||||
capacityLabel:setText(string.format('%.2f', playerFreeCapacity) .. ' ' .. WEIGHT_UNIT)
|
capacityLabel:setText(string.format('%.2f', playerFreeCapacity) .. ' ' .. WEIGHT_UNIT)
|
||||||
|
|
||||||
|
|
|
@ -80,10 +80,10 @@ function getIconImageClip(id)
|
||||||
end
|
end
|
||||||
|
|
||||||
function online()
|
function online()
|
||||||
if g_game.getProtocolVersion() < 870 then
|
if g_game.getFeature(GameSpellList) then
|
||||||
spelllistButton:setVisible(false)
|
spelllistButton:show()
|
||||||
else
|
else
|
||||||
spelllistButton:setVisible(true)
|
spelllistButton:hide()
|
||||||
end
|
end
|
||||||
if g_game.getProtocolVersion() >= 950 then -- Vocation is only send in newer clients
|
if g_game.getProtocolVersion() >= 950 then -- Vocation is only send in newer clients
|
||||||
spelllistWindow:getChildById('buttonFilterVocation'):setVisible(true)
|
spelllistWindow:getChildById('buttonFilterVocation'):setVisible(true)
|
||||||
|
|
|
@ -977,7 +977,7 @@ void UIWidget::setFocusable(bool focusable)
|
||||||
if(UIWidgetPtr parent = getParent()) {
|
if(UIWidgetPtr parent = getParent()) {
|
||||||
if(!focusable && isFocused()) {
|
if(!focusable && isFocused()) {
|
||||||
parent->focusPreviousChild(Fw::ActiveFocusReason, true);
|
parent->focusPreviousChild(Fw::ActiveFocusReason, true);
|
||||||
} else if(focusable && (!parent->getFocusedChild() && parent->getAutoFocusPolicy() != Fw::AutoFocusNone)) {
|
} else if(focusable && !parent->getFocusedChild() && parent->getAutoFocusPolicy() != Fw::AutoFocusNone) {
|
||||||
focus();
|
focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,26 @@ void UIWidget::initBaseStyle()
|
||||||
|
|
||||||
void UIWidget::parseBaseStyle(const OTMLNodePtr& styleNode)
|
void UIWidget::parseBaseStyle(const OTMLNodePtr& styleNode)
|
||||||
{
|
{
|
||||||
|
// parse lua variables and callbacks first
|
||||||
|
for(const OTMLNodePtr& node : styleNode->children()) {
|
||||||
|
// lua functions
|
||||||
|
if(stdext::starts_with(node->tag(), "@")) {
|
||||||
|
// load once
|
||||||
|
if(m_firstOnStyle) {
|
||||||
|
std::string funcName = node->tag().substr(1);
|
||||||
|
std::string funcOrigin = "@" + node->source() + ": [" + node->tag() + "]";
|
||||||
|
g_lua.loadFunction(node->value(), funcOrigin);
|
||||||
|
luaSetField(funcName);
|
||||||
|
}
|
||||||
|
// lua fields value
|
||||||
|
} else if(stdext::starts_with(node->tag(), "&")) {
|
||||||
|
std::string fieldName = node->tag().substr(1);
|
||||||
|
std::string fieldOrigin = "@" + node->source() + ": [" + node->tag() + "]";
|
||||||
|
|
||||||
|
g_lua.evaluateExpression(node->value(), fieldOrigin);
|
||||||
|
luaSetField(fieldName);
|
||||||
|
}
|
||||||
|
}
|
||||||
// load styles used by all widgets
|
// load styles used by all widgets
|
||||||
for(const OTMLNodePtr& node : styleNode->children()) {
|
for(const OTMLNodePtr& node : styleNode->children()) {
|
||||||
if(node->tag() == "color")
|
if(node->tag() == "color")
|
||||||
|
@ -309,22 +329,6 @@ void UIWidget::parseBaseStyle(const OTMLNodePtr& styleNode)
|
||||||
addAnchor(anchoredEdge, hookedWidgetId, hookedEdge);
|
addAnchor(anchoredEdge, hookedWidgetId, hookedEdge);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// lua functions
|
|
||||||
} else if(stdext::starts_with(node->tag(), "@")) {
|
|
||||||
// load once
|
|
||||||
if(m_firstOnStyle) {
|
|
||||||
std::string funcName = node->tag().substr(1);
|
|
||||||
std::string funcOrigin = "@" + node->source() + ": [" + node->tag() + "]";
|
|
||||||
g_lua.loadFunction(node->value(), funcOrigin);
|
|
||||||
luaSetField(funcName);
|
|
||||||
}
|
|
||||||
// lua fields value
|
|
||||||
} else if(stdext::starts_with(node->tag(), "&")) {
|
|
||||||
std::string fieldName = node->tag().substr(1);
|
|
||||||
std::string fieldOrigin = "@" + node->source() + ": [" + node->tag() + "]";
|
|
||||||
|
|
||||||
g_lua.evaluateExpression(node->value(), fieldOrigin);
|
|
||||||
luaSetField(fieldName);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue