Terraria 1.4.0.5 Source Code

This commit is contained in:
MikeyIsBaeYT 2021-10-26 12:45:26 -04:00
commit 05205f009e
1059 changed files with 563450 additions and 0 deletions

399
UI/AchievementAdvisor.cs Normal file
View file

@ -0,0 +1,399 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.UI.AchievementAdvisor
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using System;
using System.Collections.Generic;
using System.Linq;
using Terraria.Achievements;
using Terraria.GameInput;
namespace Terraria.UI
{
public class AchievementAdvisor
{
private List<AchievementAdvisorCard> _cards = new List<AchievementAdvisorCard>();
private Asset<Texture2D> _achievementsTexture;
private Asset<Texture2D> _achievementsBorderTexture;
private Asset<Texture2D> _achievementsBorderMouseHoverFatTexture;
private Asset<Texture2D> _achievementsBorderMouseHoverThinTexture;
private AchievementAdvisorCard _hoveredCard;
public bool CanDrawAboveCoins => Main.screenWidth >= 1000 && !PlayerInput.UsingGamepad;
public void LoadContent()
{
this._achievementsTexture = Main.Assets.Request<Texture2D>("Images/UI/Achievements", (AssetRequestMode) 1);
this._achievementsBorderTexture = Main.Assets.Request<Texture2D>("Images/UI/Achievement_Borders", (AssetRequestMode) 1);
this._achievementsBorderMouseHoverFatTexture = Main.Assets.Request<Texture2D>("Images/UI/Achievement_Borders_MouseHover", (AssetRequestMode) 1);
this._achievementsBorderMouseHoverThinTexture = Main.Assets.Request<Texture2D>("Images/UI/Achievement_Borders_MouseHoverThin", (AssetRequestMode) 1);
}
public void Draw(SpriteBatch spriteBatch)
{
}
public void DrawOneAchievement(SpriteBatch spriteBatch, Vector2 position, bool large)
{
List<AchievementAdvisorCard> bestCards = this.GetBestCards(1);
if (bestCards.Count < 1)
return;
AchievementAdvisorCard achievementAdvisorCard = bestCards[0];
float scale = 0.35f;
if (large)
scale = 0.75f;
this._hoveredCard = (AchievementAdvisorCard) null;
bool hovered;
this.DrawCard(bestCards[0], spriteBatch, position + new Vector2(8f) * scale, scale, out hovered);
if (!hovered)
return;
this._hoveredCard = achievementAdvisorCard;
if (PlayerInput.IgnoreMouseInterface)
return;
Main.player[Main.myPlayer].mouseInterface = true;
if (!Main.mouseLeft || !Main.mouseLeftRelease)
return;
Main.ingameOptionsWindow = false;
IngameFancyUI.OpenAchievementsAndGoto(this._hoveredCard.achievement);
}
public void Update() => this._hoveredCard = (AchievementAdvisorCard) null;
public void DrawOptionsPanel(
SpriteBatch spriteBatch,
Vector2 leftPosition,
Vector2 rightPosition)
{
List<AchievementAdvisorCard> bestCards = this.GetBestCards();
this._hoveredCard = (AchievementAdvisorCard) null;
int num = bestCards.Count;
if (num > 5)
num = 5;
bool hovered;
for (int index = 0; index < num; ++index)
{
this.DrawCard(bestCards[index], spriteBatch, leftPosition + new Vector2((float) (42 * index), 0.0f), 0.5f, out hovered);
if (hovered)
this._hoveredCard = bestCards[index];
}
for (int index = 5; index < bestCards.Count; ++index)
{
this.DrawCard(bestCards[index], spriteBatch, rightPosition + new Vector2((float) (42 * index), 0.0f), 0.5f, out hovered);
if (hovered)
this._hoveredCard = bestCards[index];
}
if (this._hoveredCard == null)
return;
if (this._hoveredCard.achievement.IsCompleted)
{
this._hoveredCard = (AchievementAdvisorCard) null;
}
else
{
if (PlayerInput.IgnoreMouseInterface)
return;
Main.player[Main.myPlayer].mouseInterface = true;
if (!Main.mouseLeft || !Main.mouseLeftRelease)
return;
Main.ingameOptionsWindow = false;
IngameFancyUI.OpenAchievementsAndGoto(this._hoveredCard.achievement);
}
}
public void DrawMouseHover()
{
if (this._hoveredCard == null)
return;
Main.spriteBatch.End();
Main.spriteBatch.Begin(SpriteSortMode.Deferred, (BlendState) null, (SamplerState) null, (DepthStencilState) null, (RasterizerState) null, (Effect) null, Main.UIScaleMatrix);
PlayerInput.SetZoom_UI();
Item obj = new Item();
obj.SetDefaults(0, true);
obj.SetNameOverride(this._hoveredCard.achievement.FriendlyName.Value);
obj.ToolTip = ItemTooltip.FromLanguageKey(this._hoveredCard.achievement.Description.Key);
obj.type = 1;
obj.scale = 0.0f;
obj.rare = 10;
obj.value = -1;
Main.HoverItem = obj;
Main.instance.MouseText("");
Main.mouseText = true;
}
private void DrawCard(
AchievementAdvisorCard card,
SpriteBatch spriteBatch,
Vector2 position,
float scale,
out bool hovered)
{
hovered = false;
if (Main.MouseScreen.Between(position, position + card.frame.Size() * scale))
{
Main.LocalPlayer.mouseInterface = true;
hovered = true;
}
Color color = Color.White;
if (!hovered)
color = new Color(220, 220, 220, 220);
Vector2 vector2_1 = new Vector2(-4f) * scale;
Vector2 vector2_2 = new Vector2(-8f) * scale;
Texture2D texture = this._achievementsBorderMouseHoverFatTexture.Value;
if ((double) scale > 0.5)
{
texture = this._achievementsBorderMouseHoverThinTexture.Value;
vector2_2 = new Vector2(-5f) * scale;
}
Rectangle frame = card.frame;
frame.X += 528;
spriteBatch.Draw(this._achievementsTexture.Value, position, new Rectangle?(frame), color, 0.0f, Vector2.Zero, scale, SpriteEffects.None, 0.0f);
spriteBatch.Draw(this._achievementsBorderTexture.Value, position + vector2_1, new Rectangle?(), color, 0.0f, Vector2.Zero, scale, SpriteEffects.None, 0.0f);
if (!hovered)
return;
spriteBatch.Draw(texture, position + vector2_2, new Rectangle?(), Main.OurFavoriteColor, 0.0f, Vector2.Zero, scale, SpriteEffects.None, 0.0f);
}
private List<AchievementAdvisorCard> GetBestCards(int cardsAmount = 10)
{
List<AchievementAdvisorCard> achievementAdvisorCardList = new List<AchievementAdvisorCard>();
for (int index = 0; index < this._cards.Count; ++index)
{
AchievementAdvisorCard card = this._cards[index];
if (!card.achievement.IsCompleted && card.IsAchievableInWorld())
{
achievementAdvisorCardList.Add(card);
if (achievementAdvisorCardList.Count >= cardsAmount)
break;
}
}
return achievementAdvisorCardList;
}
public void Initialize()
{
float num1 = 1f;
List<AchievementAdvisorCard> cards1 = this._cards;
Achievement achievement1 = Main.Achievements.GetAchievement("TIMBER");
double num2 = (double) num1;
float num3 = (float) (num2 + 1.0);
AchievementAdvisorCard achievementAdvisorCard1 = new AchievementAdvisorCard(achievement1, (float) num2);
cards1.Add(achievementAdvisorCard1);
List<AchievementAdvisorCard> cards2 = this._cards;
Achievement achievement2 = Main.Achievements.GetAchievement("BENCHED");
double num4 = (double) num3;
float num5 = (float) (num4 + 1.0);
AchievementAdvisorCard achievementAdvisorCard2 = new AchievementAdvisorCard(achievement2, (float) num4);
cards2.Add(achievementAdvisorCard2);
List<AchievementAdvisorCard> cards3 = this._cards;
Achievement achievement3 = Main.Achievements.GetAchievement("OBTAIN_HAMMER");
double num6 = (double) num5;
float num7 = (float) (num6 + 1.0);
AchievementAdvisorCard achievementAdvisorCard3 = new AchievementAdvisorCard(achievement3, (float) num6);
cards3.Add(achievementAdvisorCard3);
List<AchievementAdvisorCard> cards4 = this._cards;
Achievement achievement4 = Main.Achievements.GetAchievement("NO_HOBO");
double num8 = (double) num7;
float num9 = (float) (num8 + 1.0);
AchievementAdvisorCard achievementAdvisorCard4 = new AchievementAdvisorCard(achievement4, (float) num8);
cards4.Add(achievementAdvisorCard4);
List<AchievementAdvisorCard> cards5 = this._cards;
Achievement achievement5 = Main.Achievements.GetAchievement("YOU_CAN_DO_IT");
double num10 = (double) num9;
float num11 = (float) (num10 + 1.0);
AchievementAdvisorCard achievementAdvisorCard5 = new AchievementAdvisorCard(achievement5, (float) num10);
cards5.Add(achievementAdvisorCard5);
List<AchievementAdvisorCard> cards6 = this._cards;
Achievement achievement6 = Main.Achievements.GetAchievement("OOO_SHINY");
double num12 = (double) num11;
float num13 = (float) (num12 + 1.0);
AchievementAdvisorCard achievementAdvisorCard6 = new AchievementAdvisorCard(achievement6, (float) num12);
cards6.Add(achievementAdvisorCard6);
List<AchievementAdvisorCard> cards7 = this._cards;
Achievement achievement7 = Main.Achievements.GetAchievement("HEAVY_METAL");
double num14 = (double) num13;
float num15 = (float) (num14 + 1.0);
AchievementAdvisorCard achievementAdvisorCard7 = new AchievementAdvisorCard(achievement7, (float) num14);
cards7.Add(achievementAdvisorCard7);
List<AchievementAdvisorCard> cards8 = this._cards;
Achievement achievement8 = Main.Achievements.GetAchievement("MATCHING_ATTIRE");
double num16 = (double) num15;
float num17 = (float) (num16 + 1.0);
AchievementAdvisorCard achievementAdvisorCard8 = new AchievementAdvisorCard(achievement8, (float) num16);
cards8.Add(achievementAdvisorCard8);
List<AchievementAdvisorCard> cards9 = this._cards;
Achievement achievement9 = Main.Achievements.GetAchievement("HEART_BREAKER");
double num18 = (double) num17;
float num19 = (float) (num18 + 1.0);
AchievementAdvisorCard achievementAdvisorCard9 = new AchievementAdvisorCard(achievement9, (float) num18);
cards9.Add(achievementAdvisorCard9);
List<AchievementAdvisorCard> cards10 = this._cards;
Achievement achievement10 = Main.Achievements.GetAchievement("I_AM_LOOT");
double num20 = (double) num19;
float num21 = (float) (num20 + 1.0);
AchievementAdvisorCard achievementAdvisorCard10 = new AchievementAdvisorCard(achievement10, (float) num20);
cards10.Add(achievementAdvisorCard10);
List<AchievementAdvisorCard> cards11 = this._cards;
Achievement achievement11 = Main.Achievements.GetAchievement("HOLD_ON_TIGHT");
double num22 = (double) num21;
float num23 = (float) (num22 + 1.0);
AchievementAdvisorCard achievementAdvisorCard11 = new AchievementAdvisorCard(achievement11, (float) num22);
cards11.Add(achievementAdvisorCard11);
List<AchievementAdvisorCard> cards12 = this._cards;
Achievement achievement12 = Main.Achievements.GetAchievement("STAR_POWER");
double num24 = (double) num23;
float num25 = (float) (num24 + 1.0);
AchievementAdvisorCard achievementAdvisorCard12 = new AchievementAdvisorCard(achievement12, (float) num24);
cards12.Add(achievementAdvisorCard12);
List<AchievementAdvisorCard> cards13 = this._cards;
Achievement achievement13 = Main.Achievements.GetAchievement("EYE_ON_YOU");
double num26 = (double) num25;
float num27 = (float) (num26 + 1.0);
AchievementAdvisorCard achievementAdvisorCard13 = new AchievementAdvisorCard(achievement13, (float) num26);
cards13.Add(achievementAdvisorCard13);
List<AchievementAdvisorCard> cards14 = this._cards;
Achievement achievement14 = Main.Achievements.GetAchievement("SMASHING_POPPET");
double num28 = (double) num27;
float num29 = (float) (num28 + 1.0);
AchievementAdvisorCard achievementAdvisorCard14 = new AchievementAdvisorCard(achievement14, (float) num28);
cards14.Add(achievementAdvisorCard14);
List<AchievementAdvisorCard> cards15 = this._cards;
Achievement achievement15 = Main.Achievements.GetAchievement("WHERES_MY_HONEY");
double num30 = (double) num29;
float num31 = (float) (num30 + 1.0);
AchievementAdvisorCard achievementAdvisorCard15 = new AchievementAdvisorCard(achievement15, (float) num30);
cards15.Add(achievementAdvisorCard15);
List<AchievementAdvisorCard> cards16 = this._cards;
Achievement achievement16 = Main.Achievements.GetAchievement("STING_OPERATION");
double num32 = (double) num31;
float num33 = (float) (num32 + 1.0);
AchievementAdvisorCard achievementAdvisorCard16 = new AchievementAdvisorCard(achievement16, (float) num32);
cards16.Add(achievementAdvisorCard16);
List<AchievementAdvisorCard> cards17 = this._cards;
Achievement achievement17 = Main.Achievements.GetAchievement("BONED");
double num34 = (double) num33;
float num35 = (float) (num34 + 1.0);
AchievementAdvisorCard achievementAdvisorCard17 = new AchievementAdvisorCard(achievement17, (float) num34);
cards17.Add(achievementAdvisorCard17);
List<AchievementAdvisorCard> cards18 = this._cards;
Achievement achievement18 = Main.Achievements.GetAchievement("DUNGEON_HEIST");
double num36 = (double) num35;
float num37 = (float) (num36 + 1.0);
AchievementAdvisorCard achievementAdvisorCard18 = new AchievementAdvisorCard(achievement18, (float) num36);
cards18.Add(achievementAdvisorCard18);
List<AchievementAdvisorCard> cards19 = this._cards;
Achievement achievement19 = Main.Achievements.GetAchievement("ITS_GETTING_HOT_IN_HERE");
double num38 = (double) num37;
float num39 = (float) (num38 + 1.0);
AchievementAdvisorCard achievementAdvisorCard19 = new AchievementAdvisorCard(achievement19, (float) num38);
cards19.Add(achievementAdvisorCard19);
List<AchievementAdvisorCard> cards20 = this._cards;
Achievement achievement20 = Main.Achievements.GetAchievement("MINER_FOR_FIRE");
double num40 = (double) num39;
float num41 = (float) (num40 + 1.0);
AchievementAdvisorCard achievementAdvisorCard20 = new AchievementAdvisorCard(achievement20, (float) num40);
cards20.Add(achievementAdvisorCard20);
List<AchievementAdvisorCard> cards21 = this._cards;
Achievement achievement21 = Main.Achievements.GetAchievement("STILL_HUNGRY");
double num42 = (double) num41;
float num43 = (float) (num42 + 1.0);
AchievementAdvisorCard achievementAdvisorCard21 = new AchievementAdvisorCard(achievement21, (float) num42);
cards21.Add(achievementAdvisorCard21);
List<AchievementAdvisorCard> cards22 = this._cards;
Achievement achievement22 = Main.Achievements.GetAchievement("ITS_HARD");
double num44 = (double) num43;
float num45 = (float) (num44 + 1.0);
AchievementAdvisorCard achievementAdvisorCard22 = new AchievementAdvisorCard(achievement22, (float) num44);
cards22.Add(achievementAdvisorCard22);
List<AchievementAdvisorCard> cards23 = this._cards;
Achievement achievement23 = Main.Achievements.GetAchievement("BEGONE_EVIL");
double num46 = (double) num45;
float num47 = (float) (num46 + 1.0);
AchievementAdvisorCard achievementAdvisorCard23 = new AchievementAdvisorCard(achievement23, (float) num46);
cards23.Add(achievementAdvisorCard23);
List<AchievementAdvisorCard> cards24 = this._cards;
Achievement achievement24 = Main.Achievements.GetAchievement("EXTRA_SHINY");
double num48 = (double) num47;
float num49 = (float) (num48 + 1.0);
AchievementAdvisorCard achievementAdvisorCard24 = new AchievementAdvisorCard(achievement24, (float) num48);
cards24.Add(achievementAdvisorCard24);
List<AchievementAdvisorCard> cards25 = this._cards;
Achievement achievement25 = Main.Achievements.GetAchievement("HEAD_IN_THE_CLOUDS");
double num50 = (double) num49;
float num51 = (float) (num50 + 1.0);
AchievementAdvisorCard achievementAdvisorCard25 = new AchievementAdvisorCard(achievement25, (float) num50);
cards25.Add(achievementAdvisorCard25);
List<AchievementAdvisorCard> cards26 = this._cards;
Achievement achievement26 = Main.Achievements.GetAchievement("BUCKETS_OF_BOLTS");
double num52 = (double) num51;
float num53 = (float) (num52 + 1.0);
AchievementAdvisorCard achievementAdvisorCard26 = new AchievementAdvisorCard(achievement26, (float) num52);
cards26.Add(achievementAdvisorCard26);
List<AchievementAdvisorCard> cards27 = this._cards;
Achievement achievement27 = Main.Achievements.GetAchievement("DRAX_ATTAX");
double num54 = (double) num53;
float num55 = (float) (num54 + 1.0);
AchievementAdvisorCard achievementAdvisorCard27 = new AchievementAdvisorCard(achievement27, (float) num54);
cards27.Add(achievementAdvisorCard27);
List<AchievementAdvisorCard> cards28 = this._cards;
Achievement achievement28 = Main.Achievements.GetAchievement("PHOTOSYNTHESIS");
double num56 = (double) num55;
float num57 = (float) (num56 + 1.0);
AchievementAdvisorCard achievementAdvisorCard28 = new AchievementAdvisorCard(achievement28, (float) num56);
cards28.Add(achievementAdvisorCard28);
List<AchievementAdvisorCard> cards29 = this._cards;
Achievement achievement29 = Main.Achievements.GetAchievement("GET_A_LIFE");
double num58 = (double) num57;
float num59 = (float) (num58 + 1.0);
AchievementAdvisorCard achievementAdvisorCard29 = new AchievementAdvisorCard(achievement29, (float) num58);
cards29.Add(achievementAdvisorCard29);
List<AchievementAdvisorCard> cards30 = this._cards;
Achievement achievement30 = Main.Achievements.GetAchievement("THE_GREAT_SOUTHERN_PLANTKILL");
double num60 = (double) num59;
float num61 = (float) (num60 + 1.0);
AchievementAdvisorCard achievementAdvisorCard30 = new AchievementAdvisorCard(achievement30, (float) num60);
cards30.Add(achievementAdvisorCard30);
List<AchievementAdvisorCard> cards31 = this._cards;
Achievement achievement31 = Main.Achievements.GetAchievement("TEMPLE_RAIDER");
double num62 = (double) num61;
float num63 = (float) (num62 + 1.0);
AchievementAdvisorCard achievementAdvisorCard31 = new AchievementAdvisorCard(achievement31, (float) num62);
cards31.Add(achievementAdvisorCard31);
List<AchievementAdvisorCard> cards32 = this._cards;
Achievement achievement32 = Main.Achievements.GetAchievement("LIHZAHRDIAN_IDOL");
double num64 = (double) num63;
float num65 = (float) (num64 + 1.0);
AchievementAdvisorCard achievementAdvisorCard32 = new AchievementAdvisorCard(achievement32, (float) num64);
cards32.Add(achievementAdvisorCard32);
List<AchievementAdvisorCard> cards33 = this._cards;
Achievement achievement33 = Main.Achievements.GetAchievement("ROBBING_THE_GRAVE");
double num66 = (double) num65;
float num67 = (float) (num66 + 1.0);
AchievementAdvisorCard achievementAdvisorCard33 = new AchievementAdvisorCard(achievement33, (float) num66);
cards33.Add(achievementAdvisorCard33);
List<AchievementAdvisorCard> cards34 = this._cards;
Achievement achievement34 = Main.Achievements.GetAchievement("OBSESSIVE_DEVOTION");
double num68 = (double) num67;
float num69 = (float) (num68 + 1.0);
AchievementAdvisorCard achievementAdvisorCard34 = new AchievementAdvisorCard(achievement34, (float) num68);
cards34.Add(achievementAdvisorCard34);
List<AchievementAdvisorCard> cards35 = this._cards;
Achievement achievement35 = Main.Achievements.GetAchievement("STAR_DESTROYER");
double num70 = (double) num69;
float num71 = (float) (num70 + 1.0);
AchievementAdvisorCard achievementAdvisorCard35 = new AchievementAdvisorCard(achievement35, (float) num70);
cards35.Add(achievementAdvisorCard35);
List<AchievementAdvisorCard> cards36 = this._cards;
Achievement achievement36 = Main.Achievements.GetAchievement("CHAMPION_OF_TERRARIA");
double num72 = (double) num71;
float num73 = (float) (num72 + 1.0);
AchievementAdvisorCard achievementAdvisorCard36 = new AchievementAdvisorCard(achievement36, (float) num72);
cards36.Add(achievementAdvisorCard36);
this._cards.OrderBy<AchievementAdvisorCard, float>((Func<AchievementAdvisorCard, float>) (x => x.order));
}
}
}

