Inheritance: MonoGameUi.ContainerControl
Beispiel #1
0
        public TabScreen(BaseScreenComponent manager)
            : base(manager)
        {
            //Create Tab Pages
            TabPage tabPage = new TabPage(manager, "Tab 1");
            TabPage tabPage2 = new TabPage(manager, "Tab 2");
            TabPage tabPage3 = new TabPage(manager, "Tab 3");

            //Create Tab Control & Add Pages
            TabControl tab = new TabControl(manager);
            tab.Pages.Add(tabPage);
            tab.Pages.Add(tabPage2);
            tab.Pages.Add(tabPage3);
            tab.VerticalAlignment = VerticalAlignment.Stretch;
            tab.HorizontalAlignment = HorizontalAlignment.Stretch;

            //Add Text to Page 1
            tabPage.Controls.Add(new Label(manager) { Text = "Content on Page 1" });

            //Add "Create Tab" to page 2
            Button createPage = Button.TextButton(manager, "Create Tab");
            createPage.LeftMouseClick += (s, e) =>
            {
                TabPage page = new TabPage(manager, "NEW TAB");
                page.Controls.Add(new Label(manager) { Text = "This is a new tab page" });
                tab.Pages.Add(page);
            };
            tabPage2.Controls.Add(createPage);

            //Add "Remove this page" to page 3
            Button removePage3 = Button.TextButton(manager, "Remove this Page");
            removePage3.LeftMouseClick += (s, e) =>
            {
                tab.Pages.Remove(tabPage3);
            };
            tabPage3.Controls.Add(removePage3);

            Controls.Add(tab);
        }
Beispiel #2
0
        /// <summary>
        /// Wird aufgerufen wenn ein Element aus "Pages" entfernt wird, entfernt den Eintrag in der TabList
        /// </summary>
        private void OnRemove(TabPage item, int index)
        {
            tabListStack.Controls.RemoveAt(index);                      //Entferne den Tab
            if (Pages.Count > 0)                                        //Nur fortfahren wenn noch Pages vorhanden
            {
                if (index >= tabListStack.Controls.Count)                //Wenn die letzte Page entfernt wird...
                    SelectedTabIndex = tabListStack.Controls.Count - 1;     //Setze den TabIndex auf die "neue" letzte
                else SelectedTabIndex = index;                          //Andernfalls, setze den TabIndex  auf den aktuellen index

                SelectTab(SelectedTabIndex);                            //Selektiere den Tab
            }
            tabListStack.InvalidateDimensions();                        //Zeichne den TabListStack neu
        }
Beispiel #3
0
        /// <summary>
        /// Wird aufgerufen wenn ein neues Element zu "Pages" hinzugefügt wird, erstellt einen neuen Eintrag in der TabList
        /// </summary>
        private void OnInsert(TabPage item, int index)
        {
            Label title = new Label(ScreenManager);
            title.Text = item.Title;
            title.Padding = Border.All(10);
            title.Background = TabBrush;
            title.Margin = new Border(0, 0, TabSpacing, 0);
            title.LeftMouseClick += (s, e) => SelectTab(Pages.IndexOf(item));
            title.CanFocus = true;
            title.TabStop = true;
            title.KeyDown += (s, e) => {
                if (e.Key == Microsoft.Xna.Framework.Input.Keys.Enter && title.Focused == TreeState.Active)
                    SelectTab(Pages.IndexOf(item));
            };
            tabListStack.Controls.Add(title);

            SelectTab(SelectedTabIndex);
        }
Beispiel #4
0
        /// <summary>
        /// Selektieren eines Tabs mit Page
        /// </summary>
        public void SelectTab(TabPage page)
        {
            try
            {
                tabListStack.Controls.ElementAt(SelectedTabIndex).Background = TabBrush;
                SelectedTabIndex = Pages.IndexOf(page);
            }
            finally
            {
                tabListStack.Controls.ElementAt(SelectedTabIndex).Background = TabActiveBrush;
                tabPage.Content = Pages.ElementAt(SelectedTabIndex);

                if (TabIndexChanged != null)
                    TabIndexChanged.Invoke(this, page, SelectedTabIndex);
            }
        }
