Exemplo n.º 1
0
        private void BuildUI()
        {
            _button1            = new TextButton();
            _button1.Text       = "Window 1";
            _button1.Toggleable = true;
            _button1.Id         = "_button1";

            _button2            = new TextButton();
            _button2.Text       = "Window 2";
            _button2.Toggleable = true;
            _button2.Id         = "_button2";

            _button3            = new TextButton();
            _button3.Text       = "Window 3";
            _button3.Toggleable = true;
            _button3.Id         = "_button3";

            var horizontalStackPanel1 = new HorizontalStackPanel();

            horizontalStackPanel1.Spacing = 8;
            horizontalStackPanel1.Widgets.Add(_button1);
            horizontalStackPanel1.Widgets.Add(_button2);
            horizontalStackPanel1.Widgets.Add(_button3);

            _labelOverGui      = new Label();
            _labelOverGui.Text = "Is mouse over GUI: true";
            _labelOverGui.VerticalAlignment = Myra.Graphics2D.UI.VerticalAlignment.Bottom;
            _labelOverGui.Id = "_labelOverGui";


            Widgets.Add(horizontalStackPanel1);
            Widgets.Add(_labelOverGui);
        }
Exemplo n.º 2
0
        /// <inheritdoc />
        public override void LayoutControls()
        {
            var bottomToolbar = new HorizontalStackPanel
            {
                Size = new SizeF(Size.Width, 40)
            };

            bottomToolbar.Location = new PointF(0, Bounds.Height - bottomToolbar.Size.Height);

            bottomToolbar.Add(new WiFiIndicator
            {
                Size      = new SizeF(50, 40),
                TextAlign = RectAlign.Top | RectAlign.Center
            });
            bottomToolbar.Add(new BatteryIndicator
            {
                Size      = new SizeF(50, 40),
                TextAlign = RectAlign.Top | RectAlign.Center
            });
            bottomToolbar.Add(new Label
            {
                Text      = $"{PassiveDevices.Battery.GetPercentage()*100:F0}%",
                Font      = Fonts.SegoeUi.CreateFont(28),
                TextAlign = RectAlign.Top | RectAlign.Center,
                Size      = new SizeF(80, 40)
            });

            Add(bottomToolbar);
        }
Exemplo n.º 3
0
        public void addIndicators()
        {
            // Bottom Left Panel
            HorizontalStackPanel bottomLeftPanel = new HorizontalStackPanel();

            bottomLeftPanel.HorizontalAlignment = HorizontalAlignment.Left;
            bottomLeftPanel.VerticalAlignment   = VerticalAlignment.Bottom;
            bottomLeftPanel.Spacing             = 8;

            Stylesheet.Current.VerticalProgressBarStyle.Background = new ColoredRegion(DefaultAssets.WhiteRegion, Color.Gray);
            Stylesheet.Current.VerticalProgressBarStyle.Filler     = new ColoredRegion(DefaultAssets.WhiteRegion, Color.Red);
            _healthIndicator         = new VerticalProgressBar();
            _healthIndicator.Width   = 64;
            _healthIndicator.Height  = 64;
            _healthIndicator.Minimum = 0;
            _healthIndicator.Maximum = 100;
            _healthIndicator.Value   = 100;
            bottomLeftPanel.Widgets.Add(_healthIndicator);

            Stylesheet.Current.VerticalProgressBarStyle.Background = new ColoredRegion(DefaultAssets.WhiteRegion, Color.Transparent);
            Stylesheet.Current.VerticalProgressBarStyle.Filler     = new ColoredRegion(DefaultAssets.WhiteRegion, Color.Blue);
            _kevlarIndicator         = new VerticalProgressBar();
            _kevlarIndicator.Width   = 64;
            _kevlarIndicator.Height  = 64;
            _kevlarIndicator.Minimum = 0;
            _kevlarIndicator.Maximum = 100;
            _kevlarIndicator.Value   = 0;
            bottomLeftPanel.Widgets.Add(_kevlarIndicator);

            _ui.Widgets.Add(bottomLeftPanel);
            // Bottom Panel
            VerticalStackPanel bottomPanel = new VerticalStackPanel();

            bottomPanel.HorizontalAlignment = HorizontalAlignment.Center;
            bottomPanel.VerticalAlignment   = VerticalAlignment.Bottom;

            //bottomPanel.Background = new TextureRegion(Resources.MenuBackground);

            _handsLabel      = new Label();
            _handsLabel.Text = "Hands";
            bottomPanel.Widgets.Add(_handsLabel);

            _handsImage = new Image();
            bottomPanel.Widgets.Add(_handsImage);

            _handsAmount      = new Label();
            _handsAmount.Text = "";
            bottomPanel.Widgets.Add(_handsAmount);

            Stylesheet.Current.HorizontalProgressBarStyle.Background = new ColoredRegion(DefaultAssets.WhiteRegion, Color.Transparent);
            Stylesheet.Current.HorizontalProgressBarStyle.Filler     = new ColoredRegion(DefaultAssets.WhiteRegion, Color.LimeGreen);
            _handsProgressIndicator        = new HorizontalProgressBar();
            _handsProgressIndicator.Height = 20;
            _handsProgressIndicator.Width  = 100;
            bottomPanel.Widgets.Add(_handsProgressIndicator);

            _ui.Widgets.Add(bottomPanel);
        }
Exemplo n.º 4
0
        private void Build(Score score, bool levelHasHeart)
        {
            HorizontalAlignment = HorizontalAlignment.Stretch;
            Padding = new Thickness(5);
            Margin = new Thickness(0, 0, 5, 0);
            Background = background;
            MouseEntered += (_, _) => Background = hoverBackground;
            MouseLeft += (_, _) => Background = background;

            var smallerFont = Fonts.Orkney.GetFont(Fonts.PtToPx(13));

            var scoreHeartPanel = new HorizontalStackPanel();
            Widgets.Add(scoreHeartPanel);

            if (levelHasHeart)
            {
                var heart = new Image();
                UIUtil.SetHeart(heart, 18);
                heart.Renderable = score.HeartGotten
                    ? LevelSelect.HeartIcon 
                    : LevelSelect.HeartOutlineIcon;
                scoreHeartPanel.Widgets.Add(heart);
            }

            var scoreTxt = new Label
            {
                Text = $"{score.Percent:0.00%} {score.Mod}"
            };

            scoreHeartPanel.Widgets.Add(scoreTxt);

            var hits = new Label
            {
                Text = $"{score.TotalHits} hits",
                Font = smallerFont,
            };
            Widgets.Add(hits);

            var slomoTime = new Label
            {
                Text = $"{score.TotalSlomoTime/1000:0.##}s of slomo",
                Font = smallerFont,
            };
            Widgets.Add(slomoTime);

            var date = new Label
            {
                Text = score.Time.ToLocalTime().ToString(CultureInfo.InstalledUICulture),
                TextColor = Color.DimGray,
                Font = smallerFont,
            };
            Widgets.Add(date);
        }
Exemplo n.º 5
0
        public AmountDialog() : base()
        {
            var windowGrid = new Grid();

            windowGrid.RowsProportions.Add(new Proportion());
            windowGrid.RowsProportions.Add(new Proportion());

            Amount                = new TextBox();
            Amount.GridRow        = 0;
            Amount.ValueChanging += Amount_ValueChanging;


            var buttonsGrid = new HorizontalStackPanel()
            {
                GridRow             = 1,
                Spacing             = 8,
                HorizontalAlignment = HorizontalAlignment.Right
            };

            ButtonOk = new ImageTextButton
            {
                Text = "Ok"
            };

            ButtonOk.Click += (sender, args) =>
            {
                Result = true;
                Close();
            };

            buttonsGrid.Widgets.Add(ButtonOk);

            ButtonCancel = new ImageTextButton
            {
                Text       = "Cancel",
                GridColumn = 1
            };

            ButtonCancel.Click += (sender, args) =>
            {
                Result = false;
                Close();
            };


            buttonsGrid.Widgets.Add(ButtonCancel);

            windowGrid.Widgets.Add(Amount);
            windowGrid.Widgets.Add(buttonsGrid);

            InternalChild.Widgets.Add(windowGrid);
        }
Exemplo n.º 6
0
        protected override void LoadContent()
        {
            base.LoadContent();

            MyraEnvironment.Game = this;

            _root = new HorizontalStackPanel();

            _root.Proportions.Add(new Proportion(ProportionType.Auto));
            _root.Proportions.Add(new Proportion(ProportionType.Auto));
            _root.Proportions.Add(new Proportion(ProportionType.Fill));

            _listDemos = new ListBox();

            var demos = CreateDemos();

            foreach (var d in demos)
            {
                var item = new ListItem
                {
                    Text = d.Name,
                    Tag  = d
                };

                _listDemos.Items.Add(item);
            }

            _listDemos.SelectedIndexChanged += ListDemos_SelectedIndexChanged;

            _root.Widgets.Add(_listDemos);

            _root.Widgets.Add(new VerticalSeparator());

            _panelDemo = new Panel();
            _root.Widgets.Add(_panelDemo);

            _desktop      = new Desktop();
            _desktop.Root = _root;

#if MONOGAME
            // Inform Myra that external text input is available
            // So it stops translating Keys to chars
            _desktop.HasExternalTextInput = true;

            // Provide that text input
            Window.TextInput += (s, a) =>
            {
                _desktop.OnChar(a.Character);
            };
#endif
        }
Exemplo n.º 7
0
        private void BuildUI()
        {
            Version      = new Label();
            Version.Text = "0.0.0";
            Version.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            Version.VerticalAlignment   = Myra.Graphics2D.UI.VerticalAlignment.Bottom;
            Version.Id = "Version";

            Logo = new Image();
            Logo.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            Logo.VerticalAlignment   = Myra.Graphics2D.UI.VerticalAlignment.Center;
            Logo.Id = "Logo";

            Play           = new TextButton("MainMenuBtn");
            Play.Text      = "Play";
            Play.TextColor = Color.White;
            Play.Id        = "Play";

            Settings           = new TextButton("MainMenuBtn");
            Settings.Text      = "Settings";
            Settings.TextColor = Color.White;
            Settings.Id        = "Settings";

            Exit           = new TextButton("MainMenuBtn");
            Exit.Text      = "Quit";
            Exit.TextColor = Color.White;
            Exit.Id        = "Exit";

            var horizontalStackPanel1 = new HorizontalStackPanel();

            horizontalStackPanel1.Spacing             = 10;
            horizontalStackPanel1.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            horizontalStackPanel1.VerticalAlignment   = Myra.Graphics2D.UI.VerticalAlignment.Center;
            horizontalStackPanel1.Margin = new Thickness(0, 30, 0, 0);
            horizontalStackPanel1.Widgets.Add(Play);
            horizontalStackPanel1.Widgets.Add(Settings);
            horizontalStackPanel1.Widgets.Add(Exit);


            Spacing             = 10;
            HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            VerticalAlignment   = Myra.Graphics2D.UI.VerticalAlignment.Center;
            Widgets.Add(Version);
            Widgets.Add(Logo);
            Widgets.Add(horizontalStackPanel1);
        }
Exemplo n.º 8
0
        public TabPanel()
        {
            tabsPanel = new HorizontalStackPanel();

            wrapper = new DockPanel
            {
                Placement     = DockPanel.DockedControlPlacement.Top,
                DockedControl = new Background
                {
                    Color   = new Color(25, 25, 52),
                    Content = new Boundary
                    {
                        MinHeight = 1,
                        MaxHeight = 1,
                        Content   = tabsPanel
                    }
                }
            };

            Content = wrapper;
        }
Exemplo n.º 9
0
        private void BuildUI()
        {
            Left = 0;
            Top  = 0;

            ItemListBox    = new ListBox();
            ItemListBox.Id = "ItemListBox";

            TopPanel = new HorizontalStackPanel()
            {
                Padding = new Thickness(10),
                Margin  = new Thickness(0, 10, 0, 0),
            };

            HintText = new Label()
            {
                Margin              = new Thickness(10, 0, 0, 10),
                TextColor           = Color.White,
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Bottom
            };

            TopPanel.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            TopPanel.VerticalAlignment   = Myra.Graphics2D.UI.VerticalAlignment.Top;

            for (var i = 0; i < 8; i++)
            {
                var panel = new Panel();
                panel.Width             = 64;
                panel.Height            = 64;
                panel.VerticalAlignment = VerticalAlignment.Center;

                var inventorySlotBackground = new Image();
                inventorySlotBackground.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch;
                inventorySlotBackground.VerticalAlignment   = Myra.Graphics2D.UI.VerticalAlignment.Stretch;

                var inventorySlotItemImage = new Image();
                inventorySlotItemImage.Width  = 32;
                inventorySlotItemImage.Height = 32;
                inventorySlotItemImage.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
                inventorySlotItemImage.VerticalAlignment   = Myra.Graphics2D.UI.VerticalAlignment.Center;

                var inventorySlotCount = new Label();
                inventorySlotCount.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Right;
                inventorySlotCount.VerticalAlignment   = Myra.Graphics2D.UI.VerticalAlignment.Bottom;

                InventorySlotBackgrounds.Add(inventorySlotBackground);
                InventorySlotItemImages.Add(inventorySlotItemImage);
                InventorySlotItemCounts.Add(inventorySlotCount);

                panel.Widgets.Add(inventorySlotBackground);
                panel.Widgets.Add(inventorySlotItemImage);
                panel.Widgets.Add(inventorySlotCount);

                TopPanel.Widgets.Add(panel);
            }

            var topPanel = new Panel()
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Top,
                Background          = null,
                Padding             = new Thickness(5)
            };

            InventoryPanel = new VerticalStackPanel()
            {
                VerticalAlignment   = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
                Background          = new SolidBrush(Color.Black * 0.5f),
                IsDraggable         = true,
                DragHandle          = topPanel
            };

            InventoryPanel.AddChild(topPanel);

            topPanel.AddChild(new Label()
            {
                Text                = "Inventory",
                TextColor           = Color.White,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center
            });

            var closeInventoryButton = topPanel.AddChild(new TextButton()
            {
                Text                = "x",
                Background          = null,
                FocusedBackground   = null,
                OverBackground      = null,
                PressedBackground   = null,
                DisabledBackground  = null,
                HorizontalAlignment = HorizontalAlignment.Right,
                VerticalAlignment   = VerticalAlignment.Center
            });

            closeInventoryButton.Click += (sender, args) => InventoryPanel.Visible = false;

            for (var i = 0; i < 4; i++)
            {
                var horizontalRow = new HorizontalStackPanel();

                for (var j = 0; j < 6; j++)
                {
                    var panel = new Panel();
                    panel.Width  = 64;
                    panel.Height = 64;

                    var inventorySlotBackground = new Image();
                    inventorySlotBackground.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch;
                    inventorySlotBackground.VerticalAlignment   = Myra.Graphics2D.UI.VerticalAlignment.Stretch;

                    var inventorySlotItemImage = new Image();
                    inventorySlotItemImage.Width  = 32;
                    inventorySlotItemImage.Height = 32;
                    inventorySlotItemImage.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
                    inventorySlotItemImage.VerticalAlignment   = Myra.Graphics2D.UI.VerticalAlignment.Center;

                    var inventorySlotCount = new Label();
                    inventorySlotCount.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Right;
                    inventorySlotCount.VerticalAlignment   = Myra.Graphics2D.UI.VerticalAlignment.Bottom;

                    MainInventorySlotBackgrounds.Add(inventorySlotBackground);
                    MainInventorySlotItemImages.Add(inventorySlotItemImage);
                    MainInventorySlotItemCounts.Add(inventorySlotCount);

                    panel.Widgets.Add(inventorySlotBackground);
                    panel.Widgets.Add(inventorySlotItemImage);
                    panel.Widgets.Add(inventorySlotCount);

                    horizontalRow.AddChild(panel);
                }

                InventoryPanel.AddChild(horizontalRow);
            }
            ;
            Widgets.Add(ItemListBox);
            Widgets.Add(TopPanel);
            Widgets.Add(InventoryPanel);
            Widgets.Add(HintText);
        }
