mirror of
https://github.com/edubart/otclient.git
synced 2025-11-30 15:26:49 +01:00
move window
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
40
modules/game/movewindow.otui
Normal file
40
modules/game/movewindow.otui
Normal 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()
|
||||
Reference in New Issue
Block a user