tibia-client/modules/outfit/outfit.lua

71 lines
1.5 KiB
Lua
Raw Normal View History

2011-11-14 23:32:55 +01:00
Outfit = {}
-- private variables
local window = nil
2011-11-15 03:04:07 +01:00
local outfits = nil
local currentOutfit = 1
2011-11-14 23:32:55 +01:00
-- public functions
function Outfit.test()
local button = UIButton.create()
UI.root:addChild(button)
button:setText('Set Outfit')
button:setStyle('Button')
button:moveTo({x = 0, y = 100})
button:setWidth('100')
button:setHeight('30')
button.onClick = function() Game.openOutfitWindow() end
end
function Outfit.create(creature, outfitList)
2011-11-14 23:47:36 +01:00
Outfit.destroy()
2011-11-14 23:32:55 +01:00
window = loadUI("/outfit/outfit.otui", UI.root)
2011-11-15 03:04:07 +01:00
window:lock()
2011-11-14 23:32:55 +01:00
local creatureWidget = window:getChildById('creature')
creatureWidget:setCreature(creature)
2011-11-15 03:04:07 +01:00
outfits = outfitList
currentOutfit = 1
2011-11-14 23:32:55 +01:00
end
function Outfit.destroy()
2011-11-14 23:47:36 +01:00
if window ~= nil then
window:destroy()
window = nil
end
2011-11-14 23:32:55 +01:00
end
2011-11-15 03:04:07 +01:00
function Outfit.nextType()
local creatureWidget = window:getChildById('creature')
currentOutfit = currentOutfit + 1
if currentOutfit > #outfits then
currentOutfit = 1
end
creatureWidget:setOutfitType(outfits[currentOutfit][1])
-- TODO: update addons
end
function Outfit.previousType()
local creatureWidget = window:getChildById('creature')
currentOutfit = currentOutfit - 1
if currentOutfit <= 0 then
currentOutfit = #outfits
end
creatureWidget:setOutfitType(outfits[currentOutfit][1])
-- TODO: update addons
end
2011-11-14 23:32:55 +01:00
-- private functions
-- hooked events
connect(Game, { onOpenOutfitWindow = Outfit.create,
onLogout = Outfit.destroy })
connect(Game, { onLogin = Outfit.test })