Example #1
0
        /// <summary>
        /// Inits the game debug window.
        /// </summary>
        public void InitGameDebugWindow()
        {
            // Remove Focus or game will think pause menu is open
            UI.SetFocusElement(null);

            // Create the Window and add it to the UI's root node
            var window = new Window();

            UI.Root.AddChild(window);

            // Set Window size and layout settings
            window.SetPosition(-150, -50);
            window.SetAlignment(HorizontalAlignment.Right, VerticalAlignment.Center);
            window.SetSize(550, 150);
            window.SetColor(new Color(0.2f, 0.2f, 0.2f, 0.5f));
            window.Name = "WindowDebug";

            // Create the Window title Text
            backWheelSpeedText = new Text {
                Name          = "back_wheel_speed",
                Value         = "0.0",
                TextAlignment = HorizontalAlignment.Right
            };

            backWheelSpeedText.SetFont("Fonts/Anonymous Pro.ttf", 20);
            backWheelSpeedText.SetColor(Color.Green);
            backWheelSpeedText.SetAlignment(HorizontalAlignment.Right, VerticalAlignment.Center);

            // Add the title bar to the Window
            window.AddChild(backWheelSpeedText);

            // Apply styles
            window.SetStyleAuto(null);
            backWheelSpeedText.SetStyleAuto(null);
        }
Example #2
0
 public NameTextPair(string name)
 {
     Name = name;
     Text = new Text
     {
         Value = name
     };
     //Text.SetStyle("FileViewText");
     Text.SetStyleAuto();
 }
Example #3
0
        public RangeSlider(string label, Single minRange, Single maxRange, int height = 35) : base()
        {
            this.minRange = minRange;
            this.maxRange = maxRange;
            this.SetLayout(LayoutMode.Horizontal, 10, new IntRect(0, 0, 0, 0));
            this.SetStyleAuto(null);
            this.SetFixedHeight(height);
            Label       = new Text();
            Label.Value = label;
            this.AddChild(Label);

            //set the label to adjust size depending on the length of the text
            Label.LayoutFlexScale = new Vector2(0, 0);
            Label.SetMinSize(0, 0);
            Label.SetFixedWidth(10 * label.Length);
            Label.SetAlignment(HorizontalAlignment.Left, VerticalAlignment.Center);
            Slider = new Slider();
            this.AddChild(Slider);

            //slider will respect height, but stretch horizontally
            Slider.SetMaxSize(100000, height);

            ValueEditor = new LineEdit();
            ValueEditor.SetStyleAuto(null);
            this.AddChild(ValueEditor);
            ValueEditor.SetMaxSize(100, 18);
            ValueEditor.SetFixedWidth(10 * 10);

            ValueEditor.VerticalAlignment             = VerticalAlignment.Center;
            ValueEditor.TextElement.VerticalAlignment = VerticalAlignment.Center;
            ValueEditor.TextElement.SetStyleAuto(null);

            //when the slider changes, set the value display and call the action function;
            Slider.SliderChanged += (args =>
            {
                ValueEditor.Text = " " + this.Value.ToString();
                var newargs = new RangeSliderEventArgs(args.Element, this.Value);
                this.SliderChanged(newargs);
            });

            ValueEditor.TextFinished += (args =>
            {
                Single value;
                if (Single.TryParse(args.Text, out value))
                {
                    this.Value = this.Clamp(value);
                }
            });

            Label.SetStyleAuto(null);
            Slider.SetStyleAuto(null);
        }
Example #4
0
        public LineEdit CreateField(string label, float initvalue)
        {
            Text labelText = new Text();

            labelText.Value = label;
            LineEdit ret = new LineEdit();

            ret.Text = initvalue.ToString();


            labelText.SetStyleAuto(null);
            ret.SetStyleAuto(null);
            this.AddChild(labelText);
            this.AddChild(ret);
            return(ret);
        }
