mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 19:44:54 +02:00
@@ -179,9 +179,9 @@ function onUseWith(clickedWidget, mousePosition)
|
||||
local tile = clickedWidget:getTile(mousePosition)
|
||||
if tile then
|
||||
g_game.useWith(selectedThing, tile:getTopMultiUseThing())
|
||||
elseif clickedWidget:getClassName() == 'UIItem' and not clickedWidget:isVirtual() then
|
||||
g_game.useWith(selectedThing, clickedWidget:getItem())
|
||||
end
|
||||
elseif clickedWidget:getClassName() == 'UIItem' and not clickedWidget:isVirtual() then
|
||||
g_game.useWith(selectedThing, clickedWidget:getItem())
|
||||
end
|
||||
end
|
||||
|
||||
|
@@ -7,7 +7,6 @@ function UIGameMap.create()
|
||||
return gameMap
|
||||
end
|
||||
|
||||
|
||||
function UIGameMap:onDragEnter(mousePos)
|
||||
local tile = self:getTile(mousePos)
|
||||
if not tile then return false end
|
||||
@@ -28,7 +27,7 @@ function UIGameMap:onDragLeave(droppedWidget, mousePos)
|
||||
end
|
||||
|
||||
function UIGameMap:onDrop(widget, mousePos)
|
||||
if not widget or not widget.currentDragThing then return false end
|
||||
if not self:canAcceptDrop(widget, mousePos) then return false end
|
||||
|
||||
local tile = self:getTile(mousePos)
|
||||
if not tile then return false end
|
||||
@@ -82,3 +81,20 @@ function UIGameMap:onMouseRelease(mousePosition, mouseButton)
|
||||
|
||||
return ret
|
||||
end
|
||||
|
||||
function UIGameMap:canAcceptDrop(widget, mousePos)
|
||||
if not widget or not widget.currentDragThing then return false end
|
||||
|
||||
local children = rootWidget:recursiveGetChildrenByPos(mousePos)
|
||||
for i=1,#children do
|
||||
local child = children[i]
|
||||
if child == self then
|
||||
return true
|
||||
elseif not child:isPhantom() then
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
error('Widget ' .. self:getId() .. ' not in drop list.')
|
||||
return false
|
||||
end
|
||||
|
@@ -20,9 +20,7 @@ function UIItem:onDragLeave(droppedWidget, mousePos)
|
||||
end
|
||||
|
||||
function UIItem:onDrop(widget, mousePos)
|
||||
if self:isVirtual() then return false end
|
||||
|
||||
if not widget or not widget.currentDragThing then return false end
|
||||
if not self:canAcceptDrop(widget, mousePos) then return false end
|
||||
|
||||
local item = widget.currentDragThing
|
||||
if not item:isItem() then return false end
|
||||
@@ -94,3 +92,20 @@ function UIItem:onMouseRelease(mousePosition, mouseButton)
|
||||
return false
|
||||
end
|
||||
|
||||
function UIItem:canAcceptDrop(widget, mousePos)
|
||||
if self:isVirtual() then return false end
|
||||
if not widget or not widget.currentDragThing then return false end
|
||||
|
||||
local children = rootWidget:recursiveGetChildrenByPos(mousePos)
|
||||
for i=1,#children do
|
||||
local child = children[i]
|
||||
if child == self then
|
||||
return true
|
||||
elseif not child:isPhantom() then
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
error('Widget ' .. self:getId() .. ' not in drop list.')
|
||||
return false
|
||||
end
|
||||
|
Reference in New Issue
Block a user