mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 03:24:55 +02:00
reorganize modules
This commit is contained in:
73
modules/game_inventory/inventory.lua
Normal file
73
modules/game_inventory/inventory.lua
Normal file
@@ -0,0 +1,73 @@
|
||||
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 = UI.display('inventory.otui', { parent = 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 Inventory.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
|
||||
|
||||
function Inventory.onFreeCapacityChange(freeCapacity)
|
||||
local widget = window:getChildById('capacity')
|
||||
widget:setText("Cap:\n" .. freeCapacity)
|
||||
end
|
||||
|
||||
function Inventory.onSoulChange(soul)
|
||||
local widget = window:getChildById('soul')
|
||||
widget:setText("Soul:\n" .. soul)
|
||||
end
|
||||
|
||||
connect(Game, { onLogin = Inventory.create,
|
||||
onLogout = Inventory.destroy,
|
||||
onInventoryChange = Inventory.onInventoryChange,
|
||||
onFreeCapacityChange = Inventory.onFreeCapacityChange,
|
||||
onSoulChange = Inventory.onSoulChange })
|
10
modules/game_inventory/inventory.otmod
Normal file
10
modules/game_inventory/inventory.otmod
Normal file
@@ -0,0 +1,10 @@
|
||||
Module
|
||||
name: game_inventory
|
||||
description: View local player equipments window
|
||||
author: OTClient team
|
||||
website: https://github.com/edubart/otclient
|
||||
onLoad: |
|
||||
require 'inventory'
|
||||
return true
|
||||
|
||||
|
97
modules/game_inventory/inventory.otui
Normal file
97
modules/game_inventory/inventory.otui
Normal file
@@ -0,0 +1,97 @@
|
||||
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
|
||||
popup menu: /inventory/itempopupmenu.otui
|
||||
|
||||
Item
|
||||
id: armor
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin-top: 5
|
||||
|
||||
Item
|
||||
id: legs
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin-top: 5
|
||||
|
||||
Item
|
||||
id: feet
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin-top: 5
|
||||
|
||||
Item
|
||||
id: necklace
|
||||
anchors.top: parent.top
|
||||
anchors.right: head.left
|
||||
margin-top: 10
|
||||
margin-right: 5
|
||||
|
||||
Item
|
||||
id: left
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin-top: 5
|
||||
|
||||
Item
|
||||
id: ring
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin-top: 5
|
||||
|
||||
Item
|
||||
id: backpack
|
||||
anchors.top: parent.top
|
||||
anchors.left: head.right
|
||||
margin-top: 10
|
||||
margin-left: 5
|
||||
|
||||
Item
|
||||
id: right
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin-top: 5
|
||||
|
||||
Item
|
||||
id: ammo
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin-top: 5
|
||||
|
||||
Label
|
||||
id: soul
|
||||
anchors.top: ring.bottom
|
||||
anchors.bottom: feet.bottom
|
||||
anchors.left: ring.left
|
||||
anchors.right: ring.right
|
||||
margin-top: 5
|
||||
|
||||
text-align: center
|
||||
|
||||
border-image:
|
||||
source: /core_styles/images/panel_flat.png
|
||||
border: 1
|
||||
|
||||
Label
|
||||
id: capacity
|
||||
anchors.top: ammo.bottom
|
||||
anchors.bottom: feet.bottom
|
||||
anchors.left: ammo.left
|
||||
anchors.right: ammo.right
|
||||
margin-top: 5
|
||||
|
||||
text-align: center
|
||||
|
||||
border-image:
|
||||
source: /core_styles/images/panel_flat.png
|
||||
border: 1
|
||||
|
10
modules/game_inventory/itempopupmenu.otui
Normal file
10
modules/game_inventory/itempopupmenu.otui
Normal file
@@ -0,0 +1,10 @@
|
||||
Panel
|
||||
layout: verticalBox
|
||||
size: 64 48
|
||||
|
||||
MenuButton
|
||||
text: Foo
|
||||
|
||||
MenuButton
|
||||
text: Quit
|
||||
@onClick: exit()
|
Reference in New Issue
Block a user