diff --git a/Subsurface/Content/UI/style.xml b/Subsurface/Content/UI/style.xml
index 5bf34e948..0b55f7d9a 100644
--- a/Subsurface/Content/UI/style.xml
+++ b/Subsurface/Content/UI/style.xml
@@ -61,7 +61,7 @@
selectedcolor="1.0,1.0,1.0,1.0">
-
+
@@ -121,25 +121,24 @@
selectedcolor="1.0,1.0,1.0,1.0"
padding="5.0, 5.0, 5.0, 5.0">
-
-
+
+
-
-
-
+ textcolor="1.0,1.0,1.0,1.0"
+ padding="9.0, 2.0, 9.0, 2.0">
+
+
-
-
-
-
-
+
+
+
add them to the listbox
List unInitializedMessages = new List(Messages);
diff --git a/Subsurface/Source/GUI/GUIDropDown.cs b/Subsurface/Source/GUI/GUIDropDown.cs
index bc6f4e442..73cce0ffe 100644
--- a/Subsurface/Source/GUI/GUIDropDown.cs
+++ b/Subsurface/Source/GUI/GUIDropDown.cs
@@ -97,7 +97,7 @@ namespace Barotrauma
public void AddItem(string text, object userData = null)
{
- GUITextBlock textBlock = new GUITextBlock(new Rectangle(0,0,0,20), text, "", listBox);
+ GUITextBlock textBlock = new GUITextBlock(new Rectangle(0,0,0,20), text, "ListBoxElement", listBox);
textBlock.UserData = userData;
}
diff --git a/Subsurface/Source/GUI/GUIScrollBar.cs b/Subsurface/Source/GUI/GUIScrollBar.cs
index 01353ceb8..414f75059 100644
--- a/Subsurface/Source/GUI/GUIScrollBar.cs
+++ b/Subsurface/Source/GUI/GUIScrollBar.cs
@@ -45,20 +45,21 @@ namespace Barotrauma
set
{
barScroll = MathHelper.Clamp(value, 0.0f, 1.0f);
- int newX = bar.Rect.X - frame.Rect.X, newY = bar.Rect.Y - frame.Rect.Y;
+ int newX = bar.Rect.X - frame.Rect.X;
+ int newY = bar.Rect.Y - frame.Rect.Y;
float newScroll = step == 0.0f ? barScroll : MathUtils.RoundTowardsClosest(barScroll, step);
if (isHorizontal)
{
- newX = (int)(newScroll * (frame.Rect.Width - bar.Rect.Width));
- newX = MathHelper.Clamp(newX, 0, frame.Rect.Width - bar.Rect.Width);
+ newX = (int)(frame.Padding.X + newScroll * (frame.Rect.Width - bar.Rect.Width - frame.Padding.X - frame.Padding.Z));
+ newX = MathHelper.Clamp(newX, (int)frame.Padding.X, frame.Rect.Width - bar.Rect.Width - (int)frame.Padding.Z);
}
else
{
- newY = (int)(newScroll * (frame.Rect.Height - bar.Rect.Height));
- newY = MathHelper.Clamp(newY, 0, frame.Rect.Height - bar.Rect.Height);
+ newY = (int)(frame.Padding.Y + newScroll * (frame.Rect.Height - bar.Rect.Height - frame.Padding.Y - frame.Padding.W));
+ newY = MathHelper.Clamp(newY, (int)frame.Padding.Y, frame.Rect.Height - bar.Rect.Height - (int)frame.Padding.W);
}
bar.Rect = new Rectangle(newX + frame.Rect.X, newY + frame.Rect.Y, bar.Rect.Width, bar.Rect.Height);
@@ -111,18 +112,15 @@ namespace Barotrauma
parent.AddChild(this);
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);
+ frame = new GUIFrame(new Rectangle(0,0,0,0), style, this);
+ GUI.Style.Apply(frame, isHorizontal ? "GUIFrameHorizontal" : "GUIFrameVertical", this);
this.barSize = barSize;
bar = new GUIButton(new Rectangle(0, 0, 0, 0), "", color, "", this);
+ GUI.Style.Apply(bar, isHorizontal ? "GUIButtonHorizontal" : "GUIButtoneVertical", this);
bar.OnPressed = SelectBar;
- //AddChild(bar);
enabled = true;
@@ -131,12 +129,16 @@ namespace Barotrauma
private void UpdateRect()
{
-
+ float width = frame.Rect.Width - frame.Padding.X - frame.Padding.Z;
+ float height = frame.Rect.Height - frame.Padding.Y - frame.Padding.W;
+
bar.Rect = new Rectangle(
bar.Rect.X,
bar.Rect.Y,
- isHorizontal ? (int)(frame.Rect.Width * barSize) : frame.Rect.Width,
- isHorizontal ? frame.Rect.Height : (int)(frame.Rect.Height * barSize));
+ isHorizontal ? (int)(width * barSize) : (int)width,
+ isHorizontal ? (int)height : (int)(height * barSize));
+
+ ClampRect();
foreach (GUIComponent child in bar.children)
{
@@ -144,16 +146,36 @@ namespace Barotrauma
}
}
+ private void ClampRect()
+ {
+ bar.Rect = new Rectangle(
+ (int)MathHelper.Clamp(bar.Rect.X, frame.Rect.X + frame.Padding.X, frame.Rect.Right - bar.Rect.Width - frame.Padding.X - frame.Padding.Z),
+ (int)MathHelper.Clamp(bar.Rect.Y, frame.Rect.Y + frame.Padding.Y, frame.Rect.Bottom - bar.Rect.Height - frame.Padding.Y - frame.Padding.W),
+ bar.Rect.Width,
+ bar.Rect.Height);
+ }
+
public override void Update(float deltaTime)
{
if (!Visible) return;
base.Update(deltaTime);
- if (draggingBar != this) return;
- if (!PlayerInput.LeftButtonHeld()) draggingBar = null;
+ if (MouseOn == frame)
+ {
+ if (PlayerInput.LeftButtonClicked())
+ {
+ MoveButton(new Vector2(
+ Math.Sign(PlayerInput.MousePosition.X - bar.Rect.Center.X) * bar.Rect.Width,
+ Math.Sign(PlayerInput.MousePosition.Y - bar.Rect.Center.Y) * bar.Rect.Height));
+ }
+ }
- MoveButton();
+ if (draggingBar == this)
+ {
+ if (!PlayerInput.LeftButtonHeld()) draggingBar = null;
+ MoveButton(PlayerInput.MouseSpeed);
+ }
}
public override void Draw(SpriteBatch spriteBatch)
@@ -174,27 +196,22 @@ namespace Barotrauma
}
- private void MoveButton()
+ private void MoveButton(Vector2 moveAmount)
{
- float moveAmount;
if (isHorizontal)
{
- moveAmount = PlayerInput.MouseSpeed.X;
- barScroll += moveAmount / (frame.Rect.Width - bar.Rect.Width);
+ moveAmount.Y = 0.0f;
+ barScroll += moveAmount.X / (frame.Rect.Width - bar.Rect.Width - frame.Padding.X - frame.Padding.Z);
}
else
{
- moveAmount = PlayerInput.MouseSpeed.Y;
- barScroll += moveAmount / (frame.Rect.Height - bar.Rect.Height);
+ moveAmount.X = 0.0f;
+ barScroll += moveAmount.Y / (frame.Rect.Height - bar.Rect.Height - frame.Padding.Y - frame.Padding.W);
}
BarScroll = barScroll;
- if (moveAmount != 0 && OnMoved != null) OnMoved(this, BarScroll);
-
-
- //bar.Rect = new Rectangle(newX + frame.Rect.X, newY + frame.Rect.Y, bar.Rect.Width, bar.Rect.Height);
-
+ if (moveAmount != Vector2.Zero && OnMoved != null) OnMoved(this, BarScroll);
}
}
diff --git a/Subsurface/Source/GUI/GUITextBox.cs b/Subsurface/Source/GUI/GUITextBox.cs
index d0f849750..6c0582e34 100644
--- a/Subsurface/Source/GUI/GUITextBox.cs
+++ b/Subsurface/Source/GUI/GUITextBox.cs
@@ -164,7 +164,7 @@ namespace Barotrauma
}
- public GUITextBox(Rectangle rect, Color? color, Color? textColor, Alignment alignment, Alignment textAlignment = Alignment.Left, string style = null, GUIComponent parent = null)
+ public GUITextBox(Rectangle rect, Color? color, Color? textColor, Alignment alignment, Alignment textAlignment = Alignment.CenterLeft, string style = null, GUIComponent parent = null)
: base(style)
{
Enabled = true;
@@ -174,8 +174,6 @@ namespace Barotrauma
if (color != null) this.color = (Color)color;
this.alignment = alignment;
-
- //this.textAlignment = textAlignment;
if (parent != null)
parent.AddChild(this);
@@ -186,11 +184,8 @@ namespace Barotrauma
GUI.Style.Apply(textBlock, style == "" ? "GUITextBox" : style);
textBlock.Padding = new Vector4(3.0f, 0.0f, 3.0f, 0.0f);
-
- //previousMouse = PlayerInput.GetMouseState;
-
+
CaretEnabled = true;
- //SetTextPos();
}
public void Select()
diff --git a/Subsurface/Source/GameSettings.cs b/Subsurface/Source/GameSettings.cs
index 87ab703e9..5116d4a99 100644
--- a/Subsurface/Source/GameSettings.cs
+++ b/Subsurface/Source/GameSettings.cs
@@ -406,8 +406,8 @@ namespace Barotrauma
var inputNames = Enum.GetNames(typeof(InputType));
for (int i = 0; i< inputNames.Length; i++)
{
- new GUITextBlock(new Rectangle(x, y, 100, 20), inputNames[i]+": ", "", settingsFrame);
- var keyBox = new GUITextBox(new Rectangle(x + 100, y, 120, 15), "", settingsFrame);
+ new GUITextBlock(new Rectangle(x, y, 100, 18), inputNames[i]+": ", "", Alignment.TopLeft, Alignment.CenterLeft, settingsFrame);
+ var keyBox = new GUITextBox(new Rectangle(x + 100, y, 120, 18), null,null, Alignment.TopLeft, Alignment.CenterLeft, "", settingsFrame);
keyBox.Text = keyMapping[i].ToString();
keyBox.UserData = i;
diff --git a/Subsurface/Source/Networking/GameServerSettings.cs b/Subsurface/Source/Networking/GameServerSettings.cs
index 7b1633a4e..69a637aee 100644
--- a/Subsurface/Source/Networking/GameServerSettings.cs
+++ b/Subsurface/Source/Networking/GameServerSettings.cs
@@ -315,7 +315,7 @@ namespace Barotrauma.Networking
settingsTabs = new GUIFrame[tabNames.Length];
for (int i = 0; i < tabNames.Length; i++)
{
- settingsTabs[i] = new GUIFrame(new Rectangle(0, 15, 0, innerFrame.Rect.Height - 120), null, Alignment.Center, "", innerFrame);
+ settingsTabs[i] = new GUIFrame(new Rectangle(0, 15, 0, innerFrame.Rect.Height - 120), null, Alignment.Center, "InnerFrame", innerFrame);
settingsTabs[i].Padding = new Vector4(40.0f, 20.0f, 40.0f, 40.0f);
var tabButton = new GUIButton(new Rectangle(85 * i, 35, 80, 20), tabNames[i], "", innerFrame);
diff --git a/Subsurface/Source/Screens/EditMapScreen.cs b/Subsurface/Source/Screens/EditMapScreen.cs
index 2eef1cc5d..2942958e3 100644
--- a/Subsurface/Source/Screens/EditMapScreen.cs
+++ b/Subsurface/Source/Screens/EditMapScreen.cs
@@ -189,7 +189,7 @@ namespace Barotrauma
GUItabs[i] = new GUIFrame(new Rectangle(GameMain.GraphicsWidth / 2 - width / 2, GameMain.GraphicsHeight / 2 - height / 2, width, height), "");
GUItabs[i].Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
- new GUITextBlock(new Rectangle(-200, 0, 100, 15), "Filter", "", Alignment.TopRight, Alignment.TopRight, GUItabs[i], false, GUI.SmallFont);
+ new GUITextBlock(new Rectangle(-200, 0, 100, 15), "Filter", "", Alignment.TopRight, Alignment.CenterRight, GUItabs[i], false, GUI.SmallFont);
GUITextBox searchBox = new GUITextBox(new Rectangle(-20, 0, 180, 15), Alignment.TopRight, "", GUItabs[i]);
searchBox.Font = GUI.SmallFont;
@@ -206,22 +206,16 @@ namespace Barotrauma
foreach (MapEntityPrefab ep in MapEntityPrefab.list)
{
if (!ep.Category.HasFlag(category)) continue;
-
- Color color = ((itemList.CountChildren % 2) == 0) ? Color.Transparent : Color.White * 0.1f;
-
- GUIFrame frame = new GUIFrame(new Rectangle(0, 0, 0, 50), Color.Transparent, null, itemList);
+
+ GUIFrame frame = new GUIFrame(new Rectangle(0, 0, 0, 50), Color.Transparent, "ListBoxElement", itemList);
frame.UserData = ep;
frame.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
- frame.Color = color;
- frame.HoverColor = Color.Gold * 0.2f;
- frame.SelectedColor = Color.Gold * 0.5f;
GUITextBlock textBlock = new GUITextBlock(
new Rectangle(40, 0, 0, 25),
- ep.Name,
- Color.Transparent, Color.White,
- Alignment.Left, Alignment.Left,
- null, frame);
+ ep.Name, "",
+ Alignment.Top, Alignment.CenterLeft,
+ frame);
textBlock.Padding = new Vector4(5.0f, 0.0f, 5.0f, 0.0f);
if (!string.IsNullOrWhiteSpace(ep.Description))
@@ -231,7 +225,7 @@ namespace Barotrauma
if (ep.sprite != null)
{
- GUIImage img = new GUIImage(new Rectangle(0, 0, 40, 40), ep.sprite, Alignment.Left, frame);
+ GUIImage img = new GUIImage(new Rectangle(0, 0, 40, 40), ep.sprite, Alignment.CenterLeft, frame);
img.Scale = Math.Min(Math.Min(40.0f / img.SourceRect.Width, 40.0f / img.SourceRect.Height), 1.0f);
img.Color = ep.SpriteColor;
}
@@ -242,7 +236,7 @@ namespace Barotrauma
i++;
}
- y+=50;
+ y += 50;
button = new GUIButton(new Rectangle(0, y, 0, 20), "Character mode", Alignment.Left, "", leftPanel);
button.ToolTip = "Allows you to pick up and use items. Useful for things such as placing items inside closets, turning devices on/off and doing the wiring.";
button.OnClicked = ToggleCharacterMode;
@@ -251,13 +245,13 @@ namespace Barotrauma
button = new GUIButton(new Rectangle(0, y, 0, 20), "Wiring mode", Alignment.Left, "", leftPanel);
//button.ToolTip = "Allows you to pick up and use items. Useful for things such as placing items inside closets, turning devices on/off and doing the wiring.";
button.OnClicked = ToggleWiringMode;
-
- y+=50;
+
+ y += 50;
button = new GUIButton(new Rectangle(0, y, 0, 20), "Generate waypoints", Alignment.Left, "", leftPanel);
button.ToolTip = "AI controlled crew members require waypoints to navigate around the sub.";
button.OnClicked = GenerateWaypoints;
-
- y+=50;
+
+ y += 50;
new GUITextBlock(new Rectangle(0, y, 0, 20), "Show:", "", leftPanel);
diff --git a/Subsurface/Source/Screens/MainMenuScreen.cs b/Subsurface/Source/Screens/MainMenuScreen.cs
index 0eb025f6c..bb4b2dee1 100644
--- a/Subsurface/Source/Screens/MainMenuScreen.cs
+++ b/Subsurface/Source/Screens/MainMenuScreen.cs
@@ -211,7 +211,7 @@ namespace Barotrauma
{
var textBlock = new GUITextBlock(
new Rectangle(0, 0, 0, 25),
- ToolBox.LimitString(sub.Name, GUI.Font, subList.Rect.Width - 65), "",
+ ToolBox.LimitString(sub.Name, GUI.Font, subList.Rect.Width - 65), "ListBoxElement",
Alignment.Left, Alignment.Left, subList)
{
Padding = new Vector4(10.0f, 0.0f, 0.0f, 0.0f),
@@ -396,7 +396,7 @@ namespace Barotrauma
GUITextBlock textBlock = new GUITextBlock(
new Rectangle(0, 0, 0, 25),
saveFile,
- "",
+ "ListBoxElement",
Alignment.Left,
Alignment.Left,
saveList);
diff --git a/Subsurface/Source/Screens/NetLobbyScreen.cs b/Subsurface/Source/Screens/NetLobbyScreen.cs
index 58405f584..54b2baa3c 100644
--- a/Subsurface/Source/Screens/NetLobbyScreen.cs
+++ b/Subsurface/Source/Screens/NetLobbyScreen.cs
@@ -250,7 +250,7 @@ namespace Barotrauma
GUITextBlock textBlock = new GUITextBlock(
new Rectangle(0, 0, 0, 25),
- mode.Name, "",
+ mode.Name, "ListBoxElement",
Alignment.TopLeft, Alignment.CenterLeft,
modeList);
textBlock.ToolTip = mode.Description;
@@ -673,7 +673,7 @@ namespace Barotrauma
public void AddSubmarine(GUIComponent subList, Submarine sub)
{
var subTextBlock = new GUITextBlock(
- new Rectangle(0, 0, 0, 25), ToolBox.LimitString(sub.Name, GUI.Font, subList.Rect.Width - 65), "",
+ new Rectangle(0, 0, 0, 25), ToolBox.LimitString(sub.Name, GUI.Font, subList.Rect.Width - 65), "ListBoxElement",
Alignment.TopLeft, Alignment.CenterLeft, subList)
{
Padding = new Vector4(10.0f, 0.0f, 0.0f, 0.0f),
diff --git a/Subsurface/Source/Screens/ServerListScreen.cs b/Subsurface/Source/Screens/ServerListScreen.cs
index 1e5d3219d..8d66d0cc9 100644
--- a/Subsurface/Source/Screens/ServerListScreen.cs
+++ b/Subsurface/Source/Screens/ServerListScreen.cs
@@ -52,7 +52,7 @@ namespace Barotrauma
serverList = new GUIListBox(new Rectangle(middleX,60,0,height-160), "", menu);
serverList.OnSelected = SelectServer;
- float[] columnRelativeX = new float[] { 0.15f, 0.55f, 0.15f, 0.15f };
+ float[] columnRelativeX = new float[] { 0.15f, 0.5f, 0.15f, 0.2f };
columnX = new int[columnRelativeX.Length];
for (int n = 0; n < columnX.Length; n++)
{
@@ -166,12 +166,10 @@ namespace Barotrauma
string hasPassWordStr = (arguments.Length > 6) ? arguments[6] : "";
- var serverFrame = new GUIFrame(new Rectangle(0, 0, 0, 20), (i % 2 == 0) ? Color.Transparent : Color.White * 0.2f, null, serverList);
+ var serverFrame = new GUIFrame(new Rectangle(0, 0, 0, 30), (i % 2 == 0) ? Color.Transparent : Color.White * 0.2f, "ListBoxElement", serverList);
serverFrame.UserData = IP + ":" + port;
- serverFrame.HoverColor = Color.Gold * 0.2f;
- serverFrame.SelectedColor = Color.Gold * 0.5f;
- var passwordBox = new GUITickBox(new Rectangle(columnX[0] / 2, 0, 20, 20), "", Alignment.TopLeft, serverFrame);
+ var passwordBox = new GUITickBox(new Rectangle(columnX[0] / 2, 0, 20, 20), "", Alignment.CenterLeft, serverFrame);
passwordBox.Selected = hasPassWordStr == "1";
passwordBox.Enabled = false;
passwordBox.UserData = "password";
@@ -184,7 +182,7 @@ namespace Barotrauma
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);
+ var gameStartedBox = new GUITickBox(new Rectangle(columnX[2] + (columnX[3] - columnX[2])/ 2, 0, 20, 20), "", Alignment.CenterRight, serverFrame);
gameStartedBox.Selected = gameStarted == "1";
gameStartedBox.Enabled = false;