Exemplo n.º 10
0
        private void BuildUI()
        {
            _colorWheel    = new Image();
            _colorWheel.Id = "_colorWheel";

            _hsPicker = new Image();
            _hsPicker.BorderThickness     = new Thickness(1);
            _hsPicker.Padding             = new Thickness(4);
            _hsPicker.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            _hsPicker.VerticalAlignment   = Myra.Graphics2D.UI.VerticalAlignment.Center;
            _hsPicker.Enabled             = false;
            _hsPicker.Background          = new SolidBrush("#FFFFFFFF");
            _hsPicker.Border = new SolidBrush("#000000");
            _hsPicker.Id     = "_hsPicker";

            var panel1 = new Panel();

            panel1.Width  = 147;
            panel1.Height = 147;
            panel1.Widgets.Add(_colorWheel);
            panel1.Widgets.Add(_hsPicker);

            _gradient                 = new Image();
            _gradient.Width           = 10;
            _gradient.Height          = 147;
            _gradient.BorderThickness = new Thickness(1);
            _gradient.Border          = new SolidBrush("#000000");
            _gradient.Id              = "_gradient";

            _vPicker                     = new Image();
            _vPicker.Margin              = new Thickness(0, 1);
            _vPicker.BorderThickness     = new Thickness(1);
            _vPicker.Padding             = new Thickness(4);
            _vPicker.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            _vPicker.Enabled             = false;
            _vPicker.Background          = new SolidBrush("#FFFFFFFF");
            _vPicker.Border              = new SolidBrush("#000000");
            _vPicker.Id                  = "_vPicker";

            var panel2 = new Panel();

            panel2.Widgets.Add(_gradient);
            panel2.Widgets.Add(_vPicker);

            _colorBackground       = new Image();
            _colorBackground.Width = 40;
            _colorBackground.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            _colorBackground.VerticalAlignment   = Myra.Graphics2D.UI.VerticalAlignment.Stretch;
            _colorBackground.GridColumnSpan      = 3;
            _colorBackground.Background          = new SolidBrush("#FFFFFFFF");
            _colorBackground.Id = "_colorBackground";

            _colorDisplay       = new Image();
            _colorDisplay.Width = 40;
            _colorDisplay.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            _colorDisplay.VerticalAlignment   = Myra.Graphics2D.UI.VerticalAlignment.Stretch;
            _colorDisplay.GridColumnSpan      = 3;
            _colorDisplay.Id = "_colorDisplay";

            var label1 = new Label();

            label1.Text    = "RGB";
            label1.GridRow = 1;

            _inputRGB                = new TextBox();
            _inputRGB.GridColumn     = 1;
            _inputRGB.GridRow        = 1;
            _inputRGB.GridColumnSpan = 2;
            _inputRGB.Id             = "_inputRGB";

            var label2 = new Label();

            label2.Text    = "HSV";
            label2.GridRow = 2;

            _inputHSV                = new TextBox();
            _inputHSV.GridColumn     = 1;
            _inputHSV.GridRow        = 2;
            _inputHSV.GridColumnSpan = 2;
            _inputHSV.Id             = "_inputHSV";

            var label3 = new Label();

            label3.Text    = "HEX";
            label3.GridRow = 3;

            _inputHEX                = new TextBox();
            _inputHEX.GridColumn     = 1;
            _inputHEX.GridRow        = 3;
            _inputHEX.GridColumnSpan = 2;
            _inputHEX.Id             = "_inputHEX";

            var label4 = new Label();

            label4.Text    = "Alpha";
            label4.GridRow = 4;

            _inputAlpha            = new TextBox();
            _inputAlpha.GridColumn = 2;
            _inputAlpha.GridRow    = 4;
            _inputAlpha.Id         = "_inputAlpha";

            _sliderAlpha            = new HorizontalSlider();
            _sliderAlpha.Maximum    = 255;
            _sliderAlpha.Height     = 21;
            _sliderAlpha.GridColumn = 1;
            _sliderAlpha.GridRow    = 4;
            _sliderAlpha.Id         = "_sliderAlpha";

            _saveColor      = new TextButton();
            _saveColor.Text = "Save Color";
            _saveColor.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Right;
            _saveColor.GridRow             = 5;
            _saveColor.GridColumnSpan      = 3;
            _saveColor.Id = "_saveColor";

            var grid1 = new Grid();

            grid1.ColumnSpacing = 8;
            grid1.RowSpacing    = 6;
            grid1.ColumnsProportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            grid1.ColumnsProportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Fill,
            });
            grid1.ColumnsProportions.Add(new Proportion
            {
                Type  = Myra.Graphics2D.UI.ProportionType.Pixels,
                Value = 60,
            });
            grid1.RowsProportions.Add(new Proportion
            {
                Type  = Myra.Graphics2D.UI.ProportionType.Pixels,
                Value = 40,
            });
            grid1.RowsProportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            grid1.RowsProportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            grid1.RowsProportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            grid1.RowsProportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            grid1.RowsProportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            grid1.VerticalAlignment = Myra.Graphics2D.UI.VerticalAlignment.Top;
            grid1.Widgets.Add(_colorBackground);
            grid1.Widgets.Add(_colorDisplay);
            grid1.Widgets.Add(label1);
            grid1.Widgets.Add(_inputRGB);
            grid1.Widgets.Add(label2);
            grid1.Widgets.Add(_inputHSV);
            grid1.Widgets.Add(label3);
            grid1.Widgets.Add(_inputHEX);
            grid1.Widgets.Add(label4);
            grid1.Widgets.Add(_inputAlpha);
            grid1.Widgets.Add(_sliderAlpha);
            grid1.Widgets.Add(_saveColor);

            var horizontalStackPanel1 = new HorizontalStackPanel();

            horizontalStackPanel1.Spacing = 8;
            horizontalStackPanel1.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            horizontalStackPanel1.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            horizontalStackPanel1.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Fill,
            });
            horizontalStackPanel1.Widgets.Add(panel1);
            horizontalStackPanel1.Widgets.Add(panel2);
            horizontalStackPanel1.Widgets.Add(grid1);

            _userColors = new Grid();
            _userColors.ColumnSpacing     = 8;
            _userColors.RowSpacing        = 8;
            _userColors.GridSelectionMode = Myra.Graphics2D.UI.GridSelectionMode.Cell;
            _userColors.Height            = 80;
            _userColors.Padding           = new Thickness(4);
            _userColors.Id = "_userColors";


            Spacing             = 8;
            HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            Width   = 450;
            Padding = new Thickness(10, 0, 10, 5);
            Widgets.Add(horizontalStackPanel1);
            Widgets.Add(_userColors);
        }
Exemplo n.º 11
0
        private void BuildUI()
        {
            _menuFileNew              = new MenuItem();
            _menuFileNew.Text         = "&New";
            _menuFileNew.ShortcutText = "Ctrl+N";
            _menuFileNew.Id           = "_menuFileNew";

            _menuFileOpen              = new MenuItem();
            _menuFileOpen.Text         = "&Open";
            _menuFileOpen.ShortcutText = "Ctrl+O";
            _menuFileOpen.Id           = "_menuFileOpen";

            _menuFileReload              = new MenuItem();
            _menuFileReload.Text         = "&Reload";
            _menuFileReload.ShortcutText = "Ctrl+R";
            _menuFileReload.Id           = "_menuFileReload";

            _menuFileSave              = new MenuItem();
            _menuFileSave.Text         = "&Save";
            _menuFileSave.ShortcutText = "Ctrl+S";
            _menuFileSave.Id           = "_menuFileSave";

            _menuFileSaveAs      = new MenuItem();
            _menuFileSaveAs.Text = "Save &As...";
            _menuFileSaveAs.Id   = "_menuFileSaveAs";

            _menuFileExportToCS              = new MenuItem();
            _menuFileExportToCS.Text         = "&Export To C#...";
            _menuFileExportToCS.ShortcutText = "Ctrl+E";
            _menuFileExportToCS.Id           = "_menuFileExportToCS";

            var menuSeparator1 = new MenuSeparator();

            _menuFileLoadStylesheet      = new MenuItem();
            _menuFileLoadStylesheet.Text = "&Load Stylesheet";
            _menuFileLoadStylesheet.Id   = "_menuFileLoadStylesheet";

            _menuFileResetStylesheet      = new MenuItem();
            _menuFileResetStylesheet.Text = "Rese&t Stylesheet";
            _menuFileResetStylesheet.Id   = "_menuFileResetStylesheet";

            var menuSeparator2 = new MenuSeparator();

            _menuFileDebugOptions      = new MenuItem();
            _menuFileDebugOptions.Text = "&UI Debug Options";
            _menuFileDebugOptions.Id   = "_menuFileDebugOptions";

            var menuSeparator3 = new MenuSeparator();

            _menuFileQuit              = new MenuItem();
            _menuFileQuit.Text         = "&Quit";
            _menuFileQuit.ShortcutText = "Ctrl+Q";
            _menuFileQuit.Id           = "_menuFileQuit";

            _menuFile      = new MenuItem();
            _menuFile.Text = "&File";
            _menuFile.Id   = "_menuFile";
            _menuFile.Items.Add(_menuFileNew);
            _menuFile.Items.Add(_menuFileOpen);
            _menuFile.Items.Add(_menuFileReload);
            _menuFile.Items.Add(_menuFileSave);
            _menuFile.Items.Add(_menuFileSaveAs);
            _menuFile.Items.Add(_menuFileExportToCS);
            _menuFile.Items.Add(menuSeparator1);
            _menuFile.Items.Add(_menuFileLoadStylesheet);
            _menuFile.Items.Add(_menuFileResetStylesheet);
            _menuFile.Items.Add(menuSeparator2);
            _menuFile.Items.Add(_menuFileDebugOptions);
            _menuFile.Items.Add(menuSeparator3);
            _menuFile.Items.Add(_menuFileQuit);

            _menuItemSelectAll              = new MenuItem();
            _menuItemSelectAll.Text         = "Select &All";
            _menuItemSelectAll.ShortcutText = "Ctrl+A";
            _menuItemSelectAll.Id           = "_menuItemSelectAll";

            _menuItemCopy              = new MenuItem();
            _menuItemCopy.Text         = "&Copy";
            _menuItemCopy.ShortcutText = "Ctrl+Insert, Ctrl+C";
            _menuItemCopy.Id           = "_menuItemCopy";

            _menuItemPaste              = new MenuItem();
            _menuItemPaste.Text         = "&Paste";
            _menuItemPaste.ShortcutText = "Shift+Insert, Ctrl+V";
            _menuItemPaste.Id           = "_menuItemPaste";

            _menuItemCut              = new MenuItem();
            _menuItemCut.Text         = "Cu&t";
            _menuItemCut.ShortcutText = "Ctrl+X";
            _menuItemCut.Id           = "_menuItemCut";

            _menuItemDuplicate              = new MenuItem();
            _menuItemDuplicate.Text         = "Duplicate";
            _menuItemDuplicate.ShortcutText = "Ctrl+D";
            _menuItemDuplicate.Id           = "_menuItemDuplicate";

            var menuSeparator4 = new MenuSeparator();

            _menuEditFormatSource              = new MenuItem();
            _menuEditFormatSource.Text         = "&Format Source";
            _menuEditFormatSource.ShortcutText = "Ctrl+F";
            _menuEditFormatSource.Id           = "_menuEditFormatSource";

            var menuItem1 = new MenuItem();

            menuItem1.Text = "&Edit";
            menuItem1.Items.Add(_menuItemSelectAll);
            menuItem1.Items.Add(_menuItemCopy);
            menuItem1.Items.Add(_menuItemPaste);
            menuItem1.Items.Add(_menuItemCut);
            menuItem1.Items.Add(_menuItemDuplicate);
            menuItem1.Items.Add(menuSeparator4);
            menuItem1.Items.Add(_menuEditFormatSource);

            _menuHelpAbout      = new MenuItem();
            _menuHelpAbout.Text = "&About";
            _menuHelpAbout.Id   = "_menuHelpAbout";

            var menuItem2 = new MenuItem();

            menuItem2.Text = "&Help";
            menuItem2.Items.Add(_menuHelpAbout);

            _mainMenu    = new HorizontalMenu();
            _mainMenu.Id = "_mainMenu";
            _mainMenu.Items.Add(_menuFile);
            _mainMenu.Items.Add(menuItem1);
            _mainMenu.Items.Add(menuItem2);

            var horizontalSeparator1 = new HorizontalSeparator();

            _projectHolder    = new Panel();
            _projectHolder.Id = "_projectHolder";

            _textSource                   = new TextBox();
            _textSource.Multiline         = true;
            _textSource.Wrap              = true;
            _textSource.VerticalAlignment = Myra.Graphics2D.UI.VerticalAlignment.Stretch;
            _textSource.GridRow           = 2;
            _textSource.Id                = "_textSource";

            var scrollViewer1 = new ScrollViewer();

            scrollViewer1.Content = _textSource;

            _leftSplitPane    = new VerticalSplitPane();
            _leftSplitPane.Id = "_leftSplitPane";
            _leftSplitPane.Widgets.Add(_projectHolder);
            _leftSplitPane.Widgets.Add(scrollViewer1);

            var horizontalSeparator2 = new HorizontalSeparator();

            _textStatus      = new Label();
            _textStatus.Text = "Reloading...";
            _textStatus.Id   = "_textStatus";

            var verticalStackPanel1 = new VerticalStackPanel();

            verticalStackPanel1.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Fill,
            });
            verticalStackPanel1.Widgets.Add(_leftSplitPane);
            verticalStackPanel1.Widgets.Add(horizontalSeparator2);
            verticalStackPanel1.Widgets.Add(_textStatus);

            var label1 = new Label();

            label1.Text = "Filter:";

            _textBoxFilter    = new TextBox();
            _textBoxFilter.Id = "_textBoxFilter";

            var horizontalStackPanel1 = new HorizontalStackPanel();

            horizontalStackPanel1.Spacing = 8;
            horizontalStackPanel1.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            horizontalStackPanel1.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Fill,
            });
            horizontalStackPanel1.Widgets.Add(label1);
            horizontalStackPanel1.Widgets.Add(_textBoxFilter);

            var horizontalSeparator3 = new HorizontalSeparator();

            _propertyGrid    = new PropertyGrid();
            _propertyGrid.Id = "_propertyGrid";

            _propertyGridPane         = new ScrollViewer();
            _propertyGridPane.Id      = "_propertyGridPane";
            _propertyGridPane.Content = _propertyGrid;

            var horizontalSeparator4 = new HorizontalSeparator();

            _textLocation      = new Label();
            _textLocation.Text = "Line: 1, Column: 2, Indent: 3";
            _textLocation.Id   = "_textLocation";

            var verticalStackPanel2 = new VerticalStackPanel();

            verticalStackPanel2.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            verticalStackPanel2.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            verticalStackPanel2.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Fill,
            });
            verticalStackPanel2.Background = new SolidBrush("#000000FF");
            verticalStackPanel2.Widgets.Add(horizontalStackPanel1);
            verticalStackPanel2.Widgets.Add(horizontalSeparator3);
            verticalStackPanel2.Widgets.Add(_propertyGridPane);
            verticalStackPanel2.Widgets.Add(horizontalSeparator4);
            verticalStackPanel2.Widgets.Add(_textLocation);

            _topSplitPane    = new HorizontalSplitPane();
            _topSplitPane.Id = "_topSplitPane";
            _topSplitPane.Widgets.Add(verticalStackPanel1);
            _topSplitPane.Widgets.Add(verticalStackPanel2);


            Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Fill,
            });
            Widgets.Add(_mainMenu);
            Widgets.Add(horizontalSeparator1);
            Widgets.Add(_topSplitPane);
        }
