diff --git a/gamemode/engine/derma/lib/cl_menu_fade.lua b/gamemode/engine/derma/lib/cl_menu_fade.lua index 4ba4cc9..0e77ec1 100644 --- a/gamemode/engine/derma/lib/cl_menu_fade.lua +++ b/gamemode/engine/derma/lib/cl_menu_fade.lua @@ -15,9 +15,11 @@ local sw, sh = ScrW(), ScrH() local theme = Quantum.Client.Menu.GetAPI("theme") -function fade.menuTransition( parent, dt, delay, inColor, isBlur, startFunc, endFunc ) +local function changeAlpha( clr, alpha ) + return Color( clr.r, clr.g, clr.b, alpha ) +end - startFunc( dt ) +function fade.transition( parent, dt, start_delay, mid_delay, end_delay, inColor, isBlur, startFunc, endFunc ) local color = inColor || Color( 0, 0, 0, 255 ) local p = vgui.Create( "DPanel" ) @@ -27,12 +29,11 @@ function fade.menuTransition( parent, dt, delay, inColor, isBlur, startFunc, end p.starttime = CurTime() p:SetSize( sw, sh ) p:SetPos( 0, 0 ) + p:MakePopup() -- make it so the player cant move around p.Paint = function( self, w, h ) if( isBlur ) then theme.renderblur( self, Lerp( self.frac, 0, 4 ), Lerp( self.frac, 0, 8 ) ) end -- render blur - - surface.SetDrawColor( color ) - surface.SetAlphaMultiplier( self.frac ) + surface.SetDrawColor( changeAlpha( color, 255 * self.frac ) ) surface.DrawRect( 0, 0, w, h ) end @@ -40,18 +41,42 @@ function fade.menuTransition( parent, dt, delay, inColor, isBlur, startFunc, end p.Think = function( self ) self.time = CurTime() - self.starttime - if( self.fadeIn ) then self.frac = math.Clamp( self.time / delay, 0, 1 ) else self.frac = math.Clamp( self.time / delay, 1, 0 ) end + if( self.fadeIn ) then self.frac = Lerp( self.time / start_delay, 0, 1 ) else self.frac = Lerp( self.time / end_delay, 1, 0 ) end + + if( self.time >= start_delay && self.fadeIn ) then - if( self.time >= delay && self.fadeIn ) then - self.fadeIn = false -- reset the timer and invert the fading process - self.time = 0 parent:Remove() -- remove the parent - elseif( self.time >= delay && !self.fadeIn ) then + + if( !self.recordedMidStart ) then + self.midtrans_start = CurTime() + self.recordedMidStart = true + end + + if( !self.runnedStartFunc ) then + if( CurTime() - self.midtrans_start >= mid_delay ) then + startFunc( dt ) + self.runnedStartFunc = true + + self.fadeIn = false -- reset the timer and invert the fading process + self.time = 0 + self.frac = 0 + self.starttime = CurTime() + end + end + + Quantum.Debug("[Fade] First part done.") + + elseif( self.time >= end_delay && !self.fadeIn ) then + if( !self.runnedEndFunc ) then + endFunc( dt ) self.runnedEndFunc = true self:Remove() -- remove the panel when done + Quantum.Debug( "[Fade] Finished transition." ) + end + end end end diff --git a/gamemode/engine/derma/menus/menu_character.lua b/gamemode/engine/derma/menus/menu_character.lua index eaf8a7f..719fc4e 100644 --- a/gamemode/engine/derma/menus/menu_character.lua +++ b/gamemode/engine/derma/menus/menu_character.lua @@ -71,8 +71,7 @@ local function runIntroCinematic( parent, char ) if( isFirstTime(char) ) then Quantum.Debug( "Running intro cinematic..." ) - fade.menuTransition( parent, {}, 1, Color( 0,0,0,255 ), true, function() print("START FUNC") end, function() Quantum.Client.Menu.Menus["intro"].open( {} ) end) - --Quantum.Client.Menu.Menus["intro"].open( dt ) -- run the cinematic + fade.transition( parent, {}, 4, 1, 4, Color( 0,0,0,255 ), true, function() Quantum.Client.Menu.Menus["intro"].open( {} ) end, Quantum.EmptyFunction ) -- run the cinematic via fade in thing else char.runIntro = nil -- remove the unwanted var since it is taking space for no reason end @@ -643,7 +642,7 @@ function menu.open( dt ) -- enter world -- local dt = { index = Quantum.Client.selectedChar.index } snm.RunNetworkedFunc( "enterWorldChar", dt ) -- FIX CRASH ISSUE ( 0xC00000FD ) - f:Close() -- close the frame + if( !isFirstTime( Quantum.Client.selectedChar.char ) ) then f:Close() end -- close the frame -- Open the intro cinematic runIntroCinematic( f, Quantum.Client.selectedChar.char ) -- run the cinematic if it is the first time diff --git a/gamemode/shared.lua b/gamemode/shared.lua index b99bad3..5f4af6e 100644 --- a/gamemode/shared.lua +++ b/gamemode/shared.lua @@ -11,7 +11,9 @@ GM.Email = "elias@almtech.se" GM.Website = "N/A" Quantum = {} -Quantum.Version = "v0.1-alpha" +Quantum.Version = "v0.2-alpha" + +Quantum.EmptyFunction = function() end include( "engine/sh_debug.lua" ) -- add the debug functions and stuff