Beispiel #1
0
        private void DrawContent(int windowID)
        {
            if (GUI.Button(new Rect(windowRect.width - 24, 0, 19, 19), "X"))
            {
                display = false;
            }
            //Player color
            GUI.DragWindow(moveRect);
            GUI.Box(new Rect(2, 20, windowRect.width - 4, 20), string.Empty, sectionHeaderStyle);
            selectedTab = (OptionsTab)GUILayout.Toolbar((int)selectedTab, GetOptionsTabStrings(), toolbarBtnStyle);

            int windowY = 17;

            windowY += 20 + 2;
            int groupY = 0;

            if (selectedTab == OptionsTab.PLAYER)
            {
                GUI.BeginGroup(new Rect(10, windowY, windowRect.width - 20, 106));
                groupY = 0;

                GUI.Label(new Rect(0, groupY, descWidth, 20), "Name:", descriptorStyle);
                plrNameStyle.normal.textColor = dmpSettings.playerColor;
                if (networkWorker != null && networkWorker.state == DarkMultiPlayerCommon.ClientState.RUNNING)
                {
                    GUI.Label(new Rect(descWidth + sepWidth, groupY,
                                       windowRect.width - (descWidth + sepWidth) - 20, 20),
                              dmpSettings.playerName, plrNameStyle);
                }
                else
                {
                    string newName = GUI.TextField(new Rect(
                                                       descWidth + sepWidth,
                                                       0,
                                                       windowRect.width - (descWidth + sepWidth) - 20,
                                                       20), dmpSettings.playerName, plrNameStyle);

                    if (!newName.Equals(dmpSettings.playerName))
                    {
                        dmpSettings.playerName = newName;
                        dmpSettings.SaveSettings();
                    }
                }
                groupY += 20 + 4;


                Color playerColor = dmpSettings.playerColor;

                GUI.Label(new Rect(0, groupY, descWidth, 20), "Red:", descriptorStyle);
                playerColor.r = GUI.HorizontalSlider(new Rect(
                                                         descWidth + sepWidth,
                                                         groupY + 5,
                                                         windowRect.width - (descWidth + sepWidth) - 20,
                                                         12
                                                         ), dmpSettings.playerColor.r, 0, 1);
                groupY += 20;

                GUI.Label(new Rect(0, groupY, descWidth, 20), "Green:", descriptorStyle);
                playerColor.g = GUI.HorizontalSlider(new Rect(
                                                         descWidth + sepWidth,
                                                         groupY + 5,
                                                         windowRect.width - (descWidth + sepWidth) - 20,
                                                         12
                                                         ), dmpSettings.playerColor.g, 0, 1);
                groupY += 20;

                GUI.Label(new Rect(0, groupY, descWidth, 20), "Blue:", descriptorStyle);
                playerColor.b = GUI.HorizontalSlider(new Rect(
                                                         descWidth + sepWidth,
                                                         groupY + 5,
                                                         windowRect.width - (descWidth + sepWidth) - 20,
                                                         12
                                                         ), dmpSettings.playerColor.b, 0, 1);
                groupY += 22;

                if (GUI.Button(new Rect(0, groupY, windowRect.width - 20, 20), "Random Color", buttonStyle))
                {
                    playerColor = PlayerColorWorker.GenerateRandomColor();
                }

                if (!playerColor.Equals(dmpSettings.playerColor))
                {
                    dmpSettings.playerColor = playerColor;
                    dmpSettings.SaveSettings();

                    if (networkWorker != null && playerColorWorker != null && networkWorker.state == DarkMultiPlayerCommon.ClientState.RUNNING)
                    {
                        playerColorWorker.SendPlayerColorToServer();
                    }
                }

                GUI.EndGroup();
                // windowY += 106 + 5;
            }
            if (selectedTab == OptionsTab.CACHE)
            {
                GUI.BeginGroup(new Rect(10, windowY, windowRect.width - 20, 84));
                groupY = 0;

                GUI.Label(new Rect(0, groupY, descWidth, 20), "Current:", descriptorStyle);
                GUI.Label(
                    new Rect(descWidth + sepWidth, groupY, windowRect.width - (descWidth + sepWidth) - 102, 20),
                    Mathf.Round(universeSyncCache.currentCacheSize / 1024).ToString() + " KB");

                groupY += 20;

                GUI.Label(new Rect(0, groupY, descWidth, 20), "Maximum:", descriptorStyle);
                string newSizeStr = GUI.TextField(new Rect(descWidth + sepWidth, groupY, windowRect.width - (descWidth + sepWidth) - 152, 20), (dmpSettings.cacheSize / 1024).ToString(), textFieldStyle);
                GUI.Label(new Rect(descWidth + sepWidth + 80, groupY, 100, 20), "kilobytes (KB)");
                int newSize;
                if (string.IsNullOrEmpty(newSizeStr))
                {
                    newSize = 1;
                }
                else
                {
                    if (int.TryParse(newSizeStr, out newSize))
                    {
                        if (newSize < 1)
                        {
                            newSize = 1;
                        }
                        else if (newSize > 1000000)
                        {
                            newSize = 1000000;
                        }
                    }
                    else
                    {
                        newSize = 100000;
                    }
                }

                if (newSize != dmpSettings.cacheSize)
                {
                    dmpSettings.cacheSize = newSize * 1024;
                    dmpSettings.SaveSettings();
                }
                groupY += 22;

                GUI.Label(new Rect(0, groupY, descWidth, 20), "Manage:", descriptorStyle);
                if (GUI.Button(new Rect(descWidth + sepWidth, groupY, windowRect.width - (descWidth + sepWidth) - 20, 20), "Expire"))
                {
                    universeSyncCache.ExpireCache();
                }

                groupY += 22;

                if (GUI.Button(new Rect(descWidth + sepWidth, groupY, windowRect.width - (descWidth + sepWidth) - 20, 20), "Delete"))
                {
                    universeSyncCache.DeleteCache();
                }
                GUI.EndGroup();
            }
            //Key bindings
            if (selectedTab == OptionsTab.CONTROLS)
            {
                GUI.BeginGroup(new Rect(10, windowY, windowRect.width - 20, 92));
                groupY = 0;

                GUI.Label(new Rect(0, groupY, windowRect.width - 20, 48),
                          "Click a button below to select the action you want to change. Then press a key to set the binding. To cancel, click the button again or press Escape.",
                          noteStyle);
                groupY += 48;

                GUI.Label(new Rect(0, groupY, descWidth, 20), "Chat:", descriptorStyle);
                string chatKey = dmpSettings.chatKey.ToString();
                if (settingChat)
                {
                    chatKey = settingKeyMessage;
                    if (Event.current.isKey)
                    {
                        if (Event.current.keyCode != KeyCode.Escape)
                        {
                            dmpSettings.chatKey = Event.current.keyCode;
                            dmpSettings.SaveSettings();
                        }
                        settingChat = false;
                    }
                }

                if (GUI.Button(new Rect(descWidth + sepWidth, groupY, windowRect.width - (descWidth + sepWidth) - 20, 20), chatKey, buttonStyle))
                {
                    settingScreenshot = false;
                    settingChat       = !settingChat;
                }
                groupY += 22;

                GUI.Label(new Rect(0, groupY, descWidth, 20), "Screenshot:", descriptorStyle);
                string screenshotKey = dmpSettings.screenshotKey.ToString();
                if (settingScreenshot)
                {
                    screenshotKey = settingKeyMessage;
                    if (Event.current.isKey)
                    {
                        if (Event.current.keyCode != KeyCode.Escape)
                        {
                            dmpSettings.screenshotKey = Event.current.keyCode;
                            dmpSettings.SaveSettings();
                        }
                        settingScreenshot = false;
                    }
                }

                if (GUI.Button(new Rect(descWidth + sepWidth, groupY, windowRect.width - (descWidth + sepWidth) - 20, 20), screenshotKey, buttonStyle))
                {
                    settingChat       = false;
                    settingScreenshot = !settingScreenshot;
                }
                GUI.EndGroup();
            }
            if (selectedTab == OptionsTab.ADVANCED)
            {
                GUI.Box(new Rect(2, windowY, windowRect.width - 4, 20), "Mod Control", sectionHeaderStyle);
                windowY += 22;

                GUI.BeginGroup(new Rect(10, windowY, windowRect.width - 20, 42));
                groupY = 0;

                GUI.Label(new Rect(0, groupY, descWidth, 20), "Generate:", descriptorStyle);
                if (GUI.Button(new Rect(descWidth + sepWidth, groupY, windowRect.width - (descWidth + sepWidth) - 20, 20), "Whitelist", buttonStyle))
                {
                    modWorker.GenerateModControlFile(true);
                }

                groupY += 22;

                if (GUI.Button(new Rect(descWidth + sepWidth, groupY, windowRect.width - (descWidth + sepWidth) - 20, 20), "Blacklist", buttonStyle))
                {
                    modWorker.GenerateModControlFile(false);
                }

                GUI.EndGroup();
                windowY += 47;

                GUI.Box(new Rect(2, windowY, windowRect.width - 4, 20), "Other", sectionHeaderStyle);
                windowY += 22;

                GUI.BeginGroup(new Rect(10, windowY, windowRect.width - 20, 148));
                groupY = 0;

                bool toggleCompression = GUI.Toggle(new Rect(0, groupY, windowRect.width - 20, 20), dmpSettings.compressionEnabled, "Compress Network Traffic");
                if (toggleCompression != dmpSettings.compressionEnabled)
                {
                    dmpSettings.compressionEnabled = toggleCompression;
                    dmpSettings.SaveSettings();
                }
                groupY += 22;

                bool toggleRevert = GUI.Toggle(new Rect(0, groupY, windowRect.width - 20, 20), dmpSettings.revertEnabled, "Enable Revert");
                if (toggleRevert != dmpSettings.revertEnabled)
                {
                    dmpSettings.revertEnabled = toggleRevert;
                    dmpSettings.SaveSettings();
                }
                groupY += 22;

                universeConverterWindow.display = GUI.Toggle(new Rect(0, groupY, windowRect.width - 20, 20), universeConverterWindow.display, "Generate DMP universe from saved game...", buttonStyle);
                groupY += 22;

                if (GUI.Button(new Rect(0, groupY, windowRect.width - 20, 20), "Reset Disclaimer", buttonStyle))
                {
                    dmpSettings.disclaimerAccepted = 0;
                    dmpSettings.SaveSettings();
                }
                groupY += 22;

                if (GUI.Button(new Rect(0, groupY, windowRect.width - 20, 20), toolbarMode, buttonStyle))
                {
                    int newSetting = (int)dmpSettings.toolbarType + 1;
                    //Overflow to 0
                    if (!Enum.IsDefined(typeof(DMPToolbarType), newSetting))
                    {
                        newSetting = 0;
                    }
                    dmpSettings.toolbarType = (DMPToolbarType)newSetting;
                    dmpSettings.SaveSettings();
                    UpdateToolbarString();
                    toolbarSupport.DetectSettingsChange();
                }
                groupY += 22;

#if DEBUG
                if (GUI.Button(new Rect(0, groupY, windowRect.width - 20, 20), "Check missing parts", buttonStyle))
                {
                    modWorker.CheckCommonStockParts();
                }
#endif

                GUI.EndGroup();
            }
        }