(f2e516dfe) v0.9.3.2

This commit is contained in:
Joonas Rikkonen
2019-09-20 20:11:18 +03:00
parent 80698b58b0
commit 9aa12bcac2
144 changed files with 1653 additions and 1559 deletions
@@ -859,6 +859,9 @@ namespace Barotrauma
private void FillStoreItemList()
{
float prevStoreItemScroll = storeItemList.BarScroll;
float prevMyItemScroll = myItemList.BarScroll;
int width = storeItemList.Rect.Width;
HashSet<GUIComponent> existingItemFrames = new HashSet<GUIComponent>();
foreach (MapEntityPrefab mapEntityPrefab in MapEntityPrefab.List)
@@ -883,6 +886,9 @@ namespace Barotrauma
storeItemList.Content.RectTransform.SortChildren(
(x, y) => (x.GUIComponent.UserData as PurchasedItem).ItemPrefab.Name.CompareTo((y.GUIComponent.UserData as PurchasedItem).ItemPrefab.Name));
storeItemList.BarScroll = prevStoreItemScroll;
myItemList.BarScroll = prevMyItemScroll;
}
private void FilterStoreItems(MapEntityCategory? category, string filter)
@@ -904,7 +910,7 @@ namespace Barotrauma
btn.Selected = (MapEntityCategory)btn.UserData == selectedItemCategory;
}
storeItemList.UpdateScrollBarSize();
storeItemList.BarScroll = 0.0f;
//storeItemList.BarScroll = 0.0f;
}
public string GetMoney()
@@ -1216,7 +1216,7 @@ namespace Barotrauma
CanBeFocused = false
};
var matchingSub = Submarine.SavedSubmarines.FirstOrDefault(s => s.Name == sub.Name && s.MD5Hash.Hash == sub.MD5Hash.Hash);
var matchingSub = Submarine.SavedSubmarines.FirstOrDefault(s => s.Name == sub.Name && s.MD5Hash?.Hash == sub.MD5Hash?.Hash);
if (matchingSub == null) matchingSub = Submarine.SavedSubmarines.FirstOrDefault(s => s.Name == sub.Name);
if (matchingSub == null)
@@ -1224,7 +1224,7 @@ namespace Barotrauma
subTextBlock.TextColor = new Color(subTextBlock.TextColor, 0.5f);
frame.ToolTip = TextManager.Get("SubNotFound");
}
else if (matchingSub.MD5Hash.Hash != sub.MD5Hash.Hash)
else if (matchingSub?.MD5Hash == null || matchingSub.MD5Hash?.Hash != sub.MD5Hash?.Hash)
{
subTextBlock.TextColor = new Color(subTextBlock.TextColor, 0.5f);
frame.ToolTip = TextManager.Get("SubDoesntMatch");
@@ -1383,25 +1383,44 @@ namespace Barotrauma
OnClicked = (btn, userdata) => { if (GUI.MouseOn == btn || GUI.MouseOn == btn.TextBlock) ClosePlayerFrame(btn, userdata); return true; }
};
Vector2 frameSize = GameMain.Client.HasPermission(ClientPermissions.ManagePermissions) ? new Vector2(.24f, .44f) : new Vector2(.24f, .24f);
Vector2 frameSize = GameMain.Client.HasPermission(ClientPermissions.ManagePermissions) ? new Vector2(.24f, .5f) : new Vector2(.24f, .24f);
var playerFrameInner = new GUIFrame(new RectTransform(frameSize, playerFrame.RectTransform, Anchor.Center));
var paddedPlayerFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.85f), playerFrameInner.RectTransform, Anchor.Center))
var playerFrameInner = new GUIFrame(new RectTransform(frameSize, playerFrame.RectTransform, Anchor.Center) { MinSize = new Point(550, 0) });
var paddedPlayerFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.88f), playerFrameInner.RectTransform, Anchor.Center))
{
Stretch = true,
RelativeSpacing = 0.05f
RelativeSpacing = 0.03f
};
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.1f), paddedPlayerFrame.RectTransform),
var headerContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.1f), paddedPlayerFrame.RectTransform), isHorizontal: true)
{
Stretch = true
};
var nameText = new GUITextBlock(new RectTransform(new Vector2(0.75f, 1.0f), headerContainer.RectTransform),
text: selectedClient.Name, font: GUI.LargeFont);
//TODO: UI for client permission management
if (selectedClient.SteamID != 0 && Steam.SteamManager.IsInitialized)
{
var viewSteamProfileButton = new GUIButton(new RectTransform(new Vector2(0.25f, 1.0f), headerContainer.RectTransform, Anchor.TopCenter),
TextManager.Get("ViewSteamProfile"))
{
UserData = selectedClient
};
GUITextBlock.AutoScaleAndNormalize(nameText, viewSteamProfileButton.TextBlock);
viewSteamProfileButton.OnClicked = (bt, userdata) =>
{
Steam.SteamManager.Instance.Overlay.OpenUrl("https://steamcommunity.com/profiles/" + selectedClient.SteamID.ToString());
return true;
};
}
if (GameMain.Client.HasPermission(ClientPermissions.ManagePermissions))
{
playerFrame.UserData = selectedClient;
//new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.1f), paddedPlayerFrame.RectTransform), selectedClient.Connection.RemoteEndPoint.Address.ToString());
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), paddedPlayerFrame.RectTransform),
TextManager.Get("Rank"));
var rankDropDown = new GUIDropDown(new RectTransform(new Vector2(1.0f, 0.1f), paddedPlayerFrame.RectTransform),
@@ -1441,16 +1460,45 @@ namespace Barotrauma
Stretch = true,
RelativeSpacing = 0.05f
};
new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), permissionLabels.RectTransform), TextManager.Get("Permissions"));
new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), permissionLabels.RectTransform), TextManager.Get("PermittedConsoleCommands"));
var permissionLabel = new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), permissionLabels.RectTransform), TextManager.Get("Permissions"));
var consoleCommandLabel = new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), permissionLabels.RectTransform), TextManager.Get("PermittedConsoleCommands"));
GUITextBlock.AutoScaleAndNormalize(permissionLabel, consoleCommandLabel);
var permissionContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.4f), paddedPlayerFrame.RectTransform), isHorizontal: true)
{
Stretch = true,
RelativeSpacing = 0.05f
};
var permissionsBox = new GUIListBox(new RectTransform(new Vector2(0.5f, 1.0f), permissionContainer.RectTransform))
var listBoxContainerLeft = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 1.0f), permissionContainer.RectTransform))
{
Stretch = true,
RelativeSpacing = 0.05f
};
new GUITickBox(new RectTransform(new Vector2(0.15f, 0.15f), listBoxContainerLeft.RectTransform), TextManager.Get("all", fallBackTag: "clientpermission.all"))
{
Enabled = !myClient,
OnSelected = (tickbox) =>
{
//reset rank to custom
rankDropDown.SelectItem(null);
var client = playerFrame.UserData as Client;
if (client == null) { return false; }
foreach (GUIComponent child in tickbox.Parent.GetChild<GUIListBox>().Content.Children)
{
var permissionTickBox = child as GUITickBox;
permissionTickBox.Enabled = false;
permissionTickBox.Selected = tickbox.Selected;
permissionTickBox.Enabled = true;
}
GameMain.Client.UpdateClientPermissions(client);
return true;
}
};
var permissionsBox = new GUIListBox(new RectTransform(new Vector2(1.0f, 1.0f), listBoxContainerLeft.RectTransform))
{
UserData = selectedClient
};
@@ -1471,10 +1519,9 @@ namespace Barotrauma
rankDropDown.SelectItem(null);
var client = playerFrame.UserData as Client;
if (client == null) return false;
if (client == null) { return false; }
var thisPermission = (ClientPermissions)tickBox.UserData;
if (tickBox.Selected)
{
client.GivePermission(thisPermission);
@@ -1483,15 +1530,44 @@ namespace Barotrauma
{
client.RemovePermission(thisPermission);
}
GameMain.Client.UpdateClientPermissions(client);
if (tickBox.Enabled)
{
GameMain.Client.UpdateClientPermissions(client);
}
return true;
}
};
}
var commandList = new GUIListBox(new RectTransform(new Vector2(0.5f, 1.0f), permissionContainer.RectTransform))
var listBoxContainerRight = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 1.0f), permissionContainer.RectTransform))
{
Stretch = true,
RelativeSpacing = 0.05f
};
new GUITickBox(new RectTransform(new Vector2(0.15f, 0.15f), listBoxContainerRight.RectTransform), TextManager.Get("all", fallBackTag: "clientpermission.all"))
{
Enabled = !myClient,
OnSelected = (tickbox) =>
{
//reset rank to custom
rankDropDown.SelectItem(null);
var client = playerFrame.UserData as Client;
if (client == null) { return false; }
foreach (GUIComponent child in tickbox.Parent.GetChild<GUIListBox>().Content.Children)
{
var commandTickBox = child as GUITickBox;
commandTickBox.Enabled = false;
commandTickBox.Selected = tickbox.Selected;
commandTickBox.Enabled = true;
}
GameMain.Client.UpdateClientPermissions(client);
return true;
}
};
var commandList = new GUIListBox(new RectTransform(new Vector2(1.0f, 1.0f), listBoxContainerRight.RectTransform))
{
UserData = selectedClient
};
@@ -1522,37 +1598,23 @@ namespace Barotrauma
{
client.PermittedConsoleCommands.Add(selectedCommand);
}
GameMain.Client.UpdateClientPermissions(client);
if (tickBox.Enabled)
{
GameMain.Client.UpdateClientPermissions(client);
}
return true;
};
}
}
var buttonAreaUpper = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.1f), paddedPlayerFrame.RectTransform), isHorizontal: true);
var buttonAreaMiddle = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.1f), paddedPlayerFrame.RectTransform), isHorizontal: true);
var buttonAreaLower = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.1f), paddedPlayerFrame.RectTransform), isHorizontal: true);
if (selectedClient.SteamID != 0 && Steam.SteamManager.IsInitialized)
{
var viewSteamProfileButton = new GUIButton(new RectTransform(new Vector2(0.8f, 1.0f), buttonAreaUpper.RectTransform, Anchor.TopCenter),
TextManager.Get("ViewSteamProfile"))
{
UserData = selectedClient
};
viewSteamProfileButton.OnClicked = (bt, userdata) =>
{
Steam.SteamManager.Instance.Overlay.OpenUrl("https://steamcommunity.com/profiles/" + selectedClient.SteamID.ToString());
return true;
};
}
var buttonAreaTop = myClient ? null : new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.08f), paddedPlayerFrame.RectTransform), isHorizontal: true);
var buttonAreaLower = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.08f), paddedPlayerFrame.RectTransform), isHorizontal: true);
if (!myClient)
{
if (GameMain.Client.HasPermission(ClientPermissions.Ban))
{
var banButton = new GUIButton(new RectTransform(new Vector2(0.3f, 1.0f), buttonAreaMiddle.RectTransform),
var banButton = new GUIButton(new RectTransform(new Vector2(0.3f, 1.0f), buttonAreaTop.RectTransform),
TextManager.Get("Ban"))
{
UserData = selectedClient
@@ -1560,7 +1622,7 @@ namespace Barotrauma
banButton.OnClicked = (bt, userdata) => { BanPlayer(selectedClient); return true; };
banButton.OnClicked += ClosePlayerFrame;
var rangebanButton = new GUIButton(new RectTransform(new Vector2(0.3f, 1.0f), buttonAreaMiddle.RectTransform),
var rangebanButton = new GUIButton(new RectTransform(new Vector2(0.3f, 1.0f), buttonAreaTop.RectTransform),
TextManager.Get("BanRange"))
{
UserData = selectedClient
@@ -1594,7 +1656,7 @@ namespace Barotrauma
kickButton.OnClicked += ClosePlayerFrame;
}
new GUITickBox(new RectTransform(new Vector2(0.25f, 1.0f), buttonAreaMiddle.RectTransform, Anchor.TopRight),
new GUITickBox(new RectTransform(new Vector2(0.25f, 1.0f), buttonAreaTop.RectTransform, Anchor.TopRight),
TextManager.Get("Mute"))
{
IgnoreLayoutGroups = true,
@@ -1982,24 +2044,34 @@ namespace Barotrauma
public bool TrySelectSub(string subName, string md5Hash, GUIListBox subList)
{
if (GameMain.Client == null) return false;
if (GameMain.Client == null) { return false; }
//already downloading the selected sub file
if (GameMain.Client.FileReceiver.ActiveTransfers.Any(t => t.FileName == subName + ".sub"))
{
return false;
}
Submarine sub = subList.Content.Children
.FirstOrDefault(c => c.UserData is Submarine s && s.Name == subName && s.MD5Hash?.Hash == md5Hash)?
.UserData as Submarine;
Submarine sub = Submarine.SavedSubmarines.FirstOrDefault(m => m.Name == subName && m.MD5Hash.Hash == md5Hash);
if (sub == null) sub = Submarine.SavedSubmarines.FirstOrDefault(m => m.Name == subName);
var matchingListSub = subList.Content.GetChildByUserData(sub);
if (sub != null && subList.SelectedData as Submarine == sub)
//matching sub found and already selected, all good
if (sub != null && subList.SelectedData is Submarine selectedSub && selectedSub.MD5Hash?.Hash == md5Hash)
{
return true;
}
if (matchingListSub != null)
//sub not found, see if we have a sub with the same name
if (sub == null)
{
sub = subList.Content.Children
.FirstOrDefault(c => c.UserData is Submarine s && s.Name == subName)?
.UserData as Submarine;
}
//found a sub that at least has the same name, select it
if (sub != null)
{
if (subList.Parent is GUIDropDown subDropDown)
{
@@ -2008,7 +2080,7 @@ namespace Barotrauma
else
{
subList.OnSelected -= VotableClicked;
subList.Select(subList.Content.GetChildIndex(matchingListSub), true);
subList.Select(sub, force: true);
subList.OnSelected += VotableClicked;
}
@@ -2016,58 +2088,62 @@ namespace Barotrauma
FailedSelectedSub = null;
else
FailedSelectedShuttle = null;
//hashes match, all good
if (sub.MD5Hash?.Hash == md5Hash)
{
return true;
}
}
//-------------------------------------------------------------------------------------
//if we get to this point, a matching sub was not found or it has an incorrect MD5 hash
if (subList == SubList)
FailedSelectedSub = new Pair<string, string>(subName, md5Hash);
else
FailedSelectedShuttle = new Pair<string, string>(subName, md5Hash);
string errorMsg = "";
if (sub == null)
{
errorMsg = TextManager.GetWithVariable("SubNotFoundError", "[subname]", subName) + " ";
}
else if (sub.MD5Hash?.Hash == null)
{
errorMsg = TextManager.GetWithVariable("SubLoadError", "[subname]", subName) + " ";
subList.Content.GetChildByUserData(sub).GetChild<GUITextBox>().TextColor = Color.Red;
}
else
{
errorMsg = TextManager.GetWithVariables("SubDoesntMatchError", new string[3] { "[subname]" , "[myhash]", "[serverhash]" },
new string[3] { sub.Name, sub.MD5Hash.ShortHash, Md5Hash.GetShortHash(md5Hash) }) + " ";
}
if (sub == null || sub.MD5Hash.Hash != md5Hash)
errorMsg += TextManager.Get("DownloadSubQuestion");
//already showing a message about the same sub
if (GUIMessageBox.MessageBoxes.Any(mb => mb.UserData as string == "request" + subName))
{
if (subList == SubList)
FailedSelectedSub = new Pair<string, string>(subName, md5Hash);
else
FailedSelectedShuttle = new Pair<string, string>(subName, md5Hash);
string errorMsg = "";
if (sub == null)
{
errorMsg = TextManager.GetWithVariable("SubNotFoundError", "[subname]", subName) + " ";
}
else if (sub.MD5Hash.Hash == null)
{
errorMsg = TextManager.GetWithVariable("SubLoadError", "[subname]", subName) + " ";
if (matchingListSub != null) matchingListSub.GetChild<GUITextBox>().TextColor = Color.Red;
}
else
{
errorMsg = TextManager.GetWithVariables("SubDoesntMatchError", new string[3] { "[subname]" , "[myhash]", "[serverhash]" },
new string[3] { sub.Name, sub.MD5Hash.ShortHash, Md5Hash.GetShortHash(md5Hash) }) + " ";
}
errorMsg += TextManager.Get("DownloadSubQuestion");
//already showing a message about the same sub
if (GUIMessageBox.MessageBoxes.Any(mb => mb.UserData as string == "request" + subName))
{
return false;
}
var requestFileBox = new GUIMessageBox(TextManager.Get("DownloadSubLabel"), errorMsg,
new string[] { TextManager.Get("Yes"), TextManager.Get("No") })
{
UserData = "request" + subName
};
requestFileBox.Buttons[0].UserData = new string[] { subName, md5Hash };
requestFileBox.Buttons[0].OnClicked += requestFileBox.Close;
requestFileBox.Buttons[0].OnClicked += (GUIButton button, object userdata) =>
{
string[] fileInfo = (string[])userdata;
GameMain.Client?.RequestFile(FileTransferType.Submarine, fileInfo[0], fileInfo[1]);
return true;
};
requestFileBox.Buttons[1].OnClicked += requestFileBox.Close;
return false;
}
return true;
var requestFileBox = new GUIMessageBox(TextManager.Get("DownloadSubLabel"), errorMsg,
new string[] { TextManager.Get("Yes"), TextManager.Get("No") })
{
UserData = "request" + subName
};
requestFileBox.Buttons[0].UserData = new string[] { subName, md5Hash };
requestFileBox.Buttons[0].OnClicked += requestFileBox.Close;
requestFileBox.Buttons[0].OnClicked += (GUIButton button, object userdata) =>
{
string[] fileInfo = (string[])userdata;
GameMain.Client?.RequestFile(FileTransferType.Submarine, fileInfo[0], fileInfo[1]);
return true;
};
requestFileBox.Buttons[1].OnClicked += requestFileBox.Close;
return false;
}
}
@@ -1297,13 +1297,13 @@ namespace Barotrauma
string modFolder = Path.GetDirectoryName(itemContentPackage.Path);
string filePathRelativeToModFolder = UpdaterUtil.GetRelativePath(file, Path.Combine(Environment.CurrentDirectory, modFolder));
string destinationPath = Path.Combine(modFolder, Path.GetFileName(file));
string destinationPath;
//file is not inside the mod folder, we need to move it
if (filePathRelativeToModFolder.StartsWith("..") ||
Path.GetPathRoot(Environment.CurrentDirectory) != Path.GetPathRoot(file))
{
string tryPath = destinationPath;
destinationPath = Path.Combine(modFolder, Path.GetFileName(file));
//add a number to the filename if a file with the same name already exists
i = 2;
while (File.Exists(destinationPath))
@@ -1317,10 +1317,14 @@ namespace Barotrauma
}
catch (Exception e)
{
DebugConsole.ThrowError("Copying the file \""+file+"\" to the mod folder failed.", e);
DebugConsole.ThrowError("Copying the file \"" + file + "\" to the mod folder failed.", e);
return;
}
}
else
{
destinationPath = Path.Combine(modFolder, filePathRelativeToModFolder);
}
itemContentPackage.AddFile(destinationPath, ContentType.None);
}
itemContentPackage.Save(itemContentPackage.Path);
@@ -23,7 +23,7 @@ namespace Barotrauma
"CrewExperienceHigh"
};
private readonly Point defaultPreviewImageSize = new Point(512, 368);
private readonly Point defaultPreviewImageSize = new Point(640, 368);
private Camera cam;
@@ -158,7 +158,26 @@ namespace Barotrauma
var button = new GUIButton(new RectTransform(new Vector2(0.07f, 0.9f), paddedTopPanel.RectTransform, Anchor.CenterLeft), TextManager.Get("Back"))
{
OnClicked = GameMain.MainMenuScreen.ReturnToMainMenu
OnClicked = (b, d) =>
{
var msgBox = new GUIMessageBox("", TextManager.Get("PauseMenuQuitVerificationEditor"), new string[] { TextManager.Get("Yes"), TextManager.Get("Cancel") })
{
UserData = "verificationprompt"
};
msgBox.Buttons[0].OnClicked = (yesBtn, userdata) =>
{
GUIMessageBox.CloseAll();
GameMain.MainMenuScreen.Select();
return true;
};
msgBox.Buttons[0].OnClicked += msgBox.Close;
msgBox.Buttons[1].OnClicked = (_, userdata) =>
{
msgBox.Close();
return true;
};
return true;
}
};
button = new GUIButton(new RectTransform(new Vector2(0.07f, 0.9f), paddedTopPanel.RectTransform, Anchor.CenterLeft) { RelativeOffset = new Vector2(0.07f, 0.0f) }, TextManager.Get("OpenSubButton"))
@@ -497,9 +516,8 @@ namespace Barotrauma
foreach (MapEntityPrefab ep in MapEntityPrefab.List)
{
var itemAssemblyPrefab = ep as ItemAssemblyPrefab;
#if !DEBUG
if (itemAssemblyPrefab != null && itemAssemblyPrefab.HideInMenus) { continue; }
if (ep.HideInMenus) { continue; }
#endif
bool legacy = ep.Category == MapEntityCategory.Legacy;
@@ -548,7 +566,7 @@ namespace Barotrauma
};
}
if (ep.Category == MapEntityCategory.ItemAssembly)
if (ep is ItemAssemblyPrefab itemAssemblyPrefab)
{
new GUICustomComponent(new RectTransform(new Vector2(1.0f, 0.75f),
paddedFrame.RectTransform, Anchor.TopCenter), onDraw: itemAssemblyPrefab.DrawIcon, onUpdate: null)
@@ -2448,7 +2466,7 @@ namespace Barotrauma
Matrix.CreateScale(new Vector3(scale, scale, 1)) *
viewMatrix;
Sprite backgroundSprite = LevelGenerationParams.LevelParams.Find(l => l.BackgroundTopSprite != null).BackgroundTopSprite;
/*Sprite backgroundSprite = LevelGenerationParams.LevelParams.Find(l => l.BackgroundTopSprite != null).BackgroundTopSprite;*/
using (RenderTarget2D rt = new RenderTarget2D(
GameMain.Instance.GraphicsDevice,
@@ -2457,14 +2475,14 @@ namespace Barotrauma
{
GameMain.Instance.GraphicsDevice.SetRenderTarget(rt);
GameMain.Instance.GraphicsDevice.Clear(Color.Black);
GameMain.Instance.GraphicsDevice.Clear(new Color(8, 13, 19));
if (backgroundSprite != null)
/*if (backgroundSprite != null)
{
spriteBatch.Begin();
backgroundSprite.DrawTiled(spriteBatch, Vector2.Zero, new Vector2(width, height), color: new Color(0.025f, 0.075f, 0.131f, 1.0f));
spriteBatch.End();
}
}*/
spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, null, null, null, transform);
Submarine.Draw(spriteBatch, false);