Esempio n. 1
0
        public override void ApplyStyle(GUIComponentStyle componentStyle)
        {
            if (componentStyle == null)
            {
                return;
            }
            base.ApplyStyle(componentStyle);
            padding = componentStyle.Padding;

            textColor         = componentStyle.TextColor;
            hoverTextColor    = componentStyle.HoverTextColor;
            disabledTextColor = componentStyle.DisabledTextColor;
            selectedTextColor = componentStyle.SelectedTextColor;

            switch (componentStyle.Font)
            {
            case "font":
                Font = componentStyle.Style.Font;
                break;

            case "smallfont":
                Font = componentStyle.Style.SmallFont;
                break;

            case "largefont":
                Font = componentStyle.Style.LargeFont;
                break;

            case "objectivetitle":
            case "subheading":
                Font = componentStyle.Style.SubHeadingFont;
                break;
            }
        }
Esempio n. 2
0
        public GUIStyle(XElement element, GraphicsDevice graphicsDevice)
        {
            this.graphicsDevice = graphicsDevice;
            componentStyles     = new Dictionary <string, GUIComponentStyle>();
            configElement       = element;
            foreach (XElement subElement in configElement.Elements())
            {
                switch (subElement.Name.ToString().ToLowerInvariant())
                {
                case "cursor":
                    CursorSprite = new Sprite(subElement);
                    break;

                case "uiglow":
                    UIGlow = new UISprite(subElement);
                    break;

                case "focusindicator":
                    FocusIndicator = new SpriteSheet(subElement);
                    break;

                case "font":
                    Font = LoadFont(subElement, graphicsDevice);
                    break;

                case "unscaledsmallfont":
                    UnscaledSmallFont = LoadFont(subElement, graphicsDevice);
                    break;

                case "smallfont":
                    SmallFont = LoadFont(subElement, graphicsDevice);
                    break;

                case "largefont":
                    LargeFont = LoadFont(subElement, graphicsDevice);
                    break;

                case "objectivetitle":
                    ObjectiveTitleFont = LoadFont(subElement, graphicsDevice);
                    break;

                case "objectivename":
                    ObjectiveNameFont = LoadFont(subElement, graphicsDevice);
                    break;

                case "videotitle":
                    VideoTitleFont = LoadFont(subElement, graphicsDevice);
                    break;

                default:
                    GUIComponentStyle componentStyle = new GUIComponentStyle(subElement);
                    componentStyles.Add(subElement.Name.ToString().ToLowerInvariant(), componentStyle);
                    break;
                }
            }

            GameMain.Instance.OnResolutionChanged += () => { RescaleFonts(); };
        }
Esempio n. 3
0
        public override void ApplyStyle(GUIComponentStyle style)
        {
            base.ApplyStyle(style);

            if (frame != null)
            {
                frame.ApplyStyle(style);
            }
        }
Esempio n. 4
0
        private static GUIFrame LoadGUIFrame(XElement element, RectTransform parent)
        {
            string style = element.GetAttributeString("style", element.Name.ToString().ToLowerInvariant() == "spacing" ? null : "");

            if (style == "null")
            {
                style = null;
            }
            return(new GUIFrame(RectTransform.Load(element, parent), style: style));
        }
Esempio n. 5
0
        public override void ApplyStyle(GUIComponentStyle style)
        {
            if (style == null)
            {
                return;
            }
            base.ApplyStyle(style);

            textColor = style.textColor;
        }
Esempio n. 6
0
        private static GUIListBox LoadGUIListBox(XElement element, RectTransform parent)
        {
            string style = element.GetAttributeString("style", "");

            if (style == "null")
            {
                style = null;
            }
            bool isHorizontal = element.GetAttributeBool("ishorizontal", !element.GetAttributeBool("isvertical", true));

            return(new GUIListBox(RectTransform.Load(element, parent), isHorizontal, style: style));
        }
