public LedgerRecord GetLedgerRecord(string username, Service service) { Viewer viewer; if (ViewerController.ViewerExists(service, username)) { viewer = ViewerController.GetViewer(service, username); } else { viewer = ViewerController.CreateViewer(service, username, 0); } LedgerRecord ledgerRecord; ledgerRecord = LedgerRecords.Find((lr) => lr.Username == username && lr.Service == service); if (ledgerRecord == null) { ledgerRecord = new LedgerRecord() { Username = username, Service = service, PointBalance = 0 }; } return(ledgerRecord); }
public static List <Viewer> FindViewersInChatterWrapper() { ChatterWrapper chatterWrapper = JsonConvert.DeserializeObject <ChatterWrapper>(TwitchAPI.lastChatterDownload); List <Viewer> chatterNames = new List <Viewer>(); List <string[]> chatterGroups = new List <string[]>() { chatterWrapper.chatters.admins, chatterWrapper.chatters.broadcaster, chatterWrapper.chatters.global_mods, chatterWrapper.chatters.moderators, chatterWrapper.chatters.staff, chatterWrapper.chatters.viewers, chatterWrapper.chatters.vips }; foreach (string[] list in chatterGroups) { foreach (string username in list) { if (ViewerController.ViewerExists(Service.Twitch, username)) { chatterNames.Add(ViewerController.GetViewer(Service.Twitch, username)); } else { chatterNames.Add(ViewerController.CreateViewer(Service.Twitch, username, 0)); } } } return(chatterNames); }
public static void LogMessage(ChatMessage chatMessage) { if (LastChatMessages.Count >= chatMessageQueueLength - 1) { LastChatMessages.RemoveAt(0); } LastChatMessages.Add(chatMessage); if (ViewerController.ViewerExists(chatMessage.Username)) { ViewerTracker.UpdateViewer(ViewerController.GetViewer(chatMessage.Username)); } }
private void DoLedgerRow(Rect row, KeyValuePair <string, int> keyValuePair) { GUI.BeginGroup(row); Rect label = new Rect(0, 0, 300f, 24f); Rect pointLabel = new Rect(304f, 0, 200f, 24f); Viewer viewer = ViewerController.GetViewer(keyValuePair.Key); string viewerLabel = selectedViewerName == keyValuePair.Key ? TCText.ColoredText(viewer.DisplayName, ColorLibrary.Gold) : viewer.DisplayName; if (Widgets.ButtonText(label, viewerLabel, false)) { UpdateSelectedViewer(keyValuePair.Key); } Widgets.Label(pointLabel, $"{keyValuePair.Value} {ToolkitPointsSettings.pointsBaseName}"); GUI.EndGroup(); }
public override void ParseMessage(ITwitchMessage twitchCommand) { if (twitchCommand == null) { return; } Viewer viewer; if (ViewerController.ViewerExists(twitchCommand.Username)) { viewer = ViewerController.GetViewer(twitchCommand.Username); } else { viewer = ViewerController.CreateViewer(twitchCommand.Username); } if (viewer != null && twitchCommand.ChatMessage != null) { viewer.UpdateViewerFromMessage(twitchCommand.ChatMessage); } }
public override void DoWindowContents(Rect inRect) { // Left Side Text.Anchor = TextAnchor.MiddleCenter; Rect leftArrow = new Rect(0f, 0f, 32f, 32f); Rect middleLabel = new Rect(leftArrow.width + padding, 0f, 200f, 32f); Rect rightArrow = new Rect(middleLabel.x + middleLabel.width + padding, 0f, 32f, 32f); if (Widgets.ButtonText(leftArrow, "<")) { PreviousPawn(); } Widgets.Label(middleLabel, selectedPawn.NameFullColored); if (Widgets.ButtonText(rightArrow, ">")) { NextPawn(); } leftArrow.y += 37f; middleLabel.y += 37f; rightArrow.y += 37f; if (Widgets.ButtonText(leftArrow, "<", true, true, false)) { } Widgets.Label(middleLabel, PawnUtilities.groupOfPawnsLabel); if (Widgets.ButtonText(rightArrow, ">", true, true, false)) { } Text.Anchor = TextAnchor.MiddleLeft; // Right Side Rect pawnCard = new Rect(inRect.width - 124 - padding, 0, 124, 124); PawnUtilities.DrawColonist(pawnCard, selectedPawn); // Bottom Section Rect pawnInformation = new Rect(0f, 140f, 240f, 24f); if (assignedUsername != null) { // Viewer Assigned Widgets.Label(pawnInformation, $"<color=green>Assigned User</color>: {assignedUsername}"); PawnUtilities.NewLine(pawnInformation, out Rect unassignButton); unassignButton.width = 140f; if (Widgets.ButtonText(unassignButton, "Unassign Viewer")) { component.UnassignUserFromPawn(assignedUsername); UpdateInfoFromPawnChange(); } } else { // Viewer Not Assigned Widgets.Label(pawnInformation, "<color=red>Not Assigned</color>"); PawnUtilities.NewLine(pawnInformation, out Rect usernamesInfo); Widgets.Label(usernamesInfo, $"Users in Queue: {component.NumOfViewersInQueue}"); PawnUtilities.NewLine(usernamesInfo, out Rect pickUsername); if (component.NumOfViewersInQueue > 0) { Widgets.Label(pickUsername, "Pick Viewer: "); pickUsername.x += 100f; pickUsername.width = 80f; Text.Anchor = TextAnchor.MiddleCenter; if (Widgets.ButtonText(pickUsername, "Next")) { NextUsername(); } pickUsername.x += 100f; if (Widgets.ButtonText(pickUsername, "Random")) { RandomUsername(); } pickUsername.x = 0; pickUsername.width = usernamesInfo.width; } PawnUtilities.NewLine(pickUsername, out Rect usernameInput); if (usernameFromQueue != null) { usernameFromQueue = Widgets.TextEntryLabeled(usernameInput, "Assign to Viewer: ", usernameFromQueue); } else { usernameFromQueue = Widgets.TextEntryLabeled(usernameInput, "Assign to Viewer: ", ""); } PawnUtilities.NewLine(usernameInput, out Rect assignButton); if (usernameFromQueue != null & Widgets.ButtonText(assignButton, "Confirm Assignment")) { bool viewerDataExists = ViewerController.ViewerExists(usernameFromQueue); string pawnName = usernameFromQueue; if (viewerDataExists) { string displayName = ViewerController.GetViewer(usernameFromQueue).DisplayName; if (displayName != null && displayName != string.Empty) { pawnName = displayName; } } component.TryAssigningUserToPawn(pawnName, selectedPawn); UpdateInfoFromPawnChange(); } } Text.Anchor = TextAnchor.UpperLeft; }
public override void ParseCommand(ChatMessage msg) { ViewerController.GetViewer(msg.Username, out bool viewerExists).UpdateViewerFromMessage(msg); }