Terraria 1.3.5.3 Source Code
This commit is contained in:
commit
4b21dac4b6
503 changed files with 409032 additions and 0 deletions
155
UI/AchievementCompleteUI.cs
Normal file
155
UI/AchievementCompleteUI.cs
Normal file
|
@ -0,0 +1,155 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.UI.AchievementCompleteUI
|
||||
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.Achievements;
|
||||
using Terraria.GameInput;
|
||||
using Terraria.Graphics;
|
||||
|
||||
namespace Terraria.UI
|
||||
{
|
||||
public class AchievementCompleteUI
|
||||
{
|
||||
private static Texture2D AchievementsTexture;
|
||||
private static Texture2D AchievementsTextureBorder;
|
||||
private static List<AchievementCompleteUI.DrawCache> caches = new List<AchievementCompleteUI.DrawCache>();
|
||||
|
||||
public static void LoadContent()
|
||||
{
|
||||
AchievementCompleteUI.AchievementsTexture = TextureManager.Load("Images/UI/Achievements");
|
||||
AchievementCompleteUI.AchievementsTextureBorder = TextureManager.Load("Images/UI/Achievement_Borders");
|
||||
}
|
||||
|
||||
public static void Initialize() => Main.Achievements.OnAchievementCompleted += new Achievement.AchievementCompleted(AchievementCompleteUI.AddCompleted);
|
||||
|
||||
public static void Draw(SpriteBatch sb)
|
||||
{
|
||||
float y = (float) (Main.screenHeight - 40);
|
||||
if (PlayerInput.UsingGamepad)
|
||||
y -= 25f;
|
||||
Vector2 center = new Vector2((float) (Main.screenWidth / 2), y);
|
||||
foreach (AchievementCompleteUI.DrawCache cach in AchievementCompleteUI.caches)
|
||||
{
|
||||
AchievementCompleteUI.DrawAchievement(sb, ref center, cach);
|
||||
if ((double) center.Y < -100.0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void AddCompleted(Achievement achievement)
|
||||
{
|
||||
if (Main.netMode == 2)
|
||||
return;
|
||||
AchievementCompleteUI.caches.Add(new AchievementCompleteUI.DrawCache(achievement));
|
||||
}
|
||||
|
||||
public static void Clear() => AchievementCompleteUI.caches.Clear();
|
||||
|
||||
public static void Update()
|
||||
{
|
||||
foreach (AchievementCompleteUI.DrawCache cach in AchievementCompleteUI.caches)
|
||||
cach.Update();
|
||||
for (int index = 0; index < AchievementCompleteUI.caches.Count; ++index)
|
||||
{
|
||||
if (AchievementCompleteUI.caches[index].TimeLeft == 0)
|
||||
{
|
||||
AchievementCompleteUI.caches.Remove(AchievementCompleteUI.caches[index]);
|
||||
--index;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void DrawAchievement(
|
||||
SpriteBatch sb,
|
||||
ref Vector2 center,
|
||||
AchievementCompleteUI.DrawCache ach)
|
||||
{
|
||||
float alpha = ach.Alpha;
|
||||
if ((double) alpha > 0.0)
|
||||
{
|
||||
string title = ach.Title;
|
||||
Vector2 center1 = center;
|
||||
Vector2 vector2 = Main.fontItemStack.MeasureString(title);
|
||||
float num1 = ach.Scale * 1.1f;
|
||||
Vector2 size = (vector2 + new Vector2(58f, 10f)) * num1;
|
||||
Rectangle rectangle = Utils.CenteredRectangle(center1, size);
|
||||
Vector2 mouseScreen = Main.MouseScreen;
|
||||
int num2 = rectangle.Contains(mouseScreen.ToPoint()) ? 1 : 0;
|
||||
Color c = num2 != 0 ? new Color(64, 109, 164) * 0.75f : new Color(64, 109, 164) * 0.5f;
|
||||
Utils.DrawInvBG(sb, rectangle, c);
|
||||
float scale = num1 * 0.3f;
|
||||
Color color = new Color((int) Main.mouseTextColor, (int) Main.mouseTextColor, (int) Main.mouseTextColor / 5, (int) Main.mouseTextColor);
|
||||
Vector2 position = rectangle.Right() - Vector2.UnitX * num1 * (float) (12.0 + (double) scale * (double) ach.Frame.Width);
|
||||
sb.Draw(AchievementCompleteUI.AchievementsTexture, position, new Rectangle?(ach.Frame), Color.White * alpha, 0.0f, new Vector2(0.0f, (float) (ach.Frame.Height / 2)), scale, SpriteEffects.None, 0.0f);
|
||||
sb.Draw(AchievementCompleteUI.AchievementsTextureBorder, position, new Rectangle?(), Color.White * alpha, 0.0f, new Vector2(0.0f, (float) (ach.Frame.Height / 2)), scale, SpriteEffects.None, 0.0f);
|
||||
Utils.DrawBorderString(sb, title, position - Vector2.UnitX * 10f, color * alpha, num1 * 0.9f, 1f, 0.4f);
|
||||
if (num2 != 0 && !PlayerInput.IgnoreMouseInterface)
|
||||
{
|
||||
Main.player[Main.myPlayer].mouseInterface = true;
|
||||
if (Main.mouseLeft && Main.mouseLeftRelease)
|
||||
{
|
||||
IngameFancyUI.OpenAchievementsAndGoto(ach.theAchievement);
|
||||
ach.TimeLeft = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
ach.ApplyHeight(ref center);
|
||||
}
|
||||
|
||||
public class DrawCache
|
||||
{
|
||||
public Achievement theAchievement;
|
||||
private const int _iconSize = 64;
|
||||
private const int _iconSizeWithSpace = 66;
|
||||
private const int _iconsPerRow = 8;
|
||||
public int IconIndex;
|
||||
public Rectangle Frame;
|
||||
public string Title;
|
||||
public int TimeLeft;
|
||||
|
||||
public void Update()
|
||||
{
|
||||
--this.TimeLeft;
|
||||
if (this.TimeLeft >= 0)
|
||||
return;
|
||||
this.TimeLeft = 0;
|
||||
}
|
||||
|
||||
public DrawCache(Achievement achievement)
|
||||
{
|
||||
this.theAchievement = achievement;
|
||||
this.Title = achievement.FriendlyName.Value;
|
||||
int iconIndex = Main.Achievements.GetIconIndex(achievement.Name);
|
||||
this.IconIndex = iconIndex;
|
||||
this.Frame = new Rectangle(iconIndex % 8 * 66, iconIndex / 8 * 66, 64, 64);
|
||||
this.TimeLeft = 300;
|
||||
}
|
||||
|
||||
public float Scale
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.TimeLeft < 30)
|
||||
return MathHelper.Lerp(0.0f, 1f, (float) this.TimeLeft / 30f);
|
||||
return this.TimeLeft > 285 ? MathHelper.Lerp(1f, 0.0f, (float) (((double) this.TimeLeft - 285.0) / 15.0)) : 1f;
|
||||
}
|
||||
}
|
||||
|
||||
public float Alpha
|
||||
{
|
||||
get
|
||||
{
|
||||
float scale = this.Scale;
|
||||
return (double) scale <= 0.5 ? 0.0f : (float) (((double) scale - 0.5) / 0.5);
|
||||
}
|
||||
}
|
||||
|
||||
public void ApplyHeight(ref Vector2 v) => v.Y -= 50f * this.Alpha;
|
||||
}
|
||||
}
|
||||
}
|
32
UI/CalculatedStyle.cs
Normal file
32
UI/CalculatedStyle.cs
Normal file
|
@ -0,0 +1,32 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.UI.CalculatedStyle
|
||||
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace Terraria.UI
|
||||
{
|
||||
public struct CalculatedStyle
|
||||
{
|
||||
public float X;
|
||||
public float Y;
|
||||
public float Width;
|
||||
public float Height;
|
||||
|
||||
public CalculatedStyle(float x, float y, float width, float height)
|
||||
{
|
||||
this.X = x;
|
||||
this.Y = y;
|
||||
this.Width = width;
|
||||
this.Height = height;
|
||||
}
|
||||
|
||||
public Rectangle ToRectangle() => new Rectangle((int) this.X, (int) this.Y, (int) this.Width, (int) this.Height);
|
||||
|
||||
public Vector2 Position() => new Vector2(this.X, this.Y);
|
||||
|
||||
public Vector2 Center() => new Vector2(this.X + this.Width * 0.5f, this.Y + this.Height * 0.5f);
|
||||
}
|
||||
}
|
18
UI/Chat/ChatLine.cs
Normal file
18
UI/Chat/ChatLine.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.UI.Chat.ChatLine
|
||||
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace Terraria.UI.Chat
|
||||
{
|
||||
public class ChatLine
|
||||
{
|
||||
public Color color = Color.White;
|
||||
public int showTime;
|
||||
public string text = "";
|
||||
public TextSnippet[] parsedText = new TextSnippet[0];
|
||||
}
|
||||
}
|
402
UI/Chat/ChatManager.cs
Normal file
402
UI/Chat/ChatManager.cs
Normal file
|
@ -0,0 +1,402 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.UI.Chat.ChatManager
|
||||
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Graphics;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using Terraria.Chat;
|
||||
using Terraria.GameContent.UI.Chat;
|
||||
|
||||
namespace Terraria.UI.Chat
|
||||
{
|
||||
public static class ChatManager
|
||||
{
|
||||
public static readonly ChatCommandProcessor Commands = new ChatCommandProcessor();
|
||||
private static ConcurrentDictionary<string, ITagHandler> _handlers = new ConcurrentDictionary<string, ITagHandler>();
|
||||
public static readonly Vector2[] ShadowDirections = new Vector2[4]
|
||||
{
|
||||
-Vector2.UnitX,
|
||||
Vector2.UnitX,
|
||||
-Vector2.UnitY,
|
||||
Vector2.UnitY
|
||||
};
|
||||
|
||||
public static Color WaveColor(Color color)
|
||||
{
|
||||
float num = (float) Main.mouseTextColor / (float) byte.MaxValue;
|
||||
color = Color.Lerp(color, Color.Black, 1f - num);
|
||||
color.A = Main.mouseTextColor;
|
||||
return color;
|
||||
}
|
||||
|
||||
public static void ConvertNormalSnippets(TextSnippet[] snippets)
|
||||
{
|
||||
for (int index = 0; index < snippets.Length; ++index)
|
||||
{
|
||||
TextSnippet snippet = snippets[index];
|
||||
if (snippets[index].GetType() == typeof (TextSnippet))
|
||||
{
|
||||
PlainTagHandler.PlainSnippet plainSnippet = new PlainTagHandler.PlainSnippet(snippet.Text, snippet.Color, snippet.Scale);
|
||||
snippets[index] = (TextSnippet) plainSnippet;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Register<T>(params string[] names) where T : ITagHandler, new()
|
||||
{
|
||||
T obj = new T();
|
||||
for (int index = 0; index < names.Length; ++index)
|
||||
ChatManager._handlers[names[index].ToLower()] = (ITagHandler) obj;
|
||||
}
|
||||
|
||||
private static ITagHandler GetHandler(string tagName)
|
||||
{
|
||||
string lower = tagName.ToLower();
|
||||
return ChatManager._handlers.ContainsKey(lower) ? ChatManager._handlers[lower] : (ITagHandler) null;
|
||||
}
|
||||
|
||||
public static List<TextSnippet> ParseMessage(string text, Color baseColor)
|
||||
{
|
||||
MatchCollection matchCollection = ChatManager.Regexes.Format.Matches(text);
|
||||
List<TextSnippet> textSnippetList = new List<TextSnippet>();
|
||||
int startIndex = 0;
|
||||
foreach (Match match in matchCollection)
|
||||
{
|
||||
if (match.Index > startIndex)
|
||||
textSnippetList.Add(new TextSnippet(text.Substring(startIndex, match.Index - startIndex), baseColor));
|
||||
startIndex = match.Index + match.Length;
|
||||
string tagName = match.Groups["tag"].Value;
|
||||
string text1 = match.Groups[nameof (text)].Value;
|
||||
string options = match.Groups["options"].Value;
|
||||
ITagHandler handler = ChatManager.GetHandler(tagName);
|
||||
if (handler != null)
|
||||
{
|
||||
textSnippetList.Add(handler.Parse(text1, baseColor, options));
|
||||
textSnippetList[textSnippetList.Count - 1].TextOriginal = match.ToString();
|
||||
}
|
||||
else
|
||||
textSnippetList.Add(new TextSnippet(text1, baseColor));
|
||||
}
|
||||
if (text.Length > startIndex)
|
||||
textSnippetList.Add(new TextSnippet(text.Substring(startIndex, text.Length - startIndex), baseColor));
|
||||
return textSnippetList;
|
||||
}
|
||||
|
||||
public static bool AddChatText(DynamicSpriteFont font, string text, Vector2 baseScale)
|
||||
{
|
||||
int num = Main.screenWidth - 330;
|
||||
if ((double) ChatManager.GetStringSize(font, Main.chatText + text, baseScale).X > (double) num)
|
||||
return false;
|
||||
Main.chatText += text;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static Vector2 GetStringSize(
|
||||
DynamicSpriteFont font,
|
||||
string text,
|
||||
Vector2 baseScale,
|
||||
float maxWidth = -1f)
|
||||
{
|
||||
TextSnippet[] array = ChatManager.ParseMessage(text, Color.White).ToArray();
|
||||
return ChatManager.GetStringSize(font, array, baseScale, maxWidth);
|
||||
}
|
||||
|
||||
public static Vector2 GetStringSize(
|
||||
DynamicSpriteFont font,
|
||||
TextSnippet[] snippets,
|
||||
Vector2 baseScale,
|
||||
float maxWidth = -1f)
|
||||
{
|
||||
Vector2 vec = new Vector2((float) Main.mouseX, (float) Main.mouseY);
|
||||
Vector2 zero = Vector2.Zero;
|
||||
Vector2 minimum = zero;
|
||||
Vector2 vector2_1 = minimum;
|
||||
float x = font.MeasureString(" ").X;
|
||||
float num1 = 0.0f;
|
||||
for (int index1 = 0; index1 < snippets.Length; ++index1)
|
||||
{
|
||||
TextSnippet snippet = snippets[index1];
|
||||
snippet.Update();
|
||||
float scale = snippet.Scale;
|
||||
Vector2 size;
|
||||
if (snippet.UniqueDraw(true, out size, (SpriteBatch) null))
|
||||
{
|
||||
minimum.X += size.X * baseScale.X * scale;
|
||||
vector2_1.X = Math.Max(vector2_1.X, minimum.X);
|
||||
vector2_1.Y = Math.Max(vector2_1.Y, minimum.Y + size.Y);
|
||||
}
|
||||
else
|
||||
{
|
||||
string[] strArray1 = snippet.Text.Split('\n');
|
||||
foreach (string str in strArray1)
|
||||
{
|
||||
char[] chArray = new char[1]{ ' ' };
|
||||
string[] strArray2 = str.Split(chArray);
|
||||
for (int index2 = 0; index2 < strArray2.Length; ++index2)
|
||||
{
|
||||
if (index2 != 0)
|
||||
minimum.X += x * baseScale.X * scale;
|
||||
if ((double) maxWidth > 0.0)
|
||||
{
|
||||
float num2 = font.MeasureString(strArray2[index2]).X * baseScale.X * scale;
|
||||
if ((double) minimum.X - (double) zero.X + (double) num2 > (double) maxWidth)
|
||||
{
|
||||
minimum.X = zero.X;
|
||||
minimum.Y += (float) font.LineSpacing * num1 * baseScale.Y;
|
||||
vector2_1.Y = Math.Max(vector2_1.Y, minimum.Y);
|
||||
num1 = 0.0f;
|
||||
}
|
||||
}
|
||||
if ((double) num1 < (double) scale)
|
||||
num1 = scale;
|
||||
Vector2 vector2_2 = font.MeasureString(strArray2[index2]);
|
||||
vec.Between(minimum, minimum + vector2_2);
|
||||
minimum.X += vector2_2.X * baseScale.X * scale;
|
||||
vector2_1.X = Math.Max(vector2_1.X, minimum.X);
|
||||
vector2_1.Y = Math.Max(vector2_1.Y, minimum.Y + vector2_2.Y);
|
||||
}
|
||||
if (strArray1.Length > 1)
|
||||
{
|
||||
minimum.X = zero.X;
|
||||
minimum.Y += (float) font.LineSpacing * num1 * baseScale.Y;
|
||||
vector2_1.Y = Math.Max(vector2_1.Y, minimum.Y);
|
||||
num1 = 0.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return vector2_1;
|
||||
}
|
||||
|
||||
public static void DrawColorCodedStringShadow(
|
||||
SpriteBatch spriteBatch,
|
||||
DynamicSpriteFont font,
|
||||
TextSnippet[] snippets,
|
||||
Vector2 position,
|
||||
Color baseColor,
|
||||
float rotation,
|
||||
Vector2 origin,
|
||||
Vector2 baseScale,
|
||||
float maxWidth = -1f,
|
||||
float spread = 2f)
|
||||
{
|
||||
for (int index = 0; index < ChatManager.ShadowDirections.Length; ++index)
|
||||
ChatManager.DrawColorCodedString(spriteBatch, font, snippets, position + ChatManager.ShadowDirections[index] * spread, baseColor, rotation, origin, baseScale, out int _, maxWidth, true);
|
||||
}
|
||||
|
||||
public static Vector2 DrawColorCodedString(
|
||||
SpriteBatch spriteBatch,
|
||||
DynamicSpriteFont font,
|
||||
TextSnippet[] snippets,
|
||||
Vector2 position,
|
||||
Color baseColor,
|
||||
float rotation,
|
||||
Vector2 origin,
|
||||
Vector2 baseScale,
|
||||
out int hoveredSnippet,
|
||||
float maxWidth,
|
||||
bool ignoreColors = false)
|
||||
{
|
||||
int num1 = -1;
|
||||
Vector2 vec = new Vector2((float) Main.mouseX, (float) Main.mouseY);
|
||||
Vector2 vector2_1 = position;
|
||||
Vector2 vector2_2 = vector2_1;
|
||||
float x = font.MeasureString(" ").X;
|
||||
Color color = baseColor;
|
||||
float num2 = 0.0f;
|
||||
for (int index1 = 0; index1 < snippets.Length; ++index1)
|
||||
{
|
||||
TextSnippet snippet = snippets[index1];
|
||||
snippet.Update();
|
||||
if (!ignoreColors)
|
||||
color = snippet.GetVisibleColor();
|
||||
float scale = snippet.Scale;
|
||||
Vector2 size;
|
||||
if (snippet.UniqueDraw(false, out size, spriteBatch, vector2_1, color, scale))
|
||||
{
|
||||
if (vec.Between(vector2_1, vector2_1 + size))
|
||||
num1 = index1;
|
||||
vector2_1.X += size.X * baseScale.X * scale;
|
||||
vector2_2.X = Math.Max(vector2_2.X, vector2_1.X);
|
||||
}
|
||||
else
|
||||
{
|
||||
string[] strArray1 = snippet.Text.Split('\n');
|
||||
foreach (string str in strArray1)
|
||||
{
|
||||
char[] chArray = new char[1]{ ' ' };
|
||||
string[] strArray2 = str.Split(chArray);
|
||||
for (int index2 = 0; index2 < strArray2.Length; ++index2)
|
||||
{
|
||||
if (index2 != 0)
|
||||
vector2_1.X += x * baseScale.X * scale;
|
||||
if ((double) maxWidth > 0.0)
|
||||
{
|
||||
float num3 = font.MeasureString(strArray2[index2]).X * baseScale.X * scale;
|
||||
if ((double) vector2_1.X - (double) position.X + (double) num3 > (double) maxWidth)
|
||||
{
|
||||
vector2_1.X = position.X;
|
||||
vector2_1.Y += (float) font.LineSpacing * num2 * baseScale.Y;
|
||||
vector2_2.Y = Math.Max(vector2_2.Y, vector2_1.Y);
|
||||
num2 = 0.0f;
|
||||
}
|
||||
}
|
||||
if ((double) num2 < (double) scale)
|
||||
num2 = scale;
|
||||
DynamicSpriteFontExtensionMethods.DrawString(spriteBatch, font, strArray2[index2], vector2_1, color, rotation, origin, baseScale * snippet.Scale * scale, SpriteEffects.None, 0.0f);
|
||||
Vector2 vector2_3 = font.MeasureString(strArray2[index2]);
|
||||
if (vec.Between(vector2_1, vector2_1 + vector2_3))
|
||||
num1 = index1;
|
||||
vector2_1.X += vector2_3.X * baseScale.X * scale;
|
||||
vector2_2.X = Math.Max(vector2_2.X, vector2_1.X);
|
||||
}
|
||||
if (strArray1.Length > 1)
|
||||
{
|
||||
vector2_1.Y += (float) font.LineSpacing * num2 * baseScale.Y;
|
||||
vector2_1.X = position.X;
|
||||
vector2_2.Y = Math.Max(vector2_2.Y, vector2_1.Y);
|
||||
num2 = 0.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
hoveredSnippet = num1;
|
||||
return vector2_2;
|
||||
}
|
||||
|
||||
public static Vector2 DrawColorCodedStringWithShadow(
|
||||
SpriteBatch spriteBatch,
|
||||
DynamicSpriteFont font,
|
||||
TextSnippet[] snippets,
|
||||
Vector2 position,
|
||||
float rotation,
|
||||
Vector2 origin,
|
||||
Vector2 baseScale,
|
||||
out int hoveredSnippet,
|
||||
float maxWidth = -1f,
|
||||
float spread = 2f)
|
||||
{
|
||||
ChatManager.DrawColorCodedStringShadow(spriteBatch, font, snippets, position, Color.Black, rotation, origin, baseScale, maxWidth, spread);
|
||||
return ChatManager.DrawColorCodedString(spriteBatch, font, snippets, position, Color.White, rotation, origin, baseScale, out hoveredSnippet, maxWidth);
|
||||
}
|
||||
|
||||
public static void DrawColorCodedStringShadow(
|
||||
SpriteBatch spriteBatch,
|
||||
DynamicSpriteFont font,
|
||||
string text,
|
||||
Vector2 position,
|
||||
Color baseColor,
|
||||
float rotation,
|
||||
Vector2 origin,
|
||||
Vector2 baseScale,
|
||||
float maxWidth = -1f,
|
||||
float spread = 2f)
|
||||
{
|
||||
for (int index = 0; index < ChatManager.ShadowDirections.Length; ++index)
|
||||
ChatManager.DrawColorCodedString(spriteBatch, font, text, position + ChatManager.ShadowDirections[index] * spread, baseColor, rotation, origin, baseScale, maxWidth, true);
|
||||
}
|
||||
|
||||
public static Vector2 DrawColorCodedString(
|
||||
SpriteBatch spriteBatch,
|
||||
DynamicSpriteFont font,
|
||||
string text,
|
||||
Vector2 position,
|
||||
Color baseColor,
|
||||
float rotation,
|
||||
Vector2 origin,
|
||||
Vector2 baseScale,
|
||||
float maxWidth = -1f,
|
||||
bool ignoreColors = false)
|
||||
{
|
||||
Vector2 vector2_1 = position;
|
||||
Vector2 vector2_2 = vector2_1;
|
||||
string[] strArray1 = text.Split('\n');
|
||||
float x = font.MeasureString(" ").X;
|
||||
Color color = baseColor;
|
||||
float num1 = 1f;
|
||||
float num2 = 0.0f;
|
||||
foreach (string str1 in strArray1)
|
||||
{
|
||||
char[] chArray = new char[1]{ ':' };
|
||||
foreach (string str2 in str1.Split(chArray))
|
||||
{
|
||||
if (str2.StartsWith("sss"))
|
||||
{
|
||||
if (str2.StartsWith("sss1"))
|
||||
{
|
||||
if (!ignoreColors)
|
||||
color = Color.Red;
|
||||
}
|
||||
else if (str2.StartsWith("sss2"))
|
||||
{
|
||||
if (!ignoreColors)
|
||||
color = Color.Blue;
|
||||
}
|
||||
else if (str2.StartsWith("sssr") && !ignoreColors)
|
||||
color = Color.White;
|
||||
}
|
||||
else
|
||||
{
|
||||
string[] strArray2 = str2.Split(' ');
|
||||
for (int index = 0; index < strArray2.Length; ++index)
|
||||
{
|
||||
if (index != 0)
|
||||
vector2_1.X += x * baseScale.X * num1;
|
||||
if ((double) maxWidth > 0.0)
|
||||
{
|
||||
float num3 = font.MeasureString(strArray2[index]).X * baseScale.X * num1;
|
||||
if ((double) vector2_1.X - (double) position.X + (double) num3 > (double) maxWidth)
|
||||
{
|
||||
vector2_1.X = position.X;
|
||||
vector2_1.Y += (float) font.LineSpacing * num2 * baseScale.Y;
|
||||
vector2_2.Y = Math.Max(vector2_2.Y, vector2_1.Y);
|
||||
num2 = 0.0f;
|
||||
}
|
||||
}
|
||||
if ((double) num2 < (double) num1)
|
||||
num2 = num1;
|
||||
DynamicSpriteFontExtensionMethods.DrawString(spriteBatch, font, strArray2[index], vector2_1, color, rotation, origin, baseScale * num1, SpriteEffects.None, 0.0f);
|
||||
vector2_1.X += font.MeasureString(strArray2[index]).X * baseScale.X * num1;
|
||||
vector2_2.X = Math.Max(vector2_2.X, vector2_1.X);
|
||||
}
|
||||
}
|
||||
}
|
||||
vector2_1.X = position.X;
|
||||
vector2_1.Y += (float) font.LineSpacing * num2 * baseScale.Y;
|
||||
vector2_2.Y = Math.Max(vector2_2.Y, vector2_1.Y);
|
||||
num2 = 0.0f;
|
||||
}
|
||||
return vector2_2;
|
||||
}
|
||||
|
||||
public static Vector2 DrawColorCodedStringWithShadow(
|
||||
SpriteBatch spriteBatch,
|
||||
DynamicSpriteFont font,
|
||||
string text,
|
||||
Vector2 position,
|
||||
Color baseColor,
|
||||
float rotation,
|
||||
Vector2 origin,
|
||||
Vector2 baseScale,
|
||||
float maxWidth = -1f,
|
||||
float spread = 2f)
|
||||
{
|
||||
TextSnippet[] array = ChatManager.ParseMessage(text, baseColor).ToArray();
|
||||
ChatManager.ConvertNormalSnippets(array);
|
||||
ChatManager.DrawColorCodedStringShadow(spriteBatch, font, array, position, Color.Black, rotation, origin, baseScale, maxWidth, spread);
|
||||
return ChatManager.DrawColorCodedString(spriteBatch, font, array, position, Color.White, rotation, origin, baseScale, out int _, maxWidth);
|
||||
}
|
||||
|
||||
public static class Regexes
|
||||
{
|
||||
public static readonly Regex Format = new Regex("(?<!\\\\)\\[(?<tag>[a-zA-Z]{1,10})(\\/(?<options>[^:]+))?:(?<text>.+?)(?<!\\\\)\\]", RegexOptions.Compiled);
|
||||
}
|
||||
}
|
||||
}
|
15
UI/Chat/ITagHandler.cs
Normal file
15
UI/Chat/ITagHandler.cs
Normal file
|
@ -0,0 +1,15 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.UI.Chat.ITagHandler
|
||||
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace Terraria.UI.Chat
|
||||
{
|
||||
public interface ITagHandler
|
||||
{
|
||||
TextSnippet Parse(string text, Color baseColor = default (Color), string options = null);
|
||||
}
|
||||
}
|
71
UI/Chat/TextSnippet.cs
Normal file
71
UI/Chat/TextSnippet.cs
Normal file
|
@ -0,0 +1,71 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.UI.Chat.TextSnippet
|
||||
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Graphics;
|
||||
|
||||
namespace Terraria.UI.Chat
|
||||
{
|
||||
public class TextSnippet
|
||||
{
|
||||
public string Text;
|
||||
public string TextOriginal;
|
||||
public Color Color = Color.White;
|
||||
public float Scale = 1f;
|
||||
public bool CheckForHover;
|
||||
public bool DeleteWhole;
|
||||
|
||||
public TextSnippet(string text = "")
|
||||
{
|
||||
this.Text = text;
|
||||
this.TextOriginal = text;
|
||||
}
|
||||
|
||||
public TextSnippet(string text, Color color, float scale = 1f)
|
||||
{
|
||||
this.Text = text;
|
||||
this.TextOriginal = text;
|
||||
this.Color = color;
|
||||
this.Scale = scale;
|
||||
}
|
||||
|
||||
public virtual void Update()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void OnHover()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void OnClick()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual Color GetVisibleColor() => ChatManager.WaveColor(this.Color);
|
||||
|
||||
public virtual bool UniqueDraw(
|
||||
bool justCheckingString,
|
||||
out Vector2 size,
|
||||
SpriteBatch spriteBatch,
|
||||
Vector2 position = default (Vector2),
|
||||
Color color = default (Color),
|
||||
float scale = 1f)
|
||||
{
|
||||
size = Vector2.Zero;
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual TextSnippet CopyMorph(string newText)
|
||||
{
|
||||
TextSnippet textSnippet = (TextSnippet) this.MemberwiseClone();
|
||||
textSnippet.Text = newText;
|
||||
return textSnippet;
|
||||
}
|
||||
|
||||
public virtual float GetStringLength(DynamicSpriteFont font) => font.MeasureString(this.Text).X * this.Scale;
|
||||
}
|
||||
}
|
1085
UI/ChestUI.cs
Normal file
1085
UI/ChestUI.cs
Normal file
File diff suppressed because it is too large
Load diff
10
UI/GameInterfaceDrawMethod.cs
Normal file
10
UI/GameInterfaceDrawMethod.cs
Normal file
|
@ -0,0 +1,10 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.UI.GameInterfaceDrawMethod
|
||||
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
namespace Terraria.UI
|
||||
{
|
||||
public delegate bool GameInterfaceDrawMethod();
|
||||
}
|
50
UI/GameInterfaceLayer.cs
Normal file
50
UI/GameInterfaceLayer.cs
Normal file
|
@ -0,0 +1,50 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.UI.GameInterfaceLayer
|
||||
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
|
||||
// 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.GameInput;
|
||||
|
||||
namespace Terraria.UI
|
||||
{
|
||||
public class GameInterfaceLayer
|
||||
{
|
||||
public readonly string Name;
|
||||
public InterfaceScaleType ScaleType;
|
||||
|
||||
public GameInterfaceLayer(string name, InterfaceScaleType scaleType)
|
||||
{
|
||||
this.Name = name;
|
||||
this.ScaleType = scaleType;
|
||||
}
|
||||
|
||||
public bool Draw()
|
||||
{
|
||||
Matrix transformMatrix;
|
||||
if (this.ScaleType == InterfaceScaleType.Game)
|
||||
{
|
||||
PlayerInput.SetZoom_World();
|
||||
transformMatrix = Main.GameViewMatrix.ZoomMatrix;
|
||||
}
|
||||
else if (this.ScaleType == InterfaceScaleType.UI)
|
||||
{
|
||||
PlayerInput.SetZoom_UI();
|
||||
transformMatrix = Main.UIScaleMatrix;
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerInput.SetZoom_Unscaled();
|
||||
transformMatrix = Matrix.Identity;
|
||||
}
|
||||
Main.spriteBatch.Begin(SpriteSortMode.Deferred, (BlendState) null, (SamplerState) null, (DepthStencilState) null, (RasterizerState) null, (Effect) null, transformMatrix);
|
||||
int num = this.DrawSelf() ? 1 : 0;
|
||||
Main.spriteBatch.End();
|
||||
return num != 0;
|
||||
}
|
||||
|
||||
protected virtual bool DrawSelf() => true;
|
||||
}
|
||||
}
|
88
UI/Gamepad/GamepadMainMenuHandler.cs
Normal file
88
UI/Gamepad/GamepadMainMenuHandler.cs
Normal file
|
@ -0,0 +1,88 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.UI.Gamepad.GamepadMainMenuHandler
|
||||
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.GameInput;
|
||||
|
||||
namespace Terraria.UI.Gamepad
|
||||
{
|
||||
public class GamepadMainMenuHandler
|
||||
{
|
||||
public static int LastMainMenu = -1;
|
||||
public static List<Vector2> MenuItemPositions = new List<Vector2>(20);
|
||||
public static int LastDrew = -1;
|
||||
public static bool CanRun = false;
|
||||
|
||||
public static void Update()
|
||||
{
|
||||
if (!GamepadMainMenuHandler.CanRun)
|
||||
{
|
||||
UILinkPage page = UILinkPointNavigator.Pages[1000];
|
||||
page.CurrentPoint = page.DefaultPoint;
|
||||
Vector2 vector2 = new Vector2((float) Math.Cos((double) Main.GlobalTime * 6.28318548202515), (float) Math.Sin((double) Main.GlobalTime * 6.28318548202515 * 2.0)) * new Vector2(30f, 15f) + Vector2.UnitY * 20f;
|
||||
UILinkPointNavigator.SetPosition(2000, new Vector2((float) Main.screenWidth, (float) Main.screenHeight) / 2f + vector2);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!Main.gameMenu || Main.MenuUI.IsVisible || GamepadMainMenuHandler.LastDrew != Main.menuMode)
|
||||
return;
|
||||
int lastMainMenu = GamepadMainMenuHandler.LastMainMenu;
|
||||
GamepadMainMenuHandler.LastMainMenu = Main.menuMode;
|
||||
switch (Main.menuMode)
|
||||
{
|
||||
case 17:
|
||||
case 18:
|
||||
case 19:
|
||||
case 21:
|
||||
case 22:
|
||||
case 23:
|
||||
case 24:
|
||||
case 26:
|
||||
if (GamepadMainMenuHandler.MenuItemPositions.Count >= 4)
|
||||
{
|
||||
Vector2 menuItemPosition = GamepadMainMenuHandler.MenuItemPositions[3];
|
||||
GamepadMainMenuHandler.MenuItemPositions.RemoveAt(3);
|
||||
if (Main.menuMode == 17)
|
||||
{
|
||||
GamepadMainMenuHandler.MenuItemPositions.Insert(0, menuItemPosition);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 28:
|
||||
if (GamepadMainMenuHandler.MenuItemPositions.Count >= 3)
|
||||
{
|
||||
GamepadMainMenuHandler.MenuItemPositions.RemoveAt(1);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
UILinkPage page = UILinkPointNavigator.Pages[1000];
|
||||
if (lastMainMenu != Main.menuMode)
|
||||
page.CurrentPoint = page.DefaultPoint;
|
||||
for (int index = 0; index < GamepadMainMenuHandler.MenuItemPositions.Count; ++index)
|
||||
{
|
||||
if (index == 0 && lastMainMenu != GamepadMainMenuHandler.LastMainMenu && PlayerInput.UsingGamepad && Main.InvisibleCursorForGamepad)
|
||||
{
|
||||
Main.mouseX = PlayerInput.MouseX = (int) GamepadMainMenuHandler.MenuItemPositions[index].X;
|
||||
Main.mouseY = PlayerInput.MouseY = (int) GamepadMainMenuHandler.MenuItemPositions[index].Y;
|
||||
Main.menuFocus = -1;
|
||||
}
|
||||
UILinkPoint link = page.LinkMap[2000 + index];
|
||||
link.Position = GamepadMainMenuHandler.MenuItemPositions[index];
|
||||
link.Up = index != 0 ? 2000 + index - 1 : -1;
|
||||
link.Left = -3;
|
||||
link.Right = -4;
|
||||
link.Down = index != GamepadMainMenuHandler.MenuItemPositions.Count - 1 ? 2000 + index + 1 : -2;
|
||||
}
|
||||
GamepadMainMenuHandler.MenuItemPositions.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
38
UI/Gamepad/GamepadPageID.cs
Normal file
38
UI/Gamepad/GamepadPageID.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.UI.Gamepad.GamepadPageID
|
||||
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
namespace Terraria.UI.Gamepad
|
||||
{
|
||||
public static class GamepadPageID
|
||||
{
|
||||
public const int None = -1;
|
||||
public const int Inventory = 0;
|
||||
public const int Coins = 1;
|
||||
public const int Ammo = 2;
|
||||
public const int Armor = 3;
|
||||
public const int Chest = 4;
|
||||
public const int Reforge = 5;
|
||||
public const int NPCHousing = 6;
|
||||
public const int Equipment = 7;
|
||||
public const int Tabs = 8;
|
||||
public const int CraftSmall = 9;
|
||||
public const int CraftBig = 10;
|
||||
public const int HairCustomizationStyle = 11;
|
||||
public const int HairCustomizationColor = 12;
|
||||
public const int NPCShop = 13;
|
||||
public const int ClothCustomizationStyle = 14;
|
||||
public const int ClothCustomizationColor = 15;
|
||||
public const int PVP = 16;
|
||||
public const int InfoAccs = 17;
|
||||
public const int BuilderAccs = 18;
|
||||
public const int BuffsOnEquipment = 19;
|
||||
public const int MainMenu = 1000;
|
||||
public const int IngameOptionsLeft = 1001;
|
||||
public const int IngameOptionsRight = 1002;
|
||||
public const int NPCChat = 1003;
|
||||
public const int FancyUI = 1004;
|
||||
}
|
||||
}
|
219
UI/Gamepad/GamepadPointID.cs
Normal file
219
UI/Gamepad/GamepadPointID.cs
Normal file
|
@ -0,0 +1,219 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.UI.Gamepad.GamepadPointID
|
||||
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
namespace Terraria.UI.Gamepad
|
||||
{
|
||||
public static class GamepadPointID
|
||||
{
|
||||
public const int EndUp = -1;
|
||||
public const int EndDown = -2;
|
||||
public const int EndLeft = -3;
|
||||
public const int EndRight = -4;
|
||||
public const int Inventory0 = 0;
|
||||
public const int Inventory1 = 1;
|
||||
public const int Inventory2 = 2;
|
||||
public const int Inventory3 = 3;
|
||||
public const int Inventory4 = 4;
|
||||
public const int Inventory5 = 5;
|
||||
public const int Inventory6 = 6;
|
||||
public const int Inventory7 = 7;
|
||||
public const int Inventory8 = 8;
|
||||
public const int Inventory9 = 9;
|
||||
public const int Inventory10 = 10;
|
||||
public const int Inventory11 = 11;
|
||||
public const int Inventory12 = 12;
|
||||
public const int Inventory13 = 13;
|
||||
public const int Inventory14 = 14;
|
||||
public const int Inventory15 = 15;
|
||||
public const int Inventory16 = 16;
|
||||
public const int Inventory17 = 17;
|
||||
public const int Inventory18 = 18;
|
||||
public const int Inventory19 = 19;
|
||||
public const int Inventory20 = 20;
|
||||
public const int Inventory21 = 21;
|
||||
public const int Inventory22 = 22;
|
||||
public const int Inventory23 = 23;
|
||||
public const int Inventory24 = 24;
|
||||
public const int Inventory25 = 25;
|
||||
public const int Inventory26 = 26;
|
||||
public const int Inventory27 = 27;
|
||||
public const int Inventory28 = 28;
|
||||
public const int Inventory29 = 29;
|
||||
public const int Inventory30 = 30;
|
||||
public const int Inventory31 = 31;
|
||||
public const int Inventory32 = 32;
|
||||
public const int Inventory33 = 33;
|
||||
public const int Inventory34 = 34;
|
||||
public const int Inventory35 = 35;
|
||||
public const int Inventory36 = 36;
|
||||
public const int Inventory37 = 37;
|
||||
public const int Inventory38 = 38;
|
||||
public const int Inventory39 = 39;
|
||||
public const int Inventory40 = 40;
|
||||
public const int Inventory41 = 41;
|
||||
public const int Inventory42 = 42;
|
||||
public const int Inventory43 = 43;
|
||||
public const int Inventory44 = 44;
|
||||
public const int Inventory45 = 45;
|
||||
public const int Inventory46 = 46;
|
||||
public const int Inventory47 = 47;
|
||||
public const int Inventory48 = 48;
|
||||
public const int Inventory49 = 49;
|
||||
public const int Coins0 = 50;
|
||||
public const int Coins1 = 51;
|
||||
public const int Coins2 = 52;
|
||||
public const int Coins3 = 53;
|
||||
public const int Ammo0 = 54;
|
||||
public const int Ammo1 = 55;
|
||||
public const int Ammo2 = 56;
|
||||
public const int Ammo3 = 57;
|
||||
public const int Armor0 = 100;
|
||||
public const int Armor1 = 101;
|
||||
public const int Armor2 = 102;
|
||||
public const int Armor3 = 103;
|
||||
public const int Armor4 = 104;
|
||||
public const int Armor5 = 105;
|
||||
public const int Armor6 = 106;
|
||||
public const int Armor7 = 107;
|
||||
public const int Armor8 = 108;
|
||||
public const int Armor9 = 109;
|
||||
public const int Armor10 = 110;
|
||||
public const int Armor11 = 111;
|
||||
public const int Armor12 = 112;
|
||||
public const int Armor13 = 113;
|
||||
public const int Armor14 = 114;
|
||||
public const int Armor15 = 115;
|
||||
public const int Armor16 = 116;
|
||||
public const int Armor17 = 117;
|
||||
public const int Armor18 = 118;
|
||||
public const int Armor19 = 119;
|
||||
public const int DyeArmor0 = 120;
|
||||
public const int DyeArmor1 = 121;
|
||||
public const int DyeArmor2 = 122;
|
||||
public const int DyeArmor3 = 123;
|
||||
public const int DyeArmor4 = 124;
|
||||
public const int DyeArmor5 = 125;
|
||||
public const int DyeArmor6 = 126;
|
||||
public const int DyeArmor7 = 127;
|
||||
public const int DyeArmor8 = 128;
|
||||
public const int DyeArmor9 = 129;
|
||||
public const int Equips0 = 180;
|
||||
public const int Equips1 = 181;
|
||||
public const int Equips2 = 182;
|
||||
public const int Equips3 = 183;
|
||||
public const int Equips4 = 184;
|
||||
public const int DyeEquips0 = 185;
|
||||
public const int DyeEquips1 = 186;
|
||||
public const int DyeEquips2 = 187;
|
||||
public const int DyeEquips3 = 188;
|
||||
public const int DyeEquips4 = 189;
|
||||
public const int TrashItem = 300;
|
||||
public const int QuickStackToNearbyChests = 301;
|
||||
public const int SortInventory = 302;
|
||||
public const int ReforgeSlot = 303;
|
||||
public const int ReforgeButton = 304;
|
||||
public const int TabEquips = 305;
|
||||
public const int TabNPCs = 306;
|
||||
public const int TabCamera = 307;
|
||||
public const int TabSettings = 308;
|
||||
public const int Chest0 = 400;
|
||||
public const int Chest1 = 401;
|
||||
public const int Chest2 = 402;
|
||||
public const int Chest3 = 403;
|
||||
public const int Chest4 = 404;
|
||||
public const int Chest5 = 405;
|
||||
public const int Chest6 = 406;
|
||||
public const int Chest7 = 407;
|
||||
public const int Chest8 = 408;
|
||||
public const int Chest9 = 409;
|
||||
public const int Chest10 = 410;
|
||||
public const int Chest11 = 411;
|
||||
public const int Chest12 = 412;
|
||||
public const int Chest13 = 413;
|
||||
public const int Chest14 = 414;
|
||||
public const int Chest15 = 415;
|
||||
public const int Chest16 = 416;
|
||||
public const int Chest17 = 417;
|
||||
public const int Chest18 = 418;
|
||||
public const int Chest19 = 419;
|
||||
public const int Chest20 = 420;
|
||||
public const int Chest21 = 421;
|
||||
public const int Chest22 = 422;
|
||||
public const int Chest23 = 423;
|
||||
public const int Chest24 = 424;
|
||||
public const int Chest25 = 425;
|
||||
public const int Chest26 = 426;
|
||||
public const int Chest27 = 427;
|
||||
public const int Chest28 = 428;
|
||||
public const int Chest29 = 429;
|
||||
public const int Chest30 = 430;
|
||||
public const int Chest31 = 431;
|
||||
public const int Chest32 = 432;
|
||||
public const int Chest33 = 433;
|
||||
public const int Chest34 = 434;
|
||||
public const int Chest35 = 435;
|
||||
public const int Chest36 = 436;
|
||||
public const int Chest37 = 437;
|
||||
public const int Chest38 = 438;
|
||||
public const int Chest39 = 439;
|
||||
public const int ChestActLootAll = 500;
|
||||
public const int ChestActDepositAll = 501;
|
||||
public const int ChestActQuickStack = 502;
|
||||
public const int ChestActRestock = 503;
|
||||
public const int ChestActRenameChest = 504;
|
||||
public const int ChestSort = 505;
|
||||
public const int NPCHousing0 = 600;
|
||||
public const int CraftsBig = 700;
|
||||
public const int CraftsSmall = 1500;
|
||||
public const int PVP0 = 1550;
|
||||
public const int MainMenu = 2000;
|
||||
public const int MenuHack1 = 2001;
|
||||
public const int MenuHack2 = 2002;
|
||||
public const int MenuHack3 = 2003;
|
||||
public const int MenuHack4 = 2004;
|
||||
public const int MenuHack5 = 2005;
|
||||
public const int MenuHack6 = 2006;
|
||||
public const int MenuHack7 = 2007;
|
||||
public const int MenuHack8 = 2008;
|
||||
public const int MenuHack9 = 2009;
|
||||
public const int MenuHack10 = 2010;
|
||||
public const int MenuHack11 = 2011;
|
||||
public const int MenuHack12 = 2012;
|
||||
public const int MenuHack13 = 2013;
|
||||
public const int MenuHack14 = 2014;
|
||||
public const int MenuHack15 = 2015;
|
||||
public const int MenuHack16 = 2016;
|
||||
public const int MenuHack17 = 2017;
|
||||
public const int MenuHack18 = 2018;
|
||||
public const int MenuHack19 = 2019;
|
||||
public const int NPCChat0 = 2500;
|
||||
public const int NPCChat1 = 2501;
|
||||
public const int NPCChat2 = 2502;
|
||||
public const int StylistColorH = 2600;
|
||||
public const int StylistColorS = 2601;
|
||||
public const int StylistColorL = 2602;
|
||||
public const int StylistColorOk = 2603;
|
||||
public const int StylistColorClose = 2604;
|
||||
public const int StylistStyle0 = 2605;
|
||||
public const int NPCShop0 = 2700;
|
||||
public const int NPCShop39 = 2739;
|
||||
public const int ClothColorH = 2800;
|
||||
public const int ClothColorS = 2801;
|
||||
public const int ClothColorL = 2802;
|
||||
public const int ClothColorOk = 2803;
|
||||
public const int ClothColorClose = 2804;
|
||||
public const int ClothStyle = 2805;
|
||||
public const int ClothPicker0 = 2806;
|
||||
public const int ClothPicker1 = 2807;
|
||||
public const int ClothPicker2 = 2808;
|
||||
public const int ClothPicker3 = 2809;
|
||||
public const int IngameOptionsLeft0 = 2900;
|
||||
public const int IngameOptionsRight0 = 2930;
|
||||
public const int FancyUI0 = 3000;
|
||||
public const int BuilderAccs = 4000;
|
||||
public const int BuffsForEquips = 9000;
|
||||
}
|
||||
}
|
102
UI/Gamepad/UILinkPage.cs
Normal file
102
UI/Gamepad/UILinkPage.cs
Normal file
|
@ -0,0 +1,102 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.UI.Gamepad.UILinkPage
|
||||
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Terraria.UI.Gamepad
|
||||
{
|
||||
public class UILinkPage
|
||||
{
|
||||
public int ID;
|
||||
public int PageOnLeft = -1;
|
||||
public int PageOnRight = -1;
|
||||
public int DefaultPoint;
|
||||
public int CurrentPoint;
|
||||
public Dictionary<int, UILinkPoint> LinkMap = new Dictionary<int, UILinkPoint>();
|
||||
|
||||
public event Action<int, int> ReachEndEvent;
|
||||
|
||||
public event Action TravelEvent;
|
||||
|
||||
public event Action LeaveEvent;
|
||||
|
||||
public event Action EnterEvent;
|
||||
|
||||
public event Action UpdateEvent;
|
||||
|
||||
public event Func<bool> IsValidEvent;
|
||||
|
||||
public event Func<bool> CanEnterEvent;
|
||||
|
||||
public UILinkPage()
|
||||
{
|
||||
}
|
||||
|
||||
public UILinkPage(int id) => this.ID = id;
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (this.UpdateEvent == null)
|
||||
return;
|
||||
this.UpdateEvent();
|
||||
}
|
||||
|
||||
public void Leave()
|
||||
{
|
||||
if (this.LeaveEvent == null)
|
||||
return;
|
||||
this.LeaveEvent();
|
||||
}
|
||||
|
||||
public void Enter()
|
||||
{
|
||||
if (this.EnterEvent == null)
|
||||
return;
|
||||
this.EnterEvent();
|
||||
}
|
||||
|
||||
public bool IsValid() => this.IsValidEvent == null || this.IsValidEvent();
|
||||
|
||||
public bool CanEnter() => this.CanEnterEvent == null || this.CanEnterEvent();
|
||||
|
||||
public void TravelUp() => this.Travel(this.LinkMap[this.CurrentPoint].Up);
|
||||
|
||||
public void TravelDown() => this.Travel(this.LinkMap[this.CurrentPoint].Down);
|
||||
|
||||
public void TravelLeft() => this.Travel(this.LinkMap[this.CurrentPoint].Left);
|
||||
|
||||
public void TravelRight() => this.Travel(this.LinkMap[this.CurrentPoint].Right);
|
||||
|
||||
public void SwapPageLeft() => UILinkPointNavigator.ChangePage(this.PageOnLeft);
|
||||
|
||||
public void SwapPageRight() => UILinkPointNavigator.ChangePage(this.PageOnRight);
|
||||
|
||||
private void Travel(int next)
|
||||
{
|
||||
if (next < 0)
|
||||
{
|
||||
if (this.ReachEndEvent == null)
|
||||
return;
|
||||
this.ReachEndEvent(this.CurrentPoint, next);
|
||||
if (this.TravelEvent == null)
|
||||
return;
|
||||
this.TravelEvent();
|
||||
}
|
||||
else
|
||||
{
|
||||
UILinkPointNavigator.ChangePoint(next);
|
||||
if (this.TravelEvent == null)
|
||||
return;
|
||||
this.TravelEvent();
|
||||
}
|
||||
}
|
||||
|
||||
public event Func<string> OnSpecialInteracts;
|
||||
|
||||
public string SpecialInteractions() => this.OnSpecialInteracts != null ? this.OnSpecialInteracts() : string.Empty;
|
||||
}
|
||||
}
|
48
UI/Gamepad/UILinkPoint.cs
Normal file
48
UI/Gamepad/UILinkPoint.cs
Normal file
|
@ -0,0 +1,48 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.UI.Gamepad.UILinkPoint
|
||||
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
|
||||
namespace Terraria.UI.Gamepad
|
||||
{
|
||||
public class UILinkPoint
|
||||
{
|
||||
public int ID;
|
||||
public bool Enabled;
|
||||
public Vector2 Position;
|
||||
public int Left;
|
||||
public int Right;
|
||||
public int Up;
|
||||
public int Down;
|
||||
|
||||
public int Page { get; private set; }
|
||||
|
||||
public UILinkPoint(int id, bool enabled, int left, int right, int up, int down)
|
||||
{
|
||||
this.ID = id;
|
||||
this.Enabled = enabled;
|
||||
this.Left = left;
|
||||
this.Right = right;
|
||||
this.Up = up;
|
||||
this.Down = down;
|
||||
}
|
||||
|
||||
public void SetPage(int page) => this.Page = page;
|
||||
|
||||
public void Unlink()
|
||||
{
|
||||
this.Left = -3;
|
||||
this.Right = -4;
|
||||
this.Up = -1;
|
||||
this.Down = -2;
|
||||
}
|
||||
|
||||
public event Func<string> OnSpecialInteracts;
|
||||
|
||||
public string SpecialInteractions() => this.OnSpecialInteracts != null ? this.OnSpecialInteracts() : string.Empty;
|
||||
}
|
||||
}
|
315
UI/Gamepad/UILinkPointNavigator.cs
Normal file
315
UI/Gamepad/UILinkPointNavigator.cs
Normal file
|
@ -0,0 +1,315 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.UI.Gamepad.UILinkPointNavigator
|
||||
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
|
||||
// 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.GameInput;
|
||||
|
||||
namespace Terraria.UI.Gamepad
|
||||
{
|
||||
public class UILinkPointNavigator
|
||||
{
|
||||
public static Dictionary<int, UILinkPage> Pages = new Dictionary<int, UILinkPage>();
|
||||
public static Dictionary<int, UILinkPoint> Points = new Dictionary<int, UILinkPoint>();
|
||||
public static int CurrentPage = 1000;
|
||||
public static int OldPage = 1000;
|
||||
private static int XCooldown = 0;
|
||||
private static int YCooldown = 0;
|
||||
private static Vector2 LastInput;
|
||||
private static int PageLeftCD = 0;
|
||||
private static int PageRightCD = 0;
|
||||
public static bool InUse;
|
||||
public static int OverridePoint = -1;
|
||||
|
||||
public static int CurrentPoint => UILinkPointNavigator.Pages[UILinkPointNavigator.CurrentPage].CurrentPoint;
|
||||
|
||||
public static bool Available => Main.playerInventory || Main.ingameOptionsWindow || Main.player[Main.myPlayer].talkNPC != -1 || Main.player[Main.myPlayer].sign != -1 || Main.mapFullscreen || Main.clothesWindow || Main.MenuUI.IsVisible || Main.InGameUI.IsVisible;
|
||||
|
||||
public static void GoToDefaultPage(int specialFlag = 0)
|
||||
{
|
||||
if (Main.MenuUI.IsVisible)
|
||||
UILinkPointNavigator.CurrentPage = 1004;
|
||||
else if (Main.InGameUI.IsVisible || specialFlag == 1)
|
||||
UILinkPointNavigator.CurrentPage = 1004;
|
||||
else if (Main.gameMenu)
|
||||
UILinkPointNavigator.CurrentPage = 1000;
|
||||
else if (Main.ingameOptionsWindow)
|
||||
UILinkPointNavigator.CurrentPage = 1001;
|
||||
else if (Main.hairWindow)
|
||||
UILinkPointNavigator.CurrentPage = 12;
|
||||
else if (Main.clothesWindow)
|
||||
UILinkPointNavigator.CurrentPage = 15;
|
||||
else if (Main.npcShop != 0)
|
||||
UILinkPointNavigator.CurrentPage = 13;
|
||||
else if (Main.InGuideCraftMenu)
|
||||
UILinkPointNavigator.CurrentPage = 9;
|
||||
else if (Main.InReforgeMenu)
|
||||
UILinkPointNavigator.CurrentPage = 5;
|
||||
else if (Main.player[Main.myPlayer].chest != -1)
|
||||
UILinkPointNavigator.CurrentPage = 4;
|
||||
else if (Main.player[Main.myPlayer].talkNPC != -1 || Main.player[Main.myPlayer].sign != -1)
|
||||
UILinkPointNavigator.CurrentPage = 1003;
|
||||
else
|
||||
UILinkPointNavigator.CurrentPage = 0;
|
||||
}
|
||||
|
||||
public static void Update()
|
||||
{
|
||||
bool inUse = UILinkPointNavigator.InUse;
|
||||
UILinkPointNavigator.InUse = false;
|
||||
bool flag1 = true;
|
||||
if (flag1)
|
||||
{
|
||||
switch (PlayerInput.CurrentInputMode)
|
||||
{
|
||||
case InputMode.Keyboard:
|
||||
case InputMode.KeyboardUI:
|
||||
case InputMode.Mouse:
|
||||
if (!Main.gameMenu)
|
||||
{
|
||||
flag1 = false;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (flag1 && PlayerInput.NavigatorRebindingLock > 0)
|
||||
flag1 = false;
|
||||
if (flag1 && !Main.gameMenu && !PlayerInput.UsingGamepadUI)
|
||||
flag1 = false;
|
||||
if (flag1 && !Main.gameMenu && PlayerInput.InBuildingMode)
|
||||
flag1 = false;
|
||||
if (flag1 && !Main.gameMenu && !UILinkPointNavigator.Available)
|
||||
flag1 = false;
|
||||
bool flag2 = false;
|
||||
UILinkPage uiLinkPage;
|
||||
if (!UILinkPointNavigator.Pages.TryGetValue(UILinkPointNavigator.CurrentPage, out uiLinkPage))
|
||||
flag2 = true;
|
||||
else if (!uiLinkPage.IsValid())
|
||||
flag2 = true;
|
||||
if (flag2)
|
||||
{
|
||||
UILinkPointNavigator.GoToDefaultPage();
|
||||
UILinkPointNavigator.ProcessChanges();
|
||||
flag1 = false;
|
||||
}
|
||||
if (inUse != flag1)
|
||||
{
|
||||
if (!flag1)
|
||||
{
|
||||
uiLinkPage.Leave();
|
||||
UILinkPointNavigator.GoToDefaultPage();
|
||||
UILinkPointNavigator.ProcessChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
UILinkPointNavigator.GoToDefaultPage();
|
||||
UILinkPointNavigator.ProcessChanges();
|
||||
uiLinkPage.Enter();
|
||||
}
|
||||
if (flag1)
|
||||
{
|
||||
Main.player[Main.myPlayer].releaseInventory = false;
|
||||
Main.player[Main.myPlayer].releaseUseTile = false;
|
||||
PlayerInput.LockTileUseButton = true;
|
||||
}
|
||||
if (!Main.gameMenu)
|
||||
{
|
||||
if (flag1)
|
||||
PlayerInput.NavigatorCachePosition();
|
||||
else
|
||||
PlayerInput.NavigatorUnCachePosition();
|
||||
}
|
||||
}
|
||||
if (!flag1)
|
||||
return;
|
||||
UILinkPointNavigator.InUse = true;
|
||||
UILinkPointNavigator.OverridePoint = -1;
|
||||
if (UILinkPointNavigator.PageLeftCD > 0)
|
||||
--UILinkPointNavigator.PageLeftCD;
|
||||
if (UILinkPointNavigator.PageRightCD > 0)
|
||||
--UILinkPointNavigator.PageRightCD;
|
||||
Vector2 navigatorDirections = PlayerInput.Triggers.Current.GetNavigatorDirections();
|
||||
bool flag3 = PlayerInput.Triggers.Current.HotbarMinus && !PlayerInput.Triggers.Current.HotbarPlus;
|
||||
int num1 = !PlayerInput.Triggers.Current.HotbarPlus ? 0 : (!PlayerInput.Triggers.Current.HotbarMinus ? 1 : 0);
|
||||
if (!flag3)
|
||||
UILinkPointNavigator.PageLeftCD = 0;
|
||||
if (num1 == 0)
|
||||
UILinkPointNavigator.PageRightCD = 0;
|
||||
bool flag4 = flag3 && UILinkPointNavigator.PageLeftCD == 0;
|
||||
int num2 = num1 == 0 ? 0 : (UILinkPointNavigator.PageRightCD == 0 ? 1 : 0);
|
||||
if ((double) UILinkPointNavigator.LastInput.X != (double) navigatorDirections.X)
|
||||
UILinkPointNavigator.XCooldown = 0;
|
||||
if ((double) UILinkPointNavigator.LastInput.Y != (double) navigatorDirections.Y)
|
||||
UILinkPointNavigator.YCooldown = 0;
|
||||
if (UILinkPointNavigator.XCooldown > 0)
|
||||
--UILinkPointNavigator.XCooldown;
|
||||
if (UILinkPointNavigator.YCooldown > 0)
|
||||
--UILinkPointNavigator.YCooldown;
|
||||
UILinkPointNavigator.LastInput = navigatorDirections;
|
||||
if (flag4)
|
||||
UILinkPointNavigator.PageLeftCD = 16;
|
||||
if (num2 != 0)
|
||||
UILinkPointNavigator.PageRightCD = 16;
|
||||
UILinkPointNavigator.Pages[UILinkPointNavigator.CurrentPage].Update();
|
||||
int num3 = 10;
|
||||
if (!Main.gameMenu && Main.playerInventory && !Main.ingameOptionsWindow && !Main.inFancyUI && (UILinkPointNavigator.CurrentPage == 0 || UILinkPointNavigator.CurrentPage == 4 || UILinkPointNavigator.CurrentPage == 2 || UILinkPointNavigator.CurrentPage == 1))
|
||||
num3 = PlayerInput.CurrentProfile.InventoryMoveCD;
|
||||
if ((double) navigatorDirections.X == -1.0 && UILinkPointNavigator.XCooldown == 0)
|
||||
{
|
||||
UILinkPointNavigator.XCooldown = num3;
|
||||
UILinkPointNavigator.Pages[UILinkPointNavigator.CurrentPage].TravelLeft();
|
||||
}
|
||||
if ((double) navigatorDirections.X == 1.0 && UILinkPointNavigator.XCooldown == 0)
|
||||
{
|
||||
UILinkPointNavigator.XCooldown = num3;
|
||||
UILinkPointNavigator.Pages[UILinkPointNavigator.CurrentPage].TravelRight();
|
||||
}
|
||||
if ((double) navigatorDirections.Y == -1.0 && UILinkPointNavigator.YCooldown == 0)
|
||||
{
|
||||
UILinkPointNavigator.YCooldown = num3;
|
||||
UILinkPointNavigator.Pages[UILinkPointNavigator.CurrentPage].TravelUp();
|
||||
}
|
||||
if ((double) navigatorDirections.Y == 1.0 && UILinkPointNavigator.YCooldown == 0)
|
||||
{
|
||||
UILinkPointNavigator.YCooldown = num3;
|
||||
UILinkPointNavigator.Pages[UILinkPointNavigator.CurrentPage].TravelDown();
|
||||
}
|
||||
UILinkPointNavigator.XCooldown = UILinkPointNavigator.YCooldown = Math.Max(UILinkPointNavigator.XCooldown, UILinkPointNavigator.YCooldown);
|
||||
if (flag4)
|
||||
UILinkPointNavigator.Pages[UILinkPointNavigator.CurrentPage].SwapPageLeft();
|
||||
if (num2 != 0)
|
||||
UILinkPointNavigator.Pages[UILinkPointNavigator.CurrentPage].SwapPageRight();
|
||||
if (PlayerInput.Triggers.Current.UsedMovementKey)
|
||||
{
|
||||
Vector2 position = UILinkPointNavigator.Points[UILinkPointNavigator.CurrentPoint].Position;
|
||||
Vector2 vector2_1 = new Vector2((float) PlayerInput.MouseX, (float) PlayerInput.MouseY);
|
||||
float num4 = 0.3f;
|
||||
if (PlayerInput.InvisibleGamepadInMenus)
|
||||
num4 = 1f;
|
||||
Vector2 vector2_2 = position;
|
||||
double num5 = (double) num4;
|
||||
Vector2 vector2_3 = Vector2.Lerp(vector2_1, vector2_2, (float) num5);
|
||||
if (Main.gameMenu)
|
||||
{
|
||||
if ((double) Math.Abs(vector2_3.X - position.X) <= 5.0)
|
||||
vector2_3.X = position.X;
|
||||
if ((double) Math.Abs(vector2_3.Y - position.Y) <= 5.0)
|
||||
vector2_3.Y = position.Y;
|
||||
}
|
||||
PlayerInput.MouseX = (int) vector2_3.X;
|
||||
PlayerInput.MouseY = (int) vector2_3.Y;
|
||||
}
|
||||
UILinkPointNavigator.ResetFlagsEnd();
|
||||
}
|
||||
|
||||
public static void ResetFlagsEnd()
|
||||
{
|
||||
UILinkPointNavigator.Shortcuts.OPTIONS_BUTTON_SPECIALFEATURE = 0;
|
||||
UILinkPointNavigator.Shortcuts.BackButtonLock = false;
|
||||
UILinkPointNavigator.Shortcuts.BackButtonCommand = 0;
|
||||
}
|
||||
|
||||
public static string GetInstructions()
|
||||
{
|
||||
string str1 = UILinkPointNavigator.Pages[UILinkPointNavigator.CurrentPage].SpecialInteractions();
|
||||
string str2 = UILinkPointNavigator.Points[UILinkPointNavigator.CurrentPoint].SpecialInteractions();
|
||||
if (!string.IsNullOrEmpty(str2))
|
||||
{
|
||||
if (string.IsNullOrEmpty(str1))
|
||||
return str2;
|
||||
str1 = str1 + " " + str2;
|
||||
}
|
||||
return str1;
|
||||
}
|
||||
|
||||
public static void SetPosition(int ID, Vector2 Position) => UILinkPointNavigator.Points[ID].Position = Position * Main.UIScale;
|
||||
|
||||
public static void RegisterPage(UILinkPage page, int ID, bool automatedDefault = true)
|
||||
{
|
||||
if (automatedDefault)
|
||||
page.DefaultPoint = page.LinkMap.Keys.First<int>();
|
||||
page.CurrentPoint = page.DefaultPoint;
|
||||
page.ID = ID;
|
||||
UILinkPointNavigator.Pages.Add(page.ID, page);
|
||||
foreach (KeyValuePair<int, UILinkPoint> link in page.LinkMap)
|
||||
{
|
||||
link.Value.SetPage(ID);
|
||||
UILinkPointNavigator.Points.Add(link.Key, link.Value);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ChangePage(int PageID)
|
||||
{
|
||||
if (!UILinkPointNavigator.Pages.ContainsKey(PageID) || !UILinkPointNavigator.Pages[PageID].CanEnter())
|
||||
return;
|
||||
UILinkPointNavigator.CurrentPage = PageID;
|
||||
UILinkPointNavigator.ProcessChanges();
|
||||
}
|
||||
|
||||
public static void ChangePoint(int PointID)
|
||||
{
|
||||
if (!UILinkPointNavigator.Points.ContainsKey(PointID))
|
||||
return;
|
||||
UILinkPointNavigator.CurrentPage = UILinkPointNavigator.Points[PointID].Page;
|
||||
UILinkPointNavigator.OverridePoint = PointID;
|
||||
UILinkPointNavigator.ProcessChanges();
|
||||
}
|
||||
|
||||
public static void ProcessChanges()
|
||||
{
|
||||
UILinkPage page = UILinkPointNavigator.Pages[UILinkPointNavigator.OldPage];
|
||||
if (UILinkPointNavigator.OldPage != UILinkPointNavigator.CurrentPage)
|
||||
{
|
||||
page.Leave();
|
||||
if (!UILinkPointNavigator.Pages.TryGetValue(UILinkPointNavigator.CurrentPage, out page))
|
||||
{
|
||||
UILinkPointNavigator.GoToDefaultPage();
|
||||
UILinkPointNavigator.ProcessChanges();
|
||||
UILinkPointNavigator.OverridePoint = -1;
|
||||
}
|
||||
page.CurrentPoint = page.DefaultPoint;
|
||||
page.Enter();
|
||||
page.Update();
|
||||
UILinkPointNavigator.OldPage = UILinkPointNavigator.CurrentPage;
|
||||
}
|
||||
if (UILinkPointNavigator.OverridePoint == -1 || !page.LinkMap.ContainsKey(UILinkPointNavigator.OverridePoint))
|
||||
return;
|
||||
page.CurrentPoint = UILinkPointNavigator.OverridePoint;
|
||||
}
|
||||
|
||||
public static class Shortcuts
|
||||
{
|
||||
public static int NPCS_IconsPerColumn = 100;
|
||||
public static int NPCS_IconsTotal = 0;
|
||||
public static int NPCS_LastHovered = -1;
|
||||
public static bool NPCS_IconsDisplay = false;
|
||||
public static int CRAFT_IconsPerRow = 100;
|
||||
public static int CRAFT_IconsPerColumn = 100;
|
||||
public static int CRAFT_CurrentIngridientsCount = 0;
|
||||
public static int CRAFT_CurrentRecipeBig = 0;
|
||||
public static int CRAFT_CurrentRecipeSmall = 0;
|
||||
public static bool NPCCHAT_ButtonsLeft = false;
|
||||
public static bool NPCCHAT_ButtonsMiddle = false;
|
||||
public static bool NPCCHAT_ButtonsRight = false;
|
||||
public static int INGAMEOPTIONS_BUTTONS_LEFT = 0;
|
||||
public static int INGAMEOPTIONS_BUTTONS_RIGHT = 0;
|
||||
public static int OPTIONS_BUTTON_SPECIALFEATURE = 0;
|
||||
public static int BackButtonCommand = 0;
|
||||
public static bool BackButtonInUse = false;
|
||||
public static bool BackButtonLock = false;
|
||||
public static int FANCYUI_HIGHEST_INDEX = 1;
|
||||
public static int FANCYUI_SPECIAL_INSTRUCTIONS = 0;
|
||||
public static int INFOACCCOUNT = 0;
|
||||
public static int BUILDERACCCOUNT = 0;
|
||||
public static int BUFFS_PER_COLUMN = 0;
|
||||
public static int BUFFS_DRAWN = 0;
|
||||
public static int INV_MOVE_OPTION_CD = 0;
|
||||
}
|
||||
}
|
||||
}
|
167
UI/IngameFancyUI.cs
Normal file
167
UI/IngameFancyUI.cs
Normal file
|
@ -0,0 +1,167 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.UI.IngameFancyUI
|
||||
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Terraria.Achievements;
|
||||
using Terraria.GameContent.UI.States;
|
||||
using Terraria.GameInput;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI.Gamepad;
|
||||
|
||||
namespace Terraria.UI
|
||||
{
|
||||
public class IngameFancyUI
|
||||
{
|
||||
private static bool CoverForOneUIFrame;
|
||||
|
||||
public static void CoverNextFrame() => IngameFancyUI.CoverForOneUIFrame = true;
|
||||
|
||||
public static bool CanCover()
|
||||
{
|
||||
if (!IngameFancyUI.CoverForOneUIFrame)
|
||||
return false;
|
||||
IngameFancyUI.CoverForOneUIFrame = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void OpenAchievements()
|
||||
{
|
||||
IngameFancyUI.CoverNextFrame();
|
||||
Main.playerInventory = false;
|
||||
Main.editChest = false;
|
||||
Main.npcChatText = "";
|
||||
Main.inFancyUI = true;
|
||||
Main.InGameUI.SetState((UIState) Main.AchievementsMenu);
|
||||
}
|
||||
|
||||
public static void OpenAchievementsAndGoto(Achievement achievement)
|
||||
{
|
||||
IngameFancyUI.OpenAchievements();
|
||||
Main.AchievementsMenu.GotoAchievement(achievement);
|
||||
}
|
||||
|
||||
public static void OpenKeybinds()
|
||||
{
|
||||
IngameFancyUI.CoverNextFrame();
|
||||
Main.playerInventory = false;
|
||||
Main.editChest = false;
|
||||
Main.npcChatText = "";
|
||||
Main.inFancyUI = true;
|
||||
Main.InGameUI.SetState((UIState) Main.ManageControlsMenu);
|
||||
}
|
||||
|
||||
public static bool CanShowVirtualKeyboard(int context) => UIVirtualKeyboard.CanDisplay(context);
|
||||
|
||||
public static void OpenVirtualKeyboard(int keyboardContext)
|
||||
{
|
||||
IngameFancyUI.CoverNextFrame();
|
||||
Main.PlaySound(12);
|
||||
string labelText = "";
|
||||
switch (keyboardContext)
|
||||
{
|
||||
case 1:
|
||||
Main.editSign = true;
|
||||
labelText = Language.GetTextValue("UI.EnterMessage");
|
||||
break;
|
||||
case 2:
|
||||
labelText = Language.GetTextValue("UI.EnterNewName");
|
||||
Player player = Main.player[Main.myPlayer];
|
||||
Main.npcChatText = Main.chest[player.chest].name;
|
||||
if (Main.tile[player.chestX, player.chestY].type == (ushort) 21)
|
||||
Main.defaultChestName = Lang.chestType[(int) Main.tile[player.chestX, player.chestY].frameX / 36].Value;
|
||||
if (Main.tile[player.chestX, player.chestY].type == (ushort) 467)
|
||||
Main.defaultChestName = Lang.chestType2[(int) Main.tile[player.chestX, player.chestY].frameX / 36].Value;
|
||||
if (Main.tile[player.chestX, player.chestY].type == (ushort) 88)
|
||||
Main.defaultChestName = Lang.dresserType[(int) Main.tile[player.chestX, player.chestY].frameX / 54].Value;
|
||||
if (Main.npcChatText == "")
|
||||
Main.npcChatText = Main.defaultChestName;
|
||||
Main.editChest = true;
|
||||
break;
|
||||
}
|
||||
Main.clrInput();
|
||||
if (!IngameFancyUI.CanShowVirtualKeyboard(keyboardContext))
|
||||
return;
|
||||
Main.inFancyUI = true;
|
||||
switch (keyboardContext)
|
||||
{
|
||||
case 1:
|
||||
Main.InGameUI.SetState((UIState) new UIVirtualKeyboard(labelText, Main.npcChatText, (UIVirtualKeyboard.KeyboardSubmitEvent) (s =>
|
||||
{
|
||||
Main.SubmitSignText();
|
||||
IngameFancyUI.Close();
|
||||
}), (Action) (() =>
|
||||
{
|
||||
Main.InputTextSignCancel();
|
||||
IngameFancyUI.Close();
|
||||
}), keyboardContext));
|
||||
break;
|
||||
case 2:
|
||||
Main.InGameUI.SetState((UIState) new UIVirtualKeyboard(labelText, Main.npcChatText, (UIVirtualKeyboard.KeyboardSubmitEvent) (s =>
|
||||
{
|
||||
ChestUI.RenameChestSubmit(Main.player[Main.myPlayer]);
|
||||
IngameFancyUI.Close();
|
||||
}), (Action) (() =>
|
||||
{
|
||||
ChestUI.RenameChestCancel();
|
||||
IngameFancyUI.Close();
|
||||
}), keyboardContext));
|
||||
break;
|
||||
}
|
||||
UILinkPointNavigator.GoToDefaultPage(1);
|
||||
}
|
||||
|
||||
public static void Close()
|
||||
{
|
||||
Main.inFancyUI = false;
|
||||
Main.PlaySound(11);
|
||||
if (!Main.gameMenu && (!(Main.InGameUI.CurrentState is UIVirtualKeyboard) || UIVirtualKeyboard.KeyboardContext == 2))
|
||||
Main.playerInventory = true;
|
||||
Main.InGameUI.SetState((UIState) null);
|
||||
UILinkPointNavigator.Shortcuts.FANCYUI_SPECIAL_INSTRUCTIONS = 0;
|
||||
}
|
||||
|
||||
public static bool Draw(SpriteBatch spriteBatch, GameTime gameTime)
|
||||
{
|
||||
if (!Main.gameMenu && Main.player[Main.myPlayer].dead && !Main.player[Main.myPlayer].ghost)
|
||||
{
|
||||
IngameFancyUI.Close();
|
||||
Main.playerInventory = false;
|
||||
return false;
|
||||
}
|
||||
bool flag = false;
|
||||
if (Main.InGameUI.CurrentState is UIVirtualKeyboard && UIVirtualKeyboard.KeyboardContext > 0)
|
||||
{
|
||||
if (!Main.inFancyUI)
|
||||
Main.InGameUI.SetState((UIState) null);
|
||||
if (Main.screenWidth >= 1705 || !PlayerInput.UsingGamepad)
|
||||
flag = true;
|
||||
}
|
||||
if (!Main.gameMenu)
|
||||
{
|
||||
Main.mouseText = false;
|
||||
if (Main.InGameUI != null && Main.InGameUI.IsElementUnderMouse())
|
||||
Main.player[Main.myPlayer].mouseInterface = true;
|
||||
Main.instance.GUIBarsDraw();
|
||||
if (Main.InGameUI.CurrentState is UIVirtualKeyboard && UIVirtualKeyboard.KeyboardContext > 0)
|
||||
Main.instance.GUIChatDraw();
|
||||
if (!Main.inFancyUI)
|
||||
Main.InGameUI.SetState((UIState) null);
|
||||
Main.instance.DrawMouseOver();
|
||||
Main.DrawCursor(Main.DrawThickCursor());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
public static void MouseOver()
|
||||
{
|
||||
if (!Main.inFancyUI || !Main.InGameUI.IsElementUnderMouse())
|
||||
return;
|
||||
Main.mouseText = true;
|
||||
}
|
||||
}
|
||||
}
|
15
UI/InterfaceScaleType.cs
Normal file
15
UI/InterfaceScaleType.cs
Normal file
|
@ -0,0 +1,15 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.UI.InterfaceScaleType
|
||||
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
namespace Terraria.UI
|
||||
{
|
||||
public enum InterfaceScaleType
|
||||
{
|
||||
Game,
|
||||
UI,
|
||||
None,
|
||||
}
|
||||
}
|
2204
UI/ItemSlot.cs
Normal file
2204
UI/ItemSlot.cs
Normal file
File diff suppressed because it is too large
Load diff
879
UI/ItemSorting.cs
Normal file
879
UI/ItemSorting.cs
Normal file
|
@ -0,0 +1,879 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.UI.ItemSorting
|
||||
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Terraria.ID;
|
||||
|
||||
namespace Terraria.UI
|
||||
{
|
||||
public class ItemSorting
|
||||
{
|
||||
private static List<ItemSorting.ItemSortingLayer> _layerList = new List<ItemSorting.ItemSortingLayer>();
|
||||
private static Dictionary<string, List<int>> _layerWhiteLists = new Dictionary<string, List<int>>();
|
||||
|
||||
public static void SetupWhiteLists()
|
||||
{
|
||||
ItemSorting._layerWhiteLists.Clear();
|
||||
List<ItemSorting.ItemSortingLayer> itemSortingLayerList = new List<ItemSorting.ItemSortingLayer>();
|
||||
List<Item> objList = new List<Item>();
|
||||
List<int> intList1 = new List<int>();
|
||||
itemSortingLayerList.Add(ItemSorting.ItemSortingLayers.WeaponsMelee);
|
||||
itemSortingLayerList.Add(ItemSorting.ItemSortingLayers.WeaponsRanged);
|
||||
itemSortingLayerList.Add(ItemSorting.ItemSortingLayers.WeaponsMagic);
|
||||
itemSortingLayerList.Add(ItemSorting.ItemSortingLayers.WeaponsMinions);
|
||||
itemSortingLayerList.Add(ItemSorting.ItemSortingLayers.WeaponsThrown);
|
||||
itemSortingLayerList.Add(ItemSorting.ItemSortingLayers.WeaponsAssorted);
|
||||
itemSortingLayerList.Add(ItemSorting.ItemSortingLayers.WeaponsAmmo);
|
||||
itemSortingLayerList.Add(ItemSorting.ItemSortingLayers.ToolsPicksaws);
|
||||
itemSortingLayerList.Add(ItemSorting.ItemSortingLayers.ToolsHamaxes);
|
||||
itemSortingLayerList.Add(ItemSorting.ItemSortingLayers.ToolsPickaxes);
|
||||
itemSortingLayerList.Add(ItemSorting.ItemSortingLayers.ToolsAxes);
|
||||
itemSortingLayerList.Add(ItemSorting.ItemSortingLayers.ToolsHammers);
|
||||
itemSortingLayerList.Add(ItemSorting.ItemSortingLayers.ToolsTerraforming);
|
||||
itemSortingLayerList.Add(ItemSorting.ItemSortingLayers.ToolsAmmoLeftovers);
|
||||
itemSortingLayerList.Add(ItemSorting.ItemSortingLayers.ArmorCombat);
|
||||
itemSortingLayerList.Add(ItemSorting.ItemSortingLayers.ArmorVanity);
|
||||
itemSortingLayerList.Add(ItemSorting.ItemSortingLayers.ArmorAccessories);
|
||||
itemSortingLayerList.Add(ItemSorting.ItemSortingLayers.EquipGrapple);
|
||||
itemSortingLayerList.Add(ItemSorting.ItemSortingLayers.EquipMount);
|
||||
itemSortingLayerList.Add(ItemSorting.ItemSortingLayers.EquipCart);
|
||||
itemSortingLayerList.Add(ItemSorting.ItemSortingLayers.EquipLightPet);
|
||||
itemSortingLayerList.Add(ItemSorting.ItemSortingLayers.EquipVanityPet);
|
||||
itemSortingLayerList.Add(ItemSorting.ItemSortingLayers.PotionsDyes);
|
||||
itemSortingLayerList.Add(ItemSorting.ItemSortingLayers.PotionsHairDyes);
|
||||
itemSortingLayerList.Add(ItemSorting.ItemSortingLayers.PotionsLife);
|
||||
itemSortingLayerList.Add(ItemSorting.ItemSortingLayers.PotionsMana);
|
||||
itemSortingLayerList.Add(ItemSorting.ItemSortingLayers.PotionsElixirs);
|
||||
itemSortingLayerList.Add(ItemSorting.ItemSortingLayers.PotionsBuffs);
|
||||
itemSortingLayerList.Add(ItemSorting.ItemSortingLayers.MiscValuables);
|
||||
itemSortingLayerList.Add(ItemSorting.ItemSortingLayers.MiscPainting);
|
||||
itemSortingLayerList.Add(ItemSorting.ItemSortingLayers.MiscWiring);
|
||||
itemSortingLayerList.Add(ItemSorting.ItemSortingLayers.MiscMaterials);
|
||||
itemSortingLayerList.Add(ItemSorting.ItemSortingLayers.MiscRopes);
|
||||
itemSortingLayerList.Add(ItemSorting.ItemSortingLayers.MiscExtractinator);
|
||||
itemSortingLayerList.Add(ItemSorting.ItemSortingLayers.LastMaterials);
|
||||
itemSortingLayerList.Add(ItemSorting.ItemSortingLayers.LastTilesImportant);
|
||||
itemSortingLayerList.Add(ItemSorting.ItemSortingLayers.LastTilesCommon);
|
||||
itemSortingLayerList.Add(ItemSorting.ItemSortingLayers.LastNotTrash);
|
||||
itemSortingLayerList.Add(ItemSorting.ItemSortingLayers.LastTrash);
|
||||
for (int type = -48; type < 3930; ++type)
|
||||
{
|
||||
Item obj = new Item();
|
||||
obj.netDefaults(type);
|
||||
objList.Add(obj);
|
||||
intList1.Add(type + 48);
|
||||
}
|
||||
Item[] array = objList.ToArray();
|
||||
foreach (ItemSorting.ItemSortingLayer itemSortingLayer in itemSortingLayerList)
|
||||
{
|
||||
List<int> intList2 = itemSortingLayer.SortingMethod(itemSortingLayer, array, intList1);
|
||||
List<int> intList3 = new List<int>();
|
||||
for (int index = 0; index < intList2.Count; ++index)
|
||||
intList3.Add(array[intList2[index]].netID);
|
||||
ItemSorting._layerWhiteLists.Add(itemSortingLayer.Name, intList3);
|
||||
}
|
||||
}
|
||||
|
||||
private static void SetupSortingPriorities()
|
||||
{
|
||||
Player player = Main.player[Main.myPlayer];
|
||||
ItemSorting._layerList.Clear();
|
||||
List<float> floatList = new List<float>()
|
||||
{
|
||||
player.meleeDamage,
|
||||
player.rangedDamage,
|
||||
player.magicDamage,
|
||||
player.minionDamage,
|
||||
player.thrownDamage
|
||||
};
|
||||
floatList.Sort((Comparison<float>) ((x, y) => y.CompareTo(x)));
|
||||
for (int index = 0; index < 5; ++index)
|
||||
{
|
||||
if (!ItemSorting._layerList.Contains(ItemSorting.ItemSortingLayers.WeaponsMelee) && (double) player.meleeDamage == (double) floatList[0])
|
||||
{
|
||||
floatList.RemoveAt(0);
|
||||
ItemSorting._layerList.Add(ItemSorting.ItemSortingLayers.WeaponsMelee);
|
||||
}
|
||||
if (!ItemSorting._layerList.Contains(ItemSorting.ItemSortingLayers.WeaponsRanged) && (double) player.rangedDamage == (double) floatList[0])
|
||||
{
|
||||
floatList.RemoveAt(0);
|
||||
ItemSorting._layerList.Add(ItemSorting.ItemSortingLayers.WeaponsRanged);
|
||||
}
|
||||
if (!ItemSorting._layerList.Contains(ItemSorting.ItemSortingLayers.WeaponsMagic) && (double) player.magicDamage == (double) floatList[0])
|
||||
{
|
||||
floatList.RemoveAt(0);
|
||||
ItemSorting._layerList.Add(ItemSorting.ItemSortingLayers.WeaponsMagic);
|
||||
}
|
||||
if (!ItemSorting._layerList.Contains(ItemSorting.ItemSortingLayers.WeaponsMinions) && (double) player.minionDamage == (double) floatList[0])
|
||||
{
|
||||
floatList.RemoveAt(0);
|
||||
ItemSorting._layerList.Add(ItemSorting.ItemSortingLayers.WeaponsMinions);
|
||||
}
|
||||
if (!ItemSorting._layerList.Contains(ItemSorting.ItemSortingLayers.WeaponsThrown) && (double) player.thrownDamage == (double) floatList[0])
|
||||
{
|
||||
floatList.RemoveAt(0);
|
||||
ItemSorting._layerList.Add(ItemSorting.ItemSortingLayers.WeaponsThrown);
|
||||
}
|
||||
}
|
||||
ItemSorting._layerList.Add(ItemSorting.ItemSortingLayers.WeaponsAssorted);
|
||||
ItemSorting._layerList.Add(ItemSorting.ItemSortingLayers.WeaponsAmmo);
|
||||
ItemSorting._layerList.Add(ItemSorting.ItemSortingLayers.ToolsPicksaws);
|
||||
ItemSorting._layerList.Add(ItemSorting.ItemSortingLayers.ToolsHamaxes);
|
||||
ItemSorting._layerList.Add(ItemSorting.ItemSortingLayers.ToolsPickaxes);
|
||||
ItemSorting._layerList.Add(ItemSorting.ItemSortingLayers.ToolsAxes);
|
||||
ItemSorting._layerList.Add(ItemSorting.ItemSortingLayers.ToolsHammers);
|
||||
ItemSorting._layerList.Add(ItemSorting.ItemSortingLayers.ToolsTerraforming);
|
||||
ItemSorting._layerList.Add(ItemSorting.ItemSortingLayers.ToolsAmmoLeftovers);
|
||||
ItemSorting._layerList.Add(ItemSorting.ItemSortingLayers.ArmorCombat);
|
||||
ItemSorting._layerList.Add(ItemSorting.ItemSortingLayers.ArmorVanity);
|
||||
ItemSorting._layerList.Add(ItemSorting.ItemSortingLayers.ArmorAccessories);
|
||||
ItemSorting._layerList.Add(ItemSorting.ItemSortingLayers.EquipGrapple);
|
||||
ItemSorting._layerList.Add(ItemSorting.ItemSortingLayers.EquipMount);
|
||||
ItemSorting._layerList.Add(ItemSorting.ItemSortingLayers.EquipCart);
|
||||
ItemSorting._layerList.Add(ItemSorting.ItemSortingLayers.EquipLightPet);
|
||||
ItemSorting._layerList.Add(ItemSorting.ItemSortingLayers.EquipVanityPet);
|
||||
ItemSorting._layerList.Add(ItemSorting.ItemSortingLayers.PotionsDyes);
|
||||
ItemSorting._layerList.Add(ItemSorting.ItemSortingLayers.PotionsHairDyes);
|
||||
ItemSorting._layerList.Add(ItemSorting.ItemSortingLayers.PotionsLife);
|
||||
ItemSorting._layerList.Add(ItemSorting.ItemSortingLayers.PotionsMana);
|
||||
ItemSorting._layerList.Add(ItemSorting.ItemSortingLayers.PotionsElixirs);
|
||||
ItemSorting._layerList.Add(ItemSorting.ItemSortingLayers.PotionsBuffs);
|
||||
ItemSorting._layerList.Add(ItemSorting.ItemSortingLayers.MiscValuables);
|
||||
ItemSorting._layerList.Add(ItemSorting.ItemSortingLayers.MiscPainting);
|
||||
ItemSorting._layerList.Add(ItemSorting.ItemSortingLayers.MiscWiring);
|
||||
ItemSorting._layerList.Add(ItemSorting.ItemSortingLayers.MiscMaterials);
|
||||
ItemSorting._layerList.Add(ItemSorting.ItemSortingLayers.MiscRopes);
|
||||
ItemSorting._layerList.Add(ItemSorting.ItemSortingLayers.MiscExtractinator);
|
||||
ItemSorting._layerList.Add(ItemSorting.ItemSortingLayers.LastMaterials);
|
||||
ItemSorting._layerList.Add(ItemSorting.ItemSortingLayers.LastTilesImportant);
|
||||
ItemSorting._layerList.Add(ItemSorting.ItemSortingLayers.LastTilesCommon);
|
||||
ItemSorting._layerList.Add(ItemSorting.ItemSortingLayers.LastNotTrash);
|
||||
ItemSorting._layerList.Add(ItemSorting.ItemSortingLayers.LastTrash);
|
||||
}
|
||||
|
||||
private static void Sort(Item[] inv, params int[] ignoreSlots)
|
||||
{
|
||||
ItemSorting.SetupSortingPriorities();
|
||||
List<int> intList1 = new List<int>();
|
||||
for (int index = 0; index < inv.Length; ++index)
|
||||
{
|
||||
if (!((IEnumerable<int>) ignoreSlots).Contains<int>(index))
|
||||
{
|
||||
Item obj = inv[index];
|
||||
if (obj != null && obj.stack != 0 && obj.type != 0 && !obj.favorited)
|
||||
intList1.Add(index);
|
||||
}
|
||||
}
|
||||
for (int index1 = 0; index1 < intList1.Count; ++index1)
|
||||
{
|
||||
Item obj1 = inv[intList1[index1]];
|
||||
if (obj1.stack < obj1.maxStack)
|
||||
{
|
||||
int num1 = obj1.maxStack - obj1.stack;
|
||||
for (int index2 = index1; index2 < intList1.Count; ++index2)
|
||||
{
|
||||
if (index1 != index2)
|
||||
{
|
||||
Item obj2 = inv[intList1[index2]];
|
||||
if (obj1.type == obj2.type && obj2.stack != obj2.maxStack)
|
||||
{
|
||||
int num2 = obj2.stack;
|
||||
if (num1 < num2)
|
||||
num2 = num1;
|
||||
obj1.stack += num2;
|
||||
obj2.stack -= num2;
|
||||
num1 -= num2;
|
||||
if (obj2.stack == 0)
|
||||
{
|
||||
inv[intList1[index2]] = new Item();
|
||||
intList1.Remove(intList1[index2]);
|
||||
--index1;
|
||||
int num3 = index2 - 1;
|
||||
break;
|
||||
}
|
||||
if (num1 == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
List<int> intList2 = new List<int>((IEnumerable<int>) intList1);
|
||||
for (int index = 0; index < inv.Length; ++index)
|
||||
{
|
||||
if (!((IEnumerable<int>) ignoreSlots).Contains<int>(index) && !intList2.Contains(index))
|
||||
{
|
||||
Item obj = inv[index];
|
||||
if (obj == null || obj.stack == 0 || obj.type == 0)
|
||||
intList2.Add(index);
|
||||
}
|
||||
}
|
||||
intList2.Sort();
|
||||
List<int> intList3 = new List<int>();
|
||||
List<int> intList4 = new List<int>();
|
||||
foreach (ItemSorting.ItemSortingLayer layer in ItemSorting._layerList)
|
||||
{
|
||||
List<int> intList5 = layer.SortingMethod(layer, inv, intList1);
|
||||
if (intList5.Count > 0)
|
||||
intList4.Add(intList5.Count);
|
||||
intList3.AddRange((IEnumerable<int>) intList5);
|
||||
}
|
||||
intList3.AddRange((IEnumerable<int>) intList1);
|
||||
List<Item> objList = new List<Item>();
|
||||
foreach (int index in intList3)
|
||||
{
|
||||
objList.Add(inv[index]);
|
||||
inv[index] = new Item();
|
||||
}
|
||||
float num = 1f / (float) intList4.Count;
|
||||
float hue = num / 2f;
|
||||
for (int index3 = 0; index3 < objList.Count; ++index3)
|
||||
{
|
||||
int index4 = intList2[0];
|
||||
ItemSlot.SetGlow(index4, hue, Main.player[Main.myPlayer].chest != -1);
|
||||
--intList4[0];
|
||||
if (intList4[0] == 0)
|
||||
{
|
||||
intList4.RemoveAt(0);
|
||||
hue += num;
|
||||
}
|
||||
inv[index4] = objList[index3];
|
||||
intList2.Remove(index4);
|
||||
}
|
||||
}
|
||||
|
||||
public static void SortInventory() => ItemSorting.Sort(Main.player[Main.myPlayer].inventory, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 50, 51, 52, 53, 54, 55, 56, 57, 58);
|
||||
|
||||
public static void SortChest()
|
||||
{
|
||||
int chest = Main.player[Main.myPlayer].chest;
|
||||
if (chest == -1)
|
||||
return;
|
||||
Item[] inv = Main.player[Main.myPlayer].bank.item;
|
||||
if (chest == -3)
|
||||
inv = Main.player[Main.myPlayer].bank2.item;
|
||||
if (chest == -4)
|
||||
inv = Main.player[Main.myPlayer].bank3.item;
|
||||
if (chest > -1)
|
||||
inv = Main.chest[chest].item;
|
||||
Tuple<int, int, int>[] tupleArray1 = new Tuple<int, int, int>[40];
|
||||
for (int index = 0; index < 40; ++index)
|
||||
tupleArray1[index] = Tuple.Create<int, int, int>(inv[index].netID, inv[index].stack, (int) inv[index].prefix);
|
||||
ItemSorting.Sort(inv);
|
||||
Tuple<int, int, int>[] tupleArray2 = new Tuple<int, int, int>[40];
|
||||
for (int index = 0; index < 40; ++index)
|
||||
tupleArray2[index] = Tuple.Create<int, int, int>(inv[index].netID, inv[index].stack, (int) inv[index].prefix);
|
||||
if (Main.netMode != 1 || Main.player[Main.myPlayer].chest <= -1)
|
||||
return;
|
||||
for (int index = 0; index < 40; ++index)
|
||||
{
|
||||
if (tupleArray2[index] != tupleArray1[index])
|
||||
NetMessage.SendData(32, number: Main.player[Main.myPlayer].chest, number2: ((float) index));
|
||||
}
|
||||
}
|
||||
|
||||
private class ItemSortingLayer
|
||||
{
|
||||
public readonly string Name;
|
||||
public readonly Func<ItemSorting.ItemSortingLayer, Item[], List<int>, List<int>> SortingMethod;
|
||||
|
||||
public ItemSortingLayer(
|
||||
string name,
|
||||
Func<ItemSorting.ItemSortingLayer, Item[], List<int>, List<int>> method)
|
||||
{
|
||||
this.Name = name;
|
||||
this.SortingMethod = method;
|
||||
}
|
||||
|
||||
public void Validate(ref List<int> indexesSortable, Item[] inv)
|
||||
{
|
||||
List<int> list;
|
||||
if (!ItemSorting._layerWhiteLists.TryGetValue(this.Name, out list))
|
||||
return;
|
||||
indexesSortable = indexesSortable.Where<int>((Func<int, bool>) (i => list.Contains(inv[i].netID))).ToList<int>();
|
||||
}
|
||||
|
||||
public override string ToString() => this.Name;
|
||||
}
|
||||
|
||||
private class ItemSortingLayers
|
||||
{
|
||||
public static ItemSorting.ItemSortingLayer WeaponsMelee = new ItemSorting.ItemSortingLayer("Weapons - Melee", (Func<ItemSorting.ItemSortingLayer, Item[], List<int>, List<int>>) ((layer, inv, itemsToSort) =>
|
||||
{
|
||||
List<int> list = itemsToSort.Where<int>((Func<int, bool>) (i => inv[i].maxStack == 1 && inv[i].damage > 0 && inv[i].ammo == 0 && inv[i].melee && inv[i].pick < 1 && inv[i].hammer < 1 && inv[i].axe < 1)).ToList<int>();
|
||||
layer.Validate(ref list, inv);
|
||||
foreach (int num in list)
|
||||
itemsToSort.Remove(num);
|
||||
list.Sort((Comparison<int>) ((x, y) =>
|
||||
{
|
||||
int num = inv[y].rare.CompareTo(inv[x].rare);
|
||||
if (num == 0)
|
||||
num = x == y ? 0 : -1;
|
||||
return num;
|
||||
}));
|
||||
return list;
|
||||
}));
|
||||
public static ItemSorting.ItemSortingLayer WeaponsRanged = new ItemSorting.ItemSortingLayer("Weapons - Ranged", (Func<ItemSorting.ItemSortingLayer, Item[], List<int>, List<int>>) ((layer, inv, itemsToSort) =>
|
||||
{
|
||||
List<int> list = itemsToSort.Where<int>((Func<int, bool>) (i => inv[i].maxStack == 1 && inv[i].damage > 0 && inv[i].ammo == 0 && inv[i].ranged)).ToList<int>();
|
||||
layer.Validate(ref list, inv);
|
||||
foreach (int num in list)
|
||||
itemsToSort.Remove(num);
|
||||
list.Sort((Comparison<int>) ((x, y) =>
|
||||
{
|
||||
int num = inv[y].rare.CompareTo(inv[x].rare);
|
||||
if (num == 0)
|
||||
num = x == y ? 0 : -1;
|
||||
return num;
|
||||
}));
|
||||
return list;
|
||||
}));
|
||||
public static ItemSorting.ItemSortingLayer WeaponsMagic = new ItemSorting.ItemSortingLayer("Weapons - Magic", (Func<ItemSorting.ItemSortingLayer, Item[], List<int>, List<int>>) ((layer, inv, itemsToSort) =>
|
||||
{
|
||||
List<int> list = itemsToSort.Where<int>((Func<int, bool>) (i => inv[i].maxStack == 1 && inv[i].damage > 0 && inv[i].ammo == 0 && inv[i].magic)).ToList<int>();
|
||||
layer.Validate(ref list, inv);
|
||||
foreach (int num in list)
|
||||
itemsToSort.Remove(num);
|
||||
list.Sort((Comparison<int>) ((x, y) =>
|
||||
{
|
||||
int num = inv[y].rare.CompareTo(inv[x].rare);
|
||||
if (num == 0)
|
||||
num = x == y ? 0 : -1;
|
||||
return num;
|
||||
}));
|
||||
return list;
|
||||
}));
|
||||
public static ItemSorting.ItemSortingLayer WeaponsMinions = new ItemSorting.ItemSortingLayer("Weapons - Minions", (Func<ItemSorting.ItemSortingLayer, Item[], List<int>, List<int>>) ((layer, inv, itemsToSort) =>
|
||||
{
|
||||
List<int> list = itemsToSort.Where<int>((Func<int, bool>) (i => inv[i].maxStack == 1 && inv[i].damage > 0 && inv[i].summon)).ToList<int>();
|
||||
layer.Validate(ref list, inv);
|
||||
foreach (int num in list)
|
||||
itemsToSort.Remove(num);
|
||||
list.Sort((Comparison<int>) ((x, y) =>
|
||||
{
|
||||
int num = inv[y].rare.CompareTo(inv[x].rare);
|
||||
if (num == 0)
|
||||
num = x == y ? 0 : -1;
|
||||
return num;
|
||||
}));
|
||||
return list;
|
||||
}));
|
||||
public static ItemSorting.ItemSortingLayer WeaponsThrown = new ItemSorting.ItemSortingLayer("Weapons - Thrown", (Func<ItemSorting.ItemSortingLayer, Item[], List<int>, List<int>>) ((layer, inv, itemsToSort) =>
|
||||
{
|
||||
List<int> list = itemsToSort.Where<int>((Func<int, bool>) (i => inv[i].damage > 0 && (inv[i].ammo == 0 || inv[i].notAmmo) && inv[i].shoot > 0 && inv[i].thrown)).ToList<int>();
|
||||
layer.Validate(ref list, inv);
|
||||
foreach (int num in list)
|
||||
itemsToSort.Remove(num);
|
||||
list.Sort((Comparison<int>) ((x, y) =>
|
||||
{
|
||||
int num = inv[y].rare.CompareTo(inv[x].rare);
|
||||
if (num == 0)
|
||||
num = x == y ? 0 : -1;
|
||||
return num;
|
||||
}));
|
||||
return list;
|
||||
}));
|
||||
public static ItemSorting.ItemSortingLayer WeaponsAssorted = new ItemSorting.ItemSortingLayer("Weapons - Assorted", (Func<ItemSorting.ItemSortingLayer, Item[], List<int>, List<int>>) ((layer, inv, itemsToSort) =>
|
||||
{
|
||||
List<int> list = itemsToSort.Where<int>((Func<int, bool>) (i => inv[i].damage > 0 && inv[i].ammo == 0 && inv[i].pick == 0 && inv[i].axe == 0 && inv[i].hammer == 0)).ToList<int>();
|
||||
layer.Validate(ref list, inv);
|
||||
foreach (int num in list)
|
||||
itemsToSort.Remove(num);
|
||||
list.Sort((Comparison<int>) ((x, y) =>
|
||||
{
|
||||
int num = inv[y].rare.CompareTo(inv[x].rare);
|
||||
if (num == 0)
|
||||
num = x == y ? 0 : -1;
|
||||
return num;
|
||||
}));
|
||||
return list;
|
||||
}));
|
||||
public static ItemSorting.ItemSortingLayer WeaponsAmmo = new ItemSorting.ItemSortingLayer("Weapons - Ammo", (Func<ItemSorting.ItemSortingLayer, Item[], List<int>, List<int>>) ((layer, inv, itemsToSort) =>
|
||||
{
|
||||
List<int> list = itemsToSort.Where<int>((Func<int, bool>) (i => inv[i].ammo > 0 && inv[i].damage > 0)).ToList<int>();
|
||||
layer.Validate(ref list, inv);
|
||||
foreach (int num in list)
|
||||
itemsToSort.Remove(num);
|
||||
list.Sort((Comparison<int>) ((x, y) =>
|
||||
{
|
||||
int num = inv[y].rare.CompareTo(inv[x].rare);
|
||||
if (num == 0)
|
||||
num = x == y ? 0 : -1;
|
||||
return num;
|
||||
}));
|
||||
return list;
|
||||
}));
|
||||
public static ItemSorting.ItemSortingLayer ToolsPicksaws = new ItemSorting.ItemSortingLayer("Tools - Picksaws", (Func<ItemSorting.ItemSortingLayer, Item[], List<int>, List<int>>) ((layer, inv, itemsToSort) =>
|
||||
{
|
||||
List<int> list = itemsToSort.Where<int>((Func<int, bool>) (i => inv[i].pick > 0 && inv[i].axe > 0)).ToList<int>();
|
||||
layer.Validate(ref list, inv);
|
||||
foreach (int num in list)
|
||||
itemsToSort.Remove(num);
|
||||
list.Sort((Comparison<int>) ((x, y) => inv[x].pick.CompareTo(inv[y].pick)));
|
||||
return list;
|
||||
}));
|
||||
public static ItemSorting.ItemSortingLayer ToolsHamaxes = new ItemSorting.ItemSortingLayer("Tools - Hamaxes", (Func<ItemSorting.ItemSortingLayer, Item[], List<int>, List<int>>) ((layer, inv, itemsToSort) =>
|
||||
{
|
||||
List<int> list = itemsToSort.Where<int>((Func<int, bool>) (i => inv[i].hammer > 0 && inv[i].axe > 0)).ToList<int>();
|
||||
layer.Validate(ref list, inv);
|
||||
foreach (int num in list)
|
||||
itemsToSort.Remove(num);
|
||||
list.Sort((Comparison<int>) ((x, y) => inv[x].axe.CompareTo(inv[y].axe)));
|
||||
return list;
|
||||
}));
|
||||
public static ItemSorting.ItemSortingLayer ToolsPickaxes = new ItemSorting.ItemSortingLayer("Tools - Pickaxes", (Func<ItemSorting.ItemSortingLayer, Item[], List<int>, List<int>>) ((layer, inv, itemsToSort) =>
|
||||
{
|
||||
List<int> list = itemsToSort.Where<int>((Func<int, bool>) (i => inv[i].pick > 0)).ToList<int>();
|
||||
layer.Validate(ref list, inv);
|
||||
foreach (int num in list)
|
||||
itemsToSort.Remove(num);
|
||||
list.Sort((Comparison<int>) ((x, y) => inv[x].pick.CompareTo(inv[y].pick)));
|
||||
return list;
|
||||
}));
|
||||
public static ItemSorting.ItemSortingLayer ToolsAxes = new ItemSorting.ItemSortingLayer("Tools - Axes", (Func<ItemSorting.ItemSortingLayer, Item[], List<int>, List<int>>) ((layer, inv, itemsToSort) =>
|
||||
{
|
||||
List<int> list = itemsToSort.Where<int>((Func<int, bool>) (i => inv[i].pick > 0)).ToList<int>();
|
||||
layer.Validate(ref list, inv);
|
||||
foreach (int num in list)
|
||||
itemsToSort.Remove(num);
|
||||
list.Sort((Comparison<int>) ((x, y) => inv[x].axe.CompareTo(inv[y].axe)));
|
||||
return list;
|
||||
}));
|
||||
public static ItemSorting.ItemSortingLayer ToolsHammers = new ItemSorting.ItemSortingLayer("Tools - Hammers", (Func<ItemSorting.ItemSortingLayer, Item[], List<int>, List<int>>) ((layer, inv, itemsToSort) =>
|
||||
{
|
||||
List<int> list = itemsToSort.Where<int>((Func<int, bool>) (i => inv[i].hammer > 0)).ToList<int>();
|
||||
layer.Validate(ref list, inv);
|
||||
foreach (int num in list)
|
||||
itemsToSort.Remove(num);
|
||||
list.Sort((Comparison<int>) ((x, y) => inv[x].hammer.CompareTo(inv[y].hammer)));
|
||||
return list;
|
||||
}));
|
||||
public static ItemSorting.ItemSortingLayer ToolsTerraforming = new ItemSorting.ItemSortingLayer("Tools - Terraforming", (Func<ItemSorting.ItemSortingLayer, Item[], List<int>, List<int>>) ((layer, inv, itemsToSort) =>
|
||||
{
|
||||
List<int> list = itemsToSort.Where<int>((Func<int, bool>) (i => inv[i].netID > 0 && ItemID.Sets.SortingPriorityTerraforming[inv[i].netID] > -1)).ToList<int>();
|
||||
layer.Validate(ref list, inv);
|
||||
foreach (int num in list)
|
||||
itemsToSort.Remove(num);
|
||||
list.Sort((Comparison<int>) ((x, y) =>
|
||||
{
|
||||
int num = ItemID.Sets.SortingPriorityTerraforming[inv[x].netID].CompareTo(ItemID.Sets.SortingPriorityTerraforming[inv[y].netID]);
|
||||
if (num == 0)
|
||||
num = inv[y].stack.CompareTo(inv[x].stack);
|
||||
if (num == 0)
|
||||
num = x == y ? 0 : -1;
|
||||
return num;
|
||||
}));
|
||||
return list;
|
||||
}));
|
||||
public static ItemSorting.ItemSortingLayer ToolsAmmoLeftovers = new ItemSorting.ItemSortingLayer("Weapons - Ammo Leftovers", (Func<ItemSorting.ItemSortingLayer, Item[], List<int>, List<int>>) ((layer, inv, itemsToSort) =>
|
||||
{
|
||||
List<int> list = itemsToSort.Where<int>((Func<int, bool>) (i => inv[i].ammo > 0)).ToList<int>();
|
||||
layer.Validate(ref list, inv);
|
||||
foreach (int num in list)
|
||||
itemsToSort.Remove(num);
|
||||
list.Sort((Comparison<int>) ((x, y) =>
|
||||
{
|
||||
int num = inv[y].rare.CompareTo(inv[x].rare);
|
||||
if (num == 0)
|
||||
num = x == y ? 0 : -1;
|
||||
return num;
|
||||
}));
|
||||
return list;
|
||||
}));
|
||||
public static ItemSorting.ItemSortingLayer ArmorCombat = new ItemSorting.ItemSortingLayer("Armor - Combat", (Func<ItemSorting.ItemSortingLayer, Item[], List<int>, List<int>>) ((layer, inv, itemsToSort) =>
|
||||
{
|
||||
List<int> list = itemsToSort.Where<int>((Func<int, bool>) (i => (inv[i].bodySlot >= 0 || inv[i].headSlot >= 0 || inv[i].legSlot >= 0) && !inv[i].vanity)).ToList<int>();
|
||||
layer.Validate(ref list, inv);
|
||||
foreach (int num in list)
|
||||
itemsToSort.Remove(num);
|
||||
list.Sort((Comparison<int>) ((x, y) =>
|
||||
{
|
||||
int num = inv[y].rare.CompareTo(inv[x].rare);
|
||||
if (num == 0)
|
||||
num = inv[x].netID.CompareTo(inv[y].netID);
|
||||
return num;
|
||||
}));
|
||||
return list;
|
||||
}));
|
||||
public static ItemSorting.ItemSortingLayer ArmorVanity = new ItemSorting.ItemSortingLayer("Armor - Vanity", (Func<ItemSorting.ItemSortingLayer, Item[], List<int>, List<int>>) ((layer, inv, itemsToSort) =>
|
||||
{
|
||||
List<int> list = itemsToSort.Where<int>((Func<int, bool>) (i => (inv[i].bodySlot >= 0 || inv[i].headSlot >= 0 || inv[i].legSlot >= 0) && inv[i].vanity)).ToList<int>();
|
||||
layer.Validate(ref list, inv);
|
||||
foreach (int num in list)
|
||||
itemsToSort.Remove(num);
|
||||
list.Sort((Comparison<int>) ((x, y) =>
|
||||
{
|
||||
int num = inv[y].rare.CompareTo(inv[x].rare);
|
||||
if (num == 0)
|
||||
num = inv[x].netID.CompareTo(inv[y].netID);
|
||||
return num;
|
||||
}));
|
||||
return list;
|
||||
}));
|
||||
public static ItemSorting.ItemSortingLayer ArmorAccessories = new ItemSorting.ItemSortingLayer("Armor - Accessories", (Func<ItemSorting.ItemSortingLayer, Item[], List<int>, List<int>>) ((layer, inv, itemsToSort) =>
|
||||
{
|
||||
List<int> list = itemsToSort.Where<int>((Func<int, bool>) (i => inv[i].accessory)).ToList<int>();
|
||||
layer.Validate(ref list, inv);
|
||||
foreach (int num in list)
|
||||
itemsToSort.Remove(num);
|
||||
list.Sort((Comparison<int>) ((x, y) =>
|
||||
{
|
||||
int num = inv[x].vanity.CompareTo(inv[y].vanity);
|
||||
if (num == 0)
|
||||
num = inv[y].rare.CompareTo(inv[x].rare);
|
||||
if (num == 0)
|
||||
num = inv[x].netID.CompareTo(inv[y].netID);
|
||||
return num;
|
||||
}));
|
||||
return list;
|
||||
}));
|
||||
public static ItemSorting.ItemSortingLayer EquipGrapple = new ItemSorting.ItemSortingLayer("Equip - Grapple", (Func<ItemSorting.ItemSortingLayer, Item[], List<int>, List<int>>) ((layer, inv, itemsToSort) =>
|
||||
{
|
||||
List<int> list = itemsToSort.Where<int>((Func<int, bool>) (i => Main.projHook[inv[i].shoot])).ToList<int>();
|
||||
layer.Validate(ref list, inv);
|
||||
foreach (int num in list)
|
||||
itemsToSort.Remove(num);
|
||||
list.Sort((Comparison<int>) ((x, y) =>
|
||||
{
|
||||
int num = inv[y].rare.CompareTo(inv[x].rare);
|
||||
if (num == 0)
|
||||
num = inv[x].netID.CompareTo(inv[y].netID);
|
||||
if (num == 0)
|
||||
num = x == y ? 0 : -1;
|
||||
return num;
|
||||
}));
|
||||
return list;
|
||||
}));
|
||||
public static ItemSorting.ItemSortingLayer EquipMount = new ItemSorting.ItemSortingLayer("Equip - Mount", (Func<ItemSorting.ItemSortingLayer, Item[], List<int>, List<int>>) ((layer, inv, itemsToSort) =>
|
||||
{
|
||||
List<int> list = itemsToSort.Where<int>((Func<int, bool>) (i => inv[i].mountType != -1 && !MountID.Sets.Cart[inv[i].mountType])).ToList<int>();
|
||||
layer.Validate(ref list, inv);
|
||||
foreach (int num in list)
|
||||
itemsToSort.Remove(num);
|
||||
list.Sort((Comparison<int>) ((x, y) =>
|
||||
{
|
||||
int num = inv[y].rare.CompareTo(inv[x].rare);
|
||||
if (num == 0)
|
||||
num = inv[x].netID.CompareTo(inv[y].netID);
|
||||
if (num == 0)
|
||||
num = x == y ? 0 : -1;
|
||||
return num;
|
||||
}));
|
||||
return list;
|
||||
}));
|
||||
public static ItemSorting.ItemSortingLayer EquipCart = new ItemSorting.ItemSortingLayer("Equip - Cart", (Func<ItemSorting.ItemSortingLayer, Item[], List<int>, List<int>>) ((layer, inv, itemsToSort) =>
|
||||
{
|
||||
List<int> list = itemsToSort.Where<int>((Func<int, bool>) (i => inv[i].mountType != -1 && MountID.Sets.Cart[inv[i].mountType])).ToList<int>();
|
||||
layer.Validate(ref list, inv);
|
||||
foreach (int num in list)
|
||||
itemsToSort.Remove(num);
|
||||
list.Sort((Comparison<int>) ((x, y) =>
|
||||
{
|
||||
int num = inv[y].rare.CompareTo(inv[x].rare);
|
||||
if (num == 0)
|
||||
num = inv[x].netID.CompareTo(inv[y].netID);
|
||||
if (num == 0)
|
||||
num = x == y ? 0 : -1;
|
||||
return num;
|
||||
}));
|
||||
return list;
|
||||
}));
|
||||
public static ItemSorting.ItemSortingLayer EquipLightPet = new ItemSorting.ItemSortingLayer("Equip - Light Pet", (Func<ItemSorting.ItemSortingLayer, Item[], List<int>, List<int>>) ((layer, inv, itemsToSort) =>
|
||||
{
|
||||
List<int> list = itemsToSort.Where<int>((Func<int, bool>) (i => inv[i].buffType > 0 && Main.lightPet[inv[i].buffType])).ToList<int>();
|
||||
layer.Validate(ref list, inv);
|
||||
foreach (int num in list)
|
||||
itemsToSort.Remove(num);
|
||||
list.Sort((Comparison<int>) ((x, y) =>
|
||||
{
|
||||
int num = inv[y].rare.CompareTo(inv[x].rare);
|
||||
if (num == 0)
|
||||
num = inv[x].netID.CompareTo(inv[y].netID);
|
||||
if (num == 0)
|
||||
num = x == y ? 0 : -1;
|
||||
return num;
|
||||
}));
|
||||
return list;
|
||||
}));
|
||||
public static ItemSorting.ItemSortingLayer EquipVanityPet = new ItemSorting.ItemSortingLayer("Equip - Vanity Pet", (Func<ItemSorting.ItemSortingLayer, Item[], List<int>, List<int>>) ((layer, inv, itemsToSort) =>
|
||||
{
|
||||
List<int> list = itemsToSort.Where<int>((Func<int, bool>) (i => inv[i].buffType > 0 && Main.vanityPet[inv[i].buffType])).ToList<int>();
|
||||
layer.Validate(ref list, inv);
|
||||
foreach (int num in list)
|
||||
itemsToSort.Remove(num);
|
||||
list.Sort((Comparison<int>) ((x, y) =>
|
||||
{
|
||||
int num = inv[y].rare.CompareTo(inv[x].rare);
|
||||
if (num == 0)
|
||||
num = inv[x].netID.CompareTo(inv[y].netID);
|
||||
if (num == 0)
|
||||
num = x == y ? 0 : -1;
|
||||
return num;
|
||||
}));
|
||||
return list;
|
||||
}));
|
||||
public static ItemSorting.ItemSortingLayer PotionsLife = new ItemSorting.ItemSortingLayer("Potions - Life", (Func<ItemSorting.ItemSortingLayer, Item[], List<int>, List<int>>) ((layer, inv, itemsToSort) =>
|
||||
{
|
||||
List<int> list = itemsToSort.Where<int>((Func<int, bool>) (i => inv[i].consumable && inv[i].healLife > 0 && inv[i].healMana < 1)).ToList<int>();
|
||||
layer.Validate(ref list, inv);
|
||||
foreach (int num in list)
|
||||
itemsToSort.Remove(num);
|
||||
list.Sort((Comparison<int>) ((x, y) => inv[y].healLife.CompareTo(inv[x].healLife)));
|
||||
return list;
|
||||
}));
|
||||
public static ItemSorting.ItemSortingLayer PotionsMana = new ItemSorting.ItemSortingLayer("Potions - Mana", (Func<ItemSorting.ItemSortingLayer, Item[], List<int>, List<int>>) ((layer, inv, itemsToSort) =>
|
||||
{
|
||||
List<int> list = itemsToSort.Where<int>((Func<int, bool>) (i => inv[i].consumable && inv[i].healLife < 1 && inv[i].healMana > 0)).ToList<int>();
|
||||
layer.Validate(ref list, inv);
|
||||
foreach (int num in list)
|
||||
itemsToSort.Remove(num);
|
||||
list.Sort((Comparison<int>) ((x, y) => inv[y].healMana.CompareTo(inv[x].healMana)));
|
||||
return list;
|
||||
}));
|
||||
public static ItemSorting.ItemSortingLayer PotionsElixirs = new ItemSorting.ItemSortingLayer("Potions - Elixirs", (Func<ItemSorting.ItemSortingLayer, Item[], List<int>, List<int>>) ((layer, inv, itemsToSort) =>
|
||||
{
|
||||
List<int> list = itemsToSort.Where<int>((Func<int, bool>) (i => inv[i].consumable && inv[i].healLife > 0 && inv[i].healMana > 0)).ToList<int>();
|
||||
layer.Validate(ref list, inv);
|
||||
foreach (int num in list)
|
||||
itemsToSort.Remove(num);
|
||||
list.Sort((Comparison<int>) ((x, y) => inv[y].healLife.CompareTo(inv[x].healLife)));
|
||||
return list;
|
||||
}));
|
||||
public static ItemSorting.ItemSortingLayer PotionsBuffs = new ItemSorting.ItemSortingLayer("Potions - Buffs", (Func<ItemSorting.ItemSortingLayer, Item[], List<int>, List<int>>) ((layer, inv, itemsToSort) =>
|
||||
{
|
||||
List<int> list = itemsToSort.Where<int>((Func<int, bool>) (i => inv[i].consumable && inv[i].buffType > 0)).ToList<int>();
|
||||
layer.Validate(ref list, inv);
|
||||
foreach (int num in list)
|
||||
itemsToSort.Remove(num);
|
||||
list.Sort((Comparison<int>) ((x, y) =>
|
||||
{
|
||||
int num = inv[y].rare.CompareTo(inv[x].rare);
|
||||
if (num == 0)
|
||||
num = inv[x].netID.CompareTo(inv[y].netID);
|
||||
if (num == 0)
|
||||
num = inv[y].stack.CompareTo(inv[x].stack);
|
||||
if (num == 0)
|
||||
num = x == y ? 0 : -1;
|
||||
return num;
|
||||
}));
|
||||
return list;
|
||||
}));
|
||||
public static ItemSorting.ItemSortingLayer PotionsDyes = new ItemSorting.ItemSortingLayer("Potions - Dyes", (Func<ItemSorting.ItemSortingLayer, Item[], List<int>, List<int>>) ((layer, inv, itemsToSort) =>
|
||||
{
|
||||
List<int> list = itemsToSort.Where<int>((Func<int, bool>) (i => inv[i].dye > (byte) 0)).ToList<int>();
|
||||
layer.Validate(ref list, inv);
|
||||
foreach (int num in list)
|
||||
itemsToSort.Remove(num);
|
||||
list.Sort((Comparison<int>) ((x, y) =>
|
||||
{
|
||||
int num = inv[y].rare.CompareTo(inv[x].rare);
|
||||
if (num == 0)
|
||||
num = inv[y].dye.CompareTo(inv[x].dye);
|
||||
if (num == 0)
|
||||
num = inv[y].stack.CompareTo(inv[x].stack);
|
||||
if (num == 0)
|
||||
num = x == y ? 0 : -1;
|
||||
return num;
|
||||
}));
|
||||
return list;
|
||||
}));
|
||||
public static ItemSorting.ItemSortingLayer PotionsHairDyes = new ItemSorting.ItemSortingLayer("Potions - Hair Dyes", (Func<ItemSorting.ItemSortingLayer, Item[], List<int>, List<int>>) ((layer, inv, itemsToSort) =>
|
||||
{
|
||||
List<int> list = itemsToSort.Where<int>((Func<int, bool>) (i => inv[i].hairDye >= (short) 0)).ToList<int>();
|
||||
layer.Validate(ref list, inv);
|
||||
foreach (int num in list)
|
||||
itemsToSort.Remove(num);
|
||||
list.Sort((Comparison<int>) ((x, y) =>
|
||||
{
|
||||
int num = inv[y].rare.CompareTo(inv[x].rare);
|
||||
if (num == 0)
|
||||
num = inv[y].hairDye.CompareTo(inv[x].hairDye);
|
||||
if (num == 0)
|
||||
num = inv[y].stack.CompareTo(inv[x].stack);
|
||||
if (num == 0)
|
||||
num = x == y ? 0 : -1;
|
||||
return num;
|
||||
}));
|
||||
return list;
|
||||
}));
|
||||
public static ItemSorting.ItemSortingLayer MiscValuables = new ItemSorting.ItemSortingLayer("Misc - Importants", (Func<ItemSorting.ItemSortingLayer, Item[], List<int>, List<int>>) ((layer, inv, itemsToSort) =>
|
||||
{
|
||||
List<int> list = itemsToSort.Where<int>((Func<int, bool>) (i => inv[i].netID > 0 && ItemID.Sets.SortingPriorityBossSpawns[inv[i].netID] > -1)).ToList<int>();
|
||||
layer.Validate(ref list, inv);
|
||||
foreach (int num in list)
|
||||
itemsToSort.Remove(num);
|
||||
list.Sort((Comparison<int>) ((x, y) =>
|
||||
{
|
||||
int num = ItemID.Sets.SortingPriorityBossSpawns[inv[x].netID].CompareTo(ItemID.Sets.SortingPriorityBossSpawns[inv[y].netID]);
|
||||
if (num == 0)
|
||||
num = inv[y].stack.CompareTo(inv[x].stack);
|
||||
if (num == 0)
|
||||
num = x == y ? 0 : -1;
|
||||
return num;
|
||||
}));
|
||||
return list;
|
||||
}));
|
||||
public static ItemSorting.ItemSortingLayer MiscWiring = new ItemSorting.ItemSortingLayer("Misc - Wiring", (Func<ItemSorting.ItemSortingLayer, Item[], List<int>, List<int>>) ((layer, inv, itemsToSort) =>
|
||||
{
|
||||
List<int> list = itemsToSort.Where<int>((Func<int, bool>) (i => inv[i].netID > 0 && ItemID.Sets.SortingPriorityWiring[inv[i].netID] > -1 || inv[i].mech)).ToList<int>();
|
||||
layer.Validate(ref list, inv);
|
||||
foreach (int num in list)
|
||||
itemsToSort.Remove(num);
|
||||
list.Sort((Comparison<int>) ((x, y) =>
|
||||
{
|
||||
int num = ItemID.Sets.SortingPriorityWiring[inv[y].netID].CompareTo(ItemID.Sets.SortingPriorityWiring[inv[x].netID]);
|
||||
if (num == 0)
|
||||
num = inv[y].rare.CompareTo(inv[x].rare);
|
||||
if (num == 0)
|
||||
num = inv[y].netID.CompareTo(inv[x].netID);
|
||||
if (num == 0)
|
||||
num = inv[y].stack.CompareTo(inv[x].stack);
|
||||
if (num == 0)
|
||||
num = x == y ? 0 : -1;
|
||||
return num;
|
||||
}));
|
||||
return list;
|
||||
}));
|
||||
public static ItemSorting.ItemSortingLayer MiscMaterials = new ItemSorting.ItemSortingLayer("Misc - Materials", (Func<ItemSorting.ItemSortingLayer, Item[], List<int>, List<int>>) ((layer, inv, itemsToSort) =>
|
||||
{
|
||||
List<int> list = itemsToSort.Where<int>((Func<int, bool>) (i => inv[i].netID > 0 && ItemID.Sets.SortingPriorityMaterials[inv[i].netID] > -1)).ToList<int>();
|
||||
layer.Validate(ref list, inv);
|
||||
foreach (int num in list)
|
||||
itemsToSort.Remove(num);
|
||||
list.Sort((Comparison<int>) ((x, y) => ItemID.Sets.SortingPriorityMaterials[inv[y].netID].CompareTo(ItemID.Sets.SortingPriorityMaterials[inv[x].netID])));
|
||||
return list;
|
||||
}));
|
||||
public static ItemSorting.ItemSortingLayer MiscExtractinator = new ItemSorting.ItemSortingLayer("Misc - Extractinator", (Func<ItemSorting.ItemSortingLayer, Item[], List<int>, List<int>>) ((layer, inv, itemsToSort) =>
|
||||
{
|
||||
List<int> list = itemsToSort.Where<int>((Func<int, bool>) (i => inv[i].netID > 0 && ItemID.Sets.SortingPriorityExtractibles[inv[i].netID] > -1)).ToList<int>();
|
||||
layer.Validate(ref list, inv);
|
||||
foreach (int num in list)
|
||||
itemsToSort.Remove(num);
|
||||
list.Sort((Comparison<int>) ((x, y) => ItemID.Sets.SortingPriorityExtractibles[inv[y].netID].CompareTo(ItemID.Sets.SortingPriorityExtractibles[inv[x].netID])));
|
||||
return list;
|
||||
}));
|
||||
public static ItemSorting.ItemSortingLayer MiscPainting = new ItemSorting.ItemSortingLayer("Misc - Painting", (Func<ItemSorting.ItemSortingLayer, Item[], List<int>, List<int>>) ((layer, inv, itemsToSort) =>
|
||||
{
|
||||
List<int> list = itemsToSort.Where<int>((Func<int, bool>) (i => inv[i].netID > 0 && ItemID.Sets.SortingPriorityPainting[inv[i].netID] > -1 || inv[i].paint > (byte) 0)).ToList<int>();
|
||||
layer.Validate(ref list, inv);
|
||||
foreach (int num in list)
|
||||
itemsToSort.Remove(num);
|
||||
list.Sort((Comparison<int>) ((x, y) =>
|
||||
{
|
||||
int num = ItemID.Sets.SortingPriorityPainting[inv[y].netID].CompareTo(ItemID.Sets.SortingPriorityPainting[inv[x].netID]);
|
||||
if (num == 0)
|
||||
num = inv[x].paint.CompareTo(inv[y].paint);
|
||||
if (num == 0)
|
||||
num = inv[y].stack.CompareTo(inv[x].stack);
|
||||
if (num == 0)
|
||||
num = x == y ? 0 : -1;
|
||||
return num;
|
||||
}));
|
||||
return list;
|
||||
}));
|
||||
public static ItemSorting.ItemSortingLayer MiscRopes = new ItemSorting.ItemSortingLayer("Misc - Ropes", (Func<ItemSorting.ItemSortingLayer, Item[], List<int>, List<int>>) ((layer, inv, itemsToSort) =>
|
||||
{
|
||||
List<int> list = itemsToSort.Where<int>((Func<int, bool>) (i => inv[i].netID > 0 && ItemID.Sets.SortingPriorityRopes[inv[i].netID] > -1)).ToList<int>();
|
||||
layer.Validate(ref list, inv);
|
||||
foreach (int num in list)
|
||||
itemsToSort.Remove(num);
|
||||
list.Sort((Comparison<int>) ((x, y) => ItemID.Sets.SortingPriorityRopes[inv[y].netID].CompareTo(ItemID.Sets.SortingPriorityRopes[inv[x].netID])));
|
||||
return list;
|
||||
}));
|
||||
public static ItemSorting.ItemSortingLayer LastMaterials = new ItemSorting.ItemSortingLayer("Last - Materials", (Func<ItemSorting.ItemSortingLayer, Item[], List<int>, List<int>>) ((layer, inv, itemsToSort) =>
|
||||
{
|
||||
List<int> list = itemsToSort.Where<int>((Func<int, bool>) (i => inv[i].createTile < 0 && inv[i].createWall < 1)).ToList<int>();
|
||||
layer.Validate(ref list, inv);
|
||||
foreach (int num in list)
|
||||
itemsToSort.Remove(num);
|
||||
list.Sort((Comparison<int>) ((x, y) =>
|
||||
{
|
||||
int num = inv[y].rare.CompareTo(inv[x].rare);
|
||||
if (num == 0)
|
||||
num = inv[y].value.CompareTo(inv[x].value);
|
||||
if (num == 0)
|
||||
num = inv[y].stack.CompareTo(inv[x].stack);
|
||||
if (num == 0)
|
||||
num = x == y ? 0 : -1;
|
||||
return num;
|
||||
}));
|
||||
return list;
|
||||
}));
|
||||
public static ItemSorting.ItemSortingLayer LastTilesImportant = new ItemSorting.ItemSortingLayer("Last - Tiles (Frame Important)", (Func<ItemSorting.ItemSortingLayer, Item[], List<int>, List<int>>) ((layer, inv, itemsToSort) =>
|
||||
{
|
||||
List<int> list = itemsToSort.Where<int>((Func<int, bool>) (i => inv[i].createTile >= 0 && Main.tileFrameImportant[inv[i].createTile])).ToList<int>();
|
||||
layer.Validate(ref list, inv);
|
||||
foreach (int num in list)
|
||||
itemsToSort.Remove(num);
|
||||
list.Sort((Comparison<int>) ((x, y) =>
|
||||
{
|
||||
int num = string.Compare(inv[x].Name, inv[y].Name, StringComparison.OrdinalIgnoreCase);
|
||||
if (num == 0)
|
||||
num = inv[y].stack.CompareTo(inv[x].stack);
|
||||
if (num == 0)
|
||||
num = x == y ? 0 : -1;
|
||||
return num;
|
||||
}));
|
||||
return list;
|
||||
}));
|
||||
public static ItemSorting.ItemSortingLayer LastTilesCommon = new ItemSorting.ItemSortingLayer("Last - Tiles (Common), Walls", (Func<ItemSorting.ItemSortingLayer, Item[], List<int>, List<int>>) ((layer, inv, itemsToSort) =>
|
||||
{
|
||||
List<int> list = itemsToSort.Where<int>((Func<int, bool>) (i => inv[i].createWall > 0 || inv[i].createTile >= 0)).ToList<int>();
|
||||
layer.Validate(ref list, inv);
|
||||
foreach (int num in list)
|
||||
itemsToSort.Remove(num);
|
||||
list.Sort((Comparison<int>) ((x, y) =>
|
||||
{
|
||||
int num = string.Compare(inv[x].Name, inv[y].Name, StringComparison.OrdinalIgnoreCase);
|
||||
if (num == 0)
|
||||
num = inv[y].stack.CompareTo(inv[x].stack);
|
||||
if (num == 0)
|
||||
num = x == y ? 0 : -1;
|
||||
return num;
|
||||
}));
|
||||
return list;
|
||||
}));
|
||||
public static ItemSorting.ItemSortingLayer LastNotTrash = new ItemSorting.ItemSortingLayer("Last - Not Trash", (Func<ItemSorting.ItemSortingLayer, Item[], List<int>, List<int>>) ((layer, inv, itemsToSort) =>
|
||||
{
|
||||
List<int> list = itemsToSort.Where<int>((Func<int, bool>) (i => inv[i].rare >= 0)).ToList<int>();
|
||||
layer.Validate(ref list, inv);
|
||||
foreach (int num in list)
|
||||
itemsToSort.Remove(num);
|
||||
list.Sort((Comparison<int>) ((x, y) =>
|
||||
{
|
||||
int num = inv[y].rare.CompareTo(inv[x].rare);
|
||||
if (num == 0)
|
||||
num = string.Compare(inv[x].Name, inv[y].Name, StringComparison.OrdinalIgnoreCase);
|
||||
if (num == 0)
|
||||
num = inv[y].stack.CompareTo(inv[x].stack);
|
||||
if (num == 0)
|
||||
num = x == y ? 0 : -1;
|
||||
return num;
|
||||
}));
|
||||
return list;
|
||||
}));
|
||||
public static ItemSorting.ItemSortingLayer LastTrash = new ItemSorting.ItemSortingLayer("Last - Trash", (Func<ItemSorting.ItemSortingLayer, Item[], List<int>, List<int>>) ((layer, inv, itemsToSort) =>
|
||||
{
|
||||
List<int> indexesSortable = new List<int>((IEnumerable<int>) itemsToSort);
|
||||
layer.Validate(ref indexesSortable, inv);
|
||||
foreach (int num in indexesSortable)
|
||||
itemsToSort.Remove(num);
|
||||
indexesSortable.Sort((Comparison<int>) ((x, y) =>
|
||||
{
|
||||
int num = inv[y].value.CompareTo(inv[x].value);
|
||||
if (num == 0)
|
||||
num = inv[y].stack.CompareTo(inv[x].stack);
|
||||
if (num == 0)
|
||||
num = x == y ? 0 : -1;
|
||||
return num;
|
||||
}));
|
||||
return indexesSortable;
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
70
UI/ItemTooltip.cs
Normal file
70
UI/ItemTooltip.cs
Normal file
|
@ -0,0 +1,70 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.UI.ItemTooltip
|
||||
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Terraria.Localization;
|
||||
|
||||
namespace Terraria.UI
|
||||
{
|
||||
public class ItemTooltip
|
||||
{
|
||||
public static readonly ItemTooltip None = new ItemTooltip();
|
||||
private static List<TooltipProcessor> _globalProcessors = new List<TooltipProcessor>();
|
||||
private string[] _tooltipLines;
|
||||
private GameCulture _lastCulture;
|
||||
private LocalizedText _text;
|
||||
private string _processedText;
|
||||
|
||||
public int Lines
|
||||
{
|
||||
get
|
||||
{
|
||||
this.ValidateTooltip();
|
||||
return this._tooltipLines == null ? 0 : this._tooltipLines.Length;
|
||||
}
|
||||
}
|
||||
|
||||
private ItemTooltip()
|
||||
{
|
||||
}
|
||||
|
||||
private ItemTooltip(string key) => this._text = Language.GetText(key);
|
||||
|
||||
public static ItemTooltip FromLanguageKey(string key) => !Language.Exists(key) ? ItemTooltip.None : new ItemTooltip(key);
|
||||
|
||||
public string GetLine(int line)
|
||||
{
|
||||
this.ValidateTooltip();
|
||||
return this._tooltipLines[line];
|
||||
}
|
||||
|
||||
private void ValidateTooltip()
|
||||
{
|
||||
if (this._lastCulture == Language.ActiveCulture)
|
||||
return;
|
||||
this._lastCulture = Language.ActiveCulture;
|
||||
if (this._text == null)
|
||||
{
|
||||
this._tooltipLines = (string[]) null;
|
||||
this._processedText = string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
string tooltip = this._text.Value;
|
||||
foreach (TooltipProcessor globalProcessor in ItemTooltip._globalProcessors)
|
||||
tooltip = globalProcessor(tooltip);
|
||||
this._tooltipLines = tooltip.Split('\n');
|
||||
this._processedText = tooltip;
|
||||
}
|
||||
}
|
||||
|
||||
public static void AddGlobalProcessor(TooltipProcessor processor) => ItemTooltip._globalProcessors.Add(processor);
|
||||
|
||||
public static void RemoveGlobalProcessor(TooltipProcessor processor) => ItemTooltip._globalProcessors.Remove(processor);
|
||||
|
||||
public static void ClearGlobalProcessors() => ItemTooltip._globalProcessors.Clear();
|
||||
}
|
||||
}
|
24
UI/LegacyGameInterfaceLayer.cs
Normal file
24
UI/LegacyGameInterfaceLayer.cs
Normal file
|
@ -0,0 +1,24 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.UI.LegacyGameInterfaceLayer
|
||||
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
namespace Terraria.UI
|
||||
{
|
||||
public class LegacyGameInterfaceLayer : GameInterfaceLayer
|
||||
{
|
||||
private GameInterfaceDrawMethod _drawMethod;
|
||||
|
||||
public LegacyGameInterfaceLayer(
|
||||
string name,
|
||||
GameInterfaceDrawMethod drawMethod,
|
||||
InterfaceScaleType scaleType = InterfaceScaleType.Game)
|
||||
: base(name, scaleType)
|
||||
{
|
||||
this._drawMethod = drawMethod;
|
||||
}
|
||||
|
||||
protected override bool DrawSelf() => this._drawMethod();
|
||||
}
|
||||
}
|
43
UI/SnapPoint.cs
Normal file
43
UI/SnapPoint.cs
Normal file
|
@ -0,0 +1,43 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.UI.SnapPoint
|
||||
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace Terraria.UI
|
||||
{
|
||||
public class SnapPoint
|
||||
{
|
||||
private Vector2 _anchor;
|
||||
private Vector2 _offset;
|
||||
private Vector2 _calculatedPosition;
|
||||
private string _name;
|
||||
private int _id;
|
||||
public UIElement BoundElement;
|
||||
|
||||
public string Name => this._name;
|
||||
|
||||
public int ID => this._id;
|
||||
|
||||
public Vector2 Position => this._calculatedPosition;
|
||||
|
||||
public SnapPoint(string name, int id, Vector2 anchor, Vector2 offset)
|
||||
{
|
||||
this._name = name;
|
||||
this._id = id;
|
||||
this._anchor = anchor;
|
||||
this._offset = offset;
|
||||
}
|
||||
|
||||
public void Calculate(UIElement element)
|
||||
{
|
||||
this.BoundElement = element;
|
||||
CalculatedStyle dimensions = element.GetDimensions();
|
||||
this._calculatedPosition = dimensions.Position() + this._offset + this._anchor * new Vector2(dimensions.Width, dimensions.Height);
|
||||
}
|
||||
|
||||
public override string ToString() => "Snap Point - " + this.Name + " " + (object) this.ID;
|
||||
}
|
||||
}
|
30
UI/StyleDimension.cs
Normal file
30
UI/StyleDimension.cs
Normal file
|
@ -0,0 +1,30 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.UI.StyleDimension
|
||||
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
namespace Terraria.UI
|
||||
{
|
||||
public struct StyleDimension
|
||||
{
|
||||
public static StyleDimension Fill = new StyleDimension(0.0f, 1f);
|
||||
public static StyleDimension Empty = new StyleDimension(0.0f, 0.0f);
|
||||
public float Pixels;
|
||||
public float Precent;
|
||||
|
||||
public StyleDimension(float pixels, float precent)
|
||||
{
|
||||
this.Pixels = pixels;
|
||||
this.Precent = precent;
|
||||
}
|
||||
|
||||
public void Set(float pixels, float precent)
|
||||
{
|
||||
this.Pixels = pixels;
|
||||
this.Precent = precent;
|
||||
}
|
||||
|
||||
public float GetValue(float containerSize) => this.Pixels + this.Precent * containerSize;
|
||||
}
|
||||
}
|
10
UI/TooltipProcessor.cs
Normal file
10
UI/TooltipProcessor.cs
Normal file
|
@ -0,0 +1,10 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.UI.TooltipProcessor
|
||||
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
namespace Terraria.UI
|
||||
{
|
||||
public delegate string TooltipProcessor(string tooltip);
|
||||
}
|
18
UI/UIAlign.cs
Normal file
18
UI/UIAlign.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.UI.UIAlign
|
||||
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
namespace Terraria.UI
|
||||
{
|
||||
public static class UIAlign
|
||||
{
|
||||
public const float Left = 0.0f;
|
||||
public const float Center = 0.5f;
|
||||
public const float Right = 1f;
|
||||
public const float Top = 0.0f;
|
||||
public const float Middle = 0.5f;
|
||||
public const float Bottom = 1f;
|
||||
}
|
||||
}
|
389
UI/UIElement.cs
Normal file
389
UI/UIElement.cs
Normal file
|
@ -0,0 +1,389 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.UI.UIElement
|
||||
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
|
||||
// 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.UI.Elements;
|
||||
|
||||
namespace Terraria.UI
|
||||
{
|
||||
public class UIElement : IComparable
|
||||
{
|
||||
public string Id = "";
|
||||
public UIElement Parent;
|
||||
protected List<UIElement> Elements = new List<UIElement>();
|
||||
public StyleDimension Top;
|
||||
public StyleDimension Left;
|
||||
public StyleDimension Width;
|
||||
public StyleDimension Height;
|
||||
public StyleDimension MaxWidth = StyleDimension.Fill;
|
||||
public StyleDimension MaxHeight = StyleDimension.Fill;
|
||||
public StyleDimension MinWidth = StyleDimension.Empty;
|
||||
public StyleDimension MinHeight = StyleDimension.Empty;
|
||||
private bool _isInitialized;
|
||||
public bool OverflowHidden;
|
||||
public float PaddingTop;
|
||||
public float PaddingLeft;
|
||||
public float PaddingRight;
|
||||
public float PaddingBottom;
|
||||
public float MarginTop;
|
||||
public float MarginLeft;
|
||||
public float MarginRight;
|
||||
public float MarginBottom;
|
||||
public float HAlign;
|
||||
public float VAlign;
|
||||
private CalculatedStyle _innerDimensions;
|
||||
private CalculatedStyle _dimensions;
|
||||
private CalculatedStyle _outerDimensions;
|
||||
private static RasterizerState _overflowHiddenRasterizerState;
|
||||
protected bool _useImmediateMode;
|
||||
private SnapPoint _snapPoint;
|
||||
private bool _isMouseHovering;
|
||||
|
||||
public event UIElement.MouseEvent OnMouseDown;
|
||||
|
||||
public event UIElement.MouseEvent OnMouseUp;
|
||||
|
||||
public event UIElement.MouseEvent OnClick;
|
||||
|
||||
public event UIElement.MouseEvent OnMouseOver;
|
||||
|
||||
public event UIElement.MouseEvent OnMouseOut;
|
||||
|
||||
public event UIElement.MouseEvent OnDoubleClick;
|
||||
|
||||
public event UIElement.ScrollWheelEvent OnScrollWheel;
|
||||
|
||||
public bool IsMouseHovering => this._isMouseHovering;
|
||||
|
||||
public UIElement()
|
||||
{
|
||||
if (UIElement._overflowHiddenRasterizerState != null)
|
||||
return;
|
||||
UIElement._overflowHiddenRasterizerState = new RasterizerState()
|
||||
{
|
||||
CullMode = CullMode.None,
|
||||
ScissorTestEnable = true
|
||||
};
|
||||
}
|
||||
|
||||
public void SetSnapPoint(string name, int id, Vector2? anchor = null, Vector2? offset = null)
|
||||
{
|
||||
if (!anchor.HasValue)
|
||||
anchor = new Vector2?(new Vector2(0.5f));
|
||||
if (!offset.HasValue)
|
||||
offset = new Vector2?(Vector2.Zero);
|
||||
this._snapPoint = new SnapPoint(name, id, anchor.Value, offset.Value);
|
||||
}
|
||||
|
||||
public bool GetSnapPoint(out SnapPoint point)
|
||||
{
|
||||
point = this._snapPoint;
|
||||
if (this._snapPoint != null)
|
||||
this._snapPoint.Calculate(this);
|
||||
return this._snapPoint != null;
|
||||
}
|
||||
|
||||
protected virtual void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
}
|
||||
|
||||
protected virtual void DrawChildren(SpriteBatch spriteBatch)
|
||||
{
|
||||
foreach (UIElement element in this.Elements)
|
||||
element.Draw(spriteBatch);
|
||||
}
|
||||
|
||||
public void Append(UIElement element)
|
||||
{
|
||||
element.Remove();
|
||||
element.Parent = this;
|
||||
this.Elements.Add(element);
|
||||
element.Recalculate();
|
||||
}
|
||||
|
||||
public void Remove()
|
||||
{
|
||||
if (this.Parent == null)
|
||||
return;
|
||||
this.Parent.RemoveChild(this);
|
||||
}
|
||||
|
||||
public void RemoveChild(UIElement child)
|
||||
{
|
||||
this.Elements.Remove(child);
|
||||
child.Parent = (UIElement) null;
|
||||
}
|
||||
|
||||
public void RemoveAllChildren()
|
||||
{
|
||||
foreach (UIElement element in this.Elements)
|
||||
element.Parent = (UIElement) null;
|
||||
this.Elements.Clear();
|
||||
}
|
||||
|
||||
public virtual void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
int num1 = this.OverflowHidden ? 1 : 0;
|
||||
int num2 = this._useImmediateMode ? 1 : 0;
|
||||
RasterizerState rasterizerState = spriteBatch.GraphicsDevice.RasterizerState;
|
||||
Rectangle scissorRectangle = spriteBatch.GraphicsDevice.ScissorRectangle;
|
||||
SamplerState anisotropicClamp = SamplerState.AnisotropicClamp;
|
||||
if (num2 != 0)
|
||||
{
|
||||
spriteBatch.End();
|
||||
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, anisotropicClamp, DepthStencilState.None, UIElement._overflowHiddenRasterizerState, (Effect) null, Main.UIScaleMatrix);
|
||||
this.DrawSelf(spriteBatch);
|
||||
spriteBatch.End();
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, anisotropicClamp, DepthStencilState.None, UIElement._overflowHiddenRasterizerState, (Effect) null, Main.UIScaleMatrix);
|
||||
}
|
||||
else
|
||||
this.DrawSelf(spriteBatch);
|
||||
if (num1 != 0)
|
||||
{
|
||||
spriteBatch.End();
|
||||
Rectangle clippingRectangle = this.GetClippingRectangle(spriteBatch);
|
||||
spriteBatch.GraphicsDevice.ScissorRectangle = clippingRectangle;
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, anisotropicClamp, DepthStencilState.None, UIElement._overflowHiddenRasterizerState, (Effect) null, Main.UIScaleMatrix);
|
||||
}
|
||||
this.DrawChildren(spriteBatch);
|
||||
if (num1 == 0)
|
||||
return;
|
||||
spriteBatch.End();
|
||||
spriteBatch.GraphicsDevice.ScissorRectangle = scissorRectangle;
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, anisotropicClamp, DepthStencilState.None, rasterizerState, (Effect) null, Main.UIScaleMatrix);
|
||||
}
|
||||
|
||||
public virtual void Update(GameTime gameTime)
|
||||
{
|
||||
foreach (UIElement element in this.Elements)
|
||||
element.Update(gameTime);
|
||||
}
|
||||
|
||||
public Rectangle GetClippingRectangle(SpriteBatch spriteBatch)
|
||||
{
|
||||
Vector2 position1 = new Vector2(this._innerDimensions.X, this._innerDimensions.Y);
|
||||
Vector2 position2 = new Vector2(this._innerDimensions.Width, this._innerDimensions.Height) + position1;
|
||||
Vector2 vector2_1 = Vector2.Transform(position1, Main.UIScaleMatrix);
|
||||
Vector2 vector2_2 = Vector2.Transform(position2, Main.UIScaleMatrix);
|
||||
Rectangle rectangle = new Rectangle((int) vector2_1.X, (int) vector2_1.Y, (int) ((double) vector2_2.X - (double) vector2_1.X), (int) ((double) vector2_2.Y - (double) vector2_1.Y));
|
||||
int width = spriteBatch.GraphicsDevice.Viewport.Width;
|
||||
int height = spriteBatch.GraphicsDevice.Viewport.Height;
|
||||
rectangle.X = Utils.Clamp<int>(rectangle.X, 0, width);
|
||||
rectangle.Y = Utils.Clamp<int>(rectangle.Y, 0, height);
|
||||
rectangle.Width = Utils.Clamp<int>(rectangle.Width, 0, width - rectangle.X);
|
||||
rectangle.Height = Utils.Clamp<int>(rectangle.Height, 0, height - rectangle.Y);
|
||||
return rectangle;
|
||||
}
|
||||
|
||||
public virtual List<SnapPoint> GetSnapPoints()
|
||||
{
|
||||
List<SnapPoint> snapPointList = new List<SnapPoint>();
|
||||
SnapPoint point;
|
||||
if (this.GetSnapPoint(out point))
|
||||
snapPointList.Add(point);
|
||||
foreach (UIElement element in this.Elements)
|
||||
snapPointList.AddRange((IEnumerable<SnapPoint>) element.GetSnapPoints());
|
||||
return snapPointList;
|
||||
}
|
||||
|
||||
public virtual void Recalculate()
|
||||
{
|
||||
CalculatedStyle calculatedStyle1 = this.Parent == null ? UserInterface.ActiveInstance.GetDimensions() : this.Parent.GetInnerDimensions();
|
||||
if (this.Parent != null && this.Parent is UIList)
|
||||
calculatedStyle1.Height = float.MaxValue;
|
||||
CalculatedStyle calculatedStyle2;
|
||||
calculatedStyle2.X = this.Left.GetValue(calculatedStyle1.Width) + calculatedStyle1.X;
|
||||
calculatedStyle2.Y = this.Top.GetValue(calculatedStyle1.Height) + calculatedStyle1.Y;
|
||||
float min1 = this.MinWidth.GetValue(calculatedStyle1.Width);
|
||||
float max1 = this.MaxWidth.GetValue(calculatedStyle1.Width);
|
||||
float min2 = this.MinHeight.GetValue(calculatedStyle1.Height);
|
||||
float max2 = this.MaxHeight.GetValue(calculatedStyle1.Height);
|
||||
calculatedStyle2.Width = MathHelper.Clamp(this.Width.GetValue(calculatedStyle1.Width), min1, max1);
|
||||
calculatedStyle2.Height = MathHelper.Clamp(this.Height.GetValue(calculatedStyle1.Height), min2, max2);
|
||||
calculatedStyle2.Width += this.MarginLeft + this.MarginRight;
|
||||
calculatedStyle2.Height += this.MarginTop + this.MarginBottom;
|
||||
calculatedStyle2.X += (float) ((double) calculatedStyle1.Width * (double) this.HAlign - (double) calculatedStyle2.Width * (double) this.HAlign);
|
||||
calculatedStyle2.Y += (float) ((double) calculatedStyle1.Height * (double) this.VAlign - (double) calculatedStyle2.Height * (double) this.VAlign);
|
||||
this._outerDimensions = calculatedStyle2;
|
||||
calculatedStyle2.X += this.MarginLeft;
|
||||
calculatedStyle2.Y += this.MarginTop;
|
||||
calculatedStyle2.Width -= this.MarginLeft + this.MarginRight;
|
||||
calculatedStyle2.Height -= this.MarginTop + this.MarginBottom;
|
||||
this._dimensions = calculatedStyle2;
|
||||
calculatedStyle2.X += this.PaddingLeft;
|
||||
calculatedStyle2.Y += this.PaddingTop;
|
||||
calculatedStyle2.Width -= this.PaddingLeft + this.PaddingRight;
|
||||
calculatedStyle2.Height -= this.PaddingTop + this.PaddingBottom;
|
||||
this._innerDimensions = calculatedStyle2;
|
||||
this.RecalculateChildren();
|
||||
}
|
||||
|
||||
public UIElement GetElementAt(Vector2 point)
|
||||
{
|
||||
UIElement uiElement = (UIElement) null;
|
||||
foreach (UIElement element in this.Elements)
|
||||
{
|
||||
if (element.ContainsPoint(point))
|
||||
{
|
||||
uiElement = element;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (uiElement != null)
|
||||
return uiElement.GetElementAt(point);
|
||||
return this.ContainsPoint(point) ? this : (UIElement) null;
|
||||
}
|
||||
|
||||
public virtual bool ContainsPoint(Vector2 point) => (double) point.X > (double) this._dimensions.X && (double) point.Y > (double) this._dimensions.Y && (double) point.X < (double) this._dimensions.X + (double) this._dimensions.Width && (double) point.Y < (double) this._dimensions.Y + (double) this._dimensions.Height;
|
||||
|
||||
public void SetPadding(float pixels)
|
||||
{
|
||||
this.PaddingBottom = pixels;
|
||||
this.PaddingLeft = pixels;
|
||||
this.PaddingRight = pixels;
|
||||
this.PaddingTop = pixels;
|
||||
}
|
||||
|
||||
public virtual void RecalculateChildren()
|
||||
{
|
||||
foreach (UIElement element in this.Elements)
|
||||
element.Recalculate();
|
||||
}
|
||||
|
||||
public CalculatedStyle GetInnerDimensions() => this._innerDimensions;
|
||||
|
||||
public CalculatedStyle GetDimensions() => this._dimensions;
|
||||
|
||||
public CalculatedStyle GetOuterDimensions() => this._outerDimensions;
|
||||
|
||||
public void CopyStyle(UIElement element)
|
||||
{
|
||||
this.Top = element.Top;
|
||||
this.Left = element.Left;
|
||||
this.Width = element.Width;
|
||||
this.Height = element.Height;
|
||||
this.PaddingBottom = element.PaddingBottom;
|
||||
this.PaddingLeft = element.PaddingLeft;
|
||||
this.PaddingRight = element.PaddingRight;
|
||||
this.PaddingTop = element.PaddingTop;
|
||||
this.HAlign = element.HAlign;
|
||||
this.VAlign = element.VAlign;
|
||||
this.MinWidth = element.MinWidth;
|
||||
this.MaxWidth = element.MaxWidth;
|
||||
this.MinHeight = element.MinHeight;
|
||||
this.MaxHeight = element.MaxHeight;
|
||||
this.Recalculate();
|
||||
}
|
||||
|
||||
public virtual void MouseDown(UIMouseEvent evt)
|
||||
{
|
||||
if (this.OnMouseDown != null)
|
||||
this.OnMouseDown(evt, this);
|
||||
if (this.Parent == null)
|
||||
return;
|
||||
this.Parent.MouseDown(evt);
|
||||
}
|
||||
|
||||
public virtual void MouseUp(UIMouseEvent evt)
|
||||
{
|
||||
if (this.OnMouseUp != null)
|
||||
this.OnMouseUp(evt, this);
|
||||
if (this.Parent == null)
|
||||
return;
|
||||
this.Parent.MouseUp(evt);
|
||||
}
|
||||
|
||||
public virtual void MouseOver(UIMouseEvent evt)
|
||||
{
|
||||
this._isMouseHovering = true;
|
||||
if (this.OnMouseOver != null)
|
||||
this.OnMouseOver(evt, this);
|
||||
if (this.Parent == null)
|
||||
return;
|
||||
this.Parent.MouseOver(evt);
|
||||
}
|
||||
|
||||
public virtual void MouseOut(UIMouseEvent evt)
|
||||
{
|
||||
this._isMouseHovering = false;
|
||||
if (this.OnMouseOut != null)
|
||||
this.OnMouseOut(evt, this);
|
||||
if (this.Parent == null)
|
||||
return;
|
||||
this.Parent.MouseOut(evt);
|
||||
}
|
||||
|
||||
public virtual void Click(UIMouseEvent evt)
|
||||
{
|
||||
if (this.OnClick != null)
|
||||
this.OnClick(evt, this);
|
||||
if (this.Parent == null)
|
||||
return;
|
||||
this.Parent.Click(evt);
|
||||
}
|
||||
|
||||
public virtual void DoubleClick(UIMouseEvent evt)
|
||||
{
|
||||
if (this.OnDoubleClick != null)
|
||||
this.OnDoubleClick(evt, this);
|
||||
if (this.Parent == null)
|
||||
return;
|
||||
this.Parent.DoubleClick(evt);
|
||||
}
|
||||
|
||||
public virtual void ScrollWheel(UIScrollWheelEvent evt)
|
||||
{
|
||||
if (this.OnScrollWheel != null)
|
||||
this.OnScrollWheel(evt, this);
|
||||
if (this.Parent == null)
|
||||
return;
|
||||
this.Parent.ScrollWheel(evt);
|
||||
}
|
||||
|
||||
public void Activate()
|
||||
{
|
||||
if (!this._isInitialized)
|
||||
this.Initialize();
|
||||
this.OnActivate();
|
||||
foreach (UIElement element in this.Elements)
|
||||
element.Activate();
|
||||
}
|
||||
|
||||
public virtual void OnActivate()
|
||||
{
|
||||
}
|
||||
|
||||
public void Deactivate()
|
||||
{
|
||||
this.OnDeactivate();
|
||||
foreach (UIElement element in this.Elements)
|
||||
element.Deactivate();
|
||||
}
|
||||
|
||||
public virtual void OnDeactivate()
|
||||
{
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
this.OnInitialize();
|
||||
this._isInitialized = true;
|
||||
}
|
||||
|
||||
public virtual void OnInitialize()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual int CompareTo(object obj) => 0;
|
||||
|
||||
public delegate void MouseEvent(UIMouseEvent evt, UIElement listeningElement);
|
||||
|
||||
public delegate void ScrollWheelEvent(UIScrollWheelEvent evt, UIElement listeningElement);
|
||||
}
|
||||
}
|
15
UI/UIEvent.cs
Normal file
15
UI/UIEvent.cs
Normal file
|
@ -0,0 +1,15 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.UI.UIEvent
|
||||
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
namespace Terraria.UI
|
||||
{
|
||||
public class UIEvent
|
||||
{
|
||||
public readonly UIElement Target;
|
||||
|
||||
public UIEvent(UIElement target) => this.Target = target;
|
||||
}
|
||||
}
|
21
UI/UIMouseEvent.cs
Normal file
21
UI/UIMouseEvent.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.UI.UIMouseEvent
|
||||
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace Terraria.UI
|
||||
{
|
||||
public class UIMouseEvent : UIEvent
|
||||
{
|
||||
public readonly Vector2 MousePosition;
|
||||
|
||||
public UIMouseEvent(UIElement target, Vector2 mousePosition)
|
||||
: base(target)
|
||||
{
|
||||
this.MousePosition = mousePosition;
|
||||
}
|
||||
}
|
||||
}
|
21
UI/UIScrollWheelEvent.cs
Normal file
21
UI/UIScrollWheelEvent.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.UI.UIScrollWheelEvent
|
||||
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace Terraria.UI
|
||||
{
|
||||
public class UIScrollWheelEvent : UIMouseEvent
|
||||
{
|
||||
public readonly int ScrollWheelValue;
|
||||
|
||||
public UIScrollWheelEvent(UIElement target, Vector2 mousePosition, int scrollWheelValue)
|
||||
: base(target, mousePosition)
|
||||
{
|
||||
this.ScrollWheelValue = scrollWheelValue;
|
||||
}
|
||||
}
|
||||
}
|
18
UI/UIState.cs
Normal file
18
UI/UIState.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.UI.UIState
|
||||
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
namespace Terraria.UI
|
||||
{
|
||||
public class UIState : UIElement
|
||||
{
|
||||
public UIState()
|
||||
{
|
||||
this.Width.Precent = 1f;
|
||||
this.Height.Precent = 1f;
|
||||
this.Recalculate();
|
||||
}
|
||||
}
|
||||
}
|
176
UI/UserInterface.cs
Normal file
176
UI/UserInterface.cs
Normal file
|
@ -0,0 +1,176 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.UI.UserInterface
|
||||
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
|
||||
// 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;
|
||||
|
||||
namespace Terraria.UI
|
||||
{
|
||||
public class UserInterface
|
||||
{
|
||||
private const double DOUBLE_CLICK_TIME = 500.0;
|
||||
private const double STATE_CHANGE_CLICK_DISABLE_TIME = 200.0;
|
||||
private const int MAX_HISTORY_SIZE = 32;
|
||||
private const int HISTORY_PRUNE_SIZE = 4;
|
||||
public static UserInterface ActiveInstance = new UserInterface();
|
||||
private List<UIState> _history = new List<UIState>();
|
||||
public Vector2 MousePosition;
|
||||
private bool _wasMouseDown;
|
||||
private UIElement _lastElementHover;
|
||||
private UIElement _lastElementDown;
|
||||
private UIElement _lastElementClicked;
|
||||
private double _lastMouseDownTime;
|
||||
private double _clickDisabledTimeRemaining;
|
||||
public bool IsVisible;
|
||||
private UIState _currentState;
|
||||
|
||||
public void ResetLasts()
|
||||
{
|
||||
this._lastElementHover = (UIElement) null;
|
||||
this._lastElementDown = (UIElement) null;
|
||||
this._lastElementClicked = (UIElement) null;
|
||||
}
|
||||
|
||||
public UIState CurrentState => this._currentState;
|
||||
|
||||
public UserInterface() => UserInterface.ActiveInstance = this;
|
||||
|
||||
public void Use()
|
||||
{
|
||||
if (UserInterface.ActiveInstance != this)
|
||||
{
|
||||
UserInterface.ActiveInstance = this;
|
||||
this.Recalculate();
|
||||
}
|
||||
else
|
||||
UserInterface.ActiveInstance = this;
|
||||
}
|
||||
|
||||
private void ResetState()
|
||||
{
|
||||
this.MousePosition = new Vector2((float) Main.mouseX, (float) Main.mouseY);
|
||||
this._wasMouseDown = Main.mouseLeft;
|
||||
if (this._lastElementHover != null)
|
||||
this._lastElementHover.MouseOut(new UIMouseEvent(this._lastElementHover, this.MousePosition));
|
||||
this._lastElementHover = (UIElement) null;
|
||||
this._lastElementDown = (UIElement) null;
|
||||
this._lastElementClicked = (UIElement) null;
|
||||
this._lastMouseDownTime = 0.0;
|
||||
this._clickDisabledTimeRemaining = Math.Max(this._clickDisabledTimeRemaining, 200.0);
|
||||
}
|
||||
|
||||
public void Update(GameTime time)
|
||||
{
|
||||
if (this._currentState == null)
|
||||
return;
|
||||
this.MousePosition = new Vector2((float) Main.mouseX, (float) Main.mouseY);
|
||||
bool flag1 = Main.mouseLeft && Main.hasFocus;
|
||||
UIElement target = Main.hasFocus ? this._currentState.GetElementAt(this.MousePosition) : (UIElement) null;
|
||||
this._clickDisabledTimeRemaining = Math.Max(0.0, this._clickDisabledTimeRemaining - time.ElapsedGameTime.TotalMilliseconds);
|
||||
bool flag2 = this._clickDisabledTimeRemaining > 0.0;
|
||||
if (target != this._lastElementHover)
|
||||
{
|
||||
if (this._lastElementHover != null)
|
||||
this._lastElementHover.MouseOut(new UIMouseEvent(this._lastElementHover, this.MousePosition));
|
||||
target?.MouseOver(new UIMouseEvent(target, this.MousePosition));
|
||||
this._lastElementHover = target;
|
||||
}
|
||||
if (flag1 && !this._wasMouseDown && target != null && !flag2)
|
||||
{
|
||||
this._lastElementDown = target;
|
||||
target.MouseDown(new UIMouseEvent(target, this.MousePosition));
|
||||
if (this._lastElementClicked == target && time.TotalGameTime.TotalMilliseconds - this._lastMouseDownTime < 500.0)
|
||||
{
|
||||
target.DoubleClick(new UIMouseEvent(target, this.MousePosition));
|
||||
this._lastElementClicked = (UIElement) null;
|
||||
}
|
||||
this._lastMouseDownTime = time.TotalGameTime.TotalMilliseconds;
|
||||
}
|
||||
else if (!flag1 && this._wasMouseDown && this._lastElementDown != null && !flag2)
|
||||
{
|
||||
UIElement lastElementDown = this._lastElementDown;
|
||||
if (lastElementDown.ContainsPoint(this.MousePosition))
|
||||
{
|
||||
lastElementDown.Click(new UIMouseEvent(lastElementDown, this.MousePosition));
|
||||
this._lastElementClicked = this._lastElementDown;
|
||||
}
|
||||
lastElementDown.MouseUp(new UIMouseEvent(lastElementDown, this.MousePosition));
|
||||
this._lastElementDown = (UIElement) null;
|
||||
}
|
||||
if (PlayerInput.ScrollWheelDeltaForUI != 0)
|
||||
{
|
||||
target?.ScrollWheel(new UIScrollWheelEvent(target, this.MousePosition, PlayerInput.ScrollWheelDeltaForUI));
|
||||
PlayerInput.ScrollWheelDeltaForUI = 0;
|
||||
}
|
||||
this._wasMouseDown = flag1;
|
||||
if (this._currentState == null)
|
||||
return;
|
||||
this._currentState.Update(time);
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch, GameTime time)
|
||||
{
|
||||
this.Use();
|
||||
if (this._currentState == null)
|
||||
return;
|
||||
this._currentState.Draw(spriteBatch);
|
||||
}
|
||||
|
||||
public void SetState(UIState state)
|
||||
{
|
||||
if (state != null)
|
||||
this.AddToHistory(state);
|
||||
if (this._currentState != null)
|
||||
this._currentState.Deactivate();
|
||||
this._currentState = state;
|
||||
this.ResetState();
|
||||
if (state == null)
|
||||
return;
|
||||
state.Activate();
|
||||
state.Recalculate();
|
||||
}
|
||||
|
||||
public void GoBack()
|
||||
{
|
||||
if (this._history.Count < 2)
|
||||
return;
|
||||
UIState state = this._history[this._history.Count - 2];
|
||||
this._history.RemoveRange(this._history.Count - 2, 2);
|
||||
this.SetState(state);
|
||||
}
|
||||
|
||||
private void AddToHistory(UIState state)
|
||||
{
|
||||
this._history.Add(state);
|
||||
if (this._history.Count <= 32)
|
||||
return;
|
||||
this._history.RemoveRange(0, 4);
|
||||
}
|
||||
|
||||
public void Recalculate()
|
||||
{
|
||||
if (this._currentState == null)
|
||||
return;
|
||||
this._currentState.Recalculate();
|
||||
}
|
||||
|
||||
public CalculatedStyle GetDimensions() => new CalculatedStyle(0.0f, 0.0f, (float) Main.screenWidth, (float) Main.screenHeight);
|
||||
|
||||
internal void RefreshState()
|
||||
{
|
||||
if (this._currentState != null)
|
||||
this._currentState.Deactivate();
|
||||
this.ResetState();
|
||||
this._currentState.Activate();
|
||||
this._currentState.Recalculate();
|
||||
}
|
||||
|
||||
public bool IsElementUnderMouse() => this.IsVisible && this._lastElementHover != null && !(this._lastElementHover is UIState);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue