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

View file

@ -0,0 +1,116 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.BigProgressBar.BigProgressBarHelper
// 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;
namespace Terraria.GameContent.UI.BigProgressBar
{
public class BigProgressBarHelper
{
private const string _bossBarTexturePath = "Images/UI/UI_BossBar";
public static void DrawBareBonesBar(SpriteBatch spriteBatch, float lifePercent)
{
Rectangle destinationRectangle1 = Utils.CenteredRectangle(Main.ScreenSize.ToVector2() * new Vector2(0.5f, 1f) + new Vector2(0.0f, -50f), new Vector2(400f, 20f));
Rectangle destinationRectangle2 = destinationRectangle1;
destinationRectangle2.Inflate(2, 2);
Texture2D texture = TextureAssets.MagicPixel.Value;
Rectangle rectangle = new Rectangle(0, 0, 1, 1);
Rectangle destinationRectangle3 = destinationRectangle1;
destinationRectangle3.Width = (int) ((double) destinationRectangle3.Width * (double) lifePercent);
spriteBatch.Draw(texture, destinationRectangle2, new Rectangle?(rectangle), Color.White * 0.6f);
spriteBatch.Draw(texture, destinationRectangle1, new Rectangle?(rectangle), Color.Black * 0.6f);
spriteBatch.Draw(texture, destinationRectangle3, new Rectangle?(rectangle), Color.LimeGreen * 0.5f);
}
public static void DrawFancyBar(
SpriteBatch spriteBatch,
float lifePercent,
Texture2D barIconTexture,
Rectangle barIconFrame)
{
Texture2D texture2D = Main.Assets.Request<Texture2D>("Images/UI/UI_BossBar", (AssetRequestMode) 1).Value;
Point p1 = new Point(456, 22);
Point p2 = new Point(32, 24);
int verticalFrames = 6;
Rectangle rectangle1 = texture2D.Frame(verticalFrames: verticalFrames, frameY: 3);
Color color = Color.White * 0.2f;
int num1 = (int) ((double) p1.X * (double) lifePercent);
int num2 = num1 - num1 % 2;
Rectangle rectangle2 = texture2D.Frame(verticalFrames: verticalFrames, frameY: 2);
rectangle2.X += p2.X;
rectangle2.Y += p2.Y;
rectangle2.Width = 2;
rectangle2.Height = p1.Y;
Rectangle rectangle3 = texture2D.Frame(verticalFrames: verticalFrames, frameY: 1);
rectangle3.X += p2.X;
rectangle3.Y += p2.Y;
rectangle3.Width = 2;
rectangle3.Height = p1.Y;
Rectangle r = Utils.CenteredRectangle(Main.ScreenSize.ToVector2() * new Vector2(0.5f, 1f) + new Vector2(0.0f, -50f), p1.ToVector2());
Vector2 position = r.TopLeft() - p2.ToVector2();
spriteBatch.Draw(texture2D, position, new Rectangle?(rectangle1), color, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f);
spriteBatch.Draw(texture2D, r.TopLeft(), new Rectangle?(rectangle2), Color.White, 0.0f, Vector2.Zero, new Vector2((float) (num2 / rectangle2.Width), 1f), SpriteEffects.None, 0.0f);
spriteBatch.Draw(texture2D, r.TopLeft() + new Vector2((float) (num2 - 2), 0.0f), new Rectangle?(rectangle3), Color.White, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f);
Rectangle rectangle4 = texture2D.Frame(verticalFrames: verticalFrames);
spriteBatch.Draw(texture2D, position, new Rectangle?(rectangle4), Color.White, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f);
Vector2 vector2 = new Vector2(4f, 20f) + new Vector2(26f, 28f) / 2f;
spriteBatch.Draw(barIconTexture, position + vector2, new Rectangle?(barIconFrame), Color.White, 0.0f, barIconFrame.Size() / 2f, 1f, SpriteEffects.None, 0.0f);
}
public static void DrawFancyBar(
SpriteBatch spriteBatch,
float lifePercent,
Texture2D barIconTexture,
Rectangle barIconFrame,
float shieldPercent)
{
Texture2D texture2D = Main.Assets.Request<Texture2D>("Images/UI/UI_BossBar", (AssetRequestMode) 1).Value;
Point p1 = new Point(456, 22);
Point p2 = new Point(32, 24);
int verticalFrames = 6;
Rectangle rectangle1 = texture2D.Frame(verticalFrames: verticalFrames, frameY: 3);
Color color = Color.White * 0.2f;
int num1 = (int) ((double) p1.X * (double) lifePercent);
int num2 = num1 - num1 % 2;
Rectangle rectangle2 = texture2D.Frame(verticalFrames: verticalFrames, frameY: 2);
rectangle2.X += p2.X;
rectangle2.Y += p2.Y;
rectangle2.Width = 2;
rectangle2.Height = p1.Y;
Rectangle rectangle3 = texture2D.Frame(verticalFrames: verticalFrames, frameY: 1);
rectangle3.X += p2.X;
rectangle3.Y += p2.Y;
rectangle3.Width = 2;
rectangle3.Height = p1.Y;
int num3 = (int) ((double) p1.X * (double) shieldPercent);
int num4 = num3 - num3 % 2;
Rectangle rectangle4 = texture2D.Frame(verticalFrames: verticalFrames, frameY: 5);
rectangle4.X += p2.X;
rectangle4.Y += p2.Y;
rectangle4.Width = 2;
rectangle4.Height = p1.Y;
Rectangle rectangle5 = texture2D.Frame(verticalFrames: verticalFrames, frameY: 4);
rectangle5.X += p2.X;
rectangle5.Y += p2.Y;
rectangle5.Width = 2;
rectangle5.Height = p1.Y;
Rectangle r = Utils.CenteredRectangle(Main.ScreenSize.ToVector2() * new Vector2(0.5f, 1f) + new Vector2(0.0f, -50f), p1.ToVector2());
Vector2 position = r.TopLeft() - p2.ToVector2();
spriteBatch.Draw(texture2D, position, new Rectangle?(rectangle1), color, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f);
spriteBatch.Draw(texture2D, r.TopLeft(), new Rectangle?(rectangle2), Color.White, 0.0f, Vector2.Zero, new Vector2((float) (num2 / rectangle2.Width), 1f), SpriteEffects.None, 0.0f);
spriteBatch.Draw(texture2D, r.TopLeft() + new Vector2((float) (num2 - 2), 0.0f), new Rectangle?(rectangle3), Color.White, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f);
spriteBatch.Draw(texture2D, r.TopLeft(), new Rectangle?(rectangle4), Color.White, 0.0f, Vector2.Zero, new Vector2((float) (num4 / rectangle4.Width), 1f), SpriteEffects.None, 0.0f);
spriteBatch.Draw(texture2D, r.TopLeft() + new Vector2((float) (num4 - 2), 0.0f), new Rectangle?(rectangle5), Color.White, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f);
Rectangle rectangle6 = texture2D.Frame(verticalFrames: verticalFrames);
spriteBatch.Draw(texture2D, position, new Rectangle?(rectangle6), Color.White, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f);
Vector2 vector2 = new Vector2(4f, 20f) + barIconFrame.Size() / 2f;
spriteBatch.Draw(barIconTexture, position + vector2, new Rectangle?(barIconFrame), Color.White, 0.0f, barIconFrame.Size() / 2f, 1f, SpriteEffects.None, 0.0f);
}
}
}

View file

@ -0,0 +1,14 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.BigProgressBar.BigProgressBarInfo
// 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.GameContent.UI.BigProgressBar
{
public struct BigProgressBarInfo
{
public int npcIndexToAimAt;
public bool validatedAtLeastOnce;
}
}

View file

@ -0,0 +1,185 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.BigProgressBar.BigProgressBarSystem
// 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;
namespace Terraria.GameContent.UI.BigProgressBar
{
public class BigProgressBarSystem
{
private IBigProgressBar _currentBar;
private CommonBossBigProgressBar _bossBar = new CommonBossBigProgressBar();
private BigProgressBarInfo _info;
private static TwinsBigProgressBar _twinsBar = new TwinsBigProgressBar();
private static EaterOfWorldsProgressBar _eaterOfWorldsBar = new EaterOfWorldsProgressBar();
private static BrainOfCthuluBigProgressBar _brainOfCthuluBar = new BrainOfCthuluBigProgressBar();
private static GolemHeadProgressBar _golemBar = new GolemHeadProgressBar();
private static MoonLordProgressBar _moonlordBar = new MoonLordProgressBar();
private static SolarFlarePillarBigProgressBar _solarPillarBar = new SolarFlarePillarBigProgressBar();
private static VortexPillarBigProgressBar _vortexPillarBar = new VortexPillarBigProgressBar();
private static NebulaPillarBigProgressBar _nebulaPillarBar = new NebulaPillarBigProgressBar();
private static StardustPillarBigProgressBar _stardustPillarBar = new StardustPillarBigProgressBar();
private static NeverValidProgressBar _neverValid = new NeverValidProgressBar();
private static PirateShipBigProgressBar _pirateShipBar = new PirateShipBigProgressBar();
private static MartianSaucerBigProgressBar _martianSaucerBar = new MartianSaucerBigProgressBar();
private Dictionary<int, IBigProgressBar> _bossBarsByNpcNetId = new Dictionary<int, IBigProgressBar>()
{
{
125,
(IBigProgressBar) BigProgressBarSystem._twinsBar
},
{
126,
(IBigProgressBar) BigProgressBarSystem._twinsBar
},
{
13,
(IBigProgressBar) BigProgressBarSystem._eaterOfWorldsBar
},
{
14,
(IBigProgressBar) BigProgressBarSystem._eaterOfWorldsBar
},
{
15,
(IBigProgressBar) BigProgressBarSystem._eaterOfWorldsBar
},
{
266,
(IBigProgressBar) BigProgressBarSystem._brainOfCthuluBar
},
{
245,
(IBigProgressBar) BigProgressBarSystem._golemBar
},
{
246,
(IBigProgressBar) BigProgressBarSystem._golemBar
},
{
517,
(IBigProgressBar) BigProgressBarSystem._solarPillarBar
},
{
422,
(IBigProgressBar) BigProgressBarSystem._vortexPillarBar
},
{
507,
(IBigProgressBar) BigProgressBarSystem._nebulaPillarBar
},
{
493,
(IBigProgressBar) BigProgressBarSystem._stardustPillarBar
},
{
398,
(IBigProgressBar) BigProgressBarSystem._moonlordBar
},
{
396,
(IBigProgressBar) BigProgressBarSystem._moonlordBar
},
{
397,
(IBigProgressBar) BigProgressBarSystem._moonlordBar
},
{
548,
(IBigProgressBar) BigProgressBarSystem._neverValid
},
{
549,
(IBigProgressBar) BigProgressBarSystem._neverValid
},
{
491,
(IBigProgressBar) BigProgressBarSystem._pirateShipBar
},
{
492,
(IBigProgressBar) BigProgressBarSystem._pirateShipBar
},
{
440,
(IBigProgressBar) BigProgressBarSystem._neverValid
},
{
395,
(IBigProgressBar) BigProgressBarSystem._martianSaucerBar
},
{
393,
(IBigProgressBar) BigProgressBarSystem._martianSaucerBar
},
{
394,
(IBigProgressBar) BigProgressBarSystem._martianSaucerBar
},
{
68,
(IBigProgressBar) BigProgressBarSystem._neverValid
}
};
public void Update()
{
if (this._currentBar == null)
this.TryFindingNPCToTrack();
if (this._currentBar == null || this._currentBar.ValidateAndCollectNecessaryInfo(ref this._info))
return;
this._currentBar = (IBigProgressBar) null;
}
public void Draw(SpriteBatch spriteBatch)
{
if (this._currentBar == null)
return;
this._currentBar.Draw(ref this._info, spriteBatch);
}
private void TryFindingNPCToTrack()
{
Rectangle rectangle = new Rectangle((int) Main.screenPosition.X, (int) Main.screenPosition.Y, Main.screenWidth, Main.screenHeight);
rectangle.Inflate(5000, 5000);
float num1 = float.PositiveInfinity;
for (int npcIndex = 0; npcIndex < 200; ++npcIndex)
{
NPC npc = Main.npc[npcIndex];
if (npc.active && npc.Hitbox.Intersects(rectangle))
{
float num2 = npc.Distance(Main.LocalPlayer.Center);
if ((double) num1 > (double) num2 && this.TryTracking(npcIndex))
num1 = num2;
}
}
}
public bool TryTracking(int npcIndex)
{
if (npcIndex < 0 || npcIndex > 200)
return false;
NPC npc = Main.npc[npcIndex];
if (!npc.active)
return false;
BigProgressBarInfo info = new BigProgressBarInfo()
{
npcIndexToAimAt = npcIndex
};
IBigProgressBar bigProgressBar1 = (IBigProgressBar) this._bossBar;
IBigProgressBar bigProgressBar2;
if (this._bossBarsByNpcNetId.TryGetValue(npc.netID, out bigProgressBar2))
bigProgressBar1 = bigProgressBar2;
if (!bigProgressBar1.ValidateAndCollectNecessaryInfo(ref info))
return false;
this._currentBar = bigProgressBar1;
this._info = info;
return true;
}
}
}

View file

@ -0,0 +1,49 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.BigProgressBar.BrainOfCthuluBigProgressBar
// 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 Terraria.ID;
namespace Terraria.GameContent.UI.BigProgressBar
{
public class BrainOfCthuluBigProgressBar : IBigProgressBar
{
private float _lifePercentToShow;
private NPC _creeperForReference;
public BrainOfCthuluBigProgressBar() => this._creeperForReference = new NPC();
public bool ValidateAndCollectNecessaryInfo(ref BigProgressBarInfo info)
{
if (info.npcIndexToAimAt < 0 || info.npcIndexToAimAt > 200)
return false;
NPC npc1 = Main.npc[info.npcIndexToAimAt];
if (!npc1.active)
return false;
int cthuluCreepersCount = NPC.GetBrainOfCthuluCreepersCount();
this._creeperForReference.SetDefaults(267, npc1.GetMatchingSpawnParams());
int num1 = this._creeperForReference.lifeMax * cthuluCreepersCount;
float num2 = 0.0f;
for (int index = 0; index < 200; ++index)
{
NPC npc2 = Main.npc[index];
if (npc2.active && npc2.type == this._creeperForReference.type)
num2 += (float) npc2.life;
}
this._lifePercentToShow = Utils.Clamp<float>(((float) npc1.life + num2) / (float) (npc1.lifeMax + num1), 0.0f, 1f);
return true;
}
public void Draw(ref BigProgressBarInfo info, SpriteBatch spriteBatch)
{
int bossHeadTexture = NPCID.Sets.BossHeadTextures[266];
Texture2D texture2D = TextureAssets.NpcHeadBoss[bossHeadTexture].Value;
Rectangle barIconFrame = texture2D.Frame();
BigProgressBarHelper.DrawFancyBar(spriteBatch, this._lifePercentToShow, texture2D, barIconFrame);
}
}
}

View file

@ -0,0 +1,39 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.BigProgressBar.CommonBossBigProgressBar
// 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.GameContent.UI.BigProgressBar
{
public class CommonBossBigProgressBar : IBigProgressBar
{
private float _lifePercentToShow;
private int _headIndex;
public bool ValidateAndCollectNecessaryInfo(ref BigProgressBarInfo info)
{
if (info.npcIndexToAimAt < 0 || info.npcIndexToAimAt > 200)
return false;
NPC npc = Main.npc[info.npcIndexToAimAt];
if (!npc.active)
return false;
int headTextureIndex = npc.GetBossHeadTextureIndex();
if (headTextureIndex == -1)
return false;
this._lifePercentToShow = Utils.Clamp<float>((float) npc.life / (float) npc.lifeMax, 0.0f, 1f);
this._headIndex = headTextureIndex;
return true;
}
public void Draw(ref BigProgressBarInfo info, SpriteBatch spriteBatch)
{
Texture2D texture2D = TextureAssets.NpcHeadBoss[this._headIndex].Value;
Rectangle barIconFrame = texture2D.Frame();
BigProgressBarHelper.DrawFancyBar(spriteBatch, this._lifePercentToShow, texture2D, barIconFrame);
}
}
}

View file

@ -0,0 +1,55 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.BigProgressBar.EaterOfWorldsProgressBar
// 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 Terraria.ID;
namespace Terraria.GameContent.UI.BigProgressBar
{
public class EaterOfWorldsProgressBar : IBigProgressBar
{
private float _lifePercentToShow;
public bool ValidateAndCollectNecessaryInfo(ref BigProgressBarInfo info)
{
if (info.npcIndexToAimAt < 0 || info.npcIndexToAimAt > 200 || !Main.npc[info.npcIndexToAimAt].active && !this.TryFindingAnotherEOWPiece(ref info))
return false;
int worldsSegmentsCount = NPC.GetEaterOfWorldsSegmentsCount();
float num = 0.0f;
for (int index = 0; index < 200; ++index)
{
NPC npc = Main.npc[index];
if (npc.active && npc.type >= 13 && npc.type <= 15)
num += (float) npc.life / (float) npc.lifeMax;
}
this._lifePercentToShow = Utils.Clamp<float>(num / (float) worldsSegmentsCount, 0.0f, 1f);
return true;
}
public void Draw(ref BigProgressBarInfo info, SpriteBatch spriteBatch)
{
int bossHeadTexture = NPCID.Sets.BossHeadTextures[13];
Texture2D texture2D = TextureAssets.NpcHeadBoss[bossHeadTexture].Value;
Rectangle barIconFrame = texture2D.Frame();
BigProgressBarHelper.DrawFancyBar(spriteBatch, this._lifePercentToShow, texture2D, barIconFrame);
}
private bool TryFindingAnotherEOWPiece(ref BigProgressBarInfo info)
{
for (int index = 0; index < 200; ++index)
{
NPC npc = Main.npc[index];
if (npc.active && npc.type >= 13 && npc.type <= 15)
{
info.npcIndexToAimAt = index;
return true;
}
}
return false;
}
}
}

View file

@ -0,0 +1,71 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.BigProgressBar.GolemHeadProgressBar
// 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.ID;
namespace Terraria.GameContent.UI.BigProgressBar
{
public class GolemHeadProgressBar : IBigProgressBar
{
private float _lifePercentToShow;
private NPC _referenceDummy;
private HashSet<int> ValidIds = new HashSet<int>()
{
246,
245
};
public GolemHeadProgressBar() => this._referenceDummy = new NPC();
public bool ValidateAndCollectNecessaryInfo(ref BigProgressBarInfo info)
{
if (info.npcIndexToAimAt < 0 || info.npcIndexToAimAt > 200)
return false;
NPC npc1 = Main.npc[info.npcIndexToAimAt];
if (!npc1.active && !this.TryFindingAnotherGolemPiece(ref info))
return false;
int num1 = 0;
this._referenceDummy.SetDefaults(245, npc1.GetMatchingSpawnParams());
int num2 = num1 + this._referenceDummy.lifeMax;
this._referenceDummy.SetDefaults(246, npc1.GetMatchingSpawnParams());
int num3 = num2 + this._referenceDummy.lifeMax;
float num4 = 0.0f;
for (int index = 0; index < 200; ++index)
{
NPC npc2 = Main.npc[index];
if (npc2.active && this.ValidIds.Contains(npc2.type))
num4 += (float) npc2.life;
}
this._lifePercentToShow = Utils.Clamp<float>(num4 / (float) num3, 0.0f, 1f);
return true;
}
public void Draw(ref BigProgressBarInfo info, SpriteBatch spriteBatch)
{
int bossHeadTexture = NPCID.Sets.BossHeadTextures[246];
Texture2D texture2D = TextureAssets.NpcHeadBoss[bossHeadTexture].Value;
Rectangle barIconFrame = texture2D.Frame();
BigProgressBarHelper.DrawFancyBar(spriteBatch, this._lifePercentToShow, texture2D, barIconFrame);
}
private bool TryFindingAnotherGolemPiece(ref BigProgressBarInfo info)
{
for (int index = 0; index < 200; ++index)
{
NPC npc = Main.npc[index];
if (npc.active && this.ValidIds.Contains(npc.type))
{
info.npcIndexToAimAt = index;
return true;
}
}
return false;
}
}
}

View file

@ -0,0 +1,17 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.BigProgressBar.IBigProgressBar
// 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.GameContent.UI.BigProgressBar
{
internal interface IBigProgressBar
{
bool ValidateAndCollectNecessaryInfo(ref BigProgressBarInfo info);
void Draw(ref BigProgressBarInfo info, SpriteBatch spriteBatch);
}
}

View file

@ -0,0 +1,50 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.BigProgressBar.LunarPillarBigProgessBar
// 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.GameContent.UI.BigProgressBar
{
public abstract class LunarPillarBigProgessBar : IBigProgressBar
{
private float _lifePercentToShow;
private float _shieldPercentToShow;
private int _headIndex;
public bool ValidateAndCollectNecessaryInfo(ref BigProgressBarInfo info)
{
if (info.npcIndexToAimAt < 0 || info.npcIndexToAimAt > 200)
return false;
NPC npc = Main.npc[info.npcIndexToAimAt];
if (!npc.active)
return false;
int headTextureIndex = npc.GetBossHeadTextureIndex();
if (headTextureIndex == -1 || !this.IsPlayerInCombatArea() || (double) npc.ai[2] == 1.0)
return false;
float num1 = Utils.Clamp<float>((float) npc.life / (float) npc.lifeMax, 0.0f, 1f);
float num2 = this.GetCurrentShieldValue() / this.GetMaxShieldValue();
double num3 = 600.0 * (double) Main.GameModeInfo.EnemyMaxLifeMultiplier * (double) this.GetMaxShieldValue() / (double) npc.lifeMax;
this._lifePercentToShow = num1;
this._shieldPercentToShow = num2;
this._headIndex = headTextureIndex;
return true;
}
public void Draw(ref BigProgressBarInfo info, SpriteBatch spriteBatch)
{
Texture2D texture2D = TextureAssets.NpcHeadBoss[this._headIndex].Value;
Rectangle barIconFrame = texture2D.Frame();
BigProgressBarHelper.DrawFancyBar(spriteBatch, this._lifePercentToShow, texture2D, barIconFrame, this._shieldPercentToShow);
}
internal abstract float GetCurrentShieldValue();
internal abstract float GetMaxShieldValue();
internal abstract bool IsPlayerInCombatArea();
}
}

View file

@ -0,0 +1,85 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.BigProgressBar.MartianSaucerBigProgressBar
// 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.ID;
namespace Terraria.GameContent.UI.BigProgressBar
{
public class MartianSaucerBigProgressBar : IBigProgressBar
{
private float _lifePercentToShow;
private NPC _referenceDummy;
private HashSet<int> ValidIds = new HashSet<int>()
{
395
};
private HashSet<int> ValidIdsToScanHp = new HashSet<int>()
{
395,
393,
394
};
public MartianSaucerBigProgressBar() => this._referenceDummy = new NPC();
public bool ValidateAndCollectNecessaryInfo(ref BigProgressBarInfo info)
{
if (info.npcIndexToAimAt < 0 || info.npcIndexToAimAt > 200)
return false;
NPC npc1 = Main.npc[info.npcIndexToAimAt];
if (!npc1.active || npc1.type != 395)
{
if (!this.TryFindingAnotherMartianSaucerPiece(ref info))
return false;
npc1 = Main.npc[info.npcIndexToAimAt];
}
int num1 = 0;
if (Main.expertMode)
{
this._referenceDummy.SetDefaults(395, npc1.GetMatchingSpawnParams());
num1 += this._referenceDummy.lifeMax;
}
this._referenceDummy.SetDefaults(394, npc1.GetMatchingSpawnParams());
int num2 = num1 + this._referenceDummy.lifeMax * 2;
this._referenceDummy.SetDefaults(393, npc1.GetMatchingSpawnParams());
int num3 = num2 + this._referenceDummy.lifeMax * 2;
float num4 = 0.0f;
for (int index = 0; index < 200; ++index)
{
NPC npc2 = Main.npc[index];
if (npc2.active && this.ValidIdsToScanHp.Contains(npc2.type) && (Main.expertMode || npc2.type != 395))
num4 += (float) npc2.life;
}
this._lifePercentToShow = Utils.Clamp<float>(num4 / (float) num3, 0.0f, 1f);
return true;
}
public void Draw(ref BigProgressBarInfo info, SpriteBatch spriteBatch)
{
int bossHeadTexture = NPCID.Sets.BossHeadTextures[395];
Texture2D texture2D = TextureAssets.NpcHeadBoss[bossHeadTexture].Value;
Rectangle barIconFrame = texture2D.Frame();
BigProgressBarHelper.DrawFancyBar(spriteBatch, this._lifePercentToShow, texture2D, barIconFrame);
}
private bool TryFindingAnotherMartianSaucerPiece(ref BigProgressBarInfo info)
{
for (int index = 0; index < 200; ++index)
{
NPC npc = Main.npc[index];
if (npc.active && this.ValidIds.Contains(npc.type))
{
info.npcIndexToAimAt = index;
return true;
}
}
return false;
}
}
}

View file

@ -0,0 +1,81 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.BigProgressBar.MoonLordProgressBar
// 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.ID;
namespace Terraria.GameContent.UI.BigProgressBar
{
public class MoonLordProgressBar : IBigProgressBar
{
private float _lifePercentToShow;
private NPC _referenceDummy;
private HashSet<int> ValidIds = new HashSet<int>()
{
396,
397,
398
};
public MoonLordProgressBar() => this._referenceDummy = new NPC();
public bool ValidateAndCollectNecessaryInfo(ref BigProgressBarInfo info)
{
if (info.npcIndexToAimAt < 0 || info.npcIndexToAimAt > 200)
return false;
NPC npc1 = Main.npc[info.npcIndexToAimAt];
if ((!npc1.active || this.IsInBadAI(npc1)) && !this.TryFindingAnotherMoonLordPiece(ref info))
return false;
int num1 = 0;
NPCSpawnParams spawnparams = new NPCSpawnParams()
{
strengthMultiplierOverride = new float?(npc1.strengthMultiplier),
playerCountForMultiplayerDifficultyOverride = new int?(npc1.statsAreScaledForThisManyPlayers)
};
this._referenceDummy.SetDefaults(398, spawnparams);
int num2 = num1 + this._referenceDummy.lifeMax;
this._referenceDummy.SetDefaults(396, spawnparams);
int num3 = num2 + this._referenceDummy.lifeMax;
this._referenceDummy.SetDefaults(397, spawnparams);
int num4 = num3 + this._referenceDummy.lifeMax + this._referenceDummy.lifeMax;
float num5 = 0.0f;
for (int index = 0; index < 200; ++index)
{
NPC npc2 = Main.npc[index];
if (npc2.active && this.ValidIds.Contains(npc2.type) && !this.IsInBadAI(npc2))
num5 += (float) npc2.life;
}
this._lifePercentToShow = Utils.Clamp<float>(num5 / (float) num4, 0.0f, 1f);
return true;
}
private bool IsInBadAI(NPC npc) => npc.type == 398 && ((double) npc.ai[0] == 2.0 || (double) npc.ai[0] == -1.0) || (double) npc.ai[0] == -2.0 || (double) npc.ai[0] == -3.0;
public void Draw(ref BigProgressBarInfo info, SpriteBatch spriteBatch)
{
int bossHeadTexture = NPCID.Sets.BossHeadTextures[396];
Texture2D texture2D = TextureAssets.NpcHeadBoss[bossHeadTexture].Value;
Rectangle barIconFrame = texture2D.Frame();
BigProgressBarHelper.DrawFancyBar(spriteBatch, this._lifePercentToShow, texture2D, barIconFrame);
}
private bool TryFindingAnotherMoonLordPiece(ref BigProgressBarInfo info)
{
for (int index = 0; index < 200; ++index)
{
NPC npc = Main.npc[index];
if (npc.active && this.ValidIds.Contains(npc.type) && !this.IsInBadAI(npc))
{
info.npcIndexToAimAt = index;
return true;
}
}
return false;
}
}
}

View file

@ -0,0 +1,17 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.BigProgressBar.NebulaPillarBigProgressBar
// 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.GameContent.UI.BigProgressBar
{
public class NebulaPillarBigProgressBar : LunarPillarBigProgessBar
{
internal override float GetCurrentShieldValue() => (float) NPC.ShieldStrengthTowerNebula;
internal override float GetMaxShieldValue() => (float) NPC.ShieldStrengthTowerMax;
internal override bool IsPlayerInCombatArea() => Main.LocalPlayer.ZoneTowerNebula;
}
}

View file

@ -0,0 +1,19 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.BigProgressBar.NeverValidProgressBar
// 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.GameContent.UI.BigProgressBar
{
public class NeverValidProgressBar : IBigProgressBar
{
public bool ValidateAndCollectNecessaryInfo(ref BigProgressBarInfo info) => false;
public void Draw(ref BigProgressBarInfo info, SpriteBatch spriteBatch)
{
}
}
}

View file

@ -0,0 +1,76 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.BigProgressBar.PirateShipBigProgressBar
// 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.ID;
namespace Terraria.GameContent.UI.BigProgressBar
{
public class PirateShipBigProgressBar : IBigProgressBar
{
private float _lifePercentToShow;
private NPC _referenceDummy;
private HashSet<int> ValidIds = new HashSet<int>()
{
491
};
public PirateShipBigProgressBar() => this._referenceDummy = new NPC();
public bool ValidateAndCollectNecessaryInfo(ref BigProgressBarInfo info)
{
if (info.npcIndexToAimAt < 0 || info.npcIndexToAimAt > 200)
return false;
NPC npc1 = Main.npc[info.npcIndexToAimAt];
if (!npc1.active || npc1.type != 491)
{
if (!this.TryFindingAnotherPirateShipPiece(ref info))
return false;
npc1 = Main.npc[info.npcIndexToAimAt];
}
int num1 = 0;
this._referenceDummy.SetDefaults(492, npc1.GetMatchingSpawnParams());
int num2 = num1 + this._referenceDummy.lifeMax * 4;
float num3 = 0.0f;
for (int index1 = 0; index1 < 4; ++index1)
{
int index2 = (int) npc1.ai[index1];
if (Main.npc.IndexInRange<NPC>(index2))
{
NPC npc2 = Main.npc[index2];
if (npc2.active && npc2.type == 492)
num3 += (float) npc2.life;
}
}
this._lifePercentToShow = Utils.Clamp<float>(num3 / (float) num2, 0.0f, 1f);
return true;
}
public void Draw(ref BigProgressBarInfo info, SpriteBatch spriteBatch)
{
int bossHeadTexture = NPCID.Sets.BossHeadTextures[491];
Texture2D texture2D = TextureAssets.NpcHeadBoss[bossHeadTexture].Value;
Rectangle barIconFrame = texture2D.Frame();
BigProgressBarHelper.DrawFancyBar(spriteBatch, this._lifePercentToShow, texture2D, barIconFrame);
}
private bool TryFindingAnotherPirateShipPiece(ref BigProgressBarInfo info)
{
for (int index = 0; index < 200; ++index)
{
NPC npc = Main.npc[index];
if (npc.active && this.ValidIds.Contains(npc.type))
{
info.npcIndexToAimAt = index;
return true;
}
}
return false;
}
}
}

View file

@ -0,0 +1,17 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.BigProgressBar.SolarFlarePillarBigProgressBar
// 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.GameContent.UI.BigProgressBar
{
public class SolarFlarePillarBigProgressBar : LunarPillarBigProgessBar
{
internal override float GetCurrentShieldValue() => (float) NPC.ShieldStrengthTowerSolar;
internal override float GetMaxShieldValue() => (float) NPC.ShieldStrengthTowerMax;
internal override bool IsPlayerInCombatArea() => Main.LocalPlayer.ZoneTowerSolar;
}
}

View file

@ -0,0 +1,17 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.BigProgressBar.StardustPillarBigProgressBar
// 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.GameContent.UI.BigProgressBar
{
public class StardustPillarBigProgressBar : LunarPillarBigProgessBar
{
internal override float GetCurrentShieldValue() => (float) NPC.ShieldStrengthTowerStardust;
internal override float GetMaxShieldValue() => (float) NPC.ShieldStrengthTowerMax;
internal override bool IsPlayerInCombatArea() => Main.LocalPlayer.ZoneTowerStardust;
}
}

View file

@ -0,0 +1,49 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.BigProgressBar.TwinsBigProgressBar
// 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.GameContent.UI.BigProgressBar
{
public class TwinsBigProgressBar : IBigProgressBar
{
private float _lifePercentToShow;
private int _headIndex;
public bool ValidateAndCollectNecessaryInfo(ref BigProgressBarInfo info)
{
if (info.npcIndexToAimAt < 0 || info.npcIndexToAimAt > 200)
return false;
NPC npc1 = Main.npc[info.npcIndexToAimAt];
if (!npc1.active)
return false;
int num = npc1.type == 126 ? 125 : 126;
int lifeMax = npc1.lifeMax;
int life = npc1.life;
for (int index = 0; index < 200; ++index)
{
NPC npc2 = Main.npc[index];
if (npc2.active && npc2.type == num)
{
lifeMax += npc2.lifeMax;
life += npc2.life;
break;
}
}
this._lifePercentToShow = Utils.Clamp<float>((float) life / (float) lifeMax, 0.0f, 1f);
this._headIndex = npc1.GetBossHeadTextureIndex();
return true;
}
public void Draw(ref BigProgressBarInfo info, SpriteBatch spriteBatch)
{
Texture2D texture2D = TextureAssets.NpcHeadBoss[this._headIndex].Value;
Rectangle barIconFrame = texture2D.Frame();
BigProgressBarHelper.DrawFancyBar(spriteBatch, this._lifePercentToShow, texture2D, barIconFrame);
}
}
}

View file

@ -0,0 +1,17 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.BigProgressBar.VortexPillarBigProgressBar
// 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.GameContent.UI.BigProgressBar
{
public class VortexPillarBigProgressBar : LunarPillarBigProgessBar
{
internal override float GetCurrentShieldValue() => (float) NPC.ShieldStrengthTowerVortex;
internal override float GetMaxShieldValue() => (float) NPC.ShieldStrengthTowerMax;
internal override bool IsPlayerInCombatArea() => Main.LocalPlayer.ZoneTowerVortex;
}
}

View file

@ -0,0 +1,45 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Chat.AchievementTagHandler
// 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;
using Terraria.UI;
using Terraria.UI.Chat;
namespace Terraria.GameContent.UI.Chat
{
public class AchievementTagHandler : ITagHandler
{
TextSnippet ITagHandler.Parse(
string text,
Color baseColor,
string options)
{
Achievement achievement = Main.Achievements.GetAchievement(text);
return achievement == null ? new TextSnippet(text) : (TextSnippet) new AchievementTagHandler.AchievementSnippet(achievement);
}
public static string GenerateTag(Achievement achievement) => "[a:" + achievement.Name + "]";
private class AchievementSnippet : TextSnippet
{
private Achievement _achievement;
public AchievementSnippet(Achievement achievement)
: base(achievement.FriendlyName.Value, Color.LightBlue)
{
this.CheckForHover = true;
this._achievement = achievement;
}
public override void OnClick()
{
IngameOptions.Close();
IngameFancyUI.OpenAchievementsAndGoto(this._achievement);
}
}
}
}

View file

@ -0,0 +1,29 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Chat.ColorTagHandler
// 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.Globalization;
using Terraria.UI.Chat;
namespace Terraria.GameContent.UI.Chat
{
public class ColorTagHandler : ITagHandler
{
TextSnippet ITagHandler.Parse(
string text,
Color baseColor,
string options)
{
TextSnippet textSnippet = new TextSnippet(text);
int result;
if (!int.TryParse(options, NumberStyles.AllowHexSpecifier, (IFormatProvider) CultureInfo.InvariantCulture, out result))
return textSnippet;
textSnippet.Color = new Color(result >> 16 & (int) byte.MaxValue, result >> 8 & (int) byte.MaxValue, result & (int) byte.MaxValue);
return textSnippet;
}
}
}

View file

@ -0,0 +1,181 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Chat.GlyphTagHandler
// 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 Microsoft.Xna.Framework.Input;
using ReLogic.Graphics;
using System.Collections.Generic;
using Terraria.UI.Chat;
namespace Terraria.GameContent.UI.Chat
{
public class GlyphTagHandler : ITagHandler
{
private const int GlyphsPerLine = 25;
private const int MaxGlyphs = 26;
public static float GlyphsScale = 1f;
private static Dictionary<string, int> GlyphIndexes = new Dictionary<string, int>()
{
{
Buttons.A.ToString(),
0
},
{
Buttons.B.ToString(),
1
},
{
Buttons.Back.ToString(),
4
},
{
Buttons.DPadDown.ToString(),
15
},
{
Buttons.DPadLeft.ToString(),
14
},
{
Buttons.DPadRight.ToString(),
13
},
{
Buttons.DPadUp.ToString(),
16
},
{
Buttons.LeftShoulder.ToString(),
6
},
{
Buttons.LeftStick.ToString(),
10
},
{
Buttons.LeftThumbstickDown.ToString(),
20
},
{
Buttons.LeftThumbstickLeft.ToString(),
17
},
{
Buttons.LeftThumbstickRight.ToString(),
18
},
{
Buttons.LeftThumbstickUp.ToString(),
19
},
{
Buttons.LeftTrigger.ToString(),
8
},
{
Buttons.RightShoulder.ToString(),
7
},
{
Buttons.RightStick.ToString(),
11
},
{
Buttons.RightThumbstickDown.ToString(),
24
},
{
Buttons.RightThumbstickLeft.ToString(),
21
},
{
Buttons.RightThumbstickRight.ToString(),
22
},
{
Buttons.RightThumbstickUp.ToString(),
23
},
{
Buttons.RightTrigger.ToString(),
9
},
{
Buttons.Start.ToString(),
5
},
{
Buttons.X.ToString(),
2
},
{
Buttons.Y.ToString(),
3
},
{
"LR",
25
}
};
TextSnippet ITagHandler.Parse(
string text,
Color baseColor,
string options)
{
int result;
if (!int.TryParse(text, out result) || result >= 26)
return new TextSnippet(text);
GlyphTagHandler.GlyphSnippet glyphSnippet = new GlyphTagHandler.GlyphSnippet(result);
glyphSnippet.DeleteWhole = true;
glyphSnippet.Text = "[g:" + (object) result + "]";
return (TextSnippet) glyphSnippet;
}
public static string GenerateTag(int index) => "[g" + ":" + (object) index + "]";
public static string GenerateTag(string keyname)
{
int index;
return GlyphTagHandler.GlyphIndexes.TryGetValue(keyname, out index) ? GlyphTagHandler.GenerateTag(index) : keyname;
}
private class GlyphSnippet : TextSnippet
{
private int _glyphIndex;
public GlyphSnippet(int index)
: base()
{
this._glyphIndex = index;
this.Color = Color.White;
}
public override bool UniqueDraw(
bool justCheckingString,
out Vector2 size,
SpriteBatch spriteBatch,
Vector2 position = default (Vector2),
Color color = default (Color),
float scale = 1f)
{
if (!justCheckingString && color != Color.Black)
{
int frameX = this._glyphIndex;
if (this._glyphIndex == 25)
frameX = (double) Main.GlobalTimeWrappedHourly % 0.600000023841858 < 0.300000011920929 ? 17 : 18;
Texture2D texture2D = TextureAssets.TextGlyph[0].Value;
spriteBatch.Draw(texture2D, position, new Rectangle?(texture2D.Frame(25, frameX: frameX, frameY: (frameX / 25))), color, 0.0f, Vector2.Zero, GlyphTagHandler.GlyphsScale, SpriteEffects.None, 0.0f);
}
size = new Vector2(26f) * GlyphTagHandler.GlyphsScale;
return true;
}
public override float GetStringLength(DynamicSpriteFont font) => 26f * GlyphTagHandler.GlyphsScale;
}
}
}

View file

@ -0,0 +1,29 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Chat.IChatMonitor
// 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.GameContent.UI.Chat
{
public interface IChatMonitor
{
void NewText(string newText, byte R = 255, byte G = 255, byte B = 255);
void NewTextMultiline(string text, bool force = false, Color c = default (Color), int WidthLimit = -1);
void DrawChat(bool drawingPlayerChat);
void Clear();
void Update();
void Offset(int linesOffset);
void ResetOffset();
void OnResolutionChange();
}
}

View file

@ -0,0 +1,134 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Chat.ItemTagHandler
// 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.UI;
using Terraria.UI.Chat;
namespace Terraria.GameContent.UI.Chat
{
public class ItemTagHandler : ITagHandler
{
TextSnippet ITagHandler.Parse(
string text,
Color baseColor,
string options)
{
Item obj = new Item();
int result1;
if (int.TryParse(text, out result1))
obj.netDefaults(result1);
if (obj.type <= 0)
return new TextSnippet(text);
obj.stack = 1;
if (options != null)
{
string[] strArray = options.Split(',');
for (int index = 0; index < strArray.Length; ++index)
{
if (strArray[index].Length != 0)
{
switch (strArray[index][0])
{
case 'p':
int result2;
if (int.TryParse(strArray[index].Substring(1), out result2))
{
obj.Prefix((int) (byte) Utils.Clamp<int>(result2, 0, 85));
continue;
}
continue;
case 's':
case 'x':
int result3;
if (int.TryParse(strArray[index].Substring(1), out result3))
{
obj.stack = Utils.Clamp<int>(result3, 1, obj.maxStack);
continue;
}
continue;
default:
continue;
}
}
}
}
string str = "";
if (obj.stack > 1)
str = " (" + (object) obj.stack + ")";
ItemTagHandler.ItemSnippet itemSnippet = new ItemTagHandler.ItemSnippet(obj);
itemSnippet.Text = "[" + obj.AffixName() + str + "]";
itemSnippet.CheckForHover = true;
itemSnippet.DeleteWhole = true;
return (TextSnippet) itemSnippet;
}
public static string GenerateTag(Item I)
{
string str = "[i";
if (I.prefix != (byte) 0)
str = str + "/p" + (object) I.prefix;
if (I.stack != 1)
str = str + "/s" + (object) I.stack;
return str + ":" + (object) I.netID + "]";
}
private class ItemSnippet : TextSnippet
{
private Item _item;
public ItemSnippet(Item item)
: base()
{
this._item = item;
this.Color = ItemRarity.GetColor(item.rare);
}
public override void OnHover()
{
Main.HoverItem = this._item.Clone();
Main.instance.MouseText(this._item.Name, this._item.rare);
}
public override bool UniqueDraw(
bool justCheckingString,
out Vector2 size,
SpriteBatch spriteBatch,
Vector2 position = default (Vector2),
Color color = default (Color),
float scale = 1f)
{
float num1 = 1f;
float num2 = 1f;
if (Main.netMode != 2 && !Main.dedServ)
{
Main.instance.LoadItem(this._item.type);
Texture2D texture2D = TextureAssets.Item[this._item.type].Value;
Rectangle rectangle = Main.itemAnimations[this._item.type] == null ? texture2D.Frame() : Main.itemAnimations[this._item.type].GetFrame(texture2D);
if (rectangle.Height > 32)
num2 = 32f / (float) rectangle.Height;
}
float num3 = num2 * scale;
float num4 = num1 * num3;
if ((double) num4 > 0.75)
num4 = 0.75f;
if (!justCheckingString && color != Color.Black)
{
double inventoryScale = (double) Main.inventoryScale;
Main.inventoryScale = scale * num4;
ItemSlot.Draw(spriteBatch, ref this._item, 14, position - new Vector2(10f) * scale * num4, Color.White);
Main.inventoryScale = (float) inventoryScale;
}
size = new Vector2(32f) * scale * num4;
return true;
}
public override float GetStringLength(DynamicSpriteFont font) => (float) (32.0 * (double) this.Scale * 0.649999976158142);
}
}
}

View file

@ -0,0 +1,188 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Chat.LegacyChatMonitor
// 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.Audio;
using Terraria.UI.Chat;
namespace Terraria.GameContent.UI.Chat
{
public class LegacyChatMonitor : IChatMonitor
{
private int numChatLines;
private ChatLine[] chatLine;
private int chatLength;
private int showCount;
private int startChatLine;
public int TextMaxLengthForScreen => Main.screenWidth - 320;
public void OnResolutionChange()
{
}
public LegacyChatMonitor()
{
this.showCount = 10;
this.numChatLines = 500;
this.chatLength = 600;
this.chatLine = new ChatLine[this.numChatLines];
for (int index = 0; index < this.numChatLines; ++index)
this.chatLine[index] = new ChatLine();
}
public void Clear()
{
for (int index = 0; index < this.numChatLines; ++index)
this.chatLine[index] = new ChatLine();
}
public void ResetOffset() => this.startChatLine = 0;
public void Update()
{
for (int index = 0; index < this.numChatLines; ++index)
this.chatLine[index].UpdateTimeLeft();
}
public void Offset(int linesOffset)
{
this.showCount = (int) ((double) (Main.screenHeight / 3) / (double) FontAssets.MouseText.Value.MeasureString("1").Y) - 1;
switch (linesOffset)
{
case -1:
--this.startChatLine;
if (this.startChatLine >= 0)
break;
this.startChatLine = 0;
break;
case 1:
++this.startChatLine;
if (this.startChatLine + this.showCount >= this.numChatLines - 1)
this.startChatLine = this.numChatLines - this.showCount - 1;
if (!(this.chatLine[this.startChatLine + this.showCount].originalText == ""))
break;
--this.startChatLine;
break;
}
}
public void NewText(string newText, byte R = 255, byte G = 255, byte B = 255) => this.NewTextMultiline(newText, false, new Color((int) R, (int) G, (int) B), -1);
public void NewTextInternal(string newText, byte R = 255, byte G = 255, byte B = 255, bool force = false)
{
int maxTextSize = 80;
if (!force && newText.Length > maxTextSize)
{
string oldText = newText;
string newText1 = this.TrimIntoMultipleLines(R, G, B, maxTextSize, oldText);
if (newText1.Length <= 0)
return;
this.NewTextInternal(newText1, R, G, B, true);
}
else
{
for (int index = this.numChatLines - 1; index > 0; --index)
this.chatLine[index].Copy(this.chatLine[index - 1]);
this.chatLine[0].color = new Color((int) R, (int) G, (int) B);
this.chatLine[0].originalText = newText;
this.chatLine[0].parsedText = ChatManager.ParseMessage(this.chatLine[0].originalText, this.chatLine[0].color).ToArray();
this.chatLine[0].showTime = this.chatLength;
SoundEngine.PlaySound(12);
}
}
private string TrimIntoMultipleLines(byte R, byte G, byte B, int maxTextSize, string oldText)
{
while (oldText.Length > maxTextSize)
{
int num = maxTextSize;
int startIndex = num;
while (oldText.Substring(startIndex, 1) != " ")
{
--startIndex;
if (startIndex < 1)
break;
}
if (startIndex == 0)
{
while (oldText.Substring(num, 1) != " ")
{
++num;
if (num >= oldText.Length - 1)
break;
}
}
else
num = startIndex;
if (num >= oldText.Length - 1)
num = oldText.Length;
this.NewTextInternal(oldText.Substring(0, num), R, G, B, true);
oldText = oldText.Substring(num);
if (oldText.Length > 0)
{
while (oldText.Substring(0, 1) == " ")
oldText = oldText.Substring(1);
}
}
return oldText;
}
public void NewTextMultiline(string text, bool force = false, Color c = default (Color), int WidthLimit = -1)
{
if (c == new Color())
c = Color.White;
List<List<TextSnippet>> textSnippetListList = WidthLimit == -1 ? Utils.WordwrapStringSmart(text, c, FontAssets.MouseText.Value, this.TextMaxLengthForScreen, 10) : Utils.WordwrapStringSmart(text, c, FontAssets.MouseText.Value, WidthLimit, 10);
for (int index = 0; index < textSnippetListList.Count; ++index)
this.NewText(textSnippetListList[index]);
}
public void NewText(List<TextSnippet> snippets)
{
for (int index = this.numChatLines - 1; index > 0; --index)
this.chatLine[index].Copy(this.chatLine[index - 1]);
this.chatLine[0].originalText = "this is a hack because draw checks length is higher than 0";
this.chatLine[0].parsedText = snippets.ToArray();
this.chatLine[0].showTime = this.chatLength;
SoundEngine.PlaySound(12);
}
public void DrawChat(bool drawingPlayerChat)
{
int num1 = this.startChatLine;
int num2 = this.startChatLine + this.showCount;
if (num2 >= this.numChatLines)
{
num2 = --this.numChatLines;
num1 = num2 - this.showCount;
}
int num3 = 0;
int index1 = -1;
int index2 = -1;
for (int index3 = num1; index3 < num2; ++index3)
{
if (drawingPlayerChat || this.chatLine[index3].showTime > 0 && this.chatLine[index3].parsedText.Length != 0)
{
int hoveredSnippet = -1;
ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, FontAssets.MouseText.Value, this.chatLine[index3].parsedText, new Vector2(88f, (float) (Main.screenHeight - 30 - 28 - num3 * 21)), 0.0f, Vector2.Zero, Vector2.One, out hoveredSnippet);
if (hoveredSnippet >= 0 && this.chatLine[index3].parsedText[hoveredSnippet].CheckForHover)
{
index1 = index3;
index2 = hoveredSnippet;
}
}
++num3;
}
if (index1 <= -1)
return;
this.chatLine[index1].parsedText[index2].OnHover();
if (!Main.mouseLeft || !Main.mouseLeftRelease)
return;
this.chatLine[index1].parsedText[index2].OnClick();
}
}
}

View file

@ -0,0 +1,24 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Chat.NameTagHandler
// 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.UI.Chat;
namespace Terraria.GameContent.UI.Chat
{
public class NameTagHandler : ITagHandler
{
TextSnippet ITagHandler.Parse(
string text,
Color baseColor,
string options)
{
return new TextSnippet("<" + text.Replace("\\[", "[").Replace("\\]", "]") + ">", baseColor);
}
public static string GenerateTag(string name) => "[n:" + name.Replace("[", "\\[").Replace("]", "\\]") + "]";
}
}

View file

@ -0,0 +1,37 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Chat.PlainTagHandler
// 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.UI.Chat;
namespace Terraria.GameContent.UI.Chat
{
public class PlainTagHandler : ITagHandler
{
TextSnippet ITagHandler.Parse(
string text,
Color baseColor,
string options)
{
return (TextSnippet) new PlainTagHandler.PlainSnippet(text);
}
public class PlainSnippet : TextSnippet
{
public PlainSnippet(string text = "")
: base(text)
{
}
public PlainSnippet(string text, Color color, float scale = 1f)
: base(text, color, scale)
{
}
public override Color GetVisibleColor() => this.Color;
}
}
}

View file

@ -0,0 +1,156 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Chat.RemadeChatMonitor
// 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.UI.Chat;
namespace Terraria.GameContent.UI.Chat
{
public class RemadeChatMonitor : IChatMonitor
{
private const int MaxMessages = 500;
private int _showCount;
private int _startChatLine;
private List<ChatMessageContainer> _messages;
private bool _recalculateOnNextUpdate;
public RemadeChatMonitor()
{
this._showCount = 10;
this._startChatLine = 0;
this._messages = new List<ChatMessageContainer>();
}
public void NewText(string newText, byte R = 255, byte G = 255, byte B = 255) => this.AddNewMessage(newText, new Color((int) R, (int) G, (int) B));
public void NewTextMultiline(string text, bool force = false, Color c = default (Color), int WidthLimit = -1) => this.AddNewMessage(text, c, WidthLimit);
public void AddNewMessage(string text, Color color, int widthLimitInPixels = -1)
{
ChatMessageContainer messageContainer = new ChatMessageContainer();
messageContainer.SetContents(text, color, widthLimitInPixels);
this._messages.Insert(0, messageContainer);
while (this._messages.Count > 500)
this._messages.RemoveAt(this._messages.Count - 1);
}
public void DrawChat(bool drawingPlayerChat)
{
int startChatLine = this._startChatLine;
int index = 0;
int snippetIndex1 = 0;
while (startChatLine > 0 && index < this._messages.Count)
{
int num = Math.Min(startChatLine, this._messages[index].LineCount);
startChatLine -= num;
snippetIndex1 += num;
if (snippetIndex1 == this._messages[index].LineCount)
{
snippetIndex1 = 0;
++index;
}
}
int num1 = 0;
int? nullable1 = new int?();
int snippetIndex2 = -1;
int? nullable2 = new int?();
int hoveredSnippet = -1;
while (num1 < this._showCount && index < this._messages.Count)
{
ChatMessageContainer message = this._messages[index];
if (message.Prepared && drawingPlayerChat | message.CanBeShownWhenChatIsClosed)
{
TextSnippet[] withInversedIndex = message.GetSnippetWithInversedIndex(snippetIndex1);
ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, FontAssets.MouseText.Value, withInversedIndex, new Vector2(88f, (float) (Main.screenHeight - 30 - 28 - num1 * 21)), 0.0f, Vector2.Zero, Vector2.One, out hoveredSnippet);
if (hoveredSnippet >= 0)
{
nullable2 = new int?(hoveredSnippet);
nullable1 = new int?(index);
snippetIndex2 = snippetIndex1;
}
++num1;
++snippetIndex1;
if (snippetIndex1 >= message.LineCount)
{
snippetIndex1 = 0;
++index;
}
}
else
break;
}
if (!nullable1.HasValue || !nullable2.HasValue)
return;
TextSnippet[] withInversedIndex1 = this._messages[nullable1.Value].GetSnippetWithInversedIndex(snippetIndex2);
withInversedIndex1[nullable2.Value].OnHover();
if (!Main.mouseLeft || !Main.mouseLeftRelease)
return;
withInversedIndex1[nullable2.Value].OnClick();
}
public void Clear() => this._messages.Clear();
public void Update()
{
if (this._recalculateOnNextUpdate)
{
this._recalculateOnNextUpdate = false;
for (int index = 0; index < this._messages.Count; ++index)
this._messages[index].MarkToNeedRefresh();
}
for (int index = 0; index < this._messages.Count; ++index)
this._messages[index].Update();
}
public void Offset(int linesOffset)
{
this._startChatLine += linesOffset;
this.ClampMessageIndex();
}
private void ClampMessageIndex()
{
int num1 = 0;
int index = 0;
int num2 = 0;
int num3 = this._startChatLine + this._showCount;
while (num1 < num3 && index < this._messages.Count)
{
int num4 = Math.Min(num3 - num1, this._messages[index].LineCount);
num1 += num4;
if (num1 < num3)
{
++index;
num2 = 0;
}
else
num2 = num4;
}
int showCount = this._showCount;
while (showCount > 0 && num1 > 0)
{
--num2;
--showCount;
--num1;
if (num2 < 0)
{
--index;
if (index != -1)
num2 = this._messages[index].LineCount - 1;
else
break;
}
}
this._startChatLine = num1;
}
public void ResetOffset() => this._startChatLine = 0;
public void OnResolutionChange() => this._recalculateOnNextUpdate = true;
}
}

View file

@ -0,0 +1,164 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.ClassicPlayerResourcesDisplaySet
// 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.GameContent.UI
{
public class ClassicPlayerResourcesDisplaySet : IPlayerResourcesDisplaySet
{
private int UIDisplay_ManaPerStar = 20;
private float UIDisplay_LifePerHeart = 20f;
private int UI_ScreenAnchorX;
public void Draw()
{
this.UI_ScreenAnchorX = Main.screenWidth - 800;
this.DrawLife();
this.DrawMana();
}
private void DrawLife()
{
Player localPlayer = Main.LocalPlayer;
SpriteBatch spriteBatch = Main.spriteBatch;
Color color = new Color((int) Main.mouseTextColor, (int) Main.mouseTextColor, (int) Main.mouseTextColor, (int) Main.mouseTextColor);
this.UIDisplay_LifePerHeart = 20f;
if (localPlayer.ghost)
return;
int num1 = localPlayer.statLifeMax / 20;
int num2 = (localPlayer.statLifeMax - 400) / 5;
if (num2 < 0)
num2 = 0;
if (num2 > 0)
{
num1 = localPlayer.statLifeMax / (20 + num2 / 4);
this.UIDisplay_LifePerHeart = (float) localPlayer.statLifeMax / 20f;
}
this.UIDisplay_LifePerHeart += (float) ((localPlayer.statLifeMax2 - localPlayer.statLifeMax) / num1);
int num3 = (int) ((double) localPlayer.statLifeMax2 / (double) this.UIDisplay_LifePerHeart);
if (num3 >= 10)
num3 = 10;
string str = Lang.inter[0].Value + " " + (object) localPlayer.statLifeMax2 + "/" + (object) localPlayer.statLifeMax2;
Vector2 vector2 = FontAssets.MouseText.Value.MeasureString(str);
if (!localPlayer.ghost)
{
DynamicSpriteFontExtensionMethods.DrawString(spriteBatch, FontAssets.MouseText.Value, Lang.inter[0].Value, new Vector2((float) (500 + 13 * num3) - vector2.X * 0.5f + (float) this.UI_ScreenAnchorX, 6f), color, 0.0f, new Vector2(), 1f, SpriteEffects.None, 0.0f);
DynamicSpriteFontExtensionMethods.DrawString(spriteBatch, FontAssets.MouseText.Value, localPlayer.statLife.ToString() + "/" + (object) localPlayer.statLifeMax2, new Vector2((float) (500 + 13 * num3) + vector2.X * 0.5f + (float) this.UI_ScreenAnchorX, 6f), color, 0.0f, new Vector2(FontAssets.MouseText.Value.MeasureString(localPlayer.statLife.ToString() + "/" + (object) localPlayer.statLifeMax2).X, 0.0f), 1f, SpriteEffects.None, 0.0f);
}
for (int index = 1; index < (int) ((double) localPlayer.statLifeMax2 / (double) this.UIDisplay_LifePerHeart) + 1; ++index)
{
float scale = 1f;
bool flag = false;
int num4;
if ((double) localPlayer.statLife >= (double) index * (double) this.UIDisplay_LifePerHeart)
{
num4 = (int) byte.MaxValue;
if ((double) localPlayer.statLife == (double) index * (double) this.UIDisplay_LifePerHeart)
flag = true;
}
else
{
float num5 = ((float) localPlayer.statLife - (float) (index - 1) * this.UIDisplay_LifePerHeart) / this.UIDisplay_LifePerHeart;
num4 = (int) (30.0 + 225.0 * (double) num5);
if (num4 < 30)
num4 = 30;
scale = (float) ((double) num5 / 4.0 + 0.75);
if ((double) scale < 0.75)
scale = 0.75f;
if ((double) num5 > 0.0)
flag = true;
}
if (flag)
scale += Main.cursorScale - 1f;
int num6 = 0;
int num7 = 0;
if (index > 10)
{
num6 -= 260;
num7 += 26;
}
int a = (int) ((double) num4 * 0.9);
if (!localPlayer.ghost)
{
if (num2 > 0)
{
--num2;
spriteBatch.Draw(TextureAssets.Heart2.Value, new Vector2((float) (500 + 26 * (index - 1) + num6 + this.UI_ScreenAnchorX + TextureAssets.Heart.Width() / 2), (float) (32.0 + ((double) TextureAssets.Heart.Height() - (double) TextureAssets.Heart.Height() * (double) scale) / 2.0) + (float) num7 + (float) (TextureAssets.Heart.Height() / 2)), new Rectangle?(new Rectangle(0, 0, TextureAssets.Heart.Width(), TextureAssets.Heart.Height())), new Color(num4, num4, num4, a), 0.0f, new Vector2((float) (TextureAssets.Heart.Width() / 2), (float) (TextureAssets.Heart.Height() / 2)), scale, SpriteEffects.None, 0.0f);
}
else
spriteBatch.Draw(TextureAssets.Heart.Value, new Vector2((float) (500 + 26 * (index - 1) + num6 + this.UI_ScreenAnchorX + TextureAssets.Heart.Width() / 2), (float) (32.0 + ((double) TextureAssets.Heart.Height() - (double) TextureAssets.Heart.Height() * (double) scale) / 2.0) + (float) num7 + (float) (TextureAssets.Heart.Height() / 2)), new Rectangle?(new Rectangle(0, 0, TextureAssets.Heart.Width(), TextureAssets.Heart.Height())), new Color(num4, num4, num4, a), 0.0f, new Vector2((float) (TextureAssets.Heart.Width() / 2), (float) (TextureAssets.Heart.Height() / 2)), scale, SpriteEffects.None, 0.0f);
}
}
}
private void DrawMana()
{
Player localPlayer = Main.LocalPlayer;
SpriteBatch spriteBatch = Main.spriteBatch;
Color color = new Color((int) Main.mouseTextColor, (int) Main.mouseTextColor, (int) Main.mouseTextColor, (int) Main.mouseTextColor);
this.UIDisplay_ManaPerStar = 20;
if (localPlayer.ghost || localPlayer.statManaMax2 <= 0)
return;
int num1 = localPlayer.statManaMax2 / 20;
Vector2 vector2 = FontAssets.MouseText.Value.MeasureString(Lang.inter[2].Value);
int num2 = 50;
if ((double) vector2.X >= 45.0)
num2 = (int) vector2.X + 5;
DynamicSpriteFontExtensionMethods.DrawString(spriteBatch, FontAssets.MouseText.Value, Lang.inter[2].Value, new Vector2((float) (800 - num2 + this.UI_ScreenAnchorX), 6f), color, 0.0f, new Vector2(), 1f, SpriteEffects.None, 0.0f);
for (int index = 1; index < localPlayer.statManaMax2 / this.UIDisplay_ManaPerStar + 1; ++index)
{
bool flag = false;
float scale = 1f;
int num3;
if (localPlayer.statMana >= index * this.UIDisplay_ManaPerStar)
{
num3 = (int) byte.MaxValue;
if (localPlayer.statMana == index * this.UIDisplay_ManaPerStar)
flag = true;
}
else
{
float num4 = (float) (localPlayer.statMana - (index - 1) * this.UIDisplay_ManaPerStar) / (float) this.UIDisplay_ManaPerStar;
num3 = (int) (30.0 + 225.0 * (double) num4);
if (num3 < 30)
num3 = 30;
scale = (float) ((double) num4 / 4.0 + 0.75);
if ((double) scale < 0.75)
scale = 0.75f;
if ((double) num4 > 0.0)
flag = true;
}
if (flag)
scale += Main.cursorScale - 1f;
int a = (int) ((double) num3 * 0.9);
spriteBatch.Draw(TextureAssets.Mana.Value, new Vector2((float) (775 + this.UI_ScreenAnchorX), (float) (30 + TextureAssets.Mana.Height() / 2) + (float) (((double) TextureAssets.Mana.Height() - (double) TextureAssets.Mana.Height() * (double) scale) / 2.0) + (float) (28 * (index - 1))), new Rectangle?(new Rectangle(0, 0, TextureAssets.Mana.Width(), TextureAssets.Mana.Height())), new Color(num3, num3, num3, a), 0.0f, new Vector2((float) (TextureAssets.Mana.Width() / 2), (float) (TextureAssets.Mana.Height() / 2)), scale, SpriteEffects.None, 0.0f);
}
}
public void TryToHover()
{
Vector2 mouseScreen = Main.MouseScreen;
Player localPlayer = Main.LocalPlayer;
int num1 = 26 * localPlayer.statLifeMax2 / (int) this.UIDisplay_LifePerHeart;
int num2 = 0;
if (localPlayer.statLifeMax2 > 200)
{
num1 = 260;
num2 += 26;
}
if ((double) mouseScreen.X > (double) (500 + this.UI_ScreenAnchorX) && (double) mouseScreen.X < (double) (500 + num1 + this.UI_ScreenAnchorX) && (double) mouseScreen.Y > 32.0 && (double) mouseScreen.Y < (double) (32 + TextureAssets.Heart.Height() + num2))
CommonResourceBarMethods.DrawLifeMouseOver();
int num3 = 24;
int num4 = 28 * localPlayer.statManaMax2 / this.UIDisplay_ManaPerStar;
if ((double) mouseScreen.X <= (double) (762 + this.UI_ScreenAnchorX) || (double) mouseScreen.X >= (double) (762 + num3 + this.UI_ScreenAnchorX) || (double) mouseScreen.Y <= 30.0 || (double) mouseScreen.Y >= (double) (30 + num4))
return;
CommonResourceBarMethods.DrawManaMouseOver();
}
}
}

View file

@ -0,0 +1,33 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.CommonResourceBarMethods
// 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.GameContent.UI
{
public class CommonResourceBarMethods
{
public static void DrawLifeMouseOver()
{
if (Main.mouseText)
return;
Player localPlayer = Main.LocalPlayer;
localPlayer.cursorItemIconEnabled = false;
string text = localPlayer.statLife.ToString() + "/" + (object) localPlayer.statLifeMax2;
Main.instance.MouseTextHackZoom(text);
Main.mouseText = true;
}
public static void DrawManaMouseOver()
{
if (Main.mouseText)
return;
Player localPlayer = Main.LocalPlayer;
localPlayer.cursorItemIconEnabled = false;
string text = localPlayer.statMana.ToString() + "/" + (object) localPlayer.statManaMax2;
Main.instance.MouseTextHackZoom(text);
Main.mouseText = true;
}
}
}

View file

@ -0,0 +1,150 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.CustomCurrencyManager
// 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.ID;
namespace Terraria.GameContent.UI
{
public class CustomCurrencyManager
{
private static int _nextCurrencyIndex;
private static Dictionary<int, CustomCurrencySystem> _currencies = new Dictionary<int, CustomCurrencySystem>();
public static void Initialize()
{
CustomCurrencyManager._nextCurrencyIndex = 0;
CustomCurrencyID.DefenderMedals = CustomCurrencyManager.RegisterCurrency((CustomCurrencySystem) new CustomCurrencySingleCoin(3817, 999L));
}
public static int RegisterCurrency(CustomCurrencySystem collection)
{
int nextCurrencyIndex = CustomCurrencyManager._nextCurrencyIndex;
++CustomCurrencyManager._nextCurrencyIndex;
CustomCurrencyManager._currencies[nextCurrencyIndex] = collection;
return nextCurrencyIndex;
}
public static void DrawSavings(
SpriteBatch sb,
int currencyIndex,
float shopx,
float shopy,
bool horizontal = false)
{
CustomCurrencySystem currency = CustomCurrencyManager._currencies[currencyIndex];
Player player = Main.player[Main.myPlayer];
bool overFlowing;
long num1 = currency.CountCurrency(out overFlowing, player.bank.item);
long num2 = currency.CountCurrency(out overFlowing, player.bank2.item);
long num3 = currency.CountCurrency(out overFlowing, player.bank3.item);
long num4 = currency.CountCurrency(out overFlowing, player.bank4.item);
long totalCoins = currency.CombineStacks(out overFlowing, num1, num2, num3, num4);
if (totalCoins <= 0L)
return;
Main.instance.LoadItem(4076);
Main.instance.LoadItem(3813);
Main.instance.LoadItem(346);
Main.instance.LoadItem(87);
if (num4 > 0L)
sb.Draw(TextureAssets.Item[4076].Value, Utils.CenteredRectangle(new Vector2(shopx + 96f, shopy + 50f), TextureAssets.Item[4076].Value.Size() * 0.65f), new Rectangle?(), Color.White);
if (num3 > 0L)
sb.Draw(TextureAssets.Item[3813].Value, Utils.CenteredRectangle(new Vector2(shopx + 80f, shopy + 50f), TextureAssets.Item[3813].Value.Size() * 0.65f), new Rectangle?(), Color.White);
if (num2 > 0L)
sb.Draw(TextureAssets.Item[346].Value, Utils.CenteredRectangle(new Vector2(shopx + 80f, shopy + 50f), TextureAssets.Item[346].Value.Size() * 0.65f), new Rectangle?(), Color.White);
if (num1 > 0L)
sb.Draw(TextureAssets.Item[87].Value, Utils.CenteredRectangle(new Vector2(shopx + 70f, shopy + 60f), TextureAssets.Item[87].Value.Size() * 0.65f), new Rectangle?(), Color.White);
Utils.DrawBorderStringFourWay(sb, FontAssets.MouseText.Value, Lang.inter[66].Value, shopx, shopy + 40f, Color.White * ((float) Main.mouseTextColor / (float) byte.MaxValue), Color.Black, Vector2.Zero);
currency.DrawSavingsMoney(sb, Lang.inter[66].Value, shopx, shopy, totalCoins, horizontal);
}
public static void GetPriceText(
int currencyIndex,
string[] lines,
ref int currentLine,
int price)
{
CustomCurrencyManager._currencies[currencyIndex].GetPriceText(lines, ref currentLine, price);
}
public static bool BuyItem(Player player, int price, int currencyIndex)
{
CustomCurrencySystem currency = CustomCurrencyManager._currencies[currencyIndex];
bool overFlowing;
long num1 = currency.CountCurrency(out overFlowing, player.inventory, 58, 57, 56, 55, 54);
long num2 = currency.CountCurrency(out overFlowing, player.bank.item);
long num3 = currency.CountCurrency(out overFlowing, player.bank2.item);
long num4 = currency.CountCurrency(out overFlowing, player.bank3.item);
long num5 = currency.CountCurrency(out overFlowing, player.bank4.item);
if (currency.CombineStacks(out overFlowing, num1, num2, num3, num4, num5) < (long) price)
return false;
List<Item[]> objArrayList = new List<Item[]>();
Dictionary<int, List<int>> slotsToIgnore = new Dictionary<int, List<int>>();
List<Point> pointList1 = new List<Point>();
List<Point> slotCoins = new List<Point>();
List<Point> pointList2 = new List<Point>();
List<Point> pointList3 = new List<Point>();
List<Point> pointList4 = new List<Point>();
List<Point> pointList5 = new List<Point>();
objArrayList.Add(player.inventory);
objArrayList.Add(player.bank.item);
objArrayList.Add(player.bank2.item);
objArrayList.Add(player.bank3.item);
objArrayList.Add(player.bank4.item);
for (int key = 0; key < objArrayList.Count; ++key)
slotsToIgnore[key] = new List<int>();
slotsToIgnore[0] = new List<int>()
{
58,
57,
56,
55,
54
};
for (int index = 0; index < objArrayList.Count; ++index)
{
for (int y = 0; y < objArrayList[index].Length; ++y)
{
if (!slotsToIgnore[index].Contains(y) && currency.Accepts(objArrayList[index][y]))
slotCoins.Add(new Point(index, y));
}
}
CustomCurrencyManager.FindEmptySlots(objArrayList, slotsToIgnore, pointList1, 0);
CustomCurrencyManager.FindEmptySlots(objArrayList, slotsToIgnore, pointList2, 1);
CustomCurrencyManager.FindEmptySlots(objArrayList, slotsToIgnore, pointList3, 2);
CustomCurrencyManager.FindEmptySlots(objArrayList, slotsToIgnore, pointList4, 3);
CustomCurrencyManager.FindEmptySlots(objArrayList, slotsToIgnore, pointList5, 4);
return currency.TryPurchasing(price, objArrayList, slotCoins, pointList1, pointList2, pointList3, pointList4, pointList5);
}
private static void FindEmptySlots(
List<Item[]> inventories,
Dictionary<int, List<int>> slotsToIgnore,
List<Point> emptySlots,
int currentInventoryIndex)
{
for (int y = inventories[currentInventoryIndex].Length - 1; y >= 0; --y)
{
if (!slotsToIgnore[currentInventoryIndex].Contains(y) && (inventories[currentInventoryIndex][y].type == 0 || inventories[currentInventoryIndex][y].stack == 0))
emptySlots.Add(new Point(currentInventoryIndex, y));
}
}
public static bool IsCustomCurrency(Item item)
{
foreach (KeyValuePair<int, CustomCurrencySystem> currency in CustomCurrencyManager._currencies)
{
if (currency.Value.Accepts(item))
return true;
}
return false;
}
public static void GetPrices(Item item, out int calcForSelling, out int calcForBuying) => CustomCurrencyManager._currencies[item.shopSpecialCurrency].GetItemExpectedPrice(item, out calcForSelling, out calcForBuying);
}
}

View file

@ -0,0 +1,112 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.CustomCurrencySingleCoin
// 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 System.Collections.Generic;
using System.Linq;
using Terraria.Localization;
using Terraria.UI.Chat;
namespace Terraria.GameContent.UI
{
public class CustomCurrencySingleCoin : CustomCurrencySystem
{
public float CurrencyDrawScale = 0.8f;
public string CurrencyTextKey = "Currency.DefenderMedals";
public Color CurrencyTextColor = new Color(240, 100, 120);
public CustomCurrencySingleCoin(int coinItemID, long currencyCap)
{
this.Include(coinItemID, 1);
this.SetCurrencyCap(currencyCap);
}
public override bool TryPurchasing(
int price,
List<Item[]> inv,
List<Point> slotCoins,
List<Point> slotsEmpty,
List<Point> slotEmptyBank,
List<Point> slotEmptyBank2,
List<Point> slotEmptyBank3,
List<Point> slotEmptyBank4)
{
List<Tuple<Point, Item>> cache = this.ItemCacheCreate(inv);
int num1 = price;
for (int index = 0; index < slotCoins.Count; ++index)
{
Point slotCoin = slotCoins[index];
int num2 = num1;
if (inv[slotCoin.X][slotCoin.Y].stack < num2)
num2 = inv[slotCoin.X][slotCoin.Y].stack;
num1 -= num2;
inv[slotCoin.X][slotCoin.Y].stack -= num2;
if (inv[slotCoin.X][slotCoin.Y].stack == 0)
{
switch (slotCoin.X)
{
case 0:
slotsEmpty.Add(slotCoin);
break;
case 1:
slotEmptyBank.Add(slotCoin);
break;
case 2:
slotEmptyBank2.Add(slotCoin);
break;
case 3:
slotEmptyBank3.Add(slotCoin);
break;
case 4:
slotEmptyBank4.Add(slotCoin);
break;
}
slotCoins.Remove(slotCoin);
--index;
}
if (num1 == 0)
break;
}
if (num1 == 0)
return true;
this.ItemCacheRestore(cache, inv);
return false;
}
public override void DrawSavingsMoney(
SpriteBatch sb,
string text,
float shopx,
float shopy,
long totalCoins,
bool horizontal = false)
{
int i = this._valuePerUnit.Keys.ElementAt<int>(0);
Main.instance.LoadItem(i);
Texture2D texture2D = TextureAssets.Item[i].Value;
if (horizontal)
{
Vector2 position = new Vector2((float) ((double) shopx + (double) ChatManager.GetStringSize(FontAssets.MouseText.Value, text, Vector2.One).X + 45.0), shopy + 50f);
sb.Draw(texture2D, position, new Rectangle?(), Color.White, 0.0f, texture2D.Size() / 2f, this.CurrencyDrawScale, SpriteEffects.None, 0.0f);
Utils.DrawBorderStringFourWay(sb, FontAssets.ItemStack.Value, totalCoins.ToString(), position.X - 11f, position.Y, Color.White, Color.Black, new Vector2(0.3f), 0.75f);
}
else
{
int num = totalCoins > 99L ? -6 : 0;
sb.Draw(texture2D, new Vector2(shopx + 11f, shopy + 75f), new Rectangle?(), Color.White, 0.0f, texture2D.Size() / 2f, this.CurrencyDrawScale, SpriteEffects.None, 0.0f);
Utils.DrawBorderStringFourWay(sb, FontAssets.ItemStack.Value, totalCoins.ToString(), shopx + (float) num, shopy + 75f, Color.White, Color.Black, new Vector2(0.3f), 0.75f);
}
}
public override void GetPriceText(string[] lines, ref int currentLine, int price)
{
Color color = this.CurrencyTextColor * ((float) Main.mouseTextColor / (float) byte.MaxValue);
lines[currentLine++] = string.Format("[c/{0:X2}{1:X2}{2:X2}:{3} {4} {5}]", (object) color.R, (object) color.G, (object) color.B, (object) Lang.tip[50].Value, (object) price, (object) Language.GetTextValue(this.CurrencyTextKey).ToLower());
}
}
}

View file

@ -0,0 +1,253 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.CustomCurrencySystem
// 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 System.Collections.Generic;
namespace Terraria.GameContent.UI
{
public class CustomCurrencySystem
{
protected Dictionary<int, int> _valuePerUnit = new Dictionary<int, int>();
private long _currencyCap = 999999999;
public long CurrencyCap => this._currencyCap;
public void Include(int coin, int howMuchIsItWorth) => this._valuePerUnit[coin] = howMuchIsItWorth;
public void SetCurrencyCap(long cap) => this._currencyCap = cap;
public virtual long CountCurrency(out bool overFlowing, Item[] inv, params int[] ignoreSlots)
{
List<int> intList = new List<int>((IEnumerable<int>) ignoreSlots);
long num1 = 0;
for (int index = 0; index < inv.Length; ++index)
{
if (!intList.Contains(index))
{
int num2;
if (this._valuePerUnit.TryGetValue(inv[index].type, out num2))
num1 += (long) (num2 * inv[index].stack);
if (num1 >= this.CurrencyCap)
{
overFlowing = true;
return this.CurrencyCap;
}
}
}
overFlowing = false;
return num1;
}
public virtual long CombineStacks(out bool overFlowing, params long[] coinCounts)
{
long num = 0;
foreach (long coinCount in coinCounts)
{
num += coinCount;
if (num >= this.CurrencyCap)
{
overFlowing = true;
return this.CurrencyCap;
}
}
overFlowing = false;
return num;
}
public virtual bool TryPurchasing(
int price,
List<Item[]> inv,
List<Point> slotCoins,
List<Point> slotsEmpty,
List<Point> slotEmptyBank,
List<Point> slotEmptyBank2,
List<Point> slotEmptyBank3,
List<Point> slotEmptyBank4)
{
long num1 = (long) price;
Dictionary<Point, Item> dictionary = new Dictionary<Point, Item>();
bool flag = true;
while (num1 > 0L)
{
long num2 = 1000000;
for (int index = 0; index < 4; ++index)
{
if (num1 >= num2)
{
foreach (Point slotCoin in slotCoins)
{
if (inv[slotCoin.X][slotCoin.Y].type == 74 - index)
{
long num3 = num1 / num2;
dictionary[slotCoin] = inv[slotCoin.X][slotCoin.Y].Clone();
if (num3 < (long) inv[slotCoin.X][slotCoin.Y].stack)
{
inv[slotCoin.X][slotCoin.Y].stack -= (int) num3;
}
else
{
inv[slotCoin.X][slotCoin.Y].SetDefaults();
slotsEmpty.Add(slotCoin);
}
num1 -= num2 * (long) (dictionary[slotCoin].stack - inv[slotCoin.X][slotCoin.Y].stack);
}
}
}
num2 /= 100L;
}
if (num1 > 0L)
{
if (slotsEmpty.Count > 0)
{
slotsEmpty.Sort(new Comparison<Point>(DelegateMethods.CompareYReverse));
Point point = new Point(-1, -1);
for (int index1 = 0; index1 < inv.Count; ++index1)
{
long num4 = 10000;
for (int index2 = 0; index2 < 3; ++index2)
{
if (num1 >= num4)
{
foreach (Point slotCoin in slotCoins)
{
if (slotCoin.X == index1 && inv[slotCoin.X][slotCoin.Y].type == 74 - index2 && inv[slotCoin.X][slotCoin.Y].stack >= 1)
{
List<Point> pointList = slotsEmpty;
if (index1 == 1 && slotEmptyBank.Count > 0)
pointList = slotEmptyBank;
if (index1 == 2 && slotEmptyBank2.Count > 0)
pointList = slotEmptyBank2;
if (index1 == 3 && slotEmptyBank3.Count > 0)
pointList = slotEmptyBank3;
if (index1 == 4 && slotEmptyBank4.Count > 0)
pointList = slotEmptyBank4;
if (--inv[slotCoin.X][slotCoin.Y].stack <= 0)
{
inv[slotCoin.X][slotCoin.Y].SetDefaults();
pointList.Add(slotCoin);
}
dictionary[pointList[0]] = inv[pointList[0].X][pointList[0].Y].Clone();
inv[pointList[0].X][pointList[0].Y].SetDefaults(73 - index2);
inv[pointList[0].X][pointList[0].Y].stack = 100;
point = pointList[0];
pointList.RemoveAt(0);
break;
}
}
}
if (point.X == -1 && point.Y == -1)
num4 /= 100L;
else
break;
}
for (int index3 = 0; index3 < 2; ++index3)
{
if (point.X == -1 && point.Y == -1)
{
foreach (Point slotCoin in slotCoins)
{
if (slotCoin.X == index1 && inv[slotCoin.X][slotCoin.Y].type == 73 + index3 && inv[slotCoin.X][slotCoin.Y].stack >= 1)
{
List<Point> pointList = slotsEmpty;
if (index1 == 1 && slotEmptyBank.Count > 0)
pointList = slotEmptyBank;
if (index1 == 2 && slotEmptyBank2.Count > 0)
pointList = slotEmptyBank2;
if (index1 == 3 && slotEmptyBank3.Count > 0)
pointList = slotEmptyBank3;
if (index1 == 4 && slotEmptyBank4.Count > 0)
pointList = slotEmptyBank4;
if (--inv[slotCoin.X][slotCoin.Y].stack <= 0)
{
inv[slotCoin.X][slotCoin.Y].SetDefaults();
pointList.Add(slotCoin);
}
dictionary[pointList[0]] = inv[pointList[0].X][pointList[0].Y].Clone();
inv[pointList[0].X][pointList[0].Y].SetDefaults(72 + index3);
inv[pointList[0].X][pointList[0].Y].stack = 100;
point = pointList[0];
pointList.RemoveAt(0);
break;
}
}
}
}
if (point.X != -1 && point.Y != -1)
{
slotCoins.Add(point);
break;
}
}
slotsEmpty.Sort(new Comparison<Point>(DelegateMethods.CompareYReverse));
slotEmptyBank.Sort(new Comparison<Point>(DelegateMethods.CompareYReverse));
slotEmptyBank2.Sort(new Comparison<Point>(DelegateMethods.CompareYReverse));
slotEmptyBank3.Sort(new Comparison<Point>(DelegateMethods.CompareYReverse));
slotEmptyBank4.Sort(new Comparison<Point>(DelegateMethods.CompareYReverse));
}
else
{
foreach (KeyValuePair<Point, Item> keyValuePair in dictionary)
inv[keyValuePair.Key.X][keyValuePair.Key.Y] = keyValuePair.Value.Clone();
flag = false;
break;
}
}
}
return flag;
}
public virtual bool Accepts(Item item) => this._valuePerUnit.ContainsKey(item.type);
public virtual void DrawSavingsMoney(
SpriteBatch sb,
string text,
float shopx,
float shopy,
long totalCoins,
bool horizontal = false)
{
}
public virtual void GetPriceText(string[] lines, ref int currentLine, int price)
{
}
protected int SortByHighest(Tuple<int, int> valueA, Tuple<int, int> valueB) => valueA.Item2 > valueB.Item2 || valueA.Item2 != valueB.Item2 ? -1 : 0;
protected List<Tuple<Point, Item>> ItemCacheCreate(List<Item[]> inventories)
{
List<Tuple<Point, Item>> tupleList = new List<Tuple<Point, Item>>();
for (int index = 0; index < inventories.Count; ++index)
{
for (int y = 0; y < inventories[index].Length; ++y)
{
Item obj = inventories[index][y];
tupleList.Add(new Tuple<Point, Item>(new Point(index, y), obj.DeepClone()));
}
}
return tupleList;
}
protected void ItemCacheRestore(List<Tuple<Point, Item>> cache, List<Item[]> inventories)
{
foreach (Tuple<Point, Item> tuple in cache)
inventories[tuple.Item1.X][tuple.Item1.Y] = tuple.Item2;
}
public virtual void GetItemExpectedPrice(
Item item,
out int calcForSelling,
out int calcForBuying)
{
int storeValue = item.GetStoreValue();
calcForSelling = storeValue;
calcForBuying = storeValue;
}
}
}

View file

@ -0,0 +1,97 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.EmoteButton
// 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.Audio;
using Terraria.Localization;
using Terraria.UI;
namespace Terraria.GameContent.UI.Elements
{
public class EmoteButton : UIElement
{
private Asset<Texture2D> _texture;
private Asset<Texture2D> _textureBorder;
private int _emoteIndex;
private bool _hovered;
private int _frameCounter;
public EmoteButton(int emoteIndex)
{
this._texture = Main.Assets.Request<Texture2D>("Images/Extra_" + (object) (short) 48, (AssetRequestMode) 1);
this._textureBorder = Main.Assets.Request<Texture2D>("Images/UI/EmoteBubbleBorder", (AssetRequestMode) 1);
this._emoteIndex = emoteIndex;
Rectangle frame = this.GetFrame();
this.Width.Set((float) frame.Width, 0.0f);
this.Height.Set((float) frame.Height, 0.0f);
}
private Rectangle GetFrame() => this._texture.Frame(8, 38, this._emoteIndex % 4 * 2 + (this._frameCounter >= 10 ? 1 : 0), this._emoteIndex / 4 + 1);
private void UpdateFrame()
{
if (++this._frameCounter < 20)
return;
this._frameCounter = 0;
}
public override void Update(GameTime gameTime)
{
this.UpdateFrame();
base.Update(gameTime);
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
CalculatedStyle dimensions = this.GetDimensions();
Vector2 position = dimensions.Position() + new Vector2(dimensions.Width, dimensions.Height) / 2f;
Rectangle frame = this.GetFrame();
Rectangle rectangle = frame;
rectangle.X = this._texture.Width() / 8;
rectangle.Y = 0;
Vector2 origin = frame.Size() / 2f;
Color white = Color.White;
Color color = Color.Black;
if (this._hovered)
color = Main.OurFavoriteColor;
spriteBatch.Draw(this._texture.Value, position, new Rectangle?(rectangle), white, 0.0f, origin, 1f, SpriteEffects.None, 0.0f);
spriteBatch.Draw(this._texture.Value, position, new Rectangle?(frame), white, 0.0f, origin, 1f, SpriteEffects.None, 0.0f);
spriteBatch.Draw(this._textureBorder.Value, position - Vector2.One * 2f, new Rectangle?(), color, 0.0f, origin, 1f, SpriteEffects.None, 0.0f);
if (!this._hovered)
return;
string cursorText = "/" + Language.GetTextValue("EmojiName." + EmoteID.Search.GetName(this._emoteIndex));
Main.instance.MouseText(cursorText);
}
public override void MouseOver(UIMouseEvent evt)
{
base.MouseOver(evt);
SoundEngine.PlaySound(12);
this._hovered = true;
}
public override void MouseOut(UIMouseEvent evt)
{
base.MouseOut(evt);
this._hovered = false;
}
public override void Click(UIMouseEvent evt)
{
base.Click(evt);
if (Main.netMode == 0)
{
EmoteBubble.NewBubble(this._emoteIndex, new WorldUIAnchor((Entity) Main.LocalPlayer), 360);
EmoteBubble.CheckForNPCsToReactToEmoteBubble(this._emoteIndex, Main.LocalPlayer);
}
else
NetMessage.SendData(120, number: Main.myPlayer, number2: ((float) this._emoteIndex));
IngameFancyUI.Close();
}
}
}

View file

@ -0,0 +1,87 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.EmotesGroupListItem
// 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.Localization;
using Terraria.UI;
namespace Terraria.GameContent.UI.Elements
{
public class EmotesGroupListItem : UIElement
{
private const int TITLE_HEIGHT = 20;
private const int SEPARATOR_HEIGHT = 10;
private const int SIZE_PER_EMOTE = 36;
private Asset<Texture2D> _tempTex;
private int _groupIndex;
private int _maxEmotesPerRow = 10;
public EmotesGroupListItem(
LocalizedText groupTitle,
int groupIndex,
int maxEmotesPerRow,
params int[] emotes)
{
maxEmotesPerRow = 14;
this.SetPadding(0.0f);
this._groupIndex = groupIndex;
this._maxEmotesPerRow = maxEmotesPerRow;
this._tempTex = Main.Assets.Request<Texture2D>("Images/UI/ButtonFavoriteInactive", (AssetRequestMode) 1);
int num1 = emotes.Length / this._maxEmotesPerRow;
if (emotes.Length % this._maxEmotesPerRow != 0)
++num1;
this.Height.Set((float) (30 + 36 * num1), 0.0f);
this.Width.Set(0.0f, 1f);
UIElement element = new UIElement()
{
Height = StyleDimension.FromPixels(30f),
Width = StyleDimension.FromPixelsAndPercent(-20f, 1f),
HAlign = 0.5f
};
element.SetPadding(0.0f);
this.Append(element);
UIHorizontalSeparator horizontalSeparator1 = new UIHorizontalSeparator();
horizontalSeparator1.Width = StyleDimension.FromPixelsAndPercent(0.0f, 1f);
horizontalSeparator1.VAlign = 1f;
horizontalSeparator1.HAlign = 0.5f;
horizontalSeparator1.Color = Color.Lerp(Color.White, new Color(63, 65, 151, (int) byte.MaxValue), 0.85f) * 0.9f;
UIHorizontalSeparator horizontalSeparator2 = horizontalSeparator1;
element.Append((UIElement) horizontalSeparator2);
UIText uiText1 = new UIText(groupTitle);
uiText1.VAlign = 1f;
uiText1.HAlign = 0.5f;
uiText1.Top = StyleDimension.FromPixels(-6f);
UIText uiText2 = uiText1;
element.Append((UIElement) uiText2);
float num2 = 6f;
for (int id = 0; id < emotes.Length; ++id)
{
int emote = emotes[id];
int num3 = id / this._maxEmotesPerRow;
int num4 = id % this._maxEmotesPerRow;
int num5 = emotes.Length % this._maxEmotesPerRow;
if (emotes.Length / this._maxEmotesPerRow != num3)
num5 = this._maxEmotesPerRow;
if (num5 == 0)
num5 = this._maxEmotesPerRow;
float num6 = (float) (36.0 * ((double) num5 / 2.0)) - 16f;
float num7 = -16f;
EmoteButton emoteButton1 = new EmoteButton(emote);
emoteButton1.HAlign = 0.0f;
emoteButton1.VAlign = 0.0f;
emoteButton1.Top = StyleDimension.FromPixels((float) (30 + num3 * 36) + num2);
emoteButton1.Left = StyleDimension.FromPixels((float) (36 * num4) - num7);
EmoteButton emoteButton2 = emoteButton1;
this.Append((UIElement) emoteButton2);
emoteButton2.SetSnapPoint("Group " + (object) groupIndex, id);
}
}
public override int CompareTo(object obj) => obj is EmotesGroupListItem emotesGroupListItem ? this._groupIndex.CompareTo(emotesGroupListItem._groupIndex) : base.CompareTo(obj);
}
}

View file

@ -0,0 +1,15 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.ExtraBestiaryInfoPageInformation
// 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 Terraria.GameContent.Bestiary;
namespace Terraria.GameContent.UI.Elements
{
public struct ExtraBestiaryInfoPageInformation
{
public BestiaryUnlockProgressReport BestiaryProgressReport;
}
}

View file

@ -0,0 +1,169 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.GroupOptionButton`1
// 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 Terraria.Audio;
using Terraria.ID;
using Terraria.Localization;
using Terraria.UI;
namespace Terraria.GameContent.UI.Elements
{
public class GroupOptionButton<T> : UIElement, IGroupOptionButton where T : IConvertible
{
private T _currentOption;
private readonly Asset<Texture2D> _BasePanelTexture;
private readonly Asset<Texture2D> _selectedBorderTexture;
private readonly Asset<Texture2D> _hoveredBorderTexture;
private readonly Asset<Texture2D> _iconTexture;
private readonly T _myOption;
private Color _color;
private Color _borderColor;
public float FadeFromBlack = 1f;
private float _whiteLerp = 0.7f;
private float _opacity = 0.7f;
private bool _hovered;
private bool _soundedHover;
public bool ShowHighlightWhenSelected = true;
private bool _UseOverrideColors;
private Color _overrideUnpickedColor = Color.White;
private Color _overridePickedColor = Color.White;
private float _overrideOpacityPicked;
private float _overrideOpacityUnpicked;
public readonly LocalizedText Description;
private UIText _title;
public T OptionValue => this._myOption;
public bool IsSelected => this._currentOption.Equals((object) this._myOption);
public GroupOptionButton(
T option,
LocalizedText title,
LocalizedText description,
Color textColor,
string iconTexturePath,
float textSize = 1f,
float titleAlignmentX = 0.5f,
float titleWidthReduction = 10f)
{
this._borderColor = Color.White;
this._currentOption = option;
this._myOption = option;
this.Description = description;
this.Width = StyleDimension.FromPixels(44f);
this.Height = StyleDimension.FromPixels(34f);
this._BasePanelTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/PanelGrayscale", (AssetRequestMode) 1);
this._selectedBorderTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/CategoryPanelHighlight", (AssetRequestMode) 1);
this._hoveredBorderTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/CategoryPanelBorder", (AssetRequestMode) 1);
if (iconTexturePath != null)
this._iconTexture = Main.Assets.Request<Texture2D>(iconTexturePath, (AssetRequestMode) 1);
this._color = Colors.InventoryDefaultColor;
if (title == null)
return;
UIText uiText1 = new UIText(title, textSize);
uiText1.HAlign = titleAlignmentX;
uiText1.VAlign = 0.5f;
uiText1.Width = StyleDimension.FromPixelsAndPercent(-titleWidthReduction, 1f);
uiText1.Top = StyleDimension.FromPixels(0.0f);
UIText uiText2 = uiText1;
uiText2.TextColor = textColor;
this.Append((UIElement) uiText2);
this._title = uiText2;
}
public void SetText(LocalizedText text, float textSize, Color color)
{
if (this._title != null)
this._title.Remove();
UIText uiText1 = new UIText(text, textSize);
uiText1.HAlign = 0.5f;
uiText1.VAlign = 0.5f;
uiText1.Width = StyleDimension.FromPixelsAndPercent(-10f, 1f);
uiText1.Top = StyleDimension.FromPixels(0.0f);
UIText uiText2 = uiText1;
uiText2.TextColor = color;
this.Append((UIElement) uiText2);
this._title = uiText2;
}
public void SetCurrentOption(T option) => this._currentOption = option;
protected override void DrawSelf(SpriteBatch spriteBatch)
{
if (this._hovered)
{
if (!this._soundedHover)
SoundEngine.PlaySound(12);
this._soundedHover = true;
}
else
this._soundedHover = false;
CalculatedStyle dimensions = this.GetDimensions();
Color color1 = this._color;
float num = this._opacity;
bool isSelected = this.IsSelected;
if (this._UseOverrideColors)
{
color1 = isSelected ? this._overridePickedColor : this._overrideUnpickedColor;
num = isSelected ? this._overrideOpacityPicked : this._overrideOpacityUnpicked;
}
Utils.DrawSplicedPanel(spriteBatch, this._BasePanelTexture.Value, (int) dimensions.X, (int) dimensions.Y, (int) dimensions.Width, (int) dimensions.Height, 10, 10, 10, 10, Color.Lerp(Color.Black, color1, this.FadeFromBlack) * num);
if (isSelected && this.ShowHighlightWhenSelected)
Utils.DrawSplicedPanel(spriteBatch, this._selectedBorderTexture.Value, (int) dimensions.X + 7, (int) dimensions.Y + 7, (int) dimensions.Width - 14, (int) dimensions.Height - 14, 10, 10, 10, 10, Color.Lerp(color1, Color.White, this._whiteLerp) * num);
if (this._hovered)
Utils.DrawSplicedPanel(spriteBatch, this._hoveredBorderTexture.Value, (int) dimensions.X, (int) dimensions.Y, (int) dimensions.Width, (int) dimensions.Height, 10, 10, 10, 10, this._borderColor);
if (this._iconTexture == null)
return;
Color color2 = Color.White;
if (!this._hovered && !isSelected)
color2 = Color.Lerp(color1, Color.White, this._whiteLerp) * num;
spriteBatch.Draw(this._iconTexture.Value, new Vector2(dimensions.X + 1f, dimensions.Y + 1f), color2);
}
public override void MouseDown(UIMouseEvent evt)
{
SoundEngine.PlaySound(12);
base.MouseDown(evt);
}
public override void MouseOver(UIMouseEvent evt)
{
base.MouseOver(evt);
this._hovered = true;
}
public override void MouseOut(UIMouseEvent evt)
{
base.MouseOut(evt);
this._hovered = false;
}
public void SetColor(Color color, float opacity)
{
this._color = color;
this._opacity = opacity;
}
public void SetColorsBasedOnSelectionState(
Color pickedColor,
Color unpickedColor,
float opacityPicked,
float opacityNotPicked)
{
this._UseOverrideColors = true;
this._overridePickedColor = pickedColor;
this._overrideUnpickedColor = unpickedColor;
this._overrideOpacityPicked = opacityPicked;
this._overrideOpacityUnpicked = opacityNotPicked;
}
public void SetBorderColor(Color color) => this._borderColor = color;
}
}

View file

@ -0,0 +1,15 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.IColorable
// 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.GameContent.UI.Elements
{
public interface IColorable
{
Color Color { get; set; }
}
}

View file

@ -0,0 +1,21 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.IGroupOptionButton
// 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.GameContent.UI.Elements
{
public interface IGroupOptionButton
{
void SetColorsBasedOnSelectionState(
Color pickedColor,
Color unpickedColor,
float opacityPicked,
float opacityNotPicked);
void SetBorderColor(Color color);
}
}

View file

@ -0,0 +1,13 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.IManuallyOrderedUIElement
// 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.GameContent.UI.Elements
{
public interface IManuallyOrderedUIElement
{
int OrderInUIList { get; set; }
}
}

View file

@ -0,0 +1,49 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.PowerStripUIElement
// 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.UI;
namespace Terraria.GameContent.UI.Elements
{
public class PowerStripUIElement : UIElement
{
private List<UIElement> _buttonsBySorting;
private string _gamepadPointGroupname;
public PowerStripUIElement(string gamepadGroupName, List<UIElement> buttons)
{
this._buttonsBySorting = new List<UIElement>((IEnumerable<UIElement>) buttons);
this._gamepadPointGroupname = gamepadGroupName;
int count = buttons.Count;
int num1 = 4;
int num2 = 40;
int num3 = 40;
int num4 = num3 + num1;
UIPanel uiPanel1 = new UIPanel();
uiPanel1.Width = new StyleDimension((float) (num2 + num1 * 2), 0.0f);
uiPanel1.Height = new StyleDimension((float) (num3 * count + num1 * (1 + count)), 0.0f);
UIPanel uiPanel2 = uiPanel1;
this.SetPadding(0.0f);
this.Width = uiPanel2.Width;
this.Height = uiPanel2.Height;
uiPanel2.BorderColor = new Color(89, 116, 213, (int) byte.MaxValue) * 0.9f;
uiPanel2.BackgroundColor = new Color(73, 94, 171) * 0.9f;
uiPanel2.SetPadding(0.0f);
this.Append((UIElement) uiPanel2);
for (int index = 0; index < count; ++index)
{
UIElement button = buttons[index];
button.HAlign = 0.5f;
button.Top = new StyleDimension((float) (num1 + num4 * index), 0.0f);
button.SetSnapPoint(this._gamepadPointGroupname, index);
uiPanel2.Append(button);
this._buttonsBySorting.Add(button);
}
}
}
}

View file

@ -0,0 +1,231 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIAchievementListItem
// 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 Terraria.Achievements;
using Terraria.Localization;
using Terraria.UI;
using Terraria.UI.Chat;
namespace Terraria.GameContent.UI.Elements
{
public class UIAchievementListItem : UIPanel
{
private Achievement _achievement;
private UIImageFramed _achievementIcon;
private UIImage _achievementIconBorders;
private const int _iconSize = 64;
private const int _iconSizeWithSpace = 66;
private const int _iconsPerRow = 8;
private int _iconIndex;
private Rectangle _iconFrame;
private Rectangle _iconFrameUnlocked;
private Rectangle _iconFrameLocked;
private Asset<Texture2D> _innerPanelTopTexture;
private Asset<Texture2D> _innerPanelBottomTexture;
private Asset<Texture2D> _categoryTexture;
private bool _locked;
private bool _large;
public UIAchievementListItem(Achievement achievement, bool largeForOtherLanguages)
{
this._large = largeForOtherLanguages;
this.BackgroundColor = new Color(26, 40, 89) * 0.8f;
this.BorderColor = new Color(13, 20, 44) * 0.8f;
float num = (float) (16 + this._large.ToInt() * 20);
float pixels1 = (float) (this._large.ToInt() * 6);
float pixels2 = (float) (this._large.ToInt() * 12);
this._achievement = achievement;
this.Height.Set(66f + num, 0.0f);
this.Width.Set(0.0f, 1f);
this.PaddingTop = 8f;
this.PaddingLeft = 9f;
int iconIndex = Main.Achievements.GetIconIndex(achievement.Name);
this._iconIndex = iconIndex;
this._iconFrameUnlocked = new Rectangle(iconIndex % 8 * 66, iconIndex / 8 * 66, 64, 64);
this._iconFrameLocked = this._iconFrameUnlocked;
this._iconFrameLocked.X += 528;
this._iconFrame = this._iconFrameLocked;
this.UpdateIconFrame();
this._achievementIcon = new UIImageFramed(Main.Assets.Request<Texture2D>("Images/UI/Achievements", (AssetRequestMode) 1), this._iconFrame);
this._achievementIcon.Left.Set(pixels1, 0.0f);
this._achievementIcon.Top.Set(pixels2, 0.0f);
this.Append((UIElement) this._achievementIcon);
this._achievementIconBorders = new UIImage(Main.Assets.Request<Texture2D>("Images/UI/Achievement_Borders", (AssetRequestMode) 1));
this._achievementIconBorders.Left.Set(pixels1 - 4f, 0.0f);
this._achievementIconBorders.Top.Set(pixels2 - 4f, 0.0f);
this.Append((UIElement) this._achievementIconBorders);
this._innerPanelTopTexture = Main.Assets.Request<Texture2D>("Images/UI/Achievement_InnerPanelTop", (AssetRequestMode) 1);
this._innerPanelBottomTexture = !this._large ? Main.Assets.Request<Texture2D>("Images/UI/Achievement_InnerPanelBottom", (AssetRequestMode) 1) : Main.Assets.Request<Texture2D>("Images/UI/Achievement_InnerPanelBottom_Large", (AssetRequestMode) 1);
this._categoryTexture = Main.Assets.Request<Texture2D>("Images/UI/Achievement_Categories", (AssetRequestMode) 1);
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
base.DrawSelf(spriteBatch);
int num1 = this._large.ToInt() * 6;
Vector2 vector2_1 = new Vector2((float) num1, 0.0f);
this._locked = !this._achievement.IsCompleted;
this.UpdateIconFrame();
CalculatedStyle innerDimensions = this.GetInnerDimensions();
CalculatedStyle dimensions = this._achievementIconBorders.GetDimensions();
Vector2 vector2_2 = new Vector2(dimensions.X + dimensions.Width + 7f, innerDimensions.Y);
Tuple<Decimal, Decimal> trackerValues = this.GetTrackerValues();
bool flag = false;
if ((!(trackerValues.Item1 == 0M) || !(trackerValues.Item2 == 0M)) && this._locked)
flag = true;
float num2 = (float) ((double) innerDimensions.Width - (double) dimensions.Width + 1.0) - (float) (num1 * 2);
Vector2 baseScale1 = new Vector2(0.85f);
Vector2 baseScale2 = new Vector2(0.92f);
string wrappedText = FontAssets.ItemStack.Value.CreateWrappedText(this._achievement.Description.Value, (float) (((double) num2 - 20.0) * (1.0 / (double) baseScale2.X)), Language.ActiveCulture.CultureInfo);
Vector2 stringSize1 = ChatManager.GetStringSize(FontAssets.ItemStack.Value, wrappedText, baseScale2, num2);
if (!this._large)
stringSize1 = ChatManager.GetStringSize(FontAssets.ItemStack.Value, this._achievement.Description.Value, baseScale2, num2);
float num3 = (float) (38.0 + (this._large ? 20.0 : 0.0));
if ((double) stringSize1.Y > (double) num3)
baseScale2.Y *= num3 / stringSize1.Y;
Color baseColor1 = Color.Lerp(this._locked ? Color.Silver : Color.Gold, Color.White, this.IsMouseHovering ? 0.5f : 0.0f);
Color baseColor2 = Color.Lerp(this._locked ? Color.DarkGray : Color.Silver, Color.White, this.IsMouseHovering ? 1f : 0.0f);
Color color1 = this.IsMouseHovering ? Color.White : Color.Gray;
Vector2 position1 = vector2_2 - Vector2.UnitY * 2f + vector2_1;
this.DrawPanelTop(spriteBatch, position1, num2, color1);
AchievementCategory category = this._achievement.Category;
position1.Y += 2f;
position1.X += 4f;
spriteBatch.Draw(this._categoryTexture.Value, position1, new Rectangle?(this._categoryTexture.Frame(4, 2, (int) category)), this.IsMouseHovering ? Color.White : Color.Silver, 0.0f, Vector2.Zero, 0.5f, SpriteEffects.None, 0.0f);
position1.X += 4f;
position1.X += 17f;
ChatManager.DrawColorCodedStringWithShadow(spriteBatch, FontAssets.ItemStack.Value, this._achievement.FriendlyName.Value, position1, baseColor1, 0.0f, Vector2.Zero, baseScale1, num2);
position1.X -= 17f;
Vector2 position2 = vector2_2 + Vector2.UnitY * 27f + vector2_1;
this.DrawPanelBottom(spriteBatch, position2, num2, color1);
position2.X += 8f;
position2.Y += 4f;
ChatManager.DrawColorCodedStringWithShadow(spriteBatch, FontAssets.ItemStack.Value, wrappedText, position2, baseColor2, 0.0f, Vector2.Zero, baseScale2);
if (!flag)
return;
Vector2 position3 = position1 + Vector2.UnitX * num2 + Vector2.UnitY;
string text = ((int) trackerValues.Item1).ToString() + "/" + (object) (int) trackerValues.Item2;
Vector2 baseScale3 = new Vector2(0.75f);
Vector2 stringSize2 = ChatManager.GetStringSize(FontAssets.ItemStack.Value, text, baseScale3);
float progress = (float) (trackerValues.Item1 / trackerValues.Item2);
float Width = 80f;
Color color2 = new Color(100, (int) byte.MaxValue, 100);
if (!this.IsMouseHovering)
color2 = Color.Lerp(color2, Color.Black, 0.25f);
Color BackColor = new Color((int) byte.MaxValue, (int) byte.MaxValue, (int) byte.MaxValue);
if (!this.IsMouseHovering)
BackColor = Color.Lerp(BackColor, Color.Black, 0.25f);
this.DrawProgressBar(spriteBatch, progress, position3 - Vector2.UnitX * Width * 0.7f, Width, BackColor, color2, color2.MultiplyRGBA(new Color(new Vector4(1f, 1f, 1f, 0.5f))));
position3.X -= Width * 1.4f + stringSize2.X;
ChatManager.DrawColorCodedStringWithShadow(spriteBatch, FontAssets.ItemStack.Value, text, position3, baseColor1, 0.0f, new Vector2(0.0f, 0.0f), baseScale3, 90f);
}
private void UpdateIconFrame()
{
this._iconFrame = this._locked ? this._iconFrameLocked : this._iconFrameUnlocked;
if (this._achievementIcon == null)
return;
this._achievementIcon.SetFrame(this._iconFrame);
}
private void DrawPanelTop(SpriteBatch spriteBatch, Vector2 position, float width, Color color)
{
spriteBatch.Draw(this._innerPanelTopTexture.Value, position, new Rectangle?(new Rectangle(0, 0, 2, this._innerPanelTopTexture.Height())), color);
spriteBatch.Draw(this._innerPanelTopTexture.Value, new Vector2(position.X + 2f, position.Y), new Rectangle?(new Rectangle(2, 0, 2, this._innerPanelTopTexture.Height())), color, 0.0f, Vector2.Zero, new Vector2((float) (((double) width - 4.0) / 2.0), 1f), SpriteEffects.None, 0.0f);
spriteBatch.Draw(this._innerPanelTopTexture.Value, new Vector2((float) ((double) position.X + (double) width - 2.0), position.Y), new Rectangle?(new Rectangle(4, 0, 2, this._innerPanelTopTexture.Height())), color);
}
private void DrawPanelBottom(
SpriteBatch spriteBatch,
Vector2 position,
float width,
Color color)
{
spriteBatch.Draw(this._innerPanelBottomTexture.Value, position, new Rectangle?(new Rectangle(0, 0, 6, this._innerPanelBottomTexture.Height())), color);
spriteBatch.Draw(this._innerPanelBottomTexture.Value, new Vector2(position.X + 6f, position.Y), new Rectangle?(new Rectangle(6, 0, 7, this._innerPanelBottomTexture.Height())), color, 0.0f, Vector2.Zero, new Vector2((float) (((double) width - 12.0) / 7.0), 1f), SpriteEffects.None, 0.0f);
spriteBatch.Draw(this._innerPanelBottomTexture.Value, new Vector2((float) ((double) position.X + (double) width - 6.0), position.Y), new Rectangle?(new Rectangle(13, 0, 6, this._innerPanelBottomTexture.Height())), color);
}
public override void MouseOver(UIMouseEvent evt)
{
base.MouseOver(evt);
this.BackgroundColor = new Color(46, 60, 119);
this.BorderColor = new Color(20, 30, 56);
}
public override void MouseOut(UIMouseEvent evt)
{
base.MouseOut(evt);
this.BackgroundColor = new Color(26, 40, 89) * 0.8f;
this.BorderColor = new Color(13, 20, 44) * 0.8f;
}
public Achievement GetAchievement() => this._achievement;
private Tuple<Decimal, Decimal> GetTrackerValues()
{
if (!this._achievement.HasTracker)
return Tuple.Create<Decimal, Decimal>(0M, 0M);
IAchievementTracker tracker = this._achievement.GetTracker();
if (tracker.GetTrackerType() == TrackerType.Int)
{
AchievementTracker<int> achievementTracker = (AchievementTracker<int>) tracker;
return Tuple.Create<Decimal, Decimal>((Decimal) achievementTracker.Value, (Decimal) achievementTracker.MaxValue);
}
if (tracker.GetTrackerType() != TrackerType.Float)
return Tuple.Create<Decimal, Decimal>(0M, 0M);
AchievementTracker<float> achievementTracker1 = (AchievementTracker<float>) tracker;
return Tuple.Create<Decimal, Decimal>((Decimal) achievementTracker1.Value, (Decimal) achievementTracker1.MaxValue);
}
private void DrawProgressBar(
SpriteBatch spriteBatch,
float progress,
Vector2 spot,
float Width = 169f,
Color BackColor = default (Color),
Color FillingColor = default (Color),
Color BlipColor = default (Color))
{
if (BlipColor == Color.Transparent)
BlipColor = new Color((int) byte.MaxValue, 165, 0, (int) sbyte.MaxValue);
if (FillingColor == Color.Transparent)
FillingColor = new Color((int) byte.MaxValue, 241, 51);
if (BackColor == Color.Transparent)
FillingColor = new Color((int) byte.MaxValue, (int) byte.MaxValue, (int) byte.MaxValue);
Texture2D texture1 = TextureAssets.ColorBar.Value;
Texture2D texture2D = TextureAssets.ColorBlip.Value;
Texture2D texture2 = TextureAssets.MagicPixel.Value;
float num1 = MathHelper.Clamp(progress, 0.0f, 1f);
float num2 = Width * 1f;
float y = 8f;
float x = num2 / 169f;
Vector2 vector2 = spot + Vector2.UnitY * y + Vector2.UnitX * 1f;
spriteBatch.Draw(texture1, spot, new Rectangle?(new Rectangle(5, 0, texture1.Width - 9, texture1.Height)), BackColor, 0.0f, new Vector2(84.5f, 0.0f), new Vector2(x, 1f), SpriteEffects.None, 0.0f);
spriteBatch.Draw(texture1, spot + new Vector2((float) (-(double) x * 84.5 - 5.0), 0.0f), new Rectangle?(new Rectangle(0, 0, 5, texture1.Height)), BackColor, 0.0f, Vector2.Zero, Vector2.One, SpriteEffects.None, 0.0f);
spriteBatch.Draw(texture1, spot + new Vector2(x * 84.5f, 0.0f), new Rectangle?(new Rectangle(texture1.Width - 4, 0, 4, texture1.Height)), BackColor, 0.0f, Vector2.Zero, Vector2.One, SpriteEffects.None, 0.0f);
Vector2 position = vector2 + Vector2.UnitX * (num1 - 0.5f) * num2;
--position.X;
spriteBatch.Draw(texture2, position, new Rectangle?(new Rectangle(0, 0, 1, 1)), FillingColor, 0.0f, new Vector2(1f, 0.5f), new Vector2(num2 * num1, y), SpriteEffects.None, 0.0f);
if ((double) progress != 0.0)
spriteBatch.Draw(texture2, position, new Rectangle?(new Rectangle(0, 0, 1, 1)), BlipColor, 0.0f, new Vector2(1f, 0.5f), new Vector2(2f, y), SpriteEffects.None, 0.0f);
spriteBatch.Draw(texture2, position, new Rectangle?(new Rectangle(0, 0, 1, 1)), Color.Black, 0.0f, new Vector2(0.0f, 0.5f), new Vector2(num2 * (1f - num1), y), SpriteEffects.None, 0.0f);
}
public override int CompareTo(object obj)
{
if (!(obj is UIAchievementListItem achievementListItem))
return 0;
if (this._achievement.IsCompleted && !achievementListItem._achievement.IsCompleted)
return -1;
return !this._achievement.IsCompleted && achievementListItem._achievement.IsCompleted ? 1 : this._achievement.Id.CompareTo(achievementListItem._achievement.Id);
}
}
}

View file

@ -0,0 +1,155 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIBestiaryEntryButton
// 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.Audio;
using Terraria.GameContent.Bestiary;
using Terraria.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UIBestiaryEntryButton : UIElement
{
private UIImage _bordersGlow;
private UIImage _bordersOverlay;
private UIImage _borders;
private UIBestiaryEntryIcon _icon;
public BestiaryEntry Entry { get; private set; }
public UIBestiaryEntryButton(BestiaryEntry entry, bool isAPrettyPortrait)
{
this.Entry = entry;
this.Height.Set(72f, 0.0f);
this.Width.Set(72f, 0.0f);
this.SetPadding(0.0f);
UIElement element = new UIElement()
{
Width = new StyleDimension(-4f, 1f),
Height = new StyleDimension(-4f, 1f),
IgnoresMouseInteraction = true,
OverflowHidden = true,
HAlign = 0.5f,
VAlign = 0.5f
};
element.SetPadding(0.0f);
UIImage uiImage1 = new UIImage(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Slot_Back", (AssetRequestMode) 1));
uiImage1.VAlign = 0.5f;
uiImage1.HAlign = 0.5f;
element.Append((UIElement) uiImage1);
if (isAPrettyPortrait)
{
Asset<Texture2D> texture = this.TryGettingBackgroundImageProvider(entry);
if (texture != null)
{
UIElement uiElement = element;
UIImage uiImage2 = new UIImage(texture);
uiImage2.HAlign = 0.5f;
uiImage2.VAlign = 0.5f;
uiElement.Append((UIElement) uiImage2);
}
}
UIBestiaryEntryIcon bestiaryEntryIcon = new UIBestiaryEntryIcon(entry, isAPrettyPortrait);
element.Append((UIElement) bestiaryEntryIcon);
this.Append(element);
this._icon = bestiaryEntryIcon;
int? nullable = this.TryGettingDisplayIndex(entry);
if (nullable.HasValue)
{
UIText uiText = new UIText(nullable.Value.ToString(), 0.9f);
uiText.Top = new StyleDimension(10f, 0.0f);
uiText.Left = new StyleDimension(10f, 0.0f);
uiText.IgnoresMouseInteraction = true;
this.Append((UIElement) uiText);
}
UIImage uiImage3 = new UIImage(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Slot_Selection", (AssetRequestMode) 1));
uiImage3.VAlign = 0.5f;
uiImage3.HAlign = 0.5f;
uiImage3.IgnoresMouseInteraction = true;
this._bordersGlow = uiImage3;
UIImage uiImage4 = new UIImage(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Slot_Overlay", (AssetRequestMode) 1));
uiImage4.VAlign = 0.5f;
uiImage4.HAlign = 0.5f;
uiImage4.IgnoresMouseInteraction = true;
uiImage4.Color = Color.White * 0.6f;
this._bordersOverlay = uiImage4;
this.Append((UIElement) this._bordersOverlay);
UIImage uiImage5 = new UIImage(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Slot_Front", (AssetRequestMode) 1));
uiImage5.VAlign = 0.5f;
uiImage5.HAlign = 0.5f;
uiImage5.IgnoresMouseInteraction = true;
this.Append((UIElement) uiImage5);
this._borders = uiImage5;
if (isAPrettyPortrait)
this.RemoveChild((UIElement) this._bordersOverlay);
if (isAPrettyPortrait)
return;
this.OnMouseOver += new UIElement.MouseEvent(this.MouseOver);
this.OnMouseOut += new UIElement.MouseEvent(this.MouseOut);
}
private Asset<Texture2D> TryGettingBackgroundImageProvider(BestiaryEntry entry)
{
IEnumerable<IBestiaryBackgroundImagePathAndColorProvider> source = entry.Info.Where<IBestiaryInfoElement>((Func<IBestiaryInfoElement, bool>) (x => x is IBestiaryBackgroundImagePathAndColorProvider)).Select<IBestiaryInfoElement, IBestiaryBackgroundImagePathAndColorProvider>((Func<IBestiaryInfoElement, IBestiaryBackgroundImagePathAndColorProvider>) (x => x as IBestiaryBackgroundImagePathAndColorProvider));
IEnumerable<IPreferenceProviderElement> preferences = entry.Info.OfType<IPreferenceProviderElement>();
foreach (IBestiaryBackgroundImagePathAndColorProvider andColorProvider in source.Where<IBestiaryBackgroundImagePathAndColorProvider>((Func<IBestiaryBackgroundImagePathAndColorProvider, bool>) (provider => preferences.Any<IPreferenceProviderElement>((Func<IPreferenceProviderElement, bool>) (preference => preference.Matches(provider))))))
{
Asset<Texture2D> backgroundImage = andColorProvider.GetBackgroundImage();
if (backgroundImage != null)
return backgroundImage;
}
foreach (IBestiaryBackgroundImagePathAndColorProvider andColorProvider in source)
{
Asset<Texture2D> backgroundImage = andColorProvider.GetBackgroundImage();
if (backgroundImage != null)
return backgroundImage;
}
return (Asset<Texture2D>) null;
}
private int? TryGettingDisplayIndex(BestiaryEntry entry)
{
int? nullable = new int?();
IBestiaryInfoElement bestiaryInfoElement = entry.Info.FirstOrDefault<IBestiaryInfoElement>((Func<IBestiaryInfoElement, bool>) (x => x is IBestiaryEntryDisplayIndex));
if (bestiaryInfoElement != null)
nullable = new int?((bestiaryInfoElement as IBestiaryEntryDisplayIndex).BestiaryDisplayIndex);
return nullable;
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
if (!this.IsMouseHovering)
return;
Main.instance.MouseText(this._icon.GetHoverText());
}
private void MouseOver(UIMouseEvent evt, UIElement listeningElement)
{
SoundEngine.PlaySound(12);
this.RemoveChild((UIElement) this._borders);
this.RemoveChild((UIElement) this._bordersGlow);
this.RemoveChild((UIElement) this._bordersOverlay);
this.Append((UIElement) this._borders);
this.Append((UIElement) this._bordersGlow);
this._icon.ForceHover = true;
}
private void MouseOut(UIMouseEvent evt, UIElement listeningElement)
{
this.RemoveChild((UIElement) this._borders);
this.RemoveChild((UIElement) this._bordersGlow);
this.RemoveChild((UIElement) this._bordersOverlay);
this.Append((UIElement) this._bordersOverlay);
this.Append((UIElement) this._borders);
this._icon.ForceHover = false;
}
}
}

View file

@ -0,0 +1,124 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIBestiaryEntryGrid
// 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.GameContent.Bestiary;
using Terraria.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UIBestiaryEntryGrid : UIElement
{
private List<BestiaryEntry> _workingSetEntries;
private UIElement.MouseEvent _clickOnEntryEvent;
private int _atEntryIndex;
private int _lastEntry;
public event Action OnGridContentsChanged;
public UIBestiaryEntryGrid(
List<BestiaryEntry> workingSet,
UIElement.MouseEvent clickOnEntryEvent)
{
this.Width = new StyleDimension(0.0f, 1f);
this.Height = new StyleDimension(0.0f, 1f);
this._workingSetEntries = workingSet;
this._clickOnEntryEvent = clickOnEntryEvent;
this.SetPadding(0.0f);
this.UpdateEntries();
this.FillBestiarySpaceWithEntries();
}
public void UpdateEntries() => this._lastEntry = this._workingSetEntries.Count;
public void FillBestiarySpaceWithEntries()
{
this.RemoveAllChildren();
this.UpdateEntries();
int maxEntriesWidth;
int maxEntriesHeight;
int maxEntriesToHave;
this.GetEntriesToShow(out maxEntriesWidth, out maxEntriesHeight, out maxEntriesToHave);
this.FixBestiaryRange(0, maxEntriesToHave);
int atEntryIndex = this._atEntryIndex;
int num1 = Math.Min(this._lastEntry, atEntryIndex + maxEntriesToHave);
List<BestiaryEntry> bestiaryEntryList = new List<BestiaryEntry>();
for (int index = atEntryIndex; index < num1; ++index)
bestiaryEntryList.Add(this._workingSetEntries[index]);
int num2 = 0;
float num3 = 0.5f / (float) maxEntriesWidth;
float num4 = 0.5f / (float) maxEntriesHeight;
for (int index1 = 0; index1 < maxEntriesHeight; ++index1)
{
for (int index2 = 0; index2 < maxEntriesWidth && num2 < bestiaryEntryList.Count; ++index2)
{
UIElement element = (UIElement) new UIBestiaryEntryButton(bestiaryEntryList[num2], false);
++num2;
element.OnClick += this._clickOnEntryEvent;
element.VAlign = element.HAlign = 0.5f;
element.Left.Set(0.0f, (float) ((double) index2 / (double) maxEntriesWidth - 0.5) + num3);
element.Top.Set(0.0f, (float) ((double) index1 / (double) maxEntriesHeight - 0.5) + num4);
element.SetSnapPoint("Entries", num2, new Vector2?(new Vector2(0.2f, 0.7f)));
this.Append(element);
}
}
}
public override void Recalculate()
{
base.Recalculate();
this.FillBestiarySpaceWithEntries();
}
public void GetEntriesToShow(
out int maxEntriesWidth,
out int maxEntriesHeight,
out int maxEntriesToHave)
{
Rectangle rectangle = this.GetDimensions().ToRectangle();
maxEntriesWidth = rectangle.Width / 72;
maxEntriesHeight = rectangle.Height / 72;
int num = 0;
maxEntriesToHave = maxEntriesWidth * maxEntriesHeight - num;
}
public string GetRangeText()
{
int maxEntriesToHave;
this.GetEntriesToShow(out int _, out int _, out maxEntriesToHave);
int atEntryIndex = this._atEntryIndex;
int val2 = Math.Min(this._lastEntry, atEntryIndex + maxEntriesToHave);
return string.Format("{0}-{1} ({2})", (object) Math.Min(atEntryIndex + 1, val2), (object) val2, (object) this._lastEntry);
}
public void MakeButtonGoByOffset(UIElement element, int howManyPages) => element.OnClick += (UIElement.MouseEvent) ((e, v) => this.OffsetLibraryByPages(howManyPages));
public void OffsetLibraryByPages(int howManyPages)
{
int maxEntriesToHave;
this.GetEntriesToShow(out int _, out int _, out maxEntriesToHave);
this.OffsetLibrary(howManyPages * maxEntriesToHave);
}
public void OffsetLibrary(int offset)
{
int maxEntriesToHave;
this.GetEntriesToShow(out int _, out int _, out maxEntriesToHave);
this.FixBestiaryRange(offset, maxEntriesToHave);
this.FillBestiarySpaceWithEntries();
}
private void FixBestiaryRange(int offset, int maxEntriesToHave)
{
this._atEntryIndex = Utils.Clamp<int>(this._atEntryIndex + offset, 0, Math.Max(0, this._lastEntry - maxEntriesToHave));
if (this.OnGridContentsChanged == null)
return;
this.OnGridContentsChanged();
}
}
}

View file

@ -0,0 +1,73 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIBestiaryEntryIcon
// 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.GameContent.Bestiary;
using Terraria.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UIBestiaryEntryIcon : UIElement
{
private BestiaryEntry _entry;
private Asset<Texture2D> _notUnlockedTexture;
private bool _isPortrait;
public bool ForceHover;
private BestiaryUICollectionInfo _collectionInfo;
public UIBestiaryEntryIcon(BestiaryEntry entry, bool isPortrait)
{
this._entry = entry;
this.IgnoresMouseInteraction = true;
this.OverrideSamplerState = Main.DefaultSamplerState;
this.UseImmediateMode = true;
this.Width.Set(0.0f, 1f);
this.Height.Set(0.0f, 1f);
this._notUnlockedTexture = Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Icon_Locked", (AssetRequestMode) 1);
this._isPortrait = isPortrait;
this._collectionInfo = this._entry.UIInfoProvider.GetEntryUICollectionInfo();
}
public override void Update(GameTime gameTime)
{
this._collectionInfo = this._entry.UIInfoProvider.GetEntryUICollectionInfo();
CalculatedStyle dimensions = this.GetDimensions();
bool flag = this.IsMouseHovering || this.ForceHover;
this._entry.Icon.Update(this._collectionInfo, dimensions.ToRectangle(), new EntryIconDrawSettings()
{
iconbox = dimensions.ToRectangle(),
IsPortrait = this._isPortrait,
IsHovered = flag
});
base.Update(gameTime);
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
CalculatedStyle dimensions = this.GetDimensions();
int num = this._entry.Icon.GetUnlockState(this._collectionInfo) ? 1 : 0;
bool flag = this.IsMouseHovering || this.ForceHover;
if (num != 0)
{
this._entry.Icon.Draw(this._collectionInfo, spriteBatch, new EntryIconDrawSettings()
{
iconbox = dimensions.ToRectangle(),
IsPortrait = this._isPortrait,
IsHovered = flag
});
}
else
{
Texture2D texture2D = this._notUnlockedTexture.Value;
spriteBatch.Draw(texture2D, dimensions.Center(), new Rectangle?(), Color.White * 0.15f, 0.0f, texture2D.Size() / 2f, 1f, SpriteEffects.None, 0.0f);
}
}
public string GetHoverText() => this._entry.Icon.GetHoverText(this._collectionInfo);
}
}

View file

@ -0,0 +1,188 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIBestiaryEntryInfoPage
// 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.GameContent.Bestiary;
using Terraria.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UIBestiaryEntryInfoPage : UIPanel
{
private UIList _list;
private UIScrollbar _scrollbar;
private bool _isScrollbarAttached;
public UIBestiaryEntryInfoPage()
{
this.Width.Set(230f, 0.0f);
this.Height.Set(0.0f, 1f);
this.SetPadding(0.0f);
this.BorderColor = new Color(89, 116, 213, (int) byte.MaxValue);
this.BackgroundColor = new Color(73, 94, 171);
UIList uiList1 = new UIList();
uiList1.Width = StyleDimension.FromPixelsAndPercent(0.0f, 1f);
uiList1.Height = StyleDimension.FromPixelsAndPercent(0.0f, 1f);
UIList uiList2 = uiList1;
uiList2.SetPadding(2f);
uiList2.PaddingBottom = 4f;
uiList2.PaddingTop = 4f;
this.Append((UIElement) uiList2);
this._list = uiList2;
uiList2.ListPadding = 4f;
uiList2.ManualSortMethod = new Action<List<UIElement>>(this.ManualIfnoSortingMethod);
UIScrollbar uiScrollbar = new UIScrollbar();
uiScrollbar.SetView(100f, 1000f);
uiScrollbar.Height.Set(-20f, 1f);
uiScrollbar.HAlign = 1f;
uiScrollbar.VAlign = 0.5f;
uiScrollbar.Left.Set(-6f, 0.0f);
this._scrollbar = uiScrollbar;
this._list.SetScrollbar(this._scrollbar);
this.CheckScrollBar();
this.AppendBorderOverEverything();
}
public void UpdateScrollbar(int scrollWheelValue)
{
if (this._scrollbar == null)
return;
this._scrollbar.ViewPosition -= (float) scrollWheelValue;
}
private void AppendBorderOverEverything()
{
UIPanel uiPanel1 = new UIPanel();
uiPanel1.Width = new StyleDimension(0.0f, 1f);
uiPanel1.Height = new StyleDimension(0.0f, 1f);
uiPanel1.IgnoresMouseInteraction = true;
UIPanel uiPanel2 = uiPanel1;
uiPanel2.BorderColor = new Color(89, 116, 213, (int) byte.MaxValue);
uiPanel2.BackgroundColor = Color.Transparent;
this.Append((UIElement) uiPanel2);
}
private void ManualIfnoSortingMethod(List<UIElement> list)
{
}
public override void Recalculate()
{
base.Recalculate();
this.CheckScrollBar();
}
private void CheckScrollBar()
{
if (this._scrollbar == null)
return;
bool canScroll = this._scrollbar.CanScroll;
bool flag = true;
if (this._isScrollbarAttached && !flag)
{
this.RemoveChild((UIElement) this._scrollbar);
this._isScrollbarAttached = false;
this._list.Width.Set(0.0f, 1f);
}
else
{
if (!(!this._isScrollbarAttached & flag))
return;
this.Append((UIElement) this._scrollbar);
this._isScrollbarAttached = true;
this._list.Width.Set(-20f, 1f);
}
}
public void FillInfoForEntry(BestiaryEntry entry, ExtraBestiaryInfoPageInformation extraInfo)
{
this._list.Clear();
if (entry == null)
return;
this.AddInfoToList(entry, extraInfo);
this.Recalculate();
}
private BestiaryUICollectionInfo GetUICollectionInfo(
BestiaryEntry entry,
ExtraBestiaryInfoPageInformation extraInfo)
{
IBestiaryUICollectionInfoProvider uiInfoProvider = entry.UIInfoProvider;
BestiaryUICollectionInfo uiCollectionInfo = uiInfoProvider == null ? new BestiaryUICollectionInfo() : uiInfoProvider.GetEntryUICollectionInfo();
uiCollectionInfo.OwnerEntry = entry;
return uiCollectionInfo;
}
private void AddInfoToList(BestiaryEntry entry, ExtraBestiaryInfoPageInformation extraInfo)
{
BestiaryUICollectionInfo uiCollectionInfo = this.GetUICollectionInfo(entry, extraInfo);
IOrderedEnumerable<IGrouping<UIBestiaryEntryInfoPage.BestiaryInfoCategory, IBestiaryInfoElement>> orderedEnumerable = new List<IBestiaryInfoElement>((IEnumerable<IBestiaryInfoElement>) entry.Info).GroupBy<IBestiaryInfoElement, UIBestiaryEntryInfoPage.BestiaryInfoCategory>(new Func<IBestiaryInfoElement, UIBestiaryEntryInfoPage.BestiaryInfoCategory>(this.GetBestiaryInfoCategory)).OrderBy<IGrouping<UIBestiaryEntryInfoPage.BestiaryInfoCategory, IBestiaryInfoElement>, UIBestiaryEntryInfoPage.BestiaryInfoCategory>((Func<IGrouping<UIBestiaryEntryInfoPage.BestiaryInfoCategory, IBestiaryInfoElement>, UIBestiaryEntryInfoPage.BestiaryInfoCategory>) (x => x.Key));
UIElement uiElement1 = (UIElement) null;
foreach (IGrouping<UIBestiaryEntryInfoPage.BestiaryInfoCategory, IBestiaryInfoElement> source in (IEnumerable<IGrouping<UIBestiaryEntryInfoPage.BestiaryInfoCategory, IBestiaryInfoElement>>) orderedEnumerable)
{
if (source.Count<IBestiaryInfoElement>() != 0)
{
bool flag = false;
foreach (IBestiaryInfoElement bestiaryInfoElement in (IEnumerable<IBestiaryInfoElement>) source)
{
UIElement uiElement2 = bestiaryInfoElement.ProvideUIElement(uiCollectionInfo);
if (uiElement2 != null)
{
this._list.Add(uiElement2);
flag = true;
}
}
if (flag)
{
UIHorizontalSeparator horizontalSeparator1 = new UIHorizontalSeparator();
horizontalSeparator1.Width = StyleDimension.FromPixelsAndPercent(0.0f, 1f);
horizontalSeparator1.Color = new Color(89, 116, 213, (int) byte.MaxValue) * 0.9f;
UIHorizontalSeparator horizontalSeparator2 = horizontalSeparator1;
this._list.Add((UIElement) horizontalSeparator2);
uiElement1 = (UIElement) horizontalSeparator2;
}
}
}
this._list.Remove(uiElement1);
}
private UIBestiaryEntryInfoPage.BestiaryInfoCategory GetBestiaryInfoCategory(
IBestiaryInfoElement element)
{
switch (element)
{
case NPCPortraitInfoElement _:
return UIBestiaryEntryInfoPage.BestiaryInfoCategory.Portrait;
case FlavorTextBestiaryInfoElement _:
return UIBestiaryEntryInfoPage.BestiaryInfoCategory.FlavorText;
case NamePlateInfoElement _:
return UIBestiaryEntryInfoPage.BestiaryInfoCategory.Nameplate;
case ItemFromCatchingNPCBestiaryInfoElement _:
return UIBestiaryEntryInfoPage.BestiaryInfoCategory.ItemsFromCatchingNPC;
case ItemDropBestiaryInfoElement _:
return UIBestiaryEntryInfoPage.BestiaryInfoCategory.ItemsFromDrops;
case NPCStatsReportInfoElement _:
return UIBestiaryEntryInfoPage.BestiaryInfoCategory.Stats;
default:
return UIBestiaryEntryInfoPage.BestiaryInfoCategory.Misc;
}
}
private enum BestiaryInfoCategory
{
Nameplate,
Portrait,
FlavorText,
Stats,
ItemsFromCatchingNPC,
ItemsFromDrops,
Misc,
}
}
}

View file

@ -0,0 +1,244 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIBestiaryFilteringOptionsGrid
// 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 Terraria.DataStructures;
using Terraria.GameContent.Bestiary;
using Terraria.ID;
using Terraria.Localization;
using Terraria.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UIBestiaryFilteringOptionsGrid : UIPanel
{
private EntryFilterer<BestiaryEntry, IBestiaryEntryFilter> _filterer;
private List<GroupOptionButton<int>> _filterButtons;
private List<bool> _areFiltersAvailable;
private List<List<BestiaryEntry>> _filterAvailabilityTests;
private UIElement _container;
public event Action OnClickingOption;
public UIBestiaryFilteringOptionsGrid(
EntryFilterer<BestiaryEntry, IBestiaryEntryFilter> filterer)
{
this._filterer = filterer;
this._filterButtons = new List<GroupOptionButton<int>>();
this._areFiltersAvailable = new List<bool>();
this._filterAvailabilityTests = new List<List<BestiaryEntry>>();
this.Width = new StyleDimension(0.0f, 1f);
this.Height = new StyleDimension(0.0f, 1f);
this.BackgroundColor = new Color(35, 40, 83) * 0.5f;
this.BorderColor = new Color(35, 40, 83) * 0.5f;
this.IgnoresMouseInteraction = false;
this.SetPadding(0.0f);
this.BuildContainer();
}
private void BuildContainer()
{
int widthWithSpacing;
int heightWithSpacing;
int perRow;
int howManyRows;
this.GetDisplaySettings(out int _, out int _, out widthWithSpacing, out heightWithSpacing, out perRow, out float _, out float _, out howManyRows);
UIPanel uiPanel1 = new UIPanel();
uiPanel1.Width = new StyleDimension((float) (perRow * widthWithSpacing + 10), 0.0f);
uiPanel1.Height = new StyleDimension((float) (howManyRows * heightWithSpacing + 10), 0.0f);
uiPanel1.HAlign = 1f;
uiPanel1.VAlign = 0.0f;
uiPanel1.Left = new StyleDimension(0.0f, 0.0f);
uiPanel1.Top = new StyleDimension(0.0f, 0.0f);
UIPanel uiPanel2 = uiPanel1;
uiPanel2.BorderColor = new Color(89, 116, 213, (int) byte.MaxValue) * 0.9f;
uiPanel2.BackgroundColor = new Color(73, 94, 171) * 0.9f;
uiPanel2.SetPadding(0.0f);
this.Append((UIElement) uiPanel2);
this._container = (UIElement) uiPanel2;
}
public void SetupAvailabilityTest(List<BestiaryEntry> allAvailableEntries)
{
this._filterAvailabilityTests.Clear();
for (int index1 = 0; index1 < this._filterer.AvailableFilters.Count; ++index1)
{
List<BestiaryEntry> bestiaryEntryList = new List<BestiaryEntry>();
this._filterAvailabilityTests.Add(bestiaryEntryList);
IBestiaryEntryFilter availableFilter = this._filterer.AvailableFilters[index1];
for (int index2 = 0; index2 < allAvailableEntries.Count; ++index2)
{
if (availableFilter.FitsFilter(allAvailableEntries[index2]))
bestiaryEntryList.Add(allAvailableEntries[index2]);
}
}
}
public void UpdateAvailability()
{
int widthPerButton;
int heightPerButton;
int widthWithSpacing;
int heightWithSpacing;
int perRow;
float offsetLeft;
float offsetTop;
this.GetDisplaySettings(out widthPerButton, out heightPerButton, out widthWithSpacing, out heightWithSpacing, out perRow, out offsetLeft, out offsetTop, out int _);
this._container.RemoveAllChildren();
this._filterButtons.Clear();
this._areFiltersAvailable.Clear();
int num1 = -1;
int num2 = -1;
for (int index = 0; index < this._filterer.AvailableFilters.Count; ++index)
{
int num3 = index / perRow;
int num4 = index % perRow;
IBestiaryEntryFilter availableFilter = this._filterer.AvailableFilters[index];
List<BestiaryEntry> availabilityTest = this._filterAvailabilityTests[index];
if (this.GetIsFilterAvailableForEntries(availableFilter, availabilityTest))
{
GroupOptionButton<int> groupOptionButton1 = new GroupOptionButton<int>(index, (LocalizedText) null, (LocalizedText) null, Color.White, (string) null);
groupOptionButton1.Width = new StyleDimension((float) widthPerButton, 0.0f);
groupOptionButton1.Height = new StyleDimension((float) heightPerButton, 0.0f);
groupOptionButton1.HAlign = 0.0f;
groupOptionButton1.VAlign = 0.0f;
groupOptionButton1.Top = new StyleDimension(offsetTop + (float) (num3 * heightWithSpacing), 0.0f);
groupOptionButton1.Left = new StyleDimension(offsetLeft + (float) (num4 * widthWithSpacing), 0.0f);
GroupOptionButton<int> groupOptionButton2 = groupOptionButton1;
groupOptionButton2.OnClick += new UIElement.MouseEvent(this.ClickOption);
groupOptionButton2.SetSnapPoint("Filters", index);
groupOptionButton2.ShowHighlightWhenSelected = false;
this.AddOnHover(availableFilter, (UIElement) groupOptionButton2);
this._container.Append((UIElement) groupOptionButton2);
UIElement image = availableFilter.GetImage();
if (image != null)
{
image.Left = new StyleDimension((float) num1, 0.0f);
image.Top = new StyleDimension((float) num2, 0.0f);
groupOptionButton2.Append(image);
}
this._filterButtons.Add(groupOptionButton2);
}
else
{
this._filterer.ActiveFilters.Remove(availableFilter);
GroupOptionButton<int> groupOptionButton3 = new GroupOptionButton<int>(-2, (LocalizedText) null, (LocalizedText) null, Color.White, (string) null);
groupOptionButton3.Width = new StyleDimension((float) widthPerButton, 0.0f);
groupOptionButton3.Height = new StyleDimension((float) heightPerButton, 0.0f);
groupOptionButton3.HAlign = 0.0f;
groupOptionButton3.VAlign = 0.0f;
groupOptionButton3.Top = new StyleDimension(offsetTop + (float) (num3 * heightWithSpacing), 0.0f);
groupOptionButton3.Left = new StyleDimension(offsetLeft + (float) (num4 * widthWithSpacing), 0.0f);
groupOptionButton3.FadeFromBlack = 0.5f;
GroupOptionButton<int> groupOptionButton4 = groupOptionButton3;
groupOptionButton4.ShowHighlightWhenSelected = false;
groupOptionButton4.SetPadding(0.0f);
groupOptionButton4.SetSnapPoint("Filters", index);
Asset<Texture2D> asset = Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Icon_Tags_Shadow", (AssetRequestMode) 1);
UIImageFramed uiImageFramed1 = new UIImageFramed(asset, asset.Frame(16, 5, frameY: 4));
uiImageFramed1.HAlign = 0.5f;
uiImageFramed1.VAlign = 0.5f;
uiImageFramed1.Color = Color.White * 0.2f;
UIImageFramed uiImageFramed2 = uiImageFramed1;
uiImageFramed2.Left = new StyleDimension((float) num1, 0.0f);
uiImageFramed2.Top = new StyleDimension((float) num2, 0.0f);
groupOptionButton4.Append((UIElement) uiImageFramed2);
this._filterButtons.Add(groupOptionButton4);
this._container.Append((UIElement) groupOptionButton4);
}
}
this.UpdateButtonSelections();
}
public void GetEntriesToShow(
out int maxEntriesWidth,
out int maxEntriesHeight,
out int maxEntriesToHave)
{
int perRow;
int howManyRows;
this.GetDisplaySettings(out int _, out int _, out int _, out int _, out perRow, out float _, out float _, out howManyRows);
maxEntriesWidth = perRow;
maxEntriesHeight = howManyRows;
maxEntriesToHave = this._filterer.AvailableFilters.Count;
}
private void GetDisplaySettings(
out int widthPerButton,
out int heightPerButton,
out int widthWithSpacing,
out int heightWithSpacing,
out int perRow,
out float offsetLeft,
out float offsetTop,
out int howManyRows)
{
widthPerButton = 32;
heightPerButton = 32;
int num = 2;
widthWithSpacing = widthPerButton + num;
heightWithSpacing = heightPerButton + num;
perRow = (int) Math.Ceiling(Math.Sqrt((double) this._filterer.AvailableFilters.Count));
perRow = 12;
howManyRows = (int) Math.Ceiling((double) this._filterer.AvailableFilters.Count / (double) perRow);
offsetLeft = (float) (perRow * widthWithSpacing - num) * 0.5f;
offsetTop = (float) (howManyRows * heightWithSpacing - num) * 0.5f;
offsetLeft = 6f;
offsetTop = 6f;
}
private void UpdateButtonSelections()
{
foreach (GroupOptionButton<int> filterButton in this._filterButtons)
{
bool flag = this._filterer.IsFilterActive(filterButton.OptionValue);
filterButton.SetCurrentOption(flag ? filterButton.OptionValue : -1);
if (flag)
filterButton.SetColor(new Color(152, 175, 235), 1f);
else
filterButton.SetColor(Colors.InventoryDefaultColor, 0.7f);
}
}
private bool GetIsFilterAvailableForEntries(
IBestiaryEntryFilter filter,
List<BestiaryEntry> entries)
{
bool? forcedDisplay = filter.ForcedDisplay;
if (forcedDisplay.HasValue)
return forcedDisplay.Value;
for (int index = 0; index < entries.Count; ++index)
{
if (filter.FitsFilter(entries[index]) && entries[index].UIInfoProvider.GetEntryUICollectionInfo().UnlockState > BestiaryEntryUnlockState.NotKnownAtAll_0)
return true;
}
return false;
}
private void AddOnHover(IBestiaryEntryFilter filter, UIElement button) => button.OnUpdate += (UIElement.ElementEvent) (element => this.ShowButtonName(element, filter));
private void ShowButtonName(UIElement element, IBestiaryEntryFilter number)
{
if (!element.IsMouseHovering)
return;
string textValue = Language.GetTextValue(number.GetDisplayNameKey());
Main.instance.MouseText(textValue);
}
private void ClickOption(UIMouseEvent evt, UIElement listeningElement)
{
this._filterer.ToggleFilter(((GroupOptionButton<int>) listeningElement).OptionValue);
this.UpdateButtonSelections();
if (this.OnClickingOption == null)
return;
this.OnClickingOption();
}
}
}

View file

@ -0,0 +1,143 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIBestiaryInfoItemLine
// 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.Collections.Generic;
using Terraria.Audio;
using Terraria.GameContent.Bestiary;
using Terraria.GameContent.ItemDropRules;
using Terraria.ID;
using Terraria.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UIBestiaryInfoItemLine : UIPanel, IManuallyOrderedUIElement
{
private Item _infoDisplayItem;
private bool _hideMouseOver;
public int OrderInUIList { get; set; }
public UIBestiaryInfoItemLine(
DropRateInfo info,
BestiaryUICollectionInfo uiinfo,
float textScale = 1f)
{
this._infoDisplayItem = new Item();
this._infoDisplayItem.SetDefaults(info.itemId);
this.SetBestiaryNotesOnItemCache(info);
this.SetPadding(0.0f);
this.PaddingLeft = 10f;
this.PaddingRight = 10f;
this.Width.Set(-14f, 1f);
this.Height.Set(32f, 0.0f);
this.Left.Set(5f, 0.0f);
this.OnMouseOver += new UIElement.MouseEvent(this.MouseOver);
this.OnMouseOut += new UIElement.MouseEvent(this.MouseOut);
this.BorderColor = new Color(89, 116, 213, (int) byte.MaxValue);
string stackRange;
string droprate;
this.GetDropInfo(info, uiinfo, out stackRange, out droprate);
if (uiinfo.UnlockState < BestiaryEntryUnlockState.CanShowDropsWithoutDropRates_3)
{
this._hideMouseOver = true;
Asset<Texture2D> texture = Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Icon_Locked", (AssetRequestMode) 1);
UIElement element = new UIElement()
{
Height = new StyleDimension(0.0f, 1f),
Width = new StyleDimension(0.0f, 1f),
HAlign = 0.5f,
VAlign = 0.5f
};
element.SetPadding(0.0f);
UIImage uiImage1 = new UIImage(texture);
uiImage1.ImageScale = 0.55f;
uiImage1.HAlign = 0.5f;
uiImage1.VAlign = 0.5f;
UIImage uiImage2 = uiImage1;
element.Append((UIElement) uiImage2);
this.Append(element);
}
else
{
UIItemIcon uiItemIcon = new UIItemIcon(this._infoDisplayItem, uiinfo.UnlockState < BestiaryEntryUnlockState.CanShowDropsWithoutDropRates_3);
uiItemIcon.IgnoresMouseInteraction = true;
uiItemIcon.HAlign = 0.0f;
uiItemIcon.Left = new StyleDimension(4f, 0.0f);
this.Append((UIElement) uiItemIcon);
if (!string.IsNullOrEmpty(stackRange))
droprate = stackRange + " " + droprate;
UITextPanel<string> uiTextPanel = new UITextPanel<string>(droprate, textScale);
uiTextPanel.IgnoresMouseInteraction = true;
uiTextPanel.DrawPanel = false;
uiTextPanel.HAlign = 1f;
uiTextPanel.Top = new StyleDimension(-4f, 0.0f);
this.Append((UIElement) uiTextPanel);
}
}
protected void GetDropInfo(
DropRateInfo dropRateInfo,
BestiaryUICollectionInfo uiinfo,
out string stackRange,
out string droprate)
{
stackRange = dropRateInfo.stackMin == dropRateInfo.stackMax ? (dropRateInfo.stackMin != 1 ? " (" + (object) dropRateInfo.stackMin + ")" : "") : string.Format(" ({0}-{1})", (object) dropRateInfo.stackMin, (object) dropRateInfo.stackMax);
string originalFormat = "P";
if ((double) dropRateInfo.dropRate < 0.001)
originalFormat = "P4";
droprate = (double) dropRateInfo.dropRate == 1.0 ? "100%" : Utils.PrettifyPercentDisplay(dropRateInfo.dropRate, originalFormat);
if (uiinfo.UnlockState == BestiaryEntryUnlockState.CanShowDropsWithDropRates_4)
return;
droprate = "???";
stackRange = "";
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
base.DrawSelf(spriteBatch);
if (!this.IsMouseHovering || this._hideMouseOver)
return;
this.DrawMouseOver();
}
private void DrawMouseOver()
{
Main.HoverItem = this._infoDisplayItem;
Main.instance.MouseText("");
Main.mouseText = true;
}
public override int CompareTo(object obj) => obj is IManuallyOrderedUIElement orderedUiElement ? this.OrderInUIList.CompareTo(orderedUiElement.OrderInUIList) : base.CompareTo(obj);
private void SetBestiaryNotesOnItemCache(DropRateInfo info)
{
List<string> stringList = new List<string>();
if (info.conditions == null)
return;
foreach (IProvideItemConditionDescription condition in info.conditions)
{
if (condition != null)
{
string conditionDescription = condition.GetConditionDescription();
if (!string.IsNullOrWhiteSpace(conditionDescription))
stringList.Add(conditionDescription);
}
}
this._infoDisplayItem.BestiaryNotes = string.Join("\n", (IEnumerable<string>) stringList);
}
private void MouseOver(UIMouseEvent evt, UIElement listeningElement)
{
SoundEngine.PlaySound(12);
this.BorderColor = Colors.FancyUIFatButtonMouseOver;
}
private void MouseOut(UIMouseEvent evt, UIElement listeningElement) => this.BorderColor = new Color(89, 116, 213, (int) byte.MaxValue);
}
}

View file

@ -0,0 +1,69 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIBestiaryInfoLine`1
// 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 Terraria.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UIBestiaryInfoLine<T> : UIElement, IManuallyOrderedUIElement
{
private T _text;
private float _textScale = 1f;
private Vector2 _textSize = Vector2.Zero;
private Color _color = Color.White;
public int OrderInUIList { get; set; }
public float TextScale
{
get => this._textScale;
set => this._textScale = value;
}
public Vector2 TextSize => this._textSize;
public string Text => (object) this._text != null ? this._text.ToString() : "";
public Color TextColor
{
get => this._color;
set => this._color = value;
}
public UIBestiaryInfoLine(T text, float textScale = 1f) => this.SetText(text, textScale);
public override void Recalculate()
{
this.SetText(this._text, this._textScale);
base.Recalculate();
}
public void SetText(T text) => this.SetText(text, this._textScale);
public virtual void SetText(T text, float textScale)
{
Vector2 vector2 = new Vector2(FontAssets.MouseText.Value.MeasureString(text.ToString()).X, 16f) * textScale;
this._text = text;
this._textScale = textScale;
this._textSize = vector2;
this.MinWidth.Set(vector2.X + this.PaddingLeft + this.PaddingRight, 0.0f);
this.MinHeight.Set(vector2.Y + this.PaddingTop + this.PaddingBottom, 0.0f);
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
CalculatedStyle innerDimensions = this.GetInnerDimensions();
Vector2 pos = innerDimensions.Position();
pos.Y -= 2f * this._textScale;
pos.X += (float) (((double) innerDimensions.Width - (double) this._textSize.X) * 0.5);
Utils.DrawBorderString(spriteBatch, this.Text, pos, this._color, this._textScale);
}
public override int CompareTo(object obj) => obj is IManuallyOrderedUIElement orderedUiElement ? this.OrderInUIList.CompareTo(orderedUiElement.OrderInUIList) : base.CompareTo(obj);
}
}

View file

@ -0,0 +1,76 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIBestiaryNPCEntryPortrait
// 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.Collections.Generic;
using Terraria.GameContent.Bestiary;
using Terraria.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UIBestiaryNPCEntryPortrait : UIElement
{
public BestiaryEntry Entry { get; private set; }
public UIBestiaryNPCEntryPortrait(
BestiaryEntry entry,
Asset<Texture2D> portraitBackgroundAsset,
Color portraitColor,
List<IBestiaryBackgroundOverlayAndColorProvider> overlays)
{
this.Entry = entry;
this.Height.Set(112f, 0.0f);
this.Width.Set(193f, 0.0f);
this.SetPadding(0.0f);
UIElement element = new UIElement()
{
Width = new StyleDimension(-4f, 1f),
Height = new StyleDimension(-4f, 1f),
IgnoresMouseInteraction = true,
OverflowHidden = true,
HAlign = 0.5f,
VAlign = 0.5f
};
element.SetPadding(0.0f);
if (portraitBackgroundAsset != null)
{
UIElement uiElement = element;
UIImage uiImage = new UIImage(portraitBackgroundAsset);
uiImage.HAlign = 0.5f;
uiImage.VAlign = 0.5f;
uiImage.ScaleToFit = true;
uiImage.Width = new StyleDimension(0.0f, 1f);
uiImage.Height = new StyleDimension(0.0f, 1f);
uiImage.Color = portraitColor;
uiElement.Append((UIElement) uiImage);
}
for (int index = 0; index < overlays.Count; ++index)
{
Asset<Texture2D> backgroundOverlayImage = overlays[index].GetBackgroundOverlayImage();
Color? backgroundOverlayColor = overlays[index].GetBackgroundOverlayColor();
UIElement uiElement = element;
UIImage uiImage = new UIImage(backgroundOverlayImage);
uiImage.HAlign = 0.5f;
uiImage.VAlign = 0.5f;
uiImage.ScaleToFit = true;
uiImage.Width = new StyleDimension(0.0f, 1f);
uiImage.Height = new StyleDimension(0.0f, 1f);
uiImage.Color = backgroundOverlayColor.HasValue ? backgroundOverlayColor.Value : Color.Lerp(Color.White, portraitColor, 0.5f);
uiElement.Append((UIElement) uiImage);
}
UIBestiaryEntryIcon bestiaryEntryIcon = new UIBestiaryEntryIcon(entry, true);
element.Append((UIElement) bestiaryEntryIcon);
this.Append(element);
UIImage uiImage1 = new UIImage(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Portrait_Front", (AssetRequestMode) 1));
uiImage1.VAlign = 0.5f;
uiImage1.HAlign = 0.5f;
uiImage1.IgnoresMouseInteraction = true;
this.Append((UIElement) uiImage1);
}
}
}

View file

@ -0,0 +1,118 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIBestiarySortingOptionsGrid
// 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.DataStructures;
using Terraria.GameContent.Bestiary;
using Terraria.ID;
using Terraria.Localization;
using Terraria.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UIBestiarySortingOptionsGrid : UIPanel
{
private EntrySorter<BestiaryEntry, IBestiarySortStep> _sorter;
private List<GroupOptionButton<int>> _buttonsBySorting;
private int _currentSelected = -1;
private int _defaultStepIndex;
public event Action OnClickingOption;
public UIBestiarySortingOptionsGrid(
EntrySorter<BestiaryEntry, IBestiarySortStep> sorter)
{
this._sorter = sorter;
this._buttonsBySorting = new List<GroupOptionButton<int>>();
this.Width = new StyleDimension(0.0f, 1f);
this.Height = new StyleDimension(0.0f, 1f);
this.BackgroundColor = new Color(35, 40, 83) * 0.5f;
this.BorderColor = new Color(35, 40, 83) * 0.5f;
this.IgnoresMouseInteraction = false;
this.SetPadding(0.0f);
this.BuildGrid();
}
private void BuildGrid()
{
int num1 = 2;
int num2 = 26 + num1;
int num3 = 0;
for (int index = 0; index < this._sorter.Steps.Count; ++index)
{
if (!this._sorter.Steps[index].HiddenFromSortOptions)
++num3;
}
UIPanel uiPanel1 = new UIPanel();
uiPanel1.Width = new StyleDimension(126f, 0.0f);
uiPanel1.Height = new StyleDimension((float) (num3 * num2 + 5 + 3), 0.0f);
uiPanel1.HAlign = 1f;
uiPanel1.VAlign = 0.0f;
uiPanel1.Left = new StyleDimension(-118f, 0.0f);
uiPanel1.Top = new StyleDimension(0.0f, 0.0f);
UIPanel uiPanel2 = uiPanel1;
uiPanel2.BorderColor = new Color(89, 116, 213, (int) byte.MaxValue) * 0.9f;
uiPanel2.BackgroundColor = new Color(73, 94, 171) * 0.9f;
uiPanel2.SetPadding(0.0f);
this.Append((UIElement) uiPanel2);
int id = 0;
for (int index = 0; index < this._sorter.Steps.Count; ++index)
{
IBestiarySortStep step = this._sorter.Steps[index];
if (!step.HiddenFromSortOptions)
{
GroupOptionButton<int> groupOptionButton1 = new GroupOptionButton<int>(index, Language.GetText(step.GetDisplayNameKey()), (LocalizedText) null, Color.White, (string) null, 0.8f);
groupOptionButton1.Width = new StyleDimension(114f, 0.0f);
groupOptionButton1.Height = new StyleDimension((float) (num2 - num1), 0.0f);
groupOptionButton1.HAlign = 0.5f;
groupOptionButton1.Top = new StyleDimension((float) (5 + num2 * id), 0.0f);
GroupOptionButton<int> groupOptionButton2 = groupOptionButton1;
groupOptionButton2.ShowHighlightWhenSelected = false;
groupOptionButton2.OnClick += new UIElement.MouseEvent(this.ClickOption);
groupOptionButton2.SetSnapPoint("SortSteps", id);
uiPanel2.Append((UIElement) groupOptionButton2);
this._buttonsBySorting.Add(groupOptionButton2);
++id;
}
}
foreach (GroupOptionButton<int> groupOptionButton in this._buttonsBySorting)
groupOptionButton.SetCurrentOption(-1);
}
private void ClickOption(UIMouseEvent evt, UIElement listeningElement)
{
int index = ((GroupOptionButton<int>) listeningElement).OptionValue;
if (index == this._currentSelected)
index = this._defaultStepIndex;
foreach (GroupOptionButton<int> groupOptionButton in this._buttonsBySorting)
{
bool flag = index == groupOptionButton.OptionValue;
groupOptionButton.SetCurrentOption(flag ? index : -1);
if (flag)
groupOptionButton.SetColor(new Color(152, 175, 235), 1f);
else
groupOptionButton.SetColor(Colors.InventoryDefaultColor, 0.7f);
}
this._currentSelected = index;
this._sorter.SetPrioritizedStepIndex(index);
if (this.OnClickingOption == null)
return;
this.OnClickingOption();
}
public void GetEntriesToShow(
out int maxEntriesWidth,
out int maxEntriesHeight,
out int maxEntriesToHave)
{
maxEntriesWidth = 1;
maxEntriesHeight = this._buttonsBySorting.Count;
maxEntriesToHave = this._buttonsBySorting.Count;
}
}
}

View file

@ -0,0 +1,79 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UICharacter
// 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.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UICharacter : UIElement
{
private Player _player;
private Asset<Texture2D> _texture;
private static Item _blankItem = new Item();
private bool _animated;
private bool _drawsBackPanel;
private float _characterScale = 1f;
private int _animationCounter;
public UICharacter(Player player, bool animated = false, bool hasBackPanel = true, float characterScale = 1f)
{
this._player = player;
this.Width.Set(59f, 0.0f);
this.Height.Set(58f, 0.0f);
this._texture = Main.Assets.Request<Texture2D>("Images/UI/PlayerBackground", (AssetRequestMode) 1);
this.UseImmediateMode = true;
this._animated = animated;
this._drawsBackPanel = hasBackPanel;
this._characterScale = characterScale;
this.OverrideSamplerState = SamplerState.PointClamp;
}
public override void Update(GameTime gameTime)
{
this._player.ResetEffects();
this._player.ResetVisibleAccessories();
this._player.UpdateMiscCounter();
this._player.UpdateDyes();
this._player.PlayerFrame();
if (this._animated)
++this._animationCounter;
base.Update(gameTime);
}
private void UpdateAnim()
{
if (!this._animated)
{
this._player.bodyFrame.Y = this._player.legFrame.Y = this._player.headFrame.Y = 0;
}
else
{
this._player.bodyFrame.Y = this._player.legFrame.Y = this._player.headFrame.Y = ((int) ((double) Main.GlobalTimeWrappedHourly / 0.0700000002980232) % 14 + 6) * 56;
this._player.WingFrame(false);
}
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
CalculatedStyle dimensions = this.GetDimensions();
if (this._drawsBackPanel)
spriteBatch.Draw(this._texture.Value, dimensions.Position(), Color.White);
this.UpdateAnim();
Vector2 vector2 = dimensions.Position() + new Vector2(dimensions.Width * 0.5f - (float) (this._player.width >> 1), dimensions.Height * 0.5f - (float) (this._player.height >> 1));
Item obj = this._player.inventory[this._player.selectedItem];
this._player.inventory[this._player.selectedItem] = UICharacter._blankItem;
Main.PlayerRenderer.DrawPlayer(Main.Camera, this._player, vector2 + Main.screenPosition, 0.0f, Vector2.Zero, scale: this._characterScale);
this._player.inventory[this._player.selectedItem] = obj;
}
public void SetAnimated(bool animated) => this._animated = animated;
public bool IsAnimated => this._animated;
}
}

View file

@ -0,0 +1,284 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UICharacterListItem
// 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 Terraria.Audio;
using Terraria.IO;
using Terraria.Localization;
using Terraria.Social;
using Terraria.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UICharacterListItem : UIPanel
{
private PlayerFileData _data;
private Asset<Texture2D> _dividerTexture;
private Asset<Texture2D> _innerPanelTexture;
private UICharacter _playerPanel;
private UIText _buttonLabel;
private UIText _deleteButtonLabel;
private Asset<Texture2D> _buttonCloudActiveTexture;
private Asset<Texture2D> _buttonCloudInactiveTexture;
private Asset<Texture2D> _buttonFavoriteActiveTexture;
private Asset<Texture2D> _buttonFavoriteInactiveTexture;
private Asset<Texture2D> _buttonPlayTexture;
private Asset<Texture2D> _buttonDeleteTexture;
private UIImageButton _deleteButton;
public bool IsFavorite => this._data.IsFavorite;
public UICharacterListItem(PlayerFileData data, int snapPointIndex)
{
this.BorderColor = new Color(89, 116, 213) * 0.7f;
this._dividerTexture = Main.Assets.Request<Texture2D>("Images/UI/Divider", (AssetRequestMode) 1);
this._innerPanelTexture = Main.Assets.Request<Texture2D>("Images/UI/InnerPanelBackground", (AssetRequestMode) 1);
this._buttonCloudActiveTexture = Main.Assets.Request<Texture2D>("Images/UI/ButtonCloudActive", (AssetRequestMode) 1);
this._buttonCloudInactiveTexture = Main.Assets.Request<Texture2D>("Images/UI/ButtonCloudInactive", (AssetRequestMode) 1);
this._buttonFavoriteActiveTexture = Main.Assets.Request<Texture2D>("Images/UI/ButtonFavoriteActive", (AssetRequestMode) 1);
this._buttonFavoriteInactiveTexture = Main.Assets.Request<Texture2D>("Images/UI/ButtonFavoriteInactive", (AssetRequestMode) 1);
this._buttonPlayTexture = Main.Assets.Request<Texture2D>("Images/UI/ButtonPlay", (AssetRequestMode) 1);
this._buttonDeleteTexture = Main.Assets.Request<Texture2D>("Images/UI/ButtonDelete", (AssetRequestMode) 1);
this.Height.Set(96f, 0.0f);
this.Width.Set(0.0f, 1f);
this.SetPadding(6f);
this._data = data;
this._playerPanel = new UICharacter(data.Player);
this._playerPanel.Left.Set(4f, 0.0f);
this._playerPanel.OnDoubleClick += new UIElement.MouseEvent(this.PlayGame);
this.OnDoubleClick += new UIElement.MouseEvent(this.PlayGame);
this.Append((UIElement) this._playerPanel);
UIImageButton uiImageButton1 = new UIImageButton(this._buttonPlayTexture);
uiImageButton1.VAlign = 1f;
uiImageButton1.Left.Set(4f, 0.0f);
uiImageButton1.OnClick += new UIElement.MouseEvent(this.PlayGame);
uiImageButton1.OnMouseOver += new UIElement.MouseEvent(this.PlayMouseOver);
uiImageButton1.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut);
this.Append((UIElement) uiImageButton1);
UIImageButton uiImageButton2 = new UIImageButton(this._data.IsFavorite ? this._buttonFavoriteActiveTexture : this._buttonFavoriteInactiveTexture);
uiImageButton2.VAlign = 1f;
uiImageButton2.Left.Set(28f, 0.0f);
uiImageButton2.OnClick += new UIElement.MouseEvent(this.FavoriteButtonClick);
uiImageButton2.OnMouseOver += new UIElement.MouseEvent(this.FavoriteMouseOver);
uiImageButton2.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut);
uiImageButton2.SetVisibility(1f, this._data.IsFavorite ? 0.8f : 0.4f);
this.Append((UIElement) uiImageButton2);
if (SocialAPI.Cloud != null)
{
UIImageButton uiImageButton3 = new UIImageButton(this._data.IsCloudSave ? this._buttonCloudActiveTexture : this._buttonCloudInactiveTexture);
uiImageButton3.VAlign = 1f;
uiImageButton3.Left.Set(52f, 0.0f);
uiImageButton3.OnClick += new UIElement.MouseEvent(this.CloudButtonClick);
uiImageButton3.OnMouseOver += new UIElement.MouseEvent(this.CloudMouseOver);
uiImageButton3.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut);
this.Append((UIElement) uiImageButton3);
uiImageButton3.SetSnapPoint("Cloud", snapPointIndex);
}
UIImageButton uiImageButton4 = new UIImageButton(this._buttonDeleteTexture);
uiImageButton4.VAlign = 1f;
uiImageButton4.HAlign = 1f;
if (!this._data.IsFavorite)
uiImageButton4.OnClick += new UIElement.MouseEvent(this.DeleteButtonClick);
uiImageButton4.OnMouseOver += new UIElement.MouseEvent(this.DeleteMouseOver);
uiImageButton4.OnMouseOut += new UIElement.MouseEvent(this.DeleteMouseOut);
this._deleteButton = uiImageButton4;
this.Append((UIElement) uiImageButton4);
this._buttonLabel = new UIText("");
this._buttonLabel.VAlign = 1f;
this._buttonLabel.Left.Set(80f, 0.0f);
this._buttonLabel.Top.Set(-3f, 0.0f);
this.Append((UIElement) this._buttonLabel);
this._deleteButtonLabel = new UIText("");
this._deleteButtonLabel.VAlign = 1f;
this._deleteButtonLabel.HAlign = 1f;
this._deleteButtonLabel.Left.Set(-30f, 0.0f);
this._deleteButtonLabel.Top.Set(-3f, 0.0f);
this.Append((UIElement) this._deleteButtonLabel);
uiImageButton1.SetSnapPoint("Play", snapPointIndex);
uiImageButton2.SetSnapPoint("Favorite", snapPointIndex);
uiImageButton4.SetSnapPoint("Delete", snapPointIndex);
}
private void FavoriteMouseOver(UIMouseEvent evt, UIElement listeningElement)
{
if (this._data.IsFavorite)
this._buttonLabel.SetText(Language.GetTextValue("UI.Unfavorite"));
else
this._buttonLabel.SetText(Language.GetTextValue("UI.Favorite"));
}
private void CloudMouseOver(UIMouseEvent evt, UIElement listeningElement)
{
if (this._data.IsCloudSave)
this._buttonLabel.SetText(Language.GetTextValue("UI.MoveOffCloud"));
else
this._buttonLabel.SetText(Language.GetTextValue("UI.MoveToCloud"));
}
private void PlayMouseOver(UIMouseEvent evt, UIElement listeningElement) => this._buttonLabel.SetText(Language.GetTextValue("UI.Play"));
private void DeleteMouseOver(UIMouseEvent evt, UIElement listeningElement)
{
if (this._data.IsFavorite)
this._deleteButtonLabel.SetText(Language.GetTextValue("UI.CannotDeleteFavorited"));
else
this._deleteButtonLabel.SetText(Language.GetTextValue("UI.Delete"));
}
private void DeleteMouseOut(UIMouseEvent evt, UIElement listeningElement) => this._deleteButtonLabel.SetText("");
private void ButtonMouseOut(UIMouseEvent evt, UIElement listeningElement) => this._buttonLabel.SetText("");
private void CloudButtonClick(UIMouseEvent evt, UIElement listeningElement)
{
if (this._data.IsCloudSave)
this._data.MoveToLocal();
else
this._data.MoveToCloud();
((UIImageButton) evt.Target).SetImage(this._data.IsCloudSave ? this._buttonCloudActiveTexture : this._buttonCloudInactiveTexture);
if (this._data.IsCloudSave)
this._buttonLabel.SetText(Language.GetTextValue("UI.MoveOffCloud"));
else
this._buttonLabel.SetText(Language.GetTextValue("UI.MoveToCloud"));
}
private void DeleteButtonClick(UIMouseEvent evt, UIElement listeningElement)
{
for (int index = 0; index < Main.PlayerList.Count; ++index)
{
if (Main.PlayerList[index] == this._data)
{
SoundEngine.PlaySound(10);
Main.selectedPlayer = index;
Main.menuMode = 5;
break;
}
}
}
private void PlayGame(UIMouseEvent evt, UIElement listeningElement)
{
if (listeningElement != evt.Target || this._data.Player.loadStatus != 0)
return;
Main.SelectPlayer(this._data);
}
private void FavoriteButtonClick(UIMouseEvent evt, UIElement listeningElement)
{
this._data.ToggleFavorite();
((UIImageButton) evt.Target).SetImage(this._data.IsFavorite ? this._buttonFavoriteActiveTexture : this._buttonFavoriteInactiveTexture);
((UIImageButton) evt.Target).SetVisibility(1f, this._data.IsFavorite ? 0.8f : 0.4f);
if (this._data.IsFavorite)
{
this._buttonLabel.SetText(Language.GetTextValue("UI.Unfavorite"));
this._deleteButton.OnClick -= new UIElement.MouseEvent(this.DeleteButtonClick);
}
else
{
this._buttonLabel.SetText(Language.GetTextValue("UI.Favorite"));
this._deleteButton.OnClick += new UIElement.MouseEvent(this.DeleteButtonClick);
}
if (!(this.Parent.Parent is UIList parent))
return;
parent.UpdateOrder();
}
public override int CompareTo(object obj)
{
if (!(obj is UICharacterListItem characterListItem))
return base.CompareTo(obj);
if (this.IsFavorite && !characterListItem.IsFavorite)
return -1;
if (!this.IsFavorite && characterListItem.IsFavorite)
return 1;
return this._data.Name.CompareTo(characterListItem._data.Name) != 0 ? this._data.Name.CompareTo(characterListItem._data.Name) : this._data.GetFileName().CompareTo(characterListItem._data.GetFileName());
}
public override void MouseOver(UIMouseEvent evt)
{
base.MouseOver(evt);
this.BackgroundColor = new Color(73, 94, 171);
this.BorderColor = new Color(89, 116, 213);
this._playerPanel.SetAnimated(true);
}
public override void MouseOut(UIMouseEvent evt)
{
base.MouseOut(evt);
this.BackgroundColor = new Color(63, 82, 151) * 0.7f;
this.BorderColor = new Color(89, 116, 213) * 0.7f;
this._playerPanel.SetAnimated(false);
}
private void DrawPanel(SpriteBatch spriteBatch, Vector2 position, float width)
{
spriteBatch.Draw(this._innerPanelTexture.Value, position, new Rectangle?(new Rectangle(0, 0, 8, this._innerPanelTexture.Height())), Color.White);
spriteBatch.Draw(this._innerPanelTexture.Value, new Vector2(position.X + 8f, position.Y), new Rectangle?(new Rectangle(8, 0, 8, this._innerPanelTexture.Height())), Color.White, 0.0f, Vector2.Zero, new Vector2((float) (((double) width - 16.0) / 8.0), 1f), SpriteEffects.None, 0.0f);
spriteBatch.Draw(this._innerPanelTexture.Value, new Vector2((float) ((double) position.X + (double) width - 8.0), position.Y), new Rectangle?(new Rectangle(16, 0, 8, this._innerPanelTexture.Height())), Color.White);
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
base.DrawSelf(spriteBatch);
CalculatedStyle innerDimensions = this.GetInnerDimensions();
CalculatedStyle dimensions = this._playerPanel.GetDimensions();
float x = dimensions.X + dimensions.Width;
Utils.DrawBorderString(spriteBatch, this._data.Name, new Vector2(x + 6f, dimensions.Y - 2f), Color.White);
spriteBatch.Draw(this._dividerTexture.Value, new Vector2(x, innerDimensions.Y + 21f), new Rectangle?(), Color.White, 0.0f, Vector2.Zero, new Vector2((float) (((double) this.GetDimensions().X + (double) this.GetDimensions().Width - (double) x) / 8.0), 1f), SpriteEffects.None, 0.0f);
Vector2 vector2 = new Vector2(x + 6f, innerDimensions.Y + 29f);
float width1 = 200f;
Vector2 position1 = vector2;
this.DrawPanel(spriteBatch, position1, width1);
spriteBatch.Draw(TextureAssets.Heart.Value, position1 + new Vector2(5f, 2f), Color.White);
position1.X += 10f + (float) TextureAssets.Heart.Width();
Utils.DrawBorderString(spriteBatch, this._data.Player.statLifeMax.ToString() + Language.GetTextValue("GameUI.PlayerLifeMax"), position1 + new Vector2(0.0f, 3f), Color.White);
position1.X += 65f;
spriteBatch.Draw(TextureAssets.Mana.Value, position1 + new Vector2(5f, 2f), Color.White);
position1.X += 10f + (float) TextureAssets.Mana.Width();
Utils.DrawBorderString(spriteBatch, this._data.Player.statManaMax.ToString() + Language.GetTextValue("GameUI.PlayerManaMax"), position1 + new Vector2(0.0f, 3f), Color.White);
vector2.X += width1 + 5f;
Vector2 position2 = vector2;
float width2 = 140f;
if (GameCulture.FromCultureName(GameCulture.CultureName.Russian).IsActive)
width2 = 180f;
this.DrawPanel(spriteBatch, position2, width2);
string text1 = "";
Color color = Color.White;
switch (this._data.Player.difficulty)
{
case 0:
text1 = Language.GetTextValue("UI.Softcore");
break;
case 1:
text1 = Language.GetTextValue("UI.Mediumcore");
color = Main.mcColor;
break;
case 2:
text1 = Language.GetTextValue("UI.Hardcore");
color = Main.hcColor;
break;
case 3:
text1 = Language.GetTextValue("UI.Creative");
color = Main.creativeModeColor;
break;
}
Vector2 pos1 = position2 + new Vector2((float) ((double) width2 * 0.5 - (double) FontAssets.MouseText.Value.MeasureString(text1).X * 0.5), 3f);
Utils.DrawBorderString(spriteBatch, text1, pos1, color);
vector2.X += width2 + 5f;
Vector2 position3 = vector2;
float width3 = innerDimensions.X + innerDimensions.Width - position3.X;
this.DrawPanel(spriteBatch, position3, width3);
TimeSpan playTime = this._data.GetPlayTime();
int num = playTime.Days * 24 + playTime.Hours;
string text2 = (num < 10 ? (object) "0" : (object) "").ToString() + (object) num + playTime.ToString("\\:mm\\:ss");
Vector2 pos2 = position3 + new Vector2((float) ((double) width3 * 0.5 - (double) FontAssets.MouseText.Value.MeasureString(text2).X * 0.5), 3f);
Utils.DrawBorderString(spriteBatch, text2, pos2, Color.White);
}
}
}

View file

@ -0,0 +1,132 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UICharacterNameButton
// 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.Audio;
using Terraria.Localization;
using Terraria.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UICharacterNameButton : UIElement
{
private readonly Asset<Texture2D> _BasePanelTexture;
private readonly Asset<Texture2D> _selectedBorderTexture;
private readonly Asset<Texture2D> _hoveredBorderTexture;
private bool _hovered;
private bool _soundedHover;
private readonly LocalizedText _textToShowWhenEmpty;
private string actualContents;
private UIText _text;
private UIText _title;
public readonly LocalizedText Description;
public float DistanceFromTitleToOption = 20f;
public UICharacterNameButton(
LocalizedText titleText,
LocalizedText emptyContentText,
LocalizedText description = null)
{
this.Width = StyleDimension.FromPixels(400f);
this.Height = StyleDimension.FromPixels(40f);
this.Description = description;
this._BasePanelTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/CategoryPanel", (AssetRequestMode) 1);
this._selectedBorderTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/CategoryPanelHighlight", (AssetRequestMode) 1);
this._hoveredBorderTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/CategoryPanelBorder", (AssetRequestMode) 1);
this._textToShowWhenEmpty = emptyContentText;
float textScale = 1f;
UIText uiText1 = new UIText(titleText, textScale);
uiText1.HAlign = 0.0f;
uiText1.VAlign = 0.5f;
uiText1.Left = StyleDimension.FromPixels(10f);
UIText uiText2 = uiText1;
this.Append((UIElement) uiText2);
this._title = uiText2;
UIText uiText3 = new UIText(Language.GetText("UI.PlayerNameSlot"), textScale);
uiText3.HAlign = 0.0f;
uiText3.VAlign = 0.5f;
uiText3.Left = StyleDimension.FromPixels(150f);
UIText uiText4 = uiText3;
this.Append((UIElement) uiText4);
this._text = uiText4;
this.SetContents((string) null);
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
if (this._hovered)
{
if (!this._soundedHover)
SoundEngine.PlaySound(12);
this._soundedHover = true;
}
else
this._soundedHover = false;
CalculatedStyle dimensions = this.GetDimensions();
Utils.DrawSplicedPanel(spriteBatch, this._BasePanelTexture.Value, (int) dimensions.X, (int) dimensions.Y, (int) dimensions.Width, (int) dimensions.Height, 10, 10, 10, 10, Color.White * 0.5f);
if (!this._hovered)
return;
Utils.DrawSplicedPanel(spriteBatch, this._hoveredBorderTexture.Value, (int) dimensions.X, (int) dimensions.Y, (int) dimensions.Width, (int) dimensions.Height, 10, 10, 10, 10, Color.White);
}
public void SetContents(string name)
{
this.actualContents = name;
if (string.IsNullOrEmpty(this.actualContents))
{
this._text.TextColor = Color.Gray;
this._text.SetText(this._textToShowWhenEmpty);
}
else
{
this._text.TextColor = Color.White;
this._text.SetText(this.actualContents);
}
this._text.Left = StyleDimension.FromPixels(this._title.GetInnerDimensions().Width + this.DistanceFromTitleToOption);
}
public void TrimDisplayIfOverElementDimensions(int padding)
{
CalculatedStyle dimensions1 = this.GetDimensions();
Point point1 = new Point((int) dimensions1.X, (int) dimensions1.Y);
Point point2 = new Point(point1.X + (int) dimensions1.Width, point1.Y + (int) dimensions1.Height);
Rectangle rectangle1 = new Rectangle(point1.X, point1.Y, point2.X - point1.X, point2.Y - point1.Y);
CalculatedStyle dimensions2 = this._text.GetDimensions();
Point point3 = new Point((int) dimensions2.X, (int) dimensions2.Y);
Point point4 = new Point(point3.X + (int) dimensions2.Width, point3.Y + (int) dimensions2.Height);
Rectangle rectangle2 = new Rectangle(point3.X, point3.Y, point4.X - point3.X, point4.Y - point3.Y);
int num = 0;
for (; rectangle2.Right > rectangle1.Right - padding; rectangle2 = new Rectangle(point3.X, point3.Y, point4.X - point3.X, point4.Y - point3.Y))
{
this._text.SetText(this._text.Text.Substring(0, this._text.Text.Length - 1));
++num;
this.RecalculateChildren();
CalculatedStyle dimensions3 = this._text.GetDimensions();
point3 = new Point((int) dimensions3.X, (int) dimensions3.Y);
point4 = new Point(point3.X + (int) dimensions3.Width, point3.Y + (int) dimensions3.Height);
}
if (num <= 0)
return;
this._text.SetText(this._text.Text.Substring(0, this._text.Text.Length - 1) + "…");
}
public override void MouseDown(UIMouseEvent evt) => base.MouseDown(evt);
public override void MouseOver(UIMouseEvent evt)
{
base.MouseOver(evt);
this._hovered = true;
}
public override void MouseOut(UIMouseEvent evt)
{
base.MouseOut(evt);
this._hovered = false;
}
}
}

View file

@ -0,0 +1,91 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIClothStyleButton
// 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.Audio;
using Terraria.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UIClothStyleButton : UIElement
{
private readonly Player _player;
public readonly int ClothStyleId;
private readonly Asset<Texture2D> _BasePanelTexture;
private readonly Asset<Texture2D> _selectedBorderTexture;
private readonly Asset<Texture2D> _hoveredBorderTexture;
private readonly UICharacter _char;
private bool _hovered;
private bool _soundedHover;
private int _realSkinVariant;
public UIClothStyleButton(Player player, int clothStyleId)
{
this._player = player;
this.ClothStyleId = clothStyleId;
this.Width = StyleDimension.FromPixels(44f);
this.Height = StyleDimension.FromPixels(80f);
this._BasePanelTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/CategoryPanel", (AssetRequestMode) 1);
this._selectedBorderTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/CategoryPanelHighlight", (AssetRequestMode) 1);
this._hoveredBorderTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/CategoryPanelBorder", (AssetRequestMode) 1);
UICharacter uiCharacter = new UICharacter(this._player, hasBackPanel: false);
uiCharacter.HAlign = 0.5f;
uiCharacter.VAlign = 0.5f;
this._char = uiCharacter;
this.Append((UIElement) this._char);
}
public override void Draw(SpriteBatch spriteBatch)
{
this._realSkinVariant = this._player.skinVariant;
this._player.skinVariant = this.ClothStyleId;
base.Draw(spriteBatch);
this._player.skinVariant = this._realSkinVariant;
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
if (this._hovered)
{
if (!this._soundedHover)
SoundEngine.PlaySound(12);
this._soundedHover = true;
}
else
this._soundedHover = false;
CalculatedStyle dimensions = this.GetDimensions();
Utils.DrawSplicedPanel(spriteBatch, this._BasePanelTexture.Value, (int) dimensions.X, (int) dimensions.Y, (int) dimensions.Width, (int) dimensions.Height, 10, 10, 10, 10, Color.White * 0.5f);
if (this._realSkinVariant == this.ClothStyleId)
Utils.DrawSplicedPanel(spriteBatch, this._selectedBorderTexture.Value, (int) dimensions.X + 3, (int) dimensions.Y + 3, (int) dimensions.Width - 6, (int) dimensions.Height - 6, 10, 10, 10, 10, Color.White);
if (!this._hovered)
return;
Utils.DrawSplicedPanel(spriteBatch, this._hoveredBorderTexture.Value, (int) dimensions.X, (int) dimensions.Y, (int) dimensions.Width, (int) dimensions.Height, 10, 10, 10, 10, Color.White);
}
public override void MouseDown(UIMouseEvent evt)
{
this._player.skinVariant = this.ClothStyleId;
SoundEngine.PlaySound(12);
base.MouseDown(evt);
}
public override void MouseOver(UIMouseEvent evt)
{
base.MouseOver(evt);
this._hovered = true;
this._char.SetAnimated(true);
}
public override void MouseOut(UIMouseEvent evt)
{
base.MouseOut(evt);
this._hovered = false;
this._char.SetAnimated(false);
}
}
}

View file

@ -0,0 +1,89 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIColoredImageButton
// 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.Audio;
using Terraria.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UIColoredImageButton : UIElement
{
private Asset<Texture2D> _backPanelTexture;
private Asset<Texture2D> _texture;
private Asset<Texture2D> _middleTexture;
private Asset<Texture2D> _backPanelHighlightTexture;
private Asset<Texture2D> _backPanelBorderTexture;
private Color _color;
private float _visibilityActive = 1f;
private float _visibilityInactive = 0.4f;
private bool _selected;
private bool _hovered;
public UIColoredImageButton(Asset<Texture2D> texture, bool isSmall = false)
{
this._color = Color.White;
this._texture = texture;
this._backPanelTexture = !isSmall ? Main.Assets.Request<Texture2D>("Images/UI/CharCreation/CategoryPanel", (AssetRequestMode) 1) : Main.Assets.Request<Texture2D>("Images/UI/CharCreation/SmallPanel", (AssetRequestMode) 1);
this.Width.Set((float) this._backPanelTexture.Width(), 0.0f);
this.Height.Set((float) this._backPanelTexture.Height(), 0.0f);
this._backPanelHighlightTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/CategoryPanelHighlight", (AssetRequestMode) 1);
if (isSmall)
this._backPanelBorderTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/SmallPanelBorder", (AssetRequestMode) 1);
else
this._backPanelBorderTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/CategoryPanelBorder", (AssetRequestMode) 1);
}
public void SetImage(Asset<Texture2D> texture)
{
this._texture = texture;
this.Width.Set((float) this._texture.Width(), 0.0f);
this.Height.Set((float) this._texture.Height(), 0.0f);
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
CalculatedStyle dimensions = this.GetDimensions();
Vector2 position = dimensions.Position() + new Vector2(dimensions.Width, dimensions.Height) / 2f;
spriteBatch.Draw(this._backPanelTexture.Value, position, new Rectangle?(), Color.White * (this.IsMouseHovering ? this._visibilityActive : this._visibilityInactive), 0.0f, this._backPanelTexture.Size() / 2f, 1f, SpriteEffects.None, 0.0f);
Color white = Color.White;
if (this._hovered)
spriteBatch.Draw(this._backPanelBorderTexture.Value, position, new Rectangle?(), Color.White, 0.0f, this._backPanelBorderTexture.Size() / 2f, 1f, SpriteEffects.None, 0.0f);
if (this._selected)
spriteBatch.Draw(this._backPanelHighlightTexture.Value, position, new Rectangle?(), Color.White, 0.0f, this._backPanelHighlightTexture.Size() / 2f, 1f, SpriteEffects.None, 0.0f);
if (this._middleTexture != null)
spriteBatch.Draw(this._middleTexture.Value, position, new Rectangle?(), Color.White, 0.0f, this._middleTexture.Size() / 2f, 1f, SpriteEffects.None, 0.0f);
spriteBatch.Draw(this._texture.Value, position, new Rectangle?(), this._color, 0.0f, this._texture.Size() / 2f, 1f, SpriteEffects.None, 0.0f);
}
public override void MouseOver(UIMouseEvent evt)
{
base.MouseOver(evt);
SoundEngine.PlaySound(12);
this._hovered = true;
}
public void SetVisibility(float whenActive, float whenInactive)
{
this._visibilityActive = MathHelper.Clamp(whenActive, 0.0f, 1f);
this._visibilityInactive = MathHelper.Clamp(whenInactive, 0.0f, 1f);
}
public void SetColor(Color color) => this._color = color;
public void SetMiddleTexture(Asset<Texture2D> texAsset) => this._middleTexture = texAsset;
public void SetSelected(bool selected) => this._selected = selected;
public override void MouseOut(UIMouseEvent evt)
{
base.MouseOut(evt);
this._hovered = false;
}
}
}

View file

@ -0,0 +1,150 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIColoredSlider
// 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.Audio;
using Terraria.GameInput;
using Terraria.Localization;
using Terraria.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UIColoredSlider : UISliderBase
{
private Color _color;
private LocalizedText _textKey;
private Func<float> _getStatusTextAct;
private Action<float> _slideKeyboardAction;
private Func<float, Color> _blipFunc;
private Action _slideGamepadAction;
private const bool BOTHER_WITH_TEXT = false;
private bool _isReallyMouseOvered;
private bool _alreadyHovered;
private bool _soundedUsage;
public UIColoredSlider(
LocalizedText textKey,
Func<float> getStatus,
Action<float> setStatusKeyboard,
Action setStatusGamepad,
Func<float, Color> blipColorFunction,
Color color)
{
this._color = color;
this._textKey = textKey;
this._getStatusTextAct = getStatus != null ? getStatus : (Func<float>) (() => 0.0f);
this._slideKeyboardAction = setStatusKeyboard != null ? setStatusKeyboard : (Action<float>) (s => { });
this._blipFunc = blipColorFunction != null ? blipColorFunction : (Func<float, Color>) (s => Color.Lerp(Color.Black, Color.White, s));
this._slideGamepadAction = setStatusGamepad;
this._isReallyMouseOvered = false;
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
UISliderBase.CurrentAimedSlider = (UIElement) null;
if (!Main.mouseLeft)
UISliderBase.CurrentLockedSlider = (UIElement) null;
int usageLevel = this.GetUsageLevel();
float num1 = 8f;
base.DrawSelf(spriteBatch);
CalculatedStyle dimensions = this.GetDimensions();
float num2 = dimensions.Width + 1f;
Vector2 vector2_1 = new Vector2(dimensions.X, dimensions.Y);
bool flag1 = false;
bool flag2 = this.IsMouseHovering;
if (usageLevel == 2)
flag2 = false;
if (usageLevel == 1)
flag2 = true;
Vector2 vector2_2 = new Vector2(0.0f, 2f);
Vector2 drawPosition = vector2_1 + vector2_2;
Color.Lerp(flag1 ? Color.Gold : (flag2 ? Color.White : Color.Silver), Color.White, flag2 ? 0.5f : 0.0f);
Vector2 vector2_3 = new Vector2(0.8f);
drawPosition.X += 8f;
drawPosition.Y += num1;
drawPosition.X -= 17f;
TextureAssets.ColorBar.Frame();
drawPosition = new Vector2((float) ((double) dimensions.X + (double) dimensions.Width - 10.0), dimensions.Y + 10f + num1);
bool wasInBar;
float num3 = this.DrawValueBar(spriteBatch, drawPosition, 1f, this._getStatusTextAct(), usageLevel, out wasInBar, this._blipFunc);
if (UISliderBase.CurrentLockedSlider == this | wasInBar)
{
UISliderBase.CurrentAimedSlider = (UIElement) this;
if (PlayerInput.Triggers.Current.MouseLeft && !PlayerInput.UsingGamepad && UISliderBase.CurrentLockedSlider == this)
{
this._slideKeyboardAction(num3);
if (!this._soundedUsage)
SoundEngine.PlaySound(12);
this._soundedUsage = true;
}
else
this._soundedUsage = false;
}
if (UISliderBase.CurrentAimedSlider != null && UISliderBase.CurrentLockedSlider == null)
UISliderBase.CurrentLockedSlider = UISliderBase.CurrentAimedSlider;
if (!this._isReallyMouseOvered)
return;
this._slideGamepadAction();
}
private float DrawValueBar(
SpriteBatch sb,
Vector2 drawPosition,
float drawScale,
float sliderPosition,
int lockMode,
out bool wasInBar,
Func<float, Color> blipColorFunc)
{
Texture2D texture = TextureAssets.ColorBar.Value;
Vector2 vector2 = new Vector2((float) texture.Width, (float) texture.Height) * drawScale;
drawPosition.X -= (float) (int) vector2.X;
Rectangle destinationRectangle1 = new Rectangle((int) drawPosition.X, (int) drawPosition.Y - (int) vector2.Y / 2, (int) vector2.X, (int) vector2.Y);
Rectangle destinationRectangle2 = destinationRectangle1;
sb.Draw(texture, destinationRectangle1, Color.White);
float num1 = (float) destinationRectangle1.X + 5f * drawScale;
float y = (float) destinationRectangle1.Y + 4f * drawScale;
for (float num2 = 0.0f; (double) num2 < 167.0; ++num2)
{
float num3 = num2 / 167f;
Color color = blipColorFunc(num3);
sb.Draw(TextureAssets.ColorBlip.Value, new Vector2(num1 + num2 * drawScale, y), new Rectangle?(), color, 0.0f, Vector2.Zero, drawScale, SpriteEffects.None, 0.0f);
}
destinationRectangle1.X = (int) num1 - 2;
destinationRectangle1.Y = (int) y;
destinationRectangle1.Width -= 4;
destinationRectangle1.Height -= 8;
bool flag = destinationRectangle1.Contains(new Point(Main.mouseX, Main.mouseY));
this._isReallyMouseOvered = flag;
if (this.IgnoresMouseInteraction)
flag = false;
if (lockMode == 2)
flag = false;
if (flag || lockMode == 1)
{
sb.Draw(TextureAssets.ColorHighlight.Value, destinationRectangle2, Main.OurFavoriteColor);
if (!this._alreadyHovered)
SoundEngine.PlaySound(12);
this._alreadyHovered = true;
}
else
this._alreadyHovered = false;
wasInBar = false;
if (!this.IgnoresMouseInteraction)
{
sb.Draw(TextureAssets.ColorSlider.Value, new Vector2(num1 + 167f * drawScale * sliderPosition, y + 4f * drawScale), new Rectangle?(), Color.White, 0.0f, new Vector2(0.5f * (float) TextureAssets.ColorSlider.Value.Width, 0.5f * (float) TextureAssets.ColorSlider.Value.Height), drawScale, SpriteEffects.None, 0.0f);
if (Main.mouseX >= destinationRectangle1.X && Main.mouseX <= destinationRectangle1.X + destinationRectangle1.Width)
{
wasInBar = flag;
return (float) (Main.mouseX - destinationRectangle1.X) / (float) destinationRectangle1.Width;
}
}
return destinationRectangle1.X >= Main.mouseX ? 0.0f : 1f;
}
}
}

View file

@ -0,0 +1,40 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIColoredSliderSimple
// 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 Terraria.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UIColoredSliderSimple : UIElement
{
public float FillPercent;
public Color FilledColor = Main.OurFavoriteColor;
public Color EmptyColor = Color.Black;
protected override void DrawSelf(SpriteBatch spriteBatch) => this.DrawValueBarDynamicWidth(spriteBatch);
private void DrawValueBarDynamicWidth(SpriteBatch sb)
{
Texture2D texture1 = TextureAssets.ColorBar.Value;
Rectangle rectangle1 = this.GetDimensions().ToRectangle();
Rectangle rectangle2 = new Rectangle(5, 4, 4, 4);
Utils.DrawSplicedPanel(sb, texture1, rectangle1.X, rectangle1.Y, rectangle1.Width, rectangle1.Height, rectangle2.X, rectangle2.Width, rectangle2.Y, rectangle2.Height, Color.White);
Rectangle destinationRectangle1 = rectangle1;
destinationRectangle1.X += rectangle2.Left;
destinationRectangle1.Width -= rectangle2.Right;
destinationRectangle1.Y += rectangle2.Top;
destinationRectangle1.Height -= rectangle2.Bottom;
Texture2D texture2 = TextureAssets.MagicPixel.Value;
Rectangle rectangle3 = new Rectangle(0, 0, 1, 1);
sb.Draw(texture2, destinationRectangle1, new Rectangle?(rectangle3), this.EmptyColor);
Rectangle destinationRectangle2 = destinationRectangle1;
destinationRectangle2.Width = (int) ((double) destinationRectangle2.Width * (double) this.FillPercent);
sb.Draw(texture2, destinationRectangle2, new Rectangle?(rectangle3), this.FilledColor);
}
}
}

View file

@ -0,0 +1,574 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UICreativeInfiniteItemsDisplay
// 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.Audio;
using Terraria.DataStructures;
using Terraria.GameContent.Creative;
using Terraria.GameContent.UI.States;
using Terraria.Graphics.Renderers;
using Terraria.ID;
using Terraria.Localization;
using Terraria.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UICreativeInfiniteItemsDisplay : UIElement
{
private List<int> _itemIdsAvailableTotal;
private List<int> _itemIdsAvailableToShow;
private CreativeUnlocksTracker _lastTrackerCheckedForEdits;
private int _lastCheckedVersionForEdits = -1;
private UISearchBar _searchBar;
private UIPanel _searchBoxPanel;
private UIState _parentUIState;
private string _searchString;
private UIDynamicItemCollection _itemGrid;
private EntryFilterer<Item, IItemEntryFilter> _filterer;
private EntrySorter<int, ICreativeItemSortStep> _sorter;
private UIElement _containerInfinites;
private UIElement _containerSacrifice;
private bool _showSacrificesInsteadOfInfinites;
public const string SnapPointName_SacrificeSlot = "CreativeSacrificeSlot";
public const string SnapPointName_SacrificeConfirmButton = "CreativeSacrificeConfirm";
public const string SnapPointName_InfinitesFilter = "CreativeInfinitesFilter";
public const string SnapPointName_InfinitesSearch = "CreativeInfinitesSearch";
public const string SnapPointName_InfinitesItemSlot = "CreativeInfinitesSlot";
private List<UIImage> _sacrificeCogsSmall = new List<UIImage>();
private List<UIImage> _sacrificeCogsMedium = new List<UIImage>();
private List<UIImage> _sacrificeCogsBig = new List<UIImage>();
private UIImageFramed _sacrificePistons;
private UIParticleLayer _pistonParticleSystem;
private Asset<Texture2D> _pistonParticleAsset;
private int _sacrificeAnimationTimeLeft;
private bool _researchComplete;
private bool _hovered;
private int _lastItemIdSacrificed;
private int _lastItemAmountWeHad;
private int _lastItemAmountWeNeededTotal;
public UICreativeInfiniteItemsDisplay(UIState uiStateThatHoldsThis)
{
this._parentUIState = uiStateThatHoldsThis;
this._itemIdsAvailableTotal = new List<int>();
this._itemIdsAvailableToShow = new List<int>();
this._filterer = new EntryFilterer<Item, IItemEntryFilter>();
this._filterer.AddFilters(new List<IItemEntryFilter>()
{
(IItemEntryFilter) new ItemFilters.Weapon(),
(IItemEntryFilter) new ItemFilters.Armor(),
(IItemEntryFilter) new ItemFilters.BuildingBlock(),
(IItemEntryFilter) new ItemFilters.GameplayItems(),
(IItemEntryFilter) new ItemFilters.Accessories(),
(IItemEntryFilter) new ItemFilters.Consumables(),
(IItemEntryFilter) new ItemFilters.Materials()
});
this._filterer.SetSearchFilterObject<ItemFilters.BySearch>(new ItemFilters.BySearch());
this._sorter = new EntrySorter<int, ICreativeItemSortStep>();
this._sorter.AddSortSteps(new List<ICreativeItemSortStep>()
{
(ICreativeItemSortStep) new SortingSteps.ByCreativeSortingId(),
(ICreativeItemSortStep) new SortingSteps.Alphabetical()
});
this._itemIdsAvailableTotal.AddRange((IEnumerable<int>) CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId.Keys.ToList<int>());
this.BuildPage();
}
private void BuildPage()
{
this._lastCheckedVersionForEdits = -1;
this.RemoveAllChildren();
this.SetPadding(0.0f);
UIElement totalContainer1 = new UIElement()
{
Width = StyleDimension.Fill,
Height = StyleDimension.Fill
};
totalContainer1.SetPadding(0.0f);
this._containerInfinites = totalContainer1;
UIElement totalContainer2 = new UIElement()
{
Width = StyleDimension.Fill,
Height = StyleDimension.Fill
};
totalContainer2.SetPadding(0.0f);
this._containerSacrifice = totalContainer2;
this.BuildInfinitesMenuContents(totalContainer1);
this.BuildSacrificeMenuContents(totalContainer2);
this.UpdateContents();
this.OnUpdate += new UIElement.ElementEvent(this.UICreativeInfiniteItemsDisplay_OnUpdate);
}
private void Hover_OnUpdate(UIElement affectedElement)
{
if (!this._hovered)
return;
Main.LocalPlayer.mouseInterface = true;
}
private void Hover_OnMouseOut(UIMouseEvent evt, UIElement listeningElement) => this._hovered = false;
private void Hover_OnMouseOver(UIMouseEvent evt, UIElement listeningElement) => this._hovered = true;
private static UIPanel CreateBasicPanel()
{
UIPanel uiPanel = new UIPanel();
UICreativeInfiniteItemsDisplay.SetBasicSizesForCreativeSacrificeOrInfinitesPanel((UIElement) uiPanel);
uiPanel.BackgroundColor *= 0.8f;
uiPanel.BorderColor *= 0.8f;
return uiPanel;
}
private static void SetBasicSizesForCreativeSacrificeOrInfinitesPanel(UIElement element)
{
element.Width = new StyleDimension(0.0f, 1f);
element.Height = new StyleDimension(-38f, 1f);
element.Top = new StyleDimension(38f, 0.0f);
}
private void BuildInfinitesMenuContents(UIElement totalContainer)
{
UIPanel basicPanel = UICreativeInfiniteItemsDisplay.CreateBasicPanel();
totalContainer.Append((UIElement) basicPanel);
basicPanel.OnUpdate += new UIElement.ElementEvent(this.Hover_OnUpdate);
basicPanel.OnMouseOver += new UIElement.MouseEvent(this.Hover_OnMouseOver);
basicPanel.OnMouseOut += new UIElement.MouseEvent(this.Hover_OnMouseOut);
UIDynamicItemCollection dynamicItemCollection = new UIDynamicItemCollection();
this._itemGrid = dynamicItemCollection;
UIElement uiElement = new UIElement()
{
Height = new StyleDimension(24f, 0.0f),
Width = new StyleDimension(0.0f, 1f)
};
uiElement.SetPadding(0.0f);
basicPanel.Append(uiElement);
this.AddSearchBar(uiElement);
this._searchBar.SetContents((string) null, true);
UIList uiList1 = new UIList();
uiList1.Width = new StyleDimension(-25f, 1f);
uiList1.Height = new StyleDimension(-28f, 1f);
uiList1.VAlign = 1f;
uiList1.HAlign = 0.0f;
UIList uiList2 = uiList1;
basicPanel.Append((UIElement) uiList2);
float num = 4f;
UIScrollbar uiScrollbar = new UIScrollbar();
uiScrollbar.Height = new StyleDimension((float) (-28.0 - (double) num * 2.0), 1f);
uiScrollbar.Top = new StyleDimension(-num, 0.0f);
uiScrollbar.VAlign = 1f;
uiScrollbar.HAlign = 1f;
UIScrollbar scrollbar = uiScrollbar;
basicPanel.Append((UIElement) scrollbar);
uiList2.SetScrollbar(scrollbar);
uiList2.Add((UIElement) dynamicItemCollection);
UICreativeItemsInfiniteFilteringOptions filteringOptions = new UICreativeItemsInfiniteFilteringOptions(this._filterer, "CreativeInfinitesFilter");
filteringOptions.OnClickingOption += new Action(this.filtersHelper_OnClickingOption);
filteringOptions.Left = new StyleDimension(20f, 0.0f);
totalContainer.Append((UIElement) filteringOptions);
filteringOptions.OnUpdate += new UIElement.ElementEvent(this.Hover_OnUpdate);
filteringOptions.OnMouseOver += new UIElement.MouseEvent(this.Hover_OnMouseOver);
filteringOptions.OnMouseOut += new UIElement.MouseEvent(this.Hover_OnMouseOut);
}
private void BuildSacrificeMenuContents(UIElement totalContainer)
{
UIPanel basicPanel = UICreativeInfiniteItemsDisplay.CreateBasicPanel();
basicPanel.VAlign = 0.5f;
basicPanel.Height = new StyleDimension(170f, 0.0f);
basicPanel.Width = new StyleDimension(170f, 0.0f);
basicPanel.Top = new StyleDimension();
totalContainer.Append((UIElement) basicPanel);
basicPanel.OnUpdate += new UIElement.ElementEvent(this.Hover_OnUpdate);
basicPanel.OnMouseOver += new UIElement.MouseEvent(this.Hover_OnMouseOver);
basicPanel.OnMouseOut += new UIElement.MouseEvent(this.Hover_OnMouseOut);
this.AddCogsForSacrificeMenu((UIElement) basicPanel);
this._pistonParticleAsset = Main.Assets.Request<Texture2D>("Images/UI/Creative/Research_Spark", (AssetRequestMode) 1);
float pixels = 0.0f;
UIImage uiImage1 = new UIImage(Main.Assets.Request<Texture2D>("Images/UI/Creative/Research_Slots", (AssetRequestMode) 1));
uiImage1.HAlign = 0.5f;
uiImage1.VAlign = 0.5f;
uiImage1.Top = new StyleDimension(-20f, 0.0f);
uiImage1.Left = new StyleDimension(pixels, 0.0f);
UIImage uiImage2 = uiImage1;
basicPanel.Append((UIElement) uiImage2);
Asset<Texture2D> asset = Main.Assets.Request<Texture2D>("Images/UI/Creative/Research_FramedPistons", (AssetRequestMode) 1);
UIImageFramed uiImageFramed1 = new UIImageFramed(asset, asset.Frame(verticalFrames: 9));
uiImageFramed1.HAlign = 0.5f;
uiImageFramed1.VAlign = 0.5f;
uiImageFramed1.Top = new StyleDimension(-20f, 0.0f);
uiImageFramed1.Left = new StyleDimension(pixels, 0.0f);
uiImageFramed1.IgnoresMouseInteraction = true;
UIImageFramed uiImageFramed2 = uiImageFramed1;
basicPanel.Append((UIElement) uiImageFramed2);
this._sacrificePistons = uiImageFramed2;
UIParticleLayer uiParticleLayer = new UIParticleLayer();
uiParticleLayer.Width = new StyleDimension(0.0f, 1f);
uiParticleLayer.Height = new StyleDimension(0.0f, 1f);
uiParticleLayer.AnchorPositionOffsetByPercents = Vector2.One / 2f;
uiParticleLayer.AnchorPositionOffsetByPixels = Vector2.Zero;
this._pistonParticleSystem = uiParticleLayer;
uiImageFramed2.Append((UIElement) this._pistonParticleSystem);
UIElement element = Main.CreativeMenu.ProvideItemSlotElement(0);
element.HAlign = 0.5f;
element.VAlign = 0.5f;
element.Top = new StyleDimension(-15f, 0.0f);
element.Left = new StyleDimension(pixels, 0.0f);
element.SetSnapPoint("CreativeSacrificeSlot", 0);
uiImage2.Append(element);
UIText uiText1 = new UIText("(0/50)", 0.8f);
uiText1.Top = new StyleDimension(10f, 0.0f);
uiText1.Left = new StyleDimension(pixels, 0.0f);
uiText1.HAlign = 0.5f;
uiText1.VAlign = 0.5f;
uiText1.IgnoresMouseInteraction = true;
UIText uiText2 = uiText1;
uiText2.OnUpdate += new UIElement.ElementEvent(this.descriptionText_OnUpdate);
basicPanel.Append((UIElement) uiText2);
UIPanel uiPanel1 = new UIPanel();
uiPanel1.Top = new StyleDimension(0.0f, 0.0f);
uiPanel1.Left = new StyleDimension(pixels, 0.0f);
uiPanel1.HAlign = 0.5f;
uiPanel1.VAlign = 1f;
uiPanel1.Width = new StyleDimension(124f, 0.0f);
uiPanel1.Height = new StyleDimension(30f, 0.0f);
UIPanel uiPanel2 = uiPanel1;
UIText uiText3 = new UIText(Language.GetText("CreativePowers.ConfirmInfiniteItemSacrifice"), 0.8f);
uiText3.IgnoresMouseInteraction = true;
uiText3.HAlign = 0.5f;
uiText3.VAlign = 0.5f;
UIText uiText4 = uiText3;
uiPanel2.Append((UIElement) uiText4);
uiPanel2.SetSnapPoint("CreativeSacrificeConfirm", 0);
uiPanel2.OnClick += new UIElement.MouseEvent(this.sacrificeButton_OnClick);
uiPanel2.OnMouseOver += new UIElement.MouseEvent(this.FadedMouseOver);
uiPanel2.OnMouseOut += new UIElement.MouseEvent(this.FadedMouseOut);
uiPanel2.OnUpdate += new UIElement.ElementEvent(this.research_OnUpdate);
basicPanel.Append((UIElement) uiPanel2);
basicPanel.OnUpdate += new UIElement.ElementEvent(this.sacrificeWindow_OnUpdate);
}
private void research_OnUpdate(UIElement affectedElement)
{
if (!affectedElement.IsMouseHovering)
return;
Main.instance.MouseText(Language.GetTextValue("CreativePowers.ResearchButtonTooltip"));
}
private void FadedMouseOver(UIMouseEvent evt, UIElement listeningElement)
{
SoundEngine.PlaySound(12);
((UIPanel) evt.Target).BackgroundColor = new Color(73, 94, 171);
((UIPanel) evt.Target).BorderColor = Colors.FancyUIFatButtonMouseOver;
}
private void FadedMouseOut(UIMouseEvent evt, UIElement listeningElement)
{
((UIPanel) evt.Target).BackgroundColor = new Color(63, 82, 151) * 0.8f;
((UIPanel) evt.Target).BorderColor = Color.Black;
}
private void AddCogsForSacrificeMenu(UIElement sacrificesContainer)
{
UIElement uiElement = new UIElement();
uiElement.IgnoresMouseInteraction = true;
UICreativeInfiniteItemsDisplay.SetBasicSizesForCreativeSacrificeOrInfinitesPanel(uiElement);
uiElement.VAlign = 0.5f;
uiElement.Height = new StyleDimension(170f, 0.0f);
uiElement.Width = new StyleDimension(280f, 0.0f);
uiElement.Top = new StyleDimension();
uiElement.SetPadding(0.0f);
sacrificesContainer.Append(uiElement);
Vector2 vector2 = new Vector2(-10f, -10f);
this.AddSymetricalCogsPair(uiElement, new Vector2(22f, 1f) + vector2, "Images/UI/Creative/Research_GearC", this._sacrificeCogsSmall);
this.AddSymetricalCogsPair(uiElement, new Vector2(1f, 28f) + vector2, "Images/UI/Creative/Research_GearB", this._sacrificeCogsMedium);
this.AddSymetricalCogsPair(uiElement, new Vector2(5f, 5f) + vector2, "Images/UI/Creative/Research_GearA", this._sacrificeCogsBig);
}
private void sacrificeWindow_OnUpdate(UIElement affectedElement)
{
float num1 = 0.05f;
float animationProgress = this.GetSacrificeAnimationProgress();
double lerpValue = (double) Utils.GetLerpValue(1f, 0.7f, animationProgress, true);
float num2 = 1f + (float) (lerpValue * lerpValue) * 2f;
float num3 = num1 * num2;
float num4 = 1.142857f;
float num5 = 1f;
UICreativeInfiniteItemsDisplay.OffsetRotationsForCogs((float) (2.0 * (double) num3), this._sacrificeCogsSmall);
UICreativeInfiniteItemsDisplay.OffsetRotationsForCogs(num4 * num3, this._sacrificeCogsMedium);
UICreativeInfiniteItemsDisplay.OffsetRotationsForCogs(-num5 * num3, this._sacrificeCogsBig);
int frameY = 0;
if (this._sacrificeAnimationTimeLeft != 0)
{
float num6 = 0.1f;
float num7 = 0.06666667f;
frameY = (double) animationProgress < 1.0 - (double) num6 ? ((double) animationProgress < 1.0 - (double) num6 * 2.0 ? ((double) animationProgress < 1.0 - (double) num6 * 3.0 ? ((double) animationProgress < (double) num7 * 4.0 ? ((double) animationProgress < (double) num7 * 3.0 ? ((double) animationProgress < (double) num7 * 2.0 ? ((double) animationProgress < (double) num7 ? 1 : 2) : 3) : 4) : 5) : 6) : 7) : 8;
if (this._sacrificeAnimationTimeLeft == 56)
{
SoundEngine.PlaySound(63);
Vector2 vector2 = new Vector2(0.0f, 0.1635f);
for (int index = 0; index < 15; ++index)
{
Vector2 initialVelocity = Main.rand.NextVector2Circular(4f, 3f);
if ((double) initialVelocity.Y > 0.0)
initialVelocity.Y = -initialVelocity.Y;
initialVelocity.Y -= 2f;
this._pistonParticleSystem.AddParticle((IParticle) new CreativeSacrificeParticle(this._pistonParticleAsset, new Rectangle?(), initialVelocity, Vector2.Zero)
{
AccelerationPerFrame = vector2,
ScaleOffsetPerFrame = -0.01666667f
});
}
}
if (this._sacrificeAnimationTimeLeft == 40 && this._researchComplete)
{
this._researchComplete = false;
SoundEngine.PlaySound(64);
}
}
this._sacrificePistons.SetFrame(1, 9, 0, frameY, 0, 0);
}
private static void OffsetRotationsForCogs(float rotationOffset, List<UIImage> cogsList)
{
cogsList[0].Rotation += rotationOffset;
cogsList[1].Rotation -= rotationOffset;
}
private void AddSymetricalCogsPair(
UIElement sacrificesContainer,
Vector2 cogOFfsetsInPixels,
string assetPath,
List<UIImage> imagesList)
{
Asset<Texture2D> asset = Main.Assets.Request<Texture2D>(assetPath, (AssetRequestMode) 1);
cogOFfsetsInPixels += -asset.Size() / 2f;
UIImage uiImage1 = new UIImage(asset);
uiImage1.NormalizedOrigin = Vector2.One / 2f;
uiImage1.Left = new StyleDimension(cogOFfsetsInPixels.X, 0.0f);
uiImage1.Top = new StyleDimension(cogOFfsetsInPixels.Y, 0.0f);
UIImage uiImage2 = uiImage1;
imagesList.Add(uiImage2);
sacrificesContainer.Append((UIElement) uiImage2);
UIImage uiImage3 = new UIImage(asset);
uiImage3.NormalizedOrigin = Vector2.One / 2f;
uiImage3.HAlign = 1f;
uiImage3.Left = new StyleDimension(-cogOFfsetsInPixels.X, 0.0f);
uiImage3.Top = new StyleDimension(cogOFfsetsInPixels.Y, 0.0f);
UIImage uiImage4 = uiImage3;
imagesList.Add(uiImage4);
sacrificesContainer.Append((UIElement) uiImage4);
}
private void descriptionText_OnUpdate(UIElement affectedElement)
{
UIText uiText = affectedElement as UIText;
int itemIdChecked;
int amountWeHave;
int amountNeededTotal;
bool sacrificeNumbers = Main.CreativeMenu.GetSacrificeNumbers(out itemIdChecked, out amountWeHave, out amountNeededTotal);
Main.CreativeMenu.ShouldDrawSacrificeArea();
if (!Main.mouseItem.IsAir)
this.ForgetItemSacrifice();
if (itemIdChecked == 0)
{
if (this._lastItemIdSacrificed != 0 && this._lastItemAmountWeNeededTotal != this._lastItemAmountWeHad)
uiText.SetText(string.Format("({0}/{1})", (object) this._lastItemAmountWeHad, (object) this._lastItemAmountWeNeededTotal));
else
uiText.SetText("???");
}
else
{
this.ForgetItemSacrifice();
if (!sacrificeNumbers)
uiText.SetText("X");
else
uiText.SetText(string.Format("({0}/{1})", (object) amountWeHave, (object) amountNeededTotal));
}
}
private void sacrificeButton_OnClick(UIMouseEvent evt, UIElement listeningElement)
{
int itemIdChecked;
int amountWeHave;
int amountNeededTotal;
Main.CreativeMenu.GetSacrificeNumbers(out itemIdChecked, out amountWeHave, out amountNeededTotal);
int amountWeSacrificed;
switch (Main.CreativeMenu.SacrificeItem(out amountWeSacrificed))
{
case CreativeUI.ItemSacrificeResult.SacrificedButNotDone:
this._researchComplete = false;
this.BeginSacrificeAnimation();
this.RememberItemSacrifice(itemIdChecked, amountWeHave + amountWeSacrificed, amountNeededTotal);
break;
case CreativeUI.ItemSacrificeResult.SacrificedAndDone:
this._researchComplete = true;
this.BeginSacrificeAnimation();
this.RememberItemSacrifice(itemIdChecked, amountWeHave + amountWeSacrificed, amountNeededTotal);
break;
}
}
private void RememberItemSacrifice(int itemId, int amountWeHave, int amountWeNeedTotal)
{
this._lastItemIdSacrificed = itemId;
this._lastItemAmountWeHad = amountWeHave;
this._lastItemAmountWeNeededTotal = amountWeNeedTotal;
}
private void ForgetItemSacrifice()
{
this._lastItemIdSacrificed = 0;
this._lastItemAmountWeHad = 0;
this._lastItemAmountWeNeededTotal = 0;
}
private void BeginSacrificeAnimation() => this._sacrificeAnimationTimeLeft = 60;
private void UpdateSacrificeAnimation()
{
if (this._sacrificeAnimationTimeLeft <= 0)
return;
--this._sacrificeAnimationTimeLeft;
}
private float GetSacrificeAnimationProgress() => Utils.GetLerpValue(60f, 0.0f, (float) this._sacrificeAnimationTimeLeft, true);
public void SetPageTypeToShow(
UICreativeInfiniteItemsDisplay.InfiniteItemsDisplayPage page)
{
this._showSacrificesInsteadOfInfinites = page == UICreativeInfiniteItemsDisplay.InfiniteItemsDisplayPage.InfiniteItemsResearch;
}
private void UICreativeInfiniteItemsDisplay_OnUpdate(UIElement affectedElement)
{
this.RemoveAllChildren();
CreativeUnlocksTracker playerCreativeTracker = Main.LocalPlayerCreativeTracker;
if (this._lastTrackerCheckedForEdits != playerCreativeTracker)
{
this._lastTrackerCheckedForEdits = playerCreativeTracker;
this._lastCheckedVersionForEdits = -1;
}
int lastEditId = playerCreativeTracker.ItemSacrifices.LastEditId;
if (this._lastCheckedVersionForEdits != lastEditId)
{
this._lastCheckedVersionForEdits = lastEditId;
this.UpdateContents();
}
if (this._showSacrificesInsteadOfInfinites)
this.Append(this._containerSacrifice);
else
this.Append(this._containerInfinites);
this.UpdateSacrificeAnimation();
}
private void filtersHelper_OnClickingOption() => this.UpdateContents();
private void UpdateContents()
{
this._itemIdsAvailableTotal.Clear();
CreativeItemSacrificesCatalog.Instance.FillListOfItemsThatCanBeObtainedInfinitely(this._itemIdsAvailableTotal);
this._itemIdsAvailableToShow.Clear();
this._itemIdsAvailableToShow.AddRange(this._itemIdsAvailableTotal.Where<int>((Func<int, bool>) (x => this._filterer.FitsFilter(ContentSamples.ItemsByType[x]))));
this._itemIdsAvailableToShow.Sort((IComparer<int>) this._sorter);
this._itemGrid.SetContentsToShow(this._itemIdsAvailableToShow);
}
private void AddSearchBar(UIElement searchArea)
{
UIImageButton uiImageButton1 = new UIImageButton(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Button_Search", (AssetRequestMode) 1));
uiImageButton1.VAlign = 0.5f;
uiImageButton1.HAlign = 0.0f;
UIImageButton uiImageButton2 = uiImageButton1;
uiImageButton2.OnClick += new UIElement.MouseEvent(this.Click_SearchArea);
uiImageButton2.SetHoverImage(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Button_Search_Border", (AssetRequestMode) 1));
uiImageButton2.SetVisibility(1f, 1f);
uiImageButton2.SetSnapPoint("CreativeInfinitesSearch", 0);
searchArea.Append((UIElement) uiImageButton2);
UIPanel uiPanel1 = new UIPanel();
uiPanel1.Width = new StyleDimension((float) (-(double) uiImageButton2.Width.Pixels - 3.0), 1f);
uiPanel1.Height = new StyleDimension(0.0f, 1f);
uiPanel1.VAlign = 0.5f;
uiPanel1.HAlign = 1f;
UIPanel uiPanel2 = uiPanel1;
this._searchBoxPanel = uiPanel2;
uiPanel2.BackgroundColor = new Color(35, 40, 83);
uiPanel2.BorderColor = new Color(35, 40, 83);
uiPanel2.SetPadding(0.0f);
searchArea.Append((UIElement) uiPanel2);
UISearchBar uiSearchBar1 = new UISearchBar(Language.GetText("UI.PlayerNameSlot"), 0.8f);
uiSearchBar1.Width = new StyleDimension(0.0f, 1f);
uiSearchBar1.Height = new StyleDimension(0.0f, 1f);
uiSearchBar1.HAlign = 0.0f;
uiSearchBar1.VAlign = 0.5f;
uiSearchBar1.Left = new StyleDimension(0.0f, 0.0f);
uiSearchBar1.IgnoresMouseInteraction = true;
UISearchBar uiSearchBar2 = uiSearchBar1;
this._searchBar = uiSearchBar2;
uiPanel2.OnClick += new UIElement.MouseEvent(this.Click_SearchArea);
uiSearchBar2.OnContentsChanged += new Action<string>(this.OnSearchContentsChanged);
uiPanel2.Append((UIElement) uiSearchBar2);
uiSearchBar2.OnStartTakingInput += new Action(this.OnStartTakingInput);
uiSearchBar2.OnEndTakingInput += new Action(this.OnEndTakingInput);
uiSearchBar2.OnNeedingVirtualKeyboard += new Action(this.OpenVirtualKeyboardWhenNeeded);
uiSearchBar2.OnCancledTakingInput += new Action(this.OnCancledInput);
}
private void OnCancledInput() => Main.LocalPlayer.ToggleInv();
private void Click_SearchArea(UIMouseEvent evt, UIElement listeningElement) => this._searchBar.ToggleTakingText();
private void OnSearchContentsChanged(string contents)
{
this._searchString = contents;
this._filterer.SetSearchFilter(contents);
this.UpdateContents();
}
private void OnStartTakingInput() => this._searchBoxPanel.BorderColor = Main.OurFavoriteColor;
private void OnEndTakingInput() => this._searchBoxPanel.BorderColor = new Color(35, 40, 83);
private void OpenVirtualKeyboardWhenNeeded()
{
int length = 40;
UIVirtualKeyboard uiVirtualKeyboard = new UIVirtualKeyboard(Language.GetText("UI.PlayerNameSlot").Value, this._searchString, new UIVirtualKeyboard.KeyboardSubmitEvent(this.OnFinishedSettingName), new Action(this.GoBackHere), 3, true);
uiVirtualKeyboard.SetMaxInputLength(length);
IngameFancyUI.OpenUIState((UIState) uiVirtualKeyboard);
}
private static UserInterface GetCurrentInterface()
{
UserInterface activeInstance = UserInterface.ActiveInstance;
return !Main.gameMenu ? Main.InGameUI : Main.MenuUI;
}
private void OnFinishedSettingName(string name)
{
this._searchBar.SetContents(name.Trim());
this.GoBackHere();
}
private void GoBackHere()
{
IngameFancyUI.Close();
this._searchBar.ToggleTakingText();
Main.CreativeMenu.GamepadMoveToSearchButtonHack = true;
}
public int GetItemsPerLine() => this._itemGrid.GetItemsPerLine();
public enum InfiniteItemsDisplayPage
{
InfiniteItemsPickup,
InfiniteItemsResearch,
}
}
}

View file

@ -0,0 +1,112 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UICreativeItemsInfiniteFilteringOptions
// 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 Terraria.Audio;
using Terraria.DataStructures;
using Terraria.GameContent.Creative;
using Terraria.Localization;
using Terraria.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UICreativeItemsInfiniteFilteringOptions : UIElement
{
private EntryFilterer<Item, IItemEntryFilter> _filterer;
private Dictionary<UIImageFramed, IItemEntryFilter> _filtersByButtons = new Dictionary<UIImageFramed, IItemEntryFilter>();
private Dictionary<UIImageFramed, UIElement> _iconsByButtons = new Dictionary<UIImageFramed, UIElement>();
private const int barFramesX = 2;
private const int barFramesY = 4;
public event Action OnClickingOption;
public UICreativeItemsInfiniteFilteringOptions(
EntryFilterer<Item, IItemEntryFilter> filterer,
string snapPointsName)
{
this._filterer = filterer;
int num1 = 40;
int count = this._filterer.AvailableFilters.Count;
int num2 = num1 * count;
this.Height = new StyleDimension((float) num1, 0.0f);
this.Width = new StyleDimension((float) num2, 0.0f);
this.Top = new StyleDimension(4f, 0.0f);
this.SetPadding(0.0f);
Asset<Texture2D> asset = Main.Assets.Request<Texture2D>("Images/UI/Creative/Infinite_Tabs_B", (AssetRequestMode) 1);
for (int index = 0; index < this._filterer.AvailableFilters.Count; ++index)
{
IItemEntryFilter availableFilter = this._filterer.AvailableFilters[index];
asset.Frame(2, 4).OffsetSize(-2, -2);
UIImageFramed uiImageFramed = new UIImageFramed(asset, asset.Frame(2, 4).OffsetSize(-2, -2));
uiImageFramed.Left.Set((float) (num1 * index), 0.0f);
uiImageFramed.OnClick += new UIElement.MouseEvent(this.singleFilterButtonClick);
uiImageFramed.OnMouseOver += new UIElement.MouseEvent(this.button_OnMouseOver);
uiImageFramed.SetPadding(0.0f);
uiImageFramed.SetSnapPoint(snapPointsName, index);
this.AddOnHover(availableFilter, (UIElement) uiImageFramed, index);
UIElement image = availableFilter.GetImage();
image.IgnoresMouseInteraction = true;
image.Left = new StyleDimension(6f, 0.0f);
image.HAlign = 0.0f;
uiImageFramed.Append(image);
this._filtersByButtons[uiImageFramed] = availableFilter;
this._iconsByButtons[uiImageFramed] = image;
this.Append((UIElement) uiImageFramed);
this.UpdateVisuals(uiImageFramed, index);
}
}
private void button_OnMouseOver(UIMouseEvent evt, UIElement listeningElement) => SoundEngine.PlaySound(12);
private void singleFilterButtonClick(UIMouseEvent evt, UIElement listeningElement)
{
IItemEntryFilter itemEntryFilter;
if (!(evt.Target is UIImageFramed target) || !this._filtersByButtons.TryGetValue(target, out itemEntryFilter))
return;
int num = this._filterer.AvailableFilters.IndexOf(itemEntryFilter);
if (num == -1)
return;
if (!this._filterer.ActiveFilters.Contains(itemEntryFilter))
this._filterer.ActiveFilters.Clear();
this._filterer.ToggleFilter(num);
this.UpdateVisuals(target, num);
if (this.OnClickingOption == null)
return;
this.OnClickingOption();
}
private void UpdateVisuals(UIImageFramed button, int indexOfFilter)
{
bool flag = this._filterer.IsFilterActive(indexOfFilter);
bool isMouseHovering = button.IsMouseHovering;
int frameX = flag.ToInt();
int frameY = flag.ToInt() * 2 + isMouseHovering.ToInt();
button.SetFrame(2, 4, frameX, frameY, -2, -2);
if (!(this._iconsByButtons[button] is IColorable iconsByButton))
return;
Color color = flag ? Color.White : Color.White * 0.5f;
iconsByButton.Color = color;
}
private void AddOnHover(IItemEntryFilter filter, UIElement button, int indexOfFilter)
{
button.OnUpdate += (UIElement.ElementEvent) (element => this.ShowButtonName(element, filter, indexOfFilter));
button.OnUpdate += (UIElement.ElementEvent) (element => this.UpdateVisuals(button as UIImageFramed, indexOfFilter));
}
private void ShowButtonName(UIElement element, IItemEntryFilter number, int indexOfFilter)
{
if (!element.IsMouseHovering)
return;
string textValue = Language.GetTextValue(number.GetDisplayNameKey());
Main.instance.MouseText(textValue);
}
}
}

View file

@ -0,0 +1,14 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UICreativePowerButton
// 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 Terraria.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UICreativePowerButton : UIElement
{
}
}

View file

@ -0,0 +1,94 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIDifficultyButton
// 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.Audio;
using Terraria.Localization;
using Terraria.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UIDifficultyButton : UIElement
{
private readonly Player _player;
private readonly Asset<Texture2D> _BasePanelTexture;
private readonly Asset<Texture2D> _selectedBorderTexture;
private readonly Asset<Texture2D> _hoveredBorderTexture;
private readonly byte _difficulty;
private readonly Color _color;
private bool _hovered;
private bool _soundedHover;
public UIDifficultyButton(
Player player,
LocalizedText title,
LocalizedText description,
byte difficulty,
Color color)
{
this._player = player;
this._difficulty = difficulty;
this.Width = StyleDimension.FromPixels(44f);
this.Height = StyleDimension.FromPixels(110f);
this._BasePanelTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/PanelGrayscale", (AssetRequestMode) 1);
this._selectedBorderTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/CategoryPanelHighlight", (AssetRequestMode) 1);
this._hoveredBorderTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/CategoryPanelBorder", (AssetRequestMode) 1);
this._color = color;
UIText uiText = new UIText(title, 0.9f);
uiText.HAlign = 0.5f;
uiText.VAlign = 0.0f;
uiText.Width = StyleDimension.FromPixelsAndPercent(-10f, 1f);
uiText.Top = StyleDimension.FromPixels(5f);
this.Append((UIElement) uiText);
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
if (this._hovered)
{
if (!this._soundedHover)
SoundEngine.PlaySound(12);
this._soundedHover = true;
}
else
this._soundedHover = false;
CalculatedStyle dimensions = this.GetDimensions();
int num1 = 7;
if ((double) dimensions.Height < 30.0)
num1 = 5;
int num2 = 10;
int num3 = 10;
int num4 = (int) this._difficulty == (int) this._player.difficulty ? 1 : 0;
Utils.DrawSplicedPanel(spriteBatch, this._BasePanelTexture.Value, (int) dimensions.X, (int) dimensions.Y, (int) dimensions.Width, (int) dimensions.Height, num2, num2, num3, num3, Color.Lerp(Color.Black, this._color, 0.8f) * 0.5f);
if (num4 != 0)
Utils.DrawSplicedPanel(spriteBatch, this._BasePanelTexture.Value, (int) dimensions.X + num1, (int) dimensions.Y + num1 - 2, (int) dimensions.Width - num1 * 2, (int) dimensions.Height - num1 * 2, num2, num2, num3, num3, Color.Lerp(this._color, Color.White, 0.7f) * 0.5f);
if (!this._hovered)
return;
Utils.DrawSplicedPanel(spriteBatch, this._hoveredBorderTexture.Value, (int) dimensions.X, (int) dimensions.Y, (int) dimensions.Width, (int) dimensions.Height, num2, num2, num3, num3, Color.White);
}
public override void MouseDown(UIMouseEvent evt)
{
this._player.difficulty = this._difficulty;
SoundEngine.PlaySound(12);
base.MouseDown(evt);
}
public override void MouseOver(UIMouseEvent evt)
{
base.MouseOver(evt);
this._hovered = true;
}
public override void MouseOut(UIMouseEvent evt)
{
base.MouseOut(evt);
this._hovered = false;
}
}
}

View file

@ -0,0 +1,176 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIDynamicItemCollection
// 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 System.Collections.Generic;
using Terraria.GameInput;
using Terraria.ID;
using Terraria.UI;
using Terraria.UI.Gamepad;
namespace Terraria.GameContent.UI.Elements
{
public class UIDynamicItemCollection : UIElement
{
private List<int> _itemIdsAvailableToShow = new List<int>();
private List<int> _itemIdsToLoadTexturesFor = new List<int>();
private int _itemsPerLine;
private const int sizePerEntryX = 44;
private const int sizePerEntryY = 44;
private List<SnapPoint> _dummySnapPoints = new List<SnapPoint>();
public UIDynamicItemCollection()
{
this.Width = new StyleDimension(0.0f, 1f);
this.HAlign = 0.5f;
this.UpdateSize();
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
Main.inventoryScale = 0.8461539f;
int startX;
int startY;
int startItemIndex;
int endItemIndex;
this.GetGridParameters(out startX, out startY, out startItemIndex, out endItemIndex);
int itemsPerLine = this._itemsPerLine;
for (int index = startItemIndex; index < endItemIndex; ++index)
{
int key = this._itemIdsAvailableToShow[index];
Rectangle itemSlotHitbox = this.GetItemSlotHitbox(startX, startY, startItemIndex, index);
Item inv = ContentSamples.ItemsByType[key];
int context = 29;
if (TextureAssets.Item[key].State == null)
--itemsPerLine;
bool flag = false;
if (this.IsMouseHovering && itemSlotHitbox.Contains(Main.MouseScreen.ToPoint()) && !PlayerInput.IgnoreMouseInterface)
{
Main.LocalPlayer.mouseInterface = true;
ItemSlot.OverrideHover(ref inv, context);
ItemSlot.LeftClick(ref inv, context);
ItemSlot.RightClick(ref inv, context);
ItemSlot.MouseHover(ref inv, context);
flag = true;
}
UILinkPointNavigator.Shortcuts.CREATIVE_ItemSlotShouldHighlightAsSelected = flag;
ItemSlot.Draw(spriteBatch, ref inv, context, itemSlotHitbox.TopLeft());
if (itemsPerLine <= 0)
break;
}
while (this._itemIdsToLoadTexturesFor.Count > 0 && itemsPerLine > 0)
{
int i = this._itemIdsToLoadTexturesFor[0];
this._itemIdsToLoadTexturesFor.RemoveAt(0);
if (TextureAssets.Item[i].State == null)
{
Main.instance.LoadItem(i);
itemsPerLine -= 4;
}
}
}
private Rectangle GetItemSlotHitbox(
int startX,
int startY,
int startItemIndex,
int i)
{
int num1 = i - startItemIndex;
int num2 = num1 % this._itemsPerLine;
int num3 = num1 / this._itemsPerLine;
return new Rectangle(startX + num2 * 44, startY + num3 * 44, 44, 44);
}
private void GetGridParameters(
out int startX,
out int startY,
out int startItemIndex,
out int endItemIndex)
{
Rectangle rectangle = this.GetDimensions().ToRectangle();
Rectangle viewCullingArea = this.Parent.GetViewCullingArea();
int x = rectangle.Center.X;
startX = x - (int) ((double) (44 * this._itemsPerLine) * 0.5);
startY = rectangle.Top;
startItemIndex = 0;
endItemIndex = this._itemIdsAvailableToShow.Count;
int num1 = (Math.Min(viewCullingArea.Top, rectangle.Top) - viewCullingArea.Top) / 44;
startY += -num1 * 44;
startItemIndex += -num1 * this._itemsPerLine;
int num2 = (int) Math.Ceiling((double) viewCullingArea.Height / 44.0) * this._itemsPerLine;
if (endItemIndex <= num2 + startItemIndex + this._itemsPerLine)
return;
endItemIndex = num2 + startItemIndex + this._itemsPerLine;
}
public override void Recalculate()
{
base.Recalculate();
this.UpdateSize();
}
public override void Update(GameTime gameTime)
{
base.Update(gameTime);
if (!this.IsMouseHovering)
return;
Main.LocalPlayer.mouseInterface = true;
}
public void SetContentsToShow(List<int> itemIdsToShow)
{
this._itemIdsAvailableToShow.Clear();
this._itemIdsToLoadTexturesFor.Clear();
this._itemIdsAvailableToShow.AddRange((IEnumerable<int>) itemIdsToShow);
this._itemIdsToLoadTexturesFor.AddRange((IEnumerable<int>) itemIdsToShow);
this.UpdateSize();
}
public int GetItemsPerLine() => this._itemsPerLine;
public override List<SnapPoint> GetSnapPoints()
{
List<SnapPoint> snapPointList = new List<SnapPoint>();
int startX;
int startY;
int startItemIndex;
int endItemIndex;
this.GetGridParameters(out startX, out startY, out startItemIndex, out endItemIndex);
int itemsPerLine = this._itemsPerLine;
Rectangle viewCullingArea = this.Parent.GetViewCullingArea();
int num1 = endItemIndex - startItemIndex;
while (this._dummySnapPoints.Count < num1)
this._dummySnapPoints.Add(new SnapPoint("CreativeInfinitesSlot", 0, Vector2.Zero, Vector2.Zero));
int num2 = 0;
Vector2 vector2 = this.GetDimensions().Position();
for (int i = startItemIndex; i < endItemIndex; ++i)
{
Point center = this.GetItemSlotHitbox(startX, startY, startItemIndex, i).Center;
if (viewCullingArea.Contains(center))
{
SnapPoint dummySnapPoint = this._dummySnapPoints[num2];
dummySnapPoint.ThisIsAHackThatChangesTheSnapPointsInfo(Vector2.Zero, center.ToVector2() - vector2, num2);
dummySnapPoint.Calculate((UIElement) this);
++num2;
snapPointList.Add(dummySnapPoint);
}
}
foreach (UIElement element in this.Elements)
snapPointList.AddRange((IEnumerable<SnapPoint>) element.GetSnapPoints());
return snapPointList;
}
public void UpdateSize()
{
int num = this.GetDimensions().ToRectangle().Width / 44;
this._itemsPerLine = num;
this.MinHeight.Set((float) (44 * (int) Math.Ceiling((double) this._itemIdsAvailableToShow.Count / (double) num)), 0.0f);
}
}
}

View file

@ -0,0 +1,124 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIGenProgressBar
// 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.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UIGenProgressBar : UIElement
{
private Asset<Texture2D> _texOuterCrimson;
private Asset<Texture2D> _texOuterCorrupt;
private Asset<Texture2D> _texOuterLower;
private float _visualOverallProgress;
private float _targetOverallProgress;
private float _visualCurrentProgress;
private float _targetCurrentProgress;
private int _smallBarWidth = 508;
private int _longBarWidth = 570;
public UIGenProgressBar()
{
if (Main.netMode != 2)
{
this._texOuterCorrupt = Main.Assets.Request<Texture2D>("Images/UI/WorldGen/Outer_Corrupt", (AssetRequestMode) 1);
this._texOuterCrimson = Main.Assets.Request<Texture2D>("Images/UI/WorldGen/Outer_Crimson", (AssetRequestMode) 1);
this._texOuterLower = Main.Assets.Request<Texture2D>("Images/UI/WorldGen/Outer_Lower", (AssetRequestMode) 1);
}
this.Recalculate();
}
public override void Recalculate()
{
this.Width.Precent = 0.0f;
this.Height.Precent = 0.0f;
this.Width.Pixels = 612f;
this.Height.Pixels = 70f;
base.Recalculate();
}
public void SetProgress(float overallProgress, float currentProgress)
{
this._targetCurrentProgress = currentProgress;
this._targetOverallProgress = overallProgress;
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
if (!this._texOuterCorrupt.IsLoaded || !this._texOuterCrimson.IsLoaded || !this._texOuterLower.IsLoaded)
return;
bool flag = WorldGen.crimson;
if (WorldGen.drunkWorldGen && Main.rand.Next(2) == 0)
flag = !flag;
this._visualOverallProgress = this._targetOverallProgress;
this._visualCurrentProgress = this._targetCurrentProgress;
CalculatedStyle dimensions = this.GetDimensions();
int completedWidth1 = (int) ((double) this._visualOverallProgress * (double) this._longBarWidth);
int completedWidth2 = (int) ((double) this._visualCurrentProgress * (double) this._smallBarWidth);
Vector2 vector2 = new Vector2(dimensions.X, dimensions.Y);
Color filled = new Color();
filled.PackedValue = flag ? 4286836223U : 4283888223U;
this.DrawFilling2(spriteBatch, vector2 + new Vector2(20f, 40f), 16, completedWidth1, this._longBarWidth, filled, Color.Lerp(filled, Color.Black, 0.5f), new Color(48, 48, 48));
filled.PackedValue = 4290947159U;
this.DrawFilling2(spriteBatch, vector2 + new Vector2(50f, 60f), 8, completedWidth2, this._smallBarWidth, filled, Color.Lerp(filled, Color.Black, 0.5f), new Color(33, 33, 33));
Rectangle rectangle = this.GetDimensions().ToRectangle();
rectangle.X -= 8;
spriteBatch.Draw(flag ? this._texOuterCrimson.Value : this._texOuterCorrupt.Value, rectangle.TopLeft(), Color.White);
spriteBatch.Draw(this._texOuterLower.Value, rectangle.TopLeft() + new Vector2(44f, 60f), Color.White);
}
private void DrawFilling(
SpriteBatch spritebatch,
Texture2D tex,
Texture2D texShadow,
Vector2 topLeft,
int completedWidth,
int totalWidth,
Color separator,
Color empty)
{
if (completedWidth % 2 != 0)
--completedWidth;
Vector2 position = topLeft + (float) completedWidth * Vector2.UnitX;
int num = completedWidth;
Rectangle rectangle = tex.Frame();
for (; num > 0; num -= rectangle.Width)
{
if (rectangle.Width > num)
{
rectangle.X += rectangle.Width - num;
rectangle.Width = num;
}
spritebatch.Draw(tex, position, new Rectangle?(rectangle), Color.White, 0.0f, new Vector2((float) rectangle.Width, 0.0f), 1f, SpriteEffects.None, 0.0f);
position.X -= (float) rectangle.Width;
}
if (texShadow != null)
spritebatch.Draw(texShadow, topLeft, new Rectangle?(new Rectangle(0, 0, completedWidth, texShadow.Height)), Color.White);
spritebatch.Draw(TextureAssets.MagicPixel.Value, new Rectangle((int) topLeft.X + completedWidth, (int) topLeft.Y, totalWidth - completedWidth, tex.Height), new Rectangle?(new Rectangle(0, 0, 1, 1)), empty);
spritebatch.Draw(TextureAssets.MagicPixel.Value, new Rectangle((int) topLeft.X + completedWidth - 2, (int) topLeft.Y, 2, tex.Height), new Rectangle?(new Rectangle(0, 0, 1, 1)), separator);
}
private void DrawFilling2(
SpriteBatch spritebatch,
Vector2 topLeft,
int height,
int completedWidth,
int totalWidth,
Color filled,
Color separator,
Color empty)
{
if (completedWidth % 2 != 0)
--completedWidth;
spritebatch.Draw(TextureAssets.MagicPixel.Value, new Rectangle((int) topLeft.X, (int) topLeft.Y, completedWidth, height), new Rectangle?(new Rectangle(0, 0, 1, 1)), filled);
spritebatch.Draw(TextureAssets.MagicPixel.Value, new Rectangle((int) topLeft.X + completedWidth, (int) topLeft.Y, totalWidth - completedWidth, height), new Rectangle?(new Rectangle(0, 0, 1, 1)), empty);
spritebatch.Draw(TextureAssets.MagicPixel.Value, new Rectangle((int) topLeft.X + completedWidth - 2, (int) topLeft.Y, 2, height), new Rectangle?(new Rectangle(0, 0, 1, 1)), separator);
}
}
}

View file

@ -0,0 +1,76 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIHairStyleButton
// 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.Audio;
using Terraria.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UIHairStyleButton : UIImageButton
{
private readonly Player _player;
public readonly int HairStyleId;
private readonly Asset<Texture2D> _selectedBorderTexture;
private readonly Asset<Texture2D> _hoveredBorderTexture;
private bool _hovered;
private bool _soundedHover;
public UIHairStyleButton(Player player, int hairStyleId)
: base(Main.Assets.Request<Texture2D>("Images/UI/CharCreation/CategoryPanel", (AssetRequestMode) 1))
{
this._player = player;
this.HairStyleId = hairStyleId;
this.Width = StyleDimension.FromPixels(44f);
this.Height = StyleDimension.FromPixels(44f);
this._selectedBorderTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/CategoryPanelHighlight", (AssetRequestMode) 1);
this._hoveredBorderTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/CategoryPanelBorder", (AssetRequestMode) 1);
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
if (this._hovered)
{
if (!this._soundedHover)
SoundEngine.PlaySound(12);
this._soundedHover = true;
}
else
this._soundedHover = false;
Vector2 vector2 = new Vector2(-5f, -5f);
base.DrawSelf(spriteBatch);
if (this._player.hair == this.HairStyleId)
spriteBatch.Draw(this._selectedBorderTexture.Value, this.GetDimensions().Center() - this._selectedBorderTexture.Size() / 2f, Color.White);
if (this._hovered)
spriteBatch.Draw(this._hoveredBorderTexture.Value, this.GetDimensions().Center() - this._hoveredBorderTexture.Size() / 2f, Color.White);
int hair = this._player.hair;
this._player.hair = this.HairStyleId;
Main.PlayerRenderer.DrawPlayerHead(Main.Camera, this._player, this.GetDimensions().Center() + vector2);
this._player.hair = hair;
}
public override void MouseDown(UIMouseEvent evt)
{
this._player.hair = this.HairStyleId;
SoundEngine.PlaySound(12);
base.MouseDown(evt);
}
public override void MouseOver(UIMouseEvent evt)
{
base.MouseOver(evt);
this._hovered = true;
}
public override void MouseOut(UIMouseEvent evt)
{
base.MouseOut(evt);
this._hovered = false;
}
}
}

View file

@ -0,0 +1,50 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIHeader
// 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.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UIHeader : UIElement
{
private string _text;
public string Text
{
get => this._text;
set
{
if (!(this._text != value))
return;
this._text = value;
Vector2 vector2 = FontAssets.DeathText.Value.MeasureString(this.Text);
this.Width.Pixels = vector2.X;
this.Height.Pixels = vector2.Y;
this.Width.Precent = 0.0f;
this.Height.Precent = 0.0f;
this.Recalculate();
}
}
public UIHeader() => this.Text = "";
public UIHeader(string text) => this.Text = text;
protected override void DrawSelf(SpriteBatch spriteBatch)
{
CalculatedStyle dimensions = this.GetDimensions();
float num = 1.2f;
DynamicSpriteFontExtensionMethods.DrawString(spriteBatch, FontAssets.DeathText.Value, this.Text, new Vector2(dimensions.X - num, dimensions.Y - num), Color.Black);
DynamicSpriteFontExtensionMethods.DrawString(spriteBatch, FontAssets.DeathText.Value, this.Text, new Vector2(dimensions.X + num, dimensions.Y - num), Color.Black);
DynamicSpriteFontExtensionMethods.DrawString(spriteBatch, FontAssets.DeathText.Value, this.Text, new Vector2(dimensions.X - num, dimensions.Y + num), Color.Black);
DynamicSpriteFontExtensionMethods.DrawString(spriteBatch, FontAssets.DeathText.Value, this.Text, new Vector2(dimensions.X + num, dimensions.Y + num), Color.Black);
DynamicSpriteFontExtensionMethods.DrawString(spriteBatch, FontAssets.DeathText.Value, this.Text, new Vector2(dimensions.X, dimensions.Y), Color.White);
}
}
}

View file

@ -0,0 +1,36 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIHorizontalSeparator
// 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.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UIHorizontalSeparator : UIElement
{
private Asset<Texture2D> _texture;
public Color Color;
public int EdgeWidth;
public UIHorizontalSeparator(int EdgeWidth = 2, bool highlightSideUp = true)
{
this.Color = Color.White;
this._texture = !highlightSideUp ? Main.Assets.Request<Texture2D>("Images/UI/CharCreation/Separator2", (AssetRequestMode) 1) : Main.Assets.Request<Texture2D>("Images/UI/CharCreation/Separator1", (AssetRequestMode) 1);
this.Width.Set((float) this._texture.Width(), 0.0f);
this.Height.Set((float) this._texture.Height(), 0.0f);
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
CalculatedStyle dimensions = this.GetDimensions();
Utils.DrawPanel(this._texture.Value, this.EdgeWidth, 0, spriteBatch, dimensions.Position(), dimensions.Width, this.Color);
}
public override bool ContainsPoint(Vector2 point) => false;
}
}

View file

@ -0,0 +1,55 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIImage
// 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.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UIImage : UIElement
{
private Asset<Texture2D> _texture;
public float ImageScale = 1f;
public float Rotation;
public bool ScaleToFit;
public Color Color = Color.White;
public Vector2 NormalizedOrigin = Vector2.Zero;
public bool RemoveFloatingPointsFromDrawPosition;
public UIImage(Asset<Texture2D> texture)
{
this._texture = texture;
this.Width.Set((float) this._texture.Width(), 0.0f);
this.Height.Set((float) this._texture.Height(), 0.0f);
}
public void SetImage(Asset<Texture2D> texture)
{
this._texture = texture;
this.Width.Set((float) this._texture.Width(), 0.0f);
this.Height.Set((float) this._texture.Height(), 0.0f);
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
CalculatedStyle dimensions = this.GetDimensions();
if (this.ScaleToFit)
{
spriteBatch.Draw(this._texture.Value, dimensions.ToRectangle(), this.Color);
}
else
{
Vector2 vector2_1 = this._texture.Value.Size();
Vector2 vector2_2 = dimensions.Position() + vector2_1 * (1f - this.ImageScale) / 2f + vector2_1 * this.NormalizedOrigin;
if (this.RemoveFloatingPointsFromDrawPosition)
vector2_2 = vector2_2.Floor();
spriteBatch.Draw(this._texture.Value, vector2_2, new Rectangle?(), this.Color, this.Rotation, vector2_1 * this.NormalizedOrigin, this.ImageScale, SpriteEffects.None, 0.0f);
}
}
}
}

View file

@ -0,0 +1,61 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIImageButton
// 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.Audio;
using Terraria.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UIImageButton : UIElement
{
private Asset<Texture2D> _texture;
private float _visibilityActive = 1f;
private float _visibilityInactive = 0.4f;
private Asset<Texture2D> _borderTexture;
public UIImageButton(Asset<Texture2D> texture)
{
this._texture = texture;
this.Width.Set((float) this._texture.Width(), 0.0f);
this.Height.Set((float) this._texture.Height(), 0.0f);
}
public void SetHoverImage(Asset<Texture2D> texture) => this._borderTexture = texture;
public void SetImage(Asset<Texture2D> texture)
{
this._texture = texture;
this.Width.Set((float) this._texture.Width(), 0.0f);
this.Height.Set((float) this._texture.Height(), 0.0f);
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
CalculatedStyle dimensions = this.GetDimensions();
spriteBatch.Draw(this._texture.Value, dimensions.Position(), Color.White * (this.IsMouseHovering ? this._visibilityActive : this._visibilityInactive));
if (this._borderTexture == null || !this.IsMouseHovering)
return;
spriteBatch.Draw(this._borderTexture.Value, dimensions.Position(), Color.White);
}
public override void MouseOver(UIMouseEvent evt)
{
base.MouseOver(evt);
SoundEngine.PlaySound(12);
}
public override void MouseOut(UIMouseEvent evt) => base.MouseOut(evt);
public void SetVisibility(float whenActive, float whenInactive)
{
this._visibilityActive = MathHelper.Clamp(whenActive, 0.0f, 1f);
this._visibilityInactive = MathHelper.Clamp(whenInactive, 0.0f, 1f);
}
}
}

View file

@ -0,0 +1,62 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIImageFramed
// 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.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UIImageFramed : UIElement, IColorable
{
private Asset<Texture2D> _texture;
private Rectangle _frame;
public Color Color { get; set; }
public UIImageFramed(Asset<Texture2D> texture, Rectangle frame)
{
this._texture = texture;
this._frame = frame;
this.Width.Set((float) this._frame.Width, 0.0f);
this.Height.Set((float) this._frame.Height, 0.0f);
this.Color = Color.White;
}
public void SetImage(Asset<Texture2D> texture, Rectangle frame)
{
this._texture = texture;
this._frame = frame;
this.Width.Set((float) this._frame.Width, 0.0f);
this.Height.Set((float) this._frame.Height, 0.0f);
}
public void SetFrame(Rectangle frame)
{
this._frame = frame;
this.Width.Set((float) this._frame.Width, 0.0f);
this.Height.Set((float) this._frame.Height, 0.0f);
}
public void SetFrame(
int frameCountHorizontal,
int frameCountVertical,
int frameX,
int frameY,
int sizeOffsetX,
int sizeOffsetY)
{
this.SetFrame(this._texture.Frame(frameCountHorizontal, frameCountVertical, frameX, frameY).OffsetSize(sizeOffsetX, sizeOffsetY));
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
CalculatedStyle dimensions = this.GetDimensions();
spriteBatch.Draw(this._texture.Value, dimensions.Position(), new Rectangle?(this._frame), this.Color);
}
}
}

View file

@ -0,0 +1,32 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIItemIcon
// 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 Terraria.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UIItemIcon : UIElement
{
private Item _item;
private bool _blackedOut;
public UIItemIcon(Item item, bool blackedOut)
{
this._item = item;
this.Width.Set(32f, 0.0f);
this.Height.Set(32f, 0.0f);
this._blackedOut = blackedOut;
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
CalculatedStyle dimensions = this.GetDimensions();
Main.DrawItemIcon(spriteBatch, this._item, dimensions.Center(), this._blackedOut ? Color.Black : Color.White, 32f);
}
}
}

View file

@ -0,0 +1,49 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIItemSlot
// 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 Terraria.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UIItemSlot : UIElement
{
private Item[] _itemArray;
private int _itemIndex;
private int _itemSlotContext;
public UIItemSlot(Item[] itemArray, int itemIndex, int itemSlotContext)
{
this._itemArray = itemArray;
this._itemIndex = itemIndex;
this._itemSlotContext = itemSlotContext;
this.Width = new StyleDimension(48f, 0.0f);
this.Height = new StyleDimension(48f, 0.0f);
}
private void HandleItemSlotLogic()
{
if (!this.IsMouseHovering)
return;
Main.LocalPlayer.mouseInterface = true;
Item inv = this._itemArray[this._itemIndex];
ItemSlot.OverrideHover(ref inv, this._itemSlotContext);
ItemSlot.LeftClick(ref inv, this._itemSlotContext);
ItemSlot.RightClick(ref inv, this._itemSlotContext);
ItemSlot.MouseHover(ref inv, this._itemSlotContext);
this._itemArray[this._itemIndex] = inv;
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
this.HandleItemSlotLogic();
Item inv = this._itemArray[this._itemIndex];
Vector2 position = this.GetDimensions().Center() + new Vector2(52f, 52f) * -0.5f * Main.inventoryScale;
ItemSlot.Draw(spriteBatch, ref inv, this._itemSlotContext, position);
}
}
}

View file

@ -0,0 +1,204 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIKeybindingListItem
// 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.GameContent.UI.Chat;
using Terraria.GameInput;
using Terraria.Localization;
using Terraria.UI;
using Terraria.UI.Chat;
namespace Terraria.GameContent.UI.Elements
{
public class UIKeybindingListItem : UIElement
{
private InputMode _inputmode;
private Color _color;
private string _keybind;
public UIKeybindingListItem(string bind, InputMode mode, Color color)
{
this._keybind = bind;
this._inputmode = mode;
this._color = color;
this.OnClick += new UIElement.MouseEvent(this.OnClickMethod);
}
public void OnClickMethod(UIMouseEvent evt, UIElement listeningElement)
{
if (!(PlayerInput.ListeningTrigger != this._keybind))
return;
if (PlayerInput.CurrentProfile.AllowEditting)
PlayerInput.ListenFor(this._keybind, this._inputmode);
else
PlayerInput.ListenFor((string) null, this._inputmode);
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
float num1 = 6f;
base.DrawSelf(spriteBatch);
CalculatedStyle dimensions = this.GetDimensions();
float num2 = dimensions.Width + 1f;
Vector2 vector2 = new Vector2(dimensions.X, dimensions.Y);
bool flag = PlayerInput.ListeningTrigger == this._keybind;
Vector2 baseScale = new Vector2(0.8f);
Color baseColor = Color.Lerp(flag ? Color.Gold : (this.IsMouseHovering ? Color.White : Color.Silver), Color.White, this.IsMouseHovering ? 0.5f : 0.0f);
Color color = this.IsMouseHovering ? this._color : this._color.MultiplyRGBA(new Color(180, 180, 180));
Vector2 position = vector2;
Utils.DrawSettingsPanel(spriteBatch, position, num2, color);
position.X += 8f;
position.Y += 2f + num1;
ChatManager.DrawColorCodedStringWithShadow(spriteBatch, FontAssets.ItemStack.Value, this.GetFriendlyName(), position, baseColor, 0.0f, Vector2.Zero, baseScale, num2);
position.X -= 17f;
string text = this.GenInput(PlayerInput.CurrentProfile.InputModes[this._inputmode].KeyStatus[this._keybind]);
if (string.IsNullOrEmpty(text))
{
text = Lang.menu[195].Value;
if (!flag)
baseColor = new Color(80, 80, 80);
}
Vector2 stringSize = ChatManager.GetStringSize(FontAssets.ItemStack.Value, text, baseScale);
position = new Vector2((float) ((double) dimensions.X + (double) dimensions.Width - (double) stringSize.X - 10.0), dimensions.Y + 2f + num1);
if (this._inputmode == InputMode.XBoxGamepad || this._inputmode == InputMode.XBoxGamepadUI)
position += new Vector2(0.0f, -3f);
GlyphTagHandler.GlyphsScale = 0.85f;
ChatManager.DrawColorCodedStringWithShadow(spriteBatch, FontAssets.ItemStack.Value, text, position, baseColor, 0.0f, Vector2.Zero, baseScale, num2);
GlyphTagHandler.GlyphsScale = 1f;
}
private string GenInput(List<string> list)
{
if (list.Count == 0)
return "";
string str = "";
switch (this._inputmode)
{
case InputMode.Keyboard:
case InputMode.KeyboardUI:
case InputMode.Mouse:
str = list[0];
for (int index = 1; index < list.Count; ++index)
str = str + "/" + list[index];
break;
case InputMode.XBoxGamepad:
case InputMode.XBoxGamepadUI:
str = GlyphTagHandler.GenerateTag(list[0]);
for (int index = 1; index < list.Count; ++index)
str = str + "/" + GlyphTagHandler.GenerateTag(list[index]);
break;
}
return str;
}
private string GetFriendlyName()
{
switch (this._keybind)
{
case "Down":
return Lang.menu[149].Value;
case "DpadRadial1":
return Lang.menu[186].Value;
case "DpadRadial2":
return Lang.menu[187].Value;
case "DpadRadial3":
return Lang.menu[188].Value;
case "DpadRadial4":
return Lang.menu[189].Value;
case "DpadSnap1":
return Lang.menu[191].Value;
case "DpadSnap2":
return Lang.menu[192].Value;
case "DpadSnap3":
return Lang.menu[193].Value;
case "DpadSnap4":
return Lang.menu[194].Value;
case "Grapple":
return Lang.menu[155].Value;
case "Hotbar1":
return Lang.menu[176].Value;
case "Hotbar10":
return Lang.menu[185].Value;
case "Hotbar2":
return Lang.menu[177].Value;
case "Hotbar3":
return Lang.menu[178].Value;
case "Hotbar4":
return Lang.menu[179].Value;
case "Hotbar5":
return Lang.menu[180].Value;
case "Hotbar6":
return Lang.menu[181].Value;
case "Hotbar7":
return Lang.menu[182].Value;
case "Hotbar8":
return Lang.menu[183].Value;
case "Hotbar9":
return Lang.menu[184].Value;
case "HotbarMinus":
return Lang.menu[174].Value;
case "HotbarPlus":
return Lang.menu[175].Value;
case "Inventory":
return Lang.menu[154].Value;
case "Jump":
return Lang.menu[152].Value;
case "Left":
return Lang.menu[150].Value;
case "LockOn":
return Lang.menu[231].Value;
case "MapAlphaDown":
return Lang.menu[170].Value;
case "MapAlphaUp":
return Lang.menu[171].Value;
case "MapFull":
return Lang.menu[173].Value;
case "MapStyle":
return Lang.menu[172].Value;
case "MapZoomIn":
return Lang.menu[168].Value;
case "MapZoomOut":
return Lang.menu[169].Value;
case "MouseLeft":
return Lang.menu[162].Value;
case "MouseRight":
return Lang.menu[163].Value;
case "QuickBuff":
return Lang.menu[157].Value;
case "QuickHeal":
return Lang.menu[159].Value;
case "QuickMana":
return Lang.menu[156].Value;
case "QuickMount":
return Lang.menu[158].Value;
case "RadialHotbar":
return Lang.menu[190].Value;
case "RadialQuickbar":
return Lang.menu[244].Value;
case "Right":
return Lang.menu[151].Value;
case "SmartCursor":
return Lang.menu[161].Value;
case "SmartSelect":
return Lang.menu[160].Value;
case "Throw":
return Lang.menu[153].Value;
case "ToggleCreativeMenu":
return Language.GetTextValue("UI.ToggleCreativeMenu");
case "Up":
return Lang.menu[148].Value;
case "ViewZoomIn":
return Language.GetTextValue("UI.ZoomIn");
case "ViewZoomOut":
return Language.GetTextValue("UI.ZoomOut");
default:
return this._keybind;
}
}
}
}

View file

@ -0,0 +1,46 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIKeybindingSimpleListItem
// 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.UI;
using Terraria.UI.Chat;
namespace Terraria.GameContent.UI.Elements
{
public class UIKeybindingSimpleListItem : UIElement
{
private Color _color;
private Func<string> _GetTextFunction;
public UIKeybindingSimpleListItem(Func<string> getText, Color color)
{
this._color = color;
this._GetTextFunction = getText != null ? getText : (Func<string>) (() => "???");
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
float num1 = 6f;
base.DrawSelf(spriteBatch);
CalculatedStyle dimensions = this.GetDimensions();
float num2 = dimensions.Width + 1f;
Vector2 vector2 = new Vector2(dimensions.X, dimensions.Y);
Vector2 baseScale = new Vector2(0.8f);
Color baseColor = Color.Lerp(this.IsMouseHovering ? Color.White : Color.Silver, Color.White, this.IsMouseHovering ? 0.5f : 0.0f);
Color color = this.IsMouseHovering ? this._color : this._color.MultiplyRGBA(new Color(180, 180, 180));
Vector2 position = vector2;
Utils.DrawSettings2Panel(spriteBatch, position, num2, color);
position.X += 8f;
position.Y += 2f + num1;
string text = this._GetTextFunction();
Vector2 stringSize = ChatManager.GetStringSize(FontAssets.ItemStack.Value, text, baseScale);
position.X = (float) ((double) dimensions.X + (double) dimensions.Width / 2.0 - (double) stringSize.X / 2.0);
ChatManager.DrawColorCodedStringWithShadow(spriteBatch, FontAssets.ItemStack.Value, text, position, baseColor, 0.0f, Vector2.Zero, baseScale, num2);
}
}
}

View file

@ -0,0 +1,90 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIKeybindingSliderItem
// 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 Terraria.GameInput;
using Terraria.UI;
using Terraria.UI.Chat;
namespace Terraria.GameContent.UI.Elements
{
public class UIKeybindingSliderItem : UIElement
{
private Color _color;
private Func<string> _TextDisplayFunction;
private Func<float> _GetStatusFunction;
private Action<float> _SlideKeyboardAction;
private Action _SlideGamepadAction;
private int _sliderIDInPage;
private Asset<Texture2D> _toggleTexture;
public UIKeybindingSliderItem(
Func<string> getText,
Func<float> getStatus,
Action<float> setStatusKeyboard,
Action setStatusGamepad,
int sliderIDInPage,
Color color)
{
this._color = color;
this._toggleTexture = Main.Assets.Request<Texture2D>("Images/UI/Settings_Toggle", (AssetRequestMode) 1);
this._TextDisplayFunction = getText != null ? getText : (Func<string>) (() => "???");
this._GetStatusFunction = getStatus != null ? getStatus : (Func<float>) (() => 0.0f);
this._SlideKeyboardAction = setStatusKeyboard != null ? setStatusKeyboard : (Action<float>) (s => { });
this._SlideGamepadAction = setStatusGamepad != null ? setStatusGamepad : (Action) (() => { });
this._sliderIDInPage = sliderIDInPage;
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
float num1 = 6f;
base.DrawSelf(spriteBatch);
int lockState = 0;
IngameOptions.rightHover = -1;
if (!Main.mouseLeft)
IngameOptions.rightLock = -1;
if (IngameOptions.rightLock == this._sliderIDInPage)
lockState = 1;
else if (IngameOptions.rightLock != -1)
lockState = 2;
CalculatedStyle dimensions = this.GetDimensions();
float num2 = dimensions.Width + 1f;
Vector2 vector2 = new Vector2(dimensions.X, dimensions.Y);
bool flag = this.IsMouseHovering;
if (lockState == 1)
flag = true;
if (lockState == 2)
flag = false;
Vector2 baseScale = new Vector2(0.8f);
Color baseColor = Color.Lerp(false ? Color.Gold : (flag ? Color.White : Color.Silver), Color.White, flag ? 0.5f : 0.0f);
Color color = flag ? this._color : this._color.MultiplyRGBA(new Color(180, 180, 180));
Vector2 position = vector2;
Utils.DrawSettingsPanel(spriteBatch, position, num2, color);
position.X += 8f;
position.Y += 2f + num1;
ChatManager.DrawColorCodedStringWithShadow(spriteBatch, FontAssets.ItemStack.Value, this._TextDisplayFunction(), position, baseColor, 0.0f, Vector2.Zero, baseScale, num2);
position.X -= 17f;
TextureAssets.ColorBar.Frame();
position = new Vector2((float) ((double) dimensions.X + (double) dimensions.Width - 10.0), dimensions.Y + 10f + num1);
IngameOptions.valuePosition = position;
float num3 = IngameOptions.DrawValueBar(spriteBatch, 1f, this._GetStatusFunction(), lockState);
if (IngameOptions.inBar || IngameOptions.rightLock == this._sliderIDInPage)
{
IngameOptions.rightHover = this._sliderIDInPage;
if (PlayerInput.Triggers.Current.MouseLeft && PlayerInput.CurrentProfile.AllowEditting && !PlayerInput.UsingGamepad && IngameOptions.rightLock == this._sliderIDInPage)
this._SlideKeyboardAction(num3);
}
if (IngameOptions.rightHover != -1 && IngameOptions.rightLock == -1)
IngameOptions.rightLock = IngameOptions.rightHover;
if (!this.IsMouseHovering || !PlayerInput.CurrentProfile.AllowEditting)
return;
this._SlideGamepadAction();
}
}
}

View file

@ -0,0 +1,53 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIKeybindingToggleListItem
// 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 Terraria.UI;
using Terraria.UI.Chat;
namespace Terraria.GameContent.UI.Elements
{
public class UIKeybindingToggleListItem : UIElement
{
private Color _color;
private Func<string> _TextDisplayFunction;
private Func<bool> _IsOnFunction;
private Asset<Texture2D> _toggleTexture;
public UIKeybindingToggleListItem(Func<string> getText, Func<bool> getStatus, Color color)
{
this._color = color;
this._toggleTexture = Main.Assets.Request<Texture2D>("Images/UI/Settings_Toggle", (AssetRequestMode) 1);
this._TextDisplayFunction = getText != null ? getText : (Func<string>) (() => "???");
this._IsOnFunction = getStatus != null ? getStatus : (Func<bool>) (() => false);
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
float num1 = 6f;
base.DrawSelf(spriteBatch);
CalculatedStyle dimensions = this.GetDimensions();
float num2 = dimensions.Width + 1f;
Vector2 vector2_1 = new Vector2(dimensions.X, dimensions.Y);
Vector2 baseScale = new Vector2(0.8f);
Color baseColor = Color.Lerp(false ? Color.Gold : (this.IsMouseHovering ? Color.White : Color.Silver), Color.White, this.IsMouseHovering ? 0.5f : 0.0f);
Color color = this.IsMouseHovering ? this._color : this._color.MultiplyRGBA(new Color(180, 180, 180));
Vector2 position = vector2_1;
Utils.DrawSettingsPanel(spriteBatch, position, num2, color);
position.X += 8f;
position.Y += 2f + num1;
ChatManager.DrawColorCodedStringWithShadow(spriteBatch, FontAssets.ItemStack.Value, this._TextDisplayFunction(), position, baseColor, 0.0f, Vector2.Zero, baseScale, num2);
position.X -= 17f;
Rectangle rectangle = new Rectangle(this._IsOnFunction() ? (this._toggleTexture.Width() - 2) / 2 + 2 : 0, 0, (this._toggleTexture.Width() - 2) / 2, this._toggleTexture.Height());
Vector2 vector2_2 = new Vector2((float) rectangle.Width, 0.0f);
position = new Vector2((float) ((double) dimensions.X + (double) dimensions.Width - (double) vector2_2.X - 10.0), dimensions.Y + 2f + num1);
spriteBatch.Draw(this._toggleTexture.Value, position, new Rectangle?(rectangle), Color.White, 0.0f, Vector2.Zero, Vector2.One, SpriteEffects.None, 0.0f);
}
}
}

View file

@ -0,0 +1,168 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIList
// 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 System.Collections;
using System.Collections.Generic;
using Terraria.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UIList : UIElement, IEnumerable<UIElement>, IEnumerable
{
protected List<UIElement> _items = new List<UIElement>();
protected UIScrollbar _scrollbar;
private UIElement _innerList = (UIElement) new UIList.UIInnerList();
private float _innerListHeight;
public float ListPadding = 5f;
public Action<List<UIElement>> ManualSortMethod;
public int Count => this._items.Count;
public UIList()
{
this._innerList.OverflowHidden = false;
this._innerList.Width.Set(0.0f, 1f);
this._innerList.Height.Set(0.0f, 1f);
this.OverflowHidden = true;
this.Append(this._innerList);
}
public float GetTotalHeight() => this._innerListHeight;
public void Goto(UIList.ElementSearchMethod searchMethod)
{
for (int index = 0; index < this._items.Count; ++index)
{
if (searchMethod(this._items[index]))
{
this._scrollbar.ViewPosition = this._items[index].Top.Pixels;
break;
}
}
}
public virtual void Add(UIElement item)
{
this._items.Add(item);
this._innerList.Append(item);
this.UpdateOrder();
this._innerList.Recalculate();
}
public virtual bool Remove(UIElement item)
{
this._innerList.RemoveChild(item);
this.UpdateOrder();
return this._items.Remove(item);
}
public virtual void Clear()
{
this._innerList.RemoveAllChildren();
this._items.Clear();
}
public override void Recalculate()
{
base.Recalculate();
this.UpdateScrollbar();
}
public override void ScrollWheel(UIScrollWheelEvent evt)
{
base.ScrollWheel(evt);
if (this._scrollbar == null)
return;
this._scrollbar.ViewPosition -= (float) evt.ScrollWheelValue;
}
public override void RecalculateChildren()
{
base.RecalculateChildren();
float pixels = 0.0f;
for (int index = 0; index < this._items.Count; ++index)
{
float num = this._items.Count == 1 ? 0.0f : this.ListPadding;
this._items[index].Top.Set(pixels, 0.0f);
this._items[index].Recalculate();
CalculatedStyle outerDimensions = this._items[index].GetOuterDimensions();
pixels += outerDimensions.Height + num;
}
this._innerListHeight = pixels;
}
private void UpdateScrollbar()
{
if (this._scrollbar == null)
return;
this._scrollbar.SetView(this.GetInnerDimensions().Height, this._innerListHeight);
}
public void SetScrollbar(UIScrollbar scrollbar)
{
this._scrollbar = scrollbar;
this.UpdateScrollbar();
}
public void UpdateOrder()
{
if (this.ManualSortMethod != null)
this.ManualSortMethod(this._items);
else
this._items.Sort(new Comparison<UIElement>(this.SortMethod));
this.UpdateScrollbar();
}
public int SortMethod(UIElement item1, UIElement item2) => item1.CompareTo((object) item2);
public override List<SnapPoint> GetSnapPoints()
{
List<SnapPoint> snapPointList = new List<SnapPoint>();
SnapPoint point;
if (this.GetSnapPoint(out point))
snapPointList.Add(point);
foreach (UIElement uiElement in this._items)
snapPointList.AddRange((IEnumerable<SnapPoint>) uiElement.GetSnapPoints());
return snapPointList;
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
if (this._scrollbar != null)
this._innerList.Top.Set(-this._scrollbar.GetValue(), 0.0f);
this.Recalculate();
}
public IEnumerator<UIElement> GetEnumerator() => ((IEnumerable<UIElement>) this._items).GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => (IEnumerator) ((IEnumerable<UIElement>) this._items).GetEnumerator();
public delegate bool ElementSearchMethod(UIElement element);
private class UIInnerList : UIElement
{
public override bool ContainsPoint(Vector2 point) => true;
protected override void DrawChildren(SpriteBatch spriteBatch)
{
Vector2 position1 = this.Parent.GetDimensions().Position();
Vector2 dimensions1 = new Vector2(this.Parent.GetDimensions().Width, this.Parent.GetDimensions().Height);
foreach (UIElement element in this.Elements)
{
Vector2 position2 = element.GetDimensions().Position();
Vector2 dimensions2 = new Vector2(element.GetDimensions().Width, element.GetDimensions().Height);
if (Collision.CheckAABBvAABBCollision(position1, dimensions1, position2, dimensions2))
element.Draw(spriteBatch);
}
}
public override Rectangle GetViewCullingArea() => this.Parent.GetDimensions().ToRectangle();
}
}
}

View file

@ -0,0 +1,74 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIPanel
// 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.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UIPanel : UIElement
{
private int _cornerSize = 12;
private int _barSize = 4;
private Asset<Texture2D> _borderTexture;
private Asset<Texture2D> _backgroundTexture;
public Color BorderColor = Color.Black;
public Color BackgroundColor = new Color(63, 82, 151) * 0.7f;
public UIPanel()
{
if (this._borderTexture == null)
this._borderTexture = Main.Assets.Request<Texture2D>("Images/UI/PanelBorder", (AssetRequestMode) 1);
if (this._backgroundTexture == null)
this._backgroundTexture = Main.Assets.Request<Texture2D>("Images/UI/PanelBackground", (AssetRequestMode) 1);
this.SetPadding((float) this._cornerSize);
}
public UIPanel(
Asset<Texture2D> customBackground,
Asset<Texture2D> customborder,
int customCornerSize = 12,
int customBarSize = 4)
{
if (this._borderTexture == null)
this._borderTexture = customborder;
if (this._backgroundTexture == null)
this._backgroundTexture = customBackground;
this._cornerSize = customCornerSize;
this._barSize = customBarSize;
this.SetPadding((float) this._cornerSize);
}
private void DrawPanel(SpriteBatch spriteBatch, Texture2D texture, Color color)
{
CalculatedStyle dimensions = this.GetDimensions();
Point point1 = new Point((int) dimensions.X, (int) dimensions.Y);
Point point2 = new Point(point1.X + (int) dimensions.Width - this._cornerSize, point1.Y + (int) dimensions.Height - this._cornerSize);
int width = point2.X - point1.X - this._cornerSize;
int height = point2.Y - point1.Y - this._cornerSize;
spriteBatch.Draw(texture, new Rectangle(point1.X, point1.Y, this._cornerSize, this._cornerSize), new Rectangle?(new Rectangle(0, 0, this._cornerSize, this._cornerSize)), color);
spriteBatch.Draw(texture, new Rectangle(point2.X, point1.Y, this._cornerSize, this._cornerSize), new Rectangle?(new Rectangle(this._cornerSize + this._barSize, 0, this._cornerSize, this._cornerSize)), color);
spriteBatch.Draw(texture, new Rectangle(point1.X, point2.Y, this._cornerSize, this._cornerSize), new Rectangle?(new Rectangle(0, this._cornerSize + this._barSize, this._cornerSize, this._cornerSize)), color);
spriteBatch.Draw(texture, new Rectangle(point2.X, point2.Y, this._cornerSize, this._cornerSize), new Rectangle?(new Rectangle(this._cornerSize + this._barSize, this._cornerSize + this._barSize, this._cornerSize, this._cornerSize)), color);
spriteBatch.Draw(texture, new Rectangle(point1.X + this._cornerSize, point1.Y, width, this._cornerSize), new Rectangle?(new Rectangle(this._cornerSize, 0, this._barSize, this._cornerSize)), color);
spriteBatch.Draw(texture, new Rectangle(point1.X + this._cornerSize, point2.Y, width, this._cornerSize), new Rectangle?(new Rectangle(this._cornerSize, this._cornerSize + this._barSize, this._barSize, this._cornerSize)), color);
spriteBatch.Draw(texture, new Rectangle(point1.X, point1.Y + this._cornerSize, this._cornerSize, height), new Rectangle?(new Rectangle(0, this._cornerSize, this._cornerSize, this._barSize)), color);
spriteBatch.Draw(texture, new Rectangle(point2.X, point1.Y + this._cornerSize, this._cornerSize, height), new Rectangle?(new Rectangle(this._cornerSize + this._barSize, this._cornerSize, this._cornerSize, this._barSize)), color);
spriteBatch.Draw(texture, new Rectangle(point1.X + this._cornerSize, point1.Y + this._cornerSize, width, height), new Rectangle?(new Rectangle(this._cornerSize, this._cornerSize, this._barSize, this._barSize)), color);
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
if (this._backgroundTexture != null)
this.DrawPanel(spriteBatch, this._backgroundTexture.Value, this.BackgroundColor);
if (this._borderTexture == null)
return;
this.DrawPanel(spriteBatch, this._borderTexture.Value, this.BorderColor);
}
}
}

View file

@ -0,0 +1,40 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIParticleLayer
// 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 Terraria.Graphics.Renderers;
using Terraria.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UIParticleLayer : UIElement
{
public ParticleRenderer ParticleSystem;
public Vector2 AnchorPositionOffsetByPercents;
public Vector2 AnchorPositionOffsetByPixels;
public UIParticleLayer()
{
this.IgnoresMouseInteraction = true;
this.ParticleSystem = new ParticleRenderer();
this.OnUpdate += new UIElement.ElementEvent(this.ParticleSystemUpdate);
}
private void ParticleSystemUpdate(UIElement affectedElement) => this.ParticleSystem.Update();
public override void Recalculate()
{
base.Recalculate();
Rectangle rectangle = this.GetDimensions().ToRectangle();
this.ParticleSystem.Settings.AnchorPosition = rectangle.TopLeft() + this.AnchorPositionOffsetByPercents * rectangle.Size() + this.AnchorPositionOffsetByPixels;
}
protected override void DrawSelf(SpriteBatch spriteBatch) => this.ParticleSystem.Draw(spriteBatch);
public void AddParticle(IParticle particle) => this.ParticleSystem.Add(particle);
}
}

View file

@ -0,0 +1,50 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIProgressBar
// 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 Terraria.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UIProgressBar : UIElement
{
private UIProgressBar.UIInnerProgressBar _progressBar = new UIProgressBar.UIInnerProgressBar();
private float _visualProgress;
private float _targetProgress;
public UIProgressBar()
{
this._progressBar.Height.Precent = 1f;
this._progressBar.Recalculate();
this.Append((UIElement) this._progressBar);
}
public void SetProgress(float value)
{
this._targetProgress = value;
if ((double) value >= (double) this._visualProgress)
return;
this._visualProgress = value;
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
this._visualProgress = (float) ((double) this._visualProgress * 0.949999988079071 + 0.0500000007450581 * (double) this._targetProgress);
this._progressBar.Width.Precent = this._visualProgress;
this._progressBar.Recalculate();
}
private class UIInnerProgressBar : UIElement
{
protected override void DrawSelf(SpriteBatch spriteBatch)
{
CalculatedStyle dimensions = this.GetDimensions();
spriteBatch.Draw(TextureAssets.MagicPixel.Value, new Vector2(dimensions.X, dimensions.Y), new Rectangle?(), Color.Blue, 0.0f, Vector2.Zero, new Vector2(dimensions.Width, dimensions.Height / 1000f), SpriteEffects.None, 0.0f);
}
}
}
}

View file

@ -0,0 +1,119 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIResourcePack
// 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.IO;
using Terraria.Localization;
using Terraria.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UIResourcePack : UIPanel
{
private const int PANEL_PADDING = 5;
private const int ICON_SIZE = 64;
private const int ICON_BORDER_PADDING = 4;
private const int HEIGHT_FLUFF = 10;
private const float HEIGHT = 102f;
private const float MIN_WIDTH = 102f;
private static readonly Color DefaultBackgroundColor = new Color(26, 40, 89) * 0.8f;
private static readonly Color DefaultBorderColor = new Color(13, 20, 44) * 0.8f;
private static readonly Color HoverBackgroundColor = new Color(46, 60, 119);
private static readonly Color HoverBorderColor = new Color(20, 30, 56);
public readonly ResourcePack ResourcePack;
private readonly Asset<Texture2D> _iconBorderTexture;
public int Order { get; set; }
public UIElement ContentPanel { get; private set; }
public UIResourcePack(ResourcePack pack, int order)
{
this.ResourcePack = pack;
this.Order = order;
this.BackgroundColor = UIResourcePack.DefaultBackgroundColor;
this.BorderColor = UIResourcePack.DefaultBorderColor;
this.Height = StyleDimension.FromPixels(102f);
this.MinHeight = this.Height;
this.MaxHeight = this.Height;
this.MinWidth = StyleDimension.FromPixels(102f);
this.Width = StyleDimension.FromPercent(1f);
this.SetPadding(5f);
this._iconBorderTexture = Main.Assets.Request<Texture2D>("Images/UI/Achievement_Borders", (AssetRequestMode) 1);
this.OverflowHidden = true;
this.BuildChildren();
}
private void BuildChildren()
{
StyleDimension styleDimension1 = StyleDimension.FromPixels(77f);
StyleDimension styleDimension2 = StyleDimension.FromPixels(4f);
UIText uiText1 = new UIText(this.ResourcePack.Name);
uiText1.Left = styleDimension1;
uiText1.Top = styleDimension2;
UIText uiText2 = uiText1;
this.Append((UIElement) uiText2);
styleDimension2.Pixels += uiText2.GetOuterDimensions().Height + 6f;
UIText uiText3 = new UIText(Language.GetTextValue("UI.Author", (object) this.ResourcePack.Author), 0.7f);
uiText3.Left = styleDimension1;
uiText3.Top = styleDimension2;
UIText uiText4 = uiText3;
this.Append((UIElement) uiText4);
styleDimension2.Pixels += uiText4.GetOuterDimensions().Height + 10f;
Asset<Texture2D> asset = Main.Assets.Request<Texture2D>("Images/UI/Divider", (AssetRequestMode) 1);
UIImage uiImage1 = new UIImage(asset);
uiImage1.Left = StyleDimension.FromPixels(72f);
uiImage1.Top = styleDimension2;
uiImage1.Height = StyleDimension.FromPixels((float) asset.Height());
uiImage1.Width = StyleDimension.FromPixelsAndPercent(-80f, 1f);
uiImage1.ScaleToFit = true;
UIImage uiImage2 = uiImage1;
this.Recalculate();
this.Append((UIElement) uiImage2);
styleDimension2.Pixels += uiImage2.GetOuterDimensions().Height + 5f;
UIElement element = new UIElement()
{
Left = styleDimension1,
Top = styleDimension2,
Height = StyleDimension.FromPixels(92f - styleDimension2.Pixels),
Width = StyleDimension.FromPixelsAndPercent(-styleDimension1.Pixels, 1f)
};
this.Append(element);
this.ContentPanel = element;
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
base.DrawSelf(spriteBatch);
this.DrawIcon(spriteBatch);
}
private void DrawIcon(SpriteBatch spriteBatch)
{
CalculatedStyle innerDimensions = this.GetInnerDimensions();
spriteBatch.Draw(this.ResourcePack.Icon, new Rectangle((int) innerDimensions.X + 4, (int) innerDimensions.Y + 4 + 10, 64, 64), Color.White);
spriteBatch.Draw(this._iconBorderTexture.Value, new Rectangle((int) innerDimensions.X, (int) innerDimensions.Y + 10, 72, 72), Color.White);
}
public override int CompareTo(object obj) => this.Order.CompareTo(((UIResourcePack) obj).Order);
public override void MouseOver(UIMouseEvent evt)
{
base.MouseOver(evt);
this.BackgroundColor = UIResourcePack.HoverBackgroundColor;
this.BorderColor = UIResourcePack.HoverBorderColor;
}
public override void MouseOut(UIMouseEvent evt)
{
base.MouseOut(evt);
this.BackgroundColor = UIResourcePack.DefaultBackgroundColor;
this.BorderColor = UIResourcePack.DefaultBorderColor;
}
}
}

View file

@ -0,0 +1,48 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIResourcePackInfoButton`1
// 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.IO;
using Terraria.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UIResourcePackInfoButton<T> : UITextPanel<T>
{
private readonly Asset<Texture2D> _BasePanelTexture;
private readonly Asset<Texture2D> _hoveredBorderTexture;
private ResourcePack _resourcePack;
public ResourcePack ResourcePack
{
get => this._resourcePack;
set => this._resourcePack = value;
}
public UIResourcePackInfoButton(T text, float textScale = 1f, bool large = false)
: base(text, textScale, large)
{
this._BasePanelTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/PanelGrayscale", (AssetRequestMode) 1);
this._hoveredBorderTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/CategoryPanelBorder", (AssetRequestMode) 1);
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
if (this._drawPanel)
{
CalculatedStyle dimensions = this.GetDimensions();
int num1 = 10;
int num2 = 10;
Utils.DrawSplicedPanel(spriteBatch, this._BasePanelTexture.Value, (int) dimensions.X, (int) dimensions.Y, (int) dimensions.Width, (int) dimensions.Height, num1, num1, num2, num2, Color.Lerp(Color.Black, this._color, 0.8f) * 0.5f);
if (this.IsMouseHovering)
Utils.DrawSplicedPanel(spriteBatch, this._hoveredBorderTexture.Value, (int) dimensions.X, (int) dimensions.Y, (int) dimensions.Width, (int) dimensions.Height, num1, num1, num2, num2, Color.White);
}
this.DrawText(spriteBatch);
}
}
}

View file

@ -0,0 +1,116 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIScrollbar
// 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.Audio;
using Terraria.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UIScrollbar : UIElement
{
private float _viewPosition;
private float _viewSize = 1f;
private float _maxViewSize = 20f;
private bool _isDragging;
private bool _isHoveringOverHandle;
private float _dragYOffset;
private Asset<Texture2D> _texture;
private Asset<Texture2D> _innerTexture;
public float ViewPosition
{
get => this._viewPosition;
set => this._viewPosition = MathHelper.Clamp(value, 0.0f, this._maxViewSize - this._viewSize);
}
public bool CanScroll => (double) this._maxViewSize != (double) this._viewSize;
public UIScrollbar()
{
this.Width.Set(20f, 0.0f);
this.MaxWidth.Set(20f, 0.0f);
this._texture = Main.Assets.Request<Texture2D>("Images/UI/Scrollbar", (AssetRequestMode) 1);
this._innerTexture = Main.Assets.Request<Texture2D>("Images/UI/ScrollbarInner", (AssetRequestMode) 1);
this.PaddingTop = 5f;
this.PaddingBottom = 5f;
}
public void SetView(float viewSize, float maxViewSize)
{
viewSize = MathHelper.Clamp(viewSize, 0.0f, maxViewSize);
this._viewPosition = MathHelper.Clamp(this._viewPosition, 0.0f, maxViewSize - viewSize);
this._viewSize = viewSize;
this._maxViewSize = maxViewSize;
}
public float GetValue() => this._viewPosition;
private Rectangle GetHandleRectangle()
{
CalculatedStyle innerDimensions = this.GetInnerDimensions();
if ((double) this._maxViewSize == 0.0 && (double) this._viewSize == 0.0)
{
this._viewSize = 1f;
this._maxViewSize = 1f;
}
return new Rectangle((int) innerDimensions.X, (int) ((double) innerDimensions.Y + (double) innerDimensions.Height * ((double) this._viewPosition / (double) this._maxViewSize)) - 3, 20, (int) ((double) innerDimensions.Height * ((double) this._viewSize / (double) this._maxViewSize)) + 7);
}
private void DrawBar(
SpriteBatch spriteBatch,
Texture2D texture,
Rectangle dimensions,
Color color)
{
spriteBatch.Draw(texture, new Rectangle(dimensions.X, dimensions.Y - 6, dimensions.Width, 6), new Rectangle?(new Rectangle(0, 0, texture.Width, 6)), color);
spriteBatch.Draw(texture, new Rectangle(dimensions.X, dimensions.Y, dimensions.Width, dimensions.Height), new Rectangle?(new Rectangle(0, 6, texture.Width, 4)), color);
spriteBatch.Draw(texture, new Rectangle(dimensions.X, dimensions.Y + dimensions.Height, dimensions.Width, 6), new Rectangle?(new Rectangle(0, texture.Height - 6, texture.Width, 6)), color);
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
CalculatedStyle dimensions = this.GetDimensions();
CalculatedStyle innerDimensions = this.GetInnerDimensions();
if (this._isDragging)
this._viewPosition = MathHelper.Clamp((UserInterface.ActiveInstance.MousePosition.Y - innerDimensions.Y - this._dragYOffset) / innerDimensions.Height * this._maxViewSize, 0.0f, this._maxViewSize - this._viewSize);
Rectangle handleRectangle = this.GetHandleRectangle();
Vector2 mousePosition = UserInterface.ActiveInstance.MousePosition;
int num = this._isHoveringOverHandle ? 1 : 0;
this._isHoveringOverHandle = handleRectangle.Contains(new Point((int) mousePosition.X, (int) mousePosition.Y));
if (num == 0 && this._isHoveringOverHandle && Main.hasFocus)
SoundEngine.PlaySound(12);
this.DrawBar(spriteBatch, this._texture.Value, dimensions.ToRectangle(), Color.White);
this.DrawBar(spriteBatch, this._innerTexture.Value, handleRectangle, Color.White * (this._isDragging || this._isHoveringOverHandle ? 1f : 0.85f));
}
public override void MouseDown(UIMouseEvent evt)
{
base.MouseDown(evt);
if (evt.Target != this)
return;
Rectangle handleRectangle = this.GetHandleRectangle();
if (handleRectangle.Contains(new Point((int) evt.MousePosition.X, (int) evt.MousePosition.Y)))
{
this._isDragging = true;
this._dragYOffset = evt.MousePosition.Y - (float) handleRectangle.Y;
}
else
{
CalculatedStyle innerDimensions = this.GetInnerDimensions();
this._viewPosition = MathHelper.Clamp((UserInterface.ActiveInstance.MousePosition.Y - innerDimensions.Y - (float) (handleRectangle.Height >> 1)) / innerDimensions.Height * this._maxViewSize, 0.0f, this._maxViewSize - this._viewSize);
}
}
public override void MouseUp(UIMouseEvent evt)
{
base.MouseUp(evt);
this._isDragging = false;
}
}
}

View file

@ -0,0 +1,170 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UISearchBar
// 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.Audio;
using Terraria.GameInput;
using Terraria.Localization;
using Terraria.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UISearchBar : UIElement
{
private readonly LocalizedText _textToShowWhenEmpty;
private UITextBox _text;
private string actualContents;
private float _textScale;
private bool isWritingText;
public event Action<string> OnContentsChanged;
public event Action OnStartTakingInput;
public event Action OnEndTakingInput;
public event Action OnCancledTakingInput;
public event Action OnNeedingVirtualKeyboard;
public UISearchBar(LocalizedText emptyContentText, float scale)
{
this._textToShowWhenEmpty = emptyContentText;
this._textScale = scale;
UITextBox uiTextBox1 = new UITextBox("", scale);
uiTextBox1.HAlign = 0.0f;
uiTextBox1.VAlign = 0.5f;
uiTextBox1.BackgroundColor = Color.Transparent;
uiTextBox1.BorderColor = Color.Transparent;
uiTextBox1.Width = new StyleDimension(0.0f, 1f);
uiTextBox1.Height = new StyleDimension(0.0f, 1f);
uiTextBox1.TextHAlign = 0.0f;
uiTextBox1.ShowInputTicker = false;
UITextBox uiTextBox2 = uiTextBox1;
this.Append((UIElement) uiTextBox2);
this._text = uiTextBox2;
}
public void SetContents(string contents, bool forced = false)
{
if (this.actualContents == contents && !forced)
return;
this.actualContents = contents;
if (string.IsNullOrEmpty(this.actualContents))
{
this._text.TextColor = Color.Gray;
this._text.SetText(this._textToShowWhenEmpty.Value, this._textScale, false);
}
else
{
this._text.TextColor = Color.White;
this._text.SetText(this.actualContents);
}
this.TrimDisplayIfOverElementDimensions(0);
if (this.OnContentsChanged == null)
return;
this.OnContentsChanged(contents);
}
public void TrimDisplayIfOverElementDimensions(int padding)
{
CalculatedStyle dimensions1 = this.GetDimensions();
if ((double) dimensions1.Width == 0.0 && (double) dimensions1.Height == 0.0)
return;
Point point1 = new Point((int) dimensions1.X, (int) dimensions1.Y);
Point point2 = new Point(point1.X + (int) dimensions1.Width, point1.Y + (int) dimensions1.Height);
Rectangle rectangle1 = new Rectangle(point1.X, point1.Y, point2.X - point1.X, point2.Y - point1.Y);
CalculatedStyle dimensions2 = this._text.GetDimensions();
Point point3 = new Point((int) dimensions2.X, (int) dimensions2.Y);
Point point4 = new Point(point3.X + (int) dimensions2.Width, point3.Y + (int) dimensions2.Height);
Rectangle rectangle2 = new Rectangle(point3.X, point3.Y, point4.X - point3.X, point4.Y - point3.Y);
int num = 0;
for (; rectangle2.Right > rectangle1.Right - padding && this._text.Text.Length > 0; rectangle2 = new Rectangle(point3.X, point3.Y, point4.X - point3.X, point4.Y - point3.Y))
{
this._text.SetText(this._text.Text.Substring(0, this._text.Text.Length - 1));
++num;
this.RecalculateChildren();
CalculatedStyle dimensions3 = this._text.GetDimensions();
point3 = new Point((int) dimensions3.X, (int) dimensions3.Y);
point4 = new Point(point3.X + (int) dimensions3.Width, point3.Y + (int) dimensions3.Height);
}
if (num <= 0 || this._text.Text.Length <= 0)
return;
this._text.SetText(this._text.Text.Substring(0, this._text.Text.Length - 1) + "…");
}
public override void MouseDown(UIMouseEvent evt) => base.MouseDown(evt);
public override void MouseOver(UIMouseEvent evt)
{
base.MouseOver(evt);
SoundEngine.PlaySound(12);
}
public override void Update(GameTime gameTime)
{
if (this.isWritingText)
{
if (this.NeedsVirtualkeyboard())
{
if (this.OnNeedingVirtualKeyboard == null)
return;
this.OnNeedingVirtualKeyboard();
return;
}
PlayerInput.WritingText = true;
Main.CurrentInputTextTakerOverride = (object) this;
}
base.Update(gameTime);
}
private bool NeedsVirtualkeyboard() => PlayerInput.UsingGamepad;
protected override void DrawSelf(SpriteBatch spriteBatch)
{
base.DrawSelf(spriteBatch);
if (!this.isWritingText)
return;
PlayerInput.WritingText = true;
Main.instance.HandleIME();
Vector2 position = new Vector2((float) (Main.screenWidth / 2), (float) (this._text.GetDimensions().ToRectangle().Bottom + 32));
Main.instance.DrawWindowsIMEPanel(position, 0.5f);
string inputText = Main.GetInputText(this.actualContents);
if (Main.inputTextEnter)
this.ToggleTakingText();
else if (Main.inputTextEscape)
{
this.ToggleTakingText();
if (this.OnCancledTakingInput != null)
this.OnCancledTakingInput();
}
this.SetContents(inputText);
position = new Vector2((float) (Main.screenWidth / 2), (float) (this._text.GetDimensions().ToRectangle().Bottom + 32));
Main.instance.DrawWindowsIMEPanel(position, 0.5f);
}
public void ToggleTakingText()
{
this.isWritingText = !this.isWritingText;
this._text.ShowInputTicker = this.isWritingText;
Main.clrInput();
if (this.isWritingText)
{
if (this.OnStartTakingInput == null)
return;
this.OnStartTakingInput();
}
else
{
if (this.OnEndTakingInput == null)
return;
this.OnEndTakingInput();
}
}
}
}

View file

@ -0,0 +1,51 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UISelectableTextPanel`1
// 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 Terraria.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UISelectableTextPanel<T> : UITextPanel<T>
{
private readonly Asset<Texture2D> _BasePanelTexture;
private readonly Asset<Texture2D> _hoveredBorderTexture;
private Func<UISelectableTextPanel<T>, bool> _isSelected;
public Func<UISelectableTextPanel<T>, bool> IsSelected
{
get => this._isSelected;
set => this._isSelected = value;
}
public UISelectableTextPanel(T text, float textScale = 1f, bool large = false)
: base(text, textScale, large)
{
this._BasePanelTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/PanelGrayscale", (AssetRequestMode) 1);
this._hoveredBorderTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/CategoryPanelBorder", (AssetRequestMode) 1);
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
if (this._drawPanel)
{
CalculatedStyle dimensions = this.GetDimensions();
int num1 = 4;
int num2 = 10;
int num3 = 10;
Utils.DrawSplicedPanel(spriteBatch, this._BasePanelTexture.Value, (int) dimensions.X, (int) dimensions.Y, (int) dimensions.Width, (int) dimensions.Height, num2, num2, num3, num3, Color.Lerp(Color.Black, this._color, 0.8f) * 0.5f);
if (this.IsSelected != null && this.IsSelected(this))
Utils.DrawSplicedPanel(spriteBatch, this._BasePanelTexture.Value, (int) dimensions.X + num1, (int) dimensions.Y + num1, (int) dimensions.Width - num1 * 2, (int) dimensions.Height - num1 * 2, num2, num2, num3, num3, Color.Lerp(this._color, Color.White, 0.7f) * 0.5f);
if (this.IsMouseHovering)
Utils.DrawSplicedPanel(spriteBatch, this._hoveredBorderTexture.Value, (int) dimensions.X, (int) dimensions.Y, (int) dimensions.Width, (int) dimensions.Height, num2, num2, num3, num3, Color.White);
}
this.DrawText(spriteBatch);
}
}
}

View file

@ -0,0 +1,60 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UISlicedImage
// 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.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UISlicedImage : UIElement
{
private Asset<Texture2D> _texture;
private Color _color;
private int _leftSliceDepth;
private int _rightSliceDepth;
private int _topSliceDepth;
private int _bottomSliceDepth;
public Color Color
{
get => this._color;
set => this._color = value;
}
public UISlicedImage(Asset<Texture2D> texture)
{
this._texture = texture;
this.Width.Set((float) this._texture.Width(), 0.0f);
this.Height.Set((float) this._texture.Height(), 0.0f);
}
public void SetImage(Asset<Texture2D> texture) => this._texture = texture;
protected override void DrawSelf(SpriteBatch spriteBatch)
{
CalculatedStyle dimensions = this.GetDimensions();
Utils.DrawSplicedPanel(spriteBatch, this._texture.Value, (int) dimensions.X, (int) dimensions.Y, (int) dimensions.Width, (int) dimensions.Height, this._leftSliceDepth, this._rightSliceDepth, this._topSliceDepth, this._bottomSliceDepth, this._color);
}
public void SetSliceDepths(int top, int bottom, int left, int right)
{
this._leftSliceDepth = left;
this._rightSliceDepth = right;
this._topSliceDepth = top;
this._bottomSliceDepth = bottom;
}
public void SetSliceDepths(int fluff)
{
this._leftSliceDepth = fluff;
this._rightSliceDepth = fluff;
this._topSliceDepth = fluff;
this._bottomSliceDepth = fluff;
}
}
}

View file

@ -0,0 +1,29 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UISliderBase
// 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 Terraria.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UISliderBase : UIElement
{
internal const int UsageLevel_NotSelected = 0;
internal const int UsageLevel_SelectedAndLocked = 1;
internal const int UsageLevel_OtherElementIsLocked = 2;
internal static UIElement CurrentLockedSlider;
internal static UIElement CurrentAimedSlider;
internal int GetUsageLevel()
{
int num = 0;
if (UISliderBase.CurrentLockedSlider == this)
num = 1;
else if (UISliderBase.CurrentLockedSlider != null)
num = 2;
return num;
}
}
}

View file

@ -0,0 +1,127 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIText
// 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 Terraria.Localization;
using Terraria.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UIText : UIElement
{
private object _text = (object) "";
private float _textScale = 1f;
private Vector2 _textSize = Vector2.Zero;
private bool _isLarge;
private Color _color = Color.White;
private bool _isWrapped;
public bool DynamicallyScaleDownToWidth;
private string _visibleText;
private string _lastTextReference;
public string Text => this._text.ToString();
public float TextOriginX { get; set; }
public float WrappedTextBottomPadding { get; set; }
public bool IsWrapped
{
get => this._isWrapped;
set
{
this._isWrapped = value;
this.InternalSetText(this._text, this._textScale, this._isLarge);
}
}
public event Action OnInternalTextChange;
public Color TextColor
{
get => this._color;
set => this._color = value;
}
public UIText(string text, float textScale = 1f, bool large = false)
{
this.TextOriginX = 0.5f;
this.IsWrapped = false;
this.WrappedTextBottomPadding = 20f;
this.InternalSetText((object) text, textScale, large);
}
public UIText(LocalizedText text, float textScale = 1f, bool large = false)
{
this.TextOriginX = 0.5f;
this.IsWrapped = false;
this.WrappedTextBottomPadding = 20f;
this.InternalSetText((object) text, textScale, large);
}
public override void Recalculate()
{
this.InternalSetText(this._text, this._textScale, this._isLarge);
base.Recalculate();
}
public void SetText(string text) => this.InternalSetText((object) text, this._textScale, this._isLarge);
public void SetText(LocalizedText text) => this.InternalSetText((object) text, this._textScale, this._isLarge);
public void SetText(string text, float textScale, bool large) => this.InternalSetText((object) text, textScale, large);
public void SetText(LocalizedText text, float textScale, bool large) => this.InternalSetText((object) text, textScale, large);
protected override void DrawSelf(SpriteBatch spriteBatch)
{
base.DrawSelf(spriteBatch);
this.VerifyTextState();
CalculatedStyle innerDimensions = this.GetInnerDimensions();
Vector2 pos = innerDimensions.Position();
if (this._isLarge)
pos.Y -= 10f * this._textScale;
else
pos.Y -= 2f * this._textScale;
pos.X += (innerDimensions.Width - this._textSize.X) * this.TextOriginX;
float textScale = this._textScale;
if (this.DynamicallyScaleDownToWidth && (double) this._textSize.X > (double) innerDimensions.Width)
textScale *= innerDimensions.Width / this._textSize.X;
if (this._isLarge)
Utils.DrawBorderStringBig(spriteBatch, this._visibleText, pos, this._color, textScale);
else
Utils.DrawBorderString(spriteBatch, this._visibleText, pos, this._color, textScale);
}
private void VerifyTextState()
{
if ((object) this._lastTextReference == (object) this.Text)
return;
this.InternalSetText(this._text, this._textScale, this._isLarge);
}
private void InternalSetText(object text, float textScale, bool large)
{
DynamicSpriteFont dynamicSpriteFont = large ? FontAssets.DeathText.Value : FontAssets.MouseText.Value;
this._text = text;
this._isLarge = large;
this._textScale = textScale;
this._lastTextReference = this._text.ToString();
this._visibleText = !this.IsWrapped ? this._lastTextReference : dynamicSpriteFont.CreateWrappedText(this._lastTextReference, this.GetInnerDimensions().Width / this._textScale);
Vector2 vector2_1 = dynamicSpriteFont.MeasureString(this._visibleText);
Vector2 vector2_2 = !this.IsWrapped ? new Vector2(vector2_1.X, large ? 32f : 16f) * textScale : new Vector2(vector2_1.X, vector2_1.Y + this.WrappedTextBottomPadding) * textScale;
this._textSize = vector2_2;
this.MinWidth.Set(vector2_2.X + this.PaddingLeft + this.PaddingRight, 0.0f);
this.MinHeight.Set(vector2_2.Y + this.PaddingTop + this.PaddingBottom, 0.0f);
if (this.OnInternalTextChange == null)
return;
this.OnInternalTextChange();
}
}
}

View file

@ -0,0 +1,89 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UITextBox
// 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.UI;
namespace Terraria.GameContent.UI.Elements
{
internal class UITextBox : UITextPanel<string>
{
private int _cursor;
private int _frameCount;
private int _maxLength = 20;
public bool ShowInputTicker = true;
public bool HideSelf;
public UITextBox(string text, float textScale = 1f, bool large = false)
: base(text, textScale, large)
{
}
public void Write(string text)
{
this.SetText(this.Text.Insert(this._cursor, text));
this._cursor += text.Length;
}
public override void SetText(string text, float textScale, bool large)
{
if (text == null)
text = "";
if (text.Length > this._maxLength)
text = text.Substring(0, this._maxLength);
base.SetText(text, textScale, large);
this._cursor = Math.Min(this.Text.Length, this._cursor);
}
public void SetTextMaxLength(int maxLength) => this._maxLength = maxLength;
public void Backspace()
{
if (this._cursor == 0)
return;
this.SetText(this.Text.Substring(0, this.Text.Length - 1));
}
public void CursorLeft()
{
if (this._cursor == 0)
return;
--this._cursor;
}
public void CursorRight()
{
if (this._cursor >= this.Text.Length)
return;
++this._cursor;
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
if (this.HideSelf)
return;
this._cursor = this.Text.Length;
base.DrawSelf(spriteBatch);
++this._frameCount;
if ((this._frameCount %= 40) > 20 || !this.ShowInputTicker)
return;
CalculatedStyle innerDimensions = this.GetInnerDimensions();
Vector2 pos = innerDimensions.Position();
Vector2 vector2 = new Vector2((this.IsLarge ? FontAssets.DeathText.Value : FontAssets.MouseText.Value).MeasureString(this.Text.Substring(0, this._cursor)).X, this.IsLarge ? 32f : 16f) * this.TextScale;
if (this.IsLarge)
pos.Y -= 8f * this.TextScale;
else
pos.Y -= 2f * this.TextScale;
pos.X += (float) (((double) innerDimensions.Width - (double) this.TextSize.X) * (double) this.TextHAlign + (double) vector2.X - (this.IsLarge ? 8.0 : 4.0) * (double) this.TextScale + 6.0);
if (this.IsLarge)
Utils.DrawBorderStringBig(spriteBatch, "|", pos, this.TextColor, this.TextScale);
else
Utils.DrawBorderString(spriteBatch, "|", pos, this.TextColor, this.TextScale);
}
}
}

View file

@ -0,0 +1,90 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UITextPanel`1
// 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 Terraria.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UITextPanel<T> : UIPanel
{
protected T _text;
protected float _textScale = 1f;
protected Vector2 _textSize = Vector2.Zero;
protected bool _isLarge;
protected Color _color = Color.White;
protected bool _drawPanel = true;
public float TextHAlign = 0.5f;
public bool IsLarge => this._isLarge;
public bool DrawPanel
{
get => this._drawPanel;
set => this._drawPanel = value;
}
public float TextScale
{
get => this._textScale;
set => this._textScale = value;
}
public Vector2 TextSize => this._textSize;
public string Text => (object) this._text != null ? this._text.ToString() : "";
public Color TextColor
{
get => this._color;
set => this._color = value;
}
public UITextPanel(T text, float textScale = 1f, bool large = false) => this.SetText(text, textScale, large);
public override void Recalculate()
{
this.SetText(this._text, this._textScale, this._isLarge);
base.Recalculate();
}
public void SetText(T text) => this.SetText(text, this._textScale, this._isLarge);
public virtual void SetText(T text, float textScale, bool large)
{
Vector2 vector2 = new Vector2((large ? FontAssets.DeathText.Value : FontAssets.MouseText.Value).MeasureString(text.ToString()).X, large ? 32f : 16f) * textScale;
this._text = text;
this._textScale = textScale;
this._textSize = vector2;
this._isLarge = large;
this.MinWidth.Set(vector2.X + this.PaddingLeft + this.PaddingRight, 0.0f);
this.MinHeight.Set(vector2.Y + this.PaddingTop + this.PaddingBottom, 0.0f);
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
if (this._drawPanel)
base.DrawSelf(spriteBatch);
this.DrawText(spriteBatch);
}
protected void DrawText(SpriteBatch spriteBatch)
{
CalculatedStyle innerDimensions = this.GetInnerDimensions();
Vector2 pos = innerDimensions.Position();
if (this._isLarge)
pos.Y -= 10f * this._textScale * this._textScale;
else
pos.Y -= 2f * this._textScale;
pos.X += (innerDimensions.Width - this._textSize.X) * this.TextHAlign;
if (this._isLarge)
Utils.DrawBorderStringBig(spriteBatch, this.Text, pos, this._color, this._textScale);
else
Utils.DrawBorderString(spriteBatch, this.Text, pos, this._color, this._textScale);
}
}
}

View file

@ -0,0 +1,72 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIToggleImage
// 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.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UIToggleImage : UIElement
{
private Asset<Texture2D> _onTexture;
private Asset<Texture2D> _offTexture;
private int _drawWidth;
private int _drawHeight;
private Point _onTextureOffset = Point.Zero;
private Point _offTextureOffset = Point.Zero;
private bool _isOn;
public bool IsOn => this._isOn;
public UIToggleImage(
Asset<Texture2D> texture,
int width,
int height,
Point onTextureOffset,
Point offTextureOffset)
{
this._onTexture = texture;
this._offTexture = texture;
this._offTextureOffset = offTextureOffset;
this._onTextureOffset = onTextureOffset;
this._drawWidth = width;
this._drawHeight = height;
this.Width.Set((float) width, 0.0f);
this.Height.Set((float) height, 0.0f);
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
CalculatedStyle dimensions = this.GetDimensions();
Texture2D texture;
Point point;
if (this._isOn)
{
texture = this._onTexture.Value;
point = this._onTextureOffset;
}
else
{
texture = this._offTexture.Value;
point = this._offTextureOffset;
}
Color color = this.IsMouseHovering ? Color.White : Color.Silver;
spriteBatch.Draw(texture, new Rectangle((int) dimensions.X, (int) dimensions.Y, this._drawWidth, this._drawHeight), new Rectangle?(new Rectangle(point.X, point.Y, this._drawWidth, this._drawHeight)), color);
}
public override void Click(UIMouseEvent evt)
{
this.Toggle();
base.Click(evt);
}
public void SetState(bool value) => this._isOn = value;
public void Toggle() => this._isOn = !this._isOn;
}
}

View file

@ -0,0 +1,36 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIVerticalSeparator
// 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.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UIVerticalSeparator : UIElement
{
private Asset<Texture2D> _texture;
public Color Color;
public int EdgeWidth;
public UIVerticalSeparator()
{
this.Color = Color.White;
this._texture = Main.Assets.Request<Texture2D>("Images/UI/OnePixel", (AssetRequestMode) 1);
this.Width.Set((float) this._texture.Width(), 0.0f);
this.Height.Set((float) this._texture.Height(), 0.0f);
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
CalculatedStyle dimensions = this.GetDimensions();
spriteBatch.Draw(this._texture.Value, dimensions.ToRectangle(), this.Color);
}
public override bool ContainsPoint(Vector2 point) => false;
}
}

View file

@ -0,0 +1,122 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIVerticalSlider
// 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.Audio;
using Terraria.GameInput;
using Terraria.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UIVerticalSlider : UISliderBase
{
public float FillPercent;
public Color FilledColor = Main.OurFavoriteColor;
public Color EmptyColor = Color.Black;
private Func<float> _getSliderValue;
private Action<float> _slideKeyboardAction;
private Func<float, Color> _blipFunc;
private Action _slideGamepadAction;
private bool _isReallyMouseOvered;
private bool _soundedUsage;
private bool _alreadyHovered;
public UIVerticalSlider(
Func<float> getStatus,
Action<float> setStatusKeyboard,
Action setStatusGamepad,
Color color)
{
this._getSliderValue = getStatus != null ? getStatus : (Func<float>) (() => 0.0f);
this._slideKeyboardAction = setStatusKeyboard != null ? setStatusKeyboard : (Action<float>) (s => { });
this._slideGamepadAction = setStatusGamepad;
this._isReallyMouseOvered = false;
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
UISliderBase.CurrentAimedSlider = (UIElement) null;
if (!Main.mouseLeft)
UISliderBase.CurrentLockedSlider = (UIElement) null;
this.GetUsageLevel();
this.FillPercent = this._getSliderValue();
float sliderValueThatWasSet = this.FillPercent;
bool flag = false;
if (this.DrawValueBarDynamicWidth(spriteBatch, out sliderValueThatWasSet))
flag = true;
if (UISliderBase.CurrentLockedSlider == this | flag)
{
UISliderBase.CurrentAimedSlider = (UIElement) this;
if (PlayerInput.Triggers.Current.MouseLeft && !PlayerInput.UsingGamepad && UISliderBase.CurrentLockedSlider == this)
{
this._slideKeyboardAction(sliderValueThatWasSet);
if (!this._soundedUsage)
SoundEngine.PlaySound(12);
this._soundedUsage = true;
}
else
this._soundedUsage = false;
}
if (UISliderBase.CurrentAimedSlider != null && UISliderBase.CurrentLockedSlider == null)
UISliderBase.CurrentLockedSlider = UISliderBase.CurrentAimedSlider;
if (!this._isReallyMouseOvered)
return;
this._slideGamepadAction();
}
private bool DrawValueBarDynamicWidth(SpriteBatch spriteBatch, out float sliderValueThatWasSet)
{
sliderValueThatWasSet = 0.0f;
Texture2D texture1 = TextureAssets.ColorBar.Value;
Rectangle rectangle1 = this.GetDimensions().ToRectangle();
Rectangle rectangle2 = new Rectangle(5, 4, 4, 4);
Utils.DrawSplicedPanel(spriteBatch, texture1, rectangle1.X, rectangle1.Y, rectangle1.Width, rectangle1.Height, rectangle2.X, rectangle2.Width, rectangle2.Y, rectangle2.Height, Color.White);
Rectangle destinationRectangle1 = rectangle1;
destinationRectangle1.X += rectangle2.Left;
destinationRectangle1.Width -= rectangle2.Right;
destinationRectangle1.Y += rectangle2.Top;
destinationRectangle1.Height -= rectangle2.Bottom;
Texture2D texture2 = TextureAssets.MagicPixel.Value;
Rectangle rectangle3 = new Rectangle(0, 0, 1, 1);
spriteBatch.Draw(texture2, destinationRectangle1, new Rectangle?(rectangle3), this.EmptyColor);
Rectangle destinationRectangle2 = destinationRectangle1;
destinationRectangle2.Height = (int) ((double) destinationRectangle2.Height * (double) this.FillPercent);
destinationRectangle2.Y += destinationRectangle1.Height - destinationRectangle2.Height;
spriteBatch.Draw(texture2, destinationRectangle2, new Rectangle?(rectangle3), this.FilledColor);
Rectangle destinationRectangle3 = Utils.CenteredRectangle(new Vector2((float) (destinationRectangle2.Center.X + 1), (float) destinationRectangle2.Top), new Vector2((float) (destinationRectangle2.Width + 16), 4f));
Rectangle destinationRectangle4 = destinationRectangle3;
destinationRectangle4.Inflate(2, 2);
spriteBatch.Draw(texture2, destinationRectangle4, new Rectangle?(rectangle3), Color.Black);
spriteBatch.Draw(texture2, destinationRectangle3, new Rectangle?(rectangle3), Color.White);
Rectangle rectangle4 = destinationRectangle1;
rectangle4.Inflate(4, 0);
bool flag1 = rectangle4.Contains(Main.MouseScreen.ToPoint());
this._isReallyMouseOvered = flag1;
bool flag2 = flag1;
if (this.IgnoresMouseInteraction)
flag2 = false;
int usageLevel = this.GetUsageLevel();
if (usageLevel == 2)
flag2 = false;
if (usageLevel == 1)
flag2 = true;
if (flag2 || usageLevel == 1)
{
if (!this._alreadyHovered)
SoundEngine.PlaySound(12);
this._alreadyHovered = true;
}
else
this._alreadyHovered = false;
if (!flag2)
return false;
sliderValueThatWasSet = Utils.GetLerpValue((float) destinationRectangle1.Bottom, (float) destinationRectangle1.Top, (float) Main.mouseY, true);
return true;
}
}
}

View file

@ -0,0 +1,124 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIWorldCreationPreview
// 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.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UIWorldCreationPreview : UIElement
{
private readonly Asset<Texture2D> _BorderTexture;
private readonly Asset<Texture2D> _BackgroundExpertTexture;
private readonly Asset<Texture2D> _BackgroundNormalTexture;
private readonly Asset<Texture2D> _BackgroundMasterTexture;
private readonly Asset<Texture2D> _BunnyExpertTexture;
private readonly Asset<Texture2D> _BunnyNormalTexture;
private readonly Asset<Texture2D> _BunnyCreativeTexture;
private readonly Asset<Texture2D> _BunnyMasterTexture;
private readonly Asset<Texture2D> _EvilRandomTexture;
private readonly Asset<Texture2D> _EvilCorruptionTexture;
private readonly Asset<Texture2D> _EvilCrimsonTexture;
private readonly Asset<Texture2D> _SizeSmallTexture;
private readonly Asset<Texture2D> _SizeMediumTexture;
private readonly Asset<Texture2D> _SizeLargeTexture;
private byte _difficulty;
private byte _evil;
private byte _size;
public UIWorldCreationPreview()
{
this._BorderTexture = Main.Assets.Request<Texture2D>("Images/UI/WorldCreation/PreviewBorder", (AssetRequestMode) 1);
this._BackgroundNormalTexture = Main.Assets.Request<Texture2D>("Images/UI/WorldCreation/PreviewDifficultyNormal1", (AssetRequestMode) 1);
this._BackgroundExpertTexture = Main.Assets.Request<Texture2D>("Images/UI/WorldCreation/PreviewDifficultyExpert1", (AssetRequestMode) 1);
this._BackgroundMasterTexture = Main.Assets.Request<Texture2D>("Images/UI/WorldCreation/PreviewDifficultyMaster1", (AssetRequestMode) 1);
this._BunnyNormalTexture = Main.Assets.Request<Texture2D>("Images/UI/WorldCreation/PreviewDifficultyNormal2", (AssetRequestMode) 1);
this._BunnyExpertTexture = Main.Assets.Request<Texture2D>("Images/UI/WorldCreation/PreviewDifficultyExpert2", (AssetRequestMode) 1);
this._BunnyCreativeTexture = Main.Assets.Request<Texture2D>("Images/UI/WorldCreation/PreviewDifficultyCreative2", (AssetRequestMode) 1);
this._BunnyMasterTexture = Main.Assets.Request<Texture2D>("Images/UI/WorldCreation/PreviewDifficultyMaster2", (AssetRequestMode) 1);
this._EvilRandomTexture = Main.Assets.Request<Texture2D>("Images/UI/WorldCreation/PreviewEvilRandom", (AssetRequestMode) 1);
this._EvilCorruptionTexture = Main.Assets.Request<Texture2D>("Images/UI/WorldCreation/PreviewEvilCorruption", (AssetRequestMode) 1);
this._EvilCrimsonTexture = Main.Assets.Request<Texture2D>("Images/UI/WorldCreation/PreviewEvilCrimson", (AssetRequestMode) 1);
this._SizeSmallTexture = Main.Assets.Request<Texture2D>("Images/UI/WorldCreation/PreviewSizeSmall", (AssetRequestMode) 1);
this._SizeMediumTexture = Main.Assets.Request<Texture2D>("Images/UI/WorldCreation/PreviewSizeMedium", (AssetRequestMode) 1);
this._SizeLargeTexture = Main.Assets.Request<Texture2D>("Images/UI/WorldCreation/PreviewSizeLarge", (AssetRequestMode) 1);
this.Width.Set((float) this._BackgroundExpertTexture.Width(), 0.0f);
this.Height.Set((float) this._BackgroundExpertTexture.Height(), 0.0f);
}
public void UpdateOption(byte difficulty, byte evil, byte size)
{
this._difficulty = difficulty;
this._evil = evil;
this._size = size;
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
CalculatedStyle dimensions = this.GetDimensions();
Vector2 position = new Vector2(dimensions.X + 4f, dimensions.Y + 4f);
Color color = Color.White;
switch (this._difficulty)
{
case 0:
case 3:
spriteBatch.Draw(this._BackgroundNormalTexture.Value, position, Color.White);
color = Color.White;
break;
case 1:
spriteBatch.Draw(this._BackgroundExpertTexture.Value, position, Color.White);
color = Color.DarkGray;
break;
case 2:
spriteBatch.Draw(this._BackgroundMasterTexture.Value, position, Color.White);
color = Color.DarkGray;
break;
}
switch (this._size)
{
case 0:
spriteBatch.Draw(this._SizeSmallTexture.Value, position, color);
break;
case 1:
spriteBatch.Draw(this._SizeMediumTexture.Value, position, color);
break;
case 2:
spriteBatch.Draw(this._SizeLargeTexture.Value, position, color);
break;
}
switch (this._evil)
{
case 0:
spriteBatch.Draw(this._EvilRandomTexture.Value, position, color);
break;
case 1:
spriteBatch.Draw(this._EvilCorruptionTexture.Value, position, color);
break;
case 2:
spriteBatch.Draw(this._EvilCrimsonTexture.Value, position, color);
break;
}
switch (this._difficulty)
{
case 0:
spriteBatch.Draw(this._BunnyNormalTexture.Value, position, color);
break;
case 1:
spriteBatch.Draw(this._BunnyExpertTexture.Value, position, color);
break;
case 2:
spriteBatch.Draw(this._BunnyMasterTexture.Value, position, color * 1.2f);
break;
case 3:
spriteBatch.Draw(this._BunnyCreativeTexture.Value, position, color);
break;
}
spriteBatch.Draw(this._BorderTexture.Value, new Vector2(dimensions.X, dimensions.Y), Color.White);
}
}
}

View file

@ -0,0 +1,364 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.Elements.UIWorldListItem
// 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 ReLogic.OS;
using Terraria.Audio;
using Terraria.DataStructures;
using Terraria.IO;
using Terraria.Localization;
using Terraria.Social;
using Terraria.UI;
namespace Terraria.GameContent.UI.Elements
{
public class UIWorldListItem : UIPanel
{
private WorldFileData _data;
private Asset<Texture2D> _dividerTexture;
private Asset<Texture2D> _innerPanelTexture;
private UIImage _worldIcon;
private UIText _buttonLabel;
private UIText _deleteButtonLabel;
private Asset<Texture2D> _buttonCloudActiveTexture;
private Asset<Texture2D> _buttonCloudInactiveTexture;
private Asset<Texture2D> _buttonFavoriteActiveTexture;
private Asset<Texture2D> _buttonFavoriteInactiveTexture;
private Asset<Texture2D> _buttonPlayTexture;
private Asset<Texture2D> _buttonSeedTexture;
private Asset<Texture2D> _buttonDeleteTexture;
private UIImageButton _deleteButton;
private int _orderInList;
private bool _canBePlayed;
public bool IsFavorite => this._data.IsFavorite;
public UIWorldListItem(WorldFileData data, int orderInList, bool canBePlayed)
{
this._orderInList = orderInList;
this._data = data;
this._canBePlayed = canBePlayed;
this.LoadTextures();
this.InitializeAppearance();
this._worldIcon = new UIImage(this.GetIcon());
this._worldIcon.Left.Set(4f, 0.0f);
this._worldIcon.OnDoubleClick += new UIElement.MouseEvent(this.PlayGame);
this.Append((UIElement) this._worldIcon);
float pixels1 = 4f;
UIImageButton uiImageButton1 = new UIImageButton(this._buttonPlayTexture);
uiImageButton1.VAlign = 1f;
uiImageButton1.Left.Set(pixels1, 0.0f);
uiImageButton1.OnClick += new UIElement.MouseEvent(this.PlayGame);
this.OnDoubleClick += new UIElement.MouseEvent(this.PlayGame);
uiImageButton1.OnMouseOver += new UIElement.MouseEvent(this.PlayMouseOver);
uiImageButton1.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut);
this.Append((UIElement) uiImageButton1);
float pixels2 = pixels1 + 24f;
UIImageButton uiImageButton2 = new UIImageButton(this._data.IsFavorite ? this._buttonFavoriteActiveTexture : this._buttonFavoriteInactiveTexture);
uiImageButton2.VAlign = 1f;
uiImageButton2.Left.Set(pixels2, 0.0f);
uiImageButton2.OnClick += new UIElement.MouseEvent(this.FavoriteButtonClick);
uiImageButton2.OnMouseOver += new UIElement.MouseEvent(this.FavoriteMouseOver);
uiImageButton2.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut);
uiImageButton2.SetVisibility(1f, this._data.IsFavorite ? 0.8f : 0.4f);
this.Append((UIElement) uiImageButton2);
float pixels3 = pixels2 + 24f;
if (SocialAPI.Cloud != null)
{
UIImageButton uiImageButton3 = new UIImageButton(this._data.IsCloudSave ? this._buttonCloudActiveTexture : this._buttonCloudInactiveTexture);
uiImageButton3.VAlign = 1f;
uiImageButton3.Left.Set(pixels3, 0.0f);
uiImageButton3.OnClick += new UIElement.MouseEvent(this.CloudButtonClick);
uiImageButton3.OnMouseOver += new UIElement.MouseEvent(this.CloudMouseOver);
uiImageButton3.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut);
uiImageButton3.SetSnapPoint("Cloud", orderInList);
this.Append((UIElement) uiImageButton3);
pixels3 += 24f;
}
if (this._data.WorldGeneratorVersion != 0UL)
{
UIImageButton uiImageButton4 = new UIImageButton(this._buttonSeedTexture);
uiImageButton4.VAlign = 1f;
uiImageButton4.Left.Set(pixels3, 0.0f);
uiImageButton4.OnClick += new UIElement.MouseEvent(this.SeedButtonClick);
uiImageButton4.OnMouseOver += new UIElement.MouseEvent(this.SeedMouseOver);
uiImageButton4.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut);
uiImageButton4.SetSnapPoint("Seed", orderInList);
this.Append((UIElement) uiImageButton4);
pixels3 += 24f;
}
UIImageButton uiImageButton5 = new UIImageButton(this._buttonDeleteTexture);
uiImageButton5.VAlign = 1f;
uiImageButton5.HAlign = 1f;
if (!this._data.IsFavorite)
uiImageButton5.OnClick += new UIElement.MouseEvent(this.DeleteButtonClick);
uiImageButton5.OnMouseOver += new UIElement.MouseEvent(this.DeleteMouseOver);
uiImageButton5.OnMouseOut += new UIElement.MouseEvent(this.DeleteMouseOut);
this._deleteButton = uiImageButton5;
this.Append((UIElement) uiImageButton5);
float pixels4 = pixels3 + 4f;
this._buttonLabel = new UIText("");
this._buttonLabel.VAlign = 1f;
this._buttonLabel.Left.Set(pixels4, 0.0f);
this._buttonLabel.Top.Set(-3f, 0.0f);
this.Append((UIElement) this._buttonLabel);
this._deleteButtonLabel = new UIText("");
this._deleteButtonLabel.VAlign = 1f;
this._deleteButtonLabel.HAlign = 1f;
this._deleteButtonLabel.Left.Set(-30f, 0.0f);
this._deleteButtonLabel.Top.Set(-3f, 0.0f);
this.Append((UIElement) this._deleteButtonLabel);
uiImageButton1.SetSnapPoint("Play", orderInList);
uiImageButton2.SetSnapPoint("Favorite", orderInList);
uiImageButton5.SetSnapPoint("Delete", orderInList);
}
private void LoadTextures()
{
this._dividerTexture = Main.Assets.Request<Texture2D>("Images/UI/Divider", (AssetRequestMode) 1);
this._innerPanelTexture = Main.Assets.Request<Texture2D>("Images/UI/InnerPanelBackground", (AssetRequestMode) 1);
this._buttonCloudActiveTexture = Main.Assets.Request<Texture2D>("Images/UI/ButtonCloudActive", (AssetRequestMode) 1);
this._buttonCloudInactiveTexture = Main.Assets.Request<Texture2D>("Images/UI/ButtonCloudInactive", (AssetRequestMode) 1);
this._buttonFavoriteActiveTexture = Main.Assets.Request<Texture2D>("Images/UI/ButtonFavoriteActive", (AssetRequestMode) 1);
this._buttonFavoriteInactiveTexture = Main.Assets.Request<Texture2D>("Images/UI/ButtonFavoriteInactive", (AssetRequestMode) 1);
this._buttonPlayTexture = Main.Assets.Request<Texture2D>("Images/UI/ButtonPlay", (AssetRequestMode) 1);
this._buttonSeedTexture = Main.Assets.Request<Texture2D>("Images/UI/ButtonSeed", (AssetRequestMode) 1);
this._buttonDeleteTexture = Main.Assets.Request<Texture2D>("Images/UI/ButtonDelete", (AssetRequestMode) 1);
}
private void InitializeAppearance()
{
this.Height.Set(96f, 0.0f);
this.Width.Set(0.0f, 1f);
this.SetPadding(6f);
this.SetColorsToNotHovered();
}
private void SetColorsToHovered()
{
this.BackgroundColor = new Color(73, 94, 171);
this.BorderColor = new Color(89, 116, 213);
if (this._canBePlayed)
return;
this.BorderColor = new Color(150, 150, 150) * 1f;
this.BackgroundColor = Color.Lerp(this.BackgroundColor, new Color(120, 120, 120), 0.5f) * 1f;
}
private void SetColorsToNotHovered()
{
this.BackgroundColor = new Color(63, 82, 151) * 0.7f;
this.BorderColor = new Color(89, 116, 213) * 0.7f;
if (this._canBePlayed)
return;
this.BorderColor = new Color((int) sbyte.MaxValue, (int) sbyte.MaxValue, (int) sbyte.MaxValue) * 0.7f;
this.BackgroundColor = Color.Lerp(new Color(63, 82, 151), new Color(80, 80, 80), 0.5f) * 0.7f;
}
private Asset<Texture2D> GetIcon() => this._data.DrunkWorld ? Main.Assets.Request<Texture2D>("Images/UI/Icon" + (this._data.IsHardMode ? "Hallow" : "") + "CorruptionCrimson", (AssetRequestMode) 1) : Main.Assets.Request<Texture2D>("Images/UI/Icon" + (this._data.IsHardMode ? "Hallow" : "") + (this._data.HasCorruption ? "Corruption" : "Crimson"), (AssetRequestMode) 1);
private void FavoriteMouseOver(UIMouseEvent evt, UIElement listeningElement)
{
if (this._data.IsFavorite)
this._buttonLabel.SetText(Language.GetTextValue("UI.Unfavorite"));
else
this._buttonLabel.SetText(Language.GetTextValue("UI.Favorite"));
}
private void CloudMouseOver(UIMouseEvent evt, UIElement listeningElement)
{
if (this._data.IsCloudSave)
this._buttonLabel.SetText(Language.GetTextValue("UI.MoveOffCloud"));
else
this._buttonLabel.SetText(Language.GetTextValue("UI.MoveToCloud"));
}
private void PlayMouseOver(UIMouseEvent evt, UIElement listeningElement) => this._buttonLabel.SetText(Language.GetTextValue("UI.Play"));
private void SeedMouseOver(UIMouseEvent evt, UIElement listeningElement) => this._buttonLabel.SetText(Language.GetTextValue("UI.CopySeed", (object) this._data.GetFullSeedText()));
private void DeleteMouseOver(UIMouseEvent evt, UIElement listeningElement)
{
if (this._data.IsFavorite)
this._deleteButtonLabel.SetText(Language.GetTextValue("UI.CannotDeleteFavorited"));
else
this._deleteButtonLabel.SetText(Language.GetTextValue("UI.Delete"));
}
private void DeleteMouseOut(UIMouseEvent evt, UIElement listeningElement) => this._deleteButtonLabel.SetText("");
private void ButtonMouseOut(UIMouseEvent evt, UIElement listeningElement) => this._buttonLabel.SetText("");
private void CloudButtonClick(UIMouseEvent evt, UIElement listeningElement)
{
if (this._data.IsCloudSave)
this._data.MoveToLocal();
else
this._data.MoveToCloud();
((UIImageButton) evt.Target).SetImage(this._data.IsCloudSave ? this._buttonCloudActiveTexture : this._buttonCloudInactiveTexture);
if (this._data.IsCloudSave)
this._buttonLabel.SetText(Language.GetTextValue("UI.MoveOffCloud"));
else
this._buttonLabel.SetText(Language.GetTextValue("UI.MoveToCloud"));
}
private void DeleteButtonClick(UIMouseEvent evt, UIElement listeningElement)
{
for (int index = 0; index < Main.WorldList.Count; ++index)
{
if (Main.WorldList[index] == this._data)
{
SoundEngine.PlaySound(10);
Main.selectedWorld = index;
Main.menuMode = 9;
break;
}
}
}
private void PlayGame(UIMouseEvent evt, UIElement listeningElement)
{
if (listeningElement != evt.Target || this.TryMovingToRejectionMenuIfNeeded(this._data.GameMode))
return;
this._data.SetAsActive();
SoundEngine.PlaySound(10);
Main.GetInputText("");
Main.menuMode = !Main.menuMultiplayer || SocialAPI.Network == null ? (!Main.menuMultiplayer ? 10 : 30) : 889;
if (Main.menuMultiplayer)
return;
WorldGen.playWorld();
}
private bool TryMovingToRejectionMenuIfNeeded(int worldGameMode)
{
GameModeData gameModeData;
if (!Main.RegisterdGameModes.TryGetValue(worldGameMode, out gameModeData))
{
SoundEngine.PlaySound(10);
Main.statusText = Language.GetTextValue("UI.WorldCannotBeLoadedBecauseItHasAnInvalidGameMode");
Main.menuMode = 1000000;
return true;
}
bool flag = Main.ActivePlayerFileData.Player.difficulty == (byte) 3;
bool isJourneyMode = gameModeData.IsJourneyMode;
if (flag && !isJourneyMode)
{
SoundEngine.PlaySound(10);
Main.statusText = Language.GetTextValue("UI.PlayerIsCreativeAndWorldIsNotCreative");
Main.menuMode = 1000000;
return true;
}
if (!(!flag & isJourneyMode))
return false;
SoundEngine.PlaySound(10);
Main.statusText = Language.GetTextValue("UI.PlayerIsNotCreativeAndWorldIsCreative");
Main.menuMode = 1000000;
return true;
}
private void FavoriteButtonClick(UIMouseEvent evt, UIElement listeningElement)
{
this._data.ToggleFavorite();
((UIImageButton) evt.Target).SetImage(this._data.IsFavorite ? this._buttonFavoriteActiveTexture : this._buttonFavoriteInactiveTexture);
((UIImageButton) evt.Target).SetVisibility(1f, this._data.IsFavorite ? 0.8f : 0.4f);
if (this._data.IsFavorite)
{
this._buttonLabel.SetText(Language.GetTextValue("UI.Unfavorite"));
this._deleteButton.OnClick -= new UIElement.MouseEvent(this.DeleteButtonClick);
}
else
{
this._buttonLabel.SetText(Language.GetTextValue("UI.Favorite"));
this._deleteButton.OnClick += new UIElement.MouseEvent(this.DeleteButtonClick);
}
if (!(this.Parent.Parent is UIList parent))
return;
parent.UpdateOrder();
}
private void SeedButtonClick(UIMouseEvent evt, UIElement listeningElement)
{
Platform.Get<IClipboard>().Value = this._data.GetFullSeedText();
this._buttonLabel.SetText(Language.GetTextValue("UI.SeedCopied"));
}
public override int CompareTo(object obj) => obj is UIWorldListItem uiWorldListItem ? this._orderInList.CompareTo(uiWorldListItem._orderInList) : base.CompareTo(obj);
public override void MouseOver(UIMouseEvent evt)
{
base.MouseOver(evt);
this.SetColorsToHovered();
}
public override void MouseOut(UIMouseEvent evt)
{
base.MouseOut(evt);
this.SetColorsToNotHovered();
}
private void DrawPanel(SpriteBatch spriteBatch, Vector2 position, float width)
{
spriteBatch.Draw(this._innerPanelTexture.Value, position, new Rectangle?(new Rectangle(0, 0, 8, this._innerPanelTexture.Height())), Color.White);
spriteBatch.Draw(this._innerPanelTexture.Value, new Vector2(position.X + 8f, position.Y), new Rectangle?(new Rectangle(8, 0, 8, this._innerPanelTexture.Height())), Color.White, 0.0f, Vector2.Zero, new Vector2((float) (((double) width - 16.0) / 8.0), 1f), SpriteEffects.None, 0.0f);
spriteBatch.Draw(this._innerPanelTexture.Value, new Vector2((float) ((double) position.X + (double) width - 8.0), position.Y), new Rectangle?(new Rectangle(16, 0, 8, this._innerPanelTexture.Height())), Color.White);
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
base.DrawSelf(spriteBatch);
CalculatedStyle innerDimensions = this.GetInnerDimensions();
CalculatedStyle dimensions = this._worldIcon.GetDimensions();
float x1 = dimensions.X + dimensions.Width;
Color color1 = this._data.IsValid ? Color.White : Color.Red;
Utils.DrawBorderString(spriteBatch, this._data.Name, new Vector2(x1 + 6f, dimensions.Y - 2f), color1);
spriteBatch.Draw(this._dividerTexture.Value, new Vector2(x1, innerDimensions.Y + 21f), new Rectangle?(), Color.White, 0.0f, Vector2.Zero, new Vector2((float) (((double) this.GetDimensions().X + (double) this.GetDimensions().Width - (double) x1) / 8.0), 1f), SpriteEffects.None, 0.0f);
Vector2 position = new Vector2(x1 + 6f, innerDimensions.Y + 29f);
float width1 = 100f;
this.DrawPanel(spriteBatch, position, width1);
Color color2 = Color.White;
string textValue1;
switch (this._data.GameMode)
{
case 1:
textValue1 = Language.GetTextValue("UI.Expert");
color2 = Main.mcColor;
break;
case 2:
textValue1 = Language.GetTextValue("UI.Master");
color2 = Main.hcColor;
break;
case 3:
textValue1 = Language.GetTextValue("UI.Creative");
color2 = Main.creativeModeColor;
break;
default:
textValue1 = Language.GetTextValue("UI.Normal");
break;
}
float x2 = FontAssets.MouseText.Value.MeasureString(textValue1).X;
float x3 = (float) ((double) width1 * 0.5 - (double) x2 * 0.5);
Utils.DrawBorderString(spriteBatch, textValue1, position + new Vector2(x3, 3f), color2);
position.X += width1 + 5f;
float width2 = 150f;
if (!GameCulture.FromCultureName(GameCulture.CultureName.English).IsActive)
width2 += 40f;
this.DrawPanel(spriteBatch, position, width2);
string textValue2 = Language.GetTextValue("UI.WorldSizeFormat", (object) this._data.WorldSizeName);
float x4 = FontAssets.MouseText.Value.MeasureString(textValue2).X;
float x5 = (float) ((double) width2 * 0.5 - (double) x4 * 0.5);
Utils.DrawBorderString(spriteBatch, textValue2, position + new Vector2(x5, 3f), Color.White);
position.X += width2 + 5f;
float width3 = innerDimensions.X + innerDimensions.Width - position.X;
this.DrawPanel(spriteBatch, position, width3);
string textValue3 = Language.GetTextValue("UI.WorldCreatedFormat", !GameCulture.FromCultureName(GameCulture.CultureName.English).IsActive ? (object) this._data.CreationTime.ToShortDateString() : (object) this._data.CreationTime.ToString("d MMMM yyyy"));
float x6 = FontAssets.MouseText.Value.MeasureString(textValue3).X;
float x7 = (float) ((double) width3 * 0.5 - (double) x6 * 0.5);
Utils.DrawBorderString(spriteBatch, textValue3, position + new Vector2(x7, 3f), Color.White);
position.X += width3 + 5f;
}
}
}

View file

@ -0,0 +1,846 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.EmoteBubble
// 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 System.Collections.Generic;
using Terraria.GameContent.Events;
using Terraria.ID;
namespace Terraria.GameContent.UI
{
public class EmoteBubble
{
private static int[] CountNPCs = new int[663];
public static Dictionary<int, EmoteBubble> byID = new Dictionary<int, EmoteBubble>();
private static List<int> toClean = new List<int>();
public static int NextID;
public int ID;
public WorldUIAnchor anchor;
public int lifeTime;
public int lifeTimeStart;
public int emote;
public int metadata;
private const int frameSpeed = 8;
public int frameCounter;
public int frame;
public const int EMOTE_SHEET_HORIZONTAL_FRAMES = 8;
public const int EMOTE_SHEET_EMOTES_PER_ROW = 4;
public const int EMOTE_SHEET_VERTICAL_FRAMES = 38;
public static void UpdateAll()
{
lock (EmoteBubble.byID)
{
EmoteBubble.toClean.Clear();
foreach (KeyValuePair<int, EmoteBubble> keyValuePair in EmoteBubble.byID)
{
keyValuePair.Value.Update();
if (keyValuePair.Value.lifeTime <= 0)
EmoteBubble.toClean.Add(keyValuePair.Key);
}
foreach (int key in EmoteBubble.toClean)
EmoteBubble.byID.Remove(key);
EmoteBubble.toClean.Clear();
}
}
public static void DrawAll(SpriteBatch sb)
{
lock (EmoteBubble.byID)
{
foreach (KeyValuePair<int, EmoteBubble> keyValuePair in EmoteBubble.byID)
keyValuePair.Value.Draw(sb);
}
}
public static Tuple<int, int> SerializeNetAnchor(WorldUIAnchor anch)
{
if (anch.type != WorldUIAnchor.AnchorType.Entity)
return Tuple.Create<int, int>(0, 0);
int num = 0;
if (anch.entity is NPC)
num = 0;
else if (anch.entity is Player)
num = 1;
else if (anch.entity is Projectile)
num = 2;
return Tuple.Create<int, int>(num, anch.entity.whoAmI);
}
public static WorldUIAnchor DeserializeNetAnchor(int type, int meta)
{
if (type == 0)
return new WorldUIAnchor((Entity) Main.npc[meta]);
if (type == 1)
return new WorldUIAnchor((Entity) Main.player[meta]);
if (type == 2)
return new WorldUIAnchor((Entity) Main.projectile[meta]);
throw new Exception("How did you end up getting this?");
}
public static int AssignNewID() => EmoteBubble.NextID++;
public static int NewBubble(int emoticon, WorldUIAnchor bubbleAnchor, int time)
{
EmoteBubble emoteBubble = new EmoteBubble(emoticon, bubbleAnchor, time)
{
ID = EmoteBubble.AssignNewID()
};
EmoteBubble.byID[emoteBubble.ID] = emoteBubble;
if (Main.netMode == 2)
{
Tuple<int, int> tuple = EmoteBubble.SerializeNetAnchor(bubbleAnchor);
NetMessage.SendData(91, number: emoteBubble.ID, number2: ((float) tuple.Item1), number3: ((float) tuple.Item2), number4: ((float) time), number5: emoticon);
}
EmoteBubble.OnBubbleChange(emoteBubble.ID);
return emoteBubble.ID;
}
public static int NewBubbleNPC(WorldUIAnchor bubbleAnchor, int time, WorldUIAnchor other = null)
{
EmoteBubble emoteBubble = new EmoteBubble(0, bubbleAnchor, time)
{
ID = EmoteBubble.AssignNewID()
};
EmoteBubble.byID[emoteBubble.ID] = emoteBubble;
emoteBubble.PickNPCEmote(other);
if (Main.netMode == 2)
{
Tuple<int, int> tuple = EmoteBubble.SerializeNetAnchor(bubbleAnchor);
NetMessage.SendData(91, number: emoteBubble.ID, number2: ((float) tuple.Item1), number3: ((float) tuple.Item2), number4: ((float) time), number5: emoteBubble.emote, number6: emoteBubble.metadata);
}
return emoteBubble.ID;
}
public static void CheckForNPCsToReactToEmoteBubble(int emoteID, Player player)
{
for (int index = 0; index < 200; ++index)
{
NPC npc = Main.npc[index];
if (npc != null && npc.active && npc.aiStyle == 7 && npc.townNPC && (double) npc.ai[0] < 2.0 && (player.CanBeTalkedTo && (double) player.Distance(npc.Center) < 200.0 || !Collision.CanHitLine(npc.Top, 0, 0, player.Top, 0, 0)))
{
int directionInt = ((double) npc.position.X < (double) player.position.X).ToDirectionInt();
npc.ai[0] = 19f;
npc.ai[1] = 220f;
npc.ai[2] = (float) player.whoAmI;
npc.direction = directionInt;
npc.netUpdate = true;
}
}
}
public EmoteBubble(int emotion, WorldUIAnchor bubbleAnchor, int time = 180)
{
this.anchor = bubbleAnchor;
this.emote = emotion;
this.lifeTime = time;
this.lifeTimeStart = time;
}
private void Update()
{
if (--this.lifeTime <= 0 || ++this.frameCounter < 8)
return;
this.frameCounter = 0;
if (++this.frame < 2)
return;
this.frame = 0;
}
private void Draw(SpriteBatch sb)
{
Texture2D texture2D = TextureAssets.Extra[48].Value;
SpriteEffects effect = SpriteEffects.None;
Vector2 vector2 = this.GetPosition(out effect).Floor();
bool flag = this.lifeTime < 6 || this.lifeTimeStart - this.lifeTime < 6;
Rectangle rectangle = texture2D.Frame(8, 38, flag ? 0 : 1);
Vector2 origin = new Vector2((float) (rectangle.Width / 2), (float) rectangle.Height);
if ((double) Main.player[Main.myPlayer].gravDir == -1.0)
{
origin.Y = 0.0f;
effect |= SpriteEffects.FlipVertically;
vector2 = Main.ReverseGravitySupport(vector2);
}
sb.Draw(texture2D, vector2, new Rectangle?(rectangle), Color.White, 0.0f, origin, 1f, effect, 0.0f);
if (flag)
return;
if (this.emote >= 0)
{
if ((this.emote == 87 || this.emote == 89) && effect.HasFlag((Enum) SpriteEffects.FlipHorizontally))
{
effect &= ~SpriteEffects.FlipHorizontally;
vector2.X += 4f;
}
sb.Draw(texture2D, vector2, new Rectangle?(texture2D.Frame(8, 38, this.emote * 2 % 8 + this.frame, 1 + this.emote / 4)), Color.White, 0.0f, origin, 1f, effect, 0.0f);
}
else
{
if (this.emote != -1)
return;
Texture2D texture = TextureAssets.NpcHead[this.metadata].Value;
float scale = 1f;
if ((double) texture.Width / 22.0 > 1.0)
scale = 22f / (float) texture.Width;
if ((double) texture.Height / 16.0 > 1.0 / (double) scale)
scale = 16f / (float) texture.Height;
sb.Draw(texture, vector2 + new Vector2(effect.HasFlag((Enum) SpriteEffects.FlipHorizontally) ? 1f : -1f, (float) (-rectangle.Height + 3)), new Rectangle?(), Color.White, 0.0f, new Vector2((float) (texture.Width / 2), 0.0f), scale, effect, 0.0f);
}
}
private Vector2 GetPosition(out SpriteEffects effect)
{
switch (this.anchor.type)
{
case WorldUIAnchor.AnchorType.Entity:
effect = this.anchor.entity.direction == -1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
return new Vector2(this.anchor.entity.Top.X, this.anchor.entity.VisualPosition.Y) + new Vector2((float) (-this.anchor.entity.direction * this.anchor.entity.width) * 0.75f, 2f) - Main.screenPosition;
case WorldUIAnchor.AnchorType.Tile:
effect = SpriteEffects.None;
return this.anchor.pos - Main.screenPosition + new Vector2(0.0f, (float) (-(double) this.anchor.size.Y / 2.0));
case WorldUIAnchor.AnchorType.Pos:
effect = SpriteEffects.None;
return this.anchor.pos - Main.screenPosition;
default:
effect = SpriteEffects.None;
return new Vector2((float) Main.screenWidth, (float) Main.screenHeight) / 2f;
}
}
public static void OnBubbleChange(int bubbleID)
{
EmoteBubble emoteBubble1 = EmoteBubble.byID[bubbleID];
if (emoteBubble1.anchor.type != WorldUIAnchor.AnchorType.Entity || !(emoteBubble1.anchor.entity is Player entity))
return;
foreach (EmoteBubble emoteBubble2 in EmoteBubble.byID.Values)
{
if (emoteBubble2.anchor.type == WorldUIAnchor.AnchorType.Entity && emoteBubble2.anchor.entity == entity && emoteBubble2.ID != bubbleID)
emoteBubble2.lifeTime = 6;
}
}
public void PickNPCEmote(WorldUIAnchor other = null)
{
Player plr = Main.player[(int) Player.FindClosest(this.anchor.entity.Center, 0, 0)];
List<int> list = new List<int>();
bool flag = false;
for (int index = 0; index < 200; ++index)
{
if (Main.npc[index].active && Main.npc[index].boss)
flag = true;
}
if (!flag)
{
if (Main.rand.Next(3) == 0)
this.ProbeTownNPCs(list);
if (Main.rand.Next(3) == 0)
this.ProbeEmotions(list);
if (Main.rand.Next(3) == 0)
this.ProbeBiomes(list, plr);
if (Main.rand.Next(2) == 0)
this.ProbeCritters(list);
if (Main.rand.Next(2) == 0)
this.ProbeItems(list, plr);
if (Main.rand.Next(5) == 0)
this.ProbeBosses(list);
if (Main.rand.Next(2) == 0)
this.ProbeDebuffs(list, plr);
if (Main.rand.Next(2) == 0)
this.ProbeEvents(list);
if (Main.rand.Next(2) == 0)
this.ProbeWeather(list, plr);
this.ProbeExceptions(list, plr, other);
}
else
this.ProbeCombat(list);
if (list.Count <= 0)
return;
this.emote = list[Main.rand.Next(list.Count)];
}
private void ProbeCombat(List<int> list)
{
list.Add(16);
list.Add(1);
list.Add(2);
list.Add(91);
list.Add(93);
list.Add(84);
list.Add(84);
}
private void ProbeWeather(List<int> list, Player plr)
{
if ((double) Main.cloudBGActive > 0.0)
list.Add(96);
if ((double) Main.cloudAlpha > 0.0)
{
if (!Main.dayTime)
list.Add(5);
list.Add(4);
if (plr.ZoneSnow)
list.Add(98);
if ((double) plr.position.X < 4000.0 || (double) plr.position.X > (double) (Main.maxTilesX * 16 - 4000) && (double) plr.position.Y < Main.worldSurface / 16.0)
list.Add(97);
}
else
list.Add(95);
if (!plr.ZoneHallow)
return;
list.Add(6);
}
private void ProbeEvents(List<int> list)
{
if (BirthdayParty.PartyIsUp && Main.rand.Next(3) == 0)
list.Add(Utils.SelectRandom<int>(Main.rand, (int) sbyte.MaxValue, 128, 129, 126));
if (Main.bloodMoon || !Main.dayTime && Main.rand.Next(4) == 0)
list.Add(18);
if (Main.eclipse || Main.hardMode && Main.rand.Next(4) == 0)
list.Add(19);
if ((!Main.dayTime || WorldGen.spawnMeteor) && NPC.downedBoss2)
list.Add(99);
if (Main.pumpkinMoon || (NPC.downedHalloweenKing || NPC.downedHalloweenTree) && !Main.dayTime)
list.Add(20);
if (Main.snowMoon || (NPC.downedChristmasIceQueen || NPC.downedChristmasSantank || NPC.downedChristmasTree) && !Main.dayTime)
list.Add(21);
if (!DD2Event.Ongoing && !DD2Event.DownedInvasionAnyDifficulty)
return;
list.Add(133);
}
private void ProbeDebuffs(List<int> list, Player plr)
{
if ((double) plr.Center.Y > (double) (Main.maxTilesY * 16 - 3200) || plr.onFire || ((NPC) this.anchor.entity).onFire || plr.onFire2)
list.Add(9);
if (Main.rand.Next(2) == 0)
list.Add(11);
if (plr.poisoned || ((NPC) this.anchor.entity).poisoned || plr.ZoneJungle)
list.Add(8);
if (plr.inventory[plr.selectedItem].type != 215 && Main.rand.Next(3) != 0)
return;
list.Add(10);
}
private void ProbeItems(List<int> list, Player plr)
{
list.Add(7);
list.Add(73);
list.Add(74);
list.Add(75);
list.Add(78);
list.Add(90);
if (plr.statLife >= plr.statLifeMax2 / 2)
return;
list.Add(84);
}
private void ProbeTownNPCs(List<int> list)
{
for (int index = 0; index < 663; ++index)
EmoteBubble.CountNPCs[index] = 0;
for (int index = 0; index < 200; ++index)
{
if (Main.npc[index].active)
++EmoteBubble.CountNPCs[Main.npc[index].type];
}
int type = ((NPC) this.anchor.entity).type;
for (int index = 0; index < 663; ++index)
{
if (NPCID.Sets.FaceEmote[index] > 0 && EmoteBubble.CountNPCs[index] > 0 && index != type)
list.Add(NPCID.Sets.FaceEmote[index]);
}
}
private void ProbeBiomes(List<int> list, Player plr)
{
if ((double) plr.position.Y / 16.0 < Main.worldSurface * 0.45)
list.Add(22);
else if ((double) plr.position.Y / 16.0 > Main.rockLayer + (double) (Main.maxTilesY / 2) - 100.0)
list.Add(31);
else if ((double) plr.position.Y / 16.0 > Main.rockLayer)
list.Add(30);
else if (plr.ZoneHallow)
list.Add(27);
else if (plr.ZoneCorrupt)
list.Add(26);
else if (plr.ZoneCrimson)
list.Add(25);
else if (plr.ZoneJungle)
list.Add(24);
else if (plr.ZoneSnow)
list.Add(32);
else if ((double) plr.position.Y / 16.0 < Main.worldSurface && ((double) plr.position.X < 4000.0 || (double) plr.position.X > (double) (16 * (Main.maxTilesX - 250))))
list.Add(29);
else if (plr.ZoneDesert)
list.Add(28);
else
list.Add(23);
}
private void ProbeCritters(List<int> list)
{
Vector2 center = this.anchor.entity.Center;
float num1 = 1f;
float num2 = 1f;
if ((double) center.Y < Main.rockLayer * 16.0)
num2 = 0.2f;
else
num1 = 0.2f;
if ((double) Main.rand.NextFloat() <= (double) num1)
{
if (Main.dayTime)
{
list.Add(13);
list.Add(12);
list.Add(68);
list.Add(62);
list.Add(63);
list.Add(69);
list.Add(70);
}
if (!Main.dayTime || Main.dayTime && (Main.time < 5400.0 || Main.time > 48600.0))
list.Add(61);
if (NPC.downedGoblins)
list.Add(64);
if (NPC.downedFrost)
list.Add(66);
if (NPC.downedPirates)
list.Add(65);
if (NPC.downedMartians)
list.Add(71);
if (WorldGen.crimson)
list.Add(67);
}
if ((double) Main.rand.NextFloat() > (double) num2)
return;
list.Add(72);
list.Add(69);
}
private void ProbeEmotions(List<int> list)
{
list.Add(0);
list.Add(1);
list.Add(2);
list.Add(3);
list.Add(15);
list.Add(16);
list.Add(17);
list.Add(87);
list.Add(91);
list.Add(136);
list.Add(134);
list.Add(135);
list.Add(137);
list.Add(138);
list.Add(139);
if (!Main.bloodMoon || Main.dayTime)
return;
int num = Utils.SelectRandom<int>(Main.rand, 16, 1, 138);
list.Add(num);
list.Add(num);
list.Add(num);
}
private void ProbeBosses(List<int> list)
{
int num = 0;
if (!NPC.downedBoss1 && !Main.dayTime || NPC.downedBoss1)
num = 1;
if (NPC.downedBoss2)
num = 2;
if (NPC.downedQueenBee || NPC.downedBoss3)
num = 3;
if (Main.hardMode)
num = 4;
if (NPC.downedMechBossAny)
num = 5;
if (NPC.downedPlantBoss)
num = 6;
if (NPC.downedGolemBoss)
num = 7;
if (NPC.downedAncientCultist)
num = 8;
int maxValue = 10;
if (NPC.downedMoonlord)
maxValue = 1;
if (num >= 1 && num <= 2 || num >= 1 && Main.rand.Next(maxValue) == 0)
{
list.Add(39);
if (WorldGen.crimson)
list.Add(41);
else
list.Add(40);
list.Add(51);
}
if (num >= 2 && num <= 3 || num >= 2 && Main.rand.Next(maxValue) == 0)
{
list.Add(43);
list.Add(42);
}
if (num >= 4 && num <= 5 || num >= 4 && Main.rand.Next(maxValue) == 0)
{
list.Add(44);
list.Add(47);
list.Add(45);
list.Add(46);
}
if (num >= 5 && num <= 6 || num >= 5 && Main.rand.Next(maxValue) == 0)
{
if (!NPC.downedMechBoss1)
list.Add(47);
if (!NPC.downedMechBoss2)
list.Add(45);
if (!NPC.downedMechBoss3)
list.Add(46);
list.Add(48);
}
if (num == 6 || num >= 6 && Main.rand.Next(maxValue) == 0)
{
list.Add(48);
list.Add(49);
list.Add(50);
}
if (num == 7 || num >= 7 && Main.rand.Next(maxValue) == 0)
{
list.Add(49);
list.Add(50);
list.Add(52);
}
if (num == 8 || num >= 8 && Main.rand.Next(maxValue) == 0)
{
list.Add(52);
list.Add(53);
}
if (NPC.downedPirates && Main.expertMode)
list.Add(59);
if (NPC.downedMartians)
list.Add(60);
if (NPC.downedChristmasIceQueen)
list.Add(57);
if (NPC.downedChristmasSantank)
list.Add(58);
if (NPC.downedChristmasTree)
list.Add(56);
if (NPC.downedHalloweenKing)
list.Add(55);
if (NPC.downedHalloweenTree)
list.Add(54);
if (NPC.downedEmpressOfLight)
list.Add(143);
if (!NPC.downedQueenSlime)
return;
list.Add(144);
}
private void ProbeExceptions(List<int> list, Player plr, WorldUIAnchor other)
{
NPC entity = (NPC) this.anchor.entity;
if (entity.type == 17)
{
list.Add(80);
list.Add(85);
list.Add(85);
list.Add(85);
list.Add(85);
}
else if (entity.type == 18)
{
list.Add(73);
list.Add(73);
list.Add(84);
list.Add(75);
}
else if (entity.type == 19)
{
if (other != null && ((NPC) other.entity).type == 22)
{
list.Add(1);
list.Add(1);
list.Add(93);
list.Add(92);
}
else if (other != null && ((NPC) other.entity).type == 22)
{
list.Add(1);
list.Add(1);
list.Add(93);
list.Add(92);
}
else
{
list.Add(82);
list.Add(82);
list.Add(85);
list.Add(85);
list.Add(77);
list.Add(93);
}
}
else if (entity.type == 20)
{
if (list.Contains(121))
{
list.Add(121);
list.Add(121);
}
list.Add(14);
list.Add(14);
}
else if (entity.type == 22)
{
if (!Main.bloodMoon)
{
if (other != null && ((NPC) other.entity).type == 19)
{
list.Add(1);
list.Add(1);
list.Add(93);
list.Add(92);
}
else
list.Add(79);
}
if (!Main.dayTime)
{
list.Add(16);
list.Add(16);
list.Add(16);
}
}
else if (entity.type == 37)
{
list.Add(43);
list.Add(43);
list.Add(43);
list.Add(72);
list.Add(72);
}
else if (entity.type == 38)
{
if (Main.bloodMoon)
{
list.Add(77);
list.Add(77);
list.Add(77);
list.Add(81);
}
else
{
list.Add(77);
list.Add(77);
list.Add(81);
list.Add(81);
list.Add(81);
list.Add(90);
list.Add(90);
}
}
else if (entity.type == 54)
{
if (Main.bloodMoon)
{
list.Add(43);
list.Add(72);
list.Add(1);
}
else
{
if (list.Contains(111))
list.Add(111);
list.Add(17);
}
}
else if (entity.type == 107)
{
if (other != null && ((NPC) other.entity).type == 124)
{
list.Remove(111);
list.Add(0);
list.Add(0);
list.Add(0);
list.Add(17);
list.Add(17);
list.Add(86);
list.Add(88);
list.Add(88);
}
else
{
if (list.Contains(111))
{
list.Add(111);
list.Add(111);
list.Add(111);
}
list.Add(91);
list.Add(92);
list.Add(91);
list.Add(92);
}
}
else if (entity.type == 108)
{
list.Add(100);
list.Add(89);
list.Add(11);
}
if (entity.type == 124)
{
if (other != null && ((NPC) other.entity).type == 107)
{
list.Remove(111);
list.Add(0);
list.Add(0);
list.Add(0);
list.Add(17);
list.Add(17);
list.Add(88);
list.Add(88);
}
else
{
if (list.Contains(109))
{
list.Add(109);
list.Add(109);
list.Add(109);
}
if (list.Contains(108))
{
list.Remove(108);
if (Main.hardMode)
{
list.Add(108);
list.Add(108);
}
else
{
list.Add(106);
list.Add(106);
}
}
list.Add(43);
list.Add(2);
}
}
else if (entity.type == 142)
{
list.Add(32);
list.Add(66);
list.Add(17);
list.Add(15);
list.Add(15);
}
else if (entity.type == 160)
{
list.Add(10);
list.Add(89);
list.Add(94);
list.Add(8);
}
else if (entity.type == 178)
{
list.Add(83);
list.Add(83);
}
else if (entity.type == 207)
{
list.Add(28);
list.Add(95);
list.Add(93);
}
else if (entity.type == 208)
{
list.Add(94);
list.Add(17);
list.Add(3);
list.Add(77);
}
else if (entity.type == 209)
{
list.Add(48);
list.Add(83);
list.Add(5);
list.Add(5);
}
else if (entity.type == 227)
{
list.Add(63);
list.Add(68);
}
else if (entity.type == 228)
{
list.Add(24);
list.Add(24);
list.Add(95);
list.Add(8);
}
else if (entity.type == 229)
{
list.Add(93);
list.Add(9);
list.Add(65);
list.Add(120);
list.Add(59);
}
else if (entity.type == 353)
{
if (list.Contains(104))
{
list.Add(104);
list.Add(104);
}
if (list.Contains(111))
{
list.Add(111);
list.Add(111);
}
list.Add(67);
}
else if (entity.type == 368)
{
list.Add(85);
list.Add(7);
list.Add(79);
}
else if (entity.type == 369)
{
if (Main.bloodMoon)
return;
list.Add(70);
list.Add(70);
list.Add(76);
list.Add(76);
list.Add(79);
list.Add(79);
if ((double) entity.position.Y >= Main.worldSurface)
return;
list.Add(29);
}
else if (entity.type == 453)
{
list.Add(72);
list.Add(69);
list.Add(87);
list.Add(3);
}
else
{
if (entity.type != 441)
return;
list.Add(100);
list.Add(100);
list.Add(1);
list.Add(1);
list.Add(1);
list.Add(87);
}
}
}
}

162
GameContent/UI/EmoteID.cs Normal file
View file

@ -0,0 +1,162 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.EmoteID
// 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.Reflection;
namespace Terraria.GameContent.UI
{
public class EmoteID
{
public const int ItemDisplay = -1;
public const int Count = 145;
public const int RPSWinScissors = 33;
public const int RPSWinRock = 34;
public const int RPSWinPaper = 35;
public const int RPSScissors = 36;
public const int RPSRock = 37;
public const int RPSPaper = 38;
public const int WeatherRain = 4;
public const int WeatherLightning = 5;
public const int WeatherRainbow = 6;
public const int WeatherSunny = 95;
public const int WeatherCloudy = 96;
public const int WeatherStorming = 97;
public const int WeatherSnowstorm = 98;
public const int EventBloodmoon = 18;
public const int EventEclipse = 19;
public const int EventPumpkin = 20;
public const int EventSnow = 21;
public const int EventMeteor = 99;
public const int ItemRing = 7;
public const int ItemLifePotion = 73;
public const int ItemManaPotion = 74;
public const int ItemSoup = 75;
public const int ItemCookedFish = 76;
public const int ItemAle = 77;
public const int ItemSword = 78;
public const int ItemFishingRod = 79;
public const int ItemBugNet = 80;
public const int ItemDynamite = 81;
public const int ItemMinishark = 82;
public const int ItemCog = 83;
public const int ItemTombstone = 84;
public const int ItemGoldpile = 85;
public const int ItemDiamondRing = 86;
public const int ItemPickaxe = 90;
public const int DebuffPoison = 8;
public const int DebuffBurn = 9;
public const int DebuffSilence = 10;
public const int DebuffCurse = 11;
public const int CritterBee = 12;
public const int CritterSlime = 13;
public const int CritterZombie = 61;
public const int CritterBunny = 62;
public const int CritterButterfly = 63;
public const int CritterGoblin = 64;
public const int CritterPirate = 65;
public const int CritterSnowman = 66;
public const int CritterSpider = 67;
public const int CritterBird = 68;
public const int CritterMouse = 69;
public const int CritterGoldfish = 70;
public const int CritterMartian = 71;
public const int CritterSkeleton = 72;
public const int BossEoC = 39;
public const int BossEoW = 40;
public const int BossBoC = 41;
public const int BossKingSlime = 51;
public const int BossQueenBee = 42;
public const int BossSkeletron = 43;
public const int BossWoF = 44;
public const int BossDestroyer = 45;
public const int BossSkeletronPrime = 46;
public const int BossTwins = 47;
public const int BossPlantera = 48;
public const int BossGolem = 49;
public const int BossFishron = 50;
public const int BossCultist = 52;
public const int BossMoonmoon = 53;
public const int BossMourningWood = 54;
public const int BossPumpking = 55;
public const int BossEverscream = 56;
public const int BossIceQueen = 57;
public const int BossSantank = 58;
public const int BossPirateship = 59;
public const int BossMartianship = 60;
public const int BossEmpressOfLight = 143;
public const int BossQueenSlime = 144;
public const int EmotionLove = 0;
public const int EmotionAnger = 1;
public const int EmotionCry = 2;
public const int EmotionAlert = 3;
public const int EmoteLaugh = 15;
public const int EmoteFear = 16;
public const int EmoteNote = 17;
public const int EmoteConfused = 87;
public const int EmoteKiss = 88;
public const int EmoteSleep = 89;
public const int EmoteRun = 91;
public const int EmoteKick = 92;
public const int EmoteFight = 93;
public const int EmoteEating = 94;
public const int EmoteSadness = 134;
public const int EmoteAnger = 135;
public const int EmoteHappiness = 136;
public const int EmoteWink = 137;
public const int EmoteScowl = 138;
public const int EmoteSilly = 139;
public const int MiscTree = 14;
public const int MiscFire = 100;
public const int BiomeSky = 22;
public const int BiomeOtherworld = 23;
public const int BiomeJungle = 24;
public const int BiomeCrimson = 25;
public const int BiomeCorruption = 26;
public const int BiomeHallow = 27;
public const int BiomeDesert = 28;
public const int BiomeBeach = 29;
public const int BiomeRocklayer = 30;
public const int BiomeLavalayer = 31;
public const int BiomeSnow = 32;
public const int TownMerchant = 101;
public const int TownNurse = 102;
public const int TownArmsDealer = 103;
public const int TownDryad = 104;
public const int TownGuide = 105;
public const int TownOldman = 106;
public const int TownDemolitionist = 107;
public const int TownClothier = 108;
public const int TownGoblinTinkerer = 109;
public const int TownWizard = 110;
public const int TownMechanic = 111;
public const int TownSanta = 112;
public const int TownTruffle = 113;
public const int TownSteampunker = 114;
public const int TownDyeTrader = 115;
public const int TownPartyGirl = 116;
public const int TownCyborg = 117;
public const int TownPainter = 118;
public const int TownWitchDoctor = 119;
public const int TownPirate = 120;
public const int TownStylist = 121;
public const int TownTravellingMerchant = 122;
public const int TownAngler = 123;
public const int TownSkeletonMerchant = 124;
public const int TownTaxCollector = 125;
public const int TownGolfer = 140;
public const int TownBestiaryGirl = 141;
public const int TownBestiaryGirlFox = 142;
public const int PartyPresent = 126;
public const int PartyBalloons = 127;
public const int PartyCake = 128;
public const int PartyHats = 129;
public const int TownBartender = 130;
public const int ItemBeer = 131;
public const int ItemDefenderMedal = 132;
public const int EventOldOnesArmy = 133;
public static readonly IdDictionary Search = IdDictionary.Create<EmoteID, int>();
}
}

View file

@ -0,0 +1,297 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.FancyClassicPlayerResourcesDisplaySet
// 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 ReLogic.Graphics;
namespace Terraria.GameContent.UI
{
public class FancyClassicPlayerResourcesDisplaySet : IPlayerResourcesDisplaySet
{
private float _currentPlayerLife;
private float _lifePerHeart;
private int _playerLifeFruitCount;
private int _lastHeartFillingIndex;
private int _lastHeartPanelIndex;
private int _heartCountRow1;
private int _heartCountRow2;
private int _starCount;
private int _lastStarFillingIndex;
private float _manaPerStar;
private float _currentPlayerMana;
private Asset<Texture2D> _heartLeft;
private Asset<Texture2D> _heartMiddle;
private Asset<Texture2D> _heartRight;
private Asset<Texture2D> _heartRightFancy;
private Asset<Texture2D> _heartFill;
private Asset<Texture2D> _heartFillHoney;
private Asset<Texture2D> _heartSingleFancy;
private Asset<Texture2D> _starTop;
private Asset<Texture2D> _starMiddle;
private Asset<Texture2D> _starBottom;
private Asset<Texture2D> _starSingle;
private Asset<Texture2D> _starFill;
private bool _hoverLife;
private bool _hoverMana;
public FancyClassicPlayerResourcesDisplaySet(string name, AssetRequestMode mode)
{
string str = "Images\\UI\\PlayerResourceSets\\" + name;
this._heartLeft = Main.Assets.Request<Texture2D>(str + "\\Heart_Left", mode);
this._heartMiddle = Main.Assets.Request<Texture2D>(str + "\\Heart_Middle", mode);
this._heartRight = Main.Assets.Request<Texture2D>(str + "\\Heart_Right", mode);
this._heartRightFancy = Main.Assets.Request<Texture2D>(str + "\\Heart_Right_Fancy", mode);
this._heartFill = Main.Assets.Request<Texture2D>(str + "\\Heart_Fill", mode);
this._heartFillHoney = Main.Assets.Request<Texture2D>(str + "\\Heart_Fill_B", mode);
this._heartSingleFancy = Main.Assets.Request<Texture2D>(str + "\\Heart_Single_Fancy", mode);
this._starTop = Main.Assets.Request<Texture2D>(str + "\\Star_A", mode);
this._starMiddle = Main.Assets.Request<Texture2D>(str + "\\Star_B", mode);
this._starBottom = Main.Assets.Request<Texture2D>(str + "\\Star_C", mode);
this._starSingle = Main.Assets.Request<Texture2D>(str + "\\Star_Single", mode);
this._starFill = Main.Assets.Request<Texture2D>(str + "\\Star_Fill", mode);
}
public void Draw()
{
Player localPlayer = Main.LocalPlayer;
SpriteBatch spriteBatch = Main.spriteBatch;
this.PrepareFields(localPlayer);
this.DrawLifeBar(spriteBatch);
this.DrawManaBar(spriteBatch);
}
private void DrawLifeBar(SpriteBatch spriteBatch)
{
Vector2 vector2 = new Vector2((float) (Main.screenWidth - 300 + 4), 15f);
bool isHovered = false;
new ResourceDrawSettings()
{
ElementCount = this._heartCountRow1,
ElementIndexOffset = 0,
TopLeftAnchor = vector2,
GetTextureMethod = new ResourceDrawSettings.TextureGetter(this.HeartPanelDrawer),
OffsetPerDraw = Vector2.Zero,
OffsetPerDrawByTexturePercentile = Vector2.UnitX,
OffsetSpriteAnchor = Vector2.Zero,
OffsetSpriteAnchorByTexturePercentile = Vector2.Zero
}.Draw(spriteBatch, ref isHovered);
new ResourceDrawSettings()
{
ElementCount = this._heartCountRow2,
ElementIndexOffset = 10,
TopLeftAnchor = (vector2 + new Vector2(0.0f, 28f)),
GetTextureMethod = new ResourceDrawSettings.TextureGetter(this.HeartPanelDrawer),
OffsetPerDraw = Vector2.Zero,
OffsetPerDrawByTexturePercentile = Vector2.UnitX,
OffsetSpriteAnchor = Vector2.Zero,
OffsetSpriteAnchorByTexturePercentile = Vector2.Zero
}.Draw(spriteBatch, ref isHovered);
new ResourceDrawSettings()
{
ElementCount = this._heartCountRow1,
ElementIndexOffset = 0,
TopLeftAnchor = (vector2 + new Vector2(15f, 15f)),
GetTextureMethod = new ResourceDrawSettings.TextureGetter(this.HeartFillingDrawer),
OffsetPerDraw = (Vector2.UnitX * 2f),
OffsetPerDrawByTexturePercentile = Vector2.UnitX,
OffsetSpriteAnchor = Vector2.Zero,
OffsetSpriteAnchorByTexturePercentile = new Vector2(0.5f, 0.5f)
}.Draw(spriteBatch, ref isHovered);
new ResourceDrawSettings()
{
ElementCount = this._heartCountRow2,
ElementIndexOffset = 10,
TopLeftAnchor = (vector2 + new Vector2(15f, 15f) + new Vector2(0.0f, 28f)),
GetTextureMethod = new ResourceDrawSettings.TextureGetter(this.HeartFillingDrawer),
OffsetPerDraw = (Vector2.UnitX * 2f),
OffsetPerDrawByTexturePercentile = Vector2.UnitX,
OffsetSpriteAnchor = Vector2.Zero,
OffsetSpriteAnchorByTexturePercentile = new Vector2(0.5f, 0.5f)
}.Draw(spriteBatch, ref isHovered);
this._hoverLife = isHovered;
}
private static void DrawLifeBarText(SpriteBatch spriteBatch, Vector2 topLeftAnchor)
{
Vector2 vector2_1 = topLeftAnchor + new Vector2(130f, -24f);
Player localPlayer = Main.LocalPlayer;
Color color = new Color((int) Main.mouseTextColor, (int) Main.mouseTextColor, (int) Main.mouseTextColor, (int) Main.mouseTextColor);
string str = Lang.inter[0].Value + " " + (object) localPlayer.statLifeMax2 + "/" + (object) localPlayer.statLifeMax2;
Vector2 vector2_2 = FontAssets.MouseText.Value.MeasureString(str);
DynamicSpriteFontExtensionMethods.DrawString(spriteBatch, FontAssets.MouseText.Value, Lang.inter[0].Value, vector2_1 + new Vector2((float) (-(double) vector2_2.X * 0.5), 0.0f), color, 0.0f, new Vector2(), 1f, SpriteEffects.None, 0.0f);
DynamicSpriteFontExtensionMethods.DrawString(spriteBatch, FontAssets.MouseText.Value, localPlayer.statLife.ToString() + "/" + (object) localPlayer.statLifeMax2, vector2_1 + new Vector2(vector2_2.X * 0.5f, 0.0f), color, 0.0f, new Vector2(FontAssets.MouseText.Value.MeasureString(localPlayer.statLife.ToString() + "/" + (object) localPlayer.statLifeMax2).X, 0.0f), 1f, SpriteEffects.None, 0.0f);
}
private void DrawManaBar(SpriteBatch spriteBatch)
{
Vector2 vector2 = new Vector2((float) (Main.screenWidth - 40), 22f);
int starCount = this._starCount;
bool isHovered = false;
new ResourceDrawSettings()
{
ElementCount = this._starCount,
ElementIndexOffset = 0,
TopLeftAnchor = vector2,
GetTextureMethod = new ResourceDrawSettings.TextureGetter(this.StarPanelDrawer),
OffsetPerDraw = Vector2.Zero,
OffsetPerDrawByTexturePercentile = Vector2.UnitY,
OffsetSpriteAnchor = Vector2.Zero,
OffsetSpriteAnchorByTexturePercentile = Vector2.Zero
}.Draw(spriteBatch, ref isHovered);
new ResourceDrawSettings()
{
ElementCount = this._starCount,
ElementIndexOffset = 0,
TopLeftAnchor = (vector2 + new Vector2(15f, 16f)),
GetTextureMethod = new ResourceDrawSettings.TextureGetter(this.StarFillingDrawer),
OffsetPerDraw = (Vector2.UnitY * -2f),
OffsetPerDrawByTexturePercentile = Vector2.UnitY,
OffsetSpriteAnchor = Vector2.Zero,
OffsetSpriteAnchorByTexturePercentile = new Vector2(0.5f, 0.5f)
}.Draw(spriteBatch, ref isHovered);
this._hoverMana = isHovered;
}
private static void DrawManaText(SpriteBatch spriteBatch)
{
Vector2 vector2 = FontAssets.MouseText.Value.MeasureString(Lang.inter[2].Value);
Color color = new Color((int) Main.mouseTextColor, (int) Main.mouseTextColor, (int) Main.mouseTextColor, (int) Main.mouseTextColor);
int num = 50;
if ((double) vector2.X >= 45.0)
num = (int) vector2.X + 5;
DynamicSpriteFontExtensionMethods.DrawString(spriteBatch, FontAssets.MouseText.Value, Lang.inter[2].Value, new Vector2((float) (Main.screenWidth - num), 6f), color, 0.0f, new Vector2(), 1f, SpriteEffects.None, 0.0f);
}
private void HeartPanelDrawer(
int elementIndex,
int firstElementIndex,
int lastElementIndex,
out Asset<Texture2D> sprite,
out Vector2 offset,
out float drawScale,
out Rectangle? sourceRect)
{
sourceRect = new Rectangle?();
offset = Vector2.Zero;
sprite = this._heartLeft;
drawScale = 1f;
if (elementIndex == lastElementIndex && elementIndex == firstElementIndex)
{
sprite = this._heartSingleFancy;
offset = new Vector2(-4f, -4f);
}
else if (elementIndex == lastElementIndex && lastElementIndex == this._lastHeartPanelIndex)
{
sprite = this._heartRightFancy;
offset = new Vector2(-8f, -4f);
}
else if (elementIndex == lastElementIndex)
{
sprite = this._heartRight;
}
else
{
if (elementIndex == firstElementIndex)
return;
sprite = this._heartMiddle;
}
}
private void HeartFillingDrawer(
int elementIndex,
int firstElementIndex,
int lastElementIndex,
out Asset<Texture2D> sprite,
out Vector2 offset,
out float drawScale,
out Rectangle? sourceRect)
{
sourceRect = new Rectangle?();
offset = Vector2.Zero;
sprite = this._heartLeft;
sprite = elementIndex >= this._playerLifeFruitCount ? this._heartFill : this._heartFillHoney;
float lerpValue = Utils.GetLerpValue(this._lifePerHeart * (float) elementIndex, this._lifePerHeart * (float) (elementIndex + 1), this._currentPlayerLife, true);
drawScale = lerpValue;
if (elementIndex != this._lastHeartFillingIndex || (double) lerpValue <= 0.0)
return;
drawScale += Main.cursorScale - 1f;
}
private void StarPanelDrawer(
int elementIndex,
int firstElementIndex,
int lastElementIndex,
out Asset<Texture2D> sprite,
out Vector2 offset,
out float drawScale,
out Rectangle? sourceRect)
{
sourceRect = new Rectangle?();
offset = Vector2.Zero;
sprite = this._starTop;
drawScale = 1f;
if (elementIndex == lastElementIndex && elementIndex == firstElementIndex)
sprite = this._starSingle;
else if (elementIndex == lastElementIndex)
{
sprite = this._starBottom;
offset = new Vector2(0.0f, 0.0f);
}
else
{
if (elementIndex == firstElementIndex)
return;
sprite = this._starMiddle;
}
}
private void StarFillingDrawer(
int elementIndex,
int firstElementIndex,
int lastElementIndex,
out Asset<Texture2D> sprite,
out Vector2 offset,
out float drawScale,
out Rectangle? sourceRect)
{
sourceRect = new Rectangle?();
offset = Vector2.Zero;
sprite = this._starFill;
float lerpValue = Utils.GetLerpValue(this._manaPerStar * (float) elementIndex, this._manaPerStar * (float) (elementIndex + 1), this._currentPlayerMana, true);
drawScale = lerpValue;
if (elementIndex != this._lastStarFillingIndex || (double) lerpValue <= 0.0)
return;
drawScale += Main.cursorScale - 1f;
}
private void PrepareFields(Player player)
{
PlayerStatsSnapshot playerStatsSnapshot = new PlayerStatsSnapshot(player);
this._playerLifeFruitCount = playerStatsSnapshot.LifeFruitCount;
this._lifePerHeart = playerStatsSnapshot.LifePerSegment;
this._currentPlayerLife = (float) playerStatsSnapshot.Life;
this._manaPerStar = playerStatsSnapshot.ManaPerSegment;
this._heartCountRow1 = Utils.Clamp<int>((int) ((double) playerStatsSnapshot.LifeMax / (double) this._lifePerHeart), 0, 10);
this._heartCountRow2 = Utils.Clamp<int>((int) ((double) (playerStatsSnapshot.LifeMax - 200) / (double) this._lifePerHeart), 0, 10);
this._lastHeartFillingIndex = (int) ((double) playerStatsSnapshot.Life / (double) this._lifePerHeart);
this._lastHeartPanelIndex = this._heartCountRow1 + this._heartCountRow2 - 1;
this._starCount = (int) ((double) playerStatsSnapshot.ManaMax / (double) this._manaPerStar);
this._currentPlayerMana = (float) playerStatsSnapshot.Mana;
this._lastStarFillingIndex = (int) ((double) this._currentPlayerMana / (double) this._manaPerStar);
}
public void TryToHover()
{
if (this._hoverLife)
CommonResourceBarMethods.DrawLifeMouseOver();
if (!this._hoverMana)
return;
CommonResourceBarMethods.DrawManaMouseOver();
}
}
}

View file

@ -0,0 +1,157 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.GameTipsDisplay
// 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;
using Terraria.Localization;
using Terraria.UI.Chat;
namespace Terraria.GameContent.UI
{
public class GameTipsDisplay
{
private LocalizedText[] _tipsDefault;
private LocalizedText[] _tipsGamepad;
private LocalizedText[] _tipsKeyboard;
private readonly List<GameTipsDisplay.GameTip> _currentTips = new List<GameTipsDisplay.GameTip>();
private LocalizedText _lastTip;
public GameTipsDisplay()
{
this._tipsDefault = Language.FindAll(Lang.CreateDialogFilter("LoadingTips_Default."));
this._tipsGamepad = Language.FindAll(Lang.CreateDialogFilter("LoadingTips_GamePad."));
this._tipsKeyboard = Language.FindAll(Lang.CreateDialogFilter("LoadingTips_Keyboard."));
this._lastTip = (LocalizedText) null;
}
public void Update()
{
double time = Main.gameTimeCache.TotalGameTime.TotalSeconds;
this._currentTips.RemoveAll((Predicate<GameTipsDisplay.GameTip>) (x => x.IsExpired(time)));
bool flag = true;
foreach (GameTipsDisplay.GameTip currentTip in this._currentTips)
{
if (!currentTip.IsExpiring(time))
{
flag = false;
break;
}
}
if (flag)
this.AddNewTip(time);
foreach (GameTipsDisplay.GameTip currentTip in this._currentTips)
currentTip.Update(time);
}
public void ClearTips() => this._currentTips.Clear();
public void Draw()
{
SpriteBatch spriteBatch = Main.spriteBatch;
float screenWidth = (float) Main.screenWidth;
float y = (float) (Main.screenHeight - 150);
float num1 = (float) Main.screenWidth * 0.5f;
foreach (GameTipsDisplay.GameTip currentTip in this._currentTips)
{
if ((double) currentTip.ScreenAnchorX >= -0.5 && (double) currentTip.ScreenAnchorX <= 1.5)
{
DynamicSpriteFont font = FontAssets.MouseText.Value;
string text = font.CreateWrappedText(currentTip.Text, num1, Language.ActiveCulture.CultureInfo);
if (text.Split('\n').Length > 2)
text = font.CreateWrappedText(currentTip.Text, (float) ((double) num1 * 1.5 - 50.0), Language.ActiveCulture.CultureInfo);
if (WorldGen.drunkWorldGenText)
{
text = string.Concat((object) Main.rand.Next(999999999));
for (int index = 0; index < 14; ++index)
{
if (Main.rand.Next(2) == 0)
text += (string) (object) Main.rand.Next(999999999);
}
}
if (WorldGen.getGoodWorldGen)
{
string str = "";
for (int startIndex = text.Length - 1; startIndex >= 0; --startIndex)
str += text.Substring(startIndex, 1);
text = str;
}
Vector2 vector2 = font.MeasureString(text);
float num2 = 1.1f;
float num3 = 110f;
if ((double) vector2.Y > (double) num3)
num2 = num3 / vector2.Y;
Vector2 position = new Vector2(screenWidth * currentTip.ScreenAnchorX, y);
position -= vector2 * num2 * 0.5f;
ChatManager.DrawColorCodedStringWithShadow(spriteBatch, font, text, position, Color.White, 0.0f, Vector2.Zero, new Vector2(num2, num2));
}
}
}
private void AddNewTip(double currentTime)
{
string textKey = "UI.Back";
List<LocalizedText> localizedTextList = new List<LocalizedText>();
localizedTextList.AddRange((IEnumerable<LocalizedText>) this._tipsDefault);
if (PlayerInput.UsingGamepad)
localizedTextList.AddRange((IEnumerable<LocalizedText>) this._tipsGamepad);
else
localizedTextList.AddRange((IEnumerable<LocalizedText>) this._tipsKeyboard);
if (this._lastTip != null)
localizedTextList.Remove(this._lastTip);
LocalizedText localizedText = localizedTextList.Count != 0 ? localizedTextList[Main.rand.Next(localizedTextList.Count)] : LocalizedText.Empty;
this._lastTip = localizedText;
string key = localizedText.Key;
if (Language.Exists(key))
textKey = key;
this._currentTips.Add(new GameTipsDisplay.GameTip(textKey, currentTime));
}
private class GameTip
{
private const float APPEAR_FROM = 2.5f;
private const float APPEAR_TO = 0.5f;
private const float DISAPPEAR_TO = -1.5f;
private const float APPEAR_TIME = 0.5f;
private const float DISAPPEAR_TIME = 1f;
private const float DURATION = 16.5f;
private LocalizedText _textKey;
private string _formattedText;
public float ScreenAnchorX;
public readonly float Duration;
public readonly double SpawnTime;
public string Text => this._textKey == null ? "What?!" : this._formattedText;
public bool IsExpired(double currentTime) => currentTime >= this.SpawnTime + (double) this.Duration;
public bool IsExpiring(double currentTime) => currentTime >= this.SpawnTime + (double) this.Duration - 1.0;
public GameTip(string textKey, double spawnTime)
{
this._textKey = Language.GetText(textKey);
this.SpawnTime = spawnTime;
this.ScreenAnchorX = 2.5f;
this.Duration = 16.5f;
this._formattedText = this._textKey.FormatWith(Lang.CreateDialogSubstitutionObject());
}
public void Update(double currentTime)
{
double t = currentTime - this.SpawnTime;
if (t < 0.5)
this.ScreenAnchorX = MathHelper.SmoothStep(2.5f, 0.5f, (float) Utils.GetLerpValue(0.0, 0.5, t, true));
else if (t >= (double) this.Duration - 1.0)
this.ScreenAnchorX = MathHelper.SmoothStep(0.5f, -1.5f, (float) Utils.GetLerpValue((double) this.Duration - 1.0, (double) this.Duration, t, true));
else
this.ScreenAnchorX = 0.5f;
}
}
}
}

View file

@ -0,0 +1,256 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.HorizontalBarsPlayerReosurcesDisplaySet
// 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 ReLogic.Graphics;
namespace Terraria.GameContent.UI
{
public class HorizontalBarsPlayerReosurcesDisplaySet : IPlayerResourcesDisplaySet
{
private int _maxSegmentCount;
private int _hpSegmentsCount;
private int _mpSegmentsCount;
private int _hpFruitCount;
private float _hpPercent;
private float _mpPercent;
private bool _hpHovered;
private bool _mpHovered;
private Asset<Texture2D> _hpFill;
private Asset<Texture2D> _hpFillHoney;
private Asset<Texture2D> _mpFill;
private Asset<Texture2D> _panelLeft;
private Asset<Texture2D> _panelMiddleHP;
private Asset<Texture2D> _panelRightHP;
private Asset<Texture2D> _panelMiddleMP;
private Asset<Texture2D> _panelRightMP;
public HorizontalBarsPlayerReosurcesDisplaySet(string name, AssetRequestMode mode)
{
string str = "Images\\UI\\PlayerResourceSets\\" + name;
this._hpFill = Main.Assets.Request<Texture2D>(str + "\\HP_Fill", mode);
this._hpFillHoney = Main.Assets.Request<Texture2D>(str + "\\HP_Fill_Honey", mode);
this._mpFill = Main.Assets.Request<Texture2D>(str + "\\MP_Fill", mode);
this._panelLeft = Main.Assets.Request<Texture2D>(str + "\\Panel_Left", mode);
this._panelMiddleHP = Main.Assets.Request<Texture2D>(str + "\\HP_Panel_Middle", mode);
this._panelRightHP = Main.Assets.Request<Texture2D>(str + "\\HP_Panel_Right", mode);
this._panelMiddleMP = Main.Assets.Request<Texture2D>(str + "\\MP_Panel_Middle", mode);
this._panelRightMP = Main.Assets.Request<Texture2D>(str + "\\MP_Panel_Right", mode);
}
public void Draw()
{
this.PrepareFields(Main.LocalPlayer);
SpriteBatch spriteBatch = Main.spriteBatch;
int num1 = 16;
int num2 = 18;
int num3 = Main.screenWidth - 300 - 22 + num1;
Vector2 vector2_1 = new Vector2((float) num3, (float) num2);
vector2_1.X += (float) ((this._maxSegmentCount - this._hpSegmentsCount) * this._panelMiddleHP.Width());
bool isHovered1 = false;
new ResourceDrawSettings()
{
ElementCount = (this._hpSegmentsCount + 2),
ElementIndexOffset = 0,
TopLeftAnchor = vector2_1,
GetTextureMethod = new ResourceDrawSettings.TextureGetter(this.LifePanelDrawer),
OffsetPerDraw = Vector2.Zero,
OffsetPerDrawByTexturePercentile = Vector2.UnitX,
OffsetSpriteAnchor = Vector2.Zero,
OffsetSpriteAnchorByTexturePercentile = Vector2.Zero
}.Draw(spriteBatch, ref isHovered1);
new ResourceDrawSettings()
{
ElementCount = this._hpSegmentsCount,
ElementIndexOffset = 0,
TopLeftAnchor = (vector2_1 + new Vector2(6f, 6f)),
GetTextureMethod = new ResourceDrawSettings.TextureGetter(this.LifeFillingDrawer),
OffsetPerDraw = new Vector2((float) this._hpFill.Width(), 0.0f),
OffsetPerDrawByTexturePercentile = Vector2.Zero,
OffsetSpriteAnchor = Vector2.Zero,
OffsetSpriteAnchorByTexturePercentile = Vector2.Zero
}.Draw(spriteBatch, ref isHovered1);
this._hpHovered = isHovered1;
bool isHovered2 = false;
Vector2 vector2_2 = new Vector2((float) (num3 - 10), (float) (num2 + 24));
vector2_2.X += (float) ((this._maxSegmentCount - this._mpSegmentsCount) * this._panelMiddleMP.Width());
new ResourceDrawSettings()
{
ElementCount = (this._mpSegmentsCount + 2),
ElementIndexOffset = 0,
TopLeftAnchor = vector2_2,
GetTextureMethod = new ResourceDrawSettings.TextureGetter(this.ManaPanelDrawer),
OffsetPerDraw = Vector2.Zero,
OffsetPerDrawByTexturePercentile = Vector2.UnitX,
OffsetSpriteAnchor = Vector2.Zero,
OffsetSpriteAnchorByTexturePercentile = Vector2.Zero
}.Draw(spriteBatch, ref isHovered2);
new ResourceDrawSettings()
{
ElementCount = this._mpSegmentsCount,
ElementIndexOffset = 0,
TopLeftAnchor = (vector2_2 + new Vector2(6f, 6f)),
GetTextureMethod = new ResourceDrawSettings.TextureGetter(this.ManaFillingDrawer),
OffsetPerDraw = new Vector2((float) this._mpFill.Width(), 0.0f),
OffsetPerDrawByTexturePercentile = Vector2.Zero,
OffsetSpriteAnchor = Vector2.Zero,
OffsetSpriteAnchorByTexturePercentile = Vector2.Zero
}.Draw(spriteBatch, ref isHovered2);
this._mpHovered = isHovered2;
}
private static void DrawManaText(SpriteBatch spriteBatch)
{
Color color = new Color((int) Main.mouseTextColor, (int) Main.mouseTextColor, (int) Main.mouseTextColor, (int) Main.mouseTextColor);
int num = 180;
Player localPlayer = Main.LocalPlayer;
string str1 = Lang.inter[2].Value + ":";
string str2 = localPlayer.statMana.ToString() + "/" + (object) localPlayer.statManaMax2;
Vector2 vector2_1 = new Vector2((float) (Main.screenWidth - num), 65f);
string str3 = str1 + " " + str2;
Vector2 vector2_2 = FontAssets.MouseText.Value.MeasureString(str3);
DynamicSpriteFontExtensionMethods.DrawString(spriteBatch, FontAssets.MouseText.Value, str1, vector2_1 + new Vector2((float) (-(double) vector2_2.X * 0.5), 0.0f), color, 0.0f, new Vector2(), 1f, SpriteEffects.None, 0.0f);
DynamicSpriteFontExtensionMethods.DrawString(spriteBatch, FontAssets.MouseText.Value, str2, vector2_1 + new Vector2(vector2_2.X * 0.5f, 0.0f), color, 0.0f, new Vector2(FontAssets.MouseText.Value.MeasureString(str2).X, 0.0f), 1f, SpriteEffects.None, 0.0f);
}
private static void DrawLifeBarText(SpriteBatch spriteBatch, Vector2 topLeftAnchor)
{
Vector2 vector2_1 = topLeftAnchor + new Vector2(130f, -20f);
Player localPlayer = Main.LocalPlayer;
Color color = new Color((int) Main.mouseTextColor, (int) Main.mouseTextColor, (int) Main.mouseTextColor, (int) Main.mouseTextColor);
string str = Lang.inter[0].Value + " " + (object) localPlayer.statLifeMax2 + "/" + (object) localPlayer.statLifeMax2;
Vector2 vector2_2 = FontAssets.MouseText.Value.MeasureString(str);
DynamicSpriteFontExtensionMethods.DrawString(spriteBatch, FontAssets.MouseText.Value, Lang.inter[0].Value, vector2_1 + new Vector2((float) (-(double) vector2_2.X * 0.5), 0.0f), color, 0.0f, new Vector2(), 1f, SpriteEffects.None, 0.0f);
DynamicSpriteFontExtensionMethods.DrawString(spriteBatch, FontAssets.MouseText.Value, localPlayer.statLife.ToString() + "/" + (object) localPlayer.statLifeMax2, vector2_1 + new Vector2(vector2_2.X * 0.5f, 0.0f), color, 0.0f, new Vector2(FontAssets.MouseText.Value.MeasureString(localPlayer.statLife.ToString() + "/" + (object) localPlayer.statLifeMax2).X, 0.0f), 1f, SpriteEffects.None, 0.0f);
}
private void PrepareFields(Player player)
{
PlayerStatsSnapshot playerStatsSnapshot = new PlayerStatsSnapshot(player);
this._hpSegmentsCount = (int) ((double) playerStatsSnapshot.LifeMax / (double) playerStatsSnapshot.LifePerSegment);
this._mpSegmentsCount = (int) ((double) playerStatsSnapshot.ManaMax / (double) playerStatsSnapshot.ManaPerSegment);
this._maxSegmentCount = 20;
this._hpFruitCount = playerStatsSnapshot.LifeFruitCount;
this._hpPercent = (float) playerStatsSnapshot.Life / (float) playerStatsSnapshot.LifeMax;
this._mpPercent = (float) playerStatsSnapshot.Mana / (float) playerStatsSnapshot.ManaMax;
}
private void LifePanelDrawer(
int elementIndex,
int firstElementIndex,
int lastElementIndex,
out Asset<Texture2D> sprite,
out Vector2 offset,
out float drawScale,
out Rectangle? sourceRect)
{
sourceRect = new Rectangle?();
offset = Vector2.Zero;
sprite = this._panelLeft;
drawScale = 1f;
if (elementIndex == lastElementIndex)
{
sprite = this._panelRightHP;
offset = new Vector2(-16f, -10f);
}
else
{
if (elementIndex == firstElementIndex)
return;
sprite = this._panelMiddleHP;
}
}
private void ManaPanelDrawer(
int elementIndex,
int firstElementIndex,
int lastElementIndex,
out Asset<Texture2D> sprite,
out Vector2 offset,
out float drawScale,
out Rectangle? sourceRect)
{
sourceRect = new Rectangle?();
offset = Vector2.Zero;
sprite = this._panelLeft;
drawScale = 1f;
if (elementIndex == lastElementIndex)
{
sprite = this._panelRightMP;
offset = new Vector2(-16f, -6f);
}
else
{
if (elementIndex == firstElementIndex)
return;
sprite = this._panelMiddleMP;
}
}
private void LifeFillingDrawer(
int elementIndex,
int firstElementIndex,
int lastElementIndex,
out Asset<Texture2D> sprite,
out Vector2 offset,
out float drawScale,
out Rectangle? sourceRect)
{
sprite = this._hpFill;
if (elementIndex >= this._hpSegmentsCount - this._hpFruitCount)
sprite = this._hpFillHoney;
HorizontalBarsPlayerReosurcesDisplaySet.FillBarByValues(elementIndex, sprite, this._hpSegmentsCount, this._hpPercent, out offset, out drawScale, out sourceRect);
}
private static void FillBarByValues(
int elementIndex,
Asset<Texture2D> sprite,
int segmentsCount,
float fillPercent,
out Vector2 offset,
out float drawScale,
out Rectangle? sourceRect)
{
sourceRect = new Rectangle?();
offset = Vector2.Zero;
int num1 = elementIndex;
float num2 = 1f / (float) segmentsCount;
float t = 1f - fillPercent;
float num3 = 1f - Utils.GetLerpValue(num2 * (float) num1, num2 * (float) (num1 + 1), t, true);
drawScale = 1f;
Rectangle rectangle = sprite.Frame();
int num4 = (int) ((double) rectangle.Width * (1.0 - (double) num3));
offset.X += (float) num4;
rectangle.X += num4;
rectangle.Width -= num4;
sourceRect = new Rectangle?(rectangle);
}
private void ManaFillingDrawer(
int elementIndex,
int firstElementIndex,
int lastElementIndex,
out Asset<Texture2D> sprite,
out Vector2 offset,
out float drawScale,
out Rectangle? sourceRect)
{
sprite = this._mpFill;
HorizontalBarsPlayerReosurcesDisplaySet.FillBarByValues(elementIndex, sprite, this._mpSegmentsCount, this._mpPercent, out offset, out drawScale, out sourceRect);
}
public void TryToHover()
{
if (this._hpHovered)
CommonResourceBarMethods.DrawLifeMouseOver();
if (!this._mpHovered)
return;
CommonResourceBarMethods.DrawManaMouseOver();
}
}
}

View file

@ -0,0 +1,13 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.UI.IMultiplayerClosePlayersOverlay
// 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.GameContent.UI
{
public interface IMultiplayerClosePlayersOverlay
{
void Draw();
}
}

Some files were not shown because too many files have changed in this diff Show more