Browse Source

fix warnings and some reloading issues

Eduardo Bart 8 years ago
parent
commit
d0b839a4eb

+ 1
- 1
modules/client/client.otmod View File

@@ -8,8 +8,8 @@ Module
8 8
   reloadable: false
9 9
 
10 10
   load-later:
11
-    - client_topmenu
12 11
     - client_locales
12
+    - client_topmenu
13 13
     - client_background
14 14
     //- client_about
15 15
     - client_options

+ 2
- 1
modules/client_locales/locales.lua View File

@@ -28,7 +28,7 @@ function Locales.init()
28 28
     Locales.setLocale(defaultLocaleName)
29 29
     Settings.set('locale', defaultLocaleName)
30 30
   end
31
-
31
+--[[
32 32
   addEvent( function()
33 33
               localeComboBox = createWidget('ComboBox', rootWidget:recursiveGetChildById('rightButtonsPanel'))
34 34
               for key,value in pairs(installedLocales) do
@@ -37,6 +37,7 @@ function Locales.init()
37 37
               localeComboBox:setCurrentOption(currentLocale.languageName)
38 38
               localeComboBox.onOptionChange = onLocaleComboBoxOptionChange
39 39
             end, false)
40
+            ]]--
40 41
 end
41 42
 
42 43
 function Locales.terminate()

+ 1
- 0
modules/client_locales/locales/pt-br.lua View File

