Browse Source

restore inventory and healthbar

* make inventory/healthbar work again allowing reload
* changes in top menu toggle buttons
* all modules are now reloadable by default
* fix warning when using fade in
* remove some unused files
Eduardo Bart 9 years ago
parent
commit
239f58296e
41 changed files with 133 additions and 403 deletions
  1. 1
    0
      modules/client/client.otmod
  2. 0
    1
      modules/client_about/about.otmod
  3. 1
    0
      modules/client_background/background.lua
  4. 0
    1
      modules/client_background/background.otmod
  5. 0
    1
      modules/client_entergame/entergame.otmod
  6. 0
    3
      modules/client_modulemanager/modulemanager.otmod
  7. 0
    1
      modules/client_options/options.otmod
  8. 0
    1
      modules/client_terminal/terminal.otmod
  9. 5
    6
      modules/client_topmenu/topmenu.lua
  10. 0
    1
      modules/client_topmenu/topmenu.otmod
  11. 3
    2
      modules/client_topmenu/topmenu.otui
  12. 1
    0
      modules/core_lib/core_lib.otmod
  13. 26
    18
      modules/core_lib/ui/effects.lua
  14. 1
    0
      modules/core_styles/core_styles.otmod
  15. 7
    4
      modules/game/game.otmod
  16. 3
    3
      modules/game/gameinterface.lua
  17. 3
    1
      modules/game/gameinterface.otui
  18. 0
    0
      modules/game/player.lua
  19. 3
    0
      modules/game/styles/miniwindow.otui
  20. 1
    1
      modules/game/widgets/uiitem.lua
  21. 4
    3
      modules/game_console/console.lua
  22. 0
    1
      modules/game_console/console.otmod
  23. 15
    7
      modules/game_healthbar/healthbar.lua
  24. 7
    0
      modules/game_healthbar/healthbar.otmod
  25. 1
    1
      modules/game_healthbar/healthbar.otui
  26. 0
    196
      modules/game_interface/gameinterface.lua
  27. 0
    20
      modules/game_interface/gameinterface.otmod
  28. 0
    46
      modules/game_interface/gameinterface.otui
  29. 0
    56
      modules/game_interface/uimap.lua
  30. 26
    11
      modules/game_inventory/inventory.lua
  31. 8
    0
      modules/game_inventory/inventory.otmod
  32. 2
    5
      modules/game_inventory/inventory.otui
  33. 0
    1
      modules/game_outfit/outfit.otmod
  34. 2
    2
      modules/game_skills/skills.lua
  35. 4
    0
      modules/game_skills/skills.otmod
  36. 0
    1
      modules/game_textmessage/textmessage.otmod
  37. 1
    0
      modules/game_tibiafiles/tibiafiles.otmod
  38. 1
    1
      src/framework/core/module.cpp
  39. 3
    1
      src/otclient/core/container.h
  40. 0
    4
      src/otclient/core/player.h
  41. 4
    3
      src/otclient/luafunctions.cpp

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

@@ -5,6 +5,7 @@ Module
5 5
   website: https://github.com/edubart/otclient
6 6
   autoload: true
7 7
   autoload-priority: 100
8
+  reloadable: false
8 9
 
9 10
   load-later:
10 11
     - client_topmenu

+ 0
- 1
modules/client_about/about.otmod View File

@@ -3,7 +3,6 @@ Module
3 3
   description: Create the about window
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient
6
-  reloadable: true
7 6
 
8 7
   dependencies:
9 8
     - client_topmenu

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

@@ -25,6 +25,7 @@ function Background.terminate()
25 25
   disconnect(g_game, { onGameStart = Background.hide })
26 26
   disconnect(g_game, { onGameEnd = Background.show })
27 27
 
28
+  Effects.cancelFade(background:getChildById('clientVersionLabel'))
28 29
   background:destroy()
29 30
   background = nil
30 31
 

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

@@ -3,7 +3,6 @@ Module
3 3
   description: Handles the background of the login screen
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient
6
-  reloadable: true
7 6
 
8 7
   dependencies:
9 8
     - client_topmenu

+ 0
- 1
modules/client_entergame/entergame.otmod View File

@@ -3,7 +3,6 @@ Module
3 3
   description: Manages enter game and character list windows
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient
6
-  reloadable: true
7 6
 
8 7
   dependencies:
9 8
     - client_topmenu

+ 0
- 3
modules/client_modulemanager/modulemanager.otmod View File

@@ -3,9 +3,6 @@ Module
3 3
   description: Manage other modules
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient
6
-  reloadable: true
7
-  autoload: true
8
-  autoload-priority: 140
9 6
 
10 7
   dependencies:
11 8
     - client_topmenu

+ 0
- 1
modules/client_options/options.otmod View File

@@ -3,7 +3,6 @@ Module
3 3
   description: Create the options window
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient
6
-  reloadable: true
7 6
 
8 7
   dependencies:
9 8
     - client_topmenu

+ 0
- 1
modules/client_terminal/terminal.otmod View File

@@ -3,7 +3,6 @@ Module
3 3
   description: Terminal for executing lua functions
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient
6
-  reloadable: true
7 6
 
8 7
   @onLoad: |
9 8
     dofile 'terminal'

+ 5
- 6
modules/client_topmenu/topmenu.lua View File

@@ -19,12 +19,7 @@ local function addButton(id, description, icon, callback, panel, toggle)
19 19
   button:setId(id)
20 20
   button:setTooltip(description)
