StyleSpace.cs 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. using System.Linq;
  2. using Content.Client.Resources;
  3. using Robust.Client.Graphics;
  4. using Robust.Client.ResourceManagement;
  5. using Robust.Client.UserInterface;
  6. using Robust.Client.UserInterface.Controls;
  7. using static Robust.Client.UserInterface.StylesheetHelpers;
  8. namespace Content.Client.Stylesheets
  9. {
  10. public sealed class StyleSpace : StyleBase
  11. {
  12. public static readonly Color SpaceRed = Color.FromHex("#9b2236");
  13. public static readonly Color ButtonColorDefault = Color.FromHex("#464966");
  14. public static readonly Color ButtonColorHovered = Color.FromHex("#575b7f");
  15. public static readonly Color ButtonColorPressed = Color.FromHex("#3e6c45");
  16. public static readonly Color ButtonColorDisabled = Color.FromHex("#30313c");
  17. public static readonly Color ButtonColorCautionDefault = Color.FromHex("#ab3232");
  18. public static readonly Color ButtonColorCautionHovered = Color.FromHex("#cf2f2f");
  19. public static readonly Color ButtonColorCautionPressed = Color.FromHex("#3e6c45");
  20. public static readonly Color ButtonColorCautionDisabled = Color.FromHex("#602a2a");
  21. public override Stylesheet Stylesheet { get; }
  22. public StyleSpace(IResourceCache resCache) : base(resCache)
  23. {
  24. var notoSans10 = resCache.GetFont
  25. (
  26. new []
  27. {
  28. "/Fonts/NotoSans/NotoSans-Regular.ttf",
  29. "/Fonts/NotoSans/NotoSansSymbols-Regular.ttf",
  30. "/Fonts/NotoSans/NotoSansSymbols2-Regular.ttf"
  31. },
  32. 10
  33. );
  34. var notoSansBold16 = resCache.GetFont
  35. (
  36. new []
  37. {
  38. "/Fonts/NotoSans/NotoSans-Bold.ttf",
  39. "/Fonts/NotoSans/NotoSansSymbols-Regular.ttf",
  40. "/Fonts/NotoSans/NotoSansSymbols2-Regular.ttf"
  41. },
  42. 16
  43. );
  44. var progressBarBackground = new StyleBoxFlat
  45. {
  46. BackgroundColor = new Color(0.25f, 0.25f, 0.25f)
  47. };
  48. progressBarBackground.SetContentMarginOverride(StyleBox.Margin.Vertical, 14.5f);
  49. var progressBarForeground = new StyleBoxFlat
  50. {
  51. BackgroundColor = new Color(0.25f, 0.50f, 0.25f)
  52. };
  53. progressBarForeground.SetContentMarginOverride(StyleBox.Margin.Vertical, 14.5f);
  54. var textureInvertedTriangle = resCache.GetTexture("/Textures/Interface/Nano/inverted_triangle.svg.png");
  55. var tabContainerPanel = new StyleBoxTexture();
  56. tabContainerPanel.SetPatchMargin(StyleBox.Margin.All, 2);
  57. var tabContainerBoxActive = new StyleBoxFlat {BackgroundColor = new Color(64, 64, 64)};
  58. tabContainerBoxActive.SetContentMarginOverride(StyleBox.Margin.Horizontal, 5);
  59. var tabContainerBoxInactive = new StyleBoxFlat {BackgroundColor = new Color(32, 32, 32)};
  60. tabContainerBoxInactive.SetContentMarginOverride(StyleBox.Margin.Horizontal, 5);
  61. Stylesheet = new Stylesheet(BaseRules.Concat(new StyleRule[]
  62. {
  63. Element<Label>().Class(StyleClassLabelHeading)
  64. .Prop(Label.StylePropertyFont, notoSansBold16)
  65. .Prop(Label.StylePropertyFontColor, SpaceRed),
  66. Element<Label>().Class(StyleClassLabelSubText)
  67. .Prop(Label.StylePropertyFont, notoSans10)
  68. .Prop(Label.StylePropertyFontColor, Color.DarkGray),
  69. Element<PanelContainer>().Class(ClassHighDivider)
  70. .Prop(PanelContainer.StylePropertyPanel, new StyleBoxFlat
  71. {
  72. BackgroundColor = SpaceRed, ContentMarginBottomOverride = 2, ContentMarginLeftOverride = 2
  73. }),
  74. Element<PanelContainer>().Class(ClassLowDivider)
  75. .Prop(PanelContainer.StylePropertyPanel, new StyleBoxFlat
  76. {
  77. BackgroundColor = Color.FromHex("#444"),
  78. ContentMarginLeftOverride = 2,
  79. ContentMarginBottomOverride = 2
  80. }),
  81. // Shapes for the buttons.
  82. Element<ContainerButton>().Class(ContainerButton.StyleClassButton)
  83. .Prop(ContainerButton.StylePropertyStyleBox, BaseButton),
  84. Element<ContainerButton>().Class(ContainerButton.StyleClassButton)
  85. .Class(ButtonOpenRight)
  86. .Prop(ContainerButton.StylePropertyStyleBox, BaseButtonOpenRight),
  87. Element<ContainerButton>().Class(ContainerButton.StyleClassButton)
  88. .Class(ButtonOpenLeft)
  89. .Prop(ContainerButton.StylePropertyStyleBox, BaseButtonOpenLeft),
  90. Element<ContainerButton>().Class(ContainerButton.StyleClassButton)
  91. .Class(ButtonOpenBoth)
  92. .Prop(ContainerButton.StylePropertyStyleBox, BaseButtonOpenBoth),
  93. Element<ContainerButton>().Class(ContainerButton.StyleClassButton)
  94. .Class(ButtonSquare)
  95. .Prop(ContainerButton.StylePropertyStyleBox, BaseButtonSquare),
  96. // Colors for the buttons.
  97. Element<ContainerButton>().Class(ContainerButton.StyleClassButton)
  98. .Pseudo(ContainerButton.StylePseudoClassNormal)
  99. .Prop(Control.StylePropertyModulateSelf, ButtonColorDefault),
  100. Element<ContainerButton>().Class(ContainerButton.StyleClassButton)
  101. .Pseudo(ContainerButton.StylePseudoClassHover)
  102. .Prop(Control.StylePropertyModulateSelf, ButtonColorHovered),
  103. Element<ContainerButton>().Class(ContainerButton.StyleClassButton)
  104. .Pseudo(ContainerButton.StylePseudoClassPressed)
  105. .Prop(Control.StylePropertyModulateSelf, ButtonColorPressed),
  106. Element<ContainerButton>().Class(ContainerButton.StyleClassButton)
  107. .Pseudo(ContainerButton.StylePseudoClassDisabled)
  108. .Prop(Control.StylePropertyModulateSelf, ButtonColorDisabled),
  109. // Colors for the caution buttons.
  110. Element<ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonCaution)
  111. .Pseudo(ContainerButton.StylePseudoClassNormal)
  112. .Prop(Control.StylePropertyModulateSelf, ButtonColorCautionDefault),
  113. Element<ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonCaution)
  114. .Pseudo(ContainerButton.StylePseudoClassHover)
  115. .Prop(Control.StylePropertyModulateSelf, ButtonColorCautionHovered),
  116. Element<ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonCaution)
  117. .Pseudo(ContainerButton.StylePseudoClassPressed)
  118. .Prop(Control.StylePropertyModulateSelf, ButtonColorCautionPressed),
  119. Element<ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonCaution)
  120. .Pseudo(ContainerButton.StylePseudoClassDisabled)
  121. .Prop(Control.StylePropertyModulateSelf, ButtonColorCautionDisabled),
  122. Element<Label>().Class(ContainerButton.StyleClassButton)
  123. .Prop(Label.StylePropertyAlignMode, Label.AlignMode.Center),
  124. Element<PanelContainer>().Class(ClassAngleRect)
  125. .Prop(PanelContainer.StylePropertyPanel, BaseAngleRect)
  126. .Prop(Control.StylePropertyModulateSelf, Color.FromHex("#202030")),
  127. Child()
  128. .Parent(Element<Button>().Class(ContainerButton.StylePseudoClassDisabled))
  129. .Child(Element<Label>())
  130. .Prop("font-color", Color.FromHex("#E5E5E581")),
  131. Element<ProgressBar>()
  132. .Prop(ProgressBar.StylePropertyBackground, progressBarBackground)
  133. .Prop(ProgressBar.StylePropertyForeground, progressBarForeground),
  134. // OptionButton
  135. Element<OptionButton>()
  136. .Prop(ContainerButton.StylePropertyStyleBox, BaseButton),
  137. Element<OptionButton>().Pseudo(ContainerButton.StylePseudoClassNormal)
  138. .Prop(Control.StylePropertyModulateSelf, ButtonColorDefault),
  139. Element<OptionButton>().Pseudo(ContainerButton.StylePseudoClassHover)
  140. .Prop(Control.StylePropertyModulateSelf, ButtonColorHovered),
  141. Element<OptionButton>().Pseudo(ContainerButton.StylePseudoClassPressed)
  142. .Prop(Control.StylePropertyModulateSelf, ButtonColorPressed),
  143. Element<OptionButton>().Pseudo(ContainerButton.StylePseudoClassDisabled)
  144. .Prop(Control.StylePropertyModulateSelf, ButtonColorDisabled),
  145. Element<TextureRect>().Class(OptionButton.StyleClassOptionTriangle)
  146. .Prop(TextureRect.StylePropertyTexture, textureInvertedTriangle),
  147. Element<Label>().Class(OptionButton.StyleClassOptionButton)
  148. .Prop(Label.StylePropertyAlignMode, Label.AlignMode.Center),
  149. // TabContainer
  150. new StyleRule(new SelectorElement(typeof(TabContainer), null, null, null),
  151. new[]
  152. {
  153. new StyleProperty(TabContainer.StylePropertyPanelStyleBox, tabContainerPanel),
  154. new StyleProperty(TabContainer.StylePropertyTabStyleBox, tabContainerBoxActive),
  155. new StyleProperty(TabContainer.StylePropertyTabStyleBoxInactive, tabContainerBoxInactive),
  156. }),
  157. }).ToList());
  158. }
  159. }
  160. }