mirror of
https://github.com/edubart/otclient.git
synced 2025-04-30 17:49:21 +02:00

* Added new arrow buttons. * Fixed the vertical separator. * Added new game_playermount module to handle player mounting. * Moved the battle icons to /images. * Outfit window accommodates for mounts, loads addons more efficiently and keeps addons set on update, added new Outfit.randomize function that allows you to randomize your outfit colors, and set up a new layout.
60 lines
1.5 KiB
Lua
60 lines
1.5 KiB
Lua
-- @docclass
|
|
g_mouse = {}
|
|
|
|
local cursorChanged = false
|
|
|
|
function g_mouse.setTargetCursor()
|
|
g_window.setMouseCursor('/cursors/targetcursor.png', {x=9,y=9})
|
|
cursorChanged = true
|
|
end
|
|
|
|
function g_mouse.setHorizontalCursor()
|
|
g_window.setMouseCursor('/cursors/horizontal.png', {x=9,y=4})
|
|
cursorChanged = true
|
|
end
|
|
|
|
function g_mouse.setVerticalCursor()
|
|
g_window.setMouseCursor('/cursors/vertical.png', {x=4,y=9})
|
|
cursorChanged = true
|
|
end
|
|
|
|
function g_mouse.restoreCursor()
|
|
g_window.restoreMouseCursor()
|
|
cursorChanged = false
|
|
end
|
|
|
|
function g_mouse.isCursorChanged()
|
|
return cursorChanged
|
|
end
|
|
|
|
function g_mouse.isPressed(button)
|
|
if not button then button = MouseLeftButton end
|
|
return g_window.isMouseButtonPressed(button)
|
|
end
|
|
|
|
function g_mouse.bindAutoPress(widget, callback, delay, button)
|
|
local button = button or MouseLeftButton
|
|
connect(widget, { onMousePress = function(widget, mousePos, mouseButton)
|
|
if mouseButton ~= button then
|
|
return false
|
|
end
|
|
local startTime = g_clock.millis()
|
|
callback(widget, mousePos, mouseButton, 0)
|
|
periodicalEvent(function()
|
|
callback(widget, g_window.getMousePosition(), mouseButton, g_clock.millis() - startTime)
|
|
end, function()
|
|
return g_mouse.isPressed(mouseButton)
|
|
end, 30, delay)
|
|
return true
|
|
end })
|
|
end
|
|
|
|
function g_mouse.bindPressMove(widget, callback)
|
|
connect(widget, { onMouseMove = function(widget, mousePos, mouseMoved)
|
|
if widget:isPressed() then
|
|
callback(mousePos, mouseMoved)
|
|
end
|
|
return true
|
|
end })
|
|
end
|