Browse Source

modules changes

* speedup widget destruction checks
* rework outfit module using grid layout and the new design
* fixes in console, terminal, textmessage modules
Eduardo Bart 9 years ago
parent
commit
33458a3e39
41 changed files with 339 additions and 237 deletions
  1. 1
    0
      modules/client_background/background.lua
  2. 2
    2
      modules/client_background/background.otui
  3. 2
    3
      modules/client_terminal/terminal.otui
  4. 16
    16
      modules/core_lib/widgets/uicombobox.lua
  5. 4
    4
      modules/core_lib/widgets/uiprogressbar.lua
  6. 15
    15
      modules/core_lib/widgets/uispinbox.lua
  7. 7
    0
      modules/game/game.otmod
  8. 1
    1
      modules/game/gameinterface.lua
  9. 1
    1
      modules/game/gameinterface.otui
  10. 1
    1
      modules/game_battle/battle.lua
  11. 2
    1
      modules/game_battle/battle.otmod
  12. 1
    3
      modules/game_combatcontrols/combatcontrols.lua
  13. 2
    2
      modules/game_combatcontrols/combatcontrols.otmod
  14. 47
    11
      modules/game_console/console.lua
  15. 13
    13
      modules/game_containers/containers.lua
  16. 2
    1
      modules/game_containers/containers.otmod
  17. 1
    1
      modules/game_healthbar/healthbar.lua
  18. 2
    1
      modules/game_healthbar/healthbar.otmod
  19. 1
    1
      modules/game_hotkeys/hotkeys_manager.lua
  20. 5
    5
      modules/game_hotkeys/hotkeys_manager.otmod
  21. 2
    2
      modules/game_interface/gameinterface.otmod
  22. 1
    1
      modules/game_inventory/inventory.lua
  23. 2
    1
      modules/game_inventory/inventory.otmod
  24. 112
    105
      modules/game_outfit/outfit.lua
  25. 7
    1
      modules/game_outfit/outfit.otmod
  26. 36
    19
      modules/game_outfit/outfit.otui
  27. 1
    1
      modules/game_skills/skills.lua
  28. 2
    1
      modules/game_skills/skills.otmod
  29. 2
    2
      modules/game_textmessage/textmessage.lua
  30. 1
    0
      modules/game_tibiafiles/.gitignore
  31. 1
    1
      modules/game_viplist/viplist.lua
  32. 2
    1
      modules/game_viplist/viplist.otmod
  33. 5
    5
      modules/old/game/game.lua
  34. 1
    1
      modules/old/game/thing.lua
  35. 2
    0
      src/framework/core/logger.cpp
  36. 4
    0
      src/framework/core/logger.h
  37. 0
    1
      src/framework/graphics/texture.cpp
  38. 25
    0
      src/framework/ui/uimanager.cpp
  39. 1
    0
      src/framework/ui/uimanager.h
  40. 2
    12
      src/framework/ui/uiwidget.cpp
  41. 4
    1
      src/otclient/luafunctions.cpp

+ 1
- 0
modules/client_background/background.lua View File

@@ -10,6 +10,7 @@ function Background.init()
10 10
 
11 11
   local clientVersionLabel = background:getChildById('clientVersionLabel')
12 12
   clientVersionLabel:setText('OTClient ' .. g_app.getVersion() .. '\n' ..
13
+                             'Rev  ' .. g_app.getBuildRevision() .. '\n' ..
13 14
                              'Built on ' .. g_app.getBuildDate())
14 15
 
15 16
   if not g_game.isOnline() then

+ 2
- 2
modules/client_background/background.otui View File

@@ -15,8 +15,8 @@ Panel
15 15
     background-color: #00000099
16 16
     anchors.right: parent.right
17 17
     anchors.bottom: parent.bottom
18
-    text-offset: 4 2
19
-    height: 32
18
+    text-align: center
19
+    height: 48
20 20
     width: 120
21 21
     color: #ffffff
22 22
     font: verdana-11px-monochrome

+ 2
- 3
modules/client_terminal/terminal.otui View File

@@ -2,12 +2,11 @@ TerminalLabel < UILabel
2 2
   font: terminus-14px-bold
3 3
   height: 16
4 4
 
5
-Panel
6
-  id: terminalPanel
5
+UIWidget
6
+  id: terminalWidget
7 7
   background-color: #000000
8 8
   opacity: 0.85
9 9
   anchors.fill: parent
10
-  @onEscape: Terminal.hide()
11 10
 
12 11
   Panel
13 12
     id: terminalBuffer

+ 16
- 16
modules/core_lib/widgets/uicombobox.lua View File

@@ -2,16 +2,16 @@ UIComboBox = extends(UIWidget)
2 2
 
3 3
 function UIComboBox.create()
4 4
   local combobox = UIComboBox.internalCreate()
5
-  combobox.m_options = {}
6
-  combobox.m_currentIndex = -1
5
+  combobox.options = {}
6
+  combobox.currentIndex = -1
7 7
   return combobox
8 8
 end
9 9
 
10 10
 function UIComboBox:setCurrentOption(text)
11
-  if not self.m_options then return end
12
-  for i,v in ipairs(self.m_options) do
13
-    if v.text == text and self.m_currentIndex ~= i then
14
-      self.m_currentIndex = i
11
+  if not self.options then return end
12
+  for i,v in ipairs(self.options) do
13
+    if v.text == text and self.currentIndex ~= i then
14
+      self.currentIndex = i
15 15
       self:setText(text)
16 16
       self:onOptionChange(text, v.data)
17 17
       return
@@ -20,24 +20,24 @@ function UIComboBox:setCurrentOption(text)
20 20
 end
21 21
 
22 22
 function UIComboBox:setCurrentIndex(index)
23
-  if index >= 1 and index <= #self.m_options then
24
-    local v = self.m_options[index]
25
-    self.m_currentIndex = index
23
+  if index >= 1 and index <= #self.options then
24
+    local v = self.options[index]
25
+    self.currentIndex = index
26 26
     self:setText(v.text)
27 27
     self:onOptionChange(v.text, v.data)
28 28
   end
29 29
 end
30 30
 
31 31
 function UIComboBox:addOption(text, data)
32
-  table.insert(self.m_options, { text = text, data = data })
33
-  local index = #self.m_options
32
+  table.insert(self.options, { text = text, data = data })
33
+  local index = #self.options
34 34
   if index == 1 then self:setCurrentOption(text) end
35 35
   return index
36 36
 end
37 37
 
38 38
 function UIComboBox:onMousePress(mousePos, mouseButton)
39 39
   local menu = createWidget(self:getStyleName() .. 'PopupMenu', self)
40
-  for i,v in ipairs(self.m_options) do
40
+  for i,v in ipairs(self.options) do
41 41
     menu:addOption(v.text, function() self:setCurrentOption(v.text) end)
42 42
   end
43 43
   menu:setWidth(self:getWidth())
@@ -48,10 +48,10 @@ function UIComboBox:onMousePress(mousePos, mouseButton)
48 48
 end
49 49
 
50 50
 function UIComboBox:onMouseWheel(mousePos, direction)
