8 ISPanel.initialise(
self)
65 alpha = alphaMin + (alphaStart - alphaMin) * ((1 - adjustedK / (totalLines - 1)) ^ decayRate)
66 alpha = math.max(alpha, alphaMin)
69 local descriptionLabel = ISLabel:new(x, y, FONT_HEIGHT_SMALL, v, 1, 1, 1, alpha, UIFont.Small, true)
70 descriptionLabel:initialise()
71 self:addChild(descriptionLabel)
73 table.insert(self.descriptionLabels, descriptionLabel)
76 y = y + descriptionLabel.height
78 -- For more than 3 lines, the loop breaks after adding "..." to the last displayed line
84function PFW_CharacterView:render()
85 ISPanel.prerender(self)
87 -- Render the character preview and any other UI elements here
90function PFW_CharacterView:updateAppearance()
91 local survivor = self.survivor
92 local character = self.character
94 for k, v in ipairs (FrameworkZ.Characters.EquipmentSlots) do
95 survivor:setWornItem(v, nil)
98 local headItem = character.EQUIPMENT_SLOT_HEAD and InventoryItemFactory.CreateItem(character.EQUIPMENT_SLOT_HEAD.id) or nil
99 local faceItem = character.EQUIPMENT_SLOT_FACE and InventoryItemFactory.CreateItem(character.EQUIPMENT_SLOT_FACE.id) or nil
100 local earsItem = character.EQUIPMENT_SLOT_EARS and InventoryItemFactory.CreateItem(character.EQUIPMENT_SLOT_EARS.id) or nil
101 local backpackItem = character.EQUIPMENT_SLOT_BACKPACK and InventoryItemFactory.CreateItem(character.EQUIPMENT_SLOT_BACKPACK.id) or nil
102 local glovesItem = character.EQUIPMENT_SLOT_GLOVES and InventoryItemFactory.CreateItem(character.EQUIPMENT_SLOT_GLOVES.id) or nil
103 local undershirtItem = character.EQUIPMENT_SLOT_UNDERSHIRT and InventoryItemFactory.CreateItem(character.EQUIPMENT_SLOT_UNDERSHIRT.id) or nil
104 local overshirtItem = character.EQUIPMENT_SLOT_OVERSHIRT and InventoryItemFactory.CreateItem(character.EQUIPMENT_SLOT_OVERSHIRT.id) or nil
105 local vestItem = character.EQUIPMENT_SLOT_VEST and InventoryItemFactory.CreateItem(character.EQUIPMENT_SLOT_VEST.id) or nil
106 local beltItem = character.EQUIPMENT_SLOT_BELT and InventoryItemFactory.CreateItem(character.EQUIPMENT_SLOT_BELT.id) or nil
107 local pantsItem = character.EQUIPMENT_SLOT_PANTS and InventoryItemFactory.CreateItem(character.EQUIPMENT_SLOT_PANTS.id) or nil
108 local socksItem = character.EQUIPMENT_SLOT_SOCKS and InventoryItemFactory.CreateItem(character.EQUIPMENT_SLOT_SOCKS.id) or nil
109 local shoesItem = character.EQUIPMENT_SLOT_SHOES and InventoryItemFactory.CreateItem(character.EQUIPMENT_SLOT_SHOES.id) or nil
111 survivor:getHumanVisual():setSkinTextureIndex(character.INFO_SKIN_COLOR)
112 survivor:getHumanVisual():setHairModel(character.INFO_HAIR_STYLE)
113 survivor:getHumanVisual():setBeardModel(character.INFO_BEARD_STYLE)
115 local immutableColor = ImmutableColor.new(character.INFO_HAIR_COLOR.r, character.INFO_HAIR_COLOR.g, character.INFO_HAIR_COLOR.b, 1)
117 survivor:getHumanVisual():setHairColor(immutableColor)
118 survivor:getHumanVisual():setBeardColor(immutableColor)
119 survivor:getHumanVisual():setNaturalHairColor(immutableColor)
120 survivor:getHumanVisual():setNaturalBeardColor(immutableColor)
122 if headItem then survivor:setWornItem(EQUIPMENT_SLOT_HEAD, headItem) end
123 if faceItem then survivor:setWornItem(EQUIPMENT_SLOT_FACE, faceItem) end
124 if earsItem then survivor:setWornItem(EQUIPMENT_SLOT_EARS, earsItem) end
125 if backpackItem then survivor:setWornItem(EQUIPMENT_SLOT_BACKPACK, backpackItem) end
126 if glovesItem then survivor:setWornItem(EQUIPMENT_SLOT_GLOVES, glovesItem) end
127 if undershirtItem then survivor:setWornItem(EQUIPMENT_SLOT_UNDERSHIRT, undershirtItem) end
128 if overshirtItem then survivor:setWornItem(EQUIPMENT_SLOT_OVERSHIRT, overshirtItem) end
129 if vestItem then survivor:setWornItem(EQUIPMENT_SLOT_VEST, vestItem) end
130 if beltItem then survivor:setWornItem(EQUIPMENT_SLOT_BELT, beltItem) end
131 if pantsItem then survivor:setWornItem(EQUIPMENT_SLOT_PANTS, pantsItem) end
132 if socksItem then survivor:setWornItem(EQUIPMENT_SLOT_SOCKS, socksItem) end
133 if shoesItem then survivor:setWornItem(EQUIPMENT_SLOT_SHOES, shoesItem) end
135 self.characterPreview:setSurvivorDesc(survivor)
138function PFW_CharacterView:setCharacter(character)
139 self.character = character
142function PFW_CharacterView:setName(name)
146function PFW_CharacterView:setDescription(description)
147 self.description = description
150function PFW_CharacterView:reinitialize(character)
151 self:setCharacter(character)
152 self:setName(character.INFO_NAME)
153 self:setDescription(character.INFO_DESCRIPTION)
157function PFW_CharacterView:getDescriptionLines(description)
163 for word in string.gmatch(description, "%S+") do
164 table.insert(words, word)
172 local word = words[i]
173 local wordLength = string.len(word) + 1
175 if lineLength + wordLength <= 30 or lineLength == 0 then
176 line = lineLength == 0 and word or line .. " " .. word
177 lineLength = lineLength + wordLength
179 table.insert(lines, line)
181 lineLength = wordLength
186 table.insert(lines, line)
192function PFW_CharacterView:new(x, y, width, height, isoPlayer, character, name, description, defaultDirection)
195 o = ISPanel:new(x, y, width, height)
196 setmetatable(o, self)
198 o.backgroundColor = {r=0, g=0, b=0, a=0}
199 o.borderColor = {r=0, g=0, b=0, a=0}
200 o.moveWithMouse = false
201 o.isoPlayer = isoPlayer
202 o.character = character
204 o.description = description
205 o.defaultDirection = defaultDirection
206 PFW_CharacterView.instance = o
211return PFW_CharacterView
void local FONT_HEIGHT_MEDIUM()
void local FONT_HEIGHT_SMALL()
void self characterPreview()
void local FONT_HEIGHT_LARGE()
void local descriptionHeight()
void self characterNameLabel()
void self descriptionLabels()
void local descriptionLabel()
void local previewHeight()
void local descriptionLines()
void if self initialFaction and v()
void if not description or description()
void getDescriptionLines(description)
void setCharacter(character)
void setDescription(description)
void reinitialize(character)