FrameworkZ 10.8.3
Provides a framework for Project Zomboid with various systems.
Loading...
Searching...
No Matches
CharacterPreview.lua
Go to the documentation of this file.
2FrameworkZ.Interfaces:Register(FrameworkZ.UI.CharacterPreview, "CharacterPreview")
3
4function FrameworkZ.UI.CharacterPreview:initialise()
5 ISPanel.initialise(self)
7 self.avatarBackgroundTexture = getTexture("media/ui/avatarBackground.png")
9 local FONT_HGT_MEDIUM = getTextManager():getFontHeight(UIFont.Medium)
10 local FONT_HGT_SMALL = getTextManager():getFontHeight(UIFont.Small)
11 local comboHgt = FONT_HGT_SMALL + 3 * 2
13 self.avatarPanel = ISUI3DModel:new(0, 0, self.width, self.height - comboHgt)
14 self.avatarPanel.backgroundColor = {r=0, g=0, b=0, a=0.8}
15 self.avatarPanel.borderColor = {r=1, g=1, b=1, a=0.2}
16 self:addChild(self.avatarPanel)
17 self.avatarPanel:setState("idle")
18 self.avatarPanel:setDirection(self.direction)
19 self.avatarPanel:setIsometric(false)
20 self.avatarPanel:setDoRandomExtAnimations(true)
21 self.avatarPanel:reportEvent(self.defaultAnimation and self.defaultAnimation or "EventWalk")
22
23 self.turnLeftButton = ISButton:new(self.avatarPanel.x, self.avatarPanel:getBottom()-15, 15, 15, "", self, self.onTurnChar)
24 self.turnLeftButton.internal = "TURNCHARACTERLEFT"
25 self.turnLeftButton:initialise()
26 self.turnLeftButton:instantiate()
27 self.turnLeftButton:setImage(getTexture("media/ui/ArrowLeft.png"))
28 self:addChild(self.turnLeftButton)
29
30 self.turnRightButton = ISButton:new(self.avatarPanel:getRight()-15, self.avatarPanel:getBottom()-15, 15, 15, "", self, self.onTurnChar)
31 self.turnRightButton.internal = "TURNCHARACTERRIGHT"
32 self.turnRightButton:initialise()
33 self.turnRightButton:instantiate()
34 self.turnRightButton:setImage(getTexture("media/ui/ArrowRight.png"))
35 self:addChild(self.turnRightButton)
36
37 self.animCombo = ISComboBox:new(0, self.avatarPanel:getBottom() + 2, self.width, comboHgt, self, self.onAnimSelected)
38 self.animCombo:initialise()
39 self:addChild(self.animCombo)
40 self.animCombo:addOptionWithData(getText("IGUI_anim_Walk"), "EventWalk")
41 self.animCombo:addOptionWithData(getText("IGUI_anim_Idle"), "EventIdle")
42 self.animCombo:addOptionWithData(getText("IGUI_anim_Run"), "EventRun")
43 self.animCombo.selected = 1
44end
45
47 ISPanel.prerender(self)
48
49 self:drawRectBorder(self.avatarPanel.x - 2, self.avatarPanel.y - 2, self.avatarPanel.width + 4, self.avatarPanel.height + 4, 1, 0.3, 0.3, 0.3);
50 self:drawTextureScaled(self.avatarBackgroundTexture, self.avatarPanel.x, self.avatarPanel.y, self.avatarPanel.width, self.avatarPanel.height, 1, 1, 1, 1);
51end
52
53function FrameworkZ.UI.CharacterPreview:onTurnChar(button, x, y)
54 local direction = self.avatarPanel:getDirection()
55 if button.internal == "TURNCHARACTERLEFT" then
56 direction = IsoDirections.RotLeft(direction)
57 self.avatarPanel:setDirection(direction)
58 elseif button.internal == "TURNCHARACTERRIGHT" then
59 direction = IsoDirections.RotRight(direction)
60 self.avatarPanel:setDirection(direction)
61 end
62end
63
64function FrameworkZ.UI.CharacterPreview:onAnimSelected(combo)
65-- self.avatarPanel:setState(combo:getOptionData(combo.selected))
66 self.avatarPanel:reportEvent(combo:getOptionData(combo.selected))
67end
68
69function FrameworkZ.UI.CharacterPreview:setCharacter(character)
70 self.avatarPanel:setCharacter(character)
71end
72
73function FrameworkZ.UI.CharacterPreview:setSurvivorDesc(survivorDesc)
74 self.avatarPanel:setSurvivorDesc(survivorDesc)
75end
76
77function FrameworkZ.UI.CharacterPreview:new(x, y, width, height, defaultAnimation, defaultDirection)
78 local o = ISPanel:new(x, y, width, height)
79
80 setmetatable(o, self)
82
83 -- The panel is bigger than it appears when the animation selection dropdown is removed. Maybe there's a better way to handle that?
84 o.backgroundColor = {r=0, g=0, b=0, a=0}
85 o.borderColor = {r=0, g=0, b=0, a=0}
86 o.direction = defaultDirection and defaultDirection or IsoDirections.SW
87 o.defaultAnimation = defaultAnimation
88
89 return o
90end
91
void FrameworkZ UI CharacterPreview()
void local y()
void local x()
void FrameworkZ DollarFormats __index()
void local height()
void local width
void self self
Definition MainMenu.lua:89
void processingNotification backgroundColor a()
void self textCloseButton internal()
void self playerListPanel prerender()
void local getTextManager()
void local getTexture()
void local IsoDirections()
void button backgroundColor()
void setSurvivorDesc(survivorDesc)
Contains all of the User Interfaces for FrameworkZ.