51
-  if direction == MouseWheelUp and self.m_currentIndex > 1 then
52
-    self:setCurrentIndex(self.m_currentIndex - 1)
53
-  elseif direction == MouseWheelDown and self.m_currentIndex < #self.m_options then
54
-    self:setCurrentIndex(self.m_currentIndex + 1)
51
+  if direction == MouseWheelUp and self.currentIndex > 1 then
52
+    self:setCurrentIndex(self.currentIndex - 1)
53
+  elseif direction == MouseWheelDown and self.currentIndex < #self.options then
54
+    self:setCurrentIndex(self.currentIndex + 1)
55 55
   end
56 56
   return true
57 57
 end

+ 4
- 4
modules/core_lib/widgets/uiprogressbar.lua View File

@@ -4,23 +4,23 @@ function UIProgressBar.create()
4 4
   local progressbar = UIProgressBar.internalCreate()
5 5
   progressbar:setFocusable(false)
6 6
   progressbar:setPhantom(true)
7
-  progressbar.m_percent = 0
7
+  progressbar.percent = 0
8 8
   progressbar:updateBackground()
9 9
   return progressbar
10 10
 end
11 11
 
12 12
 function UIProgressBar:setPercent(percent)
13
-  self.m_percent = math.max(math.min(percent, 100), 0)
13
+  self.percent = math.max(math.min(percent, 100), 0)
14 14
   self:updateBackground()
15 15
 end
16 16
 
17 17
 
18 18
 function UIProgressBar:getPercent()
19
-  return self.m_percent
19
+  return self.percent
20 20
 end
21 21
 
22 22
 function UIProgressBar:updateBackground()
23
-  local width = math.max((self.m_percent * self:getWidth())/100, 1)
23
+  local width = math.max((self.percent * self:getWidth())/100, 1)
24 24
   local height = self:getHeight()
25 25
   self:setBackgroundSize({width=width, height=height})
26 26
 end

+ 15
- 15
modules/core_lib/widgets/uispinbox.lua View File

@@ -3,54 +3,54 @@ UISpinBox = extends(UILineEdit)
3 3
 function UISpinBox.create()
4 4
   local spinbox = UISpinBox.internalCreate()
5 5
   spinbox:setValidCharacters('0123456789')
6
-  spinbox.m_minimum = 0
7
-  spinbox.m_maximum = 0
6
+  spinbox.minimum = 0
7
+  spinbox.maximum = 0
8 8
   spinbox:setCurrentIndex(0)
9 9
   spinbox:setText("0")
10 10
   return spinbox
11 11
 end
12 12
 
13 13
 function UISpinBox:setCurrentIndex(index)
14
-  if index >= self.m_minimum and index <= self.m_maximum then
14
+  if index >= self.minimum and index <= self.maximum then
15 15
     if self:getText():len() > 0 then
16 16
       self:setText(index)
17 17
     end
18
-    self.m_currentIndex = index
18
+    self.currentIndex = index
19 19
     self:onIndexChange(index)
20 20
   end
21 21
 end
22 22
 
23 23
 function UISpinBox:setMinimum(minimum)
24
-  if minimum > self.m_maximum then
24
+  if minimum > self.maximum then
25 25
     print("[UISpinBox:setMinimum]: minimum value cant be greater than maximum")
26 26
     return false
27 27
   end
28
-  if self.m_currentIndex < minimum then
28
+  if self.currentIndex < minimum then
29 29
     self:setCurrentIndex(minimum)
30 30
   end
31
-  self.m_minimum = minimum
31
+  self.minimum = minimum
32 32
 end
33 33
 
34 34
 function UISpinBox:setMaximum(maximum)
35
-  if maximum < self.m_minimum then
35
+  if maximum < self.minimum then
36 36
     print("[UISpinBox:setMaximum]: maximum value cant be lower than minimum")
37 37
     return false
38 38
   end
39
-  if self.m_currentIndex > maximum then
39
+  if self.currentIndex > maximum then
40 40
     self:setCurrentIndex(maximum)
41 41
   end
42
-  self.m_maximum = maximum
42
+  self.maximum = maximum
43 43
 end
44 44
 
45 45
 function UISpinBox:getCurrentIndex()
46
-  return self.m_currentIndex
46
+  return self.currentIndex
47 47
 end
48 48
 
49 49
 function UISpinBox:onMouseWheel(mousePos, direction)
50 50
   if direction == MouseWheelUp then
51
-    self:setCurrentIndex(self.m_currentIndex + 1)
51
+    self:setCurrentIndex(self.currentIndex + 1)
52 52
   elseif direction == MouseWheelDown then
53
-    self:setCurrentIndex(self.m_currentIndex - 1)
53
+    self:setCurrentIndex(self.currentIndex - 1)
54 54
   end
55 55
   return true
56 56
 end
@@ -58,12 +58,12 @@ end
58 58
 function UISpinBox:onTextChange(text, oldText)
59 59
 
60 60
   if text:len() == 0 then
61
-    self:setCurrentIndex(self.m_minimum)
61
+    self:setCurrentIndex(self.minimum)
62 62
     return
63 63
   end
64 64
 
65 65
   local number = tonumber(text)
66
-  if not number or number > self.m_maximum or number < self.m_minimum then
66
+  if not number or number > self.maximum or number < self.minimum then
67 67
     self:setText(oldText)
68 68
     return
69 69
   end

+ 7
- 0
modules/game/game.otmod View File

@@ -13,6 +13,13 @@ Module
13 13
   load-later:
14 14
     - game_textmessage
15 15
     - game_console
16
+    - game_outfit
17
+    //- game_healthbar
18
+    //- game_inventory
19
+    //- game_combatcontrols
20
+    //- game_skills
21
+    //- game_viplist
22
+    //- game_hotkeys
16 23
 
17 24
   @onLoad: |
18 25
     importStyle 'styles/items.otui'

+ 1
- 1
modules/game/gameinterface.lua View File

