parent
b812d60690
commit
ea70f90e92
@ -0,0 +1,6 @@
|
|||||||
|
function UIItem:onMouseRelease(mousePosition, mouseButton)
|
||||||
|
local item = self:getItem()
|
||||||
|
if not item or not self:containsPoint(mousePosition) then return false end
|
||||||
|
return Game.processMouseAction(mousePosition, mouseButton, nil, item, item, nil, item)
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,13 @@
|
|||||||
|
MiniWindow
|
||||||
|
size: 200 186
|
||||||
|
padding-top: 30
|
||||||
|
padding-left: 10
|
||||||
|
|
||||||
|
layout:
|
||||||
|
type: grid
|
||||||
|
cell-size: 32 32
|
||||||
|
cell-spacing: 5
|
||||||
|
num-columns: 4
|
||||||
|
num-lines: 5
|
||||||
|
|
||||||
|
|
@ -0,0 +1,79 @@
|
|||||||
|
Containers = {}
|
||||||
|
|
||||||
|
-- private variables
|
||||||
|
local m_containers = {}
|
||||||
|
|
||||||
|
-- public functions
|
||||||
|
function Containers.clean()
|
||||||
|
m_containers = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
function Containers.getFreeContainerId()
|
||||||
|
for i=0,15 do
|
||||||
|
if not m_containers[i] then
|
||||||
|
return i
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
|
-- hooked events
|
||||||
|
function Containers.onContainerOpen(containerId, itemId, name, capacity, hasParent)
|
||||||
|
local container = m_containers[containerId]
|
||||||
|
if container then
|
||||||
|
Game.gameRightPanel:removeChild(container)
|
||||||
|
end
|
||||||
|
|
||||||
|
container = displayUI('container.otui', { parent = Game.gameRightPanel })
|
||||||
|
container:setText(name)
|
||||||
|
|
||||||
|
-- set icon, itemid
|
||||||
|
-- closebutton
|
||||||
|
-- resize
|
||||||
|
if hasParent then
|
||||||
|
-- parent button
|
||||||
|
end
|
||||||
|
|
||||||
|
container.itemCount = 0
|
||||||
|
container.capacity = capacity
|
||||||
|
|
||||||
|
for i=1,capacity do
|
||||||
|
local item = UIItem.create()
|
||||||
|
item:setStyle('Item')
|
||||||
|
container:addChild(item)
|
||||||
|
end
|
||||||
|
|
||||||
|
m_containers[containerId] = container
|
||||||
|
print("opencid ".. containerId)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Containers.onContainerClose(containerId)
|
||||||
|
print("closecid ".. containerId)
|
||||||
|
local container = m_containers[containerId]
|
||||||
|
if container then
|
||||||
|
Game.gameRightPanel:removeChild(container)
|
||||||
|
end
|
||||||
|
m_containers[containerId] = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
function Containers.onContainerAddItem(containerId, item)
|
||||||
|
print("addcid ".. containerId)
|
||||||
|
local container = m_containers[containerId]
|
||||||
|
if not container or not item or container.itemCount >= container.capacity then return end
|
||||||
|
|
||||||
|
-- maybe this has to be moved to client internal's files
|
||||||
|
local pos = item:getPos()
|
||||||
|
pos.z = container.itemCount
|
||||||
|
item:setPos(pos)
|
||||||
|
|
||||||
|
local itemWidget = container:getChildByIndex(container.itemCount + 1)
|
||||||
|
itemWidget:setItem(item)
|
||||||
|
container.itemCount = container.itemCount + 1
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
connect(Game, { onLogin = Containers.clean,
|
||||||
|
onLogout = Containers.clean,
|
||||||
|
onContainerOpen = Containers.onContainerOpen,
|
||||||
|
onContainerClose = Containers.onContainerClose,
|
||||||
|
onContainerAddItem = Containers.onContainerAddItem })
|
@ -0,0 +1,7 @@
|
|||||||
|
Module
|
||||||
|
name: game_containers
|
||||||
|
description: Manage containers
|
||||||
|
author: OTClient team
|
||||||
|
website: https://github.com/edubart/otclient
|
||||||
|
onLoad: |
|
||||||
|
require 'containers'
|
Loading…
Reference in new issue