Ejemplo n.º 1
0
        public void TestSelectors()
        {
            var selectorElementLabel = new SelectorElement(typeof(Label), null, null, null);

            var label = new Label();
            var panel = new PanelContainer {
                StyleIdentifier = "bar"
            };

            Assert.That(selectorElementLabel.Matches(label), Is.True);
            Assert.That(selectorElementLabel.Matches(panel), Is.False);

            selectorElementLabel = new SelectorElement(typeof(Label), new[] { "foo" }, null, null);
            Assert.That(selectorElementLabel.Matches(label), Is.False);
            Assert.That(selectorElementLabel.Matches(panel), Is.False);

            Assert.That(label.HasStyleClass("foo"), Is.False);
            label.AddStyleClass("foo");
            Assert.That(selectorElementLabel.Matches(label), Is.True);
            Assert.That(label.HasStyleClass("foo"));
            // Make sure it doesn't throw.
            label.AddStyleClass("foo");
            label.RemoveStyleClass("foo");
            Assert.That(selectorElementLabel.Matches(label), Is.False);
            Assert.That(label.HasStyleClass("foo"), Is.False);
            // Make sure it doesn't throw.
            label.RemoveStyleClass("foo");

            selectorElementLabel = new SelectorElement(null, null, "bar", null);
            Assert.That(selectorElementLabel.Matches(label), Is.False);
            Assert.That(selectorElementLabel.Matches(panel), Is.True);
        }
Ejemplo n.º 2
0
        public BaseInput(InputElement input, SelectorElement selector, EventQueue queue)
            : base()
        {
            InputName    = input.Name;
            InputType    = input.Type;
            SelectorName = selector.Name;
            Processor    = selector.Processor;

            equeue = queue;
        }
Ejemplo n.º 3
0
        public void TestStylesheetOverride()
        {
            var sheetA = new Stylesheet(new[]
            {
                new StyleRule(SelectorElement.Class("A"), new[] { new StyleProperty("foo", "bar") }),
            });

            var sheetB = new Stylesheet(new[]
            {
                new StyleRule(SelectorElement.Class("A"), new[] { new StyleProperty("foo", "honk!") })
            });

            // Set style sheet to null, property shouldn't exist.

            var uiMgr = IoCManager.Resolve <IUserInterfaceManager>();

            uiMgr.Stylesheet = null;

            var baseControl = new Control();

            baseControl.AddStyleClass("A");
            var childA = new Control();

            childA.AddStyleClass("A");
            var childB = new Control();

            childB.AddStyleClass("A");

            uiMgr.StateRoot.AddChild(baseControl);

            baseControl.AddChild(childA);
            childA.AddChild(childB);

            baseControl.ForceRunStyleUpdate();

            Assert.That(baseControl.TryGetStyleProperty("foo", out object?_), Is.False);

            uiMgr.RootControl.Stylesheet = sheetA;
            childA.Stylesheet            = sheetB;

            // Assign sheets.
            baseControl.ForceRunStyleUpdate();

            baseControl.TryGetStyleProperty("foo", out object?value);
            Assert.That(value, Is.EqualTo("bar"));

            childA.TryGetStyleProperty("foo", out value);
            Assert.That(value, Is.EqualTo("honk!"));

            childB.TryGetStyleProperty("foo", out value);
            Assert.That(value, Is.EqualTo("honk!"));
        }
Ejemplo n.º 4
0
Archivo: Base.cs Proyecto: vokac/F2B
        public BaseInput(InputElement input, SelectorElement selector, EventQueue queue)
            : base()
        {
            InputName = input.Name;
            InputType = input.Type;
            SelectorName = selector.Name;
            Processor = selector.Processor;

            switch (selector.Login)
            {
                case "success": Login = LoginStatus.SUCCESS; break;
                case "failure": Login = LoginStatus.FAILURE; break;
                default: Login = LoginStatus.UNKNOWN; break;
            }

            equeue = queue;
        }
Ejemplo n.º 5
0
        public static SelectorMatcher Compile(SelectorElement selector)
        {
            SelectorMatcher composedMatcher = (in SelectorMatcherContext _) => true;

            if (selector is SelectorList <SelectorElement> selectorList)
            {
                for (var i = 0; i < selectorList.Children.Count; i++)
                {
                    var child = selectorList.Children[i];
                    if (child is Combinator combinator)
                    {
                        var matcher = combinator.GetCombinator(composedMatcher);
                        composedMatcher = SelectorCompilerHelper.ComposeAnd(matcher, Compile(selectorList.Children[i + 1]));
                    }
                    else if (child is Selector childSelector)
                    {
                        var matcher = childSelector.GetMatcher();
                        composedMatcher = SelectorCompilerHelper.ComposeAnd(composedMatcher, matcher);
                    }
                }
            }

            return(composedMatcher);
        }