@@ -211,7 +211,7 @@ function GameInterface.processMouseAction(menuPosition, mouseButton, autoWalk, l
211 211
     return true
212 212
   end
213 213
 
214
-  if not Options.classicControl then
214
+  if not Options['classicControl'] then
215 215
     if keyboardModifiers == KeyboardNoModifier and mouseButton == MouseRightButton then
216 216
       GameInterface.createThingMenu(menuPosition, lookThing, useThing, creatureThing)
217 217
       return true

+ 1
- 1
modules/game/gameinterface.otui View File

@@ -26,7 +26,7 @@ UIWidget
26 26
 
27 27
   GameSidePanel
28 28
     id: gameLeftPanel
29
-    width: 190
29
+    width: 0
30 30
     layout: verticalBox
31 31
     anchors.left: parent.left
32 32
     anchors.top: parent.top

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

@@ -36,7 +36,7 @@ table.insert(lifeBarColors, {percentAbove = -1, color = '#4F0000' } )
36 36
 
37 37
 -- public functions
38 38
 function Battle.create()
39
-  battleWindow = displayUI('battle.otui', g_game.gameRightPanel)
39
+  battleWindow = displayUI('battle.otui', GameInterface.getRightPanel())
40 40
   battleWindow:hide()
41 41
   battleButton = TopMenu.addGameButton('battleButton', 'Battle (Ctrl+B)', '/game_battle/battle.png', Battle.toggle)
42 42
   Keyboard.bindKeyDown('Ctrl+B', Battle.toggle)

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

@@ -3,5 +3,6 @@ Module
3 3
   description: Manage battle window
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient
6
-  onLoad: |
6
+
7
+  @onLoad: |
7 8
     dofile 'battle'

+ 1
- 3
modules/game_combatcontrols/combatcontrols.lua View File

@@ -50,7 +50,7 @@ end
50 50
 function CombatControls.init()
51 51
   combatControlsButton = TopMenu.addGameButton('combatControlsButton', 'Combat Controls', 'combatcontrols.png', CombatControls.toggle)
52 52
   combatControlsButton:setOn(true)
53
-  combatControlsWindow = loadUI('combatcontrols.otui')
53
+  combatControlsWindow = loadUI('combatcontrols.otui', GameInterface.getRightPanel())
54 54
 
55 55
   fightOffensiveBox = combatControlsWindow:getChildById('fightOffensiveBox')
56 56
   fightBalancedBox = combatControlsWindow:getChildById('fightBalancedBox')
@@ -101,7 +101,6 @@ function CombatControls.terminate()
101 101
 end
102 102
 
103 103
 function CombatControls.online()
104
-  g_game.gameRightPanel:addChild(combatControlsWindow)
105 104
   combatControlsWindow:setVisible(combatControlsButton:isOn())
106 105
 
107 106
   local fightMode = g_game.getFightMode()
@@ -121,7 +120,6 @@ function CombatControls.online()
121 120
 end
122 121
 
123 122
 function CombatControls.offline()
124
-  g_game.gameRightPanel:removeChild(combatControlsWindow)
125 123
 end
126 124
 
127 125
 function CombatControls.toggle()

+ 2
- 2
modules/game_combatcontrols/combatcontrols.otmod View File

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

+ 47
- 11
modules/game_console/console.lua View File

@@ -50,6 +50,7 @@ local channels
50 50
 local messageHistory = { }
51 51
 local currentMessageIndex = 0
52 52
 local MaxHistory = 1000
53
+local channelsWindow
53 54
 
54 55
 -- private functions
55 56
 local function navigateMessageHistory(step)
@@ -67,7 +68,7 @@ end
67 68
 
68 69
 function applyMessagePrefixies(name, level, message)
69 70
   if name then
70
-    if Options.showLevelsInConsole and level > 0 then
71
+    if Options.getOption('showLevelsInConsole') and level > 0 then
71 72
       message = name .. ' [' .. level .. ']: ' .. message
72 73
     else
73 74
       message = name .. ': ' .. message
@@ -109,7 +110,7 @@ local function onOpenPrivateChannel(receiver)
109 110
   end
110 111
 end
111 112
 
112
-local function doChannelListSubmit(channelsWindow)
113
+local function doChannelListSubmit()
113 114
   local channelListPanel = channelsWindow:getChildById('channelList')
114 115
   local openPrivateChannelWith = channelsWindow:getChildById('openPrivateChannelWith'):getText()
115 116
   if openPrivateChannelWith ~= '' then
@@ -119,13 +120,16 @@ local function doChannelListSubmit(channelsWindow)
119 120
     if not selectedChannelLabel then return end
120 121
     g_game.joinChannel(selectedChannelLabel.channelId)
121 122
   end
123
+
122 124
   channelsWindow:destroy()
123 125
 end
124 126
 
125 127
 local function onChannelList(channelList)
126
-  local channelsWindow = displayUI('channelswindow.otui')
128
+  if channelsWindow then channelsWindow:destroy() end
129
+  channelsWindow = displayUI('channelswindow.otui')
127 130
   local channelListPanel = channelsWindow:getChildById('channelList')
128
-  channelsWindow.onEnter = function() doChannelListSubmit(channelsWindow) end
131
+  channelsWindow.onEnter = doChannelListSubmit
132
+  channelsWindow.onDestroy = function() channelsWindow = nil end
129 133
   Keyboard.bindKeyPress('Down', function() channelListPanel:focusNextChild(KeyboardFocusReason) end, channelsWindow)
130 134
   Keyboard.bindKeyPress('Up', function() channelListPanel:focusPreviousChild(KeyboardFocusReason) end, channelsWindow)
131 135
 
@@ -139,7 +143,7 @@ local function onChannelList(channelList)
139 143
       label:setText(channelName)
140 144
 
141 145
       label:setPhantom(false)
142
-      label.onDoubleClick = function() doChannelListSubmit(channelsWindow) end
146
+      label.onDoubleClick = doChannelListSubmit
143 147
     end
144 148
   end
145 149
 end
@@ -150,7 +154,8 @@ function Console.init()
150 154
   connect(g_game, { onCreatureSpeak = onCreatureSpeak,
151 155
                     onChannelList = onChannelList,
152 156
                     onOpenChannel = onOpenChannel,
153
-                    onOpenPrivateChannel = onOpenPrivateChannel})
157
+                    onOpenPrivateChannel = onOpenPrivateChannel,
158
+                    onGameEnd = Console.clean })
154 159
 
155 160
   consolePanel = displayUI('console.otui', GameInterface.getBottomPanel())
156 161
   consoleLineEdit = consolePanel:getChildById('consoleLineEdit')
@@ -182,15 +187,24 @@ function Console.terminate()
182 187
   disconnect(g_game, { onCreatureSpeak = onCreatureSpeak,
183 188
                        onChannelList = onChannelList,
184 189
                        onOpenChannel = onOpenChannel,
185
-                       onOpenPrivateChannel = onOpenPrivateChannel })
190
+                       onOpenPrivateChannel = onOpenPrivateChannel,
191
+                       onGameEnd = Console.clean })
186 192
 
187
-  for channelid, channelname in ipairs(channels) do
188
-    g_game.leaveChannel(channelid)
193
+  for channelid, channelname in pairs(channels) do
194
+    if channelid ~= 0 then
195
+      g_game.leaveChannel(channelid)
196
+    end
189 197
   end
198
+  channels = {}
190 199
 
191 200
   Keyboard.unbindKeyDown('Ctrl+O')
192 201
   Keyboard.unbindKeyDown('Ctrl+E')
193 202
 
203
+  if channelsWindow then
204
+    channelsWindow:destroy()
205
+    channelsWindow = nil
206
+  end
207
+
194 208
   consolePanel:destroy()
195 209
   consolePanel = nil
196 210
   consoleLineEdit = nil
@@ -200,6 +214,28 @@ function Console.terminate()
200 214
   Console = nil
201 215
 end
202 216
 
