Unstable 1.1.14.0
This commit is contained in:
@@ -421,7 +421,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void UpdateLoadMenu(IEnumerable<CampaignMode.SaveInfo> saveFiles = null);
|
||||
public abstract void CreateLoadMenu(IEnumerable<CampaignMode.SaveInfo> saveFiles = null);
|
||||
|
||||
protected bool DeleteSave(GUIButton button, object obj)
|
||||
{
|
||||
@@ -434,7 +434,7 @@ namespace Barotrauma
|
||||
{
|
||||
SaveUtil.DeleteSave(saveInfo.FilePath);
|
||||
prevSaveFiles?.RemoveAll(s => s.FilePath == saveInfo.FilePath);
|
||||
UpdateLoadMenu(prevSaveFiles.ToList());
|
||||
CreateLoadMenu(prevSaveFiles.ToList());
|
||||
return true;
|
||||
});
|
||||
|
||||
|
||||
+2
-2
@@ -162,7 +162,7 @@ namespace Barotrauma
|
||||
|
||||
verticalLayout.Recalculate();
|
||||
|
||||
UpdateLoadMenu(saveFiles);
|
||||
CreateLoadMenu(saveFiles);
|
||||
}
|
||||
|
||||
private IEnumerable<CoroutineStatus> WaitForCampaignSetup()
|
||||
@@ -192,7 +192,7 @@ namespace Barotrauma
|
||||
yield return CoroutineStatus.Success;
|
||||
}
|
||||
|
||||
public override void UpdateLoadMenu(IEnumerable<CampaignMode.SaveInfo> saveFiles = null)
|
||||
public override void CreateLoadMenu(IEnumerable<CampaignMode.SaveInfo> saveFiles = null)
|
||||
{
|
||||
prevSaveFiles?.Clear();
|
||||
prevSaveFiles = null;
|
||||
|
||||
+14
-17
@@ -20,11 +20,10 @@ namespace Barotrauma
|
||||
private GUIButton nextButton;
|
||||
private GUIListBox characterInfoColumns;
|
||||
|
||||
public SinglePlayerCampaignSetupUI(GUIComponent newGameContainer, GUIComponent loadGameContainer, IEnumerable<SubmarineInfo> submarines, IEnumerable<CampaignMode.SaveInfo> saveFiles = null)
|
||||
public SinglePlayerCampaignSetupUI(GUIComponent newGameContainer, GUIComponent loadGameContainer)
|
||||
: base(newGameContainer, loadGameContainer)
|
||||
{
|
||||
UpdateNewGameMenu(submarines);
|
||||
UpdateLoadMenu(saveFiles);
|
||||
CreateNewGameMenu();
|
||||
}
|
||||
|
||||
private int currentPage = 0;
|
||||
@@ -73,7 +72,7 @@ namespace Barotrauma
|
||||
});
|
||||
}
|
||||
|
||||
private void UpdateNewGameMenu(IEnumerable<SubmarineInfo> submarines)
|
||||
private void CreateNewGameMenu()
|
||||
{
|
||||
pageContainer =
|
||||
new GUIListBox(new RectTransform(Vector2.One, newGameContainer.RectTransform), style: null, isHorizontal: true)
|
||||
@@ -92,7 +91,7 @@ namespace Barotrauma
|
||||
Anchor.Center));
|
||||
}
|
||||
|
||||
CreateFirstPage(createPageLayout(), submarines);
|
||||
CreateFirstPage(createPageLayout());
|
||||
CreateSecondPage(createPageLayout());
|
||||
|
||||
pageContainer.RecalculateChildren();
|
||||
@@ -108,7 +107,7 @@ namespace Barotrauma
|
||||
SetPage(0);
|
||||
}
|
||||
|
||||
private void CreateFirstPage(GUILayoutGroup firstPageLayout, IEnumerable<SubmarineInfo> submarines)
|
||||
private void CreateFirstPage(GUILayoutGroup firstPageLayout)
|
||||
{
|
||||
firstPageLayout.RelativeSpacing = 0.02f;
|
||||
|
||||
@@ -238,8 +237,6 @@ namespace Barotrauma
|
||||
columnContainer.Recalculate();
|
||||
leftColumn.Recalculate();
|
||||
rightColumn.Recalculate();
|
||||
|
||||
if (submarines != null) { UpdateSubList(submarines); }
|
||||
}
|
||||
|
||||
private void CreateSecondPage(GUILayoutGroup secondPageLayout)
|
||||
@@ -578,7 +575,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public override void UpdateLoadMenu(IEnumerable<CampaignMode.SaveInfo> saveFiles = null)
|
||||
public override void CreateLoadMenu(IEnumerable<CampaignMode.SaveInfo> saveFiles = null)
|
||||
{
|
||||
prevSaveFiles?.Clear();
|
||||
prevSaveFiles = null;
|
||||
@@ -625,21 +622,21 @@ namespace Barotrauma
|
||||
var saveFrame = CreateSaveElement(saveInfo);
|
||||
if (saveFrame == null) { continue; }
|
||||
|
||||
XDocument doc = SaveUtil.LoadGameSessionDoc(saveInfo.FilePath);
|
||||
XElement docRoot = SaveUtil.ExtractGameSessionRootElementFromSaveFile(saveInfo.FilePath);
|
||||
|
||||
if (doc?.Root == null)
|
||||
if (docRoot == null)
|
||||
{
|
||||
DebugConsole.ThrowError("Error loading save file \"" + saveInfo.FilePath + "\". The file may be corrupted.");
|
||||
saveFrame.GetChild<GUITextBlock>().TextColor = GUIStyle.Red;
|
||||
continue;
|
||||
}
|
||||
if (doc.Root.GetChildElement("multiplayercampaign") != null)
|
||||
if (docRoot.GetChildElement("multiplayercampaign") != null)
|
||||
{
|
||||
//multiplayer campaign save in the wrong folder -> don't show the save
|
||||
saveList.Content.RemoveChild(saveFrame);
|
||||
continue;
|
||||
}
|
||||
if (!SaveUtil.IsSaveFileCompatible(doc))
|
||||
if (!SaveUtil.IsSaveFileCompatible(docRoot))
|
||||
{
|
||||
saveFrame.GetChild<GUITextBlock>().TextColor = GUIStyle.Red;
|
||||
saveFrame.ToolTip = TextManager.Get("campaignmode.incompatiblesave");
|
||||
@@ -668,14 +665,14 @@ namespace Barotrauma
|
||||
|
||||
string fileName = saveInfo.FilePath;
|
||||
|
||||
XDocument doc = SaveUtil.LoadGameSessionDoc(fileName);
|
||||
if (doc?.Root == null)
|
||||
XElement docRoot = SaveUtil.ExtractGameSessionRootElementFromSaveFile(fileName);
|
||||
if (docRoot == null)
|
||||
{
|
||||
DebugConsole.ThrowError("Error loading save file \"" + fileName + "\". The file may be corrupted.");
|
||||
return false;
|
||||
}
|
||||
|
||||
loadGameButton.Enabled = SaveUtil.IsSaveFileCompatible(doc);
|
||||
loadGameButton.Enabled = SaveUtil.IsSaveFileCompatible(docRoot);
|
||||
|
||||
RemoveSaveFrame();
|
||||
|
||||
@@ -684,7 +681,7 @@ namespace Barotrauma
|
||||
.Select(t => (LocalizedString)t.ToLocalUserString())
|
||||
.Fallback(TextManager.Get("Unknown"));
|
||||
|
||||
string mapseed = doc.Root.GetAttributeString("mapseed", "unknown");
|
||||
string mapseed = docRoot.GetAttributeString("mapseed", "unknown");
|
||||
|
||||
var saveFileFrame = new GUIFrame(
|
||||
new RectTransform(new Vector2(0.45f, 0.6f), loadGameContainer.RectTransform, Anchor.TopRight)
|
||||
|
||||
+14
-2
@@ -1187,6 +1187,11 @@ namespace Barotrauma.CharacterEditor
|
||||
|
||||
private void CreateLimb(ContentXElement newElement)
|
||||
{
|
||||
if (RagdollParams.MainElement == null)
|
||||
{
|
||||
DebugConsole.ThrowError("Main element null! Failed to create a limb.");
|
||||
return;
|
||||
}
|
||||
var lastElement = RagdollParams.MainElement.GetChildElements("limb").LastOrDefault();
|
||||
if (lastElement != null)
|
||||
{
|
||||
@@ -1217,6 +1222,11 @@ namespace Barotrauma.CharacterEditor
|
||||
DebugConsole.ThrowError(GetCharacterEditorTranslation("ExistingJointFound").Replace("[limbid1]", fromLimb.ToString()).Replace("[limbid2]", toLimb.ToString()));
|
||||
return;
|
||||
}
|
||||
if (RagdollParams.MainElement == null)
|
||||
{
|
||||
DebugConsole.ThrowError("The main element of the ragdoll params is null! Failed to create a joint.");
|
||||
return;
|
||||
}
|
||||
//RagdollParams.StoreState();
|
||||
Vector2 a1 = anchor1 ?? Vector2.Zero;
|
||||
Vector2 a2 = anchor2 ?? Vector2.Zero;
|
||||
@@ -1775,7 +1785,7 @@ namespace Barotrauma.CharacterEditor
|
||||
string ragdollPath = RagdollParams.GetDefaultFile(name, contentPackage);
|
||||
RagdollParams ragdollParams = isHumanoid
|
||||
? RagdollParams.CreateDefault<HumanRagdollParams>(ragdollPath, name, ragdoll)
|
||||
: RagdollParams.CreateDefault<FishRagdollParams>(ragdollPath, name, ragdoll) as RagdollParams;
|
||||
: RagdollParams.CreateDefault<FishRagdollParams>(ragdollPath, name, ragdoll);
|
||||
|
||||
// Animations
|
||||
AnimationParams.ClearCache();
|
||||
@@ -1789,6 +1799,7 @@ namespace Barotrauma.CharacterEditor
|
||||
foreach (var animation in animations)
|
||||
{
|
||||
XElement element = animation.MainElement;
|
||||
if (element == null) { continue; }
|
||||
element.SetAttributeValue("type", name);
|
||||
string fullPath = AnimationParams.GetDefaultFile(name, animation.AnimationType);
|
||||
element.Name = AnimationParams.GetDefaultFileName(name, animation.AnimationType);
|
||||
@@ -2140,7 +2151,8 @@ namespace Barotrauma.CharacterEditor
|
||||
{
|
||||
foreach (var limb in character.AnimController.Limbs)
|
||||
{
|
||||
limb.ActiveSprite.ReloadTexture();
|
||||
if (limb == null) { continue; }
|
||||
limb.ActiveSprite?.ReloadTexture();
|
||||
limb.WearingItems.ForEach(i => i.Sprite.ReloadTexture());
|
||||
limb.OtherWearables.ForEach(w => w.Sprite.ReloadTexture());
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Barotrauma
|
||||
|
||||
public bool CanAddConnections { get; set; }
|
||||
|
||||
public readonly List<NodeConnection> Connections = new List<NodeConnection>();
|
||||
public readonly List<EventEditorNodeConnection> Connections = new List<EventEditorNodeConnection>();
|
||||
|
||||
public readonly List<NodeConnectionType> RemovableTypes = new List<NodeConnectionType>();
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Barotrauma
|
||||
public XElement SaveConnections()
|
||||
{
|
||||
XElement allConnections = new XElement("Connections", new XAttribute("i", ID));
|
||||
foreach (NodeConnection connection in Connections)
|
||||
foreach (EventEditorNodeConnection connection in Connections)
|
||||
{
|
||||
XElement connectionElement = new XElement("Connection");
|
||||
connectionElement.Add(new XAttribute("i", connection.ID));
|
||||
@@ -93,12 +93,12 @@ namespace Barotrauma
|
||||
|
||||
if (id < 0) { continue; }
|
||||
|
||||
NodeConnection? connection = Connections.Find(c => c.ID == id);
|
||||
EventEditorNodeConnection? connection = Connections.Find(c => c.ID == id);
|
||||
if (connection == null)
|
||||
{
|
||||
if (string.Equals(connectionType, NodeConnectionType.Option.Label, StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
connection = new NodeConnection(this, NodeConnectionType.Option) { ID = id, EndConversation = endConversation };
|
||||
connection = new EventEditorNodeConnection(this, NodeConnectionType.Option) { ID = id, EndConversation = endConversation };
|
||||
Connections.Add(connection);
|
||||
}
|
||||
else
|
||||
@@ -143,7 +143,7 @@ namespace Barotrauma
|
||||
if (id2 < 0 || node < 0) { continue; }
|
||||
|
||||
EditorNode? otherNode = EventEditorScreen.nodeList.Find(editorNode => editorNode.ID == node);
|
||||
NodeConnection? otherConnection = otherNode?.Connections.Find(c => c.ID == id2);
|
||||
EventEditorNodeConnection? otherConnection = otherNode?.Connections.Find(c => c.ID == id2);
|
||||
if (otherConnection != null)
|
||||
{
|
||||
connection.ConnectedTo.Add(otherConnection);
|
||||
@@ -184,20 +184,20 @@ namespace Barotrauma
|
||||
|
||||
public void Connect(EditorNode otherNode, NodeConnectionType type)
|
||||
{
|
||||
NodeConnection? conn = Connections.Find(connection => connection.Type == type && !connection.ConnectedTo.Any());
|
||||
NodeConnection? found = otherNode.Connections.Find(connection => connection.Type == NodeConnectionType.Activate);
|
||||
EventEditorNodeConnection? conn = Connections.Find(connection => connection.Type == type && !connection.ConnectedTo.Any());
|
||||
EventEditorNodeConnection? found = otherNode.Connections.Find(connection => connection.Type == NodeConnectionType.Activate);
|
||||
if (found != null)
|
||||
{
|
||||
conn?.ConnectedTo.Add(found);
|
||||
}
|
||||
}
|
||||
|
||||
public void Connect(NodeConnection connection, NodeConnection ownConnection)
|
||||
public static void Connect(EventEditorNodeConnection connection, EventEditorNodeConnection ownConnection)
|
||||
{
|
||||
connection.ConnectedTo.Add(ownConnection);
|
||||
}
|
||||
|
||||
public void Disconnect(NodeConnection conn)
|
||||
public static void Disconnect(EventEditorNodeConnection conn)
|
||||
{
|
||||
foreach (var connection in EventEditorScreen.nodeList.SelectMany(editorNode => editorNode.Connections.Where(connection => connection.ConnectedTo.Contains(conn))))
|
||||
{
|
||||
@@ -207,7 +207,7 @@ namespace Barotrauma
|
||||
|
||||
public void ClearConnections()
|
||||
{
|
||||
foreach (NodeConnection conn in Connections)
|
||||
foreach (EventEditorNodeConnection conn in Connections)
|
||||
{
|
||||
conn.ClearConnections();
|
||||
}
|
||||
@@ -218,7 +218,7 @@ namespace Barotrauma
|
||||
return Rectangle;
|
||||
}
|
||||
|
||||
public NodeConnection? GetConnectionOnMouse(Vector2 mousePos)
|
||||
public EventEditorNodeConnection? GetConnectionOnMouse(Vector2 mousePos)
|
||||
{
|
||||
return Connections.FirstOrDefault(eventNodeConnection => eventNodeConnection.DrawRectangle.Contains(mousePos));
|
||||
}
|
||||
@@ -254,7 +254,7 @@ namespace Barotrauma
|
||||
GUI.DrawRectangle(spriteBatch, bodyRect, outlineColor, isFilled: false, depth: 1.0f, thickness: (int) Math.Max(1, 1.25f / camZoom));
|
||||
|
||||
int x = 0, y = 0;
|
||||
foreach (NodeConnection connection in Connections)
|
||||
foreach (EventEditorNodeConnection connection in Connections)
|
||||
{
|
||||
switch (connection.Type.NodeSide)
|
||||
{
|
||||
@@ -275,10 +275,10 @@ namespace Barotrauma
|
||||
|
||||
public virtual void AddOption()
|
||||
{
|
||||
Connections.Add(new NodeConnection(this, NodeConnectionType.Option));
|
||||
Connections.Add(new EventEditorNodeConnection(this, NodeConnectionType.Option));
|
||||
}
|
||||
|
||||
public void RemoveOption(NodeConnection connection)
|
||||
public void RemoveOption(EventEditorNodeConnection connection)
|
||||
{
|
||||
int index = Connections.IndexOf(connection);
|
||||
foreach (var nodeConnection in Connections.Skip(index))
|
||||
@@ -313,7 +313,7 @@ namespace Barotrauma
|
||||
|
||||
foreach (EditorNode editorNode in EventEditorScreen.nodeList)
|
||||
{
|
||||
List<NodeConnection> childConnection = editorNode.Connections.Where(connection => connection.Type == NodeConnectionType.Next ||
|
||||
List<EventEditorNodeConnection> childConnection = editorNode.Connections.Where(connection => connection.Type == NodeConnectionType.Next ||
|
||||
connection.Type == NodeConnectionType.Option ||
|
||||
connection.Type == NodeConnectionType.Failure ||
|
||||
connection.Type == NodeConnectionType.Success ||
|
||||
@@ -338,18 +338,18 @@ namespace Barotrauma
|
||||
Size = new Vector2(256, 256);
|
||||
PropertyInfo[] properties = type.GetProperties().Where(info => info.CustomAttributes.Any(data => data.AttributeType == typeof(Serialize))).ToArray();
|
||||
|
||||
Connections.Add(new NodeConnection(this, NodeConnectionType.Activate));
|
||||
Connections.Add(new NodeConnection(this, NodeConnectionType.Next));
|
||||
Connections.Add(new EventEditorNodeConnection(this, NodeConnectionType.Activate));
|
||||
Connections.Add(new EventEditorNodeConnection(this, NodeConnectionType.Next));
|
||||
|
||||
foreach (PropertyInfo property in properties)
|
||||
{
|
||||
Connections.Add(new NodeConnection(this, NodeConnectionType.Value, property.Name, property.PropertyType, property));
|
||||
Connections.Add(new EventEditorNodeConnection(this, NodeConnectionType.Value, property.Name, property.PropertyType, property));
|
||||
}
|
||||
|
||||
if (IsInstanceOf(type, typeof(BinaryOptionAction)))
|
||||
{
|
||||
Connections.Add(new NodeConnection(this, NodeConnectionType.Success));
|
||||
Connections.Add(new NodeConnection(this, NodeConnectionType.Failure));
|
||||
Connections.Add(new EventEditorNodeConnection(this, NodeConnectionType.Success));
|
||||
Connections.Add(new EventEditorNodeConnection(this, NodeConnectionType.Failure));
|
||||
}
|
||||
|
||||
if (IsInstanceOf(type, typeof(ConversationAction)))
|
||||
@@ -360,7 +360,7 @@ namespace Barotrauma
|
||||
|
||||
if (IsInstanceOf(type, typeof(StatusEffectAction)) || IsInstanceOf(type, typeof(MissionAction)))
|
||||
{
|
||||
Connections.Add(new NodeConnection(this, NodeConnectionType.Add));
|
||||
Connections.Add(new EventEditorNodeConnection(this, NodeConnectionType.Add));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -395,7 +395,7 @@ namespace Barotrauma
|
||||
return ScaleRectFromConnections(Connections, Rectangle);
|
||||
}
|
||||
|
||||
public static Rectangle ScaleRectFromConnections(List<NodeConnection> connections, Rectangle baseRect)
|
||||
public static Rectangle ScaleRectFromConnections(List<EventEditorNodeConnection> connections, Rectangle baseRect)
|
||||
{
|
||||
// determine how big this box should get based on how many input/output nodes the sides have
|
||||
int y = connections.Count(connection => connection.Type.NodeSide == NodeConnectionType.Side.Left),
|
||||
@@ -409,15 +409,15 @@ namespace Barotrauma
|
||||
|
||||
public Tuple<EditorNode?, string?, bool>[] GetOptions()
|
||||
{
|
||||
IEnumerable<NodeConnection> myNode = Connections.Where(connection => connection.Type == NodeConnectionType.Option).ToArray();
|
||||
IEnumerable<EventEditorNodeConnection> myNode = Connections.Where(connection => connection.Type == NodeConnectionType.Option).ToArray();
|
||||
List<Tuple<EditorNode?, string?, bool>> list = new List<Tuple<EditorNode?, string?, bool>>();
|
||||
if (myNode != null)
|
||||
{
|
||||
foreach (NodeConnection connection in myNode)
|
||||
foreach (EventEditorNodeConnection connection in myNode)
|
||||
{
|
||||
if (connection.ConnectedTo.Any())
|
||||
{
|
||||
foreach (NodeConnection nodeConnection in connection.ConnectedTo)
|
||||
foreach (EventEditorNodeConnection nodeConnection in connection.ConnectedTo)
|
||||
{
|
||||
list.Add(Tuple.Create((EditorNode?) nodeConnection.Parent, connection.OptionText, connection.EndConversation));
|
||||
}
|
||||
@@ -464,7 +464,7 @@ namespace Barotrauma
|
||||
Type = type;
|
||||
Value = type.IsValueType ? Activator.CreateInstance(type) : null;
|
||||
Size = new Vector2(256, 32);
|
||||
Connections.Add(new NodeConnection(this, NodeConnectionType.Out, "Output", Type));
|
||||
Connections.Add(new EventEditorNodeConnection(this, NodeConnectionType.Out, "Output", Type));
|
||||
}
|
||||
|
||||
public override XElement Save()
|
||||
@@ -564,7 +564,7 @@ namespace Barotrauma
|
||||
Vector2 pos = GetDrawRectangle().Location.ToVector2() + (GetDrawRectangle().Size.ToVector2() / 2) - (valueTextSize / 2);
|
||||
Rectangle drawRect = Rectangle;
|
||||
drawRect.Inflate(-1, -1);
|
||||
GUI.DrawString(spriteBatch, pos, WrappedText, NodeConnection.GetPropertyColor(Type), font: GUIStyle.SubHeadingFont);
|
||||
GUI.DrawString(spriteBatch, pos, WrappedText, EventEditorNodeConnection.GetPropertyColor(Type), font: GUIStyle.SubHeadingFont);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -587,9 +587,9 @@ namespace Barotrauma
|
||||
{
|
||||
CanAddConnections = true;
|
||||
RemovableTypes.Add(NodeConnectionType.Value);
|
||||
Connections.Add(new NodeConnection(this, NodeConnectionType.Activate));
|
||||
Connections.Add(new NodeConnection(this, NodeConnectionType.Next));
|
||||
Connections.Add(new NodeConnection(this, NodeConnectionType.Add));
|
||||
Connections.Add(new EventEditorNodeConnection(this, NodeConnectionType.Activate));
|
||||
Connections.Add(new EventEditorNodeConnection(this, NodeConnectionType.Next));
|
||||
Connections.Add(new EventEditorNodeConnection(this, NodeConnectionType.Add));
|
||||
}
|
||||
|
||||
public CustomNode() : this("Custom")
|
||||
@@ -605,7 +605,7 @@ namespace Barotrauma
|
||||
{
|
||||
Prompt(s =>
|
||||
{
|
||||
Connections.Add(new NodeConnection(this, NodeConnectionType.Value, s, typeof(string)));
|
||||
Connections.Add(new EventEditorNodeConnection(this, NodeConnectionType.Value, s, typeof(string)));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
@@ -617,7 +617,7 @@ namespace Barotrauma
|
||||
newElement.Add(new XAttribute("name", Name));
|
||||
newElement.Add(new XAttribute("xpos", Position.X));
|
||||
newElement.Add(new XAttribute("ypos", Position.Y));
|
||||
foreach (NodeConnection connection in Connections.FindAll(connection => connection.Type == NodeConnectionType.Value))
|
||||
foreach (EventEditorNodeConnection connection in Connections.FindAll(connection => connection.Type == NodeConnectionType.Value))
|
||||
{
|
||||
newElement.Add(new XElement("Value", new XAttribute("name", connection.Attribute)));
|
||||
}
|
||||
@@ -634,7 +634,7 @@ namespace Barotrauma
|
||||
newNode.Position = new Vector2(posX, posY);
|
||||
foreach (XElement valueElement in element.Elements())
|
||||
{
|
||||
newNode.Connections.Add(new NodeConnection(newNode, NodeConnectionType.Value, valueElement.GetAttributeString("name", string.Empty), typeof(string)));
|
||||
newNode.Connections.Add(new EventEditorNodeConnection(newNode, NodeConnectionType.Value, valueElement.GetAttributeString("name", string.Empty), typeof(string)));
|
||||
}
|
||||
return newNode;
|
||||
}
|
||||
|
||||
+12
-40
@@ -39,7 +39,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
internal class NodeConnection
|
||||
internal class EventEditorNodeConnection
|
||||
{
|
||||
public string Attribute { get; }
|
||||
|
||||
@@ -128,7 +128,7 @@ namespace Barotrauma
|
||||
|
||||
public readonly EditorNode Parent;
|
||||
|
||||
public readonly List<NodeConnection> ConnectedTo = new List<NodeConnection>();
|
||||
public readonly List<EventEditorNodeConnection> ConnectedTo = new List<EventEditorNodeConnection>();
|
||||
|
||||
private readonly Color bgColor = Color.DarkGray * 0.8f;
|
||||
|
||||
@@ -163,7 +163,7 @@ namespace Barotrauma
|
||||
ConnectedTo.Clear();
|
||||
}
|
||||
|
||||
public NodeConnection(EditorNode parent, NodeConnectionType type, string attribute = "", Type? valueType = null, PropertyInfo? propertyInfo = null)
|
||||
public EventEditorNodeConnection(EditorNode parent, NodeConnectionType type, string attribute = "", Type? valueType = null, PropertyInfo? propertyInfo = null)
|
||||
{
|
||||
Type = type;
|
||||
ValueType = valueType;
|
||||
@@ -244,7 +244,7 @@ namespace Barotrauma
|
||||
|
||||
private void DrawConnections(SpriteBatch spriteBatch, int yOffset, float width = 2, Color? overrideColor = null)
|
||||
{
|
||||
foreach (NodeConnection? eventNodeConnection in ConnectedTo)
|
||||
foreach (EventEditorNodeConnection? eventNodeConnection in ConnectedTo)
|
||||
{
|
||||
if (eventNodeConnection != null)
|
||||
{
|
||||
@@ -279,37 +279,9 @@ namespace Barotrauma
|
||||
|
||||
private void DrawSquareLine(SpriteBatch spriteBatch, Vector2 position, int yOffset, float width = 2, Color? overrideColor = null)
|
||||
{
|
||||
// draw a line between 2 nodes using points
|
||||
// the order of this array is messed up, I know
|
||||
// order of points is from start node to end node: 0, 4, 1, 2, 5, 3
|
||||
Vector2[] points = new Vector2[6];
|
||||
int xOffset = 24 * (yOffset + 1);
|
||||
points[0] = new Vector2(DrawRectangle.Right, DrawRectangle.Center.Y);
|
||||
points[3] = position;
|
||||
points[1] = points[0];
|
||||
points[2] = points[3];
|
||||
|
||||
points[4] = points[1];
|
||||
points[5] = points[2];
|
||||
|
||||
points[1].X += (points[2].X - points[1].X) / 2;
|
||||
points[1].X = Math.Max(points[1].X, points[0].X + xOffset);
|
||||
points[2].X = points[1].X;
|
||||
|
||||
// if the node is "behind" us do some magic to make the line curve to prevent overlapping
|
||||
if (points[1].X <= points[0].X + xOffset)
|
||||
{
|
||||
points[4].X += xOffset;
|
||||
points[1].X = points[4].X;
|
||||
points[1].Y += (points[2].Y - points[1].Y) / 2;
|
||||
}
|
||||
|
||||
if (points[2].X >= points[3].X - xOffset)
|
||||
{
|
||||
points[5].X -= xOffset;
|
||||
points[2].X = points[5].X;
|
||||
points[2].Y -= points[2].Y - points[1].Y;
|
||||
}
|
||||
float knobLength = 24 * (yOffset + 1);
|
||||
Vector2 start = new Vector2(DrawRectangle.Right, DrawRectangle.Center.Y);
|
||||
var (points, _) = ToolBox.GetSquareLineBetweenPoints(start, position, knobLength);
|
||||
|
||||
Color drawColor = Parent is ValueNode ? GetPropertyColor(ValueType) : GUIStyle.Red;
|
||||
|
||||
@@ -318,11 +290,11 @@ namespace Barotrauma
|
||||
drawColor = overrideColor.Value;
|
||||
}
|
||||
|
||||
GUI.DrawLine(spriteBatch, points[0], points[4], drawColor, width: (int)width);
|
||||
GUI.DrawLine(spriteBatch, points[4], points[1], drawColor, width: (int)width);
|
||||
GUI.DrawLine(spriteBatch, points[0], points[1], drawColor, width: (int)width);
|
||||
GUI.DrawLine(spriteBatch, points[1], points[2], drawColor, width: (int)width);
|
||||
GUI.DrawLine(spriteBatch, points[2], points[5], drawColor, width: (int)width);
|
||||
GUI.DrawLine(spriteBatch, points[5], points[3], drawColor, width: (int)width);
|
||||
GUI.DrawLine(spriteBatch, points[2], points[3], drawColor, width: (int)width);
|
||||
GUI.DrawLine(spriteBatch, points[3], points[4], drawColor, width: (int)width);
|
||||
GUI.DrawLine(spriteBatch, points[4], points[5], drawColor, width: (int)width);
|
||||
}
|
||||
|
||||
private static readonly Color defaultColor = new Color(139, 233, 253);
|
||||
@@ -345,7 +317,7 @@ namespace Barotrauma
|
||||
return color;
|
||||
}
|
||||
|
||||
public bool CanConnect(NodeConnection otherNode)
|
||||
public bool CanConnect(EventEditorNodeConnection otherNode)
|
||||
{
|
||||
if (otherNode.OverrideValue != null)
|
||||
{
|
||||
@@ -25,7 +25,7 @@ namespace Barotrauma
|
||||
private readonly List<EditorNode> selectedNodes = new List<EditorNode>();
|
||||
|
||||
public static Vector2 DraggingPosition = Vector2.Zero;
|
||||
public static NodeConnection? DraggedConnection;
|
||||
public static EventEditorNodeConnection? DraggedConnection;
|
||||
|
||||
private EditorNode? draggedNode;
|
||||
private Vector2 dragOffset;
|
||||
@@ -394,7 +394,7 @@ namespace Barotrauma
|
||||
newNode = new CustomNode(subElement.Name.ToString()) { Position = new Vector2(ident, 0), ID = CreateID() };
|
||||
foreach (XAttribute attribute in subElement.Attributes().Where(attribute => !attribute.ToString().StartsWith("_")))
|
||||
{
|
||||
newNode.Connections.Add(new NodeConnection(newNode, NodeConnectionType.Value, attribute.Name.ToString(), typeof(string)));
|
||||
newNode.Connections.Add(new EventEditorNodeConnection(newNode, NodeConnectionType.Value, attribute.Name.ToString(), typeof(string)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -414,7 +414,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (xElement.Name.ToString().ToLowerInvariant() == "option")
|
||||
{
|
||||
NodeConnection optionConnection = new NodeConnection(newNode, NodeConnectionType.Option)
|
||||
EventEditorNodeConnection optionConnection = new EventEditorNodeConnection(newNode, NodeConnectionType.Option)
|
||||
{
|
||||
OptionText = xElement.GetAttributeString("text", string.Empty),
|
||||
EndConversation = xElement.GetAttributeBool("endconversation", false)
|
||||
@@ -423,7 +423,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
foreach (NodeConnection connection in newNode.Connections)
|
||||
foreach (EventEditorNodeConnection connection in newNode.Connections)
|
||||
{
|
||||
if (connection.Type == NodeConnectionType.Value)
|
||||
{
|
||||
@@ -479,8 +479,8 @@ namespace Barotrauma
|
||||
case "option":
|
||||
if (parent != null)
|
||||
{
|
||||
NodeConnection? activateConnection = newNode.Connections.Find(connection => connection.Type == NodeConnectionType.Activate);
|
||||
NodeConnection? optionConnection = parent.Connections.FirstOrDefault(connection =>
|
||||
EventEditorNodeConnection? activateConnection = newNode.Connections.Find(connection => connection.Type == NodeConnectionType.Activate);
|
||||
EventEditorNodeConnection? optionConnection = parent.Connections.FirstOrDefault(connection =>
|
||||
connection.Type == NodeConnectionType.Option && string.Equals(connection.OptionText, parentElement.GetAttributeString("text", string.Empty), StringComparison.Ordinal));
|
||||
|
||||
if (activateConnection != null)
|
||||
@@ -671,7 +671,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateContextMenu(EditorNode node, NodeConnection? connection = null)
|
||||
private void CreateContextMenu(EditorNode node, EventEditorNodeConnection? connection = null)
|
||||
{
|
||||
if (GUIContextMenu.CurrentContextMenu != null) { return; }
|
||||
|
||||
@@ -757,7 +757,7 @@ namespace Barotrauma
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void CreateEditMenu(ValueNode? node, NodeConnection? connection = null)
|
||||
private static void CreateEditMenu(ValueNode? node, EventEditorNodeConnection? connection = null)
|
||||
{
|
||||
object? newValue;
|
||||
Type? type;
|
||||
@@ -972,7 +972,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (PlayerInput.PrimaryMouseButtonDown())
|
||||
{
|
||||
NodeConnection? connection = node.GetConnectionOnMouse(mousePos);
|
||||
EventEditorNodeConnection? connection = node.GetConnectionOnMouse(mousePos);
|
||||
if (connection != null && connection.Type.NodeSide == NodeConnectionType.Side.Right)
|
||||
{
|
||||
if (connection.Type != NodeConnectionType.Out)
|
||||
@@ -1019,7 +1019,7 @@ namespace Barotrauma
|
||||
|
||||
if (PlayerInput.SecondaryMouseButtonClicked())
|
||||
{
|
||||
NodeConnection? connection = node.GetConnectionOnMouse(mousePos);
|
||||
EventEditorNodeConnection? connection = node.GetConnectionOnMouse(mousePos);
|
||||
if (node.GetDrawRectangle().Contains(mousePos) || connection != null)
|
||||
{
|
||||
CreateContextMenu(node, node.GetConnectionOnMouse(mousePos));
|
||||
@@ -1088,7 +1088,7 @@ namespace Barotrauma
|
||||
if (!DraggedConnection.CanConnect(nodeOnMouse)) { continue; }
|
||||
|
||||
nodeOnMouse.ClearConnections();
|
||||
DraggedConnection.Parent.Connect(DraggedConnection, nodeOnMouse);
|
||||
EditorNode.Connect(DraggedConnection, nodeOnMouse);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -392,7 +392,7 @@ namespace Barotrauma
|
||||
Level.Loaded?.DrawDebugOverlay(spriteBatch, cam);
|
||||
if (GameMain.DebugDraw)
|
||||
{
|
||||
MapEntity.mapEntityList.ForEach(me => me.AiTarget?.Draw(spriteBatch));
|
||||
MapEntity.MapEntityList.ForEach(me => me.AiTarget?.Draw(spriteBatch));
|
||||
Character.CharacterList.ForEach(c => c.AiTarget?.Draw(spriteBatch));
|
||||
if (GameMain.GameSession?.EventManager != null)
|
||||
{
|
||||
@@ -415,7 +415,7 @@ namespace Barotrauma
|
||||
GameMain.LightManager.LosEffect.Parameters["xLosAlpha"].SetValue(GameMain.LightManager.LosAlpha);
|
||||
|
||||
Color losColor;
|
||||
if (GameMain.LightManager.LosMode is LosMode.Transparent or LosMode.BlockOutsideView)
|
||||
if (GameMain.LightManager.LosMode == LosMode.Transparent)
|
||||
{
|
||||
//convert the los color to HLS and make sure the luminance of the color is always the same
|
||||
//as the luminance of the ambient light color
|
||||
|
||||
@@ -236,6 +236,7 @@ namespace Barotrauma
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
new GUIButton(new RectTransform(new Vector2(1.0f, 0.05f), paddedRightPanel.RectTransform),
|
||||
TextManager.Get("leveleditor.test"))
|
||||
{
|
||||
@@ -314,6 +315,52 @@ namespace Barotrauma
|
||||
{ RelativeOffset = new Vector2(leftPanel.RectTransform.RelativeSize.X * 2, 0.0f) }, style: "GUIFrameTop");
|
||||
}
|
||||
|
||||
public void TestLevelGenerationForErrors(int amountOfLevelsToGenerate)
|
||||
{
|
||||
CoroutineManager.StartCoroutine(GenerateLevels());
|
||||
|
||||
IEnumerable<CoroutineStatus> GenerateLevels()
|
||||
{
|
||||
using var errorCatcher = DebugConsole.ErrorCatcher.Create();
|
||||
for (int i = 0; i < amountOfLevelsToGenerate; i++)
|
||||
{
|
||||
Submarine.Unload();
|
||||
GameMain.LightManager.ClearLights();
|
||||
|
||||
currentLevelData = LevelData.CreateRandom(ToolBox.RandomSeed(10), generationParams: selectedParams);
|
||||
currentLevelData.ForceOutpostGenerationParams = outpostParamsList.SelectedData as OutpostGenerationParams;
|
||||
currentLevelData.AllowInvalidOutpost = allowInvalidOutpost.Selected;
|
||||
var dummyLocations = GameSession.CreateDummyLocations(currentLevelData);
|
||||
DebugConsole.NewMessage("*****************************************************************************");
|
||||
DebugConsole.NewMessage($"Generating level {(i + 1)}/{amountOfLevelsToGenerate}: ");
|
||||
DebugConsole.NewMessage(" Seed: " + currentLevelData.Seed);
|
||||
DebugConsole.NewMessage(" Outpost parameters: " + (currentLevelData.ForceOutpostGenerationParams?.Name ?? "None"));
|
||||
DebugConsole.NewMessage(" Level generation params: " + selectedParams.Identifier);
|
||||
DebugConsole.NewMessage(" Mirrored: " + mirrorLevel.Selected);
|
||||
DebugConsole.NewMessage(" Adjacent locations: " + (dummyLocations[0]?.Type.Identifier ?? "none".ToIdentifier()) + ", " + (dummyLocations[1]?.Type.Identifier ?? "none".ToIdentifier()));
|
||||
|
||||
yield return CoroutineStatus.Running;
|
||||
|
||||
Level.Generate(currentLevelData, mirror: mirrorLevel.Selected, startLocation: dummyLocations[0], endLocation: dummyLocations[1]);
|
||||
Submarine.MainSub?.SetPosition(Level.Loaded.StartPosition);
|
||||
GameMain.LightManager.AddLight(pointerLightSource);
|
||||
seedBox.Deselect();
|
||||
|
||||
if (errorCatcher.Errors.Any())
|
||||
{
|
||||
DebugConsole.ThrowError("Error while generating level:");
|
||||
errorCatcher.Errors.ToList().ForEach(e => DebugConsole.ThrowError(e.Text));
|
||||
yield return CoroutineStatus.Success;
|
||||
}
|
||||
yield return CoroutineStatus.Running;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public override void Select()
|
||||
{
|
||||
base.Select();
|
||||
@@ -903,6 +950,7 @@ namespace Barotrauma
|
||||
spriteBatch.End();
|
||||
}
|
||||
|
||||
|
||||
public override void Update(double deltaTime)
|
||||
{
|
||||
if (lightingEnabled.Selected)
|
||||
|
||||
@@ -83,7 +83,6 @@ namespace Barotrauma
|
||||
{
|
||||
SetMenuTabPositioning();
|
||||
CreateHostServerFields();
|
||||
CreateCampaignSetupUI();
|
||||
SettingsMenu.Create(menuTabs[Tab.Settings].RectTransform);
|
||||
if (remoteContentDoc?.Root != null)
|
||||
{
|
||||
@@ -634,7 +633,7 @@ namespace Barotrauma
|
||||
campaignSetupUI.UpdateSubList(SubmarineInfo.SavedSubmarines);
|
||||
break;
|
||||
case Tab.LoadGame:
|
||||
campaignSetupUI.UpdateLoadMenu();
|
||||
campaignSetupUI.CreateLoadMenu();
|
||||
break;
|
||||
case Tab.Settings:
|
||||
SettingsMenu.Create(menuTabs[Tab.Settings].RectTransform);
|
||||
@@ -1224,7 +1223,7 @@ namespace Barotrauma
|
||||
var paddedLoadGame = new GUIFrame(new RectTransform(new Vector2(0.9f, 0.9f), menuTabs[Tab.LoadGame].RectTransform, Anchor.Center) { AbsoluteOffset = new Point(0, 10) },
|
||||
style: null);
|
||||
|
||||
campaignSetupUI = new SinglePlayerCampaignSetupUI(newGameContent, paddedLoadGame, SubmarineInfo.SavedSubmarines)
|
||||
campaignSetupUI = new SinglePlayerCampaignSetupUI(newGameContent, paddedLoadGame)
|
||||
{
|
||||
LoadGame = LoadGame,
|
||||
StartNewGame = StartGame
|
||||
@@ -1550,6 +1549,14 @@ namespace Barotrauma
|
||||
try
|
||||
{
|
||||
if (!t.TryGetResult(out IRestResponse remoteContentResponse)) { throw new Exception("Task did not return a valid result"); }
|
||||
if (remoteContentResponse.StatusCode != HttpStatusCode.OK)
|
||||
{
|
||||
DebugConsole.AddWarning(
|
||||
"Failed to receive remote main menu content. " +
|
||||
"There may be an issue with your internet connection, or the master server might be temporarily unavailable " +
|
||||
$"(error code: {remoteContentResponse.StatusCode})");
|
||||
return;
|
||||
}
|
||||
string xml = remoteContentResponse.Content;
|
||||
int index = xml.IndexOf('<');
|
||||
if (index > 0) { xml = xml.Substring(index, xml.Length - index); }
|
||||
|
||||
@@ -378,7 +378,7 @@ namespace Barotrauma
|
||||
}
|
||||
string dir = path.RemoveFromEnd(ModReceiver.Extension, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
SaveUtil.DecompressToDirectory(path, dir, file => { });
|
||||
SaveUtil.DecompressToDirectory(path, dir);
|
||||
var result = ContentPackage.TryLoad(Path.Combine(dir, ContentPackage.FileListFileName));
|
||||
|
||||
if (!result.TryUnwrapSuccess(out var newPackage))
|
||||
|
||||
@@ -22,8 +22,6 @@ namespace Barotrauma
|
||||
|
||||
private GUIComponent jobVariantTooltip;
|
||||
|
||||
private SubmarinePreview submarinePreview;
|
||||
|
||||
private readonly GUITextBox chatInput;
|
||||
private readonly GUITextBox serverLogFilter;
|
||||
public GUITextBox ChatInput
|
||||
@@ -38,8 +36,10 @@ namespace Barotrauma
|
||||
|
||||
private readonly GUIScrollBar levelDifficultyScrollBar;
|
||||
|
||||
private readonly GUIButton[] traitorProbabilityButtons;
|
||||
private readonly List<GUIComponent> traitorElements = new List<GUIComponent>();
|
||||
private readonly GUIScrollBar traitorProbabilitySlider;
|
||||
private readonly GUITextBlock traitorProbabilityText;
|
||||
private readonly GUILayoutGroup traitorDangerGroup;
|
||||
|
||||
private readonly GUIButton[] botCountButtons;
|
||||
private readonly GUITextBlock botCountText;
|
||||
@@ -68,6 +68,7 @@ namespace Barotrauma
|
||||
public static GUIButton JobInfoFrame;
|
||||
|
||||
private readonly GUITickBox spectateBox;
|
||||
public bool Spectating => spectateBox is { Selected: true, Visible: true };
|
||||
|
||||
private readonly GUIFrame playerInfoContainer;
|
||||
|
||||
@@ -1070,15 +1071,27 @@ namespace Barotrauma
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.055f), settingsHolder.RectTransform) { MinSize = new Point(0, 25) },
|
||||
TextManager.Get("Settings"), font: GUIStyle.SubHeadingFont);
|
||||
var settingsFrame = new GUIFrame(new RectTransform(Vector2.One, settingsHolder.RectTransform), style: "InnerFrame");
|
||||
var settingsContent = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.95f), settingsFrame.RectTransform, Anchor.Center))
|
||||
|
||||
var settingsFrameTop = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.55f), settingsHolder.RectTransform), style: "InnerFrame");
|
||||
var settingsContentTop = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.9f), settingsFrameTop.RectTransform, Anchor.Center))
|
||||
{
|
||||
RelativeSpacing = 0.025f
|
||||
Stretch = true,
|
||||
AbsoluteSpacing = GUI.IntScale(10)
|
||||
};
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.055f), settingsHolder.RectTransform) { MinSize = new Point(0, 30) },
|
||||
TextManager.Get("TraitorSettings"), font: GUIStyle.SubHeadingFont);
|
||||
|
||||
var settingsFrameBottom = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.35f), settingsHolder.RectTransform), style: "InnerFrame");
|
||||
var settingsContentBottom = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.85f), settingsFrameBottom.RectTransform, Anchor.Center))
|
||||
{
|
||||
Stretch = true,
|
||||
AbsoluteSpacing = GUI.IntScale(10)
|
||||
};
|
||||
|
||||
//seed ------------------------------------------------------------------
|
||||
|
||||
var seedLabel = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.1f), settingsContent.RectTransform), TextManager.Get("LevelSeed"));
|
||||
var seedLabel = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.1f), settingsContentTop.RectTransform), TextManager.Get("LevelSeed"));
|
||||
SeedBox = new GUITextBox(new RectTransform(new Vector2(0.5f, 1.0f), seedLabel.RectTransform, Anchor.CenterRight));
|
||||
SeedBox.OnDeselected += (textBox, key) =>
|
||||
{
|
||||
@@ -1089,7 +1102,10 @@ namespace Barotrauma
|
||||
|
||||
//level difficulty ------------------------------------------------------------------
|
||||
|
||||
var difficultyHolder = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.2f), settingsContent.RectTransform), style: null);
|
||||
var difficultyHolder = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.2f), settingsContentTop.RectTransform), style: null)
|
||||
{
|
||||
CanBeFocused = true
|
||||
};
|
||||
|
||||
var difficultyLabel = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.5f), difficultyHolder.RectTransform), TextManager.Get("LevelDifficulty"))
|
||||
{
|
||||
@@ -1116,46 +1132,16 @@ namespace Barotrauma
|
||||
if (!EventManagerSettings.Prefabs.Any()) { return true; }
|
||||
difficultyName.Text =
|
||||
EventManagerSettings.GetByDifficultyPercentile(value).Name
|
||||
+ " (" + ((int)Math.Round(scrollbar.BarScrollValue)) + " %)";
|
||||
+ $" ({TextManager.GetWithVariable("percentageformat", "[value]", ((int)Math.Round(scrollbar.BarScrollValue)).ToString())})";
|
||||
difficultyName.TextColor = ToolBox.GradientLerp(scrollbar.BarScroll, GUIStyle.Green, GUIStyle.Orange, GUIStyle.Red);
|
||||
return true;
|
||||
};
|
||||
|
||||
clientDisabledElements.Add(levelDifficultyScrollBar);
|
||||
|
||||
//traitor probability ------------------------------------------------------------------
|
||||
|
||||
var traitorsSettingHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.1f), settingsContent.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft) { Stretch = true };
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.7f, 0.0f), traitorsSettingHolder.RectTransform), TextManager.Get("Traitors"), wrap: true);
|
||||
|
||||
var traitorProbContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 1.0f), traitorsSettingHolder.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft) { RelativeSpacing = 0.05f, Stretch = true };
|
||||
traitorProbabilityButtons = new GUIButton[2];
|
||||
traitorProbabilityButtons[0] = new GUIButton(new RectTransform(new Vector2(0.15f, 1.0f), traitorProbContainer.RectTransform), style: "GUIButtonToggleLeft")
|
||||
{
|
||||
OnClicked = (button, obj) =>
|
||||
{
|
||||
GameMain.Client?.ServerSettings.ClientAdminWrite(ServerSettings.NetFlags.Misc, traitorSetting: -1);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
traitorProbabilityText = new GUITextBlock(new RectTransform(new Vector2(0.7f, 1.0f), traitorProbContainer.RectTransform), TextManager.Get("No"),
|
||||
textAlignment: Alignment.Center, style: "GUITextBox");
|
||||
traitorProbabilityButtons[1] = new GUIButton(new RectTransform(new Vector2(0.15f, 1.0f), traitorProbContainer.RectTransform), style: "GUIButtonToggleRight")
|
||||
{
|
||||
OnClicked = (button, obj) =>
|
||||
{
|
||||
GameMain.Client?.ServerSettings.ClientAdminWrite(ServerSettings.NetFlags.Misc, traitorSetting: 1);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
clientDisabledElements.AddRange(traitorProbabilityButtons);
|
||||
|
||||
//bot count ------------------------------------------------------------------
|
||||
|
||||
var botCountSettingHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.1f), settingsContent.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft) { Stretch = true };
|
||||
var botCountSettingHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.1f), settingsContentTop.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft) { Stretch = true };
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.7f, 0.0f), botCountSettingHolder.RectTransform), TextManager.Get("BotCount"), wrap: true);
|
||||
var botCountContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 1.0f), botCountSettingHolder.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft) { RelativeSpacing = 0.05f, Stretch = true };
|
||||
@@ -1178,10 +1164,10 @@ namespace Barotrauma
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
botCountSettingHolder.RectTransform.MinSize = new Point(0, SeedBox.RectTransform.MinSize.Y);
|
||||
clientDisabledElements.AddRange(botCountButtons);
|
||||
|
||||
var botSpawnModeSettingHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.1f), settingsContent.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft) { Stretch = true };
|
||||
var botSpawnModeSettingHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.1f), settingsContentTop.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft) { Stretch = true };
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.7f, 0.0f), botSpawnModeSettingHolder.RectTransform), TextManager.Get("BotSpawnMode"), wrap: true);
|
||||
var botSpawnModeContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 1.0f), botSpawnModeSettingHolder.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft) { RelativeSpacing = 0.05f, Stretch = true };
|
||||
@@ -1205,23 +1191,108 @@ namespace Barotrauma
|
||||
}
|
||||
};
|
||||
|
||||
List<GUIComponent> settingsElements = settingsContent.Children.ToList();
|
||||
for (int i = 0; i < settingsElements.Count; i++)
|
||||
{
|
||||
if (settingsElements[i].CountChildren > 0)
|
||||
{
|
||||
settingsElements[i].RectTransform.MinSize = new Point(0, Math.Max(settingsElements[i].RectTransform.Children.Max(c => c.Rect.Height), (int)(20 * GUI.Scale)));
|
||||
}
|
||||
}
|
||||
clientDisabledElements.AddRange(botSpawnModeButtons);
|
||||
|
||||
settingsBlocker = new GUIFrame(new RectTransform(Vector2.One, settingsFrame.RectTransform), style: "InnerFrame")
|
||||
settingsBlocker = new GUIFrame(new RectTransform(Vector2.One, settingsFrameTop.RectTransform), style: "InnerFrame")
|
||||
{
|
||||
Color = Color.Black * 0.5f,
|
||||
Color = Color.Black * 0.85f,
|
||||
IgnoreLayoutGroups = true,
|
||||
Visible = false
|
||||
};
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.75f, 0.3f), settingsBlocker.RectTransform, Anchor.Center),
|
||||
TextManager.Get("settings.campaigndisabled"), wrap: true, style: "InnerFrame", textAlignment: Alignment.Center, textColor: GUIStyle.TextColorNormal);
|
||||
|
||||
clientDisabledElements.AddRange(botSpawnModeButtons);
|
||||
//traitor probability ------------------------------------------------------------------
|
||||
|
||||
var traitorsProbHolder = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.6f), settingsContentBottom.RectTransform), style: null);
|
||||
|
||||
var traitorProbLabel = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.5f), traitorsProbHolder.RectTransform), TextManager.Get("traitor.probability"));
|
||||
|
||||
traitorProbabilitySlider = new GUIScrollBar(new RectTransform(new Vector2(1.0f, 0.5f), traitorsProbHolder.RectTransform, Anchor.BottomCenter), style: "GUISlider", barSize: 0.2f)
|
||||
{
|
||||
Step = 0.05f,
|
||||
Range = new Vector2(0.0f, 1.0f),
|
||||
ToolTip = TextManager.Get("traitor.probability.tooltip"),
|
||||
OnReleased = (scrollbar, value) =>
|
||||
{
|
||||
GameMain.Client?.ServerSettings.ClientAdminWrite(ServerSettings.NetFlags.Misc, traitorProbability: value);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
var traitorProbabilityText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 1.0f), traitorProbLabel.RectTransform), "", textAlignment: Alignment.CenterRight)
|
||||
{
|
||||
ToolTip = TextManager.Get("traitor.probability.tooltip")
|
||||
};
|
||||
traitorProbabilitySlider.OnMoved = (scrollbar, value) =>
|
||||
{
|
||||
traitorProbabilityText.Text = TextManager.GetWithVariable("percentageformat", "[value]", ((int)Math.Round(scrollbar.BarScrollValue * 100)).ToString());
|
||||
traitorProbabilityText.TextColor =
|
||||
value <= 0.0f ?
|
||||
GUIStyle.Green :
|
||||
ToolBox.GradientLerp(scrollbar.BarScroll, GUIStyle.Yellow, GUIStyle.Orange, GUIStyle.Red);
|
||||
return true;
|
||||
};
|
||||
|
||||
traitorElements.Clear();
|
||||
traitorElements.Add(traitorProbabilityText);
|
||||
traitorElements.Add(traitorProbabilitySlider);
|
||||
clientDisabledElements.Add(traitorProbabilitySlider);
|
||||
|
||||
var traitorDangerHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.4f), settingsContentBottom.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft)
|
||||
{
|
||||
Stretch = true
|
||||
};
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.7f, 1.0f), traitorDangerHolder.RectTransform), TextManager.Get("traitor.dangerlevelsetting"), wrap: true)
|
||||
{
|
||||
ToolTip = TextManager.Get("traitor.dangerlevelsetting.tooltip")
|
||||
};
|
||||
|
||||
var traitorDangerContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 1.0f), traitorDangerHolder.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft) { RelativeSpacing = 0.05f, Stretch = true };
|
||||
var traitorDangerButtons = new GUIButton[2];
|
||||
traitorDangerButtons[0] = new GUIButton(new RectTransform(new Vector2(0.15f, 1.0f), traitorDangerContainer.RectTransform), style: "GUIButtonToggleLeft")
|
||||
{
|
||||
OnClicked = (button, obj) =>
|
||||
{
|
||||
GameMain.Client?.ServerSettings.ClientAdminWrite(ServerSettings.NetFlags.Misc, traitorDangerLevel: -1);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
traitorDangerGroup = new GUILayoutGroup(new RectTransform(new Vector2(0.7f, 1.0f), traitorDangerContainer.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft)
|
||||
{
|
||||
Stretch = true,
|
||||
AbsoluteSpacing = 1
|
||||
};
|
||||
for (int i = TraitorEventPrefab.MinDangerLevel; i <= TraitorEventPrefab.MaxDangerLevel; i++)
|
||||
{
|
||||
var difficultyColor = Mission.GetDifficultyColor(i);
|
||||
new GUIImage(new RectTransform(new Vector2(0.75f), traitorDangerGroup.RectTransform), "DifficultyIndicator", scaleToFit: true)
|
||||
{
|
||||
ToolTip =
|
||||
RichString.Rich(
|
||||
$"‖color:{Color.White.ToStringHex()}‖{TextManager.Get($"traitor.dangerlevel.{i}")}‖color:end‖" + '\n' +
|
||||
TextManager.Get($"traitor.dangerlevel.{i}.description")),
|
||||
Color = difficultyColor,
|
||||
DisabledColor = Color.Gray * 0.5f,
|
||||
};
|
||||
}
|
||||
|
||||
traitorDangerButtons[1] = new GUIButton(new RectTransform(new Vector2(0.15f, 1.0f), traitorDangerContainer.RectTransform), style: "GUIButtonToggleRight")
|
||||
{
|
||||
OnClicked = (button, obj) =>
|
||||
{
|
||||
GameMain.Client?.ServerSettings.ClientAdminWrite(ServerSettings.NetFlags.Misc, traitorDangerLevel: 1);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
SetTraitorDangerIndicators(GameMain.Client?.ServerSettings.TraitorDangerLevel ?? TraitorEventPrefab.MinDangerLevel);
|
||||
traitorElements.AddRange(traitorDangerButtons);
|
||||
clientDisabledElements.AddRange(traitorDangerButtons);
|
||||
|
||||
settingsContentTop.Recalculate();
|
||||
settingsContentBottom.Recalculate();
|
||||
}
|
||||
|
||||
public void StopWaitingForStartRound()
|
||||
@@ -1264,6 +1335,7 @@ namespace Barotrauma
|
||||
|
||||
public override void Deselect()
|
||||
{
|
||||
SaveAppearance();
|
||||
chatInput.Deselect();
|
||||
CampaignCharacterDiscarded = false;
|
||||
|
||||
@@ -1338,34 +1410,35 @@ namespace Barotrauma
|
||||
|
||||
public void RefreshEnabledElements()
|
||||
{
|
||||
ServerName.Readonly = !GameMain.Client.HasPermission(ClientPermissions.ManageSettings);
|
||||
ServerMessage.Readonly = !GameMain.Client.HasPermission(ClientPermissions.ManageSettings);
|
||||
missionTypeList.Enabled = GameMain.Client.HasPermission(ClientPermissions.ManageSettings);
|
||||
bool manageSettings = GameMain.Client.HasPermission(ClientPermissions.ManageSettings);
|
||||
|
||||
ServerName.Readonly = !manageSettings;
|
||||
ServerMessage.Readonly = !manageSettings;
|
||||
missionTypeList.Enabled = manageSettings;
|
||||
foreach (var tickBox in missionTypeTickBoxes)
|
||||
{
|
||||
tickBox.Enabled = GameMain.Client.HasPermission(ClientPermissions.ManageSettings);
|
||||
tickBox.Enabled = manageSettings;
|
||||
}
|
||||
SeedBox.Enabled = !CampaignFrame.Visible && !CampaignSetupFrame.Visible && GameMain.Client.HasPermission(ClientPermissions.ManageSettings);
|
||||
levelDifficultyScrollBar.Enabled = !CampaignFrame.Visible && !CampaignSetupFrame.Visible && GameMain.Client.HasPermission(ClientPermissions.ManageSettings);
|
||||
SeedBox.Enabled = !CampaignFrame.Visible && !CampaignSetupFrame.Visible && manageSettings;
|
||||
levelDifficultyScrollBar.Enabled = !CampaignFrame.Visible && !CampaignSetupFrame.Visible && manageSettings;
|
||||
levelDifficultyScrollBar.ToolTip = string.Empty;
|
||||
if (!levelDifficultyScrollBar.Enabled)
|
||||
{
|
||||
levelDifficultyScrollBar.ToolTip = TextManager.Get("campaigndifficultydisabled");
|
||||
}
|
||||
|
||||
traitorProbabilityButtons[0].Enabled = traitorProbabilityButtons[1].Enabled = traitorProbabilityText.Enabled =
|
||||
!CampaignFrame.Visible && !CampaignSetupFrame.Visible && GameMain.Client.HasPermission(ClientPermissions.ManageSettings);
|
||||
botCountButtons[0].Enabled = botCountButtons[1].Enabled = GameMain.Client.HasPermission(ClientPermissions.ManageSettings);
|
||||
botSpawnModeButtons[0].Enabled = botSpawnModeButtons[1].Enabled = GameMain.Client.HasPermission(ClientPermissions.ManageSettings);
|
||||
traitorElements.ForEach(e => e.Enabled = manageSettings);
|
||||
botCountButtons[0].Enabled = botCountButtons[1].Enabled = manageSettings;
|
||||
botSpawnModeButtons[0].Enabled = botSpawnModeButtons[1].Enabled = manageSettings;
|
||||
|
||||
autoRestartBox.Enabled = GameMain.Client.HasPermission(ClientPermissions.ManageSettings);
|
||||
autoRestartBox.Enabled = manageSettings;
|
||||
|
||||
SettingsButton.Visible = GameMain.Client.HasPermission(ClientPermissions.ManageSettings);
|
||||
SettingsButton.Visible = manageSettings;
|
||||
SettingsButton.OnClicked = GameMain.Client.ServerSettings.ToggleSettingsFrame;
|
||||
StartButton.Visible = GameMain.Client.HasPermission(ClientPermissions.ManageRound) && !GameMain.Client.GameStarted && !CampaignSetupFrame.Visible && !CampaignFrame.Visible;
|
||||
ServerName.Readonly = !GameMain.Client.HasPermission(ClientPermissions.ManageSettings);
|
||||
ServerMessage.Readonly = !GameMain.Client.HasPermission(ClientPermissions.ManageSettings);
|
||||
shuttleTickBox.Enabled = GameMain.Client.HasPermission(ClientPermissions.ManageSettings) && !GameMain.Client.GameStarted;
|
||||
ServerName.Readonly = !manageSettings;
|
||||
ServerMessage.Readonly = !manageSettings;
|
||||
shuttleTickBox.Enabled = manageSettings && !GameMain.Client.GameStarted;
|
||||
SubList.Enabled = !CampaignFrame.Visible && (GameMain.Client.ServerSettings.AllowSubVoting || GameMain.Client.HasPermission(ClientPermissions.SelectSub));
|
||||
ShuttleList.Enabled = ShuttleList.ButtonEnabled = GameMain.Client.HasPermission(ClientPermissions.SelectSub) && !GameMain.Client.GameStarted;
|
||||
ModeList.Enabled = !GameMain.Client.GameStarted && (GameMain.Client.ServerSettings.AllowModeVoting || GameMain.Client.HasPermission(ClientPermissions.SelectMode));
|
||||
@@ -1375,7 +1448,7 @@ namespace Barotrauma
|
||||
roundControlsHolder.Children.ForEach(c => c.RectTransform.RelativeSize = Vector2.One);
|
||||
roundControlsHolder.Recalculate();
|
||||
|
||||
SubVisibilityButton.Visible = GameMain.Client.HasPermission(ClientPermissions.ManageSettings);
|
||||
SubVisibilityButton.Visible = manageSettings;
|
||||
|
||||
ReadyToStartBox.Parent.Visible = !GameMain.Client.GameStarted;
|
||||
|
||||
@@ -1415,6 +1488,7 @@ namespace Barotrauma
|
||||
|
||||
public void CreatePlayerFrame(GUIComponent parent, bool createPendingText = true, bool alwaysAllowEditing = false)
|
||||
{
|
||||
if (GameMain.Client == null) { return; }
|
||||
UpdatePlayerFrame(
|
||||
Character.Controlled?.Info ?? playerInfoContainer.Children?.First().UserData as CharacterInfo ?? GameMain.Client.CharacterInfo,
|
||||
allowEditing: alwaysAllowEditing || campaignCharacterInfo == null,
|
||||
@@ -1424,6 +1498,7 @@ namespace Barotrauma
|
||||
|
||||
private void UpdatePlayerFrame(CharacterInfo characterInfo, bool allowEditing, GUIComponent parent, bool createPendingText = true)
|
||||
{
|
||||
if (GameMain.Client == null) { return; }
|
||||
createPendingChangesText = createPendingText;
|
||||
if (characterInfo == null || CampaignCharacterDiscarded)
|
||||
{
|
||||
@@ -1447,7 +1522,6 @@ namespace Barotrauma
|
||||
bool nameChangePending = isGameRunning && GameMain.Client.PendingName != string.Empty && GameMain.Client?.Character?.Name != GameMain.Client.PendingName;
|
||||
changesPendingText = null;
|
||||
|
||||
|
||||
if (TabMenu.PendingChanges)
|
||||
{
|
||||
CreateChangesPendingText();
|
||||
@@ -1754,6 +1828,16 @@ namespace Barotrauma
|
||||
jobVariantTooltip.RectTransform.MinSize = new Point(0, content.RectTransform.Children.Sum(c => c.Rect.Height + content.AbsoluteSpacing));
|
||||
}
|
||||
|
||||
private void SetTraitorDangerIndicators(int dangerLevel)
|
||||
{
|
||||
int i = 0;
|
||||
foreach (var child in traitorDangerGroup.Children)
|
||||
{
|
||||
child.Enabled = i < dangerLevel;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
public bool ToggleSpectate(GUITickBox tickBox)
|
||||
{
|
||||
SetSpectate(tickBox.Selected);
|
||||
@@ -2088,7 +2172,7 @@ namespace Barotrauma
|
||||
private Action<SpriteBatch, GUICustomComponent> DrawDownloadThrobber(Client client, params GUIComponent[] otherComponents)
|
||||
=> (sb, c) => DrawDownloadThrobber(client, otherComponents, sb, c); //poor man's currying
|
||||
|
||||
private void DrawDownloadThrobber(Client client, GUIComponent[] otherComponents, SpriteBatch spriteBatch, GUICustomComponent component)
|
||||
private static void DrawDownloadThrobber(Client client, GUIComponent[] otherComponents, SpriteBatch spriteBatch, GUICustomComponent component)
|
||||
{
|
||||
if (!client.IsDownloading)
|
||||
{
|
||||
@@ -2322,7 +2406,14 @@ namespace Barotrauma
|
||||
|
||||
PlayerFrame = new GUIButton(new RectTransform(Vector2.One, GUI.Canvas, Anchor.Center), style: null)
|
||||
{
|
||||
OnClicked = (btn, userdata) => { if (GUI.MouseOn == btn || GUI.MouseOn == btn.TextBlock) ClosePlayerFrame(btn, userdata); return true; }
|
||||
OnClicked = (btn, userdata) =>
|
||||
{
|
||||
if (GUI.MouseOn == btn || GUI.MouseOn == btn.TextBlock)
|
||||
{
|
||||
ClosePlayerFrame(btn, userdata);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
new GUIFrame(new RectTransform(GUI.Canvas.RelativeSize, PlayerFrame.RectTransform, Anchor.Center), style: "GUIBackgroundBlocker");
|
||||
@@ -2412,7 +2503,7 @@ namespace Barotrauma
|
||||
//reset rank to custom
|
||||
rankDropDown.SelectItem(null);
|
||||
|
||||
if (!(PlayerFrame.UserData is Client client)) { return false; }
|
||||
if (PlayerFrame.UserData is not Client client) { return false; }
|
||||
|
||||
foreach (GUIComponent child in tickbox.Parent.GetChild<GUIListBox>().Content.Children)
|
||||
{
|
||||
@@ -2432,7 +2523,7 @@ namespace Barotrauma
|
||||
|
||||
foreach (ClientPermissions permission in Enum.GetValues(typeof(ClientPermissions)))
|
||||
{
|
||||
if (permission == ClientPermissions.None || permission == ClientPermissions.All) continue;
|
||||
if (permission == ClientPermissions.None || permission == ClientPermissions.All) { continue; }
|
||||
|
||||
var permissionTick = new GUITickBox(new RectTransform(new Vector2(0.15f, 0.15f), permissionsBox.Content.RectTransform),
|
||||
TextManager.Get("ClientPermission." + permission), font: GUIStyle.SmallFont)
|
||||
@@ -2445,7 +2536,7 @@ namespace Barotrauma
|
||||
//reset rank to custom
|
||||
rankDropDown.SelectItem(null);
|
||||
|
||||
if (!(PlayerFrame.UserData is Client client)) { return false; }
|
||||
if (PlayerFrame.UserData is not Client client) { return false; }
|
||||
|
||||
var thisPermission = (ClientPermissions)tickBox.UserData;
|
||||
if (tickBox.Selected)
|
||||
@@ -2480,7 +2571,7 @@ namespace Barotrauma
|
||||
//reset rank to custom
|
||||
rankDropDown.SelectItem(null);
|
||||
|
||||
if (!(PlayerFrame.UserData is Client client)) { return false; }
|
||||
if (PlayerFrame.UserData is not Client client) { return false; }
|
||||
|
||||
foreach (GUIComponent child in tickbox.Parent.GetChild<GUIListBox>().Content.Children)
|
||||
{
|
||||
@@ -2803,7 +2894,7 @@ namespace Barotrauma
|
||||
publicOrPrivate.RectTransform.NonScaledSize = (publicOrPrivate.Font.MeasureString(publicOrPrivate.Text) + new Vector2(25, 8) * GUI.Scale).ToPoint();
|
||||
}
|
||||
|
||||
private void DrawJobVariantItems(SpriteBatch spriteBatch, GUICustomComponent component, JobVariant jobPrefab, int itemsPerRow)
|
||||
private static void DrawJobVariantItems(SpriteBatch spriteBatch, GUICustomComponent component, JobVariant jobPrefab, int itemsPerRow)
|
||||
{
|
||||
var itemIdentifiers = jobPrefab.Prefab.PreviewItems[jobPrefab.Variant]
|
||||
.Where(it => it.ShowPreview)
|
||||
@@ -2938,28 +3029,22 @@ namespace Barotrauma
|
||||
{
|
||||
OnHeadSwitch = menu =>
|
||||
{
|
||||
StoreHead(true);
|
||||
UpdateJobPreferences(info);
|
||||
SelectAppearanceTab(button, _);
|
||||
},
|
||||
OnSliderMoved = (bar, scroll) =>
|
||||
{
|
||||
StoreHead(false);
|
||||
return false;
|
||||
},
|
||||
OnSliderReleased = SaveHead
|
||||
}
|
||||
};
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool SaveHead(GUIScrollBar scrollBar, float barScroll) => StoreHead(true);
|
||||
private bool StoreHead(bool save)
|
||||
public bool SaveAppearance()
|
||||
{
|
||||
var info = GameMain.Client.CharacterInfo;
|
||||
var info = GameMain.Client?.CharacterInfo;
|
||||
if (info?.Head == null) { return false; }
|
||||
|
||||
var characterConfig = MultiplayerPreferences.Instance;
|
||||
|
||||
characterConfig.TagSet.Clear(); characterConfig.TagSet.UnionWith(info.Head.Preset.TagSet);
|
||||
characterConfig.TagSet.Clear();
|
||||
characterConfig.TagSet.UnionWith(info.Head.Preset.TagSet);
|
||||
characterConfig.HairIndex = info.Head.HairIndex;
|
||||
characterConfig.BeardIndex = info.Head.BeardIndex;
|
||||
characterConfig.MoustacheIndex = info.Head.MoustacheIndex;
|
||||
@@ -2968,15 +3053,12 @@ namespace Barotrauma
|
||||
characterConfig.FacialHairColor = info.Head.FacialHairColor;
|
||||
characterConfig.SkinColor = info.Head.SkinColor;
|
||||
|
||||
if (save)
|
||||
if (GameMain.GameSession?.IsRunning ?? false)
|
||||
{
|
||||
if (GameMain.GameSession?.IsRunning ?? false)
|
||||
{
|
||||
TabMenu.PendingChanges = true;
|
||||
CreateChangesPendingText();
|
||||
}
|
||||
GameSettings.SaveCurrentConfig();
|
||||
TabMenu.PendingChanges = true;
|
||||
CreateChangesPendingText();
|
||||
}
|
||||
GameSettings.SaveCurrentConfig();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3143,7 +3225,7 @@ namespace Barotrauma
|
||||
return true;
|
||||
}
|
||||
|
||||
private GUIImage[][] AddJobSpritesToGUIComponent(GUIComponent parent, JobPrefab jobPrefab, bool selectedByPlayer)
|
||||
private static GUIImage[][] AddJobSpritesToGUIComponent(GUIComponent parent, JobPrefab jobPrefab, bool selectedByPlayer)
|
||||
{
|
||||
GUIFrame innerFrame = null;
|
||||
List<JobPrefab.OutfitPreview> outfitPreviews = jobPrefab.GetJobOutfitSprites(CharacterPrefab.HumanPrefab.CharacterInfoPrefab, useInventoryIcon: true, out var maxDimensions);
|
||||
@@ -3221,6 +3303,7 @@ namespace Barotrauma
|
||||
|
||||
if ((prevMode == GameModePreset.PvP) != (SelectedMode == GameModePreset.PvP))
|
||||
{
|
||||
SaveAppearance();
|
||||
UpdatePlayerFrame(null);
|
||||
GameMain.Client.ConnectedClients.ForEach(c => SetPlayerNameAndJobPreference(c));
|
||||
}
|
||||
@@ -3363,7 +3446,11 @@ namespace Barotrauma
|
||||
if (!enabled)
|
||||
{
|
||||
//remove campaign character from the panel
|
||||
if (campaignCharacterInfo != null) { UpdatePlayerFrame(null); }
|
||||
if (campaignCharacterInfo != null)
|
||||
{
|
||||
UpdatePlayerFrame(null);
|
||||
SetSpectate(spectateBox.Selected);
|
||||
}
|
||||
campaignCharacterInfo = null;
|
||||
CampaignCharacterDiscarded = false;
|
||||
}
|
||||
@@ -3411,7 +3498,7 @@ namespace Barotrauma
|
||||
|
||||
private bool ViewJobInfo(GUIButton button, object obj)
|
||||
{
|
||||
if (!(button.UserData is JobVariant jobPrefab)) { return false; }
|
||||
if (button.UserData is not JobVariant jobPrefab) { return false; }
|
||||
|
||||
JobInfoFrame = jobPrefab.Prefab.CreateInfoFrame(out GUIComponent buttonContainer);
|
||||
GUIButton closeButton = new GUIButton(new RectTransform(new Vector2(0.25f, 0.05f), buttonContainer.RectTransform, Anchor.BottomRight),
|
||||
@@ -3541,7 +3628,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private GUIButton CreateJobVariantButton(JobVariant jobPrefab, int variantIndex, int variantCount, GUIComponent slot)
|
||||
private static GUIButton CreateJobVariantButton(JobVariant jobPrefab, int variantIndex, int variantCount, GUIComponent slot)
|
||||
{
|
||||
float relativeSize = 0.15f;
|
||||
|
||||
@@ -3631,9 +3718,13 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
if (subList == SubList)
|
||||
{
|
||||
FailedSelectedSub = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
FailedSelectedShuttle = null;
|
||||
}
|
||||
|
||||
//hashes match, all good
|
||||
if (sub.MD5Hash?.StringRepresentation == md5Hash && SubmarineInfo.SavedSubmarines.Contains(sub))
|
||||
|
||||
+1
-3
@@ -1047,7 +1047,7 @@ namespace Barotrauma
|
||||
}
|
||||
if (filterTraitorValue != TernaryOption.Any)
|
||||
{
|
||||
if ((serverInfo.TraitorsEnabled == YesNoMaybe.Yes || serverInfo.TraitorsEnabled == YesNoMaybe.Maybe) != (filterTraitorValue == TernaryOption.Enabled))
|
||||
if ((serverInfo.TraitorProbability > 0.0f) != (filterTraitorValue == TernaryOption.Enabled))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -1829,8 +1829,6 @@ namespace Barotrauma
|
||||
{
|
||||
graphics.Clear(Color.CornflowerBlue);
|
||||
|
||||
GameMain.TitleScreen.DrawLoadingText = false;
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, null, GUI.SamplerState, null, GameMain.ScissorTestEnable);
|
||||
GameMain.MainMenuScreen.DrawBackground(graphics, spriteBatch);
|
||||
GUI.Draw(Cam, spriteBatch);
|
||||
|
||||
@@ -75,6 +75,7 @@ namespace Barotrauma
|
||||
NoCargoSpawnpoints,
|
||||
NoBallastTag,
|
||||
NonLinkedGaps,
|
||||
NoHiddenContainers,
|
||||
StructureCount,
|
||||
WallCount,
|
||||
ItemCount,
|
||||
@@ -232,6 +233,8 @@ namespace Barotrauma
|
||||
|
||||
public override Camera Cam => cam;
|
||||
|
||||
public bool DrawCharacterInventory => dummyCharacter != null && WiringMode;
|
||||
|
||||
public static XDocument AutoSaveInfo;
|
||||
private static readonly string autoSavePath = Path.Combine("Submarines", ".AutoSaves");
|
||||
private static readonly string autoSaveInfoPath = Path.Combine(autoSavePath, "autosaves.xml");
|
||||
@@ -583,7 +586,7 @@ namespace Barotrauma
|
||||
if (!(o is string layer)) { return false; }
|
||||
|
||||
MapEntity.SelectedList.Clear();
|
||||
foreach (MapEntity entity in MapEntity.mapEntityList.Where(me => !me.Removed && me.Layer == layer))
|
||||
foreach (MapEntity entity in MapEntity.MapEntityList.Where(me => !me.Removed && me.Layer == layer))
|
||||
{
|
||||
if (entity.IsSelected) { continue; }
|
||||
|
||||
@@ -842,7 +845,7 @@ namespace Barotrauma
|
||||
var structureCount = new GUITextBlock(new RectTransform(new Vector2(0.33f, 1.0f), structureCountText.RectTransform, Anchor.TopRight, Pivot.TopLeft), "", textAlignment: Alignment.CenterRight);
|
||||
structureCount.TextGetter = () =>
|
||||
{
|
||||
int count = MapEntity.mapEntityList.Count - Item.ItemList.Count - Hull.HullList.Count - WayPoint.WayPointList.Count - Gap.GapList.Count;
|
||||
int count = MapEntity.MapEntityList.Count - Item.ItemList.Count - Hull.HullList.Count - WayPoint.WayPointList.Count - Gap.GapList.Count;
|
||||
structureCount.TextColor = count > MaxStructures ? GUIStyle.Red : Color.Lerp(GUIStyle.Green, GUIStyle.Orange, count / (float)MaxStructures);
|
||||
return count.ToString();
|
||||
};
|
||||
@@ -1163,7 +1166,7 @@ namespace Barotrauma
|
||||
foreach (MapEntityPrefab ep in entityLists[categoryKey])
|
||||
{
|
||||
#if !DEBUG
|
||||
if (ep.HideInMenus && !GameMain.DebugDraw) { continue; }
|
||||
if ((ep.HideInMenus || ep.HideInEditors) && !GameMain.DebugDraw) { continue; }
|
||||
#endif
|
||||
CreateEntityElement(ep, entitiesPerRow, entityListInner.Content);
|
||||
}
|
||||
@@ -1182,7 +1185,7 @@ namespace Barotrauma
|
||||
foreach (MapEntityPrefab ep in MapEntityPrefab.List)
|
||||
{
|
||||
#if !DEBUG
|
||||
if (ep.HideInMenus && !GameMain.DebugDraw) { continue; }
|
||||
if ((ep.HideInMenus || ep.HideInEditors) && !GameMain.DebugDraw) { continue; }
|
||||
#endif
|
||||
CreateEntityElement(ep, entitiesPerRow, allEntityList.Content);
|
||||
}
|
||||
@@ -1220,7 +1223,7 @@ namespace Barotrauma
|
||||
frame.Color = Color.Magenta;
|
||||
frame.ToolTip = $"{frame.ToolTip}\n‖color:{XMLExtensions.ToStringHex(Color.MediumPurple)}‖{ep.ContentPackage?.Name}‖color:end‖";
|
||||
}
|
||||
if (ep.HideInMenus)
|
||||
if (ep.HideInMenus || ep.HideInEditors)
|
||||
{
|
||||
frame.Color = Color.Red;
|
||||
name = "[HIDDEN] " + name;
|
||||
@@ -1638,7 +1641,7 @@ namespace Barotrauma
|
||||
/// <remarks>The saving is ran in another thread to avoid lag spikes</remarks>
|
||||
private static void AutoSave()
|
||||
{
|
||||
if (MapEntity.mapEntityList.Any() && GameSettings.CurrentConfig.EnableSubmarineAutoSave && !isAutoSaving)
|
||||
if (MapEntity.MapEntityList.Any() && GameSettings.CurrentConfig.EnableSubmarineAutoSave && !isAutoSaving)
|
||||
{
|
||||
if (MainSub != null)
|
||||
{
|
||||
@@ -1939,7 +1942,7 @@ namespace Barotrauma
|
||||
var matchingFile = modProject.Files.FirstOrDefault(f => f.Type == subFileType && filePath.CleanUpPath().Equals(f.Path.CleanUpPath(), StringComparison.OrdinalIgnoreCase));
|
||||
if (matchingFile != null)
|
||||
{
|
||||
File.Delete(matchingFile.Path.Replace(ContentPath.ModDirStr, packageDir));
|
||||
File.Delete(matchingFile.Path.Replace(ContentPath.ModDirStr, packageDir, StringComparison.OrdinalIgnoreCase));
|
||||
modProject.RemoveFile(matchingFile);
|
||||
}
|
||||
var newFile = ModProject.File.FromPath(filePath, subFileType);
|
||||
@@ -2852,7 +2855,7 @@ namespace Barotrauma
|
||||
{
|
||||
OnClicked = (button, o) =>
|
||||
{
|
||||
var requiredPackages = MapEntity.mapEntityList.Select(e => e?.Prefab?.ContentPackage)
|
||||
var requiredPackages = MapEntity.MapEntityList.Select(e => e?.Prefab?.ContentPackage)
|
||||
.Where(cp => cp != null)
|
||||
.Distinct().OfType<ContentPackage>().Select(p => p.Name).ToHashSet();
|
||||
var tickboxes = requiredContentPackList.Content.Children.OfType<GUITickBox>().ToArray();
|
||||
@@ -3493,7 +3496,15 @@ namespace Barotrauma
|
||||
var ownerPackage = GetLocalPackageThatOwnsSub(selectedSubInfo);
|
||||
if (ownerPackage is null)
|
||||
{
|
||||
if (GetWorkshopPackageThatOwnsSub(selectedSubInfo) is ContentPackage workshopPackage)
|
||||
if (IsVanillaSub(selectedSubInfo))
|
||||
{
|
||||
#if DEBUG
|
||||
LoadSub(selectedSubInfo);
|
||||
#else
|
||||
AskLoadVanillaSub(selectedSubInfo);
|
||||
#endif
|
||||
}
|
||||
else if (GetWorkshopPackageThatOwnsSub(selectedSubInfo) is ContentPackage workshopPackage)
|
||||
{
|
||||
if (workshopPackage.TryExtractSteamWorkshopId(out var workshopId)
|
||||
&& publishedWorkshopItemIds.Contains(workshopId.Value))
|
||||
@@ -3505,14 +3516,6 @@ namespace Barotrauma
|
||||
AskLoadSubscribedSub(selectedSubInfo);
|
||||
}
|
||||
}
|
||||
else if (IsVanillaSub(selectedSubInfo))
|
||||
{
|
||||
#if DEBUG
|
||||
LoadSub(selectedSubInfo);
|
||||
#else
|
||||
AskLoadVanillaSub(selectedSubInfo);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3792,10 +3795,7 @@ namespace Barotrauma
|
||||
wiringModeTickBox.Selected = newMode == Mode.Wiring;
|
||||
lockMode = false;
|
||||
|
||||
foreach (MapEntity me in MapEntity.mapEntityList)
|
||||
{
|
||||
me.IsHighlighted = false;
|
||||
}
|
||||
MapEntity.ClearHighlightedEntities();
|
||||
|
||||
MapEntity.DeselectAll();
|
||||
MapEntity.FilteredSelectedList.Clear();
|
||||
@@ -3806,7 +3806,8 @@ namespace Barotrauma
|
||||
{
|
||||
var item = new Item(MapEntityPrefab.Find(null, "screwdriver") as ItemPrefab, Vector2.Zero, null);
|
||||
dummyCharacter.Inventory.TryPutItem(item, null, new List<InvSlotType>() { InvSlotType.RightHand });
|
||||
wiringToolPanel = CreateWiringPanel();
|
||||
Point wirePos = new Point((int)(10 * GUI.Scale), TopPanel.Rect.Height + entityCountPanel.Rect.Height + (int)(10 * GUI.Scale));
|
||||
wiringToolPanel = CreateWiringPanel(wirePos, SelectWire);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3830,11 +3831,11 @@ namespace Barotrauma
|
||||
Item target = null;
|
||||
|
||||
var single = targets.Count == 1 ? targets.Single() : null;
|
||||
if (single is Item item && item.Components.Any(ic => !(ic is ConnectionPanel) && ic is not Repairable && ic.GuiFrame != null))
|
||||
if (single is Item item && item.Components.Any(static ic => ic is not ConnectionPanel && ic is not Repairable && ic.GuiFrame != null))
|
||||
{
|
||||
// Do not offer the ability to open the inventory if the inventory should never be drawn
|
||||
var container = item.GetComponent<ItemContainer>();
|
||||
if (container == null || container.DrawInventory) { target = item; }
|
||||
var containers = item.GetComponents<ItemContainer>();
|
||||
if (containers.Any(static c => c.DrawInventory) || item.GetComponent<CircuitBox>() is not null) { target = item; }
|
||||
}
|
||||
|
||||
bool hasTargets = targets.Count > 0;
|
||||
@@ -3850,7 +3851,7 @@ namespace Barotrauma
|
||||
new ContextMenuOption("Editor.SelectSame", isEnabled: hasTargets, onSelected: delegate
|
||||
{
|
||||
bool doorGapSelected = targets.Any(t => t is Gap gap && gap.ConnectedDoor != null);
|
||||
foreach (MapEntity match in MapEntity.mapEntityList.Where(e => e.Prefab != null && targets.Any(t => t.Prefab?.Identifier == e.Prefab.Identifier) && !MapEntity.SelectedList.Contains(e)))
|
||||
foreach (MapEntity match in MapEntity.MapEntityList.Where(e => e.Prefab != null && targets.Any(t => t.Prefab?.Identifier == e.Prefab.Identifier) && !MapEntity.SelectedList.Contains(e)))
|
||||
{
|
||||
if (MapEntity.SelectedList.Contains(match)) { continue; }
|
||||
if (match is Gap gap)
|
||||
@@ -3892,7 +3893,7 @@ namespace Barotrauma
|
||||
new ContextMenuOption("editor.layer.createlayer", isEnabled: hasTargets, onSelected: () => { CreateNewLayer(null, targets); }),
|
||||
new ContextMenuOption("editor.layer.selectall", isEnabled: hasTargets, onSelected: () =>
|
||||
{
|
||||
foreach (MapEntity match in MapEntity.mapEntityList.Where(e => targets.Any(t => !string.IsNullOrWhiteSpace(t.Layer) && t.Layer == e.Layer && !MapEntity.SelectedList.Contains(e))))
|
||||
foreach (MapEntity match in MapEntity.MapEntityList.Where(e => targets.Any(t => !string.IsNullOrWhiteSpace(t.Layer) && t.Layer == e.Layer && !MapEntity.SelectedList.Contains(e))))
|
||||
{
|
||||
if (MapEntity.SelectedList.Contains(match)) { continue; }
|
||||
MapEntity.SelectedList.Add(match);
|
||||
@@ -3965,7 +3966,7 @@ namespace Barotrauma
|
||||
{
|
||||
Layers.Remove(original);
|
||||
|
||||
foreach (MapEntity entity in MapEntity.mapEntityList.Where(entity => entity.Layer == original))
|
||||
foreach (MapEntity entity in MapEntity.MapEntityList.Where(entity => entity.Layer == original))
|
||||
{
|
||||
entity.Layer = newName ?? string.Empty;
|
||||
}
|
||||
@@ -3980,7 +3981,7 @@ namespace Barotrauma
|
||||
private void ReconstructLayers()
|
||||
{
|
||||
ClearLayers();
|
||||
foreach (MapEntity entity in MapEntity.mapEntityList)
|
||||
foreach (MapEntity entity in MapEntity.MapEntityList)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(entity.Layer))
|
||||
{
|
||||
@@ -4307,15 +4308,15 @@ namespace Barotrauma
|
||||
static string ColorToHex(Color color) => $"#{(color.R << 16 | color.G << 8 | color.B):X6}";
|
||||
}
|
||||
|
||||
private GUIFrame CreateWiringPanel()
|
||||
public static GUIFrame CreateWiringPanel(Point offset, GUIListBox.OnSelectedHandler onWireSelected)
|
||||
{
|
||||
GUIFrame frame = new GUIFrame(new RectTransform(new Vector2(0.03f, 0.35f), GUI.Canvas)
|
||||
{ MinSize = new Point(120, 300), AbsoluteOffset = new Point((int)(10 * GUI.Scale), TopPanel.Rect.Height + entityCountPanel.Rect.Height + (int)(10 * GUI.Scale)) });
|
||||
{ MinSize = new Point(120, 300), AbsoluteOffset = offset });
|
||||
|
||||
GUIListBox listBox = new GUIListBox(new RectTransform(new Vector2(0.9f, 0.9f), frame.RectTransform, Anchor.Center))
|
||||
{
|
||||
PlaySoundOnSelect = true,
|
||||
OnSelected = SelectWire,
|
||||
OnSelected = onWireSelected,
|
||||
CanTakeKeyBoardFocus = false
|
||||
};
|
||||
|
||||
@@ -4323,12 +4324,14 @@ namespace Barotrauma
|
||||
|
||||
foreach (ItemPrefab itemPrefab in ItemPrefab.Prefabs)
|
||||
{
|
||||
if (itemPrefab.Name.IsNullOrEmpty() || itemPrefab.HideInMenus) { continue; }
|
||||
if (!itemPrefab.Tags.Contains("wire")) { continue; }
|
||||
if (itemPrefab.Name.IsNullOrEmpty() || itemPrefab.HideInMenus || itemPrefab.HideInEditors) { continue; }
|
||||
if (!itemPrefab.Tags.Contains(Tags.WireItem)) { continue; }
|
||||
if (CircuitBox.IsInGame() && itemPrefab.Tags.Contains(Tags.Thalamus)) { continue; }
|
||||
|
||||
wirePrefabs.Add(itemPrefab);
|
||||
}
|
||||
|
||||
foreach (ItemPrefab itemPrefab in wirePrefabs.OrderBy(w => !w.CanBeBought).ThenBy(w => w.UintIdentifier))
|
||||
foreach (ItemPrefab itemPrefab in wirePrefabs.OrderBy(static w => !w.CanBeBought).ThenBy(static w => w.UintIdentifier))
|
||||
{
|
||||
GUIFrame imgFrame = new GUIFrame(new RectTransform(new Point(listBox.Content.Rect.Width, listBox.Rect.Width / 2), listBox.Content.RectTransform), style: "ListBoxElement")
|
||||
{
|
||||
@@ -4393,7 +4396,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (dummyCharacter == null || itemContainer == null) { return; }
|
||||
|
||||
if (((itemContainer.GetComponent<Holdable>() is { } holdable && !holdable.Attached) || itemContainer.GetComponent<Wearable>() != null) && itemContainer.GetComponent<ItemContainer>() != null)
|
||||
if ((itemContainer.GetComponent<Holdable>() is { Attached: false } || itemContainer.GetComponent<Wearable>() != null) && itemContainer.GetComponent<ItemContainer>() != null)
|
||||
{
|
||||
// We teleport our dummy character to the item so it appears as the entity stays still when in reality the dummy is holding it
|
||||
oldItemPosition = itemContainer.SimPosition;
|
||||
@@ -4614,9 +4617,9 @@ namespace Barotrauma
|
||||
|
||||
public void AutoHull()
|
||||
{
|
||||
for (int i = 0; i < MapEntity.mapEntityList.Count; i++)
|
||||
for (int i = 0; i < MapEntity.MapEntityList.Count; i++)
|
||||
{
|
||||
MapEntity h = MapEntity.mapEntityList[i];
|
||||
MapEntity h = MapEntity.MapEntityList[i];
|
||||
if (h is Hull || h is Gap)
|
||||
{
|
||||
h.Remove();
|
||||
@@ -4629,7 +4632,7 @@ namespace Barotrauma
|
||||
|
||||
List<MapEntity> mapEntityList = new List<MapEntity>();
|
||||
|
||||
foreach (MapEntity e in MapEntity.mapEntityList)
|
||||
foreach (MapEntity e in MapEntity.MapEntityList)
|
||||
{
|
||||
if (e is Item it)
|
||||
{
|
||||
@@ -5086,10 +5089,12 @@ namespace Barotrauma
|
||||
|
||||
layerGroup.Recalculate();
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.6f, 1f), layerGroup.RectTransform), layer, textAlignment: Alignment.CenterLeft)
|
||||
var textBlock = new GUITextBlock(new RectTransform(new Vector2(0.6f, 1f), layerGroup.RectTransform), layer, textAlignment: Alignment.CenterLeft);
|
||||
if (textBlock.TextSize.X > textBlock.Rect.Width)
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
textBlock.ToolTip = textBlock.Text;
|
||||
textBlock.Text = ToolBox.LimitString(textBlock.Text, textBlock.Font, textBlock.Rect.Width);
|
||||
}
|
||||
|
||||
layerGroup.Recalculate();
|
||||
layerChainLayout.Recalculate();
|
||||
@@ -5212,7 +5217,7 @@ namespace Barotrauma
|
||||
var highlightedEntities = new List<MapEntity>();
|
||||
|
||||
// ReSharper disable once LoopCanBeConvertedToQuery
|
||||
foreach (Item item in MapEntity.mapEntityList.Where(entity => entity is Item).Cast<Item>())
|
||||
foreach (Item item in MapEntity.MapEntityList.Where(entity => entity is Item).Cast<Item>())
|
||||
{
|
||||
var wire = item.GetComponent<Wire>();
|
||||
if (wire == null || !wire.IsMouseOn()) { continue; }
|
||||
@@ -5225,8 +5230,9 @@ namespace Barotrauma
|
||||
|
||||
hullVolumeFrame.Visible = MapEntity.SelectedList.Any(s => s is Hull);
|
||||
hullVolumeFrame.RectTransform.AbsoluteOffset = new Point(Math.Max(showEntitiesPanel.Rect.Right, previouslyUsedPanel.Rect.Right), 0);
|
||||
saveAssemblyFrame.Visible = MapEntity.SelectedList.Count > 0 && !WiringMode;
|
||||
snapToGridFrame.Visible = MapEntity.SelectedList.Count > 0 && !WiringMode;
|
||||
bool isCircuitBoxOpened = dummyCharacter?.SelectedItem?.GetComponent<CircuitBox>() is not null;
|
||||
saveAssemblyFrame.Visible = MapEntity.SelectedList.Count > 0 && !WiringMode && !isCircuitBoxOpened;
|
||||
snapToGridFrame.Visible = MapEntity.SelectedList.Count > 0 && !WiringMode && !isCircuitBoxOpened;
|
||||
|
||||
var offset = cam.WorldView.Top - cam.ScreenToWorld(new Vector2(0, GameMain.GraphicsHeight - EntityMenu.Rect.Top)).Y;
|
||||
|
||||
@@ -5285,7 +5291,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (wiringToolPanel.GetChild<GUIListBox>() is { } listBox)
|
||||
{
|
||||
if (!dummyCharacter.HeldItems.Any(it => it.HasTag("wire")))
|
||||
if (!dummyCharacter.HeldItems.Any(it => it.HasTag(Tags.WireItem)))
|
||||
{
|
||||
listBox.Deselect();
|
||||
}
|
||||
@@ -5394,7 +5400,7 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
var selectables = MapEntity.mapEntityList.Where(entity => entity.SelectableInEditor).ToList();
|
||||
var selectables = MapEntity.MapEntityList.Where(entity => entity.SelectableInEditor).ToList();
|
||||
foreach (var item in Item.ItemList)
|
||||
{
|
||||
//attached wires are not normally selectable (by clicking),
|
||||
@@ -5418,7 +5424,7 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
cam.MoveCamera((float) deltaTime, allowMove: true, allowZoom: GUI.MouseOn == null);
|
||||
cam.MoveCamera((float) deltaTime, allowMove: !CircuitBox.IsCircuitBoxSelected(dummyCharacter), allowZoom: GUI.MouseOn == null);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -5426,7 +5432,7 @@ namespace Barotrauma
|
||||
cam.MoveCamera((float) deltaTime, allowMove: false, allowZoom: GUI.MouseOn == null);
|
||||
}
|
||||
|
||||
if (PlayerInput.MidButtonHeld())
|
||||
if (PlayerInput.MidButtonHeld() && !CircuitBox.IsCircuitBoxSelected(dummyCharacter))
|
||||
{
|
||||
Vector2 moveSpeed = PlayerInput.MouseSpeed * (float)deltaTime * 60.0f / cam.Zoom;
|
||||
moveSpeed.X = -moveSpeed.X;
|
||||
@@ -5460,10 +5466,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (WiringMode)
|
||||
{
|
||||
foreach (MapEntity me in MapEntity.mapEntityList)
|
||||
{
|
||||
me.IsHighlighted = false;
|
||||
}
|
||||
MapEntity.ClearHighlightedEntities();
|
||||
|
||||
if (dummyCharacter.SelectedItem == null)
|
||||
{
|
||||
@@ -5948,13 +5951,10 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
if (dummyCharacter != null)
|
||||
if (DrawCharacterInventory)
|
||||
{
|
||||
if (WiringMode)
|
||||
{
|
||||
dummyCharacter.DrawHUD(spriteBatch, cam, false);
|
||||
wiringToolPanel.DrawManually(spriteBatch);
|
||||
}
|
||||
dummyCharacter.DrawHUD(spriteBatch, cam, false);
|
||||
wiringToolPanel.DrawManually(spriteBatch);
|
||||
}
|
||||
MapEntity.DrawEditor(spriteBatch, cam);
|
||||
|
||||
@@ -5991,10 +5991,7 @@ namespace Barotrauma
|
||||
private void CreateImage(int width, int height, System.IO.Stream stream)
|
||||
{
|
||||
MapEntity.SelectedList.Clear();
|
||||
foreach (MapEntity me in MapEntity.mapEntityList)
|
||||
{
|
||||
me.IsHighlighted = false;
|
||||
}
|
||||
MapEntity.ClearHighlightedEntities();
|
||||
|
||||
var prevScissorRect = GameMain.Instance.GraphicsDevice.ScissorRectangle;
|
||||
|
||||
@@ -6037,16 +6034,21 @@ namespace Barotrauma
|
||||
private void DrawGrid(SpriteBatch spriteBatch)
|
||||
{
|
||||
// don't render at high zoom levels because it would just turn the screen white
|
||||
if (cam.Zoom < 0.5f || !ShouldDrawGrid) { return; }
|
||||
if (!ShouldDrawGrid) { return; }
|
||||
|
||||
var (gridX, gridY) = Submarine.GridSize;
|
||||
DrawGrid(spriteBatch, cam, gridX, gridY, zoomTreshold: true);
|
||||
}
|
||||
|
||||
public static void DrawGrid(SpriteBatch spriteBatch, Camera cam, float sizeX, float sizeY, bool zoomTreshold)
|
||||
{
|
||||
if (zoomTreshold && cam.Zoom < 0.5f) { return; }
|
||||
int scale = Math.Max(1, GUI.IntScale(1));
|
||||
float zoom = cam.Zoom / 2f; // Don't ask
|
||||
float lineThickness = Math.Max(1, scale / zoom);
|
||||
|
||||
Color gridColor = gridBaseColor;
|
||||
if (cam.Zoom < 1.0f)
|
||||
if (zoomTreshold && cam.Zoom < 1.0f)
|
||||
{
|
||||
// fade the grid when zooming out
|
||||
gridColor *= Math.Max(0, (cam.Zoom - 0.5f) * 2f);
|
||||
@@ -6054,18 +6056,66 @@ namespace Barotrauma
|
||||
|
||||
Rectangle camRect = cam.WorldView;
|
||||
|
||||
for (float x = snapX(camRect.X); x < snapX(camRect.X + camRect.Width) + gridX; x += gridX)
|
||||
for (float x = snapX(camRect.X); x < snapX(camRect.X + camRect.Width) + sizeX; x += sizeX)
|
||||
{
|
||||
spriteBatch.DrawLine(new Vector2(x, -camRect.Y), new Vector2(x, -(camRect.Y - camRect.Height)), gridColor, thickness: lineThickness);
|
||||
}
|
||||
|
||||
for (float y = snapY(camRect.Y); y >= snapY(camRect.Y - camRect.Height) - gridY; y -= Submarine.GridSize.Y)
|
||||
for (float y = snapY(camRect.Y); y >= snapY(camRect.Y - camRect.Height) - sizeY; y -= sizeY)
|
||||
{
|
||||
spriteBatch.DrawLine(new Vector2(camRect.X, -y), new Vector2(camRect.Right, -y), gridColor, thickness: lineThickness);
|
||||
}
|
||||
|
||||
float snapX(int x) => (float) Math.Floor(x / gridX) * gridX;
|
||||
float snapY(int y) => (float) Math.Ceiling(y / gridY) * gridY;
|
||||
float snapX(int x) => (float) Math.Floor(x / sizeX) * sizeX;
|
||||
float snapY(int y) => (float) Math.Ceiling(y / sizeY) * sizeY;
|
||||
}
|
||||
|
||||
public static void DrawOutOfBoundsArea(SpriteBatch spriteBatch, Camera cam, float playableAreaSize, Color color)
|
||||
{
|
||||
Rectangle camRect = cam.WorldView;
|
||||
|
||||
RectangleF playableArea = new RectangleF(
|
||||
-playableAreaSize / 2f,
|
||||
-playableAreaSize / 2f,
|
||||
playableAreaSize,
|
||||
playableAreaSize
|
||||
);
|
||||
|
||||
RectangleF topRect = new(
|
||||
camRect.Left,
|
||||
-camRect.Top,
|
||||
camRect.Width,
|
||||
playableArea.Top + camRect.Top
|
||||
);
|
||||
|
||||
// idk why camRect.Bottom doesn't work here
|
||||
float camRectBottom = -camRect.Top + camRect.Height;
|
||||
|
||||
RectangleF bottomRect = new(
|
||||
camRect.Left,
|
||||
playableArea.Bottom,
|
||||
camRect.Width,
|
||||
camRectBottom + playableArea.Bottom
|
||||
);
|
||||
|
||||
RectangleF rightRect = new(
|
||||
playableArea.Right,
|
||||
playableArea.Top,
|
||||
camRect.Right - playableArea.Right,
|
||||
playableArea.Height
|
||||
);
|
||||
|
||||
RectangleF leftRect = new(
|
||||
playableArea.Left,
|
||||
playableArea.Top,
|
||||
camRect.Left - playableArea.Left,
|
||||
playableArea.Height
|
||||
);
|
||||
|
||||
GUI.DrawFilledRectangle(spriteBatch, topRect, color);
|
||||
GUI.DrawFilledRectangle(spriteBatch, leftRect, color);
|
||||
GUI.DrawFilledRectangle(spriteBatch, rightRect, color);
|
||||
GUI.DrawFilledRectangle(spriteBatch, bottomRect, color);
|
||||
}
|
||||
|
||||
public void SaveScreenShot(int width, int height, string filePath)
|
||||
@@ -6116,7 +6166,7 @@ namespace Barotrauma
|
||||
public static ImmutableHashSet<MapEntity> GetEntitiesInSameLayer(MapEntity entity)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(entity.Layer)) { return ImmutableHashSet<MapEntity>.Empty; }
|
||||
return MapEntity.mapEntityList.Where(me => me.Layer == entity.Layer).ToImmutableHashSet();
|
||||
return MapEntity.MapEntityList.Where(me => me.Layer == entity.Layer).ToImmutableHashSet();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Barotrauma
|
||||
base.Select();
|
||||
if (dummyCharacter is { Removed: false })
|
||||
{
|
||||
dummyCharacter?.Remove();
|
||||
dummyCharacter.Remove();
|
||||
}
|
||||
|
||||
dummyCharacter = Character.Create(CharacterPrefab.HumanSpeciesName, Vector2.Zero, "", id: Entity.DummyID, hasAi: false);
|
||||
@@ -54,15 +54,11 @@ namespace Barotrauma
|
||||
dummyCharacter.Inventory.CreateSlots();
|
||||
dummyCharacter.Info.GiveExperience(999999);
|
||||
|
||||
miniMapItem = new Item(ItemPrefab.Find(null, "deconstructor".ToIdentifier()), Vector2.Zero, null, 1337, false);
|
||||
miniMapItem = new Item(ItemPrefab.Find(null, "circuitbox".ToIdentifier()), Vector2.Zero, null, 1337, false);
|
||||
miniMapItem.GetComponent<Holdable>().AttachToWall();
|
||||
|
||||
foreach (ItemComponent component in miniMapItem.Components)
|
||||
{
|
||||
component.OnItemLoaded();
|
||||
}
|
||||
Character.Controlled = dummyCharacter;
|
||||
GameMain.World.ProcessChanges();
|
||||
TabMenu = new TabMenu();
|
||||
}
|
||||
|
||||
public override void AddToGUIUpdateList()
|
||||
@@ -78,29 +74,30 @@ namespace Barotrauma
|
||||
base.Update(deltaTime);
|
||||
TabMenu?.Update((float)deltaTime);
|
||||
|
||||
// if (dummyCharacter is { } dummy && miniMapItem is { } item)
|
||||
// {
|
||||
// if (dummy.SelectedConstruction != item)
|
||||
// {
|
||||
// dummy.SelectedConstruction = item;
|
||||
// }
|
||||
//
|
||||
// dummy.SelectedConstruction?.UpdateHUD(Cam, dummy, (float)deltaTime);
|
||||
// Vector2 pos = FarseerPhysics.ConvertUnits.ToSimUnits(item.Position);
|
||||
//
|
||||
// foreach (Limb limb in dummy.AnimController.Limbs)
|
||||
// {
|
||||
// limb.body.SetTransform(pos, 0.0f);
|
||||
// }
|
||||
//
|
||||
// if (dummy.AnimController?.Collider is { } collider)
|
||||
// {
|
||||
// collider.SetTransform(pos, 0);
|
||||
// }
|
||||
//
|
||||
// dummy.ControlLocalPlayer((float)deltaTime, Cam, false);
|
||||
// dummy.Control((float)deltaTime, Cam);
|
||||
// }
|
||||
if (dummyCharacter is { } dummy && miniMapItem is { } item)
|
||||
{
|
||||
if (dummy.SelectedItem != item)
|
||||
{
|
||||
dummy.SelectedItem = item;
|
||||
}
|
||||
|
||||
dummy.SelectedItem?.UpdateHUD(Cam, dummy, (float)deltaTime);
|
||||
item.SendSignal("1", "signal_in1");
|
||||
Vector2 pos = FarseerPhysics.ConvertUnits.ToSimUnits(item.Position);
|
||||
|
||||
foreach (Limb limb in dummy.AnimController.Limbs)
|
||||
{
|
||||
limb.body.SetTransform(pos, 0.0f);
|
||||
}
|
||||
|
||||
if (dummy.AnimController?.Collider is { } collider)
|
||||
{
|
||||
collider.SetTransform(pos, 0);
|
||||
}
|
||||
|
||||
dummy.ControlLocalPlayer((float)deltaTime, Cam, false);
|
||||
dummy.Control((float)deltaTime, Cam);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch)
|
||||
|
||||
Reference in New Issue
Block a user