21 21
   button:setIcon(resolvepath(icon, 3))
22
-
23
-  if toggle then
24
-    button.onCheckChange = callback
25
-  else
26
-    button.onClick = callback
27
-  end
22
+  button.onClick = callback
28 23
   return button
29 24
 end
30 25
 
@@ -38,6 +33,10 @@ function TopMenu.init()
38 33
   leftButtonsPanel = topMenu:getChildById('leftButtonsPanel')
39 34
   rightButtonsPanel = topMenu:getChildById('rightButtonsPanel')
40 35
   gameButtonsPanel = topMenu:getChildById('gameButtonsPanel')
36
+
37
+  if g_game.isOnline() then
38
+    gameButtonsPanel:show()
39
+  end
41 40
 end
42 41
 
43 42
 function TopMenu.terminate()

+ 0
- 1
modules/client_topmenu/topmenu.otmod View File

@@ -3,7 +3,6 @@ Module
3 3
   description: Create the top menu
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient
6
-  reloadable: true
7 6
 
8 7
   @onLoad: |
9 8
     dofile 'topmenu'

+ 3
- 2
modules/client_topmenu/topmenu.otui View File

@@ -17,7 +17,7 @@ TopButton < UIButton
17 17
     image-color: #ffffff44
18 18
     icon-color: #ffffff44
19 19
 
20
-TopToggleButton < UICheckBox
20
+TopToggleButton < UIButton
21 21
   size: 26 26
22 22
   image-source: images/top_game_button.png
23 23
   image-clip: 26 0 26 26
@@ -25,7 +25,7 @@ TopToggleButton < UICheckBox
25 25
   image-border: 3
26 26
   icon-color: #ffffffff
27 27
 
28
-  $checked:
28
+  $on:
29 29
     image-clip: 0 0 26 26
30 30
     image-color: #ffffffff
31 31
     icon-color: #ffffffff
@@ -62,6 +62,7 @@ TopPanel
62 62
     anchors.bottom: parent.bottom
63 63
     anchors.left: prev.right
64 64
     anchors.right: next.left
65
+    visible: false
65 66
 
66 67
   TopMenuButtonsPanel
67 68
     id: rightButtonsPanel

+ 1
- 0
modules/core_lib/core_lib.otmod View File

@@ -5,6 +5,7 @@ Module
5 5
   website: https://github.com/edubart/otclient
6 6
   autoload: true
7 7
   autoload-priority: 10
8
+  reloadable: false
8 9
 
9 10
   @onLoad: |
10 11
     dofile 'ext/table'

+ 26
- 18
modules/core_lib/ui/effects.lua View File

@@ -1,26 +1,34 @@
1 1
 Effects = {}
2 2
 
3 3
 function Effects.fadeIn(widget, time, elapsed)
4
-    if not elapsed then elapsed = 0 end
5
-    if not time then time = 250 end
6
-    widget:setOpacity(math.min(elapsed/time, 1))
7
-    if elapsed < time then
8
-        scheduleEvent(function()
9
-                        Effects.fadeIn(widget, time, elapsed + 30)
10
-                      end, 30)
11
-    end
4
+  if not elapsed then elapsed = 0 end
5
+  if not time then time = 250 end
6
+  widget:setOpacity(math.min(elapsed/time, 1))
7
+  if elapsed < time then
8
+    removeEvent(widget.fadeEvent)
9
+    widget.fadeEvent = scheduleEvent(function()
10
+      Effects.fadeIn(widget, time, elapsed + 30)
11
+    end, 30)
12
+  else
13
+    widget.fadeEvent = nil
14
+  end
12 15
 end
13 16
 
14 17
 function Effects.fadeOut(widget, time, elapsed)
15
-    if not elapsed then elapsed = 0 end
16
-    if not time then time = 250 end
17
-    widget:setOpacity(math.max((time - elapsed)/time, 0))
18
-    if elapsed < time then
19
-        scheduleEvent(function()
20
-                        Effects.fadeOut(widget, time, elapsed + 30)
21
-                      end, 30)
22
-    else
23
-        widget:destroy()
24
-    end
18
+  if not elapsed then elapsed = 0 end
19
+  if not time then time = 250 end
20
+  widget:setOpacity(math.max((time - elapsed)/time, 0))
21
+  if elapsed < time then
22
+    removeEvent(widget.fadeEvent)
23
+    widget.fadeEvent = scheduleEvent(function()
24
+      Effects.fadeOut(widget, time, elapsed + 30)
25
+    end, 30)
26
+  else
27
+    widget.fadeEvent = nil
28
+    widget:destroy()
29
+  end
25 30
 end
26 31
 
32
+function Effects.cancelFade(widget)
33
+  removeEvent(widget.fadeEvent)
34
+end

+ 1
- 0
modules/core_styles/core_styles.otmod View File

@@ -5,6 +5,7 @@ Module
5 5
   website: https://github.com/edubart/otclient
6 6
   autoload: true
7 7
   autoload-priority: 20
8
+  reloadable: false
8 9
 
9 10
   @onLoad: |
10 11
     importFont 'fonts/verdana-11px-antialised'

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

@@ -3,7 +3,6 @@ Module
3 3
   description: Create the game interface, where the ingame stuff starts
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient
6
-  reloadable: true
7 6
 
8 7
   dependencies:
9 8
     - game_tibiafiles
@@ -14,8 +13,8 @@ Module
14 13
     - game_textmessage
15 14
     - game_console
16 15
     - game_outfit
