diff --git a/Barotrauma/BarotraumaClient/MacClient.csproj b/Barotrauma/BarotraumaClient/MacClient.csproj
index 29dd488d3..dff098df6 100644
--- a/Barotrauma/BarotraumaClient/MacClient.csproj
+++ b/Barotrauma/BarotraumaClient/MacClient.csproj
@@ -188,7 +188,61 @@
PreserveNewest
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
diff --git a/Barotrauma/BarotraumaClient/Source/Characters/Animation/Ragdoll.cs b/Barotrauma/BarotraumaClient/Source/Characters/Animation/Ragdoll.cs
index 847902e84..864fd5996 100644
--- a/Barotrauma/BarotraumaClient/Source/Characters/Animation/Ragdoll.cs
+++ b/Barotrauma/BarotraumaClient/Source/Characters/Animation/Ragdoll.cs
@@ -264,57 +264,17 @@ namespace Barotrauma
partial void ImpactProjSpecific(float impact, Body body)
{
- float volume = Math.Min(impact - 3.0f, 1.0f);
+ float volume = MathHelper.Clamp(impact - 3.0f, 0.5f, 1.0f);
- partial void UpdateNetPlayerPositionProjSpecific(float deltaTime, float lowestSubPos)
- {
- if (character != GameMain.Client.Character || !character.AllowInput)
+ if (body.UserData is Limb limb && character.Stun <= 0f)
{
- Limb limb = (Limb)body.UserData;
- if (impact > 3.0f && limb.LastImpactSoundTime < Timing.TotalTime - Limb.SoundInterval)
- {
- limb.LastImpactSoundTime = (float)Timing.TotalTime;
- if (!string.IsNullOrWhiteSpace(limb.HitSoundTag))
- {
- SoundPlayer.PlaySound(limb.HitSoundTag, volume, impact * 100.0f, limb.WorldPosition, character.CurrentHull);
- }
-
- //unconscious/dead characters can't correct their position using AnimController movement
- // -> we need to correct it manually
- if (!character.AllowInput)
- {
- float mainLimbDistSqrd = Vector2.DistanceSquared(MainLimb.PullJointWorldAnchorA, Collider.SimPosition);
- float mainLimbErrorTolerance = 0.1f;
- //if the main limb is roughly at the correct position and the collider isn't moving (much at least),
- //don't attempt to correct the position.
- if (mainLimbDistSqrd > mainLimbErrorTolerance || Collider.LinearVelocity.LengthSquared() > 0.05f)
- {
- SoundPlayer.PlaySound(wearable.Sound, volume, impact * 100.0f, limb.WorldPosition, character.CurrentHull);
- }
- }
- }
- character.MemLocalState.Clear();
+ if (impact > 3.0f) { PlayImpactSound(limb); }
}
- else
+ else if (body.UserData is Limb || body == Collider.FarseerBody)
{
- if (!character.IsRemotePlayer)
+ if (!character.IsRemotePlayer && impact > ImpactTolerance)
{
- if (character.Submarine == null)
- {
- //transform in-sub coordinates to outside coordinates
- if (character.MemLocalState[i].Position.Y > lowestSubPos)
- {
- character.MemLocalState[i].TransformInToOutside();
- }
- }
- else if (currentHull?.Submarine != null)
- {
- //transform outside coordinates to in-sub coordinates
- if (character.MemLocalState[i].Position.Y < lowestSubPos)
- {
- character.MemLocalState[i].TransformOutToInside(currentHull.Submarine);
- }
- }
+ SoundPlayer.PlayDamageSound("LimbBlunt", strongestImpact, Collider);
}
}
if (Character.Controlled == character)
@@ -323,6 +283,29 @@ namespace Barotrauma
}
}
+ public void PlayImpactSound(Limb limb)
+ {
+ limb.LastImpactSoundTime = (float)Timing.TotalTime;
+ if (!string.IsNullOrWhiteSpace(limb.HitSoundTag))
+ {
+ bool inWater = limb.inWater;
+ if (character.CurrentHull != null &&
+ character.CurrentHull.Surface > character.CurrentHull.Rect.Y - character.CurrentHull.Rect.Height &&
+ limb.SimPosition.Y < ConvertUnits.ToSimUnits(character.CurrentHull.Rect.Y - character.CurrentHull.Rect.Height) + limb.body.GetMaxExtent())
+ {
+ inWater = true;
+ }
+ SoundPlayer.PlaySound(inWater ? "footstep_water" : limb.HitSoundTag, limb.WorldPosition, hullGuess: character.CurrentHull);
+ }
+ foreach (WearableSprite wearable in limb.WearingItems)
+ {
+ if (limb.type == wearable.Limb && !string.IsNullOrWhiteSpace(wearable.Sound))
+ {
+ SoundPlayer.PlaySound(wearable.Sound, limb.WorldPosition, hullGuess: character.CurrentHull);
+ }
+ }
+ }
+
partial void Splash(Limb limb, Hull limbHull)
{
//create a splash particle
@@ -385,6 +368,8 @@ namespace Barotrauma
partial void UpdateProjSpecific(float deltaTime)
{
+ if (!character.Enabled || SimplePhysicsEnabled) { return; }
+
LimbJoints.ForEach(j => j.UpdateDeformations(deltaTime));
foreach (var deformation in SpriteDeformations)
{
diff --git a/Barotrauma/BarotraumaClient/Source/Characters/Attack.cs b/Barotrauma/BarotraumaClient/Source/Characters/Attack.cs
index 7d293d643..3b3626b65 100644
--- a/Barotrauma/BarotraumaClient/Source/Characters/Attack.cs
+++ b/Barotrauma/BarotraumaClient/Source/Characters/Attack.cs
@@ -50,7 +50,7 @@ namespace Barotrauma
if (sound != null)
{
- SoundPlayer.PlaySound(sound.Sound, sound.Volume, sound.Range, worldPosition);
+ SoundPlayer.PlaySound(sound.Sound, worldPosition, sound.Volume, sound.Range);
}
}
}
diff --git a/Barotrauma/BarotraumaClient/Source/Characters/Character.cs b/Barotrauma/BarotraumaClient/Source/Characters/Character.cs
index e4668eccd..11f6f191c 100644
--- a/Barotrauma/BarotraumaClient/Source/Characters/Character.cs
+++ b/Barotrauma/BarotraumaClient/Source/Characters/Character.cs
@@ -731,7 +731,7 @@ namespace Barotrauma
var matchingSoundsList = matchingSounds.ToList();
var selectedSound = matchingSoundsList[Rand.Int(matchingSoundsList.Count)];
- soundChannel = SoundPlayer.PlaySound(selectedSound.Sound, selectedSound.Volume, selectedSound.Range, AnimController.WorldPosition, CurrentHull);
+ soundChannel = SoundPlayer.PlaySound(selectedSound.Sound, AnimController.WorldPosition, selectedSound.Volume, selectedSound.Range, CurrentHull);
soundTimer = soundInterval;
}
diff --git a/Barotrauma/BarotraumaClient/Source/Characters/Health/CharacterHealth.cs b/Barotrauma/BarotraumaClient/Source/Characters/Health/CharacterHealth.cs
index 2bcb03cb3..3799e1756 100644
--- a/Barotrauma/BarotraumaClient/Source/Characters/Health/CharacterHealth.cs
+++ b/Barotrauma/BarotraumaClient/Source/Characters/Health/CharacterHealth.cs
@@ -1427,6 +1427,8 @@ namespace Barotrauma
{
foreach (Limb limb in Character.AnimController.Limbs)
{
+ if (limb.HealthIndex < 0 || limb.HealthIndex >= limbHealths.Count) { continue; }
+
limb.BurnOverlayStrength = 0.0f;
limb.DamageOverlayStrength = 0.0f;
if (limbHealths[limb.HealthIndex].Afflictions.Count == 0) continue;
diff --git a/Barotrauma/BarotraumaClient/Source/DebugConsole.cs b/Barotrauma/BarotraumaClient/Source/DebugConsole.cs
index d9b25edd0..a3b0fdc51 100644
--- a/Barotrauma/BarotraumaClient/Source/DebugConsole.cs
+++ b/Barotrauma/BarotraumaClient/Source/DebugConsole.cs
@@ -377,23 +377,27 @@ namespace Barotrauma
GameMain.SubEditorScreen.Select();
}));
- commands.Add(new Command("editparticles|particleeditor", "", (string[] args) =>
+ commands.Add(new Command("editparticles|particleeditor", "editparticles/particleeditor: Switch to the Particle Editor to edit particle effects.", (string[] args) =>
{
GameMain.ParticleEditorScreen.Select();
}));
- commands.Add(new Command("editlevels|editlevel|leveleditor", "", (string[] args) =>
+ commands.Add(new Command("editlevels|leveleditor", "editlevels/leveleditor: Switch to the Level Editor to edit levels.", (string[] args) =>
{
GameMain.LevelEditorScreen.Select();
}));
- commands.Add(new Command("editsprites|editsprite|spriteeditor|spriteedit", "", (string[] args) =>
+ commands.Add(new Command("editsprites|spriteeditor", "editsprites/spriteeditor: Switch to the Sprite Editor to edit the source rects and origins of sprites.", (string[] args) =>
{
GameMain.SpriteEditorScreen.Select();
}));
- commands.Add(new Command("charactereditor|editcharacter|editcharacters|editanimation|editanimations|animedit|animationeditor|animeditor|animationedit", "charactereditor: Edit characters, animations, ragdolls....", (string[] args) =>
+ commands.Add(new Command("editcharacters|charactereditor", "editcharacters/charactereditor: Switch to the Character Editor to edit/create the ragdolls and animations of characters.", (string[] args) =>
{
+ if (Screen.Selected == GameMain.GameScreen)
+ {
+ NewMessage("WARNING: Switching between the character editor and the game view may cause odd behaviour or bugs. Use with caution.", Color.Orange);
+ }
GameMain.CharacterEditorScreen.Select();
}));
diff --git a/Barotrauma/BarotraumaClient/Source/Fonts/ScalableFont.cs b/Barotrauma/BarotraumaClient/Source/Fonts/ScalableFont.cs
index de6bcb3ab..a5ef20967 100644
--- a/Barotrauma/BarotraumaClient/Source/Fonts/ScalableFont.cs
+++ b/Barotrauma/BarotraumaClient/Source/Fonts/ScalableFont.cs
@@ -414,28 +414,6 @@ namespace Barotrauma
return retVal;
}
- public Vector2 MeasureChar(char c)
- {
- Vector2 retVal = Vector2.Zero;
- retVal.Y = baseHeight * 1.8f;
- if (texCoords.TryGetValue(c, out GlyphData gd))
- {
- retVal.X = gd.advance;
- }
- return retVal;
- }
-
- public Vector2 MeasureChar(char c)
- {
- Vector2 retVal = Vector2.Zero;
- retVal.Y = baseHeight * 1.8f;
- if (texCoords.TryGetValue(c, out GlyphData gd))
- {
- retVal.X = gd.advance;
- }
- return retVal;
- }
-
public void Dispose()
{
FontList.Remove(this);
diff --git a/Barotrauma/BarotraumaClient/Source/GUI/ChatBox.cs b/Barotrauma/BarotraumaClient/Source/GUI/ChatBox.cs
index 490c0d21a..ff3cd1dae 100644
--- a/Barotrauma/BarotraumaClient/Source/GUI/ChatBox.cs
+++ b/Barotrauma/BarotraumaClient/Source/GUI/ChatBox.cs
@@ -18,9 +18,7 @@ namespace Barotrauma
private GUITextBox inputBox;
private GUIButton toggleButton;
-
- private GUIButton radioButton;
-
+
private Point screenResolution;
private bool isSinglePlayer;
@@ -60,12 +58,7 @@ namespace Barotrauma
{
get { return guiFrame; }
}
-
- public GUIButton RadioButton
- {
- get { return radioButton; }
- }
-
+
public GUITextBox InputBox
{
get { return inputBox; }
@@ -109,31 +102,7 @@ namespace Barotrauma
{
gui.Text = "";
};
-
- radioButton = new GUIButton(new RectTransform(new Vector2(0.1f, 2.0f), inputBox.RectTransform,
- HUDLayoutSettings.ChatBoxAlignment == Alignment.Right ? Anchor.BottomRight : Anchor.BottomLeft,
- HUDLayoutSettings.ChatBoxAlignment == Alignment.Right ? Pivot.TopRight : Pivot.TopLeft),
- style: null);
- new GUIImage(new RectTransform(Vector2.One, radioButton.RectTransform), radioIcon, scaleToFit: true);
- radioButton.OnClicked = (GUIButton btn, object userData) =>
- {
- if (inputBox.Selected)
- {
- inputBox.Text = "";
- inputBox.Deselect();
- }
- else
- {
- inputBox.Select();
- var radioItem = Character.Controlled?.Inventory?.Items.FirstOrDefault(i => i?.GetComponent() != null);
- if (radioItem != null && Character.Controlled.HasEquippedItem(radioItem) && radioItem.GetComponent().CanTransmit())
- {
- inputBox.Text = "r; ";
- }
- }
- return true;
- };
-
+
ToggleOpen = GameMain.Config.ChatOpen;
}
@@ -368,7 +337,6 @@ namespace Barotrauma
}
openState = MathHelper.Clamp(openState, 0.0f, 1.0f);
int hiddenBoxOffset = guiFrame.Rect.Width + toggleButton.Rect.Width;
- if (radioButton != null) hiddenBoxOffset += (int)(radioButton.Rect.Width * 1.5f);
guiFrame.RectTransform.AbsoluteOffset =
new Point((int)MathHelper.SmoothStep(hiddenBoxOffset * (HUDLayoutSettings.ChatBoxAlignment == Alignment.Left ? -1 : 1), 0, openState), 0);
}
diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUIComponent.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUIComponent.cs
index a02ea16c4..18a473973 100644
--- a/Barotrauma/BarotraumaClient/Source/GUI/GUIComponent.cs
+++ b/Barotrauma/BarotraumaClient/Source/GUI/GUIComponent.cs
@@ -154,6 +154,8 @@ namespace Barotrauma
public bool IgnoreLayoutGroups;
+ public bool IgnoreLayoutGroups;
+
public virtual ScalableFont Font
{
get;
diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUIListBox.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUIListBox.cs
index 049ea780e..528ce8e2b 100644
--- a/Barotrauma/BarotraumaClient/Source/GUI/GUIListBox.cs
+++ b/Barotrauma/BarotraumaClient/Source/GUI/GUIListBox.cs
@@ -511,10 +511,8 @@ namespace Barotrauma
pos = 0;
totalSize += child.Rect.Width + spacing;
}
- else
- {
- pos += child.Rect.Height + spacing;
- }
+ pos += child.Rect.Height + spacing;
+
if (child == children.Last())
{
totalSize += child.Rect.Width + spacing;
@@ -527,10 +525,7 @@ namespace Barotrauma
pos = 0;
totalSize += child.Rect.Height + spacing;
}
- else
- {
- pos += child.Rect.Width + spacing;
- }
+ pos += child.Rect.Width + spacing;
if (child == children.Last())
{
diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUIMessageBox.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUIMessageBox.cs
index cab257fd3..86e835550 100644
--- a/Barotrauma/BarotraumaClient/Source/GUI/GUIMessageBox.cs
+++ b/Barotrauma/BarotraumaClient/Source/GUI/GUIMessageBox.cs
@@ -113,6 +113,12 @@ namespace Barotrauma
Content = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.85f), InnerFrame.RectTransform, Anchor.Center)) { AbsoluteSpacing = 5 };
Tag = tag;
+ InnerFrame = new GUIFrame(new RectTransform(new Point(width, height), RectTransform, Anchor.Center) { IsFixedSize = false }, style: null);
+ GUI.Style.Apply(InnerFrame, "", this);
+
+ Content = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.85f), InnerFrame.RectTransform, Anchor.Center)) { AbsoluteSpacing = 5 };
+ Tag = tag;
+
if (height == 0)
{
string wrappedText = ToolBox.WrapText(text, Content.Rect.Width, GUI.Font);
diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUIStyle.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUIStyle.cs
index c2b17e553..1e588a5ec 100644
--- a/Barotrauma/BarotraumaClient/Source/GUI/GUIStyle.cs
+++ b/Barotrauma/BarotraumaClient/Source/GUI/GUIStyle.cs
@@ -1,4 +1,5 @@
-using Microsoft.Xna.Framework.Graphics;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Xml.Linq;
@@ -9,6 +10,8 @@ namespace Barotrauma
{
private Dictionary componentStyles;
+ private XElement configElement;
+
public ScalableFont Font { get; private set; }
public ScalableFont SmallFont { get; private set; }
public ScalableFont LargeFont { get; private set; }
@@ -45,24 +48,6 @@ namespace Barotrauma
{
switch (subElement.Name.ToString().ToLowerInvariant())
{
- case "font":
- Font = new ScalableFont(subElement, graphicsDevice);
- break;
- case "smallfont":
- SmallFont = new ScalableFont(subElement, graphicsDevice);
- break;
- case "largefont":
- LargeFont = new ScalableFont(subElement, graphicsDevice);
- break;
- case "objectivetitle":
- ObjectiveTitleFont = new ScalableFont(subElement, graphicsDevice);
- break;
- case "objectivename":
- ObjectiveNameFont = new ScalableFont(subElement, graphicsDevice);
- break;
- case "videotitle":
- VideoTitleFont = new ScalableFont(subElement, graphicsDevice);
- break;
case "cursor":
CursorSprite = new Sprite(subElement);
break;
@@ -72,12 +57,58 @@ namespace Barotrauma
case "focusindicator":
FocusIndicator = new SpriteSheet(subElement);
break;
+ case "font":
+ Font = LoadFont(subElement, graphicsDevice);
+ break;
+ case "smallfont":
+ SmallFont = LoadFont(subElement, graphicsDevice);
+ break;
+ case "largefont":
+ LargeFont = LoadFont(subElement, graphicsDevice);
+ break;
+ case "objectivetitle":
+ ObjectiveTitleFont = LoadFont(subElement, graphicsDevice);
+ break;
+ case "objectivename":
+ ObjectiveNameFont = LoadFont(subElement, graphicsDevice);
+ break;
+ case "videotitle":
+ VideoTitleFont = LoadFont(subElement, graphicsDevice);
+ break;
default:
GUIComponentStyle componentStyle = new GUIComponentStyle(subElement);
componentStyles.Add(subElement.Name.ToString().ToLowerInvariant(), componentStyle);
break;
}
}
+ }
+
+ private void RescaleFonts()
+ {
+ foreach (XElement subElement in configElement.Elements())
+ {
+ switch (subElement.Name.ToString().ToLowerInvariant())
+ {
+ case "font":
+ Font.Size = GetFontSize(subElement);
+ break;
+ case "smallfont":
+ SmallFont.Size = GetFontSize(subElement);
+ break;
+ case "largefont":
+ LargeFont.Size = GetFontSize(subElement);
+ break;
+ case "objectivetitle":
+ ObjectiveTitleFont.Size = GetFontSize(subElement);
+ break;
+ case "objectivename":
+ ObjectiveNameFont.Size = GetFontSize(subElement);
+ break;
+ case "videotitle":
+ VideoTitleFont.Size = GetFontSize(subElement);
+ break;
+ }
+ }
return element.GetAttributeBool("dynamicloading", false);
}
@@ -159,6 +190,32 @@ namespace Barotrauma
return style;
}
+ private ScalableFont LoadFont(XElement element, GraphicsDevice graphicsDevice)
+ {
+ string file = element.GetAttributeString("file", "");
+ uint size = GetFontSize(element);
+ return new ScalableFont(file, size, graphicsDevice);
+ }
+
+ private uint GetFontSize(XElement element)
+ {
+ foreach (XElement subElement in element.Elements())
+ {
+ Point maxResolution = subElement.GetAttributePoint("maxresolution", new Point(int.MaxValue, int.MaxValue));
+ if (GameMain.GraphicsWidth <= maxResolution.X && GameMain.GraphicsHeight <= maxResolution.Y)
+ {
+ return (uint)subElement.GetAttributeInt("size", 14);
+ }
+ }
+ return 14;
+ }
+
+ public GUIComponentStyle GetComponentStyle(string name)
+ {
+ componentStyles.TryGetValue(name.ToLowerInvariant(), out GUIComponentStyle style);
+ return style;
+ }
+
public void Apply(GUIComponent targetComponent, string styleName = "", GUIComponent parent = null)
{
GUIComponentStyle componentStyle = null;
diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUITextBlock.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUITextBlock.cs
index 0968704c5..65a234dfb 100644
--- a/Barotrauma/BarotraumaClient/Source/GUI/GUITextBlock.cs
+++ b/Barotrauma/BarotraumaClient/Source/GUI/GUITextBlock.cs
@@ -333,7 +333,7 @@ namespace Barotrauma
{
spriteBatch.End();
spriteBatch.GraphicsDevice.ScissorRectangle = prevScissorRect;
- spriteBatch.Begin(SpriteSortMode.Deferred);
+ spriteBatch.Begin(SpriteSortMode.Deferred, rasterizerState: GameMain.ScissorTestEnable);
}
if (OutlineColor.A * currColor.A > 0.0f) GUI.DrawRectangle(spriteBatch, rect, OutlineColor * (currColor.A / 255.0f), false);
diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUITextBox.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUITextBox.cs
index b21e70a49..73fcd1b3a 100644
--- a/Barotrauma/BarotraumaClient/Source/GUI/GUITextBox.cs
+++ b/Barotrauma/BarotraumaClient/Source/GUI/GUITextBox.cs
@@ -123,6 +123,12 @@ namespace Barotrauma
}
}
+ public bool OverflowClip
+ {
+ get { return textBlock.OverflowClip; }
+ set { textBlock.OverflowClip = value; }
+ }
+
public override bool Enabled
{
get { return enabled; }
@@ -318,7 +324,7 @@ namespace Barotrauma
for (int i = 0; i <= textBlock.Text.Length; i++)
{
Vector2 textSize = Font.MeasureString(textBlock.Text.Substring(0, i));
- Vector2 indexPos = new Vector2(textSize.X + textBlock.Padding.X, textSize.Y + textBlock.Padding.Y);
+ Vector2 indexPos = new Vector2(textSize.X + textBlock.Padding.X, textSize.Y + textBlock.Padding.Y) + textBlock.TextPos - textBlock.Origin;
//DebugConsole.NewMessage($"index: {i}, pos: {indexPos}", Color.WhiteSmoke);
positions.Add(new Tuple(textBlock.Rect.Location.ToVector2() + indexPos, i));
}
@@ -405,7 +411,7 @@ namespace Barotrauma
{
isSelecting = PlayerInput.KeyDown(Keys.LeftShift) || PlayerInput.KeyDown(Keys.RightShift);
}
-
+
if (CaretEnabled)
{
if (textBlock.OverflowClipActive)
@@ -428,7 +434,7 @@ namespace Barotrauma
CalculateCaretPos();
}
}
-
+
if (GUI.KeyboardDispatcher.Subscriber == this)
{
state = ComponentState.Selected;
@@ -547,15 +553,7 @@ namespace Barotrauma
public void ReceiveTextInput(char inputChar)
{
- if (selectedCharacters > 0)
- {
- RemoveSelectedText();
- }
- if (SetText(Text.Insert(CaretIndex, inputChar.ToString())))
- {
- CaretIndex = Math.Min(Text.Length, CaretIndex + 1);
- OnTextChanged?.Invoke(this, Text);
- }
+ ReceiveTextInput(inputChar.ToString());
}
public void ReceiveTextInput(string input)
@@ -564,10 +562,16 @@ namespace Barotrauma
{
RemoveSelectedText();
}
+ Vector2 textPos = textBlock.TextPos;
+ bool wasOverflowClipActive = textBlock.OverflowClipActive;
if (SetText(Text.Insert(CaretIndex, input)))
{
CaretIndex = Math.Min(Text.Length, CaretIndex + input.Length);
OnTextChanged?.Invoke(this, Text);
+ if (textBlock.OverflowClipActive && wasOverflowClipActive && !MathUtils.NearlyEqual(textBlock.TextPos, textPos))
+ {
+ textBlock.TextPos = textPos + Vector2.UnitX * Font.MeasureString(input).X;
+ }
}
}
diff --git a/Barotrauma/BarotraumaClient/Source/GameMain.cs b/Barotrauma/BarotraumaClient/Source/GameMain.cs
index 4708c53b4..a3335c213 100644
--- a/Barotrauma/BarotraumaClient/Source/GameMain.cs
+++ b/Barotrauma/BarotraumaClient/Source/GameMain.cs
@@ -178,6 +178,10 @@ namespace Barotrauma
GUI.KeyboardDispatcher = new EventInput.KeyboardDispatcher(Window);
+ GUI.KeyboardDispatcher = new EventInput.KeyboardDispatcher(Window);
+
+
+ PerformanceCounter = new PerformanceCounter();
PerformanceCounter = new PerformanceCounter();
@@ -718,6 +722,83 @@ namespace Barotrauma
PerformanceCounter.DrawTimeGraph.Update(sw.ElapsedTicks / (float)TimeSpan.TicksPerMillisecond);
}
+ public void ShowCampaignDisclaimer()
+ {
+ var msgBox = new GUIMessageBox(TextManager.Get("CampaignDisclaimerTitle"), TextManager.Get("CampaignDisclaimerText"),
+ new string[] { TextManager.Get("CampaignRoadMapTitle"), TextManager.Get("OK") });
+
+ msgBox.Buttons[0].OnClicked = (btn, userdata) =>
+ {
+ var roadMap = new GUIMessageBox(TextManager.Get("CampaignRoadMapTitle"), TextManager.Get("CampaignRoadMapText"),
+ new string[] { TextManager.Get("Back"), TextManager.Get("OK") });
+ roadMap.Buttons[0].OnClicked = (_, __) => { ShowCampaignDisclaimer(); return true; };
+ roadMap.Buttons[0].OnClicked += roadMap.Close;
+ roadMap.Buttons[1].OnClicked += roadMap.Close;
+ return true;
+ };
+ msgBox.Buttons[0].OnClicked += msgBox.Close;
+ msgBox.Buttons[1].OnClicked += msgBox.Close;
+
+ Config.CampaignDisclaimerShown = true;
+ Config.SaveNewPlayerConfig();
+ }
+
+ public void ShowEditorDisclaimer()
+ {
+ var msgBox = new GUIMessageBox(TextManager.Get("EditorDisclaimerTitle"), TextManager.Get("EditorDisclaimerText"));
+ var linkHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.25f), msgBox.Content.RectTransform)) { Stretch = true, RelativeSpacing = 0.025f };
+ List> links = new List>()
+ {
+ new Pair(TextManager.Get("EditorDisclaimerWikiLink"),TextManager.Get("EditorDisclaimerWikiUrl")),
+ new Pair(TextManager.Get("EditorDisclaimerDiscordLink"),TextManager.Get("EditorDisclaimerDiscordUrl")),
+ new Pair(TextManager.Get("EditorDisclaimerForumLink"),TextManager.Get("EditorDisclaimerForumUrl")),
+ };
+ foreach (var link in links)
+ {
+ new GUIButton(new RectTransform(new Vector2(1.0f, 0.2f), linkHolder.RectTransform), link.First, style: "MainMenuGUIButton", textAlignment: Alignment.Left)
+ {
+ UserData = link.Second,
+ OnClicked = (btn, userdata) =>
+ {
+ Process.Start(userdata as string);
+ return true;
+ }
+ };
+ }
+
+ msgBox.Text.RectTransform.MaxSize = new Point(int.MaxValue, msgBox.Text.Rect.Height);
+ linkHolder.RectTransform.MaxSize = new Point(int.MaxValue, linkHolder.Rect.Height);
+ msgBox.RectTransform.MinSize = new Point(0, msgBox.Rect.Height + linkHolder.Rect.Height + msgBox.Buttons.First().Rect.Height * 8);
+ Config.EditorDisclaimerShown = true;
+ Config.SaveNewPlayerConfig();
+ }
+
+ // ToDo: Move texts/links to localization, when possible.
+ public void ShowBugReporter()
+ {
+ var msgBox = new GUIMessageBox("", "");
+ var linkHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.5f), msgBox.Content.RectTransform)) { Stretch = true, RelativeSpacing = 0.05f };
+
+ List> links = new List>()
+ {
+ new Pair("Barotrauma Feedback Form","https://barotraumagame.com/feedback"),
+ new Pair("Github Issue Form (Needs account)","https://github.com/Regalis11/Barotrauma/issues/new?template=bug_report.md")
+ };
+ foreach (var link in links)
+ {
+ new GUIButton(new RectTransform(new Vector2(1.0f, 0.2f), linkHolder.RectTransform), link.First, style: "MainMenuGUIButton", textAlignment: Alignment.Left)
+ {
+ UserData = link.Second,
+ OnClicked = (btn, userdata) =>
+ {
+ Process.Start(userdata as string);
+ msgBox.Close();
+ return true;
+ }
+ };
+ }
+ }
+
static bool waitForKeyHit = true;
public CoroutineHandle ShowLoading(IEnumerable