217
+function Console.debug()
218
+  print(#channels)
219
+end
220
+
221
+function Console.clean()
222
+  for channelid, channelname in pairs(channels) do
223
+    if channelid ~= 0 then
224
+      local tab = consoleTabBar:getTab(channelname)
225
+      consoleTabBar:removeTab(tab)
226
+    end
227
+  end
228
+  channels = {}
229
+
230
+  consoleTabBar:getTab('Default').tabPanel:destroyChildren()
231
+  consoleTabBar:getTab('Server Log').tabPanel:destroyChildren()
232
+
233
+  if channelsWindow then
234
+    channelsWindow:destroy()
235
+    channelsWindow = nil
236
+  end
237
+end
238
+
203 239
 function Console.setLineEditText(text)
204 240
   consoleLineEdit:setText(text)
205 241
 end
@@ -260,7 +296,7 @@ function Console.addPrivateText(text, speaktype, name, isPrivateCommand)
260 296
 
261 297
   local privateTab = Console.getTab(name)
262 298
   if privateTab == nil then
263
-    if Options.showPrivateMessagesInConsole or (isPrivateCommand and not privateTab) then
299
+    if Options['showPrivateMessagesInConsole'] or (isPrivateCommand and not privateTab) then
264 300
       privateTab = Console.getTab('Default')
265 301
     else
266 302
       privateTab = Console.addTab(name, focus)
@@ -280,7 +316,7 @@ function Console.addText(text, speaktype, tabName)
280 316
 end
281 317
 
282 318
 function Console.addTabText(text, speaktype, tab)
283
-  if Options.showTimestampsInConsole then
319
+  if Options['showTimestampsInConsole'] then
284 320
     text = os.date('%H:%M') .. ' ' .. text
285 321
   end
286 322
 

+ 13
- 13
modules/game_containers/containers.lua View File

@@ -1,16 +1,16 @@
1 1
 Containers = {}
2 2
 
3 3
 -- private variables
4
-local m_containers = {}
4
+local containers = {}
5 5
 
6 6
 -- public functions
7 7
 function Containers.clean()
8
-  m_containers = {}
8
+  containers = {}
9 9
 end
10 10
 
11 11
 function Containers.getFreeContainerId()
12 12
   for i=0,15 do
13
-    if not m_containers[i] then
13
+    if not containers[i] then
14 14
       return i
15 15
     end
16 16
   end
@@ -19,12 +19,12 @@ end
19 19
 
20 20
 -- hooked events
21 21
 function Containers.onOpenContainer(containerId, itemId, name, capacity, hasParent, items)
22
-  local container = m_containers[containerId]
22
+  local container = containers[containerId]
23 23
   if container then
24
-    g_game.gameRightPanel:removeChild(container)
24
+    GameInterface.getRightPanel():removeChild(container)
25 25
   end
26 26
 
27
-  container = displayUI('container.otui', g_game.gameRightPanel)
27
+  container = displayUI('container.otui', GameInterface.getRightPanel())
28 28
   name = name:sub(1,1):upper() .. name:sub(2)
29 29
   container:setText(name)
30 30
 
@@ -51,19 +51,19 @@ function Containers.onOpenContainer(containerId, itemId, name, capacity, hasPare
51 51
     end
52 52
   end
53 53
 
54
-  m_containers[containerId] = container
54
+  containers[containerId] = container
55 55
 end
56 56
 
57 57
 function Containers.onCloseContainer(containerId)
58
-  local container = m_containers[containerId]
58
+  local container = containers[containerId]
59 59
   if container then
60
-    g_game.gameRightPanel:removeChild(container)
60
+    GameInterface.getRightPanel():removeChild(container)
61 61
   end
62
-  m_containers[containerId] = nil
62
+  containers[containerId] = nil
63 63
 end
64 64
 
65 65
 function Containers.onContainerAddItem(containerId, item)
66
-  local container = m_containers[containerId]
66
+  local container = containers[containerId]
67 67
   if not container or not item or container.itemCount >= container.capacity then return end
68 68
 
69 69
   local i = container.itemCount
@@ -92,7 +92,7 @@ function Containers.onContainerAddItem(containerId, item)
92 92
 end
93 93
 
94 94
 function Containers.onContainerUpdateItem(containerId, slot, item)
95
-  local container = m_containers[containerId]
95
+  local container = containers[containerId]
96 96
   if not container then return end
97 97
 
98 98
   local itemWidget = container:getChildByIndex(slot + 1)
@@ -102,7 +102,7 @@ function Containers.onContainerUpdateItem(containerId, slot, item)
102 102
 end
103 103
 
104 104
 function Containers.onContainerRemoveItem(containerId, slot)
105
-  local container = m_containers[containerId]
105
+  local container = containers[containerId]
106 106
   if not container then return end
107 107
 
108 108
   local itemWidget = container:getChildByIndex(slot+1)

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

@@ -3,5 +3,6 @@ Module
3 3
   description: Manage containers
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient
6
-  onLoad: |
6
+
7
+  @onLoad: |
7 8
     dofile 'containers'

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

@@ -9,7 +9,7 @@ local manaLabel
9 9
 
10 10
 -- public functions
11 11
 function HealthBar.create()
12
-  healthBarWindow = displayUI('healthbar.otui', g_game.gameRightPanel)
12
+  healthBarWindow = displayUI('healthbar.otui', GameInterface.getRightPanel())
13 13
   healthBarButton = TopMenu.addGameButton('healthBarButton', 'Healh Bar', 'healthbar.png', HealthBar.toggle)
14 14
   healthBarButton:setOn(true)
15 15
   healthBar = healthBarWindow:getChildById('healthBar')

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

@@ -3,5 +3,6 @@ Module
3 3
   description: Displays health and mana points
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient
6
-  onLoad: |
6
+
7
+  @onLoad: |
7 8
     dofile 'healthbar'

+ 1
- 1
modules/game_hotkeys/hotkeys_manager.lua View File

@@ -37,7 +37,7 @@ function HotkeysManager.init()
37 37
   hotkeysWindow = displayUI('hotkeys_manager.otui')
38 38
 
39 39
   hotkeysWindow:setVisible(false)
40
-  hotkeysButton = TopMenu.addButton('hotkeysButton', 'Hotkeys (Ctrl+K)', '/game_hotkeys/icon.png', HotkeysManager.toggle)
40
+  hotkeysButton = TopMenu.addLeftButton('hotkeysButton', 'Hotkeys (Ctrl+K)', '/game_hotkeys/icon.png', HotkeysManager.toggle)
41 41
   Keyboard.bindKeyDown('Ctrl+K', HotkeysManager.toggle)
42 42
 
43 43
   currentHotkeysList = hotkeysWindow:getChildById('currentHotkeys')

+ 5
- 5
modules/game_hotkeys/hotkeys_manager.otmod View File

@@ -3,13 +3,13 @@ Module
3 3
   description: Manage client hotkeys
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient
6
-  
6
+
7 7
   dependencies:
8
-    - client_tibiafiles
9
-  
10
-  onLoad: |
8
+    - game
9
+
10
+  @onLoad: |
11 11
     dofile 'hotkeys_manager'
12 12
     HotkeysManager.init()
13 13
 
14
-  onUnload: |
14
+  @onUnload: |
15 15
     HotkeysManager.terminate()

+ 2
- 2
modules/game_interface/gameinterface.otmod View File

@@ -7,7 +7,7 @@ Module
7 7
   author: OTClient team
8 8
   website: https://github.com/edubart/otclient
9 9
 
10
-  onLoad: |
10
+  @onLoad: |
11 11
     dofile 'uiminiwindow'
12 12
     dofile 'uiminiwindowcontainer'
13 13
     dofile 'uiitem'
@@ -16,5 +16,5 @@ Module
16 16
 
17 17
     GameInterface.init()
18 18
 
19
-  onUnload: |
19
+  @onUnload: |
20 20
     GameInterface.terminate()

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

@@ -6,7 +6,7 @@ local inventoryButton
6 6
 
7 7
 -- public functions
8 8
 function Inventory.create()
9
-  inventoryWindow = displayUI('inventory.otui', g_game.gameRightPanel)
9
+  inventoryWindow = displayUI('inventory.otui', GameInterface.getRightPanel())
10 10
   inventoryButton = TopMenu.addGameButton('inventoryButton', 'Inventory (Ctrl+I)', 'inventory.png', Inventory.toggle)
11 11
   inventoryButton:setOn(true)
12 12
   Keyboard.bindKeyDown('Ctrl+I', Inventory.toggle)

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

@@ -3,5 +3,6 @@ Module
3 3
   description: View local player equipments window
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient
6
-  onLoad: |
6
+
7
+  @onLoad: |
7 8
     dofile 'inventory'

+ 112
- 105
modules/game_outfit/outfit.lua View File

@@ -1,84 +1,84 @@
1 1
 Outfit = {}
2 2
 
3 3
 -- private variables
4
-local window = nil
5
-local m_creature = nil
6
-local m_outfit = nil
7
-local m_outfits = nil
8
-local m_currentOutfit = 1
9
-local m_currentColor = nil
10
-local m_currentClothe = nil
4
+local outfitWindow
5
+local outfitCreature
6
+local outfit
7
+local outfits
8
+local currentOutfit = 1
9
+local currentColorBox
10
+local currentClotheButtonBox
11 11
 
12 12
 -- private functions
13 13
 local function onAddonCheckChange(addon, value)
14 14
   if addon:isChecked() then
15
-    m_outfit.addons = m_outfit.addons + value
15
+    outfit.addons = outfit.addons + value
16 16
   else
17
-    m_outfit.addons = m_outfit.addons - value
17
+    outfit.addons = outfit.addons - value
18 18
   end
19
-  m_creature:setOutfit(m_outfit)
19
+  outfitCreature:setOutfit(outfit)
20 20
 end
21 21
 
22
-local function onColorCheckChange(color)
23
-  if color == m_currentColor then
24
-    color.onCheckChange = nil
25
-    color:setChecked(true)
26
-    color.onCheckChange = onColorCheckChange
22
+local function onColorCheckChange(colorBox)
23
+  if colorBox == currentColorBox then
24
+    colorBox.onCheckChange = nil
25
+    colorBox:setChecked(true)
26
+    colorBox.onCheckChange = onColorCheckChange
27 27
   else
28
-    m_currentColor.onCheckChange = nil
29
-    m_currentColor:setChecked(false)
30
-    m_currentColor.onCheckChange = onColorCheckChange
31
-
32
-    m_currentColor = color
33
-
34
-    if m_currentClothe:getId() == 'head' then
35
-      m_outfit.head = m_currentColor.colorId
36
-    elseif m_currentClothe:getId() == 'primary' then
37
-      m_outfit.body = m_currentColor.colorId
38
-    elseif m_currentClothe:getId() == 'secondary' then
39
-      m_outfit.legs = m_currentColor.colorId
40
-    elseif m_currentClothe:getId() == 'detail' then
41
-      m_outfit.feet = m_currentColor.colorId
28
+    currentColorBox.onCheckChange = nil
29
+    currentColorBox:setChecked(false)
30
+    currentColorBox.onCheckChange = onColorCheckChange
31
+
32
+    currentColorBox = colorBox
33
+
34
+    if currentClotheButtonBox:getId() == 'head' then
35
+      outfit.head = currentColorBox.colorId
36
+    elseif currentClotheButtonBox:getId() == 'primary' then
37
+      outfit.body = currentColorBox.colorId
38
+    elseif currentClotheButtonBox:getId() == 'secondary' then
39
+      outfit.legs = currentColorBox.colorId
40
+    elseif currentClotheButtonBox:getId() == 'detail' then
41
+      outfit.feet = currentColorBox.colorId
42 42
     end
43 43
 
44
-    m_creature:setOutfit(m_outfit)
44
+    outfitCreature:setOutfit(outfit)
45 45
   end
46 46
 end
47 47
 
48
-local function onClotheCheckChange(clothe)
49
-  if clothe == m_currentClothe then
50
-    clothe.onCheckChange = nil
51
-    clothe:setChecked(true)
52
-    clothe.onCheckChange = onClotheCheckChange
48
+local function onClotheCheckChange(clotheButtonBox)
49
+  if clotheButtonBox == currentClotheButtonBox then
50
+    clotheButtonBox.onCheckChange = nil
51
+    clotheButtonBox:setChecked(true)
52
+    clotheButtonBox.onCheckChange = onClotheCheckChange
53 53
   else
54
-    m_currentClothe.onCheckChange = nil
55
-    m_currentClothe:setChecked(false)
56
-    m_currentClothe.onCheckChange = onClotheCheckChange
57
-
58
-    m_currentClothe = clothe
59
-
60
-    local color = 0
61
-    if m_currentClothe:getId() == 'head' then
62
-      color = m_outfit.head
63
-    elseif m_currentClothe:getId() == 'primary' then
64
-      color = m_outfit.body
65
-    elseif m_currentClothe:getId() == 'secondary' then
66
-      color = m_outfit.legs
67
-    elseif m_currentClothe:getId() == 'detail' then
68
-      color = m_outfit.feet
54
+    currentClotheButtonBox.onCheckChange = nil
55
+    currentClotheButtonBox:setChecked(false)
56
+    currentClotheButtonBox.onCheckChange = onClotheCheckChange
57
+
58
+    currentClotheButtonBox = clotheButtonBox
59
+
60
+    local colorId = 0
61
+    if currentClotheButtonBox:getId() == 'head' then
62
+      colorId = outfit.head
63
+    elseif currentClotheButtonBox:getId() == 'primary' then
64
+      colorId = outfit.body
65
+    elseif currentClotheButtonBox:getId() == 'secondary' then
66
+      colorId = outfit.legs
67
+    elseif currentClotheButtonBox:getId() == 'detail' then
68
+      colorId = outfit.feet
69 69
     end
70
-    window:getChildById('color' .. color):setChecked(true)
70
+    outfitWindow:recursiveGetChildById('colorBox' .. colorId):setChecked(true)
71 71
   end
72 72
 end
73 73
 
74 74
 local function update()
75
-  local nameWidget = window:getChildById('name')
76
-  nameWidget:setText(m_outfits[m_currentOutfit][2])
75
+  local nameWidget = outfitWindow:getChildById('outfitName')
76
+  nameWidget:setText(outfits[currentOutfit][2])
77 77
 
78
-  local availableAddons = m_outfits[m_currentOutfit][3]
79
-  local addon1 = window:getChildById('addon1')
80
-  local addon2 = window:getChildById('addon2')
81
-  local addon3 = window:getChildById('addon3')
78
+  local availableAddons = outfits[currentOutfit][3]
79
+  local addon1 = outfitWindow:getChildById('addon1')
80
+  local addon2 = outfitWindow:getChildById('addon2')
81
+  local addon3 = outfitWindow:getChildById('addon3')
82 82
   addon1:setChecked(false)
83 83
   addon2:setChecked(false)
84 84
   addon3:setChecked(false)
@@ -111,55 +111,63 @@ local function update()
111 111
     addon3:setEnabled(true)
112 112
   end
113 113
 
114
-  m_outfit.type = m_outfits[m_currentOutfit][1]
115
-  m_outfit.addons = 0
116
-  m_creature:setOutfit(m_outfit)
117
-
114
+  outfit.type = outfits[currentOutfit][1]
115
+  outfit.addons = 0
116
+  outfitCreature:setOutfit(outfit)
118 117
 end
119 118
 
120 119
 -- public functions
120
+function Outfit.init()
121
+  connect(g_game, { onOpenOutfitWindow = Outfit.create,
122
+                    onGameEnd = Outfit.destroy })
123
+end
124
+
125
+function Outfit.terminate()
126
+  disconnect(g_game, { onOpenOutfitWindow = Outfit.create,
127
+                       onGameEnd = Outfit.destroy })
128
+  Outfit.destroy()
129
+end
130
+
121 131
 function Outfit.create(creature, outfitList)
132
+  outfitCreature = creature
133
+  outfits = outfitList
122 134
   Outfit.destroy()
123
-  window = displayUI('outfit.otui')
124
-  window:lock()
125 135
 
126
-  m_outfit = creature:getOutfit()
136
+  outfitWindow = displayUI('outfit.otui')
137
+  --outfitWindow:lock()
127 138
 
128
-  m_currentClothe = window:getChildById('head')
129
-  window:getChildById('head').onCheckChange = onClotheCheckChange
130
-  window:getChildById('primary').onCheckChange = onClotheCheckChange
131
-  window:getChildById('secondary').onCheckChange = onClotheCheckChange
132
-  window:getChildById('detail').onCheckChange = onClotheCheckChange
139
+  outfit = outfitCreature:getOutfit()
133 140
 
134
-  local creatureWidget = window:getChildById('creature')
135
-  creatureWidget:setCreature(creature)
141
+  currentClotheButtonBox = outfitWindow:getChildById('head')
142
+  outfitWindow:getChildById('head').onCheckChange = onClotheCheckChange
143
+  outfitWindow:getChildById('primary').onCheckChange = onClotheCheckChange
144
+  outfitWindow:getChildById('secondary').onCheckChange = onClotheCheckChange
145
+  outfitWindow:getChildById('detail').onCheckChange = onClotheCheckChange
136 146
 
137
-  for i=0,18 do
138
-    for j=0,6 do
139
-      local color = createWidget('Color', window)
147
+  local outfitCreatureBox = outfitWindow:getChildById('outfitCreatureBox')
148
+  local colorBoxPanel = outfitWindow:getChildById('colorBoxPanel')
149
+  outfitCreatureBox:setCreature(outfitCreature)
150
+
151
+  for j=0,6 do
152
+    for i=0,18 do
153
+      local colorBox = createWidget('ColorBox', colorBoxPanel)
140 154
       local outfitColor = getOufitColor(j*19 + i)
141
-      color:setId('color' .. j*19+i)
142
-      color.colorId = j*19 + i
143
-      color:setImageColor(outfitColor)
144
-      color:setMarginTop(j * 3 + j * 14)
145
-      color:setMarginLeft(10 + i * 3 + i * 14)
146
-
147
-      if j*19 + i == m_outfit.head then
148
-        m_currentColor = color
149
-        color:setChecked(true)
150
-      end
155
+      colorBox:setImageColor(outfitColor)
156
+      colorBox:setId('colorBox' .. j*19+i)
157
+      colorBox.colorId = j*19 + i
151 158
 
152
-      color.onCheckChange = onColorCheckChange
159
+      if j*19 + i == outfit.head then
160
+        currentColorBox = colorBox
161
+        colorBox:setChecked(true)
162
+      end
163
+      colorBox.onCheckChange = onColorCheckChange
153 164
     end
154 165
   end
155 166
 
156
-  m_creature = creature
157
-  m_outfits = outfitList
158
-
159
-  m_currentOutfit = 1
167
+  currentOutfit = 1
160 168
   for i=1,#outfitList do
161
-    if outfitList[i][1] == m_outfit.type then
162
-      m_currentOutfit = i
169
+    if outfitList[i][1] == outfit.type then
170
+      currentOutfit = i
163 171
       break
164 172
     end
165 173
   end
@@ -168,35 +176,33 @@ function Outfit.create(creature, outfitList)
168 176
 end
169 177
 
170 178
 function Outfit.destroy()
171
-  if window ~= nil then
172
-    window:destroy()
173
-    window = nil
179
+  if outfitWindow then
180
+    outfitWindow:destroy()
181
+    outfitWindow = nil
182
+    outfitCreature = nil
183
+    currentColorBox = nil
184
+    currentClotheButtonBox = nil
174 185
   end
175 186
 end
176 187
 
177 188
 function Outfit.accept()
178
-  g_game.changeOutfit(m_outfit)
189
+  g_game.changeOutfit(outfit)
179 190
   Outfit.destroy()
180 191
 end
181 192
 
182 193
 function Outfit.nextType()
183
-  m_currentOutfit = m_currentOutfit + 1
184
-  if m_currentOutfit > #m_outfits then
185
-    m_currentOutfit = 1
194
+  currentOutfit = currentOutfit + 1
195
+  if currentOutfit > #outfits then
196
+    currentOutfit = 1
186 197
   end
187
-
188 198
   update()
189 199
 end
190 200
 
191 201
 function Outfit.previousType()
192
-  m_currentOutfit = m_currentOutfit - 1
193
-  if m_currentOutfit <= 0 then
194
-    m_currentOutfit = #m_outfits
202
+  currentOutfit = currentOutfit - 1
203
+  if currentOutfit <= 0 then
204
+    currentOutfit = #outfits
195 205
   end
196
-
197 206
   update()
198 207
 end
199 208
 
200
-connect(g_game, { onOpenOutfitWindow = Outfit.create,
201
-                onGameEnd = Outfit.destroy })

+ 7
- 1
modules/game_outfit/outfit.otmod View File

@@ -3,5 +3,11 @@ Module
3 3
   description: Change local player outfit
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient
6
-  onLoad: |
6
+  reloadable: true
7
+
8
+  @onLoad: |
7 9
     dofile 'outfit'
10
+    Outfit.init()
11
+
12
+  @onUnload: |
13
+    Outfit.terminate()

+ 36
- 19
modules/game_outfit/outfit.otui View File

@@ -1,7 +1,3 @@
1
-Color < ColorBox
2
-  anchors.top: head.top
3
-  anchors.left: head.right
4
-
5 1
 Window
6 2
   text: Select Outfit
7 3
   size: 550 280
@@ -14,7 +10,7 @@ Window
14 10
   @onEscape: Outfit.destroy()
15 11
 
16 12
   Label
17
-    id: name
13
+    id: outfitName
18 14
     text: Outfit Name
19 15
     width: 100
20 16
     anchors.top: parent.top
@@ -23,60 +19,81 @@ Window
23 19
     margin-left: 20
24 20
 
25 21
   Creature
26
-    id: creature
27
-    anchors.top: name.bottom
28
-    anchors.left: name.left
22
+    id: outfitCreatureBox
23
+    anchors.top: outfitName.bottom
24
+    anchors.left: outfitName.left
29 25
     margin-top: 5
30 26
     padding: 16 4 4 16
31 27
     fixed-creature-size: true
32 28
 
29
+  Panel
30
+    id: colorBoxPanel
31
+    anchors.top: parent.top
32
+    anchors.right: parent.right
33
+    margin-top: 54
34
+    margin-right: 20
35
+    width: 323
36
+    height: 119
37
+    layout:
38
+      type: grid
39
+      cell-size: 16 16
40
+      cell-spacing: 2
41
+      num-columns: 19
42
+      num-lines: 7
43
+
33 44
   ButtonBox
34 45
     id: head
35 46
     text: Head
36
-    anchors.top: creature.top
37
-    anchors.left: creature.right
47
+    anchors.top: outfitCreatureBox.top
48
+    anchors.left: outfitCreatureBox.right
38 49
     margin-left: 10
39 50
     checked: true
51
+    width: 90
40 52
 
41 53
   ButtonBox
42 54
     id: primary
43 55
     text: Primary
44 56
     anchors.top: prev.bottom
45 57
     anchors.left: prev.left
58
+    width: 90
46 59
 
47 60
   ButtonBox
48 61
     id: secondary
49 62
     text: Secondary
50 63
     anchors.top: prev.bottom
51 64
     anchors.left: prev.left
65
+    width: 90
52 66
 
53 67
   ButtonBox
54 68
     id: detail
55 69
     text: Detail
56 70
     anchors.top: prev.bottom
57 71
     anchors.left: prev.left
72
+    width: 90
58 73
 
59 74
   Button
75
+    id: outfitNextButton
60 76
     @onClick: Outfit.nextType()
61 77
     text: >>
62 78
     width: 32
63 79
     margin-top: 4
64
-    anchors.top: creature.bottom
65
-    anchors.right: creature.right
80
+    anchors.top: outfitCreatureBox.bottom
81
+    anchors.right: outfitCreatureBox.right
66 82
 
67 83
   Button
84
+    id: outfitPreviousButton
68 85
     @onClick: Outfit.previousType()
69 86
     text: <<
70 87
     width: 32
71 88
     margin-top: 4
72
-    anchors.top: creature.bottom
73
-    anchors.left: creature.left
89
+    anchors.top: outfitCreatureBox.bottom
90
+    anchors.left: outfitCreatureBox.left
74 91
 
75 92
   CheckBox
76 93
     id: addon1
77 94
     text: Addon 1
78 95
     enabled: false
79
-    margin-top: 10
96
+    margin-top: 6
80 97
     width: 100
81 98
     anchors.top: prev.bottom
82 99
     anchors.left: prev.left
@@ -85,7 +102,7 @@ Window
85 102
     id: addon2
86 103
     text: Addon 2
87 104
     enabled: false
88
-    margin-top: 10
105
+    margin-top: 2
89 106
     width: 100
90 107
     anchors.top: prev.bottom
91 108
     anchors.left: prev.left
@@ -94,7 +111,7 @@ Window
94 111
     id: addon3
95 112
     text: Addon 3
96 113
     enabled: false
97
-    margin-top: 10
114
+    margin-top: 2
98 115
     width: 100
99 116
     anchors.top: prev.bottom
100 117
     anchors.left: prev.left
@@ -108,7 +125,7 @@ Window
108 125
     margin-bottom: 10
109 126
 
110 127
   Button
111
-    id: buttonOk
128
+    id: outfitOkButton
112 129
     text: Ok
113 130
     width: 64
114 131
     anchors.right: next.left
@@ -118,7 +135,7 @@ Window
118 135
     @onClick: Outfit.accept()
119 136
 
120 137
   Button
121
-    id: buttonCancel
138
+    id: outfitCancelButton
122 139
     text: Cancel
123 140
     width: 64
124 141
     anchors.right: parent.right

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

@@ -42,7 +42,7 @@ end
42 42
 
43 43
 -- public functions
44 44
 function Skills.create()
45
-  skillsWindow = displayUI('skills.otui', g_game.gameRightPanel)
45
+  skillsWindow = displayUI('skills.otui', GameInterface.getRightPanel())
46 46
   skillsWindow:hide()
47 47
   skillsButton = TopMenu.addGameButton('skillsButton', 'Skills (Ctrl+S)', '/core_styles/icons/skills.png', Skills.toggle)
48 48
   Keyboard.bindKeyDown('Ctrl+S', Skills.toggle)

+ 2
- 1
modules/game_skills/skills.otmod View File

@@ -3,5 +3,6 @@ Module
3 3
   description: Manage skills window
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient
6
-  onLoad: |
6
+
7
+  @onLoad: |
7 8
     dofile 'skills'

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

@@ -24,7 +24,7 @@ local function displayMessage(msgtype, msg, time)
24 24
   if not g_game.isOnline() then return end
25 25
 
26 26
   if msgtype.consoleTab ~= nil then
27
-    if msgtype.consoleOption == nil or Options[msgtype.consoleOption] then
27
+    if msgtype.consoleOption == nil or Options.getOption(msgtype.consoleOption) then
28 28
       Console.addText(msg, msgtype, msgtype.consoleTab)
29 29
     end
30 30
   end
@@ -93,7 +93,7 @@ end
93 93
 function TextMessage.terminate()
94 94
   disconnect(g_game, { onDeath = TextMessage.displayDeadMessage,
95 95
                        onTextMessage = TextMessage.display,
96
-                       onGameStart = TextMessage.clearMessages })
96
+                       onGameEnd = TextMessage.clearMessages })
97 97
   centerTextMessagePanel:destroy()
