예제 #1
0
        static void SwitchGuiModeIfUserWants(
            PlasticGUIClient plasticClient,
            GuiMode currentMode, GuiMode selectedMode,
            TreeView changesTreeView,
            EditorWindow editorWindow)
        {
            if (currentMode == selectedMode)
            {
                return;
            }

            bool userConfirmed = SwitchModeConfirmationDialog.SwitchMode(
                currentMode == GuiMode.GluonMode, editorWindow);

            if (!userConfirmed)
            {
                return;
            }

            bool isGluonMode = selectedMode == GuiMode.GluonMode;

            LaunchOperation.UpdateWorkspaceForMode(
                isGluonMode, plasticClient);

            PendingChangesTreeHeaderState.SetMode(
                changesTreeView.multiColumnHeader.state,
                isGluonMode);
        }
예제 #2
0
        internal static void ForMode(
            bool isGluonMode,
            PlasticGUIClient plasticClient,
            TreeView changesTreeView,
            EditorWindow editorWindow)
        {
            GUI.enabled = !plasticClient.IsOperationInProgress();

            EditorGUI.BeginChangeCheck();

            GuiMode currentMode = isGluonMode ?
                                  GuiMode.GluonMode : GuiMode.DeveloperMode;

            GuiMode selectedMode = (GuiMode)EditorGUILayout.EnumPopup(
                currentMode,
                EditorStyles.toolbarDropDown,
                GUILayout.Width(100));

            if (EditorGUI.EndChangeCheck())
            {
                SwitchGuiModeIfUserWants(
                    plasticClient, currentMode, selectedMode,
                    changesTreeView, editorWindow);
            }

            GUI.enabled = true;
        }
예제 #3
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            currentMode = GuiMode.None;
        }

        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            currentMode = GuiMode.DisplayMessages;
        }

        if (Input.GetKeyDown(KeyCode.Alpha3))
        {
            currentMode = GuiMode.SendCommand;
        }

        if (Input.GetKeyDown(KeyCode.Alpha4))
        {
            currentMode = GuiMode.DisplayGUI;
        }
    }
예제 #4
0
파일: M35fd.cs 프로젝트: MSylvia/Ketchup
        private void OnM35FdWindow(int windowId)
        {
            GUI.skin = HighLogic.Skin;

            var insertEjectButtonPressed = false;
            var cancelInsertButtonPressed = false;

            GUILayout.BeginHorizontal();
            GUILayout.Label(_currentStateCode == StateCode.NoMedia ? "<Empty>" : _disk.Label);

            switch(_guiMode)
            {
                case GuiMode.Normal:
                    if (_allDisks.Any())
                    {
                        insertEjectButtonPressed = GUILayout.Button(_currentStateCode == StateCode.NoMedia ? "Insert" : "Eject");
                    }
                    break;

                case GuiMode.Insert:
                    cancelInsertButtonPressed = GUILayout.Button("Insert", _styleButtonPressed);
                    break;
            }

            GUILayout.EndHorizontal();

            var disksToDestroy = new List<FloppyDisk>();

            var availableDisks = _allDisks.Where(i => i != _disk).ToList();

            if (availableDisks.Any())
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Disks:");
                GUILayout.EndHorizontal();

                foreach (var disk in availableDisks)
                {
                    GUILayout.BeginHorizontal();

                    switch (_guiMode)
                    {
                        case GuiMode.Normal:
                        case GuiMode.Get:
                            if (_disksBeingLabeled.ContainsKey(disk))
                            {
                                _disksBeingLabeled[disk] = GUILayout.TextField(_disksBeingLabeled[disk], GUILayout.Width(125));
                            }
                            else
                            {
                                GUILayout.Label(disk.Label, GUILayout.Width(125));
                            }

                            if (GUILayout.Button("Label"))
                            {
                                if (_disksBeingLabeled.ContainsKey(disk))
                                {
                                    var label = _disksBeingLabeled[disk];

                                    if (!String.IsNullOrEmpty(label) && !String.IsNullOrEmpty(label.Trim()))
                                    {
                                        disk.Label = label;
                                    }

                                    _disksBeingLabeled.Remove(disk);
                                }
                                else
                                {
                                    _disksBeingLabeled.Add(disk, disk.Label);
                                }
                            }

                            if (disk.IsWriteProtected)
                            {
                                if (GUILayout.Button("Protect", _styleButtonPressed))
                                {
                                    disk.IsWriteProtected = !disk.IsWriteProtected;
                                }
                            }
                            else
                            {
                                if (GUILayout.Button("Protect"))
                                {
                                    disk.IsWriteProtected = !disk.IsWriteProtected;
                                }
                            }

                            if (GUILayout.Button("Destroy"))
                            {
                                disksToDestroy.Add(disk);
                            }

                            break;

                        case GuiMode.Insert:
                            if (GUILayout.Button(disk.Label))
                            {
                                _guiMode = GuiMode.Normal;
                                InsertDisk(disk);
                            }

                            break;
                    }
                    GUILayout.EndHorizontal();
                }
            }
            else
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("No Available Disks");
                GUILayout.EndHorizontal();
            }

            GUILayout.BeginHorizontal();
            var getDiskButtonPressed = GUILayout.Button("Get Disk");
            GUILayout.EndHorizontal();

            if (_guiMode == GuiMode.Get)
            {
                var disks = GetDiskImages().ToList();

                GUILayout.Label("Disk Images:");

                foreach (var disk in disks)
                {
                    if (GUILayout.Button(disk.Label))
                    {
                        _allDisks.Add(disk);
                        _allDisks = _allDisks.OrderBy(i => i.Label).ToList();

                        _guiMode = GuiMode.Normal;
                    }
                }
            }

            GUI.DragWindow();

            if (GUI.changed)
            {
                if (insertEjectButtonPressed)
                {
                    if (_currentStateCode == StateCode.NoMedia)
                    {
                        _guiMode = GuiMode.Insert;
                    }
                    else
                    {
                        EjectDisk();
                    }
                }

                if (getDiskButtonPressed)
                {
                    _guiMode = GuiMode.Get;
                }

                if (cancelInsertButtonPressed)
                {
                    _guiMode = GuiMode.Normal;
                }

                _windowPosition = new Rect(_windowPosition) { width = 300, height = 0 };
            }

            foreach (var disk in disksToDestroy)
            {
                _allDisks.Remove(disk);
            }
        }