Example #5
0
        void InitWindow()
        {
            // Create the Window and add it to the UI's root node
            window = new Window();
            uiRoot.AddChild(window);

            // Set Window size and layout settings
            window.SetMinSize(384, 192);
            window.SetLayout(LayoutMode.Vertical, 6, new IntRect(6, 6, 6, 6));
            window.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Center);
            window.Name = "Window";

            // Create Window 'titlebar' container
            UIElement titleBar = new UIElement();

            titleBar.SetMinSize(0, 24);
            titleBar.VerticalAlignment = VerticalAlignment.Top;
            titleBar.LayoutMode        = LayoutMode.Horizontal;

            // Create the Window title Text
            var windowTitle = new Text();

            windowTitle.Name  = "WindowTitle";
            windowTitle.Value = "Hello GUI!";

            // Create the Window's close button
            Button buttonClose = new Button();

            buttonClose.Name = "CloseButton";

            // Add the controls to the title bar
            titleBar.AddChild(windowTitle);
            titleBar.AddChild(buttonClose);

            // Add the title bar to the Window
            window.AddChild(titleBar);

            // Apply styles
            window.SetStyleAuto(null);
            windowTitle.SetStyleAuto(null);
            buttonClose.SetStyle("CloseButton", null);

            buttonClose.SubscribeToReleased(_ => Engine.Exit());

            // Subscribe also to all UI mouse clicks just to see where we have clicked
            UI.SubscribeToUIMouseClick(HandleControlClicked);
        }
        void InitWindow()
        {
            // Create the Window and add it to the UI's root node
            window = new Window();
            this.AddChild(window);

            // Set Window size and layout settings
            window.SetMinSize(application.Graphics.Width - 30, application.Graphics.Height / 2);
            window.SetLayout(LayoutMode.Vertical, 6, new IntRect(6, 6, 6, 6));
            window.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Center);
            window.Name = "Window";

            // Create Window 'titlebar' container
            UIElement titleBar = new UIElement();

            titleBar.SetMinSize(0, 24);
            titleBar.VerticalAlignment = VerticalAlignment.Top;
            titleBar.LayoutMode        = LayoutMode.Horizontal;

            // Create the Window title Text
            var windowTitle = new Text();

            windowTitle.Name  = "WindowTitle";
            windowTitle.Value = "Ethereum Settings";

            // Create the Window's close button
            Button buttonClose = new Button();

            buttonClose.Name = "CloseButton";

            // Add the controls to the title bar
            titleBar.AddChild(windowTitle);
            titleBar.AddChild(buttonClose);

            // Add the title bar to the Window
            window.AddChild(titleBar);

            // Apply styles
            window.SetStyleAuto(null);
            windowTitle.SetStyleAuto(null);
            buttonClose.SetStyle("CloseButton", null);

            windowTitle.SetFont(application.ResourceCache.GetFont(Assets.Fonts.Font), application.Graphics.Width / 30);

            buttonClose.SubscribeToReleased(_ => this.Visible = false);
        }
Example #7
0
            void FillResolutions()
            {
                var resolutionsElement = Resolutions;

                foreach (var resolution in Game.Config.SupportedResolutions)
                {
                    Text text = new Text {
                        Value = resolution.ToString()
                    };


                    resolutionsElement.AddItem(text);

                    //NOTE:Maybe text style
                    text.SetStyleAuto();
                }
            }
Example #8
0
        public static Text GetText(string text, string style = "")
        {
            var txt = new Text();

            if (string.IsNullOrEmpty(style))
            {
                txt.SetStyleAuto();
            }
            else
            {
                txt.SetStyle(style);
            }
            txt.Value     = text;
            txt.MinHeight = 20;
            txt.MinWidth  = 100;
            return(txt);
        }
Example #9
0
            void FillPathFindingVisualization()
            {
                var pahtfindingElement = PathFindingVisualization;

                foreach (var visualization in Game.Config.SupportedPathFindingVisualizations)
                {
                    Text text = new Text
                    {
                        Value = visualization.ToString()
                    };


                    pahtfindingElement.AddItem(text);

                    //NOTE:Maybe text style
                    text.SetStyleAuto();
                }
            }