@@ -182,6 +182,7 @@ locale = {
182 182
     ["You are burning"] = "Você está queimando",
183 183
     ["You are cursed"] = "Você está amaldiçoado",
184 184
     ["You are dazzled"] = "Você está deslumbrado",
185
+    ["You are dead."] = "Você está morto.",
185 186
     ["You are drowing"] = "Você está se afogando",
186 187
     ["You are electrified"] = "Você está eletrificado",
187 188
     ["You are freezing"] = "Você está congelando",

+ 7
- 7
modules/client_terminal/terminal.lua View File

@@ -177,19 +177,19 @@ function Terminal.hide()
177 177
 end
178 178
 
179 179
 function Terminal.addLine(text, color)
180
-  -- create new line label
181
-  local numLines = terminalBuffer:getChildCount() + 1
182
-  local label = createWidget('TerminalLabel', terminalBuffer)
183
-  label:setId('terminalLabel' .. numLines)
184
-  label:setText(text)
185
-  label:setColor(color)
186
-
187 180
   -- delete old lines if needed
181
+  local numLines = terminalBuffer:getChildCount() + 1
188 182
   if numLines > MaxLogLines then
189 183
     terminalBuffer:getChildByIndex(1):destroy()
190 184
   else
191 185
     terminalBuffer:setHeight(terminalBuffer:getHeight() + LabelHeight)
192 186
   end
187
+
188
+  -- create new line label
189
+  local label = createWidget('TerminalLabel', terminalBuffer)
190
+  label:setId('terminalLabel' .. numLines)
191
+  label:setText(text)
192
+  label:setColor(color)
193 193
 end
194 194
 
195 195
 function Terminal.executeCommand(command)

+ 6
- 1
modules/core_lib/widgets/uitabbar.lua View File

@@ -8,7 +8,7 @@ end
8 8
 local function tabBlink(tab)
9 9
   if not tab.blinking then return end
10 10
   tab:setOn(not tab:isOn())
11
-  scheduleEvent(function() tabBlink(tab) end, 500)
11
+  tab.blinkEvent = scheduleEvent(function() tabBlink(tab) end, 500)
12 12
 end
13 13
 
14 14
 -- public functions
@@ -29,12 +29,14 @@ end
29 29
 function UITabBar:addTab(text, panel)
30 30
   if panel == nil then
31 31
     panel = createWidget(self:getStyleName() .. 'Panel')
32
+    panel:setId('tabPanel')
32 33
   end
33 34
 
34 35
   local tab = createWidget(self:getStyleName() .. 'Button', self)
35 36
   panel.isTab = true
36 37
   tab.tabPanel = panel
37 38
   tab.tabBar = self
39
+  tab:setId('tab')
38 40
   tab:setText(text)
39 41
   tab:setWidth(tab:getTextSize().width + tab:getPaddingLeft() + tab:getPaddingRight())
40 42
   tab.onClick = onTabClick
@@ -55,6 +57,9 @@ function UITabBar:removeTab(tab)
55 57
     self:selectPrevTab()
56 58
   end
57 59
   table.remove(self.tabs, index)
60
+  if tab.blinkEvent then
61
+    removeEvent(tab.blinkEvent)
62
+  end
58 63
   tab:destroy()
59 64
 end
60 65
 

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

@@ -81,11 +81,15 @@ function Battle.terminate()
81 81
   battleButton = nil
82 82
   battleWindow:destroy()
83 83
   battleWindow = nil
84
+  mouseWidget:destroy()
85
+  mouseWidget = nil
84 86
 
85 87
   disconnect(Creature, {  onSkullChange = Battle.checkCreatureSkull,
86 88
                           onEmblemChange = Battle.checkCreatureEmblem } )
87 89
 
88 90
   disconnect(g_game, {    onAttackingCreatureChange = Battle.onAttack } )
91
+
92
+  Battle = nil
89 93
 end
90 94
 
91 95
 function Battle.toggle()

+ 4
- 1
modules/game_battle/battle.otmod View File

@@ -5,10 +5,13 @@ Module
5 5
   website: https://github.com/edubart/otclient
6 6
   icon: battle.png
7 7
 
8
+  dependencies:
9
+    - game
10
+
8 11
   @onLoad: |
9 12
     dofile 'battle'
10 13
     Battle.init()
11 14
 
12
-  @onUnload:
15
+  @onUnload: |
13 16
     Battle.terminate()
14 17
 

+ 3
- 0
modules/game_combatcontrols/combatcontrols.otmod View File

@@ -4,6 +4,9 @@ Module
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient
6 6
 
7
+  dependencies:
8
+    - game
9
+
7 10
   @onLoad: |
8 11
     dofile 'combatcontrols'
9 12
     CombatControls.init()

+ 8
- 7
modules/game_console/console.lua View File

@@ -42,17 +42,18 @@ local SayModes = {
42 42
   [3] = { speakTypeDesc = 'yell', icon = '/core_styles/icons/yell.png' }
43 43
 }
44 44
 
45
+local MAX_HISTORY = 1000
46
+local MAX_LINES = 100
47
+
45 48
 local consolePanel
46 49
 local consoleContentPanel
47 50
 local consoleTabBar
48 51
 local consoleTextEdit
49 52
 local channels
50
-local messageHistory = { }
51
-local currentMessageIndex = 0
52
-local MaxHistory = 1000
53 53
 local channelsWindow
54
-local MAX_LINES = 100
55 54
 local ownPrivateName
55
+local messageHistory = {}
56
+local currentMessageIndex = 0
56 57
 
57 58
 -- private functions
58 59
 local function navigateMessageHistory(step)
@@ -252,9 +253,9 @@ function Console.terminate()
252 253
   consoleContentPanel = nil
253 254
   consoleTabBar = nil
254 255
 
255
-  Console = nil
256
-  
257 256
   ownPrivateName = nil
257
+
258
+  Console = nil
258 259
 end
259 260
 
260 261
 function Console.clear()
@@ -418,7 +419,7 @@ function Console.sendCurrentMessage()
418 419
   -- add new command to history
419 420
   currentMessageIndex = 0
420 421
   table.insert(messageHistory, originalMessage)
421
-  if #messageHistory > MaxHistory then
422
+  if #messageHistory > MAX_HISTORY then
422 423
     table.remove(messageHistory, 1)
423 424
   end
424 425
 

+ 1
- 1
modules/game_console/console.otmod View File

@@ -4,7 +4,7 @@ Module
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient
6 6
 
7
-  dependecies:
7
+  dependencies:
8 8
     - game
9 9
 
10 10
   @onLoad: |

+ 1
- 1
modules/game_containers/containers.otmod View File

@@ -4,7 +4,7 @@ Module
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient
6 6
 
7
-  dependecies:
7
+  dependencies:
8 8
     - game
9 9
 
10 10
   @onLoad: |

+ 2
- 0
modules/game_healthbar/healthbar.lua View File

@@ -63,6 +63,8 @@ function HealthBar.terminate()
63 63
   manaBar = nil
64 64
   healthLabel = nil
65 65
   manaLabel = nil
66
+
67
+  HealthBar = nil
66 68
 end
67 69
 
68 70
 function HealthBar.toggle()

+ 1
- 1
modules/game_healthbar/healthbar.otmod View File

@@ -4,7 +4,7 @@ Module
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient
6 6
 
7
-  dependecies:
7
+  dependencies:
8 8
     - game
9 9
 
10 10
   @onLoad: |

+ 2
- 0
modules/game_hotkeys/hotkeys_manager.lua View File

@@ -116,6 +116,8 @@ function HotkeysManager.terminate()
116 116
   hotkeysWindow = nil
117 117
   hotkeysButton:destroy()
118 118
   hotkeysButton = nil
119
+
120
+  HotkeysManager = nil
119 121
 end
120 122
 
121 123
 function HotkeysManager.toggle()

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

@@ -38,6 +38,8 @@ function Inventory.terminate()
38 38
   inventoryWindow = nil
39 39
   inventoryButton = nil
40 40
   inventoryPanel = nil
41
+
42
+  Inventory = nil
41 43
 end
42 44
 
43 45
 function Inventory.toggle()

+ 1
- 1
modules/game_inventory/inventory.otmod View File

@@ -4,7 +4,7 @@ Module
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient
6 6
 
7
-  dependecies:
7
+  dependencies:
8 8
     - game
9 9
 
10 10
   @onLoad: |

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

@@ -43,13 +43,15 @@ function Minimap.init()
43 43
 end
44 44
 
45 45
 function Minimap.terminate()
46
-  Keyboard.unbindKeyDown('Ctrl+M')
47 46
   disconnect(g_game, { onLogin = Minimap.reset })
47
+  Keyboard.unbindKeyDown('Ctrl+M')
48 48
 
49 49
   minimapWidget:destroy()
50 50
   minimapWidget = nil
51 51
   minimapButton:destroy()
52 52
   minimapButton = nil
53
+
54
+  Minimap = nil
53 55
 end
54 56
 
55 57
 function Minimap.toggle()

+ 2
- 2
modules/game_minimap/minimap.otmod View File

@@ -4,12 +4,12 @@ Module
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient
6 6
 
7
-  dependecies:
7
+  dependencies:
8 8
     - game
9 9
 
10 10
   @onLoad: |
11 11
     dofile 'minimap'
12 12
     Minimap.init()
13 13
 
14
-  @onUnload:
14
+  @onUnload: |
15 15
     Minimap.terminate()

+ 35
- 31
modules/game_npctrade/npctrade.lua View File

@@ -33,15 +33,15 @@ local WEIGHT_UNIT = 'oz'
33 33
 function NPCTrade.init()
34 34
   cacheItems = {}
35 35
   cacheGoods = {}
36
-  
36
+
37 37
   npcWindow = displayUI('npctrade.otui')
38 38
   npcWindow:setVisible(false)
39
-  
39
+
40 40
   itemsPanel = npcWindow:recursiveGetChildById('itemsPanel')
41 41
   buyTab = npcWindow:getChildById('buyTab')
42 42
   sellTab = npcWindow:getChildById('sellTab')
43 43
   searchText = npcWindow:getChildById('searchText')
44
-  
44
+
45 45
   setupPanel = npcWindow:recursiveGetChildById('setupPanel')
46 46
   quantityLabel = setupPanel:getChildById('quantity')
47 47
   quantityScroll = setupPanel:getChildById('quantityScroll')
@@ -51,13 +51,13 @@ function NPCTrade.init()
51 51
   weightLabel = setupPanel:getChildById('weight')
52 52
   capacityLabel = setupPanel:getChildById('capacity')
53 53
   setupButton = setupPanel:getChildById('setupButton')
54
-  
54
+
55 55
   radioTabs = RadioGroup.create()
56 56
   radioTabs:addWidget(buyTab)
57 57
   radioTabs:addWidget(sellTab)
58 58
   radioTabs:selectWidget(buyTab)
59 59
   radioTabs.onSelectionChange = NPCTrade.setList
60
-  
60
+
61 61
   connect(g_game, { onGameEnd = NPCTrade.hide,
62 62
                     onOpenNpcTrade = NPCTrade.onOpenNpcTrade,
63 63
                     onPlayerGoods = NPCTrade.onPlayerGoods,
@@ -73,7 +73,7 @@ function NPCTrade.terminate()
73 73
   buyButton = nil
74 74
   sellButton = nil
75 75
   searchText = nil
76
-  
76
+
77 77
   setupPanel = nil
78 78
   quantityLabel = nil
79 79
   quantityScroll = nil
@@ -84,14 +84,18 @@ function NPCTrade.terminate()
84 84
   capacityLabel = nil
85 85
   offerSelected = nil
86 86
   setupButton = nil
87
-  
87
+
88 88
   cacheItems = nil
89 89
   cacheGoods = nil
90
-  
90
+  buyTab = nil
91
+  sellTab = nil
92
+
91 93
   disconnect(g_game, {  onGameEnd = NPCTrade.hide,
92 94
                         onOpenNpcTrade = NPCTrade.onOpenNpcTrade,
93 95
                         onPlayerGoods = NPCTrade.onPlayerGoods,
94 96
                         onCloseNpcTrade = NPCTrade.onCloseNpcTrade } )
97
+
98
+  NPCTrade = nil
95 99
 end
96 100
 
97 101
 -- private functions
@@ -106,12 +110,12 @@ function NPCTrade.hide()
106 110
   npcWindow:hide()
107 111
 end
108 112
 
109
-function NPCTrade.setList(radioTabs, selected, deselected) 
113
+function NPCTrade.setList(radioTabs, selected, deselected)
110 114
   setupButton:setText(selected:getText())
111 115
   selected:setOn(true)
112 116
   deselected:setOn(false)
113 117
   NPCTrade.createItemsOnPanel()
114
-  
118
+
115 119
   NPCTrade.resetSetup()
116 120
   NPCTrade.refreshItemsPanel()
117 121
   NPCTrade.refreshFilters()
@@ -140,7 +144,7 @@ function NPCTrade.updateSetup()
140 144
         if cacheGoods[offerSelected[1]:getId()] then -- list might be empty.
141 145
           quantityScroll:setMaximum(math.max(0, math.min(100, cacheGoods[offerSelected[1]:getId()])))
142 146
         end
143
-      end 
147
+      end
144 148
     else
145 149
       NPCTrade.resetSetup()
146 150
     end
@@ -174,11 +178,11 @@ function NPCTrade.setItem(widget)
174 178
   weightLabel:setText(string.format('%.2f', offer[3]/100) .. ' ' .. WEIGHT_UNIT)
175 179
   priceLabel:setText(price .. ' ' .. CURRENCY)
176 180
   capacityLabel:setText(string.format('%.2f', freeCapacity) .. ' ' .. WEIGHT_UNIT)
177
-  
181
+
178 182
   quantityLabel:setText(1)
179 183
   quantityScroll:setValue(1)
180
-  NPCTrade.updateSetup()  
181
-  
184
+  NPCTrade.updateSetup()
185
+
182 186
   setupPanel:enable()
183 187
 end
184 188
 
@@ -186,7 +190,7 @@ function NPCTrade.setQuantity(quantity)
186 190
   if quantityLabel and offerSelected then
187 191
     local price = NPCTrade.getOfferPrice(offerSelected)
188 192
     quantityLabel:setText(quantity)
189
-    weightLabel:setText(string.format('%.2f', offerSelected[3]*quantity/100) .. ' ' .. WEIGHT_UNIT) 
193
+    weightLabel:setText(string.format('%.2f', offerSelected[3]*quantity/100) .. ' ' .. WEIGHT_UNIT)
190 194
     priceLabel:setText(price .. ' ' .. CURRENCY)
191 195
   end
192 196
 end
@@ -208,14 +212,14 @@ function NPCTrade.onOpenNpcTrade(items)
208 212
   -- item[5] = sellPrice
209 213
 
210 214
   cacheItems = items
211
-  
215
+
212 216
   NPCTrade.createItemsOnPanel()
213
-  
217
+
214 218
   NPCTrade.show()
215 219
 end
216 220
 
217 221
 function NPCTrade.switchBuyWithBackpack()
218
-  buyWithBackpack = not buyWithBackpack 
222
+  buyWithBackpack = not buyWithBackpack
219 223
   if offerSelected then
220 224
     priceLabel:setText(NPCTrade.getOfferPrice(offerSelected) .. ' ' .. CURRENCY)
221 225
   end
@@ -238,12 +242,12 @@ function NPCTrade.itemPopup(self, mousePosition, mouseButton)
238 242
   end
239 243
 end
240 244
 
241
-function NPCTrade.createItemsOnPanel()  
245
+function NPCTrade.createItemsOnPanel()
242 246
   local layout = itemsPanel:getLayout()
243 247
   layout:disableUpdates()
244
-  
248
+
245 249
   NPCTrade.resetSetup()
246
-  
250
+
247 251
   offerSelected = nil
248 252
   itemsPanel:destroyChildren()
249 253
 
@@ -251,7 +255,7 @@ function NPCTrade.createItemsOnPanel()
251 255
     radioItems:destroy()
252 256
   end
253 257
   radioItems = RadioGroup.create()
254
-  
258
+
255 259
   for i, v in pairs(cacheItems) do
256 260
     local price = NPCTrade.getOfferPrice(v)
257 261
     if price > 0 then
@@ -260,28 +264,28 @@ function NPCTrade.createItemsOnPanel()
260 264
       itemBox:getChildById('item'):setItem(v[1])
261 265
       itemBox:getChildById('nameLabel'):setText(v[2])
262 266
       itemBox:getChildById('weightLabel'):setText(string.format('%.2f', v[3]/100) .. ' ' .. WEIGHT_UNIT)
263
-      itemBox:getChildById('priceLabel'):setText(price .. ' ' .. CURRENCY)      
264
-      
267
+      itemBox:getChildById('priceLabel'):setText(price .. ' ' .. CURRENCY)
268
+
265 269
       itemBox.onMouseRelease = NPCTrade.itemPopup
266 270
       itemBox:getChildById('item').onMouseRelease = function (self, mousePosition, mouseButton) NPCTrade.itemPopup(itemBox, mousePosition, mouseButton) end
267
-      
271
+
268 272
       radioItems:addWidget(itemBox)
269 273
     end
270 274
   end
271
-  
275
+
272 276
   layout:enableUpdates()
273 277
   layout:update()
274 278
 end
275 279
 
276 280
 function NPCTrade.extraFilters(widget, showOnlyHolding)
277
-  if setupButton:getText() == tr('Sell') then    
281
+  if setupButton:getText() == tr('Sell') then
278 282
     if not showOnlyHolding or cacheGoods[widget.offer[1]:getId()] then
279 283
       return true
280 284
     else
281 285
       return false
282 286
     end
283 287
   end
284
-  
288
+
285 289
   return true
286 290
 end
287 291
 
@@ -332,16 +336,16 @@ end
332 336
 
333 337
 function NPCTrade.onPlayerGoods(money, goods)
334 338
   moneyGoods = money
335
-  
339
+
336 340
   moneyLabel:setText(money .. ' ' .. CURRENCY)
337 341
   local freeCapacity = g_game.getLocalPlayer():getFreeCapacity()
338 342
   capacityLabel:setText(string.format('%.2f', freeCapacity) .. ' ' .. WEIGHT_UNIT)
339
-  
343
+
340 344
   cacheGoods = {}
341 345
   for i,v in pairs(goods) do
342 346
     cacheGoods[v[1]:getId()] = v[2]
343 347
   end
344
-  
348
+
345 349
   NPCTrade.refreshItemsPanel()
346 350
   NPCTrade.updateSetup()
347 351
 end

+ 2
- 0
modules/game_outfit/outfit.lua View File

@@ -126,6 +126,8 @@ function Outfit.terminate()
126 126
   disconnect(g_game, { onOpenOutfitWindow = Outfit.create,
127 127
                        onGameEnd = Outfit.destroy })
128 128
   Outfit.destroy()
129
+
130
+  Outfit = nil
129 131
 end
130 132
 
131 133
 function Outfit.create(creature, outfitList)

+ 3
- 0
modules/game_outfit/outfit.otmod View File

@@ -4,6 +4,9 @@ Module
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient
6 6
 
7
+  dependencies:
8
+    - game
9
+
7 10
   @onLoad: |
8 11
     dofile 'outfit'
9 12
     Outfit.init()

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

@@ -59,6 +59,8 @@ function Skills.terminate()
59 59
   skillsButton = nil
60 60
   skillsWindow:destroy()
61 61
   skillsWindow = nil
62
+
63
+  Skills = nil
62 64
 end
63 65
 
64 66
 function Skills.toggle()

+ 3
- 0
modules/game_skills/skills.otmod View File

@@ -4,6 +4,9 @@ Module
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient
6 6
 
7
+  dependencies:
8
+    - game
9
+
7 10
   @onLoad: |
8 11
     dofile 'skills'
9 12
     Skills.init()

+ 1
- 1
modules/game_textmessage/textmessage.lua View File

@@ -131,5 +131,5 @@ end
131 131
 function TextMessage.displayDeadMessage()
132 132
   local advanceLabel = GameInterface.getMapPanel():recursiveGetChildById('centerAdvance')
133 133
   if advanceLabel:isVisible() then return end
134
-  TextMessage.displayEventAdvance('You are dead.')
134
+  TextMessage.displayEventAdvance(tr('You are dead.'))
135 135
 end

+ 1
- 1
modules/game_textmessage/textmessage.otmod View File

@@ -4,7 +4,7 @@ Module
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient
6 6
 
7
-  dependecies:
7
+  dependencies:
8 8
     - game
9 9
 
10 10
   @onLoad: |

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

@@ -26,6 +26,8 @@ function VipList.terminate()
26 26
   vipWindow = nil
27 27
   vipButton:destroy()
28 28
   vipButton = nil
29
+
30
+  VipList = nil
29 31
 end
30 32
 
31 33
 function VipList.clear()

+ 1
- 1
modules/game_viplist/viplist.otmod View File

@@ -8,5 +8,5 @@ Module
8 8
     dofile 'viplist'
9 9
     VipList.init()
10 10
 
11
-  @onUnload:
11
+  @onUnload: |
12 12
     VipList.terminate()

+ 5
- 3
src/framework/ui/uimanager.cpp View File

@@ -281,13 +281,15 @@ void UIManager::onWidgetDestroy(const UIWidgetPtr& widget)
281 281
 
282 282
     checkEvent = g_eventDispatcher.scheduleEvent([] {
283 283
         g_lua.collectGarbage();
284
-        g_eventDispatcher.addEvent([] {
284
+        UIWidgetList backupList = destroyedWidgets;
285
+        destroyedWidgets.clear();
286
+        g_eventDispatcher.scheduleEvent([backupList] {
285 287
             g_lua.collectGarbage();
286
-            for(const UIWidgetPtr& widget : destroyedWidgets) {
288
+            for(const UIWidgetPtr& widget : backupList) {
287 289
                 if(widget->getUseCount() != 1)
288 290
                     logWarning("widget '", widget->getId(), "' destroyed but still have ", widget->getUseCount()-1, " reference(s) left");
289 291
             }
290
-        });
292
+        }, 1);
291 293
     }, 1000);
292 294
 #endif
293 295
 }

Loading…
Cancel
Save