Example #1
0
        public override void LoadAndInitialize()
        {
            if (gameUIFont == null) gameUIFont = game.Content.Load<SpriteFont>("gameUIFont");
            if (gameUIFont_Counters == null) gameUIFont_Counters = game.Content.Load<SpriteFont>("gameUIFont_Counters");

            UIProgress hpbar;
            UILabel label;

            hpbar = new UIProgress(game);
            hpbar.Name = "hpbarMotor" + motorID;
            hpbar.Angular = true;
            hpbar.Percent = GameSettings.gameMotors[motorID].HP;
            hpbar.PositionAndSize = new Rectangle(0, 0, 100, 20);
            UIParent.UI.Add(hpbar);
            GameSettings.gameMotors[motorID].HPChanged = (Motorek_HPChanged)((m, old) => {
                ((UIProgress)UIParent.UI["hpbarMotor" + motorID]).Percent = m.HP/100.0f;
            });
            label = new UILabel(game);
            label.Font = gameUIFont;
            label.AutoSize = true;
            label.PositionAndSize = new Rectangle(2, 2, 0, 0);
            label.Text = GameSettings.gameMotors[motorID].name;
            UIParent.UI.Add(label);
            label = new UILabel(game);
            label.Font = gameUIFont;
            label.AutoSize = true;
            label.PositionAndSize = new Rectangle(0, 0, 0, 0);
            label.Text = GameSettings.gameMotors[motorID].name;
            label.fontColor = Color.Red;
            UIParent.UI.Add(label);

            label = new UILabel(game);
            label.Name = "playerCounterShade";
            label.Font = gameUIFont_Counters;
            label.AutoSize = true;
            int counter_height = (int)gameUIFont_Counters.MeasureString("Mg").Y;
            label.PositionAndSize = new Rectangle(2, height - counter_height, 0, 0);
            label.Text = "";
            UIParent.UI.Add(label);
            label = new UILabel(game);
            label.Name = "playerCounterFront";
            label.Font = gameUIFont_Counters;
            label.AutoSize = true;
            label.PositionAndSize = new Rectangle(0, height - counter_height - 2, 0, 0);
            label.Text = "";
            label.fontColor = Color.Red;
            UIParent.UI.Add(label);
            GameSettings.gameMotors[motorID].FragsChanged = FragsPoints_Changed;
            GameSettings.gameMotors[motorID].PointsChanged = FragsPoints_Changed;
            FragsPoints_Changed(GameSettings.gameMotors[motorID], 0); //show initials

            UIParent.ESCHook += UIParent_ESCHook;

            UIParent.UI.LoadAndInitialize();
            game.mCursor.Visible = false;
            GameSettings.gamePlayScreen1.gameFinished = UIParent_ESCHook;
        }
Example #2
0
        public override void LoadAndInitialize()
        {
            UIParent.UI.Clear();

            switch (subscreen)
            {
                case 0: //loading
                    {
                        UIProgress progress;
                        UIImage logo;

                        logo = new UIImage(game);
                        logo.Name = "imgLoading";
                        logo.Textures = game.Content.Load<Texture2D>("logo_loading");
                        logo.NormalTexture = new Rectangle(0, 0, 500, 75);
                        logo.PositionAndSize = new Rectangle(400 - 250, 125, 500, 75);
                        UIParent.UI.Add(logo);

                        progress = new UIProgress(game);
                        progress.Name = "pbarLoading";
                        progress.Angular = false;
                        progress.color = null;
                        progress.Percent = 0;
                        progress.PositionAndSize = new Rectangle(400 - 300, 400, 600, 50);
                        UIParent.UI.Add(progress);
                    }
                    break;
                case 1: //connecting
                    {
                        UIProgress progress;
                        UIImage logo;

                        logo = new UIImage(game);
                        logo.Name = "imgConnecting";
                        logo.Textures = game.Content.Load<Texture2D>("logo_connecting");
                        logo.NormalTexture = new Rectangle(0, 0, 500, 75);
                        logo.PositionAndSize = new Rectangle(400 - 250, 125, 500, 75);
                        UIParent.UI.Add(logo);

                        progress = new UIProgress(game);
                        progress.Name = "pbarConnecting";
                        progress.Angular = false;
                        progress.color = null;
                        progress.Percent = null;
                        progress.PositionAndSize = new Rectangle(400 - 300, 400, 600, 50);
                        UIParent.UI.Add(progress);

                        UIButton btnBack = new UIButton(game);
                        btnBack.Name = "btnBack";
                        btnBack.Text = "<-- Back";
                        btnBack.PositionAndSize = new Rectangle(5, (600 - 41), 100, 37);
                        btnBack.Action += (UIButton_Action)((btn) =>
                        {
                            //cancel connecting

                            UIParent.ESCHook -= UIParent_ESCHook;
                            oResult = new GameScreen_Main(game);
                            iResult = MenuReturnCodes.MenuSwitching;
                            Call_OnExit();
                        });
                        UIParent.UI.Add(btnBack);

                        UIParent.ESCHook += UIParent_ESCHook;
                    }
                    break;
            }

            UIParent.UI.LoadAndInitialize();
        }