View file

@ -0,0 +1,38 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.UI.AchievementAdvisorCard
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Terraria.Achievements;
namespace Terraria.UI
{
public class AchievementAdvisorCard
{
private const int _iconSize = 64;
private const int _iconSizeWithSpace = 66;
private const int _iconsPerRow = 8;
public Achievement achievement;
public float order;
public Rectangle frame;
public int achievementIndex;
public AchievementAdvisorCard(Achievement achievement, float order)
{
this.achievement = achievement;
this.order = order;
this.achievementIndex = Main.Achievements.GetIconIndex(achievement.Name);
this.frame = new Rectangle(this.achievementIndex % 8 * 66, this.achievementIndex / 8 * 66, 64, 64);
}
public bool IsAchievableInWorld()
{
string name = this.achievement.Name;
if (name == "MASTERMIND")
return WorldGen.crimson;
return !(name == "WORM_FODDER") || !WorldGen.crimson;
}
}
}

33
UI/Alignment.cs Normal file
View file

@ -0,0 +1,33 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.UI.Alignment
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
namespace Terraria.UI
{
public struct Alignment
{
public static readonly Alignment TopLeft = new Alignment(0.0f, 0.0f);
public static readonly Alignment Top = new Alignment(0.5f, 0.0f);
public static readonly Alignment TopRight = new Alignment(1f, 0.0f);
public static readonly Alignment Left = new Alignment(0.0f, 0.5f);
public static readonly Alignment Center = new Alignment(0.5f, 0.5f);
public static readonly Alignment Right = new Alignment(1f, 0.5f);
public static readonly Alignment BottomLeft = new Alignment(0.0f, 1f);
public static readonly Alignment Bottom = new Alignment(0.5f, 1f);
public static readonly Alignment BottomRight = new Alignment(1f, 1f);
public readonly float VerticalOffsetMultiplier;
public readonly float HorizontalOffsetMultiplier;
public Vector2 OffsetMultiplier => new Vector2(this.HorizontalOffsetMultiplier, this.VerticalOffsetMultiplier);
private Alignment(float horizontal, float vertical)
{
this.HorizontalOffsetMultiplier = horizontal;
this.VerticalOffsetMultiplier = vertical;
}
}
}

32
UI/CalculatedStyle.cs Normal file
View file

@ -0,0 +1,32 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.UI.CalculatedStyle
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
namespace Terraria.UI
{
public struct CalculatedStyle
{
public float X;
public float Y;
public float Width;
public float Height;
public CalculatedStyle(float x, float y, float width, float height)
{
this.X = x;
this.Y = y;
this.Width = width;
this.Height = height;
}
public Rectangle ToRectangle() => new Rectangle((int) this.X, (int) this.Y, (int) this.Width, (int) this.Height);
public Vector2 Position() => new Vector2(this.X, this.Y);
public Vector2 Center() => new Vector2(this.X + this.Width * 0.5f, this.Y + this.Height * 0.5f);
}
}

41
UI/Chat/ChatLine.cs Normal file
View file

@ -0,0 +1,41 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.UI.Chat.ChatLine
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
namespace Terraria.UI.Chat
{
public class ChatLine
{
public Color color = Color.White;
public int showTime;
public string originalText = "";
public TextSnippet[] parsedText = new TextSnippet[0];
private int? parsingPixelLimit;
private bool needsParsing;
public void UpdateTimeLeft()
{
if (this.showTime > 0)
--this.showTime;
if (!this.needsParsing)
return;
this.needsParsing = false;
}
public void Copy(ChatLine other)
{
this.needsParsing = other.needsParsing;
this.parsingPixelLimit = other.parsingPixelLimit;
this.originalText = other.originalText;
this.parsedText = other.parsedText;
this.showTime = other.showTime;
this.color = other.color;
}
public void FlagAsNeedsReprocessing() => this.needsParsing = true;
}
}

435
UI/Chat/ChatManager.cs Normal file
View file

@ -0,0 +1,435 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.UI.Chat.ChatManager
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Graphics;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using Terraria.Chat;
using Terraria.GameContent.UI.Chat;
namespace Terraria.UI.Chat
{
public static class ChatManager
{
public static readonly ChatCommandProcessor Commands = new ChatCommandProcessor();
private static ConcurrentDictionary<string, ITagHandler> _handlers = new ConcurrentDictionary<string, ITagHandler>();
public static readonly Vector2[] ShadowDirections = new Vector2[4]
{
-Vector2.UnitX,
Vector2.UnitX,
-Vector2.UnitY,
Vector2.UnitY
};
public static Color WaveColor(Color color)
{
float num = (float) Main.mouseTextColor / (float) byte.MaxValue;
color = Color.Lerp(color, Color.Black, 1f - num);
color.A = Main.mouseTextColor;
return color;
}
public static void ConvertNormalSnippets(TextSnippet[] snippets)
{
for (int index = 0; index < snippets.Length; ++index)
{
TextSnippet snippet = snippets[index];
if (snippets[index].GetType() == typeof (TextSnippet))
{
PlainTagHandler.PlainSnippet plainSnippet = new PlainTagHandler.PlainSnippet(snippet.Text, snippet.Color, snippet.Scale);
snippets[index] = (TextSnippet) plainSnippet;
}
}
}
public static void Register<T>(params string[] names) where T : ITagHandler, new()
{
T obj = new T();
for (int index = 0; index < names.Length; ++index)
ChatManager._handlers[names[index].ToLower()] = (ITagHandler) obj;
}
private static ITagHandler GetHandler(string tagName)
{
string lower = tagName.ToLower();
return ChatManager._handlers.ContainsKey(lower) ? ChatManager._handlers[lower] : (ITagHandler) null;
}
public static List<TextSnippet> ParseMessage(string text, Color baseColor)
{
text = text.Replace("\r", "");
MatchCollection matchCollection = ChatManager.Regexes.Format.Matches(text);
List<TextSnippet> textSnippetList = new List<TextSnippet>();
int startIndex = 0;
foreach (Match match in matchCollection)
{
if (match.Index > startIndex)
textSnippetList.Add(new TextSnippet(text.Substring(startIndex, match.Index - startIndex), baseColor));
startIndex = match.Index + match.Length;
string tagName = match.Groups["tag"].Value;
string text1 = match.Groups[nameof (text)].Value;
string options = match.Groups["options"].Value;
ITagHandler handler = ChatManager.GetHandler(tagName);
if (handler != null)
{
textSnippetList.Add(handler.Parse(text1, baseColor, options));
textSnippetList[textSnippetList.Count - 1].TextOriginal = match.ToString();
}
else
textSnippetList.Add(new TextSnippet(text1, baseColor));
}
if (text.Length > startIndex)
textSnippetList.Add(new TextSnippet(text.Substring(startIndex, text.Length - startIndex), baseColor));
return textSnippetList;
}
public static bool AddChatText(DynamicSpriteFont font, string text, Vector2 baseScale)
{
int num = Main.screenWidth - 330;
if ((double) ChatManager.GetStringSize(font, Main.chatText + text, baseScale).X > (double) num)
return false;
Main.chatText += text;
return true;
}
public static Vector2 GetStringSize(
DynamicSpriteFont font,
string text,
Vector2 baseScale,
float maxWidth = -1f)
{
TextSnippet[] array = ChatManager.ParseMessage(text, Color.White).ToArray();
return ChatManager.GetStringSize(font, array, baseScale, maxWidth);
}
public static Vector2 GetStringSize(
DynamicSpriteFont font,
TextSnippet[] snippets,
Vector2 baseScale,
float maxWidth = -1f)
{
Vector2 vec = new Vector2((float) Main.mouseX, (float) Main.mouseY);
Vector2 zero = Vector2.Zero;
Vector2 minimum = zero;
Vector2 vector2_1 = minimum;
float x = font.MeasureString(" ").X;
float num1 = 0.0f;
for (int index1 = 0; index1 < snippets.Length; ++index1)
{
TextSnippet snippet = snippets[index1];
snippet.Update();
float scale = snippet.Scale;
Vector2 size;
if (snippet.UniqueDraw(true, out size, (SpriteBatch) null))
{
minimum.X += size.X * baseScale.X * scale;
vector2_1.X = Math.Max(vector2_1.X, minimum.X);
vector2_1.Y = Math.Max(vector2_1.Y, minimum.Y + size.Y);
}
else
{
string[] strArray1 = snippet.Text.Split('\n');
foreach (string str in strArray1)
{
char[] chArray = new char[1]{ ' ' };
string[] strArray2 = str.Split(chArray);
for (int index2 = 0; index2 < strArray2.Length; ++index2)
{
if (index2 != 0)
minimum.X += x * baseScale.X * scale;
if ((double) maxWidth > 0.0)
{
float num2 = font.MeasureString(strArray2[index2]).X * baseScale.X * scale;
if ((double) minimum.X - (double) zero.X + (double) num2 > (double) maxWidth)
{
minimum.X = zero.X;
minimum.Y += (float) font.LineSpacing * num1 * baseScale.Y;
vector2_1.Y = Math.Max(vector2_1.Y, minimum.Y);
num1 = 0.0f;
}
}
if ((double) num1 < (double) scale)
num1 = scale;
Vector2 vector2_2 = font.MeasureString(strArray2[index2]);
vec.Between(minimum, minimum + vector2_2);
minimum.X += vector2_2.X * baseScale.X * scale;
vector2_1.X = Math.Max(vector2_1.X, minimum.X);
vector2_1.Y = Math.Max(vector2_1.Y, minimum.Y + vector2_2.Y);
}
if (strArray1.Length > 1)
{
minimum.X = zero.X;
minimum.Y += (float) font.LineSpacing * num1 * baseScale.Y;
vector2_1.Y = Math.Max(vector2_1.Y, minimum.Y);
num1 = 0.0f;
}
}
}
}
return vector2_1;
}
public static void DrawColorCodedStringShadow(
SpriteBatch spriteBatch,
DynamicSpriteFont font,
TextSnippet[] snippets,
Vector2 position,
Color baseColor,
float rotation,
Vector2 origin,
Vector2 baseScale,
float maxWidth = -1f,
float spread = 2f)
{
for (int index = 0; index < ChatManager.ShadowDirections.Length; ++index)
ChatManager.DrawColorCodedString(spriteBatch, font, snippets, position + ChatManager.ShadowDirections[index] * spread, baseColor, rotation, origin, baseScale, out int _, maxWidth, true);
}
public static Vector2 DrawColorCodedString(
SpriteBatch spriteBatch,
DynamicSpriteFont font,
TextSnippet[] snippets,
Vector2 position,
Color baseColor,
float rotation,
Vector2 origin,
Vector2 baseScale,
out int hoveredSnippet,
float maxWidth,
bool ignoreColors = false)
{
int num1 = -1;
Vector2 vec = new Vector2((float) Main.mouseX, (float) Main.mouseY);
Vector2 vector2_1 = position;
Vector2 vector2_2 = vector2_1;
float x = font.MeasureString(" ").X;
Color color = baseColor;
float num2 = 0.0f;
for (int index1 = 0; index1 < snippets.Length; ++index1)
{
TextSnippet snippet = snippets[index1];
snippet.Update();
if (!ignoreColors)
color = snippet.GetVisibleColor();
float scale = snippet.Scale;
Vector2 size;
if (snippet.UniqueDraw(false, out size, spriteBatch, vector2_1, color, scale))
{
if (vec.Between(vector2_1, vector2_1 + size))
num1 = index1;
vector2_1.X += size.X * baseScale.X * scale;
vector2_2.X = Math.Max(vector2_2.X, vector2_1.X);
}
else
{
snippet.Text.Split('\n');
string[] strArray1 = Regex.Split(snippet.Text, "(\n)");
bool flag = true;
for (int index2 = 0; index2 < strArray1.Length; ++index2)
{
string input = strArray1[index2];
Regex.Split(input, "( )");
string[] strArray2 = input.Split(' ');
if (input == "\n")
{
vector2_1.Y += (float) font.LineSpacing * num2 * baseScale.Y;
vector2_1.X = position.X;
vector2_2.Y = Math.Max(vector2_2.Y, vector2_1.Y);
num2 = 0.0f;
flag = false;
}
else
{
for (int index3 = 0; index3 < strArray2.Length; ++index3)
{
if (index3 != 0)
vector2_1.X += x * baseScale.X * scale;
if ((double) maxWidth > 0.0)
{
float num3 = font.MeasureString(strArray2[index3]).X * baseScale.X * scale;
if ((double) vector2_1.X - (double) position.X + (double) num3 > (double) maxWidth)
{
vector2_1.X = position.X;
vector2_1.Y += (float) font.LineSpacing * num2 * baseScale.Y;
vector2_2.Y = Math.Max(vector2_2.Y, vector2_1.Y);
num2 = 0.0f;
}
}
if ((double) num2 < (double) scale)
num2 = scale;
DynamicSpriteFontExtensionMethods.DrawString(spriteBatch, font, strArray2[index3], vector2_1, color, rotation, origin, baseScale * snippet.Scale * scale, SpriteEffects.None, 0.0f);
Vector2 vector2_3 = font.MeasureString(strArray2[index3]);
if (vec.Between(vector2_1, vector2_1 + vector2_3))
num1 = index1;
vector2_1.X += vector2_3.X * baseScale.X * scale;
vector2_2.X = Math.Max(vector2_2.X, vector2_1.X);
}
if (strArray1.Length > 1 & flag)
{
vector2_1.Y += (float) font.LineSpacing * num2 * baseScale.Y;
vector2_1.X = position.X;
vector2_2.Y = Math.Max(vector2_2.Y, vector2_1.Y);
num2 = 0.0f;
}
flag = true;
}
}
}
}
hoveredSnippet = num1;
return vector2_2;
}
public static Vector2 DrawColorCodedStringWithShadow(
SpriteBatch spriteBatch,
DynamicSpriteFont font,
TextSnippet[] snippets,
Vector2 position,
float rotation,
Vector2 origin,
Vector2 baseScale,
out int hoveredSnippet,
float maxWidth = -1f,
float spread = 2f)
{
ChatManager.DrawColorCodedStringShadow(spriteBatch, font, snippets, position, Color.Black, rotation, origin, baseScale, maxWidth, spread);
return ChatManager.DrawColorCodedString(spriteBatch, font, snippets, position, Color.White, rotation, origin, baseScale, out hoveredSnippet, maxWidth);
}
public static Vector2 DrawColorCodedStringWithShadow(
SpriteBatch spriteBatch,
DynamicSpriteFont font,
TextSnippet[] snippets,
Vector2 position,
float rotation,
Color color,
Vector2 origin,
Vector2 baseScale,
out int hoveredSnippet,
float maxWidth = -1f,
float spread = 2f)
{
ChatManager.DrawColorCodedStringShadow(spriteBatch, font, snippets, position, Color.Black, rotation, origin, baseScale, maxWidth, spread);
return ChatManager.DrawColorCodedString(spriteBatch, font, snippets, position, color, rotation, origin, baseScale, out hoveredSnippet, maxWidth, true);
}
public static void DrawColorCodedStringShadow(
SpriteBatch spriteBatch,
DynamicSpriteFont font,
string text,
Vector2 position,
Color baseColor,
float rotation,
Vector2 origin,
Vector2 baseScale,
float maxWidth = -1f,
float spread = 2f)
{
for (int index = 0; index < ChatManager.ShadowDirections.Length; ++index)
ChatManager.DrawColorCodedString(spriteBatch, font, text, position + ChatManager.ShadowDirections[index] * spread, baseColor, rotation, origin, baseScale, maxWidth, true);
}
public static Vector2 DrawColorCodedString(
SpriteBatch spriteBatch,
DynamicSpriteFont font,
string text,
Vector2 position,
Color baseColor,
float rotation,
Vector2 origin,
Vector2 baseScale,
float maxWidth = -1f,
bool ignoreColors = false)
{
Vector2 vector2_1 = position;
Vector2 vector2_2 = vector2_1;
string[] strArray1 = text.Split('\n');
float x = font.MeasureString(" ").X;
Color color = baseColor;
float num1 = 1f;
float num2 = 0.0f;
foreach (string str1 in strArray1)
{
char[] chArray = new char[1]{ ':' };
foreach (string str2 in str1.Split(chArray))
{
if (str2.StartsWith("sss"))
{
if (str2.StartsWith("sss1"))
{
if (!ignoreColors)
color = Color.Red;
}
else if (str2.StartsWith("sss2"))
{
if (!ignoreColors)
color = Color.Blue;
}
else if (str2.StartsWith("sssr") && !ignoreColors)
color = Color.White;
}
else
{
string[] strArray2 = str2.Split(' ');
for (int index = 0; index < strArray2.Length; ++index)
{
if (index != 0)
vector2_1.X += x * baseScale.X * num1;
if ((double) maxWidth > 0.0)
{
float num3 = font.MeasureString(strArray2[index]).X * baseScale.X * num1;
if ((double) vector2_1.X - (double) position.X + (double) num3 > (double) maxWidth)
{
vector2_1.X = position.X;
vector2_1.Y += (float) font.LineSpacing * num2 * baseScale.Y;
vector2_2.Y = Math.Max(vector2_2.Y, vector2_1.Y);
num2 = 0.0f;
}
}
if ((double) num2 < (double) num1)
num2 = num1;
DynamicSpriteFontExtensionMethods.DrawString(spriteBatch, font, strArray2[index], vector2_1, color, rotation, origin, baseScale * num1, SpriteEffects.None, 0.0f);
vector2_1.X += font.MeasureString(strArray2[index]).X * baseScale.X * num1;
vector2_2.X = Math.Max(vector2_2.X, vector2_1.X);
}
}
}
vector2_1.X = position.X;
vector2_1.Y += (float) font.LineSpacing * num2 * baseScale.Y;
vector2_2.Y = Math.Max(vector2_2.Y, vector2_1.Y);
num2 = 0.0f;
}
return vector2_2;
}
public static Vector2 DrawColorCodedStringWithShadow(
SpriteBatch spriteBatch,
DynamicSpriteFont font,
string text,
Vector2 position,
Color baseColor,
float rotation,
Vector2 origin,
Vector2 baseScale,
float maxWidth = -1f,
float spread = 2f)
{
TextSnippet[] array = ChatManager.ParseMessage(text, baseColor).ToArray();
ChatManager.ConvertNormalSnippets(array);
ChatManager.DrawColorCodedStringShadow(spriteBatch, font, array, position, new Color(0, 0, 0, (int) baseColor.A), rotation, origin, baseScale, maxWidth, spread);
return ChatManager.DrawColorCodedString(spriteBatch, font, array, position, Color.White, rotation, origin, baseScale, out int _, maxWidth);
}
public static class Regexes
{
public static readonly Regex Format = new Regex("(?<!\\\\)\\[(?<tag>[a-zA-Z]{1,10})(\\/(?<options>[^:]+))?:(?<text>.+?)(?<!\\\\)\\]", RegexOptions.Compiled);
}
}
}

