Added enable/disable chat mode (allows for alphabetical key controls), battle window anchoring fixed (thank you River) & more:
* Added better walk key binding (for other uses, like the sample given WASD). * Made string.ends part of the string meta table rather than parameter based.
This commit is contained in:
parent
0ff36a1a0a
commit
5fbb71157d
|
@ -20,8 +20,8 @@ function string:starts(start)
|
||||||
return string.sub(self, 1, #start) == start
|
return string.sub(self, 1, #start) == start
|
||||||
end
|
end
|
||||||
|
|
||||||
function string.ends(s, test)
|
function string:ends(test)
|
||||||
return test =='' or string.sub(s,-string.len(test)) == test
|
return test =='' or string.sub(self,-string.len(test)) == test
|
||||||
end
|
end
|
||||||
|
|
||||||
function string:trim()
|
function string:trim()
|
||||||
|
|
|
@ -98,7 +98,8 @@ MiniWindow
|
||||||
width: 74
|
width: 74
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.left: prev.right
|
anchors.left: prev.right
|
||||||
margin-left: 5
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
margin-left: -28
|
||||||
|
|
||||||
ComboBox
|
ComboBox
|
||||||
id: sortOrderBox
|
id: sortOrderBox
|
||||||
|
@ -134,7 +135,7 @@ MiniWindow
|
||||||
|
|
||||||
MiniWindowContents
|
MiniWindowContents
|
||||||
anchors.top: prev.bottom
|
anchors.top: prev.bottom
|
||||||
margin-top: 2
|
margin-top: 6
|
||||||
|
|
||||||
Panel
|
Panel
|
||||||
id: battlePanel
|
id: battlePanel
|
||||||
|
|
|
@ -144,9 +144,58 @@ function init()
|
||||||
g_keyboard.bindKeyDown('Ctrl+E', removeCurrentTab)
|
g_keyboard.bindKeyDown('Ctrl+E', removeCurrentTab)
|
||||||
g_keyboard.bindKeyDown('Ctrl+H', openHelp)
|
g_keyboard.bindKeyDown('Ctrl+H', openHelp)
|
||||||
|
|
||||||
|
consoleToggleChat = consolePanel:getChildById('toggleChat')
|
||||||
load()
|
load()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function toggleChat()
|
||||||
|
if consoleToggleChat:isChecked() then
|
||||||
|
disableChat()
|
||||||
|
else
|
||||||
|
enableChat()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function enableChat()
|
||||||
|
local gameInterface = modules.game_interface
|
||||||
|
|
||||||
|
consoleTextEdit:setVisible(true)
|
||||||
|
consoleTextEdit:setText("")
|
||||||
|
|
||||||
|
g_keyboard.unbindKeyUp("Space")
|
||||||
|
g_keyboard.unbindKeyUp("Enter")
|
||||||
|
|
||||||
|
gameInterface.unbindWalkKey("W")
|
||||||
|
gameInterface.unbindWalkKey("D")
|
||||||
|
gameInterface.unbindWalkKey("S")
|
||||||
|
gameInterface.unbindWalkKey("A")
|
||||||
|
|
||||||
|
consoleToggleChat:setTooltip(tr("Disable chat mode"))
|
||||||
|
end
|
||||||
|
|
||||||
|
function disableChat()
|
||||||
|
local gameInterface = modules.game_interface
|
||||||
|
|
||||||
|
consoleTextEdit:setVisible(false)
|
||||||
|
consoleTextEdit:setText("")
|
||||||
|
|
||||||
|
local quickFunc = function()
|
||||||
|
if consoleToggleChat:isChecked() then
|
||||||
|
consoleToggleChat:setChecked(false)
|
||||||
|
end
|
||||||
|
enableChat()
|
||||||
|
end
|
||||||
|
g_keyboard.bindKeyUp("Space", quickFunc)
|
||||||
|
g_keyboard.bindKeyUp("Enter", quickFunc)
|
||||||
|
|
||||||
|
gameInterface.bindWalkKey("W", North)
|
||||||
|
gameInterface.bindWalkKey("D", East)
|
||||||
|
gameInterface.bindWalkKey("S", South)
|
||||||
|
gameInterface.bindWalkKey("A", West)
|
||||||
|
|
||||||
|
consoleToggleChat:setTooltip(tr("Enable chat mode"))
|
||||||
|
end
|
||||||
|
|
||||||
function terminate()
|
function terminate()
|
||||||
save()
|
save()
|
||||||
disconnect(g_game, {
|
disconnect(g_game, {
|
||||||
|
|
|
@ -56,12 +56,21 @@ Panel
|
||||||
id: consolePanel
|
id: consolePanel
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
|
CheckBox
|
||||||
|
id: toggleChat
|
||||||
|
!tooltip: tr('Disable chat mode')
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.top: parent.top
|
||||||
|
margin-left: 13
|
||||||
|
margin-top: 8
|
||||||
|
@onCheckChange: toggleChat()
|
||||||
|
|
||||||
TabButton
|
TabButton
|
||||||
id: prevChannelButton
|
id: prevChannelButton
|
||||||
icon: /images/game/console/leftarrow
|
icon: /images/game/console/leftarrow
|
||||||
anchors.left: parent.left
|
anchors.left: toggleChat.right
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
margin-left: 6
|
margin-left: 3
|
||||||
margin-top: 6
|
margin-top: 6
|
||||||
|
|
||||||
ConsoleTabBar
|
ConsoleTabBar
|
||||||
|
|
|
@ -57,42 +57,19 @@ end
|
||||||
|
|
||||||
function bindKeys()
|
function bindKeys()
|
||||||
gameRootPanel:setAutoRepeatDelay(250)
|
gameRootPanel:setAutoRepeatDelay(250)
|
||||||
g_keyboard.bindKeyDown('Up', function() changeWalkDir(North) end, gameRootPanel, true)
|
|
||||||
g_keyboard.bindKeyDown('Right', function() changeWalkDir(East) end, gameRootPanel, true)
|
bindWalkKey('Up', North)
|
||||||
g_keyboard.bindKeyDown('Down', function() changeWalkDir(South) end, gameRootPanel, true)
|
bindWalkKey('Right', East)
|
||||||
g_keyboard.bindKeyDown('Left', function() changeWalkDir(West) end, gameRootPanel, true)
|
bindWalkKey('Down', South)
|
||||||
g_keyboard.bindKeyDown('Numpad8', function() changeWalkDir(North) end, gameRootPanel, true)
|
bindWalkKey('Left', West)
|
||||||
g_keyboard.bindKeyDown('Numpad9', function() changeWalkDir(NorthEast) end, gameRootPanel, true)
|
bindWalkKey('Numpad8', North)
|
||||||
g_keyboard.bindKeyDown('Numpad6', function() changeWalkDir(East) end, gameRootPanel, true)
|
bindWalkKey('Numpad9', NorthEast)
|
||||||
g_keyboard.bindKeyDown('Numpad3', function() changeWalkDir(SouthEast) end, gameRootPanel, true)
|
bindWalkKey('Numpad6', East)
|
||||||
g_keyboard.bindKeyDown('Numpad2', function() changeWalkDir(South) end, gameRootPanel, true)
|
bindWalkKey('Numpad3', SouthEast)
|
||||||
g_keyboard.bindKeyDown('Numpad1', function() changeWalkDir(SouthWest) end, gameRootPanel, true)
|
bindWalkKey('Numpad2', South)
|
||||||
g_keyboard.bindKeyDown('Numpad4', function() changeWalkDir(West) end, gameRootPanel, true)
|
bindWalkKey('Numpad1', SouthWest)
|
||||||
g_keyboard.bindKeyDown('Numpad7', function() changeWalkDir(NorthWest) end, gameRootPanel, true)
|
bindWalkKey('Numpad4', West)
|
||||||
g_keyboard.bindKeyUp('Up', function() changeWalkDir(North, true) end, gameRootPanel, true)
|
bindWalkKey('Numpad7', NorthWest)
|
||||||
g_keyboard.bindKeyUp('Right', function() changeWalkDir(East, true) end, gameRootPanel, true)
|
|
||||||
g_keyboard.bindKeyUp('Down', function() changeWalkDir(South, true) end, gameRootPanel, true)
|
|
||||||
g_keyboard.bindKeyUp('Left', function() changeWalkDir(West, true) end, gameRootPanel, true)
|
|
||||||
g_keyboard.bindKeyUp('Numpad8', function() changeWalkDir(North, true) end, gameRootPanel, true)
|
|
||||||
g_keyboard.bindKeyUp('Numpad9', function() changeWalkDir(NorthEast, true) end, gameRootPanel, true)
|
|
||||||
g_keyboard.bindKeyUp('Numpad6', function() changeWalkDir(East, true) end, gameRootPanel, true)
|
|
||||||
g_keyboard.bindKeyUp('Numpad3', function() changeWalkDir(SouthEast, true) end, gameRootPanel, true)
|
|
||||||
g_keyboard.bindKeyUp('Numpad2', function() changeWalkDir(South, true) end, gameRootPanel, true)
|
|
||||||
g_keyboard.bindKeyUp('Numpad1', function() changeWalkDir(SouthWest, true) end, gameRootPanel, true)
|
|
||||||
g_keyboard.bindKeyUp('Numpad4', function() changeWalkDir(West, true) end, gameRootPanel, true)
|
|
||||||
g_keyboard.bindKeyUp('Numpad7', function() changeWalkDir(NorthWest, true) end, gameRootPanel, true)
|
|
||||||
g_keyboard.bindKeyPress('Up', function() smartWalk(North) end, gameRootPanel)
|
|
||||||
g_keyboard.bindKeyPress('Right', function() smartWalk(East) end, gameRootPanel)
|
|
||||||
g_keyboard.bindKeyPress('Down', function() smartWalk(South) end, gameRootPanel)
|
|
||||||
g_keyboard.bindKeyPress('Left', function() smartWalk(West) end, gameRootPanel)
|
|
||||||
g_keyboard.bindKeyPress('Numpad8', function() smartWalk(North) end, gameRootPanel)
|
|
||||||
g_keyboard.bindKeyPress('Numpad9', function() smartWalk(NorthEast) end, gameRootPanel)
|
|
||||||
g_keyboard.bindKeyPress('Numpad6', function() smartWalk(East) end, gameRootPanel)
|
|
||||||
g_keyboard.bindKeyPress('Numpad3', function() smartWalk(SouthEast) end, gameRootPanel)
|
|
||||||
g_keyboard.bindKeyPress('Numpad2', function() smartWalk(South) end, gameRootPanel)
|
|
||||||
g_keyboard.bindKeyPress('Numpad1', function() smartWalk(SouthWest) end, gameRootPanel)
|
|
||||||
g_keyboard.bindKeyPress('Numpad4', function() smartWalk(West) end, gameRootPanel)
|
|
||||||
g_keyboard.bindKeyPress('Numpad7', function() smartWalk(NorthWest) end, gameRootPanel)
|
|
||||||
|
|
||||||
g_keyboard.bindKeyPress('Ctrl+Up', function() g_game.turn(North) changeWalkDir(North) end, gameRootPanel)
|
g_keyboard.bindKeyPress('Ctrl+Up', function() g_game.turn(North) changeWalkDir(North) end, gameRootPanel)
|
||||||
g_keyboard.bindKeyPress('Ctrl+Right', function() g_game.turn(East) changeWalkDir(East) end, gameRootPanel)
|
g_keyboard.bindKeyPress('Ctrl+Right', function() g_game.turn(East) changeWalkDir(East) end, gameRootPanel)
|
||||||
|
@ -111,6 +88,18 @@ function bindKeys()
|
||||||
g_keyboard.bindKeyDown('Ctrl+.', nextViewMode, gameRootPanel)
|
g_keyboard.bindKeyDown('Ctrl+.', nextViewMode, gameRootPanel)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function bindWalkKey(key, dir)
|
||||||
|
g_keyboard.bindKeyDown(key, function() changeWalkDir(dir) end)
|
||||||
|
g_keyboard.bindKeyUp(key, function() changeWalkDir(dir, true) end)
|
||||||
|
g_keyboard.bindKeyPress(key, function() smartWalk(dir) end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function unbindWalkKey(key)
|
||||||
|
g_keyboard.unbindKeyDown(key)
|
||||||
|
g_keyboard.unbindKeyUp(key)
|
||||||
|
g_keyboard.unbindKeyPress(key)
|
||||||
|
end
|
||||||
|
|
||||||
function terminate()
|
function terminate()
|
||||||
save()
|
save()
|
||||||
hide()
|
hide()
|
||||||
|
|
|
@ -86,7 +86,7 @@ function UIItem:onMouseRelease(mousePosition, mouseButton)
|
||||||
g_game.look(item)
|
g_game.look(item)
|
||||||
self.cancelNextRelease = true
|
self.cancelNextRelease = true
|
||||||
return true
|
return true
|
||||||
elseif modules.game_interface.processMouseAction(mousePosition, mouseButton, nil, item, item, nil, item) then
|
elseif modules.game_interface.processMouseAction(mousePosition, mouseButton, nil, item, item, nil, nil) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -6,7 +6,7 @@ end
|
||||||
|
|
||||||
function g_game.chooseRsa(host)
|
function g_game.chooseRsa(host)
|
||||||
if currentRsa ~= CIPSOFT_RSA and currentRsa ~= OTSERV_RSA then return end
|
if currentRsa ~= CIPSOFT_RSA and currentRsa ~= OTSERV_RSA then return end
|
||||||
if string.ends(host, '.tibia.com') or string.ends(host, '.cipsoft.com') then
|
if host:ends('.tibia.com') or host:ends('.cipsoft.com') then
|
||||||
g_game.setRsa(CIPSOFT_RSA)
|
g_game.setRsa(CIPSOFT_RSA)
|
||||||
|
|
||||||
if g_app.getOs() == 'windows' then
|
if g_app.getOs() == 'windows' then
|
||||||
|
|
Loading…
Reference in New Issue