Limiting too long location names in navigation terminals & end shift button
This commit is contained in:
@@ -197,13 +197,13 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
else if (leavingSub.AtEndPosition)
|
else if (leavingSub.AtEndPosition)
|
||||||
{
|
{
|
||||||
endShiftButton.Text = "Enter " + Map.SelectedLocation.Name;
|
endShiftButton.Text = ToolBox.LimitString("Enter " + Map.SelectedLocation.Name, endShiftButton.Font, endShiftButton.Rect.Width - 5);
|
||||||
endShiftButton.UserData = leavingSub;
|
endShiftButton.UserData = leavingSub;
|
||||||
endShiftButton.Visible = true;
|
endShiftButton.Visible = true;
|
||||||
}
|
}
|
||||||
else if (leavingSub.AtStartPosition)
|
else if (leavingSub.AtStartPosition)
|
||||||
{
|
{
|
||||||
endShiftButton.Text = "Enter " + Map.CurrentLocation.Name;
|
endShiftButton.Text = ToolBox.LimitString("Enter " + Map.CurrentLocation.Name, endShiftButton.Font, endShiftButton.Rect.Width - 5);
|
||||||
endShiftButton.UserData = leavingSub;
|
endShiftButton.UserData = leavingSub;
|
||||||
endShiftButton.Visible = true;
|
endShiftButton.Visible = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -395,12 +395,15 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
if (dir.X < 0.0f) markerPos.X -= GUI.SmallFont.MeasureString(label).X+10;
|
if (dir.X < 0.0f) markerPos.X -= GUI.SmallFont.MeasureString(label).X+10;
|
||||||
|
|
||||||
GUI.DrawString(spriteBatch, new Vector2(markerPos.X + 10, markerPos.Y), label, Color.LightGreen * textAlpha, Color.Black * textAlpha*0.5f, 2, GUI.SmallFont);
|
string wrappedLabel = ToolBox.WrapText(label, 150, GUI.SmallFont);
|
||||||
|
|
||||||
GUI.DrawString(spriteBatch, new Vector2(markerPos.X + 10, markerPos.Y + 15), (int)(dist * Physics.DisplayToRealWorldRatio) + " m",
|
wrappedLabel += "\n"+((int)(dist * Physics.DisplayToRealWorldRatio) + " m");
|
||||||
Color.LightGreen * textAlpha,
|
|
||||||
Color.Black * textAlpha, 2, GUI.SmallFont);
|
|
||||||
|
|
||||||
|
GUI.DrawString(spriteBatch,
|
||||||
|
new Vector2(markerPos.X + 10, markerPos.Y),
|
||||||
|
wrappedLabel,
|
||||||
|
Color.LightGreen * textAlpha, Color.Black * textAlpha * 0.5f,
|
||||||
|
2, GUI.SmallFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void RemoveComponentSpecific()
|
protected override void RemoveComponentSpecific()
|
||||||
|
|||||||
@@ -123,14 +123,14 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
levelStartTickBox = new GUITickBox(
|
levelStartTickBox = new GUITickBox(
|
||||||
new Rectangle(5, 70, 15, 15),
|
new Rectangle(5, 70, 15, 15),
|
||||||
GameMain.GameSession.StartLocation.Name,
|
ToolBox.LimitString(GameMain.GameSession.StartLocation.Name, 20),
|
||||||
Alignment.TopLeft, GUI.SmallFont, GuiFrame);
|
Alignment.TopLeft, GUI.SmallFont, GuiFrame);
|
||||||
levelStartTickBox.Enabled = false;
|
levelStartTickBox.Enabled = false;
|
||||||
levelStartTickBox.OnSelected = SelectDestination;
|
levelStartTickBox.OnSelected = SelectDestination;
|
||||||
|
|
||||||
levelEndTickBox = new GUITickBox(
|
levelEndTickBox = new GUITickBox(
|
||||||
new Rectangle(5, 90, 15, 15),
|
new Rectangle(5, 90, 15, 15),
|
||||||
GameMain.GameSession.EndLocation.Name,
|
ToolBox.LimitString(GameMain.GameSession.EndLocation.Name, 20),
|
||||||
Alignment.TopLeft, GUI.SmallFont, GuiFrame);
|
Alignment.TopLeft, GUI.SmallFont, GuiFrame);
|
||||||
levelEndTickBox.Enabled = false;
|
levelEndTickBox.Enabled = false;
|
||||||
levelEndTickBox.OnSelected = SelectDestination;
|
levelEndTickBox.OnSelected = SelectDestination;
|
||||||
@@ -139,8 +139,6 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
public override void Update(float deltaTime, Camera cam)
|
public override void Update(float deltaTime, Camera cam)
|
||||||
{
|
{
|
||||||
//base.Update(deltaTime, cam);
|
|
||||||
|
|
||||||
if (valueChanged)
|
if (valueChanged)
|
||||||
{
|
{
|
||||||
networkUpdateTimer -= deltaTime;
|
networkUpdateTimer -= deltaTime;
|
||||||
|
|||||||
@@ -343,8 +343,6 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (maxWidth <= 0 || string.IsNullOrWhiteSpace(str)) return "";
|
if (maxWidth <= 0 || string.IsNullOrWhiteSpace(str)) return "";
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
|
|
||||||
float currWidth = font.MeasureString("...").X;
|
float currWidth = font.MeasureString("...").X;
|
||||||
for (int i = 0; i < str.Length; i++ )
|
for (int i = 0; i < str.Length; i++ )
|
||||||
{
|
{
|
||||||
@@ -352,7 +350,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (currWidth > maxWidth)
|
if (currWidth > maxWidth)
|
||||||
{
|
{
|
||||||
return str.Substring(0, i + 1) + "...";
|
return str.Substring(0, Math.Max(i - 2, 1)) + "...";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user