Exemplo n.º 1
0
        private void drawUI()
        {
            //draw font for X
            x = new Text();
            x.SetAlignment(horizontal, vertical);
            x.Position = new IntVector2(positionXx, positionYx);
            x.Name     = "X";
            x.Value    = "Nama = ";
            x.SetFont(ui_font, font_small);
            x.SetColor(uicolor);
            ui_node.AddChild(x);

            //draw font for Y
            y = new Text();
            y.SetAlignment(horizontal, vertical);
            y.Position = new IntVector2(positionXy, positionYy);
            y.Name     = "Y";
            y.Value    = "Perintah = ";
            y.SetFont(ui_font, font_small);
            y.SetColor(uicolor);
            ui_node.AddChild(y);

            //draw font for Y
            z = new Text();
            z.SetAlignment(horizontal, vertical);
            z.Position = new IntVector2(positionXz, positionYz);
            z.Name     = "Z";
            z.Value    = "Perintah = ";
            z.SetFont(ui_font, font_small);
            z.SetColor(uicolor);
            ui_node.AddChild(z);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
 public MaterialPanel(UIElement parent, MaterialHelper mh, ResourceCache r) : base(r)
 {
     this.material = mh;
     parent.AddChild(this);
     this.material.SetAll();
     this.Name = "MaterialPanel";
     this.SetupPanel();
 }
Exemplo n.º 5
0
        private void drawUI()
        {
            //draw font for X
            x = new Text();
            x.SetAlignment(horizontal, vertical);
            x.Position = new IntVector2(positionXx, positionYx);
            x.Name     = "X";
            x.Value    = "X = ";
            x.SetFont(ui_font, font_large);
            x.SetColor(uicolor);
            ui_node.AddChild(x);

            //draw font for Y
            y = new Text();
            y.SetAlignment(horizontal, vertical);
            y.Position = new IntVector2(positionXy, positionYy);
            y.Name     = "Y";
            y.Value    = "Y = ";
            y.SetFont(ui_font, font_large);
            y.SetColor(uicolor);
            ui_node.AddChild(y);

            //draw font for Z
            z = new Text();
            z.SetAlignment(horizontal, vertical);
            z.Position = new IntVector2(positionXz, positionYz);
            z.Name     = "Z";
            z.Value    = "Z = ";
            z.SetFont(ui_font, font_large);
            z.SetColor(uicolor);
            ui_node.AddChild(z);

            //draw font for RMQ
            rmq = new Text();
            rmq.SetAlignment(horizontal, vertical);
            rmq.Position = new IntVector2(positionXz, positionYz);
            rmq.Name     = "RMQ";
            rmq.Value    = "RMQ = ";
            rmq.SetFont(ui_font, font_large);
            rmq.SetColor(uicolor);
            ui_node.AddChild(z);
        }
Exemplo n.º 6
0
        public static Text CreateText(UIElement parent, ScreenInfoRatio screenInfo, Font font, int fontSize, int xPos, int yPos, HorizontalAlignment hAlign, VerticalAlignment vAlign)
        {
            var text = new Text();

            parent.AddChild(text);

            text.SetAlignment(hAlign, vAlign);
            text.SetPosition(screenInfo.SetX(xPos), screenInfo.SetY(yPos));
            text.SetFont(font, screenInfo.SetX(fontSize));
            text.SetColor(Color.Black);

            return(text);
        }
Exemplo n.º 7
0
        void CreateUI()
        {
            IsLogoVisible = false;             // We need the full rendering window

            var       graphics = Graphics;
            UIElement root     = UI.Root;
            var       cache    = ResourceCache;
            XmlFile   uiStyle  = cache.GetXmlFile("UI/DefaultStyle.xml");

            // Set style to the UI root so that elements will inherit it
            root.SetDefaultStyle(uiStyle);

            Font font = cache.GetFont("Fonts/Anonymous Pro.ttf");

            chatHistoryText = new Text();
            chatHistoryText.SetFont(font, 12);
            root.AddChild(chatHistoryText);

            buttonContainer = new UIElement();
            root.AddChild(buttonContainer);
            buttonContainer.SetFixedSize(graphics.Width, 20);
            buttonContainer.SetPosition(0, graphics.Height - 20);
            buttonContainer.LayoutMode = LayoutMode.Horizontal;

            textEdit = new LineEdit();
            textEdit.SetStyleAuto(null);
            buttonContainer.AddChild(textEdit);

            sendButton        = CreateButton("Send", 70);
            connectButton     = CreateButton("Connect", 90);
            disconnectButton  = CreateButton("Disconnect", 100);
            startServerButton = CreateButton("Start Server", 110);

            UpdateButtons();

            // No viewports or scene is defined. However, the default zone's fog color controls the fill color
            Renderer.DefaultZone.FogColor = new Color(0.0f, 0.0f, 0.1f);
        }
Exemplo n.º 8
0
        public void SetupUI()
        {
            AvatarStatusElement = new UIElement();
            UI.Root.AddChild(AvatarStatusElement);

            AvatarStatusElement.EnableAnchor = true;
            AvatarStatusElement.SetMaxAnchor(0.125f, 0.125f);
            AvatarStatusElement.SetMinAnchor(0, 0);

            var text = new Text();

            text.Value = "Walking";
            text.HorizontalAlignment = HorizontalAlignment.Left;
            text.VerticalAlignment   = VerticalAlignment.Top;
            text.SetFont(ResourceCache.GetFont("fonts/Open_Sans/OpenSans-Regular.ttf"), 14);
            text.Position = new IntVector2(10, 0);
            text.SetColor(Color.Gray);
            text.SetMaxAnchor(1, 1);
            text.SetMinAnchor(0, 0);
            AvatarStatusElement.AddChild(text);

            PlayerNode.GetComponent <PlayerAvatarController>().FlightStatusChanged += new EventHandler((o, e) => text.Value = (o as PlayerAvatarController).Flying ? "Flying" : "Walking");

            PostionGUI       = new Text();
            PostionGUI.Value = "X0 Y0 Z0";
            PostionGUI.HorizontalAlignment = HorizontalAlignment.Left;
            PostionGUI.VerticalAlignment   = VerticalAlignment.Top;
            PostionGUI.SetFont(ResourceCache.GetFont("fonts/Open_Sans/OpenSans-Regular.ttf"), 14);
            PostionGUI.Position = new IntVector2(10, 20);
            PostionGUI.SetColor(Color.Gray);
            PostionGUI.SetMaxAnchor(1, 1);
            PostionGUI.SetMinAnchor(0, 0);
            AvatarStatusElement.AddChild(PostionGUI);

            var debug = new MonoDebugHud(this);

            debug.Show(Color.Gray);
        }
Exemplo n.º 9
0
        // This method is called every tick and updates the HUD values
        private void UpdateHUD()
        {
            if (gameover)
            {
                return;
            }

            InvokeOnMain(() =>
            {
                hud.RemoveAllChildren();

                var difficulty = new Text()
                {
                    Value = hardcore ? "Difficulty: Hardcore" : "Difficulty: Normal"
                };
                var weapon = new Text()
                {
                    Value = $"Weapon: {PlayerCharacter.HeldWeapon.Serialize()}"
                };
                var armor = new Text()
                {
                    Value = PlayerCharacter.Armor ? "Armor: Protected" : "Armor: Missing"
                };
                var health = new Text()
                {
                    Value = $"Health: {PlayerCharacter.Health.ToString()}"
                };
                var clock = new Text()
                {
                    Value = $"Time: {TimeSpan.FromSeconds(time / 10).ToString(@"mm\:ss")}"
                };
                var score = new Text()
                {
                    Value = $"Score: {PlayerCharacter.Score.ToString()}"
                };

                difficulty.SetColor(Color.Red);
                weapon.SetColor(Color.Red);
                armor.SetColor(Color.Red);
                health.SetColor(Color.Red);
                clock.SetColor(Color.Red);
                score.SetColor(Color.Red);

                difficulty.SetFont(font: ResourceCache.GetFont("fonts/FiraSans-Regular.otf"), size: 15);
                weapon.SetFont(font: ResourceCache.GetFont("fonts/FiraSans-Regular.otf"), size: 15);
                armor.SetFont(font: ResourceCache.GetFont("fonts/FiraSans-Regular.otf"), size: 15);
                health.SetFont(font: ResourceCache.GetFont("fonts/FiraSans-Regular.otf"), size: 15);
                clock.SetFont(font: ResourceCache.GetFont("fonts/FiraSans-Regular.otf"), size: 15);
                score.SetFont(font: ResourceCache.GetFont("fonts/FiraSans-Regular.otf"), size: 15);

                hud.AddChild(difficulty);
                hud.AddChild(weapon);
                hud.AddChild(armor);
                hud.AddChild(health);
                hud.AddChild(clock);
                hud.AddChild(score);
            });
        }
Exemplo n.º 10
0
        public static Button CreateButton(UIElement parent, ScreenInfoRatio screenInfo, int posX, int posY, int width, int height, HorizontalAlignment hAlign, VerticalAlignment vAlign)
        {
            Button button = new Button();

            parent.AddChild(button);

            button.SetStyleAuto(null);
            button.SetPosition(screenInfo.SetX(posX), screenInfo.SetY(posY));
            button.SetAlignment(hAlign, vAlign);
            button.SetSize(screenInfo.SetX(width), screenInfo.SetY(height));
            button.SetColor(Color.White);

            return(button);
        }
Exemplo n.º 11
0
        Slider CreateSlider(int x, int y, int xSize, int ySize, string text)
        {
            UIElement     root  = UI.Root;
            ResourceCache cache = ResourceCache;
            Font          font  = cache.GetFont("Fonts/Anonymous Pro.ttf");
            // Create text and slider below it
            Text sliderText = new Text();

            root.AddChild(sliderText);
            sliderText.SetPosition(x, y);
            sliderText.SetFont(font, 12);
            sliderText.Value = text;

            Slider slider = new Slider();

            root.AddChild(slider);
            slider.SetStyleAuto(null);
            slider.SetPosition(x, y + 20);
            slider.SetSize(xSize, ySize);
            // Use 0-1 range for controlling sound/music master volume
            slider.Range = 1.0f;

            return(slider);
        }
Exemplo n.º 12
0
        private static ToolTip SetToolTip(this UIElement ele, string tip)
        {
            // Add a tooltip to Fish button
            ToolTip toolTip = new ToolTip();

            toolTip.Position = new IntVector2(ele.Width + 5, ele.Width / 2);
            // slightly offset from close button
            BorderImage textHolder = new BorderImage();

            toolTip.AddChild(textHolder);
            textHolder.SetStyle("ToolTipBorderImage", null);
            var toolTipText = GetText(tip, "ToolTipText");

            textHolder.AddChild(toolTipText);
            ele.AddChild(toolTip);
            return(toolTip);
        }
Exemplo n.º 13
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();
        }
