Ejemplo n.º 1
0
        public ViewRegistry(ITextUI ui)
        {
            TextClient GetGame() => ui.Game;

            ui.RegisterMainView(Exception     = new ExceptionView(), "exception");
            ui.RegisterMainView(Auth          = new AuthView(), "auth", "authentication", "login");
            ui.RegisterMainView(Home          = new HomeView(CommandContext.HOME.Set(), 60, 2, GetGame), "home");
            ui.RegisterSideView(GameModes     = new ListView(" # Game Modes", () => ui.Game.ActiveGameModes.Select(gm => ui.Game.Resources.GetMetadata(gm)).Where(gm => gm.PermissionLevel <= ui.Game.PermissionLevel).Select(gm => (FormattedString)gm.Name), CommandContext.HOME.Set(), 25), "modes", "gamemodes", "game modes");
            ui.RegisterSideView(Settings      = new SettingsView(GetGame), "settings", "options");
            ui.RegisterSideView(Friends       = new ListView(" # Friends", () => ui.Game.Friends.Values.Select(f => f.ToDisplay()), CommandContext.HOME.Set(), 22), "friends", "friendlist", "friend list");
            ui.RegisterSideView(Notifications = new ListView(" # Notifications", () => ui.Game.PendingFriendRequests.Keys.Select(fr => (FormattedString)string.Format("FR {0}", fr)).Concat(ui.Game.PendingPartyInvitations.Keys.Select(pi => (FormattedString)string.Format("PI {0}", pi))), CommandContext.HOME.Set(), 23), "notifications");
            ui.RegisterSideView(Party         = new PartyView(CommandContext.HOME.Set().And(c => ui.Game.Party != null), GetGame), "party");
            ui.RegisterMainView(Game          = new GameView(CommandExtensions.IsInLobbyOrGame, 60, 20, GetGame), "game");
            ui.RegisterSideView(Players       = new ListView(" # Players", () => ui.Game.GameState.Players.Select(ps => (FormattedString)(ps.Dead ? "" : ui.Game.GameState.ToName(ps.ID, true))), CommandExtensions.IsInLobbyOrGame, 25), "players", "playerlist", "player list");
            ui.RegisterSideView(Roles         = new ListView(" # Roles", () => ui.Game.GameState.Roles.Select(r => ui.Game.Resources.Of(r)), CommandExtensions.IsInLobbyOrGame, 25), "roles", "rolelist", "role list");
            ui.RegisterSideView(Graveyard     = new ListView(" # Graveyard", () => ui.Game.GameState.Graveyard.Select(ps => ui.Game.GameState.ToName(ps, true)), CommandExtensions.IsInGame, 40), "graveyard", "deaths");
            ui.RegisterSideView(Team          = new ListView(" # Team", () => ui.Game.GameState.Team.Select(ps => !ps.Dead || ps.Role == Role.DISGUISER ? ui.Game.GameState.ToName(ps, true) : ""), CommandExtensions.IsInGame, 40), "team", "teammates");
            ui.RegisterSideView(LastWill      = new WillView(CommandExtensions.IsInGame), "lw", "dn", "lastwill", "deathnote", "last will", "death note");
            ui.RegisterSideView(Winners       = new ListView(" # Winners", () => ui.Game.GameState.Winners.Select(p => (FormattedString)ui.Game.GameState.ToName(p, true)), CommandContext.GAME_END.Set(), 25), "winners", "winnerlist", "winner list");
            ui.RegisterSideView(MyLastWill    = new EditableWillView(CommandExtensions.IsInGame), "mlw", "mylastwill", "my lastwill", "my last will");
            ui.RegisterSideView(MyDeathNote   = new EditableWillView(context => CommandExtensions.IsInGame(context) && ui.Game.GameState.Role.HasDeathNote()), "mdn", "mydeathnote", "my deathnote", "my death note");
            ui.RegisterSideView(MyForgedWill  = new EditableWillView(context => CommandExtensions.IsInGame(context) && ui.Game.GameState.Role == Role.FORGER), "mfw", "myforgedwill", "my forgedwill", "my forged will");
            ui.RegisterSideView(Help          = new HelpView(ui.Commands, () => ui.CommandContext, 40, 1), "?", "h", "help");
        }