mirror of
https://github.com/edubart/otclient.git
synced 2025-10-15 12:04:55 +02:00
Refactoring and flexibility changes
* Split game module into game and game_interface * Move core_lib to corelib * Move miniwindow to corelib * Introduce init.lua script for initializing the client, giving much more flexibility * OTClient is no longer Application derived and is much simpler
This commit is contained in:
53
modules/corelib/mouse.lua
Normal file
53
modules/corelib/mouse.lua
Normal file
@@ -0,0 +1,53 @@
|
||||
Mouse = {}
|
||||
|
||||
local cursorChanged = false
|
||||
|
||||
function Mouse.setTargetCursor()
|
||||
g_window.setMouseCursor('/cursors/targetcursor.png', {x=9,y=9})
|
||||
cursorChanged = true
|
||||
end
|
||||
|
||||
function Mouse.setHorizontalCursor()
|
||||
g_window.setMouseCursor('/cursors/horizontal.png', {x=9,y=4})
|
||||
cursorChanged = true
|
||||
end
|
||||
|
||||
function Mouse.setVerticalCursor()
|
||||
g_window.setMouseCursor('/cursors/vertical.png', {x=4,y=9})
|
||||
cursorChanged = true
|
||||
end
|
||||
|
||||
function Mouse.restoreCursor()
|
||||
g_window.restoreMouseCursor()
|
||||
cursorChanged = false
|
||||
end
|
||||
|
||||
function Mouse.isCursorChanged()
|
||||
return cursorChanged
|
||||
end
|
||||
|
||||
function Mouse.isPressed(button)
|
||||
if not button then button = MouseLeftButton end
|
||||
return g_window.isMouseButtonPressed(button)
|
||||
end
|
||||
|
||||
function Mouse.bindAutoPress(widget, callback)
|
||||
connect(widget, { onMousePress = function(widget, mousePos, mouseButton)
|
||||
callback()
|
||||
periodicalEvent(function()
|
||||
callback()
|
||||
end, function()
|
||||
return widget:isPressed()
|
||||
end, 30, 300)
|
||||
return true
|
||||
end })
|
||||
end
|
||||
|
||||
function Mouse.bindPressMove(widget, callback)
|
||||
connect(widget, { onMouseMove = function(widget, mousePos, mouseMoved)
|
||||
if widget:isPressed() then
|
||||
callback(mousePos, mouseMoved)
|
||||
end
|
||||
return true
|
||||
end })
|
||||
end
|
Reference in New Issue
Block a user