Exemplo n.º 12
0
        private void BuildUI()
        {
            _textNameLeft      = new Label();
            _textNameLeft.Text = "player";
            _textNameLeft.Id   = "_textNameLeft";

            _textGoldLeft      = new Label();
            _textGoldLeft.Text = "Gold: 1000";
            _textGoldLeft.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Right;
            _textGoldLeft.Id = "_textGoldLeft";

            var panel1 = new Panel();

            panel1.Widgets.Add(_textNameLeft);
            panel1.Widgets.Add(_textGoldLeft);

            var horizontalSeparator1 = new HorizontalSeparator();

            var label1 = new Label();

            label1.Text       = "iron rations(5)";
            label1.GridColumn = 1;

            var label2 = new Label();

            label2.Text = "5";
            label2.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Right;
            label2.GridColumn          = 2;

            var label3 = new Label();

            label3.Text       = "canteen";
            label3.GridColumn = 1;
            label3.GridRow    = 1;

            var label4 = new Label();

            label4.Text       = "7";
            label4.GridColumn = 2;
            label4.GridRow    = 1;

            _gridLeft = new Grid();
            _gridLeft.ColumnSpacing        = 8;
            _gridLeft.RowSpacing           = 4;
            _gridLeft.DefaultRowProportion = new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            };
            _gridLeft.ColumnsProportions.Add(new Proportion
            {
                Type  = Myra.Graphics2D.UI.ProportionType.Pixels,
                Value = 16,
            });
            _gridLeft.ColumnsProportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Fill,
            });
            _gridLeft.ColumnsProportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            _gridLeft.GridSelectionMode = Myra.Graphics2D.UI.GridSelectionMode.Row;
            _gridLeft.Id = "_gridLeft";
            _gridLeft.Widgets.Add(label1);
            _gridLeft.Widgets.Add(label2);
            _gridLeft.Widgets.Add(label3);
            _gridLeft.Widgets.Add(label4);

            var scrollViewer1 = new ScrollViewer();

            scrollViewer1.Content = _gridLeft;

            var verticalStackPanel1 = new VerticalStackPanel();

            verticalStackPanel1.Widgets.Add(panel1);
            verticalStackPanel1.Widgets.Add(horizontalSeparator1);
            verticalStackPanel1.Widgets.Add(scrollViewer1);

            _textGoldTransfer      = new Label();
            _textGoldTransfer.Text = "500";
            _textGoldTransfer.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            _textGoldTransfer.Id = "_textGoldTransfer";

            _panelArrow        = new Panel();
            _panelArrow.Height = 20;
            _panelArrow.Id     = "_panelArrow";

            _gridGoldTransfer = new VerticalStackPanel();
            _gridGoldTransfer.VerticalAlignment = Myra.Graphics2D.UI.VerticalAlignment.Center;
            _gridGoldTransfer.Id = "_gridGoldTransfer";
            _gridGoldTransfer.Widgets.Add(_textGoldTransfer);
            _gridGoldTransfer.Widgets.Add(_panelArrow);

            _textNameRight      = new Label();
            _textNameRight.Text = "merchant";
            _textNameRight.Id   = "_textNameRight";

            _textGoldRight      = new Label();
            _textGoldRight.Text = "Gold: 50000";
            _textGoldRight.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Right;
            _textGoldRight.Id = "_textGoldRight";

            var panel2 = new Panel();

            panel2.Widgets.Add(_textNameRight);
            panel2.Widgets.Add(_textGoldRight);

            var horizontalSeparator2 = new HorizontalSeparator();

            var label5 = new Label();

            label5.Text       = "iron rations(100)";
            label5.GridColumn = 1;

            var label6 = new Label();

            label6.Text = "10";
            label6.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Right;
            label6.GridColumn          = 2;

            var label7 = new Label();

            label7.Text       = "canteen";
            label7.GridColumn = 1;
            label7.GridRow    = 1;

            var label8 = new Label();

            label8.Text       = "15";
            label8.GridColumn = 2;
            label8.GridRow    = 1;

            var label9 = new Label();

            label9.Text       = "barrel";
            label9.GridColumn = 1;
            label9.GridRow    = 2;

            var label10 = new Label();

            label10.Text       = "25";
            label10.GridColumn = 2;
            label10.GridRow    = 2;

            var label11 = new Label();

            label11.Text       = "short sword";
            label11.GridColumn = 1;
            label11.GridRow    = 3;

            var label12 = new Label();

            label12.Text       = "50";
            label12.GridColumn = 2;
            label12.GridRow    = 3;

            var label13 = new Label();

            label13.Text       = "leather armor";
            label13.GridColumn = 1;
            label13.GridRow    = 4;

            var label14 = new Label();

            label14.Text       = "40";
            label14.GridColumn = 2;
            label14.GridRow    = 4;

            var label15 = new Label();

            label15.Text       = "leather leggings";
            label15.GridColumn = 1;
            label15.GridRow    = 5;

            var label16 = new Label();

            label16.Text       = "30";
            label16.GridColumn = 2;
            label16.GridRow    = 5;

            var label17 = new Label();

            label17.Text       = "small shield";
            label17.GridColumn = 1;
            label17.GridRow    = 6;

            var label18 = new Label();

            label18.Text       = "25";
            label18.GridColumn = 2;
            label18.GridRow    = 6;

            _gridRight = new Grid();
            _gridRight.ColumnSpacing        = 8;
            _gridRight.RowSpacing           = 4;
            _gridRight.DefaultRowProportion = new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            };
            _gridRight.ColumnsProportions.Add(new Proportion
            {
                Type  = Myra.Graphics2D.UI.ProportionType.Pixels,
                Value = 16,
            });
            _gridRight.ColumnsProportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Fill,
            });
            _gridRight.ColumnsProportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            _gridRight.GridSelectionMode = Myra.Graphics2D.UI.GridSelectionMode.Row;
            _gridRight.Id = "_gridRight";
            _gridRight.Widgets.Add(label5);
            _gridRight.Widgets.Add(label6);
            _gridRight.Widgets.Add(label7);
            _gridRight.Widgets.Add(label8);
            _gridRight.Widgets.Add(label9);
            _gridRight.Widgets.Add(label10);
            _gridRight.Widgets.Add(label11);
            _gridRight.Widgets.Add(label12);
            _gridRight.Widgets.Add(label13);
            _gridRight.Widgets.Add(label14);
            _gridRight.Widgets.Add(label15);
            _gridRight.Widgets.Add(label16);
            _gridRight.Widgets.Add(label17);
            _gridRight.Widgets.Add(label18);

            var scrollViewer2 = new ScrollViewer();

            scrollViewer2.Content = _gridRight;

            var verticalStackPanel2 = new VerticalStackPanel();

            verticalStackPanel2.Widgets.Add(panel2);
            verticalStackPanel2.Widgets.Add(horizontalSeparator2);
            verticalStackPanel2.Widgets.Add(scrollViewer2);

            var horizontalStackPanel1 = new HorizontalStackPanel();

            horizontalStackPanel1.Spacing = 8;
            horizontalStackPanel1.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Part,
            });
            horizontalStackPanel1.Proportions.Add(new Proportion
            {
                Type  = Myra.Graphics2D.UI.ProportionType.Pixels,
                Value = 100,
            });
            horizontalStackPanel1.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Part,
            });
            horizontalStackPanel1.Widgets.Add(verticalStackPanel1);
            horizontalStackPanel1.Widgets.Add(_gridGoldTransfer);
            horizontalStackPanel1.Widgets.Add(verticalStackPanel2);

            var horizontalSeparator3 = new HorizontalSeparator();

            _textDescription      = new Label();
            _textDescription.Text = "short sword - weapon, damage: 3-8";
            _textDescription.Id   = "_textDescription";

            var verticalStackPanel3 = new VerticalStackPanel();

            verticalStackPanel3.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Fill,
            });
            verticalStackPanel3.Width   = 800;
            verticalStackPanel3.Height  = 400;
            verticalStackPanel3.Padding = new Thickness(0, 16);
            verticalStackPanel3.Widgets.Add(horizontalStackPanel1);
            verticalStackPanel3.Widgets.Add(horizontalSeparator3);
            verticalStackPanel3.Widgets.Add(_textDescription);


            Title         = "Trade";
            DragDirection = DragDirection.None;
            Left          = 190;
            Content       = verticalStackPanel3;
        }
Exemplo n.º 13
0
        public void BuildUITopBar()
        {
            if (Desktop.ContextMenu != null)
            {
                // Dont show if it's already shown
                return;
            }

            var container = new HorizontalStackPanel
            {
                Spacing = 4
            };


            var menuItem1 = new MenuItem();

            menuItem1.Text      = "Resize grid";
            menuItem1.Selected += (s, a) =>
            {
                // "Start New Game" selected

                mapMenuComponent.Show();
            };

            var menuItem2 = new MenuItem();

            menuItem2.Text      = "Menu";
            menuItem2.Selected += (s, a) =>
            {
                // "Start New Game" selected
                game.editorMenuState = EditorMenuState.MainMenu;
                game.isMenuEnabled   = true;
            };

            var menuItem3 = new MenuItem();

            menuItem3.Text      = "Texture";
            menuItem3.Selected += (s, a) =>
            {
                // "Start New Game" selected
                game.editorMenuState      = EditorMenuState.TextureMenu;
                game.isTextureMenuEnabled = true;
            };



            var menuItem4 = new MenuItem();

            menuItem4.Text      = "Resize Window";
            menuItem4.Selected += (s, a) =>
            {
                // "Start New Game" selected
                // mapMenuComponent.ShowWindowResizingMenu();
                mapMenuComponent.Show();
            };


            var _menuFile = new MenuItem();

            _menuFile.Id   = "_menuFile";
            _menuFile.Text = "&File";
            _menuFile.Items.Add(menuItem1);
            _menuFile.Items.Add(menuItem2);
            _menuFile.Items.Add(menuItem3);
            _menuFile.Items.Add(menuItem4);


            var layer1 = new MenuItem();

            layer1.Id        = "0_layer";
            layer1.Text      = "0";
            layer1.Selected += (s, a) =>
            {
                // "Start New Game" selected
                this.game.currentLayerDepthLevel = 0.0f;
            };

            var layer2 = new MenuItem();

            layer2.Id        = "1_layer";
            layer2.Text      = "1 Layer";
            layer2.Selected += (s, a) =>
            {
                // "Start New Game" selected
                this.game.currentLayerDepthLevel = 0.1f;
            };
            var layer3 = new MenuItem();

            layer3.Id        = "2_layer";
            layer3.Text      = "2 Layer";
            layer3.Selected += (s, a) =>
            {
                // "Start New Game" selected
                this.game.currentLayerDepthLevel = 0.2f;
            };
            var layer4 = new MenuItem();

            layer4.Id        = "3_layer";
            layer4.Text      = "3 Layer";
            layer4.Selected += (s, a) =>
            {
                // "Start New Game" selected
                this.game.currentLayerDepthLevel = 0.3f;
            };



            var _menuFileLayer = new MenuItem();

            _menuFileLayer.Id   = "_LayerDepth";
            _menuFileLayer.Text = "&Layer Depth";
            _menuFileLayer.Items.Add(layer1);
            _menuFileLayer.Items.Add(layer2);
            _menuFileLayer.Items.Add(layer3);
            _menuFileLayer.Items.Add(layer4);



            var _menuEdit = new MenuItem();

            _menuEdit.Id   = "_menuEdit";
            _menuEdit.Text = "&Edit";



            var _menuMapType = new MenuItem();

            _menuMapType.Id   = "_menuMapType";
            _menuMapType.Text = "&Map Type";

            var _menuHelp = new MenuItem();

            _menuHelp.Id   = "_menuHelp";
            _menuHelp.Text = "&Help";
            //_menuHelp.Items.Add(_menuItemAbout);

            var menuMapIsometric = new MenuItem();

            menuMapIsometric.Text      = "Isometric";
            menuMapIsometric.Selected += (s, a) =>
            {
                // "Start New Game" selected
                // mapMenuComponent.ShowWindowResizingMenu();
                gridMapManager.gridMapType = GridMapManager.GridMapType.Isometric;
                topBarMenuMapTypeEventHandler("Isometric");
            };

            var menuMapDefault = new MenuItem();

            menuMapDefault.Text      = "Default/Platformer";
            menuMapDefault.Selected += (s, a) =>
            {
                // "Start New Game" selected
                // mapMenuComponent.ShowWindowResizingMenu();
                gridMapManager.gridMapType = GridMapManager.GridMapType.Default;

                topBarMenuMapTypeEventHandler("Default");
            };

            _menuMapType.Items.Add(menuMapIsometric);
            _menuMapType.Items.Add(menuMapDefault);
            //_menuHelp.Items.Add(_menu

            var zoom160 = new MenuItem();

            zoom160.Id        = "160";
            zoom160.Text      = "160";
            zoom160.Selected += (s, a) =>
            {
                // "Start New Game" selected
                camera.Zoom = 1.6f;
            };

            var zoom120 = new MenuItem();

            zoom120.Id        = "120";
            zoom120.Text      = "120";
            zoom120.Selected += (s, a) =>
            {
                // "Start New Game" selected
                camera.Zoom = 1.2f;
            };

            var zoom100 = new MenuItem();

            zoom100.Id        = "100";
            zoom100.Text      = "100";
            zoom100.Selected += (s, a) =>
            {
                // "Start New Game" selected
                camera.Zoom = 1.0f;
            };

            var zoom80 = new MenuItem();

            zoom80.Id        = "80";
            zoom80.Text      = "80";
            zoom80.Selected += (s, a) =>
            {
                // "Start New Game" selected
                camera.Zoom = 0.8f;
            };

            var zoom50 = new MenuItem();

            zoom50.Id        = "50";
            zoom50.Text      = "50";
            zoom50.Selected += (s, a) =>
            {
                // "Start New Game" selected
                camera.Zoom = 0.5f;
            };

            var zoom20 = new MenuItem();

            zoom20.Id        = "20";
            zoom20.Text      = "20";
            zoom20.Selected += (s, a) =>
            {
                // "Start New Game" selected
                camera.Zoom = 0.2f;
            };
            var _menuZoom = new MenuItem();

            _menuZoom.Id   = "_menuZoom";
            _menuZoom.Text = "&Zoom";
            _menuZoom.Items.Add(zoom20);
            _menuZoom.Items.Add(zoom50);
            _menuZoom.Items.Add(zoom80);
            _menuZoom.Items.Add(zoom120);
            _menuZoom.Items.Add(zoom100);
            _menuZoom.Items.Add(zoom160);

            var _mainMenu = new HorizontalMenu();

            _mainMenu.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch;
            _mainMenu.Id = "_mainMenu";
            _mainMenu.Items.Add(_menuFile);
            _mainMenu.Items.Add(_menuEdit);
            _mainMenu.Items.Add(_menuHelp);
            _mainMenu.Items.Add(_menuZoom);
            _mainMenu.Items.Add(_menuMapType);
            _mainMenu.Items.Add(_menuFileLayer);
            Desktop.Widgets.Add(_mainMenu);
            Desktop.ShowContextMenu(container, new Point(0, 0));
            // Desktop.Widgets.Add(horizontalStackPanel1);
        }
