Hello guys! Great implementations of splash screens, especially the fader. However, for a simple cross-platform solution, this works too:
Code: Select all
EnableExplicit
InitNetwork()
Enumeration
#MainWindow
#splashWindow
#splashImage
#splashPicture
EndEnumeration
Define.i wFlags, iWidth, iHeight, tWidth, displayTime, mainFlag, splashFont, splashText.s
If ReceiveHTTPFile("https://www.dropbox.com/s/9is77u0d7xzhvjy/rainbow.bmp?dl=1",
GetTemporaryDirectory() + "splash.bmp")
If LoadImage(#splashPicture, GetTemporaryDirectory() + "splash.bmp")
iWidth = ImageWidth(#splashPicture)
iHeight = ImageHeight(#splashPicture)
splashFont = FontID(LoadFont(#PB_Any, "Arial", 9))
splashText = "Splash Screen Example - Copyright (c) TI-994A"
StartDrawing(ImageOutput(#splashPicture))
DrawingFont(splashFont)
DrawingMode(#PB_2DDrawing_Transparent)
tWidth = TextWidth(splashText)
DrawText((iWidth - tWidth) / 2, iHeight - 30, splashText, #Black)
StopDrawing()
wFlags = #PB_Window_BorderLess | #PB_Window_ScreenCentered
If OpenWindow(#splashWindow, #PB_Any, #PB_Any, iWidth, iHeight, "", wFlags)
ImageGadget(#splashImage, 0, 0, iWidth, iHeight, ImageID(#splashPicture))
StickyWindow(#splashWindow, 1)
displayTime = ElapsedMilliseconds()
While ElapsedMilliseconds() - displayTime < 5000
WaitWindowEvent(100)
If ElapsedMilliseconds() - displayTime > 3000 And Not mainFlag
wFlags = #PB_Window_ScreenCentered | #PB_Window_MinimizeGadget
OpenWindow(#MainWindow, #PB_Any, #PB_Any, 640, 480, "Main Program", wFlags)
mainFlag = 1
EndIf
Wend
CloseWindow(#splashWindow)
EndIf
EndIf
EndIf
If Not mainFlag: End: EndIf
While WaitWindowEvent() ! #PB_Event_CloseWindow : Wend
The InitNetwork() function is only required because the example uses an image from my DropBox folder. You can remove it if you're using your own local image. And remember to add the relevant image decoders (
UseJPEGImageDecoder, UsePNGImageDecoder, etc.) if required. Also, the main program window is initialised in the timer loop to simulate a concurrent threaded process. Otherwise, it could just be opened after the splash window closes.
EDITS wrote:18th February 2019: updated download links