Browse Source

Changes/Fixes to Channels/Hotkeys/Inventory Slots.

- Fixed issue with opening multiple instances of the same message channels (will focus the channel if already exists).
- Added tooltip to the 'Clear message window' button.
- Added keyboard Up/Down press for hotkeys.
- Added inventory slots/images.
- Started on adding soul
BeniS 8 years ago
parent
commit
82233dc655

+ 15
- 1
modules/game/player.lua View File

@@ -1,5 +1,19 @@
1 1
 -- @docclass Player
2 2
 
3
+InventorySlotHead = 1
4
+InventorySlotNeck = 2
5
+InventorySlotBack = 3
6
+InventorySlotBody = 4
7
+InventorySlotRight = 5
8
+InventorySlotLeft = 6
9
+InventorySlotLeg = 7
10
+InventorySlotFeet = 8
11
+InventorySlotFinger = 9
12
+InventorySlotAmmo = 10
13
+
14
+InventorySlotFirst = 1
15
+InventorySlotLast = 10
16
+
3 17
 function Player:isPartyLeader()
4 18
   local shield = self:getShield()
5 19
   return (shield == ShieldWhiteYellow or
@@ -37,4 +51,4 @@ function Player:hasVip(creatureName)
37 51
     if (vip[1] == creatureName) then return true end
38 52
   end
39 53
   return false
40
-end
54
+end

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

@@ -118,18 +118,13 @@ local function onOpenChannel(channelId, channelName)
118 118
 end
119 119
 
120 120
 local function onOpenPrivateChannel(receiver)
121
-  local privateTab = Console.getTab(receiver)
122
-  if privateTab == nil then
123
-    channels[receiver] = receiver
124
-    Console.addTab(receiver, true)
125
-  end
121
+  Console.addPrivateChannel(receiver)
126 122
 end
127 123
 
128 124
 local function onOpenOwnPrivateChannel(channelId, channelName)
129 125
   local privateTab = Console.getTab(channelName)
130 126
   if privateTab == nil then
131
-    --channels[channelId] = channelName (this should be tested)
132
-    Console.addChannel(channelName, channelId, true)
127
+    Console.addChannel(channelName, channelId)
133 128
   end
134 129
   ownPrivateName = channelName
135 130
 end
@@ -302,7 +297,12 @@ function Console.openHelp()
302 297
 end
303 298
 
304 299
 function Console.addTab(name, focus)
305
-  local tab = consoleTabBar:addTab(name)
300
+  local tab = Console.getTab(name)
301
+  if(tab) then -- is channel already open
302
+    if(not focus) then focus = true end
303
+  else
304
+    tab = consoleTabBar:addTab(name)
305
+  end
306 306
   if focus then
307 307
     consoleTabBar:selectTab(tab)
308 308
   elseif name ~= tr('Server Log') then
@@ -348,6 +348,11 @@ function Console.addChannel(name, id)
348 348
   return tab
349 349
 end
350 350
 
351
+function Console.addPrivateChannel(receiver)
352
+  channels[receiver] = receiver
353
+  return Console.addTab(receiver, true)
354
+end
355
+
351 356
 function Console.addPrivateText(text, speaktype, name, isPrivateCommand, creatureName)
352 357
   local focus = false
353 358
   if speaktype.speakType == SpeakPrivateNpcToPlayer then

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

@@ -75,6 +75,7 @@ Panel
75 75
 
76 76
   TabButton
77 77
     id: clearChannelButton
78
+    !tooltip: tr('Clear current message window')
78 79
     icon: icons/clearchannel.png
79 80
     anchors.right: next.left
80 81
     anchors.top: parent.top

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

@@ -35,10 +35,13 @@ local hotkeyColors = {
35 35
 -- public functions
36 36
 function HotkeysManager.init()
37 37
   hotkeysWindow = g_ui.displayUI('hotkeys_manager.otui')
38
+  local hotkeyListPanel = hotkeysWindow:getChildById('currentHotkeys')
38 39
 
39 40
   hotkeysWindow:setVisible(false)
40 41
   hotkeysButton = TopMenu.addGameButton('hotkeysButton', tr('Hotkeys') .. ' (Ctrl+K)', '/game_hotkeys/icon.png', HotkeysManager.toggle)
41 42
   g_keyboard.bindKeyDown('Ctrl+K', HotkeysManager.toggle)
43
+  g_keyboard.bindKeyPress('Down', function() hotkeyListPanel:focusNextChild(KeyboardFocusReason) end, hotkeysWindow)
44
+  g_keyboard.bindKeyPress('Up', function() hotkeyListPanel:focusPreviousChild(KeyboardFocusReason) end, hotkeysWindow)
42 45
 
43 46
   currentHotkeysList = hotkeysWindow:getChildById('currentHotkeys')
44 47
   currentItemPreview = hotkeysWindow:getChildById('itemPreview')
@@ -102,6 +105,9 @@ function HotkeysManager.terminate()
102 105
   hotkeysManagerLoaded = false
103 106
 
104 107
   g_keyboard.unbindKeyDown('Ctrl+K')
108
+  g_keyboard.unbindKeyPress('Down', function() channelListPanel:focusNextChild(KeyboardFocusReason) end, channelsWindow)
109
+  g_keyboard.unbindKeyPress('Up', function() channelListPanel:focusPreviousChild(KeyboardFocusReason) end, channelsWindow)
110
+  
105 111
   HotkeysManager.save()
106 112
 
107 113
   currentHotkeysList = nil

+ 23
- 3
modules/game_inventory/inventory.lua View File

@@ -1,5 +1,19 @@
1 1
 Inventory = {}
2 2
 
3
+-- public variables
4
+InventorySlotStyles = {
5
+  [InventorySlotHead] = "HeadSlot",
6
+  [InventorySlotNeck] = "NeckSlot",
7
+  [InventorySlotBack] = "BackSlot",
8
+  [InventorySlotBody] = "BodySlot",
9
+  [InventorySlotRight] = "RightSlot",
10
+  [InventorySlotLeft] = "LeftSlot",
11
+  [InventorySlotLeg] = "LegSlot",
12
+  [InventorySlotFeet] = "FeetSlot",
13
+  [InventorySlotFinger] = "FingerSlot",
14
+  [InventorySlotAmmo] = "AmmoSlot"
15
+}
16
+
3 17
 -- private variables
4 18
 local inventoryWindow
5 19
 local inventoryPanel
@@ -39,7 +53,7 @@ end
39 53
 
40 54
 function Inventory.refresh()
41 55
   local player = g_game.getLocalPlayer()
42
-  for i=1,10 do
56
+  for i=InventorySlotFirst,InventorySlotLast do
43 57
     if player then
44 58
       Inventory.onInventoryChange(player, i, player:getInventoryItem(i))
45 59
     else
@@ -63,9 +77,15 @@ function Inventory.onMiniWindowClose()
63 77
 end
64 78
 
65 79
 -- hooked events
66
-function Inventory.onInventoryChange(player, slot, item)
80
+function Inventory.onInventoryChange(player, slot, item, oldItem)
67 81
   local itemWidget = inventoryPanel:getChildById('slot' .. slot)
68
-  itemWidget:setItem(item)
82
+  if(item) then
83
+    itemWidget:setStyle('Item')
84
+    itemWidget:setItem(item)
85
+  else
86
+    itemWidget:setStyle(InventorySlotStyles[slot])
87
+    itemWidget:setItem(nil)
88
+  end
69 89
 end
70 90
 
71 91
 function Inventory.onFreeCapacityChange(player, freeCapacity)

+ 66
- 27
modules/game_inventory/inventory.otui View File

@@ -1,3 +1,43 @@
1
+HeadSlot < Item
2
+  id: slot1
3
+  image-source: /game_inventory/slots/head.png
4
+
5
+BodySlot < Item
6
+  id: slot4
7
+  image-source: /game_inventory/slots/body.png
8
+
9
+LegSlot < Item
10
+  id: slot7
11
+  image-source: /game_inventory/slots/legs.png
12
+
13
+FeetSlot < Item
14
+  id: slot8
15
+  image-source: /game_inventory/slots/feet.png
16
+
17
+NeckSlot < Item
18
+  id: slot2
19
+  image-source: /game_inventory/slots/neck.png
20
+
21
+LeftSlot < Item
22
+  id: slot6
23
+  image-source: /game_inventory/slots/left-hand.png
24
+
25
+FingerSlot < Item
26
+  id: slot9
27
+  image-source: /game_inventory/slots/finger.png
28
+
29
+BackSlot < Item
30
+  id: slot3
31
+  image-source: /game_inventory/slots/back.png
32
+
33
+RightSlot < Item
34
+  id: slot5
35
+  image-source: /game_inventory/slots/right-hand.png
36
+
37
+AmmoSlot < Item
38
+  id: slot10
39
+  image-source: /game_inventory/slots/ammo.png
40
+
1 41
 MiniWindow
2 42
   id: inventoryWindow
3 43
   !text: tr('Inventory')
@@ -6,84 +46,74 @@ MiniWindow
6 46
   @onClose: Inventory.onMiniWindowClose()
7 47
   &save: true
8 48
 
9
-  MiniWindowContents
10
-    Item
49
+  MiniWindowContents    
50
+    HeadSlot
11 51
       // head
12
-      id: slot1
13 52
       anchors.top: parent.top
14 53
       anchors.horizontalCenter: parent.horizontalCenter
15 54
       margin-top: 4
16 55
       &position: {x=65535, y=1, z=0}
17 56
 
18
-    Item
19
-      // armor
20
-      id: slot4
57
+    BodySlot
58
+      // body
21 59
       anchors.top: prev.bottom
22 60
       anchors.horizontalCenter: prev.horizontalCenter
23 61
       margin-top: 5
24 62
       &position: {x=65535, y=4, z=0}
25 63
 
26
-    Item
64
+    LegSlot
27 65
       // legs
28
-      id: slot7
29 66
       anchors.top: prev.bottom
30 67
       anchors.horizontalCenter: prev.horizontalCenter
31 68
       margin-top: 5
32 69
       &position: {x=65535, y=7, z=0}
33 70
 
34
-    Item
71
+    FeetSlot
35 72
       // feet
36
-      id: slot8
37 73
       anchors.top: prev.bottom
38 74
       anchors.horizontalCenter: prev.horizontalCenter
39 75
       margin-top: 5
40 76
       &position: {x=65535, y=8, z=0}
41 77
 
42
-    Item
43
-      // necklace
44
-      id: slot2
78
+    NeckSlot
79
+      // neck
45 80
       anchors.top: parent.top
46 81
       anchors.right: slot1.left
47 82
       margin-top: 10
48 83
       margin-right: 5
49 84
       &position: {x=65535, y=2, z=0}
50 85
 
51
-    Item
52
-      // left
53
-      id: slot6
86
+    LeftSlot
87
+      // left hand
54 88
       anchors.top: prev.bottom
55 89
       anchors.horizontalCenter: prev.horizontalCenter
56 90
       margin-top: 5
57 91
       &position: {x=65535, y=6, z=0}
58 92
 
59
-    Item
60
-      // ring
61
-      id: slot9
93
+    FingerSlot
94
+      // finger
62 95
       anchors.top: prev.bottom
63 96
       anchors.horizontalCenter: prev.horizontalCenter
64 97
       margin-top: 5
65 98
       &position: {x=65535, y=9, z=0}
66 99
 
67
-    Item
68
-      // backpack
69
-      id: slot3
100
+    BackSlot
101
+      // back
70 102
       anchors.top: parent.top
71 103
       anchors.left: slot1.right
72 104
       margin-top: 10
73 105
       margin-left: 5
74 106
       &position: {x=65535, y=3, z=0}
75 107
 
76
-    Item
77
-      // right
78
-      id: slot5
108
+    RightSlot
109
+      // right hand
79 110
       anchors.top: prev.bottom
80 111
       anchors.horizontalCenter: prev.horizontalCenter
81 112
       margin-top: 5
82 113
       &position: {x=65535, y=5, z=0}
83 114
 
84
-    Item
115
+    AmmoSlot
85 116
       // ammo
86
-      id: slot10
87 117
       anchors.top: prev.bottom
88 118
       anchors.horizontalCenter: prev.horizontalCenter
89 119
       margin-top: 5
@@ -97,4 +127,13 @@ MiniWindow
97 127
       margin-top: 5
98 128
       text-align: center
99 129
       text-auto-resize: true
130
+      
131
+    GameLabel
132
+      id: soul
133
+      height: 30
134
+      anchors.top: slot9.bottom
135
+      anchors.left: slot9.left
136
+      margin-top: 5
137
+      text-align: center
138
+      text-auto-resize: true
100 139
 

BIN
modules/game_inventory/slots/ammo.png View File


BIN
modules/game_inventory/slots/back.png View File


BIN
modules/game_inventory/slots/body.png View File


BIN
modules/game_inventory/slots/feet.png View File


BIN
modules/game_inventory/slots/finger.png View File


BIN
modules/game_inventory/slots/head.png View File


BIN
modules/game_inventory/slots/left-hand.png View File


BIN
modules/game_inventory/slots/legs.png View File


BIN
modules/game_inventory/slots/neck.png View File


BIN
modules/game_inventory/slots/right-hand.png View File


+ 16
- 15
modules/game_minimap/minimap.lua View File

@@ -38,7 +38,7 @@ end
38 38
 -- public functions
39 39
 function Minimap.init()
40 40
   connect(g_game, { onGameStart = Minimap.reset,
41
-                    onForceWalk = Minimap.center } )
41
+                    onForceWalk = Minimap.center })
42 42
                     
