Browse Source

Refactor for documentation

Eduardo Bart 8 years ago
parent
commit
98a1b611bf
100 changed files with 554 additions and 776 deletions
  1. 3
    2
      .gitignore
  2. 5
    0
      TODO
  3. 1
    1
      init.lua
  4. 7
    7
      modules/client/client.lua
  5. 3
    3
      modules/client_background/background.lua
  6. 5
    5
      modules/client_entergame/characterlist.lua
  7. 17
    17
      modules/client_entergame/entergame.lua
  8. 5
    5
      modules/client_locales/locales.lua
  9. 5
    5
      modules/client_modulemanager/modulemanager.lua
  10. 11
    11
      modules/client_options/options.lua
  11. 5
    5
      modules/client_skins/skins.lua
  12. 2
    2
      modules/client_terminal/commands.lua
  13. 11
    11
      modules/client_terminal/terminal.lua
  14. 2
    2
      modules/client_topmenu/topmenu.lua
  15. 27
    23
      modules/corelib/const.lua
  16. 3
    4
      modules/corelib/corelib.otmod
  17. 0
    6
      modules/corelib/ext/os.lua
  18. 0
    45
      modules/corelib/ext/string.lua
  19. 9
    55
      modules/corelib/globals.lua
  20. 10
    9
      modules/corelib/keyboard.lua
  21. 10
    0
      modules/corelib/math.lua
  22. 0
    1
      modules/corelib/math/color.lua
  23. 0
    8
      modules/corelib/math/math.lua
  24. 0
    1
      modules/corelib/math/point.lua
  25. 0
    1
      modules/corelib/math/rect.lua
  26. 0
    1
      modules/corelib/math/size.lua
  27. 10
    9
      modules/corelib/mouse.lua
  28. 34
    33
      modules/corelib/settings.lua
  29. 47
    0
      modules/corelib/string.lua
  30. 2
    0
      modules/corelib/table.lua
  31. 7
    6
      modules/corelib/ui/effects.lua
  32. 20
    14
      modules/corelib/ui/tooltip.lua
  33. 1
    0
      modules/corelib/ui/uibutton.lua
  34. 1
    0
      modules/corelib/ui/uicheckbox.lua
  35. 2
    1
      modules/corelib/ui/uicombobox.lua
  36. 1
    0
      modules/corelib/ui/uilabel.lua
  37. 3
    2
      modules/corelib/ui/uimessagebox.lua
  38. 4
    3
      modules/corelib/ui/uiminiwindow.lua
  39. 2
    1
      modules/corelib/ui/uiminiwindowcontainer.lua
  40. 3
    2
      modules/corelib/ui/uipopupmenu.lua
  41. 1
    0
      modules/corelib/ui/uiprogressbar.lua
  42. 8
    7
      modules/corelib/ui/uiradiogroup.lua
  43. 9
    8
      modules/corelib/ui/uiresizeborder.lua
  44. 1
    0
      modules/corelib/ui/uiscrollarea.lua
  45. 4
    3
      modules/corelib/ui/uiscrollbar.lua
  46. 2
    1
      modules/corelib/ui/uispinbox.lua
  47. 9
    8
      modules/corelib/ui/uisplitter.lua
  48. 3
    2
      modules/corelib/ui/uitabbar.lua
  49. 2
    0
      modules/corelib/ui/uiwidget.lua
  50. 1
    0
      modules/corelib/ui/uiwindow.lua
  51. 11
    2
      modules/corelib/util.lua
  52. 4
    0
      modules/game/const.lua
  53. 6
    0
      modules/game/creature.lua
  54. 8
    6
      modules/game/player.lua
  55. 1
    0
      modules/game/protocollogin.lua
  56. 6
    6
      modules/game_battle/battle.lua
  57. 4
    4
      modules/game_bugreport/bugreport.lua
  58. 2
    2
      modules/game_combatcontrols/combatcontrols.lua
  59. 19
    19
      modules/game_console/console.lua
  60. 3
    3
      modules/game_containers/containers.lua
  61. 4
    4
      modules/game_healthbar/healthbar.lua
  62. 19
    19
      modules/game_hotkeys/hotkeys_manager.lua
  63. 43
    41
      modules/game_interface/gameinterface.lua
  64. 0
    2
      modules/game_interface/interface.otmod
  65. 4
    4
      modules/game_interface/widgets/uigamemap.lua
  66. 4
    4
      modules/game_interface/widgets/uiitem.lua
  67. 3
    3
      modules/game_inventory/inventory.lua
  68. 3
    3
      modules/game_minimap/minimap.lua
  69. 5
    5
      modules/game_npctrade/npctrade.lua
  70. 2
    2
      modules/game_outfit/outfit.lua
  71. 3
    3
      modules/game_playertrade/playertrade.lua
  72. 6
    6
      modules/game_questlog/questlog.lua
  73. 12
    12
      modules/game_ruleviolation/ruleviolation.lua
  74. 4
    4
      modules/game_shaders/shaders.lua
  75. 3
    3
      modules/game_skills/skills.lua
  76. 3
    3
      modules/game_textbooks/textbooks.lua
  77. 3
    3
      modules/game_textmessage/textmessage.lua
  78. 7
    7
      modules/game_viplist/viplist.lua
  79. 1
    1
      modules/otclientrc.lua
  80. 4
    4
      src/framework/application.cpp
  81. 1
    1
      src/framework/core/eventdispatcher.cpp
  82. 2
    2
      src/framework/core/eventdispatcher.h
  83. 1
    1
      src/framework/core/logger.cpp
  84. 2
    2
      src/framework/graphics/animatedtexture.cpp
  85. 6
    5
      src/framework/luafunctions.cpp
  86. 6
    2
      src/framework/luascript/luabinder.h
  87. 1
    1
      src/framework/net/connection.cpp
  88. 1
    1
      src/framework/ui/uigridlayout.cpp
  89. 1
    1
      src/framework/ui/uihorizontallayout.cpp
  90. 1
    1
      src/framework/ui/uilayout.cpp
  91. 4
    4
      src/framework/ui/uimanager.cpp
  92. 2
    1
      src/framework/ui/uimanager.h
  93. 1
    1
      src/framework/ui/uiverticallayout.cpp
  94. 3
    3
      src/framework/ui/uiwidget.cpp
  95. 1
    1
      src/otclient/core/animatedtext.cpp
  96. 4
    4
      src/otclient/core/creature.cpp
  97. 1
    1
      src/otclient/core/effect.cpp
  98. 0
    238
      src/otclient/core/itemloader.cpp
  99. 1
    1
      src/otclient/core/localplayer.cpp
  100. 0
    0
      src/otclient/core/map.cpp

+ 3
- 2
.gitignore View File

@@ -17,8 +17,9 @@ Makefile
17 17
 *~
18 18
 *.kate-swap
19 19
 CMakeLists.txt.user*
20
-items.xml
21
-items.otb
20
+*.xml
21
+*.otb
22
+*.otbm
22 23
 *.log
23 24
 /modules/myconfig.otml
24 25
 /modules/myotclientrc.lua

+ 5
- 0
TODO View File

@@ -76,3 +76,8 @@ terminate rework of ui events propagation  (for Key events)
76 76
 * lua engine
77 77
 make possible to bind non LuaObject derived classes on lua engine (for usage with Point,Rect,Color,Size)
78 78
 review usage of x,y/width,height in lua instead of point/size
79
+
80
+* modules system
81
+use one isolated environment for each module
82
+
83
+

+ 1
- 1
init.lua View File

@@ -47,4 +47,4 @@ if g_resources.fileExists("/otclientrc.lua") then
47 47
     dofile("/otclientrc.lua")
48 48
 end
49 49
 
50
-g_things.loadOtb('/items.otb')
50
+g_things.loadOtb('/lalal.otb')

+ 7
- 7
modules/client/client.lua View File

@@ -1,7 +1,7 @@
1 1
 Client = {}
2 2
 
3 3
 function Client.reloadScripts()
4
-  reloadModules()
4
+  g_modules.reloadModules()
5 5
   dofile '/otclientrc'
6 6
   local message = tr('All modules and scripts were reloaded.')
7 7
   TextMessage.displayEventAdvance(message)
@@ -17,18 +17,18 @@ function Client.init()
17 17
   else
18 18
     -- window size
19 19
     local size = { width = 800, height = 600 }
20
-    size = Settings.getSize('window-size', size)
20
+    size = g_settings.getSize('window-size', size)
21 21
     g_window.resize(size)
22 22
 
23 23
     -- window position, default is the screen center
24 24
     local displaySize = g_window.getDisplaySize()
25 25
     local defaultPos = { x = (displaySize.width - size.width)/2,
26 26
                          y = (displaySize.height - size.height)/2 }
27
-    local pos = Settings.getPoint('window-pos', defaultPos)
27
+    local pos = g_settings.getPoint('window-pos', defaultPos)
28 28
     g_window.move(pos)
29 29
 
30 30
     -- window maximized?
31
-    local maximized = Settings.getBoolean('window-maximized', false)
31
+    local maximized = g_settings.getBoolean('window-maximized', false)
32 32
     if maximized then g_window.maximize() end
33 33
   end
34 34
 
@@ -47,8 +47,8 @@ end
47 47
 
48 48
 function Client.terminate()
49 49
   -- save window configs
50
-  Settings.set('window-size', g_window.getUnmaximizedSize())
51
-  Settings.set('window-pos', g_window.getUnmaximizedPos())
52
-  Settings.set('window-maximized', g_window.isMaximized())
50
+  g_settings.set('window-size', g_window.getUnmaximizedSize())
51
+  g_settings.set('window-pos', g_window.getUnmaximizedPos())
52
+  g_settings.set('window-maximized', g_window.isMaximized())
53 53
   Client = nil
54 54
 end

+ 3
- 3
modules/client_background/background.lua View File

@@ -5,7 +5,7 @@ local background
5 5
 
6 6
 -- public functions
7 7
 function Background.init()
8
-  background = displayUI('background.otui')
8
+  background = g_ui.displayUI('background.otui')
9 9
   background:lower()
10 10
 
11 11
   local clientVersionLabel = background:getChildById('clientVersionLabel')
@@ -15,7 +15,7 @@ function Background.init()
15 15
                              'Built on ' .. g_app.getBuildDate())
16 16
 
17 17
   if not g_game.isOnline() then
18
-    Effects.fadeIn(clientVersionLabel, 1500)
18
+    g_effects.fadeIn(clientVersionLabel, 1500)
19 19
   end
20 20
 
21 21
   connect(g_game, { onGameStart = Background.hide })
@@ -26,7 +26,7 @@ function Background.terminate()
26 26
   disconnect(g_game, { onGameStart = Background.hide })
27 27
   disconnect(g_game, { onGameEnd = Background.show })
28 28
 
29
-  Effects.cancelFade(background:getChildById('clientVersionLabel'))
29
+  g_effects.cancelFade(background:getChildById('clientVersionLabel'))
30 30
   background:destroy()
31 31
   background = nil
32 32
 

+ 5
- 5
modules/client_entergame/characterlist.lua View File

@@ -40,7 +40,7 @@ local function tryLogin(charInfo, tries)
40 40
                                 end })
41 41
 
42 42
   -- save last used character
43
-  Settings.set('lastUsedCharacter', charInfo.characterName)
43
+  g_settings.set('lastUsedCharacter', charInfo.characterName)
44 44
 end
45 45
 
46 46
 local function updateWait(timeStart, timeEnd)
@@ -92,7 +92,7 @@ end
92 92
 local function onLoginWait(message, time)
93 93
   CharacterList.destroyLoadBox()
94 94
 
95
-  waitingWindow = displayUI('waitinglist.otui')
95
+  waitingWindow = g_ui.loadUI('waitinglist.otui')
96 96
 
97 97
   local label = waitingWindow:getChildById('infoLabel')
98 98
   label:setText(message)
@@ -134,7 +134,7 @@ end
134 134
 
135 135
 -- public functions
136 136
 function CharacterList.init()
137
-  charactersWindow = displayUI('characterlist.otui')
137
+  charactersWindow = g_ui.displayUI('characterlist.otui')
138 138
   charactersWindow:hide()
139 139
   characterList = charactersWindow:getChildById('characterList')
140 140
   charactersWindow.onKeyPress = onCharactersWindowKeyPress
@@ -196,7 +196,7 @@ function CharacterList.create(characters, premDays)
196 196
     local worldHost = characterInfo[3]
197 197
     local worldIp = characterInfo[4]
198 198
 
199
-    local label = createWidget('CharacterListLabel', characterList)
199
+    local label = g_ui.createWidget('CharacterListLabel', characterList)
200 200
     label:setText(characterName .. '  (' .. worldName .. ')')
201 201
     label:setPhantom(false)
202 202
     label.characterName = characterName
@@ -205,7 +205,7 @@ function CharacterList.create(characters, premDays)
205 205
 
206 206
     connect(label, { onDoubleClick = function () CharacterList.doLogin() return true end } )
207 207
 
208
-    if i == 1 or Settings.get('lastUsedCharacter') == characterName then
208
+    if i == 1 or g_settings.get('lastUsedCharacter') == characterName then
209 209
       focusLabel = label
210 210
     end
211 211
   end

+ 17
- 17
modules/client_entergame/entergame.lua View File

@@ -11,8 +11,8 @@ local function clearAccountFields()
11 11
   enterGame:getChildById('accountNameTextEdit'):clearText()
12 12
   enterGame:getChildById('accountPasswordTextEdit'):clearText()
13 13
   enterGame:getChildById('accountNameTextEdit'):focus()
14
-  Settings.remove('account')
15
-  Settings.remove('password')
14
+  g_settings.remove('account')
15
+  g_settings.remove('password')
16 16
 end
17 17
 
18 18
 local function onError(protocol, message, connectionError)
@@ -34,9 +34,9 @@ end
34 34
 
35 35
 local function onCharacterList(protocol, characters, premDays)
36 36
   if enterGame:getChildById('rememberPasswordBox'):isChecked() then
37
-    Settings.set('account', g_crypt.encrypt(G.account))
38
-    Settings.set('password', g_crypt.encrypt(G.password))
39
-    Settings.set('autologin', enterGame:getChildById('autoLoginBox'):isChecked())
37
+    g_settings.set('account', g_crypt.encrypt(G.account))
38
+    g_settings.set('password', g_crypt.encrypt(G.password))
39
+    g_settings.set('autologin', enterGame:getChildById('autoLoginBox'):isChecked())
40 40
   else
