Unstable 0.16.0.0
This commit is contained in:
+2
@@ -246,6 +246,8 @@ namespace Barotrauma
|
||||
|
||||
foreach (string saveFile in saveFiles)
|
||||
{
|
||||
if (string.IsNullOrEmpty(saveFile)) { continue; }
|
||||
|
||||
string fileName = saveFile;
|
||||
string subName = "";
|
||||
string saveTime = "";
|
||||
|
||||
@@ -45,6 +45,8 @@ namespace Barotrauma
|
||||
|
||||
public UpgradeStore UpgradeStore { get; set; }
|
||||
|
||||
public MedicalClinicUI MedicalClinic { get; set; }
|
||||
|
||||
public CampaignUI(CampaignMode campaign, GUIComponent container)
|
||||
{
|
||||
Campaign = campaign;
|
||||
@@ -270,6 +272,9 @@ namespace Barotrauma
|
||||
// Submarine buying tab
|
||||
tabs[(int)CampaignMode.InteractionType.PurchaseSub] = new GUIFrame(new RectTransform(Vector2.One, container.RectTransform, Anchor.TopLeft), color: Color.Black * 0.9f);
|
||||
|
||||
tabs[(int)CampaignMode.InteractionType.MedicalClinic] = new GUIFrame(new RectTransform(Vector2.One, container.RectTransform), color: Color.Black * 0.9f);
|
||||
MedicalClinic = new MedicalClinicUI(Campaign.MedicalClinic, GetTabContainer(CampaignMode.InteractionType.MedicalClinic));
|
||||
|
||||
// mission info -------------------------------------------------------------------------
|
||||
|
||||
locationInfoPanel = new GUIFrame(new RectTransform(new Vector2(0.35f, 0.75f), GetTabContainer(CampaignMode.InteractionType.Map).RectTransform, Anchor.CenterRight)
|
||||
@@ -355,6 +360,10 @@ namespace Barotrauma
|
||||
case CampaignMode.InteractionType.Store:
|
||||
Store?.Update(deltaTime);
|
||||
break;
|
||||
|
||||
case CampaignMode.InteractionType.MedicalClinic:
|
||||
MedicalClinic?.Update(deltaTime);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -247,16 +247,6 @@ namespace Barotrauma
|
||||
return msgBox;
|
||||
}
|
||||
|
||||
private void NotifyPrompt(string header, string body)
|
||||
{
|
||||
GUIMessageBox msgBox = new GUIMessageBox(header, body, new[] { TextManager.Get("Ok") }, new Vector2(0.2f, 0.175f), minSize: new Point(300, 175));
|
||||
msgBox.Buttons[0].OnClicked = delegate
|
||||
{
|
||||
msgBox.Close();
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
private bool SaveProjectToFile(GUIButton button, object o)
|
||||
{
|
||||
string directory = Path.GetFullPath("EventProjects");
|
||||
@@ -315,7 +305,7 @@ namespace Barotrauma
|
||||
CreateNodes(prefab.ConfigElement, ref hadNodes);
|
||||
if (!hadNodes)
|
||||
{
|
||||
NotifyPrompt(TextManager.Get("EventEditor.RandomGenerationHeader"), TextManager.Get("EventEditor.RandomGenerationBody"));
|
||||
GUI.NotifyPrompt(TextManager.Get("EventEditor.RandomGenerationHeader"), TextManager.Get("EventEditor.RandomGenerationBody"));
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -221,7 +221,6 @@ namespace Barotrauma
|
||||
public SubmarineInfo SelectedShuttle => ShuttleList.SelectedData as SubmarineInfo;
|
||||
|
||||
public MultiPlayerCampaignSetupUI CampaignSetupUI;
|
||||
public List<SubmarineInfo> CampaignSubmarines = new List<SubmarineInfo>();
|
||||
|
||||
// Passed onto the gamesession when created
|
||||
public List<SubmarineInfo> ServerOwnedSubmarines = new List<SubmarineInfo>();
|
||||
@@ -611,6 +610,7 @@ namespace Barotrauma
|
||||
{
|
||||
OnClicked = (btn, obj) =>
|
||||
{
|
||||
if (GameMain.Client == null) { return true; }
|
||||
GameMain.Client.RequestStartRound();
|
||||
CoroutineManager.StartCoroutine(WaitForStartRound(StartButton), "WaitForStartRound");
|
||||
return true;
|
||||
@@ -628,7 +628,7 @@ namespace Barotrauma
|
||||
{
|
||||
OnSelected = (tickBox) =>
|
||||
{
|
||||
GameMain.Client.ServerSettings.ClientAdminWrite(ServerSettings.NetFlags.Misc, autoRestart: tickBox.Selected);
|
||||
GameMain.Client?.ServerSettings.ClientAdminWrite(ServerSettings.NetFlags.Misc, autoRestart: tickBox.Selected);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -655,6 +655,7 @@ namespace Barotrauma
|
||||
};
|
||||
ServerName.OnDeselected += (textBox, key) =>
|
||||
{
|
||||
if (GameMain.Client == null) { return; }
|
||||
if (!textBox.Readonly)
|
||||
{
|
||||
GameMain.Client.ServerSettings.ClientAdminWrite(ServerSettings.NetFlags.Name);
|
||||
@@ -669,6 +670,7 @@ namespace Barotrauma
|
||||
ToolTip = TextManager.Get("addtofavorites"),
|
||||
OnSelected = (tickbox) =>
|
||||
{
|
||||
if (GameMain.Client == null) { return true; }
|
||||
ServerInfo info = GameMain.Client.ServerSettings.GetServerListInfo();
|
||||
if (tickbox.Selected)
|
||||
{
|
||||
@@ -766,6 +768,7 @@ namespace Barotrauma
|
||||
};
|
||||
ServerMessage.OnDeselected += (textBox, key) =>
|
||||
{
|
||||
if (GameMain.Client == null) { return; }
|
||||
if (!textBox.Readonly)
|
||||
{
|
||||
GameMain.Client?.ServerSettings?.ClientAdminWrite(ServerSettings.NetFlags.Message);
|
||||
@@ -849,7 +852,7 @@ namespace Barotrauma
|
||||
Selected = true,
|
||||
OnSelected = (GUITickBox box) =>
|
||||
{
|
||||
GameMain.Client.ServerSettings.ClientAdminWrite(ServerSettings.NetFlags.Misc, useRespawnShuttle: box.Selected);
|
||||
GameMain.Client?.ServerSettings.ClientAdminWrite(ServerSettings.NetFlags.Misc, useRespawnShuttle: box.Selected);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -868,7 +871,7 @@ namespace Barotrauma
|
||||
{
|
||||
OnSelected = (component, obj) =>
|
||||
{
|
||||
GameMain.Client.RequestSelectSub(component.Parent.GetChildIndex(component), isShuttle: true);
|
||||
GameMain.Client?.RequestSelectSub(component.Parent.GetChildIndex(component), isShuttle: true);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -970,7 +973,7 @@ namespace Barotrauma
|
||||
{
|
||||
OnClicked = (_, __) =>
|
||||
{
|
||||
GameMain.Client.RequestSelectMode(ModeList.Content.GetChildIndex(ModeList.Content.GetChildByUserData(GameModePreset.Sandbox)));
|
||||
GameMain.Client?.RequestSelectMode(ModeList.Content.GetChildIndex(ModeList.Content.GetChildByUserData(GameModePreset.Sandbox)));
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -1026,7 +1029,7 @@ namespace Barotrauma
|
||||
{
|
||||
int missionTypeOr = tickbox.Selected ? (int)tickbox.UserData : (int)MissionType.None;
|
||||
int missionTypeAnd = (int)MissionType.All & (!tickbox.Selected ? (~(int)tickbox.UserData) : (int)MissionType.All);
|
||||
GameMain.Client.ServerSettings.ClientAdminWrite(ServerSettings.NetFlags.Misc, (int)missionTypeOr, (int)missionTypeAnd);
|
||||
GameMain.Client?.ServerSettings.ClientAdminWrite(ServerSettings.NetFlags.Misc, (int)missionTypeOr, (int)missionTypeAnd);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -1059,7 +1062,7 @@ namespace Barotrauma
|
||||
SeedBox = new GUITextBox(new RectTransform(new Vector2(0.5f, 1.0f), seedLabel.RectTransform, Anchor.CenterRight));
|
||||
SeedBox.OnDeselected += (textBox, key) =>
|
||||
{
|
||||
GameMain.Client.ServerSettings.ClientAdminWrite(ServerSettings.NetFlags.LevelSeed);
|
||||
GameMain.Client?.ServerSettings.ClientAdminWrite(ServerSettings.NetFlags.LevelSeed);
|
||||
};
|
||||
clientDisabledElements.Add(SeedBox);
|
||||
LevelSeed = ToolBox.RandomSeed(8);
|
||||
@@ -1080,7 +1083,7 @@ namespace Barotrauma
|
||||
ToolTip = TextManager.Get("leveldifficultyexplanation"),
|
||||
OnReleased = (scrollbar, value) =>
|
||||
{
|
||||
GameMain.Client.ServerSettings.ClientAdminWrite(ServerSettings.NetFlags.Misc, levelDifficulty: scrollbar.BarScrollValue);
|
||||
GameMain.Client?.ServerSettings.ClientAdminWrite(ServerSettings.NetFlags.Misc, levelDifficulty: scrollbar.BarScrollValue);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -1112,8 +1115,7 @@ namespace Barotrauma
|
||||
{
|
||||
OnClicked = (button, obj) =>
|
||||
{
|
||||
GameMain.Client.ServerSettings.ClientAdminWrite(ServerSettings.NetFlags.Misc, traitorSetting: -1);
|
||||
|
||||
GameMain.Client?.ServerSettings.ClientAdminWrite(ServerSettings.NetFlags.Misc, traitorSetting: -1);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -1124,8 +1126,7 @@ namespace Barotrauma
|
||||
{
|
||||
OnClicked = (button, obj) =>
|
||||
{
|
||||
GameMain.Client.ServerSettings.ClientAdminWrite(ServerSettings.NetFlags.Misc, traitorSetting: 1);
|
||||
|
||||
GameMain.Client?.ServerSettings.ClientAdminWrite(ServerSettings.NetFlags.Misc, traitorSetting: 1);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -1143,7 +1144,7 @@ namespace Barotrauma
|
||||
{
|
||||
OnClicked = (button, obj) =>
|
||||
{
|
||||
GameMain.Client.ServerSettings.ClientAdminWrite(ServerSettings.NetFlags.Misc, botCount: -1);
|
||||
GameMain.Client?.ServerSettings.ClientAdminWrite(ServerSettings.NetFlags.Misc, botCount: -1);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -1153,7 +1154,7 @@ namespace Barotrauma
|
||||
{
|
||||
OnClicked = (button, obj) =>
|
||||
{
|
||||
GameMain.Client.ServerSettings.ClientAdminWrite(ServerSettings.NetFlags.Misc, botCount: 1);
|
||||
GameMain.Client?.ServerSettings.ClientAdminWrite(ServerSettings.NetFlags.Misc, botCount: 1);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -1169,7 +1170,7 @@ namespace Barotrauma
|
||||
{
|
||||
OnClicked = (button, obj) =>
|
||||
{
|
||||
GameMain.Client.ServerSettings.ClientAdminWrite(ServerSettings.NetFlags.Misc, botSpawnMode: -1);
|
||||
GameMain.Client?.ServerSettings.ClientAdminWrite(ServerSettings.NetFlags.Misc, botSpawnMode: -1);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -1179,7 +1180,7 @@ namespace Barotrauma
|
||||
{
|
||||
OnClicked = (button, obj) =>
|
||||
{
|
||||
GameMain.Client.ServerSettings.ClientAdminWrite(ServerSettings.NetFlags.Misc, botSpawnMode: 1);
|
||||
GameMain.Client?.ServerSettings.ClientAdminWrite(ServerSettings.NetFlags.Misc, botSpawnMode: 1);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -3576,7 +3577,13 @@ namespace Barotrauma
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool CheckIfCampaignSubMatches(SubmarineInfo serverSubmarine, string deliveryData)
|
||||
public enum SubmarineDeliveryData
|
||||
{
|
||||
Owned,
|
||||
Campaign
|
||||
}
|
||||
|
||||
public bool CheckIfCampaignSubMatches(SubmarineInfo serverSubmarine, SubmarineDeliveryData deliveryData)
|
||||
{
|
||||
if (GameMain.Client == null) return false;
|
||||
|
||||
@@ -3630,11 +3637,11 @@ namespace Barotrauma
|
||||
{
|
||||
FailedSubInfo fileInfo = (FailedSubInfo)userdata;
|
||||
|
||||
if (deliveryData == "owned") //owned!!!!
|
||||
if (deliveryData == SubmarineDeliveryData.Owned)
|
||||
{
|
||||
FailedOwnedSubs.Add(fileInfo);
|
||||
}
|
||||
else if (deliveryData == "campaign")
|
||||
else if (deliveryData == SubmarineDeliveryData.Campaign)
|
||||
{
|
||||
FailedCampaignSubs.Add(fileInfo);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ using Microsoft.Xna.Framework.Graphics;
|
||||
using RestSharp;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
@@ -21,6 +22,11 @@ namespace Barotrauma
|
||||
//how often the client is allowed to refresh servers
|
||||
private readonly TimeSpan AllowedRefreshInterval = new TimeSpan(0, 0, 3);
|
||||
|
||||
public ImmutableDictionary<UInt64, ContentPackage> ContentPackagesByWorkshopId { get; private set; }
|
||||
= ImmutableDictionary<UInt64, ContentPackage>.Empty;
|
||||
public ImmutableDictionary<string, ContentPackage> ContentPackagesByHash { get; private set; }
|
||||
= ImmutableDictionary<string, ContentPackage>.Empty;
|
||||
|
||||
private GUIFrame menu;
|
||||
|
||||
private GUIListBox serverList;
|
||||
@@ -1011,6 +1017,17 @@ namespace Barotrauma
|
||||
public override void Select()
|
||||
{
|
||||
base.Select();
|
||||
|
||||
ContentPackagesByWorkshopId = ContentPackage.AllPackages
|
||||
.Select(p => new KeyValuePair<UInt64, ContentPackage>(p.SteamWorkshopId, p))
|
||||
.Where(p => p.Key != 0)
|
||||
.GroupBy(x => x.Key).Select(g => g.First())
|
||||
.ToImmutableDictionary();
|
||||
ContentPackagesByHash = ContentPackage.AllPackages
|
||||
.Select(p => new KeyValuePair<string, ContentPackage>(p.MD5hash.Hash, p))
|
||||
.GroupBy(x => x.Key).Select(g => g.First())
|
||||
.ToImmutableDictionary();
|
||||
|
||||
SelectedTab = ServerListTab.All;
|
||||
LoadServerFilters(GameMain.Config.ServerFilterElement);
|
||||
if (GameSettings.ShowOffensiveServerPrompt)
|
||||
@@ -1039,6 +1056,8 @@ namespace Barotrauma
|
||||
|
||||
public override void Deselect()
|
||||
{
|
||||
ContentPackagesByWorkshopId = ImmutableDictionary<UInt64, ContentPackage>.Empty;
|
||||
ContentPackagesByHash = ImmutableDictionary<string, ContentPackage>.Empty;
|
||||
base.Deselect();
|
||||
|
||||
GameMain.Config.SaveNewPlayerConfig();
|
||||
@@ -1491,7 +1510,7 @@ namespace Barotrauma
|
||||
}
|
||||
TaskPool.Add($"Get{avatarSize}AvatarAsync", avatarFunc(friend.Id), (task) =>
|
||||
{
|
||||
Steamworks.Data.Image? img = ((Task<Steamworks.Data.Image?>)task).Result;
|
||||
if (!task.TryGetResult(out Steamworks.Data.Image? img)) { return; }
|
||||
if (!img.HasValue) { return; }
|
||||
|
||||
var avatarImage = img.Value;
|
||||
@@ -2203,7 +2222,7 @@ namespace Barotrauma
|
||||
TaskPool.PrintTaskExceptions(t, $"Failed to retrieve Workshop item info (ID {entry.Id})");
|
||||
return;
|
||||
}
|
||||
Steamworks.Ugc.Item? item = ((Task<Steamworks.Ugc.Item?>)t).Result;
|
||||
t.TryGetResult(out Steamworks.Ugc.Item? item);
|
||||
|
||||
if (!item.HasValue)
|
||||
{
|
||||
@@ -2313,7 +2332,7 @@ namespace Barotrauma
|
||||
{
|
||||
var info = obj.Item1;
|
||||
var text = obj.Item2;
|
||||
info.Ping = ((Task<int>)rtt).Result; info.PingChecked = true;
|
||||
rtt.TryGetResult(out info.Ping); info.PingChecked = true;
|
||||
text.TextColor = GetPingTextColor(info.Ping);
|
||||
text.Text = info.Ping > -1 ? info.Ping.ToString() : "?";
|
||||
lock (activePings)
|
||||
|
||||
@@ -854,7 +854,7 @@ namespace Barotrauma
|
||||
(var it, var lb) = tuple;
|
||||
if (lb.Content.FindChild(item)?.GetChildByUserData("previewimage") is GUIImage previewImage)
|
||||
{
|
||||
previewImage.Sprite = ((Task<Sprite>)task).Result;
|
||||
if (task.TryGetResult(out Sprite sprite)) { previewImage.Sprite = sprite; }
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -99,6 +99,10 @@ namespace Barotrauma
|
||||
private GUIFrame previouslyUsedPanel;
|
||||
private GUIListBox previouslyUsedList;
|
||||
|
||||
private GUIButton visibilityButton;
|
||||
private GUIFrame layerPanel;
|
||||
private GUIListBox layerList;
|
||||
|
||||
private GUIFrame undoBufferPanel;
|
||||
private GUIFrame undoBufferDisclaimer;
|
||||
private GUIListBox undoBufferList;
|
||||
@@ -234,6 +238,8 @@ namespace Barotrauma
|
||||
|
||||
public bool WiringMode => mode == Mode.Wiring;
|
||||
|
||||
public static readonly Dictionary<string, bool> Layers = new Dictionary<string, bool>();
|
||||
|
||||
public SubEditorScreen()
|
||||
{
|
||||
cam = new Camera
|
||||
@@ -320,19 +326,34 @@ namespace Barotrauma
|
||||
|
||||
new GUIFrame(new RectTransform(new Vector2(0.01f, 0.9f), paddedTopPanel.RectTransform), style: "VerticalLine");
|
||||
|
||||
var visibilityButton = new GUIButton(new RectTransform(new Vector2(0.9f, 0.9f), paddedTopPanel.RectTransform, scaleBasis: ScaleBasis.BothHeight), "", style: "SetupVisibilityButton")
|
||||
visibilityButton = new GUIButton(new RectTransform(new Vector2(0.9f, 0.9f), paddedTopPanel.RectTransform, scaleBasis: ScaleBasis.BothHeight), "", style: "SetupVisibilityButton")
|
||||
{
|
||||
ToolTip = TextManager.Get("SubEditorVisibilityButton") + '\n' + TextManager.Get("SubEditorVisibilityToolTip"),
|
||||
OnClicked = (btn, userData) =>
|
||||
{
|
||||
previouslyUsedPanel.Visible = false;
|
||||
undoBufferPanel.Visible = false;
|
||||
layerPanel.Visible = false;
|
||||
showEntitiesPanel.Visible = !showEntitiesPanel.Visible;
|
||||
showEntitiesPanel.RectTransform.AbsoluteOffset = new Point(Math.Max(Math.Max(btn.Rect.X, entityCountPanel.Rect.Right), saveAssemblyFrame.Rect.Right), TopPanel.Rect.Height);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
new GUIButton(new RectTransform(new Vector2(0.9f, 0.9f), paddedTopPanel.RectTransform, scaleBasis: ScaleBasis.BothHeight), "", style: "EditorLayerButton")
|
||||
{
|
||||
ToolTip = TextManager.Get("editor.layer.button") + '\n' + TextManager.Get("editor.layer.tooltip"),
|
||||
OnClicked = (btn, userData) =>
|
||||
{
|
||||
previouslyUsedPanel.Visible = false;
|
||||
showEntitiesPanel.Visible = false;
|
||||
undoBufferPanel.Visible = false;
|
||||
layerPanel.Visible = !layerPanel.Visible;
|
||||
layerPanel.RectTransform.AbsoluteOffset = new Point(Math.Max(Math.Max(btn.Rect.X, entityCountPanel.Rect.Right), saveAssemblyFrame.Rect.Right), TopPanel.Rect.Height);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
var previouslyUsedButton = new GUIButton(new RectTransform(new Vector2(0.9f, 0.9f), paddedTopPanel.RectTransform, scaleBasis: ScaleBasis.BothHeight), "", style: "RecentlyUsedButton")
|
||||
{
|
||||
ToolTip = TextManager.Get("PreviouslyUsedLabel"),
|
||||
@@ -340,6 +361,7 @@ namespace Barotrauma
|
||||
{
|
||||
showEntitiesPanel.Visible = false;
|
||||
undoBufferPanel.Visible = false;
|
||||
layerPanel.Visible = false;
|
||||
previouslyUsedPanel.Visible = !previouslyUsedPanel.Visible;
|
||||
previouslyUsedPanel.RectTransform.AbsoluteOffset = new Point(Math.Max(Math.Max(btn.Rect.X, entityCountPanel.Rect.Right), saveAssemblyFrame.Rect.Right), TopPanel.Rect.Height);
|
||||
return true;
|
||||
@@ -353,6 +375,7 @@ namespace Barotrauma
|
||||
{
|
||||
showEntitiesPanel.Visible = false;
|
||||
previouslyUsedPanel.Visible = false;
|
||||
layerPanel.Visible = false;
|
||||
undoBufferPanel.Visible = !undoBufferPanel.Visible;
|
||||
undoBufferPanel.RectTransform.AbsoluteOffset = new Point(Math.Max(Math.Max(btn.Rect.X, entityCountPanel.Rect.Right), saveAssemblyFrame.Rect.Right), TopPanel.Rect.Height);
|
||||
return true;
|
||||
@@ -484,14 +507,81 @@ namespace Barotrauma
|
||||
|
||||
//-----------------------------------------------
|
||||
|
||||
layerPanel = new GUIFrame(new RectTransform(new Vector2(0.175f, 0.4f), GUI.Canvas))
|
||||
{
|
||||
Visible = false
|
||||
};
|
||||
|
||||
GUILayoutGroup layerGroup = new GUILayoutGroup(new RectTransform(new Vector2(0.9f), layerPanel.RectTransform, anchor: Anchor.Center));
|
||||
|
||||
layerList = new GUIListBox(new RectTransform(new Vector2(1f, 0.8f), layerGroup.RectTransform))
|
||||
{
|
||||
ScrollBarVisible = true,
|
||||
AutoHideScrollBar = false,
|
||||
OnSelected = (component, o) =>
|
||||
{
|
||||
if (!(o is string layer)) { return false; }
|
||||
|
||||
MapEntity.SelectedList.Clear();
|
||||
foreach (MapEntity entity in MapEntity.mapEntityList.Where(me => !me.Removed && me.Layer == layer))
|
||||
{
|
||||
if (entity.IsSelected) { continue; }
|
||||
|
||||
MapEntity.SelectedList.Add(entity);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
GUILayoutGroup layerButtonGroup = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.2f), layerGroup.RectTransform));
|
||||
|
||||
GUILayoutGroup layerButtonTopGroup = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.5f), layerButtonGroup.RectTransform), isHorizontal: true);
|
||||
|
||||
GUIButton layerAddButton = new GUIButton(new RectTransform(new Vector2(0.5f, 1f), layerButtonTopGroup.RectTransform), text: TextManager.Get("editor.layer.newlayer"), style: "GUIButtonFreeScale")
|
||||
{
|
||||
OnClicked = (button, o) =>
|
||||
{
|
||||
CreateNewLayer(null, MapEntity.SelectedList.ToList());
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
GUIButton layerDeleteButton = new GUIButton(new RectTransform(new Vector2(0.5f, 1f), layerButtonTopGroup.RectTransform), text: TextManager.Get("editor.layer.deletelayer"), style: "GUIButtonFreeScale")
|
||||
{
|
||||
OnClicked = (button, o) =>
|
||||
{
|
||||
if (layerList.SelectedData is string layer)
|
||||
{
|
||||
RenameLayer(layer, null);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
GUIButton layerRenameButton = new GUIButton(new RectTransform(new Vector2(1f, 0.5f), layerButtonGroup.RectTransform), text: TextManager.Get("editor.layer.renamelayer"), style: "GUIButtonFreeScale")
|
||||
{
|
||||
OnClicked = (button, o) =>
|
||||
{
|
||||
if (layerList.SelectedData is string layer)
|
||||
{
|
||||
GUI.PromptTextInput(TextManager.Get("editor.layer.renamelayer"), layer, newName =>
|
||||
{
|
||||
RenameLayer(layer, newName);
|
||||
});
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
Vector2 subPanelSize = new Vector2(0.925f, 0.9f);
|
||||
|
||||
undoBufferPanel = new GUIFrame(new RectTransform(new Vector2(0.15f, 0.2f), GUI.Canvas) { MinSize = new Point(200, 200) })
|
||||
{
|
||||
Visible = false
|
||||
};
|
||||
|
||||
Vector2 undoSize = new Vector2(0.925f, 0.9f);
|
||||
|
||||
undoBufferList = new GUIListBox(new RectTransform(undoSize, undoBufferPanel.RectTransform, Anchor.Center))
|
||||
undoBufferList = new GUIListBox(new RectTransform(subPanelSize, undoBufferPanel.RectTransform, Anchor.Center))
|
||||
{
|
||||
ScrollBarVisible = true,
|
||||
OnSelected = (_, userData) =>
|
||||
@@ -522,7 +612,7 @@ namespace Barotrauma
|
||||
}
|
||||
};
|
||||
|
||||
undoBufferDisclaimer = new GUIFrame(new RectTransform(undoSize, undoBufferPanel.RectTransform, Anchor.Center), style: null)
|
||||
undoBufferDisclaimer = new GUIFrame(new RectTransform(subPanelSize, undoBufferPanel.RectTransform, Anchor.Center), style: null)
|
||||
{
|
||||
Color = Color.Black,
|
||||
Visible = false
|
||||
@@ -1354,7 +1444,7 @@ namespace Barotrauma
|
||||
|
||||
TimeSpan timeInEditor = DateTime.Now - editorSelectedTime;
|
||||
#if USE_STEAM
|
||||
Steam.SteamManager.IncrementStat("hoursineditor", (float)timeInEditor.TotalHours);
|
||||
SteamAchievementManager.IncrementStat("hoursineditor", (float)timeInEditor.TotalHours);
|
||||
#endif
|
||||
|
||||
GUI.ForceMouseOn(null);
|
||||
@@ -1400,6 +1490,7 @@ namespace Barotrauma
|
||||
});
|
||||
|
||||
ClearFilter();
|
||||
ClearLayers();
|
||||
}
|
||||
|
||||
private void CreateDummyCharacter()
|
||||
@@ -1752,11 +1843,11 @@ namespace Barotrauma
|
||||
DebugConsole.ThrowError($"Saving the preview image of the submarine \"{Submarine.MainSub.Info.Name}\" failed.", e);
|
||||
savePreviewImage = false;
|
||||
}
|
||||
Submarine.MainSub.SaveAs(savePath, savePreviewImage ? imgStream : null);
|
||||
Submarine.MainSub.TrySaveAs(savePath, savePreviewImage ? imgStream : null);
|
||||
}
|
||||
else
|
||||
{
|
||||
Submarine.MainSub.SaveAs(savePath);
|
||||
Submarine.MainSub.TrySaveAs(savePath);
|
||||
}
|
||||
Barotrauma.IO.Validation.SkipValidationInDebugBuilds = false;
|
||||
|
||||
@@ -2890,6 +2981,8 @@ namespace Barotrauma
|
||||
};
|
||||
adjustLightsPrompt.Buttons[1].OnClicked += adjustLightsPrompt.Close;
|
||||
}
|
||||
|
||||
ReconstructLayers();
|
||||
}
|
||||
|
||||
private void TryDeleteSub(SubmarineInfo sub)
|
||||
@@ -3075,6 +3168,8 @@ namespace Barotrauma
|
||||
if (container == null || container.DrawInventory) { target = item; }
|
||||
}
|
||||
|
||||
bool hasTargets = targets.Count > 0;
|
||||
|
||||
// Holding shift brings up special context menu options
|
||||
if (PlayerInput.IsShiftDown())
|
||||
{
|
||||
@@ -3083,7 +3178,7 @@ namespace Barotrauma
|
||||
new ContextMenuOption("SubEditor.ToggleTransparency", isEnabled: true, onSelected: () => TransparentWiringMode = !TransparentWiringMode),
|
||||
new ContextMenuOption("SubEditor.ToggleGrid", isEnabled: true, onSelected: () => ShouldDrawGrid = !ShouldDrawGrid),
|
||||
new ContextMenuOption("SubEditor.PasteAssembly", isEnabled: true, () => PasteAssembly()),
|
||||
new ContextMenuOption("Editor.SelectSame", isEnabled: targets.Count > 0, onSelected: delegate
|
||||
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)))
|
||||
@@ -3115,12 +3210,44 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
List<ContextMenuOption> availableLayerOptions = new List<ContextMenuOption>
|
||||
{
|
||||
new ContextMenuOption("editor.layer.nolayer", true, onSelected: () => { MoveToLayer(null, targets); })
|
||||
};
|
||||
|
||||
availableLayerOptions.AddRange(Layers.Select(layer => new ContextMenuOption(layer.Key, true, onSelected: () => { MoveToLayer(layer.Key, targets); })));
|
||||
|
||||
ContextMenuOption[] layerOptions =
|
||||
{
|
||||
new ContextMenuOption("editor.layer.movetolayer", isEnabled: hasTargets, availableLayerOptions.ToArray()),
|
||||
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))))
|
||||
{
|
||||
if (MapEntity.SelectedList.Contains(match)) { continue; }
|
||||
MapEntity.SelectedList.Add(match);
|
||||
}
|
||||
}),
|
||||
new ContextMenuOption("editor.layer.openlayermenu", isEnabled: true, onSelected: () =>
|
||||
{
|
||||
if (visibilityButton is null) { return; }
|
||||
previouslyUsedPanel.Visible = false;
|
||||
undoBufferPanel.Visible = false;
|
||||
showEntitiesPanel.Visible = false;
|
||||
layerPanel.Visible = !layerPanel.Visible;
|
||||
layerPanel.RectTransform.AbsoluteOffset = new Point(Math.Max(Math.Max(visibilityButton.Rect.X, entityCountPanel.Rect.Right), saveAssemblyFrame.Rect.Right), TopPanel.Rect.Height);
|
||||
})
|
||||
};
|
||||
|
||||
GUIContextMenu.CreateContextMenu(
|
||||
new ContextMenuOption("label.openlabel", isEnabled: target != null, onSelected: () => OpenItem(target)),
|
||||
new ContextMenuOption("editor.cut", isEnabled: targets.Count > 0, onSelected: () => MapEntity.Cut(targets)),
|
||||
new ContextMenuOption("editor.copytoclipboard", isEnabled: targets.Count > 0, onSelected: () => MapEntity.Copy(targets)),
|
||||
new ContextMenuOption("editor.paste", isEnabled: MapEntity.CopiedList.Any(), onSelected: () => MapEntity.Paste(cam.ScreenToWorld(PlayerInput.MousePosition))),
|
||||
new ContextMenuOption("delete", isEnabled: targets.Count > 0, onSelected: delegate
|
||||
new ContextMenuOption("label.openlabel", isEnabled: target != null, onSelected: () => OpenItem(target)),
|
||||
new ContextMenuOption("editor.layer", isEnabled: hasTargets, layerOptions),
|
||||
new ContextMenuOption("editor.cut", isEnabled: hasTargets, onSelected: () => MapEntity.Cut(targets)),
|
||||
new ContextMenuOption("editor.copytoclipboard", isEnabled: hasTargets, onSelected: () => MapEntity.Copy(targets)),
|
||||
new ContextMenuOption("editor.paste", isEnabled: MapEntity.CopiedList.Any(), onSelected: () => MapEntity.Paste(cam.ScreenToWorld(PlayerInput.MousePosition))),
|
||||
new ContextMenuOption("delete", isEnabled: hasTargets, onSelected: delegate
|
||||
{
|
||||
StoreCommand(new AddOrDeleteCommand(targets, true));
|
||||
foreach (var me in targets)
|
||||
@@ -3131,6 +3258,76 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private void MoveToLayer(string layer, List<MapEntity> content)
|
||||
{
|
||||
layer ??= string.Empty;
|
||||
|
||||
foreach (MapEntity entity in content)
|
||||
{
|
||||
entity.Layer = layer;
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateNewLayer(string name, List<MapEntity> content)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
{
|
||||
name = TextManager.Get("editor.layer.newlayer");
|
||||
}
|
||||
|
||||
string incrementedName = name;
|
||||
|
||||
for (int i = 1; Layers.ContainsKey(incrementedName); i++)
|
||||
{
|
||||
incrementedName = $"{name} ({i})";
|
||||
}
|
||||
|
||||
name = incrementedName;
|
||||
|
||||
if (content != null)
|
||||
{
|
||||
MoveToLayer(name, content);
|
||||
}
|
||||
|
||||
Layers.Add(name, true);
|
||||
UpdateLayerPanel();
|
||||
}
|
||||
|
||||
private void RenameLayer(string original, string newName)
|
||||
{
|
||||
Layers.Remove(original);
|
||||
|
||||
foreach (MapEntity entity in MapEntity.mapEntityList.Where(entity => entity.Layer == original))
|
||||
{
|
||||
entity.Layer = newName ?? string.Empty;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(newName))
|
||||
{
|
||||
Layers.TryAdd(newName, true);
|
||||
}
|
||||
UpdateLayerPanel();
|
||||
}
|
||||
|
||||
private void ReconstructLayers()
|
||||
{
|
||||
ClearLayers();
|
||||
foreach (MapEntity entity in MapEntity.mapEntityList)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(entity.Layer))
|
||||
{
|
||||
Layers.TryAdd(entity.Layer, true);
|
||||
}
|
||||
}
|
||||
UpdateLayerPanel();
|
||||
}
|
||||
|
||||
private void ClearLayers()
|
||||
{
|
||||
Layers.Clear();
|
||||
UpdateLayerPanel();
|
||||
}
|
||||
|
||||
private void PasteAssembly(string text = null, Vector2? pos = null)
|
||||
{
|
||||
pos ??= cam.ScreenToWorld(PlayerInput.MousePosition);
|
||||
@@ -4044,6 +4241,7 @@ namespace Barotrauma
|
||||
previouslyUsedPanel.AddToGUIUpdateList();
|
||||
undoBufferPanel.AddToGUIUpdateList();
|
||||
entityCountPanel.AddToGUIUpdateList();
|
||||
layerPanel.AddToGUIUpdateList();
|
||||
TopPanel.AddToGUIUpdateList();
|
||||
|
||||
if (WiringMode)
|
||||
@@ -4147,9 +4345,55 @@ namespace Barotrauma
|
||||
GameMain.SubEditorScreen.UpdateUndoHistoryPanel();
|
||||
}
|
||||
|
||||
private void UpdateLayerPanel()
|
||||
{
|
||||
if (layerPanel is null || layerList is null) { return; }
|
||||
|
||||
layerList.Content.ClearChildren();
|
||||
|
||||
layerList.Deselect();
|
||||
|
||||
foreach (var (layer, isVisible) in Layers)
|
||||
{
|
||||
GUIFrame parent = new GUIFrame(new RectTransform(new Vector2(1f, 0.1f), layerList.Content.RectTransform), style: "ListBoxElement")
|
||||
{
|
||||
UserData = layer
|
||||
};
|
||||
|
||||
GUILayoutGroup layerGroup = new GUILayoutGroup(new RectTransform(Vector2.One, parent.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft);
|
||||
|
||||
GUITickBox layerVisibleButton = new GUITickBox(new RectTransform(Vector2.One, layerGroup.RectTransform, scaleBasis: ScaleBasis.BothHeight), string.Empty)
|
||||
{
|
||||
Selected = isVisible,
|
||||
OnSelected = box =>
|
||||
{
|
||||
if (!Layers.TryGetValue(layer, out bool _))
|
||||
{
|
||||
UpdateLayerPanel();
|
||||
return false;
|
||||
}
|
||||
|
||||
Layers[layer] = box.Selected;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
layerGroup.Recalculate();
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f - layerVisibleButton.RectTransform.RelativeSize.X, 1f), layerGroup.RectTransform), layer, textAlignment: Alignment.CenterLeft)
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
|
||||
layerGroup.Recalculate();
|
||||
}
|
||||
|
||||
layerList.RecalculateChildren();
|
||||
}
|
||||
|
||||
public void UpdateUndoHistoryPanel()
|
||||
{
|
||||
if (undoBufferPanel == null) { return; }
|
||||
if (undoBufferPanel is null) { return; }
|
||||
|
||||
undoBufferDisclaimer.Visible = mode == Mode.Wiring;
|
||||
|
||||
@@ -4203,7 +4447,7 @@ namespace Barotrauma
|
||||
public override void Update(double deltaTime)
|
||||
{
|
||||
SkipInventorySlotUpdate = false;
|
||||
ImageManager.Update((float) deltaTime);
|
||||
ImageManager.Update((float)deltaTime);
|
||||
|
||||
if (GameMain.GraphicsWidth != screenResolution.X || GameMain.GraphicsHeight != screenResolution.Y)
|
||||
{
|
||||
@@ -4720,6 +4964,11 @@ namespace Barotrauma
|
||||
|
||||
if (!saveAssemblyFrame.Rect.Contains(PlayerInput.MousePosition) && dummyCharacter?.SelectedConstruction == null && !WiringMode && GUI.MouseOn == null)
|
||||
{
|
||||
if (layerList is { Visible: true } && GUI.KeyboardDispatcher.Subscriber == layerList)
|
||||
{
|
||||
GUI.KeyboardDispatcher.Subscriber = null;
|
||||
}
|
||||
|
||||
MapEntity.UpdateSelecting(cam);
|
||||
}
|
||||
|
||||
@@ -4998,7 +5247,7 @@ namespace Barotrauma
|
||||
|
||||
var prevScissorRect = GameMain.Instance.GraphicsDevice.ScissorRectangle;
|
||||
|
||||
Rectangle subDimensions = Submarine.MainSub.CalculateDimensions(false);
|
||||
Rectangle subDimensions = Submarine.MainSub.CalculateDimensions(onlyHulls: false);
|
||||
Vector2 viewPos = subDimensions.Center.ToVector2();
|
||||
float scale = Math.Min(width / (float)subDimensions.Width, height / (float)subDimensions.Height);
|
||||
|
||||
@@ -5087,5 +5336,19 @@ namespace Barotrauma
|
||||
public static bool IsSubEditor() => Screen.Selected is SubEditorScreen && !Submarine.Unloading;
|
||||
public static bool IsWiringMode() => Screen.Selected == GameMain.SubEditorScreen && GameMain.SubEditorScreen.WiringMode && !Submarine.Unloading;
|
||||
|
||||
public static bool IsLayerVisible(MapEntity entity)
|
||||
{
|
||||
if (!IsSubEditor()) { return true; }
|
||||
|
||||
if (string.IsNullOrWhiteSpace(entity.Layer)) { return true; }
|
||||
|
||||
if (!Layers.TryGetValue(entity.Layer, out bool isVisible))
|
||||
{
|
||||
Layers.TryAdd(entity.Layer, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
return isVisible;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace Barotrauma
|
||||
private Submarine? submarine;
|
||||
private Character? dummyCharacter;
|
||||
public static Effect BlueprintEffect;
|
||||
private GUIFrame container;
|
||||
|
||||
private TabMenu tabMenu;
|
||||
|
||||
@@ -42,21 +43,25 @@ namespace Barotrauma
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
public override void Select()
|
||||
{
|
||||
base.Select();
|
||||
|
||||
container = new GUIFrame(new RectTransform(Vector2.One, GUI.Canvas, Anchor.Center), style: "InnerGlow", color: Color.Black);
|
||||
var tab = new GUIFrame(new RectTransform(Vector2.One, container.RectTransform), color: Color.Black * 0.9f);
|
||||
MedicalClinicUI clinic = new MedicalClinicUI(new MedicalClinic(null!), tab);
|
||||
clinic.RequestLatestPending();
|
||||
if (dummyCharacter is { Removed: false })
|
||||
{
|
||||
dummyCharacter?.Remove();
|
||||
}
|
||||
|
||||
dummyCharacter = Character.Create(CharacterPrefab.HumanSpeciesName, Vector2.Zero, "", id: Entity.DummyID, hasAi: false);
|
||||
dummyCharacter.Info.Job = new Job(JobPrefab.Prefabs.Where(jp => TalentTree.JobTalentTrees.ContainsKey(jp.Identifier)).GetRandom());
|
||||
dummyCharacter.Info.Name = "Galldren";
|
||||
dummyCharacter.Inventory.CreateSlots();
|
||||
// dummyCharacter = Character.Create(CharacterPrefab.HumanSpeciesName, Vector2.Zero, "", id: Entity.DummyID, hasAi: false);
|
||||
// dummyCharacter.Info.Job = new Job(JobPrefab.Prefabs.Where(jp => TalentTree.JobTalentTrees.ContainsKey(jp.Identifier)).GetRandom());
|
||||
// dummyCharacter.Info.Name = "Galldren";
|
||||
// dummyCharacter.Inventory.CreateSlots();
|
||||
|
||||
Character.Controlled = dummyCharacter;
|
||||
GameMain.World.ProcessChanges();
|
||||
@@ -67,9 +72,9 @@ namespace Barotrauma
|
||||
public override void AddToGUIUpdateList()
|
||||
{
|
||||
Frame.AddToGUIUpdateList();
|
||||
CharacterHUD.AddToGUIUpdateList(dummyCharacter);
|
||||
dummyCharacter?.SelectedConstruction?.AddToGUIUpdateList();
|
||||
tabMenu.AddToGUIUpdateList();
|
||||
container.AddToGUIUpdateList();
|
||||
// CharacterHUD.AddToGUIUpdateList(dummyCharacter);
|
||||
// dummyCharacter?.SelectedConstruction?.AddToGUIUpdateList();
|
||||
}
|
||||
|
||||
public override void Update(double deltaTime)
|
||||
@@ -92,12 +97,12 @@ namespace Barotrauma
|
||||
graphics.Clear(BackgroundColor);
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.BackToFront, transformMatrix: Cam.Transform);
|
||||
miniMapItem?.Draw(spriteBatch, false);
|
||||
if (dummyCharacter is { } dummy)
|
||||
{
|
||||
dummyCharacter.DrawFront(spriteBatch, Cam);
|
||||
dummyCharacter.Draw(spriteBatch, Cam);
|
||||
}
|
||||
// miniMapItem?.Draw(spriteBatch, false);
|
||||
// if (dummyCharacter is { } dummy)
|
||||
// {
|
||||
// dummyCharacter.DrawFront(spriteBatch, Cam);
|
||||
// dummyCharacter.Draw(spriteBatch, Cam);
|
||||
// }
|
||||
spriteBatch.End();
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, samplerState: GUI.SamplerState);
|
||||
|
||||
Reference in New Issue
Block a user