Example #1
0
        private void InitUI()
        {
            canvas = new Canvas();

            InitFileList(StartingDirectory, SearchPattern);

            Button button_open = new Button("Open", new Point(600, 10), new Vector2(60, 30), CONTENT_MANAGER.Fonts["default"])
            {
                BorderColor = Color.Black
            };

            button_open.MouseClick += (o, e) => {
                if (string.IsNullOrEmpty(SelectedFile))
                {
                    msgbox.Show("Warning!\nNo File is selected.", "OK");
                    return;
                }
                CallBack?.Invoke(SelectedFile);
            };
            label_selectedFile = new Label("", new Point(600, 50), new Vector2(120, 40), CONTENT_MANAGER.Fonts["default"])
            {
                Origin = Vector2.Zero
            };

            msgbox = new MessageBox(new Point(280, 200), "Warning!", "OK");
            msgbox.Hide();
            msgbox.MiddleButtonPressed += (o, e) => {
                msgbox.Hide();
            };
            canvas.AddElement("button_open", button_open);
            canvas.AddElement("msgbox", msgbox);
            canvas.AddElement("label_selectedFile", label_selectedFile);
        }
Example #2
0
        internal static UIElement BuildItem(object textSource)
        {
            if (textSource is UIElement)
            {
                return(textSource as UIElement);
            }
            else
            {
                var text = (string)textSource;

                var icon   = ResourceManager.Instance.GetBitmapFromEmbeddedResource("item.icon.png", System.Reflection.Assembly.GetExecutingAssembly());
                var canvas = new Canvas()
                {
                    Size = new Size(480, 90)
                };
                canvas.AddElement(new TextElement(text)
                {
                    Style = MetroTheme.PhoneTextNormalStyle, Location = new Point(120, 0), Size = new Size(400, 50)
                });
                canvas.AddElement(new ImageElement(icon)
                {
                    Location = new Point(40, 0), Size = new Size(60, 60)
                });
                var myStyle = MetroTheme.PhoneTextSmallStyle;
                myStyle.Foreground = MetroTheme.PhoneAccentBrush;
                canvas.AddElement(new TextElement("This is just a sample text!")
                {
                    Style = myStyle, Location = new Point(120, 40), Size = new Size(400, 50)
                });
                return(canvas);
            }
        }
Example #3
0
        public void InitCanvas()
        {
            canvas = new Canvas();

            ListView listView = new ListView(new Point(20, 20), new Vector2(300, 300), new Point(10, 40), new Vector2(50, 30));
            Button   button   = new Button("Add Item", new Point(400, 20), new Vector2(80, 30), CONTENT_MANAGER.Fonts["default"]);
            Label    label    = new Label("", new Point(400, 60), new Vector2(50, 30), CONTENT_MANAGER.Fonts["default"])
            {
                Origin = new Vector2(-2, -2)
            };

            button.MouseClick += (o, e) =>
            {
                listView.AddItem(count++.ToString());
            };

            listView.ItemSelected += (o, e) =>
            {
                label.Text = e.Text;
                CONTENT_MANAGER.Log(e.Text);
            };

            canvas.AddElement("listView", listView);
            canvas.AddElement("button", button);
            canvas.AddElement("label", label);
        }
