(f2e516dfe) v0.9.3.2
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user