Fixed vote count text overlapping with the submarine preview button in NetLobbyScreen

This commit is contained in:
Joonas Rikkonen
2018-01-26 10:36:34 +02:00
parent a1ccf501c7
commit ad18eb0db0
5 changed files with 43 additions and 28 deletions
@@ -135,9 +135,13 @@ namespace Barotrauma
private bool SelectItem(GUIComponent component, object obj) private bool SelectItem(GUIComponent component, object obj)
{ {
GUITextBlock textBlock = component as GUITextBlock; GUITextBlock textBlock = component as GUITextBlock;
if (textBlock == null) return false; if (textBlock == null)
button.Text = textBlock.Text; {
textBlock = component.GetChild<GUITextBlock>();
if (textBlock == null) return false;
}
button.Text = textBlock.Text;
Dropped = false; Dropped = false;
if (OnSelected != null) OnSelected(component, component.UserData); if (OnSelected != null) OnSelected(component, component.UserData);
@@ -83,7 +83,7 @@ namespace Barotrauma
set set
{ {
enabled = value; enabled = value;
scrollBar.Enabled = value; //scrollBar.Enabled = value;
} }
} }
@@ -69,7 +69,7 @@ namespace Barotrauma
GUIListBox listBox = (voteType == VoteType.Sub) ? GUIListBox listBox = (voteType == VoteType.Sub) ?
GameMain.NetLobbyScreen.SubList : GameMain.NetLobbyScreen.ModeList; GameMain.NetLobbyScreen.SubList : GameMain.NetLobbyScreen.ModeList;
foreach (GUITextBlock comp in listBox.children) foreach (GUIComponent comp in listBox.children)
{ {
GUITextBlock voteText = comp.FindChild("votes") as GUITextBlock; GUITextBlock voteText = comp.FindChild("votes") as GUITextBlock;
if (voteText != null) comp.RemoveChild(voteText); if (voteText != null) comp.RemoveChild(voteText);
@@ -10,27 +10,24 @@ namespace Barotrauma
{ {
class CharacterEditorScreen : Screen class CharacterEditorScreen : Screen
{ {
Camera cam; private Camera cam;
GUIComponent GUIpanel; private GUIComponent GUIpanel;
GUIButton physicsButton; private GUIButton physicsButton;
GUIListBox limbList, jointList; private GUIListBox limbList, jointList;
GUIFrame limbPanel; private GUIFrame limbPanel;
Character editingCharacter;
Limb editingLimb;
//RevoluteJoint editingJoint;
private Character editingCharacter;
private Limb editingLimb;
private List<Texture2D> textures;
List<Texture2D> textures; private List<string> texturePaths;
List<string> texturePaths;
private bool physicsEnabled; private bool physicsEnabled;
public Camera Cam public override Camera Cam
{ {
get { return cam; } get { return cam; }
} }
@@ -99,6 +96,8 @@ namespace Barotrauma
{ {
cam.MoveCamera((float)deltaTime); cam.MoveCamera((float)deltaTime);
GUIpanel.Update((float)deltaTime);
if (physicsEnabled) if (physicsEnabled)
{ {
Character.UpdateAnimAll((float)deltaTime); Character.UpdateAnimAll((float)deltaTime);
@@ -109,6 +108,11 @@ namespace Barotrauma
} }
} }
public override void AddToGUIUpdateList()
{
GUIpanel.AddToGUIUpdateList();
}
/// <summary> /// <summary>
/// This is called when the game should draw itself. /// This is called when the game should draw itself.
/// </summary> /// </summary>
@@ -756,27 +756,31 @@ namespace Barotrauma
public void AddSubmarine(GUIComponent subList, Submarine sub) public void AddSubmarine(GUIComponent subList, Submarine sub)
{ {
var subTextBlock = new GUITextBlock( var frame = new GUIFrame(new Rectangle(0, 0, 0, 25), "ListBoxElement", subList)
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),
ToolTip = sub.Description, ToolTip = sub.Description,
UserData = sub UserData = sub
}; };
var subTextBlock = new GUITextBlock(
new Rectangle(20, 0, 0, 0), ToolBox.LimitString(sub.Name, GUI.Font, subList.Rect.Width - 65), "",
Alignment.TopLeft, Alignment.CenterLeft, frame)
{
CanBeFocused = false
};
var matchingSub = Submarine.SavedSubmarines.Find(s => s.Name == sub.Name && s.MD5Hash.Hash == sub.MD5Hash.Hash); var matchingSub = Submarine.SavedSubmarines.Find(s => s.Name == sub.Name && s.MD5Hash.Hash == sub.MD5Hash.Hash);
if (matchingSub == null) matchingSub = Submarine.SavedSubmarines.Find(s => s.Name == sub.Name); if (matchingSub == null) matchingSub = Submarine.SavedSubmarines.Find(s => s.Name == sub.Name);
if (matchingSub == null) if (matchingSub == null)
{ {
subTextBlock.TextColor = new Color(subTextBlock.TextColor, 0.5f); subTextBlock.TextColor = new Color(subTextBlock.TextColor, 0.5f);
subTextBlock.ToolTip = TextManager.Get("SubNotFound"); frame.ToolTip = TextManager.Get("SubNotFound");
} }
else if (matchingSub.MD5Hash.Hash != sub.MD5Hash.Hash) else if (matchingSub.MD5Hash.Hash != sub.MD5Hash.Hash)
{ {
subTextBlock.TextColor = new Color(subTextBlock.TextColor, 0.5f); subTextBlock.TextColor = new Color(subTextBlock.TextColor, 0.5f);
subTextBlock.ToolTip = TextManager.Get("SubDoesntMatch"); frame.ToolTip = TextManager.Get("SubDoesntMatch");
} }
else else
{ {
@@ -785,7 +789,7 @@ namespace Barotrauma
subTextBlock.TextColor = new Color(subTextBlock.TextColor, sub.HasTag(SubmarineTag.Shuttle) ? 1.0f : 0.6f); subTextBlock.TextColor = new Color(subTextBlock.TextColor, sub.HasTag(SubmarineTag.Shuttle) ? 1.0f : 0.6f);
} }
GUIButton infoButton = new GUIButton(new Rectangle(0, 0, 20, 20), "?", Alignment.CenterRight, "", subTextBlock); GUIButton infoButton = new GUIButton(new Rectangle(0, 0, 20, 20), "?", Alignment.CenterLeft, "", frame);
infoButton.UserData = sub; infoButton.UserData = sub;
infoButton.OnClicked += (component, userdata) => infoButton.OnClicked += (component, userdata) =>
{ {
@@ -797,9 +801,12 @@ namespace Barotrauma
if (sub.HasTag(SubmarineTag.Shuttle)) if (sub.HasTag(SubmarineTag.Shuttle))
{ {
var shuttleText = new GUITextBlock(new Rectangle(-20, 0, 0, 25), TextManager.Get("Shuttle"), "", Alignment.CenterRight, Alignment.CenterRight, subTextBlock, false, GUI.SmallFont); new GUITextBlock(new Rectangle(-20, 0, 0, 25), TextManager.Get("Shuttle"), "", Alignment.CenterRight, Alignment.CenterRight, subTextBlock, false, GUI.SmallFont)
shuttleText.TextColor = subTextBlock.TextColor * 0.8f; {
shuttleText.ToolTip = subTextBlock.ToolTip; TextColor = subTextBlock.TextColor * 0.8f,
ToolTip = subTextBlock.ToolTip,
CanBeFocused = false
};
} }
} }