17
-    //- game_healthbar
18
-    //- game_inventory
16
+    - game_healthbar
17
+    - game_inventory
19 18
     //- game_combatcontrols
20 19
     //- game_skills
21 20
     //- game_viplist
@@ -30,9 +29,13 @@ Module
30 29
     dofile 'const'
31 30
 
32 31
     dofile 'widgets/uigamemap'
32
+    dofile 'widgets/uiitem'
33 33
 
34
-    dofile 'gameinterface'
35 34
     dofile 'creature'
35
+    dofile 'player'
36
+
37
+    dofile 'gameinterface'
38
+
36 39
     GameInterface.init()
37 40
 
38 41
   @onUnload: |

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

@@ -105,7 +105,7 @@ function GameInterface.createThingMenu(menuPosition, lookThing, useThing, creatu
105 105
 
106 106
   if useThing then
107 107
     if useThing:isContainer() then
108
-      if useThing:isInsideContainer() then
108
+      if useThing:getParentContainer() then
109 109
         menu:addOption('Open', function() g_game.open(useThing, useThing:getContainerId()) end)
110 110
         menu:addOption('Open in new window', function() g_game.open(useThing, Containers.getFreeContainerId()) end)
111 111
       else
@@ -220,7 +220,7 @@ function GameInterface.processMouseAction(menuPosition, mouseButton, autoWalk, l
220 220
       return true
221 221
     elseif useThing and keyboardModifiers == KeyboardCtrlModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
222 222
       if useThing:isContainer() then
223
-        if useThing:isInsideContainer() then
223
+        if useThing:getParentContainer() then
224 224
           g_game.open(useThing, useThing:getContainerId())
225 225
           return true
226 226
         else
@@ -245,7 +245,7 @@ function GameInterface.processMouseAction(menuPosition, mouseButton, autoWalk, l
245 245
         g_game.attack(multiUseThing:asCreature())
246 246
         return true
247 247
       elseif multiUseThing:isContainer() then
248
-        if multiUseThing:isInsideContainer() then
248
+        if multiUseThing:getParentContainer() then
249 249
           g_game.open(multiUseThing, multiUseThing:getContainerId())
250 250
           return true
251 251
         else

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

@@ -33,8 +33,8 @@ UIWidget
33 33
     margin-bottom: 172
34 34
     height: 4
35 35
     margin-top: -2
36
-    background: red
37 36
     @canUpdateMargin: function(self, newMargin) return math.min(math.max(newMargin, 100), self:getParent():getHeight() - 300) end
37
+    @onGeometryChange: function(self) self:setMarginBottom(math.min(self:getParent():getHeight() - 300, self:getMarginBottom())) end
38 38
 
39 39
   GameBottomPanel
40 40
     id: gameBottomPanel
@@ -50,6 +50,7 @@ UIWidget
50 50
     anchors.right: parent.right
51 51
     anchors.top: parent.top
52 52
     anchors.bottom: parent.bottom
53
+    focusable: false
53 54
 
54 55
   GameSidePanel
55 56
     id: gameLeftPanel
@@ -58,6 +59,7 @@ UIWidget
58 59
     anchors.left: parent.left
59 60
     anchors.top: parent.top
60 61
     anchors.bottom: parent.bottom
62
+    focusable: false
61 63
 
62 64
   UIWidget
63 65
     id: mouseGrabber

modules/old/game/player.lua → modules/game/player.lua View File


+ 3
- 0
modules/game/styles/miniwindow.otui View File

@@ -18,3 +18,6 @@ MiniWindow < UIMiniWindow
18 18
   $on:
19 19
     height: 24
20 20
     image-border-bottom: 1
21
+
22
+BorderlessGameWindow < UIWindow
23
+  focusable: false

+ 1
- 1
modules/game/widgets/uiitem.lua View File

@@ -73,6 +73,6 @@ function UIItem:onMouseRelease(mousePosition, mouseButton)
73 73
 
74 74
   local item = self:getItem()
75 75
   if not item or not self:containsPoint(mousePosition) then return false end
76
-  return g_game.processMouseAction(mousePosition, mouseButton, nil, item, item, nil, item)
76
+  return GameInterface.processMouseAction(mousePosition, mouseButton, nil, item, item, nil, item)
77 77
 end
78 78
 

+ 4
- 3
modules/game_console/console.lua View File

@@ -155,7 +155,7 @@ function Console.init()
155 155
                     onChannelList = onChannelList,
156 156
                     onOpenChannel = onOpenChannel,
157 157
                     onOpenPrivateChannel = onOpenPrivateChannel,
158
-                    onGameEnd = Console.clean })
158
+                    onGameEnd = Console.clear })
159 159
 
160 160
   consolePanel = displayUI('console.otui', GameInterface.getBottomPanel())
161 161
   consoleLineEdit = consolePanel:getChildById('consoleLineEdit')
@@ -188,7 +188,7 @@ function Console.terminate()
188 188
                        onChannelList = onChannelList,
189 189
                        onOpenChannel = onOpenChannel,
190 190
                        onOpenPrivateChannel = onOpenPrivateChannel,
191
-                       onGameEnd = Console.clean })
191
+                       onGameEnd = Console.clear })
192 192
 
193 193
   for channelid, channelname in pairs(channels) do
194 194
     if channelid ~= 0 then