Exemplo n.º 14
0
        private void CreateDirectConnectWindow()
        {
            directConnect = new Window {
                Title = "Direct Connect"
            };

            Panel panel = new Panel {
                Background = new SolidBrush(new Color(0f, 0f, 0f, 0.5f))
            };

            VerticalStackPanel verticalStackPanel = new VerticalStackPanel {
                Spacing = 8
            };

            Grid serverSettings = new Grid {
                RowSpacing    = 8,
                ColumnSpacing = 8,
                ShowGridLines = true,
                Padding       = new Thickness(4)
            };

            serverSettings.ColumnsProportions.Add(new Proportion(ProportionType.Auto));
            serverSettings.ColumnsProportions.Add(new Proportion(ProportionType.Auto));

            serverSettings.RowsProportions.Add(new Proportion(ProportionType.Auto));
            Label ipAddressLabel = new Label {
                Text       = "IP Address:",
                TextAlign  = TextAlign.Center,
                GridColumn = 0,
                GridRow    = 0
            };

            serverSettings.Widgets.Add(ipAddressLabel);
            TextBox ipAddressInput = new TextBox {
                Text       = "127.0.0.1",
                Width      = 192,
                GridColumn = 1,
                GridRow    = 0
            };

            ipAddressInput.TextChanged += (s, a) => {
                if (IPAddress.TryParse(ipAddressInput.Text, out IPAddress ip))
                {
                    ipAddressInput.TextColor = Color.White;
                }
                else
                {
                    ipAddressInput.TextColor = Color.Red;
                }
            };
            serverSettings.Widgets.Add(ipAddressInput);

            serverSettings.RowsProportions.Add(new Proportion(ProportionType.Auto));
            Label portLabel = new Label {
                Text       = "Port:",
                TextAlign  = TextAlign.Center,
                GridColumn = 0,
                GridRow    = 1
            };

            serverSettings.Widgets.Add(portLabel);
            TextBox portTextBox = new TextBox {
                Text       = "1337",
                GridColumn = 1,
                GridRow    = 1
            };

            portTextBox.TextChanged += (s, a) => {
                if (int.TryParse(portTextBox.Text, out int port) && port > 200 && port < 65536)
                {
                    portTextBox.TextColor = Color.White;
                }
                else
                {
                    portTextBox.TextColor = Color.Red;
                }
            };
            serverSettings.Widgets.Add(portTextBox);

            verticalStackPanel.Widgets.Add(serverSettings);

            HorizontalStackPanel horizontalStackPanel = new HorizontalStackPanel {
                Spacing = 8
            };
            TextButton buttonConnect = new TextButton {
                Text = "Connect",
                HorizontalAlignment = HorizontalAlignment.Right
            };

            buttonConnect.Click += (s, a) => {
                // connect to server here
                if (IPAddress.TryParse(ipAddressInput.Text, out IPAddress ip) && int.TryParse(portTextBox.Text, out int port) && port > 200 && port < 65536)
                {
                    IPEndPoint endPoint = new IPEndPoint(ip, port);
                    game.ScreenManager.SetScreen(new ClientLevelScreen(game, endPoint, nameTextBox.Text));
                }
            };
            horizontalStackPanel.Widgets.Add(buttonConnect);
            TextButton buttonCancel = new TextButton {
                Text = "Cancel",
                HorizontalAlignment = HorizontalAlignment.Right
            };

            buttonCancel.Click += (s, a) => {
                directConnect.Close();
            };
            horizontalStackPanel.Widgets.Add(buttonCancel);

            verticalStackPanel.Widgets.Add(horizontalStackPanel);

            panel.Widgets.Add(verticalStackPanel);

            directConnect.Content = panel;
        }
Exemplo n.º 15
0
        private void CreateServerBrowser()
        {
            // create a new window for the server browser
            serverBrowser = new Window {
                Title = "Server Browser"
            };

            // create a new panel with the whole width and height of the game window
            Panel panel = new Panel {
                Width      = game.Window.ClientBounds.Width,
                Height     = game.Window.ClientBounds.Height,
                Background = new SolidBrush(new Color(0f, 0f, 0f, 0.5f))
            };

            // new vertical stack panel
            VerticalStackPanel verticalStackPanel = new VerticalStackPanel {
                Spacing = 8
            };

            // new horizontal stack panel
            HorizontalStackPanel horizontalStackPanel = new HorizontalStackPanel {
                Spacing = 8
            };

            // create a button for creating a server
            TextButton buttonCreate = new TextButton {
                Text = "Create Server"
            };

            buttonCreate.Click += (s, a) => {
                serverCreation.ShowModal(desktop);
            };
            horizontalStackPanel.Widgets.Add(buttonCreate);

            // create a button for creating a server
            TextButton buttonDirectConnect = new TextButton {
                Text = "Direct Connect"
            };

            buttonDirectConnect.Click += (s, a) => {
                directConnect.ShowModal(desktop);
            };
            horizontalStackPanel.Widgets.Add(buttonDirectConnect);

            // create a button for refreshing the server list
            TextButton buttonRefresh = new TextButton {
                Text = "Refresh List"
            };

            buttonRefresh.Click += (s, a) => {
                // get server list from master server
                MasterServerConnector.Instance.RequestServerList();
            };
            horizontalStackPanel.Widgets.Add(buttonRefresh);

            verticalStackPanel.Widgets.Add(horizontalStackPanel);


            // create the server list
            serverList = new Grid {
                RowSpacing    = 8,
                ColumnSpacing = 8,
                ShowGridLines = true,
                Padding       = new Thickness(4)
            };

            // add row for column names
            serverList.RowsProportions.Add(new Proportion(ProportionType.Auto));
            string[] columnNames = { "Name", "Players", "Ping" };
            int[]    columnWidth = { (int)(game.Window.ClientBounds.Width * 0.77f), 0, 0 };
            for (int i = 0; i < columnNames.Length; i++)
            {
                serverList.ColumnsProportions.Add(new Proportion(columnWidth[i] != 0 ? ProportionType.Pixels : ProportionType.Auto, columnWidth[i]));
                Label field = new Label {
                    Text       = columnNames[i],
                    Background = new SolidBrush(Color.White),
                    TextColor  = Color.Black,
                    GridColumn = i,
                    GridRow    = 0
                };
                serverList.Widgets.Add(field);
            }

            var scrollView = new ScrollViewer();

            scrollView.Content = serverList;

            verticalStackPanel.Widgets.Add(scrollView);

            panel.Widgets.Add(verticalStackPanel);

            serverBrowser.Content = panel;
        }
Exemplo n.º 16
0
        private void BuildUI()
        {
            var menuItem1 = new MenuItem();

            menuItem1.Text = "Add &Orc";

            var menuItem2 = new MenuItem();

            menuItem2.Text = "Add &Peasant";

            var menuItem3 = new MenuItem();

            menuItem3.Text = "Add &Knight";

            var menuItem4 = new MenuItem();

            menuItem4.Text = "Add &Priest";

            var menuItem5 = new MenuItem();

            menuItem5.Text = "Add &Wizard";

            var menuItem6 = new MenuItem();

            menuItem6.Text = "&Units";
            menuItem6.Items.Add(menuItem1);
            menuItem6.Items.Add(menuItem2);
            menuItem6.Items.Add(menuItem3);
            menuItem6.Items.Add(menuItem4);
            menuItem6.Items.Add(menuItem5);

            var menuItem7 = new MenuItem();

            menuItem7.Text = "Add 10000 &Gold";

            var menuItem8 = new MenuItem();

            menuItem8.Text = "Add 10000 &Wood";

            var menuItem9 = new MenuItem();

            menuItem9.Text = "&Operations";
            menuItem9.Items.Add(menuItem7);
            menuItem9.Items.Add(menuItem8);

            var horizontalMenu1 = new HorizontalMenu();

            horizontalMenu1.Items.Add(menuItem6);
            horizontalMenu1.Items.Add(menuItem9);

            var label1 = new Label();

            label1.Text = "Command:";

            var textBox1 = new TextBox();

            var horizontalStackPanel1 = new HorizontalStackPanel();

            horizontalStackPanel1.Spacing = 8;
            horizontalStackPanel1.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            horizontalStackPanel1.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Fill,
            });
            horizontalStackPanel1.Widgets.Add(label1);
            horizontalStackPanel1.Widgets.Add(textBox1);

            _buttonHideDebug      = new TextButton();
            _buttonHideDebug.Text = "Hide Debug Panel";
            _buttonHideDebug.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            _buttonHideDebug.Id = "_buttonHideDebug";


            Spacing = 8;
            Height  = 300;
            Widgets.Add(horizontalMenu1);
            Widgets.Add(horizontalStackPanel1);
            Widgets.Add(_buttonHideDebug);
        }
Exemplo n.º 17
0
        private void BuildUI()
        {
            var horizontalSeparator1 = new HorizontalSeparator();

            var listItem1 = new ListItem();

            listItem1.Text = "Double Attack";

            var listItem2 = new ListItem();

            listItem2.Text  = "Parry";
            listItem2.Color = Color.Red;

            var listItem3 = new ListItem();

            listItem3.Text = "Spell \'Cure Light Wounds\'";

            var listItem4 = new ListItem();

            listItem4.Text = "Spell \'Cure Minor Wounds\'";

            var listItem5 = new ListItem();

            listItem5.Text = "Spell \'Cure Normal Wounds\'";

            var listItem6 = new ListItem();

            listItem6.Text = "Spell \'Cure Serious Wounds\'";

            _listAbilities       = new ListBox();
            _listAbilities.Width = 250;
            _listAbilities.Id    = "_listAbilities";
            _listAbilities.Items.Add(listItem1);
            _listAbilities.Items.Add(listItem2);
            _listAbilities.Items.Add(listItem3);
            _listAbilities.Items.Add(listItem4);
            _listAbilities.Items.Add(listItem5);
            _listAbilities.Items.Add(listItem6);

            var verticalSeparator1 = new VerticalSeparator();

            _labelEnergyCost      = new Label();
            _labelEnergyCost.Text = "0 Energy";
            _labelEnergyCost.Id   = "_labelEnergyCost";

            var horizontalSeparator2 = new HorizontalSeparator();

            _labelType      = new Label();
            _labelType.Text = "On/Off";
            _labelType.Id   = "_labelType";

            var horizontalSeparator3 = new HorizontalSeparator();

            _labelDescription      = new Label();
            _labelDescription.Text = "Replaces first attack with parry, which is blocks first attack of enemy with almo" +
                                     "st 100% guarantee.";
            _labelDescription.Wrap   = true;
            _labelDescription.Height = 200;
            _labelDescription.Id     = "_labelDescription";

            var verticalStackPanel1 = new VerticalStackPanel();

            verticalStackPanel1.Spacing = 4;
            verticalStackPanel1.Width   = 250;
            verticalStackPanel1.Widgets.Add(_labelEnergyCost);
            verticalStackPanel1.Widgets.Add(horizontalSeparator2);
            verticalStackPanel1.Widgets.Add(_labelType);
            verticalStackPanel1.Widgets.Add(horizontalSeparator3);
            verticalStackPanel1.Widgets.Add(_labelDescription);

            var horizontalStackPanel1 = new HorizontalStackPanel();

            horizontalStackPanel1.Widgets.Add(_listAbilities);
            horizontalStackPanel1.Widgets.Add(verticalSeparator1);
            horizontalStackPanel1.Widgets.Add(verticalStackPanel1);

            var horizontalSeparator4 = new HorizontalSeparator();

            _buttonUse       = new TextButton();
            _buttonUse.Text  = "Use";
            _buttonUse.Width = 100;
            _buttonUse.Id    = "_buttonUse";

            var horizontalStackPanel2 = new HorizontalStackPanel();

            horizontalStackPanel2.Widgets.Add(_buttonUse);

            var verticalStackPanel2 = new VerticalStackPanel();

            verticalStackPanel2.Widgets.Add(horizontalSeparator1);
            verticalStackPanel2.Widgets.Add(horizontalStackPanel1);
            verticalStackPanel2.Widgets.Add(horizontalSeparator4);
            verticalStackPanel2.Widgets.Add(horizontalStackPanel2);


            Title         = "Abilities";
            DragDirection = DragDirection.None;
            Left          = 422;
            Top           = 108;
            Width         = 500;
            Content       = verticalStackPanel2;
        }
Exemplo n.º 18
0
        private void BuildUI()
        {
            Showcase             = new CheckBox();
            Showcase.Text        = " Showcase";
            Showcase.TextColor   = Color.White;
            Showcase.ImageWidth  = 16;
            Showcase.ImageHeight = 16;
            Showcase.Id          = "Showcase";

            Zen             = new CheckBox();
            Zen.Text        = " Zen";
            Zen.TextColor   = Color.White;
            Zen.ImageWidth  = 16;
            Zen.ImageHeight = 16;
            Zen.Id          = "Zen";

            var horizontalSeparator1 = new HorizontalSeparator();

            horizontalSeparator1.Thickness = 2;
            horizontalSeparator1.Padding   = new Thickness(0, 5);

            ChangeGameSpeed             = new CheckBox();
            ChangeGameSpeed.ImageWidth  = 16;
            ChangeGameSpeed.ImageHeight = 16;
            ChangeGameSpeed.Id          = "ChangeGameSpeed";

            GameSpeed                   = new HorizontalSlider();
            GameSpeed.Minimum           = 0.5f;
            GameSpeed.Maximum           = 1.5f;
            GameSpeed.Value             = 1;
            GameSpeed.Height            = 16;
            GameSpeed.VerticalAlignment = Myra.Graphics2D.UI.VerticalAlignment.Center;
            GameSpeed.Id                = "GameSpeed";

            GameSpeedLabel           = new Label();
            GameSpeedLabel.Text      = "1.0x";
            GameSpeedLabel.TextColor = Color.White;
            GameSpeedLabel.Id        = "GameSpeedLabel";

            var horizontalStackPanel1 = new HorizontalStackPanel();

            horizontalStackPanel1.Spacing = 5;
            horizontalStackPanel1.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            horizontalStackPanel1.Proportions.Add(new Proportion
            {
                Type  = Myra.Graphics2D.UI.ProportionType.Pixels,
                Value = 80,
            });
            horizontalStackPanel1.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            horizontalStackPanel1.Widgets.Add(ChangeGameSpeed);
            horizontalStackPanel1.Widgets.Add(GameSpeed);
            horizontalStackPanel1.Widgets.Add(GameSpeedLabel);

            var horizontalSeparator2 = new HorizontalSeparator();

            horizontalSeparator2.Thickness = 2;
            horizontalSeparator2.Padding   = new Thickness(0, 5);

            Flashlight             = new CheckBox();
            Flashlight.Text        = " Flashlight";
            Flashlight.TextColor   = Color.White;
            Flashlight.ImageWidth  = 16;
            Flashlight.ImageHeight = 16;
            Flashlight.Id          = "Flashlight";

            Live             = new CheckBox();
            Live.Text        = " Live";
            Live.TextColor   = Color.White;
            Live.ImageWidth  = 16;
            Live.ImageHeight = 16;
            Live.Id          = "Live";

            Ok                     = new TextButton();
            Ok.Text                = "OK";
            Ok.TextColor           = Color.White;
            Ok.Margin              = new Thickness(0, 10, 0, 0);
            Ok.Padding             = new Thickness(5);
            Ok.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            Ok.Id                  = "Ok";

            MainPanel    = new VerticalStackPanel();
            MainPanel.Id = "MainPanel";
            MainPanel.Widgets.Add(Showcase);
            MainPanel.Widgets.Add(Zen);
            MainPanel.Widgets.Add(horizontalSeparator1);
            MainPanel.Widgets.Add(horizontalStackPanel1);
            MainPanel.Widgets.Add(horizontalSeparator2);
            MainPanel.Widgets.Add(Flashlight);
            MainPanel.Widgets.Add(Live);
            MainPanel.Widgets.Add(Ok);


            Title   = "Mods";
            Left    = 456;
            Top     = 80;
            Padding = new Thickness(10);
            Content = MainPanel;
        }