Ejemplo n.º 6
0
        public StyleNano(IResourceCache resCache) : base(resCache)
        {
            var notoSans10            = resCache.GetFont("/Fonts/NotoSans/NotoSans-Regular.ttf", 10);
            var notoSansItalic10      = resCache.GetFont("/Fonts/NotoSans/NotoSans-Italic.ttf", 10);
            var notoSans12            = resCache.GetFont("/Fonts/NotoSans/NotoSans-Regular.ttf", 12);
            var notoSansItalic12      = resCache.GetFont("/Fonts/NotoSans/NotoSans-Italic.ttf", 12);
            var notoSansBold12        = resCache.GetFont("/Fonts/NotoSans/NotoSans-Bold.ttf", 12);
            var notoSansDisplayBold14 = resCache.GetFont("/Fonts/NotoSansDisplay/NotoSansDisplay-Bold.ttf", 14);
            var notoSans16            = resCache.GetFont("/Fonts/NotoSans/NotoSans-Regular.ttf", 16);
            var notoSansBold16        = resCache.GetFont("/Fonts/NotoSans/NotoSans-Bold.ttf", 16);
            var notoSansBold20        = resCache.GetFont("/Fonts/NotoSans/NotoSans-Bold.ttf", 20);
            var textureCloseButton    = resCache.GetTexture("/Textures/Interface/Nano/cross.svg.png");
            var windowHeaderTex       = resCache.GetTexture("/Textures/Interface/Nano/window_header.png");
            var windowHeader          = new StyleBoxTexture
            {
                Texture                     = windowHeaderTex,
                PatchMarginBottom           = 3,
                ExpandMarginBottom          = 3,
                ContentMarginBottomOverride = 0
            };
            var windowBackgroundTex = resCache.GetTexture("/Textures/Interface/Nano/window_background.png");
            var windowBackground    = new StyleBoxTexture
            {
                Texture = windowBackgroundTex,
            };

            windowBackground.SetPatchMargin(StyleBox.Margin.Horizontal | StyleBox.Margin.Bottom, 2);
            windowBackground.SetExpandMargin(StyleBox.Margin.Horizontal | StyleBox.Margin.Bottom, 2);

            var textureInvertedTriangle = resCache.GetTexture("/Textures/Interface/Nano/inverted_triangle.svg.png");

            var lineEditTex = resCache.GetTexture("/Textures/Interface/Nano/lineedit.png");
            var lineEdit    = new StyleBoxTexture
            {
                Texture = lineEditTex,
            };

            lineEdit.SetPatchMargin(StyleBox.Margin.All, 3);
            lineEdit.SetContentMarginOverride(StyleBox.Margin.Horizontal, 5);

            var tabContainerPanelTex = resCache.GetTexture("/Textures/Interface/Nano/tabcontainer_panel.png");
            var tabContainerPanel    = new StyleBoxTexture
            {
                Texture = tabContainerPanelTex,
            };

            tabContainerPanel.SetPatchMargin(StyleBox.Margin.All, 2);

            var tabContainerBoxActive = new StyleBoxFlat {
                BackgroundColor = new Color(64, 64, 64)
            };

            tabContainerBoxActive.SetContentMarginOverride(StyleBox.Margin.Horizontal, 5);
            var tabContainerBoxInactive = new StyleBoxFlat {
                BackgroundColor = new Color(32, 32, 32)
            };

            tabContainerBoxInactive.SetContentMarginOverride(StyleBox.Margin.Horizontal, 5);

            var vScrollBarGrabberNormal = new StyleBoxFlat
            {
                BackgroundColor          = Color.Gray.WithAlpha(0.35f), ContentMarginLeftOverride = 10,
                ContentMarginTopOverride = 10
            };
            var vScrollBarGrabberHover = new StyleBoxFlat
            {
                BackgroundColor          = new Color(140, 140, 140).WithAlpha(0.35f), ContentMarginLeftOverride = 10,
                ContentMarginTopOverride = 10
            };
            var vScrollBarGrabberGrabbed = new StyleBoxFlat
            {
                BackgroundColor          = new Color(160, 160, 160).WithAlpha(0.35f), ContentMarginLeftOverride = 10,
                ContentMarginTopOverride = 10
            };

            var hScrollBarGrabberNormal = new StyleBoxFlat
            {
                BackgroundColor = Color.Gray.WithAlpha(0.35f), ContentMarginTopOverride = 10
            };
            var hScrollBarGrabberHover = new StyleBoxFlat
            {
                BackgroundColor = new Color(140, 140, 140).WithAlpha(0.35f), ContentMarginTopOverride = 10
            };
            var hScrollBarGrabberGrabbed = new StyleBoxFlat
            {
                BackgroundColor = new Color(160, 160, 160).WithAlpha(0.35f), ContentMarginTopOverride = 10
            };

            var progressBarBackground = new StyleBoxFlat
            {
                BackgroundColor = new Color(0.25f, 0.25f, 0.25f)
            };

            progressBarBackground.SetContentMarginOverride(StyleBox.Margin.Vertical, 5);

            var progressBarForeground = new StyleBoxFlat
            {
                BackgroundColor = new Color(0.25f, 0.50f, 0.25f)
            };

            progressBarForeground.SetContentMarginOverride(StyleBox.Margin.Vertical, 5);

            // CheckBox
            var checkBoxTextureChecked   = resCache.GetTexture("/Textures/Interface/Nano/checkbox_checked.svg.96dpi.png");
            var checkBoxTextureUnchecked = resCache.GetTexture("/Textures/Interface/Nano/checkbox_unchecked.svg.96dpi.png");

            // Tooltip box
            var tooltipTexture = resCache.GetTexture("/Textures/Interface/Nano/tooltip.png");
            var tooltipBox     = new StyleBoxTexture
            {
                Texture = tooltipTexture,
            };

            tooltipBox.SetPatchMargin(StyleBox.Margin.All, 2);
            tooltipBox.SetContentMarginOverride(StyleBox.Margin.Horizontal, 5);

            // Placeholder
            var placeholderTexture = resCache.GetTexture("/Textures/Interface/Nano/placeholder.png");
            var placeholder        = new StyleBoxTexture {
                Texture = placeholderTexture
            };

            placeholder.SetPatchMargin(StyleBox.Margin.All, 19);
            placeholder.SetExpandMargin(StyleBox.Margin.All, -5);
            placeholder.Mode = StyleBoxTexture.StretchMode.Tile;

            var itemListBackgroundSelected = new StyleBoxFlat {
                BackgroundColor = new Color(75, 75, 86)
            };

            itemListBackgroundSelected.SetContentMarginOverride(StyleBox.Margin.Vertical, 2);
            itemListBackgroundSelected.SetContentMarginOverride(StyleBox.Margin.Horizontal, 4);
            var itemListItemBackgroundDisabled = new StyleBoxFlat {
                BackgroundColor = new Color(10, 10, 12)
            };

            itemListItemBackgroundDisabled.SetContentMarginOverride(StyleBox.Margin.Vertical, 2);
            itemListItemBackgroundDisabled.SetContentMarginOverride(StyleBox.Margin.Horizontal, 4);
            var itemListItemBackground = new StyleBoxFlat {
                BackgroundColor = new Color(55, 55, 68)
            };

            itemListItemBackground.SetContentMarginOverride(StyleBox.Margin.Vertical, 2);
            itemListItemBackground.SetContentMarginOverride(StyleBox.Margin.Horizontal, 4);
            var itemListItemBackgroundTransparent = new StyleBoxFlat {
                BackgroundColor = Color.Transparent
            };

            itemListItemBackgroundTransparent.SetContentMarginOverride(StyleBox.Margin.Vertical, 2);
            itemListItemBackgroundTransparent.SetContentMarginOverride(StyleBox.Margin.Horizontal, 4);

            // NanoHeading
            var nanoHeadingTex = resCache.GetTexture("/Textures/Interface/Nano/nanoheading.svg.96dpi.png");
            var nanoHeadingBox = new StyleBoxTexture
            {
                Texture                   = nanoHeadingTex,
                PatchMarginRight          = 10,
                PatchMarginTop            = 10,
                ContentMarginTopOverride  = 2,
                ContentMarginLeftOverride = 10,
                PaddingTop                = 4
            };

            nanoHeadingBox.SetPatchMargin(StyleBox.Margin.Left | StyleBox.Margin.Bottom, 2);

            // Stripe background
            var stripeBackTex = resCache.GetTexture("/Textures/Interface/Nano/stripeback.svg.96dpi.png");
            var stripeBack    = new StyleBoxTexture
            {
                Texture = stripeBackTex,
                Mode    = StyleBoxTexture.StretchMode.Tile
            };

            // Slider
            var sliderOutlineTex = resCache.GetTexture("/Textures/Interface/Nano/slider_outline.svg.96dpi.png");
            var sliderFillTex    = resCache.GetTexture("/Textures/Interface/Nano/slider_fill.svg.96dpi.png");
            var sliderGrabTex    = resCache.GetTexture("/Textures/Interface/Nano/slider_grabber.svg.96dpi.png");

            var sliderFillBox = new StyleBoxTexture
            {
                Texture  = sliderFillTex,
                Modulate = Color.FromHex("#3E6C45")
            };

            var sliderBackBox = new StyleBoxTexture
            {
                Texture  = sliderFillTex,
                Modulate = Color.FromHex("#1E1E22")
            };

            var sliderForeBox = new StyleBoxTexture
            {
                Texture  = sliderOutlineTex,
                Modulate = Color.FromHex("#494949")
            };

            var sliderGrabBox = new StyleBoxTexture
            {
                Texture = sliderGrabTex,
            };

            sliderFillBox.SetPatchMargin(StyleBox.Margin.All, 12);
            sliderBackBox.SetPatchMargin(StyleBox.Margin.All, 12);
            sliderForeBox.SetPatchMargin(StyleBox.Margin.All, 12);
            sliderGrabBox.SetPatchMargin(StyleBox.Margin.All, 12);

            var sliderFillGreen = new StyleBoxTexture(sliderFillBox)
            {
                Modulate = Color.Green
            };
            var sliderFillRed = new StyleBoxTexture(sliderFillBox)
            {
                Modulate = Color.Red
            };
            var sliderFillBlue = new StyleBoxTexture(sliderFillBox)
            {
                Modulate = Color.Blue
            };

            Stylesheet = new Stylesheet(BaseRules.Concat(new[]
            {
                // Window title.
                new StyleRule(
                    new SelectorElement(typeof(Label), new[] { SS14Window.StyleClassWindowTitle }, null, null),
                    new[]
                {
                    new StyleProperty(Label.StylePropertyFontColor, NanoGold),
                    new StyleProperty(Label.StylePropertyFont, notoSansDisplayBold14),
                }),
                // Window background.
                new StyleRule(
                    new SelectorElement(null, new[] { SS14Window.StyleClassWindowPanel }, null, null),
                    new[]
                {
                    new StyleProperty(PanelContainer.StylePropertyPanel, windowBackground),
                }),
                // Window header.
                new StyleRule(
                    new SelectorElement(typeof(PanelContainer), new[] { SS14Window.StyleClassWindowHeader }, null, null),
                    new[]
                {
                    new StyleProperty(PanelContainer.StylePropertyPanel, windowHeader),
                }),
                // Window close button base texture.
                new StyleRule(
                    new SelectorElement(typeof(TextureButton), new[] { SS14Window.StyleClassWindowCloseButton }, null,
                                        null),
                    new[]
                {
                    new StyleProperty(TextureButton.StylePropertyTexture, textureCloseButton),
                    new StyleProperty(Control.StylePropertyModulateSelf, Color.FromHex("#4B596A")),
                }),
                // Window close button hover.
                new StyleRule(
                    new SelectorElement(typeof(TextureButton), new[] { SS14Window.StyleClassWindowCloseButton }, null,
                                        new[] { TextureButton.StylePseudoClassHover }),
                    new[]
                {
                    new StyleProperty(Control.StylePropertyModulateSelf, Color.FromHex("#7F3636")),
                }),
                // Window close button pressed.
                new StyleRule(
                    new SelectorElement(typeof(TextureButton), new[] { SS14Window.StyleClassWindowCloseButton }, null,
                                        new[] { TextureButton.StylePseudoClassPressed }),
                    new[]
                {
                    new StyleProperty(Control.StylePropertyModulateSelf, Color.FromHex("#753131")),
                }),

                // Shapes for the buttons.
                Element <ContainerButton>().Class(ContainerButton.StyleClassButton)
                .Prop(ContainerButton.StylePropertyStyleBox, BaseButton),

                Element <ContainerButton>().Class(ContainerButton.StyleClassButton)
                .Class(ButtonOpenRight)
                .Prop(ContainerButton.StylePropertyStyleBox, BaseButtonOpenRight),

                Element <ContainerButton>().Class(ContainerButton.StyleClassButton)
                .Class(ButtonOpenLeft)
                .Prop(ContainerButton.StylePropertyStyleBox, BaseButtonOpenLeft),

                Element <ContainerButton>().Class(ContainerButton.StyleClassButton)
                .Class(ButtonOpenBoth)
                .Prop(ContainerButton.StylePropertyStyleBox, BaseButtonOpenBoth),

                new StyleRule(new SelectorElement(typeof(Label), new[] { Button.StyleClassButton }, null, null), new[]
                {
                    new StyleProperty(Label.StylePropertyAlignMode, Label.AlignMode.Center),
                }),

                // Colors for the buttons.
                Element <ContainerButton>().Class(ContainerButton.StyleClassButton)
                .Pseudo(ContainerButton.StylePseudoClassNormal)
                .Prop(Control.StylePropertyModulateSelf, ButtonColorDefault),

                Element <ContainerButton>().Class(ContainerButton.StyleClassButton)
                .Pseudo(ContainerButton.StylePseudoClassHover)
                .Prop(Control.StylePropertyModulateSelf, ButtonColorHovered),

                Element <ContainerButton>().Class(ContainerButton.StyleClassButton)
                .Pseudo(ContainerButton.StylePseudoClassPressed)
                .Prop(Control.StylePropertyModulateSelf, ButtonColorPressed),

                Element <ContainerButton>().Class(ContainerButton.StyleClassButton)
                .Pseudo(ContainerButton.StylePseudoClassDisabled)
                .Prop(Control.StylePropertyModulateSelf, ButtonColorDisabled),

                // Colors for the caution buttons.
                Element <ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonCaution)
                .Pseudo(ContainerButton.StylePseudoClassNormal)
                .Prop(Control.StylePropertyModulateSelf, ButtonColorCautionDefault),

                Element <ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonCaution)
                .Pseudo(ContainerButton.StylePseudoClassHover)
                .Prop(Control.StylePropertyModulateSelf, ButtonColorCautionHovered),

                Element <ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonCaution)
                .Pseudo(ContainerButton.StylePseudoClassPressed)
                .Prop(Control.StylePropertyModulateSelf, ButtonColorCautionPressed),

                Element <ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonCaution)
                .Pseudo(ContainerButton.StylePseudoClassDisabled)
                .Prop(Control.StylePropertyModulateSelf, ButtonColorCautionDisabled),

                new StyleRule(new SelectorChild(
                                  new SelectorElement(typeof(Button), null, null, new[] { ContainerButton.StylePseudoClassDisabled }),
                                  new SelectorElement(typeof(Label), null, null, null)),
                              new[]
                {
                    new StyleProperty("font-color", Color.FromHex("#E5E5E581")),
                }),

                // Main menu: Make those buttons bigger.
                new StyleRule(new SelectorChild(
                                  new SelectorElement(typeof(Button), null, "mainMenu", null),
                                  new SelectorElement(typeof(Label), null, null, null)),
                              new[]
                {
                    new StyleProperty("font", notoSansBold16),
                }),

                // Main menu: also make those buttons slightly more separated.
                new StyleRule(new SelectorElement(typeof(BoxContainer), null, "mainMenuVBox", null),
                              new[]
                {
                    new StyleProperty(BoxContainer.StylePropertySeparation, 2),
                }),

                // Fancy LineEdit
                new StyleRule(new SelectorElement(typeof(LineEdit), null, null, null),
                              new[]
                {
                    new StyleProperty(LineEdit.StylePropertyStyleBox, lineEdit),
                }),

                new StyleRule(
                    new SelectorElement(typeof(LineEdit), new[] { LineEdit.StyleClassLineEditNotEditable }, null, null),
                    new[]
                {
                    new StyleProperty("font-color", new Color(192, 192, 192)),
                }),

                new StyleRule(
                    new SelectorElement(typeof(LineEdit), null, null, new[] { LineEdit.StylePseudoClassPlaceholder }),
                    new[]
                {
                    new StyleProperty("font-color", Color.Gray),
                }),

                // TabContainer
                new StyleRule(new SelectorElement(typeof(TabContainer), null, null, null),
                              new[]
                {
                    new StyleProperty(TabContainer.StylePropertyPanelStyleBox, tabContainerPanel),
                    new StyleProperty(TabContainer.StylePropertyTabStyleBox, tabContainerBoxActive),
                    new StyleProperty(TabContainer.StylePropertyTabStyleBoxInactive, tabContainerBoxInactive),
                }),

                // Scroll bars
                new StyleRule(new SelectorElement(typeof(VScrollBar), null, null, null),
                              new[]
                {
                    new StyleProperty(ScrollBar.StylePropertyGrabber,
                                      vScrollBarGrabberNormal),
                }),

                new StyleRule(
                    new SelectorElement(typeof(VScrollBar), null, null, new[] { ScrollBar.StylePseudoClassHover }),
                    new[]
                {
                    new StyleProperty(ScrollBar.StylePropertyGrabber,
                                      vScrollBarGrabberHover),
                }),

                new StyleRule(
                    new SelectorElement(typeof(VScrollBar), null, null, new[] { ScrollBar.StylePseudoClassGrabbed }),
                    new[]
                {
                    new StyleProperty(ScrollBar.StylePropertyGrabber,
                                      vScrollBarGrabberGrabbed),
                }),

                new StyleRule(new SelectorElement(typeof(HScrollBar), null, null, null),
                              new[]
                {
                    new StyleProperty(ScrollBar.StylePropertyGrabber,
                                      hScrollBarGrabberNormal),
                }),

                new StyleRule(
                    new SelectorElement(typeof(HScrollBar), null, null, new[] { ScrollBar.StylePseudoClassHover }),
                    new[]
                {
                    new StyleProperty(ScrollBar.StylePropertyGrabber,
                                      hScrollBarGrabberHover),
                }),

                new StyleRule(
                    new SelectorElement(typeof(HScrollBar), null, null, new[] { ScrollBar.StylePseudoClassGrabbed }),
                    new[]
                {
                    new StyleProperty(ScrollBar.StylePropertyGrabber,
                                      hScrollBarGrabberGrabbed),
                }),

                // ProgressBar
                new StyleRule(new SelectorElement(typeof(ProgressBar), null, null, null),
                              new[]
                {
                    new StyleProperty(ProgressBar.StylePropertyBackground, progressBarBackground),
                    new StyleProperty(ProgressBar.StylePropertyForeground, progressBarForeground)
                }),

                // CheckBox
                new StyleRule(new SelectorElement(typeof(TextureRect), new [] { CheckBox.StyleClassCheckBox }, null, null), new[]
                {
                    new StyleProperty(TextureRect.StylePropertyTexture, checkBoxTextureUnchecked),
                }),

                new StyleRule(new SelectorElement(typeof(TextureRect), new [] { CheckBox.StyleClassCheckBox, CheckBox.StyleClassCheckBoxChecked }, null, null), new[]
                {
                    new StyleProperty(TextureRect.StylePropertyTexture, checkBoxTextureChecked),
                }),

                new StyleRule(new SelectorElement(typeof(HBoxContainer), new [] { CheckBox.StyleClassCheckBox }, null, null), new[]
                {
                    new StyleProperty(BoxContainer.StylePropertySeparation, 10),
                }),

                // Tooltip
                new StyleRule(new SelectorElement(typeof(Tooltip), null, null, null), new[]
                {
                    new StyleProperty(PanelContainer.StylePropertyPanel, tooltipBox)
                }),

                new StyleRule(new SelectorElement(typeof(PanelContainer), new[] { "tooltipBox" }, null, null), new[]
                {
                    new StyleProperty(PanelContainer.StylePropertyPanel, tooltipBox)
                }),

                new StyleRule(new SelectorElement(typeof(PanelContainer), new[] { "speechBox", "sayBox" }, null, null), new[]
                {
                    new StyleProperty(PanelContainer.StylePropertyPanel, tooltipBox)
                }),

                new StyleRule(new SelectorChild(
                                  new SelectorElement(typeof(PanelContainer), new[] { "speechBox", "emoteBox" }, null, null),
                                  new SelectorElement(typeof(RichTextLabel), null, null, null)),
                              new[]
                {
                    new StyleProperty("font", notoSansItalic12),
                }),

                // Entity tooltip
                new StyleRule(
                    new SelectorElement(typeof(PanelContainer), new[] { ExamineSystem.StyleClassEntityTooltip }, null,
                                        null), new[]
                {
                    new StyleProperty(PanelContainer.StylePropertyPanel, tooltipBox)
                }),

                // ItemList
                new StyleRule(new SelectorElement(typeof(ItemList), null, null, null), new[]
                {
                    new StyleProperty(ItemList.StylePropertyBackground,
                                      new StyleBoxFlat {
                        BackgroundColor = new Color(32, 32, 40)
                    }),
                    new StyleProperty(ItemList.StylePropertyItemBackground,
                                      itemListItemBackground),
                    new StyleProperty(ItemList.StylePropertyDisabledItemBackground,
                                      itemListItemBackgroundDisabled),
                    new StyleProperty(ItemList.StylePropertySelectedItemBackground,
                                      itemListBackgroundSelected)
                }),

                new StyleRule(new SelectorElement(typeof(ItemList), new[] { "transparentItemList" }, null, null), new[]
                {
                    new StyleProperty(ItemList.StylePropertyBackground,
                                      new StyleBoxFlat {
                        BackgroundColor = Color.Transparent
                    }),
                    new StyleProperty(ItemList.StylePropertyItemBackground,
                                      itemListItemBackgroundTransparent),
                    new StyleProperty(ItemList.StylePropertyDisabledItemBackground,
                                      itemListItemBackgroundDisabled),
                    new StyleProperty(ItemList.StylePropertySelectedItemBackground,
                                      itemListBackgroundSelected)
                }),

                // Tree
                new StyleRule(new SelectorElement(typeof(Tree), null, null, null), new[]
                {
                    new StyleProperty(Tree.StylePropertyBackground,
                                      new StyleBoxFlat {
                        BackgroundColor = new Color(32, 32, 40)
                    }),
                    new StyleProperty(Tree.StylePropertyItemBoxSelected, new StyleBoxFlat
                    {
                        BackgroundColor           = new Color(55, 55, 68),
                        ContentMarginLeftOverride = 4
                    })
                }),

                // Placeholder
                new StyleRule(new SelectorElement(typeof(Placeholder), null, null, null), new[]
                {
                    new StyleProperty(PanelContainer.StylePropertyPanel, placeholder),
                }),

                new StyleRule(
                    new SelectorElement(typeof(Label), new[] { Placeholder.StyleClassPlaceholderText }, null, null), new[]
                {
                    new StyleProperty(Label.StylePropertyFont, notoSans16),
                    new StyleProperty(Label.StylePropertyFontColor, new Color(103, 103, 103, 128)),
                }),

                // Big Label
                new StyleRule(new SelectorElement(typeof(Label), new[] { StyleClassLabelHeading }, null, null), new[]
                {
                    new StyleProperty(Label.StylePropertyFont, notoSansBold16),
                    new StyleProperty(Label.StylePropertyFontColor, NanoGold),
                }),

                // Bigger Label
                new StyleRule(new SelectorElement(typeof(Label), new[] { StyleClassLabelHeadingBigger }, null, null),
                              new[]
                {
                    new StyleProperty(Label.StylePropertyFont, notoSansBold20),
                    new StyleProperty(Label.StylePropertyFontColor, NanoGold),
                }),

                // Small Label
                new StyleRule(new SelectorElement(typeof(Label), new[] { StyleClassLabelSubText }, null, null), new[]
                {
                    new StyleProperty(Label.StylePropertyFont, notoSans10),
                    new StyleProperty(Label.StylePropertyFontColor, Color.DarkGray),
                }),

                // Label Key
                new StyleRule(new SelectorElement(typeof(Label), new[] { StyleClassLabelKeyText }, null, null), new[]
                {
                    new StyleProperty(Label.StylePropertyFont, notoSansBold12),
                    new StyleProperty(Label.StylePropertyFontColor, NanoGold)
                }),

                new StyleRule(new SelectorElement(typeof(Label), new[] { StyleClassLabelSecondaryColor }, null, null),
                              new[]
                {
                    new StyleProperty(Label.StylePropertyFont, notoSans12),
                    new StyleProperty(Label.StylePropertyFontColor, Color.DarkGray),
                }),

                // Big Button
                new StyleRule(new SelectorChild(
                                  new SelectorElement(typeof(Button), new[] { StyleClassButtonBig }, null, null),
                                  new SelectorElement(typeof(Label), null, null, null)),
                              new[]
                {
                    new StyleProperty("font", notoSans16)
                }),

                // Popup messages
                new StyleRule(new SelectorElement(typeof(Label), new[] { StyleClassPopupMessage }, null, null),
                              new[]
                {
                    new StyleProperty("font", notoSansItalic10),
                    new StyleProperty("font-color", Color.LightGray),
                }),

                //APC and SMES power state label colors
                new StyleRule(new SelectorElement(typeof(Label), new[] { StyleClassPowerStateNone }, null, null), new[]
                {
                    new StyleProperty(Label.StylePropertyFontColor, new Color(0.8f, 0.0f, 0.0f))
                }),

                new StyleRule(new SelectorElement(typeof(Label), new[] { StyleClassPowerStateLow }, null, null), new[]
                {
                    new StyleProperty(Label.StylePropertyFontColor, new Color(0.9f, 0.36f, 0.0f))
                }),

                new StyleRule(new SelectorElement(typeof(Label), new[] { StyleClassPowerStateGood }, null, null), new[]
                {
                    new StyleProperty(Label.StylePropertyFontColor, new Color(0.024f, 0.8f, 0.0f))
                }),

                // Those top menu buttons.
                Element <GameHud.TopButton>()
                .Prop(Button.StylePropertyStyleBox, BaseButton),

                new StyleRule(
                    new SelectorElement(typeof(GameHud.TopButton), null, null, new[] { Button.StylePseudoClassNormal }),
                    new[]
                {
                    new StyleProperty(Button.StylePropertyModulateSelf, ButtonColorDefault),
                }),

                new StyleRule(
                    new SelectorElement(typeof(GameHud.TopButton), null, null, new[] { Button.StylePseudoClassPressed }),
                    new[]
                {
                    new StyleProperty(Button.StylePropertyModulateSelf, ButtonColorPressed),
                }),

                new StyleRule(
                    new SelectorElement(typeof(GameHud.TopButton), null, null, new[] { Button.StylePseudoClassHover }),
                    new[]
                {
                    new StyleProperty(Button.StylePropertyModulateSelf, ButtonColorHovered),
                }),

                new StyleRule(
                    new SelectorElement(typeof(Label), new[] { GameHud.TopButton.StyleClassLabelTopButton }, null, null),
                    new[]
                {
                    new StyleProperty(Label.StylePropertyFont, notoSansDisplayBold14),
                }),

                // Targeting doll

                new StyleRule(
                    new SelectorElement(typeof(TextureButton), new[] { TargetingDoll.StyleClassTargetDollZone }, null,
                                        new[] { TextureButton.StylePseudoClassNormal }), new[]
                {
                    new StyleProperty(Control.StylePropertyModulateSelf, ButtonColorDefault),
                }),

                new StyleRule(
                    new SelectorElement(typeof(TextureButton), new[] { TargetingDoll.StyleClassTargetDollZone }, null,
                                        new[] { TextureButton.StylePseudoClassHover }), new[]
                {
                    new StyleProperty(Control.StylePropertyModulateSelf, ButtonColorHovered),
                }),

                new StyleRule(
                    new SelectorElement(typeof(TextureButton), new[] { TargetingDoll.StyleClassTargetDollZone }, null,
                                        new[] { TextureButton.StylePseudoClassPressed }), new[]
                {
                    new StyleProperty(Control.StylePropertyModulateSelf, ButtonColorPressed),
                }),

                // NanoHeading

                new StyleRule(
                    new SelectorChild(
                        SelectorElement.Type(typeof(NanoHeading)),
                        SelectorElement.Type(typeof(PanelContainer))),
                    new[]
                {
                    new StyleProperty(PanelContainer.StylePropertyPanel, nanoHeadingBox),
                }),

                // StripeBack
                new StyleRule(
                    SelectorElement.Type(typeof(StripeBack)),
                    new[]
                {
                    new StyleProperty(StripeBack.StylePropertyBackground, stripeBack),
                }),

                // StyleClassLabelBig
                new StyleRule(
                    SelectorElement.Class(StyleClassLabelBig),
                    new[]
                {
                    new StyleProperty("font", notoSans16),
                }),

                // StyleClassItemStatus
                new StyleRule(SelectorElement.Class(StyleClassItemStatus), new[]
                {
                    new StyleProperty("font", notoSans10),
                }),

                // Slider
                new StyleRule(SelectorElement.Type(typeof(Slider)), new []
                {
                    new StyleProperty(Slider.StylePropertyBackground, sliderBackBox),
                    new StyleProperty(Slider.StylePropertyForeground, sliderForeBox),
                    new StyleProperty(Slider.StylePropertyGrabber, sliderGrabBox),
                    new StyleProperty(Slider.StylePropertyFill, sliderFillBox),
                }),

                new StyleRule(new SelectorElement(typeof(Slider), new [] { StyleClassSliderRed }, null, null), new []
                {
                    new StyleProperty(Slider.StylePropertyFill, sliderFillRed),
                }),

                new StyleRule(new SelectorElement(typeof(Slider), new [] { StyleClassSliderGreen }, null, null), new []
                {
                    new StyleProperty(Slider.StylePropertyFill, sliderFillGreen),
                }),

                new StyleRule(new SelectorElement(typeof(Slider), new [] { StyleClassSliderBlue }, null, null), new []
                {
                    new StyleProperty(Slider.StylePropertyFill, sliderFillBlue),
                }),

                // OptionButton
                new StyleRule(new SelectorElement(typeof(OptionButton), null, null, null), new[]
                {
                    new StyleProperty(ContainerButton.StylePropertyStyleBox, BaseButton),
                }),
                new StyleRule(new SelectorElement(typeof(OptionButton), null, null, new[] { ContainerButton.StylePseudoClassNormal }), new[]
                {
                    new StyleProperty(Control.StylePropertyModulateSelf, ButtonColorDefault),
                }),
                new StyleRule(new SelectorElement(typeof(OptionButton), null, null, new[] { ContainerButton.StylePseudoClassHover }), new[]
                {
                    new StyleProperty(Control.StylePropertyModulateSelf, ButtonColorHovered),
                }),
                new StyleRule(new SelectorElement(typeof(OptionButton), null, null, new[] { ContainerButton.StylePseudoClassPressed }), new[]
                {
                    new StyleProperty(Control.StylePropertyModulateSelf, ButtonColorPressed),
                }),
                new StyleRule(new SelectorElement(typeof(OptionButton), null, null, new[] { ContainerButton.StylePseudoClassDisabled }), new[]
                {
                    new StyleProperty(Control.StylePropertyModulateSelf, ButtonColorDisabled),
                }),

                new StyleRule(new SelectorElement(typeof(TextureRect), new[] { OptionButton.StyleClassOptionTriangle }, null, null), new[]
                {
                    new StyleProperty(TextureRect.StylePropertyTexture, textureInvertedTriangle),
                    //new StyleProperty(Control.StylePropertyModulateSelf, Color.FromHex("#FFFFFF")),
                }),

                new StyleRule(new SelectorElement(typeof(Label), new[] { OptionButton.StyleClassOptionButton }, null, null), new[]
                {
                    new StyleProperty(Label.StylePropertyAlignMode, Label.AlignMode.Center),
                }),

                new StyleRule(new SelectorElement(typeof(PanelContainer), new [] { ClassHighDivider }, null, null), new []
                {
                    new StyleProperty(PanelContainer.StylePropertyPanel, new StyleBoxFlat {
                        BackgroundColor = NanoGold, ContentMarginBottomOverride = 2, ContentMarginLeftOverride = 2
                    }),
                })
            }).ToList());
        }
