-
-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathSplash.ahk
More file actions
242 lines (175 loc) · 6.42 KB
/
Splash.ahk
File metadata and controls
242 lines (175 loc) · 6.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Modular Simulator Controller System - Splash Screens ;;;
;;; ;;;
;;; Author: Oliver Juwig (TheBigO) ;;;
;;; License: (2026) Creative Commons - BY-NC-SA ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;-------------------------------------------------------------------------;;;
;;; Global Include Section ;;;
;;;-------------------------------------------------------------------------;;;
#Include "Constants.ahk"
#Include "Variables.ahk"
#Include "Files.ahk"
#Include "Strings.ahk"
#Include "Collections.ahk"
#Include "Localization.ahk"
#Include "MultiMap.ahk"
#Include "GUI.ahk"
;;;-------------------------------------------------------------------------;;;
;;; Local Include Section ;;;
;;;-------------------------------------------------------------------------;;;
#Include "..\Framework\Extensions\GIFViewer.ahk"
;;;-------------------------------------------------------------------------;;;
;;; Private Function Declaration Section ;;;
;;;-------------------------------------------------------------------------;;;
playSplashScreenSong(songFile) {
songFile := getFileName(songFile, kUserSplashMediaDirectory, kSplashMediaDirectory)
if FileExist(songFile)
SoundPlay(songFile)
}
;;;-------------------------------------------------------------------------;;;
;;; Public Function Declaration Section ;;;
;;;-------------------------------------------------------------------------;;;
showSplash(image, alwaysOnTop := true, video := false) {
local videoPlayer := false
local lastSplash, title, subTitle, extension, html, splashGui
static splashCounter := 0
static splashGuis := [false, false, false, false, false, false, false, false, false, false]
lastSplash := splashCounter
if !image {
if ((splashCounter > 0) && splashGuis[splashCounter]) {
splashGui := splashGuis[splashCounter]
try
splashGui["videoPlayer"].Stop()
try
splashGui.Destroy()
splashGuis[splashCounter] := false
}
}
else {
image := getFileName(image, kUserSplashMediaDirectory, kSplashMediaDirectory)
if FileExist(image) {
if (++splashCounter > splashGuis.Length) {
splashCounter := 1
if splashGuis[splashCounter] {
try
splashGuis[splashCounter].Destroy()
splashGuis[splashCounter] := false
}
}
title := substituteVariables(translate(getMultiMapValue(kSimulatorConfiguration, "Splash Window", "Title", "")))
subTitle := substituteVariables(translate(getMultiMapValue(kSimulatorConfiguration, "Splash Window", "Subtitle", "")))
SplitPath(image, , , &extension)
splashGui := Window({Options: "+E0x02000000"})
splashGuis[splashCounter] := splashGui
splashGui.SetFont("s10 Bold", "Arial")
splashGui.Add("Text", "x10 w780 Center", title)
if (extension = "GIF")
videoPlayer := splashGui.Add("GIFViewer", "x10 y30 w780 h439 vvideoPlayer", image)
else
splashGui.Add("Picture", "x10 y30 w780 h439", image)
splashGui.SetFont("s8 Norm", "Arial")
splashGui.Add("Text", "x10 y474 w780 Center", subTitle)
if alwaysOnTop
splashGui.Opt("+AlwaysOnTop")
splashGui.Show("x" . Round((A_ScreenWidth - 800) / 2) . " y" . Round(A_ScreenHeight / 4) . " AutoSize NoActivate")
if videoPlayer
videoPlayer.Start()
if ((lastSplash > 0) && splashGuis[lastSplash]) {
splashGuis[lastSplash].Destroy()
splashGuis[lastSplash] := false
}
return true
}
}
return false
}
hideSplash() {
showSplash(false)
}
rotateSplash(alwaysOnTop := true) {
local image
static number := 1
static images := false
static numImages := 0
if !images {
images := getFileNames("*.jpg", kUserSplashMediaDirectory, kSplashMediaDirectory)
numImages := images.Length
}
if (number > numImages)
number := 1
if (number <= numImages) {
image := images[number++]
if FileExist(image)
showSplash(image, alwaysOnTop)
}
}
showSplashScreen(splashScreen := unset, songHandler := false, alwaysOnTop := true) {
local song, video, duration, type
static images := false
static number := 1
static numImages := 0
static onTop := false
if !songHandler
songHandler := playSplashScreenSong
if !isSet(splashScreen) {
if (number > numImages)
number := 1
if (number <= numImages)
return showSplash(images[number++], onTop)
else
return false
}
song := false
duration := 3000
config := kSimulatorConfiguration
type := getMultiMapValue(kSimulatorConfiguration, "Splash Screens", splashScreen . ".Type", false)
if (type == "Video") {
song := getMultiMapValue(kSimulatorConfiguration, "Splash Screens", splashScreen . ".Song", false)
video := getMultiMapValue(kSimulatorConfiguration, "Splash Screens", splashScreen . ".Video")
if showSplash(video, true) {
if (song && FileExist(song))
songHandler(song)
return true
}
else
return false
}
else if (type == "Picture Carousel") {
duration := getMultiMapValue(kSimulatorConfiguration, "Splash Screens", splashScreen . ".Duration", 5000)
song := getMultiMapValue(kSimulatorConfiguration, "Splash Screens", splashScreen . ".Song", false)
images := collect(string2Values(",", getMultiMapValue(kSimulatorConfiguration, "Splash Screens", splashScreen . ".Images", false)), substituteVariables)
}
else {
logMessage(kLogCritical, translate("SplashScreen `"") . splashScreen . translate("`" not found - please check the configuration"))
images := getFileNames("*.jpg", kUserSplashMediaDirectory, kSplashMediaDirectory)
}
numImages := images.Length
onTop := alwaysOnTop
if showSplashScreen() {
SetTimer(showSplashScreen, duration)
if song
songHandler(song)
return true
}
else
return false
}
hideSplashScreen() {
SetTimer(showSplashScreen, 0)
try
SoundPlay("NonExistent.avi")
hideSplash()
}
getAllSplashScreens(configuration := false) {
local descriptor, value, splashScreen
local result := []
if !configuration
configuration := kSimulatorConfiguration
for descriptor, value in getMultiMapValues(configuration, "Splash Screens") {
splashScreen := StrSplit(descriptor, ".")[1]
if !inList(result, splashScreen)
result.Push(splashScreen)
}
return result
}