@namespace MenuProject.Modals @inherits MenuProject.Modals.BaseModal @using Sandbox; @using Sandbox.UI; @using Menu; @using System; @using Sandbox.Modals; @using Sandbox.DataModel;
room_preferences
arrow_forward_ios
CurrentTabName = null ) class="@ActiveClass( null )">General
@foreach ( var group in Settings.GroupBy( x => x.Group ) ) { @if ( group.Key == "General" || group.Key == null ) continue;
CurrentTabName = group.Key ) class="@ActiveClass( group.Key )">@GetGroupName( group.Key )
}
@{ var settings = Settings .Where( x => x.Group == CurrentTabName && Output.GameSettings.ContainsKey( x.Name ) ) .ToList(); } @if ( CurrentTabName == null || CurrentTabName == "General" ) { @if ( IsMultiplayerGame ) {
Server Name
Privacy
Max Players
} if ( NeedsMap() ) {
Map
} } @foreach ( var e in settings ) {
@e.Title.ToTitleCase()
@if ( IsCheckbox( e ) ) { { Output.GameSettings[e.Name] = x.ToString(); }) /> } else if ( IsNumeric( e, out var flValue ) ) { @if ( e.Max is not null ) { { Output.GameSettings[e.Name] = x.ToString(); }) class="glass with-grow" Min="@(e.Min ?? 0)" Max="@(e.Max ?? 100)" Step="@(e.Step ?? 1)" /> } else { { Output.GameSettings[e.Name] = x; }) /> } } else if ( HasOptions( e ) ) { { Output.GameSettings[e.Name] = x; }) BuildOptions=@( () => GetOptions(e) )> }
}
@code { public List Settings { get; set; } public Package MapPackage { get; set; } public Sandbox.Network.LobbyPrivacy Privacy { get; set; } public Action OnComplete { get; set; } CreateGameResults Output { get; set; } Package Package { get; set; } string CookieName => $"{Package.FullIdent}_create_game_config"; string CurrentTabName; // // Multiplayer Settings // int MaxPlayers => Package.GetMeta( "MaxPlayers", 1 ); int MinPlayers => Package.GetMeta( "MinPlayers", 1 ); bool IsMultiplayerGame => Package.Tags.Contains( "multiplayer" ) || Package.GetMeta( "MaxPlayers", 1 ) > 1; string ServerName { get; set; } int Players { get; set; } public CreateGameModal( Sandbox.Modals.CreateGameOptions options ) { Package = options.Package; OnComplete = options.OnComplete; // // Check if we have a saved config // Output = Game.Cookies.Get( CookieName, new() { MaxPlayers = MinPlayers, ServerName = $"{Sandbox.Utility.Steam.PersonaName}'s game" } ); // // Apply config / defaults // Players = Output.MaxPlayers; ServerName = Output.ServerName; Settings = Package.GetMeta( "GameSettings", new List() ); SetMap( Output.MapIdent ?? Package.GetValue( "DefaultMap", "" ) ); } private async void SetMap( string ident ) { if ( !string.IsNullOrWhiteSpace( ident ) ) { MapPackage = await Package.FetchAsync( ident, false ); } } List