Exemplo n.º 19
0
        private void BuildUI()
        {
            _textPath          = new TextBox();
            _textPath.Readonly = true;
            _textPath.Width    = 300;
            _textPath.Id       = "_textPath";

            _buttonChange      = new TextButton();
            _buttonChange.Text = "Change...";
            _buttonChange.Id   = "_buttonChange";

            _labelIndex      = new Label();
            _labelIndex.Text = "Index: ";
            _labelIndex.Id   = "_labelIndex";

            var label1 = new Label();

            label1.Text = "Start";

            _numericAnimationStart         = new SpinButton();
            _numericAnimationStart.Minimum = 0;
            _numericAnimationStart.Integer = true;
            _numericAnimationStart.Width   = 32;
            _numericAnimationStart.Id      = "_numericAnimationStart";

            var label2 = new Label();

            label2.Text = "Step";

            _numericAnimationStep         = new SpinButton();
            _numericAnimationStep.Maximum = 8;
            _numericAnimationStep.Minimum = 0;
            _numericAnimationStep.Value   = 8;
            _numericAnimationStep.Integer = true;
            _numericAnimationStep.Width   = 32;
            _numericAnimationStep.Id      = "_numericAnimationStep";

            _textAnimationTotal      = new Label();
            _textAnimationTotal.Text = "Total: 64";
            _textAnimationTotal.Id   = "_textAnimationTotal";

            _boxAnimation                     = new HorizontalStackPanel();
            _boxAnimation.Spacing             = 8;
            _boxAnimation.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            _boxAnimation.Id                  = "_boxAnimation";
            _boxAnimation.Widgets.Add(label1);
            _boxAnimation.Widgets.Add(_numericAnimationStart);
            _boxAnimation.Widgets.Add(label2);
            _boxAnimation.Widgets.Add(_numericAnimationStep);
            _boxAnimation.Widgets.Add(_textAnimationTotal);

            _textScenarioLocation      = new Label();
            _textScenarioLocation.Text = "Location:";
            _textScenarioLocation.Id   = "_textScenarioLocation";

            var label3 = new Label();

            label3.Text = "Functions";

            var listItem1 = new ListItem();

            listItem1.Text = "0x3AA";

            var listItem2 = new ListItem();

            listItem2.Text = "0x77B";

            var listItem3 = new ListItem();

            listItem3.Text = "0x7B3";

            var listItem4 = new ListItem();

            listItem4.Text = "0x7C9";

            var listItem5 = new ListItem();

            listItem5.Text = "0x1DFD";

            _comboFunctions = new ComboBox();
            _comboFunctions.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch;
            _comboFunctions.Id = "_comboFunctions";
            _comboFunctions.Items.Add(listItem1);
            _comboFunctions.Items.Add(listItem2);
            _comboFunctions.Items.Add(listItem3);
            _comboFunctions.Items.Add(listItem4);
            _comboFunctions.Items.Add(listItem5);

            _boxScenarios                     = new HorizontalStackPanel();
            _boxScenarios.Spacing             = 8;
            _boxScenarios.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            _boxScenarios.Id                  = "_boxScenarios";
            _boxScenarios.Widgets.Add(_textScenarioLocation);
            _boxScenarios.Widgets.Add(label3);
            _boxScenarios.Widgets.Add(_comboFunctions);

            _buttonAbout      = new TextButton();
            _buttonAbout.Text = "About";
            _buttonAbout.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Right;
            _buttonAbout.Id = "_buttonAbout";

            _boxTop         = new HorizontalStackPanel();
            _boxTop.Spacing = 8;
            _boxTop.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            _boxTop.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            _boxTop.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            _boxTop.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            _boxTop.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            _boxTop.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Part,
            });
            _boxTop.Id = "_boxTop";
            _boxTop.Widgets.Add(_textPath);
            _boxTop.Widgets.Add(_buttonChange);
            _boxTop.Widgets.Add(_labelIndex);
            _boxTop.Widgets.Add(_boxAnimation);
            _boxTop.Widgets.Add(_boxScenarios);
            _boxTop.Widgets.Add(_buttonAbout);

            var listItem6 = new ListItem();

            listItem6.Text = "Textures";

            var listItem7 = new ListItem();

            listItem7.Text = "Models";

            var listItem8 = new ListItem();

            listItem8.Text = "Images";

            var listItem9 = new ListItem();

            listItem9.Text = "Animations";

            var listItem10 = new ListItem();

            listItem10.Text = "Scenes";

            _comboResourceType = new ComboBox();
            _comboResourceType.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch;
            _comboResourceType.Id = "_comboResourceType";
            _comboResourceType.Items.Add(listItem6);
            _comboResourceType.Items.Add(listItem7);
            _comboResourceType.Items.Add(listItem8);
            _comboResourceType.Items.Add(listItem9);
            _comboResourceType.Items.Add(listItem10);

            _textFilter    = new TextBox();
            _textFilter.Id = "_textFilter";

            var listItem11 = new ListItem();

            listItem11.Text = "TEXTURE1._DS";

            var listItem12 = new ListItem();

            listItem12.Text = "TEXTURE2._DS";

            _listFiles = new ListBox();
            _listFiles.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch;
            _listFiles.VerticalAlignment   = Myra.Graphics2D.UI.VerticalAlignment.Stretch;
            _listFiles.Id = "_listFiles";
            _listFiles.Items.Add(listItem11);
            _listFiles.Items.Add(listItem12);

            var verticalStackPanel1 = new VerticalStackPanel();

            verticalStackPanel1.Spacing = 8;
            verticalStackPanel1.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            verticalStackPanel1.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            verticalStackPanel1.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Fill,
            });
            verticalStackPanel1.Width = 150;
            verticalStackPanel1.Widgets.Add(_comboResourceType);
            verticalStackPanel1.Widgets.Add(_textFilter);
            verticalStackPanel1.Widgets.Add(_listFiles);

            _panelViewer    = new Panel();
            _panelViewer.Id = "_panelViewer";

            _textStatus      = new Label();
            _textStatus.Text = "Processing mesh 23/40...";
            _textStatus.VerticalAlignment = Myra.Graphics2D.UI.VerticalAlignment.Bottom;
            _textStatus.Id = "_textStatus";

            var panel1 = new Panel();

            panel1.Widgets.Add(_panelViewer);
            panel1.Widgets.Add(_textStatus);

            _buttonPlayPause      = new TextButton();
            _buttonPlayPause.Text = "Play/Pause";
            _buttonPlayPause.VerticalAlignment = Myra.Graphics2D.UI.VerticalAlignment.Center;
            _buttonPlayPause.Id = "_buttonPlayPause";

            _sliderPlayer    = new HorizontalSlider();
            _sliderPlayer.Id = "_sliderPlayer";

            _labelDuration      = new Label();
            _labelDuration.Text = "03:10/15:00";
            _labelDuration.Id   = "_labelDuration";

            _panelPlayer         = new HorizontalStackPanel();
            _panelPlayer.Spacing = 8;
            _panelPlayer.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            _panelPlayer.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Fill,
            });
            _panelPlayer.VerticalAlignment = Myra.Graphics2D.UI.VerticalAlignment.Bottom;
            _panelPlayer.Id = "_panelPlayer";
            _panelPlayer.Widgets.Add(_buttonPlayPause);
            _panelPlayer.Widgets.Add(_sliderPlayer);
            _panelPlayer.Widgets.Add(_labelDuration);

            var verticalStackPanel2 = new VerticalStackPanel();

            verticalStackPanel2.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Fill,
            });
            verticalStackPanel2.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            verticalStackPanel2.Widgets.Add(panel1);
            verticalStackPanel2.Widgets.Add(_panelPlayer);

            var horizontalStackPanel1 = new HorizontalStackPanel();

            horizontalStackPanel1.Spacing = 8;
            horizontalStackPanel1.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            horizontalStackPanel1.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Fill,
            });
            horizontalStackPanel1.Widgets.Add(verticalStackPanel1);
            horizontalStackPanel1.Widgets.Add(verticalStackPanel2);


            Spacing = 8;
            Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Fill,
            });
            Widgets.Add(_boxTop);
            Widgets.Add(horizontalStackPanel1);
        }
Exemplo n.º 20
0
        private void CreateServerCreation()
        {
            serverCreation = new Window {
                Title = "Create Server"
            };

            Panel panel = new Panel {
                Background = new SolidBrush(new Color(0f, 0f, 0f, 0.5f))
            };

            VerticalStackPanel verticalStackPanel = new VerticalStackPanel {
                Spacing = 8
            };

            Grid serverSettings = new Grid {
                RowSpacing    = 8,
                ColumnSpacing = 8,
                ShowGridLines = true,
                Padding       = new Thickness(4)
            };

            serverSettings.ColumnsProportions.Add(new Proportion(ProportionType.Auto));
            serverSettings.ColumnsProportions.Add(new Proportion(ProportionType.Auto));
            serverSettings.ColumnsProportions.Add(new Proportion(ProportionType.Auto));

            serverSettings.RowsProportions.Add(new Proportion(ProportionType.Auto));
            Label maxPlayersLabel = new Label {
                Text       = "Max Players:",
                TextAlign  = TextAlign.Center,
                GridColumn = 0,
                GridRow    = 0
            };

            serverSettings.Widgets.Add(maxPlayersLabel);
            TextBox maxPlayersInput = new TextBox {
                Text       = NetConstants.MAX_PLAYERS.ToString(),
                Width      = 50,
                GridColumn = 1,
                GridRow    = 0
            };

            maxPlayersInput.TextChangedByUser += (s, a) => {
                if (int.TryParse(maxPlayersInput.Text, out int players) && players >= 2 && players <= 8)
                {
                    maxPlayersInput.TextColor = Color.White;
                }
                else
                {
                    maxPlayersInput.TextColor = Color.Red;
                }
            };
            serverSettings.Widgets.Add(maxPlayersInput);
            Label maxPlayersHintLabel = new Label {
                Text       = "Must be in between 2 and 8.",
                TextAlign  = TextAlign.Center,
                GridColumn = 2,
                GridRow    = 0
            };

            serverSettings.Widgets.Add(maxPlayersHintLabel);

            serverSettings.RowsProportions.Add(new Proportion(ProportionType.Auto));
            Label portLabel = new Label {
                Text       = "Port:",
                TextAlign  = TextAlign.Center,
                GridColumn = 0,
                GridRow    = 1
            };

            serverSettings.Widgets.Add(portLabel);
            TextBox portTextBox = new TextBox {
                Text       = "1337",
                TextColor  = Color.White,
                GridColumn = 1,
                GridRow    = 1
            };

            portTextBox.TextChangedByUser += (s, a) => {
                if (int.TryParse(portTextBox.Text, out int port) && port > 200 && port < 65536)
                {
                    portTextBox.TextColor = Color.White;
                }
                else
                {
                    portTextBox.TextColor = Color.Red;
                }
            };
            serverSettings.Widgets.Add(portTextBox);
            Label portHintLabel = new Label {
                Text       = "Must be in between 201 and 65535.",
                TextAlign  = TextAlign.Center,
                GridColumn = 2,
                GridRow    = 1
            };

            serverSettings.Widgets.Add(portHintLabel);

            verticalStackPanel.Widgets.Add(serverSettings);

            HorizontalStackPanel horizontalStackPanel = new HorizontalStackPanel {
                Spacing = 8
            };
            TextButton buttonCreate = new TextButton {
                Text = "Create Server",
                HorizontalAlignment = HorizontalAlignment.Right
            };

            buttonCreate.Click += (s, a) => {
                // start server here
                if (portTextBox.TextColor == Color.White && maxPlayersInput.TextColor == Color.White)
                {
                    int port = int.Parse(portTextBox.Text);

                    game.ScreenManager.SetScreen(new ServerLevelScreen(game, nameTextBox.Text, port));

                    MasterServerConnector.Instance.StartListingServer(port, nameTextBox.Text, int.Parse(maxPlayersInput.Text));
                }
                else
                {
                    Window window = new Window {
                        Title = "Something isn't correct in the settings!"
                    };

                    window.ShowModal(desktop);
                }
            };
            horizontalStackPanel.Widgets.Add(buttonCreate);
            TextButton buttonCancel = new TextButton {
                Text = "Cancel",
                HorizontalAlignment = HorizontalAlignment.Right
            };

            buttonCancel.Click += (s, a) => {
                serverCreation.Close();
            };
            horizontalStackPanel.Widgets.Add(buttonCancel);

            verticalStackPanel.Widgets.Add(horizontalStackPanel);

            panel.Widgets.Add(verticalStackPanel);

            serverCreation.Content = panel;
        }
