//// public static string RenderMarkdownPlayersTable() { IDictionary <string, string> playerInfos = null; string columns = ""; int cols = 0; for (int i = 0; i < Main.player.Length; i++) { Player plr = Main.player[i]; if (plr == null || !plr.active) { continue; } playerInfos = InfoHelpers.GetPlayerInfo(plr); cols = playerInfos.Count > cols ? playerInfos.Count : cols; playerInfos["Name"] = FormattingHelpers.SanitizeMarkdown(playerInfos["Name"]); columns += "| " + string.Join(" | ", playerInfos.Values) + " |"; } string header = "| " + string.Join(" | ", playerInfos.Keys) + " |"; string subheader = "|"; for (int i = 0; i < cols; i++) { subheader += " :--- |"; } return(header + "\n" + subheader + "\n" + columns); }
public static string RenderMarkdownPlayerEquipsTable(Player player) { IDictionary <string, string> playerEquips = InfoHelpers.GetPlayerEquipment(player); int cols = playerEquips.Count; string playerLabel = "**Player " + FormattingHelpers.SanitizeMarkdown(player.name) + "'s (" + player.whoAmI + ") equipment:**"; string equipsLabels = cols > 0 ? string.Join(" | ", playerEquips.Keys) : "-"; string header = "| " + equipsLabels + " |"; string subheader = "|"; if (cols > 0) { for (int i = 0; i < cols; i++) { subheader += " :--- |"; } } else { subheader += " :--- |"; } string equips = string.Join(" | ", playerEquips.Values.SafeSelect(e => FormattingHelpers.SanitizeMarkdown(e))); string equipsCols = cols > 0 ? equips : "-"; string columns = "| " + equipsCols + " |"; return(playerLabel + "\n \n" + header + "\n" + subheader + "\n" + columns); }
public static IList <string> GetGameData(IEnumerable <Mod> mods) { var list = new List <string>(); var modsList = mods.OrderBy(m => m.Name) .SafeSelect(m => FormattingHelpers.SanitizeMarkdown(m.DisplayName) + " " + m.Version.ToString()) .ToArray(); bool isDay = Main.dayTime; double timeOfDay = Main.time; int halfDays = WorldHelpers.WorldStateHelpers.GetElapsedHalfDays(); string worldSize = WorldHelpers.WorldHelpers.GetSize().ToString(); string[] worldProg = InfoHelpers.GetWorldProgress().ToArray(); int activeItems = ItemHelpers.ItemHelpers.GetActive().Count; int activeNpcs = NPCHelpers.NPCHelpers.GetActive().Count; //string[] playerInfos = InfoHelpers.GetCurrentPlayerInfo().ToArray(); //string[] playerEquips = InfoHelpers.GetCurrentPlayerEquipment().ToArray(); int activePlayers = Main.ActivePlayersCount; string netmode = Main.netMode == 0 ? "single-player" : "multiplayer"; bool autopause = Main.autoPause; bool autosave = Main.autoSave; int lighting = Lighting.lightMode; int lightingThreads = Lighting.LightingThreads; int frameSkipMode = Main.FrameSkipMode; bool isMaximized = Main.screenMaximized; int windowWid = Main.screenWidth; int windowHei = Main.screenHeight; int qualityStyle = Main.qaStyle; bool bgOn = Main.BackgroundEnabled; bool childSafe = !ChildSafety.Disabled; float gameZoom = Main.GameZoomTarget; float uiZoom = Main.UIScale; list.Add(InfoHelpers.RenderMarkdownModTable(modsList)); list.Add(InfoHelpers.RenderMarkdownPlayersTable()); for (int i = 0; i < Main.player.Length; i++) { Player plr = Main.player[i]; if (plr == null || !plr.active) { continue; } list.Add(InfoHelpers.RenderMarkdownPlayerEquipsTable(plr)); } list.Add("Is day: " + isDay + ", Time of day/night: " + timeOfDay + ", Elapsed half days: " + halfDays); //+ ", Total time (seconds): " + Main._drawInterfaceGameTime.TotalGameTime.Seconds; list.Add("World name: " + FormattingHelpers.SanitizeMarkdown(Main.worldName) + ", world size: " + worldSize); list.Add("World progress: " + (worldProg.Length > 0 ? string.Join(", ", worldProg) : "none")); list.Add("Items on ground: " + activeItems + ", Npcs active: " + activeNpcs); //list.Add( "Player info: " + string.Join( ", ", playerInfos ) ); //list.Add( "Player equips: " + (playerEquips.Length > 0 ? string.Join(", ", playerEquips) : "none" ) ); list.Add("Player count: " + activePlayers + " (" + netmode + ")"); list.Add("Autopause: " + autopause); list.Add("Autosave: " + autosave); list.Add("Lighting mode: " + lighting); list.Add("Lighting threads: " + lightingThreads); list.Add("Frame skip mode: " + frameSkipMode); list.Add("Is screen maximized: " + isMaximized); list.Add("Screen resolution: " + windowWid + " " + windowHei); list.Add("Quality style: " + qualityStyle); list.Add("Background on: " + bgOn); list.Add("Child safety: " + childSafe); list.Add("Game zoom: " + gameZoom); list.Add("UI zoom: " + uiZoom); return(list); }
public static string RenderModTable(string[] mods) { return(InfoHelpers.RenderMarkdownModTable(mods)); }