Exemplo n.º 14
0
        Button CreateButton(string text, int width)
        {
            var  cache = ResourceCache;
            Font font  = cache.GetFont("Fonts/Anonymous Pro.ttf");

            Button button = new Button();

            buttonContainer.AddChild(button);
            button.SetStyleAuto(null);
            button.SetFixedWidth(width);

            var buttonText = new Text();

            button.AddChild(buttonText);
            buttonText.SetFont(font, 12);
            buttonText.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Center);

            buttonText.Value = text;

            return(button);
        }
Exemplo n.º 15
0
        //public ListKotakTarget ()
        //{

        //}

        public KotakTarget(int topleft_x, int topleft_y, int bottomright_x, int bottomright_y, UIElement ui_root, Context con, Texture kotak)
        {
            //Debug.WriteLine("Mulai ");
            root          = ui_root;
            context       = con;
            topleft.x     = topleft_x; topleft.y = topleft_y;
            topright.x    = bottomright_x; topright.y = topleft_y;
            bottomright.x = bottomright_x; bottomright.y = bottomright_y;
            bottomleft.x  = topleft_x; bottomleft.y = bottomright_y;

            tlx = topleft_x; tly = topleft_y; brx = bottomright_x; bry = bottomright_y;

            titiktengah.x = ((tlx + brx) / 2); titiktengah.y = ((tly + bry) / 2);

            bounding_box         = new Sprite(context);
            bounding_box.Texture = kotak;
            bounding_box.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Center);
            bounding_box.Position = new IntVector2(topleft.x, topleft.y);
            bounding_box.SetSize(Math.Abs(bottomright.x - topleft.x), Math.Abs(topleft.y - bottomright.y));
            root.AddChild(bounding_box);
            //Debug.WriteLine("Show bounding box ok ");
        }