Exemplo n.º 21
0
        private void BuildUI()
        {
            var label1 = new Label();

            label1.Text = "Equipment";

            var horizontalSeparator1 = new HorizontalSeparator();

            var label2 = new Label();

            label2.Text = "<light>";

            var label3 = new Label();

            label3.Text       = "eye of the deep";
            label3.GridColumn = 1;

            var label4 = new Label();

            label4.Text    = "<left finger>";
            label4.GridRow = 1;

            var label5 = new Label();

            label5.Text       = "a carved wooden ring";
            label5.GridColumn = 1;
            label5.GridRow    = 1;

            var label6 = new Label();

            label6.Text    = "<right finger>";
            label6.GridRow = 2;

            var label7 = new Label();

            label7.Text       = "a carved wooden ring";
            label7.GridColumn = 1;
            label7.GridRow    = 2;

            var label8 = new Label();

            label8.Text    = "<neck 1>";
            label8.GridRow = 3;

            var label9 = new Label();

            label9.Text       = "the amulet of the sanguineous magi";
            label9.GridColumn = 1;
            label9.GridRow    = 3;

            var label10 = new Label();

            label10.Text    = "<neck 2>";
            label10.GridRow = 4;

            var label11 = new Label();

            label11.Text       = "the amulet of the sanguineous magi";
            label11.GridColumn = 1;
            label11.GridRow    = 4;

            var label12 = new Label();

            label12.Text    = "<body>";
            label12.GridRow = 5;

            var label13 = new Label();

            label13.Text       = "a gilded corset of crimson and gold";
            label13.GridColumn = 1;
            label13.GridRow    = 5;

            var label14 = new Label();

            label14.Text    = "<head>";
            label14.GridRow = 6;

            var label15 = new Label();

            label15.Text       = "The Crown of Thorns";
            label15.GridColumn = 1;
            label15.GridRow    = 6;

            var label16 = new Label();

            label16.Text    = "<legs>";
            label16.GridRow = 7;

            var label17 = new Label();

            label17.Text       = "Ogre Hide Leggings";
            label17.GridColumn = 1;
            label17.GridRow    = 7;

            var label18 = new Label();

            label18.Text    = "<feet>";
            label18.GridRow = 8;

            var label19 = new Label();

            label19.Text       = "a pair of dolphin skin boots";
            label19.GridColumn = 1;
            label19.GridRow    = 8;

            var label20 = new Label();

            label20.Text    = "<hands>";
            label20.GridRow = 9;

            var label21 = new Label();

            label21.Text       = "gloves of the yellow rose";
            label21.GridColumn = 1;
            label21.GridRow    = 9;

            var label22 = new Label();

            label22.Text    = "<arms>";
            label22.GridRow = 10;

            var label23 = new Label();

            label23.Text       = "a set of tidal sleeves";
            label23.GridColumn = 1;
            label23.GridRow    = 10;

            var label24 = new Label();

            label24.Text    = "<shield>";
            label24.GridRow = 11;

            var label25 = new Label();

            label25.Text       = "an intricately decorated shield";
            label25.GridColumn = 1;
            label25.GridRow    = 11;

            var label26 = new Label();

            label26.Text    = "<about body>";
            label26.GridRow = 12;

            var label27 = new Label();

            label27.Text       = "a dragonwing tunic";
            label27.GridColumn = 1;
            label27.GridRow    = 12;

            var label28 = new Label();

            label28.Text    = "<waist>";
            label28.GridRow = 13;

            var label29 = new Label();

            label29.Text       = "a golden belt";
            label29.GridColumn = 1;
            label29.GridRow    = 13;

            var label30 = new Label();

            label30.Text    = "<left wrist>";
            label30.GridRow = 14;

            var label31 = new Label();

            label31.Text       = "tanzanite bracelet";
            label31.GridColumn = 1;
            label31.GridRow    = 14;

            var label32 = new Label();

            label32.Text    = "<right wrist>";
            label32.GridRow = 15;

            var label33 = new Label();

            label33.Text       = "tanzanite bracelet";
            label33.GridColumn = 1;
            label33.GridRow    = 15;

            var label34 = new Label();

            label34.Text    = "<wielded>";
            label34.GridRow = 16;

            var label35 = new Label();

            label35.Text       = "a secari dagger";
            label35.GridColumn = 1;
            label35.GridRow    = 16;

            var label36 = new Label();

            label36.Text    = "<held>";
            label36.GridRow = 17;

            var label37 = new Label();

            label37.Text       = "a moss-covered pebble";
            label37.GridColumn = 1;
            label37.GridRow    = 17;

            _gridEquipment = new Grid();
            _gridEquipment.ColumnSpacing           = 8;
            _gridEquipment.RowSpacing              = 4;
            _gridEquipment.DefaultColumnProportion = new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            };
            _gridEquipment.DefaultRowProportion = new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            };
            _gridEquipment.GridSelectionMode = Myra.Graphics2D.UI.GridSelectionMode.Row;
            _gridEquipment.GridRow           = 1;
            _gridEquipment.Id = "_gridEquipment";
            _gridEquipment.Widgets.Add(label2);
            _gridEquipment.Widgets.Add(label3);
            _gridEquipment.Widgets.Add(label4);
            _gridEquipment.Widgets.Add(label5);
            _gridEquipment.Widgets.Add(label6);
            _gridEquipment.Widgets.Add(label7);
            _gridEquipment.Widgets.Add(label8);
            _gridEquipment.Widgets.Add(label9);
            _gridEquipment.Widgets.Add(label10);
            _gridEquipment.Widgets.Add(label11);
            _gridEquipment.Widgets.Add(label12);
            _gridEquipment.Widgets.Add(label13);
            _gridEquipment.Widgets.Add(label14);
            _gridEquipment.Widgets.Add(label15);
            _gridEquipment.Widgets.Add(label16);
            _gridEquipment.Widgets.Add(label17);
            _gridEquipment.Widgets.Add(label18);
            _gridEquipment.Widgets.Add(label19);
            _gridEquipment.Widgets.Add(label20);
            _gridEquipment.Widgets.Add(label21);
            _gridEquipment.Widgets.Add(label22);
            _gridEquipment.Widgets.Add(label23);
            _gridEquipment.Widgets.Add(label24);
            _gridEquipment.Widgets.Add(label25);
            _gridEquipment.Widgets.Add(label26);
            _gridEquipment.Widgets.Add(label27);
            _gridEquipment.Widgets.Add(label28);
            _gridEquipment.Widgets.Add(label29);
            _gridEquipment.Widgets.Add(label30);
            _gridEquipment.Widgets.Add(label31);
            _gridEquipment.Widgets.Add(label32);
            _gridEquipment.Widgets.Add(label33);
            _gridEquipment.Widgets.Add(label34);
            _gridEquipment.Widgets.Add(label35);
            _gridEquipment.Widgets.Add(label36);
            _gridEquipment.Widgets.Add(label37);

            var scrollViewer1 = new ScrollViewer();

            scrollViewer1.Content = _gridEquipment;

            var verticalStackPanel1 = new VerticalStackPanel();

            verticalStackPanel1.Widgets.Add(label1);
            verticalStackPanel1.Widgets.Add(horizontalSeparator1);
            verticalStackPanel1.Widgets.Add(scrollViewer1);

            var verticalSeparator1 = new VerticalSeparator();

            var label38 = new Label();

            label38.Text = "Inventory";

            _textGold      = new Label();
            _textGold.Text = "Gold: 50000";
            _textGold.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Right;
            _textGold.Id = "_textGold";

            var panel1 = new Panel();

            panel1.Widgets.Add(label38);
            panel1.Widgets.Add(_textGold);

            var horizontalSeparator2 = new HorizontalSeparator();

            var label39 = new Label();

            label39.Text = "iron rations(100)";

            var label40 = new Label();

            label40.Text    = "canteen";
            label40.GridRow = 1;

            var label41 = new Label();

            label41.Text    = "barrel";
            label41.GridRow = 2;

            var label42 = new Label();

            label42.Text    = "short sword";
            label42.GridRow = 3;

            var label43 = new Label();

            label43.Text    = "leather armor";
            label43.GridRow = 4;

            var label44 = new Label();

            label44.Text    = "leather leggings";
            label44.GridRow = 5;

            var label45 = new Label();

            label45.Text    = "small shield";
            label45.GridRow = 6;

            _gridInventory = new Grid();
            _gridInventory.ColumnSpacing        = 8;
            _gridInventory.RowSpacing           = 4;
            _gridInventory.DefaultRowProportion = new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            };
            _gridInventory.ColumnsProportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Fill,
            });
            _gridInventory.GridSelectionMode = Myra.Graphics2D.UI.GridSelectionMode.Row;
            _gridInventory.Id = "_gridInventory";
            _gridInventory.Widgets.Add(label39);
            _gridInventory.Widgets.Add(label40);
            _gridInventory.Widgets.Add(label41);
            _gridInventory.Widgets.Add(label42);
            _gridInventory.Widgets.Add(label43);
            _gridInventory.Widgets.Add(label44);
            _gridInventory.Widgets.Add(label45);

            var scrollViewer2 = new ScrollViewer();

            scrollViewer2.Content = _gridInventory;

            var verticalStackPanel2 = new VerticalStackPanel();

            verticalStackPanel2.Widgets.Add(panel1);
            verticalStackPanel2.Widgets.Add(horizontalSeparator2);
            verticalStackPanel2.Widgets.Add(scrollViewer2);

            var horizontalStackPanel1 = new HorizontalStackPanel();

            horizontalStackPanel1.DefaultProportion = new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Part,
            };
            horizontalStackPanel1.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Part,
            });
            horizontalStackPanel1.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            horizontalStackPanel1.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Part,
            });
            horizontalStackPanel1.Widgets.Add(verticalStackPanel1);
            horizontalStackPanel1.Widgets.Add(verticalSeparator1);
            horizontalStackPanel1.Widgets.Add(verticalStackPanel2);

            var horizontalSeparator3 = new HorizontalSeparator();

            _buttonEquip       = new TextButton();
            _buttonEquip.Text  = "\\c[green]E\\c[white]quip";
            _buttonEquip.Width = 100;
            _buttonEquip.Id    = "_buttonEquip";

            _buttonUse       = new TextButton();
            _buttonUse.Text  = "\\c[green]U\\c[white]se";
            _buttonUse.Width = 100;
            _buttonUse.Id    = "_buttonUse";

            _buttonDrop       = new TextButton();
            _buttonDrop.Text  = "\\c[green]D\\c[white]rop";
            _buttonDrop.Width = 100;
            _buttonDrop.Id    = "_buttonDrop";

            var horizontalStackPanel2 = new HorizontalStackPanel();

            horizontalStackPanel2.Spacing             = 8;
            horizontalStackPanel2.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Right;
            horizontalStackPanel2.Widgets.Add(_buttonEquip);
            horizontalStackPanel2.Widgets.Add(_buttonUse);
            horizontalStackPanel2.Widgets.Add(_buttonDrop);

            var horizontalSeparator4 = new HorizontalSeparator();

            _textDescription      = new Label();
            _textDescription.Text = "short sword - weapon, damage: 3-8";
            _textDescription.Id   = "_textDescription";

            var horizontalSeparator5 = new HorizontalSeparator();

            _textAc      = new Label();
            _textAc.Text = "AC: 100";
            _textAc.Id   = "_textAc";

            _textHitRoll            = new Label();
            _textHitRoll.Text       = "Hit Roll: 20";
            _textHitRoll.GridColumn = 1;
            _textHitRoll.Id         = "_textHitRoll";

            _textAttacks            = new Label();
            _textAttacks.Text       = "Attacks: 4-8/6-10";
            _textAttacks.GridColumn = 2;
            _textAttacks.Id         = "_textAttacks";

            var grid1 = new Grid();

            grid1.ColumnSpacing = 8;
            grid1.RowSpacing    = 8;
            grid1.ColumnsProportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Part,
            });
            grid1.ColumnsProportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Part,
            });
            grid1.ColumnsProportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Part,
            });
            grid1.Widgets.Add(_textAc);
            grid1.Widgets.Add(_textHitRoll);
            grid1.Widgets.Add(_textAttacks);

            var verticalStackPanel3 = new VerticalStackPanel();

            verticalStackPanel3.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Fill,
            });
            verticalStackPanel3.Width   = 1000;
            verticalStackPanel3.Padding = new Thickness(0, 16);
            verticalStackPanel3.Widgets.Add(horizontalStackPanel1);
            verticalStackPanel3.Widgets.Add(horizontalSeparator3);
            verticalStackPanel3.Widgets.Add(horizontalStackPanel2);
            verticalStackPanel3.Widgets.Add(horizontalSeparator4);
            verticalStackPanel3.Widgets.Add(_textDescription);
            verticalStackPanel3.Widgets.Add(horizontalSeparator5);
            verticalStackPanel3.Widgets.Add(grid1);


            Title         = "Items";
            DragDirection = DragDirection.None;
            Left          = 172;
            Content       = verticalStackPanel3;
        }
Exemplo n.º 22
0
        private void BuildUI()
        {
            var label1 = new Label();

            label1.Text = "Iron Ration";

            var label2 = new Label();

            label2.Text       = "10";
            label2.GridColumn = 1;

            var label3 = new Label();

            label3.Text    = "Sword";
            label3.GridRow = 1;

            var label4 = new Label();

            label4.Text       = "1";
            label4.GridColumn = 1;
            label4.GridRow    = 1;

            var label5 = new Label();

            label5.Text    = "Rhodochosite";
            label5.GridRow = 2;

            var label6 = new Label();

            label6.Text       = "5";
            label6.GridColumn = 1;
            label6.GridRow    = 2;

            _gridItems = new Grid();
            _gridItems.ColumnSpacing        = 8;
            _gridItems.DefaultRowProportion = new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            };
            _gridItems.ColumnsProportions.Add(new Proportion
            {
                Type  = Myra.Graphics2D.UI.ProportionType.Fill,
                Value = 150,
            });
            _gridItems.ColumnsProportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            _gridItems.SelectionBackground      = new SolidBrush("#0379FFFF");
            _gridItems.SelectionHoverBackground = new SolidBrush("#666666FF");
            _gridItems.GridSelectionMode        = Myra.Graphics2D.UI.GridSelectionMode.Row;
            _gridItems.Id = "_gridItems";
            _gridItems.Widgets.Add(label1);
            _gridItems.Widgets.Add(label2);
            _gridItems.Widgets.Add(label3);
            _gridItems.Widgets.Add(label4);
            _gridItems.Widgets.Add(label5);
            _gridItems.Widgets.Add(label6);

            var horizontalSeparator1 = new HorizontalSeparator();

            _buttonTakeAll       = new TextButton();
            _buttonTakeAll.Text  = "\\c[green]T\\c[white]ake All";
            _buttonTakeAll.Width = 100;
            _buttonTakeAll.Id    = "_buttonTakeAll";

            var horizontalStackPanel1 = new HorizontalStackPanel();

            horizontalStackPanel1.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Right;
            horizontalStackPanel1.Widgets.Add(_buttonTakeAll);

            var verticalStackPanel1 = new VerticalStackPanel();

            verticalStackPanel1.Widgets.Add(_gridItems);
            verticalStackPanel1.Widgets.Add(horizontalSeparator1);
            verticalStackPanel1.Widgets.Add(horizontalStackPanel1);


            Title   = "Take";
            Left    = 522;
            Top     = 212;
            Width   = 300;
            Content = verticalStackPanel1;
        }
Exemplo n.º 23
0
        private void BuildUI()
        {
            var label1 = new Label();

            label1.Text = "Font Resolution Factor:";

            _spinButtonFontResolutionFactor       = new SpinButton();
            _spinButtonFontResolutionFactor.Value = 2;
            _spinButtonFontResolutionFactor.Width = 50;
            _spinButtonFontResolutionFactor.Id    = "_spinButtonFontResolutionFactor";

            var horizontalStackPanel1 = new HorizontalStackPanel();

            horizontalStackPanel1.Spacing = 8;
            horizontalStackPanel1.Widgets.Add(label1);
            horizontalStackPanel1.Widgets.Add(_spinButtonFontResolutionFactor);

            var verticalSeparator1 = new VerticalSeparator();

            var label2 = new Label();

            label2.Text = "Kernel Width:";

            _spinButtonKernelWidth         = new SpinButton();
            _spinButtonKernelWidth.Value   = 2;
            _spinButtonKernelWidth.Integer = true;
            _spinButtonKernelWidth.Width   = 50;
            _spinButtonKernelWidth.Id      = "_spinButtonKernelWidth";

            var horizontalStackPanel2 = new HorizontalStackPanel();

            horizontalStackPanel2.Spacing = 8;
            horizontalStackPanel2.Widgets.Add(label2);
            horizontalStackPanel2.Widgets.Add(_spinButtonKernelWidth);

            var verticalSeparator2 = new VerticalSeparator();

            var label3 = new Label();

            label3.Text = "Kernel Height:";

            _spinButtonKernelHeight         = new SpinButton();
            _spinButtonKernelHeight.Value   = 2;
            _spinButtonKernelHeight.Integer = true;
            _spinButtonKernelHeight.Width   = 50;
            _spinButtonKernelHeight.Id      = "_spinButtonKernelHeight";

            var horizontalStackPanel3 = new HorizontalStackPanel();

            horizontalStackPanel3.Spacing = 8;
            horizontalStackPanel3.Widgets.Add(label3);
            horizontalStackPanel3.Widgets.Add(_spinButtonKernelHeight);

            var verticalSeparator3 = new VerticalSeparator();

            var label4 = new Label();

            label4.Text = "Scale:";

            _spinButtonScale       = new SpinButton();
            _spinButtonScale.Value = 2;
            _spinButtonScale.Width = 50;
            _spinButtonScale.Id    = "_spinButtonScale";

            var horizontalStackPanel4 = new HorizontalStackPanel();

            horizontalStackPanel4.Spacing = 8;
            horizontalStackPanel4.Widgets.Add(label4);
            horizontalStackPanel4.Widgets.Add(_spinButtonScale);

            var verticalSeparator4 = new VerticalSeparator();

            _checkBoxDrawBackground      = new CheckBox();
            _checkBoxDrawBackground.Text = "Draw Background";
            _checkBoxDrawBackground.Id   = "_checkBoxDrawBackground";

            var horizontalStackPanel5 = new HorizontalStackPanel();

            horizontalStackPanel5.Widgets.Add(horizontalStackPanel1);
            horizontalStackPanel5.Widgets.Add(verticalSeparator1);
            horizontalStackPanel5.Widgets.Add(horizontalStackPanel2);
            horizontalStackPanel5.Widgets.Add(verticalSeparator2);
            horizontalStackPanel5.Widgets.Add(horizontalStackPanel3);
            horizontalStackPanel5.Widgets.Add(verticalSeparator3);
            horizontalStackPanel5.Widgets.Add(horizontalStackPanel4);
            horizontalStackPanel5.Widgets.Add(verticalSeparator4);
            horizontalStackPanel5.Widgets.Add(_checkBoxDrawBackground);

            var horizontalSeparator1 = new HorizontalSeparator();

            _panelTopContainer    = new Panel();
            _panelTopContainer.Id = "_panelTopContainer";

            var horizontalSeparator2 = new HorizontalSeparator();

            _panelBottomContainer    = new Panel();
            _panelBottomContainer.Id = "_panelBottomContainer";


            Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Part,
            });
            Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Part,
            });
            Widgets.Add(horizontalStackPanel5);
            Widgets.Add(horizontalSeparator1);
            Widgets.Add(_panelTopContainer);
            Widgets.Add(horizontalSeparator2);
            Widgets.Add(_panelBottomContainer);
        }
