Skip to content

Instantly share code, notes, and snippets.

@samisalreadytaken
Last active January 4, 2023 19:12
Show Gist options
  • Save samisalreadytaken/4847ede81a7222b66dc82eac8622904e to your computer and use it in GitHub Desktop.
Save samisalreadytaken/4847ede81a7222b66dc82eac8622904e to your computer and use it in GitHub Desktop.
const SaveIconDisplayTime = 1.25;
const SaveIconFadeTime = 0.75;
if ( CLIENT_DLL )
{
local Time = Time;
local panel, dieTime = 0.0;
local ThinkFadeOut = function(w)
{
local a = 1.0 - (Time() - dieTime) / SaveIconFadeTime;
if ( a > 0.0 )
{
SetAlpha( a * 255.0 );
return 0.0;
}
return Destroy();
}
Hooks.Add( this, "OnSave", function()
{
dieTime = Time() + SaveIconDisplayTime;
if ( panel && panel.IsValid() )
{
panel.SetAlpha( 255 );
}
else
{
local size = YRES(22);
panel = vgui.CreatePanel( "ImagePanel", vgui.GetRootPanel(), "SaveIcon" );
panel.MakeReadyForUse();
panel.SetPos( XRES(640) - size - XRES(64), YRES(64) );
panel.SetSize( size, size );
panel.SetImage( "vgui/hud/spinner_saving_anim", false ); // from Portal 2
panel.SetShouldScaleImage( true );
Entities.First().SetContextThink( "SaveIconThinkFadeOut", ThinkFadeOut.bindenv(panel), SaveIconDisplayTime );
}
}, "SaveIcon" );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment