Fixed #12 #28 #51 issues

This commit is contained in:
Henrique Santiago
2012-08-17 18:36:53 -03:00
parent a91b7ed6be
commit 4d2bd54f6b
17 changed files with 108 additions and 38 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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