Ejemplo n.º 7
0
        public NanoStyle()
        {
            var resCache              = IoCManager.Resolve <IResourceCache>();
            var notoSans8             = resCache.GetFont("/Nano/NotoSans/NotoSans-Regular.ttf", 8);
            var notoSans10            = resCache.GetFont("/Nano/NotoSans/NotoSans-Regular.ttf", 10);
            var notoSans12            = resCache.GetFont("/Nano/NotoSans/NotoSans-Regular.ttf", 12);
            var notoSansBold12        = resCache.GetFont("/Nano/NotoSans/NotoSans-Bold.ttf", 12);
            var notoSansDisplayBold14 = resCache.GetFont("/Fonts/NotoSansDisplay/NotoSansDisplay-Bold.ttf", 14);
            var notoSans16            = resCache.GetFont("/Nano/NotoSans/NotoSans-Regular.ttf", 16);
            var notoSansBold16        = resCache.GetFont("/Nano/NotoSans/NotoSans-Bold.ttf", 16);
            var notoSansBold20        = resCache.GetFont("/Nano/NotoSans/NotoSans-Bold.ttf", 20);
            var textureCloseButton    = resCache.GetTexture("/Nano/cross.svg.png");
            var windowHeaderTex       = resCache.GetTexture("/Nano/window_header.png");
            var windowHeader          = new StyleBoxTexture
            {
                Texture                     = windowHeaderTex,
                PatchMarginBottom           = 3,
                ExpandMarginBottom          = 3,
                ContentMarginBottomOverride = 0
            };
            var windowBackgroundTex = resCache.GetTexture("/Nano/window_background.png");
            var windowBackground    = new StyleBoxTexture
            {
                Texture = windowBackgroundTex,
            };

            windowBackground.SetPatchMargin(StyleBox.Margin.Horizontal | StyleBox.Margin.Bottom, 2);
            windowBackground.SetExpandMargin(StyleBox.Margin.Horizontal | StyleBox.Margin.Bottom, 2);

            // Button styles.
            var buttonTex    = resCache.GetTexture("/Nano/button.svg.96dpi.png");
            var buttonNormal = new StyleBoxTexture
            {
                Texture  = buttonTex,
                Modulate = ButtonColorDefault
            };

            buttonNormal.SetPatchMargin(StyleBox.Margin.All, 10);
            buttonNormal.SetPadding(StyleBox.Margin.All, 1);
            buttonNormal.SetContentMarginOverride(StyleBox.Margin.Vertical, 2);
            buttonNormal.SetContentMarginOverride(StyleBox.Margin.Horizontal, 14);

            var buttonHover = new StyleBoxTexture(buttonNormal)
            {
                Modulate = ButtonColorHovered
            };

            var buttonPressed = new StyleBoxTexture(buttonNormal)
            {
                Modulate = ButtonColorPressed
            };

            var buttonDisabled = new StyleBoxTexture(buttonNormal)
            {
                Modulate = ButtonColorDisabled
            };

            var lineEditTex = resCache.GetTexture("/Nano/lineedit.png");
            var lineEdit    = new StyleBoxTexture
            {
                Texture = lineEditTex,
            };

            lineEdit.SetPatchMargin(StyleBox.Margin.All, 3);
            lineEdit.SetContentMarginOverride(StyleBox.Margin.Horizontal, 5);

            var tabContainerPanelTex = resCache.GetTexture("/Nano/tabcontainer_panel.png");
            var tabContainerPanel    = new StyleBoxTexture
            {
                Texture = tabContainerPanelTex,
            };

            tabContainerPanel.SetPatchMargin(StyleBox.Margin.All, 2);

            var tabContainerBoxActive = new StyleBoxFlat {
                BackgroundColor = new Color(64, 64, 64)
            };

            tabContainerBoxActive.SetContentMarginOverride(StyleBox.Margin.Horizontal, 5);
            var tabContainerBoxInactive = new StyleBoxFlat {
                BackgroundColor = new Color(32, 32, 32)
            };

            tabContainerBoxInactive.SetContentMarginOverride(StyleBox.Margin.Horizontal, 5);

            var vScrollBarGrabberNormal = new StyleBoxFlat
            {
                BackgroundColor          = Color.Gray.WithAlpha(0.35f), ContentMarginLeftOverride = 10,
                ContentMarginTopOverride = 10
            };
            var vScrollBarGrabberHover = new StyleBoxFlat
            {
                BackgroundColor          = new Color(140, 140, 140).WithAlpha(0.35f), ContentMarginLeftOverride = 10,
                ContentMarginTopOverride = 10
            };
            var vScrollBarGrabberGrabbed = new StyleBoxFlat
            {
                BackgroundColor          = new Color(160, 160, 160).WithAlpha(0.35f), ContentMarginLeftOverride = 10,
                ContentMarginTopOverride = 10
            };

            var hScrollBarGrabberNormal = new StyleBoxFlat
            {
                BackgroundColor = Color.Gray.WithAlpha(0.35f), ContentMarginTopOverride = 10
            };
            var hScrollBarGrabberHover = new StyleBoxFlat
            {
                BackgroundColor = new Color(140, 140, 140).WithAlpha(0.35f), ContentMarginTopOverride = 10
            };
            var hScrollBarGrabberGrabbed = new StyleBoxFlat
            {
                BackgroundColor = new Color(160, 160, 160).WithAlpha(0.35f), ContentMarginTopOverride = 10
            };

            var progressBarBackground = new StyleBoxFlat
            {
                BackgroundColor = new Color(0.25f, 0.25f, 0.25f)
            };

            progressBarBackground.SetContentMarginOverride(StyleBox.Margin.Vertical, 5);

            var progressBarForeground = new StyleBoxFlat
            {
                BackgroundColor = new Color(0.25f, 0.50f, 0.25f)
            };

            progressBarForeground.SetContentMarginOverride(StyleBox.Margin.Vertical, 5);

            // CheckBox
            var checkBoxTextureChecked   = resCache.GetTexture("/Nano/checkbox_checked.svg.96dpi.png");
            var checkBoxTextureUnchecked = resCache.GetTexture("/Nano/checkbox_unchecked.svg.96dpi.png");

            // Tooltip box
            var tooltipTexture = resCache.GetTexture("/Nano/tooltip.png");
            var tooltipBox     = new StyleBoxTexture
            {
                Texture = tooltipTexture,
            };

            tooltipBox.SetPatchMargin(StyleBox.Margin.All, 2);
            tooltipBox.SetContentMarginOverride(StyleBox.Margin.Horizontal, 5);

            // Placeholder
            var placeholderTexture = resCache.GetTexture("/Nano/placeholder.png");
            var placeholder        = new StyleBoxTexture {
                Texture = placeholderTexture
            };

            placeholder.SetPatchMargin(StyleBox.Margin.All, 19);
            placeholder.SetExpandMargin(StyleBox.Margin.All, -5);
            placeholder.Mode = StyleBoxTexture.StretchMode.Tile;

            var itemListBackgroundSelected = new StyleBoxFlat {
                BackgroundColor = new Color(75, 75, 86)
            };

            itemListBackgroundSelected.SetContentMarginOverride(StyleBox.Margin.Vertical, 2);
            itemListBackgroundSelected.SetContentMarginOverride(StyleBox.Margin.Horizontal, 4);
            var itemListItemBackgroundDisabled = new StyleBoxFlat {
                BackgroundColor = new Color(10, 10, 12)
            };

            itemListItemBackgroundDisabled.SetContentMarginOverride(StyleBox.Margin.Vertical, 2);
            itemListItemBackgroundDisabled.SetContentMarginOverride(StyleBox.Margin.Horizontal, 4);
            var itemListItemBackground = new StyleBoxFlat {
                BackgroundColor = new Color(55, 55, 68)
            };

            itemListItemBackground.SetContentMarginOverride(StyleBox.Margin.Vertical, 2);
            itemListItemBackground.SetContentMarginOverride(StyleBox.Margin.Horizontal, 4);
            var itemListItemBackgroundTransparent = new StyleBoxFlat {
                BackgroundColor = Color.Transparent
            };

            itemListItemBackgroundTransparent.SetContentMarginOverride(StyleBox.Margin.Vertical, 2);
            itemListItemBackgroundTransparent.SetContentMarginOverride(StyleBox.Margin.Horizontal, 4);

            // NanoHeading
            var nanoHeadingTex = resCache.GetTexture("/Nano/nanoheading.svg.96dpi.png");
            var nanoHeadingBox = new StyleBoxTexture
            {
                Texture                   = nanoHeadingTex,
                PatchMarginRight          = 10,
                PatchMarginTop            = 10,
                ContentMarginTopOverride  = 2,
                ContentMarginLeftOverride = 10,
                PaddingTop                = 4
            };

            nanoHeadingBox.SetPatchMargin(StyleBox.Margin.Left | StyleBox.Margin.Bottom, 2);

            // Stripe background
            var stripeBackTex = resCache.GetTexture("/Nano/stripeback.svg.96dpi.png");
            var stripeBack    = new StyleBoxTexture
            {
                Texture = stripeBackTex,
                Mode    = StyleBoxTexture.StretchMode.Tile
            };

            Stylesheet = new Stylesheet(new[]
            {
                // Default font.
                new StyleRule(
                    new SelectorElement(null, null, null, null),
                    new[]
                {
                    new StyleProperty("font", notoSans12),
                }),

                // Window title.
                new StyleRule(
                    new SelectorElement(typeof(Label), new[] { SS14Window.StyleClassWindowTitle }, null, null),
                    new[]
                {
                    new StyleProperty(Label.StylePropertyFontColor, NanoGold),
                    new StyleProperty(Label.StylePropertyFont, notoSansDisplayBold14),
                }),
                // Window background.
                new StyleRule(
                    new SelectorElement(null, new[] { SS14Window.StyleClassWindowPanel }, null, null),
                    new[]
                {
                    new StyleProperty(PanelContainer.StylePropertyPanel, windowBackground),
                }),
                // Window header.
                new StyleRule(
                    new SelectorElement(typeof(PanelContainer), new[] { SS14Window.StyleClassWindowHeader }, null, null),
                    new[]
                {
                    new StyleProperty(PanelContainer.StylePropertyPanel, windowHeader),
                }),
                // Window close button base texture.
                new StyleRule(
                    new SelectorElement(typeof(TextureButton), new[] { SS14Window.StyleClassWindowCloseButton }, null,
                                        null),
                    new[]
                {
                    new StyleProperty(TextureButton.StylePropertyTexture, textureCloseButton),
                    new StyleProperty(Control.StylePropertyModulateSelf, Color.FromHex("#4B596A")),
                }),
                // Window close button hover.
                new StyleRule(
                    new SelectorElement(typeof(TextureButton), new[] { SS14Window.StyleClassWindowCloseButton }, null,
                                        new[] { TextureButton.StylePseudoClassHover }),
                    new[]
                {
                    new StyleProperty(Control.StylePropertyModulateSelf, Color.FromHex("#7F3636")),
                }),
                // Window close button pressed.
                new StyleRule(
                    new SelectorElement(typeof(TextureButton), new[] { SS14Window.StyleClassWindowCloseButton }, null,
                                        new[] { TextureButton.StylePseudoClassPressed }),
                    new[]
                {
                    new StyleProperty(Control.StylePropertyModulateSelf, Color.FromHex("#753131")),
                }),

                // Regular buttons!
                new StyleRule(
                    new SelectorElement(typeof(Button), null, null, new[] { Button.StylePseudoClassNormal }),
                    new[]
                {
                    new StyleProperty(Button.StylePropertyStyleBox, buttonNormal),
                }),
                new StyleRule(
                    new SelectorElement(typeof(Button), null, null, new[] { Button.StylePseudoClassHover }),
                    new[]
                {
                    new StyleProperty(Button.StylePropertyStyleBox, buttonHover),
                }),
                new StyleRule(
                    new SelectorElement(typeof(Button), null, null, new[] { Button.StylePseudoClassPressed }),
                    new[]
                {
                    new StyleProperty(Button.StylePropertyStyleBox, buttonPressed),
                }),
                new StyleRule(
                    new SelectorElement(typeof(Button), null, null, new[] { Button.StylePseudoClassDisabled }),
                    new[]
                {
                    new StyleProperty(Button.StylePropertyStyleBox, buttonDisabled),
                    new StyleProperty("font-color", Color.FromHex("#E5E5E581")),
                }),

                // Main menu: Make those buttons bigger.
                new StyleRule(
                    new SelectorChild(
                        new SelectorElement(null, null, "mainMenuVBox", null),
                        new SelectorElement(typeof(Button), null, null, null)),
                    new[]
                {
                    new StyleProperty("font", notoSansBold16),
                }),

                // Main menu: also make those buttons slightly more separated.
                new StyleRule(new SelectorElement(typeof(BoxContainer), null, "mainMenuVBox", null),
                              new[]
                {
                    new StyleProperty(BoxContainer.StylePropertySeparation, 2),
                }),

                // Fancy LineEdit
                new StyleRule(new SelectorElement(typeof(LineEdit), null, null, null),
                              new[]
                {
                    new StyleProperty(LineEdit.StylePropertyStyleBox, lineEdit),
                }),

                new StyleRule(
                    new SelectorElement(typeof(LineEdit), new[] { LineEdit.StyleClassLineEditNotEditable }, null, null),
                    new[]
                {
                    new StyleProperty("font-color", new Color(192, 192, 192)),
                }),

                new StyleRule(
                    new SelectorElement(typeof(LineEdit), null, null, new[] { LineEdit.StylePseudoClassPlaceholder }),
                    new[]
                {
                    new StyleProperty("font-color", Color.Gray),
                }),

                // TabContainer
                new StyleRule(new SelectorElement(typeof(TabContainer), null, null, null),
                              new[]
                {
                    new StyleProperty(TabContainer.StylePropertyPanelStyleBox, tabContainerPanel),
                    new StyleProperty(TabContainer.StylePropertyTabStyleBox, tabContainerBoxActive),
                    new StyleProperty(TabContainer.StylePropertyTabStyleBoxInactive, tabContainerBoxInactive),
                }),

                // Scroll bars
                new StyleRule(new SelectorElement(typeof(VScrollBar), null, null, null),
                              new[]
                {
                    new StyleProperty(ScrollBar.StylePropertyGrabber,
                                      vScrollBarGrabberNormal),
                }),

                new StyleRule(
                    new SelectorElement(typeof(VScrollBar), null, null, new[] { ScrollBar.StylePseudoClassHover }),
                    new[]
                {
                    new StyleProperty(ScrollBar.StylePropertyGrabber,
                                      vScrollBarGrabberHover),
                }),

                new StyleRule(
                    new SelectorElement(typeof(VScrollBar), null, null, new[] { ScrollBar.StylePseudoClassGrabbed }),
                    new[]
                {
                    new StyleProperty(ScrollBar.StylePropertyGrabber,
                                      vScrollBarGrabberGrabbed),
                }),

                new StyleRule(new SelectorElement(typeof(HScrollBar), null, null, null),
                              new[]
                {
                    new StyleProperty(ScrollBar.StylePropertyGrabber,
                                      hScrollBarGrabberNormal),
                }),

                new StyleRule(
                    new SelectorElement(typeof(HScrollBar), null, null, new[] { ScrollBar.StylePseudoClassHover }),
                    new[]
                {
                    new StyleProperty(ScrollBar.StylePropertyGrabber,
                                      hScrollBarGrabberHover),
                }),

                new StyleRule(
                    new SelectorElement(typeof(HScrollBar), null, null, new[] { ScrollBar.StylePseudoClassGrabbed }),
                    new[]
                {
                    new StyleProperty(ScrollBar.StylePropertyGrabber,
                                      hScrollBarGrabberGrabbed),
                }),

                // ProgressBar
                new StyleRule(new SelectorElement(typeof(ProgressBar), null, null, null),
                              new[]
                {
                    new StyleProperty(ProgressBar.StylePropertyBackground, progressBarBackground),
                    new StyleProperty(ProgressBar.StylePropertyForeground, progressBarForeground)
                }),

                // CheckBox
                new StyleRule(new SelectorElement(typeof(CheckBox), null, null, null), new[]
                {
                    new StyleProperty(CheckBox.StylePropertyIcon, checkBoxTextureUnchecked),
                }),

                new StyleRule(new SelectorElement(typeof(CheckBox), null, null, new[] { Button.StylePseudoClassPressed }),
                              new[]
                {
                    new StyleProperty(CheckBox.StylePropertyIcon, checkBoxTextureChecked),
                }),

                new StyleRule(new SelectorElement(typeof(CheckBox), null, null, null), new[]
                {
                    new StyleProperty(CheckBox.StylePropertyHSeparation, 3),
                }),

                // Tooltip
                new StyleRule(new SelectorElement(typeof(Tooltip), null, null, null), new[]
                {
                    new StyleProperty(PanelContainer.StylePropertyPanel, tooltipBox)
                }),

                new StyleRule(new SelectorElement(typeof(PanelContainer), new[] { "tooltipBox" }, null, null), new[]
                {
                    new StyleProperty(PanelContainer.StylePropertyPanel, tooltipBox)
                }),

                // Entity tooltip
                new StyleRule(
                    new SelectorElement(typeof(PanelContainer), new[] { ExamineSystem.StyleClassEntityTooltip }, null,
                                        null), new[]
                {
                    new StyleProperty(PanelContainer.StylePropertyPanel, tooltipBox)
                }),

                // ItemList
                new StyleRule(new SelectorElement(typeof(ItemList), null, null, null), new[]
                {
                    new StyleProperty(ItemList.StylePropertyBackground,
                                      new StyleBoxFlat {
                        BackgroundColor = new Color(32, 32, 40)
                    }),
                    new StyleProperty(ItemList.StylePropertyItemBackground,
                                      itemListItemBackground),
                    new StyleProperty(ItemList.StylePropertyDisabledItemBackground,
                                      itemListItemBackgroundDisabled),
                    new StyleProperty(ItemList.StylePropertySelectedItemBackground,
                                      itemListBackgroundSelected)
                }),

                new StyleRule(new SelectorElement(typeof(ItemList), new[] { "transparentItemList" }, null, null), new[]
                {
                    new StyleProperty(ItemList.StylePropertyBackground,
                                      new StyleBoxFlat {
                        BackgroundColor = Color.Transparent
                    }),
                    new StyleProperty(ItemList.StylePropertyItemBackground,
                                      itemListItemBackgroundTransparent),
                    new StyleProperty(ItemList.StylePropertyDisabledItemBackground,
                                      itemListItemBackgroundDisabled),
                    new StyleProperty(ItemList.StylePropertySelectedItemBackground,
                                      itemListBackgroundSelected)
                }),

                // Tree
                new StyleRule(new SelectorElement(typeof(Tree), null, null, null), new[]
                {
                    new StyleProperty(Tree.StylePropertyBackground,
                                      new StyleBoxFlat {
                        BackgroundColor = new Color(32, 32, 40)
                    }),
                    new StyleProperty(Tree.StylePropertyItemBoxSelected, new StyleBoxFlat
                    {
                        BackgroundColor           = new Color(55, 55, 68),
                        ContentMarginLeftOverride = 4
                    })
                }),

                // Placeholder
                new StyleRule(new SelectorElement(typeof(Placeholder), null, null, null), new[]
                {
                    new StyleProperty(PanelContainer.StylePropertyPanel, placeholder),
                }),

                new StyleRule(
                    new SelectorElement(typeof(Label), new[] { Placeholder.StyleClassPlaceholderText }, null, null), new[]
                {
                    new StyleProperty(Label.StylePropertyFont, notoSans16),
                    new StyleProperty(Label.StylePropertyFontColor, new Color(103, 103, 103, 128)),
                }),

                // Big Label
                new StyleRule(new SelectorElement(typeof(Label), new[] { StyleClassLabelHeading }, null, null), new[]
                {
                    new StyleProperty(Label.StylePropertyFont, notoSansBold16),
                    new StyleProperty(Label.StylePropertyFontColor, NanoGold),
                }),

                // Bigger Label
                new StyleRule(new SelectorElement(typeof(Label), new[] { StyleClassLabelHeadingBigger }, null, null),
                              new[]
                {
                    new StyleProperty(Label.StylePropertyFont, notoSansBold20),
                    new StyleProperty(Label.StylePropertyFontColor, NanoGold),
                }),

                // Small Label
                new StyleRule(new SelectorElement(typeof(Label), new[] { StyleClassLabelSubText }, null, null), new[]
                {
                    new StyleProperty(Label.StylePropertyFont, notoSans10),
                    new StyleProperty(Label.StylePropertyFontColor, Color.DarkGray),
                }),

                // Label Key
                new StyleRule(new SelectorElement(typeof(Label), new[] { StyleClassLabelKeyText }, null, null), new[]
                {
                    new StyleProperty(Label.StylePropertyFont, notoSansBold12),
                    new StyleProperty(Label.StylePropertyFontColor, NanoGold)
                }),

                new StyleRule(new SelectorElement(typeof(Label), new[] { StyleClassLabelSecondaryColor }, null, null),
                              new[]
                {
                    new StyleProperty(Label.StylePropertyFont, notoSans12),
                    new StyleProperty(Label.StylePropertyFontColor, Color.DarkGray),
                }),

                // Big Button
                new StyleRule(new SelectorElement(typeof(Button), new[] { StyleClassButtonBig }, null, null), new[]
                {
                    new StyleProperty("font", notoSans16)
                }),

                //APC and SMES power state label colors
                new StyleRule(new SelectorElement(typeof(Label), new[] { StyleClassPowerStateNone }, null, null), new[]
                {
                    new StyleProperty(Label.StylePropertyFontColor, new Color(0.8f, 0.0f, 0.0f))
                }),

                new StyleRule(new SelectorElement(typeof(Label), new[] { StyleClassPowerStateLow }, null, null), new[]
                {
                    new StyleProperty(Label.StylePropertyFontColor, new Color(0.9f, 0.36f, 0.0f))
                }),

                new StyleRule(new SelectorElement(typeof(Label), new[] { StyleClassPowerStateGood }, null, null), new[]
                {
                    new StyleProperty(Label.StylePropertyFontColor, new Color(0.024f, 0.8f, 0.0f))
                }),

                // Those top menu buttons.
                new StyleRule(
                    new SelectorElement(typeof(GameHud.TopButton), null, null, new[] { Button.StylePseudoClassNormal }),
                    new[]
                {
                    new StyleProperty(Button.StylePropertyStyleBox, buttonNormal),
                }),

                new StyleRule(
                    new SelectorElement(typeof(GameHud.TopButton), null, null, new[] { Button.StylePseudoClassPressed }),
                    new[]
                {
                    new StyleProperty(Button.StylePropertyStyleBox, buttonPressed),
                }),

                new StyleRule(
                    new SelectorElement(typeof(GameHud.TopButton), null, null, new[] { Button.StylePseudoClassHover }),
                    new[]
                {
                    new StyleProperty(Button.StylePropertyStyleBox, buttonHover),
                }),

                new StyleRule(
                    new SelectorElement(typeof(Label), new[] { GameHud.TopButton.StyleClassLabelTopButton }, null, null),
                    new[]
                {
                    new StyleProperty(Label.StylePropertyFont, notoSansDisplayBold14),
                }),

                // Targeting doll

                new StyleRule(
                    new SelectorElement(typeof(TextureButton), new[] { TargetingDoll.StyleClassTargetDollZone }, null,
                                        new[] { TextureButton.StylePseudoClassNormal }), new[]
                {
                    new StyleProperty(Control.StylePropertyModulateSelf, ButtonColorDefault),
                }),

                new StyleRule(
                    new SelectorElement(typeof(TextureButton), new[] { TargetingDoll.StyleClassTargetDollZone }, null,
                                        new[] { TextureButton.StylePseudoClassHover }), new[]
                {
                    new StyleProperty(Control.StylePropertyModulateSelf, ButtonColorHovered),
                }),

                new StyleRule(
                    new SelectorElement(typeof(TextureButton), new[] { TargetingDoll.StyleClassTargetDollZone }, null,
                                        new[] { TextureButton.StylePseudoClassPressed }), new[]
                {
                    new StyleProperty(Control.StylePropertyModulateSelf, ButtonColorPressed),
                }),

                // NanoHeading

                new StyleRule(
                    new SelectorChild(
                        SelectorElement.Type(typeof(NanoHeading)),
                        SelectorElement.Type(typeof(PanelContainer))),
                    new[]
                {
                    new StyleProperty(PanelContainer.StylePropertyPanel, nanoHeadingBox),
                }),

                // StripeBack
                new StyleRule(
                    SelectorElement.Type(typeof(StripeBack)),
                    new[]
                {
                    new StyleProperty(StripeBack.StylePropertyBackground, stripeBack),
                }),

                // StyleClassLabelBig
                new StyleRule(
                    SelectorElement.Class(StyleClassLabelBig),
                    new[]
                {
                    new StyleProperty("font", notoSans16),
                }),

                // StyleClassItemStatus
                new StyleRule(SelectorElement.Class(StyleClassItemStatus), new[]
                {
                    new StyleProperty("font", notoSans10),
                }),
            });
        }