98 98
   centerTextMessagePanel = nil
99 99
   bottomStatusLabel:destroy()

+ 1
- 0
modules/game_tibiafiles/.gitignore View File

@@ -0,0 +1 @@
1
+ 

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

@@ -7,7 +7,7 @@ local addVipWindow
7 7
 
8 8
 -- public functions
9 9
 function VipList.create()
10
-  vipWindow = displayUI('viplist.otui', g_game.gameRightPanel)
10
+  vipWindow = displayUI('viplist.otui', GameInterface.getRightPanel())
11 11
   vipWindow:hide()
12 12
   vipButton = TopMenu.addGameButton('vipListButton', 'VIP list', 'viplist.png', VipList.toggle)
13 13
 end

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

@@ -3,5 +3,6 @@ Module
3 3
   description: Manage vip list window
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient
6
-  onLoad: |
6
+
7
+  @onLoad: |
7 8
     dofile 'viplist'

+ 5
- 5
modules/old/game/game.lua View File

@@ -1,5 +1,5 @@
1 1
 -- private variables
2
-local m_mouseGrabberWidget
2
+local mouseGrabberWidget
3 3
 
4 4
 -- private functions
5 5
 local function onGameKeyPress(self, keyCode, keyboardModifiers)
@@ -41,7 +41,7 @@ end
41 41
 -- public functions