View file

@ -0,0 +1,64 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.UI.Chat.ChatMessageContainer
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using System.Collections.Generic;
using Terraria.GameContent;
namespace Terraria.UI.Chat
{
public class ChatMessageContainer
{
public string OriginalText;
private bool _prepared;
private List<TextSnippet[]> _parsedText;
private Color _color;
private int _widthLimitInPixels;
private int _timeLeft;
public void SetContents(string text, Color color, int widthLimitInPixels)
{
this.OriginalText = text;
this._color = color;
this._widthLimitInPixels = widthLimitInPixels;
this.MarkToNeedRefresh();
this._parsedText = new List<TextSnippet[]>();
this._timeLeft = 600;
this.Refresh();
}
public void MarkToNeedRefresh() => this._prepared = false;
public void Update()
{
if (this._timeLeft > 0)
--this._timeLeft;
this.Refresh();
}
public TextSnippet[] GetSnippetWithInversedIndex(int snippetIndex) => this._parsedText[this._parsedText.Count - 1 - snippetIndex];
public int LineCount => this._parsedText.Count;
public bool CanBeShownWhenChatIsClosed => this._timeLeft > 0;
public bool Prepared => this._prepared;
public void Refresh()
{
if (this._prepared)
return;
this._prepared = true;
int maxWidth = this._widthLimitInPixels;
if (maxWidth == -1)
maxWidth = Main.screenWidth - 320;
List<List<TextSnippet>> textSnippetListList = Utils.WordwrapStringSmart(this.OriginalText, this._color, FontAssets.MouseText.Value, maxWidth, 10);
this._parsedText.Clear();
for (int index = 0; index < textSnippetListList.Count; ++index)
this._parsedText.Add(textSnippetListList[index].ToArray());
}
}
}

15
UI/Chat/ITagHandler.cs Normal file
View file

@ -0,0 +1,15 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.UI.Chat.ITagHandler
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
namespace Terraria.UI.Chat
{
public interface ITagHandler
{
TextSnippet Parse(string text, Color baseColor = default (Color), string options = null);
}
}

73
UI/Chat/TextSnippet.cs Normal file
View file

@ -0,0 +1,73 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.UI.Chat.TextSnippet
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Graphics;
namespace Terraria.UI.Chat
{
public class TextSnippet
{
public string Text;
public string TextOriginal;
public Color Color = Color.White;
public float Scale = 1f;
public bool CheckForHover;
public bool DeleteWhole;
public TextSnippet(string text = "")
{
this.Text = text;
this.TextOriginal = text;
}
public TextSnippet(string text, Color color, float scale = 1f)
{
this.Text = text;
this.TextOriginal = text;
this.Color = color;
this.Scale = scale;
}
public virtual void Update()
{
}
public virtual void OnHover()
{
}
public virtual void OnClick()
{
}
public virtual Color GetVisibleColor() => ChatManager.WaveColor(this.Color);
public virtual bool UniqueDraw(
bool justCheckingString,
out Vector2 size,
SpriteBatch spriteBatch,
Vector2 position = default (Vector2),
Color color = default (Color),
float scale = 1f)
{
size = Vector2.Zero;
return false;
}
public virtual TextSnippet CopyMorph(string newText)
{
TextSnippet textSnippet = (TextSnippet) this.MemberwiseClone();
textSnippet.Text = newText;
return textSnippet;
}
public virtual float GetStringLength(DynamicSpriteFont font) => font.MeasureString(this.Text).X * this.Scale;
public override string ToString() => "Text: " + this.Text + " | OriginalText: " + this.TextOriginal;
}
}

1216
UI/ChestUI.cs Normal file

File diff suppressed because it is too large Load diff

37
UI/EmptyDiagnosticsUI.cs Normal file
View file

@ -0,0 +1,37 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.UI.EmptyDiagnosticsUI
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework.Graphics;
namespace Terraria.UI
{
public class EmptyDiagnosticsUI : INetDiagnosticsUI
{
public void Reset()
{
}
public void CountReadMessage(int messageId, int messageLength)
{
}
public void CountSentMessage(int messageId, int messageLength)
{
}
public void CountReadModuleMessage(int moduleMessageId, int messageLength)
{
}
public void CountSentModuleMessage(int moduleMessageId, int messageLength)
{
}
public void Draw(SpriteBatch spriteBatch)
{
}
}
}

121
UI/FancyErrorPrinter.cs Normal file
View file