Esempio n. 7
0
        public GUIStyle(string file, GraphicsDevice graphicsDevice)
        {
            componentStyles = new Dictionary <string, GUIComponentStyle>();

            XDocument doc;

            try
            {
                ToolBox.IsProperFilenameCase(file);
                doc = XDocument.Load(file, LoadOptions.SetBaseUri);
            }
            catch (Exception e)
            {
                DebugConsole.ThrowError("Loading style \"" + file + "\" failed", e);
                return;
            }

            foreach (XElement subElement in doc.Root.Elements())
            {
                switch (subElement.Name.ToString().ToLowerInvariant())
                {
                case "font":
                    Font = new ScalableFont(subElement, graphicsDevice);
                    break;

                case "smallfont":
                    SmallFont = new ScalableFont(subElement, graphicsDevice);
                    break;

                case "largefont":
                    LargeFont = new ScalableFont(subElement, graphicsDevice);
                    break;

                case "cursor":
                    CursorSprite = new Sprite(subElement);
                    break;

                case "uiglow":
                    UIGlow = new UISprite(subElement);
                    break;

                case "focusindicator":
                    FocusIndicator = new SpriteSheet(subElement);
                    break;

                default:
                    GUIComponentStyle componentStyle = new GUIComponentStyle(subElement);
                    componentStyles.Add(subElement.Name.ToString().ToLowerInvariant(), componentStyle);
                    break;
                }
            }
        }
Esempio n. 8
0
        public virtual void ApplyStyle(GUIComponentStyle style)
        {
            if (style == null)
            {
                return;
            }

            color         = style.Color;
            hoverColor    = style.HoverColor;
            selectedColor = style.SelectedColor;
            pressedColor  = style.PressedColor;

            sprites = style.Sprites;

            OutlineColor = style.OutlineColor;

            this.style = style;
        }
Esempio n. 9
0
        public void Apply(GUIComponent targetComponent, string styleName = "", GUIComponent parent = null)
        {
            GUIComponentStyle componentStyle = null;

            if (parent != null)
            {
                GUIComponentStyle parentStyle = parent.Style;

                if (parent.Style == null)
                {
                    string parentStyleName = parent.GetType().Name.ToLowerInvariant();

                    if (!componentStyles.TryGetValue(parentStyleName, out parentStyle))
                    {
                        DebugConsole.ThrowError("Couldn't find a GUI style \"" + parentStyleName + "\"");
                        return;
                    }
                }


                string childStyleName = string.IsNullOrEmpty(styleName) ? targetComponent.GetType().Name : styleName;
                parentStyle.ChildStyles.TryGetValue(childStyleName.ToLowerInvariant(), out componentStyle);
            }
            else
            {
                if (string.IsNullOrEmpty(styleName))
                {
                    styleName = targetComponent.GetType().Name;
                }
                if (!componentStyles.TryGetValue(styleName.ToLowerInvariant(), out componentStyle))
                {
                    DebugConsole.ThrowError("Couldn't find a GUI style \"" + styleName + "\"");
                    return;
                }
            }

            targetComponent.ApplyStyle(componentStyle);
        }
Esempio n. 10
0
        public GUIStyle(string file)
        {
            componentStyles = new Dictionary <string, GUIComponentStyle>();

            XDocument doc;

            try
            {
                ToolBox.IsProperFilenameCase(file);
                doc = XDocument.Load(file);
            }
            catch (Exception e)
            {
                DebugConsole.ThrowError("Loading style \"" + file + "\" failed", e);
                return;
            }

            foreach (XElement subElement in doc.Root.Elements())
            {
                GUIComponentStyle componentStyle = new GUIComponentStyle(subElement);
                componentStyles.Add(subElement.Name.ToString().ToLowerInvariant(), componentStyle);
            }
        }
Esempio n. 11
0
        private static GUIButton LoadGUIButton(XElement element, RectTransform parent)
        {
            string style = element.GetAttributeString("style", "");

            if (style == "null")
            {
                style = null;
            }

            Alignment textAlignment = Alignment.Center;

            Enum.TryParse(element.GetAttributeString("textalignment", "Center"), out textAlignment);

            string text = element.Attribute("text") == null?
                          element.ElementInnerText() :
                              element.GetAttributeString("text", "");

            text = text.Replace(@"\n", "\n");

            return(new GUIButton(RectTransform.Load(element, parent),
                                 text: text,
                                 textAlignment: textAlignment,
                                 style: style));
        }
