private void AddConsoleText(string text, bool draw = true) { DisplayContent waiting = GetBroadcast(GameState.Waiting).Content; DisplayContent editing = GetBroadcast(GameState.Editing).Content; waiting.GetGroup(LobbyVars.Console).Append(text); editing.GetGroup(LobbyVars.Console).Append(text); if (!draw) { return; } waiting.GetComponent(LobbyVars.Console).Draw(); editing.GetComponent(LobbyVars.Console).Draw(Name); }
private void DrawGameConfig() { DisplayContent editing = GetBroadcast(GameState.Editing).Content; if (!_manager.Games.ContainsKey(GameId)) { return; } if (!Check.NotNullOrEmpty(Options)) { editing["game_config"].Active = false; return; } editing["game_config"].Active = true; editing["game_config"].Draw( Options.Select(x => $"{x.Name}: **{x.Value}**"), _manager.DetailsOf(GameId).Name); }
public async Task RefreshAsync(bool replacePrevious = false) { if (Destroyed) { throw new Exception("This connection was destroyed"); } if (Paused) { Logger.Debug("Connection paused"); return; } DisplayContent content = State switch { GameState.Watching => Server?.GetSpectatorBroadcast()?.Content, GameState.Playing => Server?.GetBroadcast(Frequency)?.Content, _ => Server?.GetBroadcast(State)?.Content }; string text = Check.NotNull(ContentOverride?.ToString()) ? ContentOverride?.ToString() : content?.ToString() ?? $"> ⚠️ Could not find a channel at the specified frequency ({Frequency})."; if (Message == null || IsDeleted || replacePrevious) { Message = await Channel.SendMessageAsync(text); MessageId = Message.Id; LastRefreshed = DateTime.UtcNow; IsDeleted = false; Logger.Debug("Created replacement message"); return; } // If the time to refresh is less than the specified refresh rate, ignore if (DateTime.UtcNow - LastRefreshed < RefreshRate) { Logger.Debug("Refresh called too quickly"); Content = text; // Store/preserve the existing content; return; } if (RefreshCounter > 0 && CurrentMessageCounter >= RefreshCounter) { if (State == GameState.Watching) { string panel = $"> **{Server?.Name ?? "Unknown Server"}**\n> You are currently spectating the active session.\n{(Check.NotNull(text) ? text : "Unable to load the spectator panel.")}"; text = panel; } Message = await Message.ReplaceAsync(text, deleteLastMessage : DeleteOnRefresh); MessageId = Message.Id; LastRefreshed = DateTime.UtcNow; CurrentMessageCounter = 0; Logger.Debug("Replace message success"); return; } // Don't update if the content is already exactly the same if (Message.Content == text) { Logger.Debug("Duplicate text specified"); return; } await Message.ModifyAsync(text); LastRefreshed = DateTime.UtcNow; Logger.Debug("Connection refresh was called"); } }