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 "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 "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 "uiglowcircular": UIGlowCircular = new UISprite(subElement); break; case "endroundbuttonpulse": ButtonPulse = new UISprite(subElement); break; case "focusindicator": FocusIndicator = 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 "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; }