(bf212a41f) v0.9.2.0 pre-release test version
This commit is contained in:
@@ -2788,6 +2788,7 @@ namespace Barotrauma
|
||||
if (editRagdoll || !editLimbs && !editJoints)
|
||||
{
|
||||
RagdollParams.AddToEditor(ParamsEditor.Instance, alsoChildren: false);
|
||||
RagdollParams.ColliderParams.ForEach(c => c.AddToEditor(ParamsEditor.Instance));
|
||||
}
|
||||
if (editJoints)
|
||||
{
|
||||
@@ -3041,14 +3042,16 @@ namespace Barotrauma
|
||||
|
||||
private void CalculateSpritesheetZoom()
|
||||
{
|
||||
float width = textures.OrderByDescending(t => t.Width).First().Width;
|
||||
var texture = textures.OrderByDescending(t => t.Width).FirstOrDefault();
|
||||
if (texture == null)
|
||||
{
|
||||
spriteSheetZoom = 1;
|
||||
return;
|
||||
}
|
||||
float width = texture.Width;
|
||||
float height = textures.Sum(t => t.Height);
|
||||
float margin = 20;
|
||||
if (textures == null || textures.None())
|
||||
{
|
||||
spriteSheetMaxZoom = 1;
|
||||
}
|
||||
else if (height > width)
|
||||
if (height > width)
|
||||
{
|
||||
spriteSheetMaxZoom = (centerArea.Rect.Bottom - spriteSheetOffsetY - margin) / height;
|
||||
}
|
||||
|
||||
@@ -415,9 +415,22 @@ namespace Barotrauma
|
||||
ServerInfo s1 = c1.GUIComponent.UserData as ServerInfo;
|
||||
ServerInfo s2 = c2.GUIComponent.UserData as ServerInfo;
|
||||
|
||||
if (s1 == null && s2 == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (s1 == null)
|
||||
{
|
||||
return ascending ? 1 : -1;
|
||||
}
|
||||
else if (s2 == null)
|
||||
{
|
||||
return ascending ? -1 : 1;
|
||||
}
|
||||
|
||||
switch (sortBy)
|
||||
{
|
||||
case "ServerListCompatible":
|
||||
case "ServerListCompatible":
|
||||
bool? s1Compatible = NetworkMember.IsCompatible(GameMain.Version.ToString(), s1.GameVersion);
|
||||
if (!s1.ContentPackageHashes.Any()) { s1Compatible = null; }
|
||||
if (s1Compatible.HasValue) { s1Compatible = s1Compatible.Value && s1.ContentPackagesMatch(GameMain.SelectedPackages); };
|
||||
@@ -441,7 +454,7 @@ namespace Barotrauma
|
||||
if (s1.HasPassword == s2.HasPassword) { return 0; }
|
||||
return (s1.HasPassword ? 1 : -1) * (ascending ? 1 : -1);
|
||||
case "ServerListName":
|
||||
return s1.ServerName.CompareTo(s2.ServerName) * (ascending ? 1 : -1);
|
||||
return string.Compare(s1.ServerName, s2.ServerName) * (ascending ? 1 : -1);
|
||||
case "ServerListRoundStarted":
|
||||
if (s1.GameStarted == s2.GameStarted) { return 0; }
|
||||
return (s1.GameStarted ? 1 : -1) * (ascending ? 1 : -1);
|
||||
|
||||
@@ -20,6 +20,8 @@ namespace Barotrauma
|
||||
private GUIFrame bottomPanel;
|
||||
private GUIFrame backgroundColorPanel;
|
||||
|
||||
private bool drawGrid, snapToGrid;
|
||||
|
||||
private GUIFrame topPanelContents;
|
||||
private GUITextBlock texturePathText;
|
||||
private GUITextBlock xmlPathText;
|
||||
@@ -137,7 +139,7 @@ namespace Barotrauma
|
||||
return true;
|
||||
}
|
||||
};
|
||||
new GUIButton(new RectTransform(new Vector2(0.05f, 0.35f), topPanelContents.RectTransform, Anchor.TopCenter, Pivot.CenterLeft) { RelativeOffset = new Vector2(0.055f, 0.3f) }, "Reset Zoom")
|
||||
var resetBtn = new GUIButton(new RectTransform(new Vector2(0.05f, 0.35f), topPanelContents.RectTransform, Anchor.TopCenter, Pivot.CenterLeft) { RelativeOffset = new Vector2(0.055f, 0.3f) }, "Reset Zoom")
|
||||
{
|
||||
OnClicked = (box, data) =>
|
||||
{
|
||||
@@ -145,6 +147,26 @@ namespace Barotrauma
|
||||
return true;
|
||||
}
|
||||
};
|
||||
resetBtn.TextBlock.AutoScale = true;
|
||||
|
||||
new GUITickBox(new RectTransform(new Vector2(0.2f, 0.2f), topPanelContents.RectTransform, Anchor.BottomCenter, Pivot.CenterRight) { RelativeOffset = new Vector2(0, 0.3f) }, "Show grid")
|
||||
{
|
||||
Selected = drawGrid,
|
||||
OnSelected = (tickBox) =>
|
||||
{
|
||||
drawGrid = tickBox.Selected;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
new GUITickBox(new RectTransform(new Vector2(0.2f, 0.2f), topPanelContents.RectTransform, Anchor.BottomCenter, Pivot.CenterRight) { RelativeOffset = new Vector2(0.17f, 0.3f) }, "Snap to grid")
|
||||
{
|
||||
Selected = snapToGrid,
|
||||
OnSelected = (tickBox) =>
|
||||
{
|
||||
snapToGrid = tickBox.Selected;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
texturePathText = new GUITextBlock(new RectTransform(new Vector2(0.5f, 0.4f), topPanelContents.RectTransform, Anchor.Center, Pivot.BottomCenter) { RelativeOffset = new Vector2(0.4f, 0) }, "", Color.LightGray);
|
||||
xmlPathText = new GUITextBlock(new RectTransform(new Vector2(0.5f, 0.4f), topPanelContents.RectTransform, Anchor.Center, Pivot.TopCenter) { RelativeOffset = new Vector2(0.4f, 0) }, "", Color.LightGray);
|
||||
@@ -230,8 +252,7 @@ namespace Barotrauma
|
||||
}, style: null, color: Color.Black * 0.6f);
|
||||
var colorLabel = new GUITextBlock(new RectTransform(new Vector2(0.3f, 1), element.RectTransform, Anchor.CenterLeft), colorComponentLabels[i],
|
||||
font: GUI.SmallFont, textAlignment: Alignment.CenterLeft);
|
||||
GUINumberInput numberInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1), element.RectTransform, Anchor.CenterRight),
|
||||
GUINumberInput.NumberType.Int)
|
||||
var numberInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1), element.RectTransform, Anchor.CenterRight), GUINumberInput.NumberType.Int)
|
||||
{
|
||||
Font = GUI.SmallFont
|
||||
};
|
||||
@@ -259,26 +280,32 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private HashSet<Sprite> loadedSprites = new HashSet<Sprite>();
|
||||
private readonly HashSet<Sprite> loadedSprites = new HashSet<Sprite>();
|
||||
private void LoadSprites()
|
||||
{
|
||||
loadedSprites.ForEach(s => s.Remove());
|
||||
loadedSprites.Clear();
|
||||
//foreach (string filePath in ContentPackage.GetAllContentFiles(GameMain.SelectedPackages))
|
||||
//{
|
||||
// XDocument doc = XMLExtensions.TryLoadXml(filePath);
|
||||
// if (doc != null && doc.Root != null)
|
||||
// {
|
||||
// LoadSprites(doc.Root);
|
||||
// }
|
||||
//}
|
||||
var contentPackages = GameMain.Config.SelectedContentPackages.ToList();
|
||||
|
||||
foreach (string filePath in Directory.GetFiles("Content/", "*.xml", SearchOption.AllDirectories))
|
||||
#if !DEBUG
|
||||
var vanilla = GameMain.VanillaContent;
|
||||
if (vanilla != null)
|
||||
{
|
||||
XDocument doc = XMLExtensions.TryLoadXml(filePath);
|
||||
if (doc != null && doc.Root != null)
|
||||
contentPackages.Remove(vanilla);
|
||||
}
|
||||
#endif
|
||||
foreach (var contentPackage in contentPackages)
|
||||
{
|
||||
foreach (var file in contentPackage.Files)
|
||||
{
|
||||
LoadSprites(doc.Root);
|
||||
if (file.Path.EndsWith(".xml"))
|
||||
{
|
||||
XDocument doc = XMLExtensions.TryLoadXml(file.Path);
|
||||
if (doc != null && doc.Root != null)
|
||||
{
|
||||
LoadSprites(doc.Root);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -304,11 +331,12 @@ namespace Barotrauma
|
||||
{
|
||||
string spriteFolder = "";
|
||||
string textureElement = element.GetAttributeString("texture", "");
|
||||
// TODO: parse and create
|
||||
// TODO: parse and create?
|
||||
if (textureElement.Contains("[GENDER]") || textureElement.Contains("[HEADID]") || textureElement.Contains("[RACE]")) { return; }
|
||||
if (!textureElement.Contains("/"))
|
||||
{
|
||||
spriteFolder = Path.GetDirectoryName(element.ParseContentPathFromUri());
|
||||
var parsedPath = element.ParseContentPathFromUri();
|
||||
spriteFolder = Path.GetDirectoryName(parsedPath);
|
||||
}
|
||||
// Uncomment if we do multiple passes -> there can be duplicates
|
||||
//string identifier = Sprite.GetID(element);
|
||||
@@ -344,7 +372,7 @@ namespace Barotrauma
|
||||
xmlPathText.TextColor = Color.LightGreen;
|
||||
return true;
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Public methods
|
||||
public override void AddToGUIUpdateList()
|
||||
@@ -466,6 +494,11 @@ namespace Barotrauma
|
||||
//GUI.DrawRectangle(spriteBatch, viewArea, Color.Green, isFilled: false);
|
||||
GUI.DrawRectangle(spriteBatch, textureRect, Color.Gray, isFilled: false);
|
||||
|
||||
if (drawGrid)
|
||||
{
|
||||
DrawGrid(spriteBatch, textureRect, zoom, Submarine.GridSize);
|
||||
}
|
||||
|
||||
foreach (GUIComponent element in spriteList.Content.Children)
|
||||
{
|
||||
Sprite sprite = element.UserData as Sprite;
|
||||
@@ -507,8 +540,11 @@ namespace Barotrauma
|
||||
w.tooltip = $"Position: {sprite.SourceRect.Location}";
|
||||
w.MouseHeld += dTime =>
|
||||
{
|
||||
w.DrawPos = PlayerInput.MousePosition;
|
||||
sprite.SourceRect = new Rectangle(((w.DrawPos + new Vector2(w.size / 2) - textureRect.Location.ToVector2()) / zoom).ToPoint(), sprite.SourceRect.Size);
|
||||
w.DrawPos = (drawGrid && snapToGrid) ?
|
||||
SnapToGrid(PlayerInput.MousePosition, textureRect, zoom, Submarine.GridSize, Submarine.GridSize.X / 4.0f * zoom) :
|
||||
PlayerInput.MousePosition;
|
||||
w.DrawPos = new Vector2((float)Math.Ceiling(w.DrawPos.X), (float)Math.Ceiling(w.DrawPos.Y));
|
||||
sprite.SourceRect = new Rectangle(((w.DrawPos - textureRect.Location.ToVector2()) / zoom).ToPoint(), sprite.SourceRect.Size);
|
||||
if (spriteList.SelectedComponent is GUITextBlock textBox)
|
||||
{
|
||||
// TODO: cache the sprite name?
|
||||
@@ -516,15 +552,18 @@ namespace Barotrauma
|
||||
}
|
||||
w.tooltip = $"Position: {sprite.SourceRect.Location}";
|
||||
};
|
||||
w.refresh = () => w.DrawPos = textureRect.Location.ToVector2() + sprite.SourceRect.Location.ToVector2() * zoom - new Vector2(w.size / 2);
|
||||
w.refresh = () => w.DrawPos = textureRect.Location.ToVector2() + sprite.SourceRect.Location.ToVector2() * zoom;
|
||||
});
|
||||
var sizeWidget = GetWidget($"{id}_size", sprite, widgetSize, Widget.Shape.Rectangle, initMethod: w =>
|
||||
{
|
||||
w.tooltip = $"Size: {sprite.SourceRect.Size}";
|
||||
w.MouseHeld += dTime =>
|
||||
{
|
||||
w.DrawPos = PlayerInput.MousePosition;
|
||||
sprite.SourceRect = new Rectangle(sprite.SourceRect.Location, ((w.DrawPos - new Vector2(w.size) - positionWidget.DrawPos) / zoom).ToPoint());
|
||||
w.DrawPos = (drawGrid && snapToGrid) ?
|
||||
SnapToGrid(PlayerInput.MousePosition, textureRect, zoom, Submarine.GridSize, Submarine.GridSize.X / 4.0f * zoom) :
|
||||
PlayerInput.MousePosition;
|
||||
w.DrawPos = new Vector2((float)Math.Ceiling(w.DrawPos.X), (float)Math.Ceiling(w.DrawPos.Y));
|
||||
sprite.SourceRect = new Rectangle(sprite.SourceRect.Location, ((w.DrawPos - positionWidget.DrawPos) / zoom).ToPoint());
|
||||
// TODO: allow to lock the origin
|
||||
sprite.RelativeOrigin = sprite.RelativeOrigin;
|
||||
if (spriteList.SelectedComponent is GUITextBlock textBox)
|
||||
@@ -534,7 +573,7 @@ namespace Barotrauma
|
||||
}
|
||||
w.tooltip = $"Size: {sprite.SourceRect.Size}";
|
||||
};
|
||||
w.refresh = () => w.DrawPos = textureRect.Location.ToVector2() + new Vector2(sprite.SourceRect.Right, sprite.SourceRect.Bottom) * zoom + new Vector2(w.size / 2);
|
||||
w.refresh = () => w.DrawPos = textureRect.Location.ToVector2() + new Vector2(sprite.SourceRect.Right, sprite.SourceRect.Bottom) * zoom;
|
||||
});
|
||||
if (isSelected)
|
||||
{
|
||||
@@ -553,6 +592,58 @@ namespace Barotrauma
|
||||
spriteBatch.End();
|
||||
}
|
||||
|
||||
private void DrawGrid(SpriteBatch spriteBatch, Rectangle gridArea, float zoom, Vector2 gridSize)
|
||||
{
|
||||
gridSize *= zoom;
|
||||
if (gridSize.X < 1.0f) { return; }
|
||||
if (gridSize.Y < 1.0f) { return; }
|
||||
int xLines = (int)(gridArea.Width / gridSize.X);
|
||||
int yLines = (int)(gridArea.Height / gridSize.Y);
|
||||
|
||||
for (int x = 0; x <= xLines; x++)
|
||||
{
|
||||
GUI.DrawLine(spriteBatch,
|
||||
new Vector2(gridArea.X + x * gridSize.X, gridArea.Y),
|
||||
new Vector2(gridArea.X + x * gridSize.X, gridArea.Bottom),
|
||||
Color.White * 0.25f);
|
||||
}
|
||||
for (int y = 0; y <= yLines; y++)
|
||||
{
|
||||
GUI.DrawLine(spriteBatch,
|
||||
new Vector2(gridArea.X, gridArea.Y + y * gridSize.Y),
|
||||
new Vector2(gridArea.Right, gridArea.Y + y * gridSize.Y),
|
||||
Color.White * 0.25f);
|
||||
}
|
||||
}
|
||||
|
||||
private Vector2 SnapToGrid(Vector2 position, Rectangle gridArea, float zoom, Vector2 gridSize, float tolerance)
|
||||
{
|
||||
gridSize *= zoom;
|
||||
if (gridSize.X < 1.0f) { return position; }
|
||||
if (gridSize.Y < 1.0f) { return position; }
|
||||
|
||||
Vector2 snappedPos = position;
|
||||
snappedPos.X -= gridArea.X;
|
||||
snappedPos.Y -= gridArea.Y;
|
||||
|
||||
Vector2 gridPos = new Vector2(
|
||||
MathUtils.RoundTowardsClosest(snappedPos.X, gridSize.X),
|
||||
MathUtils.RoundTowardsClosest(snappedPos.Y, gridSize.Y));
|
||||
|
||||
if (Math.Abs(gridPos.X - snappedPos.X) < tolerance)
|
||||
{
|
||||
snappedPos.X = gridPos.X;
|
||||
}
|
||||
if (Math.Abs(gridPos.Y - snappedPos.Y) < tolerance)
|
||||
{
|
||||
snappedPos.Y = gridPos.Y;
|
||||
}
|
||||
|
||||
snappedPos.X += gridArea.X;
|
||||
snappedPos.Y += gridArea.Y;
|
||||
return snappedPos;
|
||||
}
|
||||
|
||||
public override void Select()
|
||||
{
|
||||
base.Select();
|
||||
@@ -706,7 +797,7 @@ namespace Barotrauma
|
||||
zoomBar.BarScroll = GetBarScrollValue();
|
||||
viewAreaOffset = Point.Zero;
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Helpers
|
||||
private Point viewAreaOffset;
|
||||
@@ -750,7 +841,7 @@ namespace Barotrauma
|
||||
// Keeps the relative origin unchanged. The absolute origin will be recalculated.
|
||||
sprite.RelativeOrigin = sprite.RelativeOrigin;
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Widgets
|
||||
private Dictionary<string, Widget> widgets = new Dictionary<string, Widget>();
|
||||
@@ -792,6 +883,6 @@ namespace Barotrauma
|
||||
widgets.Clear();
|
||||
Widget.selectedWidgets.Clear();
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Barotrauma
|
||||
|
||||
tabs = new GUIFrame[Enum.GetValues(typeof(Tab)).Length];
|
||||
|
||||
menu = new GUIFrame(new RectTransform(new Vector2(0.85f, 0.8f), GUI.Canvas, Anchor.Center) { MinSize = new Point(GameMain.GraphicsHeight, 0) });
|
||||
menu = new GUIFrame(new RectTransform(new Vector2(0.85f, 0.85f), GUI.Canvas, Anchor.Center) { MinSize = new Point(GameMain.GraphicsHeight, 0) });
|
||||
|
||||
var container = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.85f), menu.RectTransform, Anchor.Center) { RelativeOffset = new Vector2(0.0f, 0.05f) }) { Stretch = true };
|
||||
|
||||
@@ -111,6 +111,7 @@ namespace Barotrauma
|
||||
|
||||
var listContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 1.0f), tabs[(int)Tab.Browse].RectTransform))
|
||||
{
|
||||
RelativeSpacing = 0.01f,
|
||||
Stretch = true
|
||||
};
|
||||
|
||||
@@ -125,7 +126,7 @@ namespace Barotrauma
|
||||
};
|
||||
|
||||
var findModsButtonContainer = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.02f), listContainer.RectTransform), style: null);
|
||||
new GUIButton(new RectTransform(new Vector2(1.0f, 1.0f), findModsButtonContainer.RectTransform, Anchor.Center), TextManager.Get("FindModsButton"), style: null)
|
||||
new GUIButton(new RectTransform(new Vector2(1.0f, 0.9f), findModsButtonContainer.RectTransform, Anchor.Center), TextManager.Get("FindModsButton"), style: null)
|
||||
{
|
||||
Color = new Color(38, 86, 38, 75),
|
||||
HoverColor = new Color(85, 203, 99, 50),
|
||||
@@ -260,7 +261,12 @@ namespace Barotrauma
|
||||
|
||||
private void RefreshItemLists()
|
||||
{
|
||||
SteamManager.GetSubscribedWorkshopItems((items) => { OnItemsReceived(items, subscribedItemList); });
|
||||
SteamManager.GetSubscribedWorkshopItems((items) =>
|
||||
{
|
||||
//filter out the items published by the player (they're shown in the publish tab)
|
||||
var mySteamID = SteamManager.GetSteamID();
|
||||
OnItemsReceived(items.Where(it => it.OwnerId != mySteamID).ToList(), subscribedItemList);
|
||||
});
|
||||
SteamManager.GetPopularWorkshopItems((items) => { OnItemsReceived(items, topItemList); }, 20);
|
||||
SteamManager.GetPublishedWorkshopItems((items) => { OnItemsReceived(items, publishedItemList); });
|
||||
|
||||
@@ -704,19 +710,17 @@ namespace Barotrauma
|
||||
}
|
||||
};
|
||||
|
||||
var headerAreaBackground = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.5f), content.RectTransform, maxSize: new Point(int.MaxValue, 235))) { Color = Color.Black };
|
||||
|
||||
var headerArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 1.0f), headerAreaBackground.RectTransform), childAnchor: Anchor.Center);
|
||||
var headerArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.5f), content.RectTransform)) { Color = Color.Black };
|
||||
|
||||
if (itemPreviewSprites.ContainsKey(item.PreviewImageUrl))
|
||||
{
|
||||
new GUIImage(new RectTransform(new Point(headerArea.Rect.Width, headerArea.Rect.Height), headerArea.RectTransform), itemPreviewSprites[item.PreviewImageUrl], scaleToFit: true);
|
||||
new GUIImage(new RectTransform(Vector2.One, headerArea.RectTransform), itemPreviewSprites[item.PreviewImageUrl], scaleToFit: true);
|
||||
}
|
||||
else
|
||||
{
|
||||
new GUIImage(new RectTransform(new Point(headerArea.Rect.Width, headerArea.Rect.Height), headerArea.RectTransform), SteamManager.Instance.DefaultPreviewImage, scaleToFit: true);
|
||||
new GUIImage(new RectTransform(Vector2.One, headerArea.RectTransform), SteamManager.Instance.DefaultPreviewImage, scaleToFit: true);
|
||||
}
|
||||
|
||||
|
||||
var descriptionContainer = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.2f), content.RectTransform)) { ScrollBarVisible = true };
|
||||
|
||||
//spacing
|
||||
@@ -944,21 +948,25 @@ namespace Barotrauma
|
||||
tagBtn.TextBlock.AutoScale = true;
|
||||
tagBtn.Color *= 0.5f;
|
||||
tagBtn.SelectedColor = Color.LightGreen;
|
||||
tagBtn.HoverColor = Color.Lerp(tagBtn.HoverColor, Color.LightGreen, 0.5f);
|
||||
tagBtn.Selected = itemEditor.Tags.Any(t => t.ToLowerInvariant() == tag);
|
||||
|
||||
Color defaultTextColor = tagBtn.TextColor;
|
||||
tagBtn.TextColor = tagBtn.Selected ? Color.LightGreen : defaultTextColor;
|
||||
|
||||
tagBtn.OnClicked = (btn, userdata) =>
|
||||
{
|
||||
if (!tagBtn.Selected)
|
||||
{
|
||||
if (!itemEditor.Tags.Any(t => t.ToLowerInvariant() == tag)) { itemEditor.Tags.Add(tagBtn.Text); }
|
||||
tagBtn.Selected = true;
|
||||
tagBtn.TextBlock.TextColor = Color.LightGreen;
|
||||
tagBtn.TextColor = Color.LightGreen;
|
||||
}
|
||||
else
|
||||
{
|
||||
itemEditor.Tags.RemoveAll(t => t.ToLowerInvariant() == tagBtn.Text.ToLowerInvariant());
|
||||
tagBtn.Selected = false;
|
||||
tagBtn.TextBlock.TextColor = tagBtn.TextColor;
|
||||
tagBtn.TextColor = defaultTextColor;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -71,6 +71,12 @@ namespace Barotrauma
|
||||
private Color primaryColor = new Color(12, 14, 15, 190);
|
||||
private Color secondaryColor = new Color(12, 14, 15, 215);
|
||||
|
||||
private const int submarineNameLimit = 30;
|
||||
private GUITextBlock submarineNameCharacterCount;
|
||||
|
||||
private const int submarineDescriptionLimit = 500;
|
||||
private GUITextBlock submarineDescriptionCharacterCount;
|
||||
|
||||
public override Camera Cam
|
||||
{
|
||||
get { return cam; }
|
||||
@@ -346,7 +352,6 @@ namespace Barotrauma
|
||||
UseGridLayout = true,
|
||||
CheckSelected = MapEntityPrefab.GetSelected
|
||||
};
|
||||
UpdateEntityList();
|
||||
|
||||
//empty guiframe as a separator
|
||||
new GUIFrame(new RectTransform(new Vector2(1.0f, 0.02f), paddedLeftPanel.RectTransform), style: null);
|
||||
@@ -603,14 +608,16 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
|
||||
entityList.Content.RectTransform.SortChildren((i1, i2) =>
|
||||
entityList.Content.RectTransform.SortChildren((i1, i2) =>
|
||||
(i1.GUIComponent.UserData as MapEntityPrefab).Name.CompareTo((i2.GUIComponent.UserData as MapEntityPrefab).Name));
|
||||
}
|
||||
|
||||
|
||||
public override void Select()
|
||||
{
|
||||
base.Select();
|
||||
|
||||
UpdateEntityList();
|
||||
|
||||
foreach (MapEntityPrefab prefab in MapEntityPrefab.List)
|
||||
{
|
||||
prefab.sprite?.EnsureLazyLoaded();
|
||||
@@ -950,32 +957,60 @@ namespace Barotrauma
|
||||
OnClicked = (btn, userdata) => { if (GUI.MouseOn == btn || GUI.MouseOn == btn.TextBlock) saveFrame = null; return true; }
|
||||
};
|
||||
|
||||
var innerFrame = new GUIFrame(new RectTransform(new Vector2(0.4f, 0.45f), saveFrame.RectTransform, Anchor.Center) { MinSize = new Point(750, 400) });
|
||||
var innerFrame = new GUIFrame(new RectTransform(new Vector2(0.4f, 0.5f), saveFrame.RectTransform, Anchor.Center) { MinSize = new Point(750, 400) });
|
||||
var paddedSaveFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.9f), innerFrame.RectTransform, Anchor.Center)) { Stretch = true, RelativeSpacing = 0.02f };
|
||||
|
||||
//var header = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), paddedSaveFrame.RectTransform), TextManager.Get("SaveSubDialogHeader"), font: GUI.LargeFont);
|
||||
|
||||
var columnArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.9f), paddedSaveFrame.RectTransform), isHorizontal: true) { Stretch = true };
|
||||
var leftColumn = new GUILayoutGroup(new RectTransform(new Vector2(0.55f, 1.0f), columnArea.RectTransform)) { RelativeSpacing = 0.02f, Stretch = true };
|
||||
var leftColumn = new GUILayoutGroup(new RectTransform(new Vector2(0.55f, 1.0f), columnArea.RectTransform)) { RelativeSpacing = 0.01f, Stretch = true };
|
||||
var rightColumn = new GUILayoutGroup(new RectTransform(new Vector2(0.42f, 1.0f), columnArea.RectTransform)) { RelativeSpacing = 0.02f, Stretch = true };
|
||||
|
||||
// left column -----------------------------------------------------------------------
|
||||
|
||||
var saveSubLabel = new GUITextBlock(new RectTransform(new Vector2(0.4f, 0.03f), leftColumn.RectTransform),
|
||||
var nameHeaderGroup = new GUILayoutGroup(new RectTransform(new Vector2(.975f, 0.03f), leftColumn.RectTransform), true);
|
||||
var saveSubLabel = new GUITextBlock(new RectTransform(new Vector2(.5f, 1f), nameHeaderGroup.RectTransform),
|
||||
TextManager.Get("SaveSubDialogName"));
|
||||
|
||||
nameBox = new GUITextBox(new RectTransform(new Vector2(0.65f, 0.05f), leftColumn.RectTransform))
|
||||
submarineNameCharacterCount = new GUITextBlock(new RectTransform(new Vector2(.5f, 1f), nameHeaderGroup.RectTransform), string.Empty, textAlignment: Alignment.TopRight);
|
||||
|
||||
nameBox = new GUITextBox(new RectTransform(new Vector2(.95f, 0.05f), leftColumn.RectTransform))
|
||||
{
|
||||
OnEnterPressed = ChangeSubName,
|
||||
Text = GetSubName()
|
||||
};
|
||||
nameBox.OnTextChanged += (textBox, text) =>
|
||||
{
|
||||
if (text.Length > submarineNameLimit)
|
||||
{
|
||||
nameBox.Text = text.Substring(0, submarineNameLimit);
|
||||
nameBox.Flash(Color.Red);
|
||||
return true;
|
||||
}
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.5f, 0.03f), leftColumn.RectTransform), TextManager.Get("SaveSubDialogDescription"));
|
||||
submarineNameCharacterCount.Text = text.Length + " / " + submarineNameLimit;
|
||||
return true;
|
||||
};
|
||||
|
||||
submarineNameCharacterCount.Text = nameBox.Text.Length + " / " + submarineNameLimit;
|
||||
|
||||
var descriptionHeaderGroup = new GUILayoutGroup(new RectTransform(new Vector2(.975f, 0.03f), leftColumn.RectTransform), true);
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.5f, 1f), descriptionHeaderGroup.RectTransform), TextManager.Get("SaveSubDialogDescription"));
|
||||
submarineDescriptionCharacterCount = new GUITextBlock(new RectTransform(new Vector2(.5f, 1f), descriptionHeaderGroup.RectTransform), string.Empty, textAlignment: Alignment.TopRight);
|
||||
|
||||
var descriptionContainer = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.25f), leftColumn.RectTransform));
|
||||
descriptionBox = new GUITextBox(new RectTransform(Vector2.One, descriptionContainer.Content.RectTransform), font: GUI.SmallFont, wrap: true);
|
||||
descriptionBox = new GUITextBox(new RectTransform(Vector2.One, descriptionContainer.Content.RectTransform, Anchor.Center), font: GUI.SmallFont, wrap: true);
|
||||
|
||||
descriptionBox.OnTextChanged += (textBox, text) =>
|
||||
{
|
||||
if (text.Length > submarineDescriptionLimit)
|
||||
{
|
||||
descriptionBox.Text = text.Substring(0, submarineDescriptionLimit);
|
||||
descriptionBox.Flash(Color.Red);
|
||||
return true;
|
||||
}
|
||||
|
||||
Vector2 textSize = textBox.Font.MeasureString(descriptionBox.WrappedText);
|
||||
textBox.RectTransform.NonScaledSize = new Point(textBox.RectTransform.NonScaledSize.X, Math.Max(descriptionContainer.Rect.Height, (int)textSize.Y + 10));
|
||||
descriptionContainer.UpdateScrollBarSize();
|
||||
@@ -984,6 +1019,7 @@ namespace Barotrauma
|
||||
return true;
|
||||
};
|
||||
descriptionBox.Text = Submarine.MainSub == null ? "" : Submarine.MainSub.Description;
|
||||
submarineDescriptionCharacterCount.Text = descriptionBox.Text.Length + " / " + submarineDescriptionLimit;
|
||||
|
||||
var crewSizeArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.03f), leftColumn.RectTransform), isHorizontal: true) { AbsoluteSpacing = 5 };
|
||||
|
||||
@@ -1493,8 +1529,21 @@ namespace Barotrauma
|
||||
|
||||
private void TryDeleteSub(Submarine sub)
|
||||
{
|
||||
if (sub == null) return;
|
||||
|
||||
if (sub == null) { return; }
|
||||
|
||||
//if the sub is included in a content package that only defines that one sub,
|
||||
//delete the content package as well
|
||||
ContentPackage subPackage = null;
|
||||
foreach (ContentPackage cp in ContentPackage.List)
|
||||
{
|
||||
if (cp.Files.Count == 1 && Path.GetFullPath(cp.Files[0].Path) == Path.GetFullPath(sub.FilePath))
|
||||
{
|
||||
subPackage = cp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
subPackage?.Delete();
|
||||
|
||||
var msgBox = new GUIMessageBox(
|
||||
TextManager.Get("DeleteDialogLabel"),
|
||||
TextManager.GetWithVariable("DeleteDialogQuestion", "[file]", sub.Name),
|
||||
@@ -1524,7 +1573,6 @@ namespace Barotrauma
|
||||
if (CharacterMode) SetCharacterMode(false);
|
||||
if (WiringMode) SetWiringMode(false);
|
||||
|
||||
|
||||
saveFrame = null;
|
||||
loadFrame = null;
|
||||
|
||||
@@ -1754,7 +1802,9 @@ namespace Barotrauma
|
||||
{
|
||||
textBox.UserData = text;
|
||||
}
|
||||
|
||||
|
||||
submarineDescriptionCharacterCount.Text = text.Length + " / " + submarineDescriptionLimit;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2131,6 +2181,10 @@ namespace Barotrauma
|
||||
{
|
||||
dummyCharacter.SelectedConstruction.AddToGUIUpdateList();
|
||||
}
|
||||
else if (WiringMode && MapEntity.SelectedList.Count == 1 && MapEntity.SelectedList[0] is Item item && item.GetComponent<Wire>() != null)
|
||||
{
|
||||
MapEntity.SelectedList[0].AddToGUIUpdateList();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2290,9 +2344,9 @@ namespace Barotrauma
|
||||
dummyCharacter.SelectedConstruction = null;
|
||||
}*/
|
||||
}
|
||||
else if (MapEntity.FilteredSelectedList.Count == 1)
|
||||
else if (MapEntity.SelectedList.Count == 1)
|
||||
{
|
||||
(MapEntity.FilteredSelectedList[0] as Item)?.UpdateHUD(cam, dummyCharacter, (float)deltaTime);
|
||||
(MapEntity.SelectedList[0] as Item)?.UpdateHUD(cam, dummyCharacter, (float)deltaTime);
|
||||
}
|
||||
|
||||
CharacterHUD.Update((float)deltaTime, dummyCharacter, cam);
|
||||
|
||||
Reference in New Issue
Block a user