mirror of
https://github.com/edubart/otclient.git
synced 2025-11-30 15:26:49 +01:00
rework and classic controls
This commit is contained in:
@@ -1,26 +1,5 @@
|
||||
function UIMap:onMouseRelease(mousePos, mouseButton)
|
||||
local tile = self:getTile(mousePos)
|
||||
if not tile then return false end
|
||||
|
||||
local keyboardModifiers = g_window.getKeyboardModifiers()
|
||||
if not Options.classicControl then
|
||||
if keyboardModifiers == KeyboardNoModifier and mouseButton == MouseLeftButton then
|
||||
-- auto walk
|
||||
return true
|
||||
elseif keyboardModifiers == KeyboardNoModifier and mouseButton == MouseRightButton then
|
||||
Game.createThingMenu(mousePos, tile:getTopLookThing(), tile:getTopUseThing(), tile:getTopCreature())
|
||||
return true
|
||||
elseif keyboardModifiers == KeyboardShiftModifier and (mouseButton == MouseRightButton or mouseButton == MouseLeftButton) then
|
||||
Game.look(tile:getTopLookThing())
|
||||
return true
|
||||
elseif keyboardModifiers == KeyboardCtrlModifier and (mouseButton == MouseRightButton or mouseButton == MouseLeftButton) then
|
||||
Game.use(tile:getTopUseThing())
|
||||
return true
|
||||
elseif keyboardModifiers == KeyboardAltModifier and (mouseButton == MouseRightButton or mouseButton == MouseLeftButton) then
|
||||
Game.attack(tile:getTopCreature())
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
function UIMap:onMouseRelease(mousePosition, mouseButton)
|
||||
local tile = self:getTile(mousePosition)
|
||||
if tile and Game.processMouseAction(mousePosition, mouseButton, nil, tile:getTopLookThing(), tile:getTopUseThing(), tile:getTopCreature(), tile:getTopMultiUseThing()) then return true end
|
||||
return false
|
||||
end
|
||||
|
||||
@@ -1,5 +1,61 @@
|
||||
|
||||
-- public functions
|
||||
function Game.processMouseAction(menuPosition, mouseButton, autoWalk, lookThing, useThing, creatureThing, multiUseThing)
|
||||
local keyboardModifiers = g_window.getKeyboardModifiers()
|
||||
|
||||
if autoWalk and keyboardModifiers == KeyboardNoModifier and mouseButton == MouseLeftButton then
|
||||
-- todo auto walk
|
||||
return true
|
||||
end
|
||||
|
||||
if not Options.classicControl then
|
||||
if keyboardModifiers == KeyboardNoModifier and mouseButton == MouseRightButton then
|
||||
Game.createThingMenu(menuPosition, lookThing, useThing, creatureThing)
|
||||
return true
|
||||
elseif lookThing and keyboardModifiers == KeyboardShiftModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
|
||||
Game.look(lookThing)
|
||||
return true
|
||||
elseif useThing and keyboardModifiers == KeyboardCtrlModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
|
||||
if useThing:isContainer() then
|
||||
print "open"
|
||||
elseif useThing:isMultiUse() then
|
||||
print "use with..."
|
||||
else
|
||||
Game.use(useThing)
|
||||
end
|
||||
return true
|
||||
elseif creatureThing and keyboardModifiers == KeyboardAltModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
|
||||
Game.attack(creatureThing)
|
||||
return true
|
||||
end
|
||||
else
|
||||
if multiUseThing and keyboardModifiers == KeyboardNoModifier and mouseButton == MouseRightButton then
|
||||
if multiUseThing:asCreature() then
|
||||
Game.attack(multiUseThing:asCreature())
|
||||
elseif multiUseThing:isContainer() then
|
||||
print "open"
|
||||
elseif multiUseThing:isMultiUse() then
|
||||
print "use with..."
|
||||
else
|
||||
Game.use(useThing)
|
||||
end
|
||||
return true
|
||||
elseif lookThing and keyboardModifiers == KeyboardShiftModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
|
||||
Game.look(lookThing)
|
||||
return true
|
||||
elseif useThing and keyboardModifiers == KeyboardCtrlModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
|
||||
Game.createThingMenu(menuPosition, lookThing, useThing, creatureThing)
|
||||
return true
|
||||
elseif creatureThing and keyboardModifiers == KeyboardAltModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
|
||||
Game.attack(creatureThing)
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
function Game.createThingMenu(menuPosition, lookThing, useThing, creatureThing)
|
||||
local menu = createWidget('PopupMenu')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user