Exemplo n.º 24
0
        private void BuildUI(TileObject tile)
        {
            var label1 = new Label();

            label1.Text = "Name";

            propertyName          = new TextBox();
            propertyName.Text     = "PropertyName";
            propertyName.Left     = 10;
            propertyName.MinWidth = 100;
            propertyName.MaxWidth = 100;
            propertyName.Id       = "propertyName";

            var horizontalStackPanel1 = new HorizontalStackPanel();

            horizontalStackPanel1.Widgets.Add(label1);
            horizontalStackPanel1.Widgets.Add(propertyName);

            var label2 = new Label();

            label2.Text = "IsCollidable";

            isCollidable      = new CheckBox();
            isCollidable.Left = 10;

            isCollidable.Id = "isCollidable";

            isCollidable.IsPressed = tile.isCollidable;
            isCollidable.Click    += (s, a) => {
                tile.isCollidable = isCollidable.IsPressed;
            };

            var label3 = new Label();

            label3.Text = "isFloor";
            label3.Left = 30;

            isFloor           = new CheckBox();
            isFloor.Left      = 40;
            isFloor.Id        = "isFloor";
            isFloor.IsPressed = tile.isFloor;
            isFloor.Click    += (s, a) => {
                tile.isFloor = isFloor.IsPressed;
            };

            var label4 = new Label();

            label4.Text = "IsBrakeable";
            label4.Left = 60;

            isBrakable        = new CheckBox();
            isBrakable.Left   = 70;
            isBrakable.Id     = "isBrakable";
            isBrakable.Click += (s, a) => {
                //tile.i=isBrakable.IsPressed;
            };

            var label5 = new Label();

            label5.Text = "isMoving";
            label5.Left = 90;

            isMoving        = new CheckBox();
            isMoving.Left   = 100;
            isMoving.Id     = "isMoving";
            isMoving.Click += (s, a) => {
                tile.isMoving = isMoving.IsPressed;
            };
            var horizontalStackPanel2 = new HorizontalStackPanel();

            horizontalStackPanel2.Widgets.Add(label2);
            horizontalStackPanel2.Widgets.Add(isCollidable);
            horizontalStackPanel2.Widgets.Add(label3);
            horizontalStackPanel2.Widgets.Add(isFloor);
            horizontalStackPanel2.Widgets.Add(label4);
            horizontalStackPanel2.Widgets.Add(isBrakable);
            horizontalStackPanel2.Widgets.Add(label5);
            horizontalStackPanel2.Widgets.Add(isMoving);

            var label6 = new Label();

            label6.Text = "Add new Properties";

            var label7 = new Label();

            label7.Text = "Key";
            label7.Left = 20;

            properyKey          = new TextBox();
            properyKey.Text     = "Key propery";
            properyKey.Left     = 30;
            properyKey.MinWidth = 50;
            properyKey.MaxWidth = 100;
            properyKey.Id       = "properyKey";

            var label8 = new Label();

            label8.Text = "Value";
            label8.Left = 100;

            propertyValue          = new TextBox();
            propertyValue.Text     = "Value property";
            propertyValue.Left     = 110;
            propertyValue.MinWidth = 50;
            propertyValue.MaxWidth = 100;
            propertyValue.Id       = "propertyValue";

            addProperty        = new TextButton();
            addProperty.Text   = "Add";
            addProperty.Left   = 140;
            addProperty.Id     = "addProperty";
            addProperty.Click += (s, a) => {
                int x = 0;
                Int32.TryParse(propertyValue.Text, out x);
                tile.extraParameters.Add(properyKey.Text, x);
            };

            var horizontalStackPanel3 = new HorizontalStackPanel();

            horizontalStackPanel3.Widgets.Add(label6);
            horizontalStackPanel3.Widgets.Add(label7);
            horizontalStackPanel3.Widgets.Add(properyKey);
            horizontalStackPanel3.Widgets.Add(label8);
            horizontalStackPanel3.Widgets.Add(propertyValue);
            horizontalStackPanel3.Widgets.Add(addProperty);

            saveProperties      = new TextButton();
            saveProperties.Text = "Save";
            saveProperties.Id   = "saveProperties";

            var horizontalStackPanel4 = new HorizontalStackPanel();

            horizontalStackPanel4.Widgets.Add(saveProperties);

            var verticalStackPanel1 = new VerticalStackPanel();

            verticalStackPanel1.Widgets.Add(horizontalStackPanel1);
            verticalStackPanel1.Widgets.Add(horizontalStackPanel2);
            verticalStackPanel1.Widgets.Add(horizontalStackPanel3);
            verticalStackPanel1.Widgets.Add(horizontalStackPanel4);


            Title     = "Tile Properties";
            Left      = 123;
            Top       = 7;
            MinWidth  = 700;
            MaxWidth  = 700;
            MinHeight = 500;
            MaxHeight = 600;
            Content   = verticalStackPanel1;
        }
Exemplo n.º 25
0
        private void BuildUI()
        {
            GameLabel           = new Label("Header");
            GameLabel.Text      = "GAME";
            GameLabel.TextColor = Color.White;
            GameLabel.Id        = "GameLabel";

            DrawHitbox             = new CheckBox();
            DrawHitbox.Text        = " Draw player hitbox";
            DrawHitbox.TextColor   = Color.White;
            DrawHitbox.ImageWidth  = 16;
            DrawHitbox.ImageHeight = 16;
            DrawHitbox.Id          = "DrawHitbox";

            ScreenShake             = new CheckBox();
            ScreenShake.Text        = " Screen Shake on hit";
            ScreenShake.TextColor   = Color.White;
            ScreenShake.ImageWidth  = 16;
            ScreenShake.ImageHeight = 16;
            ScreenShake.Id          = "ScreenShake";

            GraphicsLabel           = new Label("Header");
            GraphicsLabel.Text      = "VIDEO";
            GraphicsLabel.TextColor = Color.White;
            GraphicsLabel.Margin    = new Thickness(0, 15, 0, 5);
            GraphicsLabel.Id        = "GraphicsLabel";

            var label1 = new Label();

            label1.Text      = "Resolution:";
            label1.TextColor = Color.White;

            Resolution            = new ComboBox();
            Resolution.GridColumn = 1;
            Resolution.Id         = "Resolution";

            var label2 = new Label();

            label2.Text      = "Window mode:";
            label2.TextColor = Color.White;
            label2.GridRow   = 1;

            WindowMode            = new ComboBox();
            WindowMode.GridColumn = 1;
            WindowMode.GridRow    = 1;
            WindowMode.Id         = "WindowMode";

            var label3 = new Label();

            label3.Text      = "Scale mode:";
            label3.TextColor = Color.White;
            label3.GridRow   = 2;

            ScaleMode            = new ComboBox();
            ScaleMode.GridColumn = 1;
            ScaleMode.GridRow    = 2;
            ScaleMode.Id         = "ScaleMode";

            var grid1 = new Grid();

            grid1.ColumnSpacing = 20;
            grid1.RowSpacing    = 5;
            grid1.Widgets.Add(label1);
            grid1.Widgets.Add(Resolution);
            grid1.Widgets.Add(label2);
            grid1.Widgets.Add(WindowMode);
            grid1.Widgets.Add(label3);
            grid1.Widgets.Add(ScaleMode);

            Vsync             = new CheckBox();
            Vsync.Text        = " VSync";
            Vsync.TextColor   = Color.White;
            Vsync.ImageWidth  = 16;
            Vsync.ImageHeight = 16;
            Vsync.Id          = "Vsync";

            ShowFps             = new CheckBox();
            ShowFps.Text        = " Show FPS";
            ShowFps.TextColor   = Color.White;
            ShowFps.ImageWidth  = 16;
            ShowFps.ImageHeight = 16;
            ShowFps.Id          = "ShowFps";

            DrawOuterRings             = new CheckBox();
            DrawOuterRings.Text        = " Outer rings";
            DrawOuterRings.TextColor   = Color.White;
            DrawOuterRings.ImageWidth  = 16;
            DrawOuterRings.ImageHeight = 16;
            DrawOuterRings.Id          = "DrawOuterRings";

            DrawGlow             = new CheckBox();
            DrawGlow.Text        = " Glow effect";
            DrawGlow.TextColor   = Color.White;
            DrawGlow.ImageWidth  = 16;
            DrawGlow.ImageHeight = 16;
            DrawGlow.Id          = "DrawGlow";

            DrawParticles             = new CheckBox();
            DrawParticles.Text        = " Particles";
            DrawParticles.TextColor   = Color.White;
            DrawParticles.ImageWidth  = 16;
            DrawParticles.ImageHeight = 16;
            DrawParticles.Id          = "DrawParticles";

            StretchyPlayer             = new CheckBox();
            StretchyPlayer.Text        = " Stretchy cursor";
            StretchyPlayer.TextColor   = Color.White;
            StretchyPlayer.ImageWidth  = 16;
            StretchyPlayer.ImageHeight = 16;
            StretchyPlayer.Id          = "StretchyPlayer";

            AudioLabel           = new Label("Header");
            AudioLabel.Text      = "AUDIO";
            AudioLabel.TextColor = Color.White;
            AudioLabel.Margin    = new Thickness(0, 15, 0, 5);
            AudioLabel.Id        = "AudioLabel";

            var label4 = new Label();

            label4.Text      = "Volume:";
            label4.TextColor = Color.White;

            MusicVolume            = new HorizontalSlider();
            MusicVolume.MinWidth   = 100;
            MusicVolume.GridColumn = 1;
            MusicVolume.Id         = "MusicVolume";

            MusicVolumeLabel            = new Label();
            MusicVolumeLabel.Text       = "100";
            MusicVolumeLabel.TextColor  = Color.White;
            MusicVolumeLabel.GridColumn = 2;
            MusicVolumeLabel.Id         = "MusicVolumeLabel";

            var grid2 = new Grid();

            grid2.ColumnSpacing = 5;
            grid2.RowSpacing    = 5;
            grid2.Widgets.Add(label4);
            grid2.Widgets.Add(MusicVolume);
            grid2.Widgets.Add(MusicVolumeLabel);

            var verticalStackPanel1 = new VerticalStackPanel();

            verticalStackPanel1.Spacing = 5;
            verticalStackPanel1.Widgets.Add(GameLabel);
            verticalStackPanel1.Widgets.Add(DrawHitbox);
            verticalStackPanel1.Widgets.Add(ScreenShake);
            verticalStackPanel1.Widgets.Add(GraphicsLabel);
            verticalStackPanel1.Widgets.Add(grid1);
            verticalStackPanel1.Widgets.Add(Vsync);
            verticalStackPanel1.Widgets.Add(ShowFps);
            verticalStackPanel1.Widgets.Add(DrawOuterRings);
            verticalStackPanel1.Widgets.Add(DrawGlow);
            verticalStackPanel1.Widgets.Add(DrawParticles);
            verticalStackPanel1.Widgets.Add(StretchyPlayer);
            verticalStackPanel1.Widgets.Add(AudioLabel);
            verticalStackPanel1.Widgets.Add(grid2);

            var scrollViewer1 = new ScrollViewer();

            scrollViewer1.ShowHorizontalScrollBar = false;
            scrollViewer1.VerticalAlignment       = Myra.Graphics2D.UI.VerticalAlignment.Top;
            scrollViewer1.Content = verticalStackPanel1;

            Back           = new TextButton();
            Back.Text      = "Back";
            Back.TextColor = Color.White;
            Back.MinWidth  = 60;
            Back.Padding   = new Thickness(5);
            Back.Id        = "Back";

            Save           = new TextButton();
            Save.Text      = "Save";
            Save.TextColor = Color.White;
            Save.MinWidth  = 60;
            Save.Padding   = new Thickness(5);
            Save.Id        = "Save";

            var horizontalStackPanel1 = new HorizontalStackPanel();

            horizontalStackPanel1.Spacing             = 5;
            horizontalStackPanel1.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            horizontalStackPanel1.MinHeight           = 10;
            horizontalStackPanel1.Margin = new Thickness(0, 10, 0, 0);
            horizontalStackPanel1.Widgets.Add(Back);
            horizontalStackPanel1.Widgets.Add(Save);

            var verticalStackPanel2 = new VerticalStackPanel();

            verticalStackPanel2.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Fill,
            });
            verticalStackPanel2.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            verticalStackPanel2.Widgets.Add(scrollViewer1);
            verticalStackPanel2.Widgets.Add(horizontalStackPanel1);


            Title       = "Settings";
            IsDraggable = false;
            Left        = 361;
            Padding     = new Thickness(10);
            Content     = verticalStackPanel2;
        }
Exemplo n.º 26
0
        private void BuildUI()
        {
            var label1 = new Label();

            label1.Text = "Game Screen";
            label1.Top  = 100;
            label1.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;

            var radioButton1 = new RadioButton();

            radioButton1.Text = "Radio 1";

            var radioButton2 = new RadioButton();

            radioButton2.Text = "Radio 2";

            var radioButton3 = new RadioButton();

            radioButton3.Text = "Radio 3";

            var radioButton4 = new RadioButton();

            radioButton4.Text = "Radio 4";

            var horizontalStackPanel1 = new HorizontalStackPanel();

            horizontalStackPanel1.Top = 50;
            horizontalStackPanel1.Widgets.Add(radioButton1);
            horizontalStackPanel1.Widgets.Add(radioButton2);
            horizontalStackPanel1.Widgets.Add(radioButton3);
            horizontalStackPanel1.Widgets.Add(radioButton4);

            var textButton1 = new TextButton();

            textButton1.Text = "Button 1";

            var textButton2 = new TextButton();

            textButton2.Text = "Button 2";

            var textButton3 = new TextButton();

            textButton3.Text = "Button 3";

            var textButton4 = new TextButton();

            textButton4.Text = "Button 4";

            var horizontalStackPanel2 = new HorizontalStackPanel();

            horizontalStackPanel2.Spacing = 8;
            horizontalStackPanel2.Top     = 300;
            horizontalStackPanel2.Widgets.Add(textButton1);
            horizontalStackPanel2.Widgets.Add(textButton2);
            horizontalStackPanel2.Widgets.Add(textButton3);
            horizontalStackPanel2.Widgets.Add(textButton4);

            _buttonDebugPanel      = new TextButton();
            _buttonDebugPanel.Text = "Show Debug Panel";
            _buttonDebugPanel.Id   = "_buttonDebugPanel";

            _buttonModalDebugPanel      = new TextButton();
            _buttonModalDebugPanel.Text = "Show Debug Panel Modal";
            _buttonModalDebugPanel.Id   = "_buttonModalDebugPanel";

            var horizontalStackPanel3 = new HorizontalStackPanel();

            horizontalStackPanel3.Spacing           = 8;
            horizontalStackPanel3.VerticalAlignment = Myra.Graphics2D.UI.VerticalAlignment.Bottom;
            horizontalStackPanel3.Widgets.Add(_buttonDebugPanel);
            horizontalStackPanel3.Widgets.Add(_buttonModalDebugPanel);


            Widgets.Add(label1);
            Widgets.Add(horizontalStackPanel1);
            Widgets.Add(horizontalStackPanel2);
            Widgets.Add(horizontalStackPanel3);
        }
