Ejemplo n.º 1
0
        public void QueueNewScreenshot(string fromPlayer, byte[] screenshotData)
        {
            downloadingScreenshotFromPlayer = null;
            ScreenshotEntry se = new ScreenshotEntry();

            se.fromPlayer     = fromPlayer;
            se.screenshotData = screenshotData;
            newScreenshotQueue.Enqueue(se);
        }
Ejemplo n.º 2
0
        private void Update()
        {
            safeDisplay = display;

            if (workerEnabled)
            {
                while (newScreenshotNotifiyQueue.Count > 0)
                {
                    string notifyPlayer = newScreenshotNotifiyQueue.Dequeue();
                    if (!display)
                    {
                        screenshotButtonHighlighted = true;
                    }
                    if (selectedPlayer != notifyPlayer)
                    {
                        if (!highlightedPlayers.Contains(notifyPlayer))
                        {
                            highlightedPlayers.Add(notifyPlayer);
                        }
                    }
                    ChatWorker.fetch.QueueChannelMessage("Server", "", notifyPlayer + " shared screenshot");
                }

                //Update highlights
                if (screenshotButtonHighlighted && display)
                {
                    screenshotButtonHighlighted = false;
                }

                if (highlightedPlayers.Contains(selectedPlayer))
                {
                    highlightedPlayers.Remove(selectedPlayer);
                }


                while (newScreenshotQueue.Count > 0)
                {
                    ScreenshotEntry se = newScreenshotQueue.Dequeue();
                    Texture2D       screenshotTexture = new Texture2D(4, 4, TextureFormat.RGB24, false, true);
                    if (screenshotTexture.LoadImage(se.screenshotData))
                    {
                        screenshotTexture.Apply();
                        //Make sure screenshots aren't bigger than 2/3rds of the screen.
                        ResizeTextureIfNeeded(ref screenshotTexture);
                        //Save the texture in memory
                        screenshots[se.fromPlayer] = screenshotTexture;
                        DarkLog.Debug("Loaded screenshot from " + se.fromPlayer);
                    }
                    else
                    {
                        DarkLog.Debug("Error loading screenshot from " + se.fromPlayer);
                    }
                }

                while (newScreenshotWatchQueue.Count > 0)
                {
                    ScreenshotWatchEntry swe = newScreenshotWatchQueue.Dequeue();
                    if (swe.watchPlayer != "")
                    {
                        watchPlayers[swe.fromPlayer] = swe.watchPlayer;
                    }
                    else
                    {
                        if (watchPlayers.ContainsKey(swe.fromPlayer))
                        {
                            watchPlayers.Remove(swe.fromPlayer);
                        }
                    }
                }

                if (safeSelectedPlayer != selectedPlayer)
                {
                    windowRect.height  = 0;
                    windowRect.width   = 0;
                    safeSelectedPlayer = selectedPlayer;
                    WatchPlayer(selectedPlayer);
                }

                if (Input.GetKey(Settings.fetch.screenshotKey))
                {
                    uploadEventHandled = false;
                }

                if (!uploadEventHandled)
                {
                    uploadEventHandled = true;
                    if ((Client.realtimeSinceStartup - lastScreenshotSend) > MIN_SCREENSHOT_SEND_INTERVAL)
                    {
                        lastScreenshotSend                = Client.realtimeSinceStartup;
                        screenshotTaken                   = false;
                        finishedUploadingScreenshot       = false;
                        uploadScreenshot                  = true;
                        displayScreenshotUploadingMessage = true;
                    }
                }

                if ((Client.realtimeSinceStartup - lastScreenshotMessageCheck) > SCREENSHOT_MESSAGE_CHECK_INTERVAL)
                {
                    if (screenshotTaken && displayScreenshotUploadingMessage)
                    {
                        lastScreenshotMessageCheck = Client.realtimeSinceStartup;
                        if (screenshotUploadMessage != null)
                        {
                            screenshotUploadMessage.duration = 0f;
                        }
                        if (finishedUploadingScreenshot)
                        {
                            displayScreenshotUploadingMessage = false;
                            screenshotUploadMessage           = ScreenMessages.PostScreenMessage("Screenshot uploaded!", 2f, ScreenMessageStyle.UPPER_CENTER);
                        }
                        else
                        {
                            screenshotUploadMessage = ScreenMessages.PostScreenMessage("Uploading screenshot...", 1f, ScreenMessageStyle.UPPER_CENTER);
                        }
                    }

                    if (downloadingScreenshotFromPlayer != null)
                    {
                        if (screenshotDownloadMessage != null)
                        {
                            screenshotDownloadMessage.duration = 0f;
                        }
                        screenshotDownloadMessage = ScreenMessages.PostScreenMessage("Downloading screenshot...", 1f, ScreenMessageStyle.UPPER_CENTER);
                    }
                }

                if (downloadingScreenshotFromPlayer == null && screenshotDownloadMessage != null)
                {
                    screenshotDownloadMessage.duration = 0f;
                    screenshotDownloadMessage          = null;
                }
            }
        }
Ejemplo n.º 3
0
 public void QueueNewScreenshot(string fromPlayer, byte[] screenshotData)
 {
     downloadingScreenshotFromPlayer = null;
     ScreenshotEntry se = new ScreenshotEntry();
     se.fromPlayer = fromPlayer;
     se.screenshotData = screenshotData;
     newScreenshotQueue.Enqueue(se);
 }