Files
sbox-public/engine/Sandbox.Menu/GameCreateHistory.cs
s&box team 71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00

44 lines
1.1 KiB
C#

using Sandbox.Engine;
namespace Sandbox.Internal;
public partial class GameCreateHistory
{
public Package Package { get; set; }
public Dictionary<string, string> Config { get; set; }
internal static void OnCreateGame( Package game, Dictionary<string, string> details )
{
GlobalContext.AssertMenu();
var list = GetHistory();
list.RemoveAll( x => x.Package == null || x.Package.FullIdent == game.FullIdent );
while ( list.Count > 10 )
list.RemoveAt( list.Count - 1 );
list.Insert( 0, new GameCreateHistory() { Package = game, Config = details } );
Game.Cookies.Set( "created_games", list );
Game.Cookies.Save();
}
public static List<GameCreateHistory> GetHistory()
{
GlobalContext.AssertMenu();
return Game.Cookies.Get<List<GameCreateHistory>>( "created_games", null ) ?? new List<GameCreateHistory>();
}
public static void Remove( string ident )
{
GlobalContext.AssertMenu();
var list = GetHistory();
list.RemoveAll( x => x.Package.FullIdent == ident );
Game.Cookies.Set( "created_games", list );
Game.Cookies.Save();
}
}