Ejemplo n.º 8
0
        public EventLogInput(InputElement input, SelectorElement selector, EventQueue equeue)
            : base(input, selector, equeue)
        {
            // Event log query with suppressed events logged by this service
            StringBuilder qstr = new StringBuilder();
            qstr.Append("<QueryList>");
            qstr.Append("<Query>");
            qstr.Append(selector.Query.Value);
            qstr.Append("<Suppress Path=\"Application\">*[System/Provider/@Name=\"F2B\"]</Suppress>");
            qstr.Append("</Query>");
            qstr.Append("</QueryList>");

            EventLogSession session = null;
            if (input.Server != string.Empty)
            {
                SecureString pw = new SecureString();
                Array.ForEach(input.Password.ToCharArray(), pw.AppendChar);
                session = new EventLogSession(input.Server, input.Domain,
                                              input.Username, pw,
                                              SessionAuthentication.Default);
                pw.Dispose();
            }

            EventLogQuery query = new EventLogQuery(null, PathType.LogName, qstr.ToString());
            if (session != null)
            {
                query.Session = session;
            }

            // create event watcher (must be enable later)
            watcher = new EventLogWatcher(query);
            watcher.EventRecordWritten +=
                new EventHandler<EventRecordWrittenEventArgs>(
                    (s, a) => EventRead(s, a));

            // event data parsers (e.g. XPath + regex to extract event data)
            // (it is important to preserve order - it is later used as array index)
            List<Tuple<string, EventDataElement>> tmp = new List<Tuple<string, EventDataElement>>();
            tmp.Add(new Tuple<string,EventDataElement>("address", selector.Address));
            tmp.Add(new Tuple<string,EventDataElement>("port", selector.Port));
            tmp.Add(new Tuple<string,EventDataElement>("username", selector.Username));
            tmp.Add(new Tuple<string,EventDataElement>("domain", selector.Domain));

            evtmap = new Dictionary<string, Tuple<int, int>>();
            evtregex = new List<Regex>();
            List<string> xPathRefs = new List<string>();

            for (int i = 0; i < tmp.Count; i++)
            {
                string evtdescr = tmp[i].Item1;
                EventDataElement evtdata = tmp[i].Item2;

                if (evtdata == null || string.IsNullOrEmpty(evtdata.XPath))
                {
                    if (evtdescr == "address")
                    {
                        throw new ArgumentException("No address in " + Name + " configuration");
                    }

                    evtmap[evtdescr] = new Tuple<int, int>(i, -1);

                    continue;
                }

                Regex regex = null;
                if (!string.IsNullOrWhiteSpace(evtdata.Value))
                {
                    string evtstr = evtdata.Value.Trim();
                    try
                    {
                        regex = new Regex(evtstr, RegexOptions.IgnoreCase | RegexOptions.Singleline);
                    }
                    catch (ArgumentException ex)
                    {
                        Log.Error("Invalid " + Name + " " + evtdescr + " regex: "
                            + evtstr + " (" + ex.Message + ")");
                        throw;
                    }
                }

                evtregex.Add(regex);
                if (xPathRefs.Contains(evtdata.XPath))
                {
                    int index = xPathRefs.IndexOf(evtdata.XPath);
                    evtmap[evtdescr] = new Tuple<int, int>(i, index);
                }
                else
                {
                    xPathRefs.Add(evtdata.XPath);
                    evtmap[evtdescr] = new Tuple<int, int>(i, xPathRefs.Count - 1);
                }
            }

            Debug.Assert(tmp.Count == evtmap.Count,
                "Invalid index map size (tmp[" + tmp.Count
                + "] != map[" + evtmap.Count + "]).");

            evtsel = new EventLogPropertySelector(xPathRefs);
        }
