public MacDebuggerObjectNameView(MacObjectValueTreeView treeView) : base(treeView, "name")
        {
            ImageView = new NSImageView {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            TextField = new EditableTextField(this)
            {
                AutoresizingMask = NSViewResizingMask.WidthSizable,
                TranslatesAutoresizingMaskIntoConstraints = false,
                DrawsBackground = false,
                Bordered        = false,
                Editable        = false
            };
            TextField.Cell.UsesSingleLineMode = true;
            TextField.Cell.Wraps = false;

            AddSubview(ImageView);
            AddSubview(TextField);

            PreviewButton = new NSButton {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Image      = GetImage("md-empty", Gtk.IconSize.Menu),
                BezelStyle = NSBezelStyle.Inline,
                Bordered   = false
            };
            PreviewButton.Activated += OnPreviewButtonClicked;
        }
Exemple #2
0
        protected override void OnSetUp()
        {
            base.OnSetUp();

            _sut = Go.To <InputPage>()
                   .Find <EditableTextField <string, InputPage> >("sut", new FindByXPathAttribute("input[@type='text']"));
        }
Exemple #3
0
 public static void refreshTextInputs(GameObject go)
 {
     for (int i = 0; i < go.transform.childCount; i++)
     {
         GameObject        child = go.transform.GetChild(i).gameObject;
         EditableTextField field = child.GetComponent <EditableTextField>();
         if (field != null)
         {
             field.refreshText();
         }
     }
 }
Exemple #4
0
    public static void setInputFocus(EditableTextField editableTextField)
    {
        if (me == null)
        {
            return;
        }
        if (me.inputFocus != null)
        {
            MeshRenderer meshRenderer = me.inputFocus.gameObject?.GetComponent <MeshRenderer>();
            if (meshRenderer != null)
            {
                meshRenderer.material = me.inputFocusOffMaterial;
            }
        }
        me.inputFocus = editableTextField;
        if (me.inputFocus != null)
        {
            MeshRenderer meshRenderer = me.inputFocus.gameObject?.GetComponent <MeshRenderer>();
            if (meshRenderer != null)
            {
                meshRenderer.material = me.inputFocusOnMaterial;
            }
        }
        if (me.keyboard != null)
        {
            if (me.inputFocus == null)
            {
                me.keyboard.SetActive(false);
            }
            else
            {
                me.keyboard.SetActive(true);
                me.keyboard.transform.rotation = Quaternion.LookRotation(Camera.main.transform.position - me.inputFocus.gameObject.transform.position) * Quaternion.AngleAxis(90.0f, Vector3.right);

                Bounds objBounds = new Bounds(me.inputFocus.gameObject.transform.position, Vector3.zero);
                foreach (Renderer r in me.inputFocus.gameObject.GetComponentsInChildren <Renderer>())
                {
                    objBounds.Encapsulate(r.bounds);
                }
                Bounds keyboardBounds = new Bounds(me.keyboard.transform.position, Vector3.zero);
                foreach (Renderer r in me.keyboard.GetComponentsInChildren <Renderer>())
                {
                    keyboardBounds.Encapsulate(r.bounds);
                }
                me.keyboard.transform.position = new Vector3(
                    objBounds.center.x,
                    objBounds.center.y - (objBounds.extents.y + keyboardBounds.extents.y + 0.05f),
                    objBounds.center.z
                    ) + (me.keyboard.transform.up * 0.08f);
            }
        }
    }
Exemple #5
0
        public MacDebuggerObjectValueView(MacObjectValueTreeView treeView) : base(treeView, "value")
        {
            spinner = new NSProgressIndicator(new CGRect(0, 0, ImageSize, ImageSize))
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Style         = NSProgressIndicatorStyle.Spinning,
                Indeterminate = true
            };

            statusIcon = new NSImageView {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            colorPreview = new NSView(new CGRect(0, 0, ImageSize, ImageSize))
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            valueButton = new NSButton {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Title      = GettextCatalog.GetString("Show More"),
                BezelStyle = NSBezelStyle.Inline
            };
            valueButton.Cell.UsesSingleLineMode = true;
            UpdateFont(valueButton, -3);
            valueButton.Activated += OnValueButtonActivated;

            int imageSize = treeView.CompactView ? CompactImageSize : ImageSize;

            viewerButton = new NSButton {
                Image = GetImage(Gtk.Stock.Edit, imageSize, imageSize),
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            viewerButton.BezelStyle = NSBezelStyle.Inline;
            viewerButton.Bordered   = false;
            viewerButton.Activated += OnViewerButtonActivated;

            TextField = new EditableTextField(this)
            {
                AutoresizingMask = NSViewResizingMask.WidthSizable,
                TranslatesAutoresizingMaskIntoConstraints = false,
                DrawsBackground = false,
                Bordered        = false,
                Editable        = false
            };
            TextField.Cell.UsesSingleLineMode = true;
            TextField.Cell.Wraps = false;

            AddSubview(TextField);
        }
Exemple #6
0
    // Start is called before the first frame update
    void Start()
    {
        me         = this;
        inputFocus = null;
        keyboard?.SetActive(false);

        for (int i = 0; i < this.transform.childCount; i++)
        {
            GameObject child = this.transform.GetChild(i).gameObject;
            switch (child.name)
            {
            case "SubmenuNumberOfParts":
                submenuNumberOfParts = child;
                break;

            case "SubmenuFiles":
                submenuFiles = child;
                break;

            case "SubmenuGesture":
                submenuGesture = child;
                break;

            case "SubmenuCombination":
                submenuCombination = child;
                break;

            case "SubmenuRecord":
                submenuRecord = child;
                break;

            case "SubmenuTraining":
                submenuTraining = child;
                break;
            }
            for (int k = 0; k < child.transform.childCount; k++)
            {
                GameObject        grandChild        = child.transform.GetChild(k).gameObject;
                EditableTextField editableTextField = grandChild.GetComponent <EditableTextField>();
                if (editableTextField != null)
                {
                    editableTextField.refreshText();
                }
            }
        }
        refresh();
    }
Exemple #7
0
        public override void Construct()
        {
            Border = "border-fancy";

            OnConstruct = (sender) =>
            {
                sender.Root.RegisterForUpdate(sender);

                var topRow = AddChild(new Widget
                {
                    AutoLayout  = AutoLayout.DockTop,
                    MinimumSize = new Point(0, 24)
                });

                topRow.AddChild(new Widget
                {
                    AutoLayout         = AutoLayout.DockRight,
                    MinimumSize        = new Point(32, 0),
                    Text               = "Default Priorities",
                    ChangeColorOnHover = true,
                    Border             = "border-button",
                    OnClick            = (btn, args) =>
                    {
                        var screen = sender.Root.RenderData.VirtualScreen;
                        sender.Root.ShowModalPopup(new DefaultTaskPriority
                        {
                            Overworld   = World.Overworld,
                            MinimumSize = new Point(256, 512),
                            Border      = "border-fancy",
                            Rect        = new Rectangle(screen.Center.X - 128, screen.Center.Y - 256, 256, 512)
                        });
                    }
                });

                FilterBox = topRow.AddChild(new EditableTextField
                {
                    AutoLayout  = AutoLayout.DockFill,
                    MinimumSize = new Point(0, 24),
                    Text        = ""
                }) as EditableTextField;

                ListView = AddChild(new WidgetListView
                {
                    AutoLayout = AutoLayout.DockFill,
                    SelectedItemForegroundColor = new Vector4(0, 0, 0, 1),
                    Border     = null,
                    ItemHeight = 16
                }) as WidgetListView;

                ListView.Border = null; // Can't make WidgetListView stop defaulting its border without breaking everywhere else its used.
            };

            OnUpdate = (sender, time) =>
            {
                if (sender.Hidden)
                {
                    return;
                }

                var upperFilter    = FilterBox.Text.ToUpperInvariant();
                var tasksToDisplay = World.TaskManager.EnumerateTasks()
                                     .Where(t => !t.Hidden)
                                     .Where(t => String.IsNullOrEmpty(FilterBox.Text) ? true : t.Name.ToUpperInvariant().Contains(upperFilter));

                ListView.ClearItems();
                foreach (var task in tasksToDisplay)
                {
                    var tag        = task.GuiTag as Widget;
                    var lambdaCopy = task;

                    if (tag != null)
                    {
                        ListView.AddItem(tag);
                    }
                    else
                    {
                        #region Create gui row

                        tag = Root.ConstructWidget(new Widget
                        {
                            Text              = task.Name,
                            MinimumSize       = new Point(0, 16),
                            Padding           = new Margin(0, 0, 4, 4),
                            TextVerticalAlign = VerticalAlign.Center,
                            OnClick           = (_sender, args) =>
                            {
                                var loc = lambdaCopy.GetCameraZoomLocation();
                                if (loc.HasValue)
                                {
                                    World.Renderer.Camera.SetZoomTarget(loc.Value);
                                }
                            }
                        });

                        tag.AddChild(new Widget
                        {
                            Text              = "CANCEL",
                            AutoLayout        = AutoLayout.DockRight,
                            MinimumSize       = new Point(16, 0),
                            TextVerticalAlign = VerticalAlign.Center,
                            OnClick           = (_sender, args) =>
                            {
                                World.TaskManager.CancelTask(lambdaCopy);
                            }
                        });

                        Widget priorityDisplay = null;

                        tag.AddChild(new Gui.Widget
                        {
                            Background  = new TileReference("round-buttons", 3),
                            MinimumSize = new Point(16, 16),
                            MaximumSize = new Point(16, 16),
                            AutoLayout  = AutoLayout.DockRightCentered,
                            OnClick     = (_sender, args) =>
                            {
                                lambdaCopy.Priority  = (TaskPriority)(Math.Min(4, (int)lambdaCopy.Priority + 1));
                                priorityDisplay.Text = lambdaCopy.Priority.ToString();
                                priorityDisplay.Invalidate();
                            },
                            OnMouseEnter = (_sender, args) =>
                            {
                                _sender.BackgroundColor = GameSettings.Current.Colors.GetColor("Highlight", Color.DarkRed).ToVector4();
                                _sender.Invalidate();
                            },
                            OnMouseLeave = (_sender, args) =>
                            {
                                _sender.BackgroundColor = Vector4.One;
                                _sender.Invalidate();
                            }
                        });

                        priorityDisplay = tag.AddChild(new Gui.Widget
                        {
                            AutoLayout          = AutoLayout.DockRight,
                            MinimumSize         = new Point(64, 0),
                            Text                = lambdaCopy.Priority.ToString(),
                            TextHorizontalAlign = HorizontalAlign.Center,
                            TextVerticalAlign   = VerticalAlign.Center
                        });

                        tag.AddChild(new Gui.Widget
                        {
                            Background  = new TileReference("round-buttons", 7),
                            MinimumSize = new Point(16, 16),
                            MaximumSize = new Point(16, 16),
                            AutoLayout  = AutoLayout.DockRightCentered,
                            OnClick     = (_sender, args) =>
                            {
                                lambdaCopy.Priority  = (TaskPriority)(Math.Max(0, (int)lambdaCopy.Priority - 1));
                                priorityDisplay.Text = lambdaCopy.Priority.ToString();
                                priorityDisplay.Invalidate();
                            },
                            OnMouseEnter = (_sender, args) =>
                            {
                                _sender.BackgroundColor = GameSettings.Current.Colors.GetColor("Highlight", Color.DarkRed).ToVector4();
                                _sender.Invalidate();
                            },
                            OnMouseLeave = (_sender, args) =>
                            {
                                _sender.BackgroundColor = Vector4.One;
                                _sender.Invalidate();
                            }
                        });

                        #endregion

                        task.GuiTag = tag;
                        ListView.AddItem(tag);
                    }

                    tag.Text    = task.Name;
                    tag.Tooltip = task.FailureRecord.FormatTooltip();
                }

                ListView.Invalidate();
            };

            base.Construct();
        }
Exemple #8
0
        private void CreateGameplayTab()
        {
            var panel = TabPanel.AddTab("GAMEPLAY", new Widget
            {
                Border  = "border-thin",
                Padding = new Margin(4, 4, 0, 0)
            });

            panel.AddChild(new Widget
            {
                Text               = "Restore default settings",
                MinimumSize        = new Point(0, 20),
                AutoLayout         = AutoLayout.DockTop,
                Padding            = new Margin(0, 0, 4, 4),
                Border             = "border-button",
                ChangeColorOnHover = true,
                OnClick            = (sender, args) =>
                {
                    var prompt = GuiRoot.ConstructWidget(new Gui.Widgets.Confirm
                    {
                        Text    = "Set all settings to their default?",
                        OnClose = (confirm) =>
                        {
                            if ((confirm as Gui.Widgets.Confirm).DialogResult == Gui.Widgets.Confirm.Result.OKAY)
                            {
                                GameSettings.Default = new GameSettings.Settings();
                                RebuildGui();
                                ConfirmSettings();
                            }
                        }
                    });

                    GuiRoot.ShowDialog(prompt);
                }
            });

            // Todo: Display actual value beside slider.
            MoveSpeed = panel.AddChild(LabelAndDockWidget("Camera Move Speed", new HorizontalFloatSlider
            {
                ScrollArea      = 20,
                OnSliderChanged = OnItemChanged,
                Tooltip         = "Sensitivity of the camera to the movement keys"
            })).GetChild(1) as HorizontalFloatSlider;

            ZoomSpeed = panel.AddChild(LabelAndDockWidget("Camera Zoom Speed", new HorizontalFloatSlider
            {
                ScrollArea      = 2,
                OnSliderChanged = OnItemChanged,
                Tooltip         = "Sensitivity of the camera to zooming"
            })).GetChild(1) as HorizontalFloatSlider;

            InvertZoom = panel.AddChild(new CheckBox
            {
                Text               = "Invert Zoom",
                Tooltip            = "When checked, zooming in/out with the scroll wheel will be inverted",
                OnCheckStateChange = OnItemChanged,
                AutoLayout         = AutoLayout.DockTop
            }) as CheckBox;

            ZoomTowardMouse = panel.AddChild(new CheckBox
            {
                Text               = "Zoom to Mouse",
                Tooltip            = "When checked, when you zoom in, you will zoom toward the mouse.",
                OnCheckStateChange = OnItemChanged,
                AutoLayout         = AutoLayout.DockTop
            }) as CheckBox;


            EdgeScrolling = panel.AddChild(new CheckBox
            {
                Text               = "Edge Scrolling",
                Tooltip            = "When checked, moving the cursor to the edge of the screen will move the camera.",
                OnCheckStateChange = OnItemChanged,
                AutoLayout         = AutoLayout.DockTop
            }) as CheckBox;

            FollowSurface = panel.AddChild(new CheckBox
            {
                Text               = "Camera Follows Surface Height",
                Tooltip            = "When checked, the camera will follow the ground surface height when moving.",
                OnCheckStateChange = OnItemChanged,
                AutoLayout         = AutoLayout.DockTop
            }) as CheckBox;

            PlayIntro = panel.AddChild(new CheckBox
            {
                Text               = "Play Intro",
                Tooltip            = "When checked, the intro animation will play at the beginning of the game.",
                OnCheckStateChange = OnItemChanged,
                AutoLayout         = AutoLayout.DockTop
            }) as CheckBox;

            FogOfWar = panel.AddChild(new CheckBox
            {
                Text               = "Fog Of War",
                Tooltip            = "When checked, unexplored tiles underground will be invisible.",
                OnCheckStateChange = OnItemChanged,
                AutoLayout         = AutoLayout.DockTop
            }) as CheckBox;

            var guiScaleItems = new List <String>();

            for (int i = 1; i < 10; ++i)
            {
                if (i * 480 <= GameSettings.Default.ResolutionY)
                {
                    guiScaleItems.Add(i.ToString());
                }
            }

            GuiScale = panel.AddChild(LabelAndDockWidget("Gui Scale", new ComboBox
            {
                Items = guiScaleItems
            })).GetChild(1) as ComboBox;
            GuiAutoScale = panel.AddChild(new CheckBox
            {
                Text               = "Autoscale GUI",
                Tooltip            = "When checked, the GUI will get scaled up on high resolution screens",
                OnCheckStateChange = OnItemChanged,
                AutoLayout         = AutoLayout.DockTop
            }) as CheckBox;

            DisableTutorialForAllGames = panel.AddChild(new CheckBox
            {
                Text               = "Disable the tutorial for all new games",
                Tooltip            = "When checked, the tutorial will not open in new games.",
                OnCheckStateChange = OnItemChanged,
                AutoLayout         = AutoLayout.DockTop
            }) as CheckBox;

            if (World != null)
            {
                EnableTutorial = panel.AddChild(new CheckBox
                {
                    Text               = "Enable Tutorial",
                    Tooltip            = "When checked, tutorial will be displayed.",
                    OnCheckStateChange = OnItemChanged,
                    AutoLayout         = AutoLayout.DockTop
                }) as CheckBox;

                panel.AddChild(new Widget
                {
                    Text               = "Reset tutorial",
                    MinimumSize        = new Point(0, 20),
                    AutoLayout         = AutoLayout.DockTop,
                    Padding            = new Margin(0, 0, 4, 4),
                    Border             = "border-button",
                    ChangeColorOnHover = true,
                    OnClick            = (sender, args) => World.TutorialManager.ResetTutorials()
                });
            }

            Autosave = panel.AddChild(new CheckBox
            {
                Text               = "Enable Autosave",
                Tooltip            = "When checked, game will auto save.",
                OnCheckStateChange = OnItemChanged,
                AutoLayout         = AutoLayout.DockTop
            }) as CheckBox;

            AutoSaveFrequency = panel.AddChild(LabelAndDockWidget("Autosave Frequency           ", new HorizontalSlider
            {
                ScrollArea      = 115,
                OnSliderChanged = (widget) =>
                {
                    AutoSaveFrequency.GetChild(0).Text = String.Format("Autosave Frequency ({0})",
                                                                       (widget as HorizontalSlider).ScrollPosition + 5);
                    this.OnItemChanged(widget);
                },
                Tooltip = "Minutes between auto saves"
            }));

            SaveLocation = panel.AddChild(LabelAndDockWidget("Save Location", new EditableTextField
            {
                Tooltip      = "Where to look for save games. Leave blank to use default location.",
                Text         = "",
                OnTextChange = this.OnItemChanged
            })).GetChild(1) as EditableTextField;
        }
Exemple #9
0
        public override void Construct()
        {
            Border      = "border-fancy";
            Font        = "font10";
            OnConstruct = (sender) =>
            {
                sender.Root.RegisterForUpdate(sender);

                FilterBox = AddChild(new EditableTextField
                {
                    AutoLayout  = AutoLayout.DockTop,
                    MinimumSize = new Point(0, 24),
                    Text        = ""
                }) as EditableTextField;

                ListView = AddChild(new WidgetListView
                {
                    AutoLayout = AutoLayout.DockFill,
                    SelectedItemForegroundColor = new Vector4(0, 0, 0, 1),
                    ChangeColorOnSelected       = false,
                    Border     = null,
                    ItemHeight = 24
                }) as WidgetListView;

                ListView.Border = null; // Can't make WidgetListView stop defaulting its border without breaking everywhere else its used.
            };

            OnUpdate = (sender, time) =>
            {
                if (sender.Hidden)
                {
                    return;
                }

                var roomsToDisplay = World.EnumerateZones().Where(r => !String.IsNullOrEmpty(FilterBox.Text) ? r.ID.Contains(FilterBox.Text) : true);

                int i = 0;
                ListView.ClearItems();
                foreach (var room in roomsToDisplay)
                {
                    i++;
                    var tag        = room.GuiTag as Widget;
                    var lambdaCopy = room;

                    if (tag != null)
                    {
                        ListView.AddItem(tag);
                    }
                    else
                    {
                        #region Create gui row

                        tag = Root.ConstructWidget(new Widget
                        {
                            Text              = room.GetDescriptionString(),
                            MinimumSize       = new Point(0, 16),
                            Padding           = new Margin(0, 0, 4, 4),
                            TextVerticalAlign = VerticalAlign.Center,
                            Background        = new TileReference("basic", 0),
                            BackgroundColor   = i % 2 == 0 ? new Vector4(0.0f, 0.0f, 0.0f, 0.1f) : new Vector4(0, 0, 0, 0.25f)
                        });

                        tag.OnUpdate = (sender1, args) =>
                        {
                            if (tag.IsAnyParentHidden())
                            {
                                return;
                            }

                            if (sender1.ComputeBoundingChildRect().Contains(Root.MousePosition))
                            {
                                Drawer3D.DrawBox(lambdaCopy.GetBoundingBox(), Color.White, 0.1f, true);
                            }
                        };

                        Root.RegisterForUpdate(tag);

                        tag.AddChild(new Button
                        {
                            Text               = "Destroy",
                            AutoLayout         = AutoLayout.DockRight,
                            MinimumSize        = new Point(16, 0),
                            ChangeColorOnHover = true,
                            TextVerticalAlign  = VerticalAlign.Center,
                            OnClick            = (_sender, args) =>
                            {
                                World.UserInterface.Gui.ShowModalPopup(new Gui.Widgets.Confirm
                                {
                                    Text    = "Do you want to destroy this " + lambdaCopy.Type.Name + "?",
                                    OnClose = (_sender2) => DestroyZoneTool.DestroyRoom((_sender2 as Gui.Widgets.Confirm).DialogResult, lambdaCopy, World)
                                });
                            }
                        });

                        tag.AddChild(new Widget {
                            MinimumSize = new Point(4, 0), AutoLayout = AutoLayout.DockRight
                        });

                        tag.AddChild(new Button
                        {
                            Text               = "Go to",
                            AutoLayout         = AutoLayout.DockRight,
                            ChangeColorOnHover = true,
                            MinimumSize        = new Point(16, 0),
                            TextVerticalAlign  = VerticalAlign.Center,
                            OnClick            = (_sender, args) =>
                            {
                                World.Renderer.Camera.SetZoomTarget(lambdaCopy.GetBoundingBox().Center());
                            }
                        });

                        if (lambdaCopy is Stockpile stock && stock.SupportsFilters)
                        {
                            tag.AddChild(new Button
                            {
                                Text               = "Resources...",
                                AutoLayout         = AutoLayout.DockRight,
                                ChangeColorOnHover = true,
                                MinimumSize        = new Point(16, 0),
                                TextVerticalAlign  = VerticalAlign.Center,
                                OnClick            = (_sender, args) =>
                                {
                                    var savePaused = World.Paused;
                                    World.Paused   = true;

                                    Root.ShowModalPopup(new StockpilePropertiesDialog
                                    {
                                        Stockpile = lambdaCopy as Stockpile,
                                        OnClose   = (_sen2) => World.Paused = savePaused
                                    });
                                }
                            });
                        }

                        #endregion

                        room.GuiTag = tag;
                        ListView.AddItem(tag);
                    }

                    tag.Text = room.GetDescriptionString();
                }

                ListView.Invalidate();
            };

            base.Construct();
        }