inventory module

This commit is contained in:
Henrique
2011-11-10 03:29:25 -02:00
parent 9c55f18186
commit 7487931b87
15 changed files with 289 additions and 9 deletions

View File

@@ -13,5 +13,6 @@ Module
importStyles 'styles/lineedits.otui'
importStyles 'styles/windows.otui'
importStyles 'styles/listboxes.otui'
importStyles 'styles/items.otui'
return true

View File

@@ -0,0 +1,6 @@
Item < UIItem
size: 34 34
item margin: 1
border-image:
source: /core_styles/images/panel_flat.png
border: 4

View File

@@ -19,7 +19,7 @@ MiniWindow < UIWindow
size: 192 200
head height: 25
head text align: center
margin.top: 6
margin.top: 10
margin.left: 6
margin.right: 6
move policy: free updated
@@ -29,4 +29,4 @@ MiniWindow < UIWindow
border.top: 25
MainWindow < Window
anchors.centerIn: parent
anchors.centerIn: parent

View File

@@ -21,7 +21,7 @@ ManaLabel < Label
UIWindow
id: healthManaPanel
width: 192
margin.top: 6
margin.top: 10
margin.left: 6
margin.right: 6
move policy: free updated

View File

@@ -0,0 +1,61 @@
Inventory = {}
-- private variables
local window = nil
local InventorySlotHead = 1
local InventorySlotNecklace = 2
local InventorySlotBackpack = 3
local InventorySlotArmor = 4
local InventorySlotRight = 5
local InventorySlotLeft = 6
local InventorySlotLegs = 7
local InventorySlotFeet = 8
local InventorySlotRing = 9
local InventorySlotAmmo = 10
-- public functions
function Inventory.create()
window = loadUI("/inventory/inventory.otui", Game.gameRightPanel)
local itemWidget = window:getChildById('feet')
window:setHeight(itemWidget:getPosition().y + itemWidget:getHeight() - window:getPosition().y)
end
function Inventory.destroy()
window:destroy()
window = nil
end
-- hooked events
function Game.onInventoryChange(slot, item)
local slotId
if slot == InventorySlotHead then
slotId = 'head'
elseif slot == InventorySlotNecklace then
slotId = 'necklace'
elseif slot == InventorySlotBackpack then
slotId = 'backpack'
elseif slot == InventorySlotArmor then
slotId = 'armor'
elseif slot == InventorySlotRight then
slotId = 'right'
elseif slot == InventorySlotLeft then
slotId = 'left'
elseif slot == InventorySlotLegs then
slotId = 'legs'
elseif slot == InventorySlotFeet then
slotId = 'feet'
elseif slot == InventorySlotRing then
slotId = 'ring'
elseif slot == InventorySlotAmmo then
slotId = 'ammo'
end
local itemWidget = window:getChildById(slotId)
itemWidget:setItem(item)
end
connect(Game, { onLogin = Inventory.create,
onLogout = Inventory.destroy })

View File

@@ -0,0 +1,14 @@
Module
name: equipments
description: View local player equipments window
author: OTClient team
website: https://github.com/edubart/otclient
autoLoad: true
dependencies:
- game
onLoad: |
require 'inventory'
return true

View File

@@ -0,0 +1,70 @@
UIWindow
width: 192
margin.top: 10
margin.left: 6
margin.right: 6
move policy: free updated
Item
id: head
anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter
Item
id: armor
anchors.top: prev.bottom
anchors.horizontalCenter: prev.horizontalCenter
margin.top: 10
Item
id: legs
anchors.top: prev.bottom
anchors.horizontalCenter: prev.horizontalCenter
margin.top: 10
Item
id: feet
anchors.top: prev.bottom
anchors.horizontalCenter: prev.horizontalCenter
margin.top: 10
Item
id: necklace
anchors.top: parent.top
anchors.right: head.left
margin.top: 15
margin.right: 10
Item
id: left
anchors.top: prev.bottom
anchors.horizontalCenter: prev.horizontalCenter
margin.top: 10
Item
id: ring
anchors.top: prev.bottom
anchors.horizontalCenter: prev.horizontalCenter
margin.top: 10
Item
id: backpack
anchors.top: parent.top
anchors.left: head.right
margin.top: 15
margin.left: 10
Item
id: right
anchors.top: prev.bottom
anchors.horizontalCenter: prev.horizontalCenter
margin.top: 10
Item
id: ammo
anchors.top: prev.bottom
anchors.horizontalCenter: prev.horizontalCenter
margin.top: 10