Browse Source

Many changes

* IMPORTANT: dat/spr should now be placed in /data/things/
* Rename game_tibiafiles to game_things
* Make battle list algorithm much faster
* Split UITabBar into UITabBar and UIMoveableTabBar
* Fix other minor issues
Eduardo Bart 8 years ago
parent
commit
71cccac3da

+ 1
- 1
data/styles/10-buttons.otui View File

@@ -24,7 +24,7 @@ TabButton < UIButton
24 24
   image-source: /images/ui/tabbutton_rounded
25 25
   image-color: white
26 26
   image-clip: 0 0 20 20
27
-  image-border: 2
27
+  image-border: 1
28 28
   icon-color: white
29 29
   color: #aaaaaa
30 30
 

+ 1
- 1
data/styles/10-checkboxes.otui View File

@@ -48,7 +48,7 @@ ButtonBox < UICheckBox
48 48
   image-source: /images/ui/tabbutton_rounded
49 49
   image-color: white
50 50
   image-clip: 0 0 20 20
51
-  image-border: 2
51
+  image-border: 3
52 52
 
53 53
   $hover !disabled:
54 54
     image-clip: 0 20 20 20

+ 42
- 14
data/styles/20-tabbars.otui View File

@@ -1,18 +1,57 @@
1
+MoveableTabBar < UIMoveableTabBar
2
+  size: 80 20
3
+MoveableTabBarPanel < Panel
4
+MoveableTabBarButton < UIButton
5
+  size: 20 20
6
+  image-source: /images/ui/tabbutton_square
7
+  image-color: white
8
+  image-clip: 0 0 20 20
9
+  image-border: 3
10
+  icon-color: white
11
+  color: #aaaaaa
12
+  anchors.top: parent.top
13
+  anchors.left: parent.left
14
+  padding: 5
15
+
16
+  $hover !checked:
17
+    image-clip: 0 20 20 20
18
+    color: white
19
+
20
+  $disabled:
21
+    image-color: #ffffff66
22
+    icon-color: #888888
23
+
24
+  $checked:
25
+    image-clip: 0 40 20 20
26
+    color: #D8E7F0
27
+
28
+  $on !checked:
29
+    color: #F55E5E
30
+
1 31
 TabBar < UITabBar
2 32
   size: 80 20
33
+  Panel
34
+    id: buttonsPanel
35
+    anchors.fill: parent
3 36
 TabBarPanel < Panel
4 37
 TabBarButton < UIButton
5 38
   size: 20 20
6 39
   image-source: /images/ui/tabbutton_square
7 40
   image-color: white
8 41
   image-clip: 0 0 20 20
9
-  image-border: 2
42
+  image-border: 3
10 43
   icon-color: white
11 44
   color: #aaaaaa
12 45
   anchors.top: parent.top
13
-  anchors.left: parent.left
14 46
   padding: 5
15 47
 
48
+  $first:
49
+    anchors.left: parent.left
50
+
51
+  $!first:
52
+    anchors.left: prev.right
53
+    margin-left: 5
54
+
16 55
   $hover !checked:
17 56
     image-clip: 0 20 20 20
18 57
     color: white
@@ -23,7 +62,7 @@ TabBarButton < UIButton
23 62
 
24 63
   $checked:
25 64
     image-clip: 0 40 20 20
26
-    color: #D8E7F0
65
+    color: #80c7f8
27 66
 
28 67
   $on !checked:
29 68
     color: #F55E5E
@@ -35,7 +74,6 @@ TabBarRoundedButton < TabBarButton
35 74
 
36 75
 TabBarVertical < UITabBar
37 76
   width: 96
38
-
39 77
   ScrollableFlatPanel
40 78
     id: buttonsPanel
41 79
     anchors.top: parent.top
@@ -43,7 +81,6 @@ TabBarVertical < UITabBar
43 81
     anchors.right: scrollBar.left
44 82
     anchors.bottom: parent.bottom
45 83
     vertical-scrollbar: scrollBar
46
-
47 84
   VerticalScrollBar
48 85
     id: scrollBar
49 86
     anchors.top: parent.top
@@ -51,12 +88,9 @@ TabBarVertical < UITabBar
51 88
     anchors.right: parent.right
52 89
     step: 16
53 90
     pixels-scroll: true
54
-
55 91
     $!on:
56 92
       width: 0
57
-
58 93
 TabBarVerticalPanel < Panel
59
-
60 94
 TabBarVerticalButton < UIButton
61 95
   size: 48 48
62 96
   color: #aaaaaa
@@ -66,24 +100,18 @@ TabBarVerticalButton < UIButton
66 100
   icon-align: top
67 101
   icon-offset-y: 2
68 102
   icon-color: #888888
69
-
70 103
   $first:
71 104
     anchors.top: parent.top
72
-
73 105
   $!first:
74 106
     anchors.top: prev.bottom
75 107
     margin-top: 5
76
-
77 108
   $hover !checked:
78 109
     color: white
79 110
     icon-color: #cccccc
80
-
81 111
   $disabled:
82 112
     icon-color: #333333
83
-
84 113
   $checked:
85 114
     icon-color: #ffffff
86 115
     color: #80c7f8
87
-
88 116
   $on !checked:
89 117
     color: #F55E5E

+ 2
- 0
data/things/.gitignore View File

@@ -0,0 +1,2 @@
1
+*
2
+!.gitignore

+ 16
- 1
modules/client_entergame/characterlist.lua View File

@@ -30,7 +30,8 @@ local function tryLogin(charInfo, tries)
30 30
 
31 31
   CharacterList.destroyLoadBox()
32 32
 
33
-  g_game.loginWorld(G.account, G.password, charInfo.worldName, charInfo.worldHost, charInfo.worldPort, charInfo.characterName)
33
+  local locale = modules.client_locales.getCurrentLocale().name
34
+  g_game.loginWorld(G.account, G.password, charInfo.worldName, charInfo.worldHost, charInfo.worldPort, charInfo.characterName, locale)
34 35
 
35 36
   loadBox = displayCancelBox(tr('Please wait'), tr('Connecting to game server...'))
