Unstable 0.16.0.0
This commit is contained in:
@@ -44,12 +44,12 @@ namespace Barotrauma
|
||||
Waiting, // Hourglass
|
||||
WaitingBackground // Cursor + Hourglass
|
||||
}
|
||||
|
||||
|
||||
public static class GUI
|
||||
{
|
||||
public static GUICanvas Canvas => GUICanvas.Instance;
|
||||
public static CursorState MouseCursor = CursorState.Default;
|
||||
|
||||
|
||||
public static readonly SamplerState SamplerState = new SamplerState()
|
||||
{
|
||||
Filter = TextureFilter.Linear,
|
||||
@@ -116,14 +116,14 @@ namespace Barotrauma
|
||||
|
||||
public static float SlicedSpriteScale
|
||||
{
|
||||
get
|
||||
get
|
||||
{
|
||||
if (Math.Abs(1.0f - Scale) < 0.1f)
|
||||
{
|
||||
if (Math.Abs(1.0f - Scale) < 0.1f)
|
||||
{
|
||||
//don't scale if very close to the "reference resolution"
|
||||
return 1.0f;
|
||||
return 1.0f;
|
||||
}
|
||||
return Scale;
|
||||
return Scale;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,7 +306,7 @@ namespace Barotrauma
|
||||
t = new Texture2D(GraphicsDevice, 1, 1);
|
||||
t.SetData(new Color[] { Color.White });// fill the texture with white
|
||||
});
|
||||
|
||||
|
||||
SubmarineIcon = new Sprite("Content/UI/MainIconsAtlas.png", new Rectangle(452, 385, 182, 81), new Vector2(0.5f, 0.5f));
|
||||
arrow = new Sprite("Content/UI/MainIconsAtlas.png", new Rectangle(393, 393, 49, 45), new Vector2(0.5f, 0.5f));
|
||||
SpeechBubbleIcon = new Sprite("Content/UI/MainIconsAtlas.png", new Rectangle(385, 449, 66, 60), new Vector2(0.5f, 0.5f));
|
||||
@@ -314,7 +314,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// By default, all the gui elements are drawn automatically in the same order they appear on the update list.
|
||||
/// By default, all the gui elements are drawn automatically in the same order they appear on the update list.
|
||||
/// </summary>
|
||||
public static void Draw(Camera cam, SpriteBatch spriteBatch)
|
||||
{
|
||||
@@ -706,11 +706,11 @@ namespace Barotrauma
|
||||
spriteBatch.Begin(SpriteSortMode.Immediate, effect: GameMain.GameScreen.PostProcessEffect);
|
||||
|
||||
float scale = Math.Max(
|
||||
(float)GameMain.GraphicsWidth / backgroundSprite.SourceRect.Width,
|
||||
(float)GameMain.GraphicsWidth / backgroundSprite.SourceRect.Width,
|
||||
(float)GameMain.GraphicsHeight / backgroundSprite.SourceRect.Height) * 1.1f;
|
||||
float paddingX = backgroundSprite.SourceRect.Width * scale - GameMain.GraphicsWidth;
|
||||
float paddingY = backgroundSprite.SourceRect.Height * scale - GameMain.GraphicsHeight;
|
||||
|
||||
|
||||
double noiseT = (Timing.TotalTime * 0.02f);
|
||||
Vector2 pos = new Vector2((float)PerlinNoise.CalculatePerlin(noiseT, noiseT, 0) - 0.5f, (float)PerlinNoise.CalculatePerlin(noiseT, noiseT, 0.5f) - 0.5f);
|
||||
pos = new Vector2(pos.X * paddingX, pos.Y * paddingY);
|
||||
@@ -719,7 +719,7 @@ namespace Barotrauma
|
||||
new Vector2(GameMain.GraphicsWidth, GameMain.GraphicsHeight) / 2 + pos,
|
||||
null, Color.White, 0.0f, backgroundSprite.size / 2,
|
||||
scale, SpriteEffects.None, 0.0f);
|
||||
|
||||
|
||||
spriteBatch.End();
|
||||
}
|
||||
|
||||
@@ -759,8 +759,8 @@ namespace Barotrauma
|
||||
else
|
||||
{
|
||||
additions.Enqueue(component);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -786,7 +786,7 @@ namespace Barotrauma
|
||||
component.Children.ForEach(c => RemoveFromUpdateList(c));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void ClearUpdateList()
|
||||
@@ -900,7 +900,7 @@ namespace Barotrauma
|
||||
{
|
||||
GUIMessageBox.VisibleBox.AddToGUIUpdateList();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -941,7 +941,7 @@ namespace Barotrauma
|
||||
inventoryIndex = updateList.IndexOf(CharacterHUD.HUDFrame);
|
||||
}
|
||||
|
||||
if ((!PlayerInput.PrimaryMouseButtonHeld() && !PlayerInput.PrimaryMouseButtonClicked()) ||
|
||||
if ((!PlayerInput.PrimaryMouseButtonHeld() && !PlayerInput.PrimaryMouseButtonClicked()) ||
|
||||
(prevMouseOn == null && !PlayerInput.SecondaryMouseButtonHeld() && !Inventory.DraggingItems.Any()))
|
||||
{
|
||||
for (var i = updateList.Count - 1; i > inventoryIndex; i--)
|
||||
@@ -967,7 +967,7 @@ namespace Barotrauma
|
||||
return MouseOn;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static CursorState UpdateMouseCursorState(GUIComponent c)
|
||||
{
|
||||
lock (mutex)
|
||||
@@ -994,7 +994,7 @@ namespace Barotrauma
|
||||
}
|
||||
if (Wire.DraggingWire != null) { return CursorState.Dragging; }
|
||||
}
|
||||
|
||||
|
||||
if (c == null || c is GUICustomComponent)
|
||||
{
|
||||
switch (Screen.Selected)
|
||||
@@ -1027,7 +1027,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (c != null && c.Visible)
|
||||
{
|
||||
if (c.AlwaysOverrideCursor) { return c.HoverCursor; }
|
||||
@@ -1036,20 +1036,20 @@ namespace Barotrauma
|
||||
// And this is of course picked up as clickable area.
|
||||
// There has to be a better way of checking this but for now this works.
|
||||
var monitorRect = new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight);
|
||||
|
||||
|
||||
var parent = FindInteractParent(c);
|
||||
|
||||
|
||||
if (c.Enabled)
|
||||
{
|
||||
// Some parent elements take priority
|
||||
// but not when the child is a GUIButton or GUITickBox
|
||||
if (!(parent is GUIButton) && !(parent is GUIListBox) ||
|
||||
if (!(parent is GUIButton) && !(parent is GUIListBox) ||
|
||||
(c is GUIButton) || (c is GUITickBox))
|
||||
{
|
||||
if (!c.Rect.Equals(monitorRect)) { return c.HoverCursor; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Children in list boxes can be interacted with despite not having
|
||||
// a GUIButton inside of them so instead of hard coding we check if
|
||||
// the children can be interacted with by checking their hover state
|
||||
@@ -1084,7 +1084,7 @@ namespace Barotrauma
|
||||
{
|
||||
// Health menus
|
||||
if (character.CharacterHealth.MouseOnElement) { return CursorState.Hand; }
|
||||
|
||||
|
||||
if (character.SelectedCharacter != null)
|
||||
{
|
||||
if (character.SelectedCharacter.CharacterHealth.MouseOnElement)
|
||||
@@ -1096,7 +1096,7 @@ namespace Barotrauma
|
||||
// Character is hovering over an item placed in the world
|
||||
if (character.FocusedItem != null) { return CursorState.Hand; }
|
||||
}
|
||||
|
||||
|
||||
return CursorState.Default;
|
||||
|
||||
static GUIComponent FindInteractParent(GUIComponent component)
|
||||
@@ -1130,7 +1130,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static bool ContainsMouse(GUIComponent component)
|
||||
{
|
||||
// If component has a mouse rectangle then use that, if not use it's physical rect
|
||||
@@ -1138,7 +1138,7 @@ namespace Barotrauma
|
||||
component.MouseRect.Contains(PlayerInput.MousePosition) :
|
||||
component.Rect.Contains(PlayerInput.MousePosition);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1153,8 +1153,8 @@ namespace Barotrauma
|
||||
{
|
||||
MouseCursor = CursorState.Waiting;
|
||||
var timeOut = DateTime.Now + new TimeSpan(0, 0, waitSeconds);
|
||||
while (DateTime.Now < timeOut)
|
||||
{
|
||||
while (DateTime.Now < timeOut)
|
||||
{
|
||||
if (endCondition != null)
|
||||
{
|
||||
try
|
||||
@@ -1163,13 +1163,13 @@ namespace Barotrauma
|
||||
}
|
||||
catch { break; }
|
||||
}
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return CoroutineStatus.Running;
|
||||
}
|
||||
if (MouseCursor == CursorState.Waiting) { MouseCursor = CursorState.Default; }
|
||||
yield return CoroutineStatus.Success;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void ClearCursorWait()
|
||||
{
|
||||
lock (mutex)
|
||||
@@ -1208,7 +1208,7 @@ namespace Barotrauma
|
||||
{
|
||||
debugDrawMetadataOffset--;
|
||||
}
|
||||
|
||||
|
||||
if (PlayerInput.KeyHit(Keys.Down))
|
||||
{
|
||||
debugDrawMetadataOffset++;
|
||||
@@ -1240,17 +1240,20 @@ namespace Barotrauma
|
||||
debugDrawMetadataOffset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
HandlePersistingElements(deltaTime);
|
||||
RefreshUpdateList();
|
||||
UpdateMouseOn();
|
||||
Debug.Assert(updateList.Count == updateListSet.Count);
|
||||
updateList.ForEach(c => c.UpdateAuto(deltaTime));
|
||||
foreach (var c in updateList)
|
||||
{
|
||||
c.UpdateAuto(deltaTime);
|
||||
}
|
||||
UpdateMessages(deltaTime);
|
||||
UpdateSavingIndicator(deltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void UpdateMessages(float deltaTime)
|
||||
@@ -1281,17 +1284,16 @@ namespace Barotrauma
|
||||
//only the first message (the currently visible one) is updated at a time
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
foreach (GUIMessage msg in messages)
|
||||
{
|
||||
if (!msg.WorldSpace) { continue; }
|
||||
msg.Timer -= deltaTime;
|
||||
msg.Pos += msg.Velocity * deltaTime;
|
||||
msg.Timer -= deltaTime;
|
||||
msg.Pos += msg.Velocity * deltaTime;
|
||||
}
|
||||
|
||||
messages.RemoveAll(m => m.Timer <= 0.0f);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void UpdateSavingIndicator(float deltaTime)
|
||||
@@ -1628,7 +1630,7 @@ namespace Barotrauma
|
||||
|
||||
private static void DrawMessages(SpriteBatch spriteBatch, Camera cam)
|
||||
{
|
||||
if (messages.Count == 0) return;
|
||||
if (messages.Count == 0) { return; }
|
||||
|
||||
bool useScissorRect = messages.Any(m => !m.WorldSpace);
|
||||
Rectangle prevScissorRect = spriteBatch.GraphicsDevice.ScissorRectangle;
|
||||
@@ -1647,7 +1649,7 @@ namespace Barotrauma
|
||||
|
||||
msg.Font.DrawString(spriteBatch, msg.Text, drawPos + msg.DrawPos + Vector2.One, Color.Black, 0, msg.Origin, 1.0f, SpriteEffects.None, 0);
|
||||
msg.Font.DrawString(spriteBatch, msg.Text, drawPos + msg.DrawPos, msg.Color, 0, msg.Origin, 1.0f, SpriteEffects.None, 0);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
if (useScissorRect)
|
||||
@@ -1656,11 +1658,11 @@ namespace Barotrauma
|
||||
spriteBatch.GraphicsDevice.ScissorRectangle = prevScissorRect;
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred);
|
||||
}
|
||||
|
||||
|
||||
foreach (GUIMessage msg in messages)
|
||||
{
|
||||
if (!msg.WorldSpace) { continue; }
|
||||
|
||||
|
||||
if (cam != null)
|
||||
{
|
||||
float alpha = 1.0f;
|
||||
@@ -1669,7 +1671,7 @@ namespace Barotrauma
|
||||
Vector2 drawPos = cam.WorldToScreen(msg.DrawPos);
|
||||
msg.Font.DrawString(spriteBatch, msg.Text, drawPos + Vector2.One, Color.Black * alpha, 0, msg.Origin, 1.0f, SpriteEffects.None, 0);
|
||||
msg.Font.DrawString(spriteBatch, msg.Text, drawPos, msg.Color * alpha, 0, msg.Origin, 1.0f, SpriteEffects.None, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
messages.RemoveAll(m => m.Timer <= 0.0f);
|
||||
@@ -1770,7 +1772,7 @@ namespace Barotrauma
|
||||
{
|
||||
int textureWidth = Math.Max(radius * 2, 1);
|
||||
int textureHeight = Math.Max(height + radius * 2, 1);
|
||||
|
||||
|
||||
Color[] data = new Color[textureWidth * textureHeight];
|
||||
|
||||
// Colour the entire texture transparent first.
|
||||
@@ -1880,9 +1882,9 @@ namespace Barotrauma
|
||||
/// Creates multiple elements with relative size and positions them automatically.
|
||||
/// </summary>
|
||||
public static List<T> CreateElements<T>(int count, Vector2 relativeSize, RectTransform parent, Func<RectTransform, T> constructor,
|
||||
Anchor anchor = Anchor.TopLeft, Pivot? pivot = null, Point? minSize = null, Point? maxSize = null,
|
||||
int absoluteSpacing = 0, float relativeSpacing = 0, Func<int, int> extraSpacing = null,
|
||||
int startOffsetAbsolute = 0, float startOffsetRelative = 0, bool isHorizontal = false)
|
||||
Anchor anchor = Anchor.TopLeft, Pivot? pivot = null, Point? minSize = null, Point? maxSize = null,
|
||||
int absoluteSpacing = 0, float relativeSpacing = 0, Func<int, int> extraSpacing = null,
|
||||
int startOffsetAbsolute = 0, float startOffsetRelative = 0, bool isHorizontal = false)
|
||||
where T : GUIComponent
|
||||
{
|
||||
return CreateElements(count, parent, constructor, relativeSize, null, anchor, pivot, minSize, maxSize, absoluteSpacing, relativeSpacing, extraSpacing, startOffsetAbsolute, startOffsetRelative, isHorizontal);
|
||||
@@ -1891,8 +1893,8 @@ namespace Barotrauma
|
||||
/// <summary>
|
||||
/// Creates multiple elements with absolute size and positions them automatically.
|
||||
/// </summary>
|
||||
public static List<T> CreateElements<T>(int count, Point absoluteSize, RectTransform parent, Func<RectTransform, T> constructor,
|
||||
Anchor anchor = Anchor.TopLeft, Pivot? pivot = null,
|
||||
public static List<T> CreateElements<T>(int count, Point absoluteSize, RectTransform parent, Func<RectTransform, T> constructor,
|
||||
Anchor anchor = Anchor.TopLeft, Pivot? pivot = null,
|
||||
int absoluteSpacing = 0, float relativeSpacing = 0, Func<int, int> extraSpacing = null,
|
||||
int startOffsetAbsolute = 0, float startOffsetRelative = 0, bool isHorizontal = false)
|
||||
where T : GUIComponent
|
||||
@@ -1991,7 +1993,7 @@ namespace Barotrauma
|
||||
if (i == 0)
|
||||
numberInput.IntValue = value.X;
|
||||
else
|
||||
numberInput.IntValue = value.Y;
|
||||
numberInput.IntValue = value.Y;
|
||||
}
|
||||
return frame;
|
||||
}
|
||||
@@ -2028,6 +2030,16 @@ namespace Barotrauma
|
||||
return frame;
|
||||
}
|
||||
|
||||
public static void NotifyPrompt(string header, string body)
|
||||
{
|
||||
GUIMessageBox msgBox = new GUIMessageBox(header, body, new[] { TextManager.Get("Ok") }, new Vector2(0.2f, 0.175f), minSize: new Point(300, 175));
|
||||
msgBox.Buttons[0].OnClicked = delegate
|
||||
{
|
||||
msgBox.Close();
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
public static GUIMessageBox AskForConfirmation(string header, string body, Action onConfirm, Action onDeny = null)
|
||||
{
|
||||
string[] buttons = { TextManager.Get("Ok"), TextManager.Get("Cancel") };
|
||||
@@ -2051,6 +2063,32 @@ namespace Barotrauma
|
||||
return msgBox;
|
||||
}
|
||||
|
||||
public static GUIMessageBox PromptTextInput(string header, string body, Action<string> onConfirm)
|
||||
{
|
||||
string[] buttons = { TextManager.Get("Ok"), TextManager.Get("Cancel") };
|
||||
GUIMessageBox msgBox = new GUIMessageBox(header, string.Empty, buttons, new Vector2(0.2f, 0.175f), minSize: new Point(300, 175));
|
||||
GUITextBox textBox = new GUITextBox(new RectTransform(Vector2.One, msgBox.Content.RectTransform), text: body)
|
||||
{
|
||||
OverflowClip = true
|
||||
};
|
||||
|
||||
// Cancel button
|
||||
msgBox.Buttons[1].OnClicked = delegate
|
||||
{
|
||||
msgBox.Close();
|
||||
return true;
|
||||
};
|
||||
|
||||
// Ok button
|
||||
msgBox.Buttons[0].OnClicked = delegate
|
||||
{
|
||||
onConfirm.Invoke(textBox.Text);
|
||||
msgBox.Close();
|
||||
return true;
|
||||
};
|
||||
return msgBox;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Element positioning
|
||||
@@ -2210,7 +2248,7 @@ namespace Barotrauma
|
||||
if (disallowedAreas == null) { continue; }
|
||||
foreach (Rectangle rect2 in disallowedAreas)
|
||||
{
|
||||
if (!rect1.Intersects(rect2)) { continue; }
|
||||
if (!rect1.Intersects(rect2)) { continue; }
|
||||
intersections = true;
|
||||
|
||||
Point centerDiff = rect1.Center - rect2.Center;
|
||||
@@ -2330,8 +2368,8 @@ namespace Barotrauma
|
||||
});
|
||||
}
|
||||
|
||||
CreateButton(GameMain.GameSession.GameMode is CampaignMode ? "ReturnToServerlobby" : "EndRound", buttonContainer,
|
||||
verificationTextTag: GameMain.GameSession.GameMode is CampaignMode ? "PauseMenuReturnToServerLobbyVerification" : "EndRoundSubNotAtLevelEnd",
|
||||
CreateButton(GameMain.GameSession.GameMode is CampaignMode ? "ReturnToServerlobby" : "EndRound", buttonContainer,
|
||||
verificationTextTag: GameMain.GameSession.GameMode is CampaignMode ? "PauseMenuReturnToServerLobbyVerification" : "EndRoundSubNotAtLevelEnd",
|
||||
action: () =>
|
||||
{
|
||||
GameMain.Client?.RequestRoundEnd(save: false);
|
||||
@@ -2448,7 +2486,10 @@ namespace Barotrauma
|
||||
|
||||
public static void ClearMessages()
|
||||
{
|
||||
messages.Clear();
|
||||
lock (mutex)
|
||||
{
|
||||
messages.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsFourByThree()
|
||||
|
||||
@@ -219,12 +219,6 @@ namespace Barotrauma
|
||||
|
||||
GUI.Style.ButtonPulse.Draw(spriteBatch, expandRect, ToolBox.GradientLerp(pulseExpand, Color.White, Color.White, Color.Transparent));
|
||||
}
|
||||
|
||||
if (UserData is string s && s == "ReadyCheckButton" && ReadyCheck.lastReadyCheck > DateTime.Now)
|
||||
{
|
||||
float progress = (ReadyCheck.lastReadyCheck - DateTime.Now).Seconds / 60.0f;
|
||||
Frame.Color = ToolBox.GradientLerp(progress, Color.White, GUI.Style.Red);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Update(float deltaTime)
|
||||
|
||||
@@ -317,7 +317,10 @@ namespace Barotrauma
|
||||
set
|
||||
{
|
||||
selected = value;
|
||||
Children.ForEach(c => c.Selected = value);
|
||||
foreach (var child in Children)
|
||||
{
|
||||
child.Selected = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
public virtual ComponentState State
|
||||
@@ -537,7 +540,10 @@ namespace Barotrauma
|
||||
//would be real nice to un-jank this some day
|
||||
ForceUpdate();
|
||||
ForceUpdate();
|
||||
foreach (var child in Children) { child.ForceLayoutRecalculation(); }
|
||||
foreach (var child in Children)
|
||||
{
|
||||
child.ForceLayoutRecalculation();
|
||||
}
|
||||
}
|
||||
|
||||
public void ForceUpdate() => Update((float)Timing.Step);
|
||||
@@ -547,7 +553,10 @@ namespace Barotrauma
|
||||
/// </summary>
|
||||
public void UpdateChildren(float deltaTime, bool recursive)
|
||||
{
|
||||
RectTransform.Children.ForEach(c => c.GUIComponent.UpdateManually(deltaTime, recursive, recursive));
|
||||
foreach (var child in RectTransform.Children)
|
||||
{
|
||||
child.GUIComponent.UpdateManually(deltaTime, recursive, recursive);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -583,7 +592,10 @@ namespace Barotrauma
|
||||
/// </summary>
|
||||
public virtual void DrawChildren(SpriteBatch spriteBatch, bool recursive)
|
||||
{
|
||||
RectTransform.Children.ForEach(c => c.GUIComponent.DrawManually(spriteBatch, recursive, recursive));
|
||||
foreach (RectTransform child in RectTransform.Children)
|
||||
{
|
||||
child.GUIComponent.DrawManually(spriteBatch, recursive, recursive);
|
||||
}
|
||||
}
|
||||
|
||||
protected Color _currentColor;
|
||||
@@ -764,8 +776,8 @@ namespace Barotrauma
|
||||
{
|
||||
toolTipBlock = new GUITextBlock(new RectTransform(new Point(width, height), null), richTextData, toolTip, font: GUI.SmallFont, wrap: true, style: "GUIToolTip");
|
||||
toolTipBlock.RectTransform.NonScaledSize = new Point(
|
||||
(int)(GUI.SmallFont.MeasureString(toolTipBlock.WrappedText).X + padding.X + toolTipBlock.Padding.X + toolTipBlock.Padding.Z),
|
||||
(int)(GUI.SmallFont.MeasureString(toolTipBlock.WrappedText).Y + padding.Y + toolTipBlock.Padding.Y + toolTipBlock.Padding.W));
|
||||
(int)(toolTipBlock.Font.MeasureString(toolTipBlock.WrappedText).X + padding.X + toolTipBlock.Padding.X + toolTipBlock.Padding.Z),
|
||||
(int)(toolTipBlock.Font.MeasureString(toolTipBlock.WrappedText).Y + padding.Y + toolTipBlock.Padding.Y + toolTipBlock.Padding.W));
|
||||
toolTipBlock.userData = toolTip;
|
||||
}
|
||||
|
||||
|
||||
@@ -827,6 +827,13 @@ namespace Barotrauma
|
||||
|
||||
protected override void Update(float deltaTime)
|
||||
{
|
||||
foreach (GUIComponent child in Children)
|
||||
{
|
||||
if (child == ScrollBar || child == Content || child == ContentBackground) { continue; }
|
||||
|
||||
throw new InvalidOperationException($"Children were found in {nameof(GUIListBox)}, Add them to {nameof(GUIListBox)}.{nameof(Content)} instead.");
|
||||
}
|
||||
|
||||
if (!Visible) { return; }
|
||||
|
||||
UpdateChildrenRect();
|
||||
@@ -837,7 +844,6 @@ namespace Barotrauma
|
||||
UpdateScrollBarSize();
|
||||
}
|
||||
|
||||
|
||||
if (FadeElements)
|
||||
{
|
||||
foreach (var (component, _) in childVisible)
|
||||
|
||||
@@ -319,28 +319,29 @@ namespace Barotrauma
|
||||
AbsoluteSpacing = absoluteSpacing.Y,
|
||||
};
|
||||
|
||||
var bottomContainer = new GUIFrame(new RectTransform(new Vector2(0.9f, 0.3f), verticalLayoutGroup.RectTransform), style: null);
|
||||
|
||||
var tickBoxLayoutGroup = new GUILayoutGroup(new RectTransform(new Vector2(0.67f, 1.0f), bottomContainer.RectTransform, anchor: Anchor.CenterLeft),
|
||||
isHorizontal: true, childAnchor: Anchor.CenterLeft)
|
||||
var bottomContainer = new GUIFrame(new RectTransform(new Vector2(0.9f, 0.3f), verticalLayoutGroup.RectTransform), style: null)
|
||||
{
|
||||
Stretch = true,
|
||||
RelativeSpacing = 0.02f
|
||||
CanBeFocused = true
|
||||
};
|
||||
|
||||
var dontShowAgainTickBox = new GUITickBox(new RectTransform(new Vector2(0.5f, 1.0f), tickBoxLayoutGroup.RectTransform),
|
||||
var tickBoxLayoutGroup = new GUILayoutGroup(new RectTransform(new Vector2(0.67f, 1.0f), bottomContainer.RectTransform, anchor: Anchor.CenterLeft))
|
||||
{
|
||||
CanBeFocused = true,
|
||||
Stretch = true
|
||||
};
|
||||
Vector2 tickBoxRelativeSize = new Vector2(1.0f, 0.5f);
|
||||
var dontShowAgainTickBox = new GUITickBox(new RectTransform(tickBoxRelativeSize, tickBoxLayoutGroup.RectTransform),
|
||||
TextManager.Get("hintmessagebox.dontshowagain"))
|
||||
{
|
||||
ToolTip = TextManager.Get("hintmessagebox.dontshowagaintooltip"),
|
||||
UserData = "dontshowagain"
|
||||
};
|
||||
|
||||
//var disableHintsTickBox = new GUITickBox(new RectTransform(new Vector2(0.33f, 1.0f), tickBoxLayoutGroup.RectTransform),
|
||||
// TextManager.Get("hintmessagebox.disablehints"))
|
||||
//{
|
||||
// ToolTip = TextManager.Get("hintmessagebox.disablehintstooltip"),
|
||||
// UserData = "disablehints"
|
||||
//};
|
||||
var disableHintsTickBox = new GUITickBox(new RectTransform(tickBoxRelativeSize, tickBoxLayoutGroup.RectTransform),
|
||||
TextManager.Get("hintmessagebox.disablehints"))
|
||||
{
|
||||
ToolTip = TextManager.Get("hintmessagebox.disablehintstooltip"),
|
||||
UserData = "disablehints"
|
||||
};
|
||||
|
||||
Buttons = new List<GUIButton>(1)
|
||||
{
|
||||
@@ -379,12 +380,16 @@ namespace Barotrauma
|
||||
upperContainerHeight = Math.Max(upperContainerHeight, Icon.Rect.Height);
|
||||
height += upperContainerHeight;
|
||||
height += absoluteSpacing.Y;
|
||||
height += (int)((bottomContainer.RectTransform.RelativeSize.Y / topHorizontalLayoutGroup.RectTransform.RelativeSize.Y) * upperContainerHeight);
|
||||
int bottomContainerHeight = dontShowAgainTickBox.Rect.Height + disableHintsTickBox.Rect.Height;
|
||||
height += bottomContainerHeight;
|
||||
height += absoluteSpacing.Y;
|
||||
if (minSize.HasValue) { height = Math.Max(height, minSize.Value.Y); }
|
||||
|
||||
InnerFrame.RectTransform.NonScaledSize = new Point(InnerFrame.Rect.Width, height);
|
||||
verticalLayoutGroup.RectTransform.NonScaledSize = GetVerticalLayoutGroupSize();
|
||||
float upperContainerRelativeHeight = (float)upperContainerHeight / (upperContainerHeight + bottomContainerHeight);
|
||||
topHorizontalLayoutGroup.RectTransform.RelativeSize = new Vector2(topHorizontalLayoutGroup.RectTransform.RelativeSize.X, upperContainerRelativeHeight);
|
||||
bottomContainer.RectTransform.RelativeSize = new Vector2(bottomContainer.RectTransform.RelativeSize.X, 1.0f - upperContainerRelativeHeight);
|
||||
verticalLayoutGroup.Recalculate();
|
||||
topHorizontalLayoutGroup.Recalculate();
|
||||
Content.Recalculate();
|
||||
|
||||
@@ -29,6 +29,12 @@ namespace Barotrauma
|
||||
ClampChildMouseRects(Content);
|
||||
}
|
||||
|
||||
public override void DrawChildren(SpriteBatch spriteBatch, bool recursive)
|
||||
{
|
||||
//do nothing (the children have to be drawn in the Draw method after the ScissorRectangle has been set)
|
||||
return;
|
||||
}
|
||||
|
||||
protected override void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
if (!Visible) { return; }
|
||||
|
||||
@@ -204,6 +204,12 @@ namespace Barotrauma
|
||||
set { textColor = value; }
|
||||
}
|
||||
|
||||
public Color DisabledTextColor
|
||||
{
|
||||
get => disabledTextColor;
|
||||
set => disabledTextColor = value;
|
||||
}
|
||||
|
||||
private Color? hoverTextColor;
|
||||
public Color HoverTextColor
|
||||
{
|
||||
@@ -303,6 +309,10 @@ namespace Barotrauma
|
||||
if (parseRichText)
|
||||
{
|
||||
RichTextData = Barotrauma.RichTextData.GetRichTextData(text, out text);
|
||||
if (RichTextData != null && RichTextData.Count == 0)
|
||||
{
|
||||
RichTextData = null;
|
||||
}
|
||||
}
|
||||
|
||||
//if the text is in chinese/korean/japanese and we're not using a CJK-compatible font,
|
||||
@@ -457,7 +467,7 @@ namespace Barotrauma
|
||||
while (size == Vector2.Zero)
|
||||
{
|
||||
try { size = Font.MeasureString(string.IsNullOrEmpty(text) ? " " : text); }
|
||||
catch { text = text.Substring(0, text.Length - 1); }
|
||||
catch { text = text.Length > 0 ? text.Substring(0, text.Length - 1) : ""; }
|
||||
}
|
||||
|
||||
return size;
|
||||
|
||||
@@ -70,6 +70,8 @@ namespace Barotrauma
|
||||
private Vector2 selectionEndPos;
|
||||
private Vector2 selectionRectSize;
|
||||
|
||||
private GUICustomComponent caretAndSelectionRenderer;
|
||||
|
||||
private bool mouseHeldInside;
|
||||
|
||||
private readonly Memento<string> memento = new Memento<string>();
|
||||
@@ -178,8 +180,7 @@ namespace Barotrauma
|
||||
}
|
||||
set
|
||||
{
|
||||
base.ToolTip = value;
|
||||
textBlock.ToolTip = value;
|
||||
base.ToolTip = textBlock.ToolTip = caretAndSelectionRenderer.ToolTip = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,7 +269,7 @@ namespace Barotrauma
|
||||
CaretEnabled = true;
|
||||
caretPosDirty = true;
|
||||
|
||||
new GUICustomComponent(new RectTransform(Vector2.One, frame.RectTransform), onDraw: DrawCaretAndSelection);
|
||||
caretAndSelectionRenderer = new GUICustomComponent(new RectTransform(Vector2.One, frame.RectTransform), onDraw: DrawCaretAndSelection);
|
||||
|
||||
int clearButtonWidth = 0;
|
||||
if (createClearButton)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -637,7 +637,15 @@ namespace Barotrauma
|
||||
|
||||
public bool IsParentOf(RectTransform rectT, bool recursive = true)
|
||||
{
|
||||
return children.Contains(rectT) || (recursive && children.Any(c => c.IsParentOf(rectT)));
|
||||
if (children.Contains(rectT)) { return true; }
|
||||
if (recursive)
|
||||
{
|
||||
foreach (var child in children)
|
||||
{
|
||||
if (child.IsParentOf(rectT)) { return true; }
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool IsChildOf(RectTransform rectT, bool recursive = true)
|
||||
|
||||
@@ -414,15 +414,8 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GameMain.Client == null)
|
||||
{
|
||||
subsToShow.AddRange(SubmarineInfo.SavedSubmarines.Where(s => s.IsCampaignCompatible && !GameMain.GameSession.OwnedSubmarines.Any(os => os.Name == s.Name)));
|
||||
}
|
||||
else
|
||||
{
|
||||
subsToShow.AddRange(GameMain.NetLobbyScreen.CampaignSubmarines.Where(s => !GameMain.GameSession.OwnedSubmarines.Any(os => os.Name == s.Name)));
|
||||
}
|
||||
|
||||
subsToShow.AddRange((GameMain.Client is null ? SubmarineInfo.SavedSubmarines : MultiPlayerCampaign.GetCampaignSubs())
|
||||
.Where(s => s.IsCampaignCompatible && !GameMain.GameSession.OwnedSubmarines.Any(os => os.Name == s.Name)));
|
||||
subsToShow.Sort((x, y) => x.SubmarineClass.CompareTo(y.SubmarineClass));
|
||||
}
|
||||
|
||||
@@ -446,20 +439,11 @@ namespace Barotrauma
|
||||
|
||||
if (preview == null)
|
||||
{
|
||||
SubmarineInfo potentialMatch;
|
||||
|
||||
if (GameMain.Client == null)
|
||||
{
|
||||
potentialMatch = SubmarineInfo.SavedSubmarines.FirstOrDefault(s => s.EqualityCheckVal == info.EqualityCheckVal);
|
||||
}
|
||||
else
|
||||
{
|
||||
potentialMatch = GameMain.NetLobbyScreen.CampaignSubmarines.FirstOrDefault(s => s.EqualityCheckVal == info.EqualityCheckVal);
|
||||
}
|
||||
SubmarineInfo potentialMatch = SubmarineInfo.SavedSubmarines.FirstOrDefault(s => s.EqualityCheckVal == info.EqualityCheckVal);
|
||||
|
||||
preview = potentialMatch?.PreviewImage;
|
||||
|
||||
// Try from savedsubmarines with name comparison as a backup
|
||||
// Try name comparison as a backup
|
||||
if (preview == null)
|
||||
{
|
||||
potentialMatch = SubmarineInfo.SavedSubmarines.FirstOrDefault(s => s.Name == info.Name);
|
||||
|
||||
@@ -1543,30 +1543,12 @@ namespace Barotrauma
|
||||
GUITextBlock.AutoScaleAndNormalize(skillNames);
|
||||
}
|
||||
|
||||
private bool HasUnlockedAllTalents(Character controlledCharacter)
|
||||
{
|
||||
if (TalentTree.JobTalentTrees.TryGetValue(controlledCharacter.Info.Job.Prefab.Identifier, out TalentTree talentTree))
|
||||
{
|
||||
foreach (TalentSubTree talentSubTree in talentTree.TalentSubTrees)
|
||||
{
|
||||
foreach (TalentOption talentOption in talentSubTree.TalentOptionStages)
|
||||
{
|
||||
if (talentOption.Talents.None(t => controlledCharacter.HasTalent(t.Identifier)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void UpdateTalentButtons()
|
||||
{
|
||||
Character controlledCharacter = Character.Controlled;
|
||||
if (controlledCharacter?.Info == null) { return; }
|
||||
|
||||
bool unlockedAllTalents = HasUnlockedAllTalents(controlledCharacter);
|
||||
bool unlockedAllTalents = controlledCharacter.HasUnlockedAllTalents();
|
||||
|
||||
if (unlockedAllTalents)
|
||||
{
|
||||
|
||||
@@ -16,7 +16,6 @@ using Microsoft.Xna.Framework.Input;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
|
||||
internal class UpgradeStore
|
||||
{
|
||||
public readonly struct CategoryData
|
||||
@@ -1688,7 +1687,7 @@ namespace Barotrauma
|
||||
|
||||
private bool HasPermission => campaignUI.Campaign.AllowedToManageCampaign();
|
||||
|
||||
private static string FormatCurrency(int money, bool format = true)
|
||||
public static string FormatCurrency(int money, bool format = true)
|
||||
{
|
||||
return TextManager.GetWithVariable("CurrencyFormat", "[credits]", format ? string.Format(CultureInfo.InvariantCulture, "{0:N0}", money) : money.ToString());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user