3 using Microsoft.Xna.Framework;
4 using Microsoft.Xna.Framework.Graphics;
9 partial class GameSession
33 HintManager.OnShowTabMenu();
45 private GUIButton crewListButton, commandButton, tabMenuButton;
46 private GUIImage talentPointNotification;
48 private GUIComponent deathChoiceInfoFrame, deathChoiceButtonContainer;
55 private GUIImage eventLogNotification;
57 private Point prevTopLeftButtonsResolution;
62 private void CreateTopLeftButtons()
64 if (topLeftButtonGroup !=
null)
67 topLeftButtonGroup =
null;
68 crewListButton = commandButton = tabMenuButton =
null;
70 topLeftButtonGroup =
new GUILayoutGroup(HUDLayoutSettings.ToRectTransform(HUDLayoutSettings.ButtonAreaTop, GUI.Canvas), isHorizontal:
true, childAnchor:
Anchor.CenterLeft)
72 AbsoluteSpacing = HUDLayoutSettings.Padding,
75 int buttonHeight = GUI.IntScale(40);
76 Vector2 buttonSpriteSize = GUIStyle.GetComponentStyle(
"CrewListToggleButton").GetDefaultSprite().size;
77 int buttonWidth = (int)((buttonHeight / buttonSpriteSize.Y) * buttonSpriteSize.X);
78 Point buttonSize =
new Point(buttonWidth, buttonHeight);
79 crewListButton =
new GUIButton(
new RectTransform(buttonSize, parent: topLeftButtonGroup.
RectTransform), style:
"CrewListToggleButton")
81 ToolTip = TextManager.GetWithVariable(
"hudbutton.crewlist",
"[key]", GameSettings.CurrentConfig.KeyMap.KeyBindText(
InputType.CrewOrders)),
82 OnClicked = (GUIButton btn,
object userdata) =>
89 commandButton =
new GUIButton(
new RectTransform(buttonSize, parent: topLeftButtonGroup.
RectTransform), style:
"CommandButton")
91 ToolTip = TextManager.GetWithVariable(
"hudbutton.commandinterface",
"[key]", GameSettings.CurrentConfig.KeyMap.KeyBindText(
InputType.Command)),
92 OnClicked = (button, userData) =>
99 tabMenuButton =
new GUIButton(
new RectTransform(buttonSize, parent: topLeftButtonGroup.
RectTransform), style:
"TabMenuButton")
101 ToolTip = TextManager.GetWithVariable(
"hudbutton.tabmenu",
"[key]", GameSettings.CurrentConfig.KeyMap.KeyBindText(
InputType.InfoTab)),
110 deathChoiceInfoFrame =
new GUIFrame(
new RectTransform(
new Vector2(0.5f, 1.0f), parent: topLeftButtonGroup.
RectTransform)
111 { MaxSize = new Point(HUDLayoutSettings.ButtonAreaTop.Width / 3, int.MaxValue) }, style:
null)
115 respawnInfoText =
new GUITextBlock(
new RectTransform(
new Vector2(0.5f, 1.0f), deathChoiceInfoFrame.
RectTransform),
"", wrap:
true);
116 deathChoiceButtonContainer =
new GUILayoutGroup(
new RectTransform(
new Vector2(0.5f, 1.0f), deathChoiceInfoFrame.
RectTransform,
Anchor.CenterRight), isHorizontal:
true, childAnchor:
Anchor.CenterLeft)
118 AbsoluteSpacing = HUDLayoutSettings.Padding,
123 takeOverBotButton =
new GUIButton(
new RectTransform(Vector2.One * 0.9f, deathChoiceButtonContainer.
RectTransform,
Anchor.Center),
124 TextManager.Get(
"takeoverbotquestionprompttakeoverbot"), style:
"GUIButtonSmall")
126 OnClicked = (btn, userdata) =>
134 hrManagerButton =
new GUIButton(
new RectTransform(Vector2.One * 0.9f, deathChoiceButtonContainer.
RectTransform,
Anchor.Center),
135 TextManager.Get(
"npctitle.hrmanager"), style:
"GUIButtonSmall")
137 OnClicked = (btn, userdata) =>
139 if (GameMain.GameSession?.Campaign is { } campaign)
141 campaign.ShowCampaignUI =
true;
142 campaign.CampaignUI?.SelectTab(CampaignMode.InteractionType.Crew);
150 TextManager.GetWithVariable(
151 "respawnquestionprompt",
"[percentage]",
153 deathChoiceTickBox =
new GUITickBox(
new RectTransform(Vector2.One * 0.9f, deathChoiceButtonContainer.
RectTransform,
Anchor.Center),
154 TextManager.Get(
"respawnquestionpromptrespawn"))
156 ToolTip = questionText,
157 OnSelected = (tickbox) =>
159 GameMain.Client?.SendRespawnPromptResponse(waitForNextRoundRespawn: !tickbox.Selected);
164 prevTopLeftButtonsResolution =
new Point(GameMain.GraphicsWidth, GameMain.GraphicsHeight);
169 if (GUI.DisableHUD) {
return; }
172 ObjectiveManager.AddToGUIUpdateList();
174 if ((
GameMode is not
CampaignMode campaign || (!campaign.ForceMapUI && !campaign.ShowCampaignUI)) &&
175 !CoroutineManager.IsCoroutineRunning(
"LevelTransition") && !CoroutineManager.IsCoroutineRunning(
"SubmarineTransition"))
177 if (topLeftButtonGroup ==
null ||
180 CreateTopLeftButtons();
185 tabMenuButton.
Selected = IsTabMenuOpen;
195 DeathPrompt?.AddToGUIUpdateList();
215 if (eventLogNotification ==
null) {
return; }
216 if (!eventLogNotification.
Visible && enabled)
218 eventLogNotification.
Pulsate(Vector2.One, Vector2.One * 2, 1.0f);
220 eventLogNotification.
Visible = enabled;
225 if (indicator ==
null) {
return; }
233 CreateTopLeftButtons();
237 partial
void UpdateProjSpecific(
float deltaTime)
239 if (GUI.DisableHUD) {
return; }
243 if (PlayerInput.KeyHit(
InputType.InfoTab) && !(GUI.KeyboardDispatcher.Subscriber is GUITextBox))
250 tabMenu.
Update(deltaTime);
251 if ((PlayerInput.KeyHit(
InputType.InfoTab) || PlayerInput.KeyHit(Microsoft.Xna.Framework.Input.Keys.Escape)) &&
252 !(GUI.KeyboardDispatcher.Subscriber is GUITextBox))
258 UpdateTalentNotificationIndicator(talentPointNotification);
260 if (GameMain.NetworkMember !=
null)
262 GameMain.NetLobbyScreen?.CharacterAppearanceCustomizationMenu?.Update();
263 if (GameMain.NetLobbyScreen?.JobSelectionFrame !=
null)
265 if (GameMain.NetLobbyScreen.JobSelectionFrame !=
null && PlayerInput.PrimaryMouseButtonDown() && !GUI.IsMouseOn(GameMain.NetLobbyScreen.JobSelectionFrame))
267 GameMain.NetLobbyScreen.JobList.Deselect();
268 GameMain.NetLobbyScreen.JobSelectionFrame.Visible =
false;
273 HintManager.Update();
274 ObjectiveManager.VideoPlayer.Update();
282 public void SetRespawnInfo(
string text, Color textColor,
bool waitForNextRoundRespawn,
bool hideButtons =
false)
284 if (topLeftButtonGroup ==
null) {
return; }
289 bool hasRespawnOptions;
293 hasRespawnOptions = !ironmanMode &&
306 deathChoiceInfoFrame.
Visible = !text.IsNullOrEmpty() || hasRespawnOptions;
307 if (!deathChoiceInfoFrame.
Visible) {
return; }
308 respawnInfoText.
Text = text;
315 deathChoiceButtonContainer.
Visible =
false;
319 deathChoiceButtonContainer.
Visible = hasRespawnOptions && !hideButtons;
320 if (deathChoiceButtonContainer.
Visible)
322 hrManagerButton.
Visible = AllowHrManagerBotTakeover;
324 if (permadeathMode && ironmanMode)
326 takeOverBotButton.
Visible =
false;
327 deathChoiceTickBox.
Visible =
false;
328 deathChoiceTickBox.
Selected =
false;
333 deathChoiceTickBox.
Visible = !permadeathMode;
334 deathChoiceTickBox.
Selected = !waitForNextRoundRespawn;
339 public void Draw(SpriteBatch spriteBatch)
static Character? Controlled
bool HasUnlockedAllTalents()
int GetAvailableTalentPoints()
Triggers a "conversation popup" with text and support for different branching options.
Responsible for keeping track of the characters in the player crew, saving and loading their orders,...
static bool? IsCommandInterfaceOpen
bool IsCrewMenuOpen
This property stores the preference in settings. Don't use for automatic logic. Use AutoShowCrewList(...
static bool? CanIssueOrders
void Pulsate(Vector2 startScale, Vector2 endScale, float duration)
virtual void AddToGUIUpdateList(bool ignoreChildren=false, int order=0)
RectTransform RectTransform
bool AutoScaleHorizontal
When enabled, the text is automatically scaled down to fit the textblock horizontally.
static GameSession?? GameSession
static NetLobbyScreen NetLobbyScreen
static int GraphicsHeight
static NetworkMember NetworkMember
virtual void Draw(SpriteBatch spriteBatch)
virtual void AddToGUIUpdateList()
virtual void HUDScaleChanged()
void SetRespawnInfo(string text, Color textColor, bool waitForNextRoundRespawn, bool hideButtons=false)
This method controls the content and visibility logic of the respawn-related GUI elements at the top ...
static TabMenu TabMenuInstance
static void UpdateTalentNotificationIndicator(GUIImage indicator)
bool AllowHrManagerBotTakeover
void AddToGUIUpdateList()
static GUIImage CreateNotificationIcon(GUIComponent parent, bool offset=true)
static bool IsTabMenuOpen
void Draw(SpriteBatch spriteBatch)
void EnableEventLogNotificationIcon(bool enabled)
static bool IsLoadedFriendlyOutpost
Is there a loaded level set, and is it a friendly outpost (FriendlyNPC or Team1). Does not take reput...
static GUIButton JobInfoFrame
CharacterInfo.AppearanceCustomizationMenu CharacterAppearanceCustomizationMenu
GUIFrame JobSelectionFrame
static float SkillLossPercentageOnImmediateRespawn
How much more the skills drop towards the job's default skill levels when dying, in addition to Skill...