FrameworkZ 10.8.3
Provides a framework for Project Zomboid with various systems.
Loading...
Searching...
No Matches
LoadCharacterMenu.lua
Go to the documentation of this file.
2FrameworkZ.Interfaces:Register(FrameworkZ.UI.LoadCharacterMenu, "LoadCharacterMenu")
3
4function FrameworkZ.UI.LoadCharacterMenu:initialise()
5 ISPanel.initialise(self)
10 self.gender = "Male"
11 self.characters = self.player:GetCharacters()
13 local transitionButtonHeight = self.height / 2
14 local transitionButtonY = self.height / 2 - transitionButtonHeight / 2
15 local isFemale = (self.gender == "Female" and true) or (self.gender == "Male" and false)
16
17 local widthLeft = 150
18 local heightLeft = 300
19 local xLeft = self.width / 8 - widthLeft / 8
20 local yLeft = self.height / 2 - heightLeft / 2
21
22 local widthSelected = 200
23 local heightSelected = 400
24 local xSelected = self.width / 2 - widthSelected / 2
25 local ySelected = self.height / 2 - heightSelected / 2
26
27 local widthRight = 150
28 local heightRight = 300
29 local xRight = self.width - (self.width / 8 + widthLeft)
30 local yRight = self.height / 2 - heightLeft / 2
31
32 self.survivor = SurvivorFactory:CreateSurvivor(SurvivorType.Neutral, isFemale)
34
35 self.nextButton = ISButton:new(self.width - 30, transitionButtonY, 30, transitionButtonHeight, ">", self, FrameworkZ.UI.LoadCharacterMenu.onNext)
36 self.nextButton.font = UIFont.Large
37 self.nextButton.internal = "NEXT"
38 self.nextButton:initialise()
39 self.nextButton:instantiate()
40 self:addChild(self.nextButton)
41
42 self.previousButton = ISButton:new(0, transitionButtonY, 30, transitionButtonHeight, "<", self, FrameworkZ.UI.LoadCharacterMenu.onPrevious)
43 self.previousButton.font = UIFont.Large
44 self.previousButton.internal = "PREVIOUS"
45 self.previousButton:initialise()
46 self.previousButton:instantiate()
47 self:addChild(self.previousButton)
48
49 self.leftCharacter = FrameworkZ.UI.CharacterView:new(xLeft, yLeft, widthLeft, heightLeft, isoPlayer, self.characters[1], "", "", IsoDirections.SW)
50 self.leftCharacter:setVisible(false)
51 self.leftCharacter:initialise()
52 self:addChild(self.leftCharacter)
53
54 self.selectedCharacter = FrameworkZ.UI.CharacterView:new(xSelected, ySelected, widthSelected, heightSelected, isoPlayer, self.characters[1], "", "", IsoDirections.S)
55 self.selectedCharacter:setVisible(false)
56 self.selectedCharacter:initialise()
57 self:addChild(self.selectedCharacter)
58
59 self.rightCharacter = FrameworkZ.UI.CharacterView:new(xRight, yRight, widthRight, heightRight, isoPlayer, self.characters[1], "", "", IsoDirections.SE)
60 self.rightCharacter:setVisible(false)
61 self.rightCharacter:initialise()
62 self:addChild(self.rightCharacter)
63
64 if not self.player.previousCharacter then
65 if #self.characters == 1 then
66 self.selectedCharacter:setCharacter(self.characters[1])
67 self.selectedCharacter:reinitialize(self.characters[1])
68 self.selectedCharacter:setVisible(true)
69 elseif #self.characters >= 2 then
70 self.selectedCharacter:setCharacter(self.characters[1])
71 self.selectedCharacter:reinitialize(self.characters[1])
72
73 self.rightCharacter:setCharacter(self.characters[2])
74 self.rightCharacter:reinitialize(self.characters[2])
75
76 self.selectedCharacter:setVisible(true)
77 self.rightCharacter:setVisible(true)
78 end
79 else
80 for i = 1, #self.characters do
81 if i == self.player.previousCharacter then
82 self.currentIndex = i
83 break
84 end
85 end
86
87 if #self.characters == 1 then
88 self.selectedCharacter:setCharacter(self.characters[self.currentIndex])
89 self.selectedCharacter:reinitialize(self.characters[self.currentIndex])
90 self.selectedCharacter:setVisible(true)
91 self.leftCharacter:setVisible(false)
92 self.rightCharacter:setVisible(false)
93 elseif #self.characters >= 2 then
94 if self.currentIndex == 1 then
95 self.leftCharacter:setVisible(false)
96 self.rightCharacter:setVisible(true)
97 elseif self.currentIndex == #self.characters then
98 self.leftCharacter:setVisible(true)
99 self.rightCharacter:setVisible(false)
100 else
101 self.leftCharacter:setVisible(true)
102 self.rightCharacter:setVisible(true)
103 end
104
105 self.selectedCharacter:setCharacter(self.characters[self.currentIndex])
106 self.selectedCharacter:reinitialize(self.characters[self.currentIndex])
107 self.selectedCharacter:setVisible(true)
108
109 if self.leftCharacter:isVisible() then
110 self.leftCharacter:setCharacter(self.characters[self.currentIndex - 1])
111 self.leftCharacter:reinitialize(self.characters[self.currentIndex - 1])
112 end
113 if self.rightCharacter:isVisible() then
114 self.rightCharacter:setCharacter(self.characters[self.currentIndex + 1])
115 self.rightCharacter:reinitialize(self.characters[self.currentIndex + 1])
116 end
117 end
118 end
119
120 --[[
121 self.characterPreview = FrameworkZ.UI.CharacterPreview:new(self.width / 2 - characterPreviewWidth / 2, self.height / 2 - characterPreviewHeight / 2, characterPreviewWidth, characterPreviewHeight, "EventIdle")
122 self.characterPreview:initialise()
123 self.characterPreview:removeChild(self.characterPreview.animCombo)
124 self.characterPreview:setCharacter(getPlayer())
125 self.characterPreview:setSurvivorDesc(self.survivor)
126 self:addChild(self.characterPreview)
127 --]]
128end
129
130function FrameworkZ.UI.LoadCharacterMenu:onNext()
131 self.currentIndex = math.min(self.currentIndex + 1, #self.characters)
132 self:updateCharacterPreview()
133end
134
135function FrameworkZ.UI.LoadCharacterMenu:onPrevious()
136 self.currentIndex = math.max(self.currentIndex - 1, 1)
137 self:updateCharacterPreview()
138end
139
140function FrameworkZ.UI.LoadCharacterMenu:updateCharacterPreview()
141 self.selectedCharacter:setCharacter(self.characters[self.currentIndex])
142 self.selectedCharacter:reinitialize(self.characters[self.currentIndex])
143 self.selectedCharacter:setVisible(true)
144
145 if self.currentIndex > 1 then
146 self.leftCharacter:setCharacter(self.characters[self.currentIndex - 1])
147 self.leftCharacter:reinitialize(self.characters[self.currentIndex - 1])
148 self.leftCharacter:setVisible(true)
149 else
150 self.leftCharacter:setVisible(false)
151 end
152
153 if self.currentIndex < #self.characters then
154 self.rightCharacter:setCharacter(self.characters[self.currentIndex + 1])
155 self.rightCharacter:reinitialize(self.characters[self.currentIndex + 1])
156 self.rightCharacter:setVisible(true)
157 else
158 self.rightCharacter:setVisible(false)
159 end
160end
161
163 ISPanel.prerender(self)
164
165 -- Render the character preview and any other UI elements here
166end
167
169 local o = {}
170
171 o = ISPanel:new(x, y, width, height)
172 setmetatable(o, self)
173 self.__index = self
174 o.backgroundColor = {r=0, g=0, b=0, a=0}
175 o.borderColor = {r=0, g=0, b=0, a=0}
176 o.moveWithMouse = false
177 o.player = player
178 FrameworkZ.UI.LoadCharacterMenu.instance = o
179
180 return o
181end
182
void FrameworkZ UI CharacterPreview()
void local y()
void self survivor()
void FrameworkZ UI CharacterView()
void local x()
void local height()
void local width
void self characterPreview()
void FrameworkZ UI LoadCharacterMenu()
void self currentIndex()
void for i()
void self createCharacterButton font()
void self self
Definition MainMenu.lua:89
void local player()
void processingNotification backgroundColor a()
void local isFemale()
void self previousCharacter()
void self textCloseButton internal()
void self playerListPanel render()
void self playerListPanel prerender()
void local IsoDirections()
void local getPlayer()
void isoPlayer()
void local characters()
Contains all of the User Interfaces for FrameworkZ.