mirror of
https://github.com/edubart/otclient.git
synced 2025-11-30 07:26:49 +01:00
init move items
This commit is contained in:
@@ -1,3 +1,29 @@
|
||||
function UIItem:onDragEnter(mousePos)
|
||||
local item = self:getItem()
|
||||
if not item then return false end
|
||||
|
||||
self.currentDragThing = item
|
||||
setTargetCursor()
|
||||
return true
|
||||
end
|
||||
|
||||
function UIItem:onDragLeave(widget, mousePos)
|
||||
self.currentDragThing = nil
|
||||
restoreCursor()
|
||||
return true
|
||||
end
|
||||
|
||||
function UIItem:onDrop(widget, mousePos)
|
||||
if not widget or not widget.currentDragThing then return false end
|
||||
|
||||
local pos = self.position
|
||||
local count = 1 -- todo make a window for it
|
||||
|
||||
Game.move(widget.currentDragThing, pos, count)
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
function UIItem:onMouseRelease(mousePosition, mouseButton)
|
||||
local item = self:getItem()
|
||||
if not item or not self:containsPoint(mousePosition) then return false end
|
||||
|
||||
@@ -1,5 +1,34 @@
|
||||
function UIMap:onDragEnter(mousePos)
|
||||
local tile = self:getTile(mousePosition)
|
||||
if not tile then return false end
|
||||
|
||||
local thing = tile:getTopMoveThing()
|
||||
if not thing then return false end
|
||||
|
||||
self.currentDragThing = thing
|
||||
setTargetCursor()
|
||||
return true
|
||||
end
|
||||
|
||||
function UIMap:onDragLeave(widget, mousePos)
|
||||
self.currentDragThing = nil
|
||||
restoreCursor()
|
||||
return true
|
||||
end
|
||||
|
||||
function UIMap:onDrop(widget, mousePos)
|
||||
if not widget or not widget.currentDragThing then return false end
|
||||
|
||||
local pos = self:getPosition(mousePos)
|
||||
local count = 1 -- todo make a window for it
|
||||
|
||||
Game.move(widget.currentDragThing, pos, count)
|
||||
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
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ function Containers.onContainerOpen(containerId, itemId, name, capacity, hasPare
|
||||
local item = UIItem.create()
|
||||
item:setStyle('Item')
|
||||
container:addChild(item)
|
||||
item.position = {x=65535, y=containerId+64, z=i-1}
|
||||
end
|
||||
|
||||
m_containers[containerId] = container
|
||||
|
||||
@@ -11,6 +11,7 @@ UIWindow
|
||||
id: slot1
|
||||
anchors.top: parent.top
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
&position: {x=65535, y=1, z=0}
|
||||
|
||||
Item
|
||||
// armor
|
||||
@@ -18,6 +19,7 @@ UIWindow
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin-top: 5
|
||||
&position: {x=65535, y=4, z=0}
|
||||
|
||||
Item
|
||||
// legs
|
||||
@@ -25,6 +27,7 @@ UIWindow
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin-top: 5
|
||||
&position: {x=65535, y=7, z=0}
|
||||
|
||||
Item
|
||||
// feet
|
||||
@@ -32,6 +35,7 @@ UIWindow
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin-top: 5
|
||||
&position: {x=65535, y=8, z=0}
|
||||
|
||||
Item
|
||||
// necklace
|
||||
@@ -40,6 +44,7 @@ UIWindow
|
||||
anchors.right: slot1.left
|
||||
margin-top: 10
|
||||
margin-right: 5
|
||||
&position: {x=65535, y=2, z=0}
|
||||
|
||||
Item
|
||||
// left
|
||||
@@ -47,6 +52,7 @@ UIWindow
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin-top: 5
|
||||
&position: {x=65535, y=6, z=0}
|
||||
|
||||
Item
|
||||
// ring
|
||||
@@ -54,6 +60,7 @@ UIWindow
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin-top: 5
|
||||
&position: {x=65535, y=9, z=0}
|
||||
|
||||
Item
|
||||
// backpack
|
||||
@@ -62,6 +69,7 @@ UIWindow
|
||||
anchors.left: slot1.right
|
||||
margin-top: 10
|
||||
margin-left: 5
|
||||
&position: {x=65535, y=3, z=0}
|
||||
|
||||
Item
|
||||
// right
|
||||
@@ -76,6 +84,7 @@ UIWindow
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin-top: 5
|
||||
&position: {x=65535, y=10, z=0}
|
||||
|
||||
GameLabel
|
||||
id: soul
|
||||
|
||||
Reference in New Issue
Block a user