Example #10
0
        void InitWindow()
        {
            // Create the Window and add it to the UI's root node
            window = new Window();
            uiRoot.AddChild(window);
            // Set Window size and layout settings
            window.SetPosition(184, 68);
            window.SetSize(78, 40);
            window.SetColor(Color.Transparent);
            //window.SetLayout(LayoutMode.Horizontal, 0, new IntRect(3, 3, 3, 3));
            window.SetAlignment(HorizontalAlignment.Left, VerticalAlignment.Top);
            window.Name = "Window";

            // Create Window 'titlebar' container
            UIElement titleBar = new UIElement();

            titleBar.SetAlignment(HorizontalAlignment.Right, VerticalAlignment.Center);
            //titleBar.SetLayout(LayoutMode.Horizontal, 0, new IntRect(0, 0, 0, 0));

            // Create the Window title Text
            var windowTitle = new Text {
                Name          = "WindowCoins",
                Value         = "9999",
                TextAlignment = HorizontalAlignment.Right
            };

            windowTitle.SetFont("Fonts/Anonymous Pro.ttf", 20);
            windowTitle.SetAlignment(HorizontalAlignment.Right, VerticalAlignment.Center);

            // Add the controls to the title bar
            titleBar.AddChild(windowTitle);

            // Add the title bar to the Window
            window.AddChild(titleBar);

            // Apply styles
            window.SetStyleAuto(null);
            windowTitle.SetStyleAuto(null);

            /////////
            CreateUserControls();
        }
Example #11
0
            void FillWindowTypes()
            {
                var windowTypes = new List <string>();

                windowTypes.Insert((int)WindowTypeEnum.Windowed, WindowTypeToString(WindowTypeEnum.Windowed));
                windowTypes.Insert((int)WindowTypeEnum.BorderlessWindowed, WindowTypeToString(WindowTypeEnum.BorderlessWindowed));
                windowTypes.Insert((int)WindowTypeEnum.Fullscreen, WindowTypeToString(WindowTypeEnum.Fullscreen));

                var windowTypesElement = WindowTypes;

                foreach (var type in windowTypes)
                {
                    Text text = new Text {
                        Value = type
                    };


                    windowTypesElement.AddItem(text);

                    //NOTE:Maybe text style
                    text.SetStyleAuto();
                }
            }
Example #12
0
        public Uroh_Msg(UIElement rootui, string msg, string title)
        {
            // Create the Window and add it to the UI's root node
            window = new Window();
            rootui.AddChild(window);

            // Set Window size and layout settings
            window.SetMinSize(384, 192);
            window.SetLayout(LayoutMode.Vertical, 6, new IntRect(6, 6, 6, 6));
            window.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Center);
            window.Name = "Window";

            // Create Window 'titlebar' container
            UIElement titleBar = new UIElement();

            titleBar.MaxHeight = 20;
            var brd = titleBar.CreateBorderImage();

            brd.SetColor(new Color(0.22f, 0.22f, 0.22f, 1));
            brd.LayoutMode = LayoutMode.Horizontal;

            titleBar.VerticalAlignment = Urho.Gui.VerticalAlignment.Top;
            titleBar.LayoutMode        = LayoutMode.Horizontal;

            // Create the Window title Text
            var windowTitle = new Text();

            windowTitle.Name  = "WindowTitle";
            windowTitle.Value = title;

            var windowmsg = new Text();

            windowmsg.Value             = msg;
            windowmsg.VerticalAlignment = VerticalAlignment.Top;

            // Create the Window's close button
            Button buttonClose = new Button();

            buttonClose.Name = "CloseButton";

            // Add the controls to the title bar
            brd.AddChild(windowTitle);
            brd.AddChild(buttonClose);

            // Add the title bar to the Window
            window.AddChild(titleBar);
            window.AddChild(windowmsg);

            // Apply styles
            window.SetStyleAuto();

            windowmsg.SetStyleAuto();
            windowTitle.SetStyleAuto();

            buttonClose.SetStyle("CloseButton", null);

            buttonClose.SubscribeToReleased(_ => window.Remove());

            // Subscribe also to all UI mouse clicks just to see where we have clicked
            //	UI.SubscribeToUIMouseClick(HandleControlClicked);
        }
