2012-07-24 07:30:08 +02:00
|
|
|
ADDON_SETS = {
|
2012-07-15 13:49:28 +02:00
|
|
|
[1] = { 1 },
|
|
|
|
[2] = { 2 },
|
|
|
|
[3] = { 1, 2 },
|
|
|
|
[4] = { 3 },
|
|
|
|
[5] = { 1, 3 },
|
|
|
|
[6] = { 2, 3 },
|
|
|
|
[7] = { 1, 2, 3 }
|
|
|
|
}
|
2012-03-22 22:47:52 +01:00
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
outfitWindow = nil
|
|
|
|
outfit = nil
|
|
|
|
outfits = nil
|
|
|
|
outfitCreature = nil
|
|
|
|
currentOutfit = 1
|
|
|
|
|
|
|
|
addons = nil
|
|
|
|
currentColorBox = nil
|
|
|
|
currentClotheButtonBox = nil
|
|
|
|
colorBoxes = {}
|
|
|
|
|
|
|
|
mount = nil
|
|
|
|
mounts = nil
|
|
|
|
mountCreature = nil
|
|
|
|
currentMount = 1
|
|
|
|
|
|
|
|
function init()
|
2014-12-30 05:27:53 +01:00
|
|
|
connect(g_game, {
|
|
|
|
onOpenOutfitWindow = create,
|
|
|
|
onGameEnd = destroy
|
|
|
|
})
|
2011-11-30 03:42:21 +01:00
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function terminate()
|
2014-12-30 05:27:53 +01:00
|
|
|
disconnect(g_game, {
|
|
|
|
onOpenOutfitWindow = create,
|
|
|
|
onGameEnd = destroy
|
|
|
|
})
|
2012-07-24 07:30:08 +02:00
|
|
|
destroy()
|
2011-11-16 19:52:41 +01:00
|
|
|
end
|
|
|
|
|
2012-07-15 13:49:28 +02:00
|
|
|
function updateMount()
|
2012-07-16 14:21:34 +02:00
|
|
|
if table.empty(mounts) or not mount then
|
2012-07-15 13:49:28 +02:00
|
|
|
return
|
|
|
|
end
|
|
|
|
local nameMountWidget = outfitWindow:getChildById('mountName')
|
|
|
|
nameMountWidget:setText(mounts[currentMount][2])
|
2012-07-24 07:30:08 +02:00
|
|
|
|
2012-07-15 13:49:28 +02:00
|
|
|
mount.type = mounts[currentMount][1]
|
|
|
|
mountCreature:setOutfit(mount)
|
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function create(creatureOutfit, outfitList, creatureMount, mountList)
|
2012-08-25 07:02:07 +02:00
|
|
|
if outfitWindow and not outfitWindow:isHidden() then
|
|
|
|
return
|
|
|
|
end
|
2014-01-18 15:09:26 +01:00
|
|
|
|
2012-07-15 13:49:28 +02:00
|
|
|
outfitCreature = creatureOutfit
|
|
|
|
mountCreature = creatureMount
|
2012-03-22 22:47:52 +01:00
|
|
|
outfits = outfitList
|
2012-07-15 13:49:28 +02:00
|
|
|
mounts = mountList
|
2012-07-24 07:30:08 +02:00
|
|
|
destroy()
|
2012-01-03 01:42:53 +01:00
|
|
|
|
2013-01-18 23:39:11 +01:00
|
|
|
outfitWindow = g_ui.displayUI('outfitwindow')
|
2012-07-19 20:54:24 +02:00
|
|
|
local colorBoxPanel = outfitWindow:getChildById('colorBoxPanel')
|
|
|
|
|
|
|
|
-- setup outfit/mount display boxs
|
|
|
|
local outfitCreatureBox = outfitWindow:getChildById('outfitCreatureBox')
|
|
|
|
if outfitCreature then
|
|
|
|
outfit = outfitCreature:getOutfit()
|
|
|
|
outfitCreatureBox:setCreature(outfitCreature)
|
|
|
|
else
|
|
|
|
outfitCreatureBox:hide()
|
|
|
|
outfitWindow:getChildById('outfitName'):hide()
|
|
|
|
outfitWindow:getChildById('outfitNextButton'):hide()
|
|
|
|
outfitWindow:getChildById('outfitPrevButton'):hide()
|
|
|
|
end
|
|
|
|
|
|
|
|
local mountCreatureBox = outfitWindow:getChildById('mountCreatureBox')
|
|
|
|
if mountCreature then
|
2012-07-16 14:21:34 +02:00
|
|
|
mount = mountCreature:getOutfit()
|
2012-07-19 20:54:24 +02:00
|
|
|
mountCreatureBox:setCreature(mountCreature)
|
|
|
|
else
|
|
|
|
mountCreatureBox:hide()
|
|
|
|
outfitWindow:getChildById('mountName'):hide()
|
|
|
|
outfitWindow:getChildById('mountNextButton'):hide()
|
|
|
|
outfitWindow:getChildById('mountPrevButton'):hide()
|
2012-07-16 14:21:34 +02:00
|
|
|
end
|
2012-07-24 07:30:08 +02:00
|
|
|
|
2012-07-19 20:54:24 +02:00
|
|
|
-- set addons
|
2012-07-15 13:49:28 +02:00
|
|
|
addons = {
|
|
|
|
[1] = {widget = outfitWindow:getChildById('addon1'), value = 1},
|
|
|
|
[2] = {widget = outfitWindow:getChildById('addon2'), value = 2},
|
|
|
|
[3] = {widget = outfitWindow:getChildById('addon3'), value = 4}
|
|
|
|
}
|
2012-07-24 07:30:08 +02:00
|
|
|
|
2012-07-21 14:15:29 +02:00
|
|
|
for _, addon in pairs(addons) do
|
2012-07-15 13:49:28 +02:00
|
|
|
addon.widget.onCheckChange = function(self) onAddonCheckChange(self, addon.value) end
|
|
|
|
end
|
2012-07-24 07:30:08 +02:00
|
|
|
|
2013-12-24 19:37:52 +01:00
|
|
|
if outfit.addons and outfit.addons > 0 then
|
2012-07-24 07:30:08 +02:00
|
|
|
for _, i in pairs(ADDON_SETS[outfit.addons]) do
|
2012-07-15 13:49:28 +02:00
|
|
|
addons[i].widget:setChecked(true)
|
|
|
|
end
|
|
|
|
end
|
2012-07-24 07:30:08 +02:00
|
|
|
|
2012-07-19 20:54:24 +02:00
|
|
|
-- hook outfit sections
|
2012-03-22 22:47:52 +01:00
|
|
|
currentClotheButtonBox = outfitWindow:getChildById('head')
|
|
|
|
outfitWindow:getChildById('head').onCheckChange = onClotheCheckChange
|
|
|
|
outfitWindow:getChildById('primary').onCheckChange = onClotheCheckChange
|
|
|
|
outfitWindow:getChildById('secondary').onCheckChange = onClotheCheckChange
|
|
|
|
outfitWindow:getChildById('detail').onCheckChange = onClotheCheckChange
|
2011-11-16 18:03:11 +01:00
|
|
|
|
2012-07-19 20:54:24 +02:00
|
|
|
-- populate color panel
|
2012-03-22 22:47:52 +01:00
|
|
|
for j=0,6 do
|
|
|
|
for i=0,18 do
|
2012-06-26 00:13:30 +02:00
|
|
|
local colorBox = g_ui.createWidget('ColorBox', colorBoxPanel)
|
2011-11-16 08:20:14 +01:00
|
|
|
local outfitColor = getOufitColor(j*19 + i)
|
2012-03-22 22:47:52 +01:00
|
|
|
colorBox:setImageColor(outfitColor)
|
|
|
|
colorBox:setId('colorBox' .. j*19+i)
|
|
|
|
colorBox.colorId = j*19 + i
|
2011-11-17 21:40:31 +01:00
|
|
|
|
2012-03-22 22:47:52 +01:00
|
|
|
if j*19 + i == outfit.head then
|
|
|
|
currentColorBox = colorBox
|
|
|
|
colorBox:setChecked(true)
|
|
|
|
end
|
|
|
|
colorBox.onCheckChange = onColorCheckChange
|
2012-07-21 14:15:29 +02:00
|
|
|
colorBoxes[#colorBoxes+1] = colorBox
|
2011-11-16 08:20:14 +01:00
|
|
|
end
|
|
|
|
end
|
2011-11-16 18:03:11 +01:00
|
|
|
|
2012-07-19 20:54:24 +02:00
|
|
|
-- set current outfit/mount
|
2012-03-22 22:47:52 +01:00
|
|
|
currentOutfit = 1
|
2011-11-16 22:28:47 +01:00
|
|
|
for i=1,#outfitList do
|
2012-07-19 20:54:24 +02:00
|
|
|
if outfit and outfitList[i][1] == outfit.type then
|
2012-03-22 22:47:52 +01:00
|
|
|
currentOutfit = i
|
2011-11-16 22:28:47 +01:00
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
2012-07-15 13:49:28 +02:00
|
|
|
currentMount = 1
|
|
|
|
for i=1,#mountList do
|
2012-07-16 14:21:34 +02:00
|
|
|
if mount and mountList[i][1] == mount.type then
|
2012-07-15 13:49:28 +02:00
|
|
|
currentMount = i
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
2011-11-16 22:28:47 +01:00
|
|
|
|
2012-07-15 13:49:28 +02:00
|
|
|
updateOutfit()
|
|
|
|
updateMount()
|
2011-11-14 23:32:55 +01:00
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function destroy()
|
2012-03-22 22:47:52 +01:00
|
|
|
if outfitWindow then
|
|
|
|
outfitWindow:destroy()
|
|
|
|
outfitWindow = nil
|
|
|
|
outfitCreature = nil
|
2012-07-15 13:49:28 +02:00
|
|
|
mountCreature = nil
|
2012-03-22 22:47:52 +01:00
|
|
|
currentColorBox = nil
|
|
|
|
currentClotheButtonBox = nil
|
2012-07-17 16:36:27 +02:00
|
|
|
colorBoxes = {}
|
2012-07-30 14:33:10 +02:00
|
|
|
addons = {}
|
2011-11-14 23:47:36 +01:00
|
|
|
end
|
2011-11-14 23:32:55 +01:00
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function randomize()
|
2012-07-15 13:49:28 +02:00
|
|
|
local outfitTemplate = {
|
|
|
|
outfitWindow:getChildById('head'),
|
|
|
|
outfitWindow:getChildById('primary'),
|
|
|
|
outfitWindow:getChildById('secondary'),
|
|
|
|
outfitWindow:getChildById('detail')
|
|
|
|
}
|
2012-07-24 07:30:08 +02:00
|
|
|
|
2012-07-21 14:15:29 +02:00
|
|
|
for i = 1, #outfitTemplate do
|
|
|
|
outfitTemplate[i]:setChecked(true)
|
2012-07-16 14:21:34 +02:00
|
|
|
colorBoxes[math.random(1, #colorBoxes)]:setChecked(true)
|
2012-07-21 14:15:29 +02:00
|
|
|
outfitTemplate[i]:setChecked(false)
|
2012-07-15 13:49:28 +02:00
|
|
|
end
|
|
|
|
outfitTemplate[1]:setChecked(true)
|
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function accept()
|
2012-07-16 14:21:34 +02:00
|
|
|
if mount then outfit.mount = mount.type end
|
2012-03-22 22:47:52 +01:00
|
|
|
g_game.changeOutfit(outfit)
|
2012-07-24 07:30:08 +02:00
|
|
|
destroy()
|
2011-11-16 19:52:41 +01:00
|
|
|
end
|
2011-11-16 18:03:11 +01:00
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function nextOutfitType()
|
2012-07-16 14:21:34 +02:00
|
|
|
if not outfits then
|
|
|
|
return
|
|
|
|
end
|
2012-03-22 22:47:52 +01:00
|
|
|
currentOutfit = currentOutfit + 1
|
|
|
|
if currentOutfit > #outfits then
|
|
|
|
currentOutfit = 1
|
2011-11-15 03:04:07 +01:00
|
|
|
end
|
2012-07-15 13:49:28 +02:00
|
|
|
updateOutfit()
|
2011-11-15 03:04:07 +01:00
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function previousOutfitType()
|
2012-07-16 14:21:34 +02:00
|
|
|
if not outfits then
|
|
|
|
return
|
|
|
|
end
|
2012-03-22 22:47:52 +01:00
|
|
|
currentOutfit = currentOutfit - 1
|
|
|
|
if currentOutfit <= 0 then
|
|
|
|
currentOutfit = #outfits
|
2011-11-15 03:04:07 +01:00
|
|
|
end
|
2012-07-15 13:49:28 +02:00
|
|
|
updateOutfit()
|
2011-11-15 03:04:07 +01:00
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function nextMountType()
|
2012-07-16 14:21:34 +02:00
|
|
|
if not mounts then
|
|
|
|
return
|
|
|
|
end
|
2012-07-15 13:49:28 +02:00
|
|
|
currentMount = currentMount + 1
|
|
|
|
if currentMount > #mounts then
|
|
|
|
currentMount = 1
|
|
|
|
end
|
|
|
|
updateMount()
|
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function previousMountType()
|
2012-07-16 14:21:34 +02:00
|
|
|
if not mounts then
|
|
|
|
return
|
|
|
|
end
|
2012-07-15 13:49:28 +02:00
|
|
|
currentMount = currentMount - 1
|
|
|
|
if currentMount <= 0 then
|
|
|
|
currentMount = #mounts
|
|
|
|
end
|
|
|
|
updateMount()
|
|
|
|
end
|
2012-07-24 07:30:08 +02:00
|
|
|
|
|
|
|
function onAddonCheckChange(addon, value)
|
|
|
|
if addon:isChecked() then
|
|
|
|
outfit.addons = outfit.addons + value
|
|
|
|
else
|
|
|
|
outfit.addons = outfit.addons - value
|
|
|
|
end
|
|
|
|
outfitCreature:setOutfit(outfit)
|
|
|
|
end
|
|
|
|
|
|
|
|
function onColorCheckChange(colorBox)
|
|
|
|
if colorBox == currentColorBox then
|
|
|
|
colorBox.onCheckChange = nil
|
|
|
|
colorBox:setChecked(true)
|
|
|
|
colorBox.onCheckChange = onColorCheckChange
|
|
|
|
else
|
|
|
|
currentColorBox.onCheckChange = nil
|
|
|
|
currentColorBox:setChecked(false)
|
|
|
|
currentColorBox.onCheckChange = onColorCheckChange
|
|
|
|
|
|
|
|
currentColorBox = colorBox
|
|
|
|
|
|
|
|
if currentClotheButtonBox:getId() == 'head' then
|
|
|
|
outfit.head = currentColorBox.colorId
|
|
|
|
elseif currentClotheButtonBox:getId() == 'primary' then
|
|
|
|
outfit.body = currentColorBox.colorId
|
|
|
|
elseif currentClotheButtonBox:getId() == 'secondary' then
|
|
|
|
outfit.legs = currentColorBox.colorId
|
|
|
|
elseif currentClotheButtonBox:getId() == 'detail' then
|
|
|
|
outfit.feet = currentColorBox.colorId
|
|
|
|
end
|
|
|
|
|
|
|
|
outfitCreature:setOutfit(outfit)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function onClotheCheckChange(clotheButtonBox)
|
|
|
|
if clotheButtonBox == currentClotheButtonBox then
|
|
|
|
clotheButtonBox.onCheckChange = nil
|
|
|
|
clotheButtonBox:setChecked(true)
|
|
|
|
clotheButtonBox.onCheckChange = onClotheCheckChange
|
|
|
|
else
|
|
|
|
currentClotheButtonBox.onCheckChange = nil
|
|
|
|
currentClotheButtonBox:setChecked(false)
|
|
|
|
currentClotheButtonBox.onCheckChange = onClotheCheckChange
|
|
|
|
|
|
|
|
currentClotheButtonBox = clotheButtonBox
|
|
|
|
|
|
|
|
local colorId = 0
|
|
|
|
if currentClotheButtonBox:getId() == 'head' then
|
|
|
|
colorId = outfit.head
|
|
|
|
elseif currentClotheButtonBox:getId() == 'primary' then
|
|
|
|
colorId = outfit.body
|
|
|
|
elseif currentClotheButtonBox:getId() == 'secondary' then
|
|
|
|
colorId = outfit.legs
|
|
|
|
elseif currentClotheButtonBox:getId() == 'detail' then
|
|
|
|
colorId = outfit.feet
|
|
|
|
end
|
|
|
|
outfitWindow:recursiveGetChildById('colorBox' .. colorId):setChecked(true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function updateOutfit()
|
|
|
|
if table.empty(outfits) or not outfit then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
local nameWidget = outfitWindow:getChildById('outfitName')
|
|
|
|
nameWidget:setText(outfits[currentOutfit][2])
|
|
|
|
|
|
|
|
local availableAddons = outfits[currentOutfit][3]
|
|
|
|
|
|
|
|
local prevAddons = {}
|
|
|
|
for k, addon in pairs(addons) do
|
|
|
|
prevAddons[k] = addon.widget:isChecked()
|
|
|
|
addon.widget:setChecked(false)
|
|
|
|
addon.widget:setEnabled(false)
|
|
|
|
end
|
2014-12-30 05:27:53 +01:00
|
|
|
outfit.addons = 0
|
2012-07-24 07:30:08 +02:00
|
|
|
|
|
|
|
if availableAddons > 0 then
|
|
|
|
for _, i in pairs(ADDON_SETS[availableAddons]) do
|
|
|
|
addons[i].widget:setEnabled(true)
|
|
|
|
addons[i].widget:setChecked(true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
outfit.type = outfits[currentOutfit][1]
|
|
|
|
outfitCreature:setOutfit(outfit)
|
|
|
|
end
|
|
|
|
|