Esempio n. 12
0
        private void DrawConnection(SpriteBatch spriteBatch, LocationConnection connection, Rectangle viewArea, Vector2 viewOffset, Color?overrideColor = null)
        {
            Color connectionColor;

            if (GameMain.DebugDraw)
            {
                float sizeFactor = MathUtils.InverseLerp(
                    generationParams.SmallLevelConnectionLength,
                    generationParams.LargeLevelConnectionLength,
                    connection.Length);
                connectionColor = ToolBox.GradientLerp(sizeFactor, Color.LightGreen, GUI.Style.Orange, GUI.Style.Red);
            }
            else if (overrideColor.HasValue)
            {
                connectionColor = overrideColor.Value;
            }
            else
            {
                connectionColor = connection.Passed ? generationParams.ConnectionColor : generationParams.UnvisitedConnectionColor;
            }

            int width = (int)(generationParams.LocationConnectionWidth * zoom);

            if (Level.Loaded?.LevelData == connection.LevelData)
            {
                connectionColor = generationParams.HighlightedConnectionColor;
                width           = (int)(width * 1.5f);
            }
            if (SelectedLocation != CurrentDisplayLocation &&
                (connection.Locations.Contains(SelectedLocation) && connection.Locations.Contains(CurrentDisplayLocation)))
            {
                connectionColor = generationParams.HighlightedConnectionColor;
                width          *= 2;
            }
            else if (HighlightedLocation != CurrentDisplayLocation &&
                     (connection.Locations.Contains(HighlightedLocation) && connection.Locations.Contains(CurrentDisplayLocation)))
            {
                connectionColor = generationParams.HighlightedConnectionColor;
                width          *= 2;
            }

            Vector2 rectCenter = viewArea.Center.ToVector2();

            int startIndex = connection.CrackSegments.Count > 2 ? 1 : 0;
            int endIndex   = connection.CrackSegments.Count > 2 ? connection.CrackSegments.Count - 1 : connection.CrackSegments.Count;

            Vector2?connectionStart = null;
            Vector2?connectionEnd   = null;

            for (int i = startIndex; i < endIndex; i++)
            {
                var segment = connection.CrackSegments[i];

                Vector2 start = rectCenter + (segment[0] + viewOffset) * zoom;
                if (!connectionStart.HasValue)
                {
                    connectionStart = start;
                }
                Vector2 end = rectCenter + (segment[1] + viewOffset) * zoom;
                connectionEnd = end;

                if (!viewArea.Contains(start) && !viewArea.Contains(end))
                {
                    continue;
                }
                else
                {
                    if (MathUtils.GetLineRectangleIntersection(start, end, new Rectangle(viewArea.X, viewArea.Y + viewArea.Height, viewArea.Width, viewArea.Height), out Vector2 intersection))
                    {
                        if (!viewArea.Contains(start))
                        {
                            start = intersection;
                        }
                        else
                        {
                            end = intersection;
                        }
                    }
                }

                float a = 1.0f;
                if (!connection.Locations[0].Discovered && !connection.Locations[1].Discovered)
                {
                    if (IsInFogOfWar(connection.Locations[0]))
                    {
                        a = (float)i / connection.CrackSegments.Count;
                    }
                    else if (IsInFogOfWar(connection.Locations[1]))
                    {
                        a = 1.0f - (float)i / connection.CrackSegments.Count;
                    }
                }
                float dist             = Vector2.Distance(start, end);
                var   connectionSprite = connection.Passed ? generationParams.PassedConnectionSprite : generationParams.ConnectionSprite;
                spriteBatch.Draw(connectionSprite.Texture,
                                 new Rectangle((int)start.X, (int)start.Y, (int)(dist - 1 * zoom), width),
                                 connectionSprite.SourceRect, connectionColor * a, MathUtils.VectorToAngle(end - start),
                                 new Vector2(0, connectionSprite.size.Y / 2), SpriteEffects.None, 0.01f);
            }
            if (connectionStart.HasValue && connectionEnd.HasValue)
            {
                GUIComponentStyle crushDepthWarningIconStyle = null;
                string            tooltip = null;
                var subCrushDepth         = Submarine.MainSub?.RealWorldCrushDepth ?? Level.DefaultRealWorldCrushDepth;
                if (GameMain.GameSession?.Campaign?.UpgradeManager != null)
                {
                    var hullUpgradePrefab = UpgradePrefab.Find("increasewallhealth");
                    if (hullUpgradePrefab != null)
                    {
                        int pendingLevel = GameMain.GameSession.Campaign.UpgradeManager.GetUpgradeLevel(hullUpgradePrefab, hullUpgradePrefab.UpgradeCategories.First());
                        int currentLevel = GameMain.GameSession.Campaign.UpgradeManager.GetRealUpgradeLevel(hullUpgradePrefab, hullUpgradePrefab.UpgradeCategories.First());
                        if (pendingLevel > currentLevel)
                        {
                            string updateValueStr = hullUpgradePrefab.SourceElement?.Element("Structure")?.GetAttributeString("crushdepth", null);
                            if (!string.IsNullOrEmpty(updateValueStr))
                            {
                                subCrushDepth = PropertyReference.CalculateUpgrade(subCrushDepth, pendingLevel - currentLevel, updateValueStr);
                            }
                        }
                    }
                }

                if (connection.LevelData.InitialDepth * Physics.DisplayToRealWorldRatio > subCrushDepth)
                {
                    crushDepthWarningIconStyle = GUI.Style.GetComponentStyle("CrushDepthWarningHighIcon");
                    tooltip = "crushdepthwarninghigh";
                }
                else if ((connection.LevelData.InitialDepth + connection.LevelData.Size.Y) * Physics.DisplayToRealWorldRatio > subCrushDepth)
                {
                    crushDepthWarningIconStyle = GUI.Style.GetComponentStyle("CrushDepthWarningLowIcon");
                    tooltip = "crushdepthwarninglow";
                }

                if (crushDepthWarningIconStyle != null)
                {
                    Vector2 iconPos  = (connectionStart.Value + connectionEnd.Value) / 2;
                    float   iconSize = 32.0f * GUI.Scale;
                    bool    mouseOn  = HighlightedLocation == null && Vector2.DistanceSquared(iconPos, PlayerInput.MousePosition) < iconSize * iconSize;
                    Sprite  crushDepthWarningIcon = crushDepthWarningIconStyle.GetDefaultSprite();
                    crushDepthWarningIcon.Draw(spriteBatch, iconPos,
                                               mouseOn ? crushDepthWarningIconStyle.HoverColor : crushDepthWarningIconStyle.Color,
                                               scale: iconSize / crushDepthWarningIcon.size.X);
                    if (mouseOn)
                    {
                        connectionTooltip = new Pair <Rectangle, string>(
                            new Rectangle(iconPos.ToPoint(), new Point((int)iconSize)),
                            TextManager.Get(tooltip)
                            .Replace("[initialdepth]", ((int)(connection.LevelData.InitialDepth * Physics.DisplayToRealWorldRatio)).ToString())
                            .Replace("[submarinecrushdepth]", ((int)subCrushDepth).ToString()));
                    }
                }
            }

            if (GameMain.DebugDraw && zoom > 1.0f && generationParams.ShowLevelTypeNames)
            {
                Vector2 center = rectCenter + (connection.CenterPos + viewOffset) * zoom;
                if (viewArea.Contains(center) && connection.Biome != null)
                {
                    GUI.DrawString(spriteBatch, center, connection.Biome.Identifier + " (" + connection.Difficulty + ")", Color.White);
                }
            }
        }