예제 #5
0
파일: M35fd.cs 프로젝트: MSylvia/Ketchup
        private void OnM35FdWindow(int windowId)
        {
            GUI.skin = HighLogic.Skin;

            var insertEjectButtonPressed  = false;
            var cancelInsertButtonPressed = false;

            GUILayout.BeginHorizontal();
            GUILayout.Label(_currentStateCode == StateCode.NoMedia ? "<Empty>" : _disk.Label);

            switch (_guiMode)
            {
            case GuiMode.Normal:
                if (_allDisks.Any())
                {
                    insertEjectButtonPressed = GUILayout.Button(_currentStateCode == StateCode.NoMedia ? "Insert" : "Eject");
                }
                break;

            case GuiMode.Insert:
                cancelInsertButtonPressed = GUILayout.Button("Insert", _styleButtonPressed);
                break;
            }

            GUILayout.EndHorizontal();

            var disksToDestroy = new List <FloppyDisk>();

            var availableDisks = _allDisks.Where(i => i != _disk).ToList();

            if (availableDisks.Any())
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Disks:");
                GUILayout.EndHorizontal();

                foreach (var disk in availableDisks)
                {
                    GUILayout.BeginHorizontal();

                    switch (_guiMode)
                    {
                    case GuiMode.Normal:
                    case GuiMode.Get:
                        if (_disksBeingLabeled.ContainsKey(disk))
                        {
                            _disksBeingLabeled[disk] = GUILayout.TextField(_disksBeingLabeled[disk], GUILayout.Width(125));
                        }
                        else
                        {
                            GUILayout.Label(disk.Label, GUILayout.Width(125));
                        }

                        if (GUILayout.Button("Label"))
                        {
                            if (_disksBeingLabeled.ContainsKey(disk))
                            {
                                var label = _disksBeingLabeled[disk];

                                if (!String.IsNullOrEmpty(label) && !String.IsNullOrEmpty(label.Trim()))
                                {
                                    disk.Label = label;
                                }

                                _disksBeingLabeled.Remove(disk);
                            }
                            else
                            {
                                _disksBeingLabeled.Add(disk, disk.Label);
                            }
                        }

                        if (disk.IsWriteProtected)
                        {
                            if (GUILayout.Button("Protect", _styleButtonPressed))
                            {
                                disk.IsWriteProtected = !disk.IsWriteProtected;
                            }
                        }
                        else
                        {
                            if (GUILayout.Button("Protect"))
                            {
                                disk.IsWriteProtected = !disk.IsWriteProtected;
                            }
                        }

                        if (GUILayout.Button("Destroy"))
                        {
                            disksToDestroy.Add(disk);
                        }

                        break;

                    case GuiMode.Insert:
                        if (GUILayout.Button(disk.Label))
                        {
                            _guiMode = GuiMode.Normal;
                            InsertDisk(disk);
                        }

                        break;
                    }
                    GUILayout.EndHorizontal();
                }
            }
            else
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("No Available Disks");
                GUILayout.EndHorizontal();
            }

            GUILayout.BeginHorizontal();
            var getDiskButtonPressed = GUILayout.Button("Get Disk");

            GUILayout.EndHorizontal();

            if (_guiMode == GuiMode.Get)
            {
                var disks = GetDiskImages().ToList();

                GUILayout.Label("Disk Images:");

                foreach (var disk in disks)
                {
                    if (GUILayout.Button(disk.Label))
                    {
                        _allDisks.Add(disk);
                        _allDisks = _allDisks.OrderBy(i => i.Label).ToList();

                        _guiMode = GuiMode.Normal;
                    }
                }
            }

            GUI.DragWindow();

            if (GUI.changed)
            {
                if (insertEjectButtonPressed)
                {
                    if (_currentStateCode == StateCode.NoMedia)
                    {
                        _guiMode = GuiMode.Insert;
                    }
                    else
                    {
                        EjectDisk();
                    }
                }

                if (getDiskButtonPressed)
                {
                    _guiMode = GuiMode.Get;
                }

                if (cancelInsertButtonPressed)
                {
                    _guiMode = GuiMode.Normal;
                }

                _windowPosition = new Rect(_windowPosition)
                {
                    width = 300, height = 0
                };
            }

            foreach (var disk in disksToDestroy)
            {
                _allDisks.Remove(disk);
            }
        }