replace require with dofile, rename Hotkeys to Keyboard
This commit is contained in:
parent
64c9e4f1d5
commit
f97104f12e
|
@ -44,3 +44,20 @@ end
|
||||||
function quit()
|
function quit()
|
||||||
exit()
|
exit()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function reloadModule(name)
|
||||||
|
local module = g_modules.getModule(name)
|
||||||
|
if module then
|
||||||
|
module:unload()
|
||||||
|
module:load()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function autoReloadModule(name)
|
||||||
|
local function reloadEvent()
|
||||||
|
reloadModule(name)
|
||||||
|
scheduleEvent(reloadEvent, 1000)
|
||||||
|
end
|
||||||
|
reloadEvent()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
|
@ -108,15 +108,15 @@ function Terminal.init()
|
||||||
terminalWidget:setVisible(false)
|
terminalWidget:setVisible(false)
|
||||||
|
|
||||||
terminalButton = TopMenu.addButton('terminalButton', 'Terminal (Ctrl + T)', 'terminal.png', Terminal.toggle)
|
terminalButton = TopMenu.addButton('terminalButton', 'Terminal (Ctrl + T)', 'terminal.png', Terminal.toggle)
|
||||||
Hotkeys.bindKeyDown('Ctrl+T', Terminal.toggle)
|
Keyboard.bindKeyDown('Ctrl+T', Terminal.toggle)
|
||||||
|
|
||||||
commandHistory = Settings.getList('terminal-history')
|
commandHistory = Settings.getList('terminal-history')
|
||||||
|
|
||||||
commandLineEdit = terminalWidget:getChildById('commandLineEdit')
|
commandLineEdit = terminalWidget:getChildById('commandLineEdit')
|
||||||
Hotkeys.bindKeyDown('Up', function() navigateCommand(1) end, commandLineEdit)
|
Keyboard.bindKeyDown('Up', function() navigateCommand(1) end, commandLineEdit)
|
||||||
Hotkeys.bindKeyDown('Down', function() navigateCommand(-1) end, commandLineEdit)
|
Keyboard.bindKeyDown('Down', function() navigateCommand(-1) end, commandLineEdit)
|
||||||
Hotkeys.bindKeyDown('Tab', completeCommand, commandLineEdit)
|
Keyboard.bindKeyDown('Tab', completeCommand, commandLineEdit)
|
||||||
Hotkeys.bindKeyDown('Enter', doCommand, commandLineEdit)
|
Keyboard.bindKeyDown('Enter', doCommand, commandLineEdit)
|
||||||
|
|
||||||
terminalBuffer = terminalWidget:getChildById('terminalBuffer')
|
terminalBuffer = terminalWidget:getChildById('terminalBuffer')
|
||||||
Logger.setOnLog(onLog)
|
Logger.setOnLog(onLog)
|
||||||
|
@ -125,7 +125,7 @@ end
|
||||||
|
|
||||||
function Terminal.terminate()
|
function Terminal.terminate()
|
||||||
Settings.setList('terminal-history', commandHistory)
|
Settings.setList('terminal-history', commandHistory)
|
||||||
Hotkeys.unbindKeyDown('Ctrl+T')
|
Keyboard.unbindKeyDown('Ctrl+T')
|
||||||
Logger.setOnLog(nil)
|
Logger.setOnLog(nil)
|
||||||
terminalButton:destroy()
|
terminalButton:destroy()
|
||||||
terminalButton = nil
|
terminalButton = nil
|
||||||
|
|
|
@ -8,8 +8,8 @@ Module
|
||||||
autoLoadAntecedence: 200
|
autoLoadAntecedence: 200
|
||||||
|
|
||||||
onLoad: |
|
onLoad: |
|
||||||
require 'terminal'
|
dofile 'terminal'
|
||||||
require 'commands'
|
dofile 'commands'
|
||||||
Terminal.init()
|
Terminal.init()
|
||||||
|
|
||||||
onUnload: |
|
onUnload: |
|
||||||
|
|
|
@ -34,4 +34,5 @@ function Client.terminate()
|
||||||
Settings.set('window-size', g_window.getUnmaximizedSize())
|
Settings.set('window-size', g_window.getUnmaximizedSize())
|
||||||
Settings.set('window-pos', g_window.getUnmaximizedPos())
|
Settings.set('window-pos', g_window.getUnmaximizedPos())
|
||||||
Settings.set('window-maximized', g_window.isMaximized())
|
Settings.set('window-maximized', g_window.isMaximized())
|
||||||
|
g_window.hide()
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,6 +3,7 @@ Module
|
||||||
description: Load all other otclient dependecies
|
description: Load all other otclient dependecies
|
||||||
author: OTClient team
|
author: OTClient team
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
|
canUnload: false
|
||||||
|
|
||||||
// NOTE: order does matter
|
// NOTE: order does matter
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@ -16,7 +17,7 @@ Module
|
||||||
- game
|
- game
|
||||||
|
|
||||||
onLoad: |
|
onLoad: |
|
||||||
require 'client'
|
dofile 'client'
|
||||||
Client.init()
|
Client.init()
|
||||||
|
|
||||||
onUnload: |
|
onUnload: |
|
||||||
|
|
|
@ -5,7 +5,7 @@ Module
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
|
|
||||||
onLoad: |
|
onLoad: |
|
||||||
require 'about'
|
dofile 'about'
|
||||||
About.init()
|
About.init()
|
||||||
|
|
||||||
onUnload: |
|
onUnload: |
|
||||||
|
|
|
@ -5,7 +5,7 @@ Module
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
|
|
||||||
onLoad: |
|
onLoad: |
|
||||||
require 'background'
|
dofile 'background'
|
||||||
Background.init()
|
Background.init()
|
||||||
|
|
||||||
onUnload: |
|
onUnload: |
|
||||||
|
|
|
@ -57,7 +57,7 @@ end
|
||||||
-- public functions
|
-- public functions
|
||||||
function EnterGame.init()
|
function EnterGame.init()
|
||||||
enterGameButton = TopMenu.addButton('enterGameButton', 'Login (Ctrl + G)', '/core_styles/icons/login.png', EnterGame.openWindow)
|
enterGameButton = TopMenu.addButton('enterGameButton', 'Login (Ctrl + G)', '/core_styles/icons/login.png', EnterGame.openWindow)
|
||||||
Hotkeys.bindKeyDown('Ctrl+G', EnterGame.openWindow)
|
Keyboard.bindKeyDown('Ctrl+G', EnterGame.openWindow)
|
||||||
motdButton = TopMenu.addButton('motdButton', 'Message of the day', '/core_styles/icons/motd.png', EnterGame.displayMotd)
|
motdButton = TopMenu.addButton('motdButton', 'Message of the day', '/core_styles/icons/motd.png', EnterGame.displayMotd)
|
||||||
motdButton:hide()
|
motdButton:hide()
|
||||||
enterGame = displayUI('entergame.otui')
|
enterGame = displayUI('entergame.otui')
|
||||||
|
@ -82,7 +82,7 @@ function EnterGame.init()
|
||||||
end
|
end
|
||||||
|
|
||||||
function EnterGame.terminate()
|
function EnterGame.terminate()
|
||||||
Hotkeys.unbindKeyDown('Ctrl+G')
|
Keyboard.unbindKeyDown('Ctrl+G')
|
||||||
enterGame:destroy()
|
enterGame:destroy()
|
||||||
enterGame = nil
|
enterGame = nil
|
||||||
enterGameButton:destroy()
|
enterGameButton:destroy()
|
||||||
|
|
|
@ -5,8 +5,8 @@ Module
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
|
|
||||||
onLoad: |
|
onLoad: |
|
||||||
require 'entergame'
|
dofile 'entergame'
|
||||||
require 'characterlist'
|
dofile 'characterlist'
|
||||||
EnterGame.init()
|
EnterGame.init()
|
||||||
|
|
||||||
onUnload: |
|
onUnload: |
|
||||||
|
|
|
@ -4,7 +4,7 @@ Module
|
||||||
author: OTClient team
|
author: OTClient team
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
onLoad: |
|
onLoad: |
|
||||||
require 'modulemanager'
|
dofile 'modulemanager'
|
||||||
ModuleManager.init()
|
ModuleManager.init()
|
||||||
|
|
||||||
onUnload: |
|
onUnload: |
|
||||||
|
|
|
@ -25,11 +25,11 @@ function Options.init()
|
||||||
optionsWindow = displayUI('options.otui')
|
optionsWindow = displayUI('options.otui')
|
||||||
optionsWindow:setVisible(false)
|
optionsWindow:setVisible(false)
|
||||||
optionsButton = TopMenu.addButton('optionsButton', 'Options (Ctrl+O)', 'options.png', Options.toggle)
|
optionsButton = TopMenu.addButton('optionsButton', 'Options (Ctrl+O)', 'options.png', Options.toggle)
|
||||||
Hotkeys.bindKeyDown('Ctrl+O', Options.toggle)
|
Keyboard.bindKeyDown('Ctrl+O', Options.toggle)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Options.terminate()
|
function Options.terminate()
|
||||||
Hotkeys.unbindKeyDown('Ctrl+O')
|
Keyboard.unbindKeyDown('Ctrl+O')
|
||||||
optionsWindow:destroy()
|
optionsWindow:destroy()
|
||||||
optionsWindow = nil
|
optionsWindow = nil
|
||||||
optionsButton:destroy()
|
optionsButton:destroy()
|
||||||
|
|
|
@ -5,7 +5,7 @@ Module
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
|
|
||||||
onLoad: |
|
onLoad: |
|
||||||
require 'options'
|
dofile 'options'
|
||||||
Options.init()
|
Options.init()
|
||||||
|
|
||||||
onUnload: |
|
onUnload: |
|
||||||
|
|
|
@ -23,11 +23,11 @@ function TopMenu.init()
|
||||||
gameButtonsPanel = topMenu:getChildById('gameButtonsPanel')
|
gameButtonsPanel = topMenu:getChildById('gameButtonsPanel')
|
||||||
|
|
||||||
TopMenu.addRightButton('logoutButton', 'Logout (Ctrl+Q)', '/core_styles/icons/logout.png', onLogout)
|
TopMenu.addRightButton('logoutButton', 'Logout (Ctrl+Q)', '/core_styles/icons/logout.png', onLogout)
|
||||||
Hotkeys.bindKeyDown('Ctrl+Q', onLogout)
|
Keyboard.bindKeyDown('Ctrl+Q', onLogout)
|
||||||
end
|
end
|
||||||
|
|
||||||
function TopMenu.terminate()
|
function TopMenu.terminate()
|
||||||
Hotkeys.unbindKeyDown('Ctrl+Q')
|
Keyboard.unbindKeyDown('Ctrl+Q')
|
||||||
leftButtonsPanel = nil
|
leftButtonsPanel = nil
|
||||||
rightButtonsPanel = nil
|
rightButtonsPanel = nil
|
||||||
gameButtonsPanel = nil
|
gameButtonsPanel = nil
|
||||||
|
@ -71,16 +71,6 @@ function TopMenu.addRightButton(id, description, icon, callback)
|
||||||
return TopMenu.addButton(id, description, resolvepath(icon, 2), callback, true)
|
return TopMenu.addButton(id, description, resolvepath(icon, 2), callback, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
function TopMenu.removeButton(param)
|
|
||||||
local button
|
|
||||||
if type(param) == 'string' then
|
|
||||||
button = TopMenu.getButton(param)
|
|
||||||
else
|
|
||||||
button = param
|
|
||||||
end
|
|
||||||
button:destroy()
|
|
||||||
end
|
|
||||||
|
|
||||||
function TopMenu.hideGameButtons()
|
function TopMenu.hideGameButtons()
|
||||||
gameButtonsPanel:hide()
|
gameButtonsPanel:hide()
|
||||||
end
|
end
|
||||||
|
@ -93,10 +83,5 @@ function TopMenu.getButton(id)
|
||||||
return topMenu:recursiveGetChildById(id)
|
return topMenu:recursiveGetChildById(id)
|
||||||
end
|
end
|
||||||
|
|
||||||
function TopMenu:getLogoutButton(id)
|
|
||||||
return TopMenu.getButton('logoutButton')
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
connect(Game, { onLogin = TopMenu.showGameButtons,
|
connect(Game, { onLogin = TopMenu.showGameButtons,
|
||||||
onLogout = TopMenu.hideGameButtons})
|
onLogout = TopMenu.hideGameButtons })
|
||||||
|
|
|
@ -5,7 +5,7 @@ Module
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
|
|
||||||
onLoad: |
|
onLoad: |
|
||||||
require 'topmenu'
|
dofile 'topmenu'
|
||||||
TopMenu.init()
|
TopMenu.init()
|
||||||
|
|
||||||
onUnload: |
|
onUnload: |
|
||||||
|
|
|
@ -3,6 +3,8 @@ Module
|
||||||
description: Contains fonts used by core
|
description: Contains fonts used by core
|
||||||
author: OTClient team
|
author: OTClient team
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
|
canUnload: false
|
||||||
|
|
||||||
onLoad: |
|
onLoad: |
|
||||||
importFont 'verdana-11px-antialised'
|
importFont 'verdana-11px-antialised'
|
||||||
importFont 'verdana-11px-monochrome'
|
importFont 'verdana-11px-monochrome'
|
||||||
|
|
|
@ -5,21 +5,21 @@ Module
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
|
|
||||||
onLoad: |
|
onLoad: |
|
||||||
require 'ext/table'
|
dofile 'ext/table'
|
||||||
require 'ext/string'
|
dofile 'ext/string'
|
||||||
require 'ext/os'
|
dofile 'ext/os'
|
||||||
require 'math/point'
|
dofile 'math/point'
|
||||||
require 'math/size'
|
dofile 'math/size'
|
||||||
require 'math/color'
|
dofile 'math/color'
|
||||||
require 'math/rect'
|
dofile 'math/rect'
|
||||||
require 'const'
|
dofile 'const'
|
||||||
require 'util'
|
dofile 'util'
|
||||||
require 'globals'
|
dofile 'globals'
|
||||||
require 'dispatcher'
|
dofile 'dispatcher'
|
||||||
require 'effects'
|
dofile 'effects'
|
||||||
require 'settings'
|
dofile 'settings'
|
||||||
require 'hotkeys'
|
dofile 'keyboard'
|
||||||
require 'cursor'
|
dofile 'mouse'
|
||||||
|
|
||||||
onUnload: |
|
onUnload: |
|
||||||
rootWidget = nil
|
rootWidget = nil
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
function setTargetCursor()
|
|
||||||
g_window.setMouseCursor('/core_styles/icons/targetcursor.png', {x=9,y=9})
|
|
||||||
end
|
|
||||||
|
|
||||||
function restoreCursor()
|
|
||||||
g_window.restoreMouseCursor()
|
|
||||||
end
|
|
|
@ -0,0 +1,134 @@
|
||||||
|
Keyboard = {}
|
||||||
|
|
||||||
|
-- private functions
|
||||||
|
local function translateKeyCombo(keyCombo)
|
||||||
|
if not keyCombo or #keyCombo == 0 then return nil end
|
||||||
|
table.sort(keyCombo)
|
||||||
|
local keyComboDesc = ''
|
||||||
|
for k,v in pairs(keyCombo) do
|
||||||
|
local keyDesc = KeyCodeDescs[v]
|
||||||
|
if keyDesc == nil then return nil end
|
||||||
|
keyComboDesc = keyComboDesc .. '+' .. keyDesc
|
||||||
|
end
|
||||||
|
keyComboDesc = keyComboDesc:sub(2)
|
||||||
|
return keyComboDesc
|
||||||
|
end
|
||||||
|
|
||||||
|
local function retranslateKeyComboDesc(keyComboDesc)
|
||||||
|
if keyComboDesc == nil then return nil end
|
||||||
|
local keyCombo = {}
|
||||||
|
for i,currentKeyDesc in ipairs(keyComboDesc:split('+')) do
|
||||||
|
for keyCode, keyDesc in pairs(KeyCodeDescs) do
|
||||||
|
if keyDesc:lower() == currentKeyDesc:trim():lower() then
|
||||||
|
table.insert(keyCombo, keyCode)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return translateKeyCombo(keyCombo)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function determineKeyComboDesc(keyCode, keyboardModifiers)
|
||||||
|
local keyCombo = {}
|
||||||
|
if keyCode == KeyCtrl or keyCode == KeyShift or keyCode == KeyAlt then
|
||||||
|
table.insert(keyCombo, keyCode)
|
||||||
|
elseif KeyCodeDescs[keyCode] ~= nil then
|
||||||
|
if keyboardModifiers == KeyboardCtrlModifier then
|
||||||
|
table.insert(keyCombo, KeyCtrl)
|
||||||
|
elseif keyboardModifiers == KeyboardAltModifier then
|
||||||
|
table.insert(keyCombo, KeyAlt)
|
||||||
|
elseif keyboardModifiers == KeyboardCtrlAltModifier then
|
||||||
|
table.insert(keyCombo, KeyCtrl)
|
||||||
|
table.insert(keyCombo, KeyAlt)
|
||||||
|
elseif keyboardModifiers == KeyboardShiftModifier then
|
||||||
|
table.insert(keyCombo, KeyShift)
|
||||||
|
elseif keyboardModifiers == KeyboardCtrlShiftModifier then
|
||||||
|
table.insert(keyCombo, KeyCtrl)
|
||||||
|
table.insert(keyCombo, KeyShift)
|
||||||
|
elseif keyboardModifiers == KeyboardAltShiftModifier then
|
||||||
|
table.insert(keyCombo, KeyAlt)
|
||||||
|
table.insert(keyCombo, KeyShift)
|
||||||
|
elseif keyboardModifiers == KeyboardCtrlAltShiftModifier then
|
||||||
|
table.insert(keyCombo, KeyCtrl)
|
||||||
|
table.insert(keyCombo, KeyAlt)
|
||||||
|
table.insert(keyCombo, KeyShift)
|
||||||
|
end
|
||||||
|
table.insert(keyCombo, keyCode)
|
||||||
|
end
|
||||||
|
table.sort(keyCombo)
|
||||||
|
return translateKeyCombo(keyCombo)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function onWidgetKeyDown(widget, keyCode, keyboardModifiers)
|
||||||
|
if keyCode == KeyUnknown then return end
|
||||||
|
local keyComboDesc = determineKeyComboDesc(keyCode, keyboardModifiers)
|
||||||
|
local callback = widget.boundKeyDownCombos[keyComboDesc]
|
||||||
|
if callback then
|
||||||
|
callback()
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
local function onWidgetKeyPress(widget, keyCode, keyboardModifiers, wouldFilter)
|
||||||
|
local keyComboDesc = determineKeyComboDesc(keyCode, keyboardModifiers)
|
||||||
|
if keyCode == KeyUnknown then return end
|
||||||
|
local callback = widget.boundKeyPressCombos[keyComboDesc]
|
||||||
|
if callback then
|
||||||
|
callback()
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
local function connectKeyDownEvent(widget)
|
||||||
|
if widget.boundKeyDownCombos then return end
|
||||||
|
connect(widget, { onKeyDown = onWidgetKeyDown })
|
||||||
|
widget.boundKeyDownCombos = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
local function connectKeyPressEvent(widget)
|
||||||
|
if widget.boundKeyPressCombos then return end
|
||||||
|
connect(widget, { onKeyPress = onWidgetKeyPress })
|
||||||
|
widget.boundKeyPressCombos = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
-- public functions
|
||||||
|
function Keyboard.bindKeyDown(keyComboDesc, callback, widget)
|
||||||
|
widget = widget or rootWidget
|
||||||
|
connectKeyDownEvent(widget)
|
||||||
|
local keyComboDesc = retranslateKeyComboDesc(keyComboDesc)
|
||||||
|
if keyComboDesc then
|
||||||
|
widget.boundKeyDownCombos[keyComboDesc] = callback
|
||||||
|
else
|
||||||
|
error('key combo \'' .. keyComboDesc .. '\' is failed')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Keyboard.bindKeyPress(keyComboDesc, callback, widget)
|
||||||
|
widget = widget or rootWidget
|
||||||
|
connectKeyPressEvent(widget)
|
||||||
|
local keyComboDesc = retranslateKeyComboDesc(keyComboDesc)
|
||||||
|
if keyComboDesc then
|
||||||
|
widget.boundKeyPressCombos[keyComboDesc] = callback
|
||||||
|
else
|
||||||
|
error('key combo \'' .. keyComboDesc .. '\' is failed')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Keyboard.unbindKeyDown(keyComboDesc, widget)
|
||||||
|
widget = widget or rootWidget
|
||||||
|
if widget.boundKeyDownCombos == nil then return end
|
||||||
|
local keyComboDesc = retranslateKeyComboDesc(keyComboDesc)
|
||||||
|
if keyComboDesc then
|
||||||
|
widget.boundKeyDownCombos[keyComboDesc] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Keyboard.unbindKeyPress(keyComboDesc, widget)
|
||||||
|
widget = widget or rootWidget
|
||||||
|
if widget.boundKeyPressCombos == nil then return end
|
||||||
|
local keyComboDesc = retranslateKeyComboDesc(keyComboDesc)
|
||||||
|
if keyComboDesc then
|
||||||
|
widget.boundKeyPressCombos[keyComboDesc] = nil
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,2 +1,9 @@
|
||||||
Mouse = {}
|
Mouse = {}
|
||||||
|
|
||||||
|
function Mouse.setTargetCursor()
|
||||||
|
g_window.setMouseCursor('/core_styles/icons/targetcursor.png', {x=9,y=9})
|
||||||
|
end
|
||||||
|
|
||||||
|
function Mouse.restoreCursor()
|
||||||
|
g_window.restoreMouseCursor()
|
||||||
|
end
|
||||||
|
|
|
@ -114,7 +114,3 @@ function signalcall(param, ...)
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
function runscript(file)
|
|
||||||
g_lua.runScript(resolvepath(file, 2))
|
|
||||||
end
|
|
|
@ -5,17 +5,17 @@ Module
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
|
|
||||||
onLoad: |
|
onLoad: |
|
||||||
require 'uiwidget'
|
dofile 'uiwidget'
|
||||||
require 'uibutton'
|
dofile 'uibutton'
|
||||||
require 'uilabel'
|
dofile 'uilabel'
|
||||||
require 'uicheckbox'
|
dofile 'uicheckbox'
|
||||||
require 'uicombobox'
|
dofile 'uicombobox'
|
||||||
require 'uispinbox'
|
dofile 'uispinbox'
|
||||||
require 'uiprogressbar'
|
dofile 'uiprogressbar'
|
||||||
require 'uitabbar'
|
dofile 'uitabbar'
|
||||||
require 'uipopupmenu'
|
dofile 'uipopupmenu'
|
||||||
require 'uiwindow'
|
dofile 'uiwindow'
|
||||||
require 'uiitem'
|
dofile 'uiitem'
|
||||||
require 'tooltip/tooltip'
|
dofile 'tooltip/tooltip'
|
||||||
require 'messagebox/messagebox'
|
dofile 'messagebox/messagebox'
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ function UIItem:onDragEnter(mousePos)
|
||||||
|
|
||||||
self.parsed = false
|
self.parsed = false
|
||||||
self.currentDragThing = item
|
self.currentDragThing = item
|
||||||
setTargetCursor()
|
Mouse.setTargetCursor()
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ function UIItem:onDragLeave(widget, mousePos)
|
||||||
self.currentDragThing = nil
|
self.currentDragThing = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
restoreCursor()
|
Mouse.restoreCursor()
|
||||||
self:setBorderWidth(0)
|
self:setBorderWidth(0)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
--[[
|
||||||
UIMessageBox = extends(UIWindow)
|
UIMessageBox = extends(UIWindow)
|
||||||
|
|
||||||
function UIMessageBox.create(title, message)
|
function UIMessageBox.create(title, message)
|
||||||
|
@ -19,5 +20,4 @@ end
|
||||||
|
|
||||||
function UIMessageBox:setMessage(message)
|
function UIMessageBox:setMessage(message)
|
||||||
end
|
end
|
||||||
|
]]--
|
||||||
function
|
|
|
@ -32,7 +32,7 @@ local function onUseWithMouseRelease(self, mousePosition, mouseButton)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Game.selectedThing = nil
|
Game.selectedThing = nil
|
||||||
restoreCursor()
|
Mouse.restoreCursor()
|
||||||
self:ungrabMouse()
|
self:ungrabMouse()
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
@ -41,7 +41,7 @@ end
|
||||||
function Game.startUseWith(thing)
|
function Game.startUseWith(thing)
|
||||||
Game.selectedThing = thing
|
Game.selectedThing = thing
|
||||||
m_mouseGrabberWidget:grabMouse()
|
m_mouseGrabberWidget:grabMouse()
|
||||||
setTargetCursor()
|
Mouse.setTargetCursor()
|
||||||
end
|
end
|
||||||
|
|
||||||
function Game.createInterface()
|
function Game.createInterface()
|
||||||
|
@ -49,15 +49,15 @@ function Game.createInterface()
|
||||||
CharacterList.destroyLoadBox()
|
CharacterList.destroyLoadBox()
|
||||||
Game.gameUi = displayUI('game.otui')
|
Game.gameUi = displayUI('game.otui')
|
||||||
|
|
||||||
--Hotkeys.bindKeyPress('Up', function() Game.walk(North) end)
|
--Keyboard.bindKeyPress('Up', function() Game.walk(North) end)
|
||||||
--Hotkeys.bindKeyPress('Down', function() Game.walk(South) end)
|
--Keyboard.bindKeyPress('Down', function() Game.walk(South) end)
|
||||||
--Hotkeys.bindKeyPress('Left', function() Game.walk(West) end)
|
--Keyboard.bindKeyPress('Left', function() Game.walk(West) end)
|
||||||
--Hotkeys.bindKeyPress('Right', function() Game.walk(East) end)
|
--Keyboard.bindKeyPress('Right', function() Game.walk(East) end)
|
||||||
|
|
||||||
Hotkeys.bindKeyPress('Ctrl+Shift+Up', function() Game.forceWalk(North) end)
|
Keyboard.bindKeyPress('Ctrl+Shift+Up', function() Game.forceWalk(North) end)
|
||||||
Hotkeys.bindKeyPress('Ctrl+Shift+Down', function() Game.forceWalk(South) end)
|
Keyboard.bindKeyPress('Ctrl+Shift+Down', function() Game.forceWalk(South) end)
|
||||||
Hotkeys.bindKeyPress('Ctrl+Shift+Left', function() Game.forceWalk(West) end)
|
Keyboard.bindKeyPress('Ctrl+Shift+Left', function() Game.forceWalk(West) end)
|
||||||
Hotkeys.bindKeyPress('Ctrl+Shift+Right', function() Game.forceWalk(East) end)
|
Keyboard.bindKeyPress('Ctrl+Shift+Right', function() Game.forceWalk(East) end)
|
||||||
|
|
||||||
rootWidget:moveChildToIndex(Game.gameUi, 1)
|
rootWidget:moveChildToIndex(Game.gameUi, 1)
|
||||||
Game.gameMapPanel = Game.gameUi:getChildById('gameMapPanel')
|
Game.gameMapPanel = Game.gameUi:getChildById('gameMapPanel')
|
||||||
|
|
|
@ -15,8 +15,8 @@ Module
|
||||||
- game_containers
|
- game_containers
|
||||||
|
|
||||||
onLoad: |
|
onLoad: |
|
||||||
require 'game'
|
dofile 'game'
|
||||||
require 'thing'
|
dofile 'thing'
|
||||||
require 'creature'
|
dofile 'creature'
|
||||||
require 'player'
|
dofile 'player'
|
||||||
require 'map'
|
dofile 'map'
|
||||||
|
|
|
@ -7,7 +7,7 @@ function UIMap:onDragEnter(mousePos)
|
||||||
|
|
||||||
self.parsed = false
|
self.parsed = false
|
||||||
self.currentDragThing = thing
|
self.currentDragThing = thing
|
||||||
setTargetCursor()
|
Mouse.setTargetCursor()
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ function UIMap:onDragLeave(widget, mousePos)
|
||||||
self.currentDragThing = nil
|
self.currentDragThing = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
restoreCursor()
|
Mouse.restoreCursor()
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -4,4 +4,4 @@ Module
|
||||||
author: OTClient team
|
author: OTClient team
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
onLoad: |
|
onLoad: |
|
||||||
require 'combatcontrols'
|
dofile 'combatcontrols'
|
||||||
|
|
|
@ -88,11 +88,11 @@ function Console.create()
|
||||||
Console.addChannel('Default', 0)
|
Console.addChannel('Default', 0)
|
||||||
Console.addTab('Server Log', false)
|
Console.addTab('Server Log', false)
|
||||||
|
|
||||||
Hotkeys.bindKeyDown('Shift+Up', function() navigateMessageHistory(1) end, consolePanel)
|
Keyboard.bindKeyDown('Shift+Up', function() navigateMessageHistory(1) end, consolePanel)
|
||||||
Hotkeys.bindKeyDown('Shift+Down', function() navigateMessageHistory(-1) end, consolePanel)
|
Keyboard.bindKeyDown('Shift+Down', function() navigateMessageHistory(-1) end, consolePanel)
|
||||||
Hotkeys.bindKeyDown('Tab', function() consoleTabBar:selectNextTab() end, consolePanel)
|
Keyboard.bindKeyDown('Tab', function() consoleTabBar:selectNextTab() end, consolePanel)
|
||||||
Hotkeys.bindKeyDown('Shift+Tab', function() consoleTabBar:selectPrevTab() end, consolePanel)
|
Keyboard.bindKeyDown('Shift+Tab', function() consoleTabBar:selectPrevTab() end, consolePanel)
|
||||||
Hotkeys.bindKeyDown('Enter', Console.sendCurrentMessage, consolePanel)
|
Keyboard.bindKeyDown('Enter', Console.sendCurrentMessage, consolePanel)
|
||||||
|
|
||||||
-- apply buttom functions after loaded
|
-- apply buttom functions after loaded
|
||||||
connect(consolePanel:getChildById('nextChannelButton'), { onClick = function() consoleTabBar:selectNextTab() end } )
|
connect(consolePanel:getChildById('nextChannelButton'), { onClick = function() consoleTabBar:selectNextTab() end } )
|
||||||
|
@ -100,8 +100,8 @@ function Console.create()
|
||||||
connect(consoleTabBar, { onTabChange = Console.onTabChange })
|
connect(consoleTabBar, { onTabChange = Console.onTabChange })
|
||||||
|
|
||||||
-- tibia like hotkeys
|
-- tibia like hotkeys
|
||||||
Hotkeys.bindKeyDown('Ctrl+O', Game.requestChannels)
|
Keyboard.bindKeyDown('Ctrl+O', Game.requestChannels)
|
||||||
Hotkeys.bindKeyDown('Ctrl+E', Console.removeCurrentTab)
|
Keyboard.bindKeyDown('Ctrl+E', Console.removeCurrentTab)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Console.destroy()
|
function Console.destroy()
|
||||||
|
|
|
@ -4,4 +4,4 @@ Module
|
||||||
author: OTClient team
|
author: OTClient team
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
onLoad: |
|
onLoad: |
|
||||||
require 'console'
|
dofile 'console'
|
||||||
|
|
|
@ -4,4 +4,4 @@ Module
|
||||||
author: OTClient team
|
author: OTClient team
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
onLoad: |
|
onLoad: |
|
||||||
require 'containers'
|
dofile 'containers'
|
||||||
|
|
|
@ -4,4 +4,4 @@ Module
|
||||||
author: OTClient team
|
author: OTClient team
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
onLoad: |
|
onLoad: |
|
||||||
require 'healthbar'
|
dofile 'healthbar'
|
||||||
|
|
|
@ -9,11 +9,11 @@ function Inventory.create()
|
||||||
inventoryWindow = displayUI('inventory.otui', { parent = Game.gameRightPanel })
|
inventoryWindow = displayUI('inventory.otui', { parent = Game.gameRightPanel })
|
||||||
inventoryButton = TopMenu.addGameButton('inventoryButton', 'Inventory (Ctrl+I)', 'inventory.png', Inventory.toggle)
|
inventoryButton = TopMenu.addGameButton('inventoryButton', 'Inventory (Ctrl+I)', 'inventory.png', Inventory.toggle)
|
||||||
inventoryButton:setOn(true)
|
inventoryButton:setOn(true)
|
||||||
Hotkeys.bindKeyDown('Ctrl+I', Inventory.toggle)
|
Keyboard.bindKeyDown('Ctrl+I', Inventory.toggle)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Inventory.destroy()
|
function Inventory.destroy()
|
||||||
Hotkeys.unbindKeyDown('Ctrl+I')
|
Keyboard.unbindKeyDown('Ctrl+I')
|
||||||
inventoryWindow:destroy()
|
inventoryWindow:destroy()
|
||||||
inventoryWindow = nil
|
inventoryWindow = nil
|
||||||
inventoryButton:destroy()
|
inventoryButton:destroy()
|
||||||
|
|
|
@ -4,4 +4,4 @@ Module
|
||||||
author: OTClient team
|
author: OTClient team
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
onLoad: |
|
onLoad: |
|
||||||
require 'inventory'
|
dofile 'inventory'
|
||||||
|
|
|
@ -4,4 +4,4 @@ Module
|
||||||
author: OTClient team
|
author: OTClient team
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
onLoad: |
|
onLoad: |
|
||||||
require 'outfit'
|
dofile 'outfit'
|
||||||
|
|
|
@ -45,11 +45,11 @@ function Skills.create()
|
||||||
skillsWindow = displayUI('skills.otui', { parent = Game.gameRightPanel })
|
skillsWindow = displayUI('skills.otui', { parent = Game.gameRightPanel })
|
||||||
skillsWindow:hide()
|
skillsWindow:hide()
|
||||||
skillsButton = TopMenu.addGameButton('skillsButton', 'Skills (Ctrl+S)', '/core_styles/icons/skills.png', Skills.toggle)
|
skillsButton = TopMenu.addGameButton('skillsButton', 'Skills (Ctrl+S)', '/core_styles/icons/skills.png', Skills.toggle)
|
||||||
Hotkeys.bindKeyDown('Ctrl+S', Skills.toggle)
|
Keyboard.bindKeyDown('Ctrl+S', Skills.toggle)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Skills.destroy()
|
function Skills.destroy()
|
||||||
Hotkeys.unbindKeyDown('Ctrl+S')
|
Keyboard.unbindKeyDown('Ctrl+S')
|
||||||
skillsButton:destroy()
|
skillsButton:destroy()
|
||||||
skillsButton = nil
|
skillsButton = nil
|
||||||
skillsWindow:destroy()
|
skillsWindow:destroy()
|
||||||
|
|
|
@ -4,4 +4,4 @@ Module
|
||||||
author: OTClient team
|
author: OTClient team
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
onLoad: |
|
onLoad: |
|
||||||
require 'skills'
|
dofile 'skills'
|
||||||
|
|
|
@ -4,4 +4,4 @@ Module
|
||||||
author: OTClient team
|
author: OTClient team
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
onLoad: |
|
onLoad: |
|
||||||
require 'textmessage'
|
dofile 'textmessage'
|
||||||
|
|
|
@ -4,4 +4,4 @@ Module
|
||||||
author: OTClient team
|
author: OTClient team
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
onLoad: |
|
onLoad: |
|
||||||
require 'viplist'
|
dofile 'viplist'
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
-- this file use loaded after everything is loaded and initialized
|
-- this file use loaded after everything is loaded and initialized
|
||||||
-- you can place any custom user code here
|
-- you can place any custom user code here
|
||||||
|
|
||||||
Hotkeys.bindKeyDown('F1', function() Game.talk('exura gran') end)
|
Keyboard.bindKeyDown('F1', function() Game.talk('exura gran') end)
|
||||||
Hotkeys.bindKeyDown('F2', function() Game.talk('exori mort') end)
|
Keyboard.bindKeyDown('F2', function() Game.talk('exori mort') end)
|
||||||
Hotkeys.bindKeyDown('F3', function() Game.talk('exori frigo') end)
|
Keyboard.bindKeyDown('F3', function() Game.talk('exori frigo') end)
|
||||||
Hotkeys.bindKeyDown('F4', function() Game.talk('exevo vis hur') end)
|
Keyboard.bindKeyDown('F4', function() Game.talk('exevo vis hur') end)
|
||||||
Hotkeys.bindKeyDown('F5', function() Game.talk('utani gran hur') end)
|
Keyboard.bindKeyDown('F5', function() Game.talk('utani gran hur') end)
|
||||||
Hotkeys.bindKeyDown('F6', function() Game.talk('exani tera') end)
|
Keyboard.bindKeyDown('F6', function() Game.talk('exani tera') end)
|
||||||
|
|
||||||
local function reload()
|
local function reload()
|
||||||
runscript('otclientrc.lua')
|
dofile('otclientrc.lua')
|
||||||
TextMessage.displayEventAdvance('Script otclientrc.lua reloaded.')
|
TextMessage.displayEventAdvance('Script otclientrc.lua reloaded.')
|
||||||
print('Script otclient.rc lua reloaded')
|
print('Script otclient.rc lua reloaded')
|
||||||
end
|
end
|
||||||
Hotkeys.bindKeyDown('Ctrl+R', reload)
|
Keyboard.bindKeyDown('Ctrl+R', reload)
|
||||||
|
|
||||||
rcloaded = true
|
rcloaded = true
|
||||||
|
|
|
@ -512,6 +512,22 @@ int LuaInterface::luaScriptLoader(lua_State* L)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int LuaInterface::luaScriptRunner(lua_State* L)
|
||||||
|
{
|
||||||
|
std::string fileName = g_lua.popString();
|
||||||
|
if(!boost::ends_with(fileName, ".lua"))
|
||||||
|
fileName += ".lua";
|
||||||
|
|
||||||
|
try {
|
||||||
|
g_lua.loadScript(fileName);
|
||||||
|
g_lua.call(0, LUA_MULTRET);
|
||||||
|
return g_lua.stackSize();
|
||||||
|
} catch(LuaException& e) {
|
||||||
|
logError("failed to load script file '", fileName, "' :'", e.what());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int LuaInterface::luaErrorHandler(lua_State* L)
|
int LuaInterface::luaErrorHandler(lua_State* L)
|
||||||
{
|
{
|
||||||
// pops the error message
|
// pops the error message
|
||||||
|
@ -583,6 +599,10 @@ void LuaInterface::createLuaState()
|
||||||
pushCFunction(&LuaInterface::luaScriptLoader);
|
pushCFunction(&LuaInterface::luaScriptLoader);
|
||||||
rawSeti(5);
|
rawSeti(5);
|
||||||
pop(2);
|
pop(2);
|
||||||
|
|
||||||
|
// replace dofile
|
||||||
|
pushCFunction(&LuaInterface::luaScriptRunner);
|
||||||
|
setGlobal("dofile");
|
||||||
}
|
}
|
||||||
|
|
||||||
void LuaInterface::closeLuaState()
|
void LuaInterface::closeLuaState()
|
||||||
|
|
|
@ -186,6 +186,8 @@ public:
|
||||||
private:
|
private:
|
||||||
/// Load scripts requested by lua 'require'
|
/// Load scripts requested by lua 'require'
|
||||||
static int luaScriptLoader(lua_State* L);
|
static int luaScriptLoader(lua_State* L);
|
||||||
|
/// Run scripts requested by lua 'dofile'
|
||||||
|
static int luaScriptRunner(lua_State* L);
|
||||||
/// Handle lua errors from safeCall
|
/// Handle lua errors from safeCall
|
||||||
static int luaErrorHandler(lua_State* L);
|
static int luaErrorHandler(lua_State* L);
|
||||||
/// Handle bound cpp functions callbacks
|
/// Handle bound cpp functions callbacks
|
||||||
|
|
Loading…
Reference in New Issue