5 ISPanel.initialise(
self)
7 local FONT_HEIGHT_SMALL =
getTextManager():getFontHeight(UIFont.Small)
9 local FONT_HEIGHT_LARGE =
getTextManager():getFontHeight(UIFont.Large)
29 local
isFemale = (
self.character.INFO_GENDER == "Female" and true) or (
self.character.INFO_GENDER == "Male" and false)
48 self:updateAppearance()
66 alpha = alphaMin + (alphaStart - alphaMin) * ((1 - adjustedK / (totalLines - 1)) ^ decayRate)
67 alpha = math.max(alpha, alphaMin)
70 local descriptionLabel = ISLabel:new(x, y, FONT_HEIGHT_SMALL, v, 1, 1, 1, alpha, UIFont.Small, true)
71 descriptionLabel:initialise()
72 self:addChild(descriptionLabel)
74 table.insert(self.descriptionLabels, descriptionLabel)
77 y = y + descriptionLabel.height
79 -- For more than 3 lines, the loop breaks after adding "..." to the last displayed line
85function FrameworkZ.UI.CharacterView:render()
86 ISPanel.prerender(self)
88 -- Render the character preview and any other UI elements here
91function FrameworkZ.UI.CharacterView:updateAppearance()
92 local survivor = self.survivor
93 local character = self.character
95 for k, v in ipairs (FrameworkZ.Characters.EquipmentSlots) do
96 survivor:setWornItem(v, nil)
99 local headItem = character.EQUIPMENT_SLOT_HEAD and InventoryItemFactory.CreateItem(character.EQUIPMENT_SLOT_HEAD.id) or nil
100 local faceItem = character.EQUIPMENT_SLOT_FACE and InventoryItemFactory.CreateItem(character.EQUIPMENT_SLOT_FACE.id) or nil
101 local earsItem = character.EQUIPMENT_SLOT_EARS and InventoryItemFactory.CreateItem(character.EQUIPMENT_SLOT_EARS.id) or nil
102 local backpackItem = character.EQUIPMENT_SLOT_BACKPACK and InventoryItemFactory.CreateItem(character.EQUIPMENT_SLOT_BACKPACK.id) or nil
103 local glovesItem = character.EQUIPMENT_SLOT_GLOVES and InventoryItemFactory.CreateItem(character.EQUIPMENT_SLOT_GLOVES.id) or nil
104 local undershirtItem = character.EQUIPMENT_SLOT_UNDERSHIRT and InventoryItemFactory.CreateItem(character.EQUIPMENT_SLOT_UNDERSHIRT.id) or nil
105 local overshirtItem = character.EQUIPMENT_SLOT_OVERSHIRT and InventoryItemFactory.CreateItem(character.EQUIPMENT_SLOT_OVERSHIRT.id) or nil
106 local vestItem = character.EQUIPMENT_SLOT_VEST and InventoryItemFactory.CreateItem(character.EQUIPMENT_SLOT_VEST.id) or nil
107 local beltItem = character.EQUIPMENT_SLOT_BELT and InventoryItemFactory.CreateItem(character.EQUIPMENT_SLOT_BELT.id) or nil
108 local pantsItem = character.EQUIPMENT_SLOT_PANTS and InventoryItemFactory.CreateItem(character.EQUIPMENT_SLOT_PANTS.id) or nil
109 local socksItem = character.EQUIPMENT_SLOT_SOCKS and InventoryItemFactory.CreateItem(character.EQUIPMENT_SLOT_SOCKS.id) or nil
110 local shoesItem = character.EQUIPMENT_SLOT_SHOES and InventoryItemFactory.CreateItem(character.EQUIPMENT_SLOT_SHOES.id) or nil
112 survivor:getHumanVisual():setSkinTextureIndex(character.INFO_SKIN_COLOR)
113 survivor:getHumanVisual():setHairModel(character.INFO_HAIR_STYLE)
114 survivor:getHumanVisual():setBeardModel(character.INFO_BEARD_STYLE)
116 local immutableColor = ImmutableColor.new(character.INFO_HAIR_COLOR.r, character.INFO_HAIR_COLOR.g, character.INFO_HAIR_COLOR.b, 1)
118 survivor:getHumanVisual():setHairColor(immutableColor)
119 survivor:getHumanVisual():setBeardColor(immutableColor)
120 survivor:getHumanVisual():setNaturalHairColor(immutableColor)
121 survivor:getHumanVisual():setNaturalBeardColor(immutableColor)
123 if headItem then survivor:setWornItem(EQUIPMENT_SLOT_HEAD, headItem) end
124 if faceItem then survivor:setWornItem(EQUIPMENT_SLOT_FACE, faceItem) end
125 if earsItem then survivor:setWornItem(EQUIPMENT_SLOT_EARS, earsItem) end
126 if backpackItem then survivor:setWornItem(EQUIPMENT_SLOT_BACKPACK, backpackItem) end
127 if glovesItem then survivor:setWornItem(EQUIPMENT_SLOT_GLOVES, glovesItem) end
128 if undershirtItem then survivor:setWornItem(EQUIPMENT_SLOT_UNDERSHIRT, undershirtItem) end
129 if overshirtItem then survivor:setWornItem(EQUIPMENT_SLOT_OVERSHIRT, overshirtItem) end
130 if vestItem then survivor:setWornItem(EQUIPMENT_SLOT_VEST, vestItem) end
131 if beltItem then survivor:setWornItem(EQUIPMENT_SLOT_BELT, beltItem) end
132 if pantsItem then survivor:setWornItem(EQUIPMENT_SLOT_PANTS, pantsItem) end
133 if socksItem then survivor:setWornItem(EQUIPMENT_SLOT_SOCKS, socksItem) end
134 if shoesItem then survivor:setWornItem(EQUIPMENT_SLOT_SHOES, shoesItem) end
136 self.characterPreview:setSurvivorDesc(survivor)
139function FrameworkZ.UI.CharacterView:setCharacter(character)
140 self.character = character
143function FrameworkZ.UI.CharacterView:setName(name)
147function FrameworkZ.UI.CharacterView:setDescription(description)
148 self.description = description
151function FrameworkZ.UI.CharacterView:reinitialize(character)
152 self:setCharacter(character)
153 self:setName(character.INFO_NAME)
154 self:setDescription(character.INFO_DESCRIPTION)
158function FrameworkZ.UI.CharacterView:getDescriptionLines(description)
164 for word in string.gmatch(description, "%S+") do
165 table.insert(words, word)
173 local word = words[i]
174 local wordLength = string.len(word) + 1
176 if lineLength + wordLength <= 30 or lineLength == 0 then
177 line = lineLength == 0 and word or line .. " " .. word
178 lineLength = lineLength + wordLength
180 table.insert(lines, line)
182 lineLength = wordLength
187 table.insert(lines, line)
193function FrameworkZ.UI.CharacterView:new(x, y, width, height, isoPlayer, character, name, description, defaultDirection)
196 o = ISPanel:new(x, y, width, height)
197 setmetatable(o, self)
199 o.backgroundColor = {r=0, g=0, b=0, a=0}
200 o.borderColor = {r=0, g=0, b=0, a=0}
201 o.moveWithMouse = false
202 o.isoPlayer = isoPlayer
203 o.character = character
205 o.description = description
206 o.defaultDirection = defaultDirection
207 FrameworkZ.UI.CharacterView.instance = o
212return FrameworkZ.UI.CharacterView
void FrameworkZ UI CharacterPreview()
void self characterPreview()
void local descriptionHeight()
void self characterNameLabel()
void self descriptionLabels()
void local descriptionLabel()
void local previewHeight()
void local descriptionLines()
void getDescriptionLines(description)
void setCharacter(character)
void setDescription(description)
void reinitialize(character)
Contains all of the User Interfaces for FrameworkZ.