Пример #1
0
        private void DrawContent(int windowID)
        {
            GUILayout.BeginVertical();
            GUI.DragWindow(moveRect);
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUIStyle chatButtonStyle = buttonStyle;

            if (chatWorker.chatButtonHighlighted)
            {
                chatButtonStyle = highlightStyle;
            }
            chatWorker.display         = GUILayout.Toggle(chatWorker.display, "Chat", chatButtonStyle);
            craftLibraryWorker.display = GUILayout.Toggle(craftLibraryWorker.display, "Craft", buttonStyle);
            groupsWindow.display       = GUILayout.Toggle(groupsWindow.display, "Group", buttonStyle);
            permissionsWindow.display  = GUILayout.Toggle(permissionsWindow.display, "Permissions", buttonStyle);
            GUIStyle screenshotButtonStyle = buttonStyle;

            if (screenshotWorker.screenshotButtonHighlighted)
            {
                screenshotButtonStyle = highlightStyle;
            }
            screenshotWorker.display = GUILayout.Toggle(screenshotWorker.display, "Screenshot", screenshotButtonStyle);
            if (GUILayout.Button("-", buttonStyle))
            {
                minmized        = true;
                minWindowRect.x = windowRect.xMax - minWindowRect.width;
                minWindowRect.y = windowRect.y;
            }
            GUILayout.EndHorizontal();
            scrollPosition = GUILayout.BeginScrollView(scrollPosition, scrollStyle);
            //Draw subspaces
            double ourTime     = timeSyncer.locked ? timeSyncer.GetUniverseTime() : Planetarium.GetUniversalTime();
            long   serverClock = timeSyncer.GetServerClock();

            foreach (SubspaceDisplayEntry currentEntry in subspaceDisplay)
            {
                double currentTime = 0;
                double diffTime    = 0;
                string diffState   = "Unknown";
                if (!currentEntry.isUs)
                {
                    if (!currentEntry.isWarping)
                    {
                        //Subspace entry
                        if (currentEntry.subspaceEntry != null)
                        {
                            long   serverClockDiff = serverClock - currentEntry.subspaceEntry.serverClock;
                            double secondsDiff     = serverClockDiff / 10000000d;
                            currentTime = currentEntry.subspaceEntry.planetTime + (currentEntry.subspaceEntry.subspaceSpeed * secondsDiff);
                            diffTime    = currentTime - ourTime;
                            diffState   = (diffTime > 0) ? SecondsToVeryShortString((int)diffTime) + " in the future" : SecondsToVeryShortString(-(int)diffTime) + " in the past";
                        }
                    }
                    else
                    {
                        //Warp entry
                        if (currentEntry.warpingEntry != null)
                        {
                            float[] warpRates = TimeWarp.fetch.warpRates;
                            if (currentEntry.warpingEntry.isPhysWarp)
                            {
                                warpRates = TimeWarp.fetch.physicsWarpRates;
                            }
                            long   serverClockDiff = serverClock - currentEntry.warpingEntry.serverClock;
                            double secondsDiff     = serverClockDiff / 10000000d;
                            currentTime = currentEntry.warpingEntry.planetTime + (warpRates[currentEntry.warpingEntry.rateIndex] * secondsDiff);
                            diffTime    = currentTime - ourTime;
                            diffState   = (diffTime > 0) ? SecondsToVeryShortString((int)diffTime) + " in the future" : SecondsToVeryShortString(-(int)diffTime) + " in the past";
                        }
                    }
                }
                else
                {
                    currentTime = ourTime;
                    diffState   = "NOW";
                }

                //Draw the subspace black bar.
                GUILayout.BeginHorizontal(subspaceStyle);
                GUILayout.Label("T+ " + SecondsToShortString((int)currentTime) + " - " + diffState);
                GUILayout.FlexibleSpace();
                //Draw the sync button if needed
#if !DEBUG
                if ((warpWorker.warpMode == WarpMode.SUBSPACE) && !currentEntry.isUs && !currentEntry.isWarping && (currentEntry.subspaceEntry != null) && (diffTime > 0))
#else
                if ((warpWorker.warpMode == WarpMode.SUBSPACE) && !currentEntry.isUs && !currentEntry.isWarping && (currentEntry.subspaceEntry != null))
#endif
                {
                    if (GUILayout.Button("Sync", buttonStyle))
                    {
                        timeSyncer.LockSubspace(currentEntry.subspaceID);
                    }
                }
                GUILayout.EndHorizontal();

                foreach (string currentPlayer in currentEntry.players)
                {
                    if (currentPlayer == dmpSettings.playerName)
                    {
                        DrawPlayerEntry(playerStatusWorker.myPlayerStatus, playerColorWorker.GetPlayerColor(currentPlayer));
                    }
                    else
                    {
                        DrawPlayerEntry(playerStatusWorker.GetPlayerStatus(currentPlayer), playerColorWorker.GetPlayerColor(currentPlayer));
                    }
                }
            }
            if (DateTime.Now.Day == 1 && DateTime.Now.Month == 4)
            {
                PlayerStatus easterEgg = new PlayerStatus();
                easterEgg.playerName = "Princess Luna";
                easterEgg.statusText = "Stranded on the Mün";
                easterEgg.vesselText = "";
                DrawPlayerEntry(easterEgg, new Color(0.251f, 0.275f, 0.502f));
            }
            GUILayout.EndScrollView();
            GUILayout.FlexibleSpace();
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Disconnect", buttonStyle))
            {
                disconnectEventHandled = false;
            }
            optionsWindow.display = GUILayout.Toggle(optionsWindow.display, "Options", buttonStyle);
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
        }