Exemplo n.º 16
0
        Button CreateButton(int x, int y, int xSize, int ySize, string text)
        {
            UIElement root  = UI.Root;
            var       cache = ResourceCache;
            Font      font  = cache.GetFont("Fonts/Anonymous Pro.ttf");

            // Create the button and center the text onto it
            Button button = new Button();

            root.AddChild(button);
            button.SetStyleAuto(null);
            button.SetPosition(x, y);
            button.SetSize(xSize, ySize);

            Text buttonText = new Text();

            button.AddChild(buttonText);
            buttonText.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Center);
            buttonText.SetFont(font, 12);
            buttonText.Value = text;

            return(button);
        }
Exemplo n.º 17
0
        void CreateGUI()
        {
            var cache = ResourceCache;
            UI  ui    = UI;

            UIElement root = ui.Root;

            // Load the style sheet from xml
            root.SetDefaultStyle(cache.GetXmlFile("UI/DefaultStyle.xml"));

            for (int i = 0; i < 10; i++)
            {
                Button b = new Button();
                root.AddChild(b);
                // Reference a style from the style sheet loaded earlier:
                b.SetStyle("Button", null);
                b.SetSize(300, 100);
                b.Position = new IntVector2(50 * i, 50 * i);

                b.SubscribeToDragMove(HandleDragMove);
                b.SubscribeToDragBegin(HandleDragBegin);
                b.SubscribeToDragCancel(HandleDragCancel);
                b.SubscribeToDragEnd(HandleDragEnd);

                {
                    var t = new Text();
                    b.AddChild(t);
                    t.SetStyle("Text", null);
                    t.HorizontalAlignment = HorizontalAlignment.Center;
                    t.VerticalAlignment   = VerticalAlignment.Center;
                    t.Name = ("Text");
                }

                {
                    var t = new Text();
                    b.AddChild(t);
                    t.SetStyle("Text", null);
                    t.Name = ("Event Touch");
                    t.HorizontalAlignment = HorizontalAlignment.Center;
                    t.VerticalAlignment   = VerticalAlignment.Bottom;
                }

                {
                    var t = new Text();
                    b.AddChild(t);
                    t.SetStyle("Text", null);
                    t.Name = ("Num Touch");
                    t.HorizontalAlignment = HorizontalAlignment.Center;
                    t.VerticalAlignment   = VerticalAlignment.Top;
                }
            }

            for (int i = 0; i < 10; i++)
            {
                var t = new Text();
                root.AddChild(t);
                t.SetStyle("Text", null);
                t.Name    = ("Touch " + i);
                t.Visible = false;
            }
        }
