Exemplo n.º 1
0
        void TemplateSelectionWindow(int id)
        {
            GUILayout.BeginVertical();
            GUILayout.Space(10);
            GUILayout.BeginHorizontal();

            templateSelScrollVector = GUILayout.BeginScrollView(templateSelScrollVector);
            int cnt = 0;

            foreach (var template in templateList)
            {
                GUILayout.BeginHorizontal();

                bool b    = (lastSelectedTemplate == template);
                bool newB = GUILayout.Toggle(b, "");
                if (newB)
                {
                    lastSelectedTemplate = template;
                }

                if (lastSelectedTemplate == template)
                {
                    lStyle.normal.textColor = Color.green;
                }
                else
                {
                    lStyle.normal.textColor = labelStyle.normal.textColor;
                }

                GUILayout.Label(template, lStyle);

                cnt++;
                GUILayout.EndHorizontal();
            }
            GUILayout.EndScrollView();
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            if (GUILayout.Button("OK", GUILayout.Width(90)))
            {
                selectedTemplate = lastSelectedTemplate;
                Apply(templateType);
                templateGui = null;
                Destroy(this);
            }
            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Cancel", GUILayout.Width(90)))
            {
                templateGui = null;
                Destroy(this);
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
            GUI.DragWindow();
        }
Exemplo n.º 2
0
        private void DisplayConfigure()
        {
            if (!stylesInitted)
            {
                InitStyles();
            }

            GUILayout.BeginVertical();
#if DEBUG
            GUILayout.BeginHorizontal();
            GUILayout.Label("Log:");
            LogLevelButton(KSP_Log.Log.LEVEL.OFF, "OFF");
            LogLevelButton(KSP_Log.Log.LEVEL.ERROR, "ERROR");
            LogLevelButton(KSP_Log.Log.LEVEL.WARNING, "WARNING");
            LogLevelButton(KSP_Log.Log.LEVEL.INFO, "INFO");
            LogLevelButton(KSP_Log.Log.LEVEL.DETAIL, "DETAIL");
            LogLevelButton(KSP_Log.Log.LEVEL.TRACE, "TRACE");
            GUILayout.EndHorizontal();
#endif

            GUILayout.Space(20);
            GUILayout.BeginHorizontal();

            GUI.enabled = showPanel != ConfigPanel.Quicksave;
            if (GUILayout.Button("Options"))
            {
                showPanel           = ConfigPanel.Quicksave;
                windowBounds.height = 0;
            }

            GUI.enabled = showPanel != ConfigPanel.QuickSaveIntervals;
            if (GUILayout.Button("Intervals"))
            {
                showPanel           = ConfigPanel.QuickSaveIntervals;
                windowBounds.height = 0;
            }

            GUI.enabled = showPanel != ConfigPanel.QuickSaveAging;
            if (GUILayout.Button("Age Settings"))
            {
                showPanel           = ConfigPanel.QuickSaveAging;
                windowBounds.height = 0;
            }

            GUI.enabled = showPanel != ConfigPanel.Editor;
            if (GUILayout.Button("Editor Options"))
            {
                showPanel           = ConfigPanel.Editor;
                windowBounds.height = 0;
            }
            GUI.enabled = showPanel != ConfigPanel.Sound;
            if (GUILayout.Button("Sound Options"))
            {
                showPanel           = ConfigPanel.Sound;
                windowBounds.height = 0;
            }

            GUILayout.EndHorizontal();
            GUI.enabled = true;
            switch (showPanel)
            {
            case ConfigPanel.Quicksave:
            {
                GUILayout.Space(15);

                // QuickSave options
                // quicksave on launch
                QuickSaveOnLaunchToggle("Quicksave on launch");
                QuickSaveOnSceneChange("Quicksave on scene change");

                GUILayout.BeginHorizontal();
                GUILayout.Label("Minimum time between quicksaves (for scene changes only, in seconds): ");
                String sMinTimeBetweenQuicksaves = GUILayout.TextField(Configuration.MinTimeBetweenQuicksaves.ToString(), STYLE_CONFIG_TEXTFIELD);
                GUILayout.Space(CONFIG_TEXTFIELD_RIGHT_MARGIN);
                Configuration.MinTimeBetweenQuicksaves = ParseInt(sMinTimeBetweenQuicksaves);
                GUILayout.EndHorizontal();


                GUILayout.BeginHorizontal();
                GUILayout.Label("Templates:");
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Template Info"))
                {
                    showTemplateInfo = !showTemplateInfo;
                }
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                GUILayout.Label("(Click the Launch/Quicksave/Scenesave template button to select, or enter your own template)");
                GUILayout.EndHorizontal();

                GUI.enabled = (TemplateSelectionGui.templateGui == null);
                var buttonRect = GUILayoutUtility.GetRect(new GUIContent("Launch Template"), GUI.skin.button, GUILayout.Width(TEMPLATE_WIN_BUTTON_WIDTH));

                if (GUILayout.Button("Launch Template", GUILayout.Width(TEMPLATE_WIN_BUTTON_WIDTH)))
                {
                    TemplateSelectionGui.StartWindow("Launch", Configuration.LaunchNameTemplate, windowBounds, buttonRect);
                    TemplateSelectionGui.templateGui = gameObject.AddComponent <TemplateSelectionGui>();
                }
                GUI.enabled = true;
                //GUILayout.Label("Launch template: ", STYLE_CONFIG_BACKUP_PATH_LABEL);
                Configuration.LaunchNameTemplate = GUILayout.TextField(Configuration.LaunchNameTemplate);
                GUILayout.BeginHorizontal();
                string newName = StringTranslation.AddFormatInfo(Configuration.LaunchNameTemplate, "", "");
                GUILayout.Label(" ==> ");
                GUILayout.TextField(Quicksave.LAUNCH_QS_PREFIX + newName);
                GUILayout.EndHorizontal();

                GUI.enabled = (TemplateSelectionGui.templateGui == null);
                buttonRect  = GUILayoutUtility.GetRect(new GUIContent("Quicksave Template"), GUI.skin.button, GUILayout.Width(TEMPLATE_WIN_BUTTON_WIDTH));
                if (GUILayout.Button("Quicksave Template", GUILayout.Width(TEMPLATE_WIN_BUTTON_WIDTH)))
                {
                    TemplateSelectionGui.StartWindow("Quicksave", Configuration.QuickSaveNameTemplate, windowBounds, buttonRect);
                    TemplateSelectionGui.templateGui = gameObject.AddComponent <TemplateSelectionGui>();
                }
                GUI.enabled = true;
                //GUILayout.Label("Quicksave template: ", STYLE_CONFIG_BACKUP_PATH_LABEL);
                Configuration.QuickSaveNameTemplate = GUILayout.TextField(Configuration.QuickSaveNameTemplate);
                GUILayout.BeginHorizontal();
                newName = StringTranslation.AddFormatInfo(Configuration.QuickSaveNameTemplate, "", "");
                GUILayout.Label(" ==> ");
                GUILayout.TextField(Quicksave.AUTO_QS_PREFIX + newName);
                GUILayout.EndHorizontal();

                GUI.enabled = (TemplateSelectionGui.templateGui == null);
                buttonRect  = GUILayoutUtility.GetRect(new GUIContent("Scenesave Template"), GUI.skin.button, GUILayout.Width(TEMPLATE_WIN_BUTTON_WIDTH));
                if (GUILayout.Button("Scenesave Template", GUILayout.Width(TEMPLATE_WIN_BUTTON_WIDTH)))
                {
                    TemplateSelectionGui.StartWindow("Scenesave", Configuration.SceneSaveNameTemplate, windowBounds, buttonRect);
                    TemplateSelectionGui.templateGui = gameObject.AddComponent <TemplateSelectionGui>();
                }
                GUI.enabled = true;
                //GUILayout.Label("Scenesave template: ", STYLE_CONFIG_BACKUP_PATH_LABEL);
                Configuration.SceneSaveNameTemplate = GUILayout.TextField(Configuration.SceneSaveNameTemplate);
                GUILayout.BeginHorizontal();
                newName = StringTranslation.AddFormatInfo(Configuration.SceneSaveNameTemplate, "", "");
                GUILayout.Label(" ==> ");
                GUILayout.TextField(Quicksave.SCENE_QS_PREFIX + newName);
                GUILayout.EndHorizontal();
                GUILayout.Space(20);
                GUILayout.EndVertical();
            }
            break;

            case ConfigPanel.QuickSaveIntervals:
            {
                GUILayout.Label("Quicksave interval: ");

                QuicksaveIntervalToggle(Configuration.QuickSave_Interval.ONCE_IN_10_MINUTES, "Once in 10 minutes");
                QuicksaveIntervalToggle(Configuration.QuickSave_Interval.ONCE_IN_30_MINUTES, "Once in 30 minutes");
                QuicksaveIntervalToggle(Configuration.QuickSave_Interval.ONCE_PER_HOUR, "Once per hour");
                QuicksaveIntervalToggle(Configuration.QuickSave_Interval.ONCE_IN_2_HOURS, "Once in 2 hours");
                QuicksaveIntervalToggle(Configuration.QuickSave_Interval.ONCE_IN_4_HOURS, "Once in 4 hours");

                GUILayout.BeginHorizontal();
                QuicksaveIntervalToggle(Configuration.QuickSave_Interval.CUSTOM, "Custom (minutes)");
                GUILayout.FlexibleSpace();

                GUI.enabled = (Configuration.QuicksaveInterval == Configuration.QuickSave_Interval.CUSTOM);
                String sCustomInterval = GUILayout.TextField(Configuration.CustomQuicksaveInterval.ToString(), STYLE_CONFIG_TEXTFIELD);
                GUILayout.Space(CONFIG_TEXTFIELD_RIGHT_MARGIN);
                Configuration.CustomQuicksaveInterval = ParseInt(sCustomInterval);
                GUI.enabled = true;
                GUILayout.EndHorizontal();

                GUILayout.EndVertical();
                GUILayout.Space(20);
            }
            break;

            case ConfigPanel.QuickSaveAging:
            {
                GUILayout.Space(15);
                GUILayout.BeginHorizontal();
                GUILayout.Label("Days to keep quicksaves: ");
                String sDaysToKeepQuicksaves = GUILayout.TextField(Configuration.DaysToKeepQuicksaves.ToString(), STYLE_CONFIG_TEXTFIELD);
                GUILayout.Space(CONFIG_TEXTFIELD_RIGHT_MARGIN);
                Configuration.DaysToKeepQuicksaves = ParseInt(sDaysToKeepQuicksaves);
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("Min number of quicksaves: ");
                String sMinNumberOfQuicksaves = GUILayout.TextField(Configuration.MinNumberOfQuicksaves.ToString(), STYLE_CONFIG_TEXTFIELD);
                GUILayout.Space(CONFIG_TEXTFIELD_RIGHT_MARGIN);
                Configuration.MinNumberOfQuicksaves = ParseInt(sMinNumberOfQuicksaves);
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("Max number of quicksaves: ");
                String sMaxNumberOfQuicksaves = GUILayout.TextField(Configuration.MaxNumberOfQuicksaves.ToString(), STYLE_CONFIG_TEXTFIELD);
                GUILayout.Space(CONFIG_TEXTFIELD_RIGHT_MARGIN);
                Configuration.MaxNumberOfQuicksaves = ParseInt(sMaxNumberOfQuicksaves);
                GUILayout.EndHorizontal();

                GUILayout.Space(20);
                GUILayout.BeginHorizontal();
                GUILayout.Label("Max number of launch saves: ");
                String sMaxNumberOfLaunchsaves = GUILayout.TextField(Configuration.MaxNumberOfLaunchsaves.ToString(), STYLE_CONFIG_TEXTFIELD);
                GUILayout.Space(CONFIG_TEXTFIELD_RIGHT_MARGIN);
                Configuration.MaxNumberOfLaunchsaves = ParseInt(sMaxNumberOfLaunchsaves);
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("Max number of scene change saves: ");
                String sMaxNumberOfScenesaves = GUILayout.TextField(Configuration.MaxNumberOfScenesaves.ToString(), STYLE_CONFIG_TEXTFIELD);
                GUILayout.Space(CONFIG_TEXTFIELD_RIGHT_MARGIN);
                Configuration.MaxNumberOfScenesaves = ParseInt(sMaxNumberOfScenesaves);
                GUILayout.EndHorizontal();


                GUILayout.EndVertical();
                GUILayout.Space(20);
            }
            break;

            case ConfigPanel.Editor:
            {
                GUILayout.Space(15);
                Configuration.saveVesselInEditor = GUILayout.Toggle(Configuration.saveVesselInEditor, "Auto-save vessels in the editor");
                GUI.enabled = Configuration.saveVesselInEditor;
                GUILayout.BeginHorizontal();
                GUILayout.Label("Time interval between autosaves (in seconds): ");
                String sEditorTimeToSave = GUILayout.TextField(Configuration.editorTimeIntervalToSave.ToString(), STYLE_CONFIG_TEXTFIELD);
                GUILayout.Space(CONFIG_TEXTFIELD_RIGHT_MARGIN);
                Configuration.editorTimeIntervalToSave = ParseInt(sEditorTimeToSave);
                GUILayout.EndHorizontal();

                GUI.enabled = true;
                GUILayout.EndVertical();
                GUILayout.Space(20);
            }
            break;

            case ConfigPanel.Sound:
                GUILayout.Space(15);
                Configuration.SoundOnSave = GUILayout.Toggle(Configuration.SoundOnSave, "Enable sound on quicksave");

                if (Configuration.SoundOnSave)
                {
                    GUILayout.Space(15);

                    if (files == null)
                    {
                        files = Directory.GetFiles(KSPUtil.ApplicationRootPath + "GameData/" + Configuration.AUDIO_DIR, "*");
                    }
                    audioListscrollPosition = GUILayout.BeginScrollView(audioListscrollPosition, GUI.skin.box, GUILayout.Height(160));
                    int cnt = 0;

                    foreach (var name in files)
                    {
                        var shortName = Path.GetFileNameWithoutExtension(name);
                        if (selectedAudio == -1 && Configuration.AUDIO_DIR + shortName == Configuration.SoundLocation)
                        {
                            selectedAudio = cnt;
                        }
                        GUILayout.BeginHorizontal();
                        btnStyle.normal.textColor = (cnt == selectedAudio) ? Color.green : GUI.skin.button.normal.textColor;
                        if (GUILayout.Button(shortName, btnStyle, GUILayout.Width(400)))
                        {
                            selectedAudio = cnt;
                            Configuration.SoundLocation = Configuration.AUDIO_DIR + shortName;
                        }
                        if (GUILayout.Button("►", btnStyle, GUILayout.Width(25)))
                        {
                            Audio.InitializeAudio();
                            Audio.markerAudio.PlayOneShot(GameDatabase.Instance.GetAudioClip(Configuration.AUDIO_DIR + shortName));
                        }
                        cnt++;
                        GUILayout.EndHorizontal();
                    }

                    GUILayout.EndScrollView();
                }
                GUILayout.EndVertical();
                break;
            }
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label("(Click <B>Save Config</b> button to save) ==>");
            if (GUILayout.Button("Save Config", GUI.skin.button))
            {
                Configuration.Save();
                Toggle();
                Quicksave.instance.RestartLoop();
            }
            GUILayout.EndHorizontal();
            GUI.DragWindow();
        }