Example #4
0
        private void InitUI()
        {
            Button btn_create_room = new Button("Create Room", new Point(275, 150), new Vector2(170, 25), CONTENT_MANAGER.arcadefont);

            Button btn_goto_room = new Button("Go To Room", new Point(285, 200), new Vector2(150, 25), CONTENT_MANAGER.arcadefont);

            Label label_player_name = new Label(Player.Instance.Name, new Point(620, 0), null, CONTENT_MANAGER.arcadefont, 1);

            //bind event

            //Click to button go to room
            btn_goto_room.MouseClick += (sender, e) =>
            {
                enterRoom.ShowDialog();
            };

            //Click to button create room
            btn_create_room.MouseClick += (sender, e) =>
            {
                Player.Instance.CreateRoom();
            };

            //Click to ok button after enter room number
            enterRoom.button_OK.Click += (sender, e) =>
            {
                if (enterRoom.textBox_Input.Text != "")
                {
                    Player.Instance.GotoRoom(Convert.ToInt32(enterRoom.textBox_Input.Text));
                }
                else
                {
                    CONTENT_MANAGER.ShowMessageBox("You have't enter room number");
                }
            };

            //Cancel go to room
            enterRoom.button_Cancel.Click += (sender, e) =>
            {
                enterRoom.Hide();
            };

            //Event enter success
            Player.Instance.entered_succeed += (sender, e) =>
            {
                SCREEN_MANAGER.goto_screen("Room_Screen");
            };

            //Event create room success
            Player.Instance.created_room += (_sender, _e) =>
            {
                SCREEN_MANAGER.goto_screen("Room_Screen");
            };

            canvas.AddElement("btn_create_room", btn_create_room);
            canvas.AddElement("btn_goto_room", btn_goto_room);
            canvas.AddElement("label_player_name", label_player_name);
        }
Example #5
0
        private void InitUI()
        {
            console = new Console(new Point(0, 50), new Vector2(400, 200), CONTENT_MANAGER.hackfont);
            Label lbl_test = new Label("", new Point(100, 0), new Vector2(80, 30), CONTENT_MANAGER.defaultfont);

            console.CommandSubmitted += (sender, e) =>
            {
                lbl_test.Text = console.Text;
            };

            canvas.AddElement("console", console);
            canvas.AddElement("lbl_test", lbl_test);
        }
Example #6
0
        protected virtual void InitFileList(string startingdir, string searchpattern)
        {
            var files = GetFiles(startingdir, searchpattern);
            var y     = 10;

            filelist = new List <Button>();
            foreach (var m in files)
            {
                Button bt = new Button(Path.GetFileNameWithoutExtension(m), new Point(10, y), new Vector2(120, 30), CONTENT_MANAGER.Fonts["default"])
                {
                    Origin          = new Vector2(10, 0),
                    ForegroundColor = Color.Black,
                    BorderColor     = Color.Black,
                    MetaData        = Path.GetDirectoryName(m)
                };

                bt.MouseClick += (o, e) => {
                    SelectedFile            = bt.Text;
                    label_selectedFile.Text = SelectedFile;
                };

                y += 35;
                filelist.Add(bt);
            }

            foreach (var m in filelist)
            {
                canvas.AddElement(m.Text, m);
            }
        }
        public void InitUI()
        {
            canvas = new Canvas();

            InputBox inputBox = new InputBox("", new Point(400, 50), new Vector2(80, 30), CONTENT_MANAGER.Fonts["hack"], Color.White, Color.Black);

            canvas.AddElement("inputBox", inputBox);
        }
Example #8
0
        private void InitUI()
        {
            SpriteFont spriteFont = CONTENT_MANAGER.arcadefont;
            //declare ui elements


            Label enter_name = new Label("Enter your name", new Point((this._device.Viewport.Width / 2) - (int)spriteFont.MeasureString("Enter your name").X / 2, this._device.Viewport.Height / 2 - 140), null, CONTENT_MANAGER.arcadefont, 1);

            InputBox player_name = new InputBox("", new Point(this._device.Viewport.Width / 2 - 75, this._device.Viewport.Height / 2 - 120), new Vector2(150, 20), CONTENT_MANAGER.hackfont, Color.Black, Color.White);

            Label enter_ip_address = new Label("Enter server ip address", new Point((this._device.Viewport.Width / 2) - (int)spriteFont.MeasureString("Enter server ip address").X / 2, this._device.Viewport.Height / 2 - 90), null, CONTENT_MANAGER.arcadefont, 1);

            InputBox ip_address = new InputBox("", new Point(this._device.Viewport.Width / 2 - 75, this._device.Viewport.Height / 2 - 70), new Vector2(150, 20), CONTENT_MANAGER.hackfont, Color.Black, Color.White);

            string text_conect = "Connect to server";

            Point point_conect = new Point(this._device.Viewport.Width / 2 - (int)(spriteFont.MeasureString(text_conect).X + spriteFont.MeasureString(text_conect).X / 2) / 2, this._device.Viewport.Height / 2 - 20);

            Button button_connect = new Button(text_conect, point_conect, null, CONTENT_MANAGER.arcadefont);

            //bind event

            Player.Instance.connect_succeed += (sender, e) =>
            {
                Player.Instance.Name = player_name.Text;

                SCREEN_MANAGER.goto_screen("Client_Screen");
            };

            button_connect.MouseClick += (sender, e) =>
            {
                Player.Instance.ConnectToServer(ip_address.Text);
            };


            //add to canvas
            canvas.AddElement("enter_name", enter_name);
            canvas.AddElement("enter_ip_address", enter_ip_address);
            canvas.AddElement("player_name", player_name);
            canvas.AddElement("ip_address", ip_address);
            canvas.AddElement("button_connect", button_connect);
        }
