FrameworkZ 10.8.3
Provides a framework for Project Zomboid with various systems.
Loading...
Searching...
No Matches
Introduction.lua
Go to the documentation of this file.
3
4function FrameworkZ.UI.Introduction:initialise()
5 local emitter = self.playerObject:getEmitter()
6 self.vignetteTexture = getTexture("media/textures/vignette.png")
7 self.cfwTexture = getTexture(FrameworkZ.Config.Options.IntroFrameworkImage)
8 self.hl2rpTexture = getTexture(FrameworkZ.Config.Options.IntroGamemodeImage)
9
10 ISPanel.initialise(self)
12 self.initializing = ISLabel:new(self.width / 2, (self.height - getTextManager():MeasureStringY(UIFont.Large, "Initializing")) / 2, 25, "Initializing", 1, 1, 1, 1, UIFont.Large, true)
13 self.initializing.center = true
14 self:addChild(self.initializing)
15
16 self.currentTick = 1
18 FrameworkZ.Timers:Create("FZ_INITIALIZATION", FrameworkZ.Config.Options.InitializationDuration, 1, function()
19 FrameworkZ.Timers:Create("FZ_INIT_TICK", 0.2, 0, function()
20 if not FrameworkZ.Foundation.Initialized then
21 if self.currentTick == 0 then
22 self.initializing:setName("Initializing")
23 self.currentTick = 1
24 elseif self.currentTick == 1 then
25 self.initializing:setName("Initializing.")
26 self.currentTick = 2
27 elseif self.currentTick == 2 then
28 self.initializing:setName("Initializing..")
29 self.currentTick = 3
30 elseif self.currentTick == 3 then
31 self.initializing:setName("Initializing...")
32 self.currentTick = 0
33 end
34 else
35 FrameworkZ.Timers:Remove("FZ_INIT_TICK")
36 self.initializing:setName("--- Initialized ---")
37
38 FrameworkZ.Timers:Simple(2, function()
39 if not FrameworkZ.Config.Options.SkipIntro then
40 self:removeChild(self.initializing)
41 emitter:playSoundImpl(FrameworkZ.Config.Options.IntroMusic, nil)
42
43 emitter:playSoundImpl("button1", nil)
44 self.backgroundColor = {r=0.1, g=0.1, b=0.1, a=1}
45
46 FrameworkZ.Timers:Simple(0.1, function()
47 self.backgroundColor = {r=0, g=0, b=0, a=1}
48
49 self.cfw = ISImage:new(self.width / 2 - self.cfwTexture:getWidth() / 2, self.height / 2 - self.cfwTexture:getHeight() / 2, self.cfwTexture:getWidth(), self.cfwTexture:getHeight(), self.cfwTexture)
50 self.cfw.backgroundColor = {r=1, g=1, b=1, a=1}
51 self.cfw.scaledWidth = self.cfwTexture:getWidth()
52 self.cfw.scaledHeight = self.cfwTexture:getHeight()
54 self.cfw:initialise()
55 self:addChild(self.cfw)
56
57 FrameworkZ.Timers:Simple(7, function()
58 self:removeChild(self.cfw)
60
61 emitter:playSoundImpl("lightswitch2", nil)
62 self.backgroundColor = {r=0.1, g=0.1, b=0.1, a=1}
64 FrameworkZ.Timers:Simple(0.1, function()
65 self.backgroundColor = {r=0, g=0, b=0, a=1}
66
67 self.hl2rp = ISImage:new(self.width / 2 - self.hl2rpTexture:getWidth() / 2, self.height / 2 - self.hl2rpTexture:getHeight() / 2, self.hl2rpTexture:getWidth(), self.hl2rpTexture:getHeight(), self.hl2rpTexture)
68 self.hl2rp.backgroundColor = {r=1, g=1, b=1, a=1}
69 self.hl2rp.scaledWidth = self.hl2rpTexture:getWidth()
70 self.hl2rp.scaledHeight = self.hl2rpTexture:getHeight()
71 self.hl2rp.shrinking = true
72 self.hl2rp:initialise()
73 self:addChild(self.hl2rp)
74
75 FrameworkZ.Timers:Simple(7, function()
76 self:removeChild(self.hl2rp)
77 self.hl2rp = nil
78
79 emitter:playSoundImpl("lightswitch2", nil)
80 self.backgroundColor = {r=0.1, g=0.1, b=0.1, a=1}
81
82 FrameworkZ.Timers:Remove("IntroTick")
83
84 FrameworkZ.Timers:Simple(0.1, function()
85 self.backgroundColor = {r=0, g=0, b=0, a=1}
86
87 local characterSelect = FrameworkZ.UI.MainMenu:new(0, 0, getCore():getScreenWidth(), getCore():getScreenHeight(), self.playerObject)
88 characterSelect:addChild(FrameworkZ.Foundation.InitializationNotification)
89 characterSelect:initialise()
90 characterSelect:addToUIManager()
91
92 FrameworkZ.Timers:Simple(1, function()
93 self:setVisible(false)
94 self:removeFromUIManager()
95 end)
96 end)
97 end)
98 end)
99 end)
100 end)
101 else
102 FrameworkZ.Timers:Remove("IntroTick")
103 local characterSelect = FrameworkZ.UI.MainMenu:new(0, 0, getCore():getScreenWidth(), getCore():getScreenHeight(), self.playerObject)
104 characterSelect:addChild(FrameworkZ.Foundation.InitializationNotification)
105 characterSelect:initialise()
106 characterSelect:addToUIManager()
107
108 FrameworkZ.Timers:Simple(1, function()
109 self:setVisible(false)
110 self:removeFromUIManager()
111 end)
112 end
113 end)
114 end
115 end)
116 end)
117end
118
119local function calculateWidthHeight(originalAspectRatio, width, height, changeValue)
120 -- Scenario 1: Increase width by 1 and adjust height
121 local newWidth1 = width + changeValue
122 local newHeight1 = math.floor((newWidth1 / originalAspectRatio) + 0.5)
123
124 -- Scenario 2: Increase height by 1 and adjust width
125 local newHeight2 = height + changeValue
126 local newWidth2 = math.floor((newHeight2 * originalAspectRatio) + 0.5)
127
128 -- Calculate the aspect ratio difference for both scenarios
129 local difference1 = math.abs((newWidth1 / newHeight1) - originalAspectRatio)
130 local difference2 = math.abs((newWidth2 / newHeight2) - originalAspectRatio)
131
132 -- Choose the scenario with the smallest difference
133 if difference1 < difference2 then
134 return newWidth1, newHeight1
135 else
136 return newWidth2, newHeight2
137 end
138end
139
140FrameworkZ.Timers:Create("IntroTick", 0.1, 0, function()
143
144 if instance.cfw then
145 if instance.cfw.shrinking == true and instance.cfw.scaledWidth / instance.cfw:getWidth() >= 0.95 then
147
150 elseif instance.cfw.shrinking == true then
151 instance.cfw.shrinking = false
152 end
153
154 if instance.cfw.shrinking == false and instance.cfw.scaledWidth / instance.cfw:getWidth() <= 1 then
156
159 elseif instance.cfw.shrinking == false then
160 instance.cfw.shrinking = true
161 end
162
165 end
166
167 if instance.hl2rp then
168 if instance.hl2rp.shrinking == true and instance.hl2rp.scaledWidth / instance.hl2rp:getWidth() >= 0.95 then
170
173 elseif instance.hl2rp.shrinking == true then
174 instance.hl2rp.shrinking = false
175 end
176
177 if instance.hl2rp.shrinking == false and instance.hl2rp.scaledWidth / instance.hl2rp:getWidth() <= 1 then
179
182 elseif instance.hl2rp.shrinking == false then
184 end
185
188 end
189 end
190end)
191
192function FrameworkZ.UI.Introduction:update()
193 ISPanel.update(self)
194end
195
196function FrameworkZ.UI.Introduction:new(x, y, width, height, playerObject)
197 local o = {}
198
199 o = ISPanel:new(x, y, width, height)
200 setmetatable(o, self)
201 self.__index = self
202 o.backgroundColor = {r=0, g=0, b=0, a=1}
203 o.borderColor = {r=0, g=0, b=0, a=1}
204 o.moveWithMouse = false
205 o.playerObject = playerObject
206 FrameworkZ.UI.Introduction.instance = o
207
208 return o
209end
210
void local y()
void local x()
void self hl2rp()
void local newHeight1()
void local newWidth1()
void FrameworkZ UI Introduction()
void self cfw shrinking()
void local height()
void local newHeight2()
void self cfw()
void self cfw scaledWidth()
void local width
void local newWidth2()
void local difference1()
void self cfw scaledHeight()
void local instance()
void local difference2()
void local characterSelect()
void self backgroundColor()
void self MainMenu
Definition MainMenu.lua:95
void self emitter()
void self FrameworkZ UI self nil
Definition MainMenu.lua:95
void self self
Definition MainMenu.lua:89
void processingNotification backgroundColor a()
void local getTextManager()
void local getTexture()
void FrameworkZ Foundation()
Timers module for FrameworkZ. Allows for the creation of timers for delaying code executions.
Definition Timers.lua:5
Contains all of the User Interfaces for FrameworkZ.