v1.5.7.0 (Summer Update)
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using Barotrauma.Abilities;
|
||||
using Barotrauma.Networking;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -43,13 +45,19 @@ namespace Barotrauma
|
||||
private GUIButton crewListButton, commandButton, tabMenuButton;
|
||||
private GUIImage talentPointNotification;
|
||||
|
||||
private GUIComponent respawnInfoFrame, respawnButtonContainer;
|
||||
private GUIComponent deathChoiceInfoFrame, deathChoiceButtonContainer;
|
||||
private GUITextBlock respawnInfoText;
|
||||
private GUITickBox respawnTickBox;
|
||||
private GUITickBox deathChoiceTickBox;
|
||||
private GUIButton takeOverBotButton;
|
||||
private GUIButton hrManagerButton;
|
||||
public DeathPrompt DeathPrompt;
|
||||
|
||||
private GUIImage eventLogNotification;
|
||||
|
||||
private Point prevTopLeftButtonsResolution;
|
||||
|
||||
public bool AllowHrManagerBotTakeover => GameMain.NetworkMember?.ServerSettings is { RespawnMode: RespawnMode.Permadeath, IronmanMode: false }
|
||||
&& Level.IsLoadedFriendlyOutpost;
|
||||
|
||||
private void CreateTopLeftButtons()
|
||||
{
|
||||
@@ -96,30 +104,63 @@ namespace Barotrauma
|
||||
|
||||
talentPointNotification = CreateNotificationIcon(tabMenuButton);
|
||||
eventLogNotification = CreateNotificationIcon(tabMenuButton);
|
||||
|
||||
respawnInfoFrame = new GUIFrame(new RectTransform(new Vector2(0.5f, 1.0f), parent: topLeftButtonGroup.RectTransform)
|
||||
{ MaxSize = new Point(HUDLayoutSettings.ButtonAreaTop.Width / 3, int.MaxValue) }, style: null)
|
||||
|
||||
// The visibility of the following contents of deathChoiceInfoFrame is controlled by SetRespawnInfo()
|
||||
|
||||
deathChoiceInfoFrame = new GUIFrame(new RectTransform(new Vector2(0.5f, 1.0f), parent: topLeftButtonGroup.RectTransform)
|
||||
{ MaxSize = new Point(HUDLayoutSettings.ButtonAreaTop.Width / 3, int.MaxValue) }, style: null)
|
||||
{
|
||||
Visible = false
|
||||
};
|
||||
respawnInfoText = new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), respawnInfoFrame.RectTransform), "", wrap: true);
|
||||
respawnButtonContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 1.0f), respawnInfoFrame.RectTransform, Anchor.CenterRight), isHorizontal: true, childAnchor: Anchor.CenterLeft)
|
||||
respawnInfoText = new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), deathChoiceInfoFrame.RectTransform), "", wrap: true);
|
||||
deathChoiceButtonContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 1.0f), deathChoiceInfoFrame.RectTransform, Anchor.CenterRight), isHorizontal: true, childAnchor: Anchor.CenterLeft)
|
||||
{
|
||||
AbsoluteSpacing = HUDLayoutSettings.Padding,
|
||||
Stretch = true,
|
||||
Visible = false
|
||||
};
|
||||
respawnTickBox = new GUITickBox(new RectTransform(Vector2.One * 0.9f, respawnButtonContainer.RectTransform, Anchor.Center), TextManager.Get("respawnquestionpromptrespawn"))
|
||||
|
||||
takeOverBotButton = new GUIButton(new RectTransform(Vector2.One * 0.9f, deathChoiceButtonContainer.RectTransform, Anchor.Center),
|
||||
TextManager.Get("takeoverbotquestionprompttakeoverbot"), style: "GUIButtonSmall")
|
||||
{
|
||||
ToolTip = TextManager.GetWithVariable(
|
||||
"respawnquestionprompt", "[percentage]",
|
||||
(Math.Round(Networking.RespawnManager.SkillLossPercentageOnImmediateRespawn).ToString())),
|
||||
OnSelected = (tickbox) =>
|
||||
OnClicked = (btn, userdata) =>
|
||||
{
|
||||
GameMain.Client?.SendRespawnPromptResponse(waitForNextRoundRespawn: !tickbox.Selected);
|
||||
DeathPrompt.CreateTakeOverBotPanel();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
takeOverBotButton.TextBlock.AutoScaleHorizontal = true;
|
||||
|
||||
hrManagerButton = new GUIButton(new RectTransform(Vector2.One * 0.9f, deathChoiceButtonContainer.RectTransform, Anchor.Center),
|
||||
TextManager.Get("npctitle.hrmanager"), style: "GUIButtonSmall")
|
||||
{
|
||||
OnClicked = (btn, userdata) =>
|
||||
{
|
||||
if (GameMain.GameSession?.Campaign is { } campaign)
|
||||
{
|
||||
campaign.ShowCampaignUI = true;
|
||||
campaign.CampaignUI?.SelectTab(CampaignMode.InteractionType.Crew);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
hrManagerButton.TextBlock.AutoScaleHorizontal = true;
|
||||
|
||||
var questionText =
|
||||
TextManager.GetWithVariable(
|
||||
"respawnquestionprompt", "[percentage]",
|
||||
((int)Math.Round(RespawnManager.SkillLossPercentageOnImmediateRespawn)).ToString());
|
||||
deathChoiceTickBox = new GUITickBox(new RectTransform(Vector2.One * 0.9f, deathChoiceButtonContainer.RectTransform, Anchor.Center),
|
||||
TextManager.Get("respawnquestionpromptrespawn"))
|
||||
{
|
||||
ToolTip = questionText,
|
||||
OnSelected = (tickbox) =>
|
||||
{
|
||||
GameMain.Client?.SendRespawnPromptResponse(waitForNextRoundRespawn: !tickbox.Selected);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
prevTopLeftButtonsResolution = new Point(GameMain.GraphicsWidth, GameMain.GraphicsHeight);
|
||||
}
|
||||
|
||||
@@ -150,6 +191,8 @@ namespace Barotrauma
|
||||
GameMain.NetLobbyScreen.CharacterAppearanceCustomizationMenu?.AddToGUIUpdateList();
|
||||
GameMain.NetLobbyScreen?.JobSelectionFrame?.AddToGUIUpdateList();
|
||||
}
|
||||
|
||||
DeathPrompt?.AddToGUIUpdateList();
|
||||
}
|
||||
|
||||
public static GUIImage CreateNotificationIcon(GUIComponent parent, bool offset = true)
|
||||
@@ -230,16 +273,67 @@ namespace Barotrauma
|
||||
HintManager.Update();
|
||||
ObjectiveManager.VideoPlayer.Update();
|
||||
}
|
||||
|
||||
public void SetRespawnInfo(bool visible, string text, Color textColor, bool buttonsVisible, bool waitForNextRoundRespawn)
|
||||
|
||||
/// <summary>
|
||||
/// This method controls the content and visibility logic of the respawn-related GUI elements at the top left of the game screen.
|
||||
/// </summary>
|
||||
/// <param name="waitForNextRoundRespawn">Has the player chosen to wait until next round</param>
|
||||
/// <param name="hideButtons">Hide the respawn buttons even if they would otherwise be visible</param>
|
||||
public void SetRespawnInfo(string text, Color textColor, bool waitForNextRoundRespawn, bool hideButtons = false)
|
||||
{
|
||||
if (topLeftButtonGroup == null) { return; }
|
||||
respawnInfoFrame.Visible = visible;
|
||||
if (!visible) { return; }
|
||||
|
||||
bool permadeathMode = GameMain.NetworkMember?.ServerSettings is { RespawnMode: RespawnMode.Permadeath };
|
||||
bool ironmanMode = GameMain.NetworkMember is { ServerSettings: { RespawnMode: RespawnMode.Permadeath, IronmanMode: true } };
|
||||
|
||||
bool hasRespawnOptions;
|
||||
if (permadeathMode)
|
||||
{
|
||||
// In permadeath mode you can (in ironman, must) always at least wait, and possibly buy a new character from HR or take control of a bot
|
||||
hasRespawnOptions = !ironmanMode &&
|
||||
GameMain.Client is GameClient client && (client.CharacterInfo == null || client.CharacterInfo.PermanentlyDead);
|
||||
}
|
||||
else // "classic" respawn modes
|
||||
{
|
||||
//can choose between midround respawning with a penalty or waiting
|
||||
//if we're in a non-outpost level, and either don't have an existing character or have already spawned during the round
|
||||
//(otherwise, e.g. when joining a campaign in which we have an existing character, we can respawn mid-round "for free" and there's no reason to make a choice)
|
||||
hasRespawnOptions = Level.Loaded?.Type != LevelData.LevelType.Outpost &&
|
||||
(GameMain.Client is GameClient client && (client.CharacterInfo == null || client.HasSpawned));
|
||||
}
|
||||
|
||||
// Are the death choice elements shown at all, at least with the text?
|
||||
deathChoiceInfoFrame.Visible = !text.IsNullOrEmpty() || hasRespawnOptions;
|
||||
if (!deathChoiceInfoFrame.Visible) { return; }
|
||||
respawnInfoText.Text = text;
|
||||
respawnInfoText.TextColor = textColor;
|
||||
respawnButtonContainer.Visible = buttonsVisible;
|
||||
respawnTickBox.Selected = !waitForNextRoundRespawn;
|
||||
|
||||
// Determine if we even bother considering showing the buttons
|
||||
if (GameMain.GameSession.GameMode is not CampaignMode || Character.Controlled != null)
|
||||
{
|
||||
// Disable the button container in case it was left visible earlier
|
||||
deathChoiceButtonContainer.Visible = false;
|
||||
return;
|
||||
}
|
||||
|
||||
deathChoiceButtonContainer.Visible = hasRespawnOptions && !hideButtons;
|
||||
if (deathChoiceButtonContainer.Visible)
|
||||
{
|
||||
hrManagerButton.Visible = AllowHrManagerBotTakeover;
|
||||
|
||||
if (permadeathMode && ironmanMode)
|
||||
{
|
||||
takeOverBotButton.Visible = false;
|
||||
deathChoiceTickBox.Visible = false;
|
||||
deathChoiceTickBox.Selected = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
takeOverBotButton.Visible = permadeathMode && GameMain.NetworkMember?.ServerSettings is { AllowBotTakeoverOnPermadeath: true };
|
||||
deathChoiceTickBox.Visible = !permadeathMode;
|
||||
deathChoiceTickBox.Selected = !waitForNextRoundRespawn;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch)
|
||||
|
||||
Reference in New Issue
Block a user