You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.6 KiB

13 years ago
function UIMap:onDragEnter(mousePos)
local tile = self:getTile(mousePos)
13 years ago
if not tile then return false end
13 years ago
local thing = tile:getTopMoveThing()
if not thing then return false end
12 years ago
self.parsed = false
13 years ago
self.currentDragThing = thing
setTargetCursor()
return true
end
function UIMap:onDragLeave(widget, mousePos)
12 years ago
if not self.parsed then
self.currentDragThing = nil
end
13 years ago
restoreCursor()
return true
end
function UIMap:onDrop(widget, mousePos)
if not widget or not widget.currentDragThing then return false end
local tile = self:getTile(mousePos)
if not tile then return false end
12 years ago
local data = widget.currentDragThing:getCount()
12 years ago
if widget.currentDragThing:isStackable() and data > 1 then
widget.parsed = true
local moveWindow = displayUI('/game/movewindow.otui')
local spinbox = moveWindow:getChildById('spinbox')
spinbox:setMaximum(data)
spinbox:setMinimum(1)
spinbox:setCurrentIndex(data)
local okButton = moveWindow:getChildById('buttonOk')
okButton.onClick = function() Game.move(widget.currentDragThing, tile:getPosition(), spinbox:getCurrentIndex()) okButton:getParent():destroy() widget.currentDragThing = nil end
12 years ago
moveWindow.onEnter = okButton.onClick
else
Game.move(widget.currentDragThing, tile:getPosition(), 1)
12 years ago
end
13 years ago
return true
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
13 years ago