(8d282f4cc) Hide the crew area and the chat box when using a controller (= aiming with a turret or similar item).
This commit is contained in:
@@ -26,7 +26,21 @@ namespace Barotrauma
|
|||||||
private bool isSinglePlayer;
|
private bool isSinglePlayer;
|
||||||
public bool IsSinglePlayer => isSinglePlayer;
|
public bool IsSinglePlayer => isSinglePlayer;
|
||||||
|
|
||||||
private bool toggleOpen = true;
|
private bool _toggleOpen = true;
|
||||||
|
public bool ToggleOpen
|
||||||
|
{
|
||||||
|
get { return _toggleOpen; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_toggleOpen == value) { return; }
|
||||||
|
_toggleOpen = value;
|
||||||
|
foreach (GUIComponent child in ToggleButton.Children)
|
||||||
|
{
|
||||||
|
child.SpriteEffects = _toggleOpen == (HUDLayoutSettings.ChatBoxAlignment == Alignment.Right) ?
|
||||||
|
SpriteEffects.FlipHorizontally : SpriteEffects.None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
private float openState;
|
private float openState;
|
||||||
|
|
||||||
private float prevUIScale;
|
private float prevUIScale;
|
||||||
@@ -81,12 +95,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
toggleButton.OnClicked += (GUIButton btn, object userdata) =>
|
toggleButton.OnClicked += (GUIButton btn, object userdata) =>
|
||||||
{
|
{
|
||||||
toggleOpen = !toggleOpen;
|
ToggleOpen = !ToggleOpen;
|
||||||
foreach (GUIComponent child in btn.Children)
|
|
||||||
{
|
|
||||||
child.SpriteEffects = toggleOpen == (HUDLayoutSettings.ChatBoxAlignment == Alignment.Right) ?
|
|
||||||
SpriteEffects.FlipHorizontally : SpriteEffects.None;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -228,7 +237,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
chatBox.UpdateScrollBarSize();
|
chatBox.UpdateScrollBarSize();
|
||||||
|
|
||||||
if (!toggleOpen)
|
if (!ToggleOpen)
|
||||||
{
|
{
|
||||||
var popupMsg = new GUIFrame(new RectTransform(Vector2.One, guiFrame.RectTransform), style: "GUIToolTip")
|
var popupMsg = new GUIFrame(new RectTransform(Vector2.One, guiFrame.RectTransform), style: "GUIToolTip")
|
||||||
{
|
{
|
||||||
@@ -315,7 +324,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (toggleOpen || (inputBox != null && inputBox.Selected))
|
if (ToggleOpen || (inputBox != null && inputBox.Selected))
|
||||||
{
|
{
|
||||||
openState += deltaTime * 5.0f;
|
openState += deltaTime * 5.0f;
|
||||||
//delete all popup messages when the chatbox is open
|
//delete all popup messages when the chatbox is open
|
||||||
|
|||||||
@@ -41,7 +41,10 @@ namespace Barotrauma
|
|||||||
private bool toggleCrewAreaOpen = true;
|
private bool toggleCrewAreaOpen = true;
|
||||||
private int characterInfoWidth;
|
private int characterInfoWidth;
|
||||||
|
|
||||||
private ChatBox chatBox;
|
/// <summary>
|
||||||
|
/// Present only in single player games. In multiplayer. The chatbox is found from GameSession.Client.
|
||||||
|
/// </summary>
|
||||||
|
public ChatBox ChatBox { get; private set; }
|
||||||
|
|
||||||
private float prevUIScale;
|
private float prevUIScale;
|
||||||
|
|
||||||
@@ -50,7 +53,15 @@ namespace Barotrauma
|
|||||||
public bool ToggleCrewAreaOpen
|
public bool ToggleCrewAreaOpen
|
||||||
{
|
{
|
||||||
get { return toggleCrewAreaOpen; }
|
get { return toggleCrewAreaOpen; }
|
||||||
set { toggleCrewAreaOpen = value; }
|
set
|
||||||
|
{
|
||||||
|
if (toggleCrewAreaOpen == value) { return; }
|
||||||
|
toggleCrewAreaOpen = value;
|
||||||
|
foreach (GUIComponent child in toggleCrewButton.Children)
|
||||||
|
{
|
||||||
|
child.SpriteEffects = toggleCrewAreaOpen ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -93,11 +104,7 @@ namespace Barotrauma
|
|||||||
"", style: "UIToggleButton");
|
"", style: "UIToggleButton");
|
||||||
toggleCrewButton.OnClicked += (GUIButton btn, object userdata) =>
|
toggleCrewButton.OnClicked += (GUIButton btn, object userdata) =>
|
||||||
{
|
{
|
||||||
toggleCrewAreaOpen = !toggleCrewAreaOpen;
|
ToggleCrewAreaOpen = !ToggleCrewAreaOpen;
|
||||||
foreach (GUIComponent child in btn.Children)
|
|
||||||
{
|
|
||||||
child.SpriteEffects = toggleCrewAreaOpen ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -125,7 +132,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (isSinglePlayer)
|
if (isSinglePlayer)
|
||||||
{
|
{
|
||||||
chatBox = new ChatBox(guiFrame, isSinglePlayer: true)
|
ChatBox = new ChatBox(guiFrame, isSinglePlayer: true)
|
||||||
{
|
{
|
||||||
OnEnterMessage = (textbox, text) =>
|
OnEnterMessage = (textbox, text) =>
|
||||||
{
|
{
|
||||||
@@ -158,7 +165,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
chatBox.InputBox.OnTextChanged += chatBox.TypingChatMessage;
|
ChatBox.InputBox.OnTextChanged += ChatBox.TypingChatMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
var reports = Order.PrefabList.FindAll(o => o.TargetAllCharacters && o.SymbolSprite != null);
|
var reports = Order.PrefabList.FindAll(o => o.TargetAllCharacters && o.SymbolSprite != null);
|
||||||
@@ -646,7 +653,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(text)) { return; }
|
if (string.IsNullOrEmpty(text)) { return; }
|
||||||
|
|
||||||
chatBox.AddMessage(ChatMessage.Create(senderName, text, messageType, sender));
|
ChatBox.AddMessage(ChatMessage.Create(senderName, text, messageType, sender));
|
||||||
}
|
}
|
||||||
|
|
||||||
private WifiComponent GetHeadset(Character character, bool requireEquipped)
|
private WifiComponent GetHeadset(Character character, bool requireEquipped)
|
||||||
@@ -1056,24 +1063,24 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (GUI.DisableHUD || GUI.DisableUpperHUD) return;
|
if (GUI.DisableHUD || GUI.DisableUpperHUD) return;
|
||||||
if (chatBox != null)
|
if (ChatBox != null)
|
||||||
{
|
{
|
||||||
chatBox.Update(deltaTime);
|
ChatBox.Update(deltaTime);
|
||||||
chatBox.InputBox.Visible = Character.Controlled != null;
|
ChatBox.InputBox.Visible = Character.Controlled != null;
|
||||||
|
|
||||||
if (!DebugConsole.IsOpen && chatBox.InputBox.Visible)
|
if (!DebugConsole.IsOpen && ChatBox.InputBox.Visible)
|
||||||
{
|
{
|
||||||
if (PlayerInput.KeyHit(InputType.Chat) && !chatBox.InputBox.Selected)
|
if (PlayerInput.KeyHit(InputType.Chat) && !ChatBox.InputBox.Selected)
|
||||||
{
|
{
|
||||||
chatBox.GUIFrame.Flash(Color.DarkGreen, 0.5f);
|
ChatBox.GUIFrame.Flash(Color.DarkGreen, 0.5f);
|
||||||
chatBox.InputBox.Select();
|
ChatBox.InputBox.Select();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PlayerInput.KeyHit(InputType.RadioChat) && !chatBox.InputBox.Selected)
|
if (PlayerInput.KeyHit(InputType.RadioChat) && !ChatBox.InputBox.Selected)
|
||||||
{
|
{
|
||||||
chatBox.GUIFrame.Flash(Color.YellowGreen, 0.5f);
|
ChatBox.GUIFrame.Flash(Color.YellowGreen, 0.5f);
|
||||||
chatBox.InputBox.Select();
|
ChatBox.InputBox.Select();
|
||||||
chatBox.InputBox.Text = "r; ";
|
ChatBox.InputBox.Text = "r; ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1143,7 +1150,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
crewArea.RectTransform.AbsoluteOffset =
|
crewArea.RectTransform.AbsoluteOffset =
|
||||||
Vector2.SmoothStep(new Vector2(-crewArea.Rect.Width, 0), new Vector2(toggleCrewButton.Rect.Width, 0), crewAreaOpenState).ToPoint();
|
Vector2.SmoothStep(new Vector2(-crewArea.Rect.Width, 0), new Vector2(toggleCrewButton.Rect.Width, 0), crewAreaOpenState).ToPoint();
|
||||||
crewAreaOpenState = toggleCrewAreaOpen ?
|
crewAreaOpenState = ToggleCrewAreaOpen ?
|
||||||
Math.Min(crewAreaOpenState + deltaTime * 2.0f, 1.0f) :
|
Math.Min(crewAreaOpenState + deltaTime * 2.0f, 1.0f) :
|
||||||
Math.Max(crewAreaOpenState - deltaTime * 2.0f, 0.0f);
|
Math.Max(crewAreaOpenState - deltaTime * 2.0f, 0.0f);
|
||||||
|
|
||||||
@@ -1156,7 +1163,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
Character.Controlled.SelectedConstruction = null;
|
Character.Controlled.SelectedConstruction = null;
|
||||||
}
|
}
|
||||||
toggleCrewAreaOpen = !toggleCrewAreaOpen;
|
ToggleCrewAreaOpen = !ToggleCrewAreaOpen;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateReports(deltaTime);
|
UpdateReports(deltaTime);
|
||||||
@@ -1284,7 +1291,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
reportButtonFrame.Visible = true;
|
reportButtonFrame.Visible = true;
|
||||||
|
|
||||||
var reportButtonParent = chatBox ?? GameMain.Client.ChatBox;
|
var reportButtonParent = ChatBox ?? GameMain.Client.ChatBox;
|
||||||
reportButtonFrame.RectTransform.AbsoluteOffset = new Point(
|
reportButtonFrame.RectTransform.AbsoluteOffset = new Point(
|
||||||
Math.Min(reportButtonParent.GUIFrame.Rect.X, reportButtonParent.ToggleButton.Rect.X) - reportButtonFrame.Rect.Width - (int)(10 * GUI.Scale),
|
Math.Min(reportButtonParent.GUIFrame.Rect.X, reportButtonParent.ToggleButton.Rect.X) - reportButtonFrame.Rect.Width - (int)(10 * GUI.Scale),
|
||||||
reportButtonParent.GUIFrame.Rect.Y);
|
reportButtonParent.GUIFrame.Rect.Y);
|
||||||
|
|||||||
@@ -14,5 +14,59 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool crewAreaOriginalState;
|
||||||
|
private bool chatBoxOriginalState;
|
||||||
|
private bool isHUDsHidden;
|
||||||
|
|
||||||
|
partial void HideHUDs(bool value)
|
||||||
|
{
|
||||||
|
if (isHUDsHidden == value) { return; }
|
||||||
|
if (value == true)
|
||||||
|
{
|
||||||
|
ToggleCrewArea(false, storeOriginalState: true);
|
||||||
|
ToggleChatBox(false, storeOriginalState: true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ToggleCrewArea(crewAreaOriginalState, storeOriginalState: false);
|
||||||
|
ToggleChatBox(chatBoxOriginalState, storeOriginalState: false);
|
||||||
|
}
|
||||||
|
isHUDsHidden = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ToggleCrewArea(bool value, bool storeOriginalState)
|
||||||
|
{
|
||||||
|
var crewManager = GameMain.GameSession.CrewManager;
|
||||||
|
if (storeOriginalState)
|
||||||
|
{
|
||||||
|
crewAreaOriginalState = crewManager.ToggleCrewAreaOpen;
|
||||||
|
}
|
||||||
|
crewManager.ToggleCrewAreaOpen = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ToggleChatBox(bool value, bool storeOriginalState)
|
||||||
|
{
|
||||||
|
var crewManager = GameMain.GameSession.CrewManager;
|
||||||
|
if (crewManager.IsSinglePlayer)
|
||||||
|
{
|
||||||
|
if (crewManager.ChatBox != null)
|
||||||
|
{
|
||||||
|
if (storeOriginalState)
|
||||||
|
{
|
||||||
|
chatBoxOriginalState = crewManager.ChatBox.ToggleOpen;
|
||||||
|
}
|
||||||
|
crewManager.ChatBox.ToggleOpen = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (GameMain.Client != null)
|
||||||
|
{
|
||||||
|
if (storeOriginalState)
|
||||||
|
{
|
||||||
|
chatBoxOriginalState = GameMain.Client.ChatBox.ToggleOpen;
|
||||||
|
}
|
||||||
|
GameMain.Client.ChatBox.ToggleOpen = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -206,6 +206,7 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
cam.OffsetAmount = MathHelper.Lerp(cam.OffsetAmount, (focusTarget as Item).Prefab.OffsetOnSelected, deltaTime * 10.0f);
|
cam.OffsetAmount = MathHelper.Lerp(cam.OffsetAmount, (focusTarget as Item).Prefab.OffsetOnSelected, deltaTime * 10.0f);
|
||||||
}
|
}
|
||||||
|
HideHUDs(true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!character.IsRemotePlayer || character.ViewTarget == focusTarget)
|
if (!character.IsRemotePlayer || character.ViewTarget == focusTarget)
|
||||||
@@ -273,6 +274,7 @@ namespace Barotrauma.Items.Components
|
|||||||
if (character.SelectedConstruction == this.item) character.SelectedConstruction = null;
|
if (character.SelectedConstruction == this.item) character.SelectedConstruction = null;
|
||||||
|
|
||||||
character.AnimController.Anim = AnimController.Animation.None;
|
character.AnimController.Anim = AnimController.Animation.None;
|
||||||
|
HideHUDs(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Select(Character activator)
|
public override bool Select(Character activator)
|
||||||
@@ -338,5 +340,7 @@ namespace Barotrauma.Items.Components
|
|||||||
limbPositions[i] = new LimbPos(limbPositions[i].limbType, flippedPos);
|
limbPositions[i] = new LimbPos(limbPositions[i].limbType, flippedPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
partial void HideHUDs(bool value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user