(7ee8dbc11) v0.9.8.0
This commit is contained in:
@@ -135,31 +135,33 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
Color textColor = textBox.Color;
|
||||
switch (command)
|
||||
{
|
||||
case "r":
|
||||
case "radio":
|
||||
textBox.TextColor = ChatMessage.MessageColor[(int)ChatMessageType.Radio];
|
||||
textColor = ChatMessage.MessageColor[(int)ChatMessageType.Radio];
|
||||
break;
|
||||
case "d":
|
||||
case "dead":
|
||||
textBox.TextColor = ChatMessage.MessageColor[(int)ChatMessageType.Dead];
|
||||
textColor = ChatMessage.MessageColor[(int)ChatMessageType.Dead];
|
||||
break;
|
||||
default:
|
||||
if (Character.Controlled != null && (Character.Controlled.IsDead || Character.Controlled.SpeechImpediment >= 100.0f))
|
||||
{
|
||||
textBox.TextColor = ChatMessage.MessageColor[(int)ChatMessageType.Dead];
|
||||
textColor = ChatMessage.MessageColor[(int)ChatMessageType.Dead];
|
||||
}
|
||||
else if (command != "") //PMing
|
||||
{
|
||||
textBox.TextColor = ChatMessage.MessageColor[(int)ChatMessageType.Private];
|
||||
textColor = ChatMessage.MessageColor[(int)ChatMessageType.Private];
|
||||
}
|
||||
else
|
||||
{
|
||||
textBox.TextColor = ChatMessage.MessageColor[(int)ChatMessageType.Default];
|
||||
textColor = ChatMessage.MessageColor[(int)ChatMessageType.Default];
|
||||
}
|
||||
break;
|
||||
}
|
||||
textBox.TextColor = textBox.TextBlock.SelectedTextColor = textColor;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -252,21 +254,29 @@ namespace Barotrauma
|
||||
Visible = false,
|
||||
CanBeFocused = false
|
||||
};
|
||||
var senderText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), popupMsg.RectTransform, Anchor.TopRight),
|
||||
senderName, textColor: senderColor, font: GUI.SmallFont, textAlignment: Alignment.TopRight)
|
||||
var content = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.9f), popupMsg.RectTransform, Anchor.Center));
|
||||
Vector2 senderTextSize = Vector2.Zero;
|
||||
if (!string.IsNullOrEmpty(senderName))
|
||||
{
|
||||
var senderText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), content.RectTransform),
|
||||
senderName, textColor: senderColor, style: null, font: GUI.SmallFont)
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
senderTextSize = senderText.Font.MeasureString(senderText.WrappedText);
|
||||
senderText.RectTransform.MinSize = new Point(0, senderText.Rect.Height);
|
||||
}
|
||||
var msgPopupText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), content.RectTransform),
|
||||
displayedText, textColor: message.Color, font: GUI.SmallFont, textAlignment: Alignment.BottomLeft, style: null, wrap: true)
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
var msgPopupText = new GUITextBlock(new RectTransform(new Vector2(0.8f, 0.0f), popupMsg.RectTransform, Anchor.TopRight)
|
||||
{ AbsoluteOffset = new Point(0, senderText.Rect.Height) },
|
||||
displayedText, textColor: message.Color, font: GUI.SmallFont, textAlignment: Alignment.TopRight, style: null, wrap: true)
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
int textWidth = (int)Math.Max(
|
||||
msgPopupText.Font.MeasureString(msgPopupText.WrappedText).X,
|
||||
senderText.Font.MeasureString(senderText.WrappedText).X);
|
||||
popupMsg.RectTransform.Resize(new Point(textWidth + 20, msgPopupText.Rect.Bottom - senderText.Rect.Y), resizeChildren: false);
|
||||
msgPopupText.RectTransform.MinSize = new Point(0, msgPopupText.Rect.Height);
|
||||
Vector2 msgSize = msgPopupText.Font.MeasureString(msgPopupText.WrappedText);
|
||||
int textWidth = (int)Math.Max(msgSize.X + msgPopupText.Padding.X + msgPopupText.Padding.Z, senderTextSize.X) + 10;
|
||||
popupMsg.RectTransform.Resize(new Point((int)(textWidth / content.RectTransform.RelativeSize.X) , (int)((senderTextSize.Y + msgSize.Y) / content.RectTransform.RelativeSize.Y)), resizeChildren: true);
|
||||
popupMsg.RectTransform.IsFixedSize = true;
|
||||
content.Recalculate();
|
||||
popupMessages.Enqueue(popupMsg);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,16 +5,6 @@ using System.Xml.Linq;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
public enum TransitionMode
|
||||
{
|
||||
Linear,
|
||||
Smooth,
|
||||
Smoother,
|
||||
EaseIn,
|
||||
EaseOut,
|
||||
Exponential
|
||||
}
|
||||
|
||||
public enum SpriteFallBackState
|
||||
{
|
||||
None,
|
||||
|
||||
@@ -524,23 +524,9 @@ namespace Barotrauma
|
||||
};
|
||||
}
|
||||
|
||||
private float GetEasing(TransitionMode easing, float t)
|
||||
{
|
||||
return easing switch
|
||||
{
|
||||
TransitionMode.Smooth => MathUtils.SmoothStep(t),
|
||||
TransitionMode.Smoother => MathUtils.SmootherStep(t),
|
||||
TransitionMode.EaseIn => MathUtils.EaseIn(t),
|
||||
TransitionMode.EaseOut => MathUtils.EaseOut(t),
|
||||
TransitionMode.Exponential => t * t,
|
||||
TransitionMode.Linear => t,
|
||||
_ => t,
|
||||
};
|
||||
}
|
||||
|
||||
protected Color GetBlendedColor(Color targetColor, ref Color blendedColor)
|
||||
{
|
||||
blendedColor = ColorCrossFadeTime > 0 ? Color.Lerp(blendedColor, targetColor, MathUtils.InverseLerp(ColorCrossFadeTime, 0, GetEasing(ColorTransition, colorFadeTimer))) : targetColor;
|
||||
blendedColor = ColorCrossFadeTime > 0 ? Color.Lerp(blendedColor, targetColor, MathUtils.InverseLerp(ColorCrossFadeTime, 0, ToolBox.GetEasing(ColorTransition, colorFadeTimer))) : targetColor;
|
||||
return blendedColor;
|
||||
}
|
||||
|
||||
@@ -598,7 +584,7 @@ namespace Barotrauma
|
||||
foreach (UISprite uiSprite in previousSprites)
|
||||
{
|
||||
float alphaMultiplier = SpriteCrossFadeTime > 0 && (uiSprite.CrossFadeOut || currentSprites != null && currentSprites.Any(s => s.CrossFadeIn))
|
||||
? MathUtils.InverseLerp(0, SpriteCrossFadeTime, GetEasing(uiSprite.TransitionMode, spriteFadeTimer)) : 0;
|
||||
? MathUtils.InverseLerp(0, SpriteCrossFadeTime, ToolBox.GetEasing(uiSprite.TransitionMode, spriteFadeTimer)) : 0;
|
||||
if (alphaMultiplier > 0)
|
||||
{
|
||||
uiSprite.Draw(spriteBatch, rect, previousColor * alphaMultiplier, SpriteEffects);
|
||||
@@ -612,7 +598,7 @@ namespace Barotrauma
|
||||
foreach (UISprite uiSprite in currentSprites)
|
||||
{
|
||||
float alphaMultiplier = SpriteCrossFadeTime > 0 && (uiSprite.CrossFadeIn || previousSprites != null && previousSprites.Any(s => s.CrossFadeOut))
|
||||
? MathUtils.InverseLerp(SpriteCrossFadeTime, 0, GetEasing(uiSprite.TransitionMode, spriteFadeTimer)) : (_currentColor.A / 255.0f);
|
||||
? MathUtils.InverseLerp(SpriteCrossFadeTime, 0, ToolBox.GetEasing(uiSprite.TransitionMode, spriteFadeTimer)) : (_currentColor.A / 255.0f);
|
||||
if (alphaMultiplier > 0)
|
||||
{
|
||||
uiSprite.Draw(spriteBatch, rect, _currentColor * alphaMultiplier, SpriteEffects);
|
||||
|
||||
@@ -95,6 +95,15 @@ namespace Barotrauma
|
||||
set { button.TextColor = value; }
|
||||
}
|
||||
|
||||
public override ScalableFont Font
|
||||
{
|
||||
get { return button?.Font ?? base.Font; }
|
||||
set
|
||||
{
|
||||
if (button != null) { button.Font = value; }
|
||||
}
|
||||
}
|
||||
|
||||
public void ReceiveTextInput(char inputChar)
|
||||
{
|
||||
GUI.KeyboardDispatcher.Subscriber = null;
|
||||
@@ -168,12 +177,11 @@ namespace Barotrauma
|
||||
Anchor listAnchor = dropAbove ? Anchor.TopCenter : Anchor.BottomCenter;
|
||||
Pivot listPivot = dropAbove ? Pivot.BottomCenter : Pivot.TopCenter;
|
||||
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,
|
||||
OnSelected = SelectItem
|
||||
Enabled = !selectMultiple
|
||||
};
|
||||
if (!selectMultiple) { listBox.OnSelected = SelectItem; }
|
||||
GUI.Style.Apply(listBox, "GUIListBox", this);
|
||||
GUI.Style.Apply(listBox.ContentBackground, "GUIListBox", this);
|
||||
|
||||
@@ -245,7 +253,7 @@ namespace Barotrauma
|
||||
ToolTip = toolTip
|
||||
};
|
||||
|
||||
new GUITickBox(new RectTransform(new Point((int)(button.Rect.Height * 0.8f)), frame.RectTransform, anchor: Anchor.CenterLeft), text)
|
||||
new GUITickBox(new RectTransform(new Vector2(1.0f, 0.8f), frame.RectTransform, anchor: Anchor.CenterLeft) { MaxSize = new Point(int.MaxValue, (int)(button.Rect.Height * 0.8f)) }, text)
|
||||
{
|
||||
UserData = userData,
|
||||
ToolTip = toolTip,
|
||||
|
||||
@@ -328,11 +328,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (text == null) { return; }
|
||||
|
||||
censoredText = "";
|
||||
for (int i = 0; i < text.Length; i++)
|
||||
{
|
||||
censoredText += "\u2022";
|
||||
}
|
||||
censoredText = string.IsNullOrEmpty(text) ? "" : new string('\u2022', text.Length);
|
||||
|
||||
var rect = Rect;
|
||||
|
||||
@@ -446,9 +442,10 @@ namespace Barotrauma
|
||||
Rectangle prevScissorRect = spriteBatch.GraphicsDevice.ScissorRectangle;
|
||||
if (overflowClipActive)
|
||||
{
|
||||
spriteBatch.End();
|
||||
Rectangle scissorRect = new Rectangle(rect.X + (int)padding.X, rect.Y, rect.Width - (int)padding.X - (int)padding.Z, rect.Height);
|
||||
spriteBatch.GraphicsDevice.ScissorRectangle = scissorRect;
|
||||
if (!scissorRect.Intersects(prevScissorRect)) { return; }
|
||||
spriteBatch.End();
|
||||
spriteBatch.GraphicsDevice.ScissorRectangle = Rectangle.Intersect(prevScissorRect, scissorRect);
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, samplerState: GUI.SamplerState, rasterizerState: GameMain.ScissorTestEnable);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user