Font and UI fixes

This commit is contained in:
Dominic committed 2022-04-03 15:44:05 -05:00
1 parent d244d231a8
commit 2925552809
12 files changed
+133 -121

No files matched your search

View File
File renamed without changes.
+4 -3
View File
@@ -1,4 +1,4 @@
using CalamityMod.Dusts;
using CalamityMod.Dusts;
using CalamityMod.Items.Dyes;
using CalamityMod.Items.VanillaArmorChanges;
using CalamityMod.Items.Weapons.Magic;
@@ -37,6 +37,7 @@ using System.Collections.Generic;
using System.Linq;
using Terraria;
using Terraria.DataStructures;
using Terraria.GameContent;
using Terraria.ID;
using Terraria.ModLoader;
@@ -893,7 +894,7 @@ namespace CalamityMod.CalPlayer
float xOffset = CalamityConfig.Instance.SpeedrunTimerPosX;
float yOffset = CalamityConfig.Instance.SpeedrunTimerPosY;
Utils.DrawBorderStringFourWay(Main.spriteBatch, Main.fontMouseText, text, Main.screenWidth / 2f - xOffset, yOffset, Color.White, Color.Black, default, scale);
Utils.DrawBorderStringFourWay(Main.spriteBatch, FontAssets.MouseText.Value, text, Main.screenWidth / 2f - xOffset, yOffset, Color.White, Color.Black, default, scale);
if (calamityPlayer.lastSplitType > -1)
{
@@ -1097,7 +1098,7 @@ namespace CalamityMod.CalPlayer
if (texture != null)
Main.spriteBatch.Draw(texture, new Vector2(Main.screenWidth / 2f - xOffset - texture.Width - 4f, yOffset), null, Color.White, 0f, default, 1f, SpriteEffects.None, 0f);
Utils.DrawBorderStringFourWay(Main.spriteBatch, Main.fontMouseText, text, Main.screenWidth / 2f - xOffset, yOffset, Color.White, Color.Black, default, scale);
Utils.DrawBorderStringFourWay(Main.spriteBatch, FontAssets.MouseText.Value, text, Main.screenWidth / 2f - xOffset, yOffset, Color.White, Color.Black, default, scale);
}
}
+4 -3
View File
@@ -1,10 +1,11 @@
using CalamityMod.Events;
using CalamityMod.Events;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.Audio;
using Terraria.GameContent;
namespace CalamityMod.UI
{
@@ -144,8 +145,8 @@ namespace CalamityMod.UI
text = CircleNames[selectedCircle];
}
Vector2 size = Main.fontMouseText.MeasureString(text);
Utils.DrawBorderStringFourWay(sb, Main.fontMouseText, text, CenterPoint.X - size.X / 2f, CenterPoint.Y + CircleOffset + CircleTextureSize / 2 + 4, Color.White, Color.Black, default);
Vector2 size = FontAssets.MouseText.Value.MeasureString(text);
Utils.DrawBorderStringFourWay(sb, FontAssets.MouseText.Value, text, CenterPoint.X - size.X / 2f, CenterPoint.Y + CircleOffset + CircleTextureSize / 2 + 4, Color.White, Color.Black, default);
}
public static void DoTeleportation(int circle)
+17 -15
View File
@@ -1,4 +1,4 @@
using CalamityMod.Events;
using CalamityMod.Events;
using CalamityMod.NPCs.AquaticScourge;
using CalamityMod.NPCs.AstrumDeus;
using CalamityMod.NPCs.Calamitas;
@@ -23,11 +23,13 @@ using CalamityMod.NPCs.SupremeCalamitas;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using ReLogic.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using Terraria;
using Terraria.GameContent;
using Terraria.GameContent.Events;
using Terraria.ID;
using Terraria.ModLoader;
@@ -97,15 +99,15 @@ namespace CalamityMod.UI
if (!Main.dedServ)
{
BossMainHPBar = GetTexture("CalamityMod/ExtraTextures/UI/BossHPMainBar");
BossComboHPBar = GetTexture("CalamityMod/ExtraTextures/UI/BossHPComboBar");
BossSeperatorBar = GetTexture("CalamityMod/ExtraTextures/UI/BossHPSeperatorBar");
BossMainHPBar = Request<Texture2D>("CalamityMod/ExtraTextures/UI/BossHPMainBar", AssetRequestMode.ImmediateLoad).Value;
BossComboHPBar = Request<Texture2D>("CalamityMod/ExtraTextures/UI/BossHPComboBar", AssetRequestMode.ImmediateLoad).Value;
BossSeperatorBar = Request<Texture2D>("CalamityMod/ExtraTextures/UI/BossHPSeperatorBar", AssetRequestMode.ImmediateLoad).Value;
PlatformID id = Environment.OSVersion.Platform;
if (id == PlatformID.Win32NT && !Environment.Is64BitProcess)
HPBarFont = mod.GetFont("Fonts/HPBarFont");
if (id == PlatformID.Win32NT)
HPBarFont = Request<DynamicSpriteFont>("CalamityMod/Fonts/HPBarFont", AssetRequestMode.ImmediateLoad).Value;
else
HPBarFont = Main.fontMouseText;
HPBarFont = FontAssets.MouseText.Value;
}
OneToMany = new Dictionary<int, int[]>();
@@ -682,7 +684,7 @@ namespace CalamityMod.UI
// Draw a red back-glow of the text if the NPC is enraged or a gray back-glow if the NPC is increasing defense or DR.
string name = OverridingName ?? AssociatedNPC.FullName;
Vector2 nameSize = Main.fontMouseText.MeasureString(name);
Vector2 nameSize = FontAssets.MouseText.Value.MeasureString(name);
if (NPCIsEnraged)
{
if (EnrageTimer > 0)
@@ -692,7 +694,7 @@ namespace CalamityMod.UI
for (int i = 0; i < 4; i++)
{
Vector2 drawOffset = (MathHelper.TwoPi * i / 4f).ToRotationVector2() * outwardness;
CalamityUtils.DrawBorderStringEightWay(sb, Main.fontMouseText, name, new Vector2(x + BarMaxWidth - nameSize.X, y + 23 - nameSize.Y) + drawOffset, Color.Red * 0.6f, Color.Black * 0.2f);
CalamityUtils.DrawBorderStringEightWay(sb, FontAssets.MouseText.Value, name, new Vector2(x + BarMaxWidth - nameSize.X, y + 23 - nameSize.Y) + drawOffset, Color.Red * 0.6f, Color.Black * 0.2f);
}
}
}
@@ -705,13 +707,13 @@ namespace CalamityMod.UI
for (int i = 0; i < 4; i++)
{
Vector2 drawOffset = (MathHelper.TwoPi * i / 4f).ToRotationVector2() * outwardness;
CalamityUtils.DrawBorderStringEightWay(sb, Main.fontMouseText, name, new Vector2(x + BarMaxWidth - nameSize.X, y + 23 - nameSize.Y) + drawOffset, Color.LightGray * 0.6f, Color.Black * 0.2f);
CalamityUtils.DrawBorderStringEightWay(sb, FontAssets.MouseText.Value, name, new Vector2(x + BarMaxWidth - nameSize.X, y + 23 - nameSize.Y) + drawOffset, Color.LightGray * 0.6f, Color.Black * 0.2f);
}
}
}
// And draw the text to indicate the name of the boss.
CalamityUtils.DrawBorderStringEightWay(sb, Main.fontMouseText, name, new Vector2(x + BarMaxWidth - nameSize.X, y + 23 - nameSize.Y), Color.White, Color.Black * 0.2f);
CalamityUtils.DrawBorderStringEightWay(sb, FontAssets.MouseText.Value, name, new Vector2(x + BarMaxWidth - nameSize.X, y + 23 - nameSize.Y), Color.White, Color.Black * 0.2f);
if (CanDrawExtraSmallText)
{
@@ -721,11 +723,11 @@ namespace CalamityMod.UI
int totalExtraEntities = CalamityUtils.CountNPCsBetter(extraEntityData.TypesToSearchFor);
string text = $"({extraEntityData.NameOfExtensions} left: {totalExtraEntities})";
Vector2 textAreaSize = Main.fontItemStack.MeasureString(text) * SmallTextScale;
Vector2 textAreaSize = FontAssets.ItemStack.Value.MeasureString(text) * SmallTextScale;
float horizontalDrawPosition = Math.Max(x, x + mainBarWidth - textAreaSize.X);
float verticalDrawPosition = y + MainBarYOffset + 17;
Vector2 smallBarDrawPosition = new Vector2(horizontalDrawPosition, verticalDrawPosition);
CalamityUtils.DrawBorderStringEightWay(sb, Main.fontItemStack, text, smallBarDrawPosition, Color.White * openAnimationFlicker, Color.Black * openAnimationFlicker * 0.24f, SmallTextScale);
CalamityUtils.DrawBorderStringEightWay(sb, FontAssets.ItemStack.Value, text, smallBarDrawPosition, Color.White * openAnimationFlicker, Color.Black * openAnimationFlicker * 0.24f, SmallTextScale);
}
// If that isn't necessary, simply display the precise amount of remaining life for the boss.
@@ -733,11 +735,11 @@ namespace CalamityMod.UI
{
// Draw the precise life.
string actualLifeText = $"({CombinedNPCLife} / {InitialMaxLife})";
Vector2 textAreaSize = Main.fontItemStack.MeasureString(actualLifeText) * SmallTextScale;
Vector2 textAreaSize = FontAssets.ItemStack.Value.MeasureString(actualLifeText) * SmallTextScale;
float horizontalDrawPosition = Math.Max(x, x + mainBarWidth - textAreaSize.X);
float verticalDrawPosition = y + MainBarYOffset + 17;
Vector2 smallBarDrawPosition = new Vector2(horizontalDrawPosition, verticalDrawPosition);
CalamityUtils.DrawBorderStringEightWay(sb, Main.fontItemStack, actualLifeText, smallBarDrawPosition, Color.White * openAnimationFlicker, Color.Black * openAnimationFlicker * 0.24f, SmallTextScale);
CalamityUtils.DrawBorderStringEightWay(sb, FontAssets.ItemStack.Value, actualLifeText, smallBarDrawPosition, Color.White * openAnimationFlicker, Color.Black * openAnimationFlicker * 0.24f, SmallTextScale);
}
}
}
+34 -33
View File
@@ -1,4 +1,4 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System.Collections.Generic;
using System.Linq;
@@ -8,6 +8,7 @@ using Terraria.ModLoader;
using Terraria.UI;
using Terraria.UI.Chat;
using Terraria.Audio;
using Terraria.GameContent;
namespace CalamityMod.UI.CalamitasEnchants
{
@@ -55,7 +56,7 @@ namespace CalamityMod.UI.CalamitasEnchants
// If an item was stored, release it back into the world.
if (!CurrentlyHeldItem.IsAir)
{
Main.LocalPlayer.QuickSpawnClonedItem(CurrentlyHeldItem, CurrentlyHeldItem.stack);
Main.LocalPlayer.QuickSpawnClonedItem(Main.LocalPlayer.GetItemSource_Misc(CurrentlyHeldItem.type), CurrentlyHeldItem, CurrentlyHeldItem.stack);
CurrentlyHeldItem.TurnToAir();
}
@@ -82,7 +83,7 @@ namespace CalamityMod.UI.CalamitasEnchants
Main.playerInventory = true;
Main.npcChatText = string.Empty;
Texture2D backgroundTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/CalamitasCurseBackground");
Texture2D backgroundTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/CalamitasCurseBackground").Value;
Vector2 backgroundScale = Vector2.One * Main.UIScale;
// Draw the background.
@@ -107,7 +108,7 @@ namespace CalamityMod.UI.CalamitasEnchants
DrawEnchantmentDescription(spriteBatch, descriptionDrawPositionTopLeft);
if (!string.IsNullOrEmpty(SelectedEnchantment.Value.IconTexturePath))
{
Texture2D iconTexture = ModContent.Request<Texture2D>(SelectedEnchantment.Value.IconTexturePath);
Texture2D iconTexture = ModContent.Request<Texture2D>(SelectedEnchantment.Value.IconTexturePath).Value;
DrawIcon(spriteBatch, iconDrawPositionTopLeft, iconTexture);
}
}
@@ -156,7 +157,7 @@ namespace CalamityMod.UI.CalamitasEnchants
// If no possible enchantments were found, default to null.
SelectedEnchantment = null;
if (possibleEnchantments.Count() > 0)
if (possibleEnchantments.Any())
SelectedEnchantment = possibleEnchantments.ElementAt(EnchantIndex);
return possibleEnchantments;
@@ -179,15 +180,15 @@ namespace CalamityMod.UI.CalamitasEnchants
// Draw the coin costs.
string costText = "Cost: ";
Utils.DrawBorderStringFourWay(spriteBatch, Main.fontMouseText, costText, costDrawPositionTopLeft.X, costDrawPositionTopLeft.Y + 45f * Main.UIScale, Color.White * (Main.mouseTextColor / 255f), Color.Black, Vector2.Zero, Main.UIScale);
costDrawPositionTopLeft.X += (int)((Main.fontMouseText.MeasureString(costText).X * 0.5f + 12f) * Main.UIScale);
Utils.DrawBorderStringFourWay(spriteBatch, FontAssets.MouseText.Value, costText, costDrawPositionTopLeft.X, costDrawPositionTopLeft.Y + 45f * Main.UIScale, Color.White * (Main.mouseTextColor / 255f), Color.Black, Vector2.Zero, Main.UIScale);
costDrawPositionTopLeft.X += (int)((FontAssets.MouseText.Value.MeasureString(costText).X * 0.5f + 12f) * Main.UIScale);
int[] coinsArray = Utils.CoinsSplit(cost);
for (int i = 0; i < 4; i++)
{
Vector2 drawPosition = new Vector2(costDrawPositionTopLeft.X + (ChatManager.GetStringSize(Main.fontMouseText, costText, Vector2.One, -1f).X + ((24 * i) - 24f)) * Main.UIScale, costDrawPositionTopLeft.Y + 54f * Main.UIScale);
spriteBatch.Draw(Main.itemTexture[ItemID.PlatinumCoin - i], drawPosition, null, Color.White, 0f, Main.itemTexture[ItemID.PlatinumCoin - i].Size() * 0.5f, Main.UIScale, SpriteEffects.None, 0f);
Utils.DrawBorderStringFourWay(spriteBatch, Main.fontItemStack, coinsArray[3 - i].ToString(), drawPosition.X - 11f, drawPosition.Y, Color.White, Color.Black, new Vector2(0.3f), 0.75f * Main.UIScale);
Vector2 drawPosition = new Vector2(costDrawPositionTopLeft.X + (ChatManager.GetStringSize(FontAssets.MouseText.Value, costText, Vector2.One, -1f).X + ((24 * i) - 24f)) * Main.UIScale, costDrawPositionTopLeft.Y + 54f * Main.UIScale);
spriteBatch.Draw(TextureAssets.Item[ItemID.PlatinumCoin - i].Value, drawPosition, null, Color.White, 0f, TextureAssets.Item[ItemID.PlatinumCoin - i].Size() * 0.5f, Main.UIScale, SpriteEffects.None, 0f);
Utils.DrawBorderStringFourWay(spriteBatch, FontAssets.ItemStack.Value, coinsArray[3 - i].ToString(), drawPosition.X - 11f, drawPosition.Y, Color.White, Color.Black, new Vector2(0.3f), 0.75f * Main.UIScale);
}
return cost;
@@ -199,12 +200,12 @@ namespace CalamityMod.UI.CalamitasEnchants
Vector2 scale = new Vector2(0.8f, 0.825f) * MathHelper.Clamp(ResolutionRatio, 0.825f, 1f) * Main.UIScale;
string unifiedDescription = SelectedEnchantment.Value.Description.Replace("\n", " ");
foreach (string line in Utils.WordwrapString(unifiedDescription, Main.fontMouseText, 400, 16, out _))
foreach (string line in Utils.WordwrapString(unifiedDescription, FontAssets.MouseText.Value, 400, 16, out _))
{
if (string.IsNullOrEmpty(line))
continue;
ChatManager.DrawColorCodedStringWithShadow(spriteBatch, Main.fontMouseText, line, vectorDrawPosition, Color.Orange, 0f, Vector2.Zero, scale);
ChatManager.DrawColorCodedStringWithShadow(spriteBatch, FontAssets.MouseText.Value, line, vectorDrawPosition, Color.Orange, 0f, Vector2.Zero, scale);
vectorDrawPosition.Y += Main.UIScale * 16f;
}
}
@@ -217,20 +218,20 @@ namespace CalamityMod.UI.CalamitasEnchants
public static void DrawItemIcon(SpriteBatch spriteBatch, Vector2 itemSlotDrawPosition, Vector2 reforgeIconDrawPosition, Vector2 scale, out bool isHoveringOverItemIcon, out bool isHoveringOverReforgeIcon)
{
isHoveringOverReforgeIcon = false;
Texture2D itemSlotTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/CalamitasCurseItemSlot");
Texture2D itemSlotTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/CalamitasCurseItemSlot").Value;
Texture2D reforgeIconTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_Button");
Texture2D reforgeIconTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_Button").Value;
Rectangle reforgeIconArea = new Rectangle((int)reforgeIconDrawPosition.X, (int)reforgeIconDrawPosition.Y, (int)(reforgeIconTexture.Width * scale.X), (int)(reforgeIconTexture.Height * scale.Y));
// Have the reforge icon light up if the mouse is hovering over it.
if (MouseScreenArea.Intersects(reforgeIconArea))
{
reforgeIconTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_ButtonHovered");
reforgeIconTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_ButtonHovered").Value;
isHoveringOverReforgeIcon = true;
}
if (ReforgeButtonClickCountdown > 0f)
reforgeIconTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_ButtonClicked");
reforgeIconTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_ButtonClicked").Value;
// This will be used for item deposit/withdrawal logic.
isHoveringOverItemIcon = MouseScreenArea.Intersects(new Rectangle((int)itemSlotDrawPosition.X, (int)itemSlotDrawPosition.Y, (int)(itemSlotTexture.Width * scale.X), (int)(itemSlotTexture.Height * scale.Y)));
@@ -247,7 +248,7 @@ namespace CalamityMod.UI.CalamitasEnchants
public static void AttemptToDrawItemInIcon(SpriteBatch spriteBatch, Vector2 drawPosition)
{
float inventoryScale = Main.inventoryScale;
Texture2D itemTexture = Main.itemTexture[CurrentlyHeldItem.type];
Texture2D itemTexture = TextureAssets.Item[CurrentlyHeldItem.type].Value;
Rectangle itemFrame = itemTexture.Frame(1, 1, 0, 0);
bool hasMultipleFrames = Main.itemAnimations[CurrentlyHeldItem.type] != null;
if (hasMultipleFrames)
@@ -295,26 +296,26 @@ namespace CalamityMod.UI.CalamitasEnchants
public static void DrawAndInteractWithButtons(SpriteBatch spriteBatch, IEnumerable<Enchantment> possibleEnchantments, Vector2 topButtonTopLeft, Vector2 bottomButtonTopLeft, Vector2 scale)
{
// Leave the arrows blank if no possible enchants exist.
if (possibleEnchantments.Count() == 0)
if (!possibleEnchantments.Any())
return;
// Decide textures.
Texture2D topArrowTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_ArrowUp");
Texture2D bottomArrowTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_ArrowDown");
Texture2D topArrowTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_ArrowUp").Value;
Texture2D bottomArrowTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_ArrowDown").Value;
if (TopButtonClickCountdown > 0f)
topArrowTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_ArrowUpClicked");
topArrowTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_ArrowUpClicked").Value;
if (BottomButtonClickCountdown > 0f)
bottomArrowTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_ArrowDownClicked");
bottomArrowTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_ArrowDownClicked").Value;
Rectangle topButtonArea = new Rectangle((int)topButtonTopLeft.X, (int)topButtonTopLeft.Y, (int)(topArrowTexture.Width * scale.X), (int)(topArrowTexture.Height * scale.Y));
Rectangle bottomButtonArea = new Rectangle((int)bottomButtonTopLeft.X, (int)bottomButtonTopLeft.Y, (int)(bottomArrowTexture.Width * scale.X), (int)(bottomArrowTexture.Height * scale.Y));
bool hoveringOverTopArrow = MouseScreenArea.Intersects(topButtonArea);
bool hoveringOverBottomArrow = MouseScreenArea.Intersects(bottomButtonArea);
if (hoveringOverTopArrow)
topArrowTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_ArrowUpHovered");
topArrowTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_ArrowUpHovered").Value;
if (hoveringOverBottomArrow)
bottomArrowTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_ArrowDownHovered");
bottomArrowTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_ArrowDownHovered").Value;
// Draw the arrows.
if (EnchantIndex > 0)
@@ -345,10 +346,10 @@ namespace CalamityMod.UI.CalamitasEnchants
public static void DrawEnchantmentName(SpriteBatch spriteBatch, Vector2 nameDrawCenter)
{
Vector2 scale = new Vector2(0.8f, 0.745f) * Main.UIScale;
float textWidth = Main.fontMouseText.MeasureString(SelectedEnchantment.Value.Name).X * scale.X;
float textWidth = FontAssets.MouseText.Value.MeasureString(SelectedEnchantment.Value.Name).X * scale.X;
Color drawColor = SelectedEnchantment.Value.Equals(EnchantmentManager.ClearEnchantment) ? Color.White : Color.Orange;
nameDrawCenter.X -= textWidth * 0.5f;
ChatManager.DrawColorCodedStringWithShadow(spriteBatch, Main.fontMouseText, SelectedEnchantment.Value.Name, nameDrawCenter, drawColor, 0f, Vector2.Zero, scale);
ChatManager.DrawColorCodedStringWithShadow(spriteBatch, FontAssets.MouseText.Value, SelectedEnchantment.Value.Name, nameDrawCenter, drawColor, 0f, Vector2.Zero, scale);
}
public static void InteractWithEnchantIcon(int cost)
@@ -366,7 +367,7 @@ namespace CalamityMod.UI.CalamitasEnchants
return;
Item originalItem = CurrentlyHeldItem.Clone();
byte oldPrefix = CurrentlyHeldItem.prefix;
int oldPrefix = CurrentlyHeldItem.prefix;
CurrentlyHeldItem.SetDefaults(CurrentlyHeldItem.type);
CurrentlyHeldItem.Prefix(oldPrefix);
CurrentlyHeldItem = CurrentlyHeldItem.CloneWithModdedDataFrom(originalItem);
@@ -382,17 +383,17 @@ namespace CalamityMod.UI.CalamitasEnchants
SelectedEnchantment.Value.CreationEffect?.Invoke(CurrentlyHeldItem);
}
// Update the compare item. This is used check comparisons when showing reforge tooltip bonuses.
// Update the compare item. This is used to check comparisons when showing reforge tooltip bonuses.
// Updating it with the same bonuses as what was applied to the real item will negate the incorrect numbers,
// such as absurd damage boosts.
if (Main.cpItem is null)
Main.cpItem = new Item();
Main.cpItem.SetDefaults(Main.cpItem.type);
if (Main.tooltipPrefixComparisonItem is null)
Main.tooltipPrefixComparisonItem = new Item();
Main.tooltipPrefixComparisonItem.SetDefaults(Main.tooltipPrefixComparisonItem.type);
if (SelectedEnchantment.Value.Name != EnchantmentManager.UpgradeEnchantName)
{
Main.cpItem.Calamity().AppliedEnchantment = SelectedEnchantment.Value;
SelectedEnchantment.Value.CreationEffect?.Invoke(Main.cpItem);
Main.tooltipPrefixComparisonItem.Calamity().AppliedEnchantment = SelectedEnchantment.Value;
SelectedEnchantment.Value.CreationEffect?.Invoke(Main.tooltipPrefixComparisonItem);
}
// Take away the money for the cost.
+34 -33
View File
@@ -1,4 +1,4 @@
using CalamityMod.Items.DraedonMisc;
using CalamityMod.Items.DraedonMisc;
using CalamityMod.TileEntities;
using CalamityMod.World;
using Microsoft.Xna.Framework;
@@ -12,6 +12,7 @@ using Terraria.ID;
using Terraria.ModLoader;
using Terraria.UI.Chat;
using Terraria.Audio;
using Terraria.GameContent;
namespace CalamityMod.UI
{
@@ -25,7 +26,7 @@ namespace CalamityMod.UI
public static float ContactButtonScale = 1f;
public static float MechIconScale = 1f;
public static Vector2 BackgroundCenter => new Vector2(500f, Main.screenHeight * 0.5f + 115f);
public static float GeneralScale => MathHelper.Lerp(1f, 0.7f, Utils.InverseLerp(1325f, 750f, Main.screenWidth, true)) * Main.UIScale;
public static float GeneralScale => MathHelper.Lerp(1f, 0.7f, Utils.GetLerpValue(1325f, 750f, Main.screenWidth, true)) * Main.UIScale;
public static Rectangle MouseScreenArea => Utils.CenteredRectangle(Main.MouseScreen, Vector2.One * 2f);
public static void Draw(SpriteBatch spriteBatch)
@@ -44,7 +45,7 @@ namespace CalamityMod.UI
}
// Draw the background.
Texture2D backgroundTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/DraedonDecrypterBackground");
Texture2D backgroundTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/DraedonDecrypterBackground").Value;
spriteBatch.Draw(backgroundTexture, BackgroundCenter, null, Color.White, 0f, backgroundTexture.Size() * 0.5f, GeneralScale, SpriteEffects.None, 0f);
Rectangle backgroundArea = Utils.CenteredRectangle(BackgroundCenter, backgroundTexture.Size());
@@ -55,9 +56,9 @@ namespace CalamityMod.UI
Vector2 backgroundTopLeft = BackgroundCenter - backgroundTexture.Size() * GeneralScale * 0.5f;
// Draw the cell payment slot icon.
Texture2D emptyCellIconTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/PowerCellSlot_Empty");
Texture2D occupiedCellIconTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/PowerCellSlot_Filled");
Texture2D textPanelTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/DraedonDecrypterScreen");
Texture2D emptyCellIconTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/PowerCellSlot_Empty").Value;
Texture2D occupiedCellIconTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/PowerCellSlot_Filled").Value;
Texture2D textPanelTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/DraedonDecrypterScreen").Value;
Texture2D cellTexture = codebreakerTileEntity.InputtedCellCount > 0 ? occupiedCellIconTexture : emptyCellIconTexture;
Vector2 cellDrawCenter = backgroundTopLeft + Vector2.One * GeneralScale * 60f;
@@ -104,7 +105,7 @@ namespace CalamityMod.UI
DrawDecryptCancelConfirmationText(textPanelCenter);
// Draw the schematic icon.
Texture2D schematicIconBG = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/EncryptedSchematicSlotBackground");
Texture2D schematicIconBG = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/EncryptedSchematicSlotBackground").Value;
Texture2D schematicIconTexture = schematicIconBG;
int schematicType = 0;
@@ -112,13 +113,13 @@ namespace CalamityMod.UI
schematicType = CalamityLists.EncryptedSchematicIDRelationship[codebreakerTileEntity.HeldSchematicID];
if (schematicType == ModContent.ItemType<EncryptedSchematicPlanetoid>())
schematicIconTexture = ModContent.Request<Texture2D>("CalamityMod/Items/DraedonMisc/EncryptedSchematicPlanetoid");
schematicIconTexture = ModContent.Request<Texture2D>("CalamityMod/Items/DraedonMisc/EncryptedSchematicPlanetoid").Value;
if (schematicType == ModContent.ItemType<EncryptedSchematicJungle>())
schematicIconTexture = ModContent.Request<Texture2D>("CalamityMod/Items/DraedonMisc/EncryptedSchematicJungle");
schematicIconTexture = ModContent.Request<Texture2D>("CalamityMod/Items/DraedonMisc/EncryptedSchematicJungle").Value;
if (schematicType == ModContent.ItemType<EncryptedSchematicHell>())
schematicIconTexture = ModContent.Request<Texture2D>("CalamityMod/Items/DraedonMisc/EncryptedSchematicHell");
schematicIconTexture = ModContent.Request<Texture2D>("CalamityMod/Items/DraedonMisc/EncryptedSchematicHell").Value;
if (schematicType == ModContent.ItemType<EncryptedSchematicIce>())
schematicIconTexture = ModContent.Request<Texture2D>("CalamityMod/Items/DraedonMisc/EncryptedSchematicIce");
schematicIconTexture = ModContent.Request<Texture2D>("CalamityMod/Items/DraedonMisc/EncryptedSchematicIce").Value;
spriteBatch.Draw(schematicIconBG, schematicSlotDrawCenter, null, Color.White, 0f, schematicIconBG.Size() * 0.5f, GeneralScale, SpriteEffects.None, 0f);
if (codebreakerTileEntity.HeldSchematicID != 0)
@@ -155,7 +156,7 @@ namespace CalamityMod.UI
bool shouldPlaySound = true;
// If the player is holding shift and has space for the power cells, just spawn all of them on his or her face, up to the max-stack limit.
if (Main.keyState.PressingShift() && Main.LocalPlayer.ItemSpace(temporaryItem))
if (Main.keyState.PressingShift() && Main.LocalPlayer.ItemSpace(temporaryItem).CanTakeItemToPersonalInventory)
{
cellStackDiff = (short)-Math.Min(temporaryItem.stack, temporaryItem.maxStack);
DropHelper.DropItem(Main.LocalPlayer, powerCellID, -cellStackDiff);
@@ -273,20 +274,20 @@ namespace CalamityMod.UI
// Display the cost text.
string text = "Cost: ";
drawPosition.X -= GeneralScale * 30f;
Utils.DrawBorderStringFourWay(Main.spriteBatch, Main.fontMouseText, text, drawPosition.X, drawPosition.Y + GeneralScale * 20f, Color.White * (Main.mouseTextColor / 255f), Color.Black, Vector2.Zero, GeneralScale);
Utils.DrawBorderStringFourWay(Main.spriteBatch, FontAssets.MouseText.Value, text, drawPosition.X, drawPosition.Y + GeneralScale * 20f, Color.White * (Main.mouseTextColor / 255f), Color.Black, Vector2.Zero, GeneralScale);
// And draw the cells to the right of the text.
Texture2D cellTexture = ModContent.Request<Texture2D>("CalamityMod/Items/DraedonMisc/PowerCell");
Vector2 offsetDrawPosition = new Vector2(drawPosition.X + ChatManager.GetStringSize(Main.fontMouseText, text, Vector2.One, -1f).X * GeneralScale + GeneralScale * 15f, drawPosition.Y + GeneralScale * 30f);
Texture2D cellTexture = ModContent.Request<Texture2D>("CalamityMod/Items/DraedonMisc/PowerCell").Value;
Vector2 offsetDrawPosition = new Vector2(drawPosition.X + ChatManager.GetStringSize(FontAssets.MouseText.Value, text, Vector2.One, -1f).X * GeneralScale + GeneralScale * 15f, drawPosition.Y + GeneralScale * 30f);
Main.spriteBatch.Draw(cellTexture, offsetDrawPosition, null, Color.White, 0f, cellTexture.Size() * 0.5f, GeneralScale, SpriteEffects.None, 0f);
// Display the cell quantity numerically below the drawn cells.
Utils.DrawBorderStringFourWay(Main.spriteBatch, Main.fontItemStack, totalCellsCost.ToString(), offsetDrawPosition.X - GeneralScale * 11f, offsetDrawPosition.Y, Color.White, Color.Black, new Vector2(0.3f), GeneralScale * 0.75f);
Utils.DrawBorderStringFourWay(Main.spriteBatch, FontAssets.ItemStack.Value, totalCellsCost.ToString(), offsetDrawPosition.X - GeneralScale * 11f, offsetDrawPosition.Y, Color.White, Color.Black, new Vector2(0.3f), GeneralScale * 0.75f);
}
public static void DrawCostVerificationButton(TECodebreaker codebreakerTileEntity, Vector2 drawPosition)
{
Texture2D confirmationTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/DecryptIcon");
Texture2D confirmationTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/DecryptIcon").Value;
Rectangle clickArea = Utils.CenteredRectangle(drawPosition, confirmationTexture.Size() * VerificationButtonScale);
// Check if the mouse is hovering over the cost button area.
@@ -320,7 +321,7 @@ namespace CalamityMod.UI
public static void DisplayDecryptCancelButton(TECodebreaker codebreakerTileEntity, Vector2 drawPosition)
{
bool clickingMouse = Main.mouseLeft && Main.mouseLeftRelease;
Texture2D cancelTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/DecryptCancelIcon");
Texture2D cancelTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/DecryptCancelIcon").Value;
Rectangle clickArea = Utils.CenteredRectangle(drawPosition, cancelTexture.Size() * CancelButtonScale * 1.2f);
// Check if the mouse is hovering over the decrypt button area.
@@ -363,18 +364,18 @@ namespace CalamityMod.UI
public static void DrawDecryptCancelConfirmationText(Vector2 drawPosition)
{
Texture2D textPanelTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/DraedonDecrypterScreen");
Texture2D textPanelTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/DraedonDecrypterScreen").Value;
Vector2 scale = new Vector2(1f, 0.3f) * GeneralScale;
Main.spriteBatch.Draw(textPanelTexture, drawPosition, null, Color.White, 0f, textPanelTexture.Size() * 0.5f, scale, SpriteEffects.None, 0);
string confirmationText = "Are you sure?";
Vector2 confirmationTextPosition = drawPosition - Main.fontMouseText.MeasureString(confirmationText) * GeneralScale * 0.5f + Vector2.UnitY * GeneralScale * 4f;
ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, Main.fontMouseText, confirmationText, confirmationTextPosition, Color.Red, 0f, Vector2.Zero, Vector2.One * GeneralScale);
Vector2 confirmationTextPosition = drawPosition - FontAssets.MouseText.Value.MeasureString(confirmationText) * GeneralScale * 0.5f + Vector2.UnitY * GeneralScale * 4f;
ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, FontAssets.MouseText.Value, confirmationText, confirmationTextPosition, Color.Red, 0f, Vector2.Zero, Vector2.One * GeneralScale);
}
public static void HandleDecryptionStuff(TECodebreaker codebreakerTileEntity, Texture2D backgroundTexture, Vector2 backgroundTopLeft, Vector2 barCenter)
{
Texture2D textPanelTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/DraedonDecrypterScreen");
Texture2D textPanelTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/DraedonDecrypterScreen").Value;
Vector2 textPanelCenter = backgroundTopLeft + Vector2.UnitX * backgroundTexture.Width * GeneralScale + textPanelTexture.Size() * new Vector2(-0.5f, 0.5f) * GeneralScale;
Main.spriteBatch.Draw(textPanelTexture, textPanelCenter, null, Color.White, 0f, textPanelTexture.Size() * 0.5f, GeneralScale, SpriteEffects.None, 0f);
@@ -400,13 +401,13 @@ namespace CalamityMod.UI
Vector2 currentTextDrawPosition = backgroundTopLeft + new Vector2(backgroundTexture.Width - textPanelTexture.Width + textPadding, 6f) * GeneralScale;
// Draw the lines of text. A maximum of 10 may be drawn and the vertical offset per line is 16 pixels.
foreach (string line in Utils.WordwrapString(text.ToString(), Main.fontMouseText, (int)(textPanelTexture.Width * 1.5 - textPadding * 2), 10, out _))
foreach (string line in Utils.WordwrapString(text.ToString(), FontAssets.MouseText.Value, (int)(textPanelTexture.Width * 1.5 - textPadding * 2), 10, out _))
{
// If a line is null or empty for some reason, don't attempt to draw it or move to the next line position.
if (string.IsNullOrEmpty(line))
continue;
ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, Main.fontMouseText, line, currentTextDrawPosition, Color.Cyan, 0f, Vector2.Zero, new Vector2(0.6f) * GeneralScale);
ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, FontAssets.MouseText.Value, line, currentTextDrawPosition, Color.Cyan, 0f, Vector2.Zero, new Vector2(0.6f) * GeneralScale);
currentTextDrawPosition.Y += GeneralScale * 16f;
}
@@ -416,21 +417,21 @@ namespace CalamityMod.UI
return;
// Draw a small bar at the bottom to indicate how much work is left.
Texture2D borderTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/CodebreakerDecyptionBar");
Texture2D barTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/CodebreakerDecyptionBarCharge");
Texture2D borderTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/CodebreakerDecyptionBar").Value;
Texture2D barTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/CodebreakerDecyptionBarCharge").Value;
Main.spriteBatch.Draw(borderTexture, barCenter, null, Color.White, 0f, borderTexture.Size() * 0.5f, GeneralScale, SpriteEffects.None, 0);
Rectangle barRectangle = new Rectangle(0, 0, (int)(barTexture.Width * codebreakerTileEntity.DecryptionCompletion), barTexture.Width);
Main.spriteBatch.Draw(barTexture, barCenter, barRectangle, Color.White, 0f, barTexture.Size() * 0.5f, GeneralScale, SpriteEffects.None, 0);
// Display a completion percentage below the bar as a more precise indicator.
string completionText = $"{codebreakerTileEntity.DecryptionCompletion * 100f:n2}%";
Vector2 textDrawPosition = barCenter + new Vector2(-Main.fontMouseText.MeasureString(completionText).X * 0.5f, 10f) * GeneralScale;
Utils.DrawBorderStringFourWay(Main.spriteBatch, Main.fontMouseText, completionText, textDrawPosition.X, textDrawPosition.Y, Color.Cyan * 1.2f, Color.Black, Vector2.Zero, GeneralScale);
Vector2 textDrawPosition = barCenter + new Vector2(-FontAssets.MouseText.Value.MeasureString(completionText).X * 0.5f, 10f) * GeneralScale;
Utils.DrawBorderStringFourWay(Main.spriteBatch, FontAssets.MouseText.Value, completionText, textDrawPosition.X, textDrawPosition.Y, Color.Cyan * 1.2f, Color.Black, Vector2.Zero, GeneralScale);
}
public static void HandleDraedonSummonButton(TECodebreaker codebreakerTileEntity, Vector2 drawPosition)
{
Texture2D contactButton = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/ContactIcon_THanos");
Texture2D contactButton = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/ContactIcon_THanos").Value;
Rectangle clickArea = Utils.CenteredRectangle(drawPosition, contactButton.Size() * VerificationButtonScale);
@@ -447,7 +448,7 @@ namespace CalamityMod.UI
{
CalamityWorld.DraedonSummonCountdown = CalamityWorld.DraedonSummonCountdownMax;
CalamityWorld.DraedonSummonPosition = codebreakerTileEntity.Center + new Vector2(-8f, -100f);
SoundEngine.PlaySound(CalamityMod.Instance.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/CodebreakerBeam"), CalamityWorld.DraedonSummonPosition);
SoundEngine.PlaySound(SoundLoader.GetLegacySoundSlot(CalamityMod.Instance, "Sounds/Custom/CodebreakerBeam"), CalamityWorld.DraedonSummonPosition);
if (Main.netMode != NetmodeID.SinglePlayer)
{
@@ -473,15 +474,15 @@ namespace CalamityMod.UI
Color contactTextColor = CalamityUtils.MulticolorLerp((float)Math.Cos(Main.GlobalTimeWrappedHourly * 0.7f) * 0.5f + 0.5f, CalamityUtils.ExoPalette);
// Center the draw position.
drawPosition.X -= Main.fontMouseText.MeasureString(contactText).X * GeneralScale * 0.5f;
drawPosition.X -= FontAssets.MouseText.Value.MeasureString(contactText).X * GeneralScale * 0.5f;
drawPosition.Y += GeneralScale * 20f;
Utils.DrawBorderStringFourWay(Main.spriteBatch, Main.fontMouseText, contactText, drawPosition.X, drawPosition.Y, contactTextColor, Color.Black, Vector2.Zero, GeneralScale);
Utils.DrawBorderStringFourWay(Main.spriteBatch, FontAssets.MouseText.Value, contactText, drawPosition.X, drawPosition.Y, contactTextColor, Color.Black, Vector2.Zero, GeneralScale);
}
public static void DisplayNotStrongEnoughErrorText(Vector2 drawPosition)
{
string text = "Encryption unsolveable: Upgrades required.";
Utils.DrawBorderStringFourWay(Main.spriteBatch, Main.fontMouseText, text, drawPosition.X, drawPosition.Y, Color.IndianRed * (Main.mouseTextColor / 255f), Color.Black, Vector2.Zero, GeneralScale);
Utils.DrawBorderStringFourWay(Main.spriteBatch, FontAssets.MouseText.Value, text, drawPosition.X, drawPosition.Y, Color.IndianRed * (Main.mouseTextColor / 255f), Color.Black, Vector2.Zero, GeneralScale);
}
}
}
+6 -5
View File
@@ -1,9 +1,10 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.UI.Chat;
using Terraria.Localization;
using Terraria.ModLoader;
using Terraria.GameContent;
namespace CalamityMod.UI
{
@@ -18,21 +19,21 @@ namespace CalamityMod.UI
return;
string defenseDamageText = (-defenseDamage).ToString();
Texture2D defenseDamageIcon = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/DefenseDamage");
Texture2D defenseDamageIcon = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/DefenseDamage").Value;
Vector2 defenseDamageIconCenter = new Vector2(Main.screenWidth - Main.UIScale * 96f, Main.UIScale * 4f) + defenseDamageIcon.Size() * 0.5f;
Rectangle defenseDamageIconArea = Utils.CenteredRectangle(defenseDamageIconCenter, defenseDamageIcon.Size() * Main.UIScale);
Vector2 defenseDamageTextArea = Main.fontMouseText.MeasureString(defenseDamageText);
Vector2 defenseDamageTextArea = FontAssets.MouseText.Value.MeasureString(defenseDamageText);
Vector2 defenseDamageTextDrawPosition = defenseDamageIconCenter + new Vector2(6f, 16f) - defenseDamageTextArea * 0.5f;
Rectangle mouseArea = new Rectangle(Main.mouseX, Main.mouseY, 2, 2);
bool hoveringOverIcon = mouseArea.Intersects(defenseDamageIconArea);
if (hoveringOverIcon)
defenseDamageIcon = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/DefenseDamageHover");
defenseDamageIcon = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/DefenseDamageHover").Value;
// Draw the icon.
spriteBatch.Draw(defenseDamageIcon, defenseDamageIconCenter, null, Color.White, 0f, defenseDamageIcon.Size() * 0.5f, Main.UIScale, 0, 0f);
// Draw the amount of defense damage currently in effect as text. It is negatively signed as an indicator that it is quantity of loss and not gain.
ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, Main.fontMouseText, defenseDamageText, defenseDamageTextDrawPosition, Color.IndianRed, 0f, Vector2.Zero, Vector2.One * Main.UIScale * 0.75f);
ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, FontAssets.MouseText.Value, defenseDamageText, defenseDamageTextDrawPosition, Color.IndianRed, 0f, Vector2.Zero, Vector2.One * Main.UIScale * 0.75f);
// Display the amount of defense and defense damage the player has if hovering over the icon.
if (hoveringOverIcon)
+8 -7
View File
@@ -1,8 +1,9 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System.Collections.Generic;
using System.Linq;
using Terraria;
using Terraria.GameContent;
using Terraria.ModLoader;
namespace CalamityMod.UI
@@ -46,7 +47,7 @@ namespace CalamityMod.UI
public override void Draw(SpriteBatch spriteBatch)
{
Texture2D pageTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/DraedonsLogPage");
Texture2D pageTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/DraedonsLogPage").Value;
float xScale = MathHelper.Lerp(0.004f, 1f, FadeTime / (float)FadeTimeMax);
Vector2 scale = new Vector2(xScale, 1f) * new Vector2(Main.screenWidth, Main.screenHeight) / pageTexture.Size();
scale.Y *= 1.5f;
@@ -84,7 +85,7 @@ namespace CalamityMod.UI
{
int textWidth = (int)(xScale * pageTexture.Width) - TextStartOffsetX;
textWidth = (int)(textWidth * xResolutionScale);
List<string> dialogLines = Utils.WordwrapString(GetTextByPage(), Main.fontMouseText, (int)(textWidth / xResolutionScale), 250, out _).ToList();
List<string> dialogLines = Utils.WordwrapString(GetTextByPage(), FontAssets.MouseText.Value, (int)(textWidth / xResolutionScale), 250, out _).ToList();
dialogLines.RemoveAll(text => string.IsNullOrEmpty(text));
int trimmedTextCharacterCount = string.Concat(dialogLines).Length;
@@ -107,7 +108,7 @@ namespace CalamityMod.UI
int textDrawPositionY = (int)(42 * yResolutionScale) + i * (int)(yOffsetPerLine * yResolutionScale) + (int)yPageTop;
Utils.DrawBorderStringFourWay(spriteBatch,
Main.fontMouseText,
FontAssets.MouseText.Value,
dialogLines[i],
textDrawPositionX,
textDrawPositionY,
@@ -124,7 +125,7 @@ namespace CalamityMod.UI
public void DrawArrows(SpriteBatch spriteBatch, float xResolutionScale, float yResolutionScale, float yPageBottom, Rectangle mouseRectangle)
{
float arrowScale = 0.6f;
Texture2D arrowTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/DraedonsLogArrow");
Texture2D arrowTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/DraedonsLogArrow").Value;
if (Page > 0)
{
Vector2 drawPosition = new Vector2(Main.screenWidth / 2 - 80f, yPageBottom);
@@ -134,7 +135,7 @@ namespace CalamityMod.UI
if (mouseRectangle.Intersects(arrowRectangle))
{
arrowTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/DraedonsLogArrowHover");
arrowTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/DraedonsLogArrowHover").Value;
if (ArrowClickCooldown <= 0 && Main.mouseLeft)
{
Page--;
@@ -155,7 +156,7 @@ namespace CalamityMod.UI
if (mouseRectangle.Intersects(arrowRectangle))
{
arrowTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/DraedonsLogArrowHover");
arrowTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/UI/DraedonsLogArrowHover").Value;
if (ArrowClickCooldown <= 0 && Main.mouseLeft)
{
Page++;
+4 -3
View File
@@ -1,8 +1,9 @@
using CalamityMod.NPCs.ExoMechs;
using CalamityMod.NPCs.ExoMechs;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.GameContent;
using Terraria.ID;
using Terraria.ModLoader;
@@ -90,9 +91,9 @@ namespace CalamityMod.UI
// Draw the descrption if hovering over the icon.
if (hoveringOverIcon)
{
drawPosition.X -= Main.fontMouseText.MeasureString(description).X * 0.5f;
drawPosition.X -= FontAssets.MouseText.Value.MeasureString(description).X * 0.5f;
drawPosition.Y += 36f;
Utils.DrawBorderStringFourWay(Main.spriteBatch, Main.fontMouseText, description, drawPosition.X, drawPosition.Y, HoverTextColor, Color.Black, Vector2.Zero, 1f);
Utils.DrawBorderStringFourWay(Main.spriteBatch, FontAssets.MouseText.Value, description, drawPosition.X, drawPosition.Y, HoverTextColor, Color.Black, Vector2.Zero, 1f);
}
// And update to reflect the new scale.
+8 -7
View File
@@ -1,8 +1,9 @@
using CalamityMod.CalPlayer;
using CalamityMod.CalPlayer;
using CalamityMod.Events;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.GameContent;
using Terraria.Localization;
namespace CalamityMod.UI
@@ -23,7 +24,7 @@ namespace CalamityMod.UI
barDrawPosition.Y += barOffsetY;
Rectangle screenCoordsRectangle = new Rectangle((int)barDrawPosition.X - barWidth / 2, (int)barDrawPosition.Y - barHeight / 2, barWidth, barHeight);
Texture2D barTexture = Main.colorBarTexture;
Texture2D barTexture = TextureAssets.ColorBar.Value;
Utils.DrawInvBG(spriteBatch, screenCoordsRectangle, new Color(63, 65, 151, 255) * 0.785f);
spriteBatch.Draw(barTexture, barDrawPosition, null, Color.White, 0f, new Vector2(barTexture.Width / 2, 0f), 1f, SpriteEffects.None, 0f);
@@ -33,7 +34,7 @@ namespace CalamityMod.UI
string progressText = (100 * CompletionRatio).ToString($"N{SecondaryDigitPrecision}") + "%";
progressText = Language.GetTextValue("Game.WaveCleared", progressText);
Vector2 textSize = Main.fontMouseText.MeasureString(progressText);
Vector2 textSize = FontAssets.MouseText.Value.MeasureString(progressText);
float progressTextScale = 1f;
if (textSize.Y > 22f)
progressTextScale *= 22f / textSize.Y;
@@ -45,13 +46,13 @@ namespace CalamityMod.UI
{
float barDrawOffsetX = 169f;
Vector2 barDrawPosition = baseBarDrawPosition + Vector2.UnitX * (CompletionRatio - 0.5f) * barDrawOffsetX;
spriteBatch.Draw(Main.magicPixel, barDrawPosition, new Rectangle(0, 0, 1, 1), new Color(255, 241, 51), 0f, new Vector2(1f, 0.5f), new Vector2(barDrawOffsetX * CompletionRatio, yScale), SpriteEffects.None, 0f);
spriteBatch.Draw(Main.magicPixel, barDrawPosition, new Rectangle(0, 0, 1, 1), new Color(255, 165, 0, 127), 0f, new Vector2(1f, 0.5f), new Vector2(2f, yScale), SpriteEffects.None, 0f);
spriteBatch.Draw(Main.magicPixel, barDrawPosition, new Rectangle(0, 0, 1, 1), Color.Black, 0f, Vector2.UnitY * 0.5f, new Vector2(barDrawOffsetX * (1f - CompletionRatio), yScale), SpriteEffects.None, 0f);
spriteBatch.Draw(TextureAssets.MagicPixel.Value, barDrawPosition, new Rectangle(0, 0, 1, 1), new Color(255, 241, 51), 0f, new Vector2(1f, 0.5f), new Vector2(barDrawOffsetX * CompletionRatio, yScale), SpriteEffects.None, 0f);
spriteBatch.Draw(TextureAssets.MagicPixel.Value, barDrawPosition, new Rectangle(0, 0, 1, 1), new Color(255, 165, 0, 127), 0f, new Vector2(1f, 0.5f), new Vector2(2f, yScale), SpriteEffects.None, 0f);
spriteBatch.Draw(TextureAssets.MagicPixel.Value, barDrawPosition, new Rectangle(0, 0, 1, 1), Color.Black, 0f, Vector2.UnitY * 0.5f, new Vector2(barDrawOffsetX * (1f - CompletionRatio), yScale), SpriteEffects.None, 0f);
}
public virtual void DrawProgressTextAndIcons(SpriteBatch spriteBatch, int barOffsetY)
{
Vector2 textMeasurement = Main.fontMouseText.MeasureString(InvasionName);
Vector2 textMeasurement = FontAssets.MouseText.Value.MeasureString(InvasionName);
float x = 120f;
if (textMeasurement.X > 200f)
{
+9 -8
View File
@@ -1,4 +1,4 @@
using CalamityMod.CalPlayer;
using CalamityMod.CalPlayer;
using CalamityMod.TileEntities;
using Terraria.ID;
using Microsoft.Xna.Framework;
@@ -7,6 +7,7 @@ using System.Collections.Generic;
using Terraria;
using Terraria.DataStructures;
using Terraria.Audio;
using Terraria.GameContent;
namespace CalamityMod.UI
{
@@ -82,15 +83,15 @@ namespace CalamityMod.UI
Color backgroundColor = new Color(200, 200, 200, 200);
// Wrap the text so that it neatly fits in the dialogue box.
string[] dialogLines = Utils.WordwrapString(mp.CurrentlyViewedHologramText, Main.fontMouseText, (int)(TextAreaWidth - TextPadding * 2), 10, out int lineCount);
string[] dialogLines = Utils.WordwrapString(mp.CurrentlyViewedHologramText, FontAssets.MouseText.Value, (int)(TextAreaWidth - TextPadding * 2), 10, out int lineCount);
// Draw the background of the text box.
spriteBatch.Draw(Main.chatBackTexture, new Vector2(Main.screenWidth / 2 - Main.chatBackTexture.Width / 2, 100f),
new Rectangle(0, 0, Main.chatBackTexture.Width, (lineCount + 2) * 30), backgroundColor, 0f, Vector2.Zero, 1f,
spriteBatch.Draw(TextureAssets.ChatBack.Value, new Vector2(Main.screenWidth / 2 - TextureAssets.ChatBack.Value.Width / 2, 100f),
new Rectangle(0, 0, TextureAssets.ChatBack.Value.Width, (lineCount + 2) * 30), backgroundColor, 0f, Vector2.Zero, 1f,
SpriteEffects.None, 0f);
spriteBatch.Draw(Main.chatBackTexture,
new Vector2(Main.screenWidth / 2 - Main.chatBackTexture.Width / 2, 100 + (lineCount + 2) * 30),
new Rectangle(0, Main.chatBackTexture.Height - 30, Main.chatBackTexture.Width, 30), backgroundColor, 0f,
spriteBatch.Draw(TextureAssets.ChatBack.Value,
new Vector2(Main.screenWidth / 2 - TextureAssets.ChatBack.Value.Width / 2, 100 + (lineCount + 2) * 30),
new Rectangle(0, TextureAssets.ChatBack.Value.Height - 30, TextureAssets.ChatBack.Value.Width, 30), backgroundColor, 0f,
Vector2.Zero, 1f, SpriteEffects.None, 0f);
// Draw the dialogue itself.
@@ -99,7 +100,7 @@ namespace CalamityMod.UI
string text = dialogLines[i];
if (text is null)
continue;
Utils.DrawBorderStringFourWay(spriteBatch, Main.fontMouseText, dialogLines[i],
Utils.DrawBorderStringFourWay(spriteBatch, FontAssets.MouseText.Value, dialogLines[i],
(int)TextPadding + (int)(Main.screenWidth - TextAreaWidth) / 2, 120 + i * YOffsetPerLine, Color.Cyan, Color.Black,
Vector2.Zero);
}
+5 -4
View File
@@ -1,4 +1,4 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.DataStructures;
@@ -7,6 +7,7 @@ using Terraria.ModLoader;
using Terraria.UI.Chat;
using static Terraria.ModLoader.ModContent;
using Terraria.Audio;
using Terraria.GameContent;
namespace CalamityMod
{
@@ -69,11 +70,11 @@ namespace CalamityMod
// Draws the Power Cell item slot in a UI. Used by both the Power Cell Factory and Charging Station.
internal static void DrawPowercellSlot(SpriteBatch spriteBatch, Item item, Vector2 drawPosition, float iconScale = 0.7f)
{
Texture2D slotBackgroundTex = GetTexture("CalamityMod/ExtraTextures/UI/PowerCellSlot_Empty");
Texture2D slotBackgroundTex = Request<Texture2D>("CalamityMod/ExtraTextures/UI/PowerCellSlot_Empty").Value;
// This check is done twice because the draw order matters. We want to draw the background icon before any text.
if (item.stack > 0)
slotBackgroundTex = GetTexture("CalamityMod/ExtraTextures/UI/PowerCellSlot_Filled");
slotBackgroundTex = Request<Texture2D>("CalamityMod/ExtraTextures/UI/PowerCellSlot_Filled").Value;
spriteBatch.Draw(slotBackgroundTex, drawPosition, null, Color.White, 0f, slotBackgroundTex.Size() * 0.5f, iconScale, SpriteEffects.None, 0f);
if (item.stack > 0)
@@ -82,7 +83,7 @@ namespace CalamityMod
Vector2 numberOffset = slotBackgroundTex.Size() * 0.2f;
numberOffset.X -= 17f;
ChatManager.DrawColorCodedStringWithShadow(spriteBatch,
Main.fontItemStack,
FontAssets.ItemStack.Value,
item.stack.ToString(),
drawPosition + numberOffset * inventoryScale,
Color.White,