Browse Source

More fixes to miniwindow

Henrique Santiago 8 years ago
parent
commit
8d89d1194a

+ 27
- 13
modules/corelib/ui/uiminiwindow.lua View File

@@ -66,7 +66,7 @@ function UIMiniWindow:maximize(dontSave)
66 66
   signalcall(self.onMaximize, self)
67 67
 end
68 68
 
69
-function UIMiniWindow:onSetup()
69
+function UIMiniWindow:setup()
70 70
   self:getChildById('closeButton').onClick =
71 71
     function()
72 72
       self:close()
@@ -126,16 +126,11 @@ function UIMiniWindow:onSetup()
126 126
     end
127 127
   end
128 128
 
129
-  if newParent and newParent:getClassName() == 'UIMiniWindowContainer' and self:isVisible() then
130
-    newParent:fitAll(self)
131
-  end
129
+  self:fitOnParent()
132 130
 end
133 131
 
134 132
 function UIMiniWindow:onVisibilityChange(visible)
135
-  local parent = self:getParent()
136
-  if visible and parent and parent:getClassName() == 'UIMiniWindowContainer' then
137
-    parent:fitAll(self)
138
-  end
133
+  self:fitOnParent()
139 134
 end
140 135
 
141 136
 function UIMiniWindow:onDragEnter(mousePos)
@@ -227,11 +222,7 @@ end
227 222
 
228 223
 function UIMiniWindow:onHeightChange(height)
229 224
   self:setSettings({height = height})
230
-
231
-  local parent = self:getParent()
232
-  if self:isVisible() and parent and parent:getClassName() == 'UIMiniWindowContainer' then
233
-    parent:fitAll(self)
234
-  end
225
+  self:fitOnParent()
235 226
 end
236 227
 
237 228
 function UIMiniWindow:getSettings(name)
@@ -295,6 +286,24 @@ function UIMiniWindow:disableResize()
295 286
   self:getChildById('bottomResizeBorder'):disable()
296 287
 end
297 288
 
289
+function UIMiniWindow:fitOnParent()
290
+  local parent = self:getParent()
291
+  if self:isVisible() and parent and parent:getClassName() == 'UIMiniWindowContainer' then
292
+    parent:fitAll(self)
293
+  end
294
+end
295
+
296
+function UIMiniWindow:setParent(parent)
297
+  UIWidget.setParent(self, parent)
298
+  self:saveParent(parent)
299
+  self:fitOnParent()
300
+end
301
+
302
+function UIMiniWindow:setHeight(height)
303
+  UIWidget.setHeight(self, height)
304
+  signalcall(self.onHeightChange, self, height)
305
+end
306
+
298 307
 function UIMiniWindow:setContentHeight(height)
299 308
   local contentsPanel = self:getChildById('contentsPanel')
300 309
   local minHeight = contentsPanel:getMarginTop() + contentsPanel:getMarginBottom() + contentsPanel:getPaddingTop() + contentsPanel:getPaddingBottom()
@@ -328,3 +337,8 @@ function UIMiniWindow:getMaximumHeight()
328 337
   local resizeBorder = self:getChildById('bottomResizeBorder')
329 338
   return resizeBorder:getMaximum()
330 339
 end
340
+
341
+function UIMiniWindow:isResizeable()
342
+  local resizeBorder = self:getChildById('bottomResizeBorder')
343
+  return resizeBorder:isVisible() and resizeBorder:isEnabled()
344
+end

+ 1
- 1
modules/corelib/ui/uiminiwindowcontainer.lua View File

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

+ 0
- 2
modules/corelib/ui/uiresizeborder.lua View File

@@ -48,12 +48,10 @@ function UIResizeBorder:onMouseMove(mousePos, mouseMoved)
48 48
       local delta = mousePos.y - self:getY() - self:getHeight()/2
49 49
       newSize = math.min(math.max(parent:getHeight() + delta, self.minimum), self.maximum)
50 50
       parent:setHeight(newSize)
51
-      signalcall(parent.onHeightChange, parent, newSize)
52 51
     else
53 52
       local delta = mousePos.x - self:getX() - self:getWidth()/2
54 53
       newSize = math.min(math.max(parent:getWidth() + delta, self.minimum), self.maximum)
55 54
       parent:setWidth(newSize)
56
-      signalcall(parent.onWidthChange, parent, newSize)
57 55
     end
58 56
 
59 57
     self:checkBoundary(newSize)

+ 1
- 0
modules/game_battle/battle.lua View File

@@ -65,6 +65,7 @@ function init()
65 65
                     onGameEnd = removeAllCreatures } )
66 66
 
67 67
   checkCreatures()
68
+  battleWindow:setup()
68 69
 end
69 70
 
70 71
 function terminate()

+ 2
- 0
modules/game_combatcontrols/combatcontrols.lua View File

@@ -40,6 +40,8 @@ function init()
40 40
   if g_game.isOnline() then
41 41
     online()
42 42
   end
43
+
44
+  combatControlsWindow:setup()
43 45
 end
44 46
 
45 47
 function terminate()

+ 2
- 0
modules/game_containers/containers.lua View File

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

+ 2
- 0
modules/game_healthinfo/healthinfo.lua View File

@@ -56,6 +56,8 @@ function init()
56 56
     onSoulChange(localPlayer, localPlayer:getSoul())
57 57
     onFreeCapacityChange(localPlayer, localPlayer:getFreeCapacity())
58 58
   end
59
+
60
+  healthInfoWindow:setup()
59 61
 end
60 62
 
61 63
 function terminate()

+ 0
- 1
modules/game_interface/gameinterface.lua View File

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

+ 1
- 0
modules/game_inventory/inventory.lua View File

@@ -29,6 +29,7 @@ function init()
29 29
   inventoryPanel = inventoryWindow:getChildById('contentsPanel')
30 30
 
31 31
   refresh()
32
+  inventoryWindow:setup()
32 33
 end
33 34
 
34 35
 function terminate()

+ 1
- 0
modules/game_minimap/minimap.lua View File

@@ -40,6 +40,7 @@ function init()
40 40
   minimapWidget.onMouseWheel = onMinimapMouseWheel
41 41
 
42 42
   reset()
43
+  minimapWindow:setup()
43 44
 end
44 45
 
45 46
 function terminate()

+ 1
- 0
modules/game_skills/skills.lua View File

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

+ 1
- 0
modules/game_viplist/viplist.lua View File

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

Loading…
Cancel
Save