42 42
 function g_game.startUseWith(thing)
43 43
   g_game.selectedThing = thing
44
-  m_mouseGrabberWidget:grabMouse()
44
+  mouseGrabberWidget:grabMouse()
45 45
   Mouse.setTargetCursor()
46 46
 end
47 47
 
@@ -49,11 +49,11 @@ function g_game.createInterface()
49 49
 
50 50
   rootWidget:moveChildToIndex(g_game.gameUi, 1)
51 51
   g_game.gameMapPanel = g_game.gameUi:getChildById('gameMapPanel')
52
-  g_game.gameRightPanel = g_game.gameUi:getChildById('gameRightPanel')
52
+  GameInterface.getRightPanel() = g_game.gameUi:getChildById('gameRightPanel')
53 53
   g_game.gameBottomPanel = g_game.gameUi:getChildById('gameBottomPanel')
54
-  m_mouseGrabberWidget = g_game.gameUi:getChildById('mouseGrabber')
54
+  mouseGrabberWidget = g_game.gameUi:getChildById('mouseGrabber')
55 55
   connect(g_game.gameUi, { onKeyPress = onGameKeyPress })
56
-  connect(m_mouseGrabberWidget, { onMouseRelease = onUseWithMouseRelease })
56
+  connect(mouseGrabberWidget, { onMouseRelease = onUseWithMouseRelease })
57 57
 end