41 41
     clearAccountFields()
42 42
   end
@@ -47,9 +47,9 @@ local function onCharacterList(protocol, characters, premDays)
47 47
   CharacterList.create(characters, premDays)
48 48
   CharacterList.show()
49 49
 
50
-  local lastMotdNumber = Settings.getNumber("motd")
50
+  local lastMotdNumber = g_settings.getNumber("motd")
51 51
   if G.motdNumber and G.motdNumber ~= lastMotdNumber then
52
-    Settings.set("motd", motdNumber)
52
+    g_settings.set("motd", motdNumber)
53 53
     local motdBox = displayInfoBox(tr('Message of the day'), G.motdMessage)
54 54
     connect(motdBox, { onOk = CharacterList.show })
55 55
     CharacterList.hide()
@@ -58,21 +58,21 @@ end
58 58
 
59 59
 -- public functions
60 60
 function EnterGame.init()
61
-  enterGame = displayUI('entergame.otui')
61
+  enterGame = g_ui.displayUI('entergame.otui')
62 62
   enterGameButton = TopMenu.addLeftButton('enterGameButton', tr('Login') .. ' (Ctrl + G)', 'login.png', EnterGame.openWindow)
63 63
   motdButton = TopMenu.addLeftButton('motdButton', tr('Message of the day'), 'motd.png', EnterGame.displayMotd)
64 64
   motdButton:hide()
65
-  Keyboard.bindKeyDown('Ctrl+G', EnterGame.openWindow)
65
+  g_keyboard.bindKeyDown('Ctrl+G', EnterGame.openWindow)
66 66
 
67 67
   if G.motdNumber then
68 68
     motdButton:show()
69 69
   end
70 70
 
71
-  local account = g_crypt.decrypt(Settings.get('account'))
72
-  local password = g_crypt.decrypt(Settings.get('password'))
73
-  local host = Settings.get('host')
74
-  local port = Settings.get('port')
75
-  local autologin = Settings.getBoolean('autologin')
71
+  local account = g_crypt.decrypt(g_settings.get('account'))
72
+  local password = g_crypt.decrypt(g_settings.get('password'))
73
+  local host = g_settings.get('host')
74
+  local port = g_settings.get('port')
75
+  local autologin = g_settings.getBoolean('autologin')
76 76
 
77 77
   enterGame:getChildById('accountNameTextEdit'):setText(account)
78 78
   enterGame:getChildById('accountPasswordTextEdit'):setText(password)
@@ -93,7 +93,7 @@ function EnterGame.init()
93 93
 end
94 94
 
95 95
 function EnterGame.terminate()
96
-  Keyboard.unbindKeyDown('Ctrl+G')
96
+  g_keyboard.unbindKeyDown('Ctrl+G')
97 97
   enterGame:destroy()
98 98
   enterGame = nil
99 99
   enterGameButton:destroy()
@@ -128,8 +128,8 @@ function EnterGame.doLogin()
128 128
   G.port = tonumber(enterGame:getChildById('serverPortTextEdit'):getText())
129 129
   EnterGame.hide()
130 130
 
131
-  Settings.set('host', G.host)
132
-  Settings.set('port', G.port)
131
+  g_settings.set('host', G.host)
132
+  g_settings.set('port', G.port)
133 133
 
134 134
   local protocolLogin = ProtocolLogin.create()
135 135
   protocolLogin.onError = onError

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

@@ -21,9 +21,9 @@ end
21 21
 
22 22
 local function onLocaleComboBoxOptionChange(self, optionText, optionData)
23 23
   if Locales.setLocale(optionData) then
24
-    Settings.set('locale', optionData)
24
+    g_settings.set('locale', optionData)
25 25
     sendLocale(currentLocale.name)
26
-    reloadModules()
26
+    g_modules.reloadModules()
27 27
   end
28 28
 end
29 29
 
@@ -45,17 +45,17 @@ function Locales.init()
45 45
 
46 46
   Locales.installLocales('locales')
47 47
 
48
-  local userLocaleName = Settings.get('locale', 'false')
48
+  local userLocaleName = g_settings.get('locale', 'false')
49 49
   if userLocaleName ~= 'false' and Locales.setLocale(userLocaleName) then
50 50
     pdebug('Using configured locale: ' .. userLocaleName)
51 51
   else
52 52
     pdebug('Using default locale: ' .. defaultLocaleName)
53 53
     Locales.setLocale(defaultLocaleName)
54
-    Settings.set('locale', defaultLocaleName)
54
+    g_settings.set('locale', defaultLocaleName)
55 55
   end
56 56
 
57 57
   addEvent( function()
58
-              localeComboBox = createWidget('ComboBox', rootWidget:recursiveGetChildById('rightButtonsPanel'))
58
+              localeComboBox = g_ui.createWidget('ComboBox', rootWidget:recursiveGetChildById('rightButtonsPanel'))
59 59
               for key,value in pairs(installedLocales) do
60 60
                 localeComboBox:addOption(value.languageName, value.name)
61 61
               end

+ 5
- 5
modules/client_modulemanager/modulemanager.lua View File

@@ -5,7 +5,7 @@ local moduleManagerButton
5 5
 local moduleList
6 6
 
7 7
 function ModuleManager.init()
8
-  moduleManagerWindow = displayUI('modulemanager.otui')
8
+  moduleManagerWindow = g_ui.displayUI('modulemanager.otui')
9 9
   moduleManagerWindow:hide()
10 10
   moduleList = moduleManagerWindow:getChildById('moduleList')
11 11
   connect(moduleList, { onChildFocusChange = function(self, focusedChild)
@@ -13,8 +13,8 @@ function ModuleManager.init()
13 13
                           ModuleManager.updateModuleInfo(focusedChild:getText())
14 14
                         end })
15 15
 
16
-  Keyboard.bindKeyPress('Up', function() moduleList:focusPreviousChild(KeyboardFocusReason) end, moduleManagerWindow)
17
-  Keyboard.bindKeyPress('Down', function() moduleList:focusNextChild(KeyboardFocusReason) end, moduleManagerWindow)
16
+  g_keyboard.bindKeyPress('Up', function() moduleList:focusPreviousChild(KeyboardFocusReason) end, moduleManagerWindow)
17
+  g_keyboard.bindKeyPress('Down', function() moduleList:focusNextChild(KeyboardFocusReason) end, moduleManagerWindow)
18 18
 
19 19
   moduleManagerButton = TopMenu.addLeftButton('moduleManagerButton', tr('Module Manager'), 'modulemanager.png', ModuleManager.toggle)
20 20
 
@@ -61,7 +61,7 @@ function ModuleManager.listModules()
61 61
 
62 62
   local modules = g_modules.getModules()
63 63
   for i,module in ipairs(modules) do
64
-    local label = createWidget('ModuleListLabel', moduleList)
64
+    local label = g_ui.createWidget('ModuleListLabel', moduleList)
65 65
     label:setText(module:getName())
66 66
     label:setOn(module:isLoaded())
67 67
   end
@@ -146,7 +146,7 @@ function ModuleManager.unloadCurrentModule()
146 146
 end
147 147
 
148 148
 function ModuleManager.reloadAllModules()
149
-  g_modules.reloadModules()
149
+  g_modules.g_modules.reloadModules()
150 150
   ModuleManager.refreshLoadedModules()
151 151
   ModuleManager.show()
152 152
 end

+ 11
- 11
modules/client_options/options.lua View File

@@ -20,7 +20,7 @@ local generalPanel
20 20
 local graphicsPanel
21 21
 
22 22
 local function setupGraphicsEngines()
23
-  local enginesRadioGroup = RadioGroup.create()
23
+  local enginesRadioGroup = UIRadioGroup.create()
24 24
   local ogl1 = graphicsPanel:getChildById('opengl1')
25 25
   local ogl2 = graphicsPanel:getChildById('opengl2')
26 26
   enginesRadioGroup:addWidget(ogl1)
@@ -56,32 +56,32 @@ function Options.init()
56 56
   -- load options
57 57
   for k,v in pairs(options) do
58 58
     if type(v) == 'boolean' then
59
-      Settings.setDefault(k, v)
60
-      Options.setOption(k, Settings.getBoolean(k))
59
+      g_settings.setDefault(k, v)
60
+      Options.setOption(k, g_settings.getBoolean(k))
61 61
     end
62 62
   end
63 63
 
64
-  Keyboard.bindKeyDown('Ctrl+D', Options.toggle)
65
-  Keyboard.bindKeyDown('Ctrl+F', function() Options.toggleOption('fullscreen') end)
64
+  g_keyboard.bindKeyDown('Ctrl+D', Options.toggle)
65
+  g_keyboard.bindKeyDown('Ctrl+F', function() Options.toggleOption('fullscreen') end)
66 66
 
67
-  optionsWindow = displayUI('options.otui')
67
+  optionsWindow = g_ui.displayUI('options.otui')
68 68
   optionsWindow:hide()
69 69
   optionsButton = TopMenu.addLeftButton('optionsButton', tr('Options') .. ' (Ctrl+D)', 'options.png', Options.toggle)
70 70
   optionsTabBar = optionsWindow:getChildById('optionsTabBar')
71 71
   optionsTabBar:setContentWidget(optionsWindow:getChildById('optionsTabContent'))
72 72
 
73
-  generalPanel = loadUI('general.otui')
73
+  generalPanel = g_ui.loadUI('general.otui')
74 74
   optionsTabBar:addTab(tr('General'), generalPanel)
75 75
 
76
-  graphicsPanel = loadUI('graphics.otui')
76
+  graphicsPanel = g_ui.loadUI('graphics.otui')
77 77
   optionsTabBar:addTab(tr('Graphics'), graphicsPanel)
78 78
 
79 79
   setupGraphicsEngines()
80 80
 end
81 81
 
82 82
 function Options.terminate()
83
-  Keyboard.unbindKeyDown('Ctrl+D')
84
-  Keyboard.unbindKeyDown('Ctrl+F')
83
+  g_keyboard.unbindKeyDown('Ctrl+D')
84
+  g_keyboard.unbindKeyDown('Ctrl+F')
85 85
   optionsWindow:destroy()
86 86
   optionsWindow = nil
87 87
   optionsButton:destroy()
@@ -135,7 +135,7 @@ function Options.setOption(key, value)
135 135
       GameInterface.getLeftPanel():setOn(value)
136 136
     end)
137 137
   end
138
-  Settings.set(key, value)
138
+  g_settings.set(key, value)
139 139
   options[key] = value
140 140
 end
141 141
 

+ 5
- 5
modules/client_skins/skins.lua View File

@@ -9,8 +9,8 @@ local skinComboBox
9 9
 -- private functions
10 10
 local function onSkinComboBoxOptionChange(self, optionText, optionData)
11 11
   if Skins.setSkin(optionText) then
12
-    Settings.set('skin', optionText)
13
-    reloadModules()
12
+    g_settings.set('skin', optionText)
13
+    g_modules.reloadModules()
14 14
   end
15 15
 end
16 16
 
@@ -29,17 +29,17 @@ function Skins.init()
29 29
     g_resources.addToSearchPath(getSkinPath(defaultSkinName), 0)
30 30
   end
31 31
 
32
-  local userSkinName = Settings.get('skin', 'false')
32
+  local userSkinName = g_settings.get('skin', 'false')
33 33
   if userSkinName ~= 'false' and Skins.setSkin(userSkinName) then
34 34
     pdebug('Using configured skin: ' .. userSkinName)
35 35
   else
36 36
     pdebug('Using default skin: ' .. defaultSkinName)
37 37
     Skins.setSkin(defaultSkinName)
38
-    Settings.set('skin', defaultSkinName)
38
+    g_settings.set('skin', defaultSkinName)
39 39
   end
40 40
 