@ -0,0 +1,121 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.UI.FancyErrorPrinter
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using ReLogic.Content;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Windows.Forms;
namespace Terraria.UI
{
public class FancyErrorPrinter
{
public static void ShowFailedToLoadAssetError(Exception exception, string filePath)
{
bool flag = false;
if (exception is UnauthorizedAccessException)
flag = true;
if (exception is FileNotFoundException)
flag = true;
if (exception is DirectoryNotFoundException)
flag = true;
if (exception is AssetLoadException)
flag = true;
if (!flag)
return;
StringBuilder text = new StringBuilder();
text.AppendLine("Failed to load asset: \"" + filePath.Replace("/", "\\") + "\"!");
List<string> suggestions = new List<string>();
suggestions.Add("Try verifying integrity of game files via Steam, the asset may be missing.");
suggestions.Add("If you are using an Anti-virus, please make sure it does not block Terraria in any way.");
text.AppendLine();
text.AppendLine("Suggestions:");
FancyErrorPrinter.AppendSuggestions(text, suggestions);
text.AppendLine();
FancyErrorPrinter.IncludeOriginalMessage(text, exception);
FancyErrorPrinter.ShowTheBox(text.ToString());
Console.WriteLine(text.ToString());
}
public static void ShowFileSavingFailError(Exception exception, string filePath)
{
bool flag = false;
if (exception is UnauthorizedAccessException)
flag = true;
if (exception is FileNotFoundException)
flag = true;
if (exception is DirectoryNotFoundException)
flag = true;
if (!flag)
return;
StringBuilder text = new StringBuilder();
text.AppendLine("Failed to create the file: \"" + filePath.Replace("/", "\\") + "\"!");
List<string> suggestions = new List<string>();
suggestions.Add("If you are using an Anti-virus, please make sure it does not block Terraria in any way.");
suggestions.Add("Try making sure your `Documents/My Games/Terraria` folder is not set to 'read-only'.");
suggestions.Add("Try verifying integrity of game files via Steam.");
if (filePath.ToLower().Contains("onedrive"))
suggestions.Add("Try updating OneDrive.");
text.AppendLine();
text.AppendLine("Suggestions:");
FancyErrorPrinter.AppendSuggestions(text, suggestions);
text.AppendLine();
FancyErrorPrinter.IncludeOriginalMessage(text, exception);
FancyErrorPrinter.ShowTheBox(text.ToString());
Console.WriteLine(text.ToString());
}
public static void ShowDirectoryCreationFailError(Exception exception, string folderPath)
{
bool flag = false;
if (exception is UnauthorizedAccessException)
flag = true;
if (exception is FileNotFoundException)
flag = true;
if (exception is DirectoryNotFoundException)
flag = true;
if (!flag)
return;
StringBuilder text = new StringBuilder();
text.AppendLine("Failed to create the folder: \"" + folderPath.Replace("/", "\\") + "\"!");
List<string> suggestions = new List<string>();
suggestions.Add("If you are using an Anti-virus, please make sure it does not block Terraria in any way.");
suggestions.Add("Try making sure your `Documents/My Games/Terraria` folder is not set to 'read-only'.");
suggestions.Add("Try verifying integrity of game files via Steam.");
if (folderPath.ToLower().Contains("onedrive"))
suggestions.Add("Try updating OneDrive.");
text.AppendLine();
text.AppendLine("Suggestions:");
FancyErrorPrinter.AppendSuggestions(text, suggestions);
text.AppendLine();
FancyErrorPrinter.IncludeOriginalMessage(text, exception);
FancyErrorPrinter.ShowTheBox(text.ToString());
Console.WriteLine((object) exception);
}
private static void IncludeOriginalMessage(StringBuilder text, Exception exception)
{
text.AppendLine("The original Error below");
text.Append((object) exception);
}
private static void AppendSuggestions(StringBuilder text, List<string> suggestions)
{
for (int index = 0; index < suggestions.Count; ++index)
{
string suggestion = suggestions[index];
text.AppendLine((index + 1).ToString() + ". " + suggestion);
}
}
private static void ShowTheBox(string preparedMessage)
{
int num = (int) MessageBox.Show(preparedMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
}
}
}

View file

@ -0,0 +1,10 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.UI.GameInterfaceDrawMethod
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
namespace Terraria.UI
{
public delegate bool GameInterfaceDrawMethod();
}

59
UI/GameInterfaceLayer.cs Normal file
View file

@ -0,0 +1,59 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.UI.GameInterfaceLayer
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria.GameInput;
namespace Terraria.UI
{
public class GameInterfaceLayer
{
public readonly string Name;
public InterfaceScaleType ScaleType;
public GameInterfaceLayer(string name, InterfaceScaleType scaleType)
{
this.Name = name;
this.ScaleType = scaleType;
}
public bool Draw()
{
Matrix transformMatrix;
if (this.ScaleType == InterfaceScaleType.Game)
{
PlayerInput.SetZoom_World();
transformMatrix = Main.GameViewMatrix.ZoomMatrix;
}
else if (this.ScaleType == InterfaceScaleType.UI)
{
PlayerInput.SetZoom_UI();
transformMatrix = Main.UIScaleMatrix;
}
else
{
PlayerInput.SetZoom_Unscaled();
transformMatrix = Matrix.Identity;
}
bool flag = false;
Main.spriteBatch.Begin(SpriteSortMode.Deferred, (BlendState) null, (SamplerState) null, (DepthStencilState) null, (RasterizerState) null, (Effect) null, transformMatrix);
try
{
flag = this.DrawSelf();
}
catch (Exception ex)
{
TimeLogger.DrawException(ex);
}
Main.spriteBatch.End();
return flag;
}
protected virtual bool DrawSelf() => true;
}
}

View file

@ -0,0 +1,89 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.UI.Gamepad.GamepadMainMenuHandler
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using Terraria.GameInput;
namespace Terraria.UI.Gamepad
{
public class GamepadMainMenuHandler
{
public static int LastMainMenu = -1;
public static List<Vector2> MenuItemPositions = new List<Vector2>(20);
public static int LastDrew = -1;
public static bool CanRun = false;
public static void Update()
{
if (!GamepadMainMenuHandler.CanRun)
{
UILinkPage page = UILinkPointNavigator.Pages[1000];
page.CurrentPoint = page.DefaultPoint;
Vector2 vector2 = new Vector2((float) Math.Cos((double) Main.GlobalTimeWrappedHourly * 6.28318548202515), (float) Math.Sin((double) Main.GlobalTimeWrappedHourly * 6.28318548202515 * 2.0)) * new Vector2(30f, 15f) + Vector2.UnitY * 20f;
UILinkPointNavigator.SetPosition(2000, new Vector2((float) Main.screenWidth, (float) Main.screenHeight) / 2f + vector2);
}
else
{
if (!Main.gameMenu || Main.MenuUI.IsVisible || GamepadMainMenuHandler.LastDrew != Main.menuMode)
return;
int lastMainMenu = GamepadMainMenuHandler.LastMainMenu;
GamepadMainMenuHandler.LastMainMenu = Main.menuMode;
switch (Main.menuMode)
{
case 17:
case 18:
case 19:
case 21:
case 22:
case 23:
case 24:
case 26:
if (GamepadMainMenuHandler.MenuItemPositions.Count >= 4)
{
Vector2 menuItemPosition = GamepadMainMenuHandler.MenuItemPositions[3];
GamepadMainMenuHandler.MenuItemPositions.RemoveAt(3);
if (Main.menuMode == 17)
{
GamepadMainMenuHandler.MenuItemPositions.Insert(0, menuItemPosition);
break;
}
break;
}
break;
case 28:
if (GamepadMainMenuHandler.MenuItemPositions.Count >= 3)
{
GamepadMainMenuHandler.MenuItemPositions.RemoveAt(1);
break;
}
break;
}
UILinkPage page = UILinkPointNavigator.Pages[1000];
if (lastMainMenu != Main.menuMode)
page.CurrentPoint = page.DefaultPoint;
for (int index = 0; index < GamepadMainMenuHandler.MenuItemPositions.Count; ++index)
{
Vector2 vector2 = GamepadMainMenuHandler.MenuItemPositions[index] * Main.UIScale;
if (index == 0 && lastMainMenu != GamepadMainMenuHandler.LastMainMenu && PlayerInput.UsingGamepad && Main.InvisibleCursorForGamepad)
{
Main.mouseX = PlayerInput.MouseX = (int) vector2.X;
Main.mouseY = PlayerInput.MouseY = (int) vector2.Y;
Main.menuFocus = -1;
}
UILinkPoint link = page.LinkMap[2000 + index];
link.Position = vector2;
link.Up = index != 0 ? 2000 + index - 1 : -1;
link.Left = -3;
link.Right = -4;
link.Down = index != GamepadMainMenuHandler.MenuItemPositions.Count - 1 ? 2000 + index + 1 : -2;
}
GamepadMainMenuHandler.MenuItemPositions.Clear();
}
}
}
}

View file

@ -0,0 +1,41 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.UI.Gamepad.GamepadPageID
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
namespace Terraria.UI.Gamepad
{
public static class GamepadPageID
{
public const int None = -1;
public const int Inventory = 0;
public const int Coins = 1;
public const int Ammo = 2;
public const int Armor = 3;
public const int Chest = 4;
public const int Reforge = 5;
public const int NPCHousing = 6;
public const int Equipment = 7;
public const int Tabs = 8;
public const int CraftSmall = 9;
public const int CraftsBig = 10;
public const int HairCustomizationStyle = 11;
public const int HairCustomizationColor = 12;
public const int NPCShop = 13;
public const int ClothCustomizationStyle = 14;
public const int ClothCustomizationColor = 15;
public const int PVP = 16;
public const int InfoAccs = 17;
public const int BuilderAccs = 18;
public const int BuffsOnEquipment = 19;
public const int DisplayDoll = 20;
public const int HatRack = 21;
public const int MainMenu = 1000;
public const int IngameOptionsLeft = 1001;
public const int IngameOptionsRight = 1002;
public const int NPCChat = 1003;
public const int FancyUI = 1004;
public const int CreativeMenu = 1005;
}
}

View file

@ -0,0 +1,238 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.UI.Gamepad.GamepadPointID
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
namespace Terraria.UI.Gamepad
{
public static class GamepadPointID
{
public const int EndUp = -1;
public const int EndDown = -2;
public const int EndLeft = -3;
public const int EndRight = -4;
public const int Inventory0 = 0;
public const int Inventory1 = 1;
public const int Inventory2 = 2;
public const int Inventory3 = 3;
public const int Inventory4 = 4;
public const int Inventory5 = 5;
public const int Inventory6 = 6;
public const int Inventory7 = 7;
public const int Inventory8 = 8;
public const int Inventory9 = 9;
public const int Inventory10 = 10;
public const int Inventory11 = 11;
public const int Inventory12 = 12;
public const int Inventory13 = 13;
public const int Inventory14 = 14;
public const int Inventory15 = 15;
public const int Inventory16 = 16;
public const int Inventory17 = 17;
public const int Inventory18 = 18;
public const int Inventory19 = 19;
public const int Inventory20 = 20;
public const int Inventory21 = 21;
public const int Inventory22 = 22;
public const int Inventory23 = 23;
public const int Inventory24 = 24;
public const int Inventory25 = 25;
public const int Inventory26 = 26;
public const int Inventory27 = 27;
public const int Inventory28 = 28;
public const int Inventory29 = 29;
public const int Inventory30 = 30;
public const int Inventory31 = 31;
public const int Inventory32 = 32;
public const int Inventory33 = 33;
public const int Inventory34 = 34;
public const int Inventory35 = 35;
public const int Inventory36 = 36;
public const int Inventory37 = 37;
public const int Inventory38 = 38;
public const int Inventory39 = 39;
public const int Inventory40 = 40;
public const int Inventory41 = 41;
public const int Inventory42 = 42;
public const int Inventory43 = 43;
public const int Inventory44 = 44;
public const int Inventory45 = 45;
public const int Inventory46 = 46;
public const int Inventory47 = 47;
public const int Inventory48 = 48;
public const int Inventory49 = 49;
public const int Coins0 = 50;
public const int Coins1 = 51;
public const int Coins2 = 52;
public const int Coins3 = 53;
public const int Ammo0 = 54;
public const int Ammo1 = 55;
public const int Ammo2 = 56;
public const int Ammo3 = 57;
public const int Armor0 = 100;
public const int Armor1 = 101;
public const int Armor2 = 102;
public const int Armor3 = 103;
public const int Armor4 = 104;
public const int Armor5 = 105;
public const int Armor6 = 106;
public const int Armor7 = 107;
public const int Armor8 = 108;
public const int Armor9 = 109;
public const int Armor10 = 110;
public const int Armor11 = 111;
public const int Armor12 = 112;
public const int Armor13 = 113;
public const int Armor14 = 114;
public const int Armor15 = 115;
public const int Armor16 = 116;
public const int Armor17 = 117;
public const int Armor18 = 118;
public const int Armor19 = 119;
public const int DyeArmor0 = 120;
public const int DyeArmor1 = 121;
public const int DyeArmor2 = 122;
public const int DyeArmor3 = 123;
public const int DyeArmor4 = 124;
public const int DyeArmor5 = 125;
public const int DyeArmor6 = 126;
public const int DyeArmor7 = 127;
public const int DyeArmor8 = 128;
public const int DyeArmor9 = 129;
public const int Equips0 = 180;
public const int Equips1 = 181;
public const int Equips2 = 182;
public const int Equips3 = 183;
public const int Equips4 = 184;
public const int DyeEquips0 = 185;
public const int DyeEquips1 = 186;
public const int DyeEquips2 = 187;
public const int DyeEquips3 = 188;
public const int DyeEquips4 = 189;
public const int TrashItem = 300;
public const int QuickStackToNearbyChests = 301;
public const int SortInventory = 302;
public const int ReforgeSlot = 303;
public const int ReforgeButton = 304;
public const int TabEquips = 305;
public const int TabNPCs = 306;
public const int TabCamera = 307;
public const int TabSettings = 308;
public const int EmoteMenu = 309;
public const int BestiaryMenu = 310;
public const int CreativeMenuToggle = 311;
public const int Chest0 = 400;
public const int Chest1 = 401;
public const int Chest2 = 402;
public const int Chest3 = 403;
public const int Chest4 = 404;
public const int Chest5 = 405;
public const int Chest6 = 406;
public const int Chest7 = 407;
public const int Chest8 = 408;
public const int Chest9 = 409;
public const int Chest10 = 410;
public const int Chest11 = 411;
public const int Chest12 = 412;
public const int Chest13 = 413;
public const int Chest14 = 414;
public const int Chest15 = 415;
public const int Chest16 = 416;
public const int Chest17 = 417;
public const int Chest18 = 418;
public const int Chest19 = 419;
public const int Chest20 = 420;
public const int Chest21 = 421;
public const int Chest22 = 422;
public const int Chest23 = 423;
public const int Chest24 = 424;
public const int Chest25 = 425;
public const int Chest26 = 426;
public const int Chest27 = 427;
public const int Chest28 = 428;
public const int Chest29 = 429;
public const int Chest30 = 430;
public const int Chest31 = 431;
public const int Chest32 = 432;
public const int Chest33 = 433;
public const int Chest34 = 434;
public const int Chest35 = 435;
public const int Chest36 = 436;
public const int Chest37 = 437;
public const int Chest38 = 438;
public const int Chest39 = 439;
public const int ChestActLootAll = 500;
public const int ChestActDepositAll = 501;
public const int ChestActQuickStack = 502;
public const int ChestActRestock = 503;
public const int ChestActRenameChest = 504;
public const int ChestSort = 505;
public const int ChestToggleVacuum = 506;
public const int NPCHousing0 = 600;
public const int CraftsBig = 700;
public const int CraftsSmall = 1500;
public const int PVP0 = 1550;
public const int PVPShield = 1557;
public const int AchievementAdvisor = 1570;
public const int MainMenu = 2000;
public const int MenuHack1 = 2001;
public const int MenuHack2 = 2002;
public const int MenuHack3 = 2003;
public const int MenuHack4 = 2004;
public const int MenuHack5 = 2005;
public const int MenuHack6 = 2006;
public const int MenuHack7 = 2007;
public const int MenuHack8 = 2008;
public const int MenuHack9 = 2009;
public const int MenuHack10 = 2010;
public const int MenuHack11 = 2011;
public const int MenuHack12 = 2012;
public const int MenuHack13 = 2013;
public const int MenuHack14 = 2014;
public const int MenuHack15 = 2015;
public const int MenuHack16 = 2016;
public const int MenuHack17 = 2017;
public const int MenuHack18 = 2018;
public const int MenuHack19 = 2019;
public const int NPCChat0 = 2500;
public const int NPCChat1 = 2501;
public const int NPCChat2 = 2502;
public const int NPCChat3 = 2503;
public const int StylistColorH = 2600;
public const int StylistColorS = 2601;
public const int StylistColorL = 2602;
public const int StylistColorOk = 2603;
public const int StylistColorClose = 2604;
public const int StylistStyle0 = 2605;
public const int NPCShop0 = 2700;
public const int NPCShop37 = 2737;
public const int NPCShop38 = 2738;
public const int NPCShop39 = 2739;
public const int ClothColorH = 2800;
public const int ClothColorS = 2801;
public const int ClothColorL = 2802;
public const int ClothColorOk = 2803;
public const int ClothColorClose = 2804;
public const int ClothStyle = 2805;
public const int ClothPicker0 = 2806;
public const int ClothPicker1 = 2807;
public const int ClothPicker2 = 2808;
public const int ClothPicker3 = 2809;
public const int ClothPicker4 = 2810;
public const int ClothPicker5 = 2811;
public const int IngameOptionsLeft0 = 2900;
public const int IngameOptionsRight0 = 2930;
public const int FancyUI0 = 3000;
public const int FancyUILast = 4999;
public const int HatRack0 = 5000;
public const int HatRack3 = 5003;
public const int DisplayDoll0 = 5100;
public const int DisplayDoll15 = 5115;
public const int BuilderAccs = 6000;
public const int BuffsForEquips = 9000;
public const int CreativeMenu0 = 10000;
public const int CreativeMenuLast = 11000;
public const int CreativeResearchItem0 = 15000;
}
}

114
UI/Gamepad/UILinkPage.cs Normal file
View file

@ -0,0 +1,114 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.UI.Gamepad.UILinkPage
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using System;
using System.Collections.Generic;
namespace Terraria.UI.Gamepad
{
public class UILinkPage
{
public int ID;
public int PageOnLeft = -1;
public int PageOnRight = -1;
public int DefaultPoint;
public int CurrentPoint;
public Dictionary<int, UILinkPoint> LinkMap = new Dictionary<int, UILinkPoint>();
public event Action<int, int> ReachEndEvent;
public event Action TravelEvent;
public event Action LeaveEvent;
public event Action EnterEvent;
public event Action UpdateEvent;
public event Func<bool> IsValidEvent;
public event Func<bool> CanEnterEvent;
public event Action<int> OnPageMoveAttempt;
public UILinkPage()
{
}
public UILinkPage(int id) => this.ID = id;
public void Update()
{
if (this.UpdateEvent == null)
return;
this.UpdateEvent();
}
public void Leave()
{
if (this.LeaveEvent == null)
return;
this.LeaveEvent();
}
public void Enter()
{
if (this.EnterEvent == null)
return;
this.EnterEvent();
}
public bool IsValid() => this.IsValidEvent == null || this.IsValidEvent();
public bool CanEnter() => this.CanEnterEvent == null || this.CanEnterEvent();
public void TravelUp() => this.Travel(this.LinkMap[this.CurrentPoint].Up);
public void TravelDown() => this.Travel(this.LinkMap[this.CurrentPoint].Down);
public void TravelLeft() => this.Travel(this.LinkMap[this.CurrentPoint].Left);
public void TravelRight() => this.Travel(this.LinkMap[this.CurrentPoint].Right);
public void SwapPageLeft()
{
if (this.OnPageMoveAttempt != null)
this.OnPageMoveAttempt(-1);
UILinkPointNavigator.ChangePage(this.PageOnLeft);
}
public void SwapPageRight()
{
if (this.OnPageMoveAttempt != null)
this.OnPageMoveAttempt(1);
UILinkPointNavigator.ChangePage(this.PageOnRight);
}
private void Travel(int next)
{
if (next < 0)
{
if (this.ReachEndEvent == null)
return;
this.ReachEndEvent(this.CurrentPoint, next);
if (this.TravelEvent == null)
return;
this.TravelEvent();
}
else
{
UILinkPointNavigator.ChangePoint(next);
if (this.TravelEvent == null)
return;
this.TravelEvent();
}
}
public event Func<string> OnSpecialInteracts;
public string SpecialInteractions() => this.OnSpecialInteracts != null ? this.OnSpecialInteracts() : string.Empty;
}
}

48
UI/Gamepad/UILinkPoint.cs Normal file
View file

@ -0,0 +1,48 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.UI.Gamepad.UILinkPoint
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using System;
namespace Terraria.UI.Gamepad
{
public class UILinkPoint
{
public int ID;
public bool Enabled;
public Vector2 Position;
public int Left;
public int Right;
public int Up;
public int Down;
public int Page { get; private set; }
public UILinkPoint(int id, bool enabled, int left, int right, int up, int down)
{
this.ID = id;
this.Enabled = enabled;
this.Left = left;
this.Right = right;
this.Up = up;
this.Down = down;
}
public void SetPage(int page) => this.Page = page;
public void Unlink()
{
this.Left = -3;
this.Right = -4;
this.Up = -1;
this.Down = -2;
}
public event Func<string> OnSpecialInteracts;
public string SpecialInteractions() => this.OnSpecialInteracts != null ? this.OnSpecialInteracts() : string.Empty;
}
}

View file

@ -0,0 +1,335 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.UI.Gamepad.UILinkPointNavigator
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using Terraria.Audio;
using Terraria.DataStructures;
using Terraria.GameContent.Tile_Entities;
using Terraria.GameInput;
namespace Terraria.UI.Gamepad
{
public class UILinkPointNavigator
{
public static Dictionary<int, UILinkPage> Pages = new Dictionary<int, UILinkPage>();
public static Dictionary<int, UILinkPoint> Points = new Dictionary<int, UILinkPoint>();
public static int CurrentPage = 1000;
public static int OldPage = 1000;
private static int XCooldown;
private static int YCooldown;
private static Vector2 LastInput;
private static int PageLeftCD;
private static int PageRightCD;
public static bool InUse;
public static int OverridePoint = -1;
public static int CurrentPoint => UILinkPointNavigator.Pages[UILinkPointNavigator.CurrentPage].CurrentPoint;
public static bool Available => Main.playerInventory || Main.ingameOptionsWindow || Main.player[Main.myPlayer].talkNPC != -1 || Main.player[Main.myPlayer].sign != -1 || Main.mapFullscreen || Main.clothesWindow || Main.MenuUI.IsVisible || Main.InGameUI.IsVisible;
public static void GoToDefaultPage(int specialFlag = 0)
{
TileEntity tileEntity = Main.LocalPlayer.tileEntityAnchor.GetTileEntity();
if (Main.MenuUI.IsVisible)
UILinkPointNavigator.CurrentPage = 1004;
else if (Main.InGameUI.IsVisible || specialFlag == 1)
UILinkPointNavigator.CurrentPage = 1004;
else if (Main.gameMenu)
UILinkPointNavigator.CurrentPage = 1000;
else if (Main.ingameOptionsWindow)
UILinkPointNavigator.CurrentPage = 1001;
else if (Main.CreativeMenu.Enabled)
UILinkPointNavigator.CurrentPage = 1005;
else if (Main.hairWindow)
UILinkPointNavigator.CurrentPage = 12;
else if (Main.clothesWindow)
UILinkPointNavigator.CurrentPage = 15;
else if (Main.npcShop != 0)
UILinkPointNavigator.CurrentPage = 13;
else if (Main.InGuideCraftMenu)
UILinkPointNavigator.CurrentPage = 9;
else if (Main.InReforgeMenu)
UILinkPointNavigator.CurrentPage = 5;
else if (Main.player[Main.myPlayer].chest != -1)
UILinkPointNavigator.CurrentPage = 4;
else if (tileEntity is TEDisplayDoll)
UILinkPointNavigator.CurrentPage = 20;
else if (tileEntity is TEHatRack)
UILinkPointNavigator.CurrentPage = 21;
else if (Main.player[Main.myPlayer].talkNPC != -1 || Main.player[Main.myPlayer].sign != -1)
UILinkPointNavigator.CurrentPage = 1003;
else
UILinkPointNavigator.CurrentPage = 0;
}
public static void Update()
{
bool inUse = UILinkPointNavigator.InUse;
UILinkPointNavigator.InUse = false;
bool flag1 = true;
if (flag1)
{
switch (PlayerInput.CurrentInputMode)
{
case InputMode.Keyboard:
case InputMode.KeyboardUI:
case InputMode.Mouse:
if (!Main.gameMenu)
{
flag1 = false;
break;
}
break;
}
}
if (flag1 && PlayerInput.NavigatorRebindingLock > 0)
flag1 = false;
if (flag1 && !Main.gameMenu && !PlayerInput.UsingGamepadUI)
flag1 = false;
if (flag1 && !Main.gameMenu && PlayerInput.InBuildingMode)
flag1 = false;
if (flag1 && !Main.gameMenu && !UILinkPointNavigator.Available)
flag1 = false;
bool flag2 = false;
UILinkPage uiLinkPage;
if (!UILinkPointNavigator.Pages.TryGetValue(UILinkPointNavigator.CurrentPage, out uiLinkPage))
flag2 = true;
else if (!uiLinkPage.IsValid())
flag2 = true;
if (flag2)
{
UILinkPointNavigator.GoToDefaultPage();
UILinkPointNavigator.ProcessChanges();
flag1 = false;
}
if (inUse != flag1)
{
if (!flag1)
{
uiLinkPage.Leave();
UILinkPointNavigator.GoToDefaultPage();
UILinkPointNavigator.ProcessChanges();
}
else
{
UILinkPointNavigator.GoToDefaultPage();
UILinkPointNavigator.ProcessChanges();
uiLinkPage.Enter();
}
if (flag1)
{
Main.player[Main.myPlayer].releaseInventory = false;
Main.player[Main.myPlayer].releaseUseTile = false;
PlayerInput.LockGamepadTileUseButton = true;
}
if (!Main.gameMenu)
{
if (flag1)
PlayerInput.NavigatorCachePosition();
else
PlayerInput.NavigatorUnCachePosition();
}
}
if (!flag1)
return;
UILinkPointNavigator.InUse = true;
UILinkPointNavigator.OverridePoint = -1;
if (UILinkPointNavigator.PageLeftCD > 0)
--UILinkPointNavigator.PageLeftCD;
if (UILinkPointNavigator.PageRightCD > 0)
--UILinkPointNavigator.PageRightCD;
Vector2 navigatorDirections = PlayerInput.Triggers.Current.GetNavigatorDirections();
int num1 = !PlayerInput.Triggers.Current.HotbarMinus ? 0 : (!PlayerInput.Triggers.Current.HotbarPlus ? 1 : 0);
bool flag3 = PlayerInput.Triggers.Current.HotbarPlus && !PlayerInput.Triggers.Current.HotbarMinus;
if (num1 == 0)
UILinkPointNavigator.PageLeftCD = 0;
if (!flag3)
UILinkPointNavigator.PageRightCD = 0;
int num2 = num1 == 0 ? 0 : (UILinkPointNavigator.PageLeftCD == 0 ? 1 : 0);
bool flag4 = flag3 && UILinkPointNavigator.PageRightCD == 0;
if ((double) UILinkPointNavigator.LastInput.X != (double) navigatorDirections.X)
UILinkPointNavigator.XCooldown = 0;
if ((double) UILinkPointNavigator.LastInput.Y != (double) navigatorDirections.Y)
UILinkPointNavigator.YCooldown = 0;
if (UILinkPointNavigator.XCooldown > 0)
--UILinkPointNavigator.XCooldown;
if (UILinkPointNavigator.YCooldown > 0)
--UILinkPointNavigator.YCooldown;
UILinkPointNavigator.LastInput = navigatorDirections;
if (num2 != 0)
UILinkPointNavigator.PageLeftCD = 16;
if (flag4)
UILinkPointNavigator.PageRightCD = 16;
UILinkPointNavigator.Pages[UILinkPointNavigator.CurrentPage].Update();
int num3 = 10;
if (!Main.gameMenu && Main.playerInventory && !Main.ingameOptionsWindow && !Main.inFancyUI && (UILinkPointNavigator.CurrentPage == 0 || UILinkPointNavigator.CurrentPage == 4 || UILinkPointNavigator.CurrentPage == 2 || UILinkPointNavigator.CurrentPage == 1 || UILinkPointNavigator.CurrentPage == 20 || UILinkPointNavigator.CurrentPage == 21))
num3 = PlayerInput.CurrentProfile.InventoryMoveCD;
if ((double) navigatorDirections.X == -1.0 && UILinkPointNavigator.XCooldown == 0)
{
UILinkPointNavigator.XCooldown = num3;
UILinkPointNavigator.Pages[UILinkPointNavigator.CurrentPage].TravelLeft();
}
if ((double) navigatorDirections.X == 1.0 && UILinkPointNavigator.XCooldown == 0)
{
UILinkPointNavigator.XCooldown = num3;
UILinkPointNavigator.Pages[UILinkPointNavigator.CurrentPage].TravelRight();
}
if ((double) navigatorDirections.Y == -1.0 && UILinkPointNavigator.YCooldown == 0)
{
UILinkPointNavigator.YCooldown = num3;
UILinkPointNavigator.Pages[UILinkPointNavigator.CurrentPage].TravelUp();
}
if ((double) navigatorDirections.Y == 1.0 && UILinkPointNavigator.YCooldown == 0)
{
UILinkPointNavigator.YCooldown = num3;
UILinkPointNavigator.Pages[UILinkPointNavigator.CurrentPage].TravelDown();
}
UILinkPointNavigator.XCooldown = UILinkPointNavigator.YCooldown = Math.Max(UILinkPointNavigator.XCooldown, UILinkPointNavigator.YCooldown);
if (num2 != 0)
UILinkPointNavigator.Pages[UILinkPointNavigator.CurrentPage].SwapPageLeft();
if (flag4)
UILinkPointNavigator.Pages[UILinkPointNavigator.CurrentPage].SwapPageRight();
if (PlayerInput.Triggers.Current.UsedMovementKey)
{
Vector2 position = UILinkPointNavigator.Points[UILinkPointNavigator.CurrentPoint].Position;
Vector2 vector2_1 = new Vector2((float) PlayerInput.MouseX, (float) PlayerInput.MouseY);
float num4 = 0.3f;
if (PlayerInput.InvisibleGamepadInMenus)
num4 = 1f;
Vector2 vector2_2 = position;
double num5 = (double) num4;
Vector2 vector2_3 = Vector2.Lerp(vector2_1, vector2_2, (float) num5);
if (Main.gameMenu)
{
if ((double) Math.Abs(vector2_3.X - position.X) <= 5.0)
vector2_3.X = position.X;
if ((double) Math.Abs(vector2_3.Y - position.Y) <= 5.0)
vector2_3.Y = position.Y;
}
PlayerInput.MouseX = (int) vector2_3.X;
PlayerInput.MouseY = (int) vector2_3.Y;
}
UILinkPointNavigator.ResetFlagsEnd();
}
public static void ResetFlagsEnd()
{
UILinkPointNavigator.Shortcuts.OPTIONS_BUTTON_SPECIALFEATURE = 0;
UILinkPointNavigator.Shortcuts.BackButtonLock = false;
UILinkPointNavigator.Shortcuts.BackButtonCommand = 0;
}
public static string GetInstructions()
{
string str1 = UILinkPointNavigator.Pages[UILinkPointNavigator.CurrentPage].SpecialInteractions();
string str2 = UILinkPointNavigator.Points[UILinkPointNavigator.CurrentPoint].SpecialInteractions();
if (!string.IsNullOrEmpty(str2))
{
if (string.IsNullOrEmpty(str1))
return str2;
str1 = str1 + " " + str2;
}
return str1;
}
public static void ForceMovementCooldown(int time)
{
UILinkPointNavigator.LastInput = PlayerInput.Triggers.Current.GetNavigatorDirections();
UILinkPointNavigator.XCooldown = time;
UILinkPointNavigator.YCooldown = time;
}
public static void SetPosition(int ID, Vector2 Position) => UILinkPointNavigator.Points[ID].Position = Position * Main.UIScale;
public static void RegisterPage(UILinkPage page, int ID, bool automatedDefault = true)
{
if (automatedDefault)
page.DefaultPoint = page.LinkMap.Keys.First<int>();
page.CurrentPoint = page.DefaultPoint;
page.ID = ID;
UILinkPointNavigator.Pages.Add(page.ID, page);
foreach (KeyValuePair<int, UILinkPoint> link in page.LinkMap)
{
link.Value.SetPage(ID);
UILinkPointNavigator.Points.Add(link.Key, link.Value);
}
}
public static void ChangePage(int PageID)
{
if (!UILinkPointNavigator.Pages.ContainsKey(PageID) || !UILinkPointNavigator.Pages[PageID].CanEnter())
return;
SoundEngine.PlaySound(12);
UILinkPointNavigator.CurrentPage = PageID;
UILinkPointNavigator.ProcessChanges();
}
public static void ChangePoint(int PointID)
{
if (!UILinkPointNavigator.Points.ContainsKey(PointID))
return;
UILinkPointNavigator.CurrentPage = UILinkPointNavigator.Points[PointID].Page;
UILinkPointNavigator.OverridePoint = PointID;
UILinkPointNavigator.ProcessChanges();
}
public static void ProcessChanges()
{
UILinkPage page = UILinkPointNavigator.Pages[UILinkPointNavigator.OldPage];
if (UILinkPointNavigator.OldPage != UILinkPointNavigator.CurrentPage)
{
page.Leave();
if (!UILinkPointNavigator.Pages.TryGetValue(UILinkPointNavigator.CurrentPage, out page))
{
UILinkPointNavigator.GoToDefaultPage();
UILinkPointNavigator.ProcessChanges();
UILinkPointNavigator.OverridePoint = -1;
}
page.CurrentPoint = page.DefaultPoint;
page.Enter();
page.Update();
UILinkPointNavigator.OldPage = UILinkPointNavigator.CurrentPage;
}
if (UILinkPointNavigator.OverridePoint == -1 || !page.LinkMap.ContainsKey(UILinkPointNavigator.OverridePoint))
return;
page.CurrentPoint = UILinkPointNavigator.OverridePoint;
}
public static class Shortcuts
{
public static int NPCS_IconsPerColumn = 100;
public static int NPCS_IconsTotal = 0;
public static int NPCS_LastHovered = -2;
public static bool NPCS_IconsDisplay = false;
public static int CRAFT_IconsPerRow = 100;
public static int CRAFT_IconsPerColumn = 100;
public static int CRAFT_CurrentIngridientsCount = 0;
public static int CRAFT_CurrentRecipeBig = 0;
public static int CRAFT_CurrentRecipeSmall = 0;
public static bool NPCCHAT_ButtonsLeft = false;
public static bool NPCCHAT_ButtonsMiddle = false;
public static bool NPCCHAT_ButtonsRight = false;
public static bool NPCCHAT_ButtonsRight2 = false;
public static int INGAMEOPTIONS_BUTTONS_LEFT = 0;
public static int INGAMEOPTIONS_BUTTONS_RIGHT = 0;
public static bool CREATIVE_ItemSlotShouldHighlightAsSelected = false;
public static int OPTIONS_BUTTON_SPECIALFEATURE;
public static int BackButtonCommand;
public static bool BackButtonInUse = false;
public static bool BackButtonLock;
public static int FANCYUI_HIGHEST_INDEX = 1;
public static int FANCYUI_SPECIAL_INSTRUCTIONS = 0;
public static int INFOACCCOUNT = 0;
public static int BUILDERACCCOUNT = 0;
public static int BUFFS_PER_COLUMN = 0;
public static int BUFFS_DRAWN = 0;
public static int INV_MOVE_OPTION_CD = 0;
}
}
}

29
UI/IInGameNotification.cs Normal file
View file

@ -0,0 +1,29 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.UI.IInGameNotification
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace Terraria.UI
{
public interface IInGameNotification
{
object CreationObject { get; }
bool ShouldBeRemoved { get; }
void Update();
void DrawInGame(SpriteBatch spriteBatch, Vector2 bottomAnchorPosition);
void PushAnchor(ref Vector2 positionAnchorBottom);
void DrawInNotificationsArea(
SpriteBatch spriteBatch,
Rectangle area,
ref int gamepadPointLocalIndexTouse);
}
}

25
UI/INetDiagnosticsUI.cs Normal file
View file

@ -0,0 +1,25 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.UI.INetDiagnosticsUI
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework.Graphics;
namespace Terraria.UI
{
public interface INetDiagnosticsUI
{
void Reset();
void Draw(SpriteBatch spriteBatch);
void CountReadMessage(int messageId, int messageLength);
void CountSentMessage(int messageId, int messageLength);
void CountReadModuleMessage(int moduleMessageId, int messageLength);
void CountSentModuleMessage(int moduleMessageId, int messageLength);
}
}

View file

@ -0,0 +1,102 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.UI.InGameNotificationsTracker
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System.Collections.Generic;
using Terraria.Achievements;
using Terraria.GameInput;
using Terraria.Social;
using Terraria.Social.Base;
namespace Terraria.UI
{
public class InGameNotificationsTracker
{
private static List<IInGameNotification> _notifications = new List<IInGameNotification>();
public static void Initialize()
{
Main.Achievements.OnAchievementCompleted += new Achievement.AchievementCompleted(InGameNotificationsTracker.AddCompleted);
SocialAPI.JoinRequests.OnRequestAdded += new ServerJoinRequestEvent(InGameNotificationsTracker.JoinRequests_OnRequestAdded);
SocialAPI.JoinRequests.OnRequestRemoved += new ServerJoinRequestEvent(InGameNotificationsTracker.JoinRequests_OnRequestRemoved);
}
private static void JoinRequests_OnRequestAdded(UserJoinToServerRequest request) => InGameNotificationsTracker.AddJoinRequest(request);
private static void JoinRequests_OnRequestRemoved(UserJoinToServerRequest request)
{
for (int index = InGameNotificationsTracker._notifications.Count - 1; index >= 0; --index)
{
if (InGameNotificationsTracker._notifications[index].CreationObject == request)
InGameNotificationsTracker._notifications.RemoveAt(index);
}
}
public static void DrawInGame(SpriteBatch sb)
{
float y = (float) (Main.screenHeight - 40);
if (PlayerInput.UsingGamepad)
y -= 25f;
Vector2 positionAnchorBottom = new Vector2((float) (Main.screenWidth / 2), y);
foreach (IInGameNotification notification in InGameNotificationsTracker._notifications)
{
notification.DrawInGame(sb, positionAnchorBottom);
notification.PushAnchor(ref positionAnchorBottom);
if ((double) positionAnchorBottom.Y < -100.0)
break;
}
}
public static void DrawInIngameOptions(
SpriteBatch spriteBatch,
Rectangle area,
ref int gamepadPointIdLocalIndexToUse)
{
int num1 = 4;
int height = area.Height / 5 - num1;
Rectangle area1 = new Rectangle(area.X, area.Y, area.Width - 6, height);
int num2 = 0;
foreach (IInGameNotification notification in InGameNotificationsTracker._notifications)
{
notification.DrawInNotificationsArea(spriteBatch, area1, ref gamepadPointIdLocalIndexToUse);
area1.Y += height + num1;
++num2;
if (num2 >= 5)
break;
}
}
public static void AddCompleted(Achievement achievement)
{
if (Main.netMode == 2)
return;
InGameNotificationsTracker._notifications.Add((IInGameNotification) new InGamePopups.AchievementUnlockedPopup(achievement));
}
public static void AddJoinRequest(UserJoinToServerRequest request)
{
if (Main.netMode == 2)
return;
InGameNotificationsTracker._notifications.Add((IInGameNotification) new InGamePopups.PlayerWantsToJoinGamePopup(request));
}
public static void Clear() => InGameNotificationsTracker._notifications.Clear();
public static void Update()
{
for (int index = 0; index < InGameNotificationsTracker._notifications.Count; ++index)
{
InGameNotificationsTracker._notifications[index].Update();
if (InGameNotificationsTracker._notifications[index].ShouldBeRemoved)
{
InGameNotificationsTracker._notifications.Remove(InGameNotificationsTracker._notifications[index]);
--index;
}
}
}
}
}

275
UI/InGamePopups.cs Normal file
View file

@ -0,0 +1,275 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.UI.InGamePopups
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using Terraria.Achievements;
using Terraria.GameContent;
using Terraria.GameInput;
using Terraria.Social.Base;
namespace Terraria.UI
{
public class InGamePopups
{
public class AchievementUnlockedPopup : IInGameNotification
{
private Achievement _theAchievement;
private Asset<Texture2D> _achievementTexture;
private Asset<Texture2D> _achievementBorderTexture;
private const int _iconSize = 64;
private const int _iconSizeWithSpace = 66;
private const int _iconsPerRow = 8;
private int _iconIndex;
private Rectangle _achievementIconFrame;
private string _title;
private int _ingameDisplayTimeLeft;
public bool ShouldBeRemoved { get; private set; }
public object CreationObject { get; private set; }
public AchievementUnlockedPopup(Achievement achievement)
{
this.CreationObject = (object) achievement;
this._ingameDisplayTimeLeft = 300;
this._theAchievement = achievement;
this._title = achievement.FriendlyName.Value;
int iconIndex = Main.Achievements.GetIconIndex(achievement.Name);
this._iconIndex = iconIndex;
this._achievementIconFrame = new Rectangle(iconIndex % 8 * 66, iconIndex / 8 * 66, 64, 64);
this._achievementTexture = Main.Assets.Request<Texture2D>("Images/UI/Achievements", (AssetRequestMode) 2);
this._achievementBorderTexture = Main.Assets.Request<Texture2D>("Images/UI/Achievement_Borders", (AssetRequestMode) 2);
}
public void Update()
{
--this._ingameDisplayTimeLeft;
if (this._ingameDisplayTimeLeft >= 0)
return;
this._ingameDisplayTimeLeft = 0;
}
private float Scale
{
get
{
if (this._ingameDisplayTimeLeft < 30)
return MathHelper.Lerp(0.0f, 1f, (float) this._ingameDisplayTimeLeft / 30f);
return this._ingameDisplayTimeLeft > 285 ? MathHelper.Lerp(1f, 0.0f, (float) (((double) this._ingameDisplayTimeLeft - 285.0) / 15.0)) : 1f;
}
}
private float Opacity
{
get
{
float scale = this.Scale;
return (double) scale <= 0.5 ? 0.0f : (float) (((double) scale - 0.5) / 0.5);
}
}
public void PushAnchor(ref Vector2 anchorPosition)
{
float num = 50f * this.Opacity;
anchorPosition.Y -= num;
}
public void DrawInGame(SpriteBatch sb, Vector2 bottomAnchorPosition)
{
float opacity = this.Opacity;
if ((double) opacity <= 0.0)
return;
float num1 = this.Scale * 1.1f;
Vector2 size = (FontAssets.ItemStack.Value.MeasureString(this._title) + new Vector2(58f, 10f)) * num1;
Rectangle rectangle = Utils.CenteredRectangle(bottomAnchorPosition + new Vector2(0.0f, (float) (-(double) size.Y * 0.5)), size);
Vector2 mouseScreen = Main.MouseScreen;
int num2 = rectangle.Contains(mouseScreen.ToPoint()) ? 1 : 0;
Color c = num2 != 0 ? new Color(64, 109, 164) * 0.75f : new Color(64, 109, 164) * 0.5f;
Utils.DrawInvBG(sb, rectangle, c);
float scale = num1 * 0.3f;
Vector2 position = rectangle.Right() - Vector2.UnitX * num1 * (float) (12.0 + (double) scale * (double) this._achievementIconFrame.Width);
sb.Draw(this._achievementTexture.Value, position, new Rectangle?(this._achievementIconFrame), Color.White * opacity, 0.0f, new Vector2(0.0f, (float) (this._achievementIconFrame.Height / 2)), scale, SpriteEffects.None, 0.0f);
sb.Draw(this._achievementBorderTexture.Value, position, new Rectangle?(), Color.White * opacity, 0.0f, new Vector2(0.0f, (float) (this._achievementIconFrame.Height / 2)), scale, SpriteEffects.None, 0.0f);
Color color = new Color((int) Main.mouseTextColor, (int) Main.mouseTextColor, (int) Main.mouseTextColor / 5, (int) Main.mouseTextColor);
Utils.DrawBorderString(sb, this._title, position - Vector2.UnitX * 10f, color * opacity, num1 * 0.9f, 1f, 0.4f);
if (num2 == 0)
return;
this.OnMouseOver();
}
private void OnMouseOver()
{
if (PlayerInput.IgnoreMouseInterface)
return;
Main.player[Main.myPlayer].mouseInterface = true;
if (!Main.mouseLeft || !Main.mouseLeftRelease)
return;
Main.mouseLeftRelease = false;
IngameFancyUI.OpenAchievementsAndGoto(this._theAchievement);
this._ingameDisplayTimeLeft = 0;
this.ShouldBeRemoved = true;
}
public void DrawInNotificationsArea(
SpriteBatch spriteBatch,
Rectangle area,
ref int gamepadPointLocalIndexTouse)
{
Utils.DrawInvBG(spriteBatch, area, Color.Red);
}
}
public class PlayerWantsToJoinGamePopup : IInGameNotification
{
private int _timeLeft;
private const int _timeLeftMax = 1800;
private string _displayTextWithoutTime;
private UserJoinToServerRequest _request;
private float Scale
{
get
{
if (this._timeLeft < 30)
return MathHelper.Lerp(0.0f, 1f, (float) this._timeLeft / 30f);
return this._timeLeft > 1785 ? MathHelper.Lerp(1f, 0.0f, (float) (((double) this._timeLeft - 1785.0) / 15.0)) : 1f;
}
}
private float Opacity
{
get
{
float scale = this.Scale;
return (double) scale <= 0.5 ? 0.0f : (float) (((double) scale - 0.5) / 0.5);
}
}
public object CreationObject { get; private set; }
public PlayerWantsToJoinGamePopup(UserJoinToServerRequest request)
{
this._request = request;
this.CreationObject = (object) request;
this._timeLeft = 1800;
switch (Main.rand.Next(5))
{
case 1:
this._displayTextWithoutTime = "This Fucker Wants to Join you";
break;
case 2:
this._displayTextWithoutTime = "This Weirdo Wants to Join you";
break;
case 3:
this._displayTextWithoutTime = "This Great Gal Wants to Join you";
break;
case 4:
this._displayTextWithoutTime = "The one guy who beat you up 30 years ago Wants to Join you";
break;
default:
this._displayTextWithoutTime = "This Bloke Wants to Join you";
break;
}
}
public bool ShouldBeRemoved => this._timeLeft <= 0;
public void Update() => --this._timeLeft;
public void DrawInGame(SpriteBatch spriteBatch, Vector2 bottomAnchorPosition)
{
float opacity = this.Opacity;
if ((double) opacity <= 0.0)
return;
string text = Utils.FormatWith(this._request.GetUserWrapperText(), (object) new
{
DisplayName = this._request.UserDisplayName,
FullId = this._request.UserFullIdentifier
});
float num = this.Scale * 1.1f;
Vector2 size = (FontAssets.ItemStack.Value.MeasureString(text) + new Vector2(58f, 10f)) * num;
Rectangle R = Utils.CenteredRectangle(bottomAnchorPosition + new Vector2(0.0f, (float) (-(double) size.Y * 0.5)), size);
Vector2 mouseScreen = Main.MouseScreen;
Color c = R.Contains(mouseScreen.ToPoint()) ? new Color(64, 109, 164) * 0.75f : new Color(64, 109, 164) * 0.5f;
Utils.DrawInvBG(spriteBatch, R, c);
new Vector2((float) R.Left, (float) R.Center.Y).X += 32f;
Texture2D texture2D1 = Main.Assets.Request<Texture2D>("Images/UI/ButtonPlay", (AssetRequestMode) 1).Value;
Vector2 position = new Vector2((float) (R.Left + 7), (float) ((double) MathHelper.Lerp((float) R.Top, (float) R.Bottom, 0.5f) - (double) (texture2D1.Height / 2) - 1.0));
bool flag1 = Utils.CenteredRectangle(position + new Vector2((float) (texture2D1.Width / 2), 0.0f), texture2D1.Size()).Contains(mouseScreen.ToPoint());
spriteBatch.Draw(texture2D1, position, new Rectangle?(), Color.White * (flag1 ? 1f : 0.5f), 0.0f, new Vector2(0.0f, 0.5f) * texture2D1.Size(), 1f, SpriteEffects.None, 0.0f);
if (flag1)
this.OnMouseOver();
Texture2D texture2D2 = Main.Assets.Request<Texture2D>("Images/UI/ButtonDelete", (AssetRequestMode) 1).Value;
position = new Vector2((float) (R.Left + 7), (float) ((double) MathHelper.Lerp((float) R.Top, (float) R.Bottom, 0.5f) + (double) (texture2D2.Height / 2) + 1.0));
bool flag2 = Utils.CenteredRectangle(position + new Vector2((float) (texture2D2.Width / 2), 0.0f), texture2D2.Size()).Contains(mouseScreen.ToPoint());
spriteBatch.Draw(texture2D2, position, new Rectangle?(), Color.White * (flag2 ? 1f : 0.5f), 0.0f, new Vector2(0.0f, 0.5f) * texture2D2.Size(), 1f, SpriteEffects.None, 0.0f);
if (flag2)
this.OnMouseOver(true);
Color color = new Color((int) Main.mouseTextColor, (int) Main.mouseTextColor, (int) Main.mouseTextColor / 5, (int) Main.mouseTextColor);
Utils.DrawBorderString(spriteBatch, text, R.Center.ToVector2() + new Vector2(10f, 0.0f), color * opacity, num * 0.9f, 0.5f, 0.4f);
}
private void OnMouseOver(bool reject = false)
{
if (PlayerInput.IgnoreMouseInterface)
return;
Main.player[Main.myPlayer].mouseInterface = true;
if (!Main.mouseLeft || !Main.mouseLeftRelease)
return;
Main.mouseLeftRelease = false;
this._timeLeft = 0;
if (reject)
this._request.Reject();
else
this._request.Accept();
}
public void PushAnchor(ref Vector2 positionAnchorBottom)
{
float num = 70f * this.Opacity;
positionAnchorBottom.Y -= num;
}
public void DrawInNotificationsArea(
SpriteBatch spriteBatch,
Rectangle area,
ref int gamepadPointLocalIndexTouse)
{
string userWrapperText = this._request.GetUserWrapperText();
string userDisplayName = this._request.UserDisplayName;
Utils.TrimTextIfNeeded(ref userDisplayName, FontAssets.MouseText.Value, 0.9f, (float) (area.Width / 4));
var data = new
{
DisplayName = userDisplayName,
FullId = this._request.UserFullIdentifier
};
string text = Utils.FormatWith(userWrapperText, (object) data);
Vector2 mouseScreen = Main.MouseScreen;
Color c = area.Contains(mouseScreen.ToPoint()) ? new Color(64, 109, 164) * 0.75f : new Color(64, 109, 164) * 0.5f;
Utils.DrawInvBG(spriteBatch, area, c);
Vector2 pos = new Vector2((float) area.Left, (float) area.Center.Y);
pos.X += 32f;
Texture2D texture2D1 = Main.Assets.Request<Texture2D>("Images/UI/ButtonPlay", (AssetRequestMode) 1).Value;
Vector2 position = new Vector2((float) (area.Left + 7), (float) ((double) MathHelper.Lerp((float) area.Top, (float) area.Bottom, 0.5f) - (double) (texture2D1.Height / 2) - 1.0));
bool flag1 = Utils.CenteredRectangle(position + new Vector2((float) (texture2D1.Width / 2), 0.0f), texture2D1.Size()).Contains(mouseScreen.ToPoint());
spriteBatch.Draw(texture2D1, position, new Rectangle?(), Color.White * (flag1 ? 1f : 0.5f), 0.0f, new Vector2(0.0f, 0.5f) * texture2D1.Size(), 1f, SpriteEffects.None, 0.0f);
if (flag1)
this.OnMouseOver();
Texture2D texture2D2 = Main.Assets.Request<Texture2D>("Images/UI/ButtonDelete", (AssetRequestMode) 1).Value;
position = new Vector2((float) (area.Left + 7), (float) ((double) MathHelper.Lerp((float) area.Top, (float) area.Bottom, 0.5f) + (double) (texture2D2.Height / 2) + 1.0));
bool flag2 = Utils.CenteredRectangle(position + new Vector2((float) (texture2D2.Width / 2), 0.0f), texture2D2.Size()).Contains(mouseScreen.ToPoint());
spriteBatch.Draw(texture2D2, position, new Rectangle?(), Color.White * (flag2 ? 1f : 0.5f), 0.0f, new Vector2(0.0f, 0.5f) * texture2D2.Size(), 1f, SpriteEffects.None, 0.0f);
if (flag2)
this.OnMouseOver(true);
pos.X += 6f;
Color color = new Color((int) Main.mouseTextColor, (int) Main.mouseTextColor, (int) Main.mouseTextColor / 5, (int) Main.mouseTextColor);
Utils.DrawBorderString(spriteBatch, text, pos, color, 0.9f, anchory: 0.4f);
}
}
}
}

191
UI/IngameFancyUI.cs Normal file
View file

@ -0,0 +1,191 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.UI.IngameFancyUI
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria.Achievements;
using Terraria.Audio;
using Terraria.GameContent.UI.States;
using Terraria.GameInput;
using Terraria.Localization;
using Terraria.UI.Gamepad;
namespace Terraria.UI
{
public class IngameFancyUI
{
private static bool CoverForOneUIFrame;
public static void CoverNextFrame() => IngameFancyUI.CoverForOneUIFrame = true;
public static bool CanCover()
{
if (!IngameFancyUI.CoverForOneUIFrame)
return false;
IngameFancyUI.CoverForOneUIFrame = false;
return true;
}
public static void OpenAchievements()
{
IngameFancyUI.CoverNextFrame();
Main.playerInventory = false;
Main.editChest = false;
Main.npcChatText = "";
Main.inFancyUI = true;
IngameFancyUI.ClearChat();
Main.InGameUI.SetState((UIState) Main.AchievementsMenu);
}
public static void OpenAchievementsAndGoto(Achievement achievement)
{
IngameFancyUI.OpenAchievements();
Main.AchievementsMenu.GotoAchievement(achievement);
}
private static void ClearChat()
{
Main.ClosePlayerChat();
Main.chatText = "";
}
public static void OpenKeybinds() => IngameFancyUI.OpenUIState((UIState) Main.ManageControlsMenu);
public static void OpenUIState(UIState uiState)
{
IngameFancyUI.CoverNextFrame();
Main.playerInventory = false;
Main.editChest = false;
Main.npcChatText = "";
Main.inFancyUI = true;
IngameFancyUI.ClearChat();
Main.InGameUI.SetState(uiState);
}
public static bool CanShowVirtualKeyboard(int context) => UIVirtualKeyboard.CanDisplay(context);
public static void OpenVirtualKeyboard(int keyboardContext)
{
IngameFancyUI.CoverNextFrame();
IngameFancyUI.ClearChat();
SoundEngine.PlaySound(12);
string labelText = "";
switch (keyboardContext)
{
case 1:
Main.editSign = true;
labelText = Language.GetTextValue("UI.EnterMessage");
break;
case 2:
labelText = Language.GetTextValue("UI.EnterNewName");
Player player = Main.player[Main.myPlayer];
Main.npcChatText = Main.chest[player.chest].name;
Tile tile = Main.tile[player.chestX, player.chestY];
if (tile.type == (ushort) 21)
Main.defaultChestName = Lang.chestType[(int) tile.frameX / 36].Value;
else if (tile.type == (ushort) 467 && (int) tile.frameX / 36 == 4)
Main.defaultChestName = Lang.GetItemNameValue(3988);
else if (tile.type == (ushort) 467)
Main.defaultChestName = Lang.chestType2[(int) tile.frameX / 36].Value;
else if (tile.type == (ushort) 88)
Main.defaultChestName = Lang.dresserType[(int) tile.frameX / 54].Value;
if (Main.npcChatText == "")
Main.npcChatText = Main.defaultChestName;
Main.editChest = true;
break;
}
Main.clrInput();
if (!IngameFancyUI.CanShowVirtualKeyboard(keyboardContext))
return;
Main.inFancyUI = true;
switch (keyboardContext)
{
case 1:
Main.InGameUI.SetState((UIState) new UIVirtualKeyboard(labelText, Main.npcChatText, (UIVirtualKeyboard.KeyboardSubmitEvent) (s =>
{
Main.SubmitSignText();
IngameFancyUI.Close();
}), (Action) (() =>
{
Main.InputTextSignCancel();
IngameFancyUI.Close();
}), keyboardContext));
break;
case 2:
Main.InGameUI.SetState((UIState) new UIVirtualKeyboard(labelText, Main.npcChatText, (UIVirtualKeyboard.KeyboardSubmitEvent) (s =>
{
ChestUI.RenameChestSubmit(Main.player[Main.myPlayer]);
IngameFancyUI.Close();
}), (Action) (() =>
{
ChestUI.RenameChestCancel();
IngameFancyUI.Close();
}), keyboardContext));
break;
}
UILinkPointNavigator.GoToDefaultPage(1);
}
public static void Close()
{
Main.inFancyUI = false;
SoundEngine.PlaySound(11);
bool flag1 = !Main.gameMenu;
bool flag2 = !(Main.InGameUI.CurrentState is UIVirtualKeyboard);
bool flag3 = false;
switch (UIVirtualKeyboard.KeyboardContext)
{
case 2:
case 3:
flag3 = true;
break;
}
if (flag1 && !(flag2 | flag3))
flag1 = false;
if (flag1)
Main.playerInventory = true;
if (!Main.gameMenu && Main.InGameUI.CurrentState is UIEmotesMenu)
Main.playerInventory = false;
Main.LocalPlayer.releaseInventory = false;
Main.InGameUI.SetState((UIState) null);
UILinkPointNavigator.Shortcuts.FANCYUI_SPECIAL_INSTRUCTIONS = 0;
}
public static bool Draw(SpriteBatch spriteBatch, GameTime gameTime)
{
bool flag = false;
if (Main.InGameUI.CurrentState is UIVirtualKeyboard && UIVirtualKeyboard.KeyboardContext > 0)
{
if (!Main.inFancyUI)
Main.InGameUI.SetState((UIState) null);
if (Main.screenWidth >= 1705 || !PlayerInput.UsingGamepad)
flag = true;
}
if (!Main.gameMenu)
{
Main.mouseText = false;
if (Main.InGameUI != null && Main.InGameUI.IsElementUnderMouse())
Main.player[Main.myPlayer].mouseInterface = true;
Main.instance.GUIBarsDraw();
if (Main.InGameUI.CurrentState is UIVirtualKeyboard && UIVirtualKeyboard.KeyboardContext > 0)
Main.instance.GUIChatDraw();
if (!Main.inFancyUI)
Main.InGameUI.SetState((UIState) null);
Main.instance.DrawMouseOver();
Main.DrawCursor(Main.DrawThickCursor());
}
return flag;
}
public static void MouseOver()
{
if (!Main.inFancyUI || !Main.InGameUI.IsElementUnderMouse())
return;
Main.mouseText = true;
}
}
}

15
UI/InterfaceScaleType.cs Normal file
View file

@ -0,0 +1,15 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.UI.InterfaceScaleType
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
namespace Terraria.UI
{
public enum InterfaceScaleType
{
Game,
UI,
None,
}
}

2824
UI/ItemSlot.cs Normal file

File diff suppressed because it is too large Load diff

1134
UI/ItemSorting.cs Normal file

File diff suppressed because it is too large Load diff

79
UI/ItemTooltip.cs Normal file
View file

@ -0,0 +1,79 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.UI.ItemTooltip
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using System.Collections.Generic;
using Terraria.Localization;
namespace Terraria.UI
{
public class ItemTooltip
{
public static readonly ItemTooltip None = new ItemTooltip();
private static readonly List<TooltipProcessor> _globalProcessors = new List<TooltipProcessor>();
private static ulong _globalValidatorKey = 1;
private string[] _tooltipLines;
private ulong _validatorKey;
private readonly LocalizedText _text;
private string _processedText;
public int Lines
{
get
{
this.ValidateTooltip();
return this._tooltipLines == null ? 0 : this._tooltipLines.Length;
}
}
private ItemTooltip()
{
}
private ItemTooltip(string key) => this._text = Language.GetText(key);
public static ItemTooltip FromLanguageKey(string key) => !Language.Exists(key) ? ItemTooltip.None : new ItemTooltip(key);
public string GetLine(int line)
{
this.ValidateTooltip();
return this._tooltipLines[line];
}
private void ValidateTooltip()
{
if ((long) this._validatorKey == (long) ItemTooltip._globalValidatorKey)
return;
this._validatorKey = ItemTooltip._globalValidatorKey;
if (this._text == null)
{
this._tooltipLines = (string[]) null;
this._processedText = string.Empty;
}
else
{
string tooltip = this._text.Value;
foreach (TooltipProcessor globalProcessor in ItemTooltip._globalProcessors)
tooltip = globalProcessor(tooltip);
this._tooltipLines = tooltip.Split('\n');
this._processedText = tooltip;
}
}
public static void AddGlobalProcessor(TooltipProcessor processor) => ItemTooltip._globalProcessors.Add(processor);
public static void RemoveGlobalProcessor(TooltipProcessor processor) => ItemTooltip._globalProcessors.Remove(processor);
public static void ClearGlobalProcessors() => ItemTooltip._globalProcessors.Clear();
public static void InvalidateTooltips()
{
++ItemTooltip._globalValidatorKey;
if (ItemTooltip._globalValidatorKey != ulong.MaxValue)
return;
ItemTooltip._globalValidatorKey = 0UL;
}
}
}

View file

@ -0,0 +1,24 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.UI.LegacyGameInterfaceLayer
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
namespace Terraria.UI
{
public class LegacyGameInterfaceLayer : GameInterfaceLayer
{
private GameInterfaceDrawMethod _drawMethod;
public LegacyGameInterfaceLayer(
string name,
GameInterfaceDrawMethod drawMethod,
InterfaceScaleType scaleType = InterfaceScaleType.Game)
: base(name, scaleType)
{
this._drawMethod = drawMethod;
}
protected override bool DrawSelf() => this._drawMethod();
}
}

View file

@ -0,0 +1,142 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.UI.LegacyNetDiagnosticsUI
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Graphics;
using Terraria.GameContent;
namespace Terraria.UI
{
public class LegacyNetDiagnosticsUI : INetDiagnosticsUI
{
public static bool netDiag;
public static int txData = 0;
public static int rxData = 0;
public static int txMsg = 0;
public static int rxMsg = 0;
private const int maxMsg = 141;
public static int[] rxMsgType = new int[141];
public static int[] rxDataType = new int[141];
public static int[] txMsgType = new int[141];
public static int[] txDataType = new int[141];
public void Reset()
{
LegacyNetDiagnosticsUI.rxMsg = 0;
LegacyNetDiagnosticsUI.rxData = 0;
LegacyNetDiagnosticsUI.txMsg = 0;
LegacyNetDiagnosticsUI.txData = 0;
for (int index = 0; index < 141; ++index)
{
LegacyNetDiagnosticsUI.rxMsgType[index] = 0;
LegacyNetDiagnosticsUI.rxDataType[index] = 0;
LegacyNetDiagnosticsUI.txMsgType[index] = 0;
LegacyNetDiagnosticsUI.txDataType[index] = 0;
}
}
public void CountReadMessage(int messageId, int messageLength)
{
++LegacyNetDiagnosticsUI.rxMsg;
LegacyNetDiagnosticsUI.rxData += messageLength;
++LegacyNetDiagnosticsUI.rxMsgType[messageId];
LegacyNetDiagnosticsUI.rxDataType[messageId] += messageLength;
}
public void CountSentMessage(int messageId, int messageLength)
{
++LegacyNetDiagnosticsUI.txMsg;
LegacyNetDiagnosticsUI.txData += messageLength;
++LegacyNetDiagnosticsUI.txMsgType[messageId];
LegacyNetDiagnosticsUI.txDataType[messageId] += messageLength;
}
public void Draw(SpriteBatch spriteBatch)
{
LegacyNetDiagnosticsUI.DrawTitles(spriteBatch);
LegacyNetDiagnosticsUI.DrawMesageLines(spriteBatch);
}
private static void DrawMesageLines(SpriteBatch spriteBatch)
{
for (int msgId = 0; msgId < 141; ++msgId)
{
int num1 = 200;
int num2 = 120;
int num3 = msgId / 50;
int x = num1 + num3 * 400;
int y = num2 + (msgId - num3 * 50) * 13;
LegacyNetDiagnosticsUI.PrintNetDiagnosticsLineForMessage(spriteBatch, msgId, x, y);
}
}
private static void DrawTitles(SpriteBatch spriteBatch)
{
for (int index = 0; index < 4; ++index)
{
string str = "";
int num1 = 20;
int num2 = 220;
if (index == 0)
{
str = "RX Msgs: " + string.Format("{0:0,0}", (object) LegacyNetDiagnosticsUI.rxMsg);
num2 += index * 20;
}
else if (index == 1)
{
str = "RX Bytes: " + string.Format("{0:0,0}", (object) LegacyNetDiagnosticsUI.rxData);
num2 += index * 20;
}
else if (index == 2)
{
str = "TX Msgs: " + string.Format("{0:0,0}", (object) LegacyNetDiagnosticsUI.txMsg);
num2 += index * 20;
}
else if (index == 3)
{
str = "TX Bytes: " + string.Format("{0:0,0}", (object) LegacyNetDiagnosticsUI.txData);
num2 += index * 20;
}
DynamicSpriteFontExtensionMethods.DrawString(spriteBatch, FontAssets.MouseText.Value, str, new Vector2((float) num1, (float) num2), Color.White, 0.0f, new Vector2(), 1f, SpriteEffects.None, 0.0f);
}
}
private static void PrintNetDiagnosticsLineForMessage(
SpriteBatch spriteBatch,
int msgId,
int x,
int y)
{
float num = 0.7f;
string str1 = msgId.ToString() + ": ";
DynamicSpriteFontExtensionMethods.DrawString(spriteBatch, FontAssets.MouseText.Value, str1, new Vector2((float) x, (float) y), Color.White, 0.0f, new Vector2(), num, SpriteEffects.None, 0.0f);
x += 30;
string str2 = "rx:" + string.Format("{0:0,0}", (object) LegacyNetDiagnosticsUI.rxMsgType[msgId]);
DynamicSpriteFontExtensionMethods.DrawString(spriteBatch, FontAssets.MouseText.Value, str2, new Vector2((float) x, (float) y), Color.White, 0.0f, new Vector2(), num, SpriteEffects.None, 0.0f);
x += 70;
string str3 = string.Format("{0:0,0}", (object) LegacyNetDiagnosticsUI.rxDataType[msgId]);
DynamicSpriteFontExtensionMethods.DrawString(spriteBatch, FontAssets.MouseText.Value, str3, new Vector2((float) x, (float) y), Color.White, 0.0f, new Vector2(), num, SpriteEffects.None, 0.0f);
x += 70;
string str4 = msgId.ToString() + ": ";
DynamicSpriteFontExtensionMethods.DrawString(spriteBatch, FontAssets.MouseText.Value, str4, new Vector2((float) x, (float) y), Color.White, 0.0f, new Vector2(), num, SpriteEffects.None, 0.0f);
x += 30;
string str5 = "tx:" + string.Format("{0:0,0}", (object) LegacyNetDiagnosticsUI.txMsgType[msgId]);
DynamicSpriteFontExtensionMethods.DrawString(spriteBatch, FontAssets.MouseText.Value, str5, new Vector2((float) x, (float) y), Color.White, 0.0f, new Vector2(), num, SpriteEffects.None, 0.0f);
x += 70;
string str6 = string.Format("{0:0,0}", (object) LegacyNetDiagnosticsUI.txDataType[msgId]);
DynamicSpriteFontExtensionMethods.DrawString(spriteBatch, FontAssets.MouseText.Value, str6, new Vector2((float) x, (float) y), Color.White, 0.0f, new Vector2(), num, SpriteEffects.None, 0.0f);
}
public void CountReadModuleMessage(int moduleMessageId, int messageLength)
{
}
public void CountSentModuleMessage(int moduleMessageId, int messageLength)
{
}
}
}

146
UI/NetDiagnosticsUI.cs Normal file
View file

@ -0,0 +1,146 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.UI.NetDiagnosticsUI
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Graphics;
using System.Collections.Generic;
using Terraria.GameContent;
namespace Terraria.UI
{
public class NetDiagnosticsUI : INetDiagnosticsUI
{
private NetDiagnosticsUI.CounterForMessage[] _counterByMessageId = new NetDiagnosticsUI.CounterForMessage[141];
private Dictionary<int, NetDiagnosticsUI.CounterForMessage> _counterByModuleId = new Dictionary<int, NetDiagnosticsUI.CounterForMessage>();
private int _highestFoundReadBytes = 1;
private int _highestFoundReadCount = 1;
public void Reset()
{
for (int index = 0; index < this._counterByMessageId.Length; ++index)
this._counterByMessageId[index].Reset();
this._counterByModuleId.Clear();
this._counterByMessageId[10].exemptFromBadScoreTest = true;
this._counterByMessageId[82].exemptFromBadScoreTest = true;
}
public void CountReadMessage(int messageId, int messageLength) => this._counterByMessageId[messageId].CountReadMessage(messageLength);
public void CountSentMessage(int messageId, int messageLength) => this._counterByMessageId[messageId].CountSentMessage(messageLength);
public void CountReadModuleMessage(int moduleMessageId, int messageLength)
{
NetDiagnosticsUI.CounterForMessage counterForMessage;
this._counterByModuleId.TryGetValue(moduleMessageId, out counterForMessage);
counterForMessage.CountReadMessage(messageLength);
this._counterByModuleId[moduleMessageId] = counterForMessage;
}
public void CountSentModuleMessage(int moduleMessageId, int messageLength)
{
NetDiagnosticsUI.CounterForMessage counterForMessage;
this._counterByModuleId.TryGetValue(moduleMessageId, out counterForMessage);
counterForMessage.CountSentMessage(messageLength);
this._counterByModuleId[moduleMessageId] = counterForMessage;
}
public void Draw(SpriteBatch spriteBatch)
{
int num1 = this._counterByMessageId.Length + this._counterByModuleId.Count;
for (int index = 0; index <= num1 / 51; ++index)
Utils.DrawInvBG(spriteBatch, 190 + 400 * index, 110, 390, 683, new Color());
Vector2 position;
for (int index = 0; index < this._counterByMessageId.Length; ++index)
{
int num2 = index / 51;
int num3 = index - num2 * 51;
position.X = (float) (200 + num2 * 400);
position.Y = (float) (120 + num3 * 13);
this.DrawCounter(spriteBatch, ref this._counterByMessageId[index], index.ToString(), position);
}
int num4 = this._counterByMessageId.Length + 1;
foreach (KeyValuePair<int, NetDiagnosticsUI.CounterForMessage> keyValuePair in this._counterByModuleId)
{
int num5 = num4 / 51;
int num6 = num4 - num5 * 51;
position.X = (float) (200 + num5 * 400);
position.Y = (float) (120 + num6 * 13);
NetDiagnosticsUI.CounterForMessage counter = keyValuePair.Value;
this.DrawCounter(spriteBatch, ref counter, ".." + keyValuePair.Key.ToString(), position);
++num4;
}
}
private void DrawCounter(
SpriteBatch spriteBatch,
ref NetDiagnosticsUI.CounterForMessage counter,
string title,
Vector2 position)
{
if (!counter.exemptFromBadScoreTest)
{
if (this._highestFoundReadCount < counter.timesReceived)
this._highestFoundReadCount = counter.timesReceived;
if (this._highestFoundReadBytes < counter.bytesReceived)
this._highestFoundReadBytes = counter.bytesReceived;
}
Vector2 pos = position;
string str = title + ": ";
Color color = Main.hslToRgb((float) (0.300000011920929 * (1.0 - (double) Utils.Remap((float) counter.bytesReceived, 0.0f, (float) this._highestFoundReadBytes, 0.0f, 1f))), 1f, 0.5f);
if (counter.exemptFromBadScoreTest)
color = Color.White;
string text1 = str;
this.DrawText(spriteBatch, text1, pos, color);
pos.X += 30f;
string text2 = "rx:" + string.Format("{0,0}", (object) counter.timesReceived);
this.DrawText(spriteBatch, text2, pos, color);
pos.X += 70f;
string text3 = string.Format("{0,0}", (object) counter.bytesReceived);
this.DrawText(spriteBatch, text3, pos, color);
pos.X += 70f;
string text4 = str;
this.DrawText(spriteBatch, text4, pos, color);
pos.X += 30f;
string text5 = "tx:" + string.Format("{0,0}", (object) counter.timesSent);
this.DrawText(spriteBatch, text5, pos, color);
pos.X += 70f;
string text6 = string.Format("{0,0}", (object) counter.bytesSent);
this.DrawText(spriteBatch, text6, pos, color);
}
private void DrawText(SpriteBatch spriteBatch, string text, Vector2 pos, Color color) => DynamicSpriteFontExtensionMethods.DrawString(spriteBatch, FontAssets.MouseText.Value, text, pos, color, 0.0f, Vector2.Zero, 0.7f, SpriteEffects.None, 0.0f);
private struct CounterForMessage
{
public int timesReceived;
public int timesSent;
public int bytesReceived;
public int bytesSent;
public bool exemptFromBadScoreTest;
public void Reset()
{
this.timesReceived = 0;
this.timesSent = 0;
this.bytesReceived = 0;
this.bytesSent = 0;
}
public void CountReadMessage(int messageLength)
{
++this.timesReceived;
this.bytesReceived += messageLength;
}
public void CountSentMessage(int messageLength)
{
++this.timesSent;
this.bytesSent += messageLength;
}
}
}
}

44
UI/SnapPoint.cs Normal file
View file

@ -0,0 +1,44 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.UI.SnapPoint
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using System.Diagnostics;
namespace Terraria.UI
{
[DebuggerDisplay("Snap Point - {Name} {Id}")]
public class SnapPoint
{
public string Name;
private Vector2 _anchor;
private Vector2 _offset;
public int Id { get; private set; }
public Vector2 Position { get; private set; }
public SnapPoint(string name, int id, Vector2 anchor, Vector2 offset)
{
this.Name = name;
this.Id = id;
this._anchor = anchor;
this._offset = offset;
}
public void Calculate(UIElement element)
{
CalculatedStyle dimensions = element.GetDimensions();
this.Position = dimensions.Position() + this._offset + this._anchor * new Vector2(dimensions.Width, dimensions.Height);
}
public void ThisIsAHackThatChangesTheSnapPointsInfo(Vector2 anchor, Vector2 offset, int id)
{
this._anchor = anchor;
this._offset = offset;
this.Id = id;
}
}
}

36
UI/StyleDimension.cs Normal file
View file

@ -0,0 +1,36 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.UI.StyleDimension
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
namespace Terraria.UI
{
public struct StyleDimension
{
public static StyleDimension Fill = new StyleDimension(0.0f, 1f);
public static StyleDimension Empty = new StyleDimension(0.0f, 0.0f);
public float Pixels;
public float Precent;
public StyleDimension(float pixels, float precent)
{
this.Pixels = pixels;
this.Precent = precent;
}
public void Set(float pixels, float precent)
{
this.Pixels = pixels;
this.Precent = precent;
}
public float GetValue(float containerSize) => this.Pixels + this.Precent * containerSize;
public static StyleDimension FromPixels(float pixels) => new StyleDimension(pixels, 0.0f);
public static StyleDimension FromPercent(float percent) => new StyleDimension(0.0f, percent);
public static StyleDimension FromPixelsAndPercent(float pixels, float percent) => new StyleDimension(pixels, percent);
}
}

10
UI/TooltipProcessor.cs Normal file
View file

@ -0,0 +1,10 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.UI.TooltipProcessor
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
namespace Terraria.UI
{
public delegate string TooltipProcessor(string tooltip);
}

18
UI/UIAlign.cs Normal file
View file

@ -0,0 +1,18 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.UI.UIAlign
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
namespace Terraria.UI
{
public static class UIAlign
{
public const float Left = 0.0f;
public const float Center = 0.5f;
public const float Right = 1f;
public const float Top = 0.0f;
public const float Middle = 0.5f;
public const float Bottom = 1f;
}
}

432
UI/UIElement.cs Normal file
View file

@ -0,0 +1,432 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.UI.UIElement
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Graphics;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using Terraria.GameContent.UI.Elements;
namespace Terraria.UI
{
public class UIElement : IComparable
{
protected readonly List<UIElement> Elements = new List<UIElement>();
public StyleDimension Top;
public StyleDimension Left;
public StyleDimension Width;
public StyleDimension Height;
public StyleDimension MaxWidth = StyleDimension.Fill;
public StyleDimension MaxHeight = StyleDimension.Fill;
public StyleDimension MinWidth = StyleDimension.Empty;
public StyleDimension MinHeight = StyleDimension.Empty;
private bool _isInitialized;
public bool IgnoresMouseInteraction;
public bool OverflowHidden;
public SamplerState OverrideSamplerState;
public float PaddingTop;
public float PaddingLeft;
public float PaddingRight;
public float PaddingBottom;
public float MarginTop;
public float MarginLeft;
public float MarginRight;
public float MarginBottom;
public float HAlign;
public float VAlign;
private CalculatedStyle _innerDimensions;
private CalculatedStyle _dimensions;
private CalculatedStyle _outerDimensions;
private static readonly RasterizerState OverflowHiddenRasterizerState = new RasterizerState()
{
CullMode = CullMode.None,
ScissorTestEnable = true
};
public bool UseImmediateMode;
private SnapPoint _snapPoint;
private static int _idCounter = 0;
public UIElement Parent { get; private set; }
public int UniqueId { get; private set; }
public IEnumerable<UIElement> Children => (IEnumerable<UIElement>) this.Elements;
public event UIElement.MouseEvent OnMouseDown;
public event UIElement.MouseEvent OnMouseUp;
public event UIElement.MouseEvent OnClick;
public event UIElement.MouseEvent OnMouseOver;
public event UIElement.MouseEvent OnMouseOut;
public event UIElement.MouseEvent OnDoubleClick;
public event UIElement.ScrollWheelEvent OnScrollWheel;
public event UIElement.ElementEvent OnUpdate;
public bool IsMouseHovering { get; private set; }
public UIElement() => this.UniqueId = UIElement._idCounter++;
public void SetSnapPoint(string name, int id, Vector2? anchor = null, Vector2? offset = null)
{
if (!anchor.HasValue)
anchor = new Vector2?(new Vector2(0.5f));
if (!offset.HasValue)
offset = new Vector2?(Vector2.Zero);
this._snapPoint = new SnapPoint(name, id, anchor.Value, offset.Value);
}
public bool GetSnapPoint(out SnapPoint point)
{
point = this._snapPoint;
if (this._snapPoint != null)
this._snapPoint.Calculate(this);
return this._snapPoint != null;
}
protected virtual void DrawSelf(SpriteBatch spriteBatch)
{
}
protected virtual void DrawChildren(SpriteBatch spriteBatch)
{
foreach (UIElement element in this.Elements)
element.Draw(spriteBatch);
}
public void Append(UIElement element)
{
element.Remove();
element.Parent = this;
this.Elements.Add(element);
element.Recalculate();
}
public void Remove()
{
if (this.Parent == null)
return;
this.Parent.RemoveChild(this);
}
public void RemoveChild(UIElement child)
{
this.Elements.Remove(child);
child.Parent = (UIElement) null;
}
public void RemoveAllChildren()
{
foreach (UIElement element in this.Elements)
element.Parent = (UIElement) null;
this.Elements.Clear();
}
public virtual void Draw(SpriteBatch spriteBatch)
{
int num = this.OverflowHidden ? 1 : 0;
bool useImmediateMode = this.UseImmediateMode;
RasterizerState rasterizerState = spriteBatch.GraphicsDevice.RasterizerState;
Rectangle scissorRectangle = spriteBatch.GraphicsDevice.ScissorRectangle;
SamplerState anisotropicClamp = SamplerState.AnisotropicClamp;
if (useImmediateMode || this.OverrideSamplerState != null)
{
spriteBatch.End();
spriteBatch.Begin(useImmediateMode ? SpriteSortMode.Immediate : SpriteSortMode.Deferred, BlendState.AlphaBlend, this.OverrideSamplerState != null ? this.OverrideSamplerState : anisotropicClamp, DepthStencilState.None, UIElement.OverflowHiddenRasterizerState, (Effect) null, Main.UIScaleMatrix);
this.DrawSelf(spriteBatch);
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, anisotropicClamp, DepthStencilState.None, UIElement.OverflowHiddenRasterizerState, (Effect) null, Main.UIScaleMatrix);
}
else
this.DrawSelf(spriteBatch);
if (num != 0)
{
spriteBatch.End();
Rectangle clippingRectangle = this.GetClippingRectangle(spriteBatch);
spriteBatch.GraphicsDevice.ScissorRectangle = clippingRectangle;
spriteBatch.GraphicsDevice.RasterizerState = UIElement.OverflowHiddenRasterizerState;
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, anisotropicClamp, DepthStencilState.None, UIElement.OverflowHiddenRasterizerState, (Effect) null, Main.UIScaleMatrix);
}
this.DrawChildren(spriteBatch);
if (num == 0)
return;
spriteBatch.End();
spriteBatch.GraphicsDevice.ScissorRectangle = scissorRectangle;
spriteBatch.GraphicsDevice.RasterizerState = rasterizerState;
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, anisotropicClamp, DepthStencilState.None, rasterizerState, (Effect) null, Main.UIScaleMatrix);
}
public virtual void Update(GameTime gameTime)
{
if (this.OnUpdate != null)
this.OnUpdate(this);
foreach (UIElement element in this.Elements)
element.Update(gameTime);
}
public Rectangle GetClippingRectangle(SpriteBatch spriteBatch)
{
Vector2 position1 = new Vector2(this._innerDimensions.X, this._innerDimensions.Y);
Vector2 position2 = new Vector2(this._innerDimensions.Width, this._innerDimensions.Height) + position1;
Vector2 vector2_1 = Vector2.Transform(position1, Main.UIScaleMatrix);
Vector2 vector2_2 = Vector2.Transform(position2, Main.UIScaleMatrix);
Rectangle rectangle = new Rectangle((int) vector2_1.X, (int) vector2_1.Y, (int) ((double) vector2_2.X - (double) vector2_1.X), (int) ((double) vector2_2.Y - (double) vector2_1.Y));
int max1 = (int) ((double) Main.screenWidth * (double) Main.UIScale);
int max2 = (int) ((double) Main.screenHeight * (double) Main.UIScale);
rectangle.X = Utils.Clamp<int>(rectangle.X, 0, max1);
rectangle.Y = Utils.Clamp<int>(rectangle.Y, 0, max2);
rectangle.Width = Utils.Clamp<int>(rectangle.Width, 0, max1 - rectangle.X);
rectangle.Height = Utils.Clamp<int>(rectangle.Height, 0, max2 - rectangle.Y);
Rectangle scissorRectangle = spriteBatch.GraphicsDevice.ScissorRectangle;
int x = Utils.Clamp<int>(rectangle.Left, scissorRectangle.Left, scissorRectangle.Right);
int y = Utils.Clamp<int>(rectangle.Top, scissorRectangle.Top, scissorRectangle.Bottom);
int num1 = Utils.Clamp<int>(rectangle.Right, scissorRectangle.Left, scissorRectangle.Right);
int num2 = Utils.Clamp<int>(rectangle.Bottom, scissorRectangle.Top, scissorRectangle.Bottom);
return new Rectangle(x, y, num1 - x, num2 - y);
}
public virtual List<SnapPoint> GetSnapPoints()
{
List<SnapPoint> snapPointList = new List<SnapPoint>();
SnapPoint point;
if (this.GetSnapPoint(out point))
snapPointList.Add(point);
foreach (UIElement element in this.Elements)
snapPointList.AddRange((IEnumerable<SnapPoint>) element.GetSnapPoints());
return snapPointList;
}
public virtual void Recalculate()
{
CalculatedStyle parentDimensions1 = this.Parent == null ? UserInterface.ActiveInstance.GetDimensions() : this.Parent.GetInnerDimensions();
if (this.Parent != null && this.Parent is UIList)
parentDimensions1.Height = float.MaxValue;
CalculatedStyle parentDimensions2 = this.GetDimensionsBasedOnParentDimensions(parentDimensions1);
this._outerDimensions = parentDimensions2;
parentDimensions2.X += this.MarginLeft;
parentDimensions2.Y += this.MarginTop;
parentDimensions2.Width -= this.MarginLeft + this.MarginRight;
parentDimensions2.Height -= this.MarginTop + this.MarginBottom;
this._dimensions = parentDimensions2;
parentDimensions2.X += this.PaddingLeft;
parentDimensions2.Y += this.PaddingTop;
parentDimensions2.Width -= this.PaddingLeft + this.PaddingRight;
parentDimensions2.Height -= this.PaddingTop + this.PaddingBottom;
this._innerDimensions = parentDimensions2;
this.RecalculateChildren();
}
private CalculatedStyle GetDimensionsBasedOnParentDimensions(
CalculatedStyle parentDimensions)
{
CalculatedStyle calculatedStyle;
calculatedStyle.X = this.Left.GetValue(parentDimensions.Width) + parentDimensions.X;
calculatedStyle.Y = this.Top.GetValue(parentDimensions.Height) + parentDimensions.Y;
float min1 = this.MinWidth.GetValue(parentDimensions.Width);
float max1 = this.MaxWidth.GetValue(parentDimensions.Width);
float min2 = this.MinHeight.GetValue(parentDimensions.Height);
float max2 = this.MaxHeight.GetValue(parentDimensions.Height);
calculatedStyle.Width = MathHelper.Clamp(this.Width.GetValue(parentDimensions.Width), min1, max1);
calculatedStyle.Height = MathHelper.Clamp(this.Height.GetValue(parentDimensions.Height), min2, max2);
calculatedStyle.Width += this.MarginLeft + this.MarginRight;
calculatedStyle.Height += this.MarginTop + this.MarginBottom;
calculatedStyle.X += (float) ((double) parentDimensions.Width * (double) this.HAlign - (double) calculatedStyle.Width * (double) this.HAlign);
calculatedStyle.Y += (float) ((double) parentDimensions.Height * (double) this.VAlign - (double) calculatedStyle.Height * (double) this.VAlign);
return calculatedStyle;
}
public UIElement GetElementAt(Vector2 point)
{
UIElement uiElement = (UIElement) null;
for (int index = this.Elements.Count - 1; index >= 0; --index)
{
UIElement element = this.Elements[index];
if (!element.IgnoresMouseInteraction && element.ContainsPoint(point))
{
uiElement = element;
break;
}
}
if (uiElement != null)
return uiElement.GetElementAt(point);
if (this.IgnoresMouseInteraction)
return (UIElement) null;
return this.ContainsPoint(point) ? this : (UIElement) null;
}
public virtual bool ContainsPoint(Vector2 point) => (double) point.X > (double) this._dimensions.X && (double) point.Y > (double) this._dimensions.Y && (double) point.X < (double) this._dimensions.X + (double) this._dimensions.Width && (double) point.Y < (double) this._dimensions.Y + (double) this._dimensions.Height;
public virtual Rectangle GetViewCullingArea() => this._dimensions.ToRectangle();
public void SetPadding(float pixels)
{
this.PaddingBottom = pixels;
this.PaddingLeft = pixels;
this.PaddingRight = pixels;
this.PaddingTop = pixels;
}
public virtual void RecalculateChildren()
{
foreach (UIElement element in this.Elements)
element.Recalculate();
}
public CalculatedStyle GetInnerDimensions() => this._innerDimensions;
public CalculatedStyle GetDimensions() => this._dimensions;
public CalculatedStyle GetOuterDimensions() => this._outerDimensions;
public void CopyStyle(UIElement element)
{
this.Top = element.Top;
this.Left = element.Left;
this.Width = element.Width;
this.Height = element.Height;
this.PaddingBottom = element.PaddingBottom;
this.PaddingLeft = element.PaddingLeft;
this.PaddingRight = element.PaddingRight;
this.PaddingTop = element.PaddingTop;
this.HAlign = element.HAlign;
this.VAlign = element.VAlign;
this.MinWidth = element.MinWidth;
this.MaxWidth = element.MaxWidth;
this.MinHeight = element.MinHeight;
this.MaxHeight = element.MaxHeight;
this.Recalculate();
}
public virtual void MouseDown(UIMouseEvent evt)
{
if (this.OnMouseDown != null)
this.OnMouseDown(evt, this);
if (this.Parent == null)
return;
this.Parent.MouseDown(evt);
}
public virtual void MouseUp(UIMouseEvent evt)
{
if (this.OnMouseUp != null)
this.OnMouseUp(evt, this);
if (this.Parent == null)
return;
this.Parent.MouseUp(evt);
}
public virtual void MouseOver(UIMouseEvent evt)
{
this.IsMouseHovering = true;
if (this.OnMouseOver != null)
this.OnMouseOver(evt, this);
if (this.Parent == null)
return;
this.Parent.MouseOver(evt);
}
public virtual void MouseOut(UIMouseEvent evt)
{
this.IsMouseHovering = false;
if (this.OnMouseOut != null)
this.OnMouseOut(evt, this);
if (this.Parent == null)
return;
this.Parent.MouseOut(evt);
}
public virtual void Click(UIMouseEvent evt)
{
if (this.OnClick != null)
this.OnClick(evt, this);
if (this.Parent == null)
return;
this.Parent.Click(evt);
}
public virtual void DoubleClick(UIMouseEvent evt)
{
if (this.OnDoubleClick != null)
this.OnDoubleClick(evt, this);
if (this.Parent == null)
return;
this.Parent.DoubleClick(evt);
}
public virtual void ScrollWheel(UIScrollWheelEvent evt)
{
if (this.OnScrollWheel != null)
this.OnScrollWheel(evt, this);
if (this.Parent == null)
return;
this.Parent.ScrollWheel(evt);
}
public void Activate()
{
if (!this._isInitialized)
this.Initialize();
this.OnActivate();
foreach (UIElement element in this.Elements)
element.Activate();
}
public virtual void OnActivate()
{
}
[Conditional("DEBUG")]
public void DrawDebugHitbox(BasicDebugDrawer drawer, float colorIntensity = 0.0f)
{
if (this.IsMouseHovering)
colorIntensity += 0.1f;
Color rgb = Main.hslToRgb(colorIntensity, colorIntensity, 0.5f);
CalculatedStyle innerDimensions = this.GetInnerDimensions();
drawer.DrawLine(innerDimensions.Position(), innerDimensions.Position() + new Vector2(innerDimensions.Width, 0.0f), 2f, rgb);
drawer.DrawLine(innerDimensions.Position() + new Vector2(innerDimensions.Width, 0.0f), innerDimensions.Position() + new Vector2(innerDimensions.Width, innerDimensions.Height), 2f, rgb);
drawer.DrawLine(innerDimensions.Position() + new Vector2(innerDimensions.Width, innerDimensions.Height), innerDimensions.Position() + new Vector2(0.0f, innerDimensions.Height), 2f, rgb);
drawer.DrawLine(innerDimensions.Position() + new Vector2(0.0f, innerDimensions.Height), innerDimensions.Position(), 2f, rgb);
foreach (UIElement element in this.Elements)
;
}
public void Deactivate()
{
this.OnDeactivate();
foreach (UIElement element in this.Elements)
element.Deactivate();
}
public virtual void OnDeactivate()
{
}
public void Initialize()
{
this.OnInitialize();
this._isInitialized = true;
}
public virtual void OnInitialize()
{
}
public virtual int CompareTo(object obj) => 0;
public delegate void MouseEvent(UIMouseEvent evt, UIElement listeningElement);
public delegate void ScrollWheelEvent(UIScrollWheelEvent evt, UIElement listeningElement);
public delegate void ElementEvent(UIElement affectedElement);
}
}

