Build 0.18.4.0
This commit is contained in:
@@ -107,6 +107,7 @@ namespace Barotrauma
|
||||
|
||||
var buttonLeft = new GUIButton(new RectTransform(new Vector2(0.1f, 0.8f), channelSettingsContent.RectTransform), style: "DeviceButton")
|
||||
{
|
||||
PlaySoundOnSelect = false,
|
||||
OnClicked = (btn, userdata) =>
|
||||
{
|
||||
if (Character.Controlled != null && ChatMessage.CanUseRadio(Character.Controlled, out WifiComponent radio))
|
||||
@@ -150,6 +151,7 @@ namespace Barotrauma
|
||||
|
||||
var buttonRight = new GUIButton(new RectTransform(new Vector2(0.1f, 0.8f), channelSettingsContent.RectTransform), style: "DeviceButton")
|
||||
{
|
||||
PlaySoundOnSelect = false,
|
||||
OnClicked = (btn, userdata) =>
|
||||
{
|
||||
if (Character.Controlled != null && ChatMessage.CanUseRadio(Character.Controlled, out WifiComponent radio))
|
||||
@@ -178,6 +180,7 @@ namespace Barotrauma
|
||||
TextColor = new Color(51, 59, 46),
|
||||
SelectedTextColor = GUIStyle.Green,
|
||||
UserData = i,
|
||||
PlaySoundOnSelect = false,
|
||||
OnClicked = (btn, userdata) =>
|
||||
{
|
||||
if (Character.Controlled != null && ChatMessage.CanUseRadio(Character.Controlled, out WifiComponent radio))
|
||||
@@ -357,10 +360,15 @@ namespace Barotrauma
|
||||
CanBeFocused = true,
|
||||
ForceUpperCase = ForceUpperCase.No,
|
||||
UserData = message.SenderClient,
|
||||
PlaySoundOnSelect = false,
|
||||
OnClicked = (_, o) =>
|
||||
{
|
||||
if (!(o is Client client)) { return false; }
|
||||
GameMain.NetLobbyScreen?.SelectPlayer(client);
|
||||
if (GameMain.NetLobbyScreen != null)
|
||||
{
|
||||
GameMain.NetLobbyScreen.SelectPlayer(client);
|
||||
SoundPlayer.PlayUISound(GUISoundType.Select);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
OnSecondaryClicked = (_, o) =>
|
||||
|
||||
@@ -178,7 +178,14 @@ namespace Barotrauma
|
||||
return Sprites.ContainsKey(state) ? Sprites[state]?.First()?.Sprite : null;
|
||||
}
|
||||
|
||||
public void GetSize(XElement element)
|
||||
public void RefreshSize()
|
||||
{
|
||||
Width = null;
|
||||
Height = null;
|
||||
GetSize(Element);
|
||||
}
|
||||
|
||||
private void GetSize(XElement element)
|
||||
{
|
||||
Point size = new Point(0, 0);
|
||||
foreach (var subElement in element.Elements())
|
||||
|
||||
@@ -193,12 +193,13 @@ namespace Barotrauma
|
||||
};
|
||||
validateHiresButton = new GUIButton(new RectTransform(new Vector2(1.0f / 3.0f, 1.0f), group.RectTransform), text: TextManager.Get("campaigncrew.validate"))
|
||||
{
|
||||
ClickSound = GUISoundType.HireRepairClick,
|
||||
ClickSound = GUISoundType.ConfirmTransaction,
|
||||
ForceUpperCase = ForceUpperCase.Yes,
|
||||
OnClicked = (b, o) => ValidateHires(PendingHires, true)
|
||||
};
|
||||
clearAllButton = new GUIButton(new RectTransform(new Vector2(1.0f / 3.0f, 1.0f), group.RectTransform), text: TextManager.Get("campaignstore.clearall"))
|
||||
{
|
||||
ClickSound = GUISoundType.Cart,
|
||||
ForceUpperCase = ForceUpperCase.Yes,
|
||||
Enabled = HasPermission,
|
||||
OnClicked = (b, o) => RemoveAllPendingHires()
|
||||
@@ -403,6 +404,7 @@ namespace Barotrauma
|
||||
{
|
||||
var hireButton = new GUIButton(new RectTransform(new Vector2(width, 0.9f), mainGroup.RectTransform), style: "CrewManagementAddButton")
|
||||
{
|
||||
ClickSound = GUISoundType.Cart,
|
||||
UserData = characterInfo,
|
||||
Enabled = HasPermission,
|
||||
OnClicked = (b, o) => AddPendingHire(o as CharacterInfo)
|
||||
@@ -429,6 +431,7 @@ namespace Barotrauma
|
||||
{
|
||||
new GUIButton(new RectTransform(new Vector2(width, 0.9f), mainGroup.RectTransform), style: "CrewManagementRemoveButton")
|
||||
{
|
||||
ClickSound = GUISoundType.Cart,
|
||||
UserData = characterInfo,
|
||||
Enabled = HasPermission,
|
||||
OnClicked = (b, o) => RemovePendingHire(o as CharacterInfo)
|
||||
|
||||
@@ -182,7 +182,10 @@ namespace Barotrauma
|
||||
window = new GUIFrame(new RectTransform(Vector2.One * 0.8f, backgroundFrame.RectTransform, Anchor.Center));
|
||||
|
||||
var horizontalLayout = new GUILayoutGroup(new RectTransform(Vector2.One * 0.9f, window.RectTransform, Anchor.Center), true);
|
||||
sidebar = new GUIListBox(new RectTransform(new Vector2(0.29f, 1.0f), horizontalLayout.RectTransform));
|
||||
sidebar = new GUIListBox(new RectTransform(new Vector2(0.29f, 1.0f), horizontalLayout.RectTransform))
|
||||
{
|
||||
PlaySoundOnSelect = true
|
||||
};
|
||||
|
||||
var drives = System.IO.DriveInfo.GetDrives();
|
||||
foreach (var drive in drives)
|
||||
@@ -241,6 +244,7 @@ namespace Barotrauma
|
||||
|
||||
fileList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.85f), fileListLayout.RectTransform))
|
||||
{
|
||||
PlaySoundOnSelect = true,
|
||||
OnSelected = (child, userdata) =>
|
||||
{
|
||||
if (userdata is null) { return false; }
|
||||
|
||||
@@ -24,15 +24,17 @@ namespace Barotrauma
|
||||
ChatMessage,
|
||||
RadioMessage,
|
||||
DeadMessage,
|
||||
Click,
|
||||
Select,
|
||||
PickItem,
|
||||
PickItemFail,
|
||||
DropItem,
|
||||
PopupMenu,
|
||||
DecreaseQuantity,
|
||||
IncreaseQuantity,
|
||||
HireRepairClick,
|
||||
UISwitch
|
||||
Decrease,
|
||||
Increase,
|
||||
UISwitch,
|
||||
TickBox,
|
||||
ConfirmTransaction,
|
||||
Cart,
|
||||
}
|
||||
|
||||
public enum CursorState
|
||||
@@ -2384,7 +2386,7 @@ namespace Barotrauma
|
||||
CreateButton("PauseMenuResume", buttonContainer, null);
|
||||
CreateButton("PauseMenuSettings", buttonContainer, () => SettingsMenuOpen = true);
|
||||
|
||||
bool IsOutpostLevel() => GameMain.GameSession != null && Level.IsLoadedOutpost;
|
||||
bool IsFriendlyOutpostLevel() => GameMain.GameSession != null && Level.IsLoadedFriendlyOutpost;
|
||||
if (Screen.Selected == GameMain.GameScreen && GameMain.GameSession != null)
|
||||
{
|
||||
if (GameMain.GameSession.GameMode is SinglePlayerCampaign spMode)
|
||||
@@ -2399,11 +2401,11 @@ namespace Barotrauma
|
||||
GameMain.GameSession.LoadPreviousSave();
|
||||
});
|
||||
|
||||
if (IsOutpostLevel())
|
||||
if (IsFriendlyOutpostLevel())
|
||||
{
|
||||
CreateButton("PauseMenuSaveQuit", buttonContainer, verificationTextTag: "PauseMenuSaveAndReturnToMainMenuVerification", action: () =>
|
||||
{
|
||||
if (IsOutpostLevel()) { GameMain.QuitToMainMenu(save: true); }
|
||||
if (IsFriendlyOutpostLevel()) { GameMain.QuitToMainMenu(save: true); }
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -2416,7 +2418,7 @@ namespace Barotrauma
|
||||
}
|
||||
else if (!GameMain.GameSession.GameMode.IsSinglePlayer && GameMain.Client != null && GameMain.Client.HasPermission(ClientPermissions.ManageRound))
|
||||
{
|
||||
bool canSave = GameMain.GameSession.GameMode is CampaignMode && IsOutpostLevel();
|
||||
bool canSave = GameMain.GameSession.GameMode is CampaignMode && IsFriendlyOutpostLevel();
|
||||
if (canSave)
|
||||
{
|
||||
CreateButton("PauseMenuSaveQuit", buttonContainer, verificationTextTag: "PauseMenuSaveAndReturnToServerLobbyVerification", action: () =>
|
||||
|
||||
@@ -159,7 +159,9 @@ namespace Barotrauma
|
||||
private float pulseExpand;
|
||||
private bool flashed;
|
||||
|
||||
public GUISoundType ClickSound { get; set; } = GUISoundType.Click;
|
||||
public GUISoundType ClickSound { get; set; } = GUISoundType.Select;
|
||||
|
||||
public override bool PlaySoundOnSelect { get; set; } = true;
|
||||
|
||||
public GUIButton(RectTransform rectT, Alignment textAlignment = Alignment.Center, string style = "", Color? color = null) : this(rectT, new RawLString(""), textAlignment, style, color) { }
|
||||
|
||||
@@ -247,7 +249,10 @@ namespace Barotrauma
|
||||
}
|
||||
else if (PlayerInput.PrimaryMouseButtonClicked())
|
||||
{
|
||||
SoundPlayer.PlayUISound(ClickSound);
|
||||
if (PlaySoundOnSelect)
|
||||
{
|
||||
SoundPlayer.PlayUISound(ClickSound);
|
||||
}
|
||||
if (OnClicked != null)
|
||||
{
|
||||
if (OnClicked(this, UserData))
|
||||
|
||||
@@ -383,6 +383,8 @@ namespace Barotrauma
|
||||
|
||||
public bool ExternalHighlight = false;
|
||||
|
||||
public virtual bool PlaySoundOnSelect { get; set; } = false;
|
||||
|
||||
private RectTransform rectTransform;
|
||||
public RectTransform RectTransform
|
||||
{
|
||||
|
||||
@@ -113,7 +113,8 @@ namespace Barotrauma
|
||||
{
|
||||
AutoHideScrollBar = false,
|
||||
ScrollBarVisible = false,
|
||||
Padding = hasHeader ? new Vector4(4, 0, 4, 4) : padding
|
||||
Padding = hasHeader ? new Vector4(4, 0, 4, 4) : padding,
|
||||
PlaySoundOnSelect = true
|
||||
};
|
||||
|
||||
foreach (var (option, size) in optionsAndSizes)
|
||||
|
||||
@@ -183,7 +183,8 @@ namespace Barotrauma
|
||||
listBox = new GUIListBox(new RectTransform(new Point(Rect.Width, Rect.Height * MathHelper.Clamp(elementCount, 2, 10)), rectT, listAnchor, listPivot)
|
||||
{ IsFixedSize = false }, style: null)
|
||||
{
|
||||
Enabled = !selectMultiple
|
||||
Enabled = !selectMultiple,
|
||||
PlaySoundOnSelect = true,
|
||||
};
|
||||
if (!selectMultiple) { listBox.OnSelected = SelectItem; }
|
||||
GUIStyle.Apply(listBox, "GUIListBox", this);
|
||||
|
||||
@@ -309,6 +309,45 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public override bool PlaySoundOnSelect { get; set; } = false;
|
||||
|
||||
public bool PlaySoundOnDragStop { get; set; } = false;
|
||||
|
||||
public GUISoundType? SoundOnDragStart { get; set; } = null;
|
||||
|
||||
public GUISoundType? SoundOnDragStop { get; set; } = null;
|
||||
|
||||
#region enums
|
||||
public enum Force
|
||||
{
|
||||
Yes,
|
||||
No
|
||||
}
|
||||
|
||||
public enum AutoScroll
|
||||
{
|
||||
Enabled,
|
||||
Disabled
|
||||
}
|
||||
|
||||
public enum TakeKeyBoardFocus
|
||||
{
|
||||
Yes,
|
||||
No
|
||||
}
|
||||
|
||||
public enum PlaySelectSound
|
||||
{
|
||||
Yes,
|
||||
No
|
||||
}
|
||||
|
||||
private AutoScroll GetAutoScroll(bool b)
|
||||
{
|
||||
return b ? AutoScroll.Enabled : AutoScroll.Disabled;
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <param name="isScrollBarOnDefaultSide">For horizontal listbox, default side is on the bottom. For vertical, it's on the right.</param>
|
||||
public GUIListBox(RectTransform rectT, bool isHorizontal = false, Color? color = null, string style = "", bool isScrollBarOnDefaultSide = true, bool useMouseDownToSelect = false) : base(style, rectT)
|
||||
{
|
||||
@@ -396,7 +435,7 @@ namespace Barotrauma
|
||||
UpdateScrollBarSize();
|
||||
}
|
||||
|
||||
public void Select(object userData, bool force = false, bool autoScroll = true)
|
||||
public void Select(object userData, Force force = Force.No, AutoScroll autoScroll = AutoScroll.Enabled)
|
||||
{
|
||||
var children = Content.Children;
|
||||
int i = 0;
|
||||
@@ -515,9 +554,12 @@ namespace Barotrauma
|
||||
/// Scrolls the list to the specific element.
|
||||
/// </summary>
|
||||
/// <param name="component"></param>
|
||||
public void ScrollToElement(GUIComponent component, bool playSound = true)
|
||||
public void ScrollToElement(GUIComponent component, PlaySelectSound playSelectSound = PlaySelectSound.No)
|
||||
{
|
||||
if (playSound) { SoundPlayer.PlayUISound(GUISoundType.Click); }
|
||||
if (playSelectSound == PlaySelectSound.Yes)
|
||||
{
|
||||
SoundPlayer.PlayUISound(GUISoundType.Select);
|
||||
}
|
||||
List<GUIComponent> children = Content.Children.ToList();
|
||||
int index = children.IndexOf(component);
|
||||
if (index < 0) { return; }
|
||||
@@ -573,9 +615,16 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private double lastDragStartTime;
|
||||
|
||||
private void StartDraggingElement(GUIComponent child)
|
||||
{
|
||||
DraggedElement = child;
|
||||
if (Timing.TotalTime > lastDragStartTime + 0.2f)
|
||||
{
|
||||
lastDragStartTime = Timing.TotalTime;
|
||||
SoundPlayer.PlayUISound(SoundOnDragStart);
|
||||
}
|
||||
}
|
||||
|
||||
private bool UpdateDragging()
|
||||
@@ -586,6 +635,10 @@ namespace Barotrauma
|
||||
var draggedElem = draggedElement;
|
||||
OnRearranged?.Invoke(this, draggedElem.UserData);
|
||||
DraggedElement = null;
|
||||
if (PlaySoundOnDragStop)
|
||||
{
|
||||
SoundPlayer.PlayUISound(SoundOnDragStop);
|
||||
}
|
||||
RepositionChildren();
|
||||
if (AllSelected.Contains(draggedElem)) { return true; }
|
||||
}
|
||||
@@ -710,7 +763,7 @@ namespace Barotrauma
|
||||
int index = Content.Children.ToList().IndexOf(component);
|
||||
if (index >= 0)
|
||||
{
|
||||
Select(index, false, false, takeKeyBoardFocus: true);
|
||||
Select(index, autoScroll: AutoScroll.Disabled, takeKeyBoardFocus: TakeKeyBoardFocus.Yes);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -733,7 +786,7 @@ namespace Barotrauma
|
||||
{
|
||||
ScrollToElement(child);
|
||||
}
|
||||
Select(i, autoScroll: false, takeKeyBoardFocus: true);
|
||||
Select(i, autoScroll: AutoScroll.Disabled, takeKeyBoardFocus: TakeKeyBoardFocus.Yes, playSelectSound: PlaySelectSound.Yes);
|
||||
}
|
||||
|
||||
if (CurrentDragMode != DragMode.NoDragging
|
||||
@@ -929,14 +982,13 @@ namespace Barotrauma
|
||||
if (ClampScrollToElements)
|
||||
{
|
||||
bool scrollDown = Math.Clamp(PlayerInput.ScrollWheelSpeed, 0, 1) > 0;
|
||||
|
||||
if (scrollDown)
|
||||
{
|
||||
SelectPrevious(takeKeyBoardFocus: true);
|
||||
SelectPrevious(takeKeyBoardFocus: TakeKeyBoardFocus.Yes, playSelectSound: PlaySelectSound.Yes);
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectNext(takeKeyBoardFocus: true);
|
||||
SelectNext(takeKeyBoardFocus: TakeKeyBoardFocus.Yes, playSelectSound: PlaySelectSound.Yes);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -964,7 +1016,7 @@ namespace Barotrauma
|
||||
return FindScrollableParentListBox(target.Parent);
|
||||
}
|
||||
|
||||
public void SelectNext(bool force = false, bool autoScroll = true, bool takeKeyBoardFocus = false)
|
||||
public void SelectNext(Force force = Force.No, AutoScroll autoScroll = AutoScroll.Enabled, TakeKeyBoardFocus takeKeyBoardFocus = TakeKeyBoardFocus.No, PlaySelectSound playSelectSound = PlaySelectSound.No)
|
||||
{
|
||||
int index = SelectedIndex + 1;
|
||||
while (index < Content.CountChildren)
|
||||
@@ -972,10 +1024,10 @@ namespace Barotrauma
|
||||
GUIComponent child = Content.GetChild(index);
|
||||
if (child.Visible)
|
||||
{
|
||||
Select(index, force, !SmoothScroll && autoScroll, takeKeyBoardFocus: takeKeyBoardFocus);
|
||||
Select(index, force, GetAutoScroll(!SmoothScroll && autoScroll == AutoScroll.Enabled), takeKeyBoardFocus, playSelectSound);
|
||||
if (SmoothScroll)
|
||||
{
|
||||
ScrollToElement(child);
|
||||
ScrollToElement(child, playSelectSound);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -983,7 +1035,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public void SelectPrevious(bool force = false, bool autoScroll = true, bool takeKeyBoardFocus = false)
|
||||
public void SelectPrevious(Force force = Force.No, AutoScroll autoScroll = AutoScroll.Enabled, TakeKeyBoardFocus takeKeyBoardFocus = TakeKeyBoardFocus.No, PlaySelectSound playSelectSound = PlaySelectSound.No)
|
||||
{
|
||||
int index = SelectedIndex - 1;
|
||||
while (index >= 0)
|
||||
@@ -991,10 +1043,10 @@ namespace Barotrauma
|
||||
GUIComponent child = Content.GetChild(index);
|
||||
if (child.Visible)
|
||||
{
|
||||
Select(index, force, !SmoothScroll && autoScroll, takeKeyBoardFocus: takeKeyBoardFocus);
|
||||
Select(index, force, GetAutoScroll(!SmoothScroll && autoScroll == AutoScroll.Enabled), takeKeyBoardFocus, playSelectSound);
|
||||
if (SmoothScroll)
|
||||
{
|
||||
ScrollToElement(child);
|
||||
ScrollToElement(child, playSelectSound);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1002,7 +1054,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public void Select(int childIndex, bool force = false, bool autoScroll = true, bool takeKeyBoardFocus = false)
|
||||
public void Select(int childIndex, Force force = Force.No, AutoScroll autoScroll = AutoScroll.Enabled, TakeKeyBoardFocus takeKeyBoardFocus = TakeKeyBoardFocus.No, PlaySelectSound playSelectSound = PlaySelectSound.No)
|
||||
{
|
||||
if (childIndex >= Content.CountChildren || childIndex < 0) { return; }
|
||||
|
||||
@@ -1013,7 +1065,7 @@ namespace Barotrauma
|
||||
if (OnSelected != null)
|
||||
{
|
||||
// TODO: The callback is called twice, fix this!
|
||||
wasSelected = force || OnSelected(child, child.UserData);
|
||||
wasSelected = force == Force.Yes || OnSelected(child, child.UserData);
|
||||
}
|
||||
|
||||
if (!wasSelected) { return; }
|
||||
@@ -1055,7 +1107,7 @@ namespace Barotrauma
|
||||
|
||||
// Ensure that the selected element is visible. This may not be the case, if the selection is run from code. (e.g. if we have two list boxes that are synced)
|
||||
// TODO: This method only works when moving one item up/down (e.g. when using the up and down arrows)
|
||||
if (autoScroll)
|
||||
if (autoScroll == AutoScroll.Enabled)
|
||||
{
|
||||
if (ScrollBar.IsHorizontal)
|
||||
{
|
||||
@@ -1086,11 +1138,19 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
// If one of the children is the subscriber, we don't want to register, because it will unregister the child.
|
||||
if (takeKeyBoardFocus && CanTakeKeyBoardFocus && RectTransform.GetAllChildren().None(rt => rt.GUIComponent == GUI.KeyboardDispatcher.Subscriber))
|
||||
if (takeKeyBoardFocus == TakeKeyBoardFocus.Yes && CanTakeKeyBoardFocus && RectTransform.GetAllChildren().None(rt => rt.GUIComponent == GUI.KeyboardDispatcher.Subscriber))
|
||||
{
|
||||
Selected = true;
|
||||
GUI.KeyboardDispatcher.Subscriber = this;
|
||||
}
|
||||
|
||||
// List box child components can be parents to other components that can play sounds when selected (e.g. store elements)
|
||||
// so the list box shouldn't play the Select sound if the GUI.MouseOn component has a sound to play
|
||||
if (playSelectSound == PlaySelectSound.Yes && PlaySoundOnSelect && !child.PlaySoundOnSelect &&
|
||||
(GUI.MouseOn == null || GUI.MouseOn.Parent == Content || !GUI.MouseOn.PlaySoundOnSelect))
|
||||
{
|
||||
SoundPlayer.PlayUISound(GUISoundType.Select);
|
||||
}
|
||||
}
|
||||
|
||||
public void Select(IEnumerable<GUIComponent> children)
|
||||
@@ -1293,16 +1353,16 @@ namespace Barotrauma
|
||||
switch (key)
|
||||
{
|
||||
case Keys.Down:
|
||||
if (!isHorizontal && AllowArrowKeyScroll) { SelectNext(); }
|
||||
if (!isHorizontal && AllowArrowKeyScroll) { SelectNext(playSelectSound: PlaySelectSound.Yes); }
|
||||
break;
|
||||
case Keys.Up:
|
||||
if (!isHorizontal && AllowArrowKeyScroll) { SelectPrevious(); }
|
||||
if (!isHorizontal && AllowArrowKeyScroll) { SelectPrevious(playSelectSound: PlaySelectSound.Yes); }
|
||||
break;
|
||||
case Keys.Left:
|
||||
if (isHorizontal && AllowArrowKeyScroll) { SelectPrevious(); }
|
||||
if (isHorizontal && AllowArrowKeyScroll) { SelectPrevious(playSelectSound: PlaySelectSound.Yes); }
|
||||
break;
|
||||
case Keys.Right:
|
||||
if (isHorizontal && AllowArrowKeyScroll) { SelectNext(); }
|
||||
if (isHorizontal && AllowArrowKeyScroll) { SelectNext(playSelectSound: PlaySelectSound.Yes); }
|
||||
break;
|
||||
case Keys.Enter:
|
||||
case Keys.Space:
|
||||
|
||||
@@ -182,7 +182,7 @@ namespace Barotrauma
|
||||
public float valueStep;
|
||||
|
||||
private float pressedTimer;
|
||||
private float pressedDelay = 0.5f;
|
||||
private readonly float pressedDelay = 0.5f;
|
||||
private bool IsPressedTimerRunning { get { return pressedTimer > 0; } }
|
||||
|
||||
public GUINumberInput(RectTransform rectT, NumberType inputType, string style = "", Alignment textAlignment = Alignment.Center, float? relativeButtonAreaWidth = null, bool hidePlusMinusButtons = false) : base(style, rectT)
|
||||
@@ -228,6 +228,7 @@ namespace Barotrauma
|
||||
var buttonArea = new GUIFrame(new RectTransform(new Vector2(_relativeButtonAreaWidth, 1.0f), LayoutGroup.RectTransform, Anchor.CenterRight), style: null);
|
||||
PlusButton = new GUIButton(new RectTransform(new Vector2(1.0f, 0.5f), buttonArea.RectTransform), style: null);
|
||||
GUIStyle.Apply(PlusButton, "PlusButton", this);
|
||||
PlusButton.ClickSound = GUISoundType.Increase;
|
||||
PlusButton.OnButtonDown += () =>
|
||||
{
|
||||
pressedTimer = pressedDelay;
|
||||
@@ -249,6 +250,7 @@ namespace Barotrauma
|
||||
|
||||
MinusButton = new GUIButton(new RectTransform(new Vector2(1.0f, 0.5f), buttonArea.RectTransform, Anchor.BottomRight), style: null);
|
||||
GUIStyle.Apply(MinusButton, "MinusButton", this);
|
||||
MinusButton.ClickSound = GUISoundType.Decrease;
|
||||
MinusButton.OnButtonDown += () =>
|
||||
{
|
||||
pressedTimer = pressedDelay;
|
||||
@@ -423,8 +425,8 @@ namespace Barotrauma
|
||||
intValue = Math.Min(intValue, MaxValueInt.Value);
|
||||
UpdateText();
|
||||
}
|
||||
PlusButton.Enabled = intValue < MaxValueInt;
|
||||
MinusButton.Enabled = intValue > MinValueInt;
|
||||
PlusButton.Enabled = MaxValueInt == null || intValue < MaxValueInt;
|
||||
MinusButton.Enabled = MinValueInt == null || intValue > MinValueInt;
|
||||
}
|
||||
|
||||
private void UpdateText()
|
||||
|
||||
@@ -98,7 +98,6 @@ namespace Barotrauma
|
||||
foreach (var subElement in element.Elements().Reverse())
|
||||
{
|
||||
if (subElement.NameAsIdentifier() != "override") { continue; }
|
||||
|
||||
if (subElement.GetAttributeBool("iscjk", false))
|
||||
{
|
||||
return new ScalableFont(subElement, GameMain.Instance.GraphicsDevice);
|
||||
@@ -111,8 +110,7 @@ namespace Barotrauma
|
||||
{
|
||||
foreach (var subElement in element.Elements())
|
||||
{
|
||||
if (!subElement.Name.ToString().Equals("override", StringComparison.OrdinalIgnoreCase)) { continue; }
|
||||
if (GameSettings.CurrentConfig.Language == subElement.GetAttributeIdentifier("language", "").ToLanguageIdentifier())
|
||||
if (IsValidOverride(subElement))
|
||||
{
|
||||
return subElement.GetAttributeContentPath("file")?.Value;
|
||||
}
|
||||
@@ -125,8 +123,7 @@ namespace Barotrauma
|
||||
//check if any of the language override fonts want to override the font size as well
|
||||
foreach (var subElement in element.Elements())
|
||||
{
|
||||
if (!subElement.Name.ToString().Equals("override", StringComparison.OrdinalIgnoreCase)) { continue; }
|
||||
if (GameSettings.CurrentConfig.Language == subElement.GetAttributeIdentifier("language", "").ToLanguageIdentifier())
|
||||
if (IsValidOverride(subElement))
|
||||
{
|
||||
uint overrideFontSize = GetFontSize(subElement, 0);
|
||||
if (overrideFontSize > 0) { return (uint)Math.Round(overrideFontSize * GameSettings.CurrentConfig.Graphics.TextScale); }
|
||||
@@ -149,8 +146,7 @@ namespace Barotrauma
|
||||
{
|
||||
foreach (var subElement in element.Elements())
|
||||
{
|
||||
if (!subElement.Name.ToString().Equals("override", StringComparison.OrdinalIgnoreCase)) { continue; }
|
||||
if (GameSettings.CurrentConfig.Language == subElement.GetAttributeIdentifier("language", "").ToLanguageIdentifier())
|
||||
if (IsValidOverride(subElement))
|
||||
{
|
||||
return subElement.GetAttributeBool("dynamicloading", false);
|
||||
}
|
||||
@@ -162,14 +158,20 @@ namespace Barotrauma
|
||||
{
|
||||
foreach (var subElement in element.Elements())
|
||||
{
|
||||
if (!subElement.Name.ToString().Equals("override", StringComparison.OrdinalIgnoreCase)) { continue; }
|
||||
if (GameSettings.CurrentConfig.Language == subElement.GetAttributeIdentifier("language", "").ToLanguageIdentifier())
|
||||
if (IsValidOverride(subElement))
|
||||
{
|
||||
return subElement.GetAttributeBool("iscjk", false);
|
||||
}
|
||||
}
|
||||
return element.GetAttributeBool("iscjk", false);
|
||||
}
|
||||
|
||||
private bool IsValidOverride(XElement element)
|
||||
{
|
||||
if (!element.Name.ToString().Equals("override", StringComparison.OrdinalIgnoreCase)) { return false; }
|
||||
var languages = element.GetAttributeIdentifierArray("language", Array.Empty<Identifier>());
|
||||
return languages.Any(l => l.ToLanguageIdentifier() == GameSettings.CurrentConfig.Language);
|
||||
}
|
||||
}
|
||||
|
||||
public class GUIFont : GUISelector<GUIFontPrefab>
|
||||
|
||||
@@ -322,9 +322,8 @@ namespace Barotrauma
|
||||
{
|
||||
if (!enabled || !PlayerInput.PrimaryMouseButtonDown()) { return false; }
|
||||
if (barSize >= 1.0f) { return false; }
|
||||
|
||||
DraggingBar = this;
|
||||
|
||||
SoundPlayer.PlayUISound(GUISoundType.Select);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@ namespace Barotrauma
|
||||
public readonly static PrefabCollection<GUIComponentStyle> ComponentStyles = new PrefabCollection<GUIComponentStyle>();
|
||||
|
||||
public readonly static GUIFont Font = new GUIFont("Font");
|
||||
public readonly static GUIFont GlobalFont = new GUIFont("GlobalFont");
|
||||
public readonly static GUIFont UnscaledSmallFont = new GUIFont("UnscaledSmallFont");
|
||||
public readonly static GUIFont SmallFont = new GUIFont("SmallFont");
|
||||
public readonly static GUIFont LargeFont = new GUIFont("LargeFont");
|
||||
@@ -142,10 +141,6 @@ namespace Barotrauma
|
||||
public readonly static GUIColor HealthBarColorMedium = new GUIColor("HealthBarColorMedium");
|
||||
public readonly static GUIColor HealthBarColorHigh = new GUIColor("HealthBarColorHigh");
|
||||
|
||||
public readonly static GUIColor EquipmentIndicatorNotEquipped = new GUIColor("EquipmentIndicatorNotEquipped");
|
||||
public readonly static GUIColor EquipmentIndicatorEquipped = new GUIColor("EquipmentIndicatorEquipped");
|
||||
public readonly static GUIColor EquipmentIndicatorRunningOut = new GUIColor("EquipmentIndicatorRunningOut");
|
||||
|
||||
public static Point ItemFrameMargin => new Point(50, 56).Multiply(GUI.SlicedSpriteScale);
|
||||
public static Point ItemFrameOffset => new Point(0, 3).Multiply(GUI.SlicedSpriteScale);
|
||||
|
||||
@@ -159,7 +154,7 @@ namespace Barotrauma
|
||||
|
||||
public static void Apply(GUIComponent targetComponent, Identifier styleName, GUIComponent parent = null)
|
||||
{
|
||||
GUIComponentStyle componentStyle = null;
|
||||
GUIComponentStyle componentStyle;
|
||||
if (parent != null)
|
||||
{
|
||||
GUIComponentStyle parentStyle = parent.Style;
|
||||
|
||||
@@ -251,6 +251,8 @@ namespace Barotrauma
|
||||
|
||||
public bool Readonly { get; set; }
|
||||
|
||||
public override bool PlaySoundOnSelect { get; set; } = true;
|
||||
|
||||
public GUITextBox(RectTransform rectT, string text = "", Color? textColor = null, GUIFont font = null,
|
||||
Alignment textAlignment = Alignment.Left, bool wrap = false, string style = "", Color? color = null, bool createClearButton = false, bool createPenIcon = true)
|
||||
: base(style, rectT)
|
||||
@@ -363,6 +365,10 @@ namespace Barotrauma
|
||||
selected = true;
|
||||
GUI.KeyboardDispatcher.Subscriber = this;
|
||||
OnSelected?.Invoke(this, Keys.None);
|
||||
if (PlaySoundOnSelect)
|
||||
{
|
||||
SoundPlayer.PlayUISound(GUISoundType.Select);
|
||||
}
|
||||
}
|
||||
|
||||
public void Deselect()
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
public class GUITickBox : GUIComponent
|
||||
{
|
||||
private GUILayoutGroup layoutGroup;
|
||||
private GUIFrame box;
|
||||
private GUITextBlock text;
|
||||
private readonly GUILayoutGroup layoutGroup;
|
||||
private readonly GUIFrame box;
|
||||
private readonly GUITextBlock text;
|
||||
|
||||
public delegate bool OnSelectedHandler(GUITickBox obj);
|
||||
public OnSelectedHandler OnSelected;
|
||||
@@ -129,6 +127,12 @@ namespace Barotrauma
|
||||
set { text.Text = value; }
|
||||
}
|
||||
|
||||
public float ContentWidth { get; private set; }
|
||||
|
||||
public GUISoundType SoundType { private get; set; } = GUISoundType.TickBox;
|
||||
|
||||
public override bool PlaySoundOnSelect { get; set; } = true;
|
||||
|
||||
public GUITickBox(RectTransform rectT, LocalizedString label, GUIFont font = null, string style = "") : base(null, rectT)
|
||||
{
|
||||
CanBeFocused = true;
|
||||
@@ -180,6 +184,7 @@ namespace Barotrauma
|
||||
box.RectTransform.MinSize = new Point(Rect.Height);
|
||||
box.RectTransform.Resize(box.RectTransform.MinSize);
|
||||
text.SetTextPos();
|
||||
ContentWidth = box.Rect.Width + text.Padding.X + text.TextSize.X + text.Padding.Z;
|
||||
}
|
||||
|
||||
protected override void Update(float deltaTime)
|
||||
@@ -209,6 +214,10 @@ namespace Barotrauma
|
||||
{
|
||||
Selected = true;
|
||||
}
|
||||
if (PlaySoundOnSelect)
|
||||
{
|
||||
SoundPlayer.PlayUISound(SoundType);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (isSelected)
|
||||
|
||||
@@ -122,7 +122,7 @@ namespace Barotrauma
|
||||
|
||||
//horizontal slices at the corners of the screen for health bar and affliction icons
|
||||
int afflictionAreaHeight = (int)(50 * GUI.Scale);
|
||||
int healthBarWidth = (int)(BottomRightInfoArea.Width * 1.58f);
|
||||
int healthBarWidth = (int)(BottomRightInfoArea.Width * 1.3f);
|
||||
int healthBarHeight = (int)(50f * GUI.Scale);
|
||||
HealthBarArea = new Rectangle(BottomRightInfoArea.Right - healthBarWidth + (int)Math.Floor(1 / GUI.Scale), BottomRightInfoArea.Y - healthBarHeight + GUI.IntScale(10), healthBarWidth, healthBarHeight);
|
||||
AfflictionAreaLeft = new Rectangle(HealthBarArea.X, HealthBarArea.Y - Padding - afflictionAreaHeight, HealthBarArea.Width, afflictionAreaHeight);
|
||||
|
||||
@@ -569,6 +569,7 @@ namespace Barotrauma
|
||||
GUILayoutGroup buttonLayout = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.5f), footerLayout.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterRight);
|
||||
GUIButton healButton = new GUIButton(new RectTransform(new Vector2(0.33f, 1f), buttonLayout.RectTransform), TextManager.Get("medicalclinic.heal"))
|
||||
{
|
||||
ClickSound = GUISoundType.ConfirmTransaction,
|
||||
Enabled = medicalClinic.PendingHeals.Any() && medicalClinic.GetBalance() >= medicalClinic.GetTotalCost(),
|
||||
OnClicked = (button, _) =>
|
||||
{
|
||||
@@ -595,6 +596,7 @@ namespace Barotrauma
|
||||
|
||||
GUIButton clearButton = new GUIButton(new RectTransform(new Vector2(0.33f, 1f), buttonLayout.RectTransform), TextManager.Get("campaignstore.clearall"))
|
||||
{
|
||||
ClickSound = GUISoundType.Cart,
|
||||
OnClicked = (button, _) =>
|
||||
{
|
||||
button.Enabled = false;
|
||||
@@ -684,6 +686,7 @@ namespace Barotrauma
|
||||
|
||||
GUIButton healButton = new GUIButton(new RectTransform(new Vector2(0.2f, 1f), textLayout.RectTransform), style: "CrewManagementRemoveButton")
|
||||
{
|
||||
ClickSound = GUISoundType.Cart,
|
||||
OnClicked = (button, _) =>
|
||||
{
|
||||
button.Enabled = false;
|
||||
@@ -766,6 +769,7 @@ namespace Barotrauma
|
||||
|
||||
GUIButton treatAllButton = new GUIButton(new RectTransform(new Vector2(1f, 0.2f), mainLayout.RectTransform), TextManager.Get("medicalclinic.treatall"))
|
||||
{
|
||||
ClickSound = GUISoundType.Cart,
|
||||
Font = GUIStyle.SubHeadingFont,
|
||||
Visible = false
|
||||
};
|
||||
@@ -887,7 +891,10 @@ namespace Barotrauma
|
||||
|
||||
GUITextBlock priceBlock = new GUITextBlock(new RectTransform(new Vector2(1f, 0.25f), bottomTextLayout.RectTransform), TextManager.FormatCurrency(affliction.Price), font: GUIStyle.SubHeadingFont);
|
||||
|
||||
GUIButton buyButton = new GUIButton(new RectTransform(new Vector2(0.2f, 0.75f), bottomLayout.RectTransform), style: "CrewManagementAddButton");
|
||||
GUIButton buyButton = new GUIButton(new RectTransform(new Vector2(0.2f, 0.75f), bottomLayout.RectTransform), style: "CrewManagementAddButton")
|
||||
{
|
||||
ClickSound = GUISoundType.Cart
|
||||
};
|
||||
|
||||
ImmutableArray<GUIComponent> elementsToDisable = ImmutableArray.Create<GUIComponent>(prefabBlock, backgroundFrame, icon, vitalityBlock, severityBlock, buyButton, descriptionBlock, priceBlock);
|
||||
|
||||
|
||||
@@ -390,7 +390,7 @@ namespace Barotrauma
|
||||
ToolTip = TextManager.Get("campaignstore.reputationtooltip")
|
||||
};
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.5f), reputationEffectContainer.RectTransform),
|
||||
TextManager.Get("reputation"), font: GUIStyle.Font, textAlignment: Alignment.BottomLeft)
|
||||
TextManager.Get("reputationmodifier"), font: GUIStyle.Font, textAlignment: Alignment.BottomLeft)
|
||||
{
|
||||
AutoScaleVertical = true,
|
||||
CanBeFocused = false,
|
||||
@@ -656,7 +656,7 @@ namespace Barotrauma
|
||||
SetConfirmButtonBehavior();
|
||||
clearAllButton = new GUIButton(new RectTransform(new Vector2(0.35f, 1.0f), buttonContainer.RectTransform), TextManager.Get("campaignstore.clearall"))
|
||||
{
|
||||
ClickSound = GUISoundType.DecreaseQuantity,
|
||||
ClickSound = GUISoundType.Cart,
|
||||
Enabled = HasActiveTabPermissions(),
|
||||
ForceUpperCase = ForceUpperCase.Yes,
|
||||
OnClicked = (button, userData) =>
|
||||
@@ -1567,8 +1567,6 @@ namespace Barotrauma
|
||||
}
|
||||
AddToShoppingCrate(purchasedItem, quantity: numberInput.IntValue - purchasedItem.Quantity);
|
||||
};
|
||||
amountInput.PlusButton.ClickSound = GUISoundType.IncreaseQuantity;
|
||||
amountInput.MinusButton.ClickSound = GUISoundType.DecreaseQuantity;
|
||||
frame.HoverColor = frame.SelectedColor = Color.Transparent;
|
||||
}
|
||||
|
||||
@@ -1622,7 +1620,7 @@ namespace Barotrauma
|
||||
{
|
||||
new GUIButton(new RectTransform(new Vector2(buttonRelativeWidth, 0.9f), mainGroup.RectTransform), style: "StoreAddToCrateButton")
|
||||
{
|
||||
ClickSound = GUISoundType.IncreaseQuantity,
|
||||
ClickSound = GUISoundType.Cart,
|
||||
Enabled = !forceDisable && pi.Quantity > 0,
|
||||
ForceUpperCase = ForceUpperCase.Yes,
|
||||
UserData = "addbutton",
|
||||
@@ -1633,7 +1631,7 @@ namespace Barotrauma
|
||||
{
|
||||
new GUIButton(new RectTransform(new Vector2(buttonRelativeWidth, 0.9f), mainGroup.RectTransform), style: "StoreRemoveFromCrateButton")
|
||||
{
|
||||
ClickSound = GUISoundType.DecreaseQuantity,
|
||||
ClickSound = GUISoundType.Cart,
|
||||
Enabled = !forceDisable,
|
||||
ForceUpperCase = ForceUpperCase.Yes,
|
||||
UserData = "removebutton",
|
||||
@@ -2076,11 +2074,13 @@ namespace Barotrauma
|
||||
{
|
||||
if (IsBuying)
|
||||
{
|
||||
confirmButton.ClickSound = GUISoundType.ConfirmTransaction;
|
||||
confirmButton.Text = TextManager.Get("CampaignStore.Purchase");
|
||||
confirmButton.OnClicked = (b, o) => BuyItems();
|
||||
}
|
||||
else
|
||||
{
|
||||
confirmButton.ClickSound = GUISoundType.Select;
|
||||
confirmButton.Text = TextManager.Get("CampaignStoreTab.Sell");
|
||||
confirmButton.OnClicked = (b, o) =>
|
||||
{
|
||||
@@ -2088,6 +2088,7 @@ namespace Barotrauma
|
||||
TextManager.Get("FireWarningHeader"),
|
||||
TextManager.Get("CampaignStore.SellWarningText"),
|
||||
new LocalizedString[] { TextManager.Get("Yes"), TextManager.Get("No") });
|
||||
confirmDialog.Buttons[0].ClickSound = GUISoundType.ConfirmTransaction;
|
||||
confirmDialog.Buttons[0].OnClicked = (b, o) => SellItems();
|
||||
confirmDialog.Buttons[0].OnClicked += confirmDialog.Close;
|
||||
confirmDialog.Buttons[1].OnClicked = confirmDialog.Close;
|
||||
|
||||
@@ -29,6 +29,8 @@ namespace Barotrauma
|
||||
private GUITextBlock descriptionTextBlock;
|
||||
private int selectionIndicatorThickness;
|
||||
private GUIImage listBackground;
|
||||
private GUITickBox transferItemsTickBox;
|
||||
private GUITextBlock itemTransferReminderBlock;
|
||||
|
||||
private readonly List<SubmarineInfo> subsToShow;
|
||||
private readonly SubmarineDisplayContent[] submarineDisplays = new SubmarineDisplayContent[submarinesPerPage];
|
||||
@@ -61,6 +63,23 @@ namespace Barotrauma
|
||||
public GUIButton previewButton;
|
||||
}
|
||||
|
||||
private bool TransferItemsOnSwitch
|
||||
{
|
||||
get
|
||||
{
|
||||
return transferItemsOnSwitch;
|
||||
}
|
||||
set
|
||||
{
|
||||
transferItemsOnSwitch = value;
|
||||
if (transferItemsTickBox != null)
|
||||
{
|
||||
transferItemsTickBox.Selected = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
private bool transferItemsOnSwitch = true;
|
||||
|
||||
public SubmarineSelection(bool transfer, Action closeAction, RectTransform parent)
|
||||
{
|
||||
if (GameMain.GameSession.Campaign == null) { return; }
|
||||
@@ -149,11 +168,12 @@ namespace Barotrauma
|
||||
GUIListBox descriptionFrame = new GUIListBox(new RectTransform(new Vector2(0.59f, 1f), infoFrame.RectTransform), style: null) { Padding = new Vector4(HUDLayoutSettings.Padding / 2f, HUDLayoutSettings.Padding * 1.5f, HUDLayoutSettings.Padding * 1.5f, HUDLayoutSettings.Padding / 2f) };
|
||||
descriptionTextBlock = new GUITextBlock(new RectTransform(new Vector2(1, 0), descriptionFrame.Content.RectTransform), string.Empty, font: GUIStyle.Font, wrap: true) { CanBeFocused = false };
|
||||
|
||||
GUILayoutGroup buttonFrame = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.075f), content.RectTransform), childAnchor: Anchor.CenterRight) { IsHorizontal = true, AbsoluteSpacing = HUDLayoutSettings.Padding };
|
||||
GUILayoutGroup bottomContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.075f), content.RectTransform, Anchor.CenterRight), childAnchor: Anchor.CenterRight) { IsHorizontal = true, AbsoluteSpacing = HUDLayoutSettings.Padding };
|
||||
float transferInfoFrameWidth = 1.0f;
|
||||
|
||||
if (closeAction != null)
|
||||
{
|
||||
GUIButton closeButton = new GUIButton(new RectTransform(new Vector2(0.2f, 1f), buttonFrame.RectTransform), TextManager.Get("Close"), style: "GUIButtonFreeScale")
|
||||
GUIButton closeButton = new GUIButton(new RectTransform(new Vector2(0.2f, 1f), bottomContainer.RectTransform), TextManager.Get("Close"), style: "GUIButtonFreeScale")
|
||||
{
|
||||
OnClicked = (button, userData) =>
|
||||
{
|
||||
@@ -161,11 +181,33 @@ namespace Barotrauma
|
||||
return true;
|
||||
}
|
||||
};
|
||||
transferInfoFrameWidth -= closeButton.RectTransform.RelativeSize.X;
|
||||
}
|
||||
|
||||
if (purchaseService) confirmButtonAlt = new GUIButton(new RectTransform(new Vector2(0.2f, 1f), buttonFrame.RectTransform), purchaseOnlyText, style: "GUIButtonFreeScale");
|
||||
confirmButton = new GUIButton(new RectTransform(new Vector2(0.2f, 1f), buttonFrame.RectTransform), purchaseService ? purchaseAndSwitchText : deliveryFee > 0 ? deliveryText : switchText, style: "GUIButtonFreeScale");
|
||||
if (purchaseService)
|
||||
{
|
||||
confirmButtonAlt = new GUIButton(new RectTransform(new Vector2(0.2f, 1f), bottomContainer.RectTransform), purchaseOnlyText, style: "GUIButtonFreeScale");
|
||||
transferInfoFrameWidth -= confirmButtonAlt.RectTransform.RelativeSize.X;
|
||||
}
|
||||
confirmButton = new GUIButton(new RectTransform(new Vector2(0.2f, 1f), bottomContainer.RectTransform), purchaseService ? purchaseAndSwitchText : deliveryFee > 0 ? deliveryText : switchText, style: "GUIButtonFreeScale");
|
||||
SetConfirmButtonState(false);
|
||||
transferInfoFrameWidth -= confirmButton.RectTransform.RelativeSize.X;
|
||||
GUIFrame transferInfoFrame = new GUIFrame(new RectTransform(new Vector2(transferInfoFrameWidth, 1.0f), bottomContainer.RectTransform), style: null)
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
transferItemsTickBox = new GUITickBox(new RectTransform(new Vector2(0.2f, 1.0f), transferInfoFrame.RectTransform, Anchor.CenterRight), TextManager.Get("transferitems"), font: GUIStyle.SubHeadingFont)
|
||||
{
|
||||
Selected = TransferItemsOnSwitch,
|
||||
Visible = false,
|
||||
OnSelected = (tb) => transferItemsOnSwitch = tb.Selected
|
||||
};
|
||||
transferItemsTickBox.RectTransform.Resize(new Point(Math.Min((int)transferItemsTickBox.ContentWidth, transferInfoFrame.Rect.Width), transferItemsTickBox.Rect.Height));
|
||||
itemTransferReminderBlock = new GUITextBlock(new RectTransform(Vector2.One, transferInfoFrame.RectTransform, Anchor.CenterRight), null)
|
||||
{
|
||||
TextAlignment = Alignment.CenterRight,
|
||||
Visible = false
|
||||
};
|
||||
|
||||
pageIndicatorHolder = new GUIFrame(new RectTransform(new Vector2(1f, 1.5f), submarineControlsGroup.RectTransform), style: null);
|
||||
pageIndicator = GUIStyle.GetComponentStyle("GUIPageIndicator").GetDefaultSprite();
|
||||
@@ -272,7 +314,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public void RefreshSubmarineDisplay(bool updateSubs)
|
||||
public void RefreshSubmarineDisplay(bool updateSubs, bool setTransferOptionToTrue = false)
|
||||
{
|
||||
if (!initialized)
|
||||
{
|
||||
@@ -286,6 +328,10 @@ namespace Barotrauma
|
||||
{
|
||||
playerBalanceElement = CampaignUI.UpdateBalanceElement(playerBalanceElement);
|
||||
}
|
||||
if (setTransferOptionToTrue)
|
||||
{
|
||||
TransferItemsOnSwitch = true;
|
||||
}
|
||||
if (updateSubs)
|
||||
{
|
||||
UpdateSubmarines();
|
||||
@@ -401,6 +447,10 @@ namespace Barotrauma
|
||||
{
|
||||
SelectSubmarine(null, Rectangle.Empty);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateItemTransferInfoFrame();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateSubmarines()
|
||||
@@ -553,6 +603,40 @@ namespace Barotrauma
|
||||
selectedSubmarineIndicator.RectTransform.NonScaledSize = Point.Zero;
|
||||
SetConfirmButtonState(false);
|
||||
}
|
||||
|
||||
UpdateItemTransferInfoFrame();
|
||||
}
|
||||
|
||||
private void UpdateItemTransferInfoFrame()
|
||||
{
|
||||
if (selectedSubmarine != null)
|
||||
{
|
||||
var pendingSub = GameMain.GameSession?.Campaign?.PendingSubmarineSwitch;
|
||||
if (Submarine.MainSub?.Info?.Name == selectedSubmarine.Name && pendingSub == null)
|
||||
{
|
||||
transferItemsTickBox.Visible = false;
|
||||
itemTransferReminderBlock.Visible = false;
|
||||
}
|
||||
else if (pendingSub?.Name == selectedSubmarine.Name)
|
||||
{
|
||||
transferItemsTickBox.Visible = false;
|
||||
itemTransferReminderBlock.Text = GameMain.GameSession.Campaign.TransferItemsOnSubSwitch ?
|
||||
TextManager.Get("itemtransferenabledreminder") :
|
||||
TextManager.Get("itemtransferdisabledreminder");
|
||||
itemTransferReminderBlock.Visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
transferItemsTickBox.Selected = TransferItemsOnSwitch;
|
||||
transferItemsTickBox.Visible = true;
|
||||
itemTransferReminderBlock.Visible = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
transferItemsTickBox.Visible = false;
|
||||
itemTransferReminderBlock.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetConfirmButtonState(bool state)
|
||||
@@ -614,24 +698,27 @@ namespace Barotrauma
|
||||
("[submarinename2]", CurrentOrPendingSubmarine().DisplayName),
|
||||
("[amount]", deliveryFee.ToString()),
|
||||
("[currencyname]", currencyName)), messageBoxOptions);
|
||||
msgBox.Buttons[0].ClickSound = GUISoundType.ConfirmTransaction;
|
||||
}
|
||||
else
|
||||
{
|
||||
msgBox = new GUIMessageBox(TextManager.Get("switchsubmarineheader"), TextManager.GetWithVariables("switchsubmarinetext",
|
||||
var text = TextManager.GetWithVariables("switchsubmarinetext",
|
||||
("[submarinename1]", CurrentOrPendingSubmarine().DisplayName),
|
||||
("[submarinename2]", selectedSubmarine.DisplayName)), messageBoxOptions);
|
||||
("[submarinename2]", selectedSubmarine.DisplayName));
|
||||
text += GetItemTransferText();
|
||||
msgBox = new GUIMessageBox(TextManager.Get("switchsubmarineheader"), text, messageBoxOptions);
|
||||
}
|
||||
|
||||
msgBox.Buttons[0].OnClicked = (applyButton, obj) =>
|
||||
{
|
||||
if (GameMain.Client == null)
|
||||
{
|
||||
GameMain.GameSession.SwitchSubmarine(selectedSubmarine, deliveryFee);
|
||||
GameMain.GameSession.SwitchSubmarine(selectedSubmarine, TransferItemsOnSwitch, deliveryFee);
|
||||
RefreshSubmarineDisplay(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameMain.Client.InitiateSubmarineChange(selectedSubmarine, Networking.VoteType.SwitchSub);
|
||||
GameMain.Client.InitiateSubmarineChange(selectedSubmarine, TransferItemsOnSwitch, Networking.VoteType.SwitchSub);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
@@ -653,23 +740,25 @@ namespace Barotrauma
|
||||
|
||||
if (!purchaseOnly)
|
||||
{
|
||||
msgBox = new GUIMessageBox(TextManager.Get("purchaseandswitchsubmarineheader"), TextManager.GetWithVariables("purchaseandswitchsubmarinetext",
|
||||
var text = TextManager.GetWithVariables("purchaseandswitchsubmarinetext",
|
||||
("[submarinename1]", selectedSubmarine.DisplayName),
|
||||
("[amount]", selectedSubmarine.Price.ToString()),
|
||||
("[currencyname]", currencyName),
|
||||
("[submarinename2]", CurrentOrPendingSubmarine().DisplayName)), messageBoxOptions);
|
||||
("[submarinename2]", CurrentOrPendingSubmarine().DisplayName));
|
||||
text += GetItemTransferText();
|
||||
msgBox = new GUIMessageBox(TextManager.Get("purchaseandswitchsubmarineheader"), text, messageBoxOptions);
|
||||
|
||||
msgBox.Buttons[0].OnClicked = (applyButton, obj) =>
|
||||
{
|
||||
if (GameMain.Client == null)
|
||||
{
|
||||
GameMain.GameSession.PurchaseSubmarine(selectedSubmarine);
|
||||
GameMain.GameSession.SwitchSubmarine(selectedSubmarine, 0);
|
||||
GameMain.GameSession.SwitchSubmarine(selectedSubmarine, TransferItemsOnSwitch, 0);
|
||||
RefreshSubmarineDisplay(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameMain.Client.InitiateSubmarineChange(selectedSubmarine, Networking.VoteType.PurchaseAndSwitchSub);
|
||||
GameMain.Client.InitiateSubmarineChange(selectedSubmarine, TransferItemsOnSwitch, Networking.VoteType.PurchaseAndSwitchSub);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
@@ -690,14 +779,20 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
GameMain.Client.InitiateSubmarineChange(selectedSubmarine, Networking.VoteType.PurchaseSub);
|
||||
GameMain.Client.InitiateSubmarineChange(selectedSubmarine, false, Networking.VoteType.PurchaseSub);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
msgBox.Buttons[0].ClickSound = GUISoundType.ConfirmTransaction;
|
||||
msgBox.Buttons[0].OnClicked += msgBox.Close;
|
||||
msgBox.Buttons[1].OnClicked = msgBox.Close;
|
||||
}
|
||||
}
|
||||
|
||||
private LocalizedString GetItemTransferText()
|
||||
{
|
||||
return "\n\n" + TextManager.Get(TransferItemsOnSwitch ? "itemswillbetransferred" : "itemswontbetransferred");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -360,7 +360,7 @@ namespace Barotrauma
|
||||
var talentsButton = createTabButton(InfoFrameTab.Talents, "tabmenu.character");
|
||||
talentsButton.OnAddedToGUIUpdateList += (component) =>
|
||||
{
|
||||
talentsButton.Enabled = Character.Controlled?.Info != null || (GameMain.Client?.CharacterInfo != null && GameMain.GameSession?.GameMode is MultiPlayerCampaign);
|
||||
talentsButton.Enabled = Character.Controlled?.Info != null || GameMain.Client?.CharacterInfo != null;
|
||||
if (!talentsButton.Enabled && selectedTab == InfoFrameTab.Talents)
|
||||
{
|
||||
SelectInfoFrameTab(InfoFrameTab.Crew);
|
||||
@@ -453,7 +453,8 @@ namespace Barotrauma
|
||||
GUIListBox crewList = new GUIListBox(new RectTransform(crewListSize, content.RectTransform))
|
||||
{
|
||||
Padding = new Vector4(2, 5, 0, 0),
|
||||
AutoHideScrollBar = false
|
||||
AutoHideScrollBar = false,
|
||||
PlaySoundOnSelect = true
|
||||
};
|
||||
crewList.UpdateDimensions();
|
||||
|
||||
@@ -928,8 +929,8 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector2 stringOffset = GUIStyle.GlobalFont.MeasureString(inLobbyString) / 2f;
|
||||
GUIStyle.GlobalFont.DrawString(spriteBatch, inLobbyString, area.Center.ToVector2() - stringOffset, Color.White);
|
||||
Vector2 stringOffset = GUIStyle.Font.MeasureString(inLobbyString) / 2f;
|
||||
GUIStyle.Font.DrawString(spriteBatch, inLobbyString, area.Center.ToVector2() - stringOffset, Color.White);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1914,6 +1915,7 @@ namespace Barotrauma
|
||||
{
|
||||
OnClicked = (button, o) =>
|
||||
{
|
||||
GameMain.Client?.SendCharacterInfo();
|
||||
characterSettingsFrame!.Visible = false;
|
||||
talentFrameMain.Visible = true;
|
||||
return true;
|
||||
|
||||
@@ -462,7 +462,7 @@ namespace Barotrauma
|
||||
button.Enabled = false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}, overrideConfirmButtonSound: GUISoundType.ConfirmTransaction);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -497,7 +497,7 @@ namespace Barotrauma
|
||||
button.Enabled = false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}, overrideConfirmButtonSound: GUISoundType.ConfirmTransaction);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -539,7 +539,7 @@ namespace Barotrauma
|
||||
GameMain.Client?.SendCampaignState();
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}, overrideConfirmButtonSound: GUISoundType.ConfirmTransaction);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -589,7 +589,7 @@ namespace Barotrauma
|
||||
new GUITextBlock(rectT(1, 0, textLayout), title, font: GUIStyle.SubHeadingFont) { CanBeFocused = false, AutoScaleHorizontal = true };
|
||||
new GUITextBlock(rectT(1, 0, textLayout), TextManager.FormatCurrency(price));
|
||||
GUILayoutGroup buyButtonLayout = new GUILayoutGroup(rectT(0.2f, 1, contentLayout), childAnchor: Anchor.Center) { UserData = "buybutton" };
|
||||
new GUIButton(rectT(0.7f, 0.5f, buyButtonLayout), string.Empty, style: "RepairBuyButton") { ClickSound = GUISoundType.HireRepairClick, Enabled = PlayerBalance >= price && !isDisabled, OnClicked = onPressed };
|
||||
new GUIButton(rectT(0.7f, 0.5f, buyButtonLayout), string.Empty, style: "RepairBuyButton") { Enabled = PlayerBalance >= price && !isDisabled, OnClicked = onPressed };
|
||||
contentLayout.Recalculate();
|
||||
buyButtonLayout.Recalculate();
|
||||
|
||||
@@ -622,7 +622,8 @@ namespace Barotrauma
|
||||
PadBottom = true,
|
||||
SelectTop = true,
|
||||
ClampScrollToElements = true,
|
||||
Spacing = 8
|
||||
Spacing = 8,
|
||||
PlaySoundOnSelect = true
|
||||
};
|
||||
|
||||
Dictionary<UpgradeCategory, List<UpgradePrefab>> upgrades = new Dictionary<UpgradeCategory, List<UpgradePrefab>>();
|
||||
@@ -1123,7 +1124,10 @@ namespace Barotrauma
|
||||
{
|
||||
priceText.Text = string.Empty;
|
||||
}
|
||||
new GUIButton(rectT(0.7f, 0.5f, buyButtonLayout), string.Empty, style: buttonStyle) { Enabled = false };
|
||||
new GUIButton(rectT(0.7f, 0.5f, buyButtonLayout), string.Empty, style: buttonStyle)
|
||||
{
|
||||
Enabled = false
|
||||
};
|
||||
if (upgradePrefab != null)
|
||||
{
|
||||
var increaseText = new GUITextBlock(rectT(1, 0.2f, buyButtonLayout), "", textAlignment: Alignment.Center);
|
||||
@@ -1212,7 +1216,7 @@ namespace Barotrauma
|
||||
Campaign.UpgradeManager.PurchaseUpgrade(prefab, category);
|
||||
GameMain.Client?.SendCampaignState();
|
||||
return true;
|
||||
});
|
||||
}, overrideConfirmButtonSound: GUISoundType.ConfirmTransaction);
|
||||
|
||||
return true;
|
||||
};
|
||||
@@ -1400,7 +1404,7 @@ namespace Barotrauma
|
||||
|
||||
if (PlayerInput.PrimaryMouseButtonClicked() && selectedUpgradeTab == UpgradeTab.Upgrade && currentStoreLayout != null)
|
||||
{
|
||||
ScrollToCategory(data => data.Category.IsWallUpgrade);
|
||||
ScrollToCategory(data => data.Category.IsWallUpgrade, GUIListBox.PlaySelectSound.Yes);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1682,7 +1686,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private void ScrollToCategory(Predicate<CategoryData> predicate)
|
||||
private void ScrollToCategory(Predicate<CategoryData> predicate, GUIListBox.PlaySelectSound playSelectSound = GUIListBox.PlaySelectSound.No)
|
||||
{
|
||||
if (currentStoreLayout == null) { return; }
|
||||
|
||||
@@ -1690,7 +1694,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (child.UserData is CategoryData data && predicate(data))
|
||||
{
|
||||
currentStoreLayout.ScrollToElement(child);
|
||||
currentStoreLayout.ScrollToElement(child, playSelectSound);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Barotrauma
|
||||
private Color SubmarineColor => GUIStyle.Orange;
|
||||
private Point createdForResolution;
|
||||
|
||||
public static VotingInterface CreateSubmarineVotingInterface(Client starter, SubmarineInfo info, VoteType type, float votingTime)
|
||||
public static VotingInterface CreateSubmarineVotingInterface(Client starter, SubmarineInfo info, VoteType type, bool transferItems, float votingTime)
|
||||
{
|
||||
if (starter == null || info == null) { return null; }
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace Barotrauma
|
||||
getMaxVotes = () => GameMain.NetworkMember?.Voting?.GetVoteCountMax(type) ?? 0,
|
||||
};
|
||||
subVoting.onVoteEnd = () => subVoting.SendSubmarineVoteEndMessage(info, type);
|
||||
subVoting.SetSubmarineVotingText(starter, info, type);
|
||||
subVoting.SetSubmarineVotingText(starter, info, transferItems, type);
|
||||
subVoting.Initialize(starter, type);
|
||||
return subVoting;
|
||||
}
|
||||
@@ -160,19 +160,21 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
#region Submarine Voting
|
||||
private void SetSubmarineVotingText(Client starter, SubmarineInfo info, VoteType type)
|
||||
|
||||
private void SetSubmarineVotingText(Client starter, SubmarineInfo info, bool transferItems, VoteType type)
|
||||
{
|
||||
string name = starter.Name;
|
||||
JobPrefab prefab = starter?.Character?.Info?.Job?.Prefab;
|
||||
Color nameColor = prefab != null ? prefab.UIColor : Color.White;
|
||||
string characterRichString = $"‖color:{nameColor.R},{nameColor.G},{nameColor.B}‖{name}‖color:end‖";
|
||||
string submarineRichString = $"‖color:{SubmarineColor.R},{SubmarineColor.G},{SubmarineColor.B}‖{info.DisplayName}‖color:end‖";
|
||||
|
||||
string tag = string.Empty;
|
||||
LocalizedString text = string.Empty;
|
||||
switch (type)
|
||||
{
|
||||
case VoteType.PurchaseAndSwitchSub:
|
||||
text = TextManager.GetWithVariables("submarinepurchaseandswitchvote",
|
||||
tag = transferItems ? "submarinepurchaseandswitchwithitemsvote" : "submarinepurchaseandswitchvote";
|
||||
text = TextManager.GetWithVariables(tag,
|
||||
("[playername]", characterRichString),
|
||||
("[submarinename]", submarineRichString),
|
||||
("[amount]", info.Price.ToString()),
|
||||
@@ -189,7 +191,8 @@ namespace Barotrauma
|
||||
int deliveryFee = SubmarineSelection.DeliveryFeePerDistanceTravelled * GameMain.GameSession.Map.DistanceToClosestLocationWithOutpost(GameMain.GameSession.Map.CurrentLocation, out Location endLocation);
|
||||
if (deliveryFee > 0)
|
||||
{
|
||||
text = TextManager.GetWithVariables("submarineswitchfeevote",
|
||||
tag = transferItems ? "submarineswitchwithitemsfeevote" : "submarineswitchfeevote";
|
||||
text = TextManager.GetWithVariables(tag,
|
||||
("[playername]", characterRichString),
|
||||
("[submarinename]", submarineRichString),
|
||||
("[locationname]", endLocation.Name),
|
||||
@@ -198,13 +201,13 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
text = TextManager.GetWithVariables("submarineswitchnofeevote",
|
||||
tag = transferItems ? "submarineswitchwithitemsnofeevote" : "submarineswitchnofeevote";
|
||||
text = TextManager.GetWithVariables(tag,
|
||||
("[playername]", characterRichString),
|
||||
("[submarinename]", submarineRichString));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
votingOnText = RichString.Rich(text);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user