Beispiel #5
0
        public OptionsScreen(ScreenComponent manager)
            : base(manager)
        {
            assets = manager.Game.Assets;

            Padding = new Border(0, 0, 0, 0);

            Title = Languages.OctoClient.Options;

            Texture2D panelBackground = assets.LoadTexture(typeof(ScreenComponent), "panel");

            SetDefaultBackground();

            TabControl tabs = new TabControl(manager)
            {
                Padding = new Border(20, 20, 20, 20),
                Width = 700,
                TabPageBackground = NineTileBrush.FromSingleTexture(panelBackground, 30, 30),
                TabBrush = NineTileBrush.FromSingleTexture(assets.LoadTexture(typeof(ScreenComponent), "buttonLong_brown"), 15, 15),
                TabActiveBrush = NineTileBrush.FromSingleTexture(assets.LoadTexture(typeof(ScreenComponent), "buttonLong_beige"), 15, 15),
            };
            Controls.Add(tabs);

            #region OptionsPage

            TabPage optionsPage = new TabPage(manager, Languages.OctoClient.Options);
            tabs.Pages.Add(optionsPage);

            OptionsOptionControl optionsOptions = new OptionsOptionControl(manager, this)
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment = VerticalAlignment.Stretch,
            };
            optionsPage.Controls.Add(optionsOptions);

            #endregion

            #region BindingsPage

            TabPage bindingsPage = new TabPage(manager, Languages.OctoClient.KeyBindings);
            tabs.Pages.Add(bindingsPage);

            BindingsOptionControl bindingsOptions = new BindingsOptionControl(manager)
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment = VerticalAlignment.Stretch,
            };
            bindingsPage.Controls.Add(bindingsOptions);

            #endregion

            #region TexturePackPage

            TabPage resourcePackPage = new TabPage(manager, "Resource Packs");
            tabs.Pages.Add(resourcePackPage);

            ResourcePacksOptionControl resourcePacksOptions = new ResourcePacksOptionControl(manager)
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment = VerticalAlignment.Stretch,
            };
            resourcePackPage.Controls.Add(resourcePacksOptions);

            #endregion

            ////////////////////////////////////////////Restart Button////////////////////////////////////////////
            exitButton = Button.TextButton(manager, Languages.OctoClient.RestartGameToApplyChanges);
            exitButton.VerticalAlignment = VerticalAlignment.Top;
            exitButton.HorizontalAlignment = HorizontalAlignment.Right;
            exitButton.Enabled = false;
            exitButton.Visible = false;
            exitButton.LeftMouseClick += (s, e) => Program.Restart();
            exitButton.Margin = new Border(10, 10, 10, 10);
            Controls.Add(exitButton);
        }