Esempio n. 13
0
        public GUIStyle(string file, GraphicsDevice graphicsDevice)
        {
            this.graphicsDevice = graphicsDevice;
            componentStyles     = new Dictionary <string, GUIComponentStyle>();

            XDocument doc;

            try
            {
                ToolBox.IsProperFilenameCase(file);
                doc = XDocument.Load(file, LoadOptions.SetBaseUri);
                if (doc == null)
                {
                    throw new Exception("doc is null");
                }
                if (doc.Root == null)
                {
                    throw new Exception("doc.Root is null");
                }
                if (doc.Root.Elements() == null)
                {
                    throw new Exception("doc.Root.Elements() is null");
                }
            }
            catch (Exception e)
            {
                DebugConsole.ThrowError("Loading style \"" + file + "\" failed", e);
                return;
            }
            configElement = doc.Root;
            foreach (XElement subElement in doc.Root.Elements())
            {
                switch (subElement.Name.ToString().ToLowerInvariant())
                {
                case "cursor":
                    CursorSprite = new Sprite(subElement);
                    break;

                case "uiglow":
                    UIGlow = new UISprite(subElement);
                    break;

                case "focusindicator":
                    FocusIndicator = new SpriteSheet(subElement);
                    break;

                case "font":
                    Font = LoadFont(subElement, graphicsDevice);
                    break;

                case "unscaledsmallfont":
                    UnscaledSmallFont = LoadFont(subElement, graphicsDevice);
                    break;

                case "smallfont":
                    SmallFont = LoadFont(subElement, graphicsDevice);
                    break;

                case "largefont":
                    LargeFont = LoadFont(subElement, graphicsDevice);
                    break;

                case "objectivetitle":
                    ObjectiveTitleFont = LoadFont(subElement, graphicsDevice);
                    break;

                case "objectivename":
                    ObjectiveNameFont = LoadFont(subElement, graphicsDevice);
                    break;

                case "videotitle":
                    VideoTitleFont = LoadFont(subElement, graphicsDevice);
                    break;

                default:
                    GUIComponentStyle componentStyle = new GUIComponentStyle(subElement);
                    componentStyles.Add(subElement.Name.ToString().ToLowerInvariant(), componentStyle);
                    break;
                }
            }

            GameMain.Instance.OnResolutionChanged += () => { RescaleFonts(); };
        }
        public GUIComponentStyle(XElement element, GUIStyle style)
        {
            Name = element.Name.LocalName;

            Style   = style;
            Element = element;

            Sprites = new Dictionary <GUIComponent.ComponentState, List <UISprite> >();
            foreach (GUIComponent.ComponentState state in Enum.GetValues(typeof(GUIComponent.ComponentState)))
            {
                Sprites[state] = new List <UISprite>();
            }

            ChildStyles = new Dictionary <string, GUIComponentStyle>();

            Padding = element.GetAttributeVector4("padding", Vector4.Zero);

            Color         = element.GetAttributeColor("color", Color.Transparent);
            HoverColor    = element.GetAttributeColor("hovercolor", Color);
            SelectedColor = element.GetAttributeColor("selectedcolor", Color);
            DisabledColor = element.GetAttributeColor("disabledcolor", Color);
            PressedColor  = element.GetAttributeColor("pressedcolor", Color);
            OutlineColor  = element.GetAttributeColor("outlinecolor", Color.Transparent);

            TextColor           = element.GetAttributeColor("textcolor", Color.Black);
            HoverTextColor      = element.GetAttributeColor("hovertextcolor", TextColor);
            DisabledTextColor   = element.GetAttributeColor("disabledtextcolor", TextColor);
            SelectedTextColor   = element.GetAttributeColor("selectedtextcolor", TextColor);
            SpriteCrossFadeTime = element.GetAttributeFloat("spritefadetime", SpriteCrossFadeTime);
            ColorCrossFadeTime  = element.GetAttributeFloat("colorfadetime", ColorCrossFadeTime);

            if (Enum.TryParse(element.GetAttributeString("colortransition", string.Empty), ignoreCase: true, out TransitionMode transition))
            {
                TransitionMode = transition;
            }
            if (Enum.TryParse(element.GetAttributeString("fallbackstate", GUIComponent.ComponentState.None.ToString()), ignoreCase: true, out SpriteFallBackState s))
            {
                FallBackState = s;
            }

            Font           = element.GetAttributeString("font", "");
            ForceUpperCase = element.GetAttributeBool("forceuppercase", false);

            foreach (XElement subElement in element.Elements())
            {
                switch (subElement.Name.ToString().ToLowerInvariant())
                {
                case "sprite":
                    UISprite newSprite = new UISprite(subElement);

                    GUIComponent.ComponentState spriteState = GUIComponent.ComponentState.None;
                    if (subElement.Attribute("state") != null)
                    {
                        string stateStr = subElement.GetAttributeString("state", "None");
                        Enum.TryParse(stateStr, out spriteState);
                        Sprites[spriteState].Add(newSprite);
                        //use the same sprite for Hover and HoverSelected if latter is not specified
                        if (spriteState == GUIComponent.ComponentState.HoverSelected && !Sprites.ContainsKey(GUIComponent.ComponentState.HoverSelected))
                        {
                            Sprites[GUIComponent.ComponentState.HoverSelected].Add(newSprite);
                        }
                    }
                    else
                    {
                        foreach (GUIComponent.ComponentState state in Enum.GetValues(typeof(GUIComponent.ComponentState)))
                        {
                            Sprites[state].Add(newSprite);
                        }
                    }
                    break;

                case "size":
                    break;

                default:
                    string styleName = subElement.Name.ToString().ToLowerInvariant();
                    if (ChildStyles.ContainsKey(styleName))
                    {
                        DebugConsole.ThrowError("UI style \"" + element.Name.ToString() + "\" contains multiple child styles with the same name (\"" + styleName + "\")!");
                        ChildStyles[styleName] = new GUIComponentStyle(subElement, style);
                    }
                    else
                    {
                        ChildStyles.Add(styleName, new GUIComponentStyle(subElement, style));
                    }
                    break;
                }
            }

            GetSize(element);
        }
