More fixes to miniwindow

This commit is contained in:
Henrique Santiago 2012-08-21 18:40:47 -03:00
parent f27f005757
commit 8d89d1194a
12 changed files with 39 additions and 17 deletions

View File

@ -66,7 +66,7 @@ function UIMiniWindow:maximize(dontSave)
signalcall(self.onMaximize, self) signalcall(self.onMaximize, self)
end end
function UIMiniWindow:onSetup() function UIMiniWindow:setup()
self:getChildById('closeButton').onClick = self:getChildById('closeButton').onClick =
function() function()
self:close() self:close()
@ -126,16 +126,11 @@ function UIMiniWindow:onSetup()
end end
end end
if newParent and newParent:getClassName() == 'UIMiniWindowContainer' and self:isVisible() then self:fitOnParent()
newParent:fitAll(self)
end
end end
function UIMiniWindow:onVisibilityChange(visible) function UIMiniWindow:onVisibilityChange(visible)
local parent = self:getParent() self:fitOnParent()
if visible and parent and parent:getClassName() == 'UIMiniWindowContainer' then
parent:fitAll(self)
end
end end
function UIMiniWindow:onDragEnter(mousePos) function UIMiniWindow:onDragEnter(mousePos)
@ -227,11 +222,7 @@ end
function UIMiniWindow:onHeightChange(height) function UIMiniWindow:onHeightChange(height)
self:setSettings({height = height}) self:setSettings({height = height})
self:fitOnParent()
local parent = self:getParent()
if self:isVisible() and parent and parent:getClassName() == 'UIMiniWindowContainer' then
parent:fitAll(self)
end
end end
function UIMiniWindow:getSettings(name) function UIMiniWindow:getSettings(name)
@ -295,6 +286,24 @@ function UIMiniWindow:disableResize()
self:getChildById('bottomResizeBorder'):disable() self:getChildById('bottomResizeBorder'):disable()
end end
function UIMiniWindow:fitOnParent()
local parent = self:getParent()
if self:isVisible() and parent and parent:getClassName() == 'UIMiniWindowContainer' then
parent:fitAll(self)
end
end
function UIMiniWindow:setParent(parent)
UIWidget.setParent(self, parent)
self:saveParent(parent)
self:fitOnParent()
end
function UIMiniWindow:setHeight(height)
UIWidget.setHeight(self, height)
signalcall(self.onHeightChange, self, height)
end
function UIMiniWindow:setContentHeight(height) function UIMiniWindow:setContentHeight(height)
local contentsPanel = self:getChildById('contentsPanel') local contentsPanel = self:getChildById('contentsPanel')
local minHeight = contentsPanel:getMarginTop() + contentsPanel:getMarginBottom() + contentsPanel:getPaddingTop() + contentsPanel:getPaddingBottom() local minHeight = contentsPanel:getMarginTop() + contentsPanel:getMarginBottom() + contentsPanel:getPaddingTop() + contentsPanel:getPaddingBottom()
@ -328,3 +337,8 @@ function UIMiniWindow:getMaximumHeight()
local resizeBorder = self:getChildById('bottomResizeBorder') local resizeBorder = self:getChildById('bottomResizeBorder')
return resizeBorder:getMaximum() return resizeBorder:getMaximum()
end end
function UIMiniWindow:isResizeable()
local resizeBorder = self:getChildById('bottomResizeBorder')
return resizeBorder:isVisible() and resizeBorder:isEnabled()
end

View File

@ -35,7 +35,7 @@ function UIMiniWindowContainer:fitAll(noRemoveChild)
-- try to resize noRemoveChild -- try to resize noRemoveChild
local maximumHeight = selfHeight - (sumHeight - noRemoveChild:getHeight()) local maximumHeight = selfHeight - (sumHeight - noRemoveChild:getHeight())
if noRemoveChild:getMinimumHeight() <= maximumHeight then if noRemoveChild:isResizeable() and noRemoveChild:getMinimumHeight() <= maximumHeight then
sumHeight = sumHeight - noRemoveChild:getHeight() + maximumHeight sumHeight = sumHeight - noRemoveChild:getHeight() + maximumHeight
addEvent(function() noRemoveChild:setHeight(maximumHeight) end) addEvent(function() noRemoveChild:setHeight(maximumHeight) end)
end end

