(f2e516dfe) v0.9.3.2
This commit is contained in:
@@ -83,6 +83,7 @@ namespace Barotrauma
|
||||
public static ScalableFont VideoTitleFont => Style?.VideoTitleFont;
|
||||
public static ScalableFont ObjectiveTitleFont => Style?.ObjectiveTitleFont;
|
||||
public static ScalableFont ObjectiveNameFont => Style?.ObjectiveNameFont;
|
||||
public static ScalableFont CJKFont { get; private set; }
|
||||
|
||||
public static UISprite UIGlow => Style.UIGlow;
|
||||
|
||||
@@ -154,6 +155,7 @@ namespace Barotrauma
|
||||
{
|
||||
GUI.graphicsDevice = graphicsDevice;
|
||||
var uiStyles = ContentPackage.GetFilesOfType(selectedContentPackages, ContentType.UIStyle).ToList();
|
||||
|
||||
if (uiStyles.Count == 0)
|
||||
{
|
||||
DebugConsole.ThrowError("No UI styles defined in the selected content package!");
|
||||
@@ -165,6 +167,11 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
Style = new GUIStyle(uiStyles[0], graphicsDevice);
|
||||
if (CJKFont == null)
|
||||
{
|
||||
CJKFont = new ScalableFont("Content/Fonts/NotoSans/NotoSansCJKsc-Bold.otf",
|
||||
Font.Size, graphicsDevice, dynamicLoading: true, isCJK: true);
|
||||
}
|
||||
}
|
||||
|
||||
public static void LoadContent(bool loadSounds = true)
|
||||
@@ -408,7 +415,7 @@ namespace Barotrauma
|
||||
|
||||
if (Character.Controlled?.Inventory != null)
|
||||
{
|
||||
if (!Character.Controlled.LockHands && Character.Controlled.Stun >= -0.1f && !Character.Controlled.IsDead)
|
||||
if (!Character.Controlled.LockHands && Character.Controlled.Stun < 0.1f && !Character.Controlled.IsDead)
|
||||
{
|
||||
Inventory.DrawFront(spriteBatch);
|
||||
}
|
||||
@@ -1563,9 +1570,10 @@ namespace Barotrauma
|
||||
button.OnClicked += (btn, userData) =>
|
||||
{
|
||||
var quitButton = button;
|
||||
if (GameMain.GameSession != null)
|
||||
if (GameMain.GameSession != null || (Screen.Selected is CharacterEditorScreen charEditScreen || Screen.Selected is SubEditorScreen subEditScreen))
|
||||
{
|
||||
var msgBox = new GUIMessageBox("", TextManager.Get("PauseMenuQuitVerification"), new string[] { TextManager.Get("Yes"), TextManager.Get("Cancel") })
|
||||
string text = GameMain.GameSession == null ? "PauseMenuQuitVerificationEditor" : "PauseMenuQuitVerification";
|
||||
var msgBox = new GUIMessageBox("", TextManager.Get(text), new string[] { TextManager.Get("Yes"), TextManager.Get("Cancel") })
|
||||
{
|
||||
UserData = "verificationprompt"
|
||||
};
|
||||
|
||||
@@ -188,7 +188,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (!Visible) return;
|
||||
base.Update(deltaTime);
|
||||
if (Rect.Contains(PlayerInput.MousePosition) && CanBeSelected && Enabled && GUI.IsMouseOn(this))
|
||||
if (Rect.Contains(PlayerInput.MousePosition) && CanBeSelected && CanBeFocused && Enabled && GUI.IsMouseOn(this))
|
||||
{
|
||||
state = ComponentState.Hover;
|
||||
if (PlayerInput.LeftButtonDown())
|
||||
|
||||
@@ -22,10 +22,9 @@ namespace Barotrauma
|
||||
public GUIScrollBar ScrollBar { get; private set; }
|
||||
public GUIFrame Content { get; private set; }
|
||||
|
||||
private Dictionary<GUIComponent, bool> childVisible = new Dictionary<GUIComponent, bool>();
|
||||
|
||||
private int totalSize;
|
||||
|
||||
private int spacing;
|
||||
|
||||
private bool childrenNeedsRecalculation;
|
||||
private bool scrollBarNeedsRecalculation;
|
||||
|
||||
@@ -95,11 +94,7 @@ namespace Barotrauma
|
||||
get { return totalSize; }
|
||||
}
|
||||
|
||||
public int Spacing
|
||||
{
|
||||
get { return spacing; }
|
||||
set { spacing = value; }
|
||||
}
|
||||
public int Spacing { get; set; }
|
||||
|
||||
public override Color Color
|
||||
{
|
||||
@@ -244,37 +239,37 @@ namespace Barotrauma
|
||||
{
|
||||
if (ScrollBar.IsHorizontal)
|
||||
{
|
||||
if (y + child.Rect.Height + spacing > Content.Rect.Height)
|
||||
if (y + child.Rect.Height + Spacing > Content.Rect.Height)
|
||||
{
|
||||
y = 0;
|
||||
x += child.Rect.Width + spacing;
|
||||
x += child.Rect.Width + Spacing;
|
||||
if (child.RectTransform.AbsoluteOffset.X != x || child.RectTransform.AbsoluteOffset.Y != y)
|
||||
{
|
||||
child.RectTransform.AbsoluteOffset = new Point(x, y);
|
||||
}
|
||||
y += child.Rect.Height + spacing;
|
||||
y += child.Rect.Height + Spacing;
|
||||
}
|
||||
else
|
||||
{
|
||||
y += child.Rect.Height + spacing;
|
||||
y += child.Rect.Height + Spacing;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (x + child.Rect.Width + spacing > Content.Rect.Width)
|
||||
if (x + child.Rect.Width + Spacing > Content.Rect.Width)
|
||||
{
|
||||
x = 0;
|
||||
y += child.Rect.Height + spacing;
|
||||
y += child.Rect.Height + Spacing;
|
||||
if (child.RectTransform.AbsoluteOffset.X != x || child.RectTransform.AbsoluteOffset.Y != y)
|
||||
{
|
||||
child.RectTransform.AbsoluteOffset = new Point(x, y);
|
||||
}
|
||||
x += child.Rect.Width + spacing;
|
||||
x += child.Rect.Width + Spacing;
|
||||
}
|
||||
else
|
||||
{
|
||||
x += child.Rect.Width + spacing;
|
||||
x += child.Rect.Width + Spacing;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -282,11 +277,11 @@ namespace Barotrauma
|
||||
{
|
||||
if (ScrollBar.IsHorizontal)
|
||||
{
|
||||
x += child.Rect.Width + spacing;
|
||||
x += child.Rect.Width + Spacing;
|
||||
}
|
||||
else
|
||||
{
|
||||
y += child.Rect.Height + spacing;
|
||||
y += child.Rect.Height + Spacing;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -327,10 +322,23 @@ namespace Barotrauma
|
||||
public override void AddToGUIUpdateList(bool ignoreChildren = false, int order = 0)
|
||||
{
|
||||
if (!Visible) { return; }
|
||||
|
||||
foreach (GUIComponent child in Content.Children)
|
||||
{
|
||||
if (!childVisible.ContainsKey(child)) { childVisible[child] = child.Visible; }
|
||||
if (childVisible[child] != child.Visible)
|
||||
{
|
||||
childVisible[child] = child.Visible;
|
||||
childrenNeedsRecalculation = true;
|
||||
scrollBarNeedsRecalculation = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (childrenNeedsRecalculation)
|
||||
{
|
||||
RecalculateChildren();
|
||||
childVisible.Clear();
|
||||
}
|
||||
|
||||
UpdateOrder = order;
|
||||
@@ -511,30 +519,30 @@ namespace Barotrauma
|
||||
{
|
||||
if (ScrollBar.IsHorizontal)
|
||||
{
|
||||
if (pos + child.Rect.Height + spacing > Content.Rect.Height)
|
||||
if (pos + child.Rect.Height + Spacing > Content.Rect.Height)
|
||||
{
|
||||
pos = 0;
|
||||
totalSize += child.Rect.Width + spacing;
|
||||
totalSize += child.Rect.Width + Spacing;
|
||||
}
|
||||
pos += child.Rect.Height + spacing;
|
||||
pos += child.Rect.Height + Spacing;
|
||||
|
||||
if (child == children.Last())
|
||||
{
|
||||
totalSize += child.Rect.Width + spacing;
|
||||
totalSize += child.Rect.Width + Spacing;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pos + child.Rect.Width + spacing > Content.Rect.Width)
|
||||
if (pos + child.Rect.Width + Spacing > Content.Rect.Width)
|
||||
{
|
||||
pos = 0;
|
||||
totalSize += child.Rect.Height + spacing;
|
||||
totalSize += child.Rect.Height + Spacing;
|
||||
}
|
||||
pos += child.Rect.Width + spacing;
|
||||
pos += child.Rect.Width + Spacing;
|
||||
|
||||
if (child == children.Last())
|
||||
{
|
||||
totalSize += child.Rect.Height + spacing;
|
||||
totalSize += child.Rect.Height + Spacing;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -545,7 +553,7 @@ namespace Barotrauma
|
||||
{
|
||||
totalSize += (ScrollBar.IsHorizontal) ? child.Rect.Width : child.Rect.Height;
|
||||
}
|
||||
totalSize += Content.CountChildren * spacing;
|
||||
totalSize += Content.CountChildren * Spacing;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -56,7 +56,21 @@ namespace Barotrauma
|
||||
{
|
||||
if (!Visible) return;
|
||||
|
||||
if (ProgressGetter != null) BarSize = ProgressGetter();
|
||||
if (ProgressGetter != null)
|
||||
{
|
||||
float newSize = MathHelper.Clamp(ProgressGetter(), 0.0f, 1.0f);
|
||||
if (!MathUtils.IsValid(newSize))
|
||||
{
|
||||
GameAnalyticsManager.AddErrorEventOnce(
|
||||
"GUIProgressBar.Draw:GetProgress",
|
||||
GameAnalyticsSDK.Net.EGAErrorSeverity.Error,
|
||||
"ProgressGetter of a GUIProgressBar (" + ProgressGetter.Target.ToString() + " - " + ProgressGetter.Method.ToString() + ") returned an invalid value (" + newSize + ")\n" + Environment.StackTrace);
|
||||
}
|
||||
else
|
||||
{
|
||||
BarSize = newSize;
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle sliderRect = new Rectangle(
|
||||
frame.Rect.X,
|
||||
|
||||
@@ -155,7 +155,8 @@ namespace Barotrauma
|
||||
string file = GetFontFilePath(element);
|
||||
uint size = GetFontSize(element);
|
||||
bool dynamicLoading = GetFontDynamicLoading(element);
|
||||
return new ScalableFont(file, size, graphicsDevice, dynamicLoading);
|
||||
bool isCJK = GetIsCJK(element);
|
||||
return new ScalableFont(file, size, graphicsDevice, dynamicLoading, isCJK);
|
||||
}
|
||||
|
||||
private uint GetFontSize(XElement element)
|
||||
@@ -200,6 +201,20 @@ namespace Barotrauma
|
||||
return element.GetAttributeBool("dynamicloading", false);
|
||||
}
|
||||
|
||||
private bool GetIsCJK(XElement element)
|
||||
{
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
if (subElement.Name.ToString().ToLowerInvariant() != "override") { continue; }
|
||||
string language = subElement.GetAttributeString("language", "").ToLowerInvariant();
|
||||
if (GameMain.Config.Language.ToLowerInvariant() == language)
|
||||
{
|
||||
return subElement.GetAttributeBool("iscjk", false);
|
||||
}
|
||||
}
|
||||
return element.GetAttributeBool("iscjk", false);
|
||||
}
|
||||
|
||||
public GUIComponentStyle GetComponentStyle(string name)
|
||||
{
|
||||
componentStyles.TryGetValue(name.ToLowerInvariant(), out GUIComponentStyle style);
|
||||
|
||||
@@ -204,8 +204,13 @@ namespace Barotrauma
|
||||
if (textColor.HasValue)
|
||||
{
|
||||
this.textColor = textColor.Value;
|
||||
}
|
||||
this.Font = font ?? GUI.Font;
|
||||
}
|
||||
|
||||
//if the text is in chinese/korean/japanese and we're not using a CJK-compatible font,
|
||||
//use the default CJK font as a fallback
|
||||
var selectedFont = font ?? GUI.Font;
|
||||
if (TextManager.IsCJK(text) && !selectedFont.IsCJK) { selectedFont = GUI.CJKFont; }
|
||||
this.Font = selectedFont;
|
||||
this.textAlignment = textAlignment;
|
||||
this.Wrap = wrap;
|
||||
this.Text = text ?? "";
|
||||
|
||||
Reference in New Issue
Block a user