Example #9
0
        private static Canvas CreateSampleImageItem()
        {
            var sampleImageElement = new Canvas {
                Size = new Size(480, 200)
            };

            sampleImageElement.AddElement(new ImageElement(ResourceManager.Instance.GetBitmapFromEmbeddedResource("thumbnail.png"))
            {
                Location = new Point(120, 0), Size = new Size(200, 150)
            });
            return(sampleImageElement);
        }
Example #10
0
        //Notify another phayer that you are ready
        //( This method only use to phayer is no host )

        private void InitUI()
        {
            Button button_ready = new Button("Ready", new Point(127, 200), new Vector2(100, 25), CONTENT_MANAGER.arcadefont);

            Button button_selectmap = new Button(UISpriteSheetSourceRectangle.GetSpriteRectangle(SpriteSheetUI.Open), new Point(650, 20), 0.5f);

            Label label_this_ready = new Label("", new Point(50, 50), null, CONTENT_MANAGER.arcadefont, 1);

            Label label_another_ready = new Label("", new Point(490, 227), null, CONTENT_MANAGER.arcadefont, 1);

            Button separate = new Button("", new Point(355, 20), new Vector2(10, 480), CONTENT_MANAGER.arcadefont);

            Label player_name = new Label(Player.Instance.Name, new Point(130, 0), null, CONTENT_MANAGER.arcadefont, 1);

            Label another_player_name = new Label("", new Point(490, 0), null, CONTENT_MANAGER.arcadefont, 1);

            Label room_ID = new  Label(Player.Instance.RoomNumber.ToString(), new Point(360, 0), null, CONTENT_MANAGER.arcadefont, 1);

            // Bind event


            Player.Instance.another_goto_room += (sender, e) =>
            {
                another_player_name.Text = e;
            };

            //Khi chủ phòng load map và gửi cho người chơi khác
            //When select map
            button_selectmap.MouseClick += (sender, e) =>
            {
                try
                {
                    //If you are host, you can load map
                    if (Player.Instance.isHost)
                    {
                        string path = CONTENT_MANAGER.ShowFileOpenDialog(CONTENT_MANAGER.LocalRootPath + @"\map");

                        LoadMap(path);


                        //Send map to another phayer
                        string send = Path.GetFileName(path);

                        Player.Instance.Update(send);
                    }
                }
                catch (Exception er)
                {
                    Utility.HelperFunction.Log(er);
                    CONTENT_MANAGER.ShowMessageBox(er.Message);
                }
            };


            //Người chơi khác nhận map
            //Load map which host had been chosen
            Player.Instance.update += (sender, e) =>
            {
                string path = string.Format("{0}{1}{2}", CONTENT_MANAGER.LocalRootPath, @"\map\", e);
                if (File.Exists(path))
                {
                    loadPath  = path;
                    isLoadMap = true;
                }
            };

            //Event raise when another phayer ready
            Player.Instance.received_chat += (sender, e) =>
            {
                if (e == "Ready")
                {
                    is_another_ready         = true;
                    label_another_ready.Text = "Ready";
                }
                else
                {
                    is_another_ready         = false;
                    label_another_ready.Text = "NotReady";
                }
            };


            //Player is ready
            button_ready.MouseClick += (sender, e) =>
            {
                if (Player.Instance.isHost)
                {
                    if (map != null && is_another_ready)
                    {
                        is_this_ready = true;
                        Player.Instance.ChatWithAnother("Ready");
                    }
                }
                else
                {
                    //Tell another phayer, you start
                    if (!is_this_ready)
                    {
                        is_this_ready         = true;
                        label_this_ready.Text = "Ready";
                        Player.Instance.ChatWithAnother("Ready");
                    }
                    else
                    {
                        is_this_ready         = false;
                        label_this_ready.Text = "";
                        Player.Instance.ChatWithAnother("NotReady");
                    }
                }
            };

            //Add to canvas to draw to screen
            canvas.AddElement("button_selectmap", button_selectmap);
            canvas.AddElement("button_ready", button_ready);
            canvas.AddElement("label_this_ready", label_this_ready);
            canvas.AddElement("separate", separate);
            canvas.AddElement("label_another_ready", label_another_ready);
            canvas.AddElement("another_player_name", another_player_name);
            canvas.AddElement("room_ID", room_ID);
        }
Example #11
0
        public HomeScreen()
            : base(true)
        {
            this.Control.EntranceDuration = 500;
            homeScreenCanvas = new Canvas {
                Size = new Size(960, 740)
            };
            var canvas = new Canvas()
            {
                Size = new Size(400, 1203)
            };

            tiles.Add(this.CreateTile("Phone", 28, 93));
            tiles.Add(this.SetEntranceAnimationFromLeft(new PeopleTile(213, 93)));
            tiles.Add(this.CreateTile("Messaging", 28, 278));
            tiles.Add(this.CreateTile("Email", 213, 278));
            tiles.Add(this.CreateTile("Internet", 28, 463));
            tiles.Add(this.CreateTile("Games", 213, 463));
            tiles.Add(this.CreateTile("Calendar", 28, 648, true));
            tiles.Add(this.CreateTile("Pictures", 28, 833, true));
            tiles.Add(this.CreateTile("Zune", 28, 1018));
            tiles.Add(this.CreateTile("Marketplace", 213, 1018));

            tiles.ForEach(el => { canvas.AddElement(el); this.SetExitAnimationToLeft(el, this.ShowGames); });

            var sv = new ScrollViewer
            {
                Content        = canvas,
                Size           = new Size(400, this.Size.Height - 62),
                Location       = new Point(0, 0),
                VerticalScroll = true,
            };

            this.homeScreenCanvas.AddElement(sv);

            this.Control.AddElement(new SoftKeys()
            {
                Size     = new Size(480, 60),
                Location = new Point(0, this.Size.Height - 60)
            });

            this.switchArrow = new Arrow()
            {
                Location   = new Point(400, 93),
                TapHandler = this.TapOnArrow,
            };
            this.homeScreenCanvas.AddElement(this.switchArrow);

            this.homeScreenCanvas.PanHandler   = this.Pan;
            this.homeScreenCanvas.FlickHandler = this.Flick;

            var programsSv = new ScrollViewer {
                Size = new Size(315, this.Size.Height - 62), Location = new Point(574, 0), VerticalScroll = true
            };

            programsSv.Content = new ImageElement(ResourceManager.Instance.GetBitmapFromEmbeddedResource("Programs.png"))
            {
                Size = new Size(315, 893),
                EntranceAnimation = new NullAnimation(),
                ExitAnimation     = new NullAnimation()
            };

            this.homeScreenCanvas.AddElement(programsSv);

            this.Control.AddElement(this.homeScreenCanvas);
            this.Control.AddElement(new Clock()
            {
                Location = new Point(425, 0)
            });

            this.homeScreenCanvas.TapHandler = p => { this.ReShow(); return(true); };
        }
Example #12
0
    public void Init()
    {
        SDL.SDL_Init(SDL.SDL_INIT_EVERYTHING);
        Window = SDL.SDL_CreateWindow("SDL2 GUI",
                                      WindowSize[0], WindowSize[1],
                                      WindowSize[2], WindowSize[3],
                                      SDL.SDL_WindowFlags.SDL_WINDOW_RESIZABLE |
                                      SDL.SDL_WindowFlags.SDL_WINDOW_SHOWN |
                                      SDL.SDL_WindowFlags.SDL_WINDOW_INPUT_FOCUS);

        SDL.SDL_SetWindowResizable(Window, SDL.SDL_bool.SDL_FALSE);

        int drivers = SDL.SDL_GetNumRenderDrivers();

        for (int i = 0; i < drivers; i++)
        {
            SDL.SDL_RendererInfo info;
            SDL.SDL_GetRenderDriverInfo(i, out info);

            Renderer = SDL.SDL_CreateRenderer(Window, i, (SDL.SDL_RendererFlags)info.flags);
            if (Renderer.ToInt32() != 0)
            {
                Printer.Instance.Init(Renderer);
                break;
            }
        }

        SDL_image.IMG_Init(SDL_image.IMG_InitFlags.IMG_INIT_PNG);

        LoadImages();

        SDL.SDL_Rect sliceParams;
        sliceParams.x = 4;
        sliceParams.y = 4;
        sliceParams.w = 27;
        sliceParams.h = 27;

        _images[0].Slice(sliceParams);
        _images[1].Slice(sliceParams);
        _images[2].Slice(sliceParams);
        _images[3].Slice(sliceParams);

        _gui = new MyGUI(Renderer, WindowSize[2], WindowSize[3]);

        Canvas window = new Canvas(_gui);

        for (int i = 0; i < 4; i++)
        {
            Button b = new Button(_images[0], _images[1], _images[2], _images[3], 0, i * 25, 100, 25, "Click Me!");
            b.OnMouseClick = ClickHandler;

            if (i == 3)
            {
                b.Disable();
                b.SetText("Disabled");
                _toEnableRef = b;
            }
            else
            {
                _countersByButtonId.Add(b.ObjectId, 0);
            }

            window.AddElement(b);
        }

        Button enabler = new Button(_images[0], _images[1], _images[2], _images[3], 0, 5 * 25, 100, 25, "Enabler");

        enabler.OnMouseClick = EnablerHandler;
        window.AddElement(enabler);

        Button b2 = new Button(_images[0], _images[1], _images[2], _images[3], 775, 0, 25, 25, "X");

        b2.TextScale    = 1.5f;
        b2.OnMouseClick = ExitApp;

        window.AddElement(b2);

        _gui.PushCanvas(window);
    }
        private void InitCanvas()
        {
            canvas = new Canvas();

            Label label_name = new Label("Untitled", new Point(400, 0), new Vector2(200, 20), CONTENT_MANAGER.Fonts["default"])
            {
                Origin          = new Vector2(-2, -2),
                BackgroundColor = Color.LightGray
            };

            label_snippet = new Label("", new Point(400, 30), new Vector2(20, 20), CONTENT_MANAGER.Fonts["default"])
            {
                Origin = new Vector2(-2, -2)
            };

            CONTENT_MANAGER.gameInstance.Window.TextInput += (obj, e) =>
            {
                //if (label_name.IsFocused)
                {
                    if (char.IsLetterOrDigit(e.Character))
                    {
                        label_name.Text += e.Character;
                    }
                    else if (e.Key == Keys.Back)
                    {
                        int cc = label_name.Text.Length - 1;
                        if (cc >= 0)
                        {
                            label_name.Text = label_name.Text.Remove(cc);
                        }
                    }
                }
            };

            pictureBox_spritesheet = new PictureBox(CONTENT_MANAGER.Sprites[texture], new Point(50, 0), null, null);

            pictureBox_snippet = new PictureBox(CONTENT_MANAGER.Sprites[texture], new Point(400, 70), Rectangle.Empty, null);

            pictureBox_spritesheet.MouseDrag += (obj, e) =>
            {
                if (e.Size != Point.Zero)
                {
                    //DrawingHelper.RemoveShape(selectedFrame);
                    //selectedFrame = DrawingHelper.GetRectangle(e, Color.Red, false);
                    //DrawingHelper.DrawShape(selectedFrame);
                    selectedFrame      = new Rectangle((e.Location.ToVector2() * pictureBox_spritesheet.Scale).ToPoint(), (e.Size.ToVector2() * pictureBox_spritesheet.Scale).ToPoint());
                    label_snippet.Text = selectedFrame.ToString();
                    e.Location         = new Point(e.Location.X - pictureBox_spritesheet.Position.X, e.Location.Y - pictureBox_spritesheet.Position.Y);
                    pictureBox_snippet.SourceRectangle = e;
                }
            };

            pictureBox_spritesheet.KeyPress += (obj, e) =>
            {
                if (HelperFunction.IsKeyPress(Keys.OemPlus))
                {
                    pictureBox_spritesheet.Scale += 0.1f;
                    scaleChanged = true;
                }

                if (HelperFunction.IsKeyPress(Keys.OemMinus))
                {
                    if (pictureBox_spritesheet.Scale > 1)
                    {
                        pictureBox_spritesheet.Scale -= 0.1f;
                        scaleChanged = true;
                    }
                }
            };
            Button button_new = new Button("New", new Point(650, 30), new Vector2(60, 30), CONTENT_MANAGER.Fonts["default"])
            {
                ButtonColorReleased = Color.White
            };

            button_new.MouseClick += (o, e) =>
            {
                animationPlayer.StopAnimation();
                label_name.Text = "Untitled";
            };

            Button button_add_sprite = new Button("Add F", new Point(720, 30), new Vector2(60, 30), CONTENT_MANAGER.Fonts["default"])
            {
                ButtonColorReleased = Color.White
            };

            button_add_sprite.MouseClick += (obj, e) =>
            {
                if (string.IsNullOrWhiteSpace(label_name.Text))
                {
                    label_name.Text = "Please enter the name of this animation";
                }
                else if (!animation_list.ContainsKey(label_name.Text))
                {
                    animation_list.Add(label_name.Text, new List <Rectangle>()
                    {
                        pictureBox_snippet.SourceRectangle
                    });
                }
                else
                {
                    animation_list[label_name.Text].Add(pictureBox_snippet.SourceRectangle);
                }
            };

            animationPlayer = new AnimationPlayer(new AnimatedEntity(), new Point(700, 70));

            Button button_test_animation = new Button("Test", new Point(790, 30), new Vector2(60, 30), CONTENT_MANAGER.Fonts["default"])
            {
                ButtonColorReleased = Color.White
            };

            button_test_animation.MouseClick += (o, e) =>
            {
                string    animationName = label_name.Text;
                Animation animation     = new Animation(animationName, true, 1, null);
                foreach (var frame in animation_list[animationName])
                {
                    animation.AddKeyFrame(frame);
                }
                if (animationPlayer.ContainAnimation(animation.Name))
                {
                    animationPlayer.RemoveAnimation(animation.Name);
                }
                animationPlayer.AddAnimation(animation);
                animationPlayer.LoadContent(pictureBox_snippet.Texture2D);
                animationPlayer.PlayAnimation(animation.Name);
            };

            Button button_export = new Button("Export", new Point(860, 30), new Vector2(60, 30), CONTENT_MANAGER.Fonts["default"])
            {
                ButtonColorReleased = Color.White
            };

            button_export.MouseClick += (o, e) =>
            {
                var animdata = JsonConvert.SerializeObject(animationPlayer.AnimatedEntity, Formatting.Indented);
                File.WriteAllText($"{label_name.Text}.txt", animdata);
            };

            canvas.AddElement("label_test", label_name);
            canvas.AddElement("label_snippet", label_snippet);
            canvas.AddElement("pictureBox_test", pictureBox_spritesheet);
            canvas.AddElement("pictureBox_snippet", pictureBox_snippet);
            canvas.AddElement("button_add_sprite", button_add_sprite);
            canvas.AddElement("animationPlayer", animationPlayer);
            canvas.AddElement("button_test_animation", button_test_animation);
            canvas.AddElement("button_export", button_export);
            canvas.AddElement("button_new", button_new);
        }
Example #14
0
        private void InitUI()
        {
            //declare ui element

            //khai báo 1 cái label để hiển thị fps
            Label label_fps = new Label(" ", new Point(0, 0), new Vector2(100, 50), CONTENT_MANAGER.defaultfont);

            label_fps.foregroundColor = Color.DarkBlue;
            label_fps.IsVisible       = false;

            //TODO make button for main menu
            Button button_Campaign      = new Button(ModeSelectDark, null, new Point(100, 275), 2);
            Button button_MapEditor     = new Button(ModeSelectDark, null, new Point(300, 275), 2);
            Button button_OtherGamemode = new Button(ModeSelectDark, null, new Point(500, 275), 2);

            //bind action to ui event
            button_Campaign.MouseClick += (sender, e) =>
            {
                if (selectedbutton != ButtonSelected.Campaign)
                {
                    selectedbutton              = ButtonSelected.Campaign;
                    button_Campaign.Sprite      = ModeSelectLight;
                    button_MapEditor.Sprite     = ModeSelectDark;
                    button_OtherGamemode.Sprite = ModeSelectDark;
                }
                else
                {
                    SCREEN_MANAGER.goto_screen("SetupScreen");
                }
            };

            button_MapEditor.MouseClick += (sender, e) =>
            {
                if (selectedbutton != ButtonSelected.MapEditor)
                {
                    selectedbutton              = ButtonSelected.MapEditor;
                    button_Campaign.Sprite      = ModeSelectDark;
                    button_MapEditor.Sprite     = ModeSelectLight;
                    button_OtherGamemode.Sprite = ModeSelectDark;
                }
                else
                {
                    SCREEN_MANAGER.goto_screen("EditorScreen");
                }
            };

            button_OtherGamemode.MouseClick += (sender, e) =>
            {
                if (selectedbutton != ButtonSelected.Other)
                {
                    selectedbutton              = ButtonSelected.Other;
                    button_Campaign.Sprite      = ModeSelectDark;
                    button_MapEditor.Sprite     = ModeSelectDark;
                    button_OtherGamemode.Sprite = ModeSelectLight;
                }
                else
                {
                    //SCREEN_MANAGER.goto_screen("OtherGamemode");
                }
            };

            //add ui element to canvas
            canvas.AddElement("label_fps", label_fps);
            canvas.AddElement("button_Campaign", button_Campaign);
            canvas.AddElement("button_MapEditor", button_MapEditor);
            canvas.AddElement("button_OtherGameMode", button_OtherGamemode);
        }
Example #15
0
        internal void Draw(Vector2 a_size, bool a_display)
        {
            int displayedElements = 0;
            List <InternalConsole.Message> messages = InternalConsole.Messages;

            TextBox textBox = null;

            for (int i = 0; i < m_textBoxes.Count; ++i)
            {
                InternalConsole.Message message = messages[i];
                message.TimeOut += (float)PipelineTime.DeltaTime;
                messages[i]      = message;

                textBox = m_textBoxes[i];

                if (!a_display)
                {
                    textBox.Visible = message.TimeOut < 10.0f;

                    if (textBox.Visible)
                    {
                        textBox.XLockMode = e_XLockMode.Right;
                        textBox.YLockMode = e_YLockMode.Top;
                        textBox.Position  = new Vector2(320, (++displayedElements) * 32);
                    }
                }
                else
                {
                    textBox.Visible   = true;
                    textBox.XLockMode = e_XLockMode.Left;
                    textBox.YLockMode = e_YLockMode.Bottom;
                    textBox.Position  = new Vector2(160, (i + 1) * 32);
                }
            }

            m_canvas.Draw(a_size);

            for (int i = m_textBoxes.Count; i < messages.Count; ++i)
            {
                InternalConsole.Message message = messages[i];

                Brush brush = Brushes.White;

                switch (message.Alert)
                {
                case InternalConsole.e_Alert.Error:
                {
                    brush = Brushes.Red;

                    break;
                }

                case InternalConsole.e_Alert.Warning:
                {
                    brush = Brushes.Yellow;

                    break;
                }
                }

                textBox = new TextBox(brush, SystemFonts.DefaultFont, 400, 24, m_pipeline)
                {
                    Text = message.Text
                };

                m_canvas.AddElement(textBox);

                m_textBoxes.Add(textBox);
            }
        }