43 43
   g_keyboard.bindKeyDown('Ctrl+M', Minimap.toggle)
44 44
 
@@ -78,7 +78,7 @@ end
78 78
 
79 79
 function Minimap.terminate()
80 80
   disconnect(g_game, { onGameStart = Minimap.reset,
81
-                       onForceWalk = Minimap.center } )
81
+                       onForceWalk = Minimap.center })
82 82
                        
83 83
   g_keyboard.unbindKeyDown('Ctrl+M')
84 84
 
@@ -104,19 +104,6 @@ function Minimap.onMiniWindowClose()
104 104
   minimapButton:setOn(false)
105 105
 end
106 106
 
107
-function Minimap.reset()
108
-  local player = g_game.getLocalPlayer()
109
-  if not player then return end
110
-  minimapWidget:followCreature(player)
111
-  minimapWidget:setZoom(DEFAULT_ZOOM)
112
-end
113
-
114
-function Minimap.center()
115
-  local player = g_game.getLocalPlayer()
116
-  if not player then return end
117
-  minimapWidget:followCreature(player)
118
-end
119
-
120 107
 function Minimap.isClickInRange(position, fromPosition, toPosition)
121 108
 	return (position.x >= fromPosition.x and position.y >= fromPosition.y and position.x <= toPosition.x and position.y <= toPosition.y)
122 109
 end
@@ -159,4 +146,18 @@ function Minimap.onButtonClick(id)
159 146
     pos.z = pos.z + 1
160 147
     minimapWidget:setCameraPosition(pos)
161 148
   end
149
+end
150
+
151
+-- hooked events
152
+function Minimap.reset()
153
+  local player = g_game.getLocalPlayer()
154
+  if not player then return end
155
+  minimapWidget:followCreature(player)
156
+  minimapWidget:setZoom(DEFAULT_ZOOM)
157
+end
158
+
159
+function Minimap.center()
160
+  local player = g_game.getLocalPlayer()
161
+  if not player then return end
162
+  minimapWidget:followCreature(player)
162 163
 end

Loading…
Cancel
Save