Exemplo n.º 18
0
        void CreateTopBar()
        {
            var generic_bts = cache.GetTexture2D("Textures/Generic/generic_btn.png");

            black_bar = root.CreateSprite();
            root.AddChild(black_bar);
            black_bar.Texture = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.TopBar.ResourcePath);
            black_bar.Opacity = 0.5f;
            black_bar.SetPosition(0, (int)(dim.YScreenRatio * 30));
            black_bar.SetSize((int)(dim.XScreenRatio * 2000), (int)(dim.YScreenRatio * 140));
            black_bar.ImageRect = AssetsCoordinates.Generic.TopBar.Rectangle;

            // BACK
            Button btn_back = new Button();

            root.AddChild(btn_back);
            btn_back.SetStyleAuto(null);
            btn_back.SetPosition((int)(dim.XScreenRatio * 40), (int)(dim.YScreenRatio * 40));
            btn_back.SetSize((int)(dim.XScreenRatio * 120), (int)(dim.YScreenRatio * 120));
            btn_back.Texture   = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Icons.ResourcePath);
            btn_back.ImageRect = AssetsCoordinates.Generic.Icons.BntBack;
            btn_back.Pressed  += args => {
                if (_isUserProfile)
                {
                    GameInstance.LaunchScene(GameScenesEnumeration.USER_PROFILE);
                }
                else
                {
                    GameInstance.LaunchScene(GameScenesEnumeration.MENU);
                }
            };

            if (VehicleManager.Instance.UnlockedVehicles.VehicleModel.Count == 0)
            {
#if __ANDROID__
                btn_back.Visible = false;
#else
                btn_back.Visible = true;
#endif
            }


            //COINS
            Button coins = new Button();
            root.AddChild(coins);
            coins.SetStyleAuto(null);
            coins.SetPosition((int)(dim.XScreenRatio * 180), (int)(dim.YScreenRatio * 60));
            coins.SetSize((int)(dim.XScreenRatio * 75), (int)(dim.YScreenRatio * 70));
            coins.Texture   = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Icons.ResourcePath);
            coins.ImageRect = AssetsCoordinates.Generic.Icons.IconCoin;


            //Wallet text
            Text wallet = new Text();
            coins.AddChild(wallet);
            wallet.SetPosition((int)(dim.XScreenRatio * 90), (int)(dim.YScreenRatio * 10));
            wallet.SetFont(font, dim.XScreenRatio * 30);
            int wallet_tot = CharacterManager.Instance.Wallet;

            wallet.Value = "" + wallet_tot;

            // SCREEN TITLE
            Button screen_title = new Button();
            root.AddChild(screen_title);
            screen_title.SetStyleAuto(null);
            screen_title.SetPosition((int)(dim.XScreenRatio * 1500), (int)(dim.YScreenRatio * 50));
            screen_title.SetSize((int)(dim.XScreenRatio * 400), (int)(dim.YScreenRatio * 100));
            screen_title.Texture   = generic_bts;
            screen_title.Enabled   = false;
            screen_title.ImageRect = new IntRect(0, 110, 513, 213);
            Text buttonTitleText = new Text();
            screen_title.AddChild(buttonTitleText);
            buttonTitleText.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Center);
            buttonTitleText.SetPosition(0, 0);
            buttonTitleText.SetFont(font, dim.XScreenRatio * 30);
            buttonTitleText.Value = "CHARACTER";

            screen_info = new Text();
            screen_title.AddChild(screen_info);
            screen_info.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Center);
            screen_info.SetPosition((int)(dim.XScreenRatio * -100), (int)(dim.YScreenRatio * 80));
            screen_info.SetFont(font, dim.XScreenRatio * 20);
            screen_info.SetColor(Color.White);
            //screen_info.Value = "Please enter a name and select an character.";
            screen_info.Value = "Please select a character.";
        }
Exemplo n.º 19
0
 public NodePanel(UIElement Parent, Node Node, ResourceCache Cache) : base(Cache)
 {
     Parent.AddChild(this);
     this.Node = Node;
     this.SetupPanel();
 }
Exemplo n.º 20
0
 private void AddCore(View item)
 {
     _owner.AddChild(item);
 }
Exemplo n.º 21
0
        void CreateUI()
        {
            IsLogoVisible = false; // We need the full rendering window

            var graphics = Graphics;
            UIElement root = UI.Root;
            var cache = ResourceCache;
            XmlFile uiStyle = cache.GetXmlFile("UI/DefaultStyle.xml");
            // Set style to the UI root so that elements will inherit it
            root.SetDefaultStyle(uiStyle);

            Font font = cache.GetFont("Fonts/Anonymous Pro.ttf");
            chatHistoryText = new Text();
            chatHistoryText.SetFont(font, 12);
            root.AddChild(chatHistoryText);

            buttonContainer = new UIElement();
            root.AddChild(buttonContainer);
            buttonContainer.SetFixedSize(graphics.Width, 20);
            buttonContainer.SetPosition(0, graphics.Height - 20);
            buttonContainer.LayoutMode = LayoutMode.Horizontal;

            textEdit = new LineEdit();
            textEdit.SetStyleAuto(null);
            buttonContainer.AddChild(textEdit);

            sendButton = CreateButton("Send", 70);
            connectButton = CreateButton("Connect", 90);
            disconnectButton = CreateButton("Disconnect", 100);
            startServerButton = CreateButton("Start Server", 110);

            UpdateButtons();

            // No viewports or scene is defined. However, the default zone's fog color controls the fill color
            Renderer.DefaultZone.FogColor = new Color(0.0f, 0.0f, 0.1f);
        }