Esempio n. 15
0
        private static GUITextBlock LoadGUITextBlock(XElement element, RectTransform parent, string overrideText = null, Anchor?anchor = null)
        {
            string text = overrideText ??
                          (element.Attribute("text") == null ?
                           element.ElementInnerText() :
                           element.GetAttributeString("text", ""));

            text = text.Replace(@"\n", "\n");

            string style = element.GetAttributeString("style", "");

            if (style == "null")
            {
                style = null;
            }
            Color?color = null;

            if (element.Attribute("color") != null)
            {
                color = element.GetAttributeColor("color", Color.White);
            }
            float     scale     = element.GetAttributeFloat("scale", 1.0f);
            bool      wrap      = element.GetAttributeBool("wrap", true);
            Alignment alignment = Alignment.Center;

            Enum.TryParse(element.GetAttributeString("alignment", "Center"), out alignment);
            ScalableFont font = GUI.Font;

            switch (element.GetAttributeString("font", "Font").ToLowerInvariant())
            {
            case "font":
                font = GUI.Font;
                break;

            case "smallfont":
                font = GUI.SmallFont;
                break;

            case "largefont":
                font = GUI.LargeFont;
                break;

            case "videotitlefont":
                font = GUI.VideoTitleFont;
                break;

            case "objectivetitlefont":
                font = GUI.ObjectiveTitleFont;
                break;

            case "objectivenamefont":
                font = GUI.ObjectiveNameFont;
                break;
            }

            var textBlock = new GUITextBlock(RectTransform.Load(element, parent),
                                             text, color, font, alignment, wrap: wrap, style: style)
            {
                TextScale = scale
            };

            if (anchor.HasValue)
            {
                textBlock.RectTransform.SetPosition(anchor.Value);
            }
            textBlock.RectTransform.IsFixedSize   = true;
            textBlock.RectTransform.NonScaledSize = new Point(textBlock.Rect.Width, textBlock.Rect.Height);
            return(textBlock);
        }
