mirror of
https://github.com/OTCv8/otclientv8.git
synced 2025-04-29 10:49:21 +02:00
Added keypad, fixed one crash bug and few more features for mobile version
This commit is contained in:
parent
8391355c42
commit
82018bf3c9
BIN
data/images/game/mobile/keypad.png
Normal file
BIN
data/images/game/mobile/keypad.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
BIN
data/images/game/mobile/keypad_pointer.png
Normal file
BIN
data/images/game/mobile/keypad_pointer.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.8 KiB |
BIN
data/images/topbuttons/keypad.png
Normal file
BIN
data/images/topbuttons/keypad.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.6 KiB |
@ -1,17 +1,33 @@
|
|||||||
local overlay
|
local overlay
|
||||||
|
local keypad
|
||||||
local touchStart = 0
|
local touchStart = 0
|
||||||
local updateCursorEvent = nil
|
local updateCursorEvent
|
||||||
local zoomInButton
|
local zoomInButton
|
||||||
local zoomOutButton
|
local zoomOutButton
|
||||||
|
local keypadButton
|
||||||
|
local keypadEvent
|
||||||
|
local keypadMousePos = {x=0.5, y=0.5}
|
||||||
|
local keypadTicks = 0
|
||||||
|
|
||||||
-- public functions
|
-- public functions
|
||||||
function init()
|
function init()
|
||||||
if not g_app.isMobile() then return end
|
if not g_app.isMobile() then return end
|
||||||
overlay = g_ui.displayUI('mobile')
|
overlay = g_ui.displayUI('mobile')
|
||||||
|
keypad = overlay.keypad
|
||||||
overlay:raise()
|
overlay:raise()
|
||||||
|
|
||||||
zoomInButton = modules.client_topmenu.addLeftButton('zoomInButton', 'Zoom In', '/images/topbuttons/zoomin', function() g_app.scaleUp() end)
|
zoomInButton = modules.client_topmenu.addLeftButton('zoomInButton', 'Zoom In', '/images/topbuttons/zoomin', function() g_app.scaleUp() end)
|
||||||
zoomOutButton = modules.client_topmenu.addLeftButton('zoomOutButton', 'Zoom Out', '/images/topbuttons/zoomout', function() g_app.scaleDown() end)
|
zoomOutButton = modules.client_topmenu.addLeftButton('zoomOutButton', 'Zoom Out', '/images/topbuttons/zoomout', function() g_app.scaleDown() end)
|
||||||
|
keypadButton = modules.client_topmenu.addLeftGameToggleButton('keypadButton', 'Keypad', '/images/topbuttons/keypad', function()
|
||||||
|
keypadButton:setChecked(not keypadButton:isChecked())
|
||||||
|
if not g_game.isOnline() then
|
||||||
|
keypad:setVisible(false)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
keypad:setVisible(keypadButton:isChecked())
|
||||||
|
end)
|
||||||
|
keypadButton:setChecked(true)
|
||||||
|
|
||||||
scheduleEvent(function()
|
scheduleEvent(function()
|
||||||
g_app.scale(5.0)
|
g_app.scale(5.0)
|
||||||
end, 10)
|
end, 10)
|
||||||
@ -23,10 +39,25 @@ function init()
|
|||||||
onTouchRelease = onMouseRelease,
|
onTouchRelease = onMouseRelease,
|
||||||
onMouseMove = onMouseMove
|
onMouseMove = onMouseMove
|
||||||
})
|
})
|
||||||
|
connect(keypad, {
|
||||||
|
onTouchPress = onKeypadTouchPress,
|
||||||
|
onTouchRelease = onKeypadTouchRelease,
|
||||||
|
onMouseMove = onKeypadTouchMove
|
||||||
|
})
|
||||||
|
connect(g_game, {
|
||||||
|
onGameStart = online,
|
||||||
|
onGameEnd = offline
|
||||||
|
})
|
||||||
|
if g_game.isOnline() then
|
||||||
|
online()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function terminate()
|
function terminate()
|
||||||
if not g_app.isMobile() then return end
|
if not g_app.isMobile() then return end
|
||||||
|
removeEvent(updateCursorEvent)
|
||||||
|
removeEvent(keypadEvent)
|
||||||
|
keypadEvent = nil
|
||||||
disconnect(overlay, {
|
disconnect(overlay, {
|
||||||
onMousePress = onMousePress,
|
onMousePress = onMousePress,
|
||||||
onMouseRelease = onMouseRelease,
|
onMouseRelease = onMouseRelease,
|
||||||
@ -34,8 +65,18 @@ function terminate()
|
|||||||
onTouchRelease = onMouseRelease,
|
onTouchRelease = onMouseRelease,
|
||||||
onMouseMove = onMouseMove
|
onMouseMove = onMouseMove
|
||||||
})
|
})
|
||||||
|
disconnect(keypad, {
|
||||||
|
onTouchPress = onKeypadTouchPress,
|
||||||
|
onTouchRelease = onKeypadTouchRelease,
|
||||||
|
onMouseMove = onKeypadTouchMove
|
||||||
|
})
|
||||||
|
disconnect(g_game, {
|
||||||
|
onGameStart = online,
|
||||||
|
onGameEnd = offline
|
||||||
|
})
|
||||||
zoomInButton:destroy()
|
zoomInButton:destroy()
|
||||||
zoomOutButton:destroy()
|
zoomOutButton:destroy()
|
||||||
|
keypadButton:destroy()
|
||||||
overlay:destroy()
|
overlay:destroy()
|
||||||
overlay = nil
|
overlay = nil
|
||||||
end
|
end
|
||||||
@ -48,13 +89,24 @@ function show()
|
|||||||
overlay:show()
|
overlay:show()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function online()
|
||||||
|
if keypadButton:isChecked() then
|
||||||
|
keypad:raise()
|
||||||
|
keypad:show()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function offline()
|
||||||
|
keypad:hide()
|
||||||
|
end
|
||||||
|
|
||||||
function onMouseMove(widget, pos, offset)
|
function onMouseMove(widget, pos, offset)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function onMousePress(widget, pos, button)
|
function onMousePress(widget, pos, button)
|
||||||
overlay:raise()
|
overlay:raise()
|
||||||
if button == 4 then -- touch
|
if button == MouseTouch then -- touch
|
||||||
overlay:raise()
|
overlay:raise()
|
||||||
overlay.cursor:show()
|
overlay.cursor:show()
|
||||||
overlay.cursor:setPosition({x=pos.x - 32, y = pos.y - 32})
|
overlay.cursor:setPosition({x=pos.x - 32, y = pos.y - 32})
|
||||||
@ -67,12 +119,15 @@ function onMousePress(widget, pos, button)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function onMouseRelease(widget, pos, button)
|
function onMouseRelease(widget, pos, button)
|
||||||
|
if button == MouseTouch then
|
||||||
overlay.cursor:hide()
|
overlay.cursor:hide()
|
||||||
removeEvent(updateCursorEvent)
|
removeEvent(updateCursorEvent)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function updateCursor()
|
function updateCursor()
|
||||||
removeEvent(updateCursorEvent)
|
removeEvent(updateCursorEvent)
|
||||||
|
if not g_mouse.isPressed(MouseTouch) then return end
|
||||||
local percent = 100 - math.max(0, math.min(100, (g_clock.millis() - touchStart) / 5)) -- 500 ms
|
local percent = 100 - math.max(0, math.min(100, (g_clock.millis() - touchStart) / 5)) -- 500 ms
|
||||||
overlay.cursor:setPercent(percent)
|
overlay.cursor:setPercent(percent)
|
||||||
if percent > 0 then
|
if percent > 0 then
|
||||||
@ -82,3 +137,80 @@ function updateCursor()
|
|||||||
overlay.cursor:setOpacity(0.8)
|
overlay.cursor:setOpacity(0.8)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function onKeypadTouchMove(widget, pos, offset)
|
||||||
|
keypadMousePos = {x=(pos.x - widget:getPosition().x) / widget:getWidth(),
|
||||||
|
y=(pos.y - widget:getPosition().y) / widget:getHeight()}
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
function onKeypadTouchPress(widget, pos, button)
|
||||||
|
if button ~= MouseTouch then return false end
|
||||||
|
keypadTicks = 0
|
||||||
|
keypadMousePos = {x=(pos.x - widget:getPosition().x) / widget:getWidth(),
|
||||||
|
y=(pos.y - widget:getPosition().y) / widget:getHeight()}
|
||||||
|
executeWalk()
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
function onKeypadTouchRelease(widget, pos, button)
|
||||||
|
if button ~= MouseTouch then return false end
|
||||||
|
keypadMousePos = {x=(pos.x - widget:getPosition().x) / widget:getWidth(),
|
||||||
|
y=(pos.y - widget:getPosition().y) / widget:getHeight()}
|
||||||
|
executeWalk()
|
||||||
|
removeEvent(keypadEvent)
|
||||||
|
keypad.pointer:setMarginTop(0)
|
||||||
|
keypad.pointer:setMarginLeft(0)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
function executeWalk()
|
||||||
|
removeEvent(keypadEvent)
|
||||||
|
keypadEvent = nil
|
||||||
|
if not modules.game_walking or not g_mouse.isPressed(MouseTouch) then
|
||||||
|
keypad.pointer:setMarginTop(0)
|
||||||
|
keypad.pointer:setMarginLeft(0)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
keypadEvent = scheduleEvent(executeWalk, 20)
|
||||||
|
keypadMousePos.x = math.min(1, math.max(0, keypadMousePos.x))
|
||||||
|
keypadMousePos.y = math.min(1, math.max(0, keypadMousePos.y))
|
||||||
|
local angle = math.atan2(keypadMousePos.x - 0.5, keypadMousePos.y - 0.5)
|
||||||
|
local maxTop = math.abs(math.cos(angle)) * 75
|
||||||
|
local marginTop = math.max(-maxTop, math.min(maxTop, (keypadMousePos.y - 0.5) * 150))
|
||||||
|
local maxLeft = math.abs(math.sin(angle)) * 75
|
||||||
|
local marginLeft = math.max(-maxLeft, math.min(maxLeft, (keypadMousePos.x - 0.5) * 150))
|
||||||
|
keypad.pointer:setMarginTop(marginTop)
|
||||||
|
keypad.pointer:setMarginLeft(marginLeft)
|
||||||
|
local dir
|
||||||
|
if keypadMousePos.y < 0.3 and keypadMousePos.x < 0.3 then
|
||||||
|
dir = Directions.NorthWest
|
||||||
|
elseif keypadMousePos.y < 0.3 and keypadMousePos.x > 0.7 then
|
||||||
|
dir = Directions.NorthEast
|
||||||
|
elseif keypadMousePos.y > 0.7 and keypadMousePos.x < 0.3 then
|
||||||
|
dir = Directions.SouthWest
|
||||||
|
elseif keypadMousePos.y > 0.7 and keypadMousePos.x > 0.7 then
|
||||||
|
dir = Directions.SouthEast
|
||||||
|
end
|
||||||
|
if not dir and (math.abs(keypadMousePos.y - 0.5) > 0.1 or math.abs(keypadMousePos.x - 0.5) > 0.1) then
|
||||||
|
if math.abs(keypadMousePos.y - 0.5) > math.abs(keypadMousePos.x - 0.5) then
|
||||||
|
if keypadMousePos.y < 0.5 then
|
||||||
|
dir = Directions.North
|
||||||
|
else
|
||||||
|
dir = Directions.South
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if keypadMousePos.x < 0.5 then
|
||||||
|
dir = Directions.West
|
||||||
|
else
|
||||||
|
dir = Directions.East
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if dir then
|
||||||
|
modules.game_walking.walk(dir, keypadTicks)
|
||||||
|
if keypadTicks == 0 then
|
||||||
|
keypadTicks = 100
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -13,3 +13,27 @@ UIWidget
|
|||||||
y: 0
|
y: 0
|
||||||
focusable: false
|
focusable: false
|
||||||
phantom: true
|
phantom: true
|
||||||
|
|
||||||
|
UIWidget
|
||||||
|
id: keypad
|
||||||
|
size: 200 150
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
anchors.right: parent.right
|
||||||
|
phantom: false
|
||||||
|
focusable: false
|
||||||
|
visible: false
|
||||||
|
background: #00000044
|
||||||
|
image-source: /images/game/mobile/keypad
|
||||||
|
image-fixed-ratio: true
|
||||||
|
image-rect: 25 0 150 150
|
||||||
|
|
||||||
|
UIWidget
|
||||||
|
id: pointer
|
||||||
|
size: 49 49
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
image-source: /images/game/mobile/keypad_pointer
|
||||||
|
image-fixed-ratio: true
|
||||||
|
phantom: true
|
||||||
|
focusable: false
|
||||||
|
|
@ -5,7 +5,7 @@ local defaultOptions = {
|
|||||||
showPing = true,
|
showPing = true,
|
||||||
fullscreen = false,
|
fullscreen = false,
|
||||||
classicView = not g_app.isMobile(),
|
classicView = not g_app.isMobile(),
|
||||||
cacheMap = false,
|
cacheMap = g_app.isMobile(),
|
||||||
classicControl = not g_app.isMobile(),
|
classicControl = not g_app.isMobile(),
|
||||||
smartWalk = false,
|
smartWalk = false,
|
||||||
dash = false,
|
dash = false,
|
||||||
|
@ -29,11 +29,12 @@ local function addButton(id, description, icon, callback, panel, toggle, front,
|
|||||||
button:setTooltip(description)
|
button:setTooltip(description)
|
||||||
button:setIcon(resolvepath(icon, 3))
|
button:setIcon(resolvepath(icon, 3))
|
||||||
button.onMouseRelease = function(widget, mousePos, mouseButton)
|
button.onMouseRelease = function(widget, mousePos, mouseButton)
|
||||||
if widget:containsPoint(mousePos) and mouseButton ~= MouseMidButton then
|
if widget:containsPoint(mousePos) and mouseButton ~= MouseMidButton and mouseButton ~= MouseTouch then
|
||||||
callback()
|
callback()
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
button.onTouchRelease = button.onMouseRelease
|
||||||
if not button.index and type(index) == 'number' then
|
if not button.index and type(index) == 'number' then
|
||||||
button.index = index
|
button.index = index
|
||||||
end
|
end
|
||||||
|
@ -36,6 +36,9 @@ MouseNoButton = 0
|
|||||||
MouseLeftButton = 1
|
MouseLeftButton = 1
|
||||||
MouseRightButton = 2
|
MouseRightButton = 2
|
||||||
MouseMidButton = 3
|
MouseMidButton = 3
|
||||||
|
MouseTouch = 4
|
||||||
|
MouseTouch2 = 5 -- multitouch, 2nd finger
|
||||||
|
MouseTouch3 = 6 -- multitouch, 3th finger
|
||||||
|
|
||||||
MouseNoWheel = 0
|
MouseNoWheel = 0
|
||||||
MouseWheelUp = 1
|
MouseWheelUp = 1
|
||||||
|
@ -15,12 +15,12 @@ ActionTypes = {
|
|||||||
|
|
||||||
ActionColors = {
|
ActionColors = {
|
||||||
empty = '#00000033',
|
empty = '#00000033',
|
||||||
text = '#88888866',
|
text = '#00000033',
|
||||||
itemUse = '#8888FF66',
|
itemUse = '#8888FF88',
|
||||||
itemUseSelf = '#00FF0066',
|
itemUseSelf = '#00FF0088',
|
||||||
itemUseTarget = '#FF000066',
|
itemUseTarget = '#FF000088',
|
||||||
itemUseWith = '#F5B32566',
|
itemUseWith = '#F5B32588',
|
||||||
itemEquip = '#FFFFFF66'
|
itemEquip = '#FFFFFF88'
|
||||||
}
|
}
|
||||||
|
|
||||||
function init()
|
function init()
|
||||||
@ -142,6 +142,7 @@ function setupAction(action)
|
|||||||
local config = action.config
|
local config = action.config
|
||||||
action.item:setShowCount(false)
|
action.item:setShowCount(false)
|
||||||
action.onMouseRelease = actionOnMouseRelease
|
action.onMouseRelease = actionOnMouseRelease
|
||||||
|
action.onTouchRelease = actionOnMouseRelease
|
||||||
action.callback = function(k, c, ticks) executeAction(action, ticks) end
|
action.callback = function(k, c, ticks) executeAction(action, ticks) end
|
||||||
action.item.onItemChange = nil -- disable callbacks for setup
|
action.item.onItemChange = nil -- disable callbacks for setup
|
||||||
|
|
||||||
@ -165,7 +166,7 @@ function setupAction(action)
|
|||||||
action.cooldownStart = 0
|
action.cooldownStart = 0
|
||||||
if type(config.text) == 'string' and config.text:len() > 0 then
|
if type(config.text) == 'string' and config.text:len() > 0 then
|
||||||
action.text:setText(config.text)
|
action.text:setText(config.text)
|
||||||
action:setBorderColor(ActionColors.text)
|
action.item:setBorderColor(ActionColors.text)
|
||||||
action.item:setOn(true) -- removes background
|
action.item:setOn(true) -- removes background
|
||||||
action.item:setItemId(0)
|
action.item:setItemId(0)
|
||||||
if Spells then
|
if Spells then
|
||||||
@ -188,7 +189,7 @@ function setupAction(action)
|
|||||||
else
|
else
|
||||||
action.item:setItemId(0)
|
action.item:setItemId(0)
|
||||||
action.item:setOn(false)
|
action.item:setOn(false)
|
||||||
action:setBorderColor(ActionColors.empty)
|
action.item:setBorderColor(ActionColors.empty)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -212,15 +213,15 @@ function setupActionType(action, actionType)
|
|||||||
|
|
||||||
action.config.actionType = actionType
|
action.config.actionType = actionType
|
||||||
if action.config.actionType == ActionTypes.USE then
|
if action.config.actionType == ActionTypes.USE then
|
||||||
action:setBorderColor(ActionColors.itemUse)
|
action.item:setBorderColor(ActionColors.itemUse)
|
||||||
elseif action.config.actionType == ActionTypes.USE_SELF then
|
elseif action.config.actionType == ActionTypes.USE_SELF then
|
||||||
action:setBorderColor(ActionColors.itemUseSelf)
|
action.item:setBorderColor(ActionColors.itemUseSelf)
|
||||||
elseif action.config.actionType == ActionTypes.USE_TARGET then
|
elseif action.config.actionType == ActionTypes.USE_TARGET then
|
||||||
action:setBorderColor(ActionColors.itemUseTarget)
|
action.item:setBorderColor(ActionColors.itemUseTarget)
|
||||||
elseif action.config.actionType == ActionTypes.USE_WITH then
|
elseif action.config.actionType == ActionTypes.USE_WITH then
|
||||||
action:setBorderColor(ActionColors.itemUseWith)
|
action.item:setBorderColor(ActionColors.itemUseWith)
|
||||||
elseif action.config.actionType == ActionTypes.EQUIP then
|
elseif action.config.actionType == ActionTypes.EQUIP then
|
||||||
action:setBorderColor(ActionColors.itemEquip)
|
action.item:setBorderColor(ActionColors.itemEquip)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -237,6 +238,7 @@ function updateAction(action, newConfig)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function actionOnMouseRelease(action, mousePosition, mouseButton)
|
function actionOnMouseRelease(action, mousePosition, mouseButton)
|
||||||
|
if mouseButton == MouseTouch then return end
|
||||||
if mouseButton == MouseRightButton or not action.item:isOn() then
|
if mouseButton == MouseRightButton or not action.item:isOn() then
|
||||||
local menu = g_ui.createWidget('PopupMenu')
|
local menu = g_ui.createWidget('PopupMenu')
|
||||||
menu:setGameMenu(true)
|
menu:setGameMenu(true)
|
||||||
@ -292,7 +294,7 @@ function actionOnMouseRelease(action, mousePosition, mouseButton)
|
|||||||
end)
|
end)
|
||||||
menu:display(mousePosition)
|
menu:display(mousePosition)
|
||||||
return true
|
return true
|
||||||
elseif mouseButton == MouseLeftButton then
|
elseif mouseButton == MouseLeftButton or mouseButton == MouseTouch2 or mouseButton == MouseTouch3 then
|
||||||
action.callback()
|
action.callback()
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
ActionButton < Panel
|
ActionButton < Panel
|
||||||
size: 36 36
|
|
||||||
font: cipsoftFont
|
font: cipsoftFont
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
margin-left: 3
|
anchors.bottom: parent.bottom
|
||||||
border-width: 1
|
width: 40
|
||||||
border-color: #00000022
|
padding: 1 1 1 1
|
||||||
|
margin-left: 1
|
||||||
|
|
||||||
$first:
|
$first:
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
@ -15,10 +15,12 @@ ActionButton < Panel
|
|||||||
Item
|
Item
|
||||||
id: item
|
id: item
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
margin: 1 1 1 1
|
|
||||||
&selectable: true
|
&selectable: true
|
||||||
&editable: false
|
&editable: false
|
||||||
virtual: true
|
virtual: true
|
||||||
|
border-width: 1
|
||||||
|
|
||||||
|
border-color: #00000000
|
||||||
|
|
||||||
$!on:
|
$!on:
|
||||||
image-source: /images/game/actionbarslot
|
image-source: /images/game/actionbarslot
|
||||||
@ -26,7 +28,6 @@ ActionButton < Panel
|
|||||||
Label
|
Label
|
||||||
id: text
|
id: text
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
margin: 1 1 1 1
|
|
||||||
text-auto-resize: true
|
text-auto-resize: true
|
||||||
text-wrap: true
|
text-wrap: true
|
||||||
phantom: true
|
phantom: true
|
||||||
@ -85,7 +86,6 @@ Panel
|
|||||||
anchors.left: prev.right
|
anchors.left: prev.right
|
||||||
anchors.right: next.left
|
anchors.right: next.left
|
||||||
margin-right: 3
|
margin-right: 3
|
||||||
margin-top: 2
|
|
||||||
clipping: true
|
clipping: true
|
||||||
|
|
||||||
TabButton
|
TabButton
|
||||||
|
@ -126,8 +126,12 @@ end
|
|||||||
function getSortType()
|
function getSortType()
|
||||||
local settings = g_settings.getNode('BattleList')
|
local settings = g_settings.getNode('BattleList')
|
||||||
if not settings then
|
if not settings then
|
||||||
|
if g_app.isMobile() then
|
||||||
|
return 'distance'
|
||||||
|
else
|
||||||
return 'name'
|
return 'name'
|
||||||
end
|
end
|
||||||
|
end
|
||||||
return settings['sortType']
|
return settings['sortType']
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -219,7 +223,7 @@ function updateBattleList()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function checkCreatures()
|
function checkCreatures()
|
||||||
if not g_game.isOnline() then
|
if not battlePanel or not g_game.isOnline() then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -257,11 +261,17 @@ function checkCreatures()
|
|||||||
local battleButton = battleButtons[i]
|
local battleButton = battleButtons[i]
|
||||||
battleButton:creatureSetup(creature)
|
battleButton:creatureSetup(creature)
|
||||||
battleButton:show()
|
battleButton:show()
|
||||||
|
battleButton:setOn(true)
|
||||||
|
end
|
||||||
|
|
||||||
|
if g_app.isMobile() and #creatures > 0 then
|
||||||
|
onBattleButtonHoverChange(battleButtons[1], true)
|
||||||
end
|
end
|
||||||
|
|
||||||
for i=#creatures + 1,maxCreatures do
|
for i=#creatures + 1,maxCreatures do
|
||||||
if battleButtons[i]:isHidden() then break end
|
if battleButtons[i]:isHidden() then break end
|
||||||
battleButtons[i]:hide()
|
battleButtons[i]:hide()
|
||||||
|
battleButton:setOn(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
battlePanel:getLayout():enableUpdates()
|
battlePanel:getLayout():enableUpdates()
|
||||||
|
@ -66,11 +66,13 @@ MiniWindow
|
|||||||
BattlePlayers
|
BattlePlayers
|
||||||
id: hidePlayers
|
id: hidePlayers
|
||||||
!tooltip: tr('Hide players')
|
!tooltip: tr('Hide players')
|
||||||
|
@onSetup: if g_app.isMobile() then self:setChecked(true) end
|
||||||
@onCheckChange: modules.game_battle.checkCreatures()
|
@onCheckChange: modules.game_battle.checkCreatures()
|
||||||
|
|
||||||
BattleNPCs
|
BattleNPCs
|
||||||
id: hideNPCs
|
id: hideNPCs
|
||||||
!tooltip: tr('Hide Npcs')
|
!tooltip: tr('Hide Npcs')
|
||||||
|
@onSetup: if g_app.isMobile() then self:setChecked(true) end
|
||||||
@onCheckChange: modules.game_battle.checkCreatures()
|
@onCheckChange: modules.game_battle.checkCreatures()
|
||||||
|
|
||||||
BattleMonsters
|
BattleMonsters
|
||||||
@ -86,6 +88,7 @@ MiniWindow
|
|||||||
BattleParty
|
BattleParty
|
||||||
id: hideParty
|
id: hideParty
|
||||||
!tooltip: tr('Hide party members')
|
!tooltip: tr('Hide party members')
|
||||||
|
@onSetup: if g_app.isMobile() then self:setChecked(true) end
|
||||||
@onCheckChange: modules.game_battle.checkCreatures()
|
@onCheckChange: modules.game_battle.checkCreatures()
|
||||||
|
|
||||||
Panel
|
Panel
|
||||||
|
@ -14,7 +14,7 @@ UI.Button("Discord", function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
UI.Button("Forum", function()
|
UI.Button("Forum", function()
|
||||||
g_platform.openUrl("http://otclient.net")
|
g_platform.openUrl("http://otclient.net/")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
UI.Button("Help & Tutorials", function()
|
UI.Button("Help & Tutorials", function()
|
||||||
|
@ -25,7 +25,7 @@ function setupExtraHotkeys(combobox)
|
|||||||
local nextChild = nil
|
local nextChild = nil
|
||||||
local breakNext = false
|
local breakNext = false
|
||||||
for i, child in ipairs(battlePanel:getChildren()) do
|
for i, child in ipairs(battlePanel:getChildren()) do
|
||||||
if not child.creature or child:isDisabled() then
|
if not child.creature or not child:isOn() then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
nextChild = child
|
nextChild = child
|
||||||
@ -53,7 +53,7 @@ function setupExtraHotkeys(combobox)
|
|||||||
local attackedCreature = g_game.getAttackingCreature()
|
local attackedCreature = g_game.getAttackingCreature()
|
||||||
local prevChild = nil
|
local prevChild = nil
|
||||||
for i, child in ipairs(battlePanel:getChildren()) do
|
for i, child in ipairs(battlePanel:getChildren()) do
|
||||||
if not child.creature or child:isDisabled() or child:isHidden() then
|
if not child.creature or not child:isOn() then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
if child.creature == attackedCreature then
|
if child.creature == attackedCreature then
|
||||||
|
@ -40,6 +40,7 @@ function init()
|
|||||||
|
|
||||||
mouseGrabberWidget = gameRootPanel:getChildById('mouseGrabber')
|
mouseGrabberWidget = gameRootPanel:getChildById('mouseGrabber')
|
||||||
mouseGrabberWidget.onMouseRelease = onMouseGrabberRelease
|
mouseGrabberWidget.onMouseRelease = onMouseGrabberRelease
|
||||||
|
mouseGrabberWidget.onTouchRelease = mouseGrabberWidget.onMouseRelease
|
||||||
|
|
||||||
bottomSplitter = gameRootPanel:getChildById('bottomSplitter')
|
bottomSplitter = gameRootPanel:getChildById('bottomSplitter')
|
||||||
gameMapPanel = gameRootPanel:getChildById('gameMapPanel')
|
gameMapPanel = gameRootPanel:getChildById('gameMapPanel')
|
||||||
@ -267,6 +268,7 @@ function updateStretchShrink()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function onMouseGrabberRelease(self, mousePosition, mouseButton)
|
function onMouseGrabberRelease(self, mousePosition, mouseButton)
|
||||||
|
if mouseButton == MouseTouch then return end
|
||||||
if selectedThing == nil then return false end
|
if selectedThing == nil then return false end
|
||||||
if mouseButton == MouseLeftButton then
|
if mouseButton == MouseLeftButton then
|
||||||
local clickedWidget = gameRootPanel:recursiveGetChildByPos(mousePosition, false)
|
local clickedWidget = gameRootPanel:recursiveGetChildByPos(mousePosition, false)
|
||||||
@ -575,7 +577,7 @@ function processMouseAction(menuPosition, mouseButton, autoWalkPos, lookThing, u
|
|||||||
createThingMenu(menuPosition, lookThing, useThing, creatureThing)
|
createThingMenu(menuPosition, lookThing, useThing, creatureThing)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
if mouseButton ~= MouseLeftButton then
|
if mouseButton ~= MouseLeftButton and mouseButton ~= MouseTouch2 and mouseButton ~= MouseTouch3 then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
local action = getLeftAction()
|
local action = getLeftAction()
|
||||||
@ -707,7 +709,7 @@ function processMouseAction(menuPosition, mouseButton, autoWalkPos, lookThing, u
|
|||||||
local player = g_game.getLocalPlayer()
|
local player = g_game.getLocalPlayer()
|
||||||
player:stopAutoWalk()
|
player:stopAutoWalk()
|
||||||
|
|
||||||
if autoWalkPos and keyboardModifiers == KeyboardNoModifier and mouseButton == MouseLeftButton then
|
if autoWalkPos and keyboardModifiers == KeyboardNoModifier and (mouseButton == MouseLeftButton or mouseButton == MouseTouch2 or mouseButton == MouseTouch3) then
|
||||||
local autoWalkTile = g_map.getTile(autoWalkPos)
|
local autoWalkTile = g_map.getTile(autoWalkPos)
|
||||||
if autoWalkTile and not autoWalkTile:isWalkable(true) then
|
if autoWalkTile and not autoWalkTile:isWalkable(true) then
|
||||||
modules.game_textmessage.displayFailureMessage(tr('Sorry, not possible.'))
|
modules.game_textmessage.displayFailureMessage(tr('Sorry, not possible.'))
|
||||||
@ -1056,13 +1058,83 @@ function setupLeftActions()
|
|||||||
if not g_app.isMobile() then return end
|
if not g_app.isMobile() then return end
|
||||||
for _, widget in ipairs(gameLeftActions:getChildren()) do
|
for _, widget in ipairs(gameLeftActions:getChildren()) do
|
||||||
widget.image:setChecked(false)
|
widget.image:setChecked(false)
|
||||||
|
widget.lastClicked = 0
|
||||||
widget.onClick = function()
|
widget.onClick = function()
|
||||||
if widget.image:isChecked() then
|
if widget.image:isChecked() then
|
||||||
widget.image:setChecked(false)
|
widget.image:setChecked(false)
|
||||||
|
if widget.doubleClickAction and widget.lastClicked + 200 > g_clock.millis() then
|
||||||
|
widget.doubleClickAction()
|
||||||
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
resetLeftActions()
|
resetLeftActions()
|
||||||
widget.image:setChecked(true)
|
widget.image:setChecked(true)
|
||||||
|
widget.lastClicked = g_clock.millis()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if gameLeftActions.use then
|
||||||
|
gameLeftActions.use.doubleClickAction = function()
|
||||||
|
local player = g_game.getLocalPlayer()
|
||||||
|
local dir = player:getDirection()
|
||||||
|
local usePos = player:getPrewalkingPosition(true)
|
||||||
|
if dir == North then
|
||||||
|
usePos.y = usePos.y - 1
|
||||||
|
elseif dir == East then
|
||||||
|
usePos.x = usePos.x + 1
|
||||||
|
elseif dir == South then
|
||||||
|
usePos.y = usePos.y + 1
|
||||||
|
elseif dir == West then
|
||||||
|
usePos.x = usePos.x - 1
|
||||||
|
end
|
||||||
|
local tile = g_map.getTile(usePos)
|
||||||
|
if not tile then return end
|
||||||
|
local thing = tile:getTopUseThing()
|
||||||
|
if thing then
|
||||||
|
g_game.use(thing)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if gameLeftActions.attack then
|
||||||
|
gameLeftActions.attack.doubleClickAction = function()
|
||||||
|
local battlePanel = modules.game_battle.battlePanel
|
||||||
|
local attackedCreature = g_game.getAttackingCreature()
|
||||||
|
local child = battlePanel:getFirstChild()
|
||||||
|
if child and (not child.creature or not child:isOn()) then
|
||||||
|
child = nil
|
||||||
|
end
|
||||||
|
if child then
|
||||||
|
g_game.attack(child.creature)
|
||||||
|
else
|
||||||
|
g_game.attack(nil)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if gameLeftActions.follow then
|
||||||
|
gameLeftActions.follow.doubleClickAction = function()
|
||||||
|
local battlePanel = modules.game_battle.battlePanel
|
||||||
|
local attackedCreature = g_game.getAttackingCreature()
|
||||||
|
local child = battlePanel:getFirstChild()
|
||||||
|
if child and (not child.creature or not child:isOn()) then
|
||||||
|
child = nil
|
||||||
|
end
|
||||||
|
if child then
|
||||||
|
g_game.follow(child.creature)
|
||||||
|
else
|
||||||
|
g_game.follow(nil)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if gameLeftActions.look then
|
||||||
|
gameLeftActions.look.doubleClickAction = function()
|
||||||
|
local battlePanel = modules.game_battle.battlePanel
|
||||||
|
local attackedCreature = g_game.getAttackingCreature()
|
||||||
|
local child = battlePanel:getFirstChild()
|
||||||
|
if child and (not child.creature or child:isHidden()) then
|
||||||
|
child = nil
|
||||||
|
end
|
||||||
|
if child then
|
||||||
|
g_game.look(child.creature)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not gameLeftActions.chat then return end
|
if not gameLeftActions.chat then return end
|
||||||
@ -1078,6 +1150,7 @@ end
|
|||||||
function resetLeftActions()
|
function resetLeftActions()
|
||||||
for _, widget in ipairs(gameLeftActions:getChildren()) do
|
for _, widget in ipairs(gameLeftActions:getChildren()) do
|
||||||
widget.image:setChecked(false)
|
widget.image:setChecked(false)
|
||||||
|
widget.lastClicked = 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -172,6 +172,12 @@ function UIGameMap:onMouseRelease(mousePosition, mouseButton)
|
|||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function UIGameMap:onTouchRelease(mousePosition, mouseButton)
|
||||||
|
if mouseButton ~= MouseTouch then
|
||||||
|
return self:onMouseRelease(mousePosition, mouseButton)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function UIGameMap:canAcceptDrop(widget, mousePos)
|
function UIGameMap:canAcceptDrop(widget, mousePos)
|
||||||
if not widget or not widget.currentDragThing then return false end
|
if not widget or not widget.currentDragThing then return false end
|
||||||
|
|
||||||
|
@ -379,6 +379,9 @@ function walk(dir, ticks)
|
|||||||
player:lockWalk(100) -- bug fix for missing stairs down on map
|
player:lockWalk(100) -- bug fix for missing stairs down on map
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
|
if g_app.isMobile() and dir <= Directions.West then
|
||||||
|
turn(dir, ticks > 0)
|
||||||
|
end
|
||||||
return -- not walkable tile
|
return -- not walkable tile
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
BIN
otclient_dx.exe
BIN
otclient_dx.exe
Binary file not shown.
BIN
otclient_gl.exe
BIN
otclient_gl.exe
Binary file not shown.
BIN
otclient_linux
BIN
otclient_linux
Binary file not shown.
BIN
otclientv8.apk
BIN
otclientv8.apk
Binary file not shown.
BIN
pdb/pdb.7z
BIN
pdb/pdb.7z
Binary file not shown.
1
run_android.bat
Normal file
1
run_android.bat
Normal file
@ -0,0 +1 @@
|
|||||||
|
adb uninstall com.otclientv8 && adb install otclientv8.apk && adb logcat -c && adb shell am start -n com.otclientv8/com.otclientv8.OTClientV8 && adb logcat | findstr /i otclient
|
Loading…
x
Reference in New Issue
Block a user