Exemplo n.º 22
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);
        }
        private void drawUI()
        {
            //Sensor ID1
            //draw font for X
            x = new Text();
            x.SetAlignment(horizontal, vertical);
            x.Position = new IntVector2(positionXx, positionYx);
            x.Name     = "X";
            x.Value    = "Temperatur = ";
            x.SetFont(ui_font, font_small);
            x.SetColor(uicolor);
            ui_node.AddChild(x);

            //draw font for Y
            y = new Text();
            y.SetAlignment(horizontal, vertical);
            y.Position = new IntVector2(positionXy, positionYy);
            y.Name     = "Y";
            y.Value    = "Kelembapan = ";
            y.SetFont(ui_font, font_small);
            y.SetColor(uicolor);
            ui_node.AddChild(y);

            //draw font for Z
            z = new Text();
            z.SetAlignment(horizontal, vertical);
            z.Position = new IntVector2(positionXz, positionYz);
            z.Name     = "Z";
            z.Value    = "Intensitas Cahaya = ";
            z.SetFont(ui_font, font_small);
            z.SetColor(uicolor);
            ui_node.AddChild(z);


            //draw font for a
            a = new Text();
            a.SetAlignment(horizontal, vertical);
            a.Position = new IntVector2(positionXa, positionYa);
            a.Name     = "A";
            a.Value    = "Kebisingan Suara" +
                         " = ";
            a.SetFont(ui_font, font_small);
            a.SetColor(uicolor);
            ui_node.AddChild(a);

            //Sensor ID2
            //draw font for X
            x1 = new Text();
            x1.SetAlignment(horizontal, vertical);
            x1.Position = new IntVector2(positionXx1, positionYx1);
            x1.Name     = "X1";
            x1.Value    = "Temperatur = ";
            x1.SetFont(ui_font, font_small);
            x1.SetColor(uicolor);
            ui_node.AddChild(x1);

            //draw font for Y
            y1 = new Text();
            y1.SetAlignment(horizontal, vertical);
            y1.Position = new IntVector2(positionXy1, positionYy1);
            y1.Name     = "Y1";
            y1.Value    = "Kelembapan = ";
            y1.SetFont(ui_font, font_small);
            y1.SetColor(uicolor);
            ui_node.AddChild(y1);

            //draw font for Z
            z1 = new Text();
            z1.SetAlignment(horizontal, vertical);
            z1.Position = new IntVector2(positionXz1, positionYz1);
            z1.Name     = "Z1";
            z1.Value    = "Intensitas Cahaya = ";
            z1.SetFont(ui_font, font_small);
            z1.SetColor(uicolor);
            ui_node.AddChild(z1);


            //draw font for a
            a1 = new Text();
            a1.SetAlignment(horizontal, vertical);
            a1.Position = new IntVector2(positionXa1, positionYa1);
            a1.Name     = "A1";
            a1.Value    = "Kebisingan Suara" +
                          " = ";
            a1.SetFont(ui_font, font_small);
            a1.SetColor(uicolor);
            ui_node.AddChild(a1);

            //Sensor ID3
            //draw font for X
            x2 = new Text();
            x2.SetAlignment(horizontal, vertical);
            x2.Position = new IntVector2(positionXx2, positionYx2);
            x2.Name     = "X2";
            x2.Value    = "Temperatur = ";
            x2.SetFont(ui_font, font_small);
            x2.SetColor(uicolor);
            ui_node.AddChild(x2);

            //draw font for Y
            y2 = new Text();
            y2.SetAlignment(horizontal, vertical);
            y2.Position = new IntVector2(positionXy2, positionYy2);
            y2.Name     = "Y2";
            y2.Value    = "Kelembapan = ";
            y2.SetFont(ui_font, font_small);
            y2.SetColor(uicolor);
            ui_node.AddChild(y2);

            //draw font for Z
            z2 = new Text();
            z2.SetAlignment(horizontal, vertical);
            z2.Position = new IntVector2(positionXz2, positionYz2);
            z2.Name     = "Z2";
            z2.Value    = "Intensitas Cahaya = ";
            z2.SetFont(ui_font, font_small);
            z2.SetColor(uicolor);
            ui_node.AddChild(z2);


            //draw font for a
            a2 = new Text();
            a2.SetAlignment(horizontal, vertical);
            a2.Position = new IntVector2(positionXa2, positionYa2);
            a2.Name     = "A2";
            a2.Value    = "Kebisingan Suara" +
                          " = ";
            a2.SetFont(ui_font, font_small);
            a2.SetColor(uicolor);
            ui_node.AddChild(a2);

            //Sensor ID4
            //draw font for X
            x3 = new Text();
            x3.SetAlignment(horizontal, vertical);
            x3.Position = new IntVector2(positionXx3, positionYx3);
            x3.Name     = "X3";
            x3.Value    = "Temperatur = ";
            x3.SetFont(ui_font, font_small);
            x3.SetColor(uicolor);
            ui_node.AddChild(x3);

            //draw font for Y
            y3 = new Text();
            y3.SetAlignment(horizontal, vertical);
            y3.Position = new IntVector2(positionXy3, positionYy3);
            y3.Name     = "Y3";
            y3.Value    = "Kelembapan = ";
            y3.SetFont(ui_font, font_small);
            y3.SetColor(uicolor);
            ui_node.AddChild(y3);

            //draw font for Z
            z3 = new Text();
            z3.SetAlignment(horizontal, vertical);
            z3.Position = new IntVector2(positionXz3, positionYz3);
            z3.Name     = "Z3";
            z3.Value    = "Intensitas Cahaya = ";
            z3.SetFont(ui_font, font_small);
            z3.SetColor(uicolor);
            ui_node.AddChild(z3);


            //draw font for a
            a3 = new Text();
            a3.SetAlignment(horizontal, vertical);
            a3.Position = new IntVector2(positionXa3, positionYa3);
            a3.Name     = "A3" +
                          "";
            a3.Value = "Kebisingan Suara" + " = ";
            a3.SetFont(ui_font, font_small);
            a3.SetColor(uicolor);
            ui_node.AddChild(a3);
        }