15
UI/UIEvent.cs Normal file
View file

@ -0,0 +1,15 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.UI.UIEvent
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
namespace Terraria.UI
{
public class UIEvent
{
public readonly UIElement Target;
public UIEvent(UIElement target) => this.Target = target;
}
}

21
UI/UIMouseEvent.cs Normal file
View file

@ -0,0 +1,21 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.UI.UIMouseEvent
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
namespace Terraria.UI
{
public class UIMouseEvent : UIEvent
{
public readonly Vector2 MousePosition;
public UIMouseEvent(UIElement target, Vector2 mousePosition)
: base(target)
{
this.MousePosition = mousePosition;
}
}
}

21
UI/UIScrollWheelEvent.cs Normal file
View file

@ -0,0 +1,21 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.UI.UIScrollWheelEvent
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
namespace Terraria.UI
{
public class UIScrollWheelEvent : UIMouseEvent
{
public readonly int ScrollWheelValue;
public UIScrollWheelEvent(UIElement target, Vector2 mousePosition, int scrollWheelValue)
: base(target, mousePosition)
{
this.ScrollWheelValue = scrollWheelValue;
}
}
}

18
UI/UIState.cs Normal file
View file

@ -0,0 +1,18 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.UI.UIState
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
namespace Terraria.UI
{
public class UIState : UIElement
{
public UIState()
{
this.Width.Precent = 1f;
this.Height.Precent = 1f;
this.Recalculate();
}
}
}

