move window

This commit is contained in:
Henrique Santiago
2012-01-25 23:11:05 -02:00
parent cfcc3fd428
commit 1983a08cbe
11 changed files with 182 additions and 7 deletions

View File

@@ -5,13 +5,17 @@ function UIMap:onDragEnter(mousePos)
local thing = tile:getTopMoveThing()
if not thing then return false end
self.parsed = false
self.currentDragThing = thing
setTargetCursor()
return true
end
function UIMap:onDragLeave(widget, mousePos)
self.currentDragThing = nil
if not self.parsed then
self.currentDragThing = nil
end
restoreCursor()
return true
end
@@ -21,9 +25,23 @@ function UIMap:onDrop(widget, mousePos)
local tile = self:getTile(mousePos)
if not tile then return false end
local count = widget.currentDragThing:getData()
local data = widget.currentDragThing:getData()
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:getPos(), spinbox:getCurrentIndex()) okButton:getParent():destroy() widget.currentDragThing = nil end
moveWindow.onEnter = okButton.onClick
else
Game.move(widget.currentDragThing, tile:getPos(), 1)
end
Game.move(widget.currentDragThing, tile:getPos(), count)
return true
end

View File

@@ -0,0 +1,40 @@
MainWindow
text: Move Item
size: 196 112
@onEscape: self:getParent():destroy()
Label
text: Amount:
width: 64
anchors.left: parent.left
anchors.top: parent.top
margin-top: 2
SpinBox
id: spinbox
anchors.left: prev.right
anchors.right: parent.right
anchors.top: parent.top
HorizontalSeparator
id: separator
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: next.top
margin-bottom: 10
Button
id: buttonOk
text: Ok
width: 64
anchors.right: next.left
anchors.bottom: parent.bottom
margin-right: 10
Button
id: buttonCancel
text: Cancel
width: 64
anchors.right: parent.right
anchors.bottom: parent.bottom
@onClick: self:getParent():destroy()