36 37
   connect(loadBox, { onCancel = function()
@@ -82,6 +83,7 @@ local function resendWait()
82 83
       if selected then
83 84
         local charInfo = { worldHost = selected.worldHost,
84 85
                            worldPort = selected.worldPort,
86
+                           worldName = selected.worldName,
85 87
                            characterName = selected.characterName }
86 88
         tryLogin(charInfo)
87 89
       end
@@ -119,9 +121,19 @@ function onGameConnectionError(message, code)
119 121
   end
120 122
 end
121 123
 
124
+function onGameUpdateNeeded(signature)
125
+  CharacterList.destroyLoadBox()
126
+  errorBox = displayErrorBox(tr("Update needed"), tr('Enter with your account again to update your client.'))
127
+  errorBox.onOk = function()
128
+    errorBox = nil
129
+    CharacterList.showAgain()
130
+  end
131
+end
132
+
122 133
 -- public functions
123 134
 function CharacterList.init()
124 135
   connect(g_game, { onLoginError = onGameLoginError })
136
+  connect(g_game, { onUpdateNeeded = onGameUpdateNeeded })
125 137
   connect(g_game, { onConnectionError = onGameConnectionError })
126 138
   connect(g_game, { onGameStart = CharacterList.destroyLoadBox })
127 139
   connect(g_game, { onLoginWait = onLoginWait })
@@ -134,6 +146,7 @@ end
134 146
 
135 147
 function CharacterList.terminate()
136 148
   disconnect(g_game, { onLoginError = onGameLoginError })
149
+  disconnect(g_game, { onUpdateNeeded = onGameUpdateNeeded })
137 150
   disconnect(g_game, { onConnectionError = onGameConnectionError })
138 151
   disconnect(g_game, { onGameStart = CharacterList.destroyLoadBox })
139 152
   disconnect(g_game, { onLoginWait = onLoginWait })
@@ -208,6 +221,7 @@ function CharacterList.create(characters, account, otui)
208 221
 
209 222
     -- these are used by login
210 223
     widget.characterName = characterInfo.name
224
+    widget.worldName = characterInfo.worldName
211 225
     widget.worldHost = characterInfo.worldIp
212 226
     widget.worldPort = characterInfo.worldPort
213 227
 
@@ -281,6 +295,7 @@ function CharacterList.doLogin()
281 295
   if selected then
282 296
     local charInfo = { worldHost = selected.worldHost,
283 297
                        worldPort = selected.worldPort,
298
+                       worldName = selected.worldName,
284 299
                        characterName = selected.characterName }
285 300
     charactersWindow:hide()
286 301
     tryLogin(charInfo)

+ 22
- 2
modules/client_entergame/entergame.lua View File

@@ -58,6 +58,17 @@ local function onChangeProtocol(combobox, option)
58 58
   protocolBox:setTooltip("Supports Client" .. (#clients > 1 and "s" or "") .. ": " .. table.toString(clients))
59 59
 end
60 60
 
61
+local function onUpdateNeeded(protocol, signature)
62
+  loadBox:destroy()
63
+  loadBox = nil
64
+
65
+  if updateFunc then
66
+    local continueFunc = EnterGame.show
67
+    local cancelFunc = EnterGame.show
68
+    updateFunc(signature, continueFunc, cancelFunc)
69
+  end
70
+end
71
+
61 72
 -- public functions
62 73
 function EnterGame.init()
63 74
   enterGame = g_ui.displayUI('entergame')
@@ -118,6 +129,7 @@ end
118 129
 
119 130
 function EnterGame.terminate()
120 131
   g_keyboard.unbindKeyDown('Ctrl+G')
132
+  removeEvent(autoLoginEvent)
121 133
   enterGame:destroy()
122 134
   enterGame = nil
123 135
   enterGameButton:destroy()
@@ -183,6 +195,7 @@ function EnterGame.doLogin()
183 195
   protocolLogin.onError = onError
184 196
   protocolLogin.onMotd = onMotd
185 197
   protocolLogin.onCharacterList = onCharacterList
198
+  protocolLogin.onUpdateNeeded = onUpdateNeeded
186 199
 
187 200
   loadBox = displayCancelBox(tr('Please wait'), tr('Connecting to login server...'))
188 201
   connect(loadBox, { onCancel = function(msgbox)
@@ -197,8 +210,9 @@ function EnterGame.doLogin()
197 210
     g_game.setClientVersion(clientVersions[#clientVersions])
198 211
   end
199 212
 
200
-  if modules.game_tibiafiles.isLoaded() then
201
-    protocolLogin:login(G.host, G.port, G.account, G.password)
213
+  if modules.game_things.isLoaded() then
214
+    local locale = modules.client_locales.getCurrentLocale().name
215
+    protocolLogin:login(G.host, G.port, G.account, G.password, locale)
202 216
   else
203 217
     loadBox:destroy()
204 218
     loadBox = nil
@@ -264,3 +278,9 @@ function EnterGame.setUniqueServer(host, port, protocol, windowWidth, windowHeig
264 278
   if not windowHeight then windowHeight = 200 end
265 279
   enterGame:setHeight(windowHeight)
266 280
 end
281
+
282
+function EnterGame.setServerInfo(message)
283
+  local label = enterGame:getChildById('serverInfoLabel')
284
+  label:setText(message)
285
+end
286
+

+ 10
- 3
modules/client_entergame/entergame.otui View File

@@ -12,7 +12,7 @@ EnterGameWindow
12 12
     anchors.top: parent.top
13 13
     text-auto-resize: true
14 14
 
15
-  TextEdit
15
+  PasswordTextEdit
16 16
     id: accountNameTextEdit
17 17
     anchors.left: parent.left
18 18
     anchors.right: parent.right
@@ -86,7 +86,7 @@ EnterGameWindow
86 86
   CheckBox
87 87
     id: rememberPasswordBox
88 88
     !text: tr('Remember password')
89
-    !tooltip: tr('Remember account and password when starts otclient')
89
+    !tooltip: tr('Remember account and password when starts client')
90 90
     anchors.left: parent.left
91 91
     anchors.right: parent.right
92 92
     anchors.top: prev.bottom
@@ -97,7 +97,7 @@ EnterGameWindow
97 97
     id: autoLoginBox
98 98
     enabled: false
99 99
     !text: tr('Auto login')
100
-    !tooltip: tr('Open charlist automatically when starting otclient')
100
+    !tooltip: tr('Open charlist automatically when starting client')
101 101
     anchors.left: parent.left
102 102
     anchors.right: parent.right
103 103
     anchors.top: prev.bottom
@@ -109,3 +109,10 @@ EnterGameWindow
109 109
     anchors.right: parent.right
110 110
     anchors.bottom: parent.bottom
111 111
     @onClick: EnterGame.doLogin()
112
+
113
+  Label
114
+    id: serverInfoLabel
115
+    font: verdana-11px-rounded
116
+    anchors.bottom: parent.bottom
117
+    anchors.left: parent.left
118
+    color: green

+ 3
- 5
modules/client_locales/locales.lua View File

@@ -5,12 +5,10 @@ local defaultLocaleName = 'en'
5 5
 local installedLocales
6 6
 local currentLocale
7 7
 
8
-LocaleExtendedId = 1
9
-
10 8
 function sendLocale(localeName)
11 9
   local protocolGame = g_game.getProtocolGame()
12 10
   if protocolGame then
13
-    protocolGame:sendExtendedOpcode(LocaleExtendedId, localeName)
11
+    protocolGame:sendExtendedOpcode(ExtendedIds.Locale, localeName)
14 12
     return true
15 13
   end
16 14
   return false
@@ -66,7 +64,7 @@ function init()
66 64
     connect(g_app, {onRun = createWindow})
67 65
   end
68 66
 
69
-  ProtocolGame.registerExtendedOpcode(LocaleExtendedId, onExtendedLocales)
67
+  ProtocolGame.registerExtendedOpcode(ExtendedIds.Locale, onExtendedLocales)
70 68
   connect(g_game, { onGameStart = onGameStart })
71 69
 end
72 70
 
@@ -74,7 +72,7 @@ function terminate()
74 72
   installedLocales = nil
75 73
   currentLocale = nil
76 74
 
77
-  ProtocolGame.unregisterExtendedOpcode(LocaleExtendedId)
75
+  ProtocolGame.unregisterExtendedOpcode(ExtendedIds.Locale)
78 76
   disconnect(g_game, { onGameStart = onGameStart })
79 77
 end
80 78
 

+ 0
- 314
modules/client_locales/neededtranslations.lua View File

@@ -1,317 +1,3 @@
1 1
 -- generated by ./tools/gen_needed_translations.sh
2 2
 modules.client_locales.neededTranslations = {
3
-  "1a) Offensive Name",
4
-  "1b) Invalid Name Format",
5
-  "1c) Unsuitable Name",
6
-  "1d) Name Inciting Rule Violation",
7
-  "2a) Offensive Statement",
8
-  "2b) Spamming",
9
-  "2c) Illegal Advertising",
10
-  "2d) Off-Topic Public Statement",
11
-  "2e) Non-English Public Statement",
12
-  "2f) Inciting Rule Violation",
13
-  "3a) Bug Abuse",
14
-  "3b) Game Weakness Abuse",
15
-  "3c) Using Unofficial Software to Play",
16
-  "3d) Hacking",
17
-  "3e) Multi-Clienting",
18
-  "3f) Account Trading or Sharing",
19
-  "4a) Threatening Gamemaster",
20
-  "4b) Pretending to Have Influence on Rule Enforcement",
21
-  "4c) False Report to Gamemaster",
22
-  "Accept",
23
-  "Account name",
24
-  "Account Status:\nFree Account",
25
-  "Account Status:\nPremium Account (%s) days left",
26
-  "Action:",
27
-  "Add",
28
-  "Add new VIP",
29
-  "Addon 1",
30
-  "Addon 2",
31
-  "Addon 3",
32
-  "Add to VIP list",
33
-  "Adjust volume",
34
-  "Alas! Brave adventurer, you have met a sad fate.\nBut do not despair, for the gods will bring you back\ninto this world in exchange for a small sacrifice\n\nSimply click on Ok to resume your journeys!",
35
-  "All modules and scripts were reloaded.",
36
-  "Allow auto chase override",
37
-  "Amount:",
38
-  "Amount",
39
-  "Anonymous",
40
-  "Are you sure you want to logout?",
41
-  "Attack",
42
-  "Author",
43
-  "Autoload",
44
-  "Autoload priority",
45
-  "Auto login",
46
-  "Auto login selected character on next charlist load",
47
-  "Axe Fighting",
48
-  "Balance:",
49
-  "Banishment",
50
-  "Banishment + Final Warning",
51
-  "Battle",
52
-  "Browse",
53
-  "Bug report sent.",
54
-  "Button Assign",
55
-  "Buy",
56
-  "Buy Now",
57
-  "Buy Offers",
58
-  "Buy with backpack",
59
-  "Cancel",
60
-  "Cannot login while already in game.",
61
-  "Cap",
62
-  "Capacity",
63
-  "Center",
64
-  "Channels",
65
-  "Character List",
66
-  "Classic control",
67
-  "Clear current message window",
68
-  "Clear object",
69
-  "Client needs update.",
70
-  "Close",
71
-  "Close this channel",
72
-  "Club Fighting",
73
-  "Combat Controls",
74
-  "Comment:",
75
-  "Connecting to game server...",
76
-  "Connecting to login server...",
77
-  "Copy message",
78
-  "Copy name",
79
-  "Copy Name",
80
-  "Create New Offer",
81
-  "Create Offer",
82
-  "Current hotkeys:",
83
-  "Current hotkey to add: %s",
84
-  "Current Offers",
85
-  "Default",
86
-  "Description",
87
-  "Destructive Behaviour",
88
-  "Detail",
89
-  "Details",
90
-  "Disable Shared Experience",
91
-  "Distance Fighting",
92
-  "Edit hotkey text:",
93
-  "Edit List",
94
-  "Edit Text",
95
-  "Enable music",
96
-  "Enable Shared Experience",
97
-  "Enable vertical synchronization",
98
-  "Enter Game",
99
-  "Enter one name per line.",
100
-  "Error",
101
-  "Error",
102
-  "Excessive Unjustified Player Killing",
103
-  "Exclude from private chat",
104
-  "Exit",
105
-  "Experience",
106
-  "Filter list to match your level",
107
-  "Filter list to match your vocation",
108
-  "Fishing",
109
-  "Fist Fighting",
110
-  "Follow",
111
-  "Fullscreen",
112
-  "Game framerate limit: %s",
113
-  "General",
114
-  "Graphics",
115
-  "Graphics Engine:",
116
-  "Head",
117
-  "Health Info",
118
-  "Health Information",
119
-  "Hide monsters",
120
-  "Hide non-skull players",
121
-  "Hide Npcs",
122
-  "Hide party members",
123
-  "Hide players",
124
-  "Hit Points",
125
-  "Hold right mouse button to navigate\nScroll mouse middle button to zoom",
126
-  "Hotkeys",
127
-  "If you shut down the program, your character might stay in the game.\nClick on 'Logout' to ensure that you character leaves the game properly.\nClick on 'Exit' if you want to exit the program without logging out your character.",
128
-  "Ignore capacity",
129
-  "Ignore equipped",
130
-  "Interface framerate limit: %s",
131
-  "Inventory",
132
-  "Invite to Party",
133
-  "Invite to private chat",
134
-  "IP Address Banishment",
135
-  "Item Offers",
136
-  "It is empty.\n",
137
-  "Join %s\'s Party",
138
-  "Leave Party",
139
-  "Level",
140
-  "Limits FPS to 60",
141
-  "List of items that you're able to buy",
142
-  "List of items that you're able to sell",
143
-  "Load",
144
-  "Location",
145
-  "Logging out...",
146
-  "Login",
147
-  "Login Error",
148
-  "Login Error",
149
-  "Logout",
150
-  "Look",
151
-  "Magic Level",
152
-  "Make sure that your client uses\nthe correct game protocol version",
153
-  "Mana",
154
-  "Manage hotkeys:",
155
-  "Market",
156
-  "Market Offers",
157
-  "Message of the day",
158
-  "Message to ",
159
-  "Message to %s",
160
-  "Minimap",
161
-  "Module Manager",
162
-  "Module name",
163
-  "Move Stackable Item",
164
-  "Move up",
165
-  "My Offers",
166
-  "Name:",
167
-  "Name",
168
-  "Name Report",
169
-  "Name Report + Banishment",
170
-  "Name Report + Banishment + Final Warning",
171
-  "No",
172
-  "No item selected.",
173
-  "No Mount",
174
-  "No Outfit",
175
-  "No statement has been selected.",
176
-  "Notation",
177
-  "NPC Trade",
178
-  "Offer History",
179
-  "Offers",
180
-  "Offer Type:",
181
-  "Ok",
182
-  "Okay",
183
-  "on %s.\n",
184
-  "Open",
185
-  "Open a private message channel:",
186
-  "Open charlist automatically when starting otclient",
187
-  "Open in new window",
188
-  "Open new channel",
189
-  "Options",
190
-  "Particles Manager",
191
-  "Pass Leadership to %s",
192
-  "Password",
193
-  "Pause",
194
-  "Piece Price:",
195
-  "Please enter a character name:",
196
-  "Please, press the key you wish to add onto your hotkeys manager",
197
-  "Please Select",
198
-  "Please use this dialog to only report bugs. Do not report rule violations here!",
199
-  "Please wait",
200
-  "Port",
201
-  "Preview",
202
-  "Price:",
203
-  "Primary",
204
-  "Protocol",
205
-  "Quantity:",
206
-  "Quest Log",
207
-  "Randomize",
208
-  "Randomize characters outfit",
209
-  "Reason:",
210
-  "Refresh",
211
-  "Reject",
212
-  "Reload",
213
-  "Reload All",
214
-  "Remember account and password when starts otclient",
215
-  "Remember password",
216
-  "Remove",
217
-  "Remove %s",
218
-  "Report Bug",
219
-  "Revoke %s\'s Invitation",
220
-  "Rotate",
221
-  "Rule Violation",
222
-  "Search:",
223
-  "Search",
224
-  "Secondary",
225
-  "Select object",
226
-  "Select Outfit",
227
-  "Sell",
228
-  "Sell Now",
229
-  "Sell Offers",
230
-  "Send",
231
-  "Send automatically",
232
-  "Server",
233
-  "Server Log",
234
-  "Set Outfit",
235
-  "Shielding",
236
-  "Show all items",
237
-  "Show Depot Only",
238
-  "Show event messages in console",
239
-  "Show frame rate",
240
-  "Show info messages in console",
241
-  "Show left panel",
242
-  "Show levels in console",
243
-  "Show private messages in console",
244
-  "Show private messages on screen",
245
-  "Show status messages in console",
246
-  "Show Text",
247
-  "Show timestamps in console",
248
-  "Show your depot items only",
249
-  "Skills",
250
-  "Soul",
251
-  "Soul Points",
252
-  "Stamina",
253
-  "Start",
254
-  "Statement:",
255
-  "Statement Report",
256
-  "Statistics",
257
-  "Stop Attack",
258
-  "Stop Follow",
259
-  "%s: (use object)",
260
-  "%s: (use object on target)",
261
-  "%s: (use object on yourself)",
262
-  "%s: (use object with crosshair)",
263
-  "Sword Fighting",
264
-  "Terminal",
265
-  "There is no way.",
266
-  "Total Price:",
267
-  "Trade",
268
-  "Trade with ...",
269
-  "Trying to reconnect in %s seconds.",
270
-  "Unable to load dat file, please place a valid dat in '%s'",
271
-  "Unable to load spr file, please place a valid spr in '%s'",
272
-  "Unable to logout.",
273
-  "Unload",
274
-  "Use",
275
-  "Use on target",
276
-  "Use on yourself",
277
-  "Use with ...",
278
-  "Version",
279
-  "VIP list",
280
-  "VIP List",
281
-  "Voc.",
282
-  "Waiting List",
283
-  "Website",
284
-  "Weight:",
285
-  "With crosshair",
286
-  "Yes",
287
-  "You are bleeding",
288
-  "You are burning",
289
-  "You are cursed",
290
-  "You are dazzled",
291
-  "You are dead.",
292
-  "You are dead",
293
-  "You are drowing",
294
-  "You are drunk",
295
-  "You are electrified",
296
-  "You are freezing",
297
-  "You are hasted",
298
-  "You are hungry",
299
-  "You are paralysed",
300
-  "You are poisoned",
301
-  "You are protected by a magic shield",
302
-  "You are strengthened",
303
-  "You are within a protection zone",
304
-  "You can enter new text.",
305
-  "You have %s percent",
306
-  "You have %s percent to go",
307
-  "You may not logout during a fight",
308
-  "You may not logout or enter a protection zone",
309
-  "You must enter a comment.",
310
-  "You must enter an account name and password.",
311
-  "You must enter a valid server address and port.",
312
-  "You must select a character to login!",
313
-  "Your Capacity:",
314
-  "You read the following, written by \n%s\n",
315
-  "You read the following, written on %s.\n",
316
-  "Your Money:",
317 3
 }

+ 246
- 0
modules/corelib/ui/uimovabletabbar.lua View File

@@ -0,0 +1,246 @@
1
+-- @docclass
2
+UIMoveableTabBar = extends(UIWidget)
3
+
4
+-- private functions
5
+local function onTabClick(tab)
6
+  tab.tabBar:selectTab(tab)
7
+end
8
+
9
+local function updateMargins(tabBar, ignored)
10
+  if #tabBar.tabs == 0 then return end
11
+ 
12
+  local currentMargin = 0
13
+  for i = 1, #tabBar.tabs do
14
+    if tabBar.tabs[i] ~= ignored then 
15
+      if i == 1 then
16
+        tabBar.tabs[i]:setMarginLeft(0)
17
+      else
18
+        tabBar.tabs[i]:setMarginLeft(tabBar.tabSpacing * (i - 1) + currentMargin)
19
+      end
20
+    end
21
+    currentMargin = currentMargin + tabBar.tabs[i]:getWidth()
22
+  end
23
+end
24
+
25
+local function onTabMousePress(tab, mousePos, mouseButton)
26
+  if mouseButton == MouseRightButton then
27
+    if tab.menuCallback then tab.menuCallback(tab, mousePos, mouseButton) end
28
+    return true
29
+  end
30
+end
31
+
32
+local function onTabDragEnter(tab)
33
+  tab:raise()
34
+  tab.tabBar.selected = tab
35
+  return true
36
+end
37
+
38
+local function onTabDragLeave(tab)
39
+  updateMargins(tab.tabBar)
40
+  tab.tabBar.selected = nil
41
+  return true
42
+end
43
+
44
+local function onTabDragMove(tab, mousePos, mouseMoved)
45
+  if tab == tab.tabBar.selected then
46
+    local newMargin = tab:getMarginLeft() + mouseMoved.x
47
+    if newMargin >= -tab.tabBar.tabSpacing and newMargin < tab.tabBar:getWidth() - tab:getWidth() then
48
+      tab:setMarginLeft(newMargin)
49
+    end
50
+
51
+    local tabs = tab.tabBar.tabs
52
+    local lastMargin = -tab.tabBar.tabSpacing
53
+    for i = 1, #tabs do
54
+      local nextMargin = tabs[i + 1] and (tabs[i + 1] == tab and (tabs[i]:getMarginLeft() + tabs[i]:getWidth() + tab.tabBar.tabSpacing) or tabs[i + 1]:getMarginLeft()) or tab.tabBar:getWidth()
55
+      if (tab:getMarginLeft()+(tabs[i]:getWidth()/2)) >= lastMargin and (tab:getMarginLeft()+(tabs[i]:getWidth()/2)) < nextMargin then
56
+        if tabs[i] ~= tab then
57
+          local newIndex = table.find(tab.tabBar.tabs, tab.tabBar.tabs[i])
58
+          table.remove(tab.tabBar.tabs, table.find(tab.tabBar.tabs, tab))
59
+          table.insert(tab.tabBar.tabs, newIndex, tab)
60
+          updateMargins(tab.tabBar, tab)
61
+          break
62
+        else
63
+          updateMargins(tab.tabBar, tab)
64
+          break
65
+        end
66
+      end
67
+      lastMargin = tab.tabBar.tabs[i]:getMarginLeft() == 0 and -tab.tabBar.tabSpacing or tab.tabBar.tabs[i]:getMarginLeft()
68
+    end
69
+  end
70
+end
71
+
72
+local function tabBlink(tab)
73
+  if not tab.blinking then return end
74
+  tab:setOn(not tab:isOn())
75
+  tab.blinkEvent = scheduleEvent(function() tabBlink(tab) end, 500)
76
+end
77
+
78
+-- public functions
79
+function UIMoveableTabBar.create()
80
+  local tabbar = UIMoveableTabBar.internalCreate()
81
+  tabbar:setFocusable(false)
82
+  tabbar.tabs = {}
83
+  tabbar.selected = nil  -- dragged tab
84
+  tabbar.tabSpacing = 5
85
+  tabbar.tabsMoveable = false
86
+  return tabbar
87
+end
88
+
89
+function UIMoveableTabBar:setContentWidget(widget)
90
+  self.contentWidget = widget
91
+  if #self.tabs > 0 then
92
+    self.contentWidget:addChild(self.tabs[1].tabPanel)
93
+  end
94
+end
95
+
96
+function UIMoveableTabBar:setTabSpacing(tabSpacing)
97
+  self.tabSpacing = tabSpacing
98
+  updateMargins(self)
99
+end
100
+
101
+function UIMoveableTabBar:addTab(text, panel, menuCallback)
102
+  if panel == nil then
103
+    panel = g_ui.createWidget(self:getStyleName() .. 'Panel')
104
+    panel:setId('tabPanel')
105
+  end
106
+
107
+  local tab = g_ui.createWidget(self:getStyleName() .. 'Button', self)
108
+  panel.isTab = true
109
+  tab.tabPanel = panel
110
+  tab.tabBar = self
111
+  tab:setId('tab')
112
+  tab:setDraggable(self.tabsMoveable)
113
+  tab:setText(text)
114
+  tab:setWidth(tab:getTextSize().width + tab:getPaddingLeft() + tab:getPaddingRight())
115
+  tab.menuCallback = menuCallback or nil
116
+  tab.onClick = onTabClick
117
+  tab.onMousePress = onTabMousePress
118
+  tab.onDragEnter = onTabDragEnter
119
+  tab.onDragLeave = onTabDragLeave
120
+  tab.onDragMove = onTabDragMove
121
+  tab.onDestroy = function() tab.tabPanel:destroy() end
122
+
123
+  table.insert(self.tabs, tab)
124
+  if #self.tabs == 1 then
125
+    self:selectTab(tab)
126
+    tab:setMarginLeft(0)
127
+  else
128
+    local newMargin = self.tabSpacing * (#self.tabs - 1)
129
+    for i = 1, #self.tabs - 1 do
130
+      newMargin = newMargin + self.tabs[i]:getWidth()
131
+    end
132
+    tab:setMarginLeft(newMargin)
133
+  end
134
+
135
+  return tab
136
+end
137
+
138
+-- Additional function to move the tab by lua
139
+function UIMoveableTabBar:moveTab(tab, units)
140
+  local index = table.find(self.tabs, tab)
141
+  if index == nil then return end
142
+  
143
+  local focus = false
144
+  if self.currentTab == tab then
145
+    self:selectPrevTab()
146
+    focus = true
147
+  end
148
+  
149
+  table.remove(self.tabs, index)
150
+  
151
+  local newIndex = math.min(#self.tabs+1, math.max(index + units, 1))
152
+  table.insert(self.tabs, newIndex, tab) 
153
+  if focus then self:selectTab(tab) end
154
+  updateMargins(self)
155
+  return newIndex
156
+end
157
+
158
+function UIMoveableTabBar:onStyleApply(styleName, styleNode)
159
+  if styleNode['moveable'] then
160
+    self.tabsMoveable = styleNode['moveable']
161
+  end
162
+end
163
+
164
+function UIMoveableTabBar:removeTab(tab)
165
+  local index = table.find(self.tabs, tab)
166
+  if index == nil then return end
167
+  if self.currentTab == tab then
168
+    self:selectPrevTab()
169
+  end
170
+  table.remove(self.tabs, index)
171
+  if tab.blinkEvent then
172
+    removeEvent(tab.blinkEvent)
173
+  end
174
+  tab:destroy()
175
+  updateMargins(self)
176
+end
177
+
178
+function UIMoveableTabBar:getTab(text)
179
+  for k,tab in pairs(self.tabs) do
180
+    if tab:getText():lower() == text:lower() then
181
+      return tab
182
+    end
183
+  end
184
+end
185
+
186
+function UIMoveableTabBar:selectTab(tab)
187
+  if self.currentTab == tab then return end
188
+  if self.contentWidget then
189
+    local selectedWidget = self.contentWidget:getLastChild()
190
+    if selectedWidget and selectedWidget.isTab then
191
+      self.contentWidget:removeChild(selectedWidget)
192
+    end
193
+    self.contentWidget:addChild(tab.tabPanel)
194
+    tab.tabPanel:fill('parent')
195
+  end
196
+
197
+  if self.currentTab then
198
+    self.currentTab:setChecked(false)
199
+  end
200
+  signalcall(self.onTabChange, self, tab)
201
+  self.currentTab = tab
202
+  tab:setChecked(true)
203
+  tab:setOn(false)
204
+  tab.blinking = false
205
+
206
+  local parent = tab:getParent()
207
+  parent:focusChild(tab, MouseFocusReason)
208
+end
209
+
210
+function UIMoveableTabBar:selectNextTab()
211
+  if self.currentTab == nil then return end
212
+  local index = table.find(self.tabs, self.currentTab)
213
+  if index == nil then return end
214
+  local nextTab = self.tabs[index + 1] or self.tabs[1]
215
+  if not nextTab then return end
216
+  self:selectTab(nextTab)
217
+end
218
+
219
+function UIMoveableTabBar:selectPrevTab()
220
+  if self.currentTab == nil then return end
221
+  local index = table.find(self.tabs, self.currentTab)
222
+  if index == nil then return end
223
+  local prevTab = self.tabs[index - 1] or self.tabs[#self.tabs]
224
+  if not prevTab then return end
225
+  self:selectTab(prevTab)
226
+end
227
+
228
+function UIMoveableTabBar:blinkTab(tab)
229
+  if tab:isChecked() or tab.blinking then return end
230
+  tab.blinking = true
231
+  tabBlink(tab)
232
+end
233
+
234
+function UIMoveableTabBar:getTabPanel(tab)
235
+  return tab.tabPanel
236
+end
237
+
238
+function UIMoveableTabBar:getCurrentTabPanel()
239
+  if self.currentTab then
240
+    return self.currentTab.tabPanel
241
+  end
242
+end
243
+
244
+function UIMoveableTabBar:getCurrentTab()
245
+  return self.currentTab
246
+end

+ 14
- 125
modules/corelib/ui/uitabbar.lua View File

@@ -6,86 +6,24 @@ local function onTabClick(tab)
6 6
   tab.tabBar:selectTab(tab)
7 7
 end
8 8
 
9
-local function updateMargins(tabBar, ignored)
10
-  if #tabBar.tabs == 0 then return end
11
- 
12
-  local currentMargin = 0
13
-  for i = 1, #tabBar.tabs do
14
-    if tabBar.tabs[i] ~= ignored then 
15
-      if i == 1 then
16
-        tabBar.tabs[i]:setMarginLeft(0)
17
-      else
18
-        tabBar.tabs[i]:setMarginLeft(tabBar.tabSpacing * (i - 1) + currentMargin)
19
-      end
20
-    end
21
-    currentMargin = currentMargin + tabBar.tabs[i]:getWidth()
22
-  end
23
-end
24
-
25
-local function onTabMousePress(tab, mousePos, mouseButton)
26
-  if mouseButton == MouseRightButton then
27
-    if tab.menuCallback then tab.menuCallback(tab, mousePos, mouseButton) end
28
-    return true
29
-  end
30
-end
31
-
32
-local function onTabDragEnter(tab)
33
-  tab:raise()
34
-  tab.tabBar.selected = tab
35
-  return true
36
-end
37
-
38
-local function onTabDragLeave(tab)
39
-  updateMargins(tab.tabBar)
40
-  tab.tabBar.selected = nil
41
-  return true
42
-end
43
-
44
-local function onTabDragMove(tab, mousePos, mouseMoved)
45
-  if tab == tab.tabBar.selected then
46
-    local newMargin = tab:getMarginLeft() + mouseMoved.x
47
-    if newMargin >= -tab.tabBar.tabSpacing and newMargin < tab.tabBar:getWidth() - tab:getWidth() then
48
-      tab:setMarginLeft(newMargin)
49
-    end
50
-
51
-    local tabs = tab.tabBar.tabs
52
-    local lastMargin = -tab.tabBar.tabSpacing
53
-    for i = 1, #tabs do
54
-      local nextMargin = tabs[i + 1] and (tabs[i + 1] == tab and (tabs[i]:getMarginLeft() + tabs[i]:getWidth() + tab.tabBar.tabSpacing) or tabs[i + 1]:getMarginLeft()) or tab.tabBar:getWidth()
55
-      if (tab:getMarginLeft()+(tabs[i]:getWidth()/2)) >= lastMargin and (tab:getMarginLeft()+(tabs[i]:getWidth()/2)) < nextMargin then
56
-        if tabs[i] ~= tab then
57
-          local newIndex = table.find(tab.tabBar.tabs, tab.tabBar.tabs[i])
58
-          table.remove(tab.tabBar.tabs, table.find(tab.tabBar.tabs, tab))
59
-          table.insert(tab.tabBar.tabs, newIndex, tab)
60
-          updateMargins(tab.tabBar, tab)
61
-          break
62
-        else
63
-          updateMargins(tab.tabBar, tab)
64
-          break
65
-        end
66
-      end
67
-      lastMargin = tab.tabBar.tabs[i]:getMarginLeft() == 0 and -tab.tabBar.tabSpacing or tab.tabBar.tabs[i]:getMarginLeft()
68
-    end
9
+local function onTabMouseRelease(tab, mousePos, mouseButton)
10
+  if mouseButton == MouseRightButton and tab:containsPoint(mousePos) then
11
+    signalcall(tab.tabBar.onTabLeftClick, tab.tabBar, tab)
69 12
   end
70 13
 end
71 14
 
72
-local function tabBlink(tab)
73
-  if not tab.blinking then return end
74
-  tab:setOn(not tab:isOn())
75
-  tab.blinkEvent = scheduleEvent(function() tabBlink(tab) end, 500)
76
-end
77
-
78 15
 -- public functions
79 16
 function UITabBar.create()
80 17
   local tabbar = UITabBar.internalCreate()
81 18
   tabbar:setFocusable(false)
82 19
   tabbar.tabs = {}
83
-  tabbar.selected = nil  -- dragged tab
84
-  tabbar.tabSpacing = 5
85
-  tabbar.tabsMoveable = false
86 20
   return tabbar
87 21
 end
88 22
 
23
+function UITabBar:onSetup()
24
+  self.buttonsPanel = self:getChildById('buttonsPanel')
25
+end
26
+
89 27
 function UITabBar:setContentWidget(widget)
90 28
   self.contentWidget = widget
91 29
   if #self.tabs > 0 then
@@ -93,72 +31,33 @@ function UITabBar:setContentWidget(widget)
93 31
   end
94 32
 end
95 33
 
96
-function UITabBar:setTabSpacing(tabSpacing)
97
-  self.tabSpacing = tabSpacing
98
-  updateMargins(self)
99
-end
100
-
101
-function UITabBar:addTab(text, panel, menuCallback)
34
+function UITabBar:addTab(text, panel, icon)
102 35
   if panel == nil then
103 36
     panel = g_ui.createWidget(self:getStyleName() .. 'Panel')
104 37
     panel:setId('tabPanel')
105 38
   end
106 39
 
107
-  local tab = g_ui.createWidget(self:getStyleName() .. 'Button', self)
40
+  local tab = g_ui.createWidget(self:getStyleName() .. 'Button', self.buttonsPanel)
108 41
   panel.isTab = true
109 42
   tab.tabPanel = panel
110 43
   tab.tabBar = self
111 44
   tab:setId('tab')
112
-  tab:setDraggable(self.tabsMoveable)
113 45
   tab:setText(text)
114 46
   tab:setWidth(tab:getTextSize().width + tab:getPaddingLeft() + tab:getPaddingRight())
115
-  tab.menuCallback = menuCallback or nil
116 47
   tab.onClick = onTabClick
117
-  tab.onMousePress = onTabMousePress
118
-  tab.onDragEnter = onTabDragEnter
119
-  tab.onDragLeave = onTabDragLeave
120
-  tab.onDragMove = onTabDragMove
48
+  tab.onMouseRelease = onTabMouseRelease
121 49
   tab.onDestroy = function() tab.tabPanel:destroy() end
122 50
 
123 51
   table.insert(self.tabs, tab)
124 52
   if #self.tabs == 1 then
125 53
     self:selectTab(tab)
126
-    tab:setMarginLeft(0)
127
-  else
128
-    local newMargin = self.tabSpacing * (#self.tabs - 1)
129
-    for i = 1, #self.tabs - 1 do
130
-      newMargin = newMargin + self.tabs[i]:getWidth()
131
-    end
132
-    tab:setMarginLeft(newMargin)
133 54
   end
134 55
 
135
-  return tab
136
-end
137
-
138
-function UITabBar:moveTab(tab, units)
139
-  local index = table.find(self.tabs, tab)
140
-  if index == nil then return end
141
-  
142
-  local focus = false
143
-  if self.currentTab == tab then
144
-    self:selectPrevTab()
145
-    focus = true
146
-  end
147
-  
148
-  table.remove(self.tabs, index)
149
-  
150
-  local newIndex = math.min(#self.tabs+1, math.max(index + units, 1))
151
-  table.insert(self.tabs, newIndex, tab) 
152
-  if focus then self:selectTab(tab) end
153
-  updateMargins(self)
154
-  return newIndex
155
-end
56
+  local tabStyle = {}
57
+  tabStyle['icon-source'] = icon
58
+  tab:mergeStyle(tabStyle)
156 59
 
157
-function UITabBar:onStyleApply(styleName, styleNode)
158
-  if styleNode['moveable'] then
159
-    self.tabsMoveable = styleNode['moveable']
160
-  end
60
+  return tab
161 61
 end
162 62
 
163 63
 function UITabBar:removeTab(tab)
@@ -168,11 +67,7 @@ function UITabBar:removeTab(tab)
168 67
     self:selectPrevTab()
169 68
   end
170 69
   table.remove(self.tabs, index)
171
-  if tab.blinkEvent then
172
-    removeEvent(tab.blinkEvent)
173
-  end
174 70
   tab:destroy()
175
-  updateMargins(self)
176 71
 end
177 72
 
178 73
 function UITabBar:getTab(text)
@@ -201,7 +96,6 @@ function UITabBar:selectTab(tab)
201 96
   self.currentTab = tab
202 97
   tab:setChecked(true)
203 98
   tab:setOn(false)
204
-  tab.blinking = false
205 99
 
206 100
   local parent = tab:getParent()
207 101
   parent:focusChild(tab, MouseFocusReason)
@@ -225,12 +119,6 @@ function UITabBar:selectPrevTab()
225 119
   self:selectTab(prevTab)
226 120
 end
227 121
 
228
-function UITabBar:blinkTab(tab)
229
-  if tab:isChecked() or tab.blinking then return end
230
-  tab.blinking = true
231
-  tabBlink(tab)
232
-end
233
-
234 122
 function UITabBar:getTabPanel(tab)
235 123
   return tab.tabPanel
236 124
 end

+ 28
- 25
modules/game_battle/battle.lua View File

@@ -97,29 +97,25 @@ function onMiniWindowClose()
97 97
 end
98 98
 
99 99
 function checkCreatures()
100
+  removeAllCreatures()
101
+
102
+  local spectators = {}
100 103
   local player = g_game.getLocalPlayer()
101 104
   if g_game.isOnline() then
102 105
     creatures = g_map.getSpectators(player:getPosition(), false)
103 106
     for i, creature in ipairs(creatures) do
104 107
       if creature ~= player and doCreatureFitFilters(creature) then
105
-        if not hasCreature(creature) then
106
-          addCreature(creature)
107
-        end
108
-      end
109
-    end
110
-    local toRemove = {}
111
-    for i, b in pairs(battleButtonsByCreaturesList) do
112
-      if (not table.contains(creatures, b.creature)) or (not doCreatureFitFilters(b.creature)) then
113
-        table.insert(toRemove, b.creature)
108
+        table.insert(spectators, creature)
114 109
       end
115 110
     end
116
-    
117
-    for i, creature in pairs(toRemove) do
118
-      removeCreature(creature)
119
-    end
111
+  end
112
+
113
+  for i, v in pairs(spectators) do
114
+    addCreature(v)
120 115
   end
121 116
 end
122 117
 
118
+
123 119
 function doCreatureFitFilters(creature)
124 120
   local localPlayer = g_game.getLocalPlayer()
125 121
   if creature == localPlayer then
@@ -129,11 +125,7 @@ function doCreatureFitFilters(creature)
129 125
   local pos = creature:getPosition()
130 126
   if not pos then return false end
131 127
 
132
-  if pos.z ~= localPlayer:getPosition().z or not localPlayer:hasSight(pos) then
133
-    return false
134
-  end
135
-
136
-  if not creature:canBeSeen() then return false end
128
+  if pos.z ~= localPlayer:getPosition().z or not creature:canBeSeen() then return false end
137 129
 
138 130
   local hidePlayers = hidePlayersButton:isChecked()
139 131
   local hideNPCs = hideNPCsButton:isChecked()
@@ -165,24 +157,32 @@ end
165 157
 
166 158
 function onCreaturePositionChange(creature, newPos, oldPos)
167 159
   if creature:isLocalPlayer() then
168
-    checkCreatures()
160
+    if oldPos and newPos and newPos.z ~= oldPos.z then
161
+      checkCreatures()
162
+    else
163
+      for id, creatureButton in pairs(battleButtonsByCreaturesList) do
164
+        addCreature(creatureButton.creature)
165
+      end
166
+    end
169 167
   else
170 168
     local has = hasCreature(creature)
171 169
     local fit = doCreatureFitFilters(creature)
172 170
     if has and not fit then
173 171
       removeCreature(creature)
174
-    elseif not has and fit then
172
+    elseif fit then
175 173
       addCreature(creature)
176 174
     end
177 175
   end
178 176
 end
179 177
 
178
+
180 179
 function onCreatureOutfitChange(creature, outfit, oldOutfit)
181
-  if not creature:canBeSeen() then
182
-    removeCreature(creature)
183
-  elseif doCreatureFitFilters(creature) then
184
-    removeCreature(creature)
185
-    addCreature(creature)
180
+  if hasCreature(creature) then
181
+    if doCreatureFitFilters(creature) then
182
+      addCreature(creature)
183
+    else
184
+      removeCreature(creature)
185
+    end
186 186
   end
187 187
 end
188 188
 
@@ -223,6 +223,9 @@ function addCreature(creature)
223 223
   else
224 224
     battleButton:setLifeBarPercent(creature:getHealthPercent())
225 225
   end
226
+
227
+  local localPlayer = g_game.getLocalPlayer()
228
+  battleButton:setVisible(localPlayer:hasSight(creature:getPosition()) and creature:canBeSeen())
226 229
 end
227 230
 
228 231
 function removeAllCreatures()

+ 3
- 3
modules/game_console/console.otui View File

@@ -18,8 +18,8 @@ ConsolePhantomLabel < UILabel
18 18
   selection-color: #111416
19 19
   selection-background-color: #999999
20 20
 
21
-ConsoleTabBar < TabBar
22
-ConsoleTabBarPanel < TabBarPanel
21
+ConsoleTabBar < MoveableTabBar
22
+ConsoleTabBarPanel < MoveableTabBarPanel
23 23
   id: consoleTab
24 24
 
25 25
   ScrollablePanel
@@ -69,7 +69,7 @@ ConsoleTabBarPanel < TabBarPanel
69 69
     step: 14
70 70
     pixels-scroll: true
71 71
 
72
-ConsoleTabBarButton < TabBarButton
72
+ConsoleTabBarButton < MoveableTabBarButton
73 73
   height: 28
74 74
   padding: 15
75 75
 

+ 38
- 6
modules/game_interface/gameinterface.lua View File

@@ -64,11 +64,6 @@ function bindKeys()
64 64
   g_keyboard.bindKeyPress('Down', function() smartWalk(South) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
65 65
   g_keyboard.bindKeyPress('Left', function() smartWalk(West) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
66 66
 
67
-  g_keyboard.bindKeyDown('Up', function() smartWalk(North) end, gameRootPanel)
68
-  g_keyboard.bindKeyDown('Right', function() smartWalk(East) end, gameRootPanel)
69
-  g_keyboard.bindKeyDown('Down', function() smartWalk(South) end, gameRootPanel)
70
-  g_keyboard.bindKeyDown('Left', function() smartWalk(West) end, gameRootPanel)
71
-
72 67
   g_keyboard.bindKeyPress('Numpad8', function() smartWalk(North) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
73 68
   g_keyboard.bindKeyPress('Numpad9', function() smartWalk(NorthEast) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
74 69
   g_keyboard.bindKeyPress('Numpad6', function() smartWalk(East) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
@@ -91,8 +86,8 @@ function bindKeys()
91 86
   g_keyboard.bindKeyDown('Ctrl+Q', logout, gameRootPanel)
92 87
   g_keyboard.bindKeyDown('Ctrl+L', logout, gameRootPanel)
93 88
   g_keyboard.bindKeyDown('Ctrl+W', function() g_map.cleanTexts() modules.game_textmessage.clearMessages() end, gameRootPanel)
94
-  g_keyboard.bindKeyDown('Ctrl+.', toggleAspectRatio, gameRootPanel)
95 89
   g_keyboard.bindKeyDown('Ctrl+N', function() gameMapPanel:setDrawTexts(not gameMapPanel:isDrawingTexts()) end, gameRootPanel)
90
+  g_keyboard.bindKeyDown('Ctrl+.', toggleAlternativeView, gameRootPanel)
96 91
 end
97 92
 
98 93
 function terminate()
@@ -324,6 +319,7 @@ function onTradeWith(clickedWidget, mousePosition)
324 319
 end
325 320
 
326 321
 function startUseWith(thing)
322
+  if not thing then return end
327 323
   selectedType = 'use'
328 324
   selectedThing = thing
329 325
   mouseGrabberWidget:grabMouse()
@@ -497,6 +493,7 @@ function processMouseAction(menuPosition, mouseButton, autoWalkPos, lookThing, u
497 493
         return true
498 494
       else
499 495
         g_game.use(useThing)
496
+        return true
500 497
       end
501 498
       return true
502 499
     elseif creatureThing and keyboardModifiers == KeyboardAltModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
@@ -643,3 +640,38 @@ function onLeftPanelVisibilityChange(leftPanel, visible)
643 640
     end
644 641
   end
645 642
 end
643
+
644
+function toggleAlternativeView()
645
+  if gameMapPanel:isKeepAspectRatioEnabled() then
646
+    gameMapPanel:setKeepAspectRatio(false)
647
+    gameMapPanel:setZoom(14)
648
+    gameMapPanel:fill('parent')
649
+    gameRootPanel:fill('parent')
650
+    gameLeftPanel:setImageColor('alpha')
651
+    gameRightPanel:setImageColor('alpha')
652
+    gameLeftPanel:setMarginTop(36)
653
+    gameRightPanel:setMarginTop(36)
654
+    gameLeftPanel:setOn(true)
655
+    gameLeftPanel:setVisible(true)
656
+    gameRightPanel:setOn(true)
657
+    gameBottomPanel:setImageColor('#00000099')
658
+    modules.client_topmenu.getTopMenu():setImageColor('#ffffff66')
659
+    g_game.changeMapAwareRange(24, 20)
660
+  else
661
+    gameMapPanel:setKeepAspectRatio(true)
662
+    gameMapPanel:setVisibleDimension({ width = 15, height = 11 })
663
+    gameMapPanel:addAnchor(AnchorLeft, 'gameLeftPanel', AnchorRight)
664
+    gameMapPanel:addAnchor(AnchorRight, 'gameRightPanel', AnchorLeft)
665
+    gameMapPanel:addAnchor(AnchorBottom, 'gameBottomPanel', AnchorTop)
666
+    gameRootPanel:addAnchor(AnchorTop, 'topMenu', AnchorBottom)
667
+    gameLeftPanel:setOn(false)
668
+    gameLeftPanel:setVisible(false)
669
+    gameLeftPanel:setImageColor('white')
670
+    gameRightPanel:setImageColor('white')
671
+    gameLeftPanel:setMarginTop(0)
672
+    gameRightPanel:setMarginTop(0)
673
+    gameBottomPanel:setImageColor('white')
674
+    modules.client_topmenu.getTopMenu():setImageColor('white')
675
+    g_game.changeMapAwareRange(18, 14)
676
+  end
677
+end

modules/game_tibiafiles/.gitignore → modules/game_things/.gitignore View File


modules/game_tibiafiles/tibiafiles.lua → modules/game_things/things.lua View File

@@ -1,4 +1,4 @@
1
-filename = 'Tibia'
1
+filename =  nil
2 2
 loaded = false
3 3
 
4 4
 function init()
@@ -19,8 +19,15 @@ end
19 19
 
20 20
 function load()
21 21
   local version = g_game.getProtocolVersion()
22
-  local datPath = resolvepath(version .. '/' .. filename .. '.dat')
23
-  local sprPath = resolvepath(version .. '/' .. filename .. '.spr')
22
+
23
+  local datPath, sprPath
24
+  if filename then
25
+    datPath = resolvepath('/things/' .. filename)
26
+    sprPath = resolvepath('/things/' .. filename)
27
+  else
28
+    datPath = resolvepath('/things/' .. version .. '/Tibia')
29
+    sprPath = resolvepath('/things/' .. version .. '/Tibia')
30
+  end
24 31
 
25 32
   local errorMessage = ''
26 33
   if not g_things.loadDat(datPath) then

+ 8
- 0
modules/game_things/things.otmod View File

@@ -0,0 +1,8 @@
1
+Module
2
+  name: game_things
3
+  description: Contains things spr and dat
4
+  reloadable: false
5
+  sandboxed: true
6
+  scripts: [things]
7
+  @onLoad: init()
8
+  @onUnload: terminate()

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

@@ -1,8 +0,0 @@
1
-Module
2
-  name: game_tibiafiles
3
-  description: Contains tibia spr and dat
4
-  reloadable: false
5
-  sandboxed: true
6
-  scripts: [tibiafiles]
7
-  @onLoad: init()
8
-  @onUnload: terminate()

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

@@ -10,7 +10,7 @@ function init()
10 10
 
11 11
   g_keyboard.bindKeyDown('Ctrl+P', toggle)
12 12
 
13
-  vipButton = modules.client_topmenu.addRightGameToggleButton('vipListButton', tr('VIP list') .. ' (Ctrl+P)', '/images/topbuttons/viplist', toggle)
13
+  vipButton = modules.client_topmenu.addRightGameToggleButton('vipListButton', tr('VIP List') .. ' (Ctrl+P)', '/images/topbuttons/viplist', toggle)
14 14
   vipButton:setOn(true)
15 15
   vipWindow = g_ui.loadUI('viplist', modules.game_interface.getRightPanel())
16 16
 

+ 6
- 0
modules/gamelib/const.lua View File

@@ -191,4 +191,10 @@ VipState = {
191 191
   Pending = 2
192 192
 }
193 193
 
194
+ExtendedIds = {
195
+  Activate = 0,
196
+  Locale = 1,
197
+  Ping = 2
198
+}
199
+
194 200
 -- @}

+ 3
- 1
modules/gamelib/game.lua View File

@@ -14,8 +14,10 @@ function g_game.chooseRsa(host)
14 14
       g_game.setCustomOs(OsTypes.Linux)
15 15
     end
16 16
   else
17
+    if currentRsa == CIPSOFT_RSA then
18
+      g_game.setCustomOs(-1)
19
+    end
17 20
     g_game.setRsa(OTSERV_RSA)
18
-    g_game.setCustomOs(-1)
19 21
   end
20 22
 end
21 23
 

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

@@ -5,7 +5,7 @@ Module
5 5
   website: www.otclient.info
6 6
 
7 7
   dependencies:
8
-    - game_tibiafiles
8
+    - game_things
9 9
 
10 10
   @onLoad: |
11 11
     dofile 'const'

+ 1
- 0
modules/gamelib/protocollogin.lua View File

@@ -28,6 +28,7 @@ end
28 28
 
29 29
 function ProtocolLogin:sendLoginPacket()
30 30
   local msg = OutputMessage.create()
31
+
31 32
   msg:addU8(ClientOpcodes.ClientEnterAccount)
32 33
   msg:addU16(g_game.getOs())
33 34
 

+ 1
- 1
src/client/mapio.cpp View File

@@ -166,7 +166,7 @@ void Map::loadOtbm(const std::string& fileName, const UIWidgetPtr& pbar)
166 166
                     }
167 167
 
168 168
                     if(house && item->isMoveable()) {
169
-                        g_logger.warning(stdext::format("Movable item found in house: %d at pos %s - escaping...", item->getId(), stdext::to_string(pos)));
169
+                        g_logger.warning(stdext::format("Moveable item found in house: %d at pos %s - escaping...", item->getId(), stdext::to_string(pos)));
170 170
                         item.reset();
171 171
                     }
172 172
 

+ 5
- 5
src/client/minimap.cpp View File

@@ -79,13 +79,13 @@ void MinimapBlock::update()
79 79
 
80 80
 void MinimapBlock::updateTile(int x, int y, const MinimapTile& tile)
81 81
 {
82
-    if(!(m_tiles[getTileIndex(x,y)] == tile)) {
83
-        m_tiles[getTileIndex(x,y)] = tile;
82
+    if(tile.color != 0)
83
+        m_shouldDraw = true;
84 84
 
85
-        if(tile.color != 0)
86
-            m_shouldDraw = true;
85
+    if(m_tiles[getTileIndex(x,y)].color != tile.color)
87 86
         m_mustUpdate = true;
88
-    }
87
+
88
+    m_tiles[getTileIndex(x,y)] = tile;
89 89
 }
90 90
     
91 91
 void Minimap::init()

+ 2
- 2
src/client/protocolcodes.h View File

@@ -42,9 +42,9 @@ namespace Proto {
42 42
 
43 43
     enum GameServerOpcodes : uint8
44 44
     {
45
-        GameServerLoginOrPendingState    = 10,
45
+        GameServerLoginOrPendingState       = 10,
46 46
         GameServerGMActions                 = 11,
47
-        GameServerEnterGame              = 15,
47
+        GameServerEnterGame                 = 15,
48 48
         GameServerUpdateNeeded              = 17,
49 49
         GameServerLoginError                = 20,
50 50
         GameServerLoginAdvice               = 21,

+ 2
- 0
src/client/protocolgame.h View File

@@ -107,6 +107,8 @@ public:
107 107
     void sendNewNewRuleViolation(int reason, int action, const std::string& characterName, const std::string& comment, const std::string& translation);
108 108
     void sendRequestItemInfo(int itemId, int subType, int index);
109 109
     void sendAnswerModalDialog(int dialog, int button, int choice);
110
+
111
+    // otclient only
110 112
     void sendChangeMapAwareRange(int xrange, int yrange);
111 113
 
112 114
 protected:

Loading…
Cancel
Save