Exemplo n.º 24
0
        void CreateTopBar()
        {
            _blackBar = _root.CreateSprite();
            _root.AddChild(_blackBar);
            _blackBar.Texture = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.TopBar.ResourcePath);
            _blackBar.Opacity = 0.5f;
            _blackBar.SetPosition(0, (int)(_dim.YScreenRatio * 30));
            _blackBar.SetSize((int)(_dim.XScreenRatio * 2000), (int)(_dim.YScreenRatio * 140));
            _blackBar.ImageRect = AssetsCoordinates.Generic.TopBar.Rectangle;

            btnBack = new Button();
            _blackBar.AddChild(btnBack);
            btnBack.UseDerivedOpacity = false;
            btnBack.SetStyleAuto(null);
            btnBack.SetPosition(_dim.SetX(10), _dim.SetY(0));
            btnBack.HorizontalAlignment = HorizontalAlignment.Left;
            btnBack.VerticalAlignment   = VerticalAlignment.Center;
            btnBack.SetSize(_dim.SetX(120), _dim.SetY(120));
            btnBack.Texture   = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Icons.ResourcePath);
            btnBack.ImageRect = AssetsCoordinates.Generic.Icons.BntBack;
            btnBack.Pressed  += args => {
                GameInstance.LaunchScene(GameScenesEnumeration.MENU);
            };

            if (VehicleManager.Instance.UnlockedVehicles.VehicleModel.Count == 0)
            {
#if __ANDROID__
                btnBack.Visible = false;
#else
                btnBack.Visible = true;
#endif
            }

            //COINS
            Button coins = new Button();
            _blackBar.AddChild(coins);
            coins.UseDerivedOpacity = false;
            coins.SetStyleAuto(null);
            coins.SetPosition(_dim.SetX(150), _dim.SetY(0));
            coins.HorizontalAlignment = HorizontalAlignment.Left;
            coins.VerticalAlignment   = VerticalAlignment.Center;
            coins.SetSize(_dim.SetX(70), _dim.SetY(70));
            coins.Texture           = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Icons.ResourcePath);
            coins.ImageRect         = AssetsCoordinates.Generic.Icons.IconCoin;
            coins.UseDerivedOpacity = false;

            //Wallet text
            _wallet = new Text();
            coins.AddChild(_wallet);
            _wallet.SetPosition((int)(_dim.XScreenRatio * 90), (int)(_dim.YScreenRatio * 10));
            _wallet.SetFont(_font, _dim.XScreenRatio * 30);
            _wallet.Value = string.Format($"{CharacterManager.Instance.Wallet}");

            // SCREEN TITLE
            Button screen_title = new Button();
            _root.AddChild(screen_title);
            screen_title.SetStyleAuto(null);
            screen_title.SetPosition((int)(_dim.XScreenRatio * 1500), (int)(_dim.YScreenRatio * 50));
            screen_title.SetSize((int)(_dim.XScreenRatio * 400), (int)(_dim.YScreenRatio * 100));
            screen_title.Texture   = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath);
            screen_title.ImageRect = AssetsCoordinates.Generic.Boxes.BoxTitle;
            screen_title.Enabled   = false;

            Text buttonTitleText = new Text();
            screen_title.AddChild(buttonTitleText);
            buttonTitleText.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Center);
            buttonTitleText.SetPosition(0, 0);
            buttonTitleText.SetFont(_font, _dim.XScreenRatio * 30);
            buttonTitleText.Value = "VEHICLE SELECT";

            _screenInfo = new Text();
            _root.AddChild(_screenInfo);
            _screenInfo.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Top);
            _screenInfo.SetPosition(_dim.SetX(0), _dim.SetY(220));
            _screenInfo.SetFont(_font, _dim.SetX(40));
            _screenInfo.SetColor(Color.White);
            if (VehicleManager.Instance.UnlockedVehicles == null || VehicleManager.Instance.UnlockedVehicles.VehicleModel.Count == 0)
            {
                _screenInfo.Value = "Please select a free starting vehicle.";
            }
            else
            {
                _screenInfo.Value = "";
            }
        }