41 41
   addEvent( function()
42
-              skinComboBox = createWidget('ComboBox', rootWidget:recursiveGetChildById('rightButtonsPanel'))
42
+              skinComboBox = g_ui.createWidget('ComboBox', rootWidget:recursiveGetChildById('rightButtonsPanel'))
43 43
               for key,value in pairs(installedSkins) do
44 44
                 skinComboBox:addOption(value.name)
45 45
               end

+ 2
- 2
modules/client_terminal/commands.lua View File

@@ -34,9 +34,9 @@ function debugContainersItems()
34 34
   function UIItem:onHoverChange(hovered)
35 35
     if hovered then
36 36
       local item = self:getItem()
37
-      if item then ToolTip.display(item:getId()) end
37
+      if item then g_tooltip.display(item:getId()) end
38 38
     else
39
-      ToolTip.hide()
39
+      g_tooltip.hide()
40 40
     end
41 41
   end
42 42
 end

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

@@ -107,7 +107,7 @@ end
107 107
 
108 108
 -- public functions
109 109
 function Terminal.init()
110
-  terminalWindow = displayUI('terminal.otui')
110
+  terminalWindow = g_ui.displayUI('terminal.otui')
111 111
   terminalWindow:setVisible(false)
112 112
 
113 113
   local poped = false
@@ -128,16 +128,16 @@ function Terminal.init()
128 128
   end
129 129
 
130 130
   terminalButton = TopMenu.addLeftButton('terminalButton', tr('Terminal') .. ' (Ctrl + T)', 'terminal.png', Terminal.toggle)
131
-  Keyboard.bindKeyDown('Ctrl+T', Terminal.toggle)
131
+  g_keyboard.bindKeyDown('Ctrl+T', Terminal.toggle)
132 132
 
133
-  commandHistory = Settings.getList('terminal-history')
133
+  commandHistory = g_settings.getList('terminal-history')
134 134
 
135 135
   commandTextEdit = terminalWindow:getChildById('commandTextEdit')
136
-  Keyboard.bindKeyPress('Up', function() navigateCommand(1) end, commandTextEdit)
137
-  Keyboard.bindKeyPress('Down', function() navigateCommand(-1) end, commandTextEdit)
138
-  Keyboard.bindKeyDown('Tab', completeCommand, commandTextEdit)
139
-  Keyboard.bindKeyDown('Enter', doCommand, commandTextEdit)
140
-  Keyboard.bindKeyDown('Escape', Terminal.hide, terminalWindow)
136
+  g_keyboard.bindKeyPress('Up', function() navigateCommand(1) end, commandTextEdit)
137
+  g_keyboard.bindKeyPress('Down', function() navigateCommand(-1) end, commandTextEdit)
138
+  g_keyboard.bindKeyDown('Tab', completeCommand, commandTextEdit)
139
+  g_keyboard.bindKeyDown('Enter', doCommand, commandTextEdit)
140
+  g_keyboard.bindKeyDown('Escape', Terminal.hide, terminalWindow)
141 141
 
142 142
   terminalBuffer = terminalWindow:getChildById('terminalBuffer')
143 143
   g_logger.setOnLog(onLog)
@@ -145,8 +145,8 @@ function Terminal.init()
145 145
 end
146 146
 
147 147
 function Terminal.terminate()
148
-  Settings.setList('terminal-history', commandHistory)
149
-  Keyboard.unbindKeyDown('Ctrl+T')
148
+  g_settings.setList('terminal-history', commandHistory)
149
+  g_keyboard.unbindKeyDown('Ctrl+T')
150 150
   g_logger.setOnLog(nil)
151 151
   terminalButton:destroy()
152 152
   terminalButton = nil
@@ -184,7 +184,7 @@ function Terminal.addLine(text, color)
184 184
   end
185 185
 
186 186
   -- create new line label
187
-  local label = createWidget('TerminalLabel', terminalBuffer)
187
+  local label = g_ui.createWidget('TerminalLabel', terminalBuffer)
188 188
   label:setId('terminalLabel' .. numLines)
189 189
   label:setText(text)
190 190
   label:setColor(color)

+ 2
- 2
modules/client_topmenu/topmenu.lua View File

@@ -15,7 +15,7 @@ local function addButton(id, description, icon, callback, panel, toggle)
15 15
     class = 'TopButton'
16 16
   end
17 17
 
18
-  local button = createWidget(class, panel)
18
+  local button = g_ui.createWidget(class, panel)
19 19
   button:setId(id)
20 20
   button:setTooltip(description)
21 21
   button:setIcon(resolvepath(icon, 3))
@@ -28,7 +28,7 @@ function TopMenu.init()
28 28
   connect(g_game, { onGameStart = TopMenu.showGameButtons,
29 29
                     onGameEnd = TopMenu.hideGameButtons })
30 30
 
31
-  topMenu = displayUI('topmenu.otui')
31
+  topMenu = g_ui.displayUI('topmenu.otui')
32 32
 
33 33
   leftButtonsPanel = topMenu:getChildById('leftButtonsPanel')
34 34
   rightButtonsPanel = topMenu:getChildById('rightButtonsPanel')

+ 27
- 23
modules/corelib/const.lua View File

@@ -1,3 +1,5 @@
1
+-- @docconsts @{
2
+
1 3
 AnchorNone = 0
2 4
 AnchorTop = 1
3 5
 AnchorBottom = 2
@@ -169,6 +171,31 @@ KeyNumpad7 = 148
169 171
 KeyNumpad8 = 149
170 172
 KeyNumpad9 = 150
171 173
 
174
+SpeakSay = 1
175
+SpeakWhisper = 2
176
+SpeakYell = 3
177
+SpeakBroadcast = 4
178
+SpeakPrivate = 5
179
+SpeakPrivateRed = 6
180
+SpeakPrivatePlayerToNpc = 7
181
+SpeakPrivateNpcToPlayer = 8
182
+SpeakChannelYellow = 9
183
+SpeakChannelWhite = 10
184
+SpeakChannelRed = 11
185
+SpeakChannelOrange = 12
186
+SpeakMonsterSay = 13
187
+SpeakMonsterYell = 14
188
+
189
+
190
+FightOffensive = 1
191
+FightBalanced = 2
192
+FightDefensive = 3
193
+
194
+DontChase = 0
195
+ChaseOpponent = 1
196
+
197
+-- @}
198
+
172 199
 KeyCodeDescs = {
173 200
   [KeyUnknown] = 'Unknown',
174 201
   [KeyEscape] = 'Escape',
@@ -287,26 +314,3 @@ KeyCodeDescs = {
287 314
   [KeyNumpad8] = 'Numpad8',
288 315
   [KeyNumpad9] = 'Numpad9'
289 316
 }
290
-
291
-SpeakSay = 1
292
-SpeakWhisper = 2
293
-SpeakYell = 3
294
-SpeakBroadcast = 4
295
-SpeakPrivate = 5
296
-SpeakPrivateRed = 6
297
-SpeakPrivatePlayerToNpc = 7
298
-SpeakPrivateNpcToPlayer = 8
299
-SpeakChannelYellow = 9
300
-SpeakChannelWhite = 10
301
-SpeakChannelRed = 11
302
-SpeakChannelOrange = 12
303
-SpeakMonsterSay = 13
304
-SpeakMonsterYell = 14
305
-
306
-
307
-FightOffensive = 1
308
-FightBalanced = 2
309
-FightDefensive = 3
310
-
311
-DontChase = 0
312
-ChaseOpponent = 1

+ 3
- 4
modules/corelib/corelib.otmod View File

@@ -6,8 +6,9 @@ Module
6 6
   reloadable: false
7 7
 
8 8
   @onLoad: |
9
-    dofiles 'ext'
10
-    dofiles 'math'
9
+    dofile 'math'
10
+    dofile 'string'
11
+    dofile 'table'
11 12
 
12 13
     dofile 'const'
13 14
     dofile 'util'
@@ -17,5 +18,3 @@ Module
17 18
     dofile 'mouse'
18 19
 
19 20
     dofiles 'ui'
20
-    dofiles 'widgets'
21
-

+ 0
- 6
modules/corelib/ext/os.lua View File

@@ -1,6 +0,0 @@
1
-function os.execute(command)
2
-  local f = assert(io.popen(command, 'r'))
3
-  local data = assert(f:read('*a'))
4
-  f:close()
5
-  print(data)
6
-end

+ 0
- 45
modules/corelib/ext/string.lua View File

@@ -1,45 +0,0 @@
1
-function string.split(s, delim)
2
-  local start = 1
3
-  local results = {}
4
-  while true do
5
-    local pos = string.find(s, delim, start, true)
6
-    if not pos then
7
-      break
8
-    end
9
-    table.insert(results, string.sub(s, start, pos-1))
10
-    start = pos + string.len(delim)
11
-  end
12
-  table.insert(results, string.sub(s, start))
13
-  table.removevalue(results, '')
14
-  return results
15
-end
16
-
17
-function string.starts(s, start)
18
-  return string.sub(s, 1, #start) == start
19
-end
20
-
21
-function string.trim(s)
22
-  return string.match(s, '^%s*(.*%S)') or ''
23
-end
24
-
25
-function string.explode(str, sep, limit)
26
-  if(type(sep) ~= 'string' or tostring(str):len() == 0 or sep:len() == 0) then
27
-    return {}
28
-  end
29
-
30
-  local i, pos, tmp, t = 0, 1, "", {}
31
-  for s, e in function() return string.find(str, sep, pos) end do
32
-    tmp = str:sub(pos, s - 1):trim()
33
-    table.insert(t, tmp)
34
-    pos = e + 1
35
-
36
-    i = i + 1
37
-    if(limit ~= nil and i == limit) then
38
-      break
39
-    end
40
-  end
41
-
42
-  tmp = str:sub(pos):trim()
43
-  table.insert(t, tmp)
44
-  return t
45
-end

+ 9
- 55
modules/corelib/globals.lua View File

@@ -1,73 +1,36 @@
1
-rootWidget = g_ui.getRootWidget()
1
+-- @docvars @{
2 2
 
3
-importStyle = g_ui.importStyle
4
-importFont = g_fonts.importFont
5
-setDefaultFont = g_fonts.setDefaultFont
3
+-- root widget
4
+rootWidget = g_ui.getRootWidget()
6 5
 
7 6
 -- G is used as a global table to save variables in memory between reloads
8 7
 G = G or {}
9 8
 
10
-function loadUI(otui, parent)
11
-  local otuiFilePath = resolvepath(otui, 2)
12
-  return g_ui.loadUI(otuiFilePath, parent)
13
-end
9
+-- @}
14 10
 
15
-function displayUI(otui, parent)
16
-  parent = parent or rootWidget
17
-  local otuiFilePath = resolvepath(otui, 2)
18
-  return g_ui.loadUI(otuiFilePath, parent)
19
-end
20
-
21
-function createWidget(stylename, parent)
22
-  if type(parent) == 'string' then
23
-    parent = rootWidget:recursiveGetChildById(parent)
24
-  end
25
-  local widget = g_ui.createWidgetFromStyle(stylename, parent)
26
-  return widget
27
-end
11
+-- @docfuncs @{
28 12
 
29 13
 function scheduleEvent(callback, delay)
30
-  local event = g_eventDispatcher.scheduleEvent(callback, delay)
31
-
14
+  local event = g_dispatcher.scheduleEvent(callback, delay)
32 15
   -- must hold a reference to the callback, otherwise it would be collected
33 16
   event._callback = callback
34 17
   return event
35 18
 end
36 19
 
37 20
 function addEvent(callback, front)
38
-  local event = g_eventDispatcher.addEvent(callback, front)
21
+  local event = g_dispatcher.addEvent(callback, front)
39 22
   -- must hold a reference to the callback, otherwise it would be collected
40 23
   event._callback = callback
41 24
   return event
42 25
 end
43 26
 
44 27
 function cycleEvent(callback, front)
45
-  local event = g_eventDispatcher.cycleEvent(callback, front)
28
+  local event = g_dispatcher.cycleEvent(callback, front)
46 29
   -- must hold a reference to the callback, otherwise it would be collected
47 30
   event._callback = callback
48 31
   return event
49 32
 end
50 33
 
51
-
52
-function periodicalEvent(eventFunc, conditionFunc, delay, autoRepeatDelay)
53
-  delay = delay or 30
54
-  autoRepeatDelay = autoRepeatDelay or delay
55
-
56
-  local func
57
-  func = function()
58
-    if conditionFunc and not conditionFunc() then
59
-      func = nil
60
-      return
61
-    end
62
-    eventFunc()
63
-    scheduleEvent(func, delay)
64
-  end
65
-
66
-  scheduleEvent(function()
67
-    func()
68
-  end, autoRepeatDelay)
69
-end
70
-
71 34
 function removeEvent(event)
72 35
   if event then
73 36
     event:cancel()
@@ -75,13 +38,4 @@ function removeEvent(event)
75 38
   end
76 39
 end
77 40
 
78
-function reloadModule(name)
79
-  local module = g_modules.getModule(name)
80
-  if module then
81
-    module:reload()
82
-  end
83
-end
84
-
85
-function reloadModules()
86
-  g_modules.reloadModules()
87
-end
41
+-- @}

+ 10
- 9
modules/corelib/keyboard.lua View File

@@ -1,4 +1,5 @@
1
-Keyboard = {}
1
+-- @docclass
2
+g_keyboard = {}
2 3
 
3 4
 -- private functions
4 5
 function translateKeyCombo(keyCombo)
@@ -95,14 +96,14 @@ local function connectKeyPressEvent(widget)
95 96
 end
96 97
 
97 98
 -- public functions
98
-function Keyboard.bindKeyDown(keyComboDesc, callback, widget)
99
+function g_keyboard.bindKeyDown(keyComboDesc, callback, widget)
99 100
   widget = widget or rootWidget
100 101
   connectKeyDownEvent(widget)
101 102
   local keyComboDesc = retranslateKeyComboDesc(keyComboDesc)
102 103
   widget.boundKeyDownCombos[keyComboDesc] = callback
103 104
 end
104 105
 
105
-function Keyboard.bindKeyPress(keyComboDesc, callback, widget, autoRepeatDelay)
106
+function g_keyboard.bindKeyPress(keyComboDesc, callback, widget, autoRepeatDelay)
106 107
   autoRepeatDelay = autoRepeatDelay or 500
107 108
   widget = widget or rootWidget
108 109
   connectKeyPressEvent(widget)
@@ -111,7 +112,7 @@ function Keyboard.bindKeyPress(keyComboDesc, callback, widget, autoRepeatDelay)
111 112
   widget:setAutoRepeatDelay(math.min(autoRepeatDelay, widget:getAutoRepeatDelay()))
112 113
 end
113 114
 
114
-function Keyboard.unbindKeyDown(keyComboDesc, widget)
115
+function g_keyboard.unbindKeyDown(keyComboDesc, widget)
115 116
   widget = widget or rootWidget
116 117
   if widget.boundKeyDownCombos == nil then return end
117 118
   local keyComboDesc = retranslateKeyComboDesc(keyComboDesc)
@@ -120,7 +121,7 @@ function Keyboard.unbindKeyDown(keyComboDesc, widget)
120 121
   end
121 122
 end
122 123
 
123
-function Keyboard.unbindKeyPress(keyComboDesc, widget)
124
+function g_keyboard.unbindKeyPress(keyComboDesc, widget)
124 125
   widget = widget or rootWidget
125 126
   if widget.boundKeyPressCombos == nil then return end
126 127
   local keyComboDesc = retranslateKeyComboDesc(keyComboDesc)
@@ -129,18 +130,18 @@ function Keyboard.unbindKeyPress(keyComboDesc, widget)
129 130
   end
130 131
 end
131 132
 
132
-function Keyboard.getModifiers()
133
+function g_keyboard.getModifiers()
133 134
   return g_window.getKeyboardModifiers()
134 135
 end
135 136
 
136
-function Keyboard.isCtrlPressed()
137
+function g_keyboard.isCtrlPressed()
137 138
   return bit32.band(g_window.getKeyboardModifiers(), KeyboardCtrlModifier) ~= 0
138 139
 end
139 140
 
140
-function Keyboard.isAltPressed()
141
+function g_keyboard.isAltPressed()
141 142
   return bit32.band(g_window.getKeyboardModifiers(), KeyboardAltModifier) ~= 0
142 143
 end
143 144
 
144
-function Keyboard.isShiftPressed()
145
+function g_keyboard.isShiftPressed()
145 146
   return bit32.band(g_window.getKeyboardModifiers(), KeyboardShiftModifier) ~= 0
146 147
 end

+ 10
- 0
modules/corelib/math.lua View File

@@ -0,0 +1,10 @@
1
+-- @docclass math
2
+
3
+function math.round(num, idp)
4
+  local mult = 10^(idp or 0)
5
+  if num >= 0 then
6
+      return math.floor(num * mult + 0.5) / mult
7
+  else
8
+      return math.ceil(num * mult - 0.5) / mult
9
+  end
10
+end

+ 0
- 1
modules/corelib/math/color.lua View File

@@ -1 +0,0 @@
1
-Color = {}

+ 0
- 8
modules/corelib/math/math.lua View File

@@ -1,8 +0,0 @@
1
-function math.round(num, idp)
2
-    local mult = 10^(idp or 0)
3
-    if num >= 0 then 
4
-    	return math.floor(num * mult + 0.5) / mult
5
-    else 
6
-    	return math.ceil(num * mult - 0.5) / mult
7
-    end
8
-end

+ 0
- 1
modules/corelib/math/point.lua View File

@@ -1 +0,0 @@
1
-Point = {}

+ 0
- 1
modules/corelib/math/rect.lua View File

@@ -1 +0,0 @@
1
-Rect = {}

+ 0
- 1
modules/corelib/math/size.lua View File

@@ -1 +0,0 @@
1
-Size = {}

+ 10
- 9
modules/corelib/mouse.lua View File

@@ -1,37 +1,38 @@
1
-Mouse = {}
1
+-- @docclass
2
+g_mouse = {}
2 3
 
3 4
 local cursorChanged = false
4 5
 
5
-function Mouse.setTargetCursor()
6
+function g_mouse.setTargetCursor()
6 7
   g_window.setMouseCursor('/cursors/targetcursor.png', {x=9,y=9})
7 8
   cursorChanged = true
8 9
 end
9 10
 
10
-function Mouse.setHorizontalCursor()
11
+function g_mouse.setHorizontalCursor()
11 12
   g_window.setMouseCursor('/cursors/horizontal.png', {x=9,y=4})
12 13
   cursorChanged = true
13 14
 end
14 15
 
15
-function Mouse.setVerticalCursor()
16
+function g_mouse.setVerticalCursor()
16 17
   g_window.setMouseCursor('/cursors/vertical.png', {x=4,y=9})
17 18
   cursorChanged = true
18 19
 end
19 20
 
20
-function Mouse.restoreCursor()
21
+function g_mouse.restoreCursor()
21 22
   g_window.restoreMouseCursor()
22 23
   cursorChanged = false
23 24
 end
24 25
 
25
-function Mouse.isCursorChanged()
26
+function g_mouse.isCursorChanged()
26 27
   return cursorChanged
27 28
 end
28 29
 
29
-function Mouse.isPressed(button)
30
+function g_mouse.isPressed(button)
30 31
   if not button then button = MouseLeftButton end
31 32
   return g_window.isMouseButtonPressed(button)
32 33
 end
33 34
 
34
-function Mouse.bindAutoPress(widget, callback)
35
+function g_mouse.bindAutoPress(widget, callback)
35 36
   connect(widget, { onMousePress = function(widget, mousePos, mouseButton)
36 37
     callback()
37 38
     periodicalEvent(function()
@@ -43,7 +44,7 @@ function Mouse.bindAutoPress(widget, callback)
43 44
   end })
44 45
 end
45 46
 
46
-function Mouse.bindPressMove(widget, callback)
47
+function g_mouse.bindPressMove(widget, callback)
47 48
   connect(widget, { onMouseMove = function(widget, mousePos, mouseMoved)
48 49
     if widget:isPressed() then
49 50
       callback(mousePos, mouseMoved)

+ 34
- 33
modules/corelib/settings.lua View File

@@ -1,12 +1,13 @@
1
-Settings = {}
1
+-- @docclass
2
+g_settings = {}
2 3
 
3
-Settings.exists = g_configs.exists
4
-Settings.setNode = g_configs.setNode
5
-Settings.mergeNode = g_configs.mergeNode
6
-Settings.getNode = g_configs.getNode
7
-Settings.remove = g_configs.remove
8
-Settings.setList = g_configs.setList
9
-Settings.getList = g_configs.getList
4
+g_settings.exists = g_configs.exists
5
+g_settings.setNode = g_configs.setNode
6
+g_settings.mergeNode = g_configs.mergeNode
7
+g_settings.getNode = g_configs.getNode
8
+g_settings.remove = g_configs.remove
9
+g_settings.setList = g_configs.setList
10
+g_settings.getList = g_configs.getList
10 11
 
11 12
 local function convertSettingValue(value)
12 13
   if type(value) == 'table' then
@@ -28,55 +29,55 @@ local function convertSettingValue(value)
28 29
   end
29 30
 end
30 31
 
31
-function Settings.set(key, value)
32
+function g_settings.set(key, value)
32 33
   g_configs.set(key, convertSettingValue(value))
33 34
 end
34 35
 
35
-function Settings.setDefault(key, value)
36
-  if Settings.exists(key) then return false end
37
-  Settings.set(key, value)
36
+function g_settings.setDefault(key, value)
37
+  if g_settings.exists(key) then return false end
38
+  g_settings.set(key, value)
38 39
   return true
39 40
 end
40 41
 
41
-function Settings.get(key, default)
42
-  if not Settings.exists(key) and default ~= nil then
43
-    Settings.set(key, default)
42
+function g_settings.get(key, default)
43
+  if not g_settings.exists(key) and default ~= nil then
44
+    g_settings.set(key, default)
44 45
   end
45 46
   return g_configs.get(key)
46 47
 end
47 48
 
48
-function Settings.getString(key, default)
49
-  return Settings.get(key, default)
49
+function g_settings.getString(key, default)
50
+  return g_settings.get(key, default)
50 51
 end
51 52
 
52
-function Settings.getInteger(key, default)
53
-  return tonumber(Settings.get(key, default))
53
+function g_settings.getInteger(key, default)
54
+  return tonumber(g_settings.get(key, default))
54 55
 end
55 56
 
56
-function Settings.getNumber(key, default)
57
-  return tonumber(Settings.get(key, default))
57
+function g_settings.getNumber(key, default)
58
+  return tonumber(g_settings.get(key, default))
58 59
 end
59 60
 
60
-function Settings.getBoolean(key, default)
61
-  return toboolean(Settings.get(key, default))
61
+function g_settings.getBoolean(key, default)
62
+  return toboolean(g_settings.get(key, default))
62 63
 end
63 64
 
64
-function Settings.getPoint(key, default)
65
-  return topoint(Settings.get(key, default))
65
+function g_settings.getPoint(key, default)
66
+  return topoint(g_settings.get(key, default))
66 67
 end
67 68
 
68
-function Settings.getRect(key, default)
69
-  return torect(Settings.get(key, default))
69
+function g_settings.getRect(key, default)
70
+  return torect(g_settings.get(key, default))
70 71
 end
71 72
 
72
-function Settings.getSize(key, default)
73
-  return tosize(Settings.get(key, default))
73
+function g_settings.getSize(key, default)
74
+  return tosize(g_settings.get(key, default))
74 75
 end
75 76
 
76
-function Settings.getColor(key, default)
77
-  return tocolor(Settings.get(key, default))
77
+function g_settings.getColor(key, default)
78
+  return tocolor(g_settings.get(key, default))
78 79
 end
79 80
 
80
-function Settings.getColor(key, default)
81
-  return tocolor(Settings.get(key, default))
81
+function g_settings.getColor(key, default)
82
+  return tocolor(g_settings.get(key, default))
82 83
 end

+ 47
- 0
modules/corelib/string.lua View File

@@ -0,0 +1,47 @@
1
+-- @docclass string
2
+
3
+function string:split(delim)
4
+  local start = 1
5
+  local results = {}
6
+  while true do
7
+    local pos = string.find(self, delim, start, true)
8
+    if not pos then
9
+      break
10
+    end
11
+    table.insert(results, string.sub(self, start, pos-1))
12
+    start = pos + string.len(delim)
13
+  end
14
+  table.insert(results, string.sub(self, start))
15
+  table.removevalue(results, '')
16
+  return results
17
+end
18
+
19
+function string:starts(start)
20
+  return string.sub(self, 1, #start) == start
21
+end
22
+
23
+function string:trim()
24
+  return string.match(self, '^%s*(.*%S)') or ''
25
+end
26
+
27
+function string:explode(sep, limit)
28
+  if(type(sep) ~= 'string' or tostring(self):len() == 0 or sep:len() == 0) then
29
+    return {}
30
+  end
31
+
32
+  local i, pos, tmp, t = 0, 1, "", {}
33
+  for s, e in function() return string.find(self, sep, pos) end do
34
+    tmp = self:sub(pos, s - 1):trim()
35
+    table.insert(t, tmp)
36
+    pos = e + 1
37
+
38
+    i = i + 1
39
+    if(limit ~= nil and i == limit) then
40
+      break
41
+    end
42
+  end
43
+
44
+  tmp = self:sub(pos):trim()
45
+  table.insert(t, tmp)
46
+  return t
47
+end

modules/corelib/ext/table.lua → modules/corelib/table.lua View File

@@ -1,3 +1,5 @@
1
+-- @docclass table
2
+
1 3
 function table.dump(t, depth)
2 4
   if not depth then depth = 0 end
3 5
   for k,v in pairs(t) do

+ 7
- 6
modules/corelib/ui/effects.lua View File

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

+ 20
- 14
modules/corelib/ui/tooltip.lua View File

@@ -1,4 +1,5 @@
1
-ToolTip = {}
1
+-- @docclass
2
+g_tooltip = {}
2 3
 
3 4
 -- private variables
4 5
 local toolTipLabel
@@ -21,13 +22,13 @@ end
21 22
 
22 23
 local function onWidgetHoverChange(widget, hovered)
23 24
   if hovered then
24
-    if widget.tooltip and not Mouse.isPressed() then
25
-      ToolTip.display(widget.tooltip)
25
+    if widget.tooltip and not g_mouse.isPressed() then
26
+      g_tooltip.display(widget.tooltip)
26 27
       currentHoveredWidget = widget
27 28
     end
28 29
   else
29 30
     if widget == currentHoveredWidget then
30
-      ToolTip:hide()
31
+      g_tooltip.hide()
31 32
       currentHoveredWidget = nil
32 33
     end
33 34
   end
@@ -40,12 +41,12 @@ local function onWidgetStyleApply(widget, styleName, styleNode)
40 41
 end
41 42
 
42 43
 -- public functions
43
-function ToolTip.init()
44
+function g_tooltip.init()
44 45
   connect(UIWidget, {  onStyleApply = onWidgetStyleApply,
45 46
                        onHoverChange = onWidgetHoverChange})
46 47
 
47 48
   addEvent(function()
48
-    toolTipLabel = createWidget('UILabel', rootWidget)
49
+    toolTipLabel = g_ui.createWidget('UILabel', rootWidget)
49 50
     toolTipLabel:setId('toolTip')
50 51
     toolTipLabel:setBackgroundColor('#111111cc')
51 52
     toolTipLabel:setTextAlign(AlignCenter)
@@ -54,7 +55,7 @@ function ToolTip.init()
54 55
   end)
55 56
 end
56 57
 
57
-function ToolTip.terminate()
58
+function g_tooltip.terminate()
58 59
   disconnect(UIWidget, { onStyleApply = onWidgetStyleApply,
59 60
                          onHoverChange = onWidgetHoverChange })
60 61
 
@@ -62,10 +63,10 @@ function ToolTip.terminate()
62 63
   toolTipLabel:destroy()
63 64
   toolTipLabel = nil
64 65
 
65
-  ToolTip = nil
66
+  g_tooltip = nil
66 67
 end
67 68
 
68
-function ToolTip.display(text)
69
+function g_tooltip.display(text)
69 70
   if text == nil then return end
70 71
   if not toolTipLabel then return end
71 72
 
@@ -75,14 +76,17 @@ function ToolTip.display(text)
75 76
   toolTipLabel:show()
76 77
   toolTipLabel:raise()
77 78
   toolTipLabel:enable()
78
-  Effects.fadeIn(toolTipLabel, 100)
79
+  g_effects.fadeIn(toolTipLabel, 100)
79 80
   moveToolTip(toolTipLabel)
80 81
 end
81 82
 
82
-function ToolTip.hide()
83
-  Effects.fadeOut(toolTipLabel, 100)
83
+function g_tooltip.hide()
84
+  g_effects.fadeOut(toolTipLabel, 100)
84 85
 end
85 86
 
87
+
88
+-- @docclass UIWidget @{
89
+
86 90
 -- UIWidget extensions
87 91
 function UIWidget:setTooltip(text)
88 92
   self.tooltip = text
@@ -92,5 +96,7 @@ function UIWidget:getTooltip()
92 96
   return self.tooltip
93 97
 end
94 98
 
95
-ToolTip.init()
96
-connect(g_app, { onTerminate = ToolTip.terminate })
99
+-- @}
100
+
101
+g_tooltip.init()
102
+connect(g_app, { onTerminate = g_tooltip.terminate })

modules/corelib/widgets/uibutton.lua → modules/corelib/ui/uibutton.lua View File

@@ -1,3 +1,4 @@
1
+-- @docclass
1 2
 UIButton = extends(UIWidget)
2 3
 
3 4
 function UIButton.create()

modules/corelib/widgets/uicheckbox.lua → modules/corelib/ui/uicheckbox.lua View File

@@ -1,3 +1,4 @@
1
+-- @docclass
1 2
 UICheckBox = extends(UIWidget)
2 3
 
3 4
 function UICheckBox.create()

modules/corelib/widgets/uicombobox.lua → modules/corelib/ui/uicombobox.lua View File

@@ -1,3 +1,4 @@
1
+-- @docclass
1 2
 UIComboBox = extends(UIWidget)
2 3
 
3 4
 function UIComboBox.create()
@@ -36,7 +37,7 @@ function UIComboBox:addOption(text, data)
36 37
 end
37 38
 
38 39
 function UIComboBox:onMousePress(mousePos, mouseButton)
39
-  local menu = createWidget(self:getStyleName() .. 'PopupMenu')
40
+  local menu = g_ui.createWidget(self:getStyleName() .. 'PopupMenu')
40 41
   menu:setId(self:getId() .. 'PopupMenu')
41 42
   for i,v in ipairs(self.options) do
42 43
     menu:addOption(v.text, function() self:setCurrentOption(v.text) end)

modules/corelib/widgets/uilabel.lua → modules/corelib/ui/uilabel.lua View File

@@ -1,3 +1,4 @@
1
+-- @docclass
1 2
 UILabel = extends(UIWidget)
2 3
 
3 4
 function UILabel.create()

modules/corelib/widgets/uimessagebox.lua → modules/corelib/ui/uimessagebox.lua View File

@@ -1,5 +1,6 @@
1 1
 if not UIWindow then dofile 'uiwindow' end
2 2
 
3
+-- @docclass
3 4
 UIMessageBox = extends(UIWindow)
4 5
 
5 6
 MessageBoxOk = 1
@@ -15,7 +16,7 @@ function UIMessageBox.display(title, message, flags)
15 16
   messagebox:setStyle('MessageBoxWindow')
16 17
   messagebox:setText(title)
17 18
 
18
-  local messageLabel = createWidget('MessageBoxLabel', messagebox)
19
+  local messageLabel = g_ui.createWidget('MessageBoxLabel', messagebox)
19 20
   messageLabel:setText(message)
20 21
   messageLabel:resizeToText()
21 22
 
@@ -23,7 +24,7 @@ function UIMessageBox.display(title, message, flags)
23 24
   messagebox:setHeight(math.max(messageLabel:getHeight() + 64, messagebox:getHeight()))
24 25
 
25 26
   -- setup messagebox first button
26
-  local buttonRight = createWidget('MessageBoxRightButton', messagebox)
27
+  local buttonRight = g_ui.createWidget('MessageBoxRightButton', messagebox)
27 28
 
28 29
   if flags == MessageBoxOk then
29 30
     buttonRight:setText('Ok')

modules/corelib/widgets/uiminiwindow.lua → modules/corelib/ui/uiminiwindow.lua View File

@@ -1,3 +1,4 @@
1
+-- @docclass
1 2
 UIMiniWindow = extends(UIWindow)
2 3
 
3 4
 function UIMiniWindow.create()
@@ -77,7 +78,7 @@ function UIMiniWindow:onSetup()
77 78
 
78 79
   local oldParent = self:getParent()
79 80
 
80
-  local settings = Settings.getNode('MiniWindows')
81
+  local settings = g_settings.getNode('MiniWindows')
81 82
   if settings then
82 83
     local selfSettings = settings[self:getId()]
83 84
     if selfSettings then
@@ -215,7 +216,7 @@ end
215 216
 function UIMiniWindow:setSettings(data)
216 217
   if not self.save then return end
217 218
 
218
-  local settings = Settings.getNode('MiniWindows')
219
+  local settings = g_settings.getNode('MiniWindows')
219 220
   if not settings then
220 221
     settings = {}
221 222
   end
@@ -229,7 +230,7 @@ function UIMiniWindow:setSettings(data)
229 230
     settings[id][key] = value
230 231
   end
231 232
 
232
-  Settings.setNode('MiniWindows', settings)
233
+  g_settings.setNode('MiniWindows', settings)
233 234
 end
234 235
 
235 236
 function UIMiniWindow:saveParentPosition(parentId, position)

modules/corelib/widgets/uiminiwindowcontainer.lua → modules/corelib/ui/uiminiwindowcontainer.lua View File

@@ -1,3 +1,4 @@
1
+-- @docclass
1 2
 UIMiniWindowContainer = extends(UIWidget)
2 3
 
3 4
 function UIMiniWindowContainer.create()
@@ -25,7 +26,7 @@ function UIMiniWindowContainer:onDrop(widget, mousePos)
25 26
   	else
26 27
   		self:addChild(widget)
27 28
   	end
28
-    
29
+
29 30
     return true
30 31
   end
31 32
 end

modules/corelib/widgets/uipopupmenu.lua → modules/corelib/ui/uipopupmenu.lua View File

@@ -1,3 +1,4 @@
1
+-- @docclass
1 2
 UIPopupMenu = extends(UIWidget)
2 3
 
3 4
 local currentMenu
@@ -33,7 +34,7 @@ function UIPopupMenu:onGeometryChange()
33 34
 end
34 35
 
35 36
 function UIPopupMenu:addOption(optionName, optionCallback)
36
-  local optionWidget = createWidget(self:getStyleName() .. 'Button', self)
37
+  local optionWidget = g_ui.createWidget(self:getStyleName() .. 'Button', self)
37 38
   local lastOptionWidget = self:getLastChild()
38 39
   optionWidget.onClick = function(self)
39 40
     optionCallback()
@@ -45,7 +46,7 @@ function UIPopupMenu:addOption(optionName, optionCallback)
45 46
 end
46 47
 
47 48
 function UIPopupMenu:addSeparator()
48
-  createWidget(self:getStyleName() .. 'Separator', self)
49
+  g_ui.createWidget(self:getStyleName() .. 'Separator', self)
49 50
 end
50 51
 
51 52
 function UIPopupMenu:onDestroy()

modules/corelib/widgets/uiprogressbar.lua → modules/corelib/ui/uiprogressbar.lua View File

@@ -1,3 +1,4 @@
1
+-- @docclass
1 2
 UIProgressBar = extends(UIWidget)
2 3
 
3 4
 function UIProgressBar.create()

modules/corelib/ui/radiogroup.lua → modules/corelib/ui/uiradiogroup.lua View File

@@ -1,24 +1,25 @@
1
-RadioGroup = newclass()
1
+-- @docclass
2
+UIRadioGroup = newclass()
2 3
 
3
-function RadioGroup.create()
4
-  local radiogroup = RadioGroup.internalCreate()
4
+function UIRadioGroup.create()
5
+  local radiogroup = UIRadioGroup.internalCreate()
5 6
   radiogroup.widgets = {}
6 7
   return radiogroup
7 8
 end
8 9
 
9
-function RadioGroup:destroy()
10
+function UIRadioGroup:destroy()
10 11
   for k,widget in pairs(self.widgets) do
11 12
     widget.onClick = nil
12 13
   end
13 14
   self.widgets = {}
14 15
 end
15 16
 
16
-function RadioGroup:addWidget(widget)
17
+function UIRadioGroup:addWidget(widget)
17 18
   table.insert(self.widgets, widget)
18 19
   widget.onClick = function(widget) self:selectWidget(widget) end
19 20
 end
20 21
 
21
-function RadioGroup:removeWidget(widget)
22
+function UIRadioGroup:removeWidget(widget)
22 23
   if self.selectedWidget == widget then
23 24
     self:selectWidget(nil)
24 25
   end
@@ -26,7 +27,7 @@ function RadioGroup:removeWidget(widget)
26 27
   table.removevalue(self.widgets, widget)
27 28
 end
28 29
 
29
-function RadioGroup:selectWidget(selectedWidget)
30
+function UIRadioGroup:selectWidget(selectedWidget)
30 31
   if selectedWidget == self.selectedWidget then return end
31 32
 
32 33
   local previousSelectedWidget = self.selectedWidget

modules/corelib/widgets/uiresizeborder.lua → modules/corelib/ui/uiresizeborder.lua View File

@@ -1,3 +1,4 @@
1
+-- @docclass
1 2
 UIResizeBorder = extends(UIWidget)
2 3
 
3 4
 function UIResizeBorder.create()
@@ -10,22 +11,22 @@ end
10 11
 
11 12
 function UIResizeBorder:onHoverChange(hovered)
12 13
   if hovered then
13
-    if Mouse.isCursorChanged() or Mouse.isPressed() then return end
14
+    if g_mouse.isCursorChanged() or g_mouse.isPressed() then return end
14 15
     if self:getWidth() > self:getHeight() then
15
-      Mouse.setVerticalCursor()
16
+      g_mouse.setVerticalCursor()
16 17
       self.vertical = true
17 18
     else
18
-      Mouse.setHorizontalCursor()
19
+      g_mouse.setHorizontalCursor()
19 20
       self.vertical = false
20 21
     end
21 22
     self.hovering = true
22 23
     if not self:isPressed() then
23
-      Effects.fadeIn(self)
24
+      g_effects.fadeIn(self)
24 25
     end
25 26
   else
26 27
     if not self:isPressed() and self.hovering then
27
-      Mouse.restoreCursor()
28
-      Effects.fadeOut(self)
28
+      g_mouse.restoreCursor()
29
+      g_effects.fadeOut(self)
29 30
       self.hovering = false
30 31
     end
31 32
   end
@@ -64,8 +65,8 @@ end
64 65
 
65 66
 function UIResizeBorder:onMouseRelease(mousePos, mouseButton)
66 67
   if not self:isHovered() then
67
-    Mouse.restoreCursor()
68
-    Effects.fadeOut(self)
68
+    g_mouse.restoreCursor()
69
+    g_effects.fadeOut(self)
69 70
     self.hovering = false
70 71
   end
71 72
 end

modules/corelib/widgets/uiscrollarea.lua → modules/corelib/ui/uiscrollarea.lua View File

@@ -1,3 +1,4 @@
1
+-- @docclass
1 2
 UIScrollArea = extends(UIWidget)
2 3
 
3 4
 -- public functions

modules/corelib/widgets/uiscrollbar.lua → modules/corelib/ui/uiscrollbar.lua View File

@@ -1,3 +1,4 @@
1
+-- @docclass
1 2
 UIScrollBar = extends(UIWidget)
2 3
 
3 4
 -- private functions
@@ -101,9 +102,9 @@ end
101 102
 function UIScrollBar:onSetup()
102 103
   self.setupDone = true
103 104
   signalcall(self.onValueChange, self, self.value)
104
-  Mouse.bindAutoPress(self:getChildById('decrementButton'), function() self:decrement() end)
105
-  Mouse.bindAutoPress(self:getChildById('incrementButton'), function() self:increment() end)
106
-  Mouse.bindPressMove(self:getChildById('sliderButton'), function(mousePos, mouseMoved) parseSliderPos(self, mousePos) end)
105
+  g_mouse.bindAutoPress(self:getChildById('decrementButton'), function() self:decrement() end)
106
+  g_mouse.bindAutoPress(self:getChildById('incrementButton'), function() self:increment() end)
107
+  g_mouse.bindPressMove(self:getChildById('sliderButton'), function(mousePos, mouseMoved) parseSliderPos(self, mousePos) end)
107 108
   updateSlider(self)
108 109
 end
109 110
 

modules/corelib/widgets/uispinbox.lua → modules/corelib/ui/uispinbox.lua View File

@@ -1,3 +1,4 @@
1
+-- @docclass
1 2
 UISpinBox = extends(UITextEdit)
2 3
 
3 4
 function UISpinBox.create()
@@ -30,7 +31,7 @@ function UISpinBox:onTextChange(text, oldText)
30 31
     self:setText(oldText)
31 32
     return
32 33
   end
33
-  
34
+
34 35
   self:setValue(number)
35 36
 end
36 37
 

modules/corelib/widgets/uisplitter.lua → modules/corelib/ui/uisplitter.lua View File

@@ -1,3 +1,4 @@
1
+-- @docclass
1 2
 UISplitter = extends(UIWidget)
2 3
 
3 4
 function UISplitter.create()
@@ -9,22 +10,22 @@ end
9 10
 
10 11
 function UISplitter:onHoverChange(hovered)
11 12
   if hovered then
12
-    if Mouse.isCursorChanged() or Mouse.isPressed() then return end
13
+    if g_mouse.isCursorChanged() or g_mouse.isPressed() then return end
13 14
     if self:getWidth() > self:getHeight() then
14
-      Mouse.setVerticalCursor()
15
+      g_mouse.setVerticalCursor()
15 16
       self.vertical = true
16 17
     else
17
-      Mouse.setHorizontalCursor()
18
+      g_mouse.setHorizontalCursor()
18 19
       self.vertical = false
19 20
     end
20 21
     self.hovering = true
21 22
     if not self:isPressed() then
22
-      Effects.fadeIn(self)
23
+      g_effects.fadeIn(self)
23 24
     end
24 25
   else
25 26
     if not self:isPressed() and self.hovering then
26
-      Mouse.restoreCursor()
27
-      Effects.fadeOut(self)
27
+      g_mouse.restoreCursor()
28
+      g_effects.fadeOut(self)
28 29
       self.hovering = false
29 30
     end
30 31
   end
@@ -64,8 +65,8 @@ end
64 65
 
65 66
 function UISplitter:onMouseRelease(mousePos, mouseButton)
66 67
   if not self:isHovered() then
67
-    Mouse.restoreCursor()
68
-    Effects.fadeOut(self)
68
+    g_mouse.restoreCursor()
69
+    g_effects.fadeOut(self)
69 70
     self.hovering = false
70 71
   end
71 72
 end

modules/corelib/widgets/uitabbar.lua → modules/corelib/ui/uitabbar.lua View File

@@ -1,3 +1,4 @@
1
+-- @docclass
1 2
 UITabBar = extends(UIWidget)
2 3
 
3 4
 -- private functions
@@ -28,11 +29,11 @@ end
28 29
 
29 30
 function UITabBar:addTab(text, panel)
30 31
   if panel == nil then
31
-    panel = createWidget(self:getStyleName() .. 'Panel')
32
+    panel = g_ui.createWidget(self:getStyleName() .. 'Panel')
32 33
     panel:setId('tabPanel')
33 34
   end
34 35
 
35
-  local tab = createWidget(self:getStyleName() .. 'Button', self)
36
+  local tab = g_ui.createWidget(self:getStyleName() .. 'Button', self)
36 37
   panel.isTab = true
37 38
   tab.tabPanel = panel
38 39
   tab.tabBar = self

modules/corelib/widgets/uiwidget.lua → modules/corelib/ui/uiwidget.lua View File

@@ -1,3 +1,5 @@
1
+-- @docclass UIWidget
2
+
1 3
 function UIWidget:setMargin(...)
2 4
   local params = {...}
3 5
   if #params == 1 then

modules/corelib/widgets/uiwindow.lua → modules/corelib/ui/uiwindow.lua View File

@@ -1,3 +1,4 @@
1
+-- @docclass
1 2
 UIWindow = extends(UIWidget)
2 3
 
3 4
 function UIWindow.create()

+ 11
- 2
modules/corelib/util.lua View File

@@ -1,3 +1,5 @@
1
+-- @docfuncs @{
2
+
1 3
 function print(...)
2 4
   local msg = ""
3 5
   for i,v in ipairs({...}) do
@@ -26,9 +28,13 @@ function fatal(msg)
26 28
   g_logger.log(LogFatal, msg)
27 29
 end
28 30
 
31
+function exit()
32
+  g_app.exit()
33
+end
29 34
 
30
-exit = g_app.exit
31
-quit = g_app.exit
35
+function quit()
36
+  g_app.quit()
37
+end
32 38
 
33 39
 function connect(object, signalsAndSlots, pushFront)
34 40
   for signal,slot in pairs(signalsAndSlots) do
@@ -151,6 +157,7 @@ function toboolean(str)
151 157
 end
152 158
 
153 159
 local oldtonumber = tonumber
160
+
154 161
 function tonumber(v)
155 162
   if v == nil then return 0 end
156 163
   return oldtonumber(v)
@@ -174,3 +181,5 @@ end
174 181
 function tr(s)
175 182
   return s
176 183
 end
184
+
185
+-- @}

+ 4
- 0
modules/game/const.lua View File

@@ -1,3 +1,5 @@
1
+-- @docconsts @{
2
+
1 3
 SkullNone = 0
2 4
 SkullYellow = 1
3 5
 SkullGreen = 2
@@ -64,3 +66,5 @@ GameTrucatedPingOpcode = 20
64 66
 GameReverseCreatureStack = 21
65 67
 
66 68
 OTSERV_RSA = "109120132967399429278860960508995541528237502902798129123468757937266291492576446330739696001110603907230888610072655818825358503429057592827629436413108566029093628212635953836686562675849720620786279431090218017681061521755056710823876476444260558147179707119674283982419152118103759076030616683978566631413"
69
+
70
+-- @}

+ 6
- 0
modules/game/creature.lua View File

@@ -1,3 +1,7 @@
1
+-- @docclass Creature
2
+
3
+-- @docconsts @{
4
+
1 5
 SkullNone = 0
2 6
 SkullYellow = 1
3 7
 SkullGreen = 2
@@ -23,6 +27,8 @@ EmblemGreen = 1
23 27
 EmblemRed = 2
24 28
 EmblemBlue = 3
25 29
 
30
+-- @}
31
+
26 32
 function getSkullImagePath(skullId)
27 33
   if skullId == SkullYellow then
28 34
     return 'icons/skull_yellow.png'

+ 8
- 6
modules/game/player.lua View File

@@ -1,3 +1,5 @@
1
+-- @docclass Player
2
+
1 3
 function Player:isPartyLeader()
2 4
   local shield = self:getShield()
3 5
   return (shield == ShieldWhiteYellow or
@@ -9,10 +11,10 @@ end
9 11
 
10 12
 function Player:isPartyMember()
11 13
   local shield = self:getShield()
12
-  return (shield == ShieldWhiteYellow or 
13
-          shield == ShieldYellow or 
14
-          shield == ShieldYellowSharedExp or 
15
-          shield == ShieldYellowNoSharedExpBlink or 
14
+  return (shield == ShieldWhiteYellow or
15
+          shield == ShieldYellow or
16
+          shield == ShieldYellowSharedExp or
17
+          shield == ShieldYellowNoSharedExpBlink or
16 18
           shield == ShieldYellowNoSharedExp or
17 19
           shield == ShieldBlueSharedExp or
18 20
           shield == ShieldBlueNoSharedExpBlink or
@@ -22,8 +24,8 @@ end
22 24
 
23 25
 function Player:isPartySharedExperienceActive()
24 26
   local shield = self:getShield()
25
-  return (shield == ShieldYellowSharedExp or 
26
-          shield == ShieldYellowNoSharedExpBlink or 
27
+  return (shield == ShieldYellowSharedExp or
28
+          shield == ShieldYellowNoSharedExpBlink or
27 29
           shield == ShieldYellowNoSharedExp or
28 30
           shield == ShieldBlueSharedExp or
29 31
           shield == ShieldBlueNoSharedExpBlink or

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

@@ -1,3 +1,4 @@
1
+-- @docclass
1 2
 ProtocolLogin = extends(Protocol)
2 3
 
3 4
 -- private functions

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

@@ -36,10 +36,10 @@ table.insert(lifeBarColors, {percentAbove = -1, color = '#4F0000' } )
36 36
 
37 37
 -- public functions
38 38
 function Battle.init()
39
-  battleWindow = displayUI('battle.otui', GameInterface.getRightPanel())
39
+  battleWindow = g_ui.loadUI('battle.otui', GameInterface.getRightPanel())
40 40
   battleButton = TopMenu.addGameToggleButton('battleButton', tr('Battle') .. ' (Ctrl+B)', 'battle.png', Battle.toggle)
41 41
   battleButton:setOn(true)
42
-  Keyboard.bindKeyDown('Ctrl+B', Battle.toggle)
42
+  g_keyboard.bindKeyDown('Ctrl+B', Battle.toggle)
43 43
 
44 44
   battlePanel = battleWindow:recursiveGetChildById('battlePanel')
45 45
 
@@ -49,7 +49,7 @@ function Battle.init()
49 49
   hideSkullsButton = battleWindow:recursiveGetChildById('hideSkulls')
50 50
   hidePartyButton = battleWindow:recursiveGetChildById('hideParty')
51 51
 
52
-  mouseWidget = createWidget('UIButton')
52
+  mouseWidget = g_ui.createWidget('UIButton')
53 53
   mouseWidget:setVisible(false)
54 54
   mouseWidget:setFocusable(false)
55 55
 
@@ -65,7 +65,7 @@ function Battle.init()
65 65
 end
66 66
 
67 67
 function Battle.terminate()
68
-  Keyboard.unbindKeyDown('Ctrl+B')
68
+  g_keyboard.unbindKeyDown('Ctrl+B')
69 69
   battlePanel = nil
70 70
   lastBattleButtonTargeted = nil
71 71
   lastBattleButtonFollowed = nil
@@ -191,7 +191,7 @@ function Battle.addCreature(creature)
191 191
   local creatureId = creature:getId()
192 192
 
193 193
   if battleButtonsByCreaturesList[creatureId] == nil then
194
-    local battleButton = displayUI('battleButton.otui', battlePanel)
194
+    local battleButton = g_ui.loadUI('battleButton.otui', battlePanel)
195 195
     local creatureWidget = battleButton:getChildById('creature')
196 196
     local labelWidget = battleButton:getChildById('label')
197 197
     local lifeBarWidget = battleButton:getChildById('lifeBar')
@@ -264,7 +264,7 @@ function Battle.onMouseRelease(self, mousePosition, mouseButton)
264 264
     GameInterface.createThingMenu(mousePosition, nil, nil, self.creature)
265 265
     return true
266 266
   elseif mouseButton == MouseLeftButton then
267
-    if Keyboard.isShiftPressed() then
267
+    if g_keyboard.isShiftPressed() then
268 268
       g_game.look(self.creature)
269 269
     else
270 270
       if self.isTarget then

+ 4
- 4
modules/game_bugreport/bugreport.lua View File

@@ -5,18 +5,18 @@ local bugTextEdit
5 5
 local HOTKEY = 'Ctrl+Z'
6 6
 
7 7
 function BugReport.init()
8
-  importStyle 'bugreport.otui'
8
+  g_ui.importStyle('bugreport.otui')
9 9
 
10
-  bugReportWindow = createWidget('BugReportWindow', rootWidget)
10
+  bugReportWindow = g_ui.createWidget('BugReportWindow', rootWidget)
11 11
   bugReportWindow:hide()
12 12
 
13 13
   bugTextEdit = bugReportWindow:getChildById('bugTextEdit')
14 14
 
15
-  Keyboard.bindKeyDown(HOTKEY, BugReport.show)
15
+  g_keyboard.bindKeyDown(HOTKEY, BugReport.show)
16 16
 end
17 17
 
18 18
 function BugReport.terminate()
19
-  Keyboard.unbindKeyDown(HOTKEY)
19
+  g_keyboard.unbindKeyDown(HOTKEY)
20 20
   bugReportWindow:destroy()
21 21
   bugReportWindow = nil
22 22
   bugTextEdit = nil

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

@@ -43,7 +43,7 @@ end
43 43
 function CombatControls.init()
44 44
   combatControlsButton = TopMenu.addGameToggleButton('combatControlsButton', tr('Combat Controls'), 'combatcontrols.png', CombatControls.toggle)
45 45
   combatControlsButton:setOn(true)
46
-  combatControlsWindow = loadUI('combatcontrols.otui', GameInterface.getRightPanel())
46
+  combatControlsWindow = g_ui.loadUI('combatcontrols.otui', GameInterface.getRightPanel())
47 47
 
48 48
   fightOffensiveBox = combatControlsWindow:recursiveGetChildById('fightOffensiveBox')
49 49
   fightBalancedBox = combatControlsWindow:recursiveGetChildById('fightBalancedBox')
@@ -51,7 +51,7 @@ function CombatControls.init()
51 51
   chaseModeButton = combatControlsWindow:recursiveGetChildById('chaseModeBox')
52 52
   safeFightButton = combatControlsWindow:recursiveGetChildById('safeFightBox')
53 53
 
54
-  fightModeRadioGroup = RadioGroup.create()
54
+  fightModeRadioGroup = UIRadioGroup.create()
55 55
   fightModeRadioGroup:addWidget(fightOffensiveBox)
56 56
   fightModeRadioGroup:addWidget(fightBalancedBox)
57 57
   fightModeRadioGroup:addWidget(fightDefensiveBox)

+ 19
- 19
modules/game_console/console.lua View File

@@ -162,19 +162,19 @@ end
162 162
 
163 163
 local function onChannelList(channelList)
164 164
   if channelsWindow then channelsWindow:destroy() end
165
-  channelsWindow = displayUI('channelswindow.otui')
165
+  channelsWindow = g_ui.displayUI('channelswindow.otui')
166 166
   local channelListPanel = channelsWindow:getChildById('channelList')
167 167
   channelsWindow.onEnter = doChannelListSubmit
168 168
   channelsWindow.onDestroy = function() channelsWindow = nil end
169
-  Keyboard.bindKeyPress('Down', function() channelListPanel:focusNextChild(KeyboardFocusReason) end, channelsWindow)
170
-  Keyboard.bindKeyPress('Up', function() channelListPanel:focusPreviousChild(KeyboardFocusReason) end, channelsWindow)
169
+  g_keyboard.bindKeyPress('Down', function() channelListPanel:focusNextChild(KeyboardFocusReason) end, channelsWindow)
170
+  g_keyboard.bindKeyPress('Up', function() channelListPanel:focusPreviousChild(KeyboardFocusReason) end, channelsWindow)
171 171
 
172 172
   for k,v in pairs(channelList) do
173 173
     local channelId = v[1]
174 174
     local channelName = v[2]
175 175
 
176 176
     if #channelName > 0 then
177
-      local label = createWidget('ChannelListLabel', channelListPanel)
177
+      local label = g_ui.createWidget('ChannelListLabel', channelListPanel)
178 178
       label.channelId = channelId
179 179
       label:setText(channelName)
180 180
 
@@ -202,7 +202,7 @@ function Console.init()
202 202
                     onGameStart = onGameStart,
203 203
                     onGameEnd = Console.clear })
204 204
 
205
-  consolePanel = displayUI('console.otui', GameInterface.getBottomPanel())
205
+  consolePanel = g_ui.loadUI('console.otui', GameInterface.getBottomPanel())
206 206
   consoleTextEdit = consolePanel:getChildById('consoleTextEdit')
207 207
   consoleContentPanel = consolePanel:getChildById('consoleContentPanel')
208 208
   consoleTabBar = consolePanel:getChildById('consoleTabBar')
@@ -212,12 +212,12 @@ function Console.init()
212 212
   Console.addTab(tr('Default'), true)
213 213
   Console.addTab(tr('Server Log'), false)
214 214
 
215
-  Keyboard.bindKeyPress('Shift+Up', function() navigateMessageHistory(1) end, consolePanel)
216
-  Keyboard.bindKeyPress('Shift+Down', function() navigateMessageHistory(-1) end, consolePanel)
217
-  Keyboard.bindKeyPress('Tab', function() consoleTabBar:selectNextTab() end, consolePanel)
218
-  Keyboard.bindKeyPress('Shift+Tab', function() consoleTabBar:selectPrevTab() end, consolePanel)
219
-  Keyboard.bindKeyDown('Enter', Console.sendCurrentMessage, consolePanel)
220
-  Keyboard.bindKeyPress('Ctrl+A', function() consoleTextEdit:clearText() end, consolePanel)
215
+  g_keyboard.bindKeyPress('Shift+Up', function() navigateMessageHistory(1) end, consolePanel)
216
+  g_keyboard.bindKeyPress('Shift+Down', function() navigateMessageHistory(-1) end, consolePanel)
217
+  g_keyboard.bindKeyPress('Tab', function() consoleTabBar:selectNextTab() end, consolePanel)
218
+  g_keyboard.bindKeyPress('Shift+Tab', function() consoleTabBar:selectPrevTab() end, consolePanel)
219
+  g_keyboard.bindKeyDown('Enter', Console.sendCurrentMessage, consolePanel)
220
+  g_keyboard.bindKeyPress('Ctrl+A', function() consoleTextEdit:clearText() end, consolePanel)
221 221
 
222 222
   -- apply buttom functions after loaded
223 223
   consolePanel:getChildById('nextChannelButton').onClick = function() consoleTabBar:selectNextTab() end
@@ -225,9 +225,9 @@ function Console.init()
225 225
   consoleTabBar.onTabChange = Console.onTabChange
226 226
 
227 227
   -- tibia like hotkeys
228
-  Keyboard.bindKeyDown('Ctrl+O', g_game.requestChannels)
229
-  Keyboard.bindKeyDown('Ctrl+E', Console.removeCurrentTab)
230
-  Keyboard.bindKeyDown('Ctrl+H', Console.openHelp)
228
+  g_keyboard.bindKeyDown('Ctrl+O', g_game.requestChannels)
229
+  g_keyboard.bindKeyDown('Ctrl+E', Console.removeCurrentTab)
230
+  g_keyboard.bindKeyDown('Ctrl+H', Console.openHelp)
231 231
 end
232 232
 
233 233
 function Console.terminate()
@@ -247,9 +247,9 @@ function Console.terminate()
247 247
   end
248 248
   channels = {}
249 249
 
250
-  Keyboard.unbindKeyDown('Ctrl+O')
251
-  Keyboard.unbindKeyDown('Ctrl+E')
252
-  Keyboard.unbindKeyDown('Ctrl+H')
250
+  g_keyboard.unbindKeyDown('Ctrl+O')
251
+  g_keyboard.unbindKeyDown('Ctrl+E')
252
+  g_keyboard.unbindKeyDown('Ctrl+H')
253 253
 
254 254
   if channelsWindow then
255 255
     channelsWindow:destroy()
@@ -382,7 +382,7 @@ function Console.addTabText(text, speaktype, tab, creatureName)
382 382
 
383 383
   local panel = consoleTabBar:getTabPanel(tab)
384 384
   local consoleBuffer = panel:getChildById('consoleBuffer')
385
-  local label = createWidget('ConsoleLabel', consoleBuffer)
385
+  local label = g_ui.createWidget('ConsoleLabel', consoleBuffer)
386 386
   label:setId('consoleLabel' .. panel:getChildCount())
387 387
   label:setText(text)
388 388
   label:setColor(speaktype.color)
@@ -397,7 +397,7 @@ end
397 397
 
398 398
 function Console.popupMenu(mousePos, mouseButton, creatureName, text)
399 399
   if mouseButton == MouseRightButton then
400
-    local menu = createWidget('PopupMenu')
400
+    local menu = g_ui.createWidget('PopupMenu')
401 401
     if creatureName then
402 402
       if creatureName ~= g_game.getCharacterName() then
403 403
         menu:addOption(tr('Message to ' .. creatureName), function () g_game.openPrivateChannel(creatureName) end)

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

@@ -14,7 +14,7 @@ local function onContainerOpen(container, previousContainer)
14 14
     previousContainer.window = nil
15 15
     previousContainer.itemsPanel = nil
16 16
   else
17
-    containerWindow = createWidget('ContainerWindow', GameInterface.getRightPanel())
17
+    containerWindow = g_ui.createWidget('ContainerWindow', GameInterface.getRightPanel())
18 18
   end
19 19
   containerWindow:setId('container' .. container:getId())
20 20
   local containerPanel = containerWindow:getChildById('contentsPanel')
@@ -42,7 +42,7 @@ local function onContainerOpen(container, previousContainer)
42 42
 
43 43
   containerPanel:destroyChildren()
44 44
   for slot=0,container:getCapacity()-1 do
45
-    local itemWidget = createWidget('Item', containerPanel)
45
+    local itemWidget = g_ui.createWidget('Item', containerPanel)
46 46
     itemWidget:setId('item' .. slot)
47 47
     itemWidget:setItem(container:getItem(slot))
48 48
     itemWidget:setMargin(3)
@@ -74,7 +74,7 @@ local function onContainerRemoveItem(container, slot, item)
74 74
 end
75 75
 
76 76
 function Containers.init()
77
-  importStyle 'container.otui'
77
+  g_ui.importStyle('container.otui')
78 78
 
79 79
   connect(Container, { onOpen = onContainerOpen,
80 80
                        onClose = onContainerClose,

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

@@ -35,7 +35,7 @@ function HealthBar.init()
35 35
 
36 36
   connect(g_game, { onGameEnd = HealthBar.offline })
37 37
 
38
-  healthBarWindow = displayUI('healthbar.otui', GameInterface.getRightPanel())
38
+  healthBarWindow = g_ui.loadUI('healthbar.otui', GameInterface.getRightPanel())
39 39
   healthBarButton = TopMenu.addGameToggleButton('healthBarButton', tr('Health Bar'), 'healthbar.png', HealthBar.toggle)
40 40
   healthBarButton:setOn(true)
41 41
   healthBar = healthBarWindow:recursiveGetChildById('healthBar')
@@ -108,7 +108,7 @@ end
108 108
 
109 109
 function HealthBar.onStatesChange(localPlayer, now, old)
110 110
   if now == old then return end
111
-  
111
+
112 112
   local bitsChanged = bit32.bxor(now, old)
113 113
   for i = 1, 32 do
114 114
     local pow = math.pow(2, i-1)
@@ -122,12 +122,12 @@ end
122 122
 
123 123
 function HealthBar.toggleIcon(bitChanged)
124 124
   local content = healthBarWindow:recursiveGetChildById('conditionPanel')
125
-  
125
+
126 126
   local icon = content:getChildById(Icons[bitChanged].id)
127 127
   if icon then
128 128
     icon:destroy()
129 129
   else
130
-    icon = createWidget('ConditionWidget', content)
130
+    icon = g_ui.createWidget('ConditionWidget', content)
131 131
     icon:setId(Icons[bitChanged].id)
132 132
     icon:setImageSource(Icons[bitChanged].path)
133 133
     icon:setTooltip(Icons[bitChanged].tooltip)

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

@@ -34,11 +34,11 @@ local hotkeyColors = {
34 34
 
35 35
 -- public functions
36 36
 function HotkeysManager.init()
37
-  hotkeysWindow = displayUI('hotkeys_manager.otui')
37
+  hotkeysWindow = g_ui.displayUI('hotkeys_manager.otui')
38 38
 
39 39
   hotkeysWindow:setVisible(false)
40 40
   hotkeysButton = TopMenu.addGameButton('hotkeysButton', tr('Hotkeys') .. ' (Ctrl+K)', '/game_hotkeys/icon.png', HotkeysManager.toggle)
41
-  Keyboard.bindKeyDown('Ctrl+K', HotkeysManager.toggle)
41
+  g_keyboard.bindKeyDown('Ctrl+K', HotkeysManager.toggle)
42 42
 
43 43
   currentHotkeysList = hotkeysWindow:getChildById('currentHotkeys')
44 44
   currentItemPreview = hotkeysWindow:getChildById('itemPreview')
@@ -53,7 +53,7 @@ function HotkeysManager.init()
53 53
   useOnTarget = hotkeysWindow:getChildById('useOnTarget')
54 54
   useWith = hotkeysWindow:getChildById('useWith')
55 55
 
56
-  itemWidget = createWidget('UIItem')
56
+  itemWidget = g_ui.createWidget('UIItem')
57 57
   itemWidget:setVirtual(true)
58 58
   itemWidget:setVisible(false)
59 59
   itemWidget:setFocusable(false)
@@ -66,7 +66,7 @@ function HotkeysManager.init()
66 66
 end
67 67
 
68 68
 function HotkeysManager.load()
69
-  local hotkeySettings = Settings.getNode('HotkeysManager')
69
+  local hotkeySettings = g_settings.getNode('HotkeysManager')
70 70
 
71 71
   local hasCombos = false
72 72
   if hotkeySettings ~= nil then
@@ -79,7 +79,7 @@ function HotkeysManager.load()
79 79
   -- add default F keys combos
80 80
   if not hasCombos then
81 81
     for i=1,12 do
82
-      HotkeysManager.addKeyCombo(nil, 'F' .. i, nil)
82
+      HotkeysManager.addKeyCombo(nil, 'F' .. i)
83 83
     end
84 84
   end
85 85
 end
@@ -95,13 +95,13 @@ function HotkeysManager.save()
95 95
                                   value = child.value})
96 96
   end
97 97
 
98
-  Settings.setNode('HotkeysManager', hotkeySettings)
98
+  g_settings.setNode('HotkeysManager', hotkeySettings)
99 99
 end
100 100
 
101 101
 function HotkeysManager.terminate()
102 102
   hotkeysManagerLoaded = false
103 103
 
104
-  Keyboard.unbindKeyDown('Ctrl+K')
104
+  g_keyboard.unbindKeyDown('Ctrl+K')
105 105
   HotkeysManager.save()
106 106
 
107 107
   currentHotkeysList = nil
@@ -179,20 +179,20 @@ function HotkeysManager.onChooseItemMouseRelease(self, mousePosition, mouseButto
179 179
     HotkeysManager:show()
180 180
   end
181 181
 
182
-  Mouse.restoreCursor()
182
+  g_mouse.restoreCursor()
183 183
   self:ungrabMouse()
184 184
   self:destroy()
185 185
 end
186 186
 
187 187
 function HotkeysManager.startChooseItem()
188
-  local mouseGrabberWidget = createWidget('UIWidget')
188
+  local mouseGrabberWidget = g_ui.createWidget('UIWidget')
189 189
   mouseGrabberWidget:setVisible(false)
190 190
   mouseGrabberWidget:setFocusable(false)
191 191
 
192 192
   connect(mouseGrabberWidget, { onMouseRelease = HotkeysManager.onChooseItemMouseRelease })
193 193
 
194 194
   mouseGrabberWidget:grabMouse()
195
-  Mouse.setTargetCursor()
195
+  g_mouse.setTargetCursor()
196 196
 
197 197
   HotkeysManager:hide()
198 198
 end
@@ -210,7 +210,7 @@ end
210 210
 function HotkeysManager.addHotkey()
211 211
   local widget
212 212
 
213
-  messageBox = createWidget('MainWindow', rootWidget)
213
+  messageBox = g_ui.createWidget('MainWindow', rootWidget)
214 214
   messageBox:grabKeyboard()
215 215
   messageBox:setId('assignWindow')
216 216
   messageBox:setText(tr('Button Assign'))
@@ -218,13 +218,13 @@ function HotkeysManager.addHotkey()
218 218
   messageBox:setHeight(140)
219 219
   messageBox:setDragable(false)
220 220
 
221
-  widget = createWidget('Label', messageBox)
221
+  widget = g_ui.createWidget('Label', messageBox)
222 222
   widget:setText(tr('Please, press the key you wish to add onto your hotkeys manager'))
223 223
   widget:resizeToText()
224 224
   widget:addAnchor(AnchorHorizontalCenter, 'parent', AnchorHorizontalCenter)
225 225
   widget:addAnchor(AnchorTop, 'parent', AnchorTop)
226 226
 
227
-  widget = createWidget('Label', messageBox)
227
+  widget = g_ui.createWidget('Label', messageBox)
228 228
   widget:setId('comboPreview')
229 229
   widget:setText(tr('Current hotkey to add: %s', 'none'))
230 230
   widget.keyCombo = ''
@@ -233,7 +233,7 @@ function HotkeysManager.addHotkey()
233 233
   widget:addAnchor(AnchorTop, 'prev', AnchorBottom)
234 234
   widget:setMarginTop(20)
235 235
 
236
-  widget = createWidget('Button', messageBox)
236
+  widget = g_ui.createWidget('Button', messageBox)
237 237
   widget:setId('cancelButton')
238 238
   widget:setText(tr('Cancel'))
239 239
   widget:setWidth(64)
@@ -244,7 +244,7 @@ function HotkeysManager.addHotkey()
244 244
                       self:getParent():destroy()
245 245
                     end
246 246
 
247
-  widget = createWidget('Button', messageBox)
247
+  widget = g_ui.createWidget('Button', messageBox)
248 248
   widget:setId('addButton')
249 249
   widget:setText(tr('Add'))
250 250
   widget:setWidth(64)
@@ -263,7 +263,7 @@ end
263 263
 function HotkeysManager.addKeyCombo(messageBox, keyCombo, keySettings)
264 264
   local label = nil
265 265
   if currentHotkeysList:getChildById(keyCombo) == nil then
266
-    local label = createWidget('HotkeyListLabel', currentHotkeysList)
266
+    local label = g_ui.createWidget('HotkeyListLabel', currentHotkeysList)
267 267
     label:setId(keyCombo)
268 268
     label:setColor(hotkeyColors.text)
269 269
     label:setText(keyCombo..': ')
@@ -286,7 +286,7 @@ function HotkeysManager.addKeyCombo(messageBox, keyCombo, keySettings)
286 286
     HotkeysManager.checkSelectedHotkey(label)
287 287
 
288 288
     hotkeyList[keyCombo] = label
289
-    Keyboard.bindKeyPress(keyCombo, function () HotkeysManager.call(keyCombo) end, nil, 350)
289
+    g_keyboard.bindKeyPress(keyCombo, function () HotkeysManager.call(keyCombo) end, nil, 350)
290 290
   end
291 291
 
292 292
   if messageBox then
@@ -430,7 +430,7 @@ end
430 430
 function HotkeysManager.removeHotkey()
431 431
   if hotkeyLabelSelectedOnList ~= nil then
432 432
     hotkeyList[hotkeyLabelSelectedOnList.keyCombo] = nil
433
-    Keyboard.unbindKeyPress(hotkeyLabelSelectedOnList.keyCombo)
433
+    g_keyboard.unbindKeyPress(hotkeyLabelSelectedOnList.keyCombo)
434 434
     hotkeyLabelSelectedOnList:destroy()
435 435
   end
436 436
 end
@@ -445,7 +445,7 @@ function HotkeysManager.onHotkeyTextChange(id, value)
445 445
     else
446 446
       sendAutomatically:disable()
447 447
       sendAutomatically:setChecked(false)
448
-    end 
448
+    end
449 449
   end
450 450
 end
451 451
 

+ 43
- 41
modules/game_interface/gameinterface.lua View File

@@ -19,10 +19,12 @@ local function onLeftPanelVisibilityChange(leftPanel, visible)
19 19
 end
20 20
 
21 21
 function GameInterface.init()
22
+  g_ui.importStyle('styles/countwindow.otui')
23
+
22 24
   connect(g_game, { onGameStart = GameInterface.show }, true)
23 25
   connect(g_game, { onGameEnd = GameInterface.hide }, true)
24 26
 
25
-  gameRootPanel = displayUI('gameinterface.otui')
27
+  gameRootPanel = g_ui.displayUI('gameinterface.otui')
26 28
   gameRootPanel:hide()
27 29
   gameRootPanel:lower()
28 30
 
@@ -38,34 +40,34 @@ function GameInterface.init()
38 40
   logoutButton = TopMenu.addRightButton('logoutButton', 'Logout', '/images/logout.png', GameInterface.tryLogout)
39 41
   logoutButton:hide()
40 42
 
41
-  Keyboard.bindKeyPress('Up', function() g_game.walk(North) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
42
-  Keyboard.bindKeyPress('Right', function() g_game.walk(East) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
43
-  Keyboard.bindKeyPress('Down', function() g_game.walk(South) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
44
-  Keyboard.bindKeyPress('Left', function() g_game.walk(West) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
45
-  Keyboard.bindKeyPress('Numpad8', function() g_game.walk(North) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
46
-  Keyboard.bindKeyPress('Numpad9', function() g_game.walk(NorthEast) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
47
-  Keyboard.bindKeyPress('Numpad6', function() g_game.walk(East) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
48
-  Keyboard.bindKeyPress('Numpad3', function() g_game.walk(SouthEast) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
49
-  Keyboard.bindKeyPress('Numpad2', function() g_game.walk(South) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
50
-  Keyboard.bindKeyPress('Numpad1', function() g_game.walk(SouthWest) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
51
-  Keyboard.bindKeyPress('Numpad4', function() g_game.walk(West) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
52
-  Keyboard.bindKeyPress('Numpad7', function() g_game.walk(NorthWest) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
53
-  Keyboard.bindKeyPress('Ctrl+Up', function() g_game.turn(North) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
54
-  Keyboard.bindKeyPress('Ctrl+Right', function() g_game.turn(East) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
55
-  Keyboard.bindKeyPress('Ctrl+Down', function() g_game.turn(South) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
56
-  Keyboard.bindKeyPress('Ctrl+Left', function() g_game.turn(West) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
57
-  Keyboard.bindKeyPress('Ctrl+Numpad8', function() g_game.turn(North) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
58
-  Keyboard.bindKeyPress('Ctrl+Numpad6', function() g_game.turn(East) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
59
-  Keyboard.bindKeyPress('Ctrl+Numpad2', function() g_game.turn(South) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
60
-  Keyboard.bindKeyPress('Ctrl+Numpad4', function() g_game.turn(West) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
61
-  Keyboard.bindKeyPress('Escape', function() g_game.cancelAttackAndFollow() end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
62
-  Keyboard.bindKeyPress('Ctrl+=', function() gameMapPanel:zoomIn() end, gameRootPanel, 250)
63
-  Keyboard.bindKeyPress('Ctrl+-', function() gameMapPanel:zoomOut() end, gameRootPanel, 250)
64
-  Keyboard.bindKeyDown('Ctrl+Q', GameInterface.tryLogout, gameRootPanel)
65
-  Keyboard.bindKeyDown('Ctrl+L', GameInterface.tryLogout, gameRootPanel)
66
-  Keyboard.bindKeyDown('Ctrl+W', function() g_map.cleanTexts() TextMessage.clearMessages() end, gameRootPanel)
67
-
68
-  Keyboard.bindKeyDown('Ctrl+.', function()
43
+  g_keyboard.bindKeyPress('Up', function() g_game.walk(North) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
44
+  g_keyboard.bindKeyPress('Right', function() g_game.walk(East) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
45
+  g_keyboard.bindKeyPress('Down', function() g_game.walk(South) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
46
+  g_keyboard.bindKeyPress('Left', function() g_game.walk(West) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
47
+  g_keyboard.bindKeyPress('Numpad8', function() g_game.walk(North) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
48
+  g_keyboard.bindKeyPress('Numpad9', function() g_game.walk(NorthEast) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
49
+  g_keyboard.bindKeyPress('Numpad6', function() g_game.walk(East) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
50
+  g_keyboard.bindKeyPress('Numpad3', function() g_game.walk(SouthEast) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
51
+  g_keyboard.bindKeyPress('Numpad2', function() g_game.walk(South) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
52
+  g_keyboard.bindKeyPress('Numpad1', function() g_game.walk(SouthWest) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
53
+  g_keyboard.bindKeyPress('Numpad4', function() g_game.walk(West) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
54
+  g_keyboard.bindKeyPress('Numpad7', function() g_game.walk(NorthWest) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
55
+  g_keyboard.bindKeyPress('Ctrl+Up', function() g_game.turn(North) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
56
+  g_keyboard.bindKeyPress('Ctrl+Right', function() g_game.turn(East) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
57
+  g_keyboard.bindKeyPress('Ctrl+Down', function() g_game.turn(South) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
58
+  g_keyboard.bindKeyPress('Ctrl+Left', function() g_game.turn(West) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
59
+  g_keyboard.bindKeyPress('Ctrl+Numpad8', function() g_game.turn(North) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
60
+  g_keyboard.bindKeyPress('Ctrl+Numpad6', function() g_game.turn(East) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
61
+  g_keyboard.bindKeyPress('Ctrl+Numpad2', function() g_game.turn(South) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
62
+  g_keyboard.bindKeyPress('Ctrl+Numpad4', function() g_game.turn(West) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
63
+  g_keyboard.bindKeyPress('Escape', function() g_game.cancelAttackAndFollow() end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
64
+  g_keyboard.bindKeyPress('Ctrl+=', function() gameMapPanel:zoomIn() end, gameRootPanel, 250)
65
+  g_keyboard.bindKeyPress('Ctrl+-', function() gameMapPanel:zoomOut() end, gameRootPanel, 250)
66
+  g_keyboard.bindKeyDown('Ctrl+Q', GameInterface.tryLogout, gameRootPanel)
67
+  g_keyboard.bindKeyDown('Ctrl+L', GameInterface.tryLogout, gameRootPanel)
68
+  g_keyboard.bindKeyDown('Ctrl+W', function() g_map.cleanTexts() TextMessage.clearMessages() end, gameRootPanel)
69
+
70
+  g_keyboard.bindKeyDown('Ctrl+.', function()
69 71
     if gameMapPanel:isKeepAspectRatioEnabled() then
70 72
       gameMapPanel:setKeepAspectRatio(false)
71 73
     else
@@ -141,7 +143,7 @@ function GameInterface.onMouseGrabberRelease(self, mousePosition, mouseButton)
141 143
   end
142 144
 
143 145
   GameInterface.selectedThing = nil
144
-  Mouse.restoreCursor()
146
+  g_mouse.restoreCursor()
145 147
   self:ungrabMouse()
146 148
   return true
147 149
 end
@@ -170,18 +172,18 @@ function GameInterface.startUseWith(thing)
170 172
   GameInterface.selectedType = 'use'
171 173
   GameInterface.selectedThing = thing
172 174
   mouseGrabberWidget:grabMouse()
173
-  Mouse.setTargetCursor()
175
+  g_mouse.setTargetCursor()
174 176
 end
175 177
 
176 178
 function GameInterface.startTradeWith(thing)
177 179
   GameInterface.selectedType = 'trade'
178 180
   GameInterface.selectedThing = thing
179 181
   mouseGrabberWidget:grabMouse()
180
-  Mouse.setTargetCursor()
182
+  g_mouse.setTargetCursor()
181 183
 end
182 184
 
183 185
 function GameInterface.createThingMenu(menuPosition, lookThing, useThing, creatureThing)
184
-  local menu = createWidget('PopupMenu')
186
+  local menu = g_ui.createWidget('PopupMenu')
185 187
 
186 188
   if lookThing then
187 189
     menu:addOption(tr('Look'), function() g_game.look(lookThing) end)
@@ -191,9 +193,9 @@ function GameInterface.createThingMenu(menuPosition, lookThing, useThing, creatu
191 193
     if useThing:isContainer() then
192 194
       if useThing:getParentContainer() then
193 195
         menu:addOption(tr('Open'), function() g_game.open(useThing, useThing:getParentContainer()) end)
194
-        menu:addOption(tr('Open in new window'), function() g_game.open(useThing, nil) end)
196
+        menu:addOption(tr('Open in new window'), function() g_game.open(useThing) end)
195 197
       else
196
-        menu:addOption(tr('Open'), function() g_game.open(useThing, nil) end)
198
+        menu:addOption(tr('Open'), function() g_game.open(useThing) end)
197 199
       end
198 200
     else
199 201
       if useThing:isMultiUse() then
@@ -303,7 +305,7 @@ function GameInterface.createThingMenu(menuPosition, lookThing, useThing, creatu
303 305
 end
304 306
 
305 307
 function GameInterface.processMouseAction(menuPosition, mouseButton, autoWalk, lookThing, useThing, creatureThing, multiUseThing)
306
-  local keyboardModifiers = Keyboard.getModifiers()
308
+  local keyboardModifiers = g_keyboard.getModifiers()
307 309
 
308 310
   if autoWalk and keyboardModifiers == KeyboardNoModifier and mouseButton == MouseLeftButton then
309 311
     -- todo auto walk
@@ -323,7 +325,7 @@ function GameInterface.processMouseAction(menuPosition, mouseButton, autoWalk, l
323 325
           g_game.open(useThing, useThing:getParentContainer())
324 326
           return true
325 327
         else
326
-          g_game.open(useThing, nil)
328
+          g_game.open(useThing)
327 329
         return true
328 330
         end
329 331
       elseif useThing:isMultiUse() then
@@ -348,7 +350,7 @@ function GameInterface.processMouseAction(menuPosition, mouseButton, autoWalk, l
348 350
           g_game.open(multiUseThing, multiUseThing:getParentContainer())
349 351
           return true
350 352
         else
351
-          g_game.open(multiUseThing, nil)
353
+          g_game.open(multiUseThing)
352 354
           return true
353 355
         end
354 356
       elseif multiUseThing:isMultiUse() then
@@ -374,16 +376,16 @@ function GameInterface.processMouseAction(menuPosition, mouseButton, autoWalk, l
374 376
 end
375 377
 
376 378
 function GameInterface.moveStackableItem(item, toPos)
377
-  if Keyboard.isCtrlPressed() then
379
+  if g_keyboard.isCtrlPressed() then
378 380
     g_game.move(item, toPos, item:getCount())
379 381
     return
380
-  elseif Keyboard.isShiftPressed() then
382
+  elseif g_keyboard.isShiftPressed() then
381 383
     g_game.move(item, toPos, 1)
382 384
     return
383 385
   end
384 386
 
385 387
   local count = item:getCount()
386
-  local countWindow = createWidget('CountWindow', rootWidget)
388
+  local countWindow = g_ui.createWidget('CountWindow', rootWidget)
387 389
   local spinbox = countWindow:getChildById('countSpinBox')
388 390
   local scrollbar = countWindow:getChildById('countScrollBar')
389 391
   spinbox:setMaximum(count)

+ 0
- 2
modules/game_interface/interface.otmod View File

@@ -5,8 +5,6 @@ Module
5 5
   website: www.otclient.info
6 6
 
7 7
   @onLoad: |
8
-    importStyle 'styles/countwindow.otui'
9
-
10 8
     dofile 'widgets/uigamemap'
11 9
     dofile 'widgets/uiitem'
12 10
 

+ 4
- 4
modules/game_interface/widgets/uigamemap.lua View File

@@ -16,13 +16,13 @@ function UIGameMap:onDragEnter(mousePos)
16 16
   if not thing then return false end
17 17
 
18 18
   self.currentDragThing = thing
19
-  Mouse.setTargetCursor()
19
+  g_mouse.setTargetCursor()
20 20
   return true
21 21
 end
22 22
 
23 23
 function UIGameMap:onDragLeave(droppedWidget, mousePos)
24 24
   self.currentDragThing = nil
25
-  Mouse.restoreCursor()
25
+  g_mouse.restoreCursor()
26 26
   return true
27 27
 end
28 28
 
@@ -57,8 +57,8 @@ function UIGameMap:onMouseRelease(mousePosition, mouseButton)
57 57
   if tile == nil then return false end
58 58
 
59 59
   if Options.getOption('classicControl') and
60
-     ((Mouse.isPressed(MouseLeftButton) and mouseButton == MouseRightButton) or
61
-      (Mouse.isPressed(MouseRightButton) and mouseButton == MouseLeftButton)) then
60
+     ((g_mouse.isPressed(MouseLeftButton) and mouseButton == MouseRightButton) or
61
+      (g_mouse.isPressed(MouseRightButton) and mouseButton == MouseLeftButton)) then
62 62
     local tile = self:getTile(mousePosition)
63 63
     g_game.look(tile:getTopLookThing())
64 64
     self.cancelNextRelease = true

+ 4
- 4
modules/game_interface/widgets/uiitem.lua View File

@@ -6,14 +6,14 @@ function UIItem:onDragEnter(mousePos)
6 6
 
7 7
   self:setBorderWidth(1)
8 8
   self.currentDragThing = item
9
-  Mouse.setTargetCursor()
9
+  g_mouse.setTargetCursor()
10 10
   return true
11 11
 end
12 12
 
13 13
 function UIItem:onDragLeave(droppedWidget, mousePos)
14 14
   if self:isVirtual() then return false end
15 15
   self.currentDragThing = nil
16
-  Mouse.restoreCursor()
16
+  g_mouse.restoreCursor()
17 17
   self:setBorderWidth(0)
18 18
   return true
19 19
 end
@@ -68,8 +68,8 @@ function UIItem:onMouseRelease(mousePosition, mouseButton)
68 68
   if not item or not self:containsPoint(mousePosition) then return false end
69 69
 
70 70
   if Options.getOption('classicControl') and
71
-     ((Mouse.isPressed(MouseLeftButton) and mouseButton == MouseRightButton) or
72
-      (Mouse.isPressed(MouseRightButton) and mouseButton == MouseLeftButton)) then
71
+     ((g_mouse.isPressed(MouseLeftButton) and mouseButton == MouseRightButton) or
72
+      (g_mouse.isPressed(MouseRightButton) and mouseButton == MouseLeftButton)) then
73 73
     g_game.look(item)
74 74
     self.cancelNextRelease = true
75 75
     return true

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

@@ -11,9 +11,9 @@ function Inventory.init()
11 11
                          onFreeCapacityChange = Inventory.onFreeCapacityChange })
12 12
   connect(g_game, { onGameStart = Inventory.refresh })
13 13
 
14
-  Keyboard.bindKeyDown('Ctrl+I', Inventory.toggle)
14
+  g_keyboard.bindKeyDown('Ctrl+I', Inventory.toggle)
15 15
 
16
-  inventoryWindow = displayUI('inventory.otui', GameInterface.getRightPanel())
16
+  inventoryWindow = g_ui.loadUI('inventory.otui', GameInterface.getRightPanel())
17 17
   inventoryPanel = inventoryWindow:getChildById('contentsPanel')
18 18
   inventoryButton = TopMenu.addGameToggleButton('inventoryButton', tr('Inventory') .. ' (Ctrl+I)', 'inventory.png', Inventory.toggle)
19 19
   inventoryButton:setOn(true)
@@ -26,7 +26,7 @@ function Inventory.terminate()
26 26
                          onFreeCapacityChange = Inventory.onFreeCapacityChange })
27 27