Fade in/out animations API added

master
AlmTech Software 5 years ago
parent aa13e54be4
commit 6140e7bf77
  1. 4
      gamemode/engine/derma/cl_menu.lua
  2. 59
      gamemode/engine/derma/lib/cl_menu_fade.lua
  3. 7
      gamemode/engine/derma/lib/cl_menu_theme.lua
  4. 26
      gamemode/engine/derma/menus/menu_character.lua

@ -6,12 +6,14 @@
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/ -- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/
Quantum.Client.Menu = {} Quantum.Client.Menu = {}
Quantum.Client.Menu.Temp = {}
local libs = { local libs = {
["net"] = GM.FolderName .. "/gamemode/engine/derma/lib/cl_network.lua", ["net"] = GM.FolderName .. "/gamemode/engine/derma/lib/cl_network.lua",
["page"] = GM.FolderName .. "/gamemode/engine/derma/lib/cl_menu_pages.lua", ["page"] = GM.FolderName .. "/gamemode/engine/derma/lib/cl_menu_pages.lua",
["theme"] = GM.FolderName .. "/gamemode/engine/derma/lib/cl_menu_theme.lua", ["theme"] = GM.FolderName .. "/gamemode/engine/derma/lib/cl_menu_theme.lua",
["dialogue"] = GM.FolderName .. "/gamemode/engine/derma/lib/cl_menu_dialogueBox.lua", ["dialogue"] = GM.FolderName .. "/gamemode/engine/derma/lib/cl_menu_dialogueBox.lua",
["sure"] = GM.FolderName .. "/gamemode/engine/derma/lib/cl_menu_areusure.lua" ["sure"] = GM.FolderName .. "/gamemode/engine/derma/lib/cl_menu_areusure.lua",
["fade"] = GM.FolderName .. "/gamemode/engine/derma/lib/cl_menu_fade.lua"
} }
Quantum.Client.Menu.GetAPI = function( lib ) return include( libs[lib] ) end Quantum.Client.Menu.GetAPI = function( lib ) return include( libs[lib] ) end

@ -0,0 +1,59 @@
-- __ _ _______ _ __
-- / / /\ | | |__ __| | | \ \
-- / / / \ | |_ __ ___ | | ___ ___| |__ \ \
-- < < / /\ \ | | '_ ` _ \| |/ _ \/ __| '_ \ > >
-- \ \ / ____ \| | | | | | | | __/ (__| | | | / /
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/
local fade = {}
local scale = Quantum.Client.ResolutionScale
local padding = math.Round( 10 * scale )
local padding_s = math.Round( 4 * scale )
local sw, sh = ScrW(), ScrH()
local theme = Quantum.Client.Menu.GetAPI("theme")
function fade.menuTransition( parent, dt, delay, inColor, isBlur, startFunc, endFunc )
startFunc( dt )
local color = inColor || Color( 0, 0, 0, 255 )
local p = vgui.Create( "DPanel" )
p.frac = startFrac || 0
p.time = 0
p.fadeIn = true
p.starttime = CurTime()
p:SetSize( sw, sh )
p:SetPos( 0, 0 )
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.DrawRect( 0, 0, w, h )
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.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.runnedEndFunc ) then
endFunc( dt )
self.runnedEndFunc = true
self:Remove() -- remove the panel when done
end
end
end
end
return fade

@ -94,14 +94,17 @@ end
function theme.sharpblurrbutton( b, inClr ) function theme.sharpblurrbutton( b, inClr )
local w, h = b:GetSize() local w, h = b:GetSize()
inClr = inClr || Color( 80, 80, 80, 150 ) inClr = inClr || Color( 80, 80, 80, 100 )
surface.SetDrawColor( inClr )
surface.DrawRect( 0, 0, w, h )
theme.renderblur( b, 4, 8 ) theme.renderblur( b, 4, 8 )
if( !b:IsHovered() ) then if( !b:IsHovered() ) then
surface.SetDrawColor( 205, 205, 205, 255 ) surface.SetDrawColor( 205, 205, 205, 255 )
else else
surface.SetDrawColor( 120, 120, 120, 255 ) surface.SetDrawColor( 116, 185, 255, 255 )
end end
surface.DrawOutlinedRect( 0, 0, w, h ) surface.DrawOutlinedRect( 0, 0, w, h )
end end