Exemplo n.º 25
0
        void CreateTopBar()
        {
            black_bar = root.CreateSprite();
            GameInstance.UI.Root.AddChild(black_bar);
            black_bar.Texture = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.TopBar.ResourcePath);
            black_bar.Opacity = 0.5f;
            black_bar.SetPosition(GameInstance.ScreenInfo.SetX(0), (int)(dim.YScreenRatio * 30));
            black_bar.SetSize((int)(dim.XScreenRatio * 2000), (int)(dim.YScreenRatio * 140));
            black_bar.ImageRect = AssetsCoordinates.Generic.TopBar.Rectangle;

            Button btn_back = new Button();

            root.AddChild(btn_back);
            btn_back.SetStyleAuto(null);
            btn_back.SetPosition((int)(dim.XScreenRatio * 40), (int)(dim.YScreenRatio * 40));
            btn_back.SetSize((int)(dim.XScreenRatio * 120), (int)(dim.YScreenRatio * 120));
            btn_back.Texture   = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Icons.ResourcePath);
            btn_back.ImageRect = AssetsCoordinates.Generic.Icons.BntBack;
            btn_back.Pressed  += args => {
                GameInstance.LaunchScene(GameScenesEnumeration.MENU);
            };


            //COINS
            Button coins = new Button();

            root.AddChild(coins);
            coins.SetStyleAuto(null);
            coins.SetPosition((int)(dim.XScreenRatio * 180), (int)(dim.YScreenRatio * 60));
            coins.SetSize((int)(dim.XScreenRatio * 75), (int)(dim.YScreenRatio * 70));
            coins.Texture   = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Icons.ResourcePath);
            coins.ImageRect = AssetsCoordinates.Generic.Icons.IconCoin;


            //Wallet text
            Text wallet = new Text();

            coins.AddChild(wallet);
            wallet.SetPosition((int)(dim.XScreenRatio * 90), (int)(dim.YScreenRatio * 10));
            wallet.SetFont(font, dim.XScreenRatio * 30);
            int wallet_tot = CharacterManager.Instance.Wallet;

            wallet.Value = "" + wallet_tot;

            // SCREEN TITLE
            Button screen_title = new Button();

            root.AddChild(screen_title);
            screen_title.SetStyleAuto(null);
            screen_title.SetPosition((int)(dim.XScreenRatio * 1500), (int)(dim.YScreenRatio * 50));
            screen_title.SetSize((int)(dim.XScreenRatio * 400), (int)(dim.YScreenRatio * 100));
            screen_title.Texture   = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath);
            screen_title.ImageRect = AssetsCoordinates.Generic.Boxes.BoxTitle;
            screen_title.Enabled   = false;

            Text buttonTitleText = new Text();

            screen_title.AddChild(buttonTitleText);
            buttonTitleText.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Center);
            buttonTitleText.SetPosition(GameInstance.ScreenInfo.SetX(0), GameInstance.ScreenInfo.SetY(0));
            buttonTitleText.SetFont(font, dim.XScreenRatio * 30);
            buttonTitleText.Value = "RESULTS";
        }
Exemplo n.º 26
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 =>
                //{
                //};
            }
        }
Exemplo n.º 27
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);
        }
Exemplo n.º 28
0
        private void drawUI()
        {
            //draw font for X
            x = new Text();
            x.SetAlignment(horizontal, vertical);
            x.Position = new IntVector2(positionXx1, positionYx1);
            x.Name     = "X";
            x.Value    = "Camera ID = ";
            x.SetFont(ui_font, font_small);
            x.SetColor(uicolor);
            ui_node.AddChild(x);

            //draw font for Y
            y = new Text();
            y.SetAlignment(horizontal, vertical);
            y.Position = new IntVector2(positionXy1, positionYx1);
            y.Name     = "Y";
            y.Value    = "Gestur = ";
            y.SetFont(ui_font, font_small);
            y.SetColor(uicolor);
            ui_node.AddChild(y);

            //draw font for Z
            z = new Text();
            z.SetAlignment(horizontal, vertical);
            z.Position = new IntVector2(positionXz1, positionYx1);
            z.Name     = "Z";
            z.Value    = "Confidence = ";
            z.SetFont(ui_font, font_small);
            z.SetColor(uicolor);
            ui_node.AddChild(z);

            //draw font for X
            x1 = new Text();
            x1.SetAlignment(horizontal, vertical);
            x1.Position = new IntVector2(positionXx1, positionYy1);
            x1.Name     = "X1";
            x1.Value    = "Camera ID = ";
            x1.SetFont(ui_font, font_small);
            x1.SetColor(uicolor);
            ui_node.AddChild(x1);

            //draw font for Y
            y1 = new Text();
            y1.SetAlignment(horizontal, vertical);
            y1.Position = new IntVector2(positionXy1, positionYy1);
            y1.Name     = "Y1";
            y1.Value    = "Gestur = ";
            y1.SetFont(ui_font, font_small);
            y1.SetColor(uicolor);
            ui_node.AddChild(y1);

            //draw font for Z
            z1 = new Text();
            z1.SetAlignment(horizontal, vertical);
            z1.Position = new IntVector2(positionXz1, positionYy1);
            z1.Name     = "Z1";
            z1.Value    = "Confidence = ";
            z1.SetFont(ui_font, font_small);
            z1.SetColor(uicolor);
            ui_node.AddChild(z1);

            //draw font for X
            x2 = new Text();
            x2.SetAlignment(horizontal, vertical);
            x2.Position = new IntVector2(positionXx1, positionYz1);
            x2.Name     = "X2";
            x2.Value    = "Camera ID = ";
            x2.SetFont(ui_font, font_small);
            x2.SetColor(uicolor);
            ui_node.AddChild(x2);

            //draw font for Y
            y2 = new Text();
            y2.SetAlignment(horizontal, vertical);
            y2.Position = new IntVector2(positionXy1, positionYz1);
            y2.Name     = "Y2";
            y2.Value    = "Gestur = ";
            y2.SetFont(ui_font, font_small);
            y2.SetColor(uicolor);
            ui_node.AddChild(y2);

            //draw font for Z
            z2 = new Text();
            z2.SetAlignment(horizontal, vertical);
            z2.Position = new IntVector2(positionXz1, positionYz1);
            z2.Name     = "Z2";
            z2.Value    = "Confidence = ";
            z2.SetFont(ui_font, font_small);
            z2.SetColor(uicolor);
            ui_node.AddChild(z2);

            //draw font for X
            x3 = new Text();
            x3.SetAlignment(horizontal, vertical);
            x3.Position = new IntVector2(positionXx1, positionYa1);
            x3.Name     = "X3";
            x3.Value    = "Camera ID = ";
            x3.SetFont(ui_font, font_small);
            x3.SetColor(uicolor);
            ui_node.AddChild(x3);

            //draw font for Y
            y3 = new Text();
            y3.SetAlignment(horizontal, vertical);
            y3.Position = new IntVector2(positionXy1, positionYa1);
            y3.Name     = "Y3";
            y3.Value    = "Gestur = ";
            y3.SetFont(ui_font, font_small);
            y3.SetColor(uicolor);
            ui_node.AddChild(y3);

            //draw font for Z
            z3 = new Text();
            z3.SetAlignment(horizontal, vertical);
            z3.Position = new IntVector2(positionXz1, positionYa1);
            z3.Name     = "Z3";
            z3.Value    = "Confidence = ";
            z3.SetFont(ui_font, font_small);
            z3.SetColor(uicolor);
            ui_node.AddChild(z3);

            //draw font for X
            x4 = new Text();
            x4.SetAlignment(horizontal, vertical);
            x4.Position = new IntVector2(positionXx1, positionYKinect);
            x4.Name     = "X3";
            x4.Value    = "Camera ID = ";
            x4.SetFont(ui_font, font_small);
            x4.SetColor(uicolor);
            ui_node.AddChild(x4);

            //draw font for Y
            y4 = new Text();
            y4.SetAlignment(horizontal, vertical);
            y4.Position = new IntVector2(positionXy1, positionYKinect);
            y4.Name     = "Y3";
            y4.Value    = "Gestur = ";
            y4.SetFont(ui_font, font_small);
            y4.SetColor(uicolor);
            ui_node.AddChild(y4);
        }
