Implemented the mount interface, Fixed some interface stuff, Some cosmetics, and Updated the outfits window

* Added new arrow buttons.
* Fixed the vertical separator.
* Added new game_playermount module to handle player mounting.
* Moved the battle icons to /images.
* Outfit window accommodates for mounts, loads addons more efficiently and keeps addons set on update, added new Outfit.randomize function that allows you to randomize your outfit colors, and set up a new layout.
This commit is contained in:
BeniS
2012-07-15 23:49:28 +12:00
parent 3db6217b7c
commit 5520501673
39 changed files with 506 additions and 267 deletions

View File

@@ -1,13 +1,30 @@
Outfit = {}
-- private variables
local addonSets = {
[1] = { 1 },
[2] = { 2 },
[3] = { 1, 2 },
[4] = { 3 },
[5] = { 1, 3 },
[6] = { 2, 3 },
[7] = { 1, 2, 3 }
}
local outfitWindow
local outfitCreature
local outfit
local outfits
local outfitCreature
local currentOutfit = 1
local addons
local currentColorBox
local currentClotheButtonBox
local colorBoxes = {}
local mount
local mounts
local mountCreature
local currentMount = 1
-- private functions
local function onAddonCheckChange(addon, value)
@@ -71,51 +88,50 @@ local function onClotheCheckChange(clotheButtonBox)
end
end
local function update()
local function updateOutfit()
if table.empty(outfits) then
return
end
local nameWidget = outfitWindow:getChildById('outfitName')
nameWidget:setText(outfits[currentOutfit][2])
local availableAddons = outfits[currentOutfit][3]
local addon1 = outfitWindow:getChildById('addon1')
local addon2 = outfitWindow:getChildById('addon2')
local addon3 = outfitWindow:getChildById('addon3')
addon1:setChecked(false)
addon2:setChecked(false)
addon3:setChecked(false)
addon1.onCheckChange = function(self) onAddonCheckChange(self, 1) end
addon2.onCheckChange = function(self) onAddonCheckChange(self, 2) end
addon3.onCheckChange = function(self) onAddonCheckChange(self, 4) end
addon1:setEnabled(false)
addon2:setEnabled(false)
addon3:setEnabled(false)
-- Maybe rework this someday
if availableAddons == 1 then
addon1:setEnabled(true)
elseif availableAddons == 2 then
addon2:setEnabled(true)
elseif availableAddons == 3 then
addon1:setEnabled(true)
addon2:setEnabled(true)
elseif availableAddons == 4 then
addon3:setEnabled(true)
elseif availableAddons == 5 then
addon1:setEnabled(true)
addon3:setEnabled(true)
elseif availableAddons == 6 then
addon2:setEnabled(true)
addon3:setEnabled(true)
elseif availableAddons == 7 then
addon1:setEnabled(true)
addon2:setEnabled(true)
addon3:setEnabled(true)
local prevAddons = {}
for k, addon in pairs(addons) do
prevAddons[k] = addon.widget:isChecked()
addon.widget:setChecked(false)
addon.widget:setEnabled(false)
end
if availableAddons > 0 then
for _, i in pairs(addonSets[availableAddons]) do
addons[i].widget:setEnabled(true)
end
end
outfit.addons = 0
for k, addon in pairs(prevAddons) do
if addon and addons[k].widget:isEnabled() then
addons[k].widget:setChecked(true)
end
end
outfit.type = outfits[currentOutfit][1]
outfit.addons = 0
outfitCreature:setOutfit(outfit)
end
function updateMount()
if table.empty(mounts) then
return
end
local nameMountWidget = outfitWindow:getChildById('mountName')
nameMountWidget:setText(mounts[currentMount][2])
mount.type = mounts[currentMount][1]
mountCreature:setOutfit(mount)
end
-- public functions
function Outfit.init()
connect(g_game, { onOpenOutfitWindow = Outfit.create,
@@ -126,20 +142,36 @@ function Outfit.terminate()
disconnect(g_game, { onOpenOutfitWindow = Outfit.create,
onGameEnd = Outfit.destroy })
Outfit.destroy()
Outfit = nil
end
function Outfit.create(creature, outfitList)
outfitCreature = creature
function Outfit.create(creatureOutfit, outfitList, creatureMount, mountList)
outfitCreature = creatureOutfit
mountCreature = creatureMount
outfits = outfitList
Outfit.destroy()
outfitWindow = g_ui.displayUI('outfit.otui')
--outfitWindow:lock()
mounts = mountList
Outfit.destroy()
outfitWindow = g_ui.displayUI('outfitwindow.otui')
outfit = outfitCreature:getOutfit()
mount = mountCreature:getOutfit()
addons = {
[1] = {widget = outfitWindow:getChildById('addon1'), value = 1},
[2] = {widget = outfitWindow:getChildById('addon2'), value = 2},
[3] = {widget = outfitWindow:getChildById('addon3'), value = 4}
}
for k, addon in pairs(addons) do
addon.widget.onCheckChange = function(self) onAddonCheckChange(self, addon.value) end
end
if outfit.addons > 0 then
for _, i in pairs(addonSets[outfit.addons]) do
addons[i].widget:setChecked(true)
end
end
currentClotheButtonBox = outfitWindow:getChildById('head')
outfitWindow:getChildById('head').onCheckChange = onClotheCheckChange
outfitWindow:getChildById('primary').onCheckChange = onClotheCheckChange
@@ -150,6 +182,9 @@ function Outfit.create(creature, outfitList)
local colorBoxPanel = outfitWindow:getChildById('colorBoxPanel')
outfitCreatureBox:setCreature(outfitCreature)
local mountCreatureBox = outfitWindow:getChildById('mountCreatureBox')
mountCreatureBox:setCreature(mountCreature)
for j=0,6 do
for i=0,18 do
local colorBox = g_ui.createWidget('ColorBox', colorBoxPanel)
@@ -163,6 +198,7 @@ function Outfit.create(creature, outfitList)
colorBox:setChecked(true)
end
colorBox.onCheckChange = onColorCheckChange
table.insert(colorBoxes, colorBox)
end
end
@@ -173,8 +209,16 @@ function Outfit.create(creature, outfitList)
break
end
end
currentMount = 1
for i=1,#mountList do
if mountList[i][1] == mount.type then
currentMount = i
break
end
end
update()
updateOutfit()
updateMount()
end
function Outfit.destroy()
@@ -182,29 +226,62 @@ function Outfit.destroy()
outfitWindow:destroy()
outfitWindow = nil
outfitCreature = nil
mountCreature = nil
currentColorBox = nil
currentClotheButtonBox = nil
end
end
function Outfit.randomize()
local outfitTemplate = {
outfitWindow:getChildById('head'),
outfitWindow:getChildById('primary'),
outfitWindow:getChildById('secondary'),
outfitWindow:getChildById('detail')
}
for k, section in pairs(outfitTemplate) do
section:setChecked(true)
colorBoxes[math.random(1, #colorBoxes)]:setChecked(true)
section:setChecked(false)
end
outfitTemplate[1]:setChecked(true)
end
function Outfit.accept()
outfit.mount = mount.type
g_game.changeOutfit(outfit)
Outfit.destroy()
end
function Outfit.nextType()
function Outfit.nextOutfitType()
currentOutfit = currentOutfit + 1
if currentOutfit > #outfits then
currentOutfit = 1
end
update()
updateOutfit()
end
function Outfit.previousType()
function Outfit.previousOutfitType()
currentOutfit = currentOutfit - 1
if currentOutfit <= 0 then
currentOutfit = #outfits
end
update()
updateOutfit()
end
function Outfit.nextMountType()
currentMount = currentMount + 1
if currentMount > #mounts then
currentMount = 1
end
updateMount()
end
function Outfit.previousMountType()
currentMount = currentMount - 1
if currentMount <= 0 then
currentMount = #mounts
end
updateMount()
end

View File

@@ -1,145 +0,0 @@
Window
!text: tr('Select Outfit')
size: 550 280
padding: 0 0 0 0
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
@onEnter: Outfit.accept()
@onEscape: Outfit.destroy()
Label
id: outfitName
!text: tr('Outfit Name')
width: 100
anchors.top: parent.top
anchors.left: parent.left
margin-top: 34
margin-left: 20
Creature
id: outfitCreatureBox
anchors.top: outfitName.bottom
anchors.left: outfitName.left
margin-top: 5
padding: 4 4 4 4
fixed-creature-size: true
Panel
id: colorBoxPanel
anchors.top: parent.top
anchors.right: parent.right
margin-top: 54
margin-right: 20
width: 323
height: 119
layout:
type: grid
cell-size: 16 16
cell-spacing: 2
num-columns: 19
num-lines: 7
ButtonBox
id: head
!text: tr('Head')
anchors.top: outfitCreatureBox.top
anchors.left: outfitCreatureBox.right
margin-left: 10
checked: true
width: 90
ButtonBox
id: primary
!text: tr('Primary')
anchors.top: prev.bottom
anchors.left: prev.left
width: 90
ButtonBox
id: secondary
!text: tr('Secondary')
anchors.top: prev.bottom
anchors.left: prev.left
width: 90
ButtonBox
id: detail
!text: tr('Detail')
anchors.top: prev.bottom
anchors.left: prev.left
width: 90
Button
id: outfitNextButton
@onClick: Outfit.nextType()
text: >>
width: 32
margin-top: 4
anchors.top: outfitCreatureBox.bottom
anchors.right: outfitCreatureBox.right
Button
id: outfitPreviousButton
@onClick: Outfit.previousType()
text: <<
width: 32
margin-top: 4
anchors.top: outfitCreatureBox.bottom
anchors.left: outfitCreatureBox.left
CheckBox
id: addon1
!text: tr('Addon 1')
enabled: false
margin-top: 6
width: 100
anchors.top: prev.bottom
anchors.left: prev.left
CheckBox
id: addon2
!text: tr('Addon 2')
enabled: false
margin-top: 2
width: 100
anchors.top: prev.bottom
anchors.left: prev.left
CheckBox
id: addon3
!text: tr('Addon 3')
enabled: false
margin-top: 2
width: 100
anchors.top: prev.bottom
anchors.left: prev.left
HorizontalSeparator
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: next.top
margin-left: 16
margin-right: 16
margin-bottom: 10
Button
id: outfitOkButton
!text: tr('Ok')
width: 64
anchors.right: next.left
anchors.bottom: parent.bottom
margin-bottom: 16
margin-right: 16
@onClick: Outfit.accept()
Button
id: outfitCancelButton
!text: tr('Cancel')
width: 64
anchors.right: parent.right
anchors.bottom: parent.bottom
margin-bottom: 16
margin-right: 16
@onClick: Outfit.destroy()

View File

@@ -0,0 +1,221 @@
BrowseButton < Button
size: 20 29
icon-clip: 0 0 12 21
$hover !disabled:
icon-clip: 0 21 12 21
$pressed:
icon-clip: 0 22 12 21
$disabled:
color: #f0ad4d88
NextOutfitButton < BrowseButton
icon-source: /images/arrow_right.png
PrevOutfitButton < BrowseButton
icon-source: /images/arrow_left.png
NextMountButton < BrowseButton
icon-source: /images/arrow_right.png
PrevMountButton < BrowseButton
icon-source: /images/arrow_left.png
Window
!text: tr('Select Outfit')
size: 338 375
padding: 0 0 0 0
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
@onEnter: Outfit.accept()
@onEscape: Outfit.destroy()
// Creature Boxes
Creature
id: outfitCreatureBox
anchors.top: parent.top
anchors.left: parent.left
margin-top: 48
margin-left: 40
padding: 4 4 4 4
fixed-creature-size: true
Label
id: outfitName
!text: tr('No Outfit')
width: 100
anchors.bottom: prev.top
anchors.left: prev.left
margin-bottom: 2
NextOutfitButton
id: outfitNextButton
anchors.left: outfitCreatureBox.right
anchors.verticalCenter: outfitCreatureBox.verticalCenter
margin-left: 3
enabled: true
@onClick: Outfit.nextOutfitType()
PrevOutfitButton
id: outfitPrevButton
anchors.right: outfitCreatureBox.left
anchors.verticalCenter: outfitCreatureBox.verticalCenter
margin-right: 3
enabled: true
@onClick: Outfit.previousOutfitType()
Creature
id: mountCreatureBox
anchors.top: parent.top
anchors.right: parent.right
margin-top: 48
margin-right: 40
padding: 4 4 4 4
fixed-creature-size: true
Label
id: mountName
!text: tr('No Mount')
width: 140
anchors.bottom: prev.top
anchors.left: prev.left
margin-bottom: 2
NextMountButton
id: mountNextButton
anchors.left: mountCreatureBox.right
anchors.verticalCenter: mountCreatureBox.verticalCenter
margin-left: 3
enabled: true
@onClick: Outfit.nextMountType()
PrevMountButton
id: mountPreviousButton
anchors.right: mountCreatureBox.left
anchors.verticalCenter: mountCreatureBox.verticalCenter
margin-right: 3
enabled: true
@onClick: Outfit.previousMountType()
// Addon Check Boxes
CheckBox
id: addon1
!text: tr('Addon 1')
width: 80
anchors.top: outfitCreatureBox.bottom
anchors.left: parent.left
margin-top: 6
margin-left: 18
enabled: false
CheckBox
id: addon2
!text: tr('Addon 2')
width: 80
anchors.top: prev.top
anchors.left: prev.right
enabled: false
CheckBox
id: addon3
!text: tr('Addon 3')
width: 80
anchors.top: prev.top
anchors.left: prev.right
enabled: false
// Body Selection Buttons
ButtonBox
id: head
!text: tr('Head')
anchors.top: addon1.bottom
anchors.left: addon1.left
margin-top: 5
checked: true
width: 76
ButtonBox
id: primary
!text: tr('Primary')
anchors.top: prev.top
anchors.left: prev.right
width: 76
ButtonBox
id: secondary
!text: tr('Secondary')
anchors.top: prev.top
anchors.left: prev.right
width: 76
ButtonBox
id: detail
!text: tr('Detail')
anchors.top: prev.top
anchors.left: prev.right
width: 76
// Color Panel
Panel
id: colorBoxPanel
anchors.top: head.bottom
anchors.left: head.left
margin-top: 3
margin-right: 20
width: 323
height: 119
layout:
type: grid
cell-size: 14 14
cell-spacing: 2
num-columns: 19
num-lines: 7
// Action Button Section
Button
id: randomizeButton
!text: tr('Randomize')
!tooltip: tr('Randomize characters outfit')
width: 75
anchors.left: prev.left
anchors.top: prev.bottom
margin-right: 16
@onClick: Outfit.randomize()
HorizontalSeparator
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: next.top
margin-left: 16
margin-right: 16
margin-bottom: 10
margin-top: 5
Button
id: outfitOkButton
!text: tr('Okay')
width: 64
anchors.right: next.left
anchors.bottom: parent.bottom
margin-bottom: 16
margin-right: 16
@onClick: Outfit.accept()
Button
id: outfitCancelButton
!text: tr('Cancel')
width: 64
anchors.right: parent.right
anchors.bottom: parent.bottom
margin-bottom: 16
margin-right: 16
@onClick: Outfit.destroy()