254 | function GuiOverlay.copyOverlay(overlay, overlaySrc) |
255 | overlay.filename = overlaySrc.filename |
256 | overlay.uvs = {overlaySrc.uvs[1], overlaySrc.uvs[2], overlaySrc.uvs[3], overlaySrc.uvs[4], overlaySrc.uvs[5], overlaySrc.uvs[6], overlaySrc.uvs[7], overlaySrc.uvs[8]} |
257 | overlay.color = {overlaySrc.color[1], overlaySrc.color[2], overlaySrc.color[3], overlaySrc.color[4]} |
258 | overlay.rotation = overlaySrc.rotation |
259 | overlay.alpha = overlaySrc.alpha |
260 | overlay.isWebOverlay = overlaySrc.isWebOverlay |
261 | overlay.previewFilename = overlaySrc.previewFilename |
262 | |
263 | if overlaySrc.uvsFocused ~= nil then |
264 | overlay.uvsFocused = {overlaySrc.uvsFocused[1], overlaySrc.uvsFocused[2], overlaySrc.uvsFocused[3], overlaySrc.uvsFocused[4], overlaySrc.uvsFocused[5], overlaySrc.uvsFocused[6], overlaySrc.uvsFocused[7], overlaySrc.uvsFocused[8]} |
265 | end |
266 | |
267 | if overlaySrc.colorFocused ~= nil then |
268 | overlay.colorFocused = {overlaySrc.colorFocused[1], overlaySrc.colorFocused[2], overlaySrc.colorFocused[3], overlaySrc.colorFocused[4]} |
269 | end |
270 | |
271 | if overlaySrc.uvsPressed ~= nil then |
272 | overlay.uvsPressed = {overlaySrc.uvsPressed[1], overlaySrc.uvsPressed[2], overlaySrc.uvsPressed[3], overlaySrc.uvsPressed[4], overlaySrc.uvsPressed[5], overlaySrc.uvsPressed[6], overlaySrc.uvsPressed[7], overlaySrc.uvsPressed[8]} |
273 | end |
274 | |
275 | if overlaySrc.colorPressed ~= nil then |
276 | overlay.colorPressed = {overlaySrc.colorPressed[1], overlaySrc.colorPressed[2], overlaySrc.colorPressed[3], overlaySrc.colorPressed[4]} |
277 | end |
278 | |
279 | if overlaySrc.uvsSelected ~= nil then |
280 | overlay.uvsSelected = {overlaySrc.uvsSelected[1], overlaySrc.uvsSelected[2], overlaySrc.uvsSelected[3], overlaySrc.uvsSelected[4], overlaySrc.uvsSelected[5], overlaySrc.uvsSelected[6], overlaySrc.uvsSelected[7], overlaySrc.uvsSelected[8]} |
281 | end |
282 | |
283 | if overlaySrc.colorSelected ~= nil then |
284 | overlay.colorSelected = {overlaySrc.colorSelected[1], overlaySrc.colorSelected[2], overlaySrc.colorSelected[3], overlaySrc.colorSelected[4]} |
285 | end |
286 | |
287 | if overlaySrc.uvsDisabled ~= nil then |
288 | overlay.uvsDisabled = {overlaySrc.uvsDisabled[1], overlaySrc.uvsDisabled[2], overlaySrc.uvsDisabled[3], overlaySrc.uvsDisabled[4], overlaySrc.uvsDisabled[5], overlaySrc.uvsDisabled[6], overlaySrc.uvsDisabled[7], overlaySrc.uvsDisabled[8]} |
289 | end |
290 | |
291 | if overlaySrc.colorDisabled ~= nil then |
292 | overlay.colorDisabled = {overlaySrc.colorDisabled[1], overlaySrc.colorDisabled[2], overlaySrc.colorDisabled[3], overlaySrc.colorDisabled[4]} |
293 | end |
294 | |
295 | if overlaySrc.uvsHighlighted ~= nil then |
296 | overlay.uvsHighlighted = {overlaySrc.uvsHighlighted[1], overlaySrc.uvsHighlighted[2], overlaySrc.uvsHighlighted[3], overlaySrc.uvsHighlighted[4], overlaySrc.uvsHighlighted[5], overlaySrc.uvsHighlighted[6], overlaySrc.uvsHighlighted[7], overlaySrc.uvsHighlighted[8]} |
297 | end |
298 | |
299 | if overlaySrc.colorHighlighted ~= nil then |
300 | overlay.colorHighlighted = {overlaySrc.colorHighlighted[1], overlaySrc.colorHighlighted[2], overlaySrc.colorHighlighted[3], overlaySrc.colorHighlighted[4]} |
301 | end |
302 | |
303 | return GuiOverlay.createOverlay(overlay) |
304 | end |
222 | function GuiOverlay.createOverlay(overlay, filename) |
223 | if overlay.overlay ~= nil and overlay.filename == filename then |
224 | return overlay -- already created / loaded |
225 | end |
226 | |
227 | if filename ~= nil then |
228 | overlay.filename = string.gsub(filename, "$l10nSuffix", g_gui.languageSuffix) |
229 | end |
230 | |
231 | -- delete previously created overlay, if necessary |
232 | GuiOverlay.deleteOverlay(overlay) |
233 | |
234 | if overlay.filename ~= nil then |
235 | local imageOverlay = 0 |
236 | if overlay.isWebOverlay == nil or not overlay.isWebOverlay or (overlay.isWebOverlay and not StringUtil.startsWith(overlay.filename, "http")) then |
237 | imageOverlay = createImageOverlay(overlay.filename) |
238 | else |
239 | imageOverlay = createWebImageOverlay(overlay.filename, overlay.previewFilename) |
240 | end |
241 | if imageOverlay ~= 0 then |
242 | overlay.overlay = imageOverlay |
243 | end |
244 | end |
245 | |
246 | overlay.rotation = Utils.getNoNil(overlay.rotation, 0) |
247 | overlay.alpha = Utils.getNoNil(overlay.alpha, 1) |
248 | |
249 | return overlay |
250 | end |
19 | function GuiOverlay.loadOverlay(self, overlay, overlayName, imageSize, profile, xmlFile, key) |
20 | if overlay.uvs == nil then |
21 | overlay.uvs = Overlay.DEFAULT_UVS |
22 | end |
23 | |
24 | if overlay.color == nil then |
25 | overlay.color = {1, 1, 1, 1} |
26 | end |
27 | |
28 | local filename = nil |
29 | local previewFilename = nil |
30 | if xmlFile ~= nil then |
31 | filename = getXMLString(xmlFile, key .. "#" .. overlayName .. "Filename") |
32 | previewFilename = getXMLString(xmlFile, key .. "#" .. overlayName .. "PreviewFilename") |
33 | |
34 | GuiOverlay.loadXMLUVs(xmlFile, key, overlay, overlayName, imageSize) |
35 | GuiOverlay.loadXMLColors(xmlFile, key, overlay, overlayName) |
36 | elseif profile ~= nil then |
37 | filename = profile:getValue(overlayName .. "Filename") |
38 | previewFilename = profile:getValue(overlayName .. "PreviewFilename") |
39 | |
40 | GuiOverlay.loadProfileUVs(profile, overlay, overlayName, imageSize) |
41 | GuiOverlay.loadProfileColors(profile, overlay, overlayName) |
42 | end |
43 | |
44 | if filename == nil then |
45 | return nil |
46 | end |
47 | |
48 | if previewFilename == nil then |
49 | previewFilename = "dataS2/menu/blank.png" |
50 | end |
51 | |
52 | if filename == "g_baseUIFilename" then |
53 | filename = g_baseUIFilename |
54 | end |
55 | |
56 | overlay.filename = string.gsub(filename, "$l10nSuffix", g_gui.languageSuffix) |
57 | overlay.previewFilename = previewFilename |
58 | |
59 | return overlay |
60 | end |
175 | function GuiOverlay.loadProfileColors(profile, overlay, overlayName) |
176 | local color = GuiUtils.getColorArray(profile:getValue(overlayName .. "Color")) |
177 | if color ~= nil then |
178 | overlay.color = color |
179 | end |
180 | |
181 | local color = GuiUtils.getColorArray(profile:getValue(overlayName .. "FocusedColor")) |
182 | if color ~= nil then |
183 | overlay.colorFocused = color |
184 | end |
185 | |
186 | local color = GuiUtils.getColorArray(profile:getValue(overlayName .. "PressedColor")) |
187 | if color ~= nil then |
188 | overlay.colorPressed = color |
189 | end |
190 | |
191 | local color = GuiUtils.getColorArray(profile:getValue(overlayName .. "SelectedColor")) |
192 | if color ~= nil then |
193 | overlay.colorSelected = color |
194 | end |
195 | |
196 | local color = GuiUtils.getColorArray(profile:getValue(overlayName .. "DisabledColor")) |
197 | if color ~= nil then |
198 | overlay.colorDisabled = color |
199 | end |
200 | |
201 | local color = GuiUtils.getColorArray(profile:getValue(overlayName .. "HighlightedColor")) |
202 | if color ~= nil then |
203 | overlay.colorHighlighted = color |
204 | end |
205 | |
206 | local rotation = profile:getValue(overlayName .. "Rotation") |
207 | if rotation ~= nil then |
208 | overlay.rotation = math.rad(tonumber(rotation)) |
209 | end |
210 | |
211 | local isWebOverlay = profile:getBool(overlayName .. "IsWebOverlay") |
212 | if isWebOverlay ~= nil then |
213 | overlay.isWebOverlay = isWebOverlay |
214 | end |
215 | end |
97 | function GuiOverlay.loadProfileUVs(profile, overlay, overlayName, imageSize) |
98 | local uvs = profile:getValue(overlayName .. "UVs") |
99 | if uvs ~= nil then |
100 | overlay.uvs = GuiUtils.getUVs(uvs, imageSize) |
101 | end |
102 | |
103 | local uvs = profile:getValue(overlayName .. "FocusedUVs") |
104 | if uvs ~= nil then |
105 | overlay.uvsFocused = GuiUtils.getUVs(uvs, imageSize) |
106 | end |
107 | |
108 | local uvs = profile:getValue(overlayName .. "PressedUVs") |
109 | if uvs ~= nil then |
110 | overlay.uvsPressed = GuiUtils.getUVs(uvs, imageSize) |
111 | end |
112 | |
113 | local uvs = profile:getValue(overlayName .. "SelectedUVs") |
114 | if uvs ~= nil then |
115 | overlay.uvsSelected = GuiUtils.getUVs(uvs, imageSize) |
116 | end |
117 | |
118 | local uvs = profile:getValue(overlayName .. "DisabledUVs") |
119 | if uvs ~= nil then |
120 | overlay.uvsDisabled = GuiUtils.getUVs(uvs, imageSize) |
121 | end |
122 | |
123 | local uvs = profile:getValue(overlayName .. "HighlightedUVs") |
124 | if uvs ~= nil then |
125 | overlay.uvsHighlighted = GuiUtils.getUVs(uvs, imageSize) |
126 | end |
127 | end |
131 | function GuiOverlay.loadXMLColors(xmlFile, key, overlay, overlayName) |
132 | local color = GuiUtils.getColorArray(getXMLString(xmlFile, key .. "#" .. overlayName .. "Color")) |
133 | if color ~= nil then |
134 | overlay.color = color |
135 | end |
136 | |
137 | local color = GuiUtils.getColorArray(getXMLString(xmlFile, key .. "#" .. overlayName .. "FocusedColor")) |
138 | if color ~= nil then |
139 | overlay.colorFocused = color |
140 | end |
141 | |
142 | local color = GuiUtils.getColorArray(getXMLString(xmlFile, key .. "#" .. overlayName .. "PressedColor")) |
143 | if color ~= nil then |
144 | overlay.colorPressed = color |
145 | end |
146 | |
147 | local color = GuiUtils.getColorArray(getXMLString(xmlFile, key .. "#" .. overlayName .. "SelectedColor")) |
148 | if color ~= nil then |
149 | overlay.colorSelected = color |
150 | end |
151 | |
152 | local color = GuiUtils.getColorArray(getXMLString(xmlFile, key .. "#" .. overlayName .. "DisabledColor")) |
153 | if color ~= nil then |
154 | overlay.colorDisabled = color |
155 | end |
156 | |
157 | local color = GuiUtils.getColorArray(getXMLString(xmlFile, key .. "#" .. overlayName .. "HighlightedColor")) |
158 | if color ~= nil then |
159 | overlay.colorHighlighted = color |
160 | end |
161 | |
162 | local rotation = getXMLFloat(xmlFile, key .. "#" .. overlayName .. "Rotation") |
163 | if rotation ~= nil then |
164 | overlay.rotation = math.rad(rotation) |
165 | end |
166 | |
167 | local isWebOverlay = getXMLBool(xmlFile, key .. "#" .. overlayName .. "IsWebOverlay") |
168 | if isWebOverlay ~= nil then |
169 | overlay.isWebOverlay = isWebOverlay |
170 | end |
171 | end |
383 | function GuiOverlay.renderOverlay(overlay, posX, posY, sizeX, sizeY, state) |
384 | if overlay.overlay ~= nil then |
385 | local r,g,b,a = unpack(GuiOverlay.getOverlayColor(overlay, state)) |
386 | |
387 | if a ~= 0 then |
388 | setOverlayRotation(overlay.overlay, overlay.rotation, sizeX/2, sizeY/2) |
389 | setOverlayUVs(overlay.overlay, unpack(GuiOverlay.getOverlayUVs(overlay, state))) |
390 | setOverlayColor(overlay.overlay, r, g, b, a*overlay.alpha) |
391 | renderOverlay(overlay.overlay, posX, posY, sizeX, sizeY) |
392 | end |
393 | end |
394 | end |