diff --git a/Subsurface/Content/UI/UI_Atlas.png b/Subsurface/Content/UI/UI_Atlas.png
index f75200b7d..11b7ac806 100644
Binary files a/Subsurface/Content/UI/UI_Atlas.png and b/Subsurface/Content/UI/UI_Atlas.png differ
diff --git a/Subsurface/Content/UI/style.xml b/Subsurface/Content/UI/style.xml
index 6e34e03f3..2ffc1526e 100644
--- a/Subsurface/Content/UI/style.xml
+++ b/Subsurface/Content/UI/style.xml
@@ -3,74 +3,169 @@
+ textcolor="0.0, 0.0, 0.0, 1.0">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ hovercolor="1.0,1.0,1.0,1.0"
+ selectedcolor="1.0,1.0,1.0,1.0">
-
+
+
+
+
+
+
+ textcolor="1.0, 1.0, 1.0, 1.0">
+
+
+
+
+
+
-
+ padding="10.0, 0.0, 10.0, 0.0">
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
-
+ color="1.0,1.0,1.0,1.0"
+ hovercolor="1.0,1.0,1.0,1.0"
+ selectedcolor="1.0,1.0,1.0,1.0"
+
+ textcolor="0.5, 0.55, 0.6, 1.0">
+
+
+
-
+ color="1.0,1.0,1.0,1.0"
+ hovercolor="1.0,1.0,1.0,1.0"
+ selectedcolor="1.0,1.0,1.0,1.0"
+
+ textcolor="0.5, 0.55, 0.6, 1.0">
+
+
+
-
+ color="1.0,1.0,1.0,1.0"
+ hovercolor="1.0,1.0,1.0,1.0"
+ selectedcolor="1.0,1.0,1.0,1.0" >
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
\ No newline at end of file
diff --git a/Subsurface/Source/GUI/ComponentStyle.cs b/Subsurface/Source/GUI/ComponentStyle.cs
index 850be1572..57f11faf2 100644
--- a/Subsurface/Source/GUI/ComponentStyle.cs
+++ b/Subsurface/Source/GUI/ComponentStyle.cs
@@ -1,4 +1,5 @@
using Microsoft.Xna.Framework;
+using System;
using System.Collections.Generic;
using System.Xml.Linq;
@@ -57,14 +58,21 @@ namespace Barotrauma
public readonly Color OutlineColor;
- public readonly List Sprites;
+ public readonly Dictionary> Sprites;
public readonly bool TileSprites;
+ public Dictionary ChildStyles;
public GUIComponentStyle(XElement element)
{
- Sprites = new List();
+ Sprites = new Dictionary>();
+ foreach (GUIComponent.ComponentState state in Enum.GetValues(typeof(GUIComponent.ComponentState)))
+ {
+ Sprites[state] = new List();
+ }
+
+ ChildStyles = new Dictionary();
Padding = ToolBox.GetAttributeVector4(element, "padding", Vector4.Zero);
@@ -92,6 +100,10 @@ namespace Barotrauma
bool maintainAspect = ToolBox.GetAttributeBool(subElement, "maintainaspectratio",false);
bool tile = ToolBox.GetAttributeBool(subElement, "tile", true);
+ string stateStr = ToolBox.GetAttributeString(subElement, "state", "None");
+ GUIComponent.ComponentState spriteState = GUIComponent.ComponentState.None;
+ Enum.TryParse(stateStr, out spriteState);
+
UISprite newSprite = new UISprite(sprite, tile, maintainAspect);
Vector4 sliceVec = ToolBox.GetAttributeVector4(subElement, "slice", Vector4.Zero);
@@ -125,7 +137,10 @@ namespace Barotrauma
newSprite.Slices[8] = new Rectangle(newSprite.Slices[2].X, slice.Bottom, newSprite.Slices[2].Width, newSprite.Sprite.SourceRect.Bottom - slice.Bottom);
}
- Sprites.Add(newSprite);
+ Sprites[spriteState].Add(newSprite);
+ break;
+ default:
+ ChildStyles.Add(subElement.Name.ToString().ToLowerInvariant(), new GUIComponentStyle(subElement));
break;
}
}
diff --git a/Subsurface/Source/GUI/GUI.cs b/Subsurface/Source/GUI/GUI.cs
index 9505c8ff2..a55453cc6 100644
--- a/Subsurface/Source/GUI/GUI.cs
+++ b/Subsurface/Source/GUI/GUI.cs
@@ -1,7 +1,6 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
-using Microsoft.Xna.Framework.Input;
using System;
using System.Collections.Generic;
@@ -10,10 +9,10 @@ namespace Barotrauma
[Flags]
public enum Alignment
{
- CenterX = 1, Left = 2, Right = 4, CenterY = 8, Top = 16, Bottom = 32 ,
- TopRight = (Top | Right), TopLeft = (Top | Left), TopCenter = (CenterX | Top),
- Center = (CenterX | CenterY),
- BottomRight = (Bottom | Right), BottomLeft = (Bottom | Left), BottomCenter = (CenterX | Bottom)
+ CenterX = 1, Left = 2, Right = 4, CenterY = 8, Top = 16, Bottom = 32,
+ TopLeft = (Top | Left), TopCenter = (CenterX | Top), TopRight = (Top | Right),
+ CenterLeft = (Left | CenterY), Center = (CenterX | CenterY), CenterRight = (Right | CenterY),
+ BottomLeft = (Bottom | Left), BottomCenter = (CenterX | Bottom), BottomRight = (Bottom | Right),
}
public enum GUISoundType
diff --git a/Subsurface/Source/GUI/GUIButton.cs b/Subsurface/Source/GUI/GUIButton.cs
index 7363ed789..3ffcbeefe 100644
--- a/Subsurface/Source/GUI/GUIButton.cs
+++ b/Subsurface/Source/GUI/GUIButton.cs
@@ -155,41 +155,30 @@ namespace Barotrauma
}
public GUIButton(Rectangle rect, string text, Color? color, Alignment alignment, Alignment textAlignment, string style = "", GUIComponent parent = null)
- : base (style)
+ : base(style)
{
this.rect = rect;
- if (color!=null) this.color = (Color)color;
+ if (color != null) this.color = (Color)color;
this.alignment = alignment;
if (parent != null) parent.AddChild(this);
frame = new GUIFrame(Rectangle.Empty, style, this);
- GUI.Style.Apply(frame, style, this);
+ GUI.Style.Apply(frame, style == "" ? "GUIButton" : style);
textBlock = new GUITextBlock(Rectangle.Empty, text,
Color.Transparent, (this.style == null) ? Color.Black : this.style.textColor,
- textAlignment, style, this);
+ textAlignment, null, this);
+ GUI.Style.Apply(textBlock, style, this);
Enabled = true;
}
-
+
public override void Draw(SpriteBatch spriteBatch)
{
if (!Visible) return;
-
- //Color currColor = color;
- //if (state == ComponentState.Hover) currColor = hoverColor;
- //if (state == ComponentState.Selected) currColor = selectedColor;
-
- //GUI.DrawRectangle(spriteBatch, rect, currColor * alpha, true);
-
- ////spriteBatch.DrawString(HUD.font, text, new Vector2(rect.X+rect.Width/2, rect.Y+rect.Height/2), Color.Black, 0.0f, new Vector2(0.5f,0.5f), 1.0f, SpriteEffects.None, 0.0f);
-
- //GUI.DrawRectangle(spriteBatch, rect, Color.Black * alpha, false);
-
+
DrawChildren(spriteBatch);
-
- //if (!Enabled) GUI.DrawRectangle(spriteBatch, rect, Color.Gray*0.5f, true);
}
public override void Update(float deltaTime)
@@ -203,7 +192,7 @@ namespace Barotrauma
{
if (OnPressed != null)
{
- if (OnPressed()) state = ComponentState.Selected;
+ if (OnPressed()) state = ComponentState.Pressed;
}
}
else if (PlayerInput.LeftButtonClicked())
diff --git a/Subsurface/Source/GUI/GUIComponent.cs b/Subsurface/Source/GUI/GUIComponent.cs
index b4f0371c1..22e9dbaef 100644
--- a/Subsurface/Source/GUI/GUIComponent.cs
+++ b/Subsurface/Source/GUI/GUIComponent.cs
@@ -73,7 +73,7 @@ namespace Barotrauma
protected static KeyboardDispatcher keyboardDispatcher;
- public enum ComponentState { None, Hover, Selected};
+ public enum ComponentState { None, Hover, Pressed, Selected };
protected Alignment alignment;
@@ -119,7 +119,7 @@ namespace Barotrauma
public bool TileSprites;
- private GUITextBlock toolTipBlock;
+ private static GUITextBlock toolTipBlock;
//protected float alpha;
@@ -161,7 +161,7 @@ namespace Barotrauma
get { return CanBeFocused ? rect : Rectangle.Empty; }
}
- public List sprites;
+ public Dictionary> sprites;
//public Alignment SpriteAlignment { get; set; }
//public bool RepeatSpriteX, RepeatSpriteY;
@@ -222,8 +222,7 @@ namespace Barotrauma
OutlineColor = Color.Transparent;
Font = GUI.Font;
-
- sprites = new List();
+
children = new List();
CanBeFocused = true;
@@ -286,42 +285,38 @@ namespace Barotrauma
if (state == ComponentState.Selected) currColor = selectedColor;
if (state == ComponentState.Hover) currColor = hoverColor;
- if (flashTimer>0.0f)
+ if (flashTimer > 0.0f)
{
- GUI.DrawRectangle(spriteBatch,
- new Rectangle(rect.X-5,rect.Y-5,rect.Width+10,rect.Height+10),
+ GUI.DrawRectangle(spriteBatch,
+ new Rectangle(rect.X - 5, rect.Y - 5, rect.Width + 10, rect.Height + 10),
flashColor * (flashTimer / FlashDuration), true);
}
- if (currColor.A>0.0f && !sprites.Any()) GUI.DrawRectangle(spriteBatch, rect, currColor * (currColor.A / 255.0f), true);
+ if (currColor.A > 0.0f && (sprites == null || !sprites.Any())) GUI.DrawRectangle(spriteBatch, rect, currColor * (currColor.A / 255.0f), true);
- if (sprites != null && currColor.A > 0.0f)
+ if (sprites != null && sprites[state] != null && currColor.A > 0.0f)
{
- foreach (UISprite uiSprite in sprites)
+ foreach (UISprite uiSprite in sprites[state])
{
if (uiSprite.Slice)
{
Vector2 pos = new Vector2(rect.X, rect.Y);
- int centerWidth = rect.Width - uiSprite.Slices[0].Width - uiSprite.Slices[2].Width;
- int centerHeight = rect.Height - uiSprite.Slices[0].Height - uiSprite.Slices[8].Height;
+ int centerWidth = Math.Max(rect.Width - uiSprite.Slices[0].Width - uiSprite.Slices[2].Width, 0);
+ int centerHeight = Math.Max(rect.Height - uiSprite.Slices[0].Height - uiSprite.Slices[8].Height, 0);
- for (int x = 0; x<3; x++)
+ for (int x = 0; x < 3; x++)
{
int width = x == 1 ? centerWidth : uiSprite.Slices[x].Width;
- for (int y = 0; y<3; y++)
+ for (int y = 0; y < 3; y++)
{
int height = y == 1 ? centerHeight : uiSprite.Slices[x + y * 3].Height;
- //GUI.DrawString(spriteBatch, pos, x + ", " + y, Color.White);
- uiSprite.Sprite.DrawTiled(
- spriteBatch,
- pos,
- new Vector2(width, height),
- Vector2.Zero,
+ spriteBatch.Draw(uiSprite.Sprite.Texture,
+ new Rectangle((int)pos.X, (int)pos.Y, width, height),
uiSprite.Slices[x + y * 3],
currColor * (currColor.A / 255.0f));
-
+
pos.Y += height;
}
pos.X += width;
@@ -366,18 +361,17 @@ namespace Barotrauma
//DrawChildren(spriteBatch);
}
- public void DrawToolTip(SpriteBatch spriteBatch)
+ public void DrawToolTip(SpriteBatch spriteBatch)
{
if (!Visible) return;
int width = 400;
- if (toolTipBlock==null || (string)toolTipBlock.userData != ToolTip)
+ if (toolTipBlock == null || (string)toolTipBlock.userData != ToolTip)
{
- toolTipBlock = new GUITextBlock(new Rectangle(0,0,width, 18), ToolTip, "", Alignment.TopLeft, Alignment.TopLeft, null, true, GUI.SmallFont);
+ toolTipBlock = new GUITextBlock(new Rectangle(0, 0, width, 18), ToolTip, "GUIToolTip", Alignment.TopLeft, Alignment.TopLeft, null, true, GUI.SmallFont);
toolTipBlock.padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
toolTipBlock.rect.Width = (int)(GUI.SmallFont.MeasureString(toolTipBlock.WrappedText).X + 20);
- toolTipBlock.rect.Height = toolTipBlock.WrappedText.Split('\n').Length * 18;
- toolTipBlock.Color = Color.Black * 0.7f;
+ toolTipBlock.rect.Height = toolTipBlock.WrappedText.Split('\n').Length * 18 + 7;
toolTipBlock.userData = ToolTip;
}
@@ -468,13 +462,15 @@ namespace Barotrauma
}
public virtual void ApplyStyle(GUIComponentStyle style)
- {
+ {
+ if (style == null) return;
+
color = style.Color;
hoverColor = style.HoverColor;
selectedColor = style.SelectedColor;
padding = style.Padding;
- sprites = new List(style.Sprites);
+ sprites = style.Sprites;
OutlineColor = style.OutlineColor;
diff --git a/Subsurface/Source/GUI/GUIDropDown.cs b/Subsurface/Source/GUI/GUIDropDown.cs
index 0e8939e4a..bc6f4e442 100644
--- a/Subsurface/Source/GUI/GUIDropDown.cs
+++ b/Subsurface/Source/GUI/GUIDropDown.cs
@@ -81,17 +81,13 @@ namespace Barotrauma
if (parent != null) parent.AddChild(this);
- button = new GUIButton(this.rect, text, Color.White, Alignment.TopLeft, Alignment.TopLeft, null, null);
-
- button.TextColor = Color.White;
- button.Color = Color.Black * 0.8f;
- button.HoverColor = Color.DarkGray * 0.8f;
- button.OutlineColor = Color.LightGray * 0.8f;
+ button = new GUIButton(this.rect, text, Color.White, Alignment.TopLeft, Alignment.CenterLeft, "GUIDropDown", null);
+ GUI.Style.Apply(button, style, this);
+
button.OnClicked = OnClicked;
listBox = new GUIListBox(new Rectangle(this.rect.X, this.rect.Bottom, this.rect.Width, 200), style, null);
listBox.OnSelected = SelectItem;
- //listBox.ScrollBarEnabled = false;
}
public override void AddChild(GUIComponent child)
diff --git a/Subsurface/Source/GUI/GUIFrame.cs b/Subsurface/Source/GUI/GUIFrame.cs
index 664e1a6ef..d75a732fc 100644
--- a/Subsurface/Source/GUI/GUIFrame.cs
+++ b/Subsurface/Source/GUI/GUIFrame.cs
@@ -45,7 +45,7 @@ namespace Barotrauma
if (state == ComponentState.Selected) currColor = selectedColor;
if (state == ComponentState.Hover) currColor = hoverColor;
- if (!sprites.Any()) GUI.DrawRectangle(spriteBatch, rect, currColor * (currColor.A/255.0f), true);
+ if (sprites == null || !sprites.Any()) GUI.DrawRectangle(spriteBatch, rect, currColor * (currColor.A/255.0f), true);
base.Draw(spriteBatch);
if (OutlineColor != Color.Transparent)
diff --git a/Subsurface/Source/GUI/GUIMessageBox.cs b/Subsurface/Source/GUI/GUIMessageBox.cs
index ab8929fd0..fc0ca9421 100644
--- a/Subsurface/Source/GUI/GUIMessageBox.cs
+++ b/Subsurface/Source/GUI/GUIMessageBox.cs
@@ -26,21 +26,21 @@ namespace Barotrauma
set { (children[0].children[1] as GUITextBlock).Text = value; }
}
- public GUIMessageBox(string header, string text)
- : this(header, text, new string[] {"OK"})
+ public GUIMessageBox(string headerText, string text)
+ : this(headerText, text, new string[] {"OK"})
{
this.Buttons[0].OnClicked = Close;
}
- public GUIMessageBox(string header, string text, int width, int height)
- : this(header, text, new string[] { "OK" }, width, height)
+ public GUIMessageBox(string headerText, string text, int width, int height)
+ : this(headerText, text, new string[] { "OK" }, width, height)
{
this.Buttons[0].OnClicked = Close;
}
-
- public GUIMessageBox(string header, string text, string[] buttons, int width=DefaultWidth, int height=DefaultHeight, Alignment textAlignment = Alignment.TopLeft, GUIComponent parent = null)
- : base(new Rectangle(0,0, GameMain.GraphicsWidth, GameMain.GraphicsHeight),
- Color.Black*0.5f, Alignment.TopLeft, null, parent)
+
+ public GUIMessageBox(string headerText, string text, string[] buttons, int width = DefaultWidth, int height = DefaultHeight, Alignment textAlignment = Alignment.TopLeft, GUIComponent parent = null)
+ : base(new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight),
+ Color.Black * 0.5f, Alignment.TopLeft, null, parent)
{
if (height == 0)
{
@@ -53,13 +53,17 @@ namespace Barotrauma
height += 220;
}
- var frame = new GUIFrame(new Rectangle(0,0,width,height), null, Alignment.Center, "", this);
+ var frame = new GUIFrame(new Rectangle(0, 0, width, height), null, Alignment.Center, "", this);
+ GUI.Style.Apply(frame, "", this);
+
+ var header = new GUITextBlock(new Rectangle(0, 0, 0, 30), headerText, null, null, textAlignment, "", frame, true);
+ GUI.Style.Apply(header, "", this);
- new GUITextBlock(new Rectangle(0, 0, 0, 30), header, Color.Transparent, Color.White, textAlignment, "", frame, true);
if (!string.IsNullOrWhiteSpace(text))
{
- new GUITextBlock(new Rectangle(0, 30, 0, height - 70), text,
- Color.Transparent, Color.White, textAlignment, "", frame, true);
+ var textBlock = new GUITextBlock(new Rectangle(0, 30, 0, height - 70), text,
+ null, null, textAlignment, "", frame, true);
+ GUI.Style.Apply(textBlock, "", this);
}
int x = 0;
diff --git a/Subsurface/Source/GUI/GUIProgressBar.cs b/Subsurface/Source/GUI/GUIProgressBar.cs
index 1b21ce22c..c711506d4 100644
--- a/Subsurface/Source/GUI/GUIProgressBar.cs
+++ b/Subsurface/Source/GUI/GUIProgressBar.cs
@@ -7,11 +7,9 @@ namespace Barotrauma
{
private bool isHorizontal;
- private GUIFrame frame;
+ private GUIFrame frame, slider;
private float barSize;
-
- private int margin;
-
+
public delegate float ProgressGetterHandler();
public ProgressGetterHandler ProgressGetter;
@@ -24,23 +22,23 @@ namespace Barotrauma
public float BarSize
{
get { return barSize; }
- set
+ set
{
float oldBarSize = barSize;
barSize = MathHelper.Clamp(value, 0.0f, 1.0f);
- if (barSize!=oldBarSize) UpdateRect();
+ if (barSize != oldBarSize) UpdateRect();
}
}
public GUIProgressBar(Rectangle rect, Color color, float barSize, GUIComponent parent = null)
- : this(rect,color,barSize, (Alignment.Left | Alignment.Top), parent)
+ : this(rect, color, barSize, (Alignment.Left | Alignment.Top), parent)
{
}
public GUIProgressBar(Rectangle rect, Color color, float barSize, Alignment alignment, GUIComponent parent = null)
- : this(rect,color,null, barSize,alignment, parent)
+ : this(rect, color, null, barSize, alignment, parent)
{
-
+
}
public GUIProgressBar(Rectangle rect, Color color, string style, float barSize, Alignment alignment, GUIComponent parent = null)
@@ -51,19 +49,21 @@ namespace Barotrauma
isHorizontal = (rect.Width > rect.Height);
this.alignment = alignment;
-
- margin = 5;
-
+
if (parent != null)
parent.AddChild(this);
- frame = new GUIFrame(new Rectangle(0, 0, 0, 0), Color.Black, null, this);
+ frame = new GUIFrame(new Rectangle(0, 0, 0, 0), null, this);
+ GUI.Style.Apply(frame, "", this);
+
+ slider = new GUIFrame(new Rectangle(0, 0, 0, 0), null, this);
+ GUI.Style.Apply(slider, "Slider", this);
this.barSize = barSize;
UpdateRect();
}
- public override void ApplyStyle(GUIComponentStyle style)
+ /*public override void ApplyStyle(GUIComponentStyle style)
{
if (frame == null) return;
@@ -76,15 +76,15 @@ namespace Barotrauma
frame.OutlineColor = style.OutlineColor;
this.style = style;
- }
+ }*/
private void UpdateRect()
{
- rect = new Rectangle(
+ slider.Rect = new Rectangle(
(int)(frame.Rect.X + padding.X),
(int)(frame.Rect.Y + padding.Y),
- isHorizontal ? (int)((frame.Rect.Width - padding.X - padding.Z) * barSize) : (frame.Rect.Width - margin * 2),
- isHorizontal ? (int)(frame.Rect.Height - padding.Y - padding.W) : (int)((frame.Rect.Height - margin * 2) * barSize));
+ isHorizontal ? (int)((frame.Rect.Width - padding.X - padding.Z) * barSize) : frame.Rect.Width,
+ isHorizontal ? (int)(frame.Rect.Height - padding.Y - padding.W) : (int)(frame.Rect.Height * barSize));
}
public override void Draw(SpriteBatch spriteBatch)
@@ -95,7 +95,7 @@ namespace Barotrauma
DrawChildren(spriteBatch);
- GUI.DrawRectangle(spriteBatch, rect, color * (color.A / 255.0f), true);
+ //GUI.DrawRectangle(spriteBatch, rect, color * (color.A / 255.0f), true);
}
}
diff --git a/Subsurface/Source/GUI/GUIScrollBar.cs b/Subsurface/Source/GUI/GUIScrollBar.cs
index 645323f0a..01353ceb8 100644
--- a/Subsurface/Source/GUI/GUIScrollBar.cs
+++ b/Subsurface/Source/GUI/GUIScrollBar.cs
@@ -112,6 +112,7 @@ namespace Barotrauma
isHorizontal = (rect.Width > rect.Height);
frame = new GUIFrame(new Rectangle(0,0,0,0), Color.Black*0.8f, style, this);
+ GUI.Style.Apply(frame, "", this);
//AddChild(frame);
//System.Diagnostics.Debug.WriteLine(frame.rect);
diff --git a/Subsurface/Source/GUI/GUIStyle.cs b/Subsurface/Source/GUI/GUIStyle.cs
index 69050b69a..2f52adf01 100644
--- a/Subsurface/Source/GUI/GUIStyle.cs
+++ b/Subsurface/Source/GUI/GUIStyle.cs
@@ -33,22 +33,35 @@ namespace Barotrauma
public void Apply(GUIComponent targetComponent, string styleName = "", GUIComponent parent = null)
{
- if (string.IsNullOrEmpty(styleName))
+ GUIComponentStyle componentStyle = null;
+ if (parent != null)
{
- styleName = parent == null ? targetComponent.GetType().Name.ToLowerInvariant() : parent.GetType().Name.ToLowerInvariant();
+ string parentStyleName = parent.GetType().Name.ToLowerInvariant();
+
+ GUIComponentStyle parentStyle = null;
+ 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);
}
-
- GUIComponentStyle componentStyle = null;
-
- if (!componentStyles.TryGetValue(styleName, out componentStyle))
+ else
{
- DebugConsole.ThrowError("Couldn't find a GUI style \""+ styleName+"\"");
- return;
+ 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);
}
-
-
}
}
diff --git a/Subsurface/Source/GUI/GUITextBlock.cs b/Subsurface/Source/GUI/GUITextBlock.cs
index 906db2c2b..05a2c85d2 100644
--- a/Subsurface/Source/GUI/GUITextBlock.cs
+++ b/Subsurface/Source/GUI/GUITextBlock.cs
@@ -150,6 +150,7 @@ namespace Barotrauma
public override void ApplyStyle(GUIComponentStyle style)
{
+ if (style == null) return;
base.ApplyStyle(style);
textColor = style.textColor;
@@ -174,6 +175,8 @@ namespace Barotrauma
this.alignment = alignment;
+ this.padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
+
this.textAlignment = textAlignment;
if (parent != null)
diff --git a/Subsurface/Source/GUI/GUITextBox.cs b/Subsurface/Source/GUI/GUITextBox.cs
index 8933dd5d6..d0f849750 100644
--- a/Subsurface/Source/GUI/GUITextBox.cs
+++ b/Subsurface/Source/GUI/GUITextBox.cs
@@ -184,7 +184,7 @@ namespace Barotrauma
Font = GUI.Font;
- GUI.Style.Apply(textBlock, "", this);
+ GUI.Style.Apply(textBlock, style == "" ? "GUITextBox" : style);
textBlock.Padding = new Vector4(3.0f, 0.0f, 3.0f, 0.0f);
//previousMouse = PlayerInput.GetMouseState;
diff --git a/Subsurface/Source/GUI/GUITickBox.cs b/Subsurface/Source/GUI/GUITickBox.cs
index 28564a7ec..4dcd3a188 100644
--- a/Subsurface/Source/GUI/GUITickBox.cs
+++ b/Subsurface/Source/GUI/GUITickBox.cs
@@ -36,7 +36,6 @@ namespace Barotrauma
set
{
enabled = value;
- text.TextColor = enabled ? Color.White : Color.White * 0.5f;
}
}
@@ -76,9 +75,10 @@ namespace Barotrauma
box.SelectedColor = Color.DarkGray;
box.CanBeFocused = false;
- GUI.Style.Apply(box, "", this);
+ GUI.Style.Apply(box, "GUITickBox");
- text = new GUITextBlock(new Rectangle(rect.Right + 10, rect.Y+2, 20, rect.Height), label, "", this, font);
+ text = new GUITextBlock(new Rectangle(rect.Right, rect.Y, 20, rect.Height), label, "", Alignment.TopLeft, Alignment.Left | Alignment.CenterY, this, false, font);
+ GUI.Style.Apply(text, "", this);
this.rect = new Rectangle(box.Rect.X, box.Rect.Y, 240, rect.Height);
@@ -89,15 +89,8 @@ namespace Barotrauma
{
if (!Visible || !Enabled) return;
- //if (MouseOn != null && MouseOn != this && !MouseOn.IsParentOf(this)) return;
-
- //if (text.Rect.Contains(PlayerInput.MousePosition)) MouseOn = this;
-
- if (MouseOn==this)//box.Rect.Contains(PlayerInput.MousePosition))
+ if (MouseOn == this)
{
- //ToolTip = this.ToolTip;
- //MouseOn = this;
-
box.State = ComponentState.Hover;
if (PlayerInput.LeftButtonHeld())
@@ -105,7 +98,6 @@ namespace Barotrauma
box.State = ComponentState.Selected;
}
-
if (PlayerInput.LeftButtonClicked())
{
Selected = !Selected;
@@ -116,24 +108,18 @@ namespace Barotrauma
{
box.State = ComponentState.None;
}
-
+
+ if (selected)
+ {
+ box.State = ComponentState.Selected;
+ }
}
public override void Draw(SpriteBatch spriteBatch)
{
if (!Visible) return;
- DrawChildren(spriteBatch);
-
- float alpha = enabled ? 1.0f : 0.8f;
-
- GUI.DrawRectangle(spriteBatch, new Rectangle(box.Rect.X + 1, box.Rect.Y + 1, box.Rect.Width - 2, box.Rect.Height - 2),
- (box.State == ComponentState.Hover ? new Color(50, 50, 50, 255) : Color.Black) * alpha, true);
-
- if (!selected) return;
- GUI.DrawRectangle(spriteBatch, new Rectangle(box.Rect.X + 5, box.Rect.Y + 5, box.Rect.Width - 10, box.Rect.Height - 10),
- Color.Green * 0.8f * alpha, true);
-
+ DrawChildren(spriteBatch);
}
}
}
diff --git a/Subsurface/Source/Screens/EditMapScreen.cs b/Subsurface/Source/Screens/EditMapScreen.cs
index 19ecad00d..2eef1cc5d 100644
--- a/Subsurface/Source/Screens/EditMapScreen.cs
+++ b/Subsurface/Source/Screens/EditMapScreen.cs
@@ -31,7 +31,7 @@ namespace Barotrauma
const int PreviouslyUsedCount = 10;
private GUIListBox previouslyUsedList;
- GUIDropDown linkedSubBox;
+ private GUIDropDown linkedSubBox;
//a Character used for picking up and manipulating items
private Character dummyCharacter;
@@ -126,7 +126,7 @@ namespace Barotrauma
selectedTab = -1;
- topPanel = new GUIFrame(new Rectangle(0, 0, 0, 31), "");
+ topPanel = new GUIFrame(new Rectangle(0, 0, 0, 50), "GUIFrameTop");
topPanel.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
hullVolumeFrame = new GUIFrame(new Rectangle(145, 26, 280, 70), "", topPanel);
@@ -153,10 +153,10 @@ namespace Barotrauma
var nameLabel = new GUITextBlock(new Rectangle(170, -4, 150, 20), "", "", topPanel, GUI.LargeFont);
nameLabel.TextGetter = GetSubName;
- linkedSubBox = new GUIDropDown(new Rectangle(750,0,200,20), "Add submarine", "", topPanel);
- linkedSubBox.ToolTip =
- "Places another submarine into the current submarine file. "+
- "Can be used for adding things such as smaller vessels, "+
+ linkedSubBox = new GUIDropDown(new Rectangle(750, 0, 200, 20), "Add submarine", "", topPanel);
+ linkedSubBox.ToolTip =
+ "Places another submarine into the current submarine file. " +
+ "Can be used for adding things such as smaller vessels, " +
"escape pods or detachable sections into the main submarine.";
foreach (Submarine sub in Submarine.SavedSubmarines)
@@ -164,17 +164,17 @@ namespace Barotrauma
linkedSubBox.AddItem(sub.Name, sub);
}
linkedSubBox.OnSelected += SelectLinkedSub;
-
- leftPanel = new GUIFrame(new Rectangle(0, 30, 150, GameMain.GraphicsHeight-30), "");
+
+ leftPanel = new GUIFrame(new Rectangle(0, 0, 150, GameMain.GraphicsHeight), "GUIFrameLeft");
leftPanel.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
-
+
GUITextBlock itemCount = new GUITextBlock(new Rectangle(0, 30, 0, 20), "", "", leftPanel);
itemCount.TextGetter = GetItemCount;
GUITextBlock structureCount = new GUITextBlock(new Rectangle(0, 50, 0, 20), "", "", leftPanel);
structureCount.TextGetter = GetStructureCount;
- GUItabs = new GUIComponent[Enum.GetValues(typeof(MapEntityCategory)).Length];
+ GUItabs = new GUIComponent[Enum.GetValues(typeof(MapEntityCategory)).Length];
int width = 400, height = 400;
int y = 90;
diff --git a/Subsurface/Source/Screens/NetLobbyScreen.cs b/Subsurface/Source/Screens/NetLobbyScreen.cs
index dd0900399..58405f584 100644
--- a/Subsurface/Source/Screens/NetLobbyScreen.cs
+++ b/Subsurface/Source/Screens/NetLobbyScreen.cs
@@ -170,7 +170,7 @@ namespace Barotrauma
Rectangle panelRect = new Rectangle(0,0,width,height);
- menu = new GUIFrame(panelRect, Color.Transparent, Alignment.Center);
+ menu = new GUIFrame(panelRect, Color.Transparent, Alignment.Center, null);
//menu.Padding = GUI.style.smallPadding;
//server info panel ------------------------------------------------------------
@@ -251,7 +251,7 @@ namespace Barotrauma
GUITextBlock textBlock = new GUITextBlock(
new Rectangle(0, 0, 0, 25),
mode.Name, "",
- Alignment.Left, Alignment.Left,
+ Alignment.TopLeft, Alignment.CenterLeft,
modeList);
textBlock.ToolTip = mode.Description;
textBlock.Padding = new Vector4(10.0f, 0.0f, 0.0f, 0.0f);
@@ -674,7 +674,7 @@ namespace Barotrauma
{
var subTextBlock = new GUITextBlock(
new Rectangle(0, 0, 0, 25), ToolBox.LimitString(sub.Name, GUI.Font, subList.Rect.Width - 65), "",
- Alignment.Left, Alignment.CenterY | Alignment.Left, subList)
+ Alignment.TopLeft, Alignment.CenterLeft, subList)
{
Padding = new Vector4(10.0f, 0.0f, 0.0f, 0.0f),
ToolTip = sub.Description,
diff --git a/Subsurface/Source/Screens/ServerListScreen.cs b/Subsurface/Source/Screens/ServerListScreen.cs
index 4b6714afa..1e5d3219d 100644
--- a/Subsurface/Source/Screens/ServerListScreen.cs
+++ b/Subsurface/Source/Screens/ServerListScreen.cs
@@ -176,13 +176,13 @@ namespace Barotrauma
passwordBox.Enabled = false;
passwordBox.UserData = "password";
- new GUITextBlock(new Rectangle(columnX[0], 0, 0, 0), serverName, "", serverFrame);
+ new GUITextBlock(new Rectangle(columnX[0], 0, 0, 0), serverName, "", Alignment.TopLeft, Alignment.CenterLeft, serverFrame);
int playerCount = 0, maxPlayers = 1;
int.TryParse(currPlayersStr, out playerCount);
int.TryParse(maxPlayersStr, out maxPlayers);
- new GUITextBlock(new Rectangle(columnX[1], 0, 0, 0), playerCount + "/" + maxPlayers, "", serverFrame);
+ new GUITextBlock(new Rectangle(columnX[1], 0, 0, 0), playerCount + "/" + maxPlayers, "", Alignment.TopLeft, Alignment.CenterLeft, serverFrame);
var gameStartedBox = new GUITickBox(new Rectangle(columnX[2] + (columnX[3] - columnX[2])/ 2, 0, 20, 20), "", Alignment.TopLeft, serverFrame);
gameStartedBox.Selected = gameStarted == "1";