示例#1
0
        private void InitializeComponents()
        {
            // buttonBack
            buttonBack                 = new UI.Components.Button("buttonBack");
            buttonBack.Size            = new Vector2f(120, 50);
            buttonBack.Location        = new Vector2f(Application.Game.Window.Size.X * 0.05f, 5);
            buttonBack.Content         = "Back";
            buttonBack.FontSize        = 15;
            buttonBack.ForegroundColor = Color.White;
            buttonBack.BackgroundImage = new Image(@"assets/images/block_icon.png");
            buttonBack.OnClicked      += ButtonBack_Clicked;
            buttonBack.SetLayer(1);


            // labelVolumeText
            labelVolumeText                 = new UI.Components.Label("labelVolumeText");
            labelVolumeText.Location        = new Vector2f(Application.Game.Window.Size.X * 0.05f, Application.Game.Window.Size.Y * 0.15f);
            labelVolumeText.Size            = new Vector2f(120, 50);
            labelVolumeText.Content         = "Volume:";
            labelVolumeText.FontSize        = 18;
            labelVolumeText.Alignment       = UI.Components.Alignment.Center;
            labelVolumeText.BackgroundColor = Color.Transparent;
            labelVolumeText.ForegroundColor = Color.White;
            labelVolumeText.SetLayer(1);

            // textboxVolumeInput
            textboxVolumeInput                 = new UI.Components.TextBox("textboxVolumeInput");
            textboxVolumeInput.Location        = new Vector2f(Application.Game.Window.Size.X * 0.35f, Application.Game.Window.Size.Y * 0.145f);
            textboxVolumeInput.Size            = new Vector2f(120, 50);
            textboxVolumeInput.Content         = Settings.Volume.ToString();
            textboxVolumeInput.FontSize        = 18;
            textboxVolumeInput.BackgroundColor = Color.Transparent;
            textboxVolumeInput.ForegroundColor = Color.White;
            textboxVolumeInput.SetLayer(1);

            // labelScaleText
            labelScaleText                 = new UI.Components.Label("labelScaleText");
            labelScaleText.Location        = new Vector2f(Application.Game.Window.Size.X * 0.05f, Application.Game.Window.Size.Y * 0.3f);
            labelScaleText.Size            = new Vector2f(120, 50);
            labelScaleText.Content         = "Scale:";
            labelScaleText.FontSize        = 18;
            labelScaleText.Alignment       = UI.Components.Alignment.Center;
            labelScaleText.BackgroundColor = Color.Transparent;
            labelScaleText.ForegroundColor = Color.White;
            labelScaleText.SetLayer(1);

            // textboxScaleInput
            textboxScaleInput                 = new UI.Components.TextBox("textboxScaleInput");
            textboxScaleInput.Location        = new Vector2f(Application.Game.Window.Size.X * 0.35f, Application.Game.Window.Size.Y * 0.295f);
            textboxScaleInput.Size            = new Vector2f(120, 50);
            textboxScaleInput.Content         = Settings.Scale.ToString();
            textboxScaleInput.FontSize        = 18;
            textboxScaleInput.BackgroundColor = Color.Transparent;
            textboxScaleInput.ForegroundColor = Color.White;
            textboxScaleInput.SetLayer(1);

            // block
            block.BlockType  = 'T';
            block.BlockArray = BlockInformation.BlockArrays.Where(b => b.Key == block.BlockType).First().Value;
            block.Position   = new Vector2f(Application.Game.Window.Size.X * 0.35f, Application.Game.Window.Size.Y * 0.4f);

            // buttonCancel
            buttonCancel                 = new UI.Components.Button("buttonCancel");
            buttonCancel.Location        = new Vector2f(Application.Game.Window.Size.X * 0.05f, Application.Game.Window.Size.Y * 0.90f);
            buttonCancel.Size            = new Vector2f(150, 50);
            buttonCancel.Content         = "Cancel";
            buttonCancel.FontSize        = 15;
            buttonCancel.ForegroundColor = Color.White;
            buttonCancel.BackgroundImage = new Image(@"assets/images/block_icon.png");
            buttonCancel.OnClicked      += ButtonCancel_Click;
            buttonCancel.SetLayer(1);

            // buttonApply
            buttonApply                 = new UI.Components.Button("buttonCancel");
            buttonApply.Size            = new Vector2f(150, 50);
            buttonApply.Location        = new Vector2f(Application.Game.Window.Size.X * 0.95f - buttonApply.Size.X, Application.Game.Window.Size.Y * 0.90f);
            buttonApply.Content         = "Apply Changes";
            buttonApply.FontSize        = 15;
            buttonApply.ForegroundColor = Color.White;
            buttonApply.BackgroundImage = new Image(@"assets/images/block_icon.png");
            buttonApply.OnClicked      += ButtonApply_Click;
            buttonApply.SetLayer(1);

            // buttonApply

            m_Interface.AddChild(new UIElement[]
            {
                labelVolumeText,
                textboxVolumeInput,
                labelScaleText,
                textboxScaleInput,
                buttonCancel,
                buttonApply,
                buttonBack,
            });
        }
