public UIMenuItemSlider(
            string text,
            UIMenuAction action = null,
            FieldBinding field  = null,
            float step          = 0.1f,
            Color c             = default(Color))
            : base(action)
        {
            if (c == new Color())
            {
                c = Colors.MenuOption;
            }
            UIDivider uiDivider = new UIDivider(true, 0.0f);
            UIText    uiText    = new UIText(text, c);

            uiText.align = UIAlign.Left;
            uiDivider.leftSection.Add((UIComponent)uiText, true);
            UIProgressBar uiProgressBar = new UIProgressBar(30f, 7f, field, step);

            uiProgressBar.align = UIAlign.Right;
            uiDivider.rightSection.Add((UIComponent)uiProgressBar, true);
            this.rightSection.Add((UIComponent)uiDivider, true);
            this._arrow         = new UIImage("contextArrowRight");
            this._arrow.align   = UIAlign.Right;
            this._arrow.visible = false;
            this.leftSection.Add((UIComponent)this._arrow, true);
            this._field = field;
            this._step  = step;
        }
Пример #2
0
        public UIMenu(
            string title,
            float xpos,
            float ypos,
            float wide              = -1f,
            float high              = -1f,
            string conString        = "",
            InputProfile conProfile = null,
            bool tiny = false)
            : base(xpos, ypos, wide, high)
        {
            this._controlProfile = conProfile;
            this._splitter       = new UIDivider(false, 0.0f, 4f);
            this._section        = this._splitter.rightSection;
            UIText uiText = new UIText(title, Color.White);

            if (tiny)
            {
                BitmapFont f = new BitmapFont("smallBiosFontUI", 7, 5);
                uiText.SetFont(f);
            }
            uiText.align |= UIAlign.Top;
            this._splitter.topSection.Add((UIComponent)uiText, true);
            this._controlString = conString;
            if (this._controlString != "" && this._controlString != null)
            {
                UIDivider uiDivider = new UIDivider(false, 0.0f, 4f);
                this._controlText = new UIText(this._controlString, Color.White, heightAdd: 4f, controlProfile: this._controlProfile);
                uiDivider.bottomSection.Add((UIComponent)this._controlText, true);
                this.Add((UIComponent)uiDivider, true);
                this._section = uiDivider.topSection;
            }
            base.Add((UIComponent)this._splitter, true);
        }