@@ -218,7 +218,7 @@ function Console.debug()
218 218
   print(#channels)
219 219
 end
220 220
 
221
-function Console.clean()
221
+function Console.clear()
222 222
   for channelid, channelname in pairs(channels) do
223 223
     if channelid ~= 0 then
224 224
       local tab = consoleTabBar:getTab(channelname)
@@ -229,6 +229,7 @@ function Console.clean()
229 229
 
230 230
   consoleTabBar:getTab('Default').tabPanel:destroyChildren()
231 231
   consoleTabBar:getTab('Server Log').tabPanel:destroyChildren()
232
+  consoleLineEdit:clearText()
232 233
 
233 234
   if channelsWindow then
234 235
     channelsWindow:destroy()

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

@@ -3,7 +3,6 @@ Module
3 3
   description: Manage chat window
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient
6
-  reloadable: true
7 6
 
8 7
   dependecies:
9 8
     - game

+ 15
- 7
modules/game_healthbar/healthbar.lua View File

@@ -8,17 +8,29 @@ local healthLabel
8 8
 local manaLabel
9 9
 
10 10
 -- public functions
11
-function HealthBar.create()
11
+function HealthBar.init()
12
+  connect(LocalPlayer, { onHealthChange = HealthBar.onHealthChange,
13
+                         onManaChange = HealthBar.onManaChange })
14
+
12 15
   healthBarWindow = displayUI('healthbar.otui', GameInterface.getRightPanel())
13
-  healthBarButton = TopMenu.addGameButton('healthBarButton', 'Healh Bar', 'healthbar.png', HealthBar.toggle)
16
+  healthBarButton = TopMenu.addGameToggleButton('healthBarButton', 'Healh Bar', 'healthbar.png', HealthBar.toggle)
14 17
   healthBarButton:setOn(true)
15 18
   healthBar = healthBarWindow:getChildById('healthBar')
16 19
   manaBar = healthBarWindow:getChildById('manaBar')
17 20
   healthLabel = healthBarWindow:getChildById('healthLabel')
18 21
   manaLabel = healthBarWindow:getChildById('manaLabel')
22
+
23
+  if g_game.isOnline() then
24
+    local localPlayer = g_game.getLocalPlayer()
25
+    HealthBar.onHealthChange(localPlayer, localPlayer:getHealth(), localPlayer:getMaxHealth())
26
+    HealthBar.onManaChange(localPlayer, localPlayer:getMana(), localPlayer:getMaxMana())
27
+  end
19 28
 end
20 29
 
21
-function HealthBar.destroy()
30
+function HealthBar.terminate()
31
+  disconnect(LocalPlayer, { onHealthChange = HealthBar.onHealthChange,
32
+                            onManaChange = HealthBar.onManaChange })
33
+
22 34
   healthBarWindow:destroy()
23 35
   healthBarWindow = nil
24 36
   healthBarButton:destroy()
@@ -53,7 +65,3 @@ function HealthBar.onManaChange(localPlayer, mana, maxMana)
53 65
   manaBar:setPercent(percent)
54 66
 end
55 67
 
56
-connect(g_game, { onGameStart = HealthBar.create,
57
-                onGameEnd = HealthBar.destroy })
58
-connect(LocalPlayer, { onHealthChange = HealthBar.onHealthChange,
59
-                       onManaChange = HealthBar.onManaChange })

+ 7
- 0
modules/game_healthbar/healthbar.otmod View File

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

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

@@ -32,7 +32,7 @@ ManaLabel < GameLabel
32 32
   margin-top: 2
33 33
   text: 0 / 0
34 34
 
35
-UIWindow
35
+BorderlessGameWindow
36 36
   id: healthManaPanel
37 37
   width: 192
38 38
   height: 34

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

@@ -1,199 +0,0 @@
1
-GameInterface = {}
2
-
3
-local WALK_AUTO_REPEAT_DELAY = 90
4
-local gameRootPanel
5
-local gameMapPanel
6
-local gameRightPanel
7
-local gameLeftPanel
8
-local gameBottomPanel
9
-
10
-function onGameStart()
11
-  -- hook window close event
12
-  setonclose(GameInterface.tryLogout)
13
-  GameInterface.show()
14
-end
15
-
16
-function onGameEnd()
17
-  setonclose(exit)
18
-  GameInterface.hide()
19
-end
20
-
21
-function GameInterface.init()
22
-  gameRootPanel = displayUI('gameinterface.otui')
23
-  gameRootPanel:lower()
24
-  connect(g_game, { onGameStart = onGameStart }, true)
25
-  connect(g_game, { onGameEnd = onGameEnd })
26
-
27
-  Keyboard.bindKeyPress('Up', function() g_game.walk(North) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
28
-  Keyboard.bindKeyPress('Right', function() g_game.walk(East) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
29
-  Keyboard.bindKeyPress('Down', function() g_game.walk(South) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
30
-  Keyboard.bindKeyPress('Left', function() g_game.walk(West) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
31
-  Keyboard.bindKeyPress('Numpad8', function() g_game.walk(North) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
32
-  Keyboard.bindKeyPress('Numpad9', function() g_game.walk(NorthEast) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
33
-  Keyboard.bindKeyPress('Numpad6', function() g_game.walk(East) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
34
-  Keyboard.bindKeyPress('Numpad3', function() g_game.walk(SouthEast) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
35
-  Keyboard.bindKeyPress('Numpad2', function() g_game.walk(South) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
36
-  Keyboard.bindKeyPress('Numpad1', function() g_game.walk(SouthWest) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
37
-  Keyboard.bindKeyPress('Numpad4', function() g_game.walk(West) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
38
-  Keyboard.bindKeyPress('Numpad7', function() g_game.walk(NorthWest) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
39
-  Keyboard.bindKeyPress('Ctrl+Up', function() g_game.turn(North) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
40
-  Keyboard.bindKeyPress('Ctrl+Right', function() g_game.turn(East) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
41
-  Keyboard.bindKeyPress('Ctrl+Down', function() g_game.turn(South) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
42
-  Keyboard.bindKeyPress('Ctrl+Left', function() g_game.turn(West) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
43
-  Keyboard.bindKeyPress('Ctrl+Numpad8', function() g_game.turn(North) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
44
-  Keyboard.bindKeyPress('Ctrl+Numpad6', function() g_game.turn(East) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
45
-  Keyboard.bindKeyPress('Ctrl+Numpad2', function() g_game.turn(South) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
46
-  Keyboard.bindKeyPress('Ctrl+Numpad4', function() g_game.turn(West) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
47
-  Keyboard.bindKeyPress('Esc', function() g_game.cancelAttackAndFollow() end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
48
-end
49
-
50
-function GameInterface.terminate()
51
-  disconnect(g_game, { onGameStart = onGameStart }, true)
52
-  disconnect(g_game, { onGameEnd = onGameEnd })
53
-end
54
-
55
-function GameInterface.show()
56
-  gameRootPanel:show()
57
-end
58
-
59
-function GameInterface.hide()
60
-  gameRootPanel:hide()
61
-end
62
-
63
-function GameInterface.tryLogout()
64
-  if g_game.isOnline() then
65
-    g_game.forceLogout()
66
-  else
67
-    exit()
68
-  end
69
-end
70
-
71
-function GameInterface.getRootPanel()
72
-  return gameRootPanel
73
-end
74
-
75
-function GameInterface.getMapPanel()
76
-  return gameMapPanel
77
-end
78
-
79
-function GameInterface.getRightPanel()
80
-  return gameRightPanel
81
-end
82
-
83
-function GameInterface.getLeftPanel()
84
-  return gameLeftPanel
85
-end
86
-
87
-function GameInterface.getBottomPanel()
88
-  return gameBottomPanel
89
-end
90
-
91
-function GameInterface.createThingMenu(menuPosition, lookThing, useThing, creatureThing)
92
-  local menu = createWidget('PopupMenu')
93
-
94
-  if lookThing then
95
-    menu:addOption('Look', function() g_game.look(lookThing) end)
96
-  end
97
-
98
-  if useThing then
99
-    if useThing:isContainer() then
100
-      if useThing:isInsideContainer() then
101
-        menu:addOption('Open', function() g_game.open(useThing, useThing:getContainerId()) end)
102
-        menu:addOption('Open in new window', function() g_game.open(useThing, Containers.getFreeContainerId()) end)
103
-      else
104
-        menu:addOption('Open', function() g_game.open(useThing, Containers.getFreeContainerId()) end)
105
-      end
106
-    else
107
-      if useThing:isMultiUse() then
108
-        menu:addOption('Use with ...', function() g_game.startUseWith(useThing) end)
109
-      else
110
-        menu:addOption('Use', function() g_game.use(useThing) end)
111
-      end
112
-    end
113
-
114
-    if useThing:isRotateable() then
115
-      menu:addOption('Rotate', function() g_game.rotate(useThing) end)
116
-    end
117
-
118
-  end
119
-
120
-  if lookThing and not lookThing:asCreature() and not lookThing:isNotMoveable() and lookThing:isPickupable() then
121
-    menu:addSeparator()
122
-    menu:addOption('Trade with ...', function() print('trade with') end)
123
-  end
124
-
125
-  -- check for move up
126
-
127
-  if creatureThing then
128
-    menu:addSeparator()
129
-
130
-    if creatureThing:asLocalPlayer() then
131
-      menu:addOption('Set Outfit', function() g_game.requestOutfit() end)
132
-
133
-      if creatureThing:asPlayer():isPartyMember() --[[and not fighting]] then
134
-        if creatureThing:asPlayer():isPartyLeader() then
135
-          if creatureThing:asPlayer():isPartySharedExperienceActive() then
136
-            menu:addOption('Disable Shared Experience', function() g_game.partyShareExperience(false) end)
137
-          else
138
-            menu:addOption('Enable Shared Experience', function() g_game.partyShareExperience(true) end)
139
-          end
140
-        end
141
-        menu:addOption('Leave Party', function() g_game.partyLeave() end)
142
-      end
143
-
144
-    else
145
-      local localPlayer = g_game.getLocalPlayer()
146
-      if localPlayer then
147
-        if g_game.getAttackingCreature() ~= creatureThing then
148
-          menu:addOption('Attack', function() g_game.attack(creatureThing) end)
149
-        else
150
-          menu:addOption('Stop Attack', function() g_game.cancelAttack() end)
151
-        end
152
-
153
-        if g_game.getFollowingCreature() ~= creatureThing then
154
-          menu:addOption('Follow', function() g_game.follow(creatureThing) end)
155
-        else
156
-          menu:addOption('Stop Follow', function() g_game.cancelFollow() end)
157
-        end
158
-
159
-        if creatureThing:asPlayer() then
160
-          menu:addSeparator()
161
-          menu:addOption('Message to ' .. creatureThing:getName(), function() print('message') end)
162
-          menu:addOption('Add to VIP list', function() g_game.addVip(creatureThing:getName()) end)
163
-
164
-          local localPlayerShield = localPlayer:asCreature():getShield()
165
-          local creatureShield = creatureThing:getShield()
166
-
167
-          if localPlayerShield == ShieldNone or localPlayerShield == ShieldWhiteBlue then
168
-            if creatureShield == ShieldWhiteYellow then
169
-              menu:addOption('Join ' .. creatureThing:getName() .. '\'s Party', function() g_game.partyJoin(creatureThing:getId()) end)
170
-            else
171
-              menu:addOption('Invite to Party', function() g_game.partyInvite(creatureThing:getId()) end)
172
-            end
173
-          elseif localPlayerShield == ShieldWhiteYellow then
174
-            if creatureShield == ShieldWhiteBlue then
175
-              menu:addOption('Revoke ' .. creatureThing:getName() .. '\'s Invitation', function() g_game.partyRevokeInvitation(creatureThing:getId()) end)
176
-            end
177
-          elseif localPlayerShield == ShieldYellow or localPlayerShield == ShieldYellowSharedExp or localPlayerShield == ShieldYellowNoSharedExpBlink or localPlayerShield == ShieldYellowNoSharedExp then
178
-            if creatureShield == ShieldWhiteBlue then
179
-              menu:addOption('Revoke ' .. creatureThing:getName() .. '\'s Invitation', function() g_game.partyRevokeInvitation(creatureThing:getId()) end)
180
-            elseif creatureShield == ShieldBlue or creatureShield == ShieldBlueSharedExp or creatureShield == ShieldBlueNoSharedExpBlink or creatureShield == ShieldBlueNoSharedExp then
181
-              menu:addOption('Pass Leadership to ' .. creatureThing:getName(), function() g_game.partyPassLeadership(creatureThing:getId()) end)
182
-            else
183
-              menu:addOption('Invite to Party', function() g_game.partyInvite(creatureThing:getId()) end)
184
-            end
185
-          end
186
-        end
187
-      end
188
-    end
189
-
190
-    menu:addSeparator()
191
-    menu:addOption('Copy Name', function() g_window.setClipboardText(creatureThing:getName()) end)
192
-
193
-  end
194
-
195
-  menu:display(menuPosition)
196
-end

+ 0
- 20
modules/game_interface/gameinterface.otmod View File

@@ -1,20 +0,0 @@
1
-Module
2
-  name: game_interface
3
-  description: |
4
-    Create the game main interface (map and bottom/left/right panels),
5
-    any game module must use it to add ingame interfaces
6
-
7
-  author: OTClient team
8
-  website: https://github.com/edubart/otclient
9
-
10
-  @onLoad: |
11
-    dofile 'uiminiwindow'
12
-    dofile 'uiminiwindowcontainer'
13
-    dofile 'uiitem'
14
-    dofile 'uimap'
15
-    dofile 'gameinterface'
16
-
17
-    GameInterface.init()
18
-
19
-  @onUnload: |
20
-    GameInterface.terminate()

+ 0
- 46
modules/game_interface/gameinterface.otui View File

@@ -1,46 +0,0 @@
1
-GameSidePanel < UIMiniWindowContainer
2
-  image-source: images/sidepanel.png
3
-  image-border: 4
4
-
5
-GameBottomPanel < Panel
6
-  image-source: images/bottompanel.png
7
-  image-border: 4
8
-
9
-GameMapPanel < UIMap
10
-  padding: 4
11
-  image-source: images/mappanel.png
12
-  image-border: 4
13
-
14
-UIGame
15
-  id: gameRootPanel
16
-  anchors.fill: parent
17
-  anchors.top: topMenu.bottom
18
-
19
-  GameSidePanel
20
-    id: gameRightPanel
21
-    width: 190
22
-    layout: verticalBox
23
-    anchors.right: parent.right
24
-    anchors.top: parent.top
25
-    anchors.bottom: parent.bottom
26
-
27
-  GameBottomPanel
28
-    id: gameBottomPanel
29
-    height: 170
30
-    anchors.left: parent.left
31
-    anchors.right: gameRightPanel.left
32
-    anchors.bottom: parent.bottom
33
-
34
-  GameMapPanel
35
-    id: gameMapPanel
36
-    anchors.left: parent.left
37
-    anchors.right: gameRightPanel.left
38
-    anchors.top: parent.top
39
-    anchors.bottom: gameBottomPanel.top
40
-    focusable: false
41
-
42
-  UIWidget
43
-    id: mouseGrabber
44
-    focusable: false
45
-    visible: false
46
-

+ 0
- 56
modules/game_interface/uimap.lua View File

@@ -1,56 +0,0 @@
1
-function UIMap:onDragEnter(mousePos)
2
-  local tile = self:getTile(mousePos)
3
-  if not tile then return false end
4
-
5
-  local thing = tile:getTopMoveThing()
6
-  if not thing then return false end
7
-
8
-  self.parsed = false
9
-  self.currentDragThing = thing
10
-  Mouse.setTargetCursor()
11
-  return true
12
-end
13
-
14
-function UIMap:onDragLeave(droppedWidget, mousePos)
15
-  if not self.parsed then
16
-    self.currentDragThing = nil
17
-  end
18
-
19
-  Mouse.restoreCursor()
20
-  return true
21
-end
22
-
23
-function UIMap:onDrop(widget, mousePos)
24
-  if not widget or not widget.currentDragThing then return false end
25
-
26
-  local tile = self:getTile(mousePos)
27
-  if not tile then return false end
28
-
29
-  local count = widget.currentDragThing:getCount()
30
-  if widget.currentDragThing:isStackable() and count > 1 then
31
-    widget.parsed = true
32
-    local moveWindow = displayUI('/game/movewindow.otui')
33
-    local spinbox = moveWindow:getChildById('spinbox')
34
-    spinbox:setMaximum(count)
35
-    spinbox:setMinimum(1)
36
-    spinbox:setCurrentIndex(count)
37
-
38
-    local okButton = moveWindow:getChildById('buttonOk')
39
-    okButton.onClick = function()
40
-                         g_game.move(widget.currentDragThing, tile:getPosition(), spinbox:getCurrentIndex())
41
-                         okButton:getParent():destroy()
42
-                         widget.currentDragThing = nil
43
-                       end
44
-    moveWindow.onEnter = okButton.onClick
45
-  else
46
-    g_game.move(widget.currentDragThing, tile:getPosition(), 1)
47
-  end
48
-
49
-  return true
50
-end
51
-
52
-function UIMap:onMouseRelease(mousePosition, mouseButton)
53
-  local tile = self:getTile(mousePosition)
54
-  if tile and g_game.processMouseAction(mousePosition, mouseButton, nil, tile:getTopLookThing(), tile:getTopUseThing(), tile:getTopCreature(), tile:getTopMultiUseThing()) then return true end
55
-  return false
56
-end

+ 26
- 11
modules/game_inventory/inventory.lua View File

@@ -5,15 +5,31 @@ local inventoryWindow
5 5
 local inventoryButton
6 6
 
7 7
 -- public functions
8
-function Inventory.create()
8
+function Inventory.init()
9
+  connect(g_game, { onGameEnd = Inventory.clear,
10
+                    onInventoryChange = Inventory.onInventoryChange,
11
+                    onFreeCapacityChange = Inventory.onFreeCapacityChange,
12
+                    onSoulChange = Inventory.onSoulChange })
13
+
14
+  Keyboard.bindKeyDown('Ctrl+I', Inventory.toggle)
15
+
9 16
   inventoryWindow = displayUI('inventory.otui', GameInterface.getRightPanel())
10
-  inventoryButton = TopMenu.addGameButton('inventoryButton', 'Inventory (Ctrl+I)', 'inventory.png', Inventory.toggle)
17
+  inventoryButton = TopMenu.addGameToggleButton('inventoryButton', 'Inventory (Ctrl+I)', 'inventory.png', Inventory.toggle)
11 18
   inventoryButton:setOn(true)
12
-  Keyboard.bindKeyDown('Ctrl+I', Inventory.toggle)
19
+
20
+  if g_game.isOnline() then
21
+    Inventory.reload()
22
+  end
13 23
 end
14 24
 
15
-function Inventory.destroy()
25
+function Inventory.terminate()
26
+  connect(g_game, { onGameEnd = Inventory.clear,
27
+                    onInventoryChange = Inventory.onInventoryChange,
28
+                    onFreeCapacityChange = Inventory.onFreeCapacityChange,
29
+                    onSoulChange = Inventory.onSoulChange })
30
+
16 31
   Keyboard.unbindKeyDown('Ctrl+I')
32
+
17 33
   inventoryWindow:destroy()
18 34
   inventoryWindow = nil
19 35
   inventoryButton:destroy()
@@ -26,6 +42,12 @@ function Inventory.toggle()
26 42
   inventoryButton:setOn(visible)
27 43
 end
28 44
 
45
+function Inventory.clear()
46
+end
47
+
48
+function Inventory.reload()
49
+end
50
+
29 51
 -- hooked events
30 52
 function Inventory.onInventoryChange(slot, item)
31 53
   local itemWidget = inventoryWindow:getChildById('slot' .. slot)
@@ -41,10 +63,3 @@ function Inventory.onSoulChange(soul)
41 63
   local widget = inventoryWindow:getChildById('soul')
42 64
   widget:setText("Soul:\n" .. soul)
43 65
 end
44
-
45
-connect(g_game, { onGameStart = Inventory.create,
46
-                onGameEnd = Inventory.destroy,
47
-                onInventoryChange = Inventory.onInventoryChange,
48
-                onFreeCapacityChange = Inventory.onFreeCapacityChange,
49
-                onSoulChange = Inventory.onSoulChange })
50
-

+ 8
- 0
modules/game_inventory/inventory.otmod View File

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

+ 2
- 5
modules/game_inventory/inventory.otui View File

@@ -1,4 +1,5 @@
1
-UIWindow
1
+BorderlessGameWindow
2
+  id: inventoryWindow
2 3
   width: 192
3 4
   height: 154
4 5
   margin-top: 10
@@ -93,9 +94,7 @@ UIWindow
93 94
     anchors.left: slot9.left
94 95
     anchors.right: slot9.right
95 96
     margin-top: 5
96
-
97 97
     text-align: center
98
-
99 98
     image-source: /core_styles/styles/images/panel_flat.png
100 99
     image-border: 1
101 100
 
@@ -106,9 +105,7 @@ UIWindow
106 105
     anchors.left: slot10.left
107 106
     anchors.right: slot10.right
108 107
     margin-top: 5
109
-
110 108
     text-align: center
111
-
112 109
     image-source: /core_styles/styles/images/panel_flat.png
113 110
     image-border: 1
114 111
 

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

@@ -3,7 +3,6 @@ Module
3 3
   description: Change local player outfit
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient
6
-  reloadable: true
7 6
 
8 7
   @onLoad: |
9 8
     dofile 'outfit'

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

@@ -41,14 +41,14 @@ local function setSkillPercent(id, percent, tooltip)
41 41
 end
42 42
 
43 43
 -- public functions
44
-function Skills.create()
44
+function Skills.init()
45 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)
49 49
 end
50 50
 
51
-function Skills.destroy()
51
+function Skills.terminate()
52 52
   Keyboard.unbindKeyDown('Ctrl+S')
53 53
   skillsButton:destroy()
54 54
   skillsButton = nil

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

@@ -6,3 +6,7 @@ Module
6 6
 
7 7
   @onLoad: |
8 8
     dofile 'skills'
9
+    Skills.init()
10
+
11
+  @onUnload: |
12
+    Skills.terminate()

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

@@ -3,7 +3,6 @@ Module
3 3
   description: Manage game text messages
4 4
   author: OTClient team
5 5
   website: https://github.com/edubart/otclient
6
-  reloadable: true
7 6
 
8 7
   dependecies:
9 8
     - game

+ 1
- 0
modules/game_tibiafiles/tibiafiles.otmod View File

@@ -1,6 +1,7 @@
1 1
 Module
2 2
   name: game_tibiafiles
3 3
   description: Contains tibia spr and dat
4
+  reloadable: false
4 5
 
5 6
   @onLoad: |
6 7
     if not g_thingsType.load('/game_tibiafiles/Tibia.dat') then

+ 1
- 1
src/framework/core/module.cpp View File

@@ -108,7 +108,7 @@ void Module::discover(const OTMLNodePtr& moduleNode)
108 108
     m_website = moduleNode->valueAt("website", none);
109 109
     m_version = moduleNode->valueAt("version", none);
110 110
     m_autoLoad = moduleNode->valueAt<bool>("autoload", false);
111
-    m_reloadable = moduleNode->valueAt<bool>("reloadable", false);
111
+    m_reloadable = moduleNode->valueAt<bool>("reloadable", true);
112 112
     m_autoLoadPriority = moduleNode->valueAt<int>("autoload-priority", 9999);
113 113
 
114 114
     if(OTMLNodePtr node = moduleNode->get("dependencies")) {

+ 3
- 1
src/otclient/core/container.h View File

@@ -25,7 +25,9 @@
25 25
 
26 26
 #include "declarations.h"
27 27
 
28
-class Container
28
+#include <framework/luascript/luaobject.h>
29
+
30
+class Container : public LuaObject
29 31
 {
30 32
 public:
31 33
     Container();

+ 0
- 4
src/otclient/core/player.h View File

@@ -31,10 +31,6 @@ public:
31 31
     Player() { }
32 32
     virtual ~Player() { }
33 33
 
34
-    bool isPartyMember() { return (m_shield != 0); }
35
-    bool isPartyLeader() { return (m_shield & Otc::ShieldYellow); } 
36
-    bool isPartySharedExperienceActive() { return false; }
37
-
38 34
     PlayerPtr asPlayer() { return std::static_pointer_cast<Player>(shared_from_this()); }
39 35
 };
40 36
 

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

@@ -25,6 +25,7 @@
25 25
 #include <otclient/luascript/luavaluecasts.h>
26 26
 #include <otclient/core/game.h>
27 27
 #include <otclient/core/tile.h>
28
+#include <otclient/core/container.h>
28 29
 #include <otclient/core/item.h>
29 30
 #include <otclient/core/effect.h>
30 31
 #include <otclient/core/missile.h>
@@ -161,6 +162,8 @@ void OTClient::registerLuaFunctions()
161 162
 
162 163
     g_lua.registerClass<ProtocolGame, Protocol>();
163 164
 
165
+    g_lua.registerClass<Container>();
166
+
164 167
     g_lua.registerClass<Thing>();
165 168
     g_lua.bindClassMemberFunction<Thing>("setId", &Thing::setId);
166 169
     g_lua.bindClassMemberFunction<Thing>("setPosition", &Thing::setPosition);
@@ -192,6 +195,7 @@ void OTClient::registerLuaFunctions()
192 195
     g_lua.bindClassMemberFunction<Thing>("isHookSouth", &Thing::isHookSouth);
193 196
     g_lua.bindClassMemberFunction<Thing>("isTranslucent", &Thing::isTranslucent);
194 197
     g_lua.bindClassMemberFunction<Thing>("isFullGround", &Thing::isFullGround);
198
+    g_lua.bindClassMemberFunction<Thing>("getParentContainer", &Thing::getParentContainer);
195 199
 
196 200
     g_lua.registerClass<Creature, Thing>();
197 201
     g_lua.bindClassMemberFunction<Creature>("getId", &Creature::getId);
@@ -221,9 +225,6 @@ void OTClient::registerLuaFunctions()
221 225
     g_lua.registerClass<AnimatedText, Thing>();
222 226
 
223 227
     g_lua.registerClass<Player, Creature>();
224
-    g_lua.bindClassMemberFunction<Player>("isPartyMember", &LocalPlayer::isPartyMember);
225
-    g_lua.bindClassMemberFunction<Player>("isPartyLeader", &LocalPlayer::isPartyLeader);
226
-    g_lua.bindClassMemberFunction<Player>("isPartySharedExperienceActive", &LocalPlayer::isPartySharedExperienceActive);
227 228
     g_lua.registerClass<Npc, Creature>();
228 229
     g_lua.registerClass<Monster, Creature>();
229 230
 

Loading…
Cancel
Save