Exemplo n.º 27
0
        private void BuildUI()
        {
            var horizontalSeparator1 = new HorizontalSeparator();

            var listItem1 = new ListItem();

            listItem1.Text = "Rat Skin (5)";

            var listItem2 = new ListItem();

            listItem2.Text = "Leather Armor (2)";

            var listItem3 = new ListItem();

            listItem3.Text = "Wolf Skin";

            _listBoxItems        = new ListBox();
            _listBoxItems.Width  = 200;
            _listBoxItems.Height = 200;
            _listBoxItems.Id     = "_listBoxItems";
            _listBoxItems.Items.Add(listItem1);
            _listBoxItems.Items.Add(listItem2);
            _listBoxItems.Items.Add(listItem3);

            var verticalSeparator1 = new VerticalSeparator();

            _labelResult      = new Label();
            _labelResult.Text = "Leather(2)";
            _labelResult.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            _labelResult.Id = "_labelResult";

            _panelArrow    = new Panel();
            _panelArrow.Id = "_panelArrow";

            var verticalStackPanel1 = new VerticalStackPanel();

            verticalStackPanel1.VerticalAlignment = Myra.Graphics2D.UI.VerticalAlignment.Center;
            verticalStackPanel1.Width             = 200;
            verticalStackPanel1.Widgets.Add(_labelResult);
            verticalStackPanel1.Widgets.Add(_panelArrow);

            var verticalSeparator2 = new VerticalSeparator();

            var listItem4 = new ListItem();

            listItem4.Text = "Leather(2)";

            _listBoxComponents         = new ListBox();
            _listBoxComponents.Enabled = false;
            _listBoxComponents.Width   = 200;
            _listBoxComponents.Height  = 200;
            _listBoxComponents.Id      = "_listBoxComponents";
            _listBoxComponents.Items.Add(listItem4);

            var horizontalStackPanel1 = new HorizontalStackPanel();

            horizontalStackPanel1.Widgets.Add(_listBoxItems);
            horizontalStackPanel1.Widgets.Add(verticalSeparator1);
            horizontalStackPanel1.Widgets.Add(verticalStackPanel1);
            horizontalStackPanel1.Widgets.Add(verticalSeparator2);
            horizontalStackPanel1.Widgets.Add(_listBoxComponents);

            var horizontalSeparator2 = new HorizontalSeparator();

            _buttonTan       = new TextButton();
            _buttonTan.Text  = "\\c[green]T\\c[white]an";
            _buttonTan.Width = 120;
            _buttonTan.Id    = "_buttonTan";

            var horizontalStackPanel2 = new HorizontalStackPanel();

            horizontalStackPanel2.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Right;
            horizontalStackPanel2.Widgets.Add(_buttonTan);

            var verticalStackPanel2 = new VerticalStackPanel();

            verticalStackPanel2.Widgets.Add(horizontalSeparator1);
            verticalStackPanel2.Widgets.Add(horizontalStackPanel1);
            verticalStackPanel2.Widgets.Add(horizontalSeparator2);
            verticalStackPanel2.Widgets.Add(horizontalStackPanel2);


            Title   = "Leather Tanning Bench";
            Left    = 369;
            Top     = 141;
            Content = verticalStackPanel2;
        }
        public MenuState(GameManager gameManager, GraphicsDevice graphicsDevice, ContentManager contentManager) : base(gameManager, graphicsDevice, contentManager)
        {
            this.gameManager    = gameManager;
            this.graphicsDevice = graphicsDevice;
            SpriteBatch         = new SpriteBatch(graphicsDevice);
            menuViewController  = new MenuViewController();
            GameManager.graphics.PreferredBackBufferWidth  = GameManager.window.ClientBounds.Width;
            GameManager.graphics.PreferredBackBufferHeight = GameManager.window.ClientBounds.Height;
            menuViewController.viewPortWidth  = GameManager.window.ClientBounds.Width;
            menuViewController.viewPortHeight = GameManager.window.ClientBounds.Height;
            GameManager.graphics.ApplyChanges(); // I'm not questioning why this works. I, Cato Sicarius, approve of this action, because I, Cato Sicarius, am the most well versed Captain when it comes to the Codex Astartes!


            _menu = new Desktop();

            var panel           = new Panel();
            var BackGroundImage = new TextureRegion(Assets.GetTexture("title_splash")); // , new Rectangle(0,0, 1600, 900)

            panel.Background = BackGroundImage;

            var Buttons = new HorizontalStackPanel {
                Spacing             = 60,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Bottom,
                Margin = new Thickness(0, 0, 0, 60)
            };

            var NewGameTexture   = new TextureRegion(Assets.GetButton("new_game"));
            var LoadGameTexture  = new TextureRegion(Assets.GetButton("load_game"));
            var AboutGameTexture = new TextureRegion(Assets.GetButton("about"));

            Stylesheet.Current.ButtonStyle.PressedBackground = new SolidBrush("#0000000"); // TODO: rethink this later
            //Stylesheet.Current.ButtonStyle.OverBackground = new SolidBrush("#0000000");

            var NewGameButton = new ImageButton
            {
                Background = NewGameTexture,
                OverImage  = NewGameTexture,
                Width      = 265,
                Height     = 48,
            };

            NewGameButton.TouchDown += (s, a) => {
                gameManager.ChangeState(new CampaignPickerState(gameManager, gameManager.GraphicsDevice, gameManager.Content));
            };

            Buttons.Widgets.Add(NewGameButton);

            var LoadGameButton = new ImageButton
            {
                Background = LoadGameTexture,
                OverImage  = LoadGameTexture,
                Width      = 265,
                Height     = 48
            };

            LoadGameButton.TouchDown += (s, a) => {
                gameManager.ChangeState(new GameState(gameManager, gameManager.GraphicsDevice, gameManager.Content, false));
            };


            Buttons.Widgets.Add(LoadGameButton);

            var AboutGameButton = new ImageButton
            {
                Background = AboutGameTexture,
                OverImage  = AboutGameTexture,
                Width      = 265,
                Height     = 48
            };

            AboutGameButton.TouchDown += (s, a) => {
                gameManager.ChangeState(new AboutState(gameManager, gameManager.GraphicsDevice, gameManager.Content));
            };


            Buttons.Widgets.Add(AboutGameButton);

            panel.AddChild(new Label
            {
                Text = "Chapter Master Restoration (sewer rat and SirNuke)",
                VerticalAlignment   = VerticalAlignment.Bottom,
                HorizontalAlignment = HorizontalAlignment.Left
            });

            panel.Widgets.Add(Buttons);
            _menu.Root = panel;
        }
Exemplo n.º 29
0
        public LevelBoxLevel(CachedLevelData level) : this()
        {
            var gridRow = 0;

            var heartAndTitle = new HorizontalStackPanel();

            heartAndTitle.GridRow = gridRow++;
            heartAndTitle.Proportions.Add(new Proportion(ProportionType.Fill));
            Widgets.Add(heartAndTitle);

            var title = new Label
            {
                AutoEllipsisMethod  = AutoEllipsisMethod.Character,
                Margin              = new Thickness(0, 0, 10, 0),
                HorizontalAlignment = HorizontalAlignment.Left,
                Font = Fonts.OrkneyWithFallback.GetFont(24),
                Text = level.Info.Title,
            };

            heartAndTitle.Widgets.Add(title);

            if (level.Info.HasHeart)
            {
                var heart = new Image();
                UIUtil.SetHeart(heart, 18);
                heart.Renderable = level.HeartGotten
                    ? LevelSelect.HeartIcon
                    : LevelSelect.HeartOutlineIcon;
                heartAndTitle.Widgets.Add(heart);
            }


            var artistAndScore = new HorizontalStackPanel();

            artistAndScore.Proportions.Add(new Proportion(ProportionType.Fill));
            artistAndScore.GridRow = gridRow++;
            Widgets.Add(artistAndScore);

            var artist = new Label
            {
                AutoEllipsisMethod = AutoEllipsisMethod.Character,
                Font = Fonts.OrkneyWithFallback.GetFont(20),
                Text = level.Info.Artist,
            };

            artistAndScore.Widgets.Add(artist);

            if (level.BestScore.HasValue)
            {
                var score = new Label
                {
                    Font = Fonts.OrkneyWithFallback.GetFont(20),
                    Text = $"{level.BestScore:0%}",
                };
                artistAndScore.Widgets.Add(score);
            }


            var diffAndSubtitle = new HorizontalStackPanel
            {
                GridRow = gridRow++,
                Spacing = 10
            };

            Widgets.Add(diffAndSubtitle);

            var diff = new Label
            {
                Text = UIUtil.GetDifficultyString(level.Info.Difficulty),
                Font = Fonts.DejaVuSans.GetFont(20),
                VerticalAlignment = VerticalAlignment.Center
            };

            diffAndSubtitle.Widgets.Add(diff);

            var subtitle = new Label
            {
                VerticalAlignment = VerticalAlignment.Center
            };

            diffAndSubtitle.Widgets.Add(subtitle);
        }
Exemplo n.º 30
0
        private void BuildUI()
        {
            _mapViewContainer    = new Panel();
            _mapViewContainer.Id = "_mapViewContainer";

            var horizontalSeparator1 = new HorizontalSeparator();

            _buttonUse       = new TextButton();
            _buttonUse.Text  = "\\c[green]E\\c[white]|Use";
            _buttonUse.Width = 100;
            _buttonUse.Id    = "_buttonUse";

            _buttonCharacter       = new TextButton();
            _buttonCharacter.Text  = "\\c[green]C\\c[white]haracter";
            _buttonCharacter.Width = 100;
            _buttonCharacter.Id    = "_buttonCharacter";

            _buttonInventory       = new TextButton();
            _buttonInventory.Text  = "\\c[green]I\\c[white]nventory";
            _buttonInventory.Width = 100;
            _buttonInventory.Id    = "_buttonInventory";

            _buttonAbilities       = new TextButton();
            _buttonAbilities.Text  = "\\c[green]A\\c[white]bilities";
            _buttonAbilities.Width = 100;
            _buttonAbilities.Id    = "_buttonAbilities";

            var horizontalStackPanel1 = new HorizontalStackPanel();

            horizontalStackPanel1.Spacing = 8;
            horizontalStackPanel1.Widgets.Add(_buttonUse);
            horizontalStackPanel1.Widgets.Add(_buttonCharacter);
            horizontalStackPanel1.Widgets.Add(_buttonInventory);
            horizontalStackPanel1.Widgets.Add(_buttonAbilities);

            var verticalStackPanel1 = new VerticalStackPanel();

            verticalStackPanel1.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Fill,
            });
            verticalStackPanel1.Widgets.Add(_mapViewContainer);
            verticalStackPanel1.Widgets.Add(horizontalSeparator1);
            verticalStackPanel1.Widgets.Add(horizontalStackPanel1);

            var verticalSeparator1 = new VerticalSeparator();

            _labelHp      = new Label();
            _labelHp.Text = "HP: 50/100";
            _labelHp.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            _labelHp.Id = "_labelHp";

            var verticalSeparator2 = new VerticalSeparator();

            _labelMana      = new Label();
            _labelMana.Text = "MA: 50/100";
            _labelMana.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            _labelMana.Id = "_labelMana";

            var verticalSeparator3 = new VerticalSeparator();

            _labelStamina      = new Label();
            _labelStamina.Text = "ST: 50/100";
            _labelStamina.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            _labelStamina.Id = "_labelStamina";

            var horizontalStackPanel2 = new HorizontalStackPanel();

            horizontalStackPanel2.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Part,
            });
            horizontalStackPanel2.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            horizontalStackPanel2.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Part,
            });
            horizontalStackPanel2.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            horizontalStackPanel2.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Part,
            });
            horizontalStackPanel2.Widgets.Add(_labelHp);
            horizontalStackPanel2.Widgets.Add(verticalSeparator2);
            horizontalStackPanel2.Widgets.Add(_labelMana);
            horizontalStackPanel2.Widgets.Add(verticalSeparator3);
            horizontalStackPanel2.Widgets.Add(_labelStamina);

            var horizontalSeparator2 = new HorizontalSeparator();

            _mapContainer        = new Panel();
            _mapContainer.Height = 247;
            _mapContainer.Id     = "_mapContainer";

            var horizontalSeparator3 = new HorizontalSeparator();

            _logContainer    = new Panel();
            _logContainer.Id = "_logContainer";

            var verticalStackPanel2 = new VerticalStackPanel();

            verticalStackPanel2.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            verticalStackPanel2.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            verticalStackPanel2.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            verticalStackPanel2.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            verticalStackPanel2.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Fill,
            });
            verticalStackPanel2.Widgets.Add(horizontalStackPanel2);
            verticalStackPanel2.Widgets.Add(horizontalSeparator2);
            verticalStackPanel2.Widgets.Add(_mapContainer);
            verticalStackPanel2.Widgets.Add(horizontalSeparator3);
            verticalStackPanel2.Widgets.Add(_logContainer);


            Proportions.Add(new Proportion
            {
                Type  = Myra.Graphics2D.UI.ProportionType.Part,
                Value = 2,
            });
            Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Part,
            });
            Widgets.Add(verticalStackPanel1);
            Widgets.Add(verticalSeparator1);
            Widgets.Add(verticalStackPanel2);
        }
Exemplo n.º 31
0
        public override void LoadContent()
        {
            this._font = this.GameManager.Game.Content.Load<SpriteFont>(@"Fonts\GameFont");

            this._engineIdle = this.GameManager.Game.Content.Load<SoundEffect>(@"Sounds\Engine").CreateInstance();
            this._carScreech = this.GameManager.Game.Content.Load<SoundEffect>(@"Sounds\pop").CreateInstance();
            this._carHorn = this.GameManager.Game.Content.Load<SoundEffect>(@"Sounds\Horn").CreateInstance();

            this.Logo = this.GameManager.Game.Content.Load<Texture2D>(@"Textures\racer");
            this._car = this.GameManager.Game.Content.Load<Texture2D>(@"Textures\car");
            this._raceFlags = this.GameManager.Game.Content.Load<Texture2D>(@"Textures\racerflags");

            _textureMap.Add(TilePiece.Grass, this.GameManager.Game.Content.Load<Texture2D>(@"Textures\grass"));
            _textureMap.Add(TilePiece.TopLeft, this.GameManager.Game.Content.Load<Texture2D>(@"Textures\tl"));
            _textureMap.Add(TilePiece.TopRight, this.GameManager.Game.Content.Load<Texture2D>(@"Textures\tr"));
            _textureMap.Add(TilePiece.BottomLeft, this.GameManager.Game.Content.Load<Texture2D>(@"Textures\bl"));
            _textureMap.Add(TilePiece.BottomRight, this.GameManager.Game.Content.Load<Texture2D>(@"Textures\br"));
            _textureMap.Add(TilePiece.Horizontal, this.GameManager.Game.Content.Load<Texture2D>(@"Textures\h"));
            _textureMap.Add(TilePiece.Vertical, this.GameManager.Game.Content.Load<Texture2D>(@"Textures\v"));
            _textureMap.Add(TilePiece.Start, this.GameManager.Game.Content.Load<Texture2D>(@"Textures\tl"));

            this.Assets.Add(_engineIdle);
            this.Assets.Add(_carScreech);
            this.Assets.Add(_carHorn);
            this.Assets.Add(Logo);
            this.Assets.Add(_car);
            this.Assets.Add(_raceFlags);

            foreach (IDisposable asset in _textureMap.Values)
            {
                this.Assets.Add(asset);
            }

            this._engineIdle.Volume = this._carScreech.Volume = this._carHorn.Volume = 0.5f;
            this._engineIdle.IsLooped = true;

            _mapPanel.Bounds = new Rectangle(0, 0, 800, 480);

            int mapCount = 0;
            HorizontalStackPanel panel = null;

            foreach (string mapName in MapNames)
            {
                string mapData = this.GameManager.Game.Content.Load<string>(@"RacerMaps\" + mapName).Trim();
                LoadedMaps.Add(mapName, mapData);

                if (null == panel)
                {
                    panel = new HorizontalStackPanel();
                    panel.VerticalAlignment = VerticalAlignment.Middle;
                    panel.FixedSize = false;
                    panel.Bounds = new Rectangle(0, 0, 800, 180);

                    _mapPanel.AddChild(panel);
                }

                VerticalStackPanel vertPanel = new VerticalStackPanel();
                vertPanel.Bounds = new Rectangle(0, 0, 200, 150);

                XnaRaceTrackTile tile = new XnaRaceTrackTile(_textureMap, mapName, mapData);
                tile.Tag = tile;
                tile.Bounds = new Rectangle(0, 0, 200, 120);
                tile.Click += new EventHandler(mapTile_Click);

                XnaButton button = new XnaButton(new Rectangle(0, 0, 250, 30));
                button.Tag = tile;
                button.Text = mapName;
                button.FontZoom = 0.5f;
                button.Click += new EventHandler(mapTile_Click);

                if (FingerGames.IsTrial && mapCount > 2)
                {
                    button.Color = new Color(110, 110, 110);
                }

                vertPanel.AddChild(tile);
                vertPanel.AddChild(button);

                panel.AddChild(vertPanel);

                mapCount++;

                if ((mapCount % 3) == 0)
                {
                    panel = null;
                }
            }
            _mapPanel.ForceLayout();

            float maxX = 0;
            for (int i = 0; i < 10; ++i)
            {
                maxX = Math.Max(maxX, _font.MeasureString(i.ToString()).X);
            }

            _decimalWidth = maxX * 1.05f / 2;

            this._timePanel.Bounds = new Rectangle(0, 10, 800, 470);
            this._timePanel.FixedSize = true;

            XnaImage flagsImage = new XnaImage(this._raceFlags, new Rectangle(0, 0, this._raceFlags.Width, this._raceFlags.Height));
            XnaLabel completedLabel = new XnaLabel(new Rectangle(0, 0, 800, 90));
            completedLabel.BackColor = new Color(0, 0, 0, 150);
            completedLabel.FontZoom = 1.5f;
            completedLabel.Text = "Race Completed!";

            this._timePanel.AddChild(flagsImage);
            this._timePanel.AddChild(completedLabel);
            this._timePanel.AddChild(_timeLabel);

            base.LoadContent();
        }