Пример #3
0
        public UpgradeStationUI()
        {
            UIPanel panelMain = new UIPanel
            {
                Width    = { Pixels = 1000 },
                Height   = { Pixels = 550 + 28 },
                X        = { Percent = 50 },
                Y        = { Percent = 50 },
                Settings =
                {
                    Draggable = true,
                    DragZones = new List <DragZone> {
                        new DragZone {
                            Width = { Percent = 100 },Height               = { Pixels = 28 }
                        }
                    }
                }
            };

            Add(panelMain);

            panelMain.With(() =>
            {
                UIText title = new UIText("Upgrade Station")
                {
                    Height = { Pixels = 20 }
                };
                panelMain.Add(title);

                UIText closeButton = new UIText("X")
                {
                    Height = { Pixels = 20 },
                    Width  = { Pixels = 20 },
                    X      = { Percent = 100 }
                };
                closeButton.OnClick += args =>
                {
                    args.Handled = true;
                    Display      = Display.None;
                };
                closeButton.OnMouseEnter += args => closeButton.Settings.TextColor = Color.Red;
                closeButton.OnMouseLeave += args => closeButton.Settings.TextColor = Color.White;
                panelMain.Add(closeButton);

                UIPanel panelItems = new UIPanel
                {
                    Width    = { Pixels = 64 },
                    Height   = { Percent = 100, Pixels = -28 },
                    Y        = { Pixels = 28 },
                    Settings =
                    {
                        BorderColor     = Color.Transparent,
                        BackgroundColor = DrawingUtility.Colors.PanelSelected * 0.75f
                    }
                };
                panelMain.Add(panelItems);
                panelMain.With(() =>
                {
                    gridItems = new UIGrid <UIModularItem>
                    {
                        Width    = { Percent = 100 },
                        Height   = { Percent = 100 },
                        Settings = { MaxSelectedItems = 1 }
                    };
                    panelItems.Add(gridItems);
                });

                UIPanel panelModules = new UIPanel
                {
                    Width    = { Percent = 40, Pixels = -64 },
                    Height   = { Percent = 100, Pixels = -28 },
                    X        = { Pixels = 64 },
                    Y        = { Pixels = 28 },
                    Settings =
                    {
                        BorderColor     = Color.Transparent,
                        BackgroundColor = DrawingUtility.Colors.PanelSelected * 0.75f
                    }
                };
                panelMain.Add(panelModules);
                panelModules.With(() =>
                {
                    UIPanel inputBG = new UIPanel
                    {
                        Width    = { Percent = 100 },
                        Height   = { Pixels = 36 },
                        Settings = { BorderColor = Color.Transparent }
                    };
                    panelModules.Add(inputBG);

                    UITextInput input = new UITextInput(ref search)
                    {
                        Width        = { Percent = 100 },
                        Height       = { Percent = 100 },
                        OnTextChange = () => gridModules.Search(),
                        Settings     = { HintText = "<Search>" }
                    };
                    inputBG.Add(input);

                    // todo: category buttons

                    gridModules = new UIGrid <UIModule>
                    {
                        Width          = { Percent = 100 },
                        Height         = { Percent = 100, Pixels = -44 },
                        Y              = { Pixels = 44 },
                        SearchSelector = item => string.IsNullOrWhiteSpace(search.Value) || TextUtility.Search(item.Module.DisplayName.Get().ToLower(), search.Value.ToLower()).Any()
                    };
                    panelModules.Add(gridModules);
                });

                UIPanel panelInfo = new UIPanel
                {
                    Width    = { Percent = 60 },
                    Height   = { Percent = 100, Pixels = -28 },
                    X        = { Percent = 100 },
                    Y        = { Pixels = 28 },
                    Settings =
                    {
                        BorderColor     = Color.Transparent,
                        BackgroundColor = DrawingUtility.Colors.PanelSelected * 0.75f
                    }
                };
                panelMain.Add(panelInfo);
                panelInfo.With(() =>
                {
                    textModule = new UIText("")
                    {
                        Width  = { Percent = 100 },
                        Height = { Pixels = 20 }
                    };
                    panelInfo.Add(textModule);

                    UIDivider divider = new UIDivider
                    {
                        Width = { Percent = 100 },
                        Y     = { Pixels = 28 }
                    };
                    panelInfo.Add(divider);

                    textModuleDescription = new UIText("")
                    {
                        Width  = { Percent = 100 },
                        Height = { Percent = 100 },
                        Y      = { Pixels = 36 }
                    };
                    panelInfo.Add(textModuleDescription);

                    textRequirements = new UIText("")
                    {
                        Width  = { Percent = 50 },
                        Height = { Pixels = 20 },
                        Y      = { Pixels = 100 + 36 }
                    };
                    panelInfo.Add(textRequirements);

                    textIncompatible = new UIText("")
                    {
                        Width  = { Percent = 50 },
                        Height = { Pixels = 20 },
                        X      = { Percent = 100 },
                        Y      = { Pixels = 100 + 36 }
                    };
                    panelInfo.Add(textIncompatible);

                    buttonInstall = new UITextButton("Install")
                    {
                        Width    = { Percent = 50, Pixels = -4 },
                        Height   = { Pixels = 30 },
                        Y        = { Percent = 100 },
                        Settings =
                        {
                            VerticalAlignment   = VerticalAlignment.Center,
                            HorizontalAlignment = HorizontalAlignment.Center
                        }
                    };
                    buttonInstall.OnClick += args =>
                    {
                        args.Handled = true;

                        if (selectedItem.CanInstall(selectedModule.Type))
                        {
                            BaseModule clone = selectedModule.Clone();
                            clone.InternalInstall(selectedItem);

                            gridModules.Children.OfType <UIModule>().FirstOrDefault(x => x.Module == selectedModule).Color = Color.LimeGreen;
                            buttonInstall.Settings.Disabled   = true;
                            buttonUninstall.Settings.Disabled = false;
                        }
                    };
                    panelInfo.Add(buttonInstall);

                    buttonUninstall = new UITextButton("Uninstall")
                    {
                        Width    = { Percent = 50, Pixels = -4 },
                        Height   = { Pixels = 30 },
                        X        = { Percent = 100 },
                        Y        = { Percent = 100 },
                        Settings =
                        {
                            VerticalAlignment   = VerticalAlignment.Center,
                            HorizontalAlignment = HorizontalAlignment.Center
                        }
                    };
                    buttonUninstall.OnClick += args =>
                    {
                        args.Handled = true;

                        if (selectedItem.CanUninstall(selectedModule.Type))
                        {
                            BaseModule clone = selectedItem.InstalledModules.First(x => x.Type == selectedModule.Type);
                            clone.InternalRemove(selectedItem);

                            gridModules.Children.OfType <UIModule>().FirstOrDefault(x => x.Module == selectedModule).Color = Color.Red;
                            buttonInstall.Settings.Disabled   = false;
                            buttonUninstall.Settings.Disabled = true;
                        }
                    };
                    panelInfo.Add(buttonUninstall);
                });
            });
        }