Unstable 0.17.0.0

This commit is contained in:
Markus Isberg
2022-02-26 02:43:01 +09:00
parent a83f375681
commit 3974067915
913 changed files with 32472 additions and 32364 deletions
@@ -43,7 +43,7 @@ namespace Barotrauma
}
public float QuickUseTimer;
public string QuickUseButtonToolTip;
public LocalizedString QuickUseButtonToolTip;
public bool IsMoving = false;
private static Rectangle offScreenRect = new Rectangle(new Point(-1000, 0), Point.Zero);
@@ -144,7 +144,7 @@ namespace Barotrauma
{
public static float UIScale
{
get { return (GameMain.GraphicsWidth / 1920.0f + GameMain.GraphicsHeight / 1080.0f) / 2.5f * GameSettings.InventoryScale; }
get { return (GameMain.GraphicsWidth / 1920.0f + GameMain.GraphicsHeight / 1080.0f) / 2.5f * GameSettings.CurrentConfig.Graphics.InventoryScale; }
}
public static int ContainedIndicatorHeight
@@ -215,8 +215,7 @@ namespace Barotrauma
public Inventory Inventory;
public readonly Item Item;
public readonly bool IsSubSlot;
public string Tooltip { get; private set; }
public List<RichTextData> TooltipRichTextData { get; private set;}
public RichString Tooltip { get; private set; }
public int tooltipDisplayedCondition;
@@ -250,23 +249,22 @@ namespace Barotrauma
{
itemsInSlot = ParentInventory.GetItemsAt(SlotIndex);
}
TooltipRichTextData = RichTextData.GetRichTextData(GetTooltip(Item, itemsInSlot), out string newTooltip);
Tooltip = newTooltip;
Tooltip = GetTooltip(Item, itemsInSlot);
tooltipDisplayedCondition = (int)Item.ConditionPercentage;
}
private string GetTooltip(Item item, IEnumerable<Item> itemsInSlot)
private RichString GetTooltip(Item item, IEnumerable<Item> itemsInSlot)
{
if (item == null) { return null; }
string toolTip = "";
LocalizedString toolTip = "";
if (GameMain.DebugDraw)
{
toolTip = item.ToString();
}
else
{
string description = item.Description;
LocalizedString description = item.Description;
if (item.Prefab.Identifier == "idcard" || item.Tags.Contains("despawncontainer"))
{
string[] readTags = item.Tags.Split(',');
@@ -288,7 +286,7 @@ namespace Barotrauma
}
else
{
description = TextManager.GetWithVariables("IDCardNameJob", new string[2] { "[name]", "[job]" }, new string[2] { idName, idJob }, new bool[2] { false, true });
description = TextManager.GetWithVariables("IDCardNameJob", ("[name]", idName, FormatCapitals.No), ("[job]", idJob, FormatCapitals.Yes));
}
if (!string.IsNullOrEmpty(item.Description))
{
@@ -297,7 +295,7 @@ namespace Barotrauma
}
}
string name = item.Name;
LocalizedString name = item.Name;
foreach (ItemComponent component in item.Components)
{
component.AddTooltipInfo(ref name, ref description);
@@ -314,13 +312,14 @@ namespace Barotrauma
}
}
string colorStr = XMLExtensions.ColorToString(item.SpawnedInCurrentOutpost && !item.AllowStealing ? GUI.Style.Red : Color.White);
string colorStr = (item.SpawnedInCurrentOutpost && !item.AllowStealing ? GUIStyle.Red : Color.White).ToStringHex();
toolTip = $"‖color:{colorStr}‖{name}‖color:end‖";
if (item.GetComponent<Quality>() != null)
{
// substring by to get rid of the empty space at start, text file should be adjusted
toolTip += $"\n{TextManager.GetWithVariable("itemname.quality" + item.Quality, "[itemname]", "", fallBackTag: "itemname.quality3")?.Substring(1)}";
toolTip += "\n" + TextManager.GetWithVariable("itemname.quality" + item.Quality, "[itemname]", "")
.Fallback(TextManager.GetWithVariable("itemname.quality3", "[itemname]", ""))
.TrimStart();
}
if (itemsInSlot.All(it => it.NonInteractable || it.NonPlayerTeamInteractable))
@@ -329,24 +328,24 @@ namespace Barotrauma
}
if (!item.IsFullCondition && !item.Prefab.HideConditionInTooltip)
{
string conditionColorStr = XMLExtensions.ColorToString(ToolBox.GradientLerp(item.Condition / item.MaxCondition, GUI.Style.ColorInventoryEmpty, GUI.Style.ColorInventoryHalf, GUI.Style.ColorInventoryFull));
string conditionColorStr = XMLExtensions.ColorToString(ToolBox.GradientLerp(item.Condition / item.MaxCondition, GUIStyle.ColorInventoryEmpty, GUIStyle.ColorInventoryHalf, GUIStyle.ColorInventoryFull));
toolTip += $"‖color:{conditionColorStr}‖ ({(int)item.ConditionPercentage} %)‖color:end‖";
}
if (!string.IsNullOrEmpty(description)) { toolTip += '\n' + description; }
if (item.prefab.ContentPackage != GameMain.VanillaContent && item.prefab.ContentPackage != null)
if (!description.IsNullOrEmpty()) { toolTip += '\n' + description; }
if (item.Prefab.ContentPackage != GameMain.VanillaContent && item.Prefab.ContentPackage != null)
{
colorStr = XMLExtensions.ColorToString(Color.MediumPurple);
toolTip += $"\n‖color:{colorStr}‖{item.prefab.ContentPackage.Name}‖color:end‖";
toolTip += $"\n‖color:{colorStr}‖{item.Prefab.ContentPackage.Name}‖color:end‖";
}
}
if (itemsInSlot.Count() > 1)
{
string colorStr = XMLExtensions.ColorToString(GUI.Style.Blue);
toolTip += $"\n‖color:{colorStr}‖[{GameMain.Config.KeyBindText(InputType.TakeOneFromInventorySlot)}] {TextManager.Get("inputtype.takeonefrominventoryslot")}‖color:end‖";
colorStr = XMLExtensions.ColorToString(GUI.Style.Blue);
toolTip += $"\n‖color:{colorStr}‖[{GameMain.Config.KeyBindText(InputType.TakeHalfFromInventorySlot)}] {TextManager.Get("inputtype.takehalffrominventoryslot")}‖color:end‖";
string colorStr = XMLExtensions.ColorToString(GUIStyle.Blue);
toolTip += $"\n‖color:{colorStr}‖[{GameSettings.CurrentConfig.KeyMap.KeyBindText(InputType.TakeOneFromInventorySlot)}] {TextManager.Get("inputtype.takeonefrominventoryslot")}‖color:end‖";
colorStr = XMLExtensions.ColorToString(GUIStyle.Blue);
toolTip += $"\n‖color:{colorStr}‖[{GameSettings.CurrentConfig.KeyMap.KeyBindText(InputType.TakeHalfFromInventorySlot)}] {TextManager.Get("inputtype.takehalffrominventoryslot")}‖color:end‖";
}
return toolTip;
return RichString.Rich(toolTip);
}
}
@@ -551,7 +550,7 @@ namespace Barotrauma
{
if (item != null)
{
slot.ShowBorderHighlight(GUI.Style.Red, 0.1f, 0.4f);
slot.ShowBorderHighlight(GUIStyle.Red, 0.1f, 0.4f);
if (!mouseDrag)
{
SoundPlayer.PlayUISound(GUISoundType.PickItem);
@@ -1038,9 +1037,9 @@ namespace Barotrauma
return CursorState.Default;
}
protected static void DrawToolTip(SpriteBatch spriteBatch, string toolTip, Rectangle highlightedSlot, List<RichTextData> richTextData = null)
protected static void DrawToolTip(SpriteBatch spriteBatch, RichString toolTip, Rectangle highlightedSlot)
{
GUIComponent.DrawToolTip(spriteBatch, toolTip, highlightedSlot, richTextData);
GUIComponent.DrawToolTip(spriteBatch, toolTip, highlightedSlot);
}
public void DrawSubInventory(SpriteBatch spriteBatch, int slotIndex)
@@ -1155,7 +1154,7 @@ namespace Barotrauma
{
foreach (int i in indices)
{
inventory.visualSlots[i]?.ShowBorderHighlight(GUI.Style.Green, 0.1f, 0.4f);
inventory.visualSlots[i]?.ShowBorderHighlight(GUIStyle.Green, 0.1f, 0.4f);
}
}
break;
@@ -1248,7 +1247,7 @@ namespace Barotrauma
selectedInventory.visualSlots[slotIndex].ShowBorderHighlight(Color.White, 0.1f, 0.4f);
}
}
selectedInventory.visualSlots[slotIndex].ShowBorderHighlight(GUI.Style.Red, 0.1f, 0.9f);
selectedInventory.visualSlots[slotIndex].ShowBorderHighlight(GUIStyle.Red, 0.1f, 0.9f);
}
SoundPlayer.PlayUISound(GUISoundType.PickItem);
}
@@ -1289,7 +1288,7 @@ namespace Barotrauma
}
else
{
if (selectedInventory.visualSlots != null){ selectedInventory.visualSlots[slotIndex].ShowBorderHighlight(GUI.Style.Red, 0.1f, 0.9f); }
if (selectedInventory.visualSlots != null){ selectedInventory.visualSlots[slotIndex].ShowBorderHighlight(GUIStyle.Red, 0.1f, 0.9f); }
SoundPlayer.PlayUISound(GUISoundType.PickItemFail);
}
}
@@ -1439,20 +1438,20 @@ namespace Barotrauma
if ((GUI.MouseOn == null || mouseOnHealthInterface) && selectedSlot == null)
{
var shadowSprite = GUI.Style.GetComponentStyle("OuterGlow").Sprites[GUIComponent.ComponentState.None][0];
string toolTip = mouseOnHealthInterface ? TextManager.Get("QuickUseAction.UseTreatment") :
var shadowSprite = GUIStyle.GetComponentStyle("OuterGlow").Sprites[GUIComponent.ComponentState.None][0];
LocalizedString toolTip = mouseOnHealthInterface ? TextManager.Get("QuickUseAction.UseTreatment") :
Character.Controlled.FocusedItem != null ?
TextManager.GetWithVariable("PutItemIn", "[itemname]", Character.Controlled.FocusedItem.Name, true) :
TextManager.GetWithVariable("PutItemIn", "[itemname]", Character.Controlled.FocusedItem.Name, FormatCapitals.Yes) :
TextManager.Get(Screen.Selected is SubEditorScreen editor && editor.EntityMenu.Rect.Contains(PlayerInput.MousePosition) ? "Delete" : "DropItem");
int textWidth = (int)Math.Max(GUI.Font.MeasureString(DraggingItems.First().Name).X, GUI.SmallFont.MeasureString(toolTip).X);
int textWidth = (int)Math.Max(GUIStyle.Font.MeasureString(DraggingItems.First().Name).X, GUIStyle.SmallFont.MeasureString(toolTip).X);
int textSpacing = (int)(15 * GUI.Scale);
Point shadowBorders = (new Point(40, 10)).Multiply(GUI.Scale);
shadowSprite.Draw(spriteBatch,
new Rectangle(itemPos.ToPoint() - new Point(iconSize / 2) - shadowBorders, new Point(iconSize + textWidth + textSpacing, iconSize) + shadowBorders.Multiply(2)), Color.Black * 0.8f);
GUI.DrawString(spriteBatch, new Vector2(itemPos.X + iconSize / 2 + textSpacing, itemPos.Y - iconSize / 2), DraggingItems.First().Name, Color.White);
GUI.DrawString(spriteBatch, new Vector2(itemPos.X + iconSize / 2 + textSpacing, itemPos.Y), toolTip,
color: Character.Controlled.FocusedItem == null && !mouseOnHealthInterface ? GUI.Style.Red : Color.LightGreen,
font: GUI.SmallFont);
color: Character.Controlled.FocusedItem == null && !mouseOnHealthInterface ? GUIStyle.Red : Color.LightGreen,
font: GUIStyle.SmallFont);
}
sprite.Draw(spriteBatch, itemPos + Vector2.One * 2, Color.Black, scale: scale);
sprite.Draw(spriteBatch,
@@ -1464,8 +1463,8 @@ namespace Barotrauma
{
Vector2 stackCountPos = itemPos + Vector2.One * iconSize * 0.25f;
string stackCountText = "x" + DraggingItems.Count;
GUI.SmallFont.DrawString(spriteBatch, stackCountText, stackCountPos + Vector2.One, Color.Black);
GUI.SmallFont.DrawString(spriteBatch, stackCountText, stackCountPos, Color.White);
GUIStyle.SmallFont.DrawString(spriteBatch, stackCountText, stackCountPos + Vector2.One, Color.Black);
GUIStyle.SmallFont.DrawString(spriteBatch, stackCountText, stackCountPos, Color.White);
}
}
}
@@ -1478,7 +1477,7 @@ namespace Barotrauma
{
selectedSlot.RefreshTooltip();
}
DrawToolTip(spriteBatch, selectedSlot.Tooltip, slotRect, selectedSlot.TooltipRichTextData);
DrawToolTip(spriteBatch, selectedSlot.Tooltip, slotRect);
}
}
@@ -1514,11 +1513,11 @@ namespace Barotrauma
/*if (inventory != null && (CharacterInventory.PersonalSlots.HasFlag(type) || (inventory.isSubInventory && (inventory.Owner as Item) != null
&& (inventory.Owner as Item).AllowedSlots.Any(a => CharacterInventory.PersonalSlots.HasFlag(a)))))
{
slotColor = slot.IsHighlighted ? GUI.Style.EquipmentSlotColor : GUI.Style.EquipmentSlotColor * 0.8f;
slotColor = slot.IsHighlighted ? GUIStyle.EquipmentSlotColor : GUIStyle.EquipmentSlotColor * 0.8f;
}
else
{
slotColor = slot.IsHighlighted ? GUI.Style.InventorySlotColor : GUI.Style.InventorySlotColor * 0.8f;
slotColor = slot.IsHighlighted ? GUIStyle.InventorySlotColor : GUIStyle.InventorySlotColor * 0.8f;
}*/
if (inventory != null && inventory.Locked) { slotColor = Color.Gray * 0.5f; }
@@ -1526,7 +1525,7 @@ namespace Barotrauma
if (SubEditorScreen.IsSubEditor() && PlayerInput.IsCtrlDown() && selectedSlot?.Slot == slot)
{
GUI.DrawRectangle(spriteBatch, rect, GUI.Style.Red * 0.3f, isFilled: true);
GUI.DrawRectangle(spriteBatch, rect, GUIStyle.Red * 0.3f, isFilled: true);
}
bool canBePut = false;
@@ -1550,7 +1549,7 @@ namespace Barotrauma
}
if (slot.MouseOn() && canBePut && selectedSlot?.Slot == slot)
{
GUI.UIGlow.Draw(spriteBatch, rect, GUI.Style.Green);
GUIStyle.UIGlow.Draw(spriteBatch, rect, GUIStyle.Green);
}
if (item != null && drawItem)
@@ -1571,7 +1570,7 @@ namespace Barotrauma
conditionIndicatorArea.Inflate(-4, 0);
}
var indicatorStyle = GUI.Style.GetComponentStyle("ContainedStateIndicator.Default");
var indicatorStyle = GUIStyle.GetComponentStyle("ContainedStateIndicator.Default");
Sprite indicatorSprite = indicatorStyle?.GetDefaultSprite();
Sprite emptyIndicatorSprite = indicatorStyle?.GetSprite(GUIComponent.ComponentState.Hover);
DrawItemStateIndicator(spriteBatch, inventory, indicatorSprite, emptyIndicatorSprite, conditionIndicatorArea, item.Condition / item.MaxCondition);
@@ -1624,14 +1623,14 @@ namespace Barotrauma
if (item.Quality != 0)
{
var style = GUI.Style.GetComponentStyle("InnerGlowSmall");
var style = GUIStyle.GetComponentStyle("InnerGlowSmall");
if (style == null)
{
GUI.DrawRectangle(spriteBatch, rect, GUI.Style.GetQualityColor(item.Quality) * 0.7f);
GUI.DrawRectangle(spriteBatch, rect, GUIStyle.GetQualityColor(item.Quality) * 0.7f);
}
else
{
style.Sprites[GUIComponent.ComponentState.None].FirstOrDefault()?.Draw(spriteBatch, rect, GUI.Style.GetQualityColor(item.Quality) * 0.5f);
style.Sprites[GUIComponent.ComponentState.None].FirstOrDefault()?.Draw(spriteBatch, rect, GUIStyle.GetQualityColor(item.Quality) * 0.5f);
}
}
}
@@ -1640,7 +1639,7 @@ namespace Barotrauma
var slotIcon = parentItem?.GetComponent<ItemContainer>()?.GetSlotIcon(slotIndex);
if (slotIcon != null)
{
slotIcon.Draw(spriteBatch, rect.Center.ToVector2(), GUI.Style.EquipmentSlotIconColor, scale: Math.Min(rect.Width / slotIcon.size.X, rect.Height / slotIcon.size.Y) * 0.8f);
slotIcon.Draw(spriteBatch, rect.Center.ToVector2(), GUIStyle.EquipmentSlotIconColor, scale: Math.Min(rect.Width / slotIcon.size.X, rect.Height / slotIcon.size.Y) * 0.8f);
}
}
}
@@ -1653,7 +1652,7 @@ namespace Barotrauma
if (slot.HighlightColor != Color.Transparent)
{
GUI.UIGlow.Draw(spriteBatch, rect, slot.HighlightColor);
GUIStyle.UIGlow.Draw(spriteBatch, rect, slot.HighlightColor);
}
if (item != null && drawItem)
@@ -1693,7 +1692,7 @@ namespace Barotrauma
stealIcon.Draw(
spriteBatch,
new Vector2(rect.X + iconSize.X * 0.2f, rect.Bottom - iconSize.Y * 1.2f),
color: GUI.Style.Red,
color: GUIStyle.Red,
scale: iconSize.X / stealIcon.size.X);
}
int maxStackSize = item.Prefab.MaxStackSize;
@@ -1708,9 +1707,9 @@ namespace Barotrauma
{
Vector2 stackCountPos = new Vector2(rect.Right, rect.Bottom);
string stackCountText = "x" + itemCount;
stackCountPos -= GUI.SmallFont.MeasureString(stackCountText) + new Vector2(4, 2);
GUI.SmallFont.DrawString(spriteBatch, stackCountText, stackCountPos + Vector2.One, Color.Black);
GUI.SmallFont.DrawString(spriteBatch, stackCountText, stackCountPos, Color.White);
stackCountPos -= GUIStyle.SmallFont.MeasureString(stackCountText) + new Vector2(4, 2);
GUIStyle.SmallFont.DrawString(spriteBatch, stackCountText, stackCountPos + Vector2.One, Color.Black);
GUIStyle.SmallFont.DrawString(spriteBatch, stackCountText, stackCountPos, Color.White);
}
}
}
@@ -1721,7 +1720,7 @@ namespace Barotrauma
slot.InventoryKeyIndex != -1)
{
spriteBatch.Draw(slotHotkeySprite.Texture, rect.ScaleSize(1.15f), slotHotkeySprite.SourceRect, slotColor);
GUI.DrawString(spriteBatch, rect.Location.ToVector2() + new Vector2((int)(4.25f * UIScale), (int)Math.Ceiling(-1.5f * UIScale)), GameMain.Config.InventoryKeyBind(slot.InventoryKeyIndex).Name, Color.Black, font: GUI.HotkeyFont);
GUI.DrawString(spriteBatch, rect.Location.ToVector2() + new Vector2((int)(4.25f * UIScale), (int)Math.Ceiling(-1.5f * UIScale)), GameSettings.CurrentConfig.InventoryKeyMap.Bindings[slot.InventoryKeyIndex].Name, Color.Black, font: GUIStyle.HotkeyFont);
}
}
@@ -1730,7 +1729,7 @@ namespace Barotrauma
Sprite indicatorSprite, Sprite emptyIndicatorSprite, Rectangle containedIndicatorArea, float containedState,
bool pulsate = false)
{
Color backgroundColor = GUI.Style.ColorInventoryBackground;
Color backgroundColor = GUIStyle.ColorInventoryBackground;
if (indicatorSprite == null)
{
@@ -1738,7 +1737,7 @@ namespace Barotrauma
GUI.DrawRectangle(spriteBatch, containedIndicatorArea, backgroundColor, true);
GUI.DrawRectangle(spriteBatch,
new Rectangle(containedIndicatorArea.X, containedIndicatorArea.Y, (int)(containedIndicatorArea.Width * containedState), containedIndicatorArea.Height),
ToolBox.GradientLerp(containedState, GUI.Style.ColorInventoryEmpty, GUI.Style.ColorInventoryHalf, GUI.Style.ColorInventoryFull) * 0.8f, true);
ToolBox.GradientLerp(containedState, GUIStyle.ColorInventoryEmpty, GUIStyle.ColorInventoryHalf, GUIStyle.ColorInventoryFull) * 0.8f, true);
GUI.DrawLine(spriteBatch,
new Vector2(containedIndicatorArea.X + (int)(containedIndicatorArea.Width * containedState), containedIndicatorArea.Y),
new Vector2(containedIndicatorArea.X + (int)(containedIndicatorArea.Width * containedState), containedIndicatorArea.Bottom),
@@ -1763,7 +1762,7 @@ namespace Barotrauma
if (containedState > 0.0f)
{
Color indicatorColor = ToolBox.GradientLerp(containedState, GUI.Style.ColorInventoryEmpty, GUI.Style.ColorInventoryHalf, GUI.Style.ColorInventoryFull);
Color indicatorColor = ToolBox.GradientLerp(containedState, GUIStyle.ColorInventoryEmpty, GUIStyle.ColorInventoryHalf, GUIStyle.ColorInventoryFull);
if (inventory != null && inventory.Locked) { indicatorColor *= 0.5f; }
spriteBatch.Draw(indicatorSprite.Texture, containedIndicatorArea.Center.ToVector2(),
@@ -1784,7 +1783,7 @@ namespace Barotrauma
}
else if (emptyIndicatorSprite != null)
{
Color indicatorColor = GUI.Style.ColorInventoryEmptyOverlay;
Color indicatorColor = GUIStyle.ColorInventoryEmptyOverlay;
if (inventory != null && inventory.Locked) { indicatorColor *= 0.5f; }
emptyIndicatorSprite.Draw(spriteBatch, containedIndicatorArea.Center.ToVector2(),