Login to ZARP





View BBCode Back »

Warning: Spoiler! [ Click to expand ]


Please be patient I'm stupid, try:
local MenuGradient = Material( "html/img/gradient.png", "nocull smooth" )

local Images = {}

local Active = nil
local Outgoing = nil
local ImageIndex = 1

local function Think( tbl )

	tbl.Angle = tbl.Angle + ( tbl.AngleVel * FrameTime() )
	tbl.Size = tbl.Size + ( ( tbl.SizeVel / tbl.Size) * FrameTime() )

	if ( tbl.AlphaVel ) then
		tbl.Alpha = tbl.Alpha - tbl.AlphaVel * FrameTime()
	end

	if ( tbl.DieTime > 0 ) then
		tbl.DieTime = tbl.DieTime - FrameTime()

		if ( tbl.DieTime <= 0 ) then
			ChangeBackground()

			if ImageIndex + 1 > #Images then
				ImageIngex = 1
			else
				ImageIndex = ImageIndex + 1
			end
			
		end
	end

end

local function Render( tbl )

	surface.SetMaterial( tbl.mat )
	surface.SetDrawColor( 255, 255, 255, tbl.Alpha )

	local w = ScrH() * tbl.Size * tbl.Ratio
	local h = ScrH() * tbl.Size

	local x = ScrW() * 0.5
	local y = ScrH() * 0.5

	surface.DrawTexturedRectRotated( x, y, w, h, tbl.Angle )

end

local function ShouldBackgroundUpdate()

	return !IsInGame() && !IsInLoading()

end

function DrawBackground()

	if ( ShouldBackgroundUpdate() ) then

		if ( Active ) then
			Think( Active )
			Render( Active )
		end 

		if ( Outgoing ) then

			Think( Outgoing )
			Render( Outgoing )

		end

	end

	surface.SetMaterial( MenuGradient )
	surface.SetDrawColor( 255, 255, 255, 255 )
	surface.DrawTexturedRect( 0, 0, 0, ScrH() )

end

function ClearBackgroundImages( img )

	Images = {}

end

function AddBackgroundImage( img )

	table.insert( Images, img )

end

local LastGamemode = "none"

function ChangeBackground( currentgm )

	if ( !ShouldBackgroundUpdate() ) then return end -- Don't try to load new images while in-game or loading

	if ( currentgm && currentgm == LastGamemode ) then return end
	if ( currentgm ) then LastGamemode = currentgm end

	local img = Images[ImageIndex]

	if ( !img ) then return end

	-- Remove the texture from memory
	-- There's a bit of internal magic going on here
	--[[
	local DoUnload = Outgoing != nil

	if ( Outgoing && Outgoing.Name == img ) then
		DoUnload = false
	end

	if ( Outgoing && Active && Outgoing.Name == Active.Name ) then
		DoUnload = false
	end

	if ( DoUnload ) then
		Outgoing.mat:SetUndefined( "$basetexture" )
	end
	]]

	Outgoing = Active
	if ( Outgoing ) then
		Outgoing.AlphaVel = 0
	end

	local mat = Material( img, "nocull smooth" )
	if ( !mat || mat:IsError() ) then return end

	Active = {
		Ratio = mat:GetInt( "$realwidth" ) / mat:GetInt( "$realheight" ),
		Size = 1,
		Angle = 0,
		AngleVel = -( 0 / 30 ),
		SizeVel = ( 0 / 30 ),
		Alpha = 255,
		DieTime = 0.1,
		mat = mat,
		Name = img
	}

	if ( Active.Ratio < ScrW() / ScrH() ) then

		Active.Size = Active.Size + ( ( ScrW() / ScrH() ) - Active.Ratio )

	end

end

BBCode


Time to create page: 0.147 seconds

257 PLAYERS ONLINE

Connect to server View Gametracker DarkRP
17/127
Online
Connect to server View Gametracker Deathrun
0/40
Online
Connect to server View Gametracker TTT
0/47
Online
Connect to server View Gametracker Bhop
0/32
Online
Connect to server View Gametracker Surf
0/32
Online
Connect to server View Gametracker Prop Hunt
0/42
Online
Connect to server View Gametracker Sandbox
0/42
Online
Connect to server Discord
240/963
Online
Top