Ejemplo n.º 9
0
        public StyleNano(IResourceCache resCache) : base(resCache)
        {
            var notoSans10            = resCache.GetFont("/Fonts/NotoSans/NotoSans-Regular.ttf", 10);
            var notoSansItalic10      = resCache.GetFont("/Fonts/NotoSans/NotoSans-Italic.ttf", 10);
            var notoSans12            = resCache.GetFont("/Fonts/NotoSans/NotoSans-Regular.ttf", 12);
            var notoSansItalic12      = resCache.GetFont("/Fonts/NotoSans/NotoSans-Italic.ttf", 12);
            var notoSansBold12        = resCache.GetFont("/Fonts/NotoSans/NotoSans-Bold.ttf", 12);
            var notoSansDisplayBold14 = resCache.GetFont("/Fonts/NotoSansDisplay/NotoSansDisplay-Bold.ttf", 14);
            var notoSansDisplayBold16 = resCache.GetFont("/Fonts/NotoSansDisplay/NotoSansDisplay-Bold.ttf", 16);
            var notoSans15            = resCache.GetFont("/Fonts/NotoSans/NotoSans-Regular.ttf", 15);
            var notoSans16            = resCache.GetFont("/Fonts/NotoSans/NotoSans-Regular.ttf", 16);
            var notoSansBold16        = resCache.GetFont("/Fonts/NotoSans/NotoSans-Bold.ttf", 16);
            var notoSansBold18        = resCache.GetFont("/Fonts/NotoSans/NotoSans-Bold.ttf", 18);
            var notoSansBold20        = resCache.GetFont("/Fonts/NotoSans/NotoSans-Bold.ttf", 20);
            var windowHeaderTex       = resCache.GetTexture("/Textures/Interface/Nano/window_header.png");
            var windowHeader          = new StyleBoxTexture
            {
                Texture                     = windowHeaderTex,
                PatchMarginBottom           = 3,
                ExpandMarginBottom          = 3,
                ContentMarginBottomOverride = 0
            };
            var windowBackgroundTex = resCache.GetTexture("/Textures/Interface/Nano/window_background.png");
            var windowBackground    = new StyleBoxTexture
            {
                Texture = windowBackgroundTex,
            };

            windowBackground.SetPatchMargin(StyleBox.Margin.Horizontal | StyleBox.Margin.Bottom, 2);
            windowBackground.SetExpandMargin(StyleBox.Margin.Horizontal | StyleBox.Margin.Bottom, 2);

            var borderedWindowBackgroundTex = resCache.GetTexture("/Textures/Interface/Nano/window_background_bordered.png");
            var borderedWindowBackground    = new StyleBoxTexture
            {
                Texture = borderedWindowBackgroundTex,
            };

            borderedWindowBackground.SetPatchMargin(StyleBox.Margin.All, 2);

            var invSlotBgTex = resCache.GetTexture("/Textures/Interface/Inventory/inv_slot_background.png");
            var invSlotBg    = new StyleBoxTexture
            {
                Texture = invSlotBgTex,
            };

            invSlotBg.SetPatchMargin(StyleBox.Margin.All, 2);
            invSlotBg.SetContentMarginOverride(StyleBox.Margin.All, 0);

            var handSlotHighlightTex = resCache.GetTexture("/Textures/Interface/Inventory/hand_slot_highlight.png");
            var handSlotHighlight    = new StyleBoxTexture
            {
                Texture = handSlotHighlightTex,
            };

            handSlotHighlight.SetPatchMargin(StyleBox.Margin.All, 2);

            var borderedTransparentWindowBackgroundTex = resCache.GetTexture("/Textures/Interface/Nano/transparent_window_background_bordered.png");
            var borderedTransparentWindowBackground    = new StyleBoxTexture
            {
                Texture = borderedTransparentWindowBackgroundTex,
            };

            borderedTransparentWindowBackground.SetPatchMargin(StyleBox.Margin.All, 2);

            var hotbarBackground = new StyleBoxTexture
            {
                Texture = borderedWindowBackgroundTex,
            };

            hotbarBackground.SetPatchMargin(StyleBox.Margin.All, 2);
            hotbarBackground.SetExpandMargin(StyleBox.Margin.All, 4);

            var buttonRectTex = resCache.GetTexture("/Textures/Interface/Nano/light_panel_background_bordered.png");
            var buttonRect    = new StyleBoxTexture(BaseButton)
            {
                Texture = buttonRectTex
            };

            buttonRect.SetPatchMargin(StyleBox.Margin.All, 2);
            buttonRect.SetPadding(StyleBox.Margin.All, 2);
            buttonRect.SetContentMarginOverride(StyleBox.Margin.Vertical, 2);
            buttonRect.SetContentMarginOverride(StyleBox.Margin.Horizontal, 2);

            var buttonRectHover = new StyleBoxTexture(buttonRect)
            {
                Modulate = ButtonColorHovered
            };

            var buttonRectPressed = new StyleBoxTexture(buttonRect)
            {
                Modulate = ButtonColorPressed
            };

            var buttonRectDisabled = new StyleBoxTexture(buttonRect)
            {
                Modulate = ButtonColorDisabled
            };

            var buttonRectActionMenuItemTex        = resCache.GetTexture("/Textures/Interface/Nano/black_panel_light_thin_border.png");
            var buttonRectActionMenuRevokedItemTex = resCache.GetTexture("/Textures/Interface/Nano/black_panel_red_thin_border.png");
            var buttonRectActionMenuItem           = new StyleBoxTexture(BaseButton)
            {
                Texture = buttonRectActionMenuItemTex
            };

            buttonRectActionMenuItem.SetPatchMargin(StyleBox.Margin.All, 2);
            buttonRectActionMenuItem.SetPadding(StyleBox.Margin.All, 2);
            buttonRectActionMenuItem.SetContentMarginOverride(StyleBox.Margin.Vertical, 2);
            buttonRectActionMenuItem.SetContentMarginOverride(StyleBox.Margin.Horizontal, 2);
            var buttonRectActionMenuItemRevoked = new StyleBoxTexture(buttonRectActionMenuItem)
            {
                Texture = buttonRectActionMenuRevokedItemTex
            };
            var buttonRectActionMenuItemHover = new StyleBoxTexture(buttonRectActionMenuItem)
            {
                Modulate = ButtonColorHovered
            };
            var buttonRectActionMenuItemPressed = new StyleBoxTexture(buttonRectActionMenuItem)
            {
                Modulate = ButtonColorPressed
            };

            var buttonTex     = resCache.GetTexture("/Textures/Interface/Nano/button.svg.96dpi.png");
            var topButtonBase = new StyleBoxTexture
            {
                Texture = buttonTex,
            };

            topButtonBase.SetPatchMargin(StyleBox.Margin.All, 10);
            topButtonBase.SetPadding(StyleBox.Margin.All, 0);
            topButtonBase.SetContentMarginOverride(StyleBox.Margin.All, 0);

            var topButtonOpenRight = new StyleBoxTexture(topButtonBase)
            {
                Texture = new AtlasTexture(buttonTex, UIBox2.FromDimensions((0, 0), (14, 24))),
            };

            topButtonOpenRight.SetPatchMargin(StyleBox.Margin.Right, 0);

            var topButtonOpenLeft = new StyleBoxTexture(topButtonBase)
            {
                Texture = new AtlasTexture(buttonTex, UIBox2.FromDimensions((10, 0), (14, 24))),
            };

            topButtonOpenLeft.SetPatchMargin(StyleBox.Margin.Left, 0);

            var topButtonSquare = new StyleBoxTexture(topButtonBase)
            {
                Texture = new AtlasTexture(buttonTex, UIBox2.FromDimensions((10, 0), (3, 24))),
            };

            topButtonSquare.SetPatchMargin(StyleBox.Margin.Horizontal, 0);

            var textureInvertedTriangle = resCache.GetTexture("/Textures/Interface/Nano/inverted_triangle.svg.png");

            var lineEditTex = resCache.GetTexture("/Textures/Interface/Nano/lineedit.png");
            var lineEdit    = new StyleBoxTexture
            {
                Texture = lineEditTex,
            };

            lineEdit.SetPatchMargin(StyleBox.Margin.All, 3);
            lineEdit.SetContentMarginOverride(StyleBox.Margin.Horizontal, 5);

            var actionSearchBoxTex = resCache.GetTexture("/Textures/Interface/Nano/black_panel_dark_thin_border.png");
            var actionSearchBox    = new StyleBoxTexture
            {
                Texture = actionSearchBoxTex,
            };

            actionSearchBox.SetPatchMargin(StyleBox.Margin.All, 3);
            actionSearchBox.SetContentMarginOverride(StyleBox.Margin.Horizontal, 5);

            var tabContainerPanelTex = resCache.GetTexture("/Textures/Interface/Nano/tabcontainer_panel.png");
            var tabContainerPanel    = new StyleBoxTexture
            {
                Texture = tabContainerPanelTex,
            };

            tabContainerPanel.SetPatchMargin(StyleBox.Margin.All, 2);

            var tabContainerBoxActive = new StyleBoxFlat {
                BackgroundColor = new Color(64, 64, 64)
            };

            tabContainerBoxActive.SetContentMarginOverride(StyleBox.Margin.Horizontal, 5);
            var tabContainerBoxInactive = new StyleBoxFlat {
                BackgroundColor = new Color(32, 32, 32)
            };

            tabContainerBoxInactive.SetContentMarginOverride(StyleBox.Margin.Horizontal, 5);

            var progressBarBackground = new StyleBoxFlat
            {
                BackgroundColor = new Color(0.25f, 0.25f, 0.25f)
            };

            progressBarBackground.SetContentMarginOverride(StyleBox.Margin.Vertical, 5);

            var progressBarForeground = new StyleBoxFlat
            {
                BackgroundColor = new Color(0.25f, 0.50f, 0.25f)
            };

            progressBarForeground.SetContentMarginOverride(StyleBox.Margin.Vertical, 5);

            // CheckBox
            var checkBoxTextureChecked   = resCache.GetTexture("/Textures/Interface/Nano/checkbox_checked.svg.96dpi.png");
            var checkBoxTextureUnchecked = resCache.GetTexture("/Textures/Interface/Nano/checkbox_unchecked.svg.96dpi.png");

            // Tooltip box
            var tooltipTexture = resCache.GetTexture("/Textures/Interface/Nano/tooltip.png");
            var tooltipBox     = new StyleBoxTexture
            {
                Texture = tooltipTexture,
            };

            tooltipBox.SetPatchMargin(StyleBox.Margin.All, 2);
            tooltipBox.SetContentMarginOverride(StyleBox.Margin.Horizontal, 7);

            // Placeholder
            var placeholderTexture = resCache.GetTexture("/Textures/Interface/Nano/placeholder.png");
            var placeholder        = new StyleBoxTexture {
                Texture = placeholderTexture
            };

            placeholder.SetPatchMargin(StyleBox.Margin.All, 19);
            placeholder.SetExpandMargin(StyleBox.Margin.All, -5);
            placeholder.Mode = StyleBoxTexture.StretchMode.Tile;

            var itemListBackgroundSelected = new StyleBoxFlat {
                BackgroundColor = new Color(75, 75, 86)
            };

            itemListBackgroundSelected.SetContentMarginOverride(StyleBox.Margin.Vertical, 2);
            itemListBackgroundSelected.SetContentMarginOverride(StyleBox.Margin.Horizontal, 4);
            var itemListItemBackgroundDisabled = new StyleBoxFlat {
                BackgroundColor = new Color(10, 10, 12)
            };

            itemListItemBackgroundDisabled.SetContentMarginOverride(StyleBox.Margin.Vertical, 2);
            itemListItemBackgroundDisabled.SetContentMarginOverride(StyleBox.Margin.Horizontal, 4);
            var itemListItemBackground = new StyleBoxFlat {
                BackgroundColor = new Color(55, 55, 68)
            };

            itemListItemBackground.SetContentMarginOverride(StyleBox.Margin.Vertical, 2);
            itemListItemBackground.SetContentMarginOverride(StyleBox.Margin.Horizontal, 4);
            var itemListItemBackgroundTransparent = new StyleBoxFlat {
                BackgroundColor = Color.Transparent
            };

            itemListItemBackgroundTransparent.SetContentMarginOverride(StyleBox.Margin.Vertical, 2);
            itemListItemBackgroundTransparent.SetContentMarginOverride(StyleBox.Margin.Horizontal, 4);

            // NanoHeading
            var nanoHeadingTex = resCache.GetTexture("/Textures/Interface/Nano/nanoheading.svg.96dpi.png");
            var nanoHeadingBox = new StyleBoxTexture
            {
                Texture                   = nanoHeadingTex,
                PatchMarginRight          = 10,
                PatchMarginTop            = 10,
                ContentMarginTopOverride  = 2,
                ContentMarginLeftOverride = 10,
                PaddingTop                = 4
            };

            nanoHeadingBox.SetPatchMargin(StyleBox.Margin.Left | StyleBox.Margin.Bottom, 2);

            // Stripe background
            var stripeBackTex = resCache.GetTexture("/Textures/Interface/Nano/stripeback.svg.96dpi.png");
            var stripeBack    = new StyleBoxTexture
            {
                Texture = stripeBackTex,
                Mode    = StyleBoxTexture.StretchMode.Tile
            };

            // Slider
            var sliderOutlineTex = resCache.GetTexture("/Textures/Interface/Nano/slider_outline.svg.96dpi.png");
            var sliderFillTex    = resCache.GetTexture("/Textures/Interface/Nano/slider_fill.svg.96dpi.png");
            var sliderGrabTex    = resCache.GetTexture("/Textures/Interface/Nano/slider_grabber.svg.96dpi.png");

            var sliderFillBox = new StyleBoxTexture
            {
                Texture  = sliderFillTex,
                Modulate = Color.FromHex("#3E6C45")
            };

            var sliderBackBox = new StyleBoxTexture
            {
                Texture  = sliderFillTex,
                Modulate = Color.FromHex("#1E1E22")
            };

            var sliderForeBox = new StyleBoxTexture
            {
                Texture  = sliderOutlineTex,
                Modulate = Color.FromHex("#494949")
            };

            var sliderGrabBox = new StyleBoxTexture
            {
                Texture = sliderGrabTex,
            };

            sliderFillBox.SetPatchMargin(StyleBox.Margin.All, 12);
            sliderBackBox.SetPatchMargin(StyleBox.Margin.All, 12);
            sliderForeBox.SetPatchMargin(StyleBox.Margin.All, 12);
            sliderGrabBox.SetPatchMargin(StyleBox.Margin.All, 12);

            var sliderFillGreen = new StyleBoxTexture(sliderFillBox)
            {
                Modulate = Color.Green
            };
            var sliderFillRed = new StyleBoxTexture(sliderFillBox)
            {
                Modulate = Color.Red
            };
            var sliderFillBlue = new StyleBoxTexture(sliderFillBox)
            {
                Modulate = Color.Blue
            };

            Stylesheet = new Stylesheet(BaseRules.Concat(new[]
            {
                // Window title.
                new StyleRule(
                    new SelectorElement(typeof(Label), new[] { SS14Window.StyleClassWindowTitle }, null, null),
                    new[]
                {
                    new StyleProperty(Label.StylePropertyFontColor, NanoGold),
                    new StyleProperty(Label.StylePropertyFont, notoSansDisplayBold14),
                }),
                // Window background.
                new StyleRule(
                    new SelectorElement(null, new[] { SS14Window.StyleClassWindowPanel }, null, null),
                    new[]
                {
                    new StyleProperty(PanelContainer.StylePropertyPanel, windowBackground),
                }),
                // bordered window background
                new StyleRule(
                    new SelectorElement(null, new[] { StyleClassBorderedWindowPanel }, null, null),
                    new[]
                {
                    new StyleProperty(PanelContainer.StylePropertyPanel, borderedWindowBackground),
                }),
                new StyleRule(
                    new SelectorElement(null, new[] { StyleClassTransparentBorderedWindowPanel }, null, null),
                    new[]
                {
                    new StyleProperty(PanelContainer.StylePropertyPanel, borderedTransparentWindowBackground),
                }),
                // inventory slot background
                new StyleRule(
                    new SelectorElement(null, new[] { StyleClassInventorySlotBackground }, null, null),
                    new[]
                {
                    new StyleProperty(PanelContainer.StylePropertyPanel, invSlotBg),
                }),
                // hand slot highlight
                new StyleRule(
                    new SelectorElement(null, new[] { StyleClassHandSlotHighlight }, null, null),
                    new[]
                {
                    new StyleProperty(PanelContainer.StylePropertyPanel, handSlotHighlight),
                }),
                // Hotbar background
                new StyleRule(new SelectorElement(typeof(PanelContainer), new[] { StyleClassHotbarPanel }, null, null),
                              new[]
                {
                    new StyleProperty(PanelContainer.StylePropertyPanel, hotbarBackground),
                }),
                // Window header.
                new StyleRule(
                    new SelectorElement(typeof(PanelContainer), new[] { SS14Window.StyleClassWindowHeader }, null, null),
                    new[]
                {
                    new StyleProperty(PanelContainer.StylePropertyPanel, windowHeader),
                }),

                // Shapes for the buttons.
                Element <ContainerButton>().Class(ContainerButton.StyleClassButton)
                .Prop(ContainerButton.StylePropertyStyleBox, BaseButton),

                Element <ContainerButton>().Class(ContainerButton.StyleClassButton)
                .Class(ButtonOpenRight)
                .Prop(ContainerButton.StylePropertyStyleBox, BaseButtonOpenRight),

                Element <ContainerButton>().Class(ContainerButton.StyleClassButton)
                .Class(ButtonOpenLeft)
                .Prop(ContainerButton.StylePropertyStyleBox, BaseButtonOpenLeft),

                Element <ContainerButton>().Class(ContainerButton.StyleClassButton)
                .Class(ButtonOpenBoth)
                .Prop(ContainerButton.StylePropertyStyleBox, BaseButtonOpenBoth),

                Element <ContainerButton>().Class(ContainerButton.StyleClassButton)
                .Class(ButtonSquare)
                .Prop(ContainerButton.StylePropertyStyleBox, BaseButtonSquare),

                new StyleRule(new SelectorElement(typeof(Label), new[] { Button.StyleClassButton }, null, null), new[]
                {
                    new StyleProperty(Label.StylePropertyAlignMode, Label.AlignMode.Center),
                }),

                // Colors for the buttons.
                Element <ContainerButton>().Class(ContainerButton.StyleClassButton)
                .Pseudo(ContainerButton.StylePseudoClassNormal)
                .Prop(Control.StylePropertyModulateSelf, ButtonColorDefault),

                Element <ContainerButton>().Class(ContainerButton.StyleClassButton)
                .Pseudo(ContainerButton.StylePseudoClassHover)
                .Prop(Control.StylePropertyModulateSelf, ButtonColorHovered),

                Element <ContainerButton>().Class(ContainerButton.StyleClassButton)
                .Pseudo(ContainerButton.StylePseudoClassPressed)
                .Prop(Control.StylePropertyModulateSelf, ButtonColorPressed),

                Element <ContainerButton>().Class(ContainerButton.StyleClassButton)
                .Pseudo(ContainerButton.StylePseudoClassDisabled)
                .Prop(Control.StylePropertyModulateSelf, ButtonColorDisabled),

                // Colors for the caution buttons.
                Element <ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonCaution)
                .Pseudo(ContainerButton.StylePseudoClassNormal)
                .Prop(Control.StylePropertyModulateSelf, ButtonColorCautionDefault),

                Element <ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonCaution)
                .Pseudo(ContainerButton.StylePseudoClassHover)
                .Prop(Control.StylePropertyModulateSelf, ButtonColorCautionHovered),

                Element <ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonCaution)
                .Pseudo(ContainerButton.StylePseudoClassPressed)
                .Prop(Control.StylePropertyModulateSelf, ButtonColorCautionPressed),

                Element <ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonCaution)
                .Pseudo(ContainerButton.StylePseudoClassDisabled)
                .Prop(Control.StylePropertyModulateSelf, ButtonColorCautionDisabled),

                new StyleRule(new SelectorChild(
                                  new SelectorElement(typeof(Button), null, null, new[] { ContainerButton.StylePseudoClassDisabled }),
                                  new SelectorElement(typeof(Label), null, null, null)),
                              new[]
                {
                    new StyleProperty("font-color", Color.FromHex("#E5E5E581")),
                }),

                // action slot hotbar buttons
                new StyleRule(new SelectorElement(typeof(ActionSlot), null, null, new[] { ContainerButton.StylePseudoClassNormal }), new[]
                {
                    new StyleProperty(PanelContainer.StylePropertyPanel, buttonRect),
                }),
                new StyleRule(new SelectorElement(typeof(ActionSlot), null, null, new[] { ContainerButton.StylePseudoClassHover }), new[]
                {
                    new StyleProperty(PanelContainer.StylePropertyPanel, buttonRectHover),
                }),
                new StyleRule(new SelectorElement(typeof(ActionSlot), null, null, new[] { ContainerButton.StylePseudoClassPressed }), new[]
                {
                    new StyleProperty(PanelContainer.StylePropertyPanel, buttonRectPressed),
                }),
                new StyleRule(new SelectorElement(typeof(ActionSlot), null, null, new[] { ContainerButton.StylePseudoClassDisabled }), new[]
                {
                    new StyleProperty(PanelContainer.StylePropertyPanel, buttonRectDisabled),
                }),

                // action menu item buttons
                new StyleRule(new SelectorElement(typeof(ActionMenuItem), null, null, new[] { ContainerButton.StylePseudoClassNormal }), new[]
                {
                    new StyleProperty(ContainerButton.StylePropertyStyleBox, buttonRectActionMenuItem),
                }),
                // we don't actually disable the action menu items, only change their style based on the underlying action being revoked
                new StyleRule(new SelectorElement(typeof(ActionMenuItem), new [] { StyleClassActionMenuItemRevoked }, null, new[] { ContainerButton.StylePseudoClassNormal }), new[]
                {
                    new StyleProperty(ContainerButton.StylePropertyStyleBox, buttonRectActionMenuItemRevoked),
                }),
                new StyleRule(new SelectorElement(typeof(ActionMenuItem), null, null, new[] { ContainerButton.StylePseudoClassHover }), new[]
                {
                    new StyleProperty(ContainerButton.StylePropertyStyleBox, buttonRectActionMenuItemHover),
                }),
                new StyleRule(new SelectorElement(typeof(ActionMenuItem), null, null, new[] { ContainerButton.StylePseudoClassPressed }), new[]
                {
                    new StyleProperty(ContainerButton.StylePropertyStyleBox, buttonRectActionMenuItemPressed),
                }),

                // Main menu: Make those buttons bigger.
                new StyleRule(new SelectorChild(
                                  new SelectorElement(typeof(Button), null, "mainMenu", null),
                                  new SelectorElement(typeof(Label), null, null, null)),
                              new[]
                {
                    new StyleProperty("font", notoSansBold16),
                }),

                // Main menu: also make those buttons slightly more separated.
                new StyleRule(new SelectorElement(typeof(BoxContainer), null, "mainMenuVBox", null),
                              new[]
                {
                    new StyleProperty(BoxContainer.StylePropertySeparation, 2),
                }),

                // Fancy LineEdit
                new StyleRule(new SelectorElement(typeof(LineEdit), null, null, null),
                              new[]
                {
                    new StyleProperty(LineEdit.StylePropertyStyleBox, lineEdit),
                }),

                new StyleRule(
                    new SelectorElement(typeof(LineEdit), new[] { LineEdit.StyleClassLineEditNotEditable }, null, null),
                    new[]
                {
                    new StyleProperty("font-color", new Color(192, 192, 192)),
                }),

                new StyleRule(
                    new SelectorElement(typeof(LineEdit), null, null, new[] { LineEdit.StylePseudoClassPlaceholder }),
                    new[]
                {
                    new StyleProperty("font-color", Color.Gray),
                }),

                // Action searchbox lineedit
                new StyleRule(new SelectorElement(typeof(LineEdit), new[] { StyleClassActionSearchBox }, null, null),
                              new[]
                {
                    new StyleProperty(LineEdit.StylePropertyStyleBox, actionSearchBox),
                }),

                // TabContainer
                new StyleRule(new SelectorElement(typeof(TabContainer), null, null, null),
                              new[]
                {
                    new StyleProperty(TabContainer.StylePropertyPanelStyleBox, tabContainerPanel),
                    new StyleProperty(TabContainer.StylePropertyTabStyleBox, tabContainerBoxActive),
                    new StyleProperty(TabContainer.StylePropertyTabStyleBoxInactive, tabContainerBoxInactive),
                }),

                // ProgressBar
                new StyleRule(new SelectorElement(typeof(ProgressBar), null, null, null),
                              new[]
                {
                    new StyleProperty(ProgressBar.StylePropertyBackground, progressBarBackground),
                    new StyleProperty(ProgressBar.StylePropertyForeground, progressBarForeground)
                }),

                // CheckBox
                new StyleRule(new SelectorElement(typeof(TextureRect), new [] { CheckBox.StyleClassCheckBox }, null, null), new[]
                {
                    new StyleProperty(TextureRect.StylePropertyTexture, checkBoxTextureUnchecked),
                }),

                new StyleRule(new SelectorElement(typeof(TextureRect), new [] { CheckBox.StyleClassCheckBox, CheckBox.StyleClassCheckBoxChecked }, null, null), new[]
                {
                    new StyleProperty(TextureRect.StylePropertyTexture, checkBoxTextureChecked),
                }),

                new StyleRule(new SelectorElement(typeof(HBoxContainer), new [] { CheckBox.StyleClassCheckBox }, null, null), new[]
                {
                    new StyleProperty(BoxContainer.StylePropertySeparation, 10),
                }),

                // Tooltip
                new StyleRule(new SelectorElement(typeof(Tooltip), null, null, null), new[]
                {
                    new StyleProperty(PanelContainer.StylePropertyPanel, tooltipBox)
                }),

                new StyleRule(new SelectorElement(typeof(PanelContainer), new [] { StyleClassTooltipPanel }, null, null), new[]
                {
                    new StyleProperty(PanelContainer.StylePropertyPanel, tooltipBox)
                }),

                new StyleRule(new SelectorElement(typeof(PanelContainer), new[] { "speechBox", "sayBox" }, null, null), new[]
                {
                    new StyleProperty(PanelContainer.StylePropertyPanel, tooltipBox)
                }),

                new StyleRule(new SelectorChild(
                                  new SelectorElement(typeof(PanelContainer), new[] { "speechBox", "emoteBox" }, null, null),
                                  new SelectorElement(typeof(RichTextLabel), null, null, null)),
                              new[]
                {
                    new StyleProperty("font", notoSansItalic12),
                }),

                // alert tooltip
                new StyleRule(new SelectorElement(typeof(RichTextLabel), new[] { StyleClassTooltipAlertTitle }, null, null), new[]
                {
                    new StyleProperty("font", notoSansBold18)
                }),
                new StyleRule(new SelectorElement(typeof(RichTextLabel), new[] { StyleClassTooltipAlertDescription }, null, null), new[]
                {
                    new StyleProperty("font", notoSans16)
                }),
                new StyleRule(new SelectorElement(typeof(RichTextLabel), new[] { StyleClassTooltipAlertCooldown }, null, null), new[]
                {
                    new StyleProperty("font", notoSans16)
                }),

                // action tooltip
                new StyleRule(new SelectorElement(typeof(RichTextLabel), new[] { StyleClassTooltipActionTitle }, null, null), new[]
                {
                    new StyleProperty("font", notoSansBold16)
                }),
                new StyleRule(new SelectorElement(typeof(RichTextLabel), new[] { StyleClassTooltipActionDescription }, null, null), new[]
                {
                    new StyleProperty("font", notoSans15)
                }),
                new StyleRule(new SelectorElement(typeof(RichTextLabel), new[] { StyleClassTooltipActionCooldown }, null, null), new[]
                {
                    new StyleProperty("font", notoSans15)
                }),
                new StyleRule(new SelectorElement(typeof(RichTextLabel), new[] { StyleClassTooltipActionRequirements }, null, null), new[]
                {
                    new StyleProperty("font", notoSans15)
                }),

                // small number for the context menu
                new StyleRule(new SelectorElement(typeof(Label), new[] { StyleClassContextMenuCount }, null, null), new[]
                {
                    new StyleProperty("font", notoSans10),
                    new StyleProperty(Label.StylePropertyAlignMode, Label.AlignMode.Right),
                }),

                // hotbar slot
                new StyleRule(new SelectorElement(typeof(RichTextLabel), new[] { StyleClassHotbarSlotNumber }, null, null), new[]
                {
                    new StyleProperty("font", notoSansDisplayBold16)
                }),

                // Entity tooltip
                new StyleRule(
                    new SelectorElement(typeof(PanelContainer), new[] { ExamineSystem.StyleClassEntityTooltip }, null,
                                        null), new[]
                {
                    new StyleProperty(PanelContainer.StylePropertyPanel, tooltipBox)
                }),

                // ItemList
                new StyleRule(new SelectorElement(typeof(ItemList), null, null, null), new[]
                {
                    new StyleProperty(ItemList.StylePropertyBackground,
                                      new StyleBoxFlat {
                        BackgroundColor = new Color(32, 32, 40)
                    }),
                    new StyleProperty(ItemList.StylePropertyItemBackground,
                                      itemListItemBackground),
                    new StyleProperty(ItemList.StylePropertyDisabledItemBackground,
                                      itemListItemBackgroundDisabled),
                    new StyleProperty(ItemList.StylePropertySelectedItemBackground,
                                      itemListBackgroundSelected)
                }),

                new StyleRule(new SelectorElement(typeof(ItemList), new[] { "transparentItemList" }, null, null), new[]
                {
                    new StyleProperty(ItemList.StylePropertyBackground,
                                      new StyleBoxFlat {
                        BackgroundColor = Color.Transparent
                    }),
                    new StyleProperty(ItemList.StylePropertyItemBackground,
                                      itemListItemBackgroundTransparent),
                    new StyleProperty(ItemList.StylePropertyDisabledItemBackground,
                                      itemListItemBackgroundDisabled),
                    new StyleProperty(ItemList.StylePropertySelectedItemBackground,
                                      itemListBackgroundSelected)
                }),

                // Tree
                new StyleRule(new SelectorElement(typeof(Tree), null, null, null), new[]
                {
                    new StyleProperty(Tree.StylePropertyBackground,
                                      new StyleBoxFlat {
                        BackgroundColor = new Color(32, 32, 40)
                    }),
                    new StyleProperty(Tree.StylePropertyItemBoxSelected, new StyleBoxFlat
                    {
                        BackgroundColor           = new Color(55, 55, 68),
                        ContentMarginLeftOverride = 4
                    })
                }),

                // Placeholder
                new StyleRule(new SelectorElement(typeof(Placeholder), null, null, null), new[]
                {
                    new StyleProperty(PanelContainer.StylePropertyPanel, placeholder),
                }),

                new StyleRule(
                    new SelectorElement(typeof(Label), new[] { Placeholder.StyleClassPlaceholderText }, null, null), new[]
                {
                    new StyleProperty(Label.StylePropertyFont, notoSans16),
                    new StyleProperty(Label.StylePropertyFontColor, new Color(103, 103, 103, 128)),
                }),

                // Big Label
                new StyleRule(new SelectorElement(typeof(Label), new[] { StyleClassLabelHeading }, null, null), new[]
                {
                    new StyleProperty(Label.StylePropertyFont, notoSansBold16),
                    new StyleProperty(Label.StylePropertyFontColor, NanoGold),
                }),

                // Bigger Label
                new StyleRule(new SelectorElement(typeof(Label), new[] { StyleClassLabelHeadingBigger }, null, null),
                              new[]
                {
                    new StyleProperty(Label.StylePropertyFont, notoSansBold20),
                    new StyleProperty(Label.StylePropertyFontColor, NanoGold),
                }),

                // Small Label
                new StyleRule(new SelectorElement(typeof(Label), new[] { StyleClassLabelSubText }, null, null), new[]
                {
                    new StyleProperty(Label.StylePropertyFont, notoSans10),
                    new StyleProperty(Label.StylePropertyFontColor, Color.DarkGray),
                }),

                // Label Key
                new StyleRule(new SelectorElement(typeof(Label), new[] { StyleClassLabelKeyText }, null, null), new[]
                {
                    new StyleProperty(Label.StylePropertyFont, notoSansBold12),
                    new StyleProperty(Label.StylePropertyFontColor, NanoGold)
                }),

                new StyleRule(new SelectorElement(typeof(Label), new[] { StyleClassLabelSecondaryColor }, null, null),
                              new[]
                {
                    new StyleProperty(Label.StylePropertyFont, notoSans12),
                    new StyleProperty(Label.StylePropertyFontColor, Color.DarkGray),
                }),

                // Big Button
                new StyleRule(new SelectorChild(
                                  new SelectorElement(typeof(Button), new[] { StyleClassButtonBig }, null, null),
                                  new SelectorElement(typeof(Label), null, null, null)),
                              new[]
                {
                    new StyleProperty("font", notoSans16)
                }),

                // Popup messages
                new StyleRule(new SelectorElement(typeof(Label), new[] { StyleClassPopupMessage }, null, null),
                              new[]
                {
                    new StyleProperty("font", notoSansItalic10),
                    new StyleProperty("font-color", Color.LightGray),
                }),

                //APC and SMES power state label colors
                new StyleRule(new SelectorElement(typeof(Label), new[] { StyleClassPowerStateNone }, null, null), new[]
                {
                    new StyleProperty(Label.StylePropertyFontColor, new Color(0.8f, 0.0f, 0.0f))
                }),

                new StyleRule(new SelectorElement(typeof(Label), new[] { StyleClassPowerStateLow }, null, null), new[]
                {
                    new StyleProperty(Label.StylePropertyFontColor, new Color(0.9f, 0.36f, 0.0f))
                }),

                new StyleRule(new SelectorElement(typeof(Label), new[] { StyleClassPowerStateGood }, null, null), new[]
                {
                    new StyleProperty(Label.StylePropertyFontColor, new Color(0.024f, 0.8f, 0.0f))
                }),

                // Those top menu buttons.
                // these use slight variations on the various BaseButton styles so that the content within them appears centered,
                // which is NOT the case for the default BaseButton styles (OpenLeft/OpenRight adds extra padding on one of the sides
                // which makes the TopButton icons appear off-center, which we don't want).
                new StyleRule(
                    new SelectorElement(typeof(GameHud.TopButton), new[] { ButtonSquare }, null, null),
                    new[]
                {
                    new StyleProperty(Button.StylePropertyStyleBox, topButtonSquare),
                }),

                new StyleRule(
                    new SelectorElement(typeof(GameHud.TopButton), new[] { ButtonOpenLeft }, null, null),
                    new[]
                {
                    new StyleProperty(Button.StylePropertyStyleBox, topButtonOpenLeft),
                }),

                new StyleRule(
                    new SelectorElement(typeof(GameHud.TopButton), new[] { ButtonOpenRight }, null, null),
                    new[]
                {
                    new StyleProperty(Button.StylePropertyStyleBox, topButtonOpenRight),
                }),

                new StyleRule(
                    new SelectorElement(typeof(GameHud.TopButton), null, null, new[] { Button.StylePseudoClassNormal }),
                    new[]
                {
                    new StyleProperty(Button.StylePropertyModulateSelf, ButtonColorDefault),
                }),

                new StyleRule(
                    new SelectorElement(typeof(GameHud.TopButton), new[] { GameHud.TopButton.StyleClassRedTopButton }, null, new[] { Button.StylePseudoClassNormal }),
                    new[]
                {
                    new StyleProperty(Button.StylePropertyModulateSelf, ButtonColorDefaultRed),
                }),

                new StyleRule(
                    new SelectorElement(typeof(GameHud.TopButton), null, null, new[] { Button.StylePseudoClassNormal }),
                    new[]
                {
                    new StyleProperty(Button.StylePropertyModulateSelf, ButtonColorDefault),
                }),

                new StyleRule(
                    new SelectorElement(typeof(GameHud.TopButton), null, null, new[] { Button.StylePseudoClassPressed }),
                    new[]
                {
                    new StyleProperty(Button.StylePropertyModulateSelf, ButtonColorPressed),
                }),

                new StyleRule(
                    new SelectorElement(typeof(GameHud.TopButton), null, null, new[] { Button.StylePseudoClassHover }),
                    new[]
                {
                    new StyleProperty(Button.StylePropertyModulateSelf, ButtonColorHovered),
                }),

                new StyleRule(
                    new SelectorElement(typeof(GameHud.TopButton), new[] { GameHud.TopButton.StyleClassRedTopButton }, null, new[] { Button.StylePseudoClassHover }),
                    new[]
                {
                    new StyleProperty(Button.StylePropertyModulateSelf, ButtonColorHoveredRed),
                }),

                new StyleRule(
                    new SelectorElement(typeof(Label), new[] { GameHud.TopButton.StyleClassLabelTopButton }, null, null),
                    new[]
                {
                    new StyleProperty(Label.StylePropertyFont, notoSansDisplayBold14),
                }),

                // Targeting doll

                new StyleRule(
                    new SelectorElement(typeof(TextureButton), new[] { TargetingDoll.StyleClassTargetDollZone }, null,
                                        new[] { TextureButton.StylePseudoClassNormal }), new[]
                {
                    new StyleProperty(Control.StylePropertyModulateSelf, ButtonColorDefault),
                }),

                new StyleRule(
                    new SelectorElement(typeof(TextureButton), new[] { TargetingDoll.StyleClassTargetDollZone }, null,
                                        new[] { TextureButton.StylePseudoClassHover }), new[]
                {
                    new StyleProperty(Control.StylePropertyModulateSelf, ButtonColorHovered),
                }),

                new StyleRule(
                    new SelectorElement(typeof(TextureButton), new[] { TargetingDoll.StyleClassTargetDollZone }, null,
                                        new[] { TextureButton.StylePseudoClassPressed }), new[]
                {
                    new StyleProperty(Control.StylePropertyModulateSelf, ButtonColorPressed),
                }),

                // NanoHeading

                new StyleRule(
                    new SelectorChild(
                        SelectorElement.Type(typeof(NanoHeading)),
                        SelectorElement.Type(typeof(PanelContainer))),
                    new[]
                {
                    new StyleProperty(PanelContainer.StylePropertyPanel, nanoHeadingBox),
                }),

                // StripeBack
                new StyleRule(
                    SelectorElement.Type(typeof(StripeBack)),
                    new[]
                {
                    new StyleProperty(StripeBack.StylePropertyBackground, stripeBack),
                }),

                // StyleClassLabelBig
                new StyleRule(
                    SelectorElement.Class(StyleClassLabelBig),
                    new[]
                {
                    new StyleProperty("font", notoSans16),
                }),

                // StyleClassItemStatus
                new StyleRule(SelectorElement.Class(StyleClassItemStatus), new[]
                {
                    new StyleProperty("font", notoSans10),
                }),

                // Slider
                new StyleRule(SelectorElement.Type(typeof(Slider)), new []
                {
                    new StyleProperty(Slider.StylePropertyBackground, sliderBackBox),
                    new StyleProperty(Slider.StylePropertyForeground, sliderForeBox),
                    new StyleProperty(Slider.StylePropertyGrabber, sliderGrabBox),
                    new StyleProperty(Slider.StylePropertyFill, sliderFillBox),
                }),

                new StyleRule(new SelectorElement(typeof(Slider), new [] { StyleClassSliderRed }, null, null), new []
                {
                    new StyleProperty(Slider.StylePropertyFill, sliderFillRed),
                }),

                new StyleRule(new SelectorElement(typeof(Slider), new [] { StyleClassSliderGreen }, null, null), new []
                {
                    new StyleProperty(Slider.StylePropertyFill, sliderFillGreen),
                }),

                new StyleRule(new SelectorElement(typeof(Slider), new [] { StyleClassSliderBlue }, null, null), new []
                {
                    new StyleProperty(Slider.StylePropertyFill, sliderFillBlue),
                }),

                // OptionButton
                new StyleRule(new SelectorElement(typeof(OptionButton), null, null, null), new[]
                {
                    new StyleProperty(ContainerButton.StylePropertyStyleBox, BaseButton),
                }),
                new StyleRule(new SelectorElement(typeof(OptionButton), null, null, new[] { ContainerButton.StylePseudoClassNormal }), new[]
                {
                    new StyleProperty(Control.StylePropertyModulateSelf, ButtonColorDefault),
                }),
                new StyleRule(new SelectorElement(typeof(OptionButton), null, null, new[] { ContainerButton.StylePseudoClassHover }), new[]
                {
                    new StyleProperty(Control.StylePropertyModulateSelf, ButtonColorHovered),
                }),
                new StyleRule(new SelectorElement(typeof(OptionButton), null, null, new[] { ContainerButton.StylePseudoClassPressed }), new[]
                {
                    new StyleProperty(Control.StylePropertyModulateSelf, ButtonColorPressed),
                }),
                new StyleRule(new SelectorElement(typeof(OptionButton), null, null, new[] { ContainerButton.StylePseudoClassDisabled }), new[]
                {
                    new StyleProperty(Control.StylePropertyModulateSelf, ButtonColorDisabled),
                }),

                new StyleRule(new SelectorElement(typeof(TextureRect), new[] { OptionButton.StyleClassOptionTriangle }, null, null), new[]
                {
                    new StyleProperty(TextureRect.StylePropertyTexture, textureInvertedTriangle),
                    //new StyleProperty(Control.StylePropertyModulateSelf, Color.FromHex("#FFFFFF")),
                }),

                new StyleRule(new SelectorElement(typeof(Label), new[] { OptionButton.StyleClassOptionButton }, null, null), new[]
                {
                    new StyleProperty(Label.StylePropertyAlignMode, Label.AlignMode.Center),
                }),

                new StyleRule(new SelectorElement(typeof(PanelContainer), new [] { ClassHighDivider }, null, null), new []
                {
                    new StyleProperty(PanelContainer.StylePropertyPanel, new StyleBoxFlat {
                        BackgroundColor = NanoGold, ContentMarginBottomOverride = 2, ContentMarginLeftOverride = 2
                    }),
                }),

                Element <PanelContainer>().Class(ClassAngleRect)
                .Prop(PanelContainer.StylePropertyPanel, BaseAngleRect)
                .Prop(Control.StylePropertyModulateSelf, Color.FromHex("#25252A")),
            }).ToList());
        }