213
UI/UserInterface.cs Normal file
View file

@ -0,0 +1,213 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.UI.UserInterface
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Graphics;
using System;
using System.Collections.Generic;
using Terraria.GameInput;
namespace Terraria.UI
{
public class UserInterface
{
private const double DOUBLE_CLICK_TIME = 500.0;
private const double STATE_CHANGE_CLICK_DISABLE_TIME = 200.0;
private const int MAX_HISTORY_SIZE = 32;
private const int HISTORY_PRUNE_SIZE = 4;
public static UserInterface ActiveInstance = new UserInterface();
private List<UIState> _history = new List<UIState>();
public Vector2 MousePosition;
private bool _wasMouseDown;
private UIElement _lastElementHover;
private UIElement _lastElementDown;
private UIElement _lastElementClicked;
private double _lastMouseDownTime;
private double _clickDisabledTimeRemaining;
private bool _isStateDirty;
public bool IsVisible;
private UIState _currentState;
public void ResetLasts()
{
if (this._lastElementHover != null)
this._lastElementHover.MouseOut(new UIMouseEvent(this._lastElementHover, this.MousePosition));
this._lastElementHover = (UIElement) null;
this._lastElementDown = (UIElement) null;
this._lastElementClicked = (UIElement) null;
}
public void EscapeElements() => this._lastElementHover = (UIElement) null;
public UIState CurrentState => this._currentState;
public UserInterface() => UserInterface.ActiveInstance = this;
public void Use()
{
if (UserInterface.ActiveInstance != this)
{
UserInterface.ActiveInstance = this;
this.Recalculate();
}
else
UserInterface.ActiveInstance = this;
}
private void ResetState()
{
this.GetMousePosition();
this._wasMouseDown = Main.mouseLeft;
if (this._lastElementHover != null)
this._lastElementHover.MouseOut(new UIMouseEvent(this._lastElementHover, this.MousePosition));
this._lastElementHover = (UIElement) null;
this._lastElementDown = (UIElement) null;
this._lastElementClicked = (UIElement) null;
this._lastMouseDownTime = 0.0;
this._clickDisabledTimeRemaining = Math.Max(this._clickDisabledTimeRemaining, 200.0);
}
private void GetMousePosition() => this.MousePosition = new Vector2((float) Main.mouseX, (float) Main.mouseY);
public void Update(GameTime time)
{
if (this._currentState == null)
return;
this.GetMousePosition();
bool flag1 = Main.mouseLeft && Main.hasFocus;
UIElement target = Main.hasFocus ? this._currentState.GetElementAt(this.MousePosition) : (UIElement) null;
double disabledTimeRemaining = this._clickDisabledTimeRemaining;
TimeSpan timeSpan = time.ElapsedGameTime;
double totalMilliseconds = timeSpan.TotalMilliseconds;
this._clickDisabledTimeRemaining = Math.Max(0.0, disabledTimeRemaining - totalMilliseconds);
bool flag2 = this._clickDisabledTimeRemaining > 0.0;
if (target != this._lastElementHover)
{
if (this._lastElementHover != null)
this._lastElementHover.MouseOut(new UIMouseEvent(this._lastElementHover, this.MousePosition));
target?.MouseOver(new UIMouseEvent(target, this.MousePosition));
this._lastElementHover = target;
}
if (flag1 && !this._wasMouseDown && target != null && !flag2)
{
this._lastElementDown = target;
target.MouseDown(new UIMouseEvent(target, this.MousePosition));
if (this._lastElementClicked == target)
{
timeSpan = time.TotalGameTime;
if (timeSpan.TotalMilliseconds - this._lastMouseDownTime < 500.0)
{
target.DoubleClick(new UIMouseEvent(target, this.MousePosition));
this._lastElementClicked = (UIElement) null;
}
}
timeSpan = time.TotalGameTime;
this._lastMouseDownTime = timeSpan.TotalMilliseconds;
}
else if (!flag1 && this._wasMouseDown && this._lastElementDown != null && !flag2)
{
UIElement lastElementDown = this._lastElementDown;
if (lastElementDown.ContainsPoint(this.MousePosition))
{
lastElementDown.Click(new UIMouseEvent(lastElementDown, this.MousePosition));
this._lastElementClicked = this._lastElementDown;
}
lastElementDown.MouseUp(new UIMouseEvent(lastElementDown, this.MousePosition));
this._lastElementDown = (UIElement) null;
}
if (PlayerInput.ScrollWheelDeltaForUI != 0)
{
target?.ScrollWheel(new UIScrollWheelEvent(target, this.MousePosition, PlayerInput.ScrollWheelDeltaForUI));
PlayerInput.ScrollWheelDeltaForUI = 0;
}
this._wasMouseDown = flag1;
if (this._currentState == null)
return;
this._currentState.Update(time);
}
public void Draw(SpriteBatch spriteBatch, GameTime time)
{
this.Use();
if (this._currentState == null)
return;
if (this._isStateDirty)
{
this._currentState.Recalculate();
this._isStateDirty = false;
}
this._currentState.Draw(spriteBatch);
}
public void DrawDebugHitbox(BasicDebugDrawer drawer)
{
UIState currentState = this._currentState;
}
public void SetState(UIState state)
{
if (state == this._currentState)
return;
if (state != null)
this.AddToHistory(state);
if (this._currentState != null)
{
if (this._lastElementHover != null)
this._lastElementHover.MouseOut(new UIMouseEvent(this._lastElementHover, this.MousePosition));
this._currentState.Deactivate();
}
this._currentState = state;
this.ResetState();
if (state == null)
return;
this._isStateDirty = true;
state.Activate();
state.Recalculate();
}
public void GoBack()
{
if (this._history.Count < 2)
return;
UIState state = this._history[this._history.Count - 2];
this._history.RemoveRange(this._history.Count - 2, 2);
this.SetState(state);
}
private void AddToHistory(UIState state)
{
this._history.Add(state);
if (this._history.Count <= 32)
return;
this._history.RemoveRange(0, 4);
}
public void Recalculate()
{
if (this._currentState == null)
return;
this._currentState.Recalculate();
}
public CalculatedStyle GetDimensions()
{
Vector2 originalScreenSize = PlayerInput.OriginalScreenSize;
return new CalculatedStyle(0.0f, 0.0f, originalScreenSize.X / Main.UIScale, originalScreenSize.Y / Main.UIScale);
}
internal void RefreshState()
{
if (this._currentState != null)
this._currentState.Deactivate();
this.ResetState();
this._currentState.Activate();
this._currentState.Recalculate();
}
public bool IsElementUnderMouse() => this.IsVisible && this._lastElementHover != null && !(this._lastElementHover is UIState);
}
}