Esempio n. 16
0
        public GUIStyle(XElement element, GraphicsDevice graphicsDevice)
        {
            this.graphicsDevice = graphicsDevice;
            componentStyles     = new Dictionary <string, GUIComponentStyle>();
            configElement       = element;
            foreach (XElement subElement in configElement.Elements())
            {
                var name = subElement.Name.ToString().ToLowerInvariant();
                switch (name)
                {
                case "cursor":
                    if (subElement.HasElements)
                    {
                        foreach (var children in subElement.Descendants())
                        {
                            var index = children.GetAttributeInt("state", (int)CursorState.Default);
                            CursorSprite[index] = new Sprite(children);
                        }
                    }
                    else
                    {
                        CursorSprite[(int)CursorState.Default] = new Sprite(subElement);
                    }
                    break;

                case "green":
                    Green = subElement.GetAttributeColor("color", Green);
                    break;

                case "orange":
                    Orange = subElement.GetAttributeColor("color", Orange);
                    break;

                case "red":
                    Red = subElement.GetAttributeColor("color", Red);
                    break;

                case "blue":
                    Blue = subElement.GetAttributeColor("color", Blue);
                    break;

                case "yellow":
                    Yellow = subElement.GetAttributeColor("color", Yellow);
                    break;

                case "colorinventoryempty":
                    ColorInventoryEmpty = subElement.GetAttributeColor("color", ColorInventoryEmpty);
                    break;

                case "colorinventoryhalf":
                    ColorInventoryHalf = subElement.GetAttributeColor("color", ColorInventoryHalf);
                    break;

                case "colorinventoryfull":
                    ColorInventoryFull = subElement.GetAttributeColor("color", ColorInventoryFull);
                    break;

                case "colorinventorybackground":
                    ColorInventoryBackground = subElement.GetAttributeColor("color", ColorInventoryBackground);
                    break;

                case "colorinventoryemptyoverlay":
                    ColorInventoryEmptyOverlay = subElement.GetAttributeColor("color", ColorInventoryEmptyOverlay);
                    break;

                case "textcolordark":
                    TextColorDark = subElement.GetAttributeColor("color", TextColorDark);
                    break;

                case "textcolorbright":
                    TextColorBright = subElement.GetAttributeColor("color", TextColorBright);
                    break;

                case "textcolordim":
                    TextColorDim = subElement.GetAttributeColor("color", TextColorDim);
                    break;

                case "textcolornormal":
                case "textcolor":
                    TextColor = subElement.GetAttributeColor("color", TextColor);
                    break;

                case "colorreputationverylow":
                    ColorReputationVeryLow = subElement.GetAttributeColor("color", TextColor);
                    break;

                case "colorreputationlow":
                    ColorReputationLow = subElement.GetAttributeColor("color", TextColor);
                    break;

                case "colorreputationneutral":
                    ColorReputationNeutral = subElement.GetAttributeColor("color", TextColor);
                    break;

                case "colorreputationhigh":
                    ColorReputationHigh = subElement.GetAttributeColor("color", TextColor);
                    break;

                case "colorreputationveryhigh":
                    ColorReputationVeryHigh = subElement.GetAttributeColor("color", TextColor);
                    break;

                case "equipmentsloticoncolor":
                    EquipmentSlotIconColor = subElement.GetAttributeColor("color", EquipmentSlotIconColor);
                    break;

                case "buffcolorlow":
                    BuffColorLow = subElement.GetAttributeColor("color", BuffColorLow);
                    break;

                case "buffcolormedium":
                    BuffColorMedium = subElement.GetAttributeColor("color", BuffColorMedium);
                    break;

                case "buffcolorhigh":
                    BuffColorHigh = subElement.GetAttributeColor("color", BuffColorHigh);
                    break;

                case "debuffcolorlow":
                    DebuffColorLow = subElement.GetAttributeColor("color", DebuffColorLow);
                    break;

                case "debuffcolormedium":
                    DebuffColorMedium = subElement.GetAttributeColor("color", DebuffColorMedium);
                    break;

                case "debuffcolorhigh":
                    DebuffColorHigh = subElement.GetAttributeColor("color", DebuffColorHigh);
                    break;

                case "healthbarcolorlow":
                    HealthBarColorLow = subElement.GetAttributeColor("color", HealthBarColorLow);
                    break;

                case "healthbarcolormedium":
                    HealthBarColorMedium = subElement.GetAttributeColor("color", HealthBarColorMedium);
                    break;

                case "healthbarcolorhigh":
                    HealthBarColorHigh = subElement.GetAttributeColor("color", HealthBarColorHigh);
                    break;

                case "equipmentindicatornotequipped":
                    EquipmentIndicatorNotEquipped = subElement.GetAttributeColor("color", EquipmentIndicatorNotEquipped);
                    break;

                case "equipmentindicatorequipped":
                    EquipmentIndicatorEquipped = subElement.GetAttributeColor("color", EquipmentIndicatorEquipped);
                    break;

                case "equipmentindicatorrunningout":
                    EquipmentIndicatorRunningOut = subElement.GetAttributeColor("color", EquipmentIndicatorRunningOut);
                    break;

                case "uiglow":
                    UIGlow = new UISprite(subElement);
                    break;

                case "pingcircle":
                    PingCircle = new UISprite(subElement);
                    break;

                case "radiation":
                    RadiationSprite = new UISprite(subElement);
                    break;

                case "radiationanimspritesheet":
                    RadiationAnimSpriteSheet = new SpriteSheet(subElement);
                    break;

                case "uiglowcircular":
                    UIGlowCircular = new UISprite(subElement);
                    break;

                case "uiglowsolidcircular":
                    UIGlowSolidCircular = new UISprite(subElement);
                    break;

                case "uithermalglow":
                    UIThermalGlow = new UISprite(subElement);
                    break;

                case "endroundbuttonpulse":
                    ButtonPulse = new UISprite(subElement);
                    break;

                case "iconoverflowindicator":
                    IconOverflowIndicator = new UISprite(subElement);
                    break;

                case "focusindicator":
                    FocusIndicator = new SpriteSheet(subElement);
                    break;

                case "savingindicator":
                    SavingIndicator = new SpriteSheet(subElement);
                    break;

                case "font":
                    Font = LoadFont(subElement, graphicsDevice);
                    ForceFontUpperCase[Font] = subElement.GetAttributeBool("forceuppercase", false);
                    break;

                case "globalfont":
                    GlobalFont = LoadFont(subElement, graphicsDevice);
                    ForceFontUpperCase[GlobalFont] = subElement.GetAttributeBool("forceuppercase", false);
                    break;

                case "unscaledsmallfont":
                    UnscaledSmallFont = LoadFont(subElement, graphicsDevice);
                    ForceFontUpperCase[UnscaledSmallFont] = subElement.GetAttributeBool("forceuppercase", false);
                    break;

                case "smallfont":
                    SmallFont = LoadFont(subElement, graphicsDevice);
                    ForceFontUpperCase[SmallFont] = subElement.GetAttributeBool("forceuppercase", false);
                    break;

                case "largefont":
                    LargeFont = LoadFont(subElement, graphicsDevice);
                    ForceFontUpperCase[LargeFont] = subElement.GetAttributeBool("forceuppercase", false);
                    break;

                case "digitalfont":
                    DigitalFont = LoadFont(subElement, graphicsDevice);
                    ForceFontUpperCase[DigitalFont] = subElement.GetAttributeBool("forceuppercase", false);
                    break;

                case "monospacedfont":
                    MonospacedFont = LoadFont(subElement, graphicsDevice);
                    ForceFontUpperCase[MonospacedFont] = subElement.GetAttributeBool("forceuppercase", false);
                    break;

                case "hotkeyfont":
                    HotkeyFont = LoadFont(subElement, graphicsDevice);
                    ForceFontUpperCase[HotkeyFont] = subElement.GetAttributeBool("forceuppercase", false);
                    break;

                case "objectivetitle":
                case "subheading":
                    SubHeadingFont = LoadFont(subElement, graphicsDevice);
                    ForceFontUpperCase[SubHeadingFont] = subElement.GetAttributeBool("forceuppercase", false);
                    break;

                default:
                    GUIComponentStyle componentStyle = new GUIComponentStyle(subElement, this);
                    componentStyles.Add(subElement.Name.ToString().ToLowerInvariant(), componentStyle);
                    break;
                }
            }

            if (GlobalFont == null)
            {
                GlobalFont = Font;
                DebugConsole.NewMessage("Global font not defined in the current UI style file. The global font is used to render western symbols when using Chinese/Japanese/Korean localization. Using default font instead...", Color.Orange);
            }

            // TODO: Needs to unregister if we ever remove GUIStyles.
            GameMain.Instance.ResolutionChanged += RescaleElements;
        }
Esempio n. 17
0
        public override void ApplyStyle(GUIComponentStyle style)
        {
            base.ApplyStyle(style);

            frame?.ApplyStyle(style);
        }