Separate sprites for horizontal and vertical scrollbars, style tweaking

This commit is contained in:
Regalis
2017-04-18 19:24:13 +03:00
parent dc6ed7daf1
commit 9a5777183f
11 changed files with 88 additions and 86 deletions
+14 -15
View File
@@ -61,7 +61,7 @@
selectedcolor="1.0,1.0,1.0,1.0"> selectedcolor="1.0,1.0,1.0,1.0">
<Sprite texture="Content/UI/UI_Atlas.png" state="None" sourcerect ="683, 74, 129, 41" slice="687, 78, 808, 109"/> <Sprite texture="Content/UI/UI_Atlas.png" state="None" sourcerect ="683, 74, 129, 41" slice="687, 78, 808, 109"/>
<Sprite texture="Content/UI/UI_Atlas.png" state="Hover" sourcerect ="888, 91, 129, 41" slice="897, 98, 1009, 125"/> <Sprite texture="Content/UI/UI_Atlas.png" state="Hover" sourcerect ="888, 91, 129, 41" slice="893, 98, 1013, 125"/>
<Sprite texture="Content/UI/UI_Atlas.png" state="Selected" sourcerect ="553, 74, 129, 41" slice="557, 78, 676, 109"/> <Sprite texture="Content/UI/UI_Atlas.png" state="Selected" sourcerect ="553, 74, 129, 41" slice="557, 78, 676, 109"/>
<Sprite texture="Content/UI/UI_Atlas.png" state="Pressed" sourcerect ="553, 74, 129, 41" slice="557, 78, 676, 109"/> <Sprite texture="Content/UI/UI_Atlas.png" state="Pressed" sourcerect ="553, 74, 129, 41" slice="557, 78, 676, 109"/>
@@ -121,25 +121,24 @@
selectedcolor="1.0,1.0,1.0,1.0" selectedcolor="1.0,1.0,1.0,1.0"
padding="5.0, 5.0, 5.0, 5.0"> padding="5.0, 5.0, 5.0, 5.0">
<Sprite texture="Content/UI/UI_Atlas.png" state="Hover" sourcerect ="474, 544, 266, 52" slice="480, 552, 731, 584"/> <Sprite texture="Content/UI/UI_Atlas.png" state="Hover" sourcerect ="493, 544, 227, 52" slice="494, 552, 718, 584"/>
<Sprite texture="Content/UI/UI_Atlas.png" state="Selected" sourcerect ="474, 544, 266, 52" slice="480, 552, 731, 584"/> <Sprite texture="Content/UI/UI_Atlas.png" state="Selected" sourcerect ="493, 544, 227, 52" slice="494, 552, 718, 584"/>
</ListBoxElement> </ListBoxElement>
<GUIScrollBar> <GUIScrollBar>
<GUIFrame <GUIFrameHorizontal
color="1.0,1.0,1.0,1.0" color="1.0,1.0,1.0,1.0"
textcolor="1.0, 1.0, 1.0, 1.0"> textcolor="1.0,1.0,1.0,1.0"
<Sprite texture="Content/UI/UI_Atlas.png" sourcerect="986, 874, 11, 148" slice="988, 881, 995, 1014"/> padding="9.0, 2.0, 9.0, 2.0">
</GUIFrame> <Sprite texture="Content/UI/UI_Atlas.png" sourcerect="0, 11, 307, 11" slice="7, 13, 299, 20"/>
</GUIFrameHorizontal>
<GUIButton <GUIFrameVertical
color="0.88, 0.25, 0.15, 0.8" color="1.0,1.0,1.0,1.0"
textcolor="1.0, 1.0, 1.0, 1.0" textcolor="1.0,1.0,1.0,1.0"
outlinecolor="0.5, 0.57, 0.6, 1.0"> padding="2.0, 6.0, 2.0, 6.0">
<Sprite texture="Content/UI/UI_Atlas.png" state="Hover" sourcerect="950, 806, 9, 47" slice="953, 810, 956, 849"/> <Sprite texture="Content/UI/UI_Atlas.png" sourcerect="986, 874, 11, 148" slice="988, 881, 995, 1014"/>
<Sprite texture="Content/UI/UI_Atlas.png" state="None" sourcerect="843, 350, 9, 47" slice="846, 354, 849, 391"/> </GUIFrameVertical>
<Sprite texture="Content/UI/UI_Atlas.png" state="Pressed" sourcerect="843, 350, 9, 47" slice="846, 354, 849, 391"/>
</GUIButton>
</GUIScrollBar> </GUIScrollBar>
<GUIDropDown <GUIDropDown
+3 -4
View File
@@ -55,15 +55,14 @@ namespace Barotrauma
int x = 20, y = 20; int x = 20, y = 20;
int width = 800, height = 500; int width = 800, height = 500;
frame = new GUIFrame(new Rectangle(x, y, width, height), new Color(0.4f, 0.4f, 0.4f, 0.5f)); frame = new GUIFrame(new Rectangle(x, y, width, height), new Color(0.4f, 0.4f, 0.4f, 0.8f));
frame.Color = Color.White * 0.4f;
frame.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f); frame.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
listBox = new GUIListBox(new Rectangle(0, 0, 0, frame.Rect.Height - 40), Color.Black, "", frame); listBox = new GUIListBox(new Rectangle(0, 0, 0, frame.Rect.Height - 40), Color.Black, "", frame);
listBox.Color = Color.Black * 0.7f; //listBox.Color = Color.Black * 0.7f;
textBox = new GUITextBox(new Rectangle(0,0,0,20), Color.Black, Color.White, Alignment.BottomLeft, Alignment.Left, "", frame); textBox = new GUITextBox(new Rectangle(0,0,0,20), Color.Black, Color.White, Alignment.BottomLeft, Alignment.Left, "", frame);
textBox.Color = Color.Black * 0.7f; //textBox.Color = Color.Black * 0.7f;
//messages already added before initialization -> add them to the listbox //messages already added before initialization -> add them to the listbox
List<ColoredText> unInitializedMessages = new List<ColoredText>(Messages); List<ColoredText> unInitializedMessages = new List<ColoredText>(Messages);
+1 -1
View File
@@ -97,7 +97,7 @@ namespace Barotrauma
public void AddItem(string text, object userData = null) 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; textBlock.UserData = userData;
} }
+45 -28
View File
@@ -45,20 +45,21 @@ namespace Barotrauma
set set
{ {
barScroll = MathHelper.Clamp(value, 0.0f, 1.0f); 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); float newScroll = step == 0.0f ? barScroll : MathUtils.RoundTowardsClosest(barScroll, step);
if (isHorizontal) if (isHorizontal)
{ {
newX = (int)(newScroll * (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, 0, frame.Rect.Width - bar.Rect.Width); newX = MathHelper.Clamp(newX, (int)frame.Padding.X, frame.Rect.Width - bar.Rect.Width - (int)frame.Padding.Z);
} }
else else
{ {
newY = (int)(newScroll * (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, 0, frame.Rect.Height - bar.Rect.Height); 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); 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); parent.AddChild(this);
isHorizontal = (rect.Width > rect.Height); isHorizontal = (rect.Width > rect.Height);
frame = new GUIFrame(new Rectangle(0,0,0,0), Color.Black*0.8f, style, this); frame = new GUIFrame(new Rectangle(0,0,0,0), style, this);
GUI.Style.Apply(frame, "", this); GUI.Style.Apply(frame, isHorizontal ? "GUIFrameHorizontal" : "GUIFrameVertical", this);
//AddChild(frame);
//System.Diagnostics.Debug.WriteLine(frame.rect);
this.barSize = barSize; this.barSize = barSize;
bar = new GUIButton(new Rectangle(0, 0, 0, 0), "", color, "", this); bar = new GUIButton(new Rectangle(0, 0, 0, 0), "", color, "", this);
GUI.Style.Apply(bar, isHorizontal ? "GUIButtonHorizontal" : "GUIButtoneVertical", this);
bar.OnPressed = SelectBar; bar.OnPressed = SelectBar;
//AddChild(bar);
enabled = true; enabled = true;
@@ -131,12 +129,16 @@ namespace Barotrauma
private void UpdateRect() 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 = new Rectangle(
bar.Rect.X, bar.Rect.X,
bar.Rect.Y, bar.Rect.Y,
isHorizontal ? (int)(frame.Rect.Width * barSize) : frame.Rect.Width, isHorizontal ? (int)(width * barSize) : (int)width,
isHorizontal ? frame.Rect.Height : (int)(frame.Rect.Height * barSize)); isHorizontal ? (int)height : (int)(height * barSize));
ClampRect();
foreach (GUIComponent child in bar.children) 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) public override void Update(float deltaTime)
{ {
if (!Visible) return; if (!Visible) return;
base.Update(deltaTime); base.Update(deltaTime);
if (draggingBar != this) return; if (MouseOn == frame)
if (!PlayerInput.LeftButtonHeld()) draggingBar = null; {
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) public override void Draw(SpriteBatch spriteBatch)
@@ -174,27 +196,22 @@ namespace Barotrauma
} }
private void MoveButton() private void MoveButton(Vector2 moveAmount)
{ {
float moveAmount;
if (isHorizontal) if (isHorizontal)
{ {
moveAmount = PlayerInput.MouseSpeed.X; moveAmount.Y = 0.0f;
barScroll += moveAmount / (frame.Rect.Width - bar.Rect.Width); barScroll += moveAmount.X / (frame.Rect.Width - bar.Rect.Width - frame.Padding.X - frame.Padding.Z);
} }
else else
{ {
moveAmount = PlayerInput.MouseSpeed.Y; moveAmount.X = 0.0f;
barScroll += moveAmount / (frame.Rect.Height - bar.Rect.Height); barScroll += moveAmount.Y / (frame.Rect.Height - bar.Rect.Height - frame.Padding.Y - frame.Padding.W);
} }
BarScroll = barScroll; BarScroll = barScroll;
if (moveAmount != 0 && OnMoved != null) OnMoved(this, BarScroll); if (moveAmount != Vector2.Zero && OnMoved != null) OnMoved(this, BarScroll);
//bar.Rect = new Rectangle(newX + frame.Rect.X, newY + frame.Rect.Y, bar.Rect.Width, bar.Rect.Height);
} }
} }
+2 -7
View File
@@ -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) : base(style)
{ {
Enabled = true; Enabled = true;
@@ -174,8 +174,6 @@ namespace Barotrauma
if (color != null) this.color = (Color)color; if (color != null) this.color = (Color)color;
this.alignment = alignment; this.alignment = alignment;
//this.textAlignment = textAlignment;
if (parent != null) if (parent != null)
parent.AddChild(this); parent.AddChild(this);
@@ -186,11 +184,8 @@ namespace Barotrauma
GUI.Style.Apply(textBlock, style == "" ? "GUITextBox" : style); GUI.Style.Apply(textBlock, style == "" ? "GUITextBox" : style);
textBlock.Padding = new Vector4(3.0f, 0.0f, 3.0f, 0.0f); textBlock.Padding = new Vector4(3.0f, 0.0f, 3.0f, 0.0f);
//previousMouse = PlayerInput.GetMouseState;
CaretEnabled = true; CaretEnabled = true;
//SetTextPos();
} }
public void Select() public void Select()
+2 -2
View File
@@ -406,8 +406,8 @@ namespace Barotrauma
var inputNames = Enum.GetNames(typeof(InputType)); var inputNames = Enum.GetNames(typeof(InputType));
for (int i = 0; i< inputNames.Length; i++) for (int i = 0; i< inputNames.Length; i++)
{ {
new GUITextBlock(new Rectangle(x, y, 100, 20), inputNames[i]+": ", "", 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, 15), "", 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.Text = keyMapping[i].ToString();
keyBox.UserData = i; keyBox.UserData = i;
@@ -315,7 +315,7 @@ namespace Barotrauma.Networking
settingsTabs = new GUIFrame[tabNames.Length]; settingsTabs = new GUIFrame[tabNames.Length];
for (int i = 0; i < tabNames.Length; i++) 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); 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); var tabButton = new GUIButton(new Rectangle(85 * i, 35, 80, 20), tabNames[i], "", innerFrame);
+12 -18
View File
@@ -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] = 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); 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]); GUITextBox searchBox = new GUITextBox(new Rectangle(-20, 0, 180, 15), Alignment.TopRight, "", GUItabs[i]);
searchBox.Font = GUI.SmallFont; searchBox.Font = GUI.SmallFont;
@@ -206,22 +206,16 @@ namespace Barotrauma
foreach (MapEntityPrefab ep in MapEntityPrefab.list) foreach (MapEntityPrefab ep in MapEntityPrefab.list)
{ {
if (!ep.Category.HasFlag(category)) continue; 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, "ListBoxElement", itemList);
GUIFrame frame = new GUIFrame(new Rectangle(0, 0, 0, 50), Color.Transparent, null, itemList);
frame.UserData = ep; frame.UserData = ep;
frame.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f); 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( GUITextBlock textBlock = new GUITextBlock(
new Rectangle(40, 0, 0, 25), new Rectangle(40, 0, 0, 25),
ep.Name, ep.Name, "",
Color.Transparent, Color.White, Alignment.Top, Alignment.CenterLeft,
Alignment.Left, Alignment.Left, frame);
null, frame);
textBlock.Padding = new Vector4(5.0f, 0.0f, 5.0f, 0.0f); textBlock.Padding = new Vector4(5.0f, 0.0f, 5.0f, 0.0f);
if (!string.IsNullOrWhiteSpace(ep.Description)) if (!string.IsNullOrWhiteSpace(ep.Description))
@@ -231,7 +225,7 @@ namespace Barotrauma
if (ep.sprite != null) 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.Scale = Math.Min(Math.Min(40.0f / img.SourceRect.Width, 40.0f / img.SourceRect.Height), 1.0f);
img.Color = ep.SpriteColor; img.Color = ep.SpriteColor;
} }
@@ -242,7 +236,7 @@ namespace Barotrauma
i++; i++;
} }
y+=50; y += 50;
button = new GUIButton(new Rectangle(0, y, 0, 20), "Character mode", Alignment.Left, "", leftPanel); 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.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; button.OnClicked = ToggleCharacterMode;
@@ -251,13 +245,13 @@ namespace Barotrauma
button = new GUIButton(new Rectangle(0, y, 0, 20), "Wiring mode", Alignment.Left, "", leftPanel); 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.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; button.OnClicked = ToggleWiringMode;
y+=50; y += 50;
button = new GUIButton(new Rectangle(0, y, 0, 20), "Generate waypoints", Alignment.Left, "", leftPanel); 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.ToolTip = "AI controlled crew members require waypoints to navigate around the sub.";
button.OnClicked = GenerateWaypoints; button.OnClicked = GenerateWaypoints;
y+=50; y += 50;
new GUITextBlock(new Rectangle(0, y, 0, 20), "Show:", "", leftPanel); new GUITextBlock(new Rectangle(0, y, 0, 20), "Show:", "", leftPanel);
+2 -2
View File
@@ -211,7 +211,7 @@ namespace Barotrauma
{ {
var textBlock = new GUITextBlock( var textBlock = new GUITextBlock(
new Rectangle(0, 0, 0, 25), 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) Alignment.Left, Alignment.Left, subList)
{ {
Padding = new Vector4(10.0f, 0.0f, 0.0f, 0.0f), Padding = new Vector4(10.0f, 0.0f, 0.0f, 0.0f),
@@ -396,7 +396,7 @@ namespace Barotrauma
GUITextBlock textBlock = new GUITextBlock( GUITextBlock textBlock = new GUITextBlock(
new Rectangle(0, 0, 0, 25), new Rectangle(0, 0, 0, 25),
saveFile, saveFile,
"", "ListBoxElement",
Alignment.Left, Alignment.Left,
Alignment.Left, Alignment.Left,
saveList); saveList);
+2 -2
View File
@@ -250,7 +250,7 @@ namespace Barotrauma
GUITextBlock textBlock = new GUITextBlock( GUITextBlock textBlock = new GUITextBlock(
new Rectangle(0, 0, 0, 25), new Rectangle(0, 0, 0, 25),
mode.Name, "", mode.Name, "ListBoxElement",
Alignment.TopLeft, Alignment.CenterLeft, Alignment.TopLeft, Alignment.CenterLeft,
modeList); modeList);
textBlock.ToolTip = mode.Description; textBlock.ToolTip = mode.Description;
@@ -673,7 +673,7 @@ namespace Barotrauma
public void AddSubmarine(GUIComponent subList, Submarine sub) public void AddSubmarine(GUIComponent subList, Submarine sub)
{ {
var subTextBlock = new GUITextBlock( 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) Alignment.TopLeft, Alignment.CenterLeft, subList)
{ {
Padding = new Vector4(10.0f, 0.0f, 0.0f, 0.0f), Padding = new Vector4(10.0f, 0.0f, 0.0f, 0.0f),
@@ -52,7 +52,7 @@ namespace Barotrauma
serverList = new GUIListBox(new Rectangle(middleX,60,0,height-160), "", menu); serverList = new GUIListBox(new Rectangle(middleX,60,0,height-160), "", menu);
serverList.OnSelected = SelectServer; 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]; columnX = new int[columnRelativeX.Length];
for (int n = 0; n < columnX.Length; n++) for (int n = 0; n < columnX.Length; n++)
{ {
@@ -166,12 +166,10 @@ namespace Barotrauma
string hasPassWordStr = (arguments.Length > 6) ? arguments[6] : ""; 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.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.Selected = hasPassWordStr == "1";
passwordBox.Enabled = false; passwordBox.Enabled = false;
passwordBox.UserData = "password"; 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); 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.Selected = gameStarted == "1";
gameStartedBox.Enabled = false; gameStartedBox.Enabled = false;