Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better PlayStartupVideos function #205

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified GFX/menu/startup_TSS.avi
Binary file not shown.
Binary file modified GFX/menu/startup_TSS.ogg
Binary file not shown.
136 changes: 34 additions & 102 deletions Main.bb
Original file line number Diff line number Diff line change
Expand Up @@ -11903,116 +11903,48 @@ Function TeleportEntity(entity%,x#,y#,z#,customradius#=0.3,isglobal%=False,pickr
End Function

Function PlayStartupVideos()

If GetINIInt("options.ini","options","play startup video")=0 Then Return

Local Cam = CreateCamera()
CameraClsMode Cam, 0, 1
Local Quad = CreateQuad()
Local Texture = CreateTexture(2048, 2048, 256 Or 16 Or 32)
EntityTexture Quad, Texture
EntityFX Quad, 1
CameraRange Cam, 0.01, 100
TranslateEntity Cam, 1.0 / 2048 ,-1.0 / 2048 ,-1.0
EntityParent Quad, Cam, 1
HidePointer()

Local ScaledGraphicHeight%
Local Ratio# = Float(RealGraphicWidth)/Float(RealGraphicHeight)
If Ratio>1.76 And Ratio<1.78
Local Ratio# = Float(RealGraphicWidth) / Float(RealGraphicHeight)
If Ratio>1.76 And Ratio<1.78 Then
ScaledGraphicHeight = RealGraphicHeight
DebugLog "Not Scaled"
Else
ScaledGraphicHeight% = Float(RealGraphicWidth)/(16.0/9.0)
DebugLog "Scaled: "+ScaledGraphicHeight
ScaledGraphicHeight = Float(RealGraphicWidth)/(16.0/9.0)
EndIf
Local MovieFile$,i%
Local StartupPath$ = "GFX\menu\"

Local moviefile$ = "GFX\menu\startup_Undertow"
BlitzMovie_Open(moviefile$+".avi") ;Get movie size
Local moview = BlitzMovie_GetWidth()
Local movieh = BlitzMovie_GetHeight()
BlitzMovie_Close()
Local image = CreateImage(moview, movieh)
Local SplashScreenVideo = BlitzMovie_OpenDecodeToImage(moviefile$+".avi", image, False)
SplashScreenVideo = BlitzMovie_Play()
Local SplashScreenAudio = StreamSound_Strict(moviefile$+".ogg",SFXVolume,0)
Repeat
Cls
ProjectImage(image, RealGraphicWidth, ScaledGraphicHeight, Quad, Texture)
Flip
Until (GetKey() Or (Not IsStreamPlaying_Strict(SplashScreenAudio)))
StopStream_Strict(SplashScreenAudio)
BlitzMovie_Stop()
BlitzMovie_Close()
FreeImage image

Cls
Flip

moviefile$ = "GFX\menu\startup_TSS"
BlitzMovie_Open(moviefile$+".avi") ;Get movie size
moview = BlitzMovie_GetWidth()
movieh = BlitzMovie_GetHeight()
BlitzMovie_Close()
image = CreateImage(moview, movieh)
SplashScreenVideo = BlitzMovie_OpenDecodeToImage(moviefile$+".avi", image, False)
SplashScreenVideo = BlitzMovie_Play()
SplashScreenAudio = StreamSound_Strict(moviefile$+".ogg",SFXVolume,0)
Repeat
Cls
ProjectImage(image, RealGraphicWidth, ScaledGraphicHeight, Quad, Texture)
Flip
Until (GetKey() Or (Not IsStreamPlaying_Strict(SplashScreenAudio)))
StopStream_Strict(SplashScreenAudio)
BlitzMovie_Stop()
BlitzMovie_Close()

FreeTexture Texture
FreeEntity Quad
FreeEntity Cam
FreeImage image
Cls
Flip

End Function

Function ProjectImage(img, w#, h#, Quad%, Texture%)

Local img_w# = ImageWidth(img)
Local img_h# = ImageHeight(img)
If img_w > 2048 Then img_w = 2048
If img_h > 2048 Then img_h = 2048
If img_w < 1 Then img_w = 1
If img_h < 1 Then img_h = 1

If w > 2048 Then w = 2048
If h > 2048 Then h = 2048
If w < 1 Then w = 1
If h < 1 Then h = 1

Local w_rel# = w# / img_w#
Local h_rel# = h# / img_h#
Local g_rel# = 2048.0 / Float(RealGraphicWidth)
Local dst_x = 1024 - (img_w / 2.0)
Local dst_y = 1024 - (img_h / 2.0)
CopyRect 0, 0, img_w, img_h, dst_x, dst_y, ImageBuffer(img), TextureBuffer(Texture)
ScaleEntity Quad, w_rel * g_rel, h_rel * g_rel, 0.0001
RenderWorld()

End Function

Function CreateQuad()

mesh = CreateMesh()
surf = CreateSurface(mesh)
v0 = AddVertex(surf,-1.0, 1.0, 0, 0, 0)
v1 = AddVertex(surf, 1.0, 1.0, 0, 1, 0)
v2 = AddVertex(surf, 1.0,-1.0, 0, 1, 1)
v3 = AddVertex(surf,-1.0,-1.0, 0, 0, 1)
AddTriangle(surf, v0, v1, v2)
AddTriangle(surf, v0, v2, v3)
UpdateNormals mesh
Return mesh

For i = 0 To 1
Select i
Case 0
;[Block]
MovieFile=StartupPath+"startup_Undertow"
;[End Block]
Case 1
;[Block]
MovieFile=StartupPath+"startup_TSS"
;[End Block]
End Select
Local Movie%=OpenMovie(MovieFile+".avi")
If (Not Movie) Then
PutINIValue("options.ini","options","play startup video", 0)
RuntimeError("Movie "+Chr(34)+MovieFile+Chr(34)+" not found.")
EndIf
Local SplashScreenAudio% = StreamSound_Strict(MovieFile+".ogg",SFXVolume,0)
Repeat
Cls()
DrawMovie(Movie,0,(RealGraphicHeight/2-ScaledGraphicHeight/2),RealGraphicWidth,ScaledGraphicHeight)
Flip()
Until (GetKey() Or (Not IsStreamPlaying_Strict(SplashScreenAudio)))
StopStream_Strict(SplashScreenAudio)
CloseMovie(Movie)
Cls()
Flip()
Next
ShowPointer()
End Function

Function CanUseItem(canUseWithHazmat%, canUseWithGasMask%, canUseWithEyewear%)
Expand Down