Exemplo n.º 29
0
        public void Update(IEnumerable <BarData> newData)
        {
            if (newData.Count() != data.Count)
            {
                graphRoot.Size = new IntVector2(MAX_BAR_WIDTH + labelWidth, newData.Count() * HEIGHT);

                graphRoot.RemoveAllChildren();
                for (int i = 0; i < newData.Count(); ++i)
                {
                    var row = new UIElement();

                    var label = new Text()
                    {
                        TextAlignment       = HorizontalAlignment.Right,
                        HorizontalAlignment = HorizontalAlignment.Right
                    };
                    label.SetColor(new Color(1.0f, 1.0f, 1.0f));
                    label.SetFont(barFont, 22);
                    label.Position = new IntVector2(labelWidth, i * HEIGHT);
                    label.Width    = labelWidth;
                    row.AddChild(label);

                    var bar = new BorderImage()
                    {
                        Texture   = barTex,
                        ImageRect = new IntRect(0, 0, 32, 32),
                        Border    = new IntRect(6, 9, 6, 9),

                        MinSize   = new IntVector2(20, 20),
                        BlendMode = BlendMode.Alpha
                    };
                    bar.Position = new IntVector2(labelWidth + LABEL_GAP, i * HEIGHT);
                    row.AddChild(bar);

                    graphRoot.AddChild(row);
                }
            }
            data.Clear();
            data.AddRange(newData);

            var selected = data.Select(bd => bd.Value);
            // TODO: Check whether this should be in or out

            /*if (!selected.Any()) {
             *  return;
             * }*/
            var maxValue      = selected.Max();
            int maxLabelWidth = -1;

            for (int i = 0; i < data.Count; ++i)
            {
                var row = graphRoot.GetChild((uint)i);

                var label = row.GetChild(0) as Text;
                label.Value   = data[i].Label;
                maxLabelWidth = (int)Math.Max(label.GetRowWidth(0), maxLabelWidth);

                var bar = row.GetChild(1) as BorderImage;
                if (data[i].Color.HasValue)
                {
                    bar.SetColor(data[i].Color.Value);
                }
                else
                {
                    bar.SetColor(colorCycle[i % colorCycle.Length]);
                }
                bar.Size = new IntVector2((int)(MAX_BAR_WIDTH * (data[i].Value / maxValue)), HEIGHT);
            }

            if (maxLabelWidth != labelWidth)
            {
                labelWidth = maxLabelWidth;
                for (int i = 0; i < data.Count; ++i)
                {
                    var row   = graphRoot.GetChild((uint)i);
                    var label = row.GetChild(0) as Text;
                    var bar   = row.GetChild(1) as BorderImage;

                    label.Position = new IntVector2(labelWidth, i * HEIGHT);
                    label.Width    = labelWidth;
                    bar.Position   = new IntVector2(labelWidth + LABEL_GAP, i * HEIGHT);
                }
            }

            var billboard = billboards.GetBillboardSafe(0);

            billboard.Size    = new Vector2(0.001f * (MAX_BAR_WIDTH + labelWidth), 0.002f * (HEIGHT * data.Count));
            billboard.Enabled = true;
            billboards.Commit();
        }
Exemplo n.º 30
0
 protected void AddCore(UIElement item)
 {
     _owner.AddChild(item);
 }