示例#2
0
        private void InitializeComponents()
        {
            //
            // ButtonStart
            //
            ButtonRestart                 = new UI.Components.Button("ButtonRestart");
            ButtonRestart.Content         = "Restart";
            ButtonRestart.FontSize        = 12;
            ButtonRestart.ForegroundColor = Color.White;
            ButtonRestart.Size            = new Vector2f(150, 75);
            ButtonRestart.Location        = new Vector2f(Application.Game.Window.Size.X * 0.10f, 250);
            ButtonRestart.BackgroundImage = new Image(@"assets/images/block_icon.png");
            ButtonRestart.OnClicked      += ButtonRestart_Clicked;
            ButtonRestart.OnMouseEntered += ButtonRestart_MouseEntered;
            ButtonRestart.OnMouseLeft    += ButtonRestart_MouseLeft;
            ButtonRestart.SetLayer(1);

            //
            // ButtonQuit
            //
            ButtonQuit                 = new UI.Components.Button("ButtonQuitToMainMenu");
            ButtonQuit.Content         = "Quit To Main Menu";
            ButtonQuit.FontSize        = 12;
            ButtonQuit.ForegroundColor = Color.White;
            ButtonQuit.Size            = new Vector2f(150, 75);
            ButtonQuit.Location        = new Vector2f(Application.Game.Window.Size.X - Application.Game.Window.Size.X * 0.10f - ButtonQuit.Size.X, 250);
            ButtonQuit.BackgroundImage = new Image(@"assets/images/block_icon.png");
            ButtonQuit.OnClicked      += (ButtonQuit_Clicked);
            ButtonQuit.OnMouseEntered += ButtonQuit_MouseEntered;
            ButtonQuit.OnMouseLeft    += ButtonQuit_MouseLeft;
            ButtonQuit.SetLayer(1);

            //
            // LabelGameOver
            //
            LabelGameOver                 = new UI.Components.Label("LabelGameOver");
            LabelGameOver.Content         = $"Game Over";
            LabelGameOver.Size            = new Vector2f(100, 50);
            LabelGameOver.Location        = new Vector2f(Application.Game.Window.Size.X / 2 - LabelGameOver.Size.X * 1.5f, 100);
            LabelGameOver.ForegroundColor = Color.Red;
            LabelGameOver.BackgroundColor = Color.Transparent;
            LabelGameOver.FontSize        = 50;
            LabelGameOver.SetLayer(1);

            //
            // ImageBlur
            //
            Image img = new Image(Application.Game.Window.Size.X, Application.Game.Window.Size.Y, new Color(54, 50, 41));

            ImageBlur              = new UI.Components.Image("ImageBlur", img);
            ImageBlur.Size         = new Vector2f(Application.Game.Window.Size.X, Application.Game.Window.Size.Y);
            ImageBlur.Transparency = 150;
            ImageBlur.SetLayer(0);

            //
            // Add Components
            //
            m_Interface.AddChild(new UIElement[]
            {
                ButtonRestart,
                ButtonQuit,
                LabelGameOver,
                ImageBlur,
            });
        }