Ejemplo n.º 10
0
Archivo: FileLog.cs Proyecto: vokac/F2B
        public FileLogInput(InputElement input, SelectorElement selector, EventQueue equeue)
            : base(input, selector, equeue)
        {
            filename = input.LogPath;
            interval = input.Interval;
            onlyWatcher = false;
            active = false;

            List<Regex> tmpMatch = new List<Regex>();
            List<Regex> tmpIgnore = new List<Regex>();
            foreach (RegexpElement ree in selector.Regexps)
            {
                Regex re = new Regex(ree.Value, RegexOptions.Singleline);
                switch (ree.Type)
                {
                    case "match": tmpMatch.Add(re); break;
                    case "ignore": tmpIgnore.Add(re); break;
                    default: throw new Exception("unknown regex type: " + ree.Type);
                }
            }
            match = tmpMatch.ToArray();
            ignore = tmpMatch.ToArray();

            if (interval <= 0)
            {
                onlyWatcher = true;
            }

            // Create a new FileSystemWatcher and set its properties.
            watcher = new FileSystemWatcher();
            watcher.Path = Path.GetDirectoryName(filename);
            watcher.Filter = Path.GetFileName(filename);
            // Watch for changes (assuming we are monitoring log file
            // where we just append data to the end of the file)
            watcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.DirectoryName;

            // Add event handlers.
            watcher.Created += new FileSystemEventHandler((s, e) => FileWatcherReplaced(s, e));
            watcher.Deleted += new FileSystemEventHandler((s, e) => FileWatcherReplaced(s, e));
            watcher.Renamed += new RenamedEventHandler((s, e) => FileWatcherReplaced(s, e));

            if (onlyWatcher)
            {
                watcher.NotifyFilter |= NotifyFilters.Size;
                watcher.Changed += new FileSystemEventHandler((s, e) => FileWatcherChanged(s, e));
                // Increase size of internal buffer used to monitor all changes in given directory.
                // It can help not to loose change events in case of heavy activity in log
                // directory - it is probably better not to use this watcher for changes
                // in monitored file by setting interval to some reasonable number (e.g.
                // 1000 microseconds), because of better reliability. This buffer is using
                // non-swappable memory (be careful with its size)
                //watcher.InternalBufferSize *= 16;

                // signal used to synchronize event processing deactivation with
                // currently running ProcessLines code
                exit = new AutoResetEvent(false);
            }
            else
            {
                // signal used to interupt waiting line processing thread
                wait = new AutoResetEvent(false);
            }
        }