Example #13
0
        protected override void Start()
        {
            var ui = UI;

            ui.Scale = 2f;
            ui.Root.SetDefaultStyle(CoreAssets.UIs.DefaultStyle);

            // Create the Window and add it to the UI's root node
            var window = new Window();

            ui.Root.AddChild(window);

            // Set Window size and layout settings
            window.SetMinSize(384, 192);
            window.SetLayout(LayoutMode.Vertical, 6, new IntRect(6, 6, 6, 6));
            window.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Center);
            window.Name = "Window";

            // Create Window 'titlebar' container
            var titleBar = new UIElement();

            titleBar.SetMinSize(0, 24);
            titleBar.VerticalAlignment = VerticalAlignment.Top;
            titleBar.LayoutMode        = LayoutMode.Horizontal;

            // Create the Window title Text
            var windowTitle = new Text
            {
                Name  = "WindowTitle",
                Value = "Hello GUI!"
            };

            // Create the Window's close button
            var buttonClose = new Button
            {
                Name = "CloseButton"
            };

            // Add the controls to the title bar
            titleBar.AddChild(windowTitle);
            titleBar.AddChild(buttonClose);

            // Add the title bar to the Window
            window.AddChild(titleBar);

            // Apply styles
            window.SetStyleAuto(null);
            windowTitle.SetStyleAuto(null);
            buttonClose.SetStyle("CloseButton", null);

            buttonClose.Released += args =>
            {
                window.Visible = false;
            };

            // Subscribe also to all UI mouse clicks just to see where we have clicked
            UI.UIMouseClick += args =>
            {
            };


            for (int i = 0; i < 4; i++)
            {
                // Create a CheckBox
                var checkBox = new CheckBox
                {
                    Name = "CheckBox"
                };
                // Add controls to Window
                window.AddChild(checkBox);
                // Apply previously set default style
                checkBox.SetStyleAuto(null);
            }

            for (int i = 0; i < 4; i++)
            {
                // Create a Button
                var button = new Button
                {
                    Name      = "Button",
                    MinHeight = 24
                };
                window.AddChild(button);
                button.SetStyleAuto(null);
            }

            for (int i = 0; i < 8; i++)
            {
                // Create a LineEdit
                var lineEdit = new LineEdit
                {
                    Name      = "LineEdit",
                    MinHeight = 24
                };
                window.AddChild(lineEdit);
                lineEdit.SetStyleAuto(null);
                // TODO
                //lineEdit.Focused += args =>
                //{
                //};
            }
        }
        void InitWindow()
        {
            // Create the Window and add it to the UI's root node
            window = new Window();
            uiRoot.AddChild(window);

            // Set Window size and layout settings
            window.SetMinSize(384, 192);
            window.SetLayout(LayoutMode.Vertical, 6, new IntRect(6, 6, 6, 6));
            window.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Center);
            window.Name = "Window";

            // Create Window 'titlebar' container
            UIElement titleBar = new UIElement();
            titleBar.SetMinSize(0, 24);
            titleBar.VerticalAlignment = VerticalAlignment.Top;
            titleBar.LayoutMode = LayoutMode.Horizontal;

            // Create the Window title Text
            var windowTitle = new Text();
            windowTitle.Name = "WindowTitle";
            windowTitle.Value = "Hello GUI!";

            // Create the Window's close button
            Button buttonClose = new Button();
            buttonClose.Name = "CloseButton";

            // Add the controls to the title bar
            titleBar.AddChild(windowTitle);
            titleBar.AddChild(buttonClose);

            // Add the title bar to the Window
            window.AddChild(titleBar);

            // Apply styles
            window.SetStyleAuto(null);
            windowTitle.SetStyleAuto(null);
            buttonClose.SetStyle("CloseButton", null);

            buttonClose.SubscribeToReleased(_ => Engine.Exit());

            // Subscribe also to all UI mouse clicks just to see where we have clicked
            UI.SubscribeToUIMouseClick(HandleControlClicked);
        }