Example #3
0
        public override void LoadAndInitialize()
        {
            if (gameUIFont == null) gameUIFont = game.Content.Load<SpriteFont>("gameUIFont");
            if (gameUIFont_Counters == null) gameUIFont_Counters = game.Content.Load<SpriteFont>("gameUIFont_Counters");

            //create game UI
            UIProgress hpbar;
            UILabel label;

            //player hp bar and name
            hpbar = new UIProgress(game);
            hpbar.Name = "hpbarMotor" + motorID;
            hpbar.Angular = true;
            hpbar.Percent = GameSettings.gameMotors[motorID].HP;
            hpbar.PositionAndSize = new Rectangle(0, 0, 100, 20);
            UIParent.UI.Add(hpbar);
            GameSettings.gameMotors[motorID].HPChanged = (Motorek_HPChanged)((m, old) => { //connect hp bar to player hp change event
                ((UIProgress)UIParent.UI["hpbarMotor" + motorID]).Percent = m.HP / 100.0f;
            });
            label = new UILabel(game);
            label.Font = gameUIFont;
            label.AutoSize = true;
            label.PositionAndSize = new Rectangle(2, 2, 0, 0);
            label.Text = GameSettings.gameMotors[motorID].name;
            UIParent.UI.Add(label);
            label = new UILabel(game);
            label.Font = gameUIFont;
            label.AutoSize = true;
            label.PositionAndSize = new Rectangle(0, 0, 0, 0);
            label.Text = GameSettings.gameMotors[motorID].name;
            label.fontColor = motorID >= 5 ? Color.Blue : Color.Red;
            UIParent.UI.Add(label);

            //teammates hp bars and names

            //minimap

            //frag/point/time counter
            label = new UILabel(game);
            label.Name = "playerCounterShade";
            label.Font = gameUIFont_Counters;
            label.AutoSize = true;
            int counter_height = (int)gameUIFont_Counters.MeasureString("Mg").Y;
            label.PositionAndSize = new Rectangle(2, height - counter_height, 0, 0);
            label.Text = "";
            UIParent.UI.Add(label);
            label = new UILabel(game);
            label.Name = "playerCounterFront";
            label.Font = gameUIFont_Counters;
            label.AutoSize = true;
            label.PositionAndSize = new Rectangle(0, height - counter_height - 2, 0, 0);
            label.Text = "";
            label.fontColor = motorID >= 5 ? Color.Blue : Color.Red;
            UIParent.UI.Add(label);
            for (int i = 0; i < GameSettings.gameMotors.Length; i++)
                if (GameSettings.gameMotors[i] != null)
                {
                    GameSettings.gameMotors[i].FragsChanged = FragsPoints_Changed;
                    GameSettings.gameMotors[i].PointsChanged = FragsPoints_Changed;
                }
            FragsPoints_Changed(GameSettings.gameMotors[motorID], 0); //show initials

            UIParent.ESCHook += UIParent_ESCHook;

            UIParent.UI.LoadAndInitialize();
            game.mCursor.Visible = false;
            GameSettings.gamePlayScreen.gameFinished = UIParent_ESCHook;
        }