View File

@ -48,12 +48,10 @@ function UIResizeBorder:onMouseMove(mousePos, mouseMoved)
local delta = mousePos.y - self:getY() - self:getHeight()/2 local delta = mousePos.y - self:getY() - self:getHeight()/2
newSize = math.min(math.max(parent:getHeight() + delta, self.minimum), self.maximum) newSize = math.min(math.max(parent:getHeight() + delta, self.minimum), self.maximum)
parent:setHeight(newSize) parent:setHeight(newSize)
signalcall(parent.onHeightChange, parent, newSize)
else else
local delta = mousePos.x - self:getX() - self:getWidth()/2 local delta = mousePos.x - self:getX() - self:getWidth()/2
newSize = math.min(math.max(parent:getWidth() + delta, self.minimum), self.maximum) newSize = math.min(math.max(parent:getWidth() + delta, self.minimum), self.maximum)
parent:setWidth(newSize) parent:setWidth(newSize)
signalcall(parent.onWidthChange, parent, newSize)
end end
self:checkBoundary(newSize) self:checkBoundary(newSize)

View File

@ -65,6 +65,7 @@ function init()
onGameEnd = removeAllCreatures } ) onGameEnd = removeAllCreatures } )
checkCreatures() checkCreatures()
battleWindow:setup()
end end
function terminate() function terminate()

View File

@ -40,6 +40,8 @@ function init()
if g_game.isOnline() then if g_game.isOnline() then
online() online()
end end
combatControlsWindow:setup()
end end
function terminate() function terminate()

View File

@ -98,6 +98,8 @@ function onContainerOpen(container, previousContainer)
local filledLines = math.max(math.ceil(container:getItemsCount() / layout:getNumColumns()), 1) local filledLines = math.max(math.ceil(container:getItemsCount() / layout:getNumColumns()), 1)
containerWindow:setContentHeight(filledLines*cellSize.height) containerWindow:setContentHeight(filledLines*cellSize.height)
end end
containerWindow:setup()
end end
function onContainerClose(container) function onContainerClose(container)

View File

@ -56,6 +56,8 @@ function init()
onSoulChange(localPlayer, localPlayer:getSoul()) onSoulChange(localPlayer, localPlayer:getSoul())
onFreeCapacityChange(localPlayer, localPlayer:getFreeCapacity()) onFreeCapacityChange(localPlayer, localPlayer:getFreeCapacity())
end end
healthInfoWindow:setup()
end end
function terminate() function terminate()

View File

@ -486,7 +486,6 @@ function onLeftPanelVisibilityChange(leftPanel, visible)
local children = leftPanel:getChildren() local children = leftPanel:getChildren()
for i=1,#children do for i=1,#children do
children[i]:setParent(gameRightPanel) children[i]:setParent(gameRightPanel)
children[i]:saveParent(gameRightPanel)
end end
end end
end end

View File

@ -29,6 +29,7 @@ function init()
inventoryPanel = inventoryWindow:getChildById('contentsPanel') inventoryPanel = inventoryWindow:getChildById('contentsPanel')
refresh() refresh()
inventoryWindow:setup()
end end
function terminate() function terminate()

View File

@ -40,6 +40,7 @@ function init()
minimapWidget.onMouseWheel = onMinimapMouseWheel minimapWidget.onMouseWheel = onMinimapMouseWheel
reset() reset()
minimapWindow:setup()
end end
function terminate() function terminate()

View File

@ -31,6 +31,7 @@ function init()
g_keyboard.bindKeyDown('Ctrl+S', toggle) g_keyboard.bindKeyDown('Ctrl+S', toggle)
refresh() refresh()
skillsWindow:setup()
end end
function terminate() function terminate()

View File

@ -15,6 +15,7 @@ function init()
vipWindow = g_ui.loadUI('viplist.otui', modules.game_interface.getRightPanel()) vipWindow = g_ui.loadUI('viplist.otui', modules.game_interface.getRightPanel())
refresh() refresh()
vipWindow:setup()
end end
function terminate() function terminate()