Ejemplo n.º 11
0
        public EventLogInput(InputElement input, SelectorElement selector, EventQueue equeue)
            : base(input, selector, equeue)
        {
            Log.Info("input[" + InputName + "]/selector[" + SelectorName
                     + "] creating EventLogInput");

            // Event log query with suppressed events logged by this service
            StringBuilder qstr = new StringBuilder();

            qstr.Append("<QueryList>");
            qstr.Append("<Query>");
            qstr.Append(selector.Query.Value);
            qstr.Append("<Suppress Path=\"Application\">*[System/Provider/@Name=\"F2B\"]</Suppress>");
            qstr.Append("</Query>");
            qstr.Append("</QueryList>");

            EventLogSession session = null;

            if (input.Server != string.Empty)
            {
                SecureString pw = new SecureString();
                Array.ForEach(input.Password.ToCharArray(), pw.AppendChar);
                session = new EventLogSession(input.Server, input.Domain,
                                              input.Username, pw,
                                              SessionAuthentication.Default);
                pw.Dispose();
            }

            EventLogQuery query = new EventLogQuery(null, PathType.LogName, qstr.ToString());

            if (session != null)
            {
                query.Session = session;
            }

            // create event watcher (must be enable later)
            watcher = new EventLogWatcher(query);
            watcher.EventRecordWritten +=
                new EventHandler <EventRecordWrittenEventArgs>(
                    (s, a) => EventRead(s, a));

            // event data parsers (e.g. XPath + regex to extract event data)
            // (it is important to preserve order - it is later used as array index)
            evtregexs = new List <EventLogParserData>();
            List <string> xPathRefs = new List <string>();

            foreach (RegexElement item in selector.Regexes)
            {
                if (string.IsNullOrEmpty(item.XPath))
                {
                    Log.Warn("Invalid input[" + InputName + "]/selector[" + SelectorName
                             + "] event regexp \"" + item.Id + "\" attribute xpath empty");

                    continue;
                }

                if (!xPathRefs.Contains(item.XPath))
                {
                    xPathRefs.Add(item.XPath);
                }

                try
                {
                    int index = xPathRefs.IndexOf(item.XPath);
                    EventLogParserData eli = new EventLogParserData(item.Id, item.Type, item.XPath, index, item.Value);
                    evtregexs.Add(eli);
                }
                catch (ArgumentException ex)
                {
                    Log.Error("Invalid input[" + InputName + "]/selector[" + SelectorName
                              + "] event regexp failed: " + ex.Message);

                    throw;
                }
            }

            evtsel = null;
            if (xPathRefs.Count > 0)
            {
                evtsel = new EventLogPropertySelector(xPathRefs);
            }

            // user defined event properties
            evtdata_before = new List <EventDataElement>();
            evtdata_match  = new List <KeyValuePair <string, EventDataElement> >();
            evtdata_after  = new List <EventDataElement>();
            foreach (EventDataElement item in selector.EventData)
            {
                if (item.Apply == "before")
                {
                    evtdata_before.Add(item);
                }
                else if (item.Apply == "after")
                {
                    evtdata_after.Add(item);
                }
                else if (item.Apply.StartsWith("match."))
                {
                    string key = item.Apply.Substring("match.".Length);
                    evtdata_match.Add(new KeyValuePair <string, EventDataElement>(key, item));
                }
                else
                {
                    Log.Warn("Invalid input[" + InputName + "]/selector[" + SelectorName
                             + "] event data \"" + item.Name + "\" attribute apply \""
                             + item.Apply + "\": ignoring this item");
                }
            }
        }