Beispiel #6
0
        public OptionsScreen(ScreenComponent manager)
            : base(manager)
        {
            game = manager.Game;
            Padding = new Border(0, 0, 0, 0);

            Title = Languages.OctoClient.Options;

            Texture2D panelBackground = manager.Content.LoadTexture2DFromFile("./Assets/OctoAwesome.Client/panel.png", manager.GraphicsDevice);

            SetDefaultBackground();

            TabControl tabs = new TabControl(manager)
            {
                Padding = new Border(20, 20, 20, 20),
                Width = 700,
                TabPageBackground = NineTileBrush.FromSingleTexture(panelBackground, 30, 30),
                TabBrush = NineTileBrush.FromSingleTexture(manager.Content.LoadTexture2DFromFile("./Assets/OctoAwesome.Client/UI/buttonLong_brown.png", manager.GraphicsDevice), 15, 15),
                TabActiveBrush = NineTileBrush.FromSingleTexture(manager.Content.LoadTexture2DFromFile("./Assets/OctoAwesome.Client/UI/buttonLong_beige.png", manager.GraphicsDevice), 15, 15),
            };
            Controls.Add(tabs);

            #region OptionsPage

            TabPage optionsPage = new TabPage(manager, "Options");
            tabs.Pages.Add(optionsPage);

            ////////////////////////////////////////////Settings Stack////////////////////////////////////////////
            StackPanel settingsStack = new StackPanel(manager)
            {
                Orientation = Orientation.Vertical,
                VerticalAlignment = VerticalAlignment.Top,
                Padding = new Border(20, 20, 20, 20),
                Width = 650
            };
            optionsPage.Controls.Add(settingsStack);

            //////////////////////Viewrange//////////////////////
            string viewrange = SettingsManager.Get("Viewrange");

            rangeTitle = new Label(manager)
            {
                Text = Languages.OctoClient.Viewrange + ": " + viewrange
            };
            settingsStack.Controls.Add(rangeTitle);

            Slider viewrangeSlider = new Slider(manager)
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                Height = 20,
                Range = 9,
                Value = int.Parse(viewrange) - 1
            };
            viewrangeSlider.ValueChanged += (value) => SetViewrange(value + 1);
            settingsStack.Controls.Add(viewrangeSlider);

            //////////////////////Persistence//////////////////////
            StackPanel persistenceStack = new StackPanel(manager)
            {
                Orientation = Orientation.Horizontal,
                Margin = new Border(0, 20, 0, 0)
            };
            settingsStack.Controls.Add(persistenceStack);

            Label persistenceTitle = new Label(manager)
            {
                Text = Languages.OctoClient.DisablePersistence + ":"
            };
            persistenceStack.Controls.Add(persistenceTitle);

            Checkbox disablePersistence = new Checkbox(manager)
            {
                Checked = bool.Parse(SettingsManager.Get("DisablePersistence")),
                HookBrush = new TextureBrush(manager.Content.LoadTexture2DFromFile("./Assets/OctoAwesome.Client/UI/iconCheck_brown.png", manager.GraphicsDevice), TextureBrushMode.Stretch),
            };
            disablePersistence.CheckedChanged += (state) => SetPersistence(state);
            persistenceStack.Controls.Add(disablePersistence);

            //////////////////////Map Path//////////////////////
            StackPanel mapPathStack = new StackPanel(manager)
            {
                Orientation = Orientation.Vertical,
                Margin = new Border(0, 20, 0, 0),
                HorizontalAlignment = HorizontalAlignment.Stretch
            };
            settingsStack.Controls.Add(mapPathStack);

            mapPath = new Textbox(manager)
            {
                Text = SettingsManager.Get("ChunkRoot"),
                Enabled = false,
                HorizontalAlignment = HorizontalAlignment.Stretch,
                Background = new BorderBrush(Color.LightGray, LineType.Solid, Color.Gray)
            };
            mapPathStack.Controls.Add(mapPath);

            Button changePath = Button.TextButton(manager, Languages.OctoClient.ChangePath);
            changePath.HorizontalAlignment = HorizontalAlignment.Center;
            changePath.Height = 40;
            changePath.LeftMouseClick += (s, e) => ChangePath();
            mapPathStack.Controls.Add(changePath);

            //////////////////////Fullscreen//////////////////////
            StackPanel fullscreenStack = new StackPanel(manager)
            {
                Orientation = Orientation.Horizontal,
                Margin = new Border(0, 20, 0, 0)
            };
            settingsStack.Controls.Add(fullscreenStack);

            Label fullscreenTitle = new Label(manager)
            {
                Text = Languages.OctoClient.EnableFullscreenOnStartup + ":"
            };
            fullscreenStack.Controls.Add(fullscreenTitle);

            Checkbox enableFullscreen = new Checkbox(manager)
            {
                Checked = bool.Parse(SettingsManager.Get("EnableFullscreen")),
                HookBrush = new TextureBrush(manager.Content.LoadTexture2DFromFile("./Assets/OctoAwesome.Client/UI/iconCheck_brown.png", manager.GraphicsDevice), TextureBrushMode.Stretch),
            };
            enableFullscreen.CheckedChanged += (state) => SetFullscreen(state);
            fullscreenStack.Controls.Add(enableFullscreen);

            //////////////////////Auflösung//////////////////////
            StackPanel resolutionStack = new StackPanel(manager)
            {
                Orientation = Orientation.Horizontal,
                Margin = new Border(0, 20, 0, 0)
            };
            settingsStack.Controls.Add(resolutionStack);

            Label resolutionTitle = new Label(manager)
            {
                Text = Languages.OctoClient.Resolution + ":"
            };
            resolutionStack.Controls.Add(resolutionTitle);

            Textbox resolutionWidthTextbox = new Textbox(manager)
            {
                Text = SettingsManager.Get("Width"),
                Width = 50,
                Background = new BorderBrush(Color.LightGray, LineType.Solid, Color.Gray)
            };
            resolutionWidthTextbox.TextChanged += ResolutionWidthTextbox_TextChanged;
            resolutionStack.Controls.Add(resolutionWidthTextbox);

            Label xLabel = new Label(manager)
            {
                Text = "x"
            };
            resolutionStack.Controls.Add(xLabel);

            Textbox resolutionHeightTextbox = new Textbox(manager)
            {
                Text = SettingsManager.Get("Height"),
                Width = 50,
                Background = new BorderBrush(Color.LightGray, LineType.Solid, Color.Gray)
            };
            resolutionHeightTextbox.TextChanged += ResolutionHeightTextbox_TextChanged;
            resolutionStack.Controls.Add(resolutionHeightTextbox);

            Label pxLabel = new Label(manager)
            {
                Text = Languages.OctoClient.Pixels
            };
            resolutionStack.Controls.Add(pxLabel);

            #endregion

            #region BindingsPage

            TabPage bindingsPage = new TabPage(manager, "Bindings");
            tabs.Pages.Add(bindingsPage);

            ScrollContainer bindingsScroll = new ScrollContainer(manager);
            bindingsPage.Controls.Add(bindingsScroll);

            StackPanel bindingsStack = new StackPanel(manager)
            {
                Orientation = Orientation.Vertical,
                Padding = new Border(20, 20, 20, 20),
                Width = 650
            };
            bindingsScroll.Content = bindingsStack;

            //////////////////////////////KeyBindings////////////////////////////////////////////
            var bindings = game.KeyMapper.GetBindings();
            foreach (var binding in bindings)
            {
                StackPanel bindingStack = new StackPanel(manager)
                {
                    Orientation = Orientation.Horizontal,
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    Height = 35
                };

                Label lbl = new Label(manager)
                {
                    Text = binding.DisplayName,
                    Width = 480
                };

                Label bindingKeyLabel = new Label(manager)
                {
                    Text = binding.Keys.First().ToString(),
                    HorizontalAlignment = HorizontalAlignment.Right,
                    Width = 90,
                    Background = new BorderBrush(Color.LightGray, LineType.Solid, Color.Gray),
                    Tag = new object[] { binding.Id, binding.Keys.First() }
                };
                bindingKeyLabel.LeftMouseClick += BindingKeyLabel_LeftMouseClick;

                bindingStack.Controls.Add(lbl);
                bindingStack.Controls.Add(bindingKeyLabel);
                bindingsStack.Controls.Add(bindingStack);
            }

            #endregion

            ////////////////////////////////////////////Restart Button////////////////////////////////////////////
            exitButton = Button.TextButton(manager, Languages.OctoClient.RestartGameToApplyChanges);
            exitButton.VerticalAlignment = VerticalAlignment.Top;
            exitButton.HorizontalAlignment = HorizontalAlignment.Right;
            exitButton.Enabled = false;
            exitButton.Visible = false;
            exitButton.LeftMouseClick += (s, e) => Program.Restart();
            exitButton.Margin = new Border(10, 10, 10, 10);
            Controls.Add(exitButton);
        }