v0.13.0.11
This commit is contained in:
@@ -23,7 +23,7 @@ namespace Barotrauma
|
||||
|
||||
private GUIButton loadGameButton, deleteMpSaveButton;
|
||||
|
||||
public Action<SubmarineInfo, string, string> StartNewGame;
|
||||
public Action<SubmarineInfo, string, string, CampaignSettings> StartNewGame;
|
||||
public Action<string> LoadGame;
|
||||
|
||||
private enum CategoryFilter { All = 0, Vanilla = 1, Custom = 2 };
|
||||
@@ -40,6 +40,8 @@ namespace Barotrauma
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public GUITickBox EnableRadiationToggle { get; set; }
|
||||
|
||||
private readonly bool isMultiplayer;
|
||||
|
||||
@@ -171,6 +173,16 @@ namespace Barotrauma
|
||||
string savePath = SaveUtil.CreateSavePath(isMultiplayer ? SaveUtil.SaveType.Multiplayer : SaveUtil.SaveType.Singleplayer, saveNameBox.Text);
|
||||
bool hasRequiredContentPackages = selectedSub.RequiredContentPackagesInstalled;
|
||||
|
||||
CampaignSettings settings = new CampaignSettings();
|
||||
if (isMultiplayer)
|
||||
{
|
||||
settings.RadiationEnabled = GameMain.NetLobbyScreen.IsRadiationEnabled();
|
||||
}
|
||||
else
|
||||
{
|
||||
settings.RadiationEnabled = EnableRadiationToggle?.Selected ?? false;
|
||||
}
|
||||
|
||||
if (selectedSub.HasTag(SubmarineTag.Shuttle) || !hasRequiredContentPackages)
|
||||
{
|
||||
if (!hasRequiredContentPackages)
|
||||
@@ -184,7 +196,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (GUIMessageBox.MessageBoxes.Count == 0)
|
||||
{
|
||||
StartNewGame?.Invoke(selectedSub, savePath, seedBox.Text);
|
||||
StartNewGame?.Invoke(selectedSub, savePath, seedBox.Text, settings);
|
||||
if (isMultiplayer)
|
||||
{
|
||||
CoroutineManager.StartCoroutine(WaitForCampaignSetup(), "WaitForCampaignSetup");
|
||||
@@ -204,7 +216,7 @@ namespace Barotrauma
|
||||
|
||||
msgBox.Buttons[0].OnClicked = (button, obj) =>
|
||||
{
|
||||
StartNewGame?.Invoke(selectedSub, savePath, seedBox.Text);
|
||||
StartNewGame?.Invoke(selectedSub, savePath, seedBox.Text, settings);
|
||||
if (isMultiplayer)
|
||||
{
|
||||
CoroutineManager.StartCoroutine(WaitForCampaignSetup(), "WaitForCampaignSetup");
|
||||
@@ -219,7 +231,7 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
StartNewGame?.Invoke(selectedSub, savePath, seedBox.Text);
|
||||
StartNewGame?.Invoke(selectedSub, savePath, seedBox.Text, settings);
|
||||
if (isMultiplayer)
|
||||
{
|
||||
CoroutineManager.StartCoroutine(WaitForCampaignSetup(), "WaitForCampaignSetup");
|
||||
@@ -230,8 +242,7 @@ namespace Barotrauma
|
||||
}
|
||||
};
|
||||
|
||||
InitialMoneyText = new GUITextBlock(new RectTransform(new Vector2(0.6f, 1f), buttonContainer.RectTransform), "",
|
||||
font: isMultiplayer ? GUI.Style.SmallFont : GUI.Style.Font, textColor: GUI.Style.Green)
|
||||
InitialMoneyText = new GUITextBlock(new RectTransform(new Vector2(isMultiplayer ? 0.6f : 0.3f, 1f), buttonContainer.RectTransform), "", font: isMultiplayer ? GUI.Style.SmallFont : GUI.Style.Font, textColor: GUI.Style.Green)
|
||||
{
|
||||
TextGetter = () =>
|
||||
{
|
||||
@@ -254,6 +265,15 @@ namespace Barotrauma
|
||||
|
||||
if (!isMultiplayer)
|
||||
{
|
||||
if (MapGenerationParams.Instance.RadiationParams != null)
|
||||
{
|
||||
EnableRadiationToggle = new GUITickBox(new RectTransform(new Vector2(0.3f, 1f), buttonContainer.RectTransform), TextManager.Get("CampaignOption.EnableRadiation"), font: GUI.Style.Font)
|
||||
{
|
||||
Selected = true,
|
||||
ToolTip = TextManager.Get("campaignoption.enableradiation.tooltip")
|
||||
};
|
||||
}
|
||||
|
||||
var disclaimerBtn = new GUIButton(new RectTransform(new Vector2(1.0f, 0.8f), rightColumn.RectTransform, Anchor.TopRight) { AbsoluteOffset = new Point(5) }, style: "GUINotificationButton")
|
||||
{
|
||||
IgnoreLayoutGroups = true,
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Barotrauma
|
||||
campaign.Map.OnLocationSelected += SelectLocation;
|
||||
campaign.Map.OnMissionSelected += (connection, mission) =>
|
||||
{
|
||||
missionList.Select(mission);
|
||||
missionList?.Select(mission);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -306,7 +306,7 @@ namespace Barotrauma
|
||||
{
|
||||
var map = GameMain.GameSession?.Map;
|
||||
if (map == null) { return; }
|
||||
if (selectedLocation != null && selectedLocation == map.CurrentDisplayLocation)
|
||||
if (selectedLocation != null && selectedLocation == GameMain.GameSession.Campaign.GetCurrentDisplayLocation())
|
||||
{
|
||||
map.SelectLocation(-1);
|
||||
}
|
||||
@@ -394,6 +394,42 @@ namespace Barotrauma
|
||||
var difficultyLabel = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), textContent.RectTransform),
|
||||
TextManager.Get("LevelDifficulty"), font: GUI.SubHeadingFont, textAlignment: Alignment.CenterLeft);
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 1.0f), difficultyLabel.RectTransform), ((int)connection.LevelData.Difficulty) + " %", textAlignment: Alignment.CenterRight);
|
||||
|
||||
if (connection.LevelData.HasBeaconStation)
|
||||
{
|
||||
var beaconStationContent = new GUILayoutGroup(new RectTransform(biomeLabel.RectTransform.NonScaledSize, textContent.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft);
|
||||
string style = connection.LevelData.IsBeaconActive ? "BeaconStationActive" : "BeaconStationInactive";
|
||||
var icon = new GUIImage(new RectTransform(new Point((int)(beaconStationContent.Rect.Height * 1.2f)), beaconStationContent.RectTransform),
|
||||
style, scaleToFit: true)
|
||||
{
|
||||
Color = MapGenerationParams.Instance.IndicatorColor,
|
||||
HoverColor = Color.Lerp(MapGenerationParams.Instance.IndicatorColor, Color.White, 0.5f),
|
||||
ToolTip = TextManager.Get(connection.LevelData.IsBeaconActive ? "BeaconStationActiveTooltip" : "BeaconStationInactiveTooltip")
|
||||
};
|
||||
new GUITextBlock(new RectTransform(Vector2.One, beaconStationContent.RectTransform),
|
||||
TextManager.Get("submarinetype.beaconstation"), font: GUI.SubHeadingFont, textAlignment: Alignment.CenterLeft)
|
||||
{
|
||||
Padding = Vector4.Zero,
|
||||
ToolTip = icon.ToolTip
|
||||
};
|
||||
}
|
||||
if (connection.LevelData.HasHuntingGrounds)
|
||||
{
|
||||
var huntingGroundsContent = new GUILayoutGroup(new RectTransform(biomeLabel.RectTransform.NonScaledSize, textContent.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft);
|
||||
var icon = new GUIImage(new RectTransform(new Point((int)(huntingGroundsContent.Rect.Height * 1.5f)), huntingGroundsContent.RectTransform),
|
||||
"HuntingGrounds", scaleToFit: true)
|
||||
{
|
||||
Color = MapGenerationParams.Instance.IndicatorColor,
|
||||
HoverColor = Color.Lerp(MapGenerationParams.Instance.IndicatorColor, Color.White, 0.5f),
|
||||
ToolTip = TextManager.Get("HuntingGroundsTooltip")
|
||||
};
|
||||
new GUITextBlock(new RectTransform(Vector2.One, huntingGroundsContent.RectTransform),
|
||||
TextManager.Get("missionname.huntinggrounds"), font: GUI.SubHeadingFont, textAlignment: Alignment.CenterLeft)
|
||||
{
|
||||
Padding = Vector4.Zero,
|
||||
ToolTip = icon.ToolTip
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
missionList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.4f), content.RectTransform))
|
||||
@@ -402,7 +438,7 @@ namespace Barotrauma
|
||||
};
|
||||
|
||||
SelectedLevel = connection?.LevelData;
|
||||
Location currentDisplayLocation = Campaign.CurrentDisplayLocation;
|
||||
Location currentDisplayLocation = Campaign.GetCurrentDisplayLocation();
|
||||
if (connection != null && connection.Locations.Contains(currentDisplayLocation))
|
||||
{
|
||||
List<Mission> availableMissions = currentDisplayLocation.GetMissionsInConnection(connection).ToList();
|
||||
@@ -437,11 +473,44 @@ namespace Barotrauma
|
||||
SelectedColor = MapGenerationParams.Instance.IndicatorColor,
|
||||
HoverColor = Color.Lerp(MapGenerationParams.Instance.IndicatorColor, Color.White, 0.5f)
|
||||
};
|
||||
missionName.Padding = new Vector4(missionName.Padding.X + icon.Rect.Width * 1.5f, missionName.Padding.Y, missionName.Padding.Z, missionName.Padding.W);
|
||||
icon.RectTransform.IsFixedSize = true;
|
||||
|
||||
GUILayoutGroup difficultyIndicatorGroup = null;
|
||||
if (mission.Difficulty.HasValue)
|
||||
{
|
||||
difficultyIndicatorGroup = new GUILayoutGroup(new RectTransform(Vector2.One * 0.9f, missionName.RectTransform, anchor: Anchor.CenterRight, scaleBasis: ScaleBasis.Smallest) { AbsoluteOffset = new Point((int)missionName.Padding.Z, 0) },
|
||||
isHorizontal: true, childAnchor: Anchor.CenterRight)
|
||||
{
|
||||
AbsoluteSpacing = 1,
|
||||
UserData = "difficulty"
|
||||
};
|
||||
var difficultyColor = mission.GetDifficultyColor();
|
||||
for (int i = 0; i < mission.Difficulty; i++)
|
||||
{
|
||||
new GUIImage(new RectTransform(Vector2.One, difficultyIndicatorGroup.RectTransform, scaleBasis: ScaleBasis.Smallest) { IsFixedSize = true }, "DifficultyIndicator", scaleToFit: true)
|
||||
{
|
||||
Color = difficultyColor * 0.5f,
|
||||
SelectedColor = difficultyColor,
|
||||
HoverColor = Color.Lerp(difficultyColor, Color.White, 0.5f)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
float extraPadding = 0.5f * icon.Rect.Width;
|
||||
float extraZPadding = difficultyIndicatorGroup != null ? mission.Difficulty.Value * (difficultyIndicatorGroup.Children.First().Rect.Width + difficultyIndicatorGroup.AbsoluteSpacing) : 0;
|
||||
missionName.Padding = new Vector4(missionName.Padding.X + icon.Rect.Width + extraPadding,
|
||||
missionName.Padding.Y,
|
||||
missionName.Padding.Z + extraZPadding + extraPadding,
|
||||
missionName.Padding.W);
|
||||
missionName.CalculateHeightFromText();
|
||||
}
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), missionTextContent.RectTransform),
|
||||
TextManager.GetWithVariable("missionreward", "[reward]", string.Format(CultureInfo.InvariantCulture, "{0:N0}", mission.Reward)), wrap: true);
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), missionTextContent.RectTransform), mission.Description, wrap: true);
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), missionTextContent.RectTransform), mission.GetMissionRewardText(), wrap: true, parseRichText: true);
|
||||
|
||||
string reputationText = mission.GetReputationRewardText(mission.Locations[0]);
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), missionTextContent.RectTransform), reputationText, wrap: true, parseRichText: true);
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), missionTextContent.RectTransform), mission.Description, wrap: true, parseRichText: true);
|
||||
}
|
||||
missionPanel.RectTransform.MinSize = new Point(0, (int)(missionTextContent.Children.Sum(c => c.Rect.Height) / missionTextContent.RectTransform.RelativeSize.Y) + GUI.IntScale(20));
|
||||
foreach (GUIComponent child in missionTextContent.Children)
|
||||
@@ -454,6 +523,10 @@ namespace Barotrauma
|
||||
missionPanel.OnAddedToGUIUpdateList = (c) =>
|
||||
{
|
||||
missionTextContent.Children.ForEach(child => child.State = c.State);
|
||||
if (missionTextContent.FindChild("difficulty", recursive: true) is GUILayoutGroup group)
|
||||
{
|
||||
group.State = c.State;
|
||||
}
|
||||
};
|
||||
|
||||
if (mission != availableMissions.Last())
|
||||
@@ -491,7 +564,25 @@ namespace Barotrauma
|
||||
StartButton = new GUIButton(new RectTransform(new Vector2(0.5f, 0.1f), content.RectTransform),
|
||||
TextManager.Get("StartCampaignButton"), style: "GUIButtonLarge")
|
||||
{
|
||||
OnClicked = (GUIButton btn, object obj) => { StartRound?.Invoke(); return true; },
|
||||
OnClicked = (GUIButton btn, object obj) =>
|
||||
{
|
||||
if (missionList.Content.Children.Any(c => c.UserData is Mission) && !(missionList.SelectedData is Mission))
|
||||
{
|
||||
var noMissionVerification = new GUIMessageBox(string.Empty, TextManager.Get("nomissionprompt"), new string[] { TextManager.Get("yes"), TextManager.Get("no") });
|
||||
noMissionVerification.Buttons[0].OnClicked = (btn, userdata) =>
|
||||
{
|
||||
StartRound?.Invoke();
|
||||
noMissionVerification.Close();
|
||||
return true;
|
||||
};
|
||||
noMissionVerification.Buttons[1].OnClicked = noMissionVerification.Close;
|
||||
}
|
||||
else
|
||||
{
|
||||
StartRound?.Invoke();
|
||||
}
|
||||
return true;
|
||||
},
|
||||
Enabled = true,
|
||||
Visible = Campaign.AllowedToEndRound()
|
||||
};
|
||||
@@ -507,6 +598,11 @@ namespace Barotrauma
|
||||
|
||||
public void SelectTab(CampaignMode.InteractionType tab)
|
||||
{
|
||||
if (Campaign.ShowCampaignUI || (Campaign.ForceMapUI && tab == CampaignMode.InteractionType.Map))
|
||||
{
|
||||
HintManager.OnShowCampaignInterface(tab);
|
||||
}
|
||||
|
||||
selectedTab = tab;
|
||||
for (int i = 0; i < tabs.Length; i++)
|
||||
{
|
||||
|
||||
+4
-4
@@ -711,7 +711,7 @@ namespace Barotrauma.CharacterEditor
|
||||
}
|
||||
}
|
||||
// Camera
|
||||
Cam.MoveCamera((float)deltaTime, allowMove: false);
|
||||
Cam.MoveCamera((float)deltaTime, allowMove: false, allowZoom: GUI.MouseOn == null);
|
||||
Vector2 targetPos = character.WorldPosition;
|
||||
if (PlayerInput.MidButtonHeld())
|
||||
{
|
||||
@@ -766,7 +766,7 @@ namespace Barotrauma.CharacterEditor
|
||||
if (editLimbs && !spriteSheetRect.Contains(PlayerInput.MousePosition) &&
|
||||
MathUtils.RectangleContainsPoint(GetLimbPhysicRect(limb), PlayerInput.MousePosition)) { return CursorState.Hand; }
|
||||
// spritesheet
|
||||
if (GetLimbSpritesheetRect(limb).Contains(PlayerInput.MousePosition)) { return CursorState.Hand; }
|
||||
if (showSpritesheet && GetLimbSpritesheetRect(limb).Contains(PlayerInput.MousePosition)) { return CursorState.Hand; }
|
||||
}
|
||||
return CursorState.Default;
|
||||
}
|
||||
@@ -1761,9 +1761,9 @@ namespace Barotrauma.CharacterEditor
|
||||
#endif
|
||||
// Add to the selected content package
|
||||
contentPackage.AddFile(configFilePath, ContentType.Character);
|
||||
Barotrauma.IO.Validation.DevException = true;
|
||||
Barotrauma.IO.Validation.SkipValidationInDebugBuilds = true;
|
||||
contentPackage.Save(contentPackage.Path);
|
||||
Barotrauma.IO.Validation.DevException = false;
|
||||
Barotrauma.IO.Validation.SkipValidationInDebugBuilds = false;
|
||||
DebugConsole.NewMessage(GetCharacterEditorTranslation("ContentPackageSaved").Replace("[path]", contentPackage.Path));
|
||||
|
||||
// Ragdoll
|
||||
|
||||
@@ -256,14 +256,14 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public void CreateImageWizard(Vector2 positon)
|
||||
public void CreateImageWizard()
|
||||
{
|
||||
string home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
|
||||
if (!Directory.Exists(home)) { return; }
|
||||
|
||||
FileSelection.OnFileSelected = file =>
|
||||
{
|
||||
Vector2 pos = Screen.Selected.Cam.ScreenToWorld(positon);
|
||||
Vector2 pos = Screen.Selected.Cam.ScreenToWorld(PlayerInput.MousePosition);
|
||||
pos.Y = -pos.Y;
|
||||
Images.Add(new EditorImage(file, pos) { DrawTarget = EditorImage.DrawTargetType.World });
|
||||
UpdateImageCategories();
|
||||
|
||||
@@ -17,8 +17,6 @@ namespace Barotrauma
|
||||
{
|
||||
private GUIFrame GuiFrame = null!;
|
||||
|
||||
private GUIListBox? contextMenu;
|
||||
|
||||
public override Camera Cam { get; }
|
||||
public static string? DrawnTooltip { get; set; }
|
||||
|
||||
@@ -538,7 +536,6 @@ namespace Barotrauma
|
||||
public override void AddToGUIUpdateList()
|
||||
{
|
||||
GuiFrame.AddToGUIUpdateList();
|
||||
contextMenu?.AddToGUIUpdateList();
|
||||
}
|
||||
|
||||
private XElement? ExportXML()
|
||||
@@ -597,7 +594,7 @@ namespace Barotrauma
|
||||
foreach (var (node, text, end) in options)
|
||||
{
|
||||
XElement optionElement = new XElement("Option");
|
||||
optionElement.Add(new XAttribute("text", text));
|
||||
optionElement.Add(new XAttribute("text", text ?? ""));
|
||||
if (end) { optionElement.Add(new XAttribute("endconversation", true)); }
|
||||
|
||||
if (node is EventNode eventNode)
|
||||
@@ -674,82 +671,37 @@ namespace Barotrauma
|
||||
|
||||
private void CreateContextMenu(EditorNode node, NodeConnection? connection = null)
|
||||
{
|
||||
contextMenu = new GUIListBox(new RectTransform(new Vector2(0.1f, 0.1f), GUI.Canvas) { ScreenSpaceOffset = PlayerInput.MousePosition.ToPoint() }, style: "GUIToolTip") { Padding = new Vector4(5) };
|
||||
if (GUIContextMenu.CurrentContextMenu != null) { return; }
|
||||
|
||||
new GUITextBlock(new RectTransform(Point.Zero, contextMenu.Content.RectTransform),
|
||||
TextManager.Get("EventEditor.Edit"), font: GUI.SmallFont) { UserData = "edit", Enabled = node is ValueNode || connection?.Type == NodeConnectionType.Value || connection?.Type == NodeConnectionType.Option };
|
||||
|
||||
new GUITextBlock(new RectTransform(Point.Zero, contextMenu.Content.RectTransform),
|
||||
TextManager.Get("EventEditor.MarkEnding"), font: GUI.SmallFont) { UserData = "markend", Enabled = connection != null && connection.Type == NodeConnectionType.Option };
|
||||
|
||||
new GUITextBlock(new RectTransform(Point.Zero, contextMenu.Content.RectTransform),
|
||||
TextManager.Get("EventEditor.RemoveConnection"), font: GUI.SmallFont) { UserData = "remcon", Enabled = connection != null };
|
||||
|
||||
new GUITextBlock(new RectTransform(Point.Zero, contextMenu.Content.RectTransform),
|
||||
TextManager.Get("EventEditor.AddOption"), font: GUI.SmallFont) { UserData = "addoption", Enabled = node.CanAddConnections };
|
||||
|
||||
new GUITextBlock(new RectTransform(Point.Zero, contextMenu.Content.RectTransform),
|
||||
TextManager.Get("EventEditor.RemoveOption"), font: GUI.SmallFont) { UserData = "removeoption", Enabled = connection != null && node.RemovableTypes.Contains(connection.Type) };
|
||||
|
||||
new GUITextBlock(new RectTransform(Point.Zero, contextMenu.Content.RectTransform),
|
||||
TextManager.Get("EventEditor.Delete"), font: GUI.SmallFont) { UserData = "delete", Enabled = true };
|
||||
|
||||
foreach (var guiComponent in contextMenu.Content.Children)
|
||||
{
|
||||
if (guiComponent is GUITextBlock child)
|
||||
GUIContextMenu.CreateContextMenu(
|
||||
new ContextMenuOption("EventEditor.Edit", isEnabled: node is ValueNode || connection?.Type == NodeConnectionType.Value || connection?.Type == NodeConnectionType.Option, onSelected: delegate
|
||||
{
|
||||
if (!child.Enabled)
|
||||
{
|
||||
child.TextColor *= 0.5f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (GUIComponent c in contextMenu.Content.Children)
|
||||
{
|
||||
if (c is GUITextBlock block)
|
||||
CreateEditMenu(node as ValueNode, connection);
|
||||
}),
|
||||
new ContextMenuOption("EventEditor.MarkEnding", isEnabled: connection != null && connection.Type == NodeConnectionType.Option, onSelected: delegate
|
||||
{
|
||||
block.RectTransform.NonScaledSize = new Point((int) (block.TextSize.X + block.Padding.X * 2), (int) (18 * GUI.Scale));
|
||||
}
|
||||
}
|
||||
if (connection == null) { return; }
|
||||
|
||||
int biggestSize = contextMenu.Content.Children.Max(c => c.Rect.Width + (int) contextMenu.Padding.X * 2);
|
||||
contextMenu.Content.Children.ForEach(c => c.RectTransform.MinSize = new Point(biggestSize, c.Rect.Height));
|
||||
contextMenu.RectTransform.NonScaledSize = new Point(biggestSize, (int) (contextMenu.Content.Children.Sum(c => c.Rect.Height) + (contextMenu.Padding.X * 2)));
|
||||
|
||||
contextMenu.OnSelected = (component, obj) =>
|
||||
{
|
||||
if (!component.Enabled) { return false; }
|
||||
|
||||
switch (obj as string)
|
||||
connection.EndConversation = !connection.EndConversation;
|
||||
}),
|
||||
new ContextMenuOption("EventEditor.RemoveConnection", isEnabled: connection != null, onSelected: delegate
|
||||
{
|
||||
case "edit":
|
||||
CreateEditMenu(node as ValueNode, connection);
|
||||
break;
|
||||
case "markend" when connection != null:
|
||||
connection.EndConversation = !connection.EndConversation;
|
||||
break;
|
||||
case "remcon" when connection != null:
|
||||
connection.ClearConnections();
|
||||
connection.OverrideValue = null;
|
||||
connection.OptionText = connection.OptionText;
|
||||
break;
|
||||
case "addoption":
|
||||
node.AddOption();
|
||||
break;
|
||||
case "removeoption":
|
||||
connection?.Parent.RemoveOption(connection);
|
||||
break;
|
||||
case "delete":
|
||||
nodeList.Remove(node);
|
||||
node.ClearConnections();
|
||||
if (connection == null) { return; }
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
contextMenu = null;
|
||||
return true;
|
||||
};
|
||||
connection.ClearConnections();
|
||||
connection.OverrideValue = null;
|
||||
connection.OptionText = connection.OptionText;
|
||||
}),
|
||||
new ContextMenuOption("EventEditor.AddOption", isEnabled: node.CanAddConnections, onSelected: node.AddOption),
|
||||
new ContextMenuOption("EventEditor.RemoveOption", isEnabled: connection != null && node.RemovableTypes.Contains(connection.Type), onSelected: delegate
|
||||
{
|
||||
connection?.Parent.RemoveOption(connection);
|
||||
}),
|
||||
new ContextMenuOption("EventEditor.Delete", isEnabled: true, onSelected: delegate
|
||||
{
|
||||
nodeList.Remove(node);
|
||||
node.ClearConnections();
|
||||
}));
|
||||
}
|
||||
|
||||
private bool CreateTestSetupMenu()
|
||||
@@ -930,7 +882,7 @@ namespace Barotrauma
|
||||
return false;
|
||||
}
|
||||
|
||||
GameSession gameSession = new GameSession(subInfo, "", GameModePreset.TestMode, null);
|
||||
GameSession gameSession = new GameSession(subInfo, "", GameModePreset.TestMode, CampaignSettings.Empty, null);
|
||||
TestGameMode gameMode = (TestGameMode) gameSession.GameMode;
|
||||
|
||||
gameMode.SpawnOutpost = true;
|
||||
@@ -1001,7 +953,7 @@ namespace Barotrauma
|
||||
CreateGUI();
|
||||
}
|
||||
|
||||
Cam.MoveCamera((float) deltaTime, true, true);
|
||||
Cam.MoveCamera((float) deltaTime, allowMove: true, allowZoom: GUI.MouseOn == null);
|
||||
Vector2 mousePos = Cam.ScreenToWorld(PlayerInput.MousePosition);
|
||||
mousePos.Y = -mousePos.Y;
|
||||
|
||||
@@ -1142,16 +1094,6 @@ namespace Barotrauma
|
||||
DraggingPosition = Vector2.Zero;
|
||||
}
|
||||
|
||||
if (contextMenu != null)
|
||||
{
|
||||
Rectangle expandedRect = contextMenu.Rect;
|
||||
expandedRect.Inflate(20, 20);
|
||||
if (!expandedRect.Contains(PlayerInput.MousePosition))
|
||||
{
|
||||
contextMenu = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (PlayerInput.MidButtonHeld())
|
||||
{
|
||||
Vector2 moveSpeed = PlayerInput.MouseSpeed * (float) deltaTime * 60.0f / Cam.Zoom;
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace Barotrauma
|
||||
|
||||
public Effect PostProcessEffect { get; private set; }
|
||||
public Effect GradientEffect { get; private set; }
|
||||
public Effect GrainEffect { get; private set; }
|
||||
|
||||
public GameScreen(GraphicsDevice graphics, ContentManager content)
|
||||
{
|
||||
@@ -41,11 +42,13 @@ namespace Barotrauma
|
||||
damageEffect = content.Load<Effect>("Effects/damageshader_opengl");
|
||||
PostProcessEffect = content.Load<Effect>("Effects/postprocess_opengl");
|
||||
GradientEffect = content.Load<Effect>("Effects/gradientshader_opengl");
|
||||
GrainEffect = content.Load<Effect>("Effects/grainshader_opengl");
|
||||
#else
|
||||
//var blurEffect = content.Load<Effect>("Effects/blurshader");
|
||||
damageEffect = content.Load<Effect>("Effects/damageshader");
|
||||
PostProcessEffect = content.Load<Effect>("Effects/postprocess");
|
||||
GradientEffect = content.Load<Effect>("Effects/gradientshader");
|
||||
GrainEffect = content.Load<Effect>("Effects/grainshader");
|
||||
#endif
|
||||
|
||||
damageStencil = TextureLoader.FromFile("Content/Map/walldamage.png");
|
||||
@@ -168,10 +171,7 @@ namespace Barotrauma
|
||||
Character.Controlled.ObstructVision &&
|
||||
(Character.Controlled.ViewTarget == Character.Controlled || Character.Controlled.ViewTarget == null);
|
||||
|
||||
if (Character.Controlled != null)
|
||||
{
|
||||
GameMain.LightManager.UpdateObstructVision(graphics, spriteBatch, cam, Character.Controlled.CursorWorldPosition);
|
||||
}
|
||||
GameMain.LightManager.UpdateObstructVision(graphics, spriteBatch, cam, Character.Controlled?.CursorWorldPosition ?? Vector2.Zero);
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
graphics.SetRenderTarget(renderTarget);
|
||||
@@ -331,12 +331,13 @@ namespace Barotrauma
|
||||
}
|
||||
spriteBatch.End();
|
||||
|
||||
if (GameMain.LightManager.LosEnabled && GameMain.LightManager.LosMode != LosMode.None && Character.Controlled != null)
|
||||
if (GameMain.LightManager.LosEnabled && GameMain.LightManager.LosMode != LosMode.None && Lights.LightManager.ViewTarget != null)
|
||||
{
|
||||
GameMain.LightManager.LosEffect.CurrentTechnique = GameMain.LightManager.LosEffect.Techniques["LosShader"];
|
||||
|
||||
GameMain.LightManager.LosEffect.Parameters["xTexture"].SetValue(renderTargetBackground);
|
||||
GameMain.LightManager.LosEffect.Parameters["xLosTexture"].SetValue(GameMain.LightManager.LosTexture);
|
||||
GameMain.LightManager.LosEffect.Parameters["xLosAlpha"].SetValue(GameMain.LightManager.LosAlpha);
|
||||
|
||||
Color losColor;
|
||||
if (GameMain.LightManager.LosMode == LosMode.Transparent)
|
||||
@@ -362,6 +363,17 @@ namespace Barotrauma
|
||||
GameMain.LightManager.LosEffect.CurrentTechnique.Passes[0].Apply();
|
||||
Quad.Render();
|
||||
}
|
||||
|
||||
float grainStrength = Character.Controlled?.GrainStrength ?? 0;
|
||||
if (grainStrength > 0)
|
||||
{
|
||||
Rectangle screenRect = new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight);
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, effect: GrainEffect);
|
||||
GUI.DrawRectangle(spriteBatch, screenRect, Color.White * grainStrength, isFilled: true);
|
||||
GrainEffect.Parameters["seed"].SetValue(Rand.Range(0f, 1f, Rand.RandSync.Unsynced));
|
||||
spriteBatch.End();
|
||||
}
|
||||
|
||||
graphics.SetRenderTarget(null);
|
||||
|
||||
float BlurStrength = 0.0f;
|
||||
|
||||
@@ -296,7 +296,7 @@ namespace Barotrauma
|
||||
subInfo ??= SubmarineInfo.SavedSubmarines.GetRandom(s =>
|
||||
s.IsPlayer && !s.HasTag(SubmarineTag.Shuttle) &&
|
||||
!nonPlayerFiles.Any(f => f.Path.CleanUpPath().Equals(s.FilePath.CleanUpPath(), StringComparison.InvariantCultureIgnoreCase)));
|
||||
GameSession gameSession = new GameSession(subInfo, "", GameModePreset.TestMode, null);
|
||||
GameSession gameSession = new GameSession(subInfo, "", GameModePreset.TestMode, CampaignSettings.Empty, null);
|
||||
gameSession.StartRound(Level.Loaded.LevelData);
|
||||
(gameSession.GameMode as TestGameMode).OnRoundEnd = () =>
|
||||
{
|
||||
@@ -489,7 +489,7 @@ namespace Barotrauma
|
||||
{
|
||||
MinValueFloat = 0,
|
||||
MaxValueFloat = 100,
|
||||
FloatValue = caveGenerationParams.GetCommonness(selectedParams),
|
||||
FloatValue = caveGenerationParams.GetCommonness(selectedParams, abyss: false),
|
||||
OnValueChanged = (numberInput) =>
|
||||
{
|
||||
caveGenerationParams.OverrideCommonness[selectedParams.Identifier] = numberInput.FloatValue;
|
||||
@@ -514,7 +514,7 @@ namespace Barotrauma
|
||||
}
|
||||
foreach (var caveParam in CaveGenerationParams.CaveParams)
|
||||
{
|
||||
if (selectedParams != null && caveParam.GetCommonness(selectedParams) <= 0.0f) { continue; }
|
||||
if (selectedParams != null && caveParam.GetCommonness(selectedParams, abyss: false) <= 0.0f) { continue; }
|
||||
availableIdentifiers.Add(caveParam.Identifier);
|
||||
}
|
||||
availableIdentifiers.Reverse();
|
||||
@@ -811,6 +811,19 @@ namespace Barotrauma
|
||||
GUI.DrawLine(spriteBatch, new Vector2(0, crushDepthScreen), new Vector2(GameMain.GraphicsWidth, crushDepthScreen), GUI.Style.Red * 0.25f, width: 5);
|
||||
GUI.DrawString(spriteBatch, new Vector2(GameMain.GraphicsWidth / 2, crushDepthScreen), "Crush depth", GUI.Style.Red, backgroundColor: Color.Black);
|
||||
}
|
||||
|
||||
float abyssStartScreen = cam.WorldToScreen(new Vector2(0.0f, Level.Loaded.AbyssArea.Bottom)).Y;
|
||||
if (abyssStartScreen > 0.0f && abyssStartScreen < GameMain.GraphicsHeight)
|
||||
{
|
||||
GUI.DrawLine(spriteBatch, new Vector2(0, abyssStartScreen), new Vector2(GameMain.GraphicsWidth, abyssStartScreen), GUI.Style.Blue * 0.25f, width: 5);
|
||||
GUI.DrawString(spriteBatch, new Vector2(GameMain.GraphicsWidth / 2, abyssStartScreen), "Abyss start", GUI.Style.Blue, backgroundColor: Color.Black);
|
||||
}
|
||||
float abyssEndScreen = cam.WorldToScreen(new Vector2(0.0f, Level.Loaded.AbyssArea.Y)).Y;
|
||||
if (abyssEndScreen > 0.0f && abyssEndScreen < GameMain.GraphicsHeight)
|
||||
{
|
||||
GUI.DrawLine(spriteBatch, new Vector2(0, abyssEndScreen), new Vector2(GameMain.GraphicsWidth, abyssEndScreen), GUI.Style.Blue * 0.25f, width: 5);
|
||||
GUI.DrawString(spriteBatch, new Vector2(GameMain.GraphicsWidth / 2, abyssEndScreen), "Abyss end", GUI.Style.Blue, backgroundColor: Color.Black);
|
||||
}
|
||||
}
|
||||
GUI.Draw(Cam, spriteBatch);
|
||||
spriteBatch.End();
|
||||
@@ -830,7 +843,7 @@ namespace Barotrauma
|
||||
pointerLightSource.Position = cam.ScreenToWorld(PlayerInput.MousePosition);
|
||||
pointerLightSource.Enabled = cursorLightEnabled.Selected;
|
||||
pointerLightSource.IsBackground = true;
|
||||
cam.MoveCamera((float)deltaTime);
|
||||
cam.MoveCamera((float)deltaTime, allowZoom: GUI.MouseOn == null);
|
||||
cam.UpdateTransform();
|
||||
Level.Loaded?.Update((float)deltaTime, cam);
|
||||
|
||||
|
||||
@@ -15,12 +15,26 @@ using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading;
|
||||
using System.Xml.Linq;
|
||||
using Barotrauma.Steam;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
class MainMenuScreen : Screen
|
||||
{
|
||||
public enum Tab { NewGame = 1, LoadGame = 2, HostServer = 3, Settings = 4, Tutorials = 5, JoinServer = 6, CharacterEditor = 7, SubmarineEditor = 8, QuickStartDev = 9, ProfilingTestBench = 10, SteamWorkshop = 11, Credits = 12, Empty = 13 }
|
||||
public enum Tab
|
||||
{
|
||||
NewGame = 0,
|
||||
LoadGame = 1,
|
||||
HostServer = 2,
|
||||
Settings = 3,
|
||||
Tutorials = 4,
|
||||
JoinServer = 5,
|
||||
CharacterEditor = 6,
|
||||
SubmarineEditor = 7,
|
||||
SteamWorkshop = 8,
|
||||
Credits = 9,
|
||||
Empty = 10
|
||||
}
|
||||
|
||||
private readonly GUIComponent buttonsParent;
|
||||
|
||||
@@ -29,8 +43,7 @@ namespace Barotrauma
|
||||
private CampaignSetupUI campaignSetupUI;
|
||||
|
||||
private GUITextBox serverNameBox, /*portBox, queryPortBox,*/ passwordBox, maxPlayersBox;
|
||||
private GUITickBox isPublicBox, wrongPasswordBanBox, karmaEnabledBox;
|
||||
private GUIDropDown karmaPresetDD;
|
||||
private GUITickBox isPublicBox, wrongPasswordBanBox, karmaBox;
|
||||
private readonly GUIFrame downloadingModsContainer, enableModsContainer;
|
||||
private readonly GUIButton joinServerButton, hostServerButton, steamWorkshopButton;
|
||||
private readonly GameMain game;
|
||||
@@ -41,7 +54,7 @@ namespace Barotrauma
|
||||
private GUIComponent remoteContentContainer;
|
||||
private XDocument remoteContentDoc;
|
||||
|
||||
private Tab selectedTab;
|
||||
private Tab selectedTab = Tab.Empty;
|
||||
|
||||
private Sprite backgroundSprite;
|
||||
|
||||
@@ -335,6 +348,16 @@ namespace Barotrauma
|
||||
CanBeFocused = false
|
||||
};
|
||||
|
||||
new GUIButton(new RectTransform(new Vector2(1.0f, 1.0f), optionList.RectTransform), TextManager.Get("EditorDisclaimerWikiLink"), textAlignment: Alignment.Left, style: "MainMenuGUIButton")
|
||||
{
|
||||
ForceUpperCase = true,
|
||||
OnClicked = (button, userData) =>
|
||||
{
|
||||
string url = TextManager.Get("EditorDisclaimerWikiUrl", returnNull: true) ?? "https://barotraumagame.com/wiki";
|
||||
GameMain.Instance.ShowOpenUrlInWebBrowserPrompt(url, promptExtensionTag: "wikinotice");
|
||||
return true;
|
||||
}
|
||||
};
|
||||
new GUIButton(new RectTransform(new Vector2(1.0f, 1.0f), optionList.RectTransform), TextManager.Get("CreditsButton"), textAlignment: Alignment.Left, style: "MainMenuGUIButton")
|
||||
{
|
||||
ForceUpperCase = true,
|
||||
@@ -353,10 +376,13 @@ namespace Barotrauma
|
||||
"Quickstart (dev)", style: "GUIButtonLarge", color: GUI.Style.Red)
|
||||
{
|
||||
IgnoreLayoutGroups = true,
|
||||
UserData = Tab.QuickStartDev,
|
||||
UserData = Tab.Empty,
|
||||
OnClicked = (tb, userdata) =>
|
||||
{
|
||||
SelectTab(tb, userdata);
|
||||
|
||||
QuickStart();
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -364,11 +390,32 @@ namespace Barotrauma
|
||||
"Profiling", style: "GUIButtonLarge", color: GUI.Style.Red)
|
||||
{
|
||||
IgnoreLayoutGroups = true,
|
||||
UserData = Tab.ProfilingTestBench,
|
||||
UserData = Tab.Empty,
|
||||
ToolTip = "Enables performance indicators and starts the game with a fixed sub, crew and level to make it easier to compare the performance between sessions.",
|
||||
OnClicked = (tb, userdata) =>
|
||||
{
|
||||
SelectTab(tb, userdata);
|
||||
|
||||
QuickStart(fixedSeed: true);
|
||||
GameMain.ShowPerf = true;
|
||||
GameMain.ShowFPS = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
new GUIButton(new RectTransform(new Point(300, 30), Frame.RectTransform, Anchor.TopRight) { AbsoluteOffset = new Point(40, 180) },
|
||||
"Join Localhost", style: "GUIButtonLarge", color: GUI.Style.Red)
|
||||
{
|
||||
IgnoreLayoutGroups = true,
|
||||
UserData = Tab.Empty,
|
||||
ToolTip = "Connects to a locally hosted dedicated server, assuming default port.",
|
||||
OnClicked = (tb, userdata) =>
|
||||
{
|
||||
SelectTab(tb, userdata);
|
||||
|
||||
GameMain.Client = new GameClient(string.IsNullOrEmpty(GameMain.Config.PlayerName) ? SteamManager.GetUsername() : GameMain.Config.PlayerName,
|
||||
IPAddress.Loopback.ToString(), 0, "localhost", 0, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -538,13 +585,13 @@ namespace Barotrauma
|
||||
case Tab.NewGame:
|
||||
if (GameMain.Config.ShowTutorialSkipWarning)
|
||||
{
|
||||
selectedTab = 0;
|
||||
selectedTab = Tab.Empty;
|
||||
ShowTutorialSkipWarning(Tab.NewGame);
|
||||
return true;
|
||||
}
|
||||
if (!GameMain.Config.CampaignDisclaimerShown)
|
||||
{
|
||||
selectedTab = 0;
|
||||
selectedTab = Tab.Empty;
|
||||
GameMain.Instance.ShowCampaignDisclaimer(() => { SelectTab(null, Tab.NewGame); });
|
||||
return true;
|
||||
}
|
||||
@@ -564,13 +611,13 @@ namespace Barotrauma
|
||||
case Tab.JoinServer:
|
||||
if (GameMain.Config.ShowTutorialSkipWarning)
|
||||
{
|
||||
selectedTab = 0;
|
||||
selectedTab = Tab.Empty;
|
||||
ShowTutorialSkipWarning(Tab.JoinServer);
|
||||
return true;
|
||||
}
|
||||
if (!GameMain.Config.CampaignDisclaimerShown)
|
||||
{
|
||||
selectedTab = 0;
|
||||
selectedTab = Tab.Empty;
|
||||
GameMain.Instance.ShowCampaignDisclaimer(() => { SelectTab(null, Tab.JoinServer); });
|
||||
return true;
|
||||
}
|
||||
@@ -580,18 +627,18 @@ namespace Barotrauma
|
||||
if (GameMain.Config.ContentPackageSelectionDirty)
|
||||
{
|
||||
new GUIMessageBox(TextManager.Get("RestartRequiredLabel"), TextManager.Get("ServerRestartRequiredContentPackage", fallBackTag: "RestartRequiredGeneric"));
|
||||
selectedTab = 0;
|
||||
selectedTab = Tab.Empty;
|
||||
return false;
|
||||
}
|
||||
if (GameMain.Config.ShowTutorialSkipWarning)
|
||||
{
|
||||
selectedTab = 0;
|
||||
selectedTab = Tab.Empty;
|
||||
ShowTutorialSkipWarning(tab);
|
||||
return true;
|
||||
}
|
||||
if (!GameMain.Config.CampaignDisclaimerShown)
|
||||
{
|
||||
selectedTab = 0;
|
||||
selectedTab = Tab.Empty;
|
||||
GameMain.Instance.ShowCampaignDisclaimer(() => { SelectTab(null, Tab.HostServer); });
|
||||
return true;
|
||||
}
|
||||
@@ -599,7 +646,7 @@ namespace Barotrauma
|
||||
case Tab.Tutorials:
|
||||
if (!GameMain.Config.CampaignDisclaimerShown)
|
||||
{
|
||||
selectedTab = 0;
|
||||
selectedTab = Tab.Empty;
|
||||
GameMain.Instance.ShowCampaignDisclaimer(() => { SelectTab(null, Tab.Tutorials); });
|
||||
return true;
|
||||
}
|
||||
@@ -612,14 +659,6 @@ namespace Barotrauma
|
||||
case Tab.SubmarineEditor:
|
||||
CoroutineManager.StartCoroutine(SelectScreenWithWaitCursor(GameMain.SubEditorScreen));
|
||||
break;
|
||||
case Tab.QuickStartDev:
|
||||
QuickStart();
|
||||
break;
|
||||
case Tab.ProfilingTestBench:
|
||||
QuickStart(fixedSeed: true);
|
||||
GameMain.ShowPerf = true;
|
||||
GameMain.ShowFPS = true;
|
||||
break;
|
||||
case Tab.SteamWorkshop:
|
||||
if (!Steam.SteamManager.IsInitialized) return false;
|
||||
CoroutineManager.StartCoroutine(SelectScreenWithWaitCursor(GameMain.SteamWorkshopScreen));
|
||||
@@ -630,7 +669,7 @@ namespace Barotrauma
|
||||
break;
|
||||
case Tab.Empty:
|
||||
titleText.Visible = true;
|
||||
selectedTab = 0;
|
||||
selectedTab = Tab.Empty;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -709,7 +748,7 @@ namespace Barotrauma
|
||||
var gamesession = new GameSession(
|
||||
selectedSub,
|
||||
GameModePreset.DevSandbox,
|
||||
missionPrefab: null);
|
||||
missionPrefabs: null);
|
||||
//(gamesession.GameMode as SinglePlayerCampaign).GenerateMap(ToolBox.RandomSeed(8));
|
||||
gamesession.StartRound(fixedSeed ? "abcd" : ToolBox.RandomSeed(8), difficulty: 40);
|
||||
GameMain.GameScreen.Select();
|
||||
@@ -886,8 +925,8 @@ namespace Barotrauma
|
||||
" -public " + isPublicBox.Selected.ToString() +
|
||||
" -playstyle " + ((PlayStyle)playstyleBanner.UserData).ToString() +
|
||||
" -banafterwrongpassword " + wrongPasswordBanBox.Selected.ToString() +
|
||||
" -karmaenabled " + karmaEnabledBox.Selected.ToString() +
|
||||
" -karmapreset " + (karmaPresetDD.SelectedData?.ToString() ?? "default") +
|
||||
" -karmaenabled " + (!karmaBox.Selected).ToString() +
|
||||
" -karmapreset default" +
|
||||
" -maxplayers " + maxPlayersBox.Text;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(passwordBox.Text))
|
||||
@@ -946,7 +985,7 @@ namespace Barotrauma
|
||||
public override void AddToGUIUpdateList()
|
||||
{
|
||||
Frame.AddToGUIUpdateList();
|
||||
if (selectedTab > 0 && menuTabs[(int)selectedTab] != null)
|
||||
if (selectedTab < Tab.Empty && menuTabs[(int)selectedTab] != null)
|
||||
{
|
||||
menuTabs[(int)selectedTab].AddToGUIUpdateList();
|
||||
}
|
||||
@@ -1043,7 +1082,7 @@ namespace Barotrauma
|
||||
spriteBatch.End();
|
||||
}
|
||||
|
||||
private void StartGame(SubmarineInfo selectedSub, string saveName, string mapSeed)
|
||||
private void StartGame(SubmarineInfo selectedSub, string saveName, string mapSeed, CampaignSettings settings)
|
||||
{
|
||||
if (string.IsNullOrEmpty(saveName)) return;
|
||||
|
||||
@@ -1082,7 +1121,7 @@ namespace Barotrauma
|
||||
|
||||
selectedSub = new SubmarineInfo(Path.Combine(SaveUtil.TempPath, selectedSub.Name + ".sub"));
|
||||
|
||||
GameMain.GameSession = new GameSession(selectedSub, saveName, GameModePreset.SinglePlayerCampaign, mapSeed);
|
||||
GameMain.GameSession = new GameSession(selectedSub, saveName, GameModePreset.SinglePlayerCampaign, settings, mapSeed);
|
||||
((SinglePlayerCampaign)GameMain.GameSession.GameMode).LoadNewLevel();
|
||||
}
|
||||
|
||||
@@ -1134,6 +1173,10 @@ namespace Barotrauma
|
||||
(int)(campaignSetupUI.StartButton.TextBlock.TextSize.X * 1.5f),
|
||||
campaignSetupUI.StartButton.RectTransform.MinSize.Y);
|
||||
startButtonContainer.RectTransform.MinSize = new Point(0, campaignSetupUI.StartButton.RectTransform.MinSize.Y);
|
||||
if (campaignSetupUI.EnableRadiationToggle != null)
|
||||
{
|
||||
campaignSetupUI.EnableRadiationToggle.RectTransform.Parent = startButtonContainer.RectTransform;
|
||||
}
|
||||
campaignSetupUI.InitialMoneyText.RectTransform.Parent = startButtonContainer.RectTransform;
|
||||
}
|
||||
|
||||
@@ -1141,9 +1184,11 @@ namespace Barotrauma
|
||||
{
|
||||
menuTabs[(int)Tab.HostServer].ClearChildren();
|
||||
|
||||
int port = NetConfig.DefaultPort;
|
||||
int queryPort = NetConfig.DefaultQueryPort;
|
||||
string name = "";
|
||||
string password = "";
|
||||
int maxPlayers = 8;
|
||||
bool isPublic = true;
|
||||
bool banAfterWrongPassword = false;
|
||||
bool karmaEnabled = true;
|
||||
string selectedKarmaPreset = "";
|
||||
PlayStyle selectedPlayStyle = PlayStyle.Casual;
|
||||
@@ -1152,8 +1197,10 @@ namespace Barotrauma
|
||||
XDocument settingsDoc = XMLExtensions.TryLoadXml(ServerSettings.SettingsFile);
|
||||
if (settingsDoc != null)
|
||||
{
|
||||
port = settingsDoc.Root.GetAttributeInt("port", port);
|
||||
queryPort = settingsDoc.Root.GetAttributeInt("queryport", queryPort);
|
||||
name = settingsDoc.Root.GetAttributeString("name", name);
|
||||
password = settingsDoc.Root.GetAttributeString("password", password);
|
||||
isPublic = settingsDoc.Root.GetAttributeBool("public", isPublic);
|
||||
banAfterWrongPassword = settingsDoc.Root.GetAttributeBool("banafterwrongpassword", banAfterWrongPassword);
|
||||
|
||||
int maxPlayersElement = settingsDoc.Root.GetAttributeInt("maxplayers", maxPlayers);
|
||||
if (maxPlayersElement > NetConfig.MaxPlayers)
|
||||
@@ -1255,30 +1302,12 @@ namespace Barotrauma
|
||||
new GUIFrame(new RectTransform(new Vector2(1.0f, 0.05f), content.RectTransform), style: null);
|
||||
|
||||
var label = new GUITextBlock(new RectTransform(textLabelSize, parent.RectTransform), TextManager.Get("ServerName"), textAlignment: textAlignment);
|
||||
serverNameBox = new GUITextBox(new RectTransform(textFieldSize, label.RectTransform, Anchor.CenterRight), textAlignment: textAlignment)
|
||||
serverNameBox = new GUITextBox(new RectTransform(textFieldSize, label.RectTransform, Anchor.CenterRight), text: name, textAlignment: textAlignment)
|
||||
{
|
||||
MaxTextLength = NetConfig.ServerNameMaxLength,
|
||||
OverflowClip = true
|
||||
};
|
||||
label.RectTransform.MaxSize = serverNameBox.RectTransform.MaxSize;
|
||||
|
||||
/* TODO: allow lidgren servers from client?
|
||||
label = new GUITextBlock(new RectTransform(textLabelSize, parent.RectTransform), TextManager.Get("ServerPort"), textAlignment: textAlignment);
|
||||
portBox = new GUITextBox(new RectTransform(textFieldSize, label.RectTransform, Anchor.CenterRight), textAlignment: textAlignment)
|
||||
{
|
||||
Text = port.ToString(),
|
||||
ToolTip = TextManager.Get("ServerPortToolTip")
|
||||
};
|
||||
|
||||
#if USE_STEAM
|
||||
label = new GUITextBlock(new RectTransform(textLabelSize, parent.RectTransform), TextManager.Get("ServerQueryPort"), textAlignment: textAlignment);
|
||||
queryPortBox = new GUITextBox(new RectTransform(textFieldSize, label.RectTransform, Anchor.CenterRight), textAlignment: textAlignment)
|
||||
{
|
||||
Text = queryPort.ToString(),
|
||||
ToolTip = TextManager.Get("ServerQueryPortToolTip")
|
||||
};
|
||||
#endif
|
||||
*/
|
||||
|
||||
var maxPlayersLabel = new GUITextBlock(new RectTransform(textLabelSize, parent.RectTransform), TextManager.Get("MaxPlayers"), textAlignment: textAlignment);
|
||||
var buttonContainer = new GUILayoutGroup(new RectTransform(textFieldSize, maxPlayersLabel.RectTransform, Anchor.CenterRight), isHorizontal: true)
|
||||
@@ -1304,7 +1333,7 @@ namespace Barotrauma
|
||||
maxPlayersLabel.RectTransform.MaxSize = maxPlayersBox.RectTransform.MaxSize;
|
||||
|
||||
label = new GUITextBlock(new RectTransform(textLabelSize, parent.RectTransform), TextManager.Get("Password"), textAlignment: textAlignment);
|
||||
passwordBox = new GUITextBox(new RectTransform(textFieldSize, label.RectTransform, Anchor.CenterRight), textAlignment: textAlignment)
|
||||
passwordBox = new GUITextBox(new RectTransform(textFieldSize, label.RectTransform, Anchor.CenterRight), text: password, textAlignment: textAlignment)
|
||||
{
|
||||
Censor = true
|
||||
};
|
||||
@@ -1316,10 +1345,14 @@ namespace Barotrauma
|
||||
|
||||
isPublicBox = new GUITickBox(new RectTransform(new Vector2(0.5f, 1.0f), tickboxAreaUpper.RectTransform), TextManager.Get("PublicServer"))
|
||||
{
|
||||
Selected = isPublic,
|
||||
ToolTip = TextManager.Get("PublicServerToolTip")
|
||||
};
|
||||
|
||||
wrongPasswordBanBox = new GUITickBox(new RectTransform(new Vector2(0.5f, 1.0f), tickboxAreaUpper.RectTransform), TextManager.Get("ServerSettingsBanAfterWrongPassword"));
|
||||
wrongPasswordBanBox = new GUITickBox(new RectTransform(new Vector2(0.5f, 1.0f), tickboxAreaUpper.RectTransform), TextManager.Get("ServerSettingsBanAfterWrongPassword"))
|
||||
{
|
||||
Selected = banAfterWrongPassword
|
||||
};
|
||||
|
||||
tickboxAreaUpper.RectTransform.MaxSize = isPublicBox.RectTransform.MaxSize;
|
||||
|
||||
@@ -1327,31 +1360,13 @@ namespace Barotrauma
|
||||
|
||||
var tickboxAreaLower = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, tickBoxSize.Y), parent.RectTransform), isHorizontal: true);
|
||||
|
||||
karmaEnabledBox = new GUITickBox(new RectTransform(new Vector2(0.5f, 1.0f), tickboxAreaLower.RectTransform), TextManager.Get("ServerSettingsUseKarma"))
|
||||
karmaBox = new GUITickBox(new RectTransform(new Vector2(0.5f, 1.0f), tickboxAreaLower.RectTransform), TextManager.Get("HostServerKarmaSetting"))
|
||||
{
|
||||
ToolTip = TextManager.Get("karmaexplanation"),
|
||||
OnSelected = (tb) =>
|
||||
{
|
||||
karmaPresetDD.Enabled = karmaPresetDD.ButtonEnabled = tb.Selected;
|
||||
return true;
|
||||
}
|
||||
Selected = !karmaEnabled,
|
||||
ToolTip = TextManager.Get("hostserverkarmasettingtooltip")
|
||||
};
|
||||
karmaPresetDD = new GUIDropDown(new RectTransform(new Vector2(0.5f, 1.0f), tickboxAreaLower.RectTransform))
|
||||
{
|
||||
ButtonEnabled = false,
|
||||
Enabled = false
|
||||
};
|
||||
var tempKarmaManager = new KarmaManager();
|
||||
foreach (string karmaPreset in tempKarmaManager.Presets.Keys)
|
||||
{
|
||||
karmaPresetDD.AddItem(TextManager.Get("KarmaPreset." + karmaPreset), karmaPreset);
|
||||
if (karmaPreset == selectedKarmaPreset) { karmaPresetDD.SelectItem(karmaPreset); }
|
||||
}
|
||||
if (karmaPresetDD.SelectedIndex == -1) { karmaPresetDD.Select(0); }
|
||||
|
||||
karmaEnabledBox.Selected = karmaEnabled;
|
||||
|
||||
tickboxAreaLower.RectTransform.MaxSize = karmaEnabledBox.RectTransform.MaxSize;
|
||||
tickboxAreaLower.RectTransform.MaxSize = karmaBox.RectTransform.MaxSize;
|
||||
|
||||
//spacing
|
||||
new GUIFrame(new RectTransform(new Vector2(1.0f, 0.05f), content.RectTransform), style: null);
|
||||
|
||||
@@ -27,6 +27,8 @@ namespace Barotrauma
|
||||
|
||||
private GUIComponent jobVariantTooltip;
|
||||
|
||||
private SubmarinePreview submarinePreview;
|
||||
|
||||
private readonly GUITextBox chatInput;
|
||||
private readonly GUITextBox serverLogFilter;
|
||||
public GUITextBox ChatInput
|
||||
@@ -41,6 +43,8 @@ namespace Barotrauma
|
||||
|
||||
private readonly GUIScrollBar levelDifficultyScrollBar;
|
||||
|
||||
private readonly GUITickBox radiationEnabledTickBox;
|
||||
|
||||
private readonly GUIButton[] traitorProbabilityButtons;
|
||||
private readonly GUITextBlock traitorProbabilityText;
|
||||
|
||||
@@ -128,6 +132,12 @@ namespace Barotrauma
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public GUITickBox Favorite
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public GUITextBox ServerMessage
|
||||
{
|
||||
@@ -144,6 +154,8 @@ namespace Barotrauma
|
||||
private readonly GUIButton showChatButton;
|
||||
private readonly GUIButton showLogButton;
|
||||
|
||||
private readonly GUITextBlock publicOrPrivate;
|
||||
|
||||
public GUIListBox SubList
|
||||
{
|
||||
get { return subList; }
|
||||
@@ -473,6 +485,7 @@ namespace Barotrauma
|
||||
if (socialHolder != null) { socialHolder.Visible = false; }
|
||||
if (!(serverLogHolder?.Visible ?? true))
|
||||
{
|
||||
if (GameMain.Client?.ServerSettings?.ServerLog == null) { return false; }
|
||||
serverLogHolder.Visible = true;
|
||||
GameMain.Client.ServerSettings.ServerLog.AssignLogFrame(serverLogReverseButton, serverLogBox, serverLogFilterTicks.Content, serverLogFilter);
|
||||
}
|
||||
@@ -663,6 +676,27 @@ namespace Barotrauma
|
||||
};
|
||||
clientReadonlyElements.Add(ServerName);
|
||||
|
||||
Favorite = new GUITickBox(new RectTransform(new Vector2(1.0f, 1.0f), lobbyHeader.RectTransform, scaleBasis: ScaleBasis.BothHeight),
|
||||
"", null, "GUIServerListFavoriteTickBox")
|
||||
{
|
||||
Selected = false,
|
||||
ToolTip = TextManager.Get("addtofavorites"),
|
||||
OnSelected = (tickbox) =>
|
||||
{
|
||||
ServerInfo info = GameMain.Client.ServerSettings.GetServerListInfo();
|
||||
if (tickbox.Selected)
|
||||
{
|
||||
GameMain.ServerListScreen.AddToFavoriteServers(info);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameMain.ServerListScreen.RemoveFromFavoriteServers(info);
|
||||
}
|
||||
tickbox.ToolTip = TextManager.Get(tickbox.Selected ? "removefromfavorites" : "addtofavorites");
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
SettingsButton = new GUIButton(new RectTransform(new Vector2(0.25f, 1.0f), lobbyHeader.RectTransform, Anchor.TopRight),
|
||||
TextManager.Get("ServerSettingsButton"));
|
||||
clientHiddenElements.Add(SettingsButton);
|
||||
@@ -691,6 +725,12 @@ namespace Barotrauma
|
||||
CanBeFocused = false
|
||||
};
|
||||
|
||||
publicOrPrivate = new GUITextBlock(new RectTransform(new Vector2(0.15f, 1.0f), serverBanner.RectTransform, Anchor.BottomRight, Pivot.BottomRight),
|
||||
"", font: GUI.SmallFont, textAlignment: Alignment.Center, textColor: Color.White, style: "GUISlopedHeader")
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
|
||||
var serverMessageContainer = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.75f), serverInfoHolder.RectTransform));
|
||||
ServerMessage = new GUITextBox(new RectTransform(Vector2.One, serverMessageContainer.Content.RectTransform), style: "GUITextBoxNoBorder")
|
||||
{
|
||||
@@ -1095,6 +1135,20 @@ namespace Barotrauma
|
||||
}
|
||||
};
|
||||
|
||||
if (MapGenerationParams.Instance.RadiationParams != null)
|
||||
{
|
||||
radiationEnabledTickBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.1f), settingsContent.RectTransform), TextManager.Get("CampaignOption.EnableRadiation"), font: GUI.Style.Font)
|
||||
{
|
||||
Selected = true,
|
||||
OnSelected = box =>
|
||||
{
|
||||
GameMain.Client.ServerSettings.ClientAdminWrite(ServerSettings.NetFlags.Misc, radiationEnabled: box.Selected);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
List<GUIComponent> settingsElements = settingsContent.Children.ToList();
|
||||
for (int i = 0; i < settingsElements.Count; i++)
|
||||
{
|
||||
@@ -1226,6 +1280,11 @@ namespace Barotrauma
|
||||
|
||||
base.Select();
|
||||
}
|
||||
|
||||
public void SetPublic(bool isPublic)
|
||||
{
|
||||
publicOrPrivate.Text = isPublic ? TextManager.Get("PublicLobbyTag") : TextManager.Get("PrivateLobbyTag");
|
||||
}
|
||||
|
||||
public void RefreshEnabledElements()
|
||||
{
|
||||
@@ -1238,6 +1297,10 @@ namespace Barotrauma
|
||||
}
|
||||
SeedBox.Enabled = !CampaignFrame.Visible && !CampaignSetupFrame.Visible && GameMain.Client.HasPermission(ClientPermissions.ManageSettings);
|
||||
levelDifficultyScrollBar.Enabled = !CampaignFrame.Visible && !CampaignSetupFrame.Visible && GameMain.Client.HasPermission(ClientPermissions.ManageSettings);
|
||||
if (radiationEnabledTickBox != null)
|
||||
{
|
||||
radiationEnabledTickBox.Enabled = CampaignSetupFrame.Visible && GameMain.Client.HasPermission(ClientPermissions.ManageSettings);
|
||||
}
|
||||
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);
|
||||
@@ -1250,9 +1313,9 @@ namespace Barotrauma
|
||||
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 = !CampaignFrame.Visible && !CampaignSetupFrame.Visible && GameMain.Client.HasPermission(ClientPermissions.ManageSettings);
|
||||
shuttleTickBox.Enabled = GameMain.Client.HasPermission(ClientPermissions.ManageSettings);
|
||||
SubList.Enabled = !CampaignFrame.Visible && (GameMain.Client.ServerSettings.Voting.AllowSubVoting || GameMain.Client.HasPermission(ClientPermissions.SelectSub));
|
||||
shuttleList.Enabled = shuttleList.ButtonEnabled = shuttleTickBox.Enabled = !CampaignFrame.Visible && !CampaignSetupFrame.Visible && GameMain.Client.HasPermission(ClientPermissions.SelectSub);
|
||||
shuttleList.Enabled = shuttleList.ButtonEnabled = GameMain.Client.HasPermission(ClientPermissions.SelectSub);
|
||||
ModeList.Enabled = GameMain.Client.ServerSettings.Voting.AllowModeVoting || GameMain.Client.HasPermission(ClientPermissions.SelectMode);
|
||||
LogButtons.Visible = GameMain.Client.HasPermission(ClientPermissions.ServerLog);
|
||||
GameMain.Client.ShowLogButton.Visible = GameMain.Client.HasPermission(ClientPermissions.ServerLog);
|
||||
@@ -1298,7 +1361,7 @@ namespace Barotrauma
|
||||
public void CreatePlayerFrame(GUIComponent parent)
|
||||
{
|
||||
UpdatePlayerFrame(
|
||||
playerInfoContainer.Children?.First().UserData as CharacterInfo,
|
||||
Character.Controlled?.Info ?? playerInfoContainer.Children?.First().UserData as CharacterInfo,
|
||||
allowEditing: campaignCharacterInfo == null,
|
||||
parent: parent);
|
||||
}
|
||||
@@ -1962,6 +2025,17 @@ namespace Barotrauma
|
||||
if (child != null) { playerList.RemoveChild(child); }
|
||||
}
|
||||
|
||||
public void SelectPlayer(GUITextBlock component, GUITextBlock.ClickableArea area)
|
||||
{
|
||||
if (!UInt64.TryParse(area.Data.Metadata, out UInt64 id)) { return; }
|
||||
Client client = GameMain.Client.ConnectedClients.Find(c => c.SteamID == id)
|
||||
?? GameMain.Client.ConnectedClients.Find(c => c.ID == id)
|
||||
?? GameMain.Client.PreviouslyConnectedClients.FirstOrDefault(c => c.SteamID == id)
|
||||
?? GameMain.Client.PreviouslyConnectedClients.FirstOrDefault(c => c.ID == id);
|
||||
if (client == null) { return; }
|
||||
GameMain.NetLobbyScreen.SelectPlayer(client);
|
||||
}
|
||||
|
||||
public bool SelectPlayer(Client selectedClient)
|
||||
{
|
||||
bool myClient = selectedClient.ID == GameMain.Client.ID;
|
||||
@@ -2460,6 +2534,8 @@ namespace Barotrauma
|
||||
|
||||
component.ToolTip = TextManager.Get("servertagdescription." + playStyle);
|
||||
}
|
||||
|
||||
publicOrPrivate.RectTransform.NonScaledSize = (publicOrPrivate.Font.MeasureString(publicOrPrivate.Text) + new Vector2(25, 8) * GUI.Scale).ToPoint();
|
||||
}
|
||||
|
||||
private void DrawJobVariantItems(SpriteBatch spriteBatch, GUICustomComponent component, Pair<JobPrefab, int> jobPrefab, int itemsPerRow)
|
||||
@@ -2537,11 +2613,24 @@ namespace Barotrauma
|
||||
text: ChatMessage.GetTimeStamp() + (message.Type == ChatMessageType.Private ? TextManager.Get("PrivateMessageTag") + " " : "") + message.TextWithSender,
|
||||
textColor: message.Color,
|
||||
color: ((chatBox.CountChildren % 2) == 0) ? Color.Transparent : Color.Black * 0.1f,
|
||||
wrap: true, font: GUI.SmallFont)
|
||||
wrap: true, font: GUI.SmallFont,
|
||||
parseRichText: true)
|
||||
{
|
||||
UserData = message,
|
||||
CanBeFocused = false
|
||||
};
|
||||
msg.CalculateHeightFromText();
|
||||
if (msg.RichTextData != null)
|
||||
{
|
||||
foreach (var data in msg.RichTextData)
|
||||
{
|
||||
msg.ClickableAreas.Add(new GUITextBlock.ClickableArea()
|
||||
{
|
||||
Data = data,
|
||||
OnClick = GameMain.NetLobbyScreen.SelectPlayer
|
||||
});
|
||||
}
|
||||
}
|
||||
msg.RectTransform.SizeChanged += Recalculate;
|
||||
void Recalculate()
|
||||
{
|
||||
@@ -3463,29 +3552,35 @@ namespace Barotrauma
|
||||
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") })
|
||||
if (GameMain.Client.ServerSettings.AllowFileTransfers)
|
||||
{
|
||||
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;
|
||||
errorMsg += TextManager.Get("DownloadSubQuestion");
|
||||
|
||||
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;
|
||||
}
|
||||
else
|
||||
{
|
||||
new GUIMessageBox(TextManager.Get("DownloadSubLabel"), errorMsg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -311,7 +311,7 @@ namespace Barotrauma
|
||||
|
||||
public override void Update(double deltaTime)
|
||||
{
|
||||
cam.MoveCamera((float)deltaTime, true);
|
||||
cam.MoveCamera((float)deltaTime, allowMove: true, allowZoom: GUI.MouseOn == null);
|
||||
|
||||
if (selectedPrefab != null)
|
||||
{
|
||||
|
||||
@@ -43,6 +43,13 @@ namespace Barotrauma
|
||||
private Dictionary<ulong, Steamworks.Ugc.Item?> pendingWorkshopDownloads = null;
|
||||
private string autoConnectName; private string autoConnectEndpoint;
|
||||
|
||||
private enum TernaryOption
|
||||
{
|
||||
Any,
|
||||
Enabled,
|
||||
Disabled
|
||||
}
|
||||
|
||||
private class FriendInfo
|
||||
{
|
||||
public UInt64 SteamID;
|
||||
@@ -131,7 +138,7 @@ namespace Barotrauma
|
||||
|
||||
private bool masterServerResponded;
|
||||
private IRestResponse masterServerResponse;
|
||||
|
||||
|
||||
private readonly float[] columnRelativeWidth = new float[] { 0.1f, 0.1f, 0.7f, 0.12f, 0.08f, 0.08f };
|
||||
private readonly string[] columnLabel = new string[] { "ServerListCompatible", "ServerListHasPassword", "ServerListName", "ServerListRoundStarted", "ServerListPlayers", "ServerListPing" };
|
||||
|
||||
@@ -146,16 +153,19 @@ namespace Barotrauma
|
||||
private GUITickBox filterFull;
|
||||
private GUITickBox filterEmpty;
|
||||
private GUITickBox filterWhitelisted;
|
||||
private GUITickBox filterFriendlyFire;
|
||||
private GUITickBox filterKarma;
|
||||
private GUITickBox filterTraitor;
|
||||
private GUITickBox filterModded;
|
||||
private GUITickBox filterVoip;
|
||||
private Dictionary<string, GUIDropDown> ternaryFilters;
|
||||
private Dictionary<string, GUITickBox> filterTickBoxes;
|
||||
private Dictionary<string, GUITickBox> playStyleTickBoxes;
|
||||
private Dictionary<string, GUITickBox> gameModeTickBoxes;
|
||||
private GUITickBox filterOffensive;
|
||||
|
||||
//GUIDropDown sends the OnSelected event before SelectedData is set, so we have to cache it manually.
|
||||
private TernaryOption filterFriendlyFireValue = TernaryOption.Any;
|
||||
private TernaryOption filterKarmaValue = TernaryOption.Any;
|
||||
private TernaryOption filterTraitorValue = TernaryOption.Any;
|
||||
private TernaryOption filterVoipValue = TernaryOption.Any;
|
||||
private TernaryOption filterModdedValue = TernaryOption.Any;
|
||||
|
||||
private string sortedBy;
|
||||
|
||||
private GUIButton serverPreviewToggleButton;
|
||||
@@ -173,6 +183,49 @@ namespace Barotrauma
|
||||
CreateUI();
|
||||
}
|
||||
|
||||
private void AddTernaryFilter(RectTransform parent, float elementHeight, string tag, Action<TernaryOption> valueSetter)
|
||||
{
|
||||
var filterLayoutGroup = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, elementHeight), parent), isHorizontal: true)
|
||||
{
|
||||
Stretch = true
|
||||
};
|
||||
|
||||
var box = new GUIFrame(new RectTransform(Vector2.One, filterLayoutGroup.RectTransform, Anchor.CenterLeft, scaleBasis: ScaleBasis.BothHeight)
|
||||
{
|
||||
IsFixedSize = true,
|
||||
}, null)
|
||||
{
|
||||
HoverColor = Color.Gray,
|
||||
SelectedColor = Color.DarkGray,
|
||||
CanBeFocused = false
|
||||
};
|
||||
if (box.RectTransform.MinSize.Y > 0)
|
||||
{
|
||||
box.RectTransform.MinSize = new Point(box.RectTransform.MinSize.Y);
|
||||
box.RectTransform.Resize(box.RectTransform.MinSize);
|
||||
}
|
||||
Vector2 textBlockScale = new Vector2((float)(filterLayoutGroup.Rect.Width - filterLayoutGroup.Rect.Height) / (float)Math.Max(filterLayoutGroup.Rect.Width, 1.0), 1.0f);
|
||||
|
||||
var filterLabel = new GUITextBlock(new RectTransform(new Vector2(0.6f, 1.0f) * textBlockScale, filterLayoutGroup.RectTransform, Anchor.CenterLeft), TextManager.Get("servertag." + tag + ".label"), textAlignment: Alignment.CenterLeft)
|
||||
{
|
||||
UserData = TextManager.Get("servertag." + tag + ".label")
|
||||
};
|
||||
GUI.Style.Apply(filterLabel, "GUITextBlock", null);
|
||||
|
||||
var dropDown = new GUIDropDown(new RectTransform(new Vector2(0.4f, 1.0f) * textBlockScale, filterLayoutGroup.RectTransform, Anchor.CenterLeft), elementCount: 3);
|
||||
dropDown.AddItem(TextManager.Get("any"), TernaryOption.Any);
|
||||
dropDown.AddItem(TextManager.Get("servertag." + tag + ".true"), TernaryOption.Enabled, TextManager.Get("servertagdescription." + tag + ".true"));
|
||||
dropDown.AddItem(TextManager.Get("servertag." + tag + ".false"), TernaryOption.Disabled, TextManager.Get("servertagdescription." + tag + ".false"));
|
||||
dropDown.SelectItem(TernaryOption.Any);
|
||||
dropDown.OnSelected = (_, data) => {
|
||||
valueSetter((TernaryOption)data);
|
||||
FilterServers();
|
||||
return true;
|
||||
};
|
||||
|
||||
ternaryFilters.Add(tag, dropDown);
|
||||
}
|
||||
|
||||
private void CreateUI()
|
||||
{
|
||||
menu = new GUIFrame(new RectTransform(new Vector2(0.95f, 0.85f), GUI.Canvas, Anchor.Center) { MinSize = new Point(GameMain.GraphicsHeight, 0) });
|
||||
@@ -323,6 +376,7 @@ namespace Barotrauma
|
||||
};
|
||||
filterToggle.Children.ForEach(c => c.SpriteEffects = SpriteEffects.FlipHorizontally);
|
||||
|
||||
ternaryFilters = new Dictionary<string, GUIDropDown>();
|
||||
filterTickBoxes = new Dictionary<string, GUITickBox>();
|
||||
|
||||
filterSameVersion = new GUITickBox(new RectTransform(new Vector2(1.0f, elementHeight), filters.Content.RectTransform), TextManager.Get("FilterSameVersion"))
|
||||
@@ -382,40 +436,11 @@ namespace Barotrauma
|
||||
CanBeFocused = false
|
||||
};
|
||||
|
||||
filterKarma = new GUITickBox(new RectTransform(new Vector2(1.0f, elementHeight), filters.Content.RectTransform), TextManager.Get("servertag.karma.true"))
|
||||
{
|
||||
UserData = TextManager.Get("servertag.karma.true"),
|
||||
OnSelected = (tickBox) => { FilterServers(); return true; }
|
||||
};
|
||||
filterTickBoxes.Add("servertag.karma", filterKarma);
|
||||
|
||||
filterTraitor = new GUITickBox(new RectTransform(new Vector2(1.0f, elementHeight), filters.Content.RectTransform), TextManager.Get("servertag.traitors.true"))
|
||||
{
|
||||
UserData = TextManager.Get("servertag.traitors.true"),
|
||||
OnSelected = (tickBox) => { FilterServers(); return true; }
|
||||
};
|
||||
filterTickBoxes.Add("servertag.traitors", filterTraitor);
|
||||
|
||||
filterFriendlyFire = new GUITickBox(new RectTransform(new Vector2(1.0f, elementHeight), filters.Content.RectTransform), TextManager.Get("servertag.friendlyfire.false"))
|
||||
{
|
||||
UserData = TextManager.Get("servertag.friendlyfire.false"),
|
||||
OnSelected = (tickBox) => { FilterServers(); return true; }
|
||||
};
|
||||
filterTickBoxes.Add("servertag.friendlyfire", filterFriendlyFire);
|
||||
|
||||
filterVoip = new GUITickBox(new RectTransform(new Vector2(1.0f, elementHeight), filters.Content.RectTransform), TextManager.Get("servertag.voip.false"))
|
||||
{
|
||||
UserData = TextManager.Get("servertag.voip.false"),
|
||||
OnSelected = (tickBox) => { FilterServers(); return true; }
|
||||
};
|
||||
filterTickBoxes.Add("servertag.voip", filterVoip);
|
||||
|
||||
filterModded = new GUITickBox(new RectTransform(new Vector2(1.0f, elementHeight), filters.Content.RectTransform), TextManager.Get("servertag.modded.true"))
|
||||
{
|
||||
UserData = TextManager.Get("servertag.modded.true"),
|
||||
OnSelected = (tickBox) => { FilterServers(); return true; }
|
||||
};
|
||||
filterTickBoxes.Add("servertag.modded", filterModded);
|
||||
AddTernaryFilter(filters.Content.RectTransform, elementHeight, "karma", (value) => { filterKarmaValue = value; });
|
||||
AddTernaryFilter(filters.Content.RectTransform, elementHeight, "traitors", (value) => { filterTraitorValue = value; });
|
||||
AddTernaryFilter(filters.Content.RectTransform, elementHeight, "friendlyfire", (value) => { filterFriendlyFireValue = value; });
|
||||
AddTernaryFilter(filters.Content.RectTransform, elementHeight, "voip", (value) => { filterVoipValue = value; });
|
||||
AddTernaryFilter(filters.Content.RectTransform, elementHeight, "modded", (value) => { filterModdedValue = value; });
|
||||
|
||||
// Play Style Selection
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), filters.Content.RectTransform), TextManager.Get("ServerSettingsPlayStyle"), font: GUI.SubHeadingFont)
|
||||
@@ -462,7 +487,10 @@ namespace Barotrauma
|
||||
filterTickBoxes.ForEach(t => t.Value.Text = t.Value.UserData as string);
|
||||
gameModeTickBoxes.ForEach(tb => tb.Value.Text = tb.Value.ToolTip);
|
||||
playStyleTickBoxes.ForEach(tb => tb.Value.Text = tb.Value.ToolTip);
|
||||
GUITextBlock.AutoScaleAndNormalize(filterTickBoxes.Values.Select(tb => tb.TextBlock), defaultScale: 1.0f);
|
||||
GUITextBlock.AutoScaleAndNormalize(
|
||||
filterTickBoxes.Values.Select(tb => tb.TextBlock)
|
||||
.Concat(ternaryFilters.Values.Select(dd => dd.Parent.GetChild<GUITextBlock>())),
|
||||
defaultScale: 1.0f);
|
||||
if (filterTickBoxes.Values.First().TextBlock.TextScale < 0.8f)
|
||||
{
|
||||
filterTickBoxes.ForEach(t => t.Value.TextBlock.TextScale = 1.0f);
|
||||
@@ -751,28 +779,19 @@ namespace Barotrauma
|
||||
doc.SaveSafe(file);
|
||||
}
|
||||
|
||||
public ServerInfo UpdateServerInfoWithServerSettings(object endpoint, ServerSettings serverSettings)
|
||||
public ServerInfo UpdateServerInfoWithServerSettings(NetworkConnection endpoint, ServerSettings serverSettings)
|
||||
{
|
||||
UInt64 steamId = 0;
|
||||
string ip = ""; string port = "";
|
||||
if (endpoint is UInt64 id) { steamId = id; }
|
||||
else if (endpoint is string strEndpoint)
|
||||
if (endpoint is SteamP2PConnection steamP2PConnection) { steamId = steamP2PConnection.SteamID; }
|
||||
else if (endpoint is LidgrenConnection lidgrenConnection)
|
||||
{
|
||||
string[] address = strEndpoint.Split(':');
|
||||
if (address.Length == 1)
|
||||
{
|
||||
ip = strEndpoint;
|
||||
port = NetConfig.DefaultPort.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
ip = string.Join(":", address.Take(address.Length - 1));
|
||||
port = address[address.Length - 1];
|
||||
}
|
||||
ip = lidgrenConnection.IPString;
|
||||
port = lidgrenConnection.Port.ToString();
|
||||
}
|
||||
|
||||
bool isInfoNew = false;
|
||||
ServerInfo info = serverList.Content.FindChild(d => (d.UserData is ServerInfo serverInfo) && serverInfo != null &&
|
||||
ServerInfo info = serverList.Content.FindChild(d => (d.UserData is ServerInfo serverInfo) &&
|
||||
(steamId != 0 ? steamId == serverInfo.OwnerID : (ip == serverInfo.IP && port == serverInfo.Port)))?.UserData as ServerInfo;
|
||||
if (info == null)
|
||||
{
|
||||
@@ -821,7 +840,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
info.Recent = true;
|
||||
ServerInfo existingInfo = recentServers.Find(serverInfo => info.OwnerID == serverInfo.OwnerID && (info.OwnerID != 0 ? true : (info.IP == serverInfo.IP && info.Port == serverInfo.Port)));
|
||||
ServerInfo existingInfo = recentServers.Find(info.MatchesByEndpoint);
|
||||
if (existingInfo == null)
|
||||
{
|
||||
recentServers.Add(info);
|
||||
@@ -835,10 +854,15 @@ namespace Barotrauma
|
||||
WriteServerMemToFile(recentServersFile, recentServers);
|
||||
}
|
||||
|
||||
public bool IsFavorite(ServerInfo info)
|
||||
{
|
||||
return favoriteServers.Any(info.MatchesByEndpoint);
|
||||
}
|
||||
|
||||
public void AddToFavoriteServers(ServerInfo info)
|
||||
{
|
||||
info.Favorite = true;
|
||||
ServerInfo existingInfo = favoriteServers.Find(serverInfo => info.OwnerID == serverInfo.OwnerID && (info.OwnerID != 0 ? true : (info.IP == serverInfo.IP && info.Port == serverInfo.Port)));
|
||||
ServerInfo existingInfo = favoriteServers.Find(info.MatchesByEndpoint);
|
||||
if (existingInfo == null)
|
||||
{
|
||||
favoriteServers.Add(info);
|
||||
@@ -855,7 +879,7 @@ namespace Barotrauma
|
||||
public void RemoveFromFavoriteServers(ServerInfo info)
|
||||
{
|
||||
info.Favorite = false;
|
||||
ServerInfo existingInfo = favoriteServers.Find(serverInfo => info.OwnerID == serverInfo.OwnerID && (info.OwnerID != 0 ? true : (info.IP == serverInfo.IP && info.Port == serverInfo.Port)));
|
||||
ServerInfo existingInfo = favoriteServers.Find(info.MatchesByEndpoint);
|
||||
if (existingInfo != null)
|
||||
{
|
||||
favoriteServers.Remove(existingInfo);
|
||||
@@ -1076,9 +1100,15 @@ namespace Barotrauma
|
||||
else
|
||||
{
|
||||
bool incompatible =
|
||||
(!serverInfo.ContentPackageHashes.Any() && serverInfo.ContentPackagesMatch()) ||
|
||||
(serverInfo.ContentPackageHashes.Any() && !serverInfo.ContentPackagesMatch()) ||
|
||||
(remoteVersion != null && !NetworkMember.IsCompatible(GameMain.Version, remoteVersion));
|
||||
|
||||
var karmaFilterPassed = filterKarmaValue == TernaryOption.Any|| (filterKarmaValue == TernaryOption.Enabled) == serverInfo.KarmaEnabled;
|
||||
var friendlyFireFilterPassed = filterFriendlyFireValue == TernaryOption.Any || (filterFriendlyFireValue == TernaryOption.Enabled) == serverInfo.FriendlyFireEnabled;
|
||||
var traitorsFilterPassed = filterTraitorValue == TernaryOption.Any || (filterTraitorValue == TernaryOption.Enabled) == (serverInfo.TraitorsEnabled == YesNoMaybe.Yes || serverInfo.TraitorsEnabled == YesNoMaybe.Maybe);
|
||||
var voipFilterPassed = filterVoipValue == TernaryOption.Any || (filterVoipValue == TernaryOption.Enabled) == serverInfo.VoipEnabled;
|
||||
var moddedFilterPassed = filterModdedValue == TernaryOption.Any || (filterModdedValue == TernaryOption.Enabled) == serverInfo.GetPlayStyleTags().Any(t => t.Contains("modded.true"));
|
||||
|
||||
child.Visible =
|
||||
serverInfo.OwnerVerified &&
|
||||
serverInfo.ServerName.Contains(searchBox.Text, StringComparison.OrdinalIgnoreCase) &&
|
||||
@@ -1089,11 +1119,11 @@ namespace Barotrauma
|
||||
(!filterEmpty.Selected || serverInfo.PlayerCount > 0) &&
|
||||
(!filterWhitelisted.Selected || serverInfo.UsingWhiteList == true) &&
|
||||
(!filterOffensive.Selected || !ForbiddenWordFilter.IsForbidden(serverInfo.ServerName)) &&
|
||||
(!filterKarma.Selected || serverInfo.KarmaEnabled == true) &&
|
||||
(!filterFriendlyFire.Selected || serverInfo.FriendlyFireEnabled == false) &&
|
||||
(!filterTraitor.Selected || serverInfo.TraitorsEnabled == YesNoMaybe.Yes || serverInfo.TraitorsEnabled == YesNoMaybe.Maybe) &&
|
||||
(!filterVoip.Selected || serverInfo.VoipEnabled == false) &&
|
||||
(!filterModded.Selected || serverInfo.GetPlayStyleTags().Any(t => t.Contains("modded.true"))) &&
|
||||
karmaFilterPassed &&
|
||||
friendlyFireFilterPassed &&
|
||||
traitorsFilterPassed &&
|
||||
voipFilterPassed &&
|
||||
moddedFilterPassed &&
|
||||
((selectedTab == ServerListTab.All && (serverInfo.LobbyID != 0 || !string.IsNullOrWhiteSpace(serverInfo.Port))) ||
|
||||
(selectedTab == ServerListTab.Recent && serverInfo.Recent) ||
|
||||
(selectedTab == ServerListTab.Favorites && serverInfo.Favorite));
|
||||
@@ -1224,8 +1254,7 @@ namespace Barotrauma
|
||||
};
|
||||
|
||||
var serverFrame = serverList.Content.FindChild(d => (d.UserData is ServerInfo info) &&
|
||||
info.OwnerID == serverInfo.OwnerID &&
|
||||
(serverInfo.OwnerID != 0 ? true : (info.IP == serverInfo.IP && info.Port == serverInfo.Port)));
|
||||
info.MatchesByEndpoint(serverInfo));
|
||||
|
||||
if (serverFrame != null)
|
||||
{
|
||||
@@ -2334,6 +2363,10 @@ namespace Barotrauma
|
||||
{
|
||||
element.Add(new XAttribute(filterBox.Key, filterBox.Value.Selected.ToString()));
|
||||
}
|
||||
foreach (KeyValuePair<string, GUIDropDown> ternaryFilter in ternaryFilters)
|
||||
{
|
||||
element.Add(new XAttribute(ternaryFilter.Key, ternaryFilter.Value.SelectedData.ToString()));
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadServerFilters(XElement element)
|
||||
@@ -2344,6 +2377,15 @@ namespace Barotrauma
|
||||
{
|
||||
filterBox.Value.Selected = element.GetAttributeBool(filterBox.Key, filterBox.Value.Selected);
|
||||
}
|
||||
foreach (KeyValuePair<string, GUIDropDown> ternaryFilter in ternaryFilters)
|
||||
{
|
||||
string valueStr = element.GetAttributeString(ternaryFilter.Key, "");
|
||||
TernaryOption ternaryOption = (TernaryOption)ternaryFilter.Value.SelectedData;
|
||||
Enum.TryParse<TernaryOption>(valueStr, true, out ternaryOption);
|
||||
|
||||
var child = ternaryFilter.Value.ListBox.Content.GetChildByUserData(ternaryOption);
|
||||
ternaryFilter.Value.Select(ternaryFilter.Value.ListBox.Content.GetChildIndex(child));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -410,9 +410,9 @@ namespace Barotrauma
|
||||
if (sub.HasTag(SubmarineTag.HideInMenus)) { continue; }
|
||||
string subPath = Path.GetFullPath(sub.FilePath);
|
||||
|
||||
//ignore subs that are part of the vanilla content package
|
||||
//ignore files that are part of the vanilla content package
|
||||
if (GameMain.VanillaContent != null &&
|
||||
GameMain.VanillaContent.GetFilesOfType(ContentType.Submarine).Any(s => Path.GetFullPath(s) == subPath))
|
||||
GameMain.VanillaContent.Files.Any(s => Path.GetFullPath(s.Path) == subPath))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user