@ -62,14 +62,16 @@ local function checkNameString( name )
return table.concat( strTbl ) -- return the "fixed" name return table.concat( strTbl ) -- return the "fixed" name
end end
local function isFirstTime(char) local function isFirstTime( char )
return char.runIntro || false return char.runIntro || false
end end
local function runIntroCinematic(char) local function runIntroCinematic( parent, char )
if( isFirstTime(char) ) then if( isFirstTime(char) ) then
Quantum.Debug( "Running intro cinematic..." ) Quantum.Debug( "Running intro cinematic..." )
Quantum.Client.Menu.Menus["intro"].open( dt ) -- run the 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
else else
char.runIntro = nil -- remove the unwanted var since it is taking space for no reason char.runIntro = nil -- remove the unwanted var since it is taking space for no reason
end end
@ -190,7 +192,7 @@ local pages = {
gbuttons.female:SetTextColor( Color( 255, 255, 255, 255 ) ) gbuttons.female:SetTextColor( Color( 255, 255, 255, 255 ) )
gbuttons.female:SetFont( "q_button2" ) gbuttons.female:SetFont( "q_button2" )
gbuttons.female.Paint = function( self, w, h ) gbuttons.female.Paint = function( self, w, h )
theme.sharpbutton( self, Color( 0, 0, 0, 0 ) ) theme.sharpblurrbutton( self, Color( 0, 0, 0, 0 ) )
renderSelectedButton( self, selectedGenderButton == self ) renderSelectedButton( self, selectedGenderButton == self )
end end
gbuttons.female:SizeToContents() gbuttons.female:SizeToContents()
@ -215,7 +217,7 @@ local pages = {
gbuttons.male:SetPos( padding + gbuttons.male.w/2, rheader.y + gbuttons.male.h + padding ) gbuttons.male:SetPos( padding + gbuttons.male.w/2, rheader.y + gbuttons.male.h + padding )
gbuttons.male.Paint = function( self, w, h ) gbuttons.male.Paint = function( self, w, h )
theme.sharpbutton( self, Color( 0, 0, 0, 0 ) ) theme.sharpblurrbutton( self, Color( 0, 0, 0, 0 ) )
renderSelectedButton( self, selectedGenderButton == self ) renderSelectedButton( self, selectedGenderButton == self )
end end
gbuttons.male.DoClick = function( self ) gbuttons.male.DoClick = function( self )
@ -249,7 +251,7 @@ local pages = {
classButtons[classCount].w, classButtons[classCount].h = classButtons[classCount]:GetSize() classButtons[classCount].w, classButtons[classCount].h = classButtons[classCount]:GetSize()
classButtons[classCount]:SetPos( cscroll.w/2 - classButtons[classCount].w/2, (classCount-1) * ( padding + classButtons[classCount].h ) ) classButtons[classCount]:SetPos( cscroll.w/2 - classButtons[classCount].w/2, (classCount-1) * ( padding + classButtons[classCount].h ) )
classButtons[classCount].Paint = function( self ) classButtons[classCount].Paint = function( self )
theme.sharpbutton( self, Color( 0, 0, 0, 0 ) ) theme.sharpblurrbutton( self, Color( 0, 0, 0, 0 ) )
renderSelectedButton( self, inputs.class == self.class ) renderSelectedButton( self, inputs.class == self.class )
end end
classButtons[classCount].DoClick = function( self ) classButtons[classCount].DoClick = function( self )
@ -268,7 +270,7 @@ local pages = {
pmodel:SizeToContents() pmodel:SizeToContents()
pmodel.w, pmodel.h = pmodel:GetSize() pmodel.w, pmodel.h = pmodel:GetSize()
pmodel:SetPos( (mdl.x - pmodel.w) + padding*10, (mdl.y + mdl.h/2) - pmodel.h/2 ) pmodel:SetPos( (mdl.x - pmodel.w) + padding*10, (mdl.y + mdl.h/2) - pmodel.h/2 )
pmodel.Paint = function( self ) theme.sharpbutton( self, Color( 0, 0, 0, 100 ) ) end pmodel.Paint = function( self ) theme.sharpblurrbutton( self, Color( 0, 0, 0, 100 ) ) end
pmodel.DoClick = function( self ) pmodel.DoClick = function( self )
surface.PlaySound( "UI/buttonclick.wav" ) surface.PlaySound( "UI/buttonclick.wav" )
inputs.modelIndex = getNextIndex( inputs.modelIndex, false, 1, #getClassModels( inputs.class )[inputs.gender] ) inputs.modelIndex = getNextIndex( inputs.modelIndex, false, 1, #getClassModels( inputs.class )[inputs.gender] )
@ -281,7 +283,7 @@ local pages = {
nmodel:SetSize( pmodel.w, pmodel.h ) nmodel:SetSize( pmodel.w, pmodel.h )
nmodel.w, nmodel.h = nmodel:GetSize() nmodel.w, nmodel.h = nmodel:GetSize()
nmodel:SetPos( (mdl.x + mdl.w) - padding*10, (mdl.y + mdl.h/2) - nmodel.h/2 ) nmodel:SetPos( (mdl.x + mdl.w) - padding*10, (mdl.y + mdl.h/2) - nmodel.h/2 )
nmodel.Paint = function( self ) theme.sharpbutton( self, Color( 0, 0, 0, 100 ) ) end nmodel.Paint = function( self ) theme.sharpblurrbutton( self, Color( 0, 0, 0, 100 ) ) end
nmodel.DoClick = function( self ) nmodel.DoClick = function( self )
surface.PlaySound( "UI/buttonclick.wav" ) surface.PlaySound( "UI/buttonclick.wav" )
inputs.modelIndex = getNextIndex( inputs.modelIndex, true, 1, #getClassModels( inputs.class )[inputs.gender] ) inputs.modelIndex = getNextIndex( inputs.modelIndex, true, 1, #getClassModels( inputs.class )[inputs.gender] )
@ -586,7 +588,7 @@ function menu.open( dt )
cr.w, cr.h = cr:GetSize() cr.w, cr.h = cr:GetSize()
cr:SetPos( Quantum.Client.CharMenuList.x + ( Quantum.Client.CharMenuList.w/2 - cr.w/2 ), Quantum.Client.CharMenuList.y + ( ( Quantum.Client.CharMenuList.h - cr.h ) - padding*2 ) ) cr:SetPos( Quantum.Client.CharMenuList.x + ( Quantum.Client.CharMenuList.w/2 - cr.w/2 ), Quantum.Client.CharMenuList.y + ( ( Quantum.Client.CharMenuList.h - cr.h ) - padding*2 ) )
cr.Paint = function( self ) cr.Paint = function( self )
theme.sharpbutton( self ) theme.sharpblurrbutton( self )
end end
cr.Think = function( self ) cr.Think = function( self )
if( table.Count(Quantum.Client.Chars) >= Quantum.CharacterLimit ) then if( table.Count(Quantum.Client.Chars) >= Quantum.CharacterLimit ) then
@ -630,11 +632,11 @@ function menu.open( dt )
p.enter = vgui.Create( "DButton", p ) p.enter = vgui.Create( "DButton", p )
p.enter:SetText( "Enter World" ) p.enter:SetText( "Enter World" )
p.enter:SetFont( "q_button2" ) p.enter:SetFont( "q_button2" )
p.enter:SetTextColor( Color( 0, 0, 0, 255 ) ) p.enter:SetTextColor( Color( 255, 255, 255, 255 ) )
p.enter:SizeToContents() p.enter:SizeToContents()
p.enter.w, p.enter.h = p.enter:GetSize() p.enter.w, p.enter.h = p.enter:GetSize()
p.enter:SetPos( p.w/2 - p.enter.w/2, p.h*0.925 - p.enter.h/2 ) p.enter:SetPos( p.w/2 - p.enter.w/2, p.h*0.925 - p.enter.h/2 )
p.enter.Paint = function( self ) theme.sharpbutton( self ) end p.enter.Paint = function( self ) theme.sharpblurrbutton( self ) end
p.enter.DoClick = function() p.enter.DoClick = function()
surface.PlaySound( "UI/buttonclick.wav" ) surface.PlaySound( "UI/buttonclick.wav" )
-- enter world -- -- enter world --
@ -643,7 +645,7 @@ function menu.open( dt )
f:Close() -- close the frame f:Close() -- close the frame
-- Open the intro cinematic -- Open the intro cinematic
runIntroCinematic( Quantum.Client.selectedChar.char ) -- run the cinematic if it is the first time runIntroCinematic( f, Quantum.Client.selectedChar.char ) -- run the cinematic if it is the first time
-- else do nothing -- else do nothing
end end

Loading…
Cancel
Save