58 58
 
59 59
 function g_game.destroyInterface()

+ 1
- 1
modules/old/game/thing.lua View File

@@ -19,7 +19,7 @@ function g_game.processMouseAction(menuPosition, mouseButton, autoWalk, lookThin
19 19
     return true
20 20
   end
21 21
 
22
-  if not Options.classicControl then
22
+  if not Options.getOption('classicControl') then
23 23
     if keyboardModifiers == KeyboardNoModifier and mouseButton == MouseRightButton then
24 24
       g_game.createThingMenu(menuPosition, lookThing, useThing, creatureThing)
25 25
       return true

+ 2
- 0
src/framework/core/logger.cpp View File

@@ -44,6 +44,8 @@ void Logger::log(Fw::LogLevel level, const std::string& message)
44 44
 
45 45
     std::size_t now = std::time(NULL);
46 46
     m_logMessages.push_back(LogMessage(level, outmsg, now));
47
+    if(m_logMessages.size() > MAX_LOG_HISTORY)
48
+        m_logMessages.pop_front();
47 49
 
48 50
     if(m_onLog)
49 51
         m_onLog(level, outmsg, now);

+ 4
- 0
src/framework/core/logger.h View File

@@ -34,6 +34,10 @@ struct LogMessage {
34 34
 
35 35
 class Logger
36 36
 {
37
+    enum {
38
+        MAX_LOG_HISTORY = 1000
39
+    };
40
+
37 41
     typedef std::function<void(Fw::LogLevel, std::string, std::size_t)> OnLogCallback;
38 42
 
39 43
 public:

+ 0
- 1
src/framework/graphics/texture.cpp View File

@@ -171,7 +171,6 @@ void Texture::generateSoftwareMipmaps(std::vector<uint8> inPixels)
171 171
     Size outSize = inSize / 2;
172 172
     std::vector<uint8> outPixels(outSize.area()*4);
173 173
 
174
-    dump << "yeah";
175 174
     int mipmap = 1;
176 175
     while(true) {
177 176
         // this is a simple bilinear filtering algorithm, it combines every 4 pixels in one pixel

+ 25
- 0
src/framework/ui/uimanager.cpp View File

@@ -225,6 +225,31 @@ void UIManager::onWidgetDestroy(const UIWidgetPtr& widget)
225 225
         updateDraggingWidget(nullptr);
226 226
 }
227 227
 
228
+void UIManager::addDestroyedWidget(const UIWidgetPtr& widget)
229
+{
230
+    static UIWidgetList destroyedWidgets;
231
+    static ScheduledEventPtr checkEvent;
232
+
233
+    if(widget == m_rootWidget)
234
+        return;
235
+
236
+    destroyedWidgets.push_back(widget);
237
+
238
+    if(checkEvent && !checkEvent->isExecuted())
239
+        return;
240
+
241
+    checkEvent = g_eventDispatcher.scheduleEvent([] {
242
+        g_lua.collectGarbage();
243
+        g_eventDispatcher.addEvent([] {
244
+            g_lua.collectGarbage();
245
+            for(const UIWidgetPtr& widget : destroyedWidgets) {
246
+                if(widget->getUseCount() != 1)
247
+                    logWarning("widget '", widget->getId(), "' destroyed but still have ", widget->getUseCount()-1, " reference(s) left");
248
+            }
249
+        });
250
+    }, 1000);
251
+}
252
+
228 253
 bool UIManager::importStyle(const std::string& file)
229 254
 {
230 255
     try {

+ 1
- 0
src/framework/ui/uimanager.h View File

@@ -68,6 +68,7 @@ protected:
68 68
     void onWidgetAppear(const UIWidgetPtr& widget);
69 69
     void onWidgetDisappear(const UIWidgetPtr& widget);
70 70
     void onWidgetDestroy(const UIWidgetPtr& widget);
71
+    void addDestroyedWidget(const UIWidgetPtr& widget);
71 72
 
72 73
     friend class UIWidget;
73 74
 

+ 2
- 12
src/framework/ui/uiwidget.cpp View File

@@ -636,10 +636,8 @@ void UIWidget::destroy()
636 636
     g_ui.onWidgetDestroy(asUIWidget());
637 637
 
638 638
     // remove itself from parent
639
-    if(UIWidgetPtr parent = getParent()) {
640
-        assert(parent->hasChild(asUIWidget()));
639
+    if(UIWidgetPtr parent = getParent())
641 640
         parent->removeChild(asUIWidget());
642
-    }
643 641
 
644 642
     destroyChildren();
645 643
     m_focusedChild = nullptr;
@@ -649,15 +647,7 @@ void UIWidget::destroy()
649 647
     releaseLuaFieldsTable();
650 648
 
651 649
 #ifdef DEBUG
652
-    auto self = asUIWidget();
653
-    g_lua.collectGarbage();
654
-    if(self != g_ui.getRootWidget()) {
655
-        g_eventDispatcher.scheduleEvent([self] {
656
-            g_lua.collectGarbage();
657
-            if(self->getUseCount() != 1)
658
-                logWarning("widget '", self->getId(), "' destroyed but still have ", self->getUseCount()-1, " reference(s) left");
659
-        }, 500);
660
-    }
650
+    g_ui.addDestroyedWidget(asUIWidget());
661 651
 #endif
662 652
 }
663 653
 

+ 4
- 1
src/otclient/luafunctions.cpp View File

@@ -207,6 +207,7 @@ void OTClient::registerLuaFunctions()
207 207
     g_lua.bindClassMemberFunction<Creature>("setEmblemTexture", &Creature::setEmblemTexture);
208 208
     g_lua.bindClassMemberFunction<Creature>("showStaticSquare", &Creature::showStaticSquare);
209 209
     g_lua.bindClassMemberFunction<Creature>("hideStaticSquare", &Creature::hideStaticSquare);
210
+    g_lua.bindClassMemberFunction<Creature>("isWalking", &Creature::isWalking);
210 211
     g_lua.bindClassMemberFunction<Creature>("asMonster", &Creature::asMonster);
211 212
     g_lua.bindClassMemberFunction<Creature>("asNpc", &Creature::asNpc);
212 213
 
@@ -220,7 +221,9 @@ void OTClient::registerLuaFunctions()
220 221
     g_lua.registerClass<AnimatedText, Thing>();
221 222
 
222 223
     g_lua.registerClass<Player, Creature>();
223
-    g_lua.bindClassMemberFunction<Creature>("isWalking", &Creature::isWalking);
224
+    g_lua.bindClassMemberFunction<Player>("isPartyMember", &LocalPlayer::isPartyMember);
225
+    g_lua.bindClassMemberFunction<Player>("isPartyLeader", &LocalPlayer::isPartyLeader);
226
+    g_lua.bindClassMemberFunction<Player>("isPartySharedExperienceActive", &LocalPlayer::isPartySharedExperienceActive);
224 227
     g_lua.registerClass<Npc, Creature>();
225 228
     g_lua.registerClass<Monster, Creature>();
226 229
 

Loading…
Cancel
Save