Example #4
0
        private void CreateTestUI()
        {
            UIButton button;
            button = new UIButton(this);
            button.Name = "Button1";
            button.Text = "Fullscreen: " + (graphics.IsFullScreen ? "On" : "Off");
            button.PositionAndSize = new Rectangle(10, 10, 150, 30);
            button.Action += (UIButton_Action)((btn) =>
            {
                SetGraphMode(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight, !graphics.IsFullScreen);
                btn.Text = "Fullscreen: " + (graphics.IsFullScreen ? "On" : "Off");
                UI["TextBox1"].Enabled = !UI["TextBox1"].Enabled;
                UI["Combo1"].Enabled = !UI["Combo1"].Enabled;
            });
            UI.Add(button);

            button = new UIButton(this);
            button.Name = "Button2";
            button.Text = "taaa...";
            button.PositionAndSize = new Rectangle(165, 10, 100, 50);
            button.Action += (UIButton_Action)((btn) =>
            {
                UI["Button1"].Enabled = !UI["Button1"].Enabled;
                UI["Label1"].Enabled = !UI["Label1"].Enabled;
                ((UIComboBox)UI["Combo1"]).Edible = !((UIComboBox)UI["Combo1"]).Edible;
                if (((UIComboBox)UI["Combo1"]).Edible)
                    UI["Combo1"].PositionAndSize = new Rectangle(UI["Combo1"].PositionAndSize.X, UI["Combo1"].PositionAndSize.Y, 200, 50);
                else
                    UI["Combo1"].PositionAndSize = new Rectangle(UI["Combo1"].PositionAndSize.X, UI["Combo1"].PositionAndSize.Y, 100, 0);
                switch (((UITextBox)UI["TextBox1"]).PasswordChar)
                {
                    case '\0': ((UITextBox)UI["TextBox1"]).PasswordChar = '*'; break;
                    case '*': ((UITextBox)UI["TextBox1"]).PasswordChar = '\0'; break;
                }
                ((UIListBox)UI["ListBox1"]).Add(UI["TextBox1"].Text);
            });
            UI.Add(button);

            UITextBox textbox = new UITextBox(this);
            textbox.Name = "TextBox1";
            textbox.Text = "kupa";
            textbox.TextLenghtLimit = 10;
            textbox.PositionAndSize = new Rectangle(270, 10, 150, 30);
            textbox.PasswordChar = '*';
            UI.Add(textbox);

            UILabel label = new UILabel(this);
            label.Name = "Label1";
            label.Text = "jakis tam...\ntekst";
            label.Enabled = false;
            label.PositionAndSize = new Rectangle(UI["Button1"].PositionAndSize.X, UI["Button1"].PositionAndSize.Y + UI["Button1"].PositionAndSize.Height + 5, 0, 0);
            UI.Add(label);

            UIComboBox combo1 = new UIComboBox(this);
            combo1.Name = "Combo1";
            combo1.Edible = false;
            combo1.PositionAndSize = new Rectangle(UI["Button2"].PositionAndSize.X, UI["Button2"].PositionAndSize.Y + UI["Button2"].PositionAndSize.Height + 5, 100, 0);
            combo1.Values.Add("pos1");
            combo1.Values.Add("pos2");
            combo1.Values.Add("pos3");
            combo1.Values.Add("pos4");
            combo1.MaxDisplayedItems = 3;
            combo1.SelectionChanged += (UIComboBox_SelectionChanged)((combo, oldindex) =>
            {
                UI["TextBox1"].Text = combo.SelectedValue;
            });
            UI.Add(combo1);

            UIListBox listBox1 = new UIListBox(this);
            listBox1.Name = "ListBox1";
            listBox1.PositionAndSize = new Rectangle(UI["TextBox1"].PositionAndSize.X + UI["TextBox1"].PositionAndSize.Width + 5, UI["TextBox1"].PositionAndSize.Y, 150, 0);
            listBox1.AutoSizeHeight = true;
            listBox1.MaxVisibleValues = 5;
            listBox1.Add("Button1");
            listBox1.Add("Button2");
            listBox1.Add("TextBox1");
            listBox1.Add("Label1");
            listBox1.Add("Combo1");
            listBox1.AutoSizeHeight = false;
            listBox1.PositionAndSize = new Rectangle(listBox1.PositionAndSize.X, listBox1.PositionAndSize.Y, listBox1.PositionAndSize.Width, listBox1.PositionAndSize.Height + 50);
            listBox1.ItemHover += (UIListBox_ItemEvent)((list, itemindex) =>
            {
                list.SelectedIndex = itemindex;
            });
            listBox1.ItemClicked += (UIListBox_ItemEvent)((list, itemindex) =>
            {
                if (itemindex < 5)
                    UI[list[itemindex].Text].Enabled = !UI[list[itemindex].Text].Enabled;
                else
                    ((UIListBox)UI["ListBox1"]).RemoveAt(itemindex);
            });
            UI.Add(listBox1);

            UIScrollBar scroll1 = new UIScrollBar(this, false);
            scroll1.Name = "Scroll1";
            scroll1.MinimalValue = 0;
            scroll1.MaximalValue = 200;
            scroll1.PositionAndSize = new Rectangle(label.PositionAndSize.X, label.PositionAndSize.Y + label.PositionAndSize.Height + 100, 150, 150);
            scroll1.Value = 0;
            scroll1.ValuesOnScreen = 3;
            scroll1.ValueChanged += (UIScrollBar_ValueChanged)((scroll, oldval) =>
            {
                UI["Label1"].Text = (oldval < scroll.Value ? "zwiekszone na:\n" : "zmniejszone na:\n") + scroll.Value;
                ((UIProgress)UI["ProgressBar1"]).Percent = scroll.Value / 200.0;
            });
            UI.Add(scroll1);

            UICheckBox checkBox1 = new UICheckBox(this);
            checkBox1.Name = "CheckBox1";
            checkBox1.AutoSize = true;
            checkBox1.Text = "checkbox1";
            checkBox1.PositionAndSize = new Rectangle(combo1.PositionAndSize.X, combo1.PositionAndSize.Bottom + 5, 0, 0);
            UI.Add(checkBox1);

            UIKeyPicker keypicker1 = new UIKeyPicker(this);
            keypicker1.Name = "KeyPicker1";
            keypicker1.PositionAndSize = new Rectangle(scroll1.PositionAndSize.X, scroll1.PositionAndSize.Bottom + 5, 100, 30);
            keypicker1.SelectedKey = Keys.A;
            UI.Add(keypicker1);

            UIProgress progress1 = new UIProgress(this);
            progress1.Name = "ProgressBar1";
            progress1.PositionAndSize = new Rectangle(keypicker1.PositionAndSize.X, keypicker1.PositionAndSize.Bottom + 5, 100, 20);
            progress1.Angular = true;
            progress1.color = Color.Blue; //relevant when Angular==true
            progress1.Percent = 0.8;
            UI.Add(progress1);
        }