Ejemplo n.º 12
0
        public FileLogInput(InputElement input, SelectorElement selector, EventQueue equeue)
            : base(input, selector, equeue)
        {
            Log.Info("input[" + InputName + "]/selector[" + SelectorName
                     + "] creating FileLogInput");

            filename    = input.LogPath;
            interval    = input.Interval;
            onlyWatcher = false;
            active      = false;

            List <Regex> tmpMatch  = new List <Regex>();
            List <Regex> tmpIgnore = new List <Regex>();
            List <Tuple <string, Regex> > tmpData = new List <Tuple <string, Regex> >();

            foreach (RegexElement ree in selector.Regexes)
            {
                Regex re = new Regex(ree.Value, RegexOptions.Singleline);
                switch (ree.Type)
                {
                case "match": tmpMatch.Add(re); break;

                case "ignore": tmpIgnore.Add(re); break;

                case "data": tmpData.Add(new Tuple <string, Regex>(ree.Id, re)); break;

                default: throw new Exception("unknown regex type: " + ree.Type);
                }
            }
            match  = tmpMatch.ToArray();
            ignore = tmpIgnore.ToArray();
            data   = tmpData.ToArray();

            if (interval <= 0)
            {
                onlyWatcher = true;
            }

            // Create a new FileSystemWatcher and set its properties.
            watcher        = new FileSystemWatcher();
            watcher.Path   = Path.GetDirectoryName(filename);
            watcher.Filter = Path.GetFileName(filename);
            // Watch for changes (assuming we are monitoring log file
            // where we just append data to the end of the file)
            watcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.DirectoryName;

            // Add event handlers.
            watcher.Created += new FileSystemEventHandler((s, e) => FileWatcherReplaced(s, e));
            watcher.Deleted += new FileSystemEventHandler((s, e) => FileWatcherReplaced(s, e));
            watcher.Renamed += new RenamedEventHandler((s, e) => FileWatcherReplaced(s, e));

            if (onlyWatcher)
            {
                watcher.NotifyFilter |= NotifyFilters.Size;
                watcher.Changed      += new FileSystemEventHandler((s, e) => FileWatcherChanged(s, e));
                // Increase size of internal buffer used to monitor all changes in given directory.
                // It can help not to loose change events in case of heavy activity in log
                // directory - it is probably better not to use this watcher for changes
                // in monitored file by setting interval to some reasonable number (e.g.
                // 1000 microseconds), because of better reliability. This buffer is using
                // non-swappable memory (be careful with its size)
                //watcher.InternalBufferSize *= 16;

                // signal used to synchronize event processing deactivation with
                // currently running ProcessLines code
                exit = new AutoResetEvent(false);
            }
            else
            {
                // signal used to interupt waiting line processing thread
                wait = new AutoResetEvent(false);
            }

            // user defined event properties
            evtdata_before = new List <EventDataElement>();
            evtdata_match  = new Dictionary <string, EventDataElement>();
            evtdata_after  = new List <EventDataElement>();
            foreach (EventDataElement item in selector.EventData)
            {
                if (item.Apply == "before")
                {
                    evtdata_before.Add(item);
                }
                else if (item.Apply == "after")
                {
                    evtdata_after.Add(item);
                }
                else if (item.Apply.StartsWith("match."))
                {
                    evtdata_match[item.Apply.Substring("match.".Length)] = item;
                }
                else
                {
                    Log.Warn("Invalid input[" + InputName + "]/selector[" + SelectorName
                             + "] event data \"" + item.Name + "\" attribute apply \""
                             + item.Apply + "\": ignoring this item");
                }
            }
        }