Terraria 1.3.5.3 Source Code
This commit is contained in:
commit
4b21dac4b6
503 changed files with 409032 additions and 0 deletions
45
GameContent/UI/Chat/AchievementTagHandler.cs
Normal file
45
GameContent/UI/Chat/AchievementTagHandler.cs
Normal file
|
@ -0,0 +1,45 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Chat.AchievementTagHandler
|
||||
// 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 Terraria.Achievements;
|
||||
using Terraria.UI;
|
||||
using Terraria.UI.Chat;
|
||||
|
||||
namespace Terraria.GameContent.UI.Chat
|
||||
{
|
||||
public class AchievementTagHandler : ITagHandler
|
||||
{
|
||||
TextSnippet ITagHandler.Parse(
|
||||
string text,
|
||||
Color baseColor,
|
||||
string options)
|
||||
{
|
||||
Achievement achievement = Main.Achievements.GetAchievement(text);
|
||||
return achievement == null ? new TextSnippet(text) : (TextSnippet) new AchievementTagHandler.AchievementSnippet(achievement);
|
||||
}
|
||||
|
||||
public static string GenerateTag(Achievement achievement) => "[a:" + achievement.Name + "]";
|
||||
|
||||
private class AchievementSnippet : TextSnippet
|
||||
{
|
||||
private Achievement _achievement;
|
||||
|
||||
public AchievementSnippet(Achievement achievement)
|
||||
: base(achievement.FriendlyName.Value, Color.LightBlue)
|
||||
{
|
||||
this.CheckForHover = true;
|
||||
this._achievement = achievement;
|
||||
}
|
||||
|
||||
public override void OnClick()
|
||||
{
|
||||
IngameOptions.Close();
|
||||
IngameFancyUI.OpenAchievementsAndGoto(this._achievement);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
29
GameContent/UI/Chat/ColorTagHandler.cs
Normal file
29
GameContent/UI/Chat/ColorTagHandler.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Chat.ColorTagHandler
|
||||
// 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.Globalization;
|
||||
using Terraria.UI.Chat;
|
||||
|
||||
namespace Terraria.GameContent.UI.Chat
|
||||
{
|
||||
public class ColorTagHandler : ITagHandler
|
||||
{
|
||||
TextSnippet ITagHandler.Parse(
|
||||
string text,
|
||||
Color baseColor,
|
||||
string options)
|
||||
{
|
||||
TextSnippet textSnippet = new TextSnippet(text);
|
||||
int result;
|
||||
if (!int.TryParse(options, NumberStyles.AllowHexSpecifier, (IFormatProvider) CultureInfo.InvariantCulture, out result))
|
||||
return textSnippet;
|
||||
textSnippet.Color = new Color(result >> 16 & (int) byte.MaxValue, result >> 8 & (int) byte.MaxValue, result & (int) byte.MaxValue);
|
||||
return textSnippet;
|
||||
}
|
||||
}
|
||||
}
|
181
GameContent/UI/Chat/GlyphTagHandler.cs
Normal file
181
GameContent/UI/Chat/GlyphTagHandler.cs
Normal file
|
@ -0,0 +1,181 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Chat.GlyphTagHandler
|
||||
// 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 Microsoft.Xna.Framework.Input;
|
||||
using ReLogic.Graphics;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.UI.Chat;
|
||||
|
||||
namespace Terraria.GameContent.UI.Chat
|
||||
{
|
||||
public class GlyphTagHandler : ITagHandler
|
||||
{
|
||||
private const int GlyphsPerLine = 25;
|
||||
private const int MaxGlyphs = 26;
|
||||
public static float GlyphsScale = 1f;
|
||||
private static Dictionary<string, int> GlyphIndexes = new Dictionary<string, int>()
|
||||
{
|
||||
{
|
||||
Buttons.A.ToString(),
|
||||
0
|
||||
},
|
||||
{
|
||||
Buttons.B.ToString(),
|
||||
1
|
||||
},
|
||||
{
|
||||
Buttons.Back.ToString(),
|
||||
4
|
||||
},
|
||||
{
|
||||
Buttons.DPadDown.ToString(),
|
||||
15
|
||||
},
|
||||
{
|
||||
Buttons.DPadLeft.ToString(),
|
||||
14
|
||||
},
|
||||
{
|
||||
Buttons.DPadRight.ToString(),
|
||||
13
|
||||
},
|
||||
{
|
||||
Buttons.DPadUp.ToString(),
|
||||
16
|
||||
},
|
||||
{
|
||||
Buttons.LeftShoulder.ToString(),
|
||||
6
|
||||
},
|
||||
{
|
||||
Buttons.LeftStick.ToString(),
|
||||
10
|
||||
},
|
||||
{
|
||||
Buttons.LeftThumbstickDown.ToString(),
|
||||
20
|
||||
},
|
||||
{
|
||||
Buttons.LeftThumbstickLeft.ToString(),
|
||||
17
|
||||
},
|
||||
{
|
||||
Buttons.LeftThumbstickRight.ToString(),
|
||||
18
|
||||
},
|
||||
{
|
||||
Buttons.LeftThumbstickUp.ToString(),
|
||||
19
|
||||
},
|
||||
{
|
||||
Buttons.LeftTrigger.ToString(),
|
||||
8
|
||||
},
|
||||
{
|
||||
Buttons.RightShoulder.ToString(),
|
||||
7
|
||||
},
|
||||
{
|
||||
Buttons.RightStick.ToString(),
|
||||
11
|
||||
},
|
||||
{
|
||||
Buttons.RightThumbstickDown.ToString(),
|
||||
24
|
||||
},
|
||||
{
|
||||
Buttons.RightThumbstickLeft.ToString(),
|
||||
21
|
||||
},
|
||||
{
|
||||
Buttons.RightThumbstickRight.ToString(),
|
||||
22
|
||||
},
|
||||
{
|
||||
Buttons.RightThumbstickUp.ToString(),
|
||||
23
|
||||
},
|
||||
{
|
||||
Buttons.RightTrigger.ToString(),
|
||||
9
|
||||
},
|
||||
{
|
||||
Buttons.Start.ToString(),
|
||||
5
|
||||
},
|
||||
{
|
||||
Buttons.X.ToString(),
|
||||
2
|
||||
},
|
||||
{
|
||||
Buttons.Y.ToString(),
|
||||
3
|
||||
},
|
||||
{
|
||||
"LR",
|
||||
25
|
||||
}
|
||||
};
|
||||
|
||||
TextSnippet ITagHandler.Parse(
|
||||
string text,
|
||||
Color baseColor,
|
||||
string options)
|
||||
{
|
||||
int result;
|
||||
if (!int.TryParse(text, out result) || result >= 26)
|
||||
return new TextSnippet(text);
|
||||
GlyphTagHandler.GlyphSnippet glyphSnippet = new GlyphTagHandler.GlyphSnippet(result);
|
||||
glyphSnippet.DeleteWhole = true;
|
||||
glyphSnippet.Text = "[g:" + (object) result + "]";
|
||||
return (TextSnippet) glyphSnippet;
|
||||
}
|
||||
|
||||
public static string GenerateTag(int index) => "[g" + ":" + (object) index + "]";
|
||||
|
||||
public static string GenerateTag(string keyname)
|
||||
{
|
||||
int index;
|
||||
return GlyphTagHandler.GlyphIndexes.TryGetValue(keyname, out index) ? GlyphTagHandler.GenerateTag(index) : keyname;
|
||||
}
|
||||
|
||||
private class GlyphSnippet : TextSnippet
|
||||
{
|
||||
private int _glyphIndex;
|
||||
|
||||
public GlyphSnippet(int index)
|
||||
: base()
|
||||
{
|
||||
this._glyphIndex = index;
|
||||
this.Color = Color.White;
|
||||
}
|
||||
|
||||
public override bool UniqueDraw(
|
||||
bool justCheckingString,
|
||||
out Vector2 size,
|
||||
SpriteBatch spriteBatch,
|
||||
Vector2 position = default (Vector2),
|
||||
Color color = default (Color),
|
||||
float scale = 1f)
|
||||
{
|
||||
if (!justCheckingString && color != Color.Black)
|
||||
{
|
||||
int frameX = this._glyphIndex;
|
||||
if (this._glyphIndex == 25)
|
||||
frameX = (double) Main.GlobalTime % 0.600000023841858 < 0.300000011920929 ? 17 : 18;
|
||||
Texture2D texture2D = Main.textGlyphTexture[0];
|
||||
spriteBatch.Draw(texture2D, position, new Rectangle?(texture2D.Frame(25, frameX: frameX, frameY: (frameX / 25))), color, 0.0f, Vector2.Zero, GlyphTagHandler.GlyphsScale, SpriteEffects.None, 0.0f);
|
||||
}
|
||||
size = new Vector2(26f) * GlyphTagHandler.GlyphsScale;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override float GetStringLength(DynamicSpriteFont font) => 26f * GlyphTagHandler.GlyphsScale;
|
||||
}
|
||||
}
|
||||
}
|
133
GameContent/UI/Chat/ItemTagHandler.cs
Normal file
133
GameContent/UI/Chat/ItemTagHandler.cs
Normal file
|
@ -0,0 +1,133 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Chat.ItemTagHandler
|
||||
// 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 Terraria.UI;
|
||||
using Terraria.UI.Chat;
|
||||
|
||||
namespace Terraria.GameContent.UI.Chat
|
||||
{
|
||||
public class ItemTagHandler : ITagHandler
|
||||
{
|
||||
TextSnippet ITagHandler.Parse(
|
||||
string text,
|
||||
Color baseColor,
|
||||
string options)
|
||||
{
|
||||
Item obj = new Item();
|
||||
int result1;
|
||||
if (int.TryParse(text, out result1))
|
||||
obj.netDefaults(result1);
|
||||
if (obj.type <= 0)
|
||||
return new TextSnippet(text);
|
||||
obj.stack = 1;
|
||||
if (options != null)
|
||||
{
|
||||
string[] strArray = options.Split(',');
|
||||
for (int index = 0; index < strArray.Length; ++index)
|
||||
{
|
||||
if (strArray[index].Length != 0)
|
||||
{
|
||||
switch (strArray[index][0])
|
||||
{
|
||||
case 'p':
|
||||
int result2;
|
||||
if (int.TryParse(strArray[index].Substring(1), out result2))
|
||||
{
|
||||
obj.Prefix((int) (byte) Utils.Clamp<int>(result2, 0, 84));
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
case 's':
|
||||
case 'x':
|
||||
int result3;
|
||||
if (int.TryParse(strArray[index].Substring(1), out result3))
|
||||
{
|
||||
obj.stack = Utils.Clamp<int>(result3, 1, obj.maxStack);
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
string str = "";
|
||||
if (obj.stack > 1)
|
||||
str = " (" + (object) obj.stack + ")";
|
||||
ItemTagHandler.ItemSnippet itemSnippet = new ItemTagHandler.ItemSnippet(obj);
|
||||
itemSnippet.Text = "[" + obj.AffixName() + str + "]";
|
||||
itemSnippet.CheckForHover = true;
|
||||
itemSnippet.DeleteWhole = true;
|
||||
return (TextSnippet) itemSnippet;
|
||||
}
|
||||
|
||||
public static string GenerateTag(Item I)
|
||||
{
|
||||
string str = "[i";
|
||||
if (I.prefix != (byte) 0)
|
||||
str = str + "/p" + (object) I.prefix;
|
||||
if (I.stack != 1)
|
||||
str = str + "/s" + (object) I.stack;
|
||||
return str + ":" + (object) I.netID + "]";
|
||||
}
|
||||
|
||||
private class ItemSnippet : TextSnippet
|
||||
{
|
||||
private Item _item;
|
||||
|
||||
public ItemSnippet(Item item)
|
||||
: base()
|
||||
{
|
||||
this._item = item;
|
||||
this.Color = ItemRarity.GetColor(item.rare);
|
||||
}
|
||||
|
||||
public override void OnHover()
|
||||
{
|
||||
Main.HoverItem = this._item.Clone();
|
||||
Main.instance.MouseText(this._item.Name, this._item.rare);
|
||||
}
|
||||
|
||||
public override bool UniqueDraw(
|
||||
bool justCheckingString,
|
||||
out Vector2 size,
|
||||
SpriteBatch spriteBatch,
|
||||
Vector2 position = default (Vector2),
|
||||
Color color = default (Color),
|
||||
float scale = 1f)
|
||||
{
|
||||
float num1 = 1f;
|
||||
float num2 = 1f;
|
||||
if (Main.netMode != 2 && !Main.dedServ)
|
||||
{
|
||||
Texture2D texture2D = Main.itemTexture[this._item.type];
|
||||
Rectangle rectangle = Main.itemAnimations[this._item.type] == null ? texture2D.Frame() : Main.itemAnimations[this._item.type].GetFrame(texture2D);
|
||||
if (rectangle.Height > 32)
|
||||
num2 = 32f / (float) rectangle.Height;
|
||||
}
|
||||
float num3 = num2 * scale;
|
||||
float num4 = num1 * num3;
|
||||
if ((double) num4 > 0.75)
|
||||
num4 = 0.75f;
|
||||
if (!justCheckingString && color != Color.Black)
|
||||
{
|
||||
double inventoryScale = (double) Main.inventoryScale;
|
||||
Main.inventoryScale = scale * num4;
|
||||
ItemSlot.Draw(spriteBatch, ref this._item, 14, position - new Vector2(10f) * scale * num4, Color.White);
|
||||
Main.inventoryScale = (float) inventoryScale;
|
||||
}
|
||||
size = new Vector2(32f) * scale * num4;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override float GetStringLength(DynamicSpriteFont font) => (float) (32.0 * (double) this.Scale * 0.649999976158142);
|
||||
}
|
||||
}
|
||||
}
|
24
GameContent/UI/Chat/NameTagHandler.cs
Normal file
24
GameContent/UI/Chat/NameTagHandler.cs
Normal file
|
@ -0,0 +1,24 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Chat.NameTagHandler
|
||||
// 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 Terraria.UI.Chat;
|
||||
|
||||
namespace Terraria.GameContent.UI.Chat
|
||||
{
|
||||
public class NameTagHandler : ITagHandler
|
||||
{
|
||||
TextSnippet ITagHandler.Parse(
|
||||
string text,
|
||||
Color baseColor,
|
||||
string options)
|
||||
{
|
||||
return new TextSnippet("<" + text.Replace("\\[", "[").Replace("\\]", "]") + ">", baseColor);
|
||||
}
|
||||
|
||||
public static string GenerateTag(string name) => "[n:" + name.Replace("[", "\\[").Replace("]", "\\]") + "]";
|
||||
}
|
||||
}
|
37
GameContent/UI/Chat/PlainTagHandler.cs
Normal file
37
GameContent/UI/Chat/PlainTagHandler.cs
Normal file
|
@ -0,0 +1,37 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Chat.PlainTagHandler
|
||||
// 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 Terraria.UI.Chat;
|
||||
|
||||
namespace Terraria.GameContent.UI.Chat
|
||||
{
|
||||
public class PlainTagHandler : ITagHandler
|
||||
{
|
||||
TextSnippet ITagHandler.Parse(
|
||||
string text,
|
||||
Color baseColor,
|
||||
string options)
|
||||
{
|
||||
return (TextSnippet) new PlainTagHandler.PlainSnippet(text);
|
||||
}
|
||||
|
||||
public class PlainSnippet : TextSnippet
|
||||
{
|
||||
public PlainSnippet(string text = "")
|
||||
: base(text)
|
||||
{
|
||||
}
|
||||
|
||||
public PlainSnippet(string text, Color color, float scale = 1f)
|
||||
: base(text, color, scale)
|
||||
{
|
||||
}
|
||||
|
||||
public override Color GetVisibleColor() => this.Color;
|
||||
}
|
||||
}
|
||||
}
|
127
GameContent/UI/CustomCurrencyManager.cs
Normal file
127
GameContent/UI/CustomCurrencyManager.cs
Normal file
|
@ -0,0 +1,127 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.CustomCurrencyManager
|
||||
// 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.ID;
|
||||
|
||||
namespace Terraria.GameContent.UI
|
||||
{
|
||||
public class CustomCurrencyManager
|
||||
{
|
||||
private static int _nextCurrencyIndex = 0;
|
||||
private static Dictionary<int, CustomCurrencySystem> _currencies = new Dictionary<int, CustomCurrencySystem>();
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
CustomCurrencyManager._nextCurrencyIndex = 0;
|
||||
CustomCurrencyID.DefenderMedals = CustomCurrencyManager.RegisterCurrency((CustomCurrencySystem) new CustomCurrencySingleCoin(3817, 999L));
|
||||
}
|
||||
|
||||
public static int RegisterCurrency(CustomCurrencySystem collection)
|
||||
{
|
||||
int nextCurrencyIndex = CustomCurrencyManager._nextCurrencyIndex;
|
||||
++CustomCurrencyManager._nextCurrencyIndex;
|
||||
CustomCurrencyManager._currencies[nextCurrencyIndex] = collection;
|
||||
return nextCurrencyIndex;
|
||||
}
|
||||
|
||||
public static void DrawSavings(
|
||||
SpriteBatch sb,
|
||||
int currencyIndex,
|
||||
float shopx,
|
||||
float shopy,
|
||||
bool horizontal = false)
|
||||
{
|
||||
CustomCurrencySystem currency = CustomCurrencyManager._currencies[currencyIndex];
|
||||
Player player = Main.player[Main.myPlayer];
|
||||
bool overFlowing;
|
||||
long num1 = currency.CountCurrency(out overFlowing, player.bank.item);
|
||||
long num2 = currency.CountCurrency(out overFlowing, player.bank2.item);
|
||||
long num3 = currency.CountCurrency(out overFlowing, player.bank3.item);
|
||||
long totalCoins = currency.CombineStacks(out overFlowing, num1, num2, num3);
|
||||
if (totalCoins <= 0L)
|
||||
return;
|
||||
if (num3 > 0L)
|
||||
sb.Draw(Main.itemTexture[3813], Utils.CenteredRectangle(new Vector2(shopx + 80f, shopy + 50f), Main.itemTexture[3813].Size() * 0.65f), new Rectangle?(), Color.White);
|
||||
if (num2 > 0L)
|
||||
sb.Draw(Main.itemTexture[346], Utils.CenteredRectangle(new Vector2(shopx + 80f, shopy + 50f), Main.itemTexture[346].Size() * 0.65f), new Rectangle?(), Color.White);
|
||||
if (num1 > 0L)
|
||||
sb.Draw(Main.itemTexture[87], Utils.CenteredRectangle(new Vector2(shopx + 70f, shopy + 60f), Main.itemTexture[87].Size() * 0.65f), new Rectangle?(), Color.White);
|
||||
Utils.DrawBorderStringFourWay(sb, Main.fontMouseText, Lang.inter[66].Value, shopx, shopy + 40f, Color.White * ((float) Main.mouseTextColor / (float) byte.MaxValue), Color.Black, Vector2.Zero);
|
||||
currency.DrawSavingsMoney(sb, Lang.inter[66].Value, shopx, shopy, totalCoins, horizontal);
|
||||
}
|
||||
|
||||
public static void GetPriceText(
|
||||
int currencyIndex,
|
||||
string[] lines,
|
||||
ref int currentLine,
|
||||
int price)
|
||||
{
|
||||
CustomCurrencyManager._currencies[currencyIndex].GetPriceText(lines, ref currentLine, price);
|
||||
}
|
||||
|
||||
public static bool BuyItem(Player player, int price, int currencyIndex)
|
||||
{
|
||||
CustomCurrencySystem currency = CustomCurrencyManager._currencies[currencyIndex];
|
||||
bool overFlowing;
|
||||
long num1 = currency.CountCurrency(out overFlowing, player.inventory, 58, 57, 56, 55, 54);
|
||||
long num2 = currency.CountCurrency(out overFlowing, player.bank.item);
|
||||
long num3 = currency.CountCurrency(out overFlowing, player.bank2.item);
|
||||
long num4 = currency.CountCurrency(out overFlowing, player.bank3.item);
|
||||
if (currency.CombineStacks(out overFlowing, num1, num2, num3, num4) < (long) price)
|
||||
return false;
|
||||
List<Item[]> objArrayList = new List<Item[]>();
|
||||
Dictionary<int, List<int>> slotsToIgnore = new Dictionary<int, List<int>>();
|
||||
List<Point> pointList1 = new List<Point>();
|
||||
List<Point> slotCoins = new List<Point>();
|
||||
List<Point> pointList2 = new List<Point>();
|
||||
List<Point> pointList3 = new List<Point>();
|
||||
List<Point> pointList4 = new List<Point>();
|
||||
objArrayList.Add(player.inventory);
|
||||
objArrayList.Add(player.bank.item);
|
||||
objArrayList.Add(player.bank2.item);
|
||||
objArrayList.Add(player.bank3.item);
|
||||
for (int key = 0; key < objArrayList.Count; ++key)
|
||||
slotsToIgnore[key] = new List<int>();
|
||||
slotsToIgnore[0] = new List<int>()
|
||||
{
|
||||
58,
|
||||
57,
|
||||
56,
|
||||
55,
|
||||
54
|
||||
};
|
||||
for (int index = 0; index < objArrayList.Count; ++index)
|
||||
{
|
||||
for (int y = 0; y < objArrayList[index].Length; ++y)
|
||||
{
|
||||
if (!slotsToIgnore[index].Contains(y) && currency.Accepts(objArrayList[index][y]))
|
||||
slotCoins.Add(new Point(index, y));
|
||||
}
|
||||
}
|
||||
CustomCurrencyManager.FindEmptySlots(objArrayList, slotsToIgnore, pointList1, 0);
|
||||
CustomCurrencyManager.FindEmptySlots(objArrayList, slotsToIgnore, pointList2, 1);
|
||||
CustomCurrencyManager.FindEmptySlots(objArrayList, slotsToIgnore, pointList3, 2);
|
||||
CustomCurrencyManager.FindEmptySlots(objArrayList, slotsToIgnore, pointList4, 3);
|
||||
return currency.TryPurchasing(price, objArrayList, slotCoins, pointList1, pointList2, pointList3, pointList4);
|
||||
}
|
||||
|
||||
private static void FindEmptySlots(
|
||||
List<Item[]> inventories,
|
||||
Dictionary<int, List<int>> slotsToIgnore,
|
||||
List<Point> emptySlots,
|
||||
int currentInventoryIndex)
|
||||
{
|
||||
for (int y = inventories[currentInventoryIndex].Length - 1; y >= 0; --y)
|
||||
{
|
||||
if (!slotsToIgnore[currentInventoryIndex].Contains(y) && (inventories[currentInventoryIndex][y].type == 0 || inventories[currentInventoryIndex][y].stack == 0))
|
||||
emptySlots.Add(new Point(currentInventoryIndex, y));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
107
GameContent/UI/CustomCurrencySingleCoin.cs
Normal file
107
GameContent/UI/CustomCurrencySingleCoin.cs
Normal file
|
@ -0,0 +1,107 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.CustomCurrencySingleCoin
|
||||
// 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 System.Linq;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI.Chat;
|
||||
|
||||
namespace Terraria.GameContent.UI
|
||||
{
|
||||
public class CustomCurrencySingleCoin : CustomCurrencySystem
|
||||
{
|
||||
public float CurrencyDrawScale = 0.8f;
|
||||
public string CurrencyTextKey = "Currency.DefenderMedals";
|
||||
public Color CurrencyTextColor = new Color(240, 100, 120);
|
||||
|
||||
public CustomCurrencySingleCoin(int coinItemID, long currencyCap)
|
||||
{
|
||||
this.Include(coinItemID, 1);
|
||||
this.SetCurrencyCap(currencyCap);
|
||||
}
|
||||
|
||||
public override bool TryPurchasing(
|
||||
int price,
|
||||
List<Item[]> inv,
|
||||
List<Point> slotCoins,
|
||||
List<Point> slotsEmpty,
|
||||
List<Point> slotEmptyBank,
|
||||
List<Point> slotEmptyBank2,
|
||||
List<Point> slotEmptyBank3)
|
||||
{
|
||||
List<Tuple<Point, Item>> cache = this.ItemCacheCreate(inv);
|
||||
int num1 = price;
|
||||
for (int index = 0; index < slotCoins.Count; ++index)
|
||||
{
|
||||
Point slotCoin = slotCoins[index];
|
||||
int num2 = num1;
|
||||
if (inv[slotCoin.X][slotCoin.Y].stack < num2)
|
||||
num2 = inv[slotCoin.X][slotCoin.Y].stack;
|
||||
num1 -= num2;
|
||||
inv[slotCoin.X][slotCoin.Y].stack -= num2;
|
||||
if (inv[slotCoin.X][slotCoin.Y].stack == 0)
|
||||
{
|
||||
switch (slotCoin.X)
|
||||
{
|
||||
case 0:
|
||||
slotsEmpty.Add(slotCoin);
|
||||
break;
|
||||
case 1:
|
||||
slotEmptyBank.Add(slotCoin);
|
||||
break;
|
||||
case 2:
|
||||
slotEmptyBank2.Add(slotCoin);
|
||||
break;
|
||||
case 3:
|
||||
slotEmptyBank3.Add(slotCoin);
|
||||
break;
|
||||
}
|
||||
slotCoins.Remove(slotCoin);
|
||||
--index;
|
||||
}
|
||||
if (num1 == 0)
|
||||
break;
|
||||
}
|
||||
if (num1 == 0)
|
||||
return true;
|
||||
this.ItemCacheRestore(cache, inv);
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void DrawSavingsMoney(
|
||||
SpriteBatch sb,
|
||||
string text,
|
||||
float shopx,
|
||||
float shopy,
|
||||
long totalCoins,
|
||||
bool horizontal = false)
|
||||
{
|
||||
int index = this._valuePerUnit.Keys.ElementAt<int>(0);
|
||||
Texture2D texture2D = Main.itemTexture[index];
|
||||
if (horizontal)
|
||||
{
|
||||
Vector2 position = new Vector2((float) ((double) shopx + (double) ChatManager.GetStringSize(Main.fontMouseText, text, Vector2.One).X + 45.0), shopy + 50f);
|
||||
sb.Draw(texture2D, position, new Rectangle?(), Color.White, 0.0f, texture2D.Size() / 2f, this.CurrencyDrawScale, SpriteEffects.None, 0.0f);
|
||||
Utils.DrawBorderStringFourWay(sb, Main.fontItemStack, totalCoins.ToString(), position.X - 11f, position.Y, Color.White, Color.Black, new Vector2(0.3f), 0.75f);
|
||||
}
|
||||
else
|
||||
{
|
||||
int num = totalCoins > 99L ? -6 : 0;
|
||||
sb.Draw(texture2D, new Vector2(shopx + 11f, shopy + 75f), new Rectangle?(), Color.White, 0.0f, texture2D.Size() / 2f, this.CurrencyDrawScale, SpriteEffects.None, 0.0f);
|
||||
Utils.DrawBorderStringFourWay(sb, Main.fontItemStack, totalCoins.ToString(), shopx + (float) num, shopy + 75f, Color.White, Color.Black, new Vector2(0.3f), 0.75f);
|
||||
}
|
||||
}
|
||||
|
||||
public override void GetPriceText(string[] lines, ref int currentLine, int price)
|
||||
{
|
||||
Color color = this.CurrencyTextColor * ((float) Main.mouseTextColor / (float) byte.MaxValue);
|
||||
lines[currentLine++] = string.Format("[c/{0:X2}{1:X2}{2:X2}:{3} {4} {5}]", (object) color.R, (object) color.G, (object) color.B, (object) Lang.tip[50].Value, (object) price, (object) Language.GetTextValue(this.CurrencyTextKey).ToLower());
|
||||
}
|
||||
}
|
||||
}
|
237
GameContent/UI/CustomCurrencySystem.cs
Normal file
237
GameContent/UI/CustomCurrencySystem.cs
Normal file
|
@ -0,0 +1,237 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.CustomCurrencySystem
|
||||
// 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;
|
||||
|
||||
namespace Terraria.GameContent.UI
|
||||
{
|
||||
public class CustomCurrencySystem
|
||||
{
|
||||
protected Dictionary<int, int> _valuePerUnit = new Dictionary<int, int>();
|
||||
private long _currencyCap = 999999999;
|
||||
|
||||
public long CurrencyCap => this._currencyCap;
|
||||
|
||||
public void Include(int coin, int howMuchIsItWorth) => this._valuePerUnit[coin] = howMuchIsItWorth;
|
||||
|
||||
public void SetCurrencyCap(long cap) => this._currencyCap = cap;
|
||||
|
||||
public virtual long CountCurrency(out bool overFlowing, Item[] inv, params int[] ignoreSlots)
|
||||
{
|
||||
List<int> intList = new List<int>((IEnumerable<int>) ignoreSlots);
|
||||
long num1 = 0;
|
||||
for (int index = 0; index < inv.Length; ++index)
|
||||
{
|
||||
if (!intList.Contains(index))
|
||||
{
|
||||
int num2;
|
||||
if (this._valuePerUnit.TryGetValue(inv[index].type, out num2))
|
||||
num1 += (long) (num2 * inv[index].stack);
|
||||
if (num1 >= this.CurrencyCap)
|
||||
{
|
||||
overFlowing = true;
|
||||
return this.CurrencyCap;
|
||||
}
|
||||
}
|
||||
}
|
||||
overFlowing = false;
|
||||
return num1;
|
||||
}
|
||||
|
||||
public virtual long CombineStacks(out bool overFlowing, params long[] coinCounts)
|
||||
{
|
||||
long num = 0;
|
||||
foreach (long coinCount in coinCounts)
|
||||
{
|
||||
num += coinCount;
|
||||
if (num >= this.CurrencyCap)
|
||||
{
|
||||
overFlowing = true;
|
||||
return this.CurrencyCap;
|
||||
}
|
||||
}
|
||||
overFlowing = false;
|
||||
return num;
|
||||
}
|
||||
|
||||
public virtual bool TryPurchasing(
|
||||
int price,
|
||||
List<Item[]> inv,
|
||||
List<Point> slotCoins,
|
||||
List<Point> slotsEmpty,
|
||||
List<Point> slotEmptyBank,
|
||||
List<Point> slotEmptyBank2,
|
||||
List<Point> slotEmptyBank3)
|
||||
{
|
||||
long num1 = (long) price;
|
||||
Dictionary<Point, Item> dictionary = new Dictionary<Point, Item>();
|
||||
bool flag = true;
|
||||
while (num1 > 0L)
|
||||
{
|
||||
long num2 = 1000000;
|
||||
for (int index = 0; index < 4; ++index)
|
||||
{
|
||||
if (num1 >= num2)
|
||||
{
|
||||
foreach (Point slotCoin in slotCoins)
|
||||
{
|
||||
if (inv[slotCoin.X][slotCoin.Y].type == 74 - index)
|
||||
{
|
||||
long num3 = num1 / num2;
|
||||
dictionary[slotCoin] = inv[slotCoin.X][slotCoin.Y].Clone();
|
||||
if (num3 < (long) inv[slotCoin.X][slotCoin.Y].stack)
|
||||
{
|
||||
inv[slotCoin.X][slotCoin.Y].stack -= (int) num3;
|
||||
}
|
||||
else
|
||||
{
|
||||
inv[slotCoin.X][slotCoin.Y].SetDefaults();
|
||||
slotsEmpty.Add(slotCoin);
|
||||
}
|
||||
num1 -= num2 * (long) (dictionary[slotCoin].stack - inv[slotCoin.X][slotCoin.Y].stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
num2 /= 100L;
|
||||
}
|
||||
if (num1 > 0L)
|
||||
{
|
||||
if (slotsEmpty.Count > 0)
|
||||
{
|
||||
slotsEmpty.Sort(new Comparison<Point>(DelegateMethods.CompareYReverse));
|
||||
Point point = new Point(-1, -1);
|
||||
for (int index1 = 0; index1 < inv.Count; ++index1)
|
||||
{
|
||||
long num4 = 10000;
|
||||
for (int index2 = 0; index2 < 3; ++index2)
|
||||
{
|
||||
if (num1 >= num4)
|
||||
{
|
||||
foreach (Point slotCoin in slotCoins)
|
||||
{
|
||||
if (slotCoin.X == index1 && inv[slotCoin.X][slotCoin.Y].type == 74 - index2 && inv[slotCoin.X][slotCoin.Y].stack >= 1)
|
||||
{
|
||||
List<Point> pointList = slotsEmpty;
|
||||
if (index1 == 1 && slotEmptyBank.Count > 0)
|
||||
pointList = slotEmptyBank;
|
||||
if (index1 == 2 && slotEmptyBank2.Count > 0)
|
||||
pointList = slotEmptyBank2;
|
||||
if (index1 == 3 && slotEmptyBank3.Count > 0)
|
||||
pointList = slotEmptyBank3;
|
||||
if (--inv[slotCoin.X][slotCoin.Y].stack <= 0)
|
||||
{
|
||||
inv[slotCoin.X][slotCoin.Y].SetDefaults();
|
||||
pointList.Add(slotCoin);
|
||||
}
|
||||
dictionary[pointList[0]] = inv[pointList[0].X][pointList[0].Y].Clone();
|
||||
inv[pointList[0].X][pointList[0].Y].SetDefaults(73 - index2);
|
||||
inv[pointList[0].X][pointList[0].Y].stack = 100;
|
||||
point = pointList[0];
|
||||
pointList.RemoveAt(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (point.X == -1 && point.Y == -1)
|
||||
num4 /= 100L;
|
||||
else
|
||||
break;
|
||||
}
|
||||
for (int index3 = 0; index3 < 2; ++index3)
|
||||
{
|
||||
if (point.X == -1 && point.Y == -1)
|
||||
{
|
||||
foreach (Point slotCoin in slotCoins)
|
||||
{
|
||||
if (slotCoin.X == index1 && inv[slotCoin.X][slotCoin.Y].type == 73 + index3 && inv[slotCoin.X][slotCoin.Y].stack >= 1)
|
||||
{
|
||||
List<Point> pointList = slotsEmpty;
|
||||
if (index1 == 1 && slotEmptyBank.Count > 0)
|
||||
pointList = slotEmptyBank;
|
||||
if (index1 == 2 && slotEmptyBank2.Count > 0)
|
||||
pointList = slotEmptyBank2;
|
||||
if (index1 == 3 && slotEmptyBank3.Count > 0)
|
||||
pointList = slotEmptyBank3;
|
||||
if (--inv[slotCoin.X][slotCoin.Y].stack <= 0)
|
||||
{
|
||||
inv[slotCoin.X][slotCoin.Y].SetDefaults();
|
||||
pointList.Add(slotCoin);
|
||||
}
|
||||
dictionary[pointList[0]] = inv[pointList[0].X][pointList[0].Y].Clone();
|
||||
inv[pointList[0].X][pointList[0].Y].SetDefaults(72 + index3);
|
||||
inv[pointList[0].X][pointList[0].Y].stack = 100;
|
||||
point = pointList[0];
|
||||
pointList.RemoveAt(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (point.X != -1 && point.Y != -1)
|
||||
{
|
||||
slotCoins.Add(point);
|
||||
break;
|
||||
}
|
||||
}
|
||||
slotsEmpty.Sort(new Comparison<Point>(DelegateMethods.CompareYReverse));
|
||||
slotEmptyBank.Sort(new Comparison<Point>(DelegateMethods.CompareYReverse));
|
||||
slotEmptyBank2.Sort(new Comparison<Point>(DelegateMethods.CompareYReverse));
|
||||
slotEmptyBank3.Sort(new Comparison<Point>(DelegateMethods.CompareYReverse));
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (KeyValuePair<Point, Item> keyValuePair in dictionary)
|
||||
inv[keyValuePair.Key.X][keyValuePair.Key.Y] = keyValuePair.Value.Clone();
|
||||
flag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
public virtual bool Accepts(Item item) => this._valuePerUnit.ContainsKey(item.type);
|
||||
|
||||
public virtual void DrawSavingsMoney(
|
||||
SpriteBatch sb,
|
||||
string text,
|
||||
float shopx,
|
||||
float shopy,
|
||||
long totalCoins,
|
||||
bool horizontal = false)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void GetPriceText(string[] lines, ref int currentLine, int price)
|
||||
{
|
||||
}
|
||||
|
||||
protected int SortByHighest(Tuple<int, int> valueA, Tuple<int, int> valueB) => valueA.Item2 > valueB.Item2 || valueA.Item2 != valueB.Item2 ? -1 : 0;
|
||||
|
||||
protected List<Tuple<Point, Item>> ItemCacheCreate(List<Item[]> inventories)
|
||||
{
|
||||
List<Tuple<Point, Item>> tupleList = new List<Tuple<Point, Item>>();
|
||||
for (int index = 0; index < inventories.Count; ++index)
|
||||
{
|
||||
for (int y = 0; y < inventories[index].Length; ++y)
|
||||
{
|
||||
Item obj = inventories[index][y];
|
||||
tupleList.Add(new Tuple<Point, Item>(new Point(index, y), obj.DeepClone()));
|
||||
}
|
||||
}
|
||||
return tupleList;
|
||||
}
|
||||
|
||||
protected void ItemCacheRestore(List<Tuple<Point, Item>> cache, List<Item[]> inventories)
|
||||
{
|
||||
foreach (Tuple<Point, Item> tuple in cache)
|
||||
inventories[tuple.Item1.X][tuple.Item1.Y] = tuple.Item2;
|
||||
}
|
||||
}
|
||||
}
|
231
GameContent/UI/Elements/UIAchievementListItem.cs
Normal file
231
GameContent/UI/Elements/UIAchievementListItem.cs
Normal file
|
@ -0,0 +1,231 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIAchievementListItem
|
||||
// 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.Graphics;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI;
|
||||
using Terraria.UI.Chat;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIAchievementListItem : UIPanel
|
||||
{
|
||||
private Achievement _achievement;
|
||||
private UIImageFramed _achievementIcon;
|
||||
private UIImage _achievementIconBorders;
|
||||
private const int _iconSize = 64;
|
||||
private const int _iconSizeWithSpace = 66;
|
||||
private const int _iconsPerRow = 8;
|
||||
private int _iconIndex;
|
||||
private Rectangle _iconFrame;
|
||||
private Rectangle _iconFrameUnlocked;
|
||||
private Rectangle _iconFrameLocked;
|
||||
private Texture2D _innerPanelTopTexture;
|
||||
private Texture2D _innerPanelBottomTexture;
|
||||
private Texture2D _categoryTexture;
|
||||
private bool _locked;
|
||||
private bool _large;
|
||||
|
||||
public UIAchievementListItem(Achievement achievement, bool largeForOtherLanguages)
|
||||
{
|
||||
this._large = largeForOtherLanguages;
|
||||
this.BackgroundColor = new Color(26, 40, 89) * 0.8f;
|
||||
this.BorderColor = new Color(13, 20, 44) * 0.8f;
|
||||
float num = (float) (16 + this._large.ToInt() * 20);
|
||||
float pixels1 = (float) (this._large.ToInt() * 6);
|
||||
float pixels2 = (float) (this._large.ToInt() * 12);
|
||||
this._achievement = achievement;
|
||||
this.Height.Set(66f + num, 0.0f);
|
||||
this.Width.Set(0.0f, 1f);
|
||||
this.PaddingTop = 8f;
|
||||
this.PaddingLeft = 9f;
|
||||
int iconIndex = Main.Achievements.GetIconIndex(achievement.Name);
|
||||
this._iconIndex = iconIndex;
|
||||
this._iconFrameUnlocked = new Rectangle(iconIndex % 8 * 66, iconIndex / 8 * 66, 64, 64);
|
||||
this._iconFrameLocked = this._iconFrameUnlocked;
|
||||
this._iconFrameLocked.X += 528;
|
||||
this._iconFrame = this._iconFrameLocked;
|
||||
this.UpdateIconFrame();
|
||||
this._achievementIcon = new UIImageFramed(TextureManager.Load("Images/UI/Achievements"), this._iconFrame);
|
||||
this._achievementIcon.Left.Set(pixels1, 0.0f);
|
||||
this._achievementIcon.Top.Set(pixels2, 0.0f);
|
||||
this.Append((UIElement) this._achievementIcon);
|
||||
this._achievementIconBorders = new UIImage(TextureManager.Load("Images/UI/Achievement_Borders"));
|
||||
this._achievementIconBorders.Left.Set(pixels1 - 4f, 0.0f);
|
||||
this._achievementIconBorders.Top.Set(pixels2 - 4f, 0.0f);
|
||||
this.Append((UIElement) this._achievementIconBorders);
|
||||
this._innerPanelTopTexture = TextureManager.Load("Images/UI/Achievement_InnerPanelTop");
|
||||
this._innerPanelBottomTexture = !this._large ? TextureManager.Load("Images/UI/Achievement_InnerPanelBottom") : TextureManager.Load("Images/UI/Achievement_InnerPanelBottom_Large");
|
||||
this._categoryTexture = TextureManager.Load("Images/UI/Achievement_Categories");
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
base.DrawSelf(spriteBatch);
|
||||
int num1 = this._large.ToInt() * 6;
|
||||
Vector2 vector2_1 = new Vector2((float) num1, 0.0f);
|
||||
this._locked = !this._achievement.IsCompleted;
|
||||
this.UpdateIconFrame();
|
||||
CalculatedStyle innerDimensions = this.GetInnerDimensions();
|
||||
CalculatedStyle dimensions = this._achievementIconBorders.GetDimensions();
|
||||
Vector2 vector2_2 = new Vector2(dimensions.X + dimensions.Width + 7f, innerDimensions.Y);
|
||||
Tuple<Decimal, Decimal> trackerValues = this.GetTrackerValues();
|
||||
bool flag = false;
|
||||
if ((!(trackerValues.Item1 == 0M) || !(trackerValues.Item2 == 0M)) && this._locked)
|
||||
flag = true;
|
||||
float num2 = (float) ((double) innerDimensions.Width - (double) dimensions.Width + 1.0) - (float) (num1 * 2);
|
||||
Vector2 baseScale1 = new Vector2(0.85f);
|
||||
Vector2 baseScale2 = new Vector2(0.92f);
|
||||
string wrappedText = Main.fontItemStack.CreateWrappedText(this._achievement.Description.Value, (float) (((double) num2 - 20.0) * (1.0 / (double) baseScale2.X)), Language.ActiveCulture.CultureInfo);
|
||||
Vector2 stringSize1 = ChatManager.GetStringSize(Main.fontItemStack, wrappedText, baseScale2, num2);
|
||||
if (!this._large)
|
||||
stringSize1 = ChatManager.GetStringSize(Main.fontItemStack, this._achievement.Description.Value, baseScale2, num2);
|
||||
float num3 = (float) (38.0 + (this._large ? 20.0 : 0.0));
|
||||
if ((double) stringSize1.Y > (double) num3)
|
||||
baseScale2.Y *= num3 / stringSize1.Y;
|
||||
Color baseColor1 = Color.Lerp(this._locked ? Color.Silver : Color.Gold, Color.White, this.IsMouseHovering ? 0.5f : 0.0f);
|
||||
Color baseColor2 = Color.Lerp(this._locked ? Color.DarkGray : Color.Silver, Color.White, this.IsMouseHovering ? 1f : 0.0f);
|
||||
Color color1 = this.IsMouseHovering ? Color.White : Color.Gray;
|
||||
Vector2 position1 = vector2_2 - Vector2.UnitY * 2f + vector2_1;
|
||||
this.DrawPanelTop(spriteBatch, position1, num2, color1);
|
||||
AchievementCategory category = this._achievement.Category;
|
||||
position1.Y += 2f;
|
||||
position1.X += 4f;
|
||||
spriteBatch.Draw(this._categoryTexture, position1, new Rectangle?(this._categoryTexture.Frame(4, 2, (int) category)), this.IsMouseHovering ? Color.White : Color.Silver, 0.0f, Vector2.Zero, 0.5f, SpriteEffects.None, 0.0f);
|
||||
position1.X += 4f;
|
||||
position1.X += 17f;
|
||||
ChatManager.DrawColorCodedStringWithShadow(spriteBatch, Main.fontItemStack, this._achievement.FriendlyName.Value, position1, baseColor1, 0.0f, Vector2.Zero, baseScale1, num2);
|
||||
position1.X -= 17f;
|
||||
Vector2 position2 = vector2_2 + Vector2.UnitY * 27f + vector2_1;
|
||||
this.DrawPanelBottom(spriteBatch, position2, num2, color1);
|
||||
position2.X += 8f;
|
||||
position2.Y += 4f;
|
||||
ChatManager.DrawColorCodedStringWithShadow(spriteBatch, Main.fontItemStack, wrappedText, position2, baseColor2, 0.0f, Vector2.Zero, baseScale2);
|
||||
if (!flag)
|
||||
return;
|
||||
Vector2 position3 = position1 + Vector2.UnitX * num2 + Vector2.UnitY;
|
||||
string text = ((int) trackerValues.Item1).ToString() + "/" + ((int) trackerValues.Item2).ToString();
|
||||
Vector2 baseScale3 = new Vector2(0.75f);
|
||||
Vector2 stringSize2 = ChatManager.GetStringSize(Main.fontItemStack, text, baseScale3);
|
||||
float progress = (float) (trackerValues.Item1 / trackerValues.Item2);
|
||||
float Width = 80f;
|
||||
Color color2 = new Color(100, (int) byte.MaxValue, 100);
|
||||
if (!this.IsMouseHovering)
|
||||
color2 = Color.Lerp(color2, Color.Black, 0.25f);
|
||||
Color BackColor = new Color((int) byte.MaxValue, (int) byte.MaxValue, (int) byte.MaxValue);
|
||||
if (!this.IsMouseHovering)
|
||||
BackColor = Color.Lerp(BackColor, Color.Black, 0.25f);
|
||||
this.DrawProgressBar(spriteBatch, progress, position3 - Vector2.UnitX * Width * 0.7f, Width, BackColor, color2, color2.MultiplyRGBA(new Color(new Vector4(1f, 1f, 1f, 0.5f))));
|
||||
position3.X -= Width * 1.4f + stringSize2.X;
|
||||
ChatManager.DrawColorCodedStringWithShadow(spriteBatch, Main.fontItemStack, text, position3, baseColor1, 0.0f, new Vector2(0.0f, 0.0f), baseScale3, 90f);
|
||||
}
|
||||
|
||||
private void UpdateIconFrame()
|
||||
{
|
||||
this._iconFrame = this._locked ? this._iconFrameLocked : this._iconFrameUnlocked;
|
||||
if (this._achievementIcon == null)
|
||||
return;
|
||||
this._achievementIcon.SetFrame(this._iconFrame);
|
||||
}
|
||||
|
||||
private void DrawPanelTop(SpriteBatch spriteBatch, Vector2 position, float width, Color color)
|
||||
{
|
||||
spriteBatch.Draw(this._innerPanelTopTexture, position, new Rectangle?(new Rectangle(0, 0, 2, this._innerPanelTopTexture.Height)), color);
|
||||
spriteBatch.Draw(this._innerPanelTopTexture, new Vector2(position.X + 2f, position.Y), new Rectangle?(new Rectangle(2, 0, 2, this._innerPanelTopTexture.Height)), color, 0.0f, Vector2.Zero, new Vector2((float) (((double) width - 4.0) / 2.0), 1f), SpriteEffects.None, 0.0f);
|
||||
spriteBatch.Draw(this._innerPanelTopTexture, new Vector2((float) ((double) position.X + (double) width - 2.0), position.Y), new Rectangle?(new Rectangle(4, 0, 2, this._innerPanelTopTexture.Height)), color);
|
||||
}
|
||||
|
||||
private void DrawPanelBottom(
|
||||
SpriteBatch spriteBatch,
|
||||
Vector2 position,
|
||||
float width,
|
||||
Color color)
|
||||
{
|
||||
spriteBatch.Draw(this._innerPanelBottomTexture, position, new Rectangle?(new Rectangle(0, 0, 6, this._innerPanelBottomTexture.Height)), color);
|
||||
spriteBatch.Draw(this._innerPanelBottomTexture, new Vector2(position.X + 6f, position.Y), new Rectangle?(new Rectangle(6, 0, 7, this._innerPanelBottomTexture.Height)), color, 0.0f, Vector2.Zero, new Vector2((float) (((double) width - 12.0) / 7.0), 1f), SpriteEffects.None, 0.0f);
|
||||
spriteBatch.Draw(this._innerPanelBottomTexture, new Vector2((float) ((double) position.X + (double) width - 6.0), position.Y), new Rectangle?(new Rectangle(13, 0, 6, this._innerPanelBottomTexture.Height)), color);
|
||||
}
|
||||
|
||||
public override void MouseOver(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseOver(evt);
|
||||
this.BackgroundColor = new Color(46, 60, 119);
|
||||
this.BorderColor = new Color(20, 30, 56);
|
||||
}
|
||||
|
||||
public override void MouseOut(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseOut(evt);
|
||||
this.BackgroundColor = new Color(26, 40, 89) * 0.8f;
|
||||
this.BorderColor = new Color(13, 20, 44) * 0.8f;
|
||||
}
|
||||
|
||||
public Achievement GetAchievement() => this._achievement;
|
||||
|
||||
private Tuple<Decimal, Decimal> GetTrackerValues()
|
||||
{
|
||||
if (!this._achievement.HasTracker)
|
||||
return Tuple.Create<Decimal, Decimal>(0M, 0M);
|
||||
IAchievementTracker tracker = this._achievement.GetTracker();
|
||||
if (tracker.GetTrackerType() == TrackerType.Int)
|
||||
{
|
||||
AchievementTracker<int> achievementTracker = (AchievementTracker<int>) tracker;
|
||||
return Tuple.Create<Decimal, Decimal>((Decimal) achievementTracker.Value, (Decimal) achievementTracker.MaxValue);
|
||||
}
|
||||
if (tracker.GetTrackerType() != TrackerType.Float)
|
||||
return Tuple.Create<Decimal, Decimal>(0M, 0M);
|
||||
AchievementTracker<float> achievementTracker1 = (AchievementTracker<float>) tracker;
|
||||
return Tuple.Create<Decimal, Decimal>((Decimal) achievementTracker1.Value, (Decimal) achievementTracker1.MaxValue);
|
||||
}
|
||||
|
||||
private void DrawProgressBar(
|
||||
SpriteBatch spriteBatch,
|
||||
float progress,
|
||||
Vector2 spot,
|
||||
float Width = 169f,
|
||||
Color BackColor = default (Color),
|
||||
Color FillingColor = default (Color),
|
||||
Color BlipColor = default (Color))
|
||||
{
|
||||
if (BlipColor == Color.Transparent)
|
||||
BlipColor = new Color((int) byte.MaxValue, 165, 0, (int) sbyte.MaxValue);
|
||||
if (FillingColor == Color.Transparent)
|
||||
FillingColor = new Color((int) byte.MaxValue, 241, 51);
|
||||
if (BackColor == Color.Transparent)
|
||||
FillingColor = new Color((int) byte.MaxValue, (int) byte.MaxValue, (int) byte.MaxValue);
|
||||
Texture2D colorBarTexture = Main.colorBarTexture;
|
||||
Texture2D colorBlipTexture = Main.colorBlipTexture;
|
||||
Texture2D magicPixel = Main.magicPixel;
|
||||
float num1 = MathHelper.Clamp(progress, 0.0f, 1f);
|
||||
float num2 = Width * 1f;
|
||||
float y = 8f;
|
||||
float x = num2 / 169f;
|
||||
Vector2 vector2 = spot + Vector2.UnitY * y + Vector2.UnitX * 1f;
|
||||
spriteBatch.Draw(colorBarTexture, spot, new Rectangle?(new Rectangle(5, 0, colorBarTexture.Width - 9, colorBarTexture.Height)), BackColor, 0.0f, new Vector2(84.5f, 0.0f), new Vector2(x, 1f), SpriteEffects.None, 0.0f);
|
||||
spriteBatch.Draw(colorBarTexture, spot + new Vector2((float) (-(double) x * 84.5 - 5.0), 0.0f), new Rectangle?(new Rectangle(0, 0, 5, colorBarTexture.Height)), BackColor, 0.0f, Vector2.Zero, Vector2.One, SpriteEffects.None, 0.0f);
|
||||
spriteBatch.Draw(colorBarTexture, spot + new Vector2(x * 84.5f, 0.0f), new Rectangle?(new Rectangle(colorBarTexture.Width - 4, 0, 4, colorBarTexture.Height)), BackColor, 0.0f, Vector2.Zero, Vector2.One, SpriteEffects.None, 0.0f);
|
||||
Vector2 position = vector2 + Vector2.UnitX * (num1 - 0.5f) * num2;
|
||||
--position.X;
|
||||
spriteBatch.Draw(magicPixel, position, new Rectangle?(new Rectangle(0, 0, 1, 1)), FillingColor, 0.0f, new Vector2(1f, 0.5f), new Vector2(num2 * num1, y), SpriteEffects.None, 0.0f);
|
||||
if ((double) progress != 0.0)
|
||||
spriteBatch.Draw(magicPixel, position, new Rectangle?(new Rectangle(0, 0, 1, 1)), BlipColor, 0.0f, new Vector2(1f, 0.5f), new Vector2(2f, y), SpriteEffects.None, 0.0f);
|
||||
spriteBatch.Draw(magicPixel, position, new Rectangle?(new Rectangle(0, 0, 1, 1)), Color.Black, 0.0f, new Vector2(0.0f, 0.5f), new Vector2(num2 * (1f - num1), y), SpriteEffects.None, 0.0f);
|
||||
}
|
||||
|
||||
public override int CompareTo(object obj)
|
||||
{
|
||||
if (!(obj is UIAchievementListItem achievementListItem))
|
||||
return 0;
|
||||
if (this._achievement.IsCompleted && !achievementListItem._achievement.IsCompleted)
|
||||
return -1;
|
||||
return !this._achievement.IsCompleted && achievementListItem._achievement.IsCompleted ? 1 : this._achievement.Id.CompareTo(achievementListItem._achievement.Id);
|
||||
}
|
||||
}
|
||||
}
|
40
GameContent/UI/Elements/UICharacter.cs
Normal file
40
GameContent/UI/Elements/UICharacter.cs
Normal file
|
@ -0,0 +1,40 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UICharacter
|
||||
// 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.Graphics;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UICharacter : UIElement
|
||||
{
|
||||
private Player _player;
|
||||
private Texture2D _texture;
|
||||
private static Item _blankItem = new Item();
|
||||
|
||||
public UICharacter(Player player)
|
||||
{
|
||||
this._player = player;
|
||||
this.Width.Set(59f, 0.0f);
|
||||
this.Height.Set(58f, 0.0f);
|
||||
this._texture = TextureManager.Load("Images/UI/PlayerBackground");
|
||||
this._useImmediateMode = true;
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
spriteBatch.Draw(this._texture, dimensions.Position(), Color.White);
|
||||
Vector2 vector2 = dimensions.Position() + new Vector2(dimensions.Width * 0.5f - (float) (this._player.width >> 1), dimensions.Height * 0.5f - (float) (this._player.height >> 1));
|
||||
Item obj = this._player.inventory[this._player.selectedItem];
|
||||
this._player.inventory[this._player.selectedItem] = UICharacter._blankItem;
|
||||
Main.instance.DrawPlayer(this._player, vector2 + Main.screenPosition, 0.0f, Vector2.Zero);
|
||||
this._player.inventory[this._player.selectedItem] = obj;
|
||||
}
|
||||
}
|
||||
}
|
271
GameContent/UI/Elements/UICharacterListItem.cs
Normal file
271
GameContent/UI/Elements/UICharacterListItem.cs
Normal file
|
@ -0,0 +1,271 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UICharacterListItem
|
||||
// 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.Graphics;
|
||||
using Terraria.IO;
|
||||
using Terraria.Localization;
|
||||
using Terraria.Social;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UICharacterListItem : UIPanel
|
||||
{
|
||||
private PlayerFileData _data;
|
||||
private Texture2D _dividerTexture;
|
||||
private Texture2D _innerPanelTexture;
|
||||
private UICharacter _playerPanel;
|
||||
private UIText _buttonLabel;
|
||||
private UIText _deleteButtonLabel;
|
||||
private Texture2D _buttonCloudActiveTexture;
|
||||
private Texture2D _buttonCloudInactiveTexture;
|
||||
private Texture2D _buttonFavoriteActiveTexture;
|
||||
private Texture2D _buttonFavoriteInactiveTexture;
|
||||
private Texture2D _buttonPlayTexture;
|
||||
private Texture2D _buttonDeleteTexture;
|
||||
private UIImageButton _deleteButton;
|
||||
|
||||
public bool IsFavorite => this._data.IsFavorite;
|
||||
|
||||
public UICharacterListItem(PlayerFileData data, int snapPointIndex)
|
||||
{
|
||||
this.BorderColor = new Color(89, 116, 213) * 0.7f;
|
||||
this._dividerTexture = TextureManager.Load("Images/UI/Divider");
|
||||
this._innerPanelTexture = TextureManager.Load("Images/UI/InnerPanelBackground");
|
||||
this._buttonCloudActiveTexture = TextureManager.Load("Images/UI/ButtonCloudActive");
|
||||
this._buttonCloudInactiveTexture = TextureManager.Load("Images/UI/ButtonCloudInactive");
|
||||
this._buttonFavoriteActiveTexture = TextureManager.Load("Images/UI/ButtonFavoriteActive");
|
||||
this._buttonFavoriteInactiveTexture = TextureManager.Load("Images/UI/ButtonFavoriteInactive");
|
||||
this._buttonPlayTexture = TextureManager.Load("Images/UI/ButtonPlay");
|
||||
this._buttonDeleteTexture = TextureManager.Load("Images/UI/ButtonDelete");
|
||||
this.Height.Set(96f, 0.0f);
|
||||
this.Width.Set(0.0f, 1f);
|
||||
this.SetPadding(6f);
|
||||
this._data = data;
|
||||
this._playerPanel = new UICharacter(data.Player);
|
||||
this._playerPanel.Left.Set(4f, 0.0f);
|
||||
this._playerPanel.OnDoubleClick += new UIElement.MouseEvent(this.PlayGame);
|
||||
this.OnDoubleClick += new UIElement.MouseEvent(this.PlayGame);
|
||||
this.Append((UIElement) this._playerPanel);
|
||||
UIImageButton uiImageButton1 = new UIImageButton(this._buttonPlayTexture);
|
||||
uiImageButton1.VAlign = 1f;
|
||||
uiImageButton1.Left.Set(4f, 0.0f);
|
||||
uiImageButton1.OnClick += new UIElement.MouseEvent(this.PlayGame);
|
||||
uiImageButton1.OnMouseOver += new UIElement.MouseEvent(this.PlayMouseOver);
|
||||
uiImageButton1.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut);
|
||||
this.Append((UIElement) uiImageButton1);
|
||||
UIImageButton uiImageButton2 = new UIImageButton(this._data.IsFavorite ? this._buttonFavoriteActiveTexture : this._buttonFavoriteInactiveTexture);
|
||||
uiImageButton2.VAlign = 1f;
|
||||
uiImageButton2.Left.Set(28f, 0.0f);
|
||||
uiImageButton2.OnClick += new UIElement.MouseEvent(this.FavoriteButtonClick);
|
||||
uiImageButton2.OnMouseOver += new UIElement.MouseEvent(this.FavoriteMouseOver);
|
||||
uiImageButton2.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut);
|
||||
uiImageButton2.SetVisibility(1f, this._data.IsFavorite ? 0.8f : 0.4f);
|
||||
this.Append((UIElement) uiImageButton2);
|
||||
if (SocialAPI.Cloud != null)
|
||||
{
|
||||
UIImageButton uiImageButton3 = new UIImageButton(this._data.IsCloudSave ? this._buttonCloudActiveTexture : this._buttonCloudInactiveTexture);
|
||||
uiImageButton3.VAlign = 1f;
|
||||
uiImageButton3.Left.Set(52f, 0.0f);
|
||||
uiImageButton3.OnClick += new UIElement.MouseEvent(this.CloudButtonClick);
|
||||
uiImageButton3.OnMouseOver += new UIElement.MouseEvent(this.CloudMouseOver);
|
||||
uiImageButton3.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut);
|
||||
this.Append((UIElement) uiImageButton3);
|
||||
uiImageButton3.SetSnapPoint("Cloud", snapPointIndex);
|
||||
}
|
||||
UIImageButton uiImageButton4 = new UIImageButton(this._buttonDeleteTexture);
|
||||
uiImageButton4.VAlign = 1f;
|
||||
uiImageButton4.HAlign = 1f;
|
||||
uiImageButton4.OnClick += new UIElement.MouseEvent(this.DeleteButtonClick);
|
||||
uiImageButton4.OnMouseOver += new UIElement.MouseEvent(this.DeleteMouseOver);
|
||||
uiImageButton4.OnMouseOut += new UIElement.MouseEvent(this.DeleteMouseOut);
|
||||
this._deleteButton = uiImageButton4;
|
||||
if (!this._data.IsFavorite)
|
||||
this.Append((UIElement) uiImageButton4);
|
||||
this._buttonLabel = new UIText("");
|
||||
this._buttonLabel.VAlign = 1f;
|
||||
this._buttonLabel.Left.Set(80f, 0.0f);
|
||||
this._buttonLabel.Top.Set(-3f, 0.0f);
|
||||
this.Append((UIElement) this._buttonLabel);
|
||||
this._deleteButtonLabel = new UIText("");
|
||||
this._deleteButtonLabel.VAlign = 1f;
|
||||
this._deleteButtonLabel.HAlign = 1f;
|
||||
this._deleteButtonLabel.Left.Set(-30f, 0.0f);
|
||||
this._deleteButtonLabel.Top.Set(-3f, 0.0f);
|
||||
this.Append((UIElement) this._deleteButtonLabel);
|
||||
uiImageButton1.SetSnapPoint("Play", snapPointIndex);
|
||||
uiImageButton2.SetSnapPoint("Favorite", snapPointIndex);
|
||||
uiImageButton4.SetSnapPoint("Delete", snapPointIndex);
|
||||
}
|
||||
|
||||
private void FavoriteMouseOver(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
if (this._data.IsFavorite)
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.Unfavorite"));
|
||||
else
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.Favorite"));
|
||||
}
|
||||
|
||||
private void CloudMouseOver(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
if (this._data.IsCloudSave)
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.MoveOffCloud"));
|
||||
else
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.MoveToCloud"));
|
||||
}
|
||||
|
||||
private void PlayMouseOver(UIMouseEvent evt, UIElement listeningElement) => this._buttonLabel.SetText(Language.GetTextValue("UI.Play"));
|
||||
|
||||
private void DeleteMouseOver(UIMouseEvent evt, UIElement listeningElement) => this._deleteButtonLabel.SetText(Language.GetTextValue("UI.Delete"));
|
||||
|
||||
private void DeleteMouseOut(UIMouseEvent evt, UIElement listeningElement) => this._deleteButtonLabel.SetText("");
|
||||
|
||||
private void ButtonMouseOut(UIMouseEvent evt, UIElement listeningElement) => this._buttonLabel.SetText("");
|
||||
|
||||
private void CloudButtonClick(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
if (this._data.IsCloudSave)
|
||||
this._data.MoveToLocal();
|
||||
else
|
||||
this._data.MoveToCloud();
|
||||
((UIImageButton) evt.Target).SetImage(this._data.IsCloudSave ? this._buttonCloudActiveTexture : this._buttonCloudInactiveTexture);
|
||||
if (this._data.IsCloudSave)
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.MoveOffCloud"));
|
||||
else
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.MoveToCloud"));
|
||||
}
|
||||
|
||||
private void DeleteButtonClick(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
for (int index = 0; index < Main.PlayerList.Count; ++index)
|
||||
{
|
||||
if (Main.PlayerList[index] == this._data)
|
||||
{
|
||||
Main.PlaySound(10);
|
||||
Main.selectedPlayer = index;
|
||||
Main.menuMode = 5;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void PlayGame(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
if (listeningElement != evt.Target || this._data.Player.loadStatus != 0)
|
||||
return;
|
||||
Main.SelectPlayer(this._data);
|
||||
}
|
||||
|
||||
private void FavoriteButtonClick(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
this._data.ToggleFavorite();
|
||||
((UIImageButton) evt.Target).SetImage(this._data.IsFavorite ? this._buttonFavoriteActiveTexture : this._buttonFavoriteInactiveTexture);
|
||||
((UIImageButton) evt.Target).SetVisibility(1f, this._data.IsFavorite ? 0.8f : 0.4f);
|
||||
if (this._data.IsFavorite)
|
||||
{
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.Unfavorite"));
|
||||
this.RemoveChild((UIElement) this._deleteButton);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.Favorite"));
|
||||
this.Append((UIElement) this._deleteButton);
|
||||
}
|
||||
if (!(this.Parent.Parent is UIList parent))
|
||||
return;
|
||||
parent.UpdateOrder();
|
||||
}
|
||||
|
||||
public override int CompareTo(object obj)
|
||||
{
|
||||
if (!(obj is UICharacterListItem characterListItem))
|
||||
return base.CompareTo(obj);
|
||||
if (this.IsFavorite && !characterListItem.IsFavorite)
|
||||
return -1;
|
||||
if (!this.IsFavorite && characterListItem.IsFavorite)
|
||||
return 1;
|
||||
return this._data.Name.CompareTo(characterListItem._data.Name) != 0 ? this._data.Name.CompareTo(characterListItem._data.Name) : this._data.GetFileName().CompareTo(characterListItem._data.GetFileName());
|
||||
}
|
||||
|
||||
public override void MouseOver(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseOver(evt);
|
||||
this.BackgroundColor = new Color(73, 94, 171);
|
||||
this.BorderColor = new Color(89, 116, 213);
|
||||
}
|
||||
|
||||
public override void MouseOut(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseOut(evt);
|
||||
this.BackgroundColor = new Color(63, 82, 151) * 0.7f;
|
||||
this.BorderColor = new Color(89, 116, 213) * 0.7f;
|
||||
}
|
||||
|
||||
private void DrawPanel(SpriteBatch spriteBatch, Vector2 position, float width)
|
||||
{
|
||||
spriteBatch.Draw(this._innerPanelTexture, position, new Rectangle?(new Rectangle(0, 0, 8, this._innerPanelTexture.Height)), Color.White);
|
||||
spriteBatch.Draw(this._innerPanelTexture, new Vector2(position.X + 8f, position.Y), new Rectangle?(new Rectangle(8, 0, 8, this._innerPanelTexture.Height)), Color.White, 0.0f, Vector2.Zero, new Vector2((float) (((double) width - 16.0) / 8.0), 1f), SpriteEffects.None, 0.0f);
|
||||
spriteBatch.Draw(this._innerPanelTexture, new Vector2((float) ((double) position.X + (double) width - 8.0), position.Y), new Rectangle?(new Rectangle(16, 0, 8, this._innerPanelTexture.Height)), Color.White);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
base.DrawSelf(spriteBatch);
|
||||
CalculatedStyle innerDimensions = this.GetInnerDimensions();
|
||||
CalculatedStyle dimensions = this._playerPanel.GetDimensions();
|
||||
float x = dimensions.X + dimensions.Width;
|
||||
Utils.DrawBorderString(spriteBatch, this._data.Name, new Vector2(x + 6f, dimensions.Y - 2f), Color.White);
|
||||
spriteBatch.Draw(this._dividerTexture, new Vector2(x, innerDimensions.Y + 21f), new Rectangle?(), Color.White, 0.0f, Vector2.Zero, new Vector2((float) (((double) this.GetDimensions().X + (double) this.GetDimensions().Width - (double) x) / 8.0), 1f), SpriteEffects.None, 0.0f);
|
||||
Vector2 vector2 = new Vector2(x + 6f, innerDimensions.Y + 29f);
|
||||
float width1 = 200f;
|
||||
Vector2 position1 = vector2;
|
||||
this.DrawPanel(spriteBatch, position1, width1);
|
||||
spriteBatch.Draw(Main.heartTexture, position1 + new Vector2(5f, 2f), Color.White);
|
||||
position1.X += 10f + (float) Main.heartTexture.Width;
|
||||
Utils.DrawBorderString(spriteBatch, this._data.Player.statLifeMax.ToString() + " HP", position1 + new Vector2(0.0f, 3f), Color.White);
|
||||
position1.X += 65f;
|
||||
spriteBatch.Draw(Main.manaTexture, position1 + new Vector2(5f, 2f), Color.White);
|
||||
position1.X += 10f + (float) Main.manaTexture.Width;
|
||||
Utils.DrawBorderString(spriteBatch, this._data.Player.statManaMax.ToString() + " MP", position1 + new Vector2(0.0f, 3f), Color.White);
|
||||
vector2.X += width1 + 5f;
|
||||
Vector2 position2 = vector2;
|
||||
float width2 = 140f;
|
||||
if (GameCulture.Russian.IsActive)
|
||||
width2 = 180f;
|
||||
this.DrawPanel(spriteBatch, position2, width2);
|
||||
string text1 = "";
|
||||
Color color = Color.White;
|
||||
switch (this._data.Player.difficulty)
|
||||
{
|
||||
case 0:
|
||||
text1 = Language.GetTextValue("UI.Softcore");
|
||||
break;
|
||||
case 1:
|
||||
text1 = Language.GetTextValue("UI.Mediumcore");
|
||||
color = Main.mcColor;
|
||||
break;
|
||||
case 2:
|
||||
text1 = Language.GetTextValue("UI.Hardcore");
|
||||
color = Main.hcColor;
|
||||
break;
|
||||
}
|
||||
Vector2 pos1 = position2 + new Vector2((float) ((double) width2 * 0.5 - (double) Main.fontMouseText.MeasureString(text1).X * 0.5), 3f);
|
||||
Utils.DrawBorderString(spriteBatch, text1, pos1, color);
|
||||
vector2.X += width2 + 5f;
|
||||
Vector2 position3 = vector2;
|
||||
float width3 = innerDimensions.X + innerDimensions.Width - position3.X;
|
||||
this.DrawPanel(spriteBatch, position3, width3);
|
||||
TimeSpan playTime = this._data.GetPlayTime();
|
||||
int num = playTime.Days * 24 + playTime.Hours;
|
||||
string text2 = (num < 10 ? (object) "0" : (object) "").ToString() + (object) num + playTime.ToString("\\:mm\\:ss");
|
||||
Vector2 pos2 = position3 + new Vector2((float) ((double) width3 * 0.5 - (double) Main.fontMouseText.MeasureString(text2).X * 0.5), 3f);
|
||||
Utils.DrawBorderString(spriteBatch, text2, pos2, Color.White);
|
||||
}
|
||||
}
|
||||
}
|
119
GameContent/UI/Elements/UIGenProgressBar.cs
Normal file
119
GameContent/UI/Elements/UIGenProgressBar.cs
Normal file
|
@ -0,0 +1,119 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIGenProgressBar
|
||||
// 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.Graphics;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIGenProgressBar : UIElement
|
||||
{
|
||||
private Texture2D _texInnerDirt;
|
||||
private Texture2D _texOuterCrimson;
|
||||
private Texture2D _texOuterCorrupt;
|
||||
private Texture2D _texOuterLower;
|
||||
private float _visualOverallProgress;
|
||||
private float _targetOverallProgress;
|
||||
private float _visualCurrentProgress;
|
||||
private float _targetCurrentProgress;
|
||||
|
||||
public UIGenProgressBar()
|
||||
{
|
||||
if (Main.netMode != 2)
|
||||
{
|
||||
this._texInnerDirt = TextureManager.Load("Images/UI/WorldGen/Outer Dirt");
|
||||
this._texOuterCorrupt = TextureManager.Load("Images/UI/WorldGen/Outer Corrupt");
|
||||
this._texOuterCrimson = TextureManager.Load("Images/UI/WorldGen/Outer Crimson");
|
||||
this._texOuterLower = TextureManager.Load("Images/UI/WorldGen/Outer Lower");
|
||||
}
|
||||
this.Recalculate();
|
||||
}
|
||||
|
||||
public override void Recalculate()
|
||||
{
|
||||
this.Width.Precent = 0.0f;
|
||||
this.Height.Precent = 0.0f;
|
||||
this.Width.Pixels = 612f;
|
||||
this.Height.Pixels = 70f;
|
||||
base.Recalculate();
|
||||
}
|
||||
|
||||
public void SetProgress(float overallProgress, float currentProgress)
|
||||
{
|
||||
this._targetCurrentProgress = currentProgress;
|
||||
this._targetOverallProgress = overallProgress;
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
this._visualOverallProgress = this._targetOverallProgress;
|
||||
this._visualCurrentProgress = this._targetCurrentProgress;
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
int completedWidth1 = (int) ((double) this._visualOverallProgress * 504.0);
|
||||
int completedWidth2 = (int) ((double) this._visualCurrentProgress * 504.0);
|
||||
Vector2 vector2 = new Vector2(dimensions.X, dimensions.Y);
|
||||
Color filled = new Color();
|
||||
filled.PackedValue = WorldGen.crimson ? 4286836223U : 4283888223U;
|
||||
this.DrawFilling2(spriteBatch, vector2 + new Vector2(20f, 40f), 16, completedWidth1, 564, filled, Color.Lerp(filled, Color.Black, 0.5f), new Color(48, 48, 48));
|
||||
filled.PackedValue = 4290947159U;
|
||||
this.DrawFilling2(spriteBatch, vector2 + new Vector2(50f, 60f), 8, completedWidth2, 504, filled, Color.Lerp(filled, Color.Black, 0.5f), new Color(33, 33, 33));
|
||||
Rectangle rectangle = this.GetDimensions().ToRectangle();
|
||||
rectangle.X -= 8;
|
||||
spriteBatch.Draw(WorldGen.crimson ? this._texOuterCrimson : this._texOuterCorrupt, rectangle.TopLeft(), Color.White);
|
||||
spriteBatch.Draw(this._texOuterLower, rectangle.TopLeft() + new Vector2(44f, 60f), Color.White);
|
||||
}
|
||||
|
||||
private void DrawFilling(
|
||||
SpriteBatch spritebatch,
|
||||
Texture2D tex,
|
||||
Texture2D texShadow,
|
||||
Vector2 topLeft,
|
||||
int completedWidth,
|
||||
int totalWidth,
|
||||
Color separator,
|
||||
Color empty)
|
||||
{
|
||||
if (completedWidth % 2 != 0)
|
||||
--completedWidth;
|
||||
Vector2 position = topLeft + (float) completedWidth * Vector2.UnitX;
|
||||
int num = completedWidth;
|
||||
Rectangle rectangle = tex.Frame();
|
||||
for (; num > 0; num -= rectangle.Width)
|
||||
{
|
||||
if (rectangle.Width > num)
|
||||
{
|
||||
rectangle.X += rectangle.Width - num;
|
||||
rectangle.Width = num;
|
||||
}
|
||||
spritebatch.Draw(tex, position, new Rectangle?(rectangle), Color.White, 0.0f, new Vector2((float) rectangle.Width, 0.0f), 1f, SpriteEffects.None, 0.0f);
|
||||
position.X -= (float) rectangle.Width;
|
||||
}
|
||||
if (texShadow != null)
|
||||
spritebatch.Draw(texShadow, topLeft, new Rectangle?(new Rectangle(0, 0, completedWidth, texShadow.Height)), Color.White);
|
||||
spritebatch.Draw(Main.magicPixel, new Rectangle((int) topLeft.X + completedWidth, (int) topLeft.Y, totalWidth - completedWidth, tex.Height), new Rectangle?(new Rectangle(0, 0, 1, 1)), empty);
|
||||
spritebatch.Draw(Main.magicPixel, new Rectangle((int) topLeft.X + completedWidth - 2, (int) topLeft.Y, 2, tex.Height), new Rectangle?(new Rectangle(0, 0, 1, 1)), separator);
|
||||
}
|
||||
|
||||
private void DrawFilling2(
|
||||
SpriteBatch spritebatch,
|
||||
Vector2 topLeft,
|
||||
int height,
|
||||
int completedWidth,
|
||||
int totalWidth,
|
||||
Color filled,
|
||||
Color separator,
|
||||
Color empty)
|
||||
{
|
||||
if (completedWidth % 2 != 0)
|
||||
--completedWidth;
|
||||
spritebatch.Draw(Main.magicPixel, new Rectangle((int) topLeft.X, (int) topLeft.Y, completedWidth, height), new Rectangle?(new Rectangle(0, 0, 1, 1)), filled);
|
||||
spritebatch.Draw(Main.magicPixel, new Rectangle((int) topLeft.X + completedWidth, (int) topLeft.Y, totalWidth - completedWidth, height), new Rectangle?(new Rectangle(0, 0, 1, 1)), empty);
|
||||
spritebatch.Draw(Main.magicPixel, new Rectangle((int) topLeft.X + completedWidth - 2, (int) topLeft.Y, 2, height), new Rectangle?(new Rectangle(0, 0, 1, 1)), separator);
|
||||
}
|
||||
}
|
||||
}
|
45
GameContent/UI/Elements/UIHeader.cs
Normal file
45
GameContent/UI/Elements/UIHeader.cs
Normal file
|
@ -0,0 +1,45 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIHeader
|
||||
// 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 Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIHeader : UIElement
|
||||
{
|
||||
private string _text;
|
||||
|
||||
public string Text
|
||||
{
|
||||
get => this._text;
|
||||
set
|
||||
{
|
||||
if (!(this._text != value))
|
||||
return;
|
||||
this._text = value;
|
||||
Vector2 vector2 = Main.fontDeathText.MeasureString(this.Text);
|
||||
this.Width.Pixels = vector2.X;
|
||||
this.Height.Pixels = vector2.Y;
|
||||
this.Width.Precent = 0.0f;
|
||||
this.Height.Precent = 0.0f;
|
||||
this.Recalculate();
|
||||
}
|
||||
}
|
||||
|
||||
public UIHeader() => this.Text = "";
|
||||
|
||||
public UIHeader(string text) => this.Text = text;
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
DynamicSpriteFontExtensionMethods.DrawString(spriteBatch, Main.fontDeathText, this.Text, new Vector2(dimensions.X, dimensions.Y), Color.White);
|
||||
}
|
||||
}
|
||||
}
|
38
GameContent/UI/Elements/UIImage.cs
Normal file
38
GameContent/UI/Elements/UIImage.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIImage
|
||||
// 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.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIImage : UIElement
|
||||
{
|
||||
private Texture2D _texture;
|
||||
public float ImageScale = 1f;
|
||||
|
||||
public UIImage(Texture2D texture)
|
||||
{
|
||||
this._texture = texture;
|
||||
this.Width.Set((float) this._texture.Width, 0.0f);
|
||||
this.Height.Set((float) this._texture.Height, 0.0f);
|
||||
}
|
||||
|
||||
public void SetImage(Texture2D texture)
|
||||
{
|
||||
this._texture = texture;
|
||||
this.Width.Set((float) this._texture.Width, 0.0f);
|
||||
this.Height.Set((float) this._texture.Height, 0.0f);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
spriteBatch.Draw(this._texture, dimensions.Position() + this._texture.Size() * (1f - this.ImageScale) / 2f, new Rectangle?(), Color.White, 0.0f, Vector2.Zero, this.ImageScale, SpriteEffects.None, 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
51
GameContent/UI/Elements/UIImageButton.cs
Normal file
51
GameContent/UI/Elements/UIImageButton.cs
Normal file
|
@ -0,0 +1,51 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIImageButton
|
||||
// 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.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIImageButton : UIElement
|
||||
{
|
||||
private Texture2D _texture;
|
||||
private float _visibilityActive = 1f;
|
||||
private float _visibilityInactive = 0.4f;
|
||||
|
||||
public UIImageButton(Texture2D texture)
|
||||
{
|
||||
this._texture = texture;
|
||||
this.Width.Set((float) this._texture.Width, 0.0f);
|
||||
this.Height.Set((float) this._texture.Height, 0.0f);
|
||||
}
|
||||
|
||||
public void SetImage(Texture2D texture)
|
||||
{
|
||||
this._texture = texture;
|
||||
this.Width.Set((float) this._texture.Width, 0.0f);
|
||||
this.Height.Set((float) this._texture.Height, 0.0f);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
spriteBatch.Draw(this._texture, dimensions.Position(), Color.White * (this.IsMouseHovering ? this._visibilityActive : this._visibilityInactive));
|
||||
}
|
||||
|
||||
public override void MouseOver(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseOver(evt);
|
||||
Main.PlaySound(12);
|
||||
}
|
||||
|
||||
public void SetVisibility(float whenActive, float whenInactive)
|
||||
{
|
||||
this._visibilityActive = MathHelper.Clamp(whenActive, 0.0f, 1f);
|
||||
this._visibilityInactive = MathHelper.Clamp(whenInactive, 0.0f, 1f);
|
||||
}
|
||||
}
|
||||
}
|
48
GameContent/UI/Elements/UIImageFramed.cs
Normal file
48
GameContent/UI/Elements/UIImageFramed.cs
Normal file
|
@ -0,0 +1,48 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIImageFramed
|
||||
// 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.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIImageFramed : UIElement
|
||||
{
|
||||
private Texture2D _texture;
|
||||
private Rectangle _frame;
|
||||
public Color Color = Color.White;
|
||||
|
||||
public UIImageFramed(Texture2D texture, Rectangle frame)
|
||||
{
|
||||
this._texture = texture;
|
||||
this._frame = frame;
|
||||
this.Width.Set((float) this._frame.Width, 0.0f);
|
||||
this.Height.Set((float) this._frame.Height, 0.0f);
|
||||
}
|
||||
|
||||
public void SetImage(Texture2D texture, Rectangle frame)
|
||||
{
|
||||
this._texture = texture;
|
||||
this._frame = frame;
|
||||
this.Width.Set((float) this._frame.Width, 0.0f);
|
||||
this.Height.Set((float) this._frame.Height, 0.0f);
|
||||
}
|
||||
|
||||
public void SetFrame(Rectangle frame)
|
||||
{
|
||||
this._frame = frame;
|
||||
this.Width.Set((float) this._frame.Width, 0.0f);
|
||||
this.Height.Set((float) this._frame.Height, 0.0f);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
spriteBatch.Draw(this._texture, dimensions.Position(), new Rectangle?(this._frame), this.Color);
|
||||
}
|
||||
}
|
||||
}
|
202
GameContent/UI/Elements/UIKeybindingListItem.cs
Normal file
202
GameContent/UI/Elements/UIKeybindingListItem.cs
Normal file
|
@ -0,0 +1,202 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIKeybindingListItem
|
||||
// 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.GameContent.UI.Chat;
|
||||
using Terraria.GameInput;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI;
|
||||
using Terraria.UI.Chat;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIKeybindingListItem : UIElement
|
||||
{
|
||||
private InputMode _inputmode;
|
||||
private Color _color;
|
||||
private string _keybind;
|
||||
|
||||
public UIKeybindingListItem(string bind, InputMode mode, Color color)
|
||||
{
|
||||
this._keybind = bind;
|
||||
this._inputmode = mode;
|
||||
this._color = color;
|
||||
this.OnClick += new UIElement.MouseEvent(this.OnClickMethod);
|
||||
}
|
||||
|
||||
public void OnClickMethod(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
if (!(PlayerInput.ListeningTrigger != this._keybind))
|
||||
return;
|
||||
if (PlayerInput.CurrentProfile.AllowEditting)
|
||||
PlayerInput.ListenFor(this._keybind, this._inputmode);
|
||||
else
|
||||
PlayerInput.ListenFor((string) null, this._inputmode);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
float num1 = 6f;
|
||||
base.DrawSelf(spriteBatch);
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
float num2 = dimensions.Width + 1f;
|
||||
Vector2 vector2 = new Vector2(dimensions.X, dimensions.Y);
|
||||
bool flag = PlayerInput.ListeningTrigger == this._keybind;
|
||||
Vector2 baseScale = new Vector2(0.8f);
|
||||
Color baseColor = Color.Lerp(flag ? Color.Gold : (this.IsMouseHovering ? Color.White : Color.Silver), Color.White, this.IsMouseHovering ? 0.5f : 0.0f);
|
||||
Color color = this.IsMouseHovering ? this._color : this._color.MultiplyRGBA(new Color(180, 180, 180));
|
||||
Vector2 position = vector2;
|
||||
Utils.DrawSettingsPanel(spriteBatch, position, num2, color);
|
||||
position.X += 8f;
|
||||
position.Y += 2f + num1;
|
||||
ChatManager.DrawColorCodedStringWithShadow(spriteBatch, Main.fontItemStack, this.GetFriendlyName(), position, baseColor, 0.0f, Vector2.Zero, baseScale, num2);
|
||||
position.X -= 17f;
|
||||
string text = this.GenInput(PlayerInput.CurrentProfile.InputModes[this._inputmode].KeyStatus[this._keybind]);
|
||||
if (string.IsNullOrEmpty(text))
|
||||
{
|
||||
text = Lang.menu[195].Value;
|
||||
if (!flag)
|
||||
baseColor = new Color(80, 80, 80);
|
||||
}
|
||||
Vector2 stringSize = ChatManager.GetStringSize(Main.fontItemStack, text, baseScale);
|
||||
position = new Vector2((float) ((double) dimensions.X + (double) dimensions.Width - (double) stringSize.X - 10.0), dimensions.Y + 2f + num1);
|
||||
if (this._inputmode == InputMode.XBoxGamepad || this._inputmode == InputMode.XBoxGamepadUI)
|
||||
position += new Vector2(0.0f, -3f);
|
||||
GlyphTagHandler.GlyphsScale = 0.85f;
|
||||
ChatManager.DrawColorCodedStringWithShadow(spriteBatch, Main.fontItemStack, text, position, baseColor, 0.0f, Vector2.Zero, baseScale, num2);
|
||||
GlyphTagHandler.GlyphsScale = 1f;
|
||||
}
|
||||
|
||||
private string GenInput(List<string> list)
|
||||
{
|
||||
if (list.Count == 0)
|
||||
return "";
|
||||
string str = "";
|
||||
switch (this._inputmode)
|
||||
{
|
||||
case InputMode.Keyboard:
|
||||
case InputMode.KeyboardUI:
|
||||
case InputMode.Mouse:
|
||||
str = list[0];
|
||||
for (int index = 1; index < list.Count; ++index)
|
||||
str = str + "/" + list[index];
|
||||
break;
|
||||
case InputMode.XBoxGamepad:
|
||||
case InputMode.XBoxGamepadUI:
|
||||
str = GlyphTagHandler.GenerateTag(list[0]);
|
||||
for (int index = 1; index < list.Count; ++index)
|
||||
str = str + "/" + GlyphTagHandler.GenerateTag(list[index]);
|
||||
break;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
private string GetFriendlyName()
|
||||
{
|
||||
switch (this._keybind)
|
||||
{
|
||||
case "Down":
|
||||
return Lang.menu[149].Value;
|
||||
case "DpadRadial1":
|
||||
return Lang.menu[186].Value;
|
||||
case "DpadRadial2":
|
||||
return Lang.menu[187].Value;
|
||||
case "DpadRadial3":
|
||||
return Lang.menu[188].Value;
|
||||
case "DpadRadial4":
|
||||
return Lang.menu[189].Value;
|
||||
case "DpadSnap1":
|
||||
return Lang.menu[191].Value;
|
||||
case "DpadSnap2":
|
||||
return Lang.menu[192].Value;
|
||||
case "DpadSnap3":
|
||||
return Lang.menu[193].Value;
|
||||
case "DpadSnap4":
|
||||
return Lang.menu[194].Value;
|
||||
case "Grapple":
|
||||
return Lang.menu[155].Value;
|
||||
case "Hotbar1":
|
||||
return Lang.menu[176].Value;
|
||||
case "Hotbar10":
|
||||
return Lang.menu[185].Value;
|
||||
case "Hotbar2":
|
||||
return Lang.menu[177].Value;
|
||||
case "Hotbar3":
|
||||
return Lang.menu[178].Value;
|
||||
case "Hotbar4":
|
||||
return Lang.menu[179].Value;
|
||||
case "Hotbar5":
|
||||
return Lang.menu[180].Value;
|
||||
case "Hotbar6":
|
||||
return Lang.menu[181].Value;
|
||||
case "Hotbar7":
|
||||
return Lang.menu[182].Value;
|
||||
case "Hotbar8":
|
||||
return Lang.menu[183].Value;
|
||||
case "Hotbar9":
|
||||
return Lang.menu[184].Value;
|
||||
case "HotbarMinus":
|
||||
return Lang.menu[174].Value;
|
||||
case "HotbarPlus":
|
||||
return Lang.menu[175].Value;
|
||||
case "Inventory":
|
||||
return Lang.menu[154].Value;
|
||||
case "Jump":
|
||||
return Lang.menu[152].Value;
|
||||
case "Left":
|
||||
return Lang.menu[150].Value;
|
||||
case "LockOn":
|
||||
return Lang.menu[231].Value;
|
||||
case "MapAlphaDown":
|
||||
return Lang.menu[170].Value;
|
||||
case "MapAlphaUp":
|
||||
return Lang.menu[171].Value;
|
||||
case "MapFull":
|
||||
return Lang.menu[173].Value;
|
||||
case "MapStyle":
|
||||
return Lang.menu[172].Value;
|
||||
case "MapZoomIn":
|
||||
return Lang.menu[168].Value;
|
||||
case "MapZoomOut":
|
||||
return Lang.menu[169].Value;
|
||||
case "MouseLeft":
|
||||
return Lang.menu[162].Value;
|
||||
case "MouseRight":
|
||||
return Lang.menu[163].Value;
|
||||
case "QuickBuff":
|
||||
return Lang.menu[157].Value;
|
||||
case "QuickHeal":
|
||||
return Lang.menu[159].Value;
|
||||
case "QuickMana":
|
||||
return Lang.menu[156].Value;
|
||||
case "QuickMount":
|
||||
return Lang.menu[158].Value;
|
||||
case "RadialHotbar":
|
||||
return Lang.menu[190].Value;
|
||||
case "RadialQuickbar":
|
||||
return Lang.menu[244].Value;
|
||||
case "Right":
|
||||
return Lang.menu[151].Value;
|
||||
case "SmartCursor":
|
||||
return Lang.menu[161].Value;
|
||||
case "SmartSelect":
|
||||
return Lang.menu[160].Value;
|
||||
case "Throw":
|
||||
return Lang.menu[153].Value;
|
||||
case "Up":
|
||||
return Lang.menu[148].Value;
|
||||
case "ViewZoomIn":
|
||||
return Language.GetTextValue("UI.ZoomIn");
|
||||
case "ViewZoomOut":
|
||||
return Language.GetTextValue("UI.ZoomOut");
|
||||
default:
|
||||
return this._keybind;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
46
GameContent/UI/Elements/UIKeybindingSimpleListItem.cs
Normal file
46
GameContent/UI/Elements/UIKeybindingSimpleListItem.cs
Normal file
|
@ -0,0 +1,46 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIKeybindingSimpleListItem
|
||||
// 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.UI;
|
||||
using Terraria.UI.Chat;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIKeybindingSimpleListItem : UIElement
|
||||
{
|
||||
private Color _color;
|
||||
private Func<string> _GetTextFunction;
|
||||
|
||||
public UIKeybindingSimpleListItem(Func<string> getText, Color color)
|
||||
{
|
||||
this._color = color;
|
||||
this._GetTextFunction = getText != null ? getText : (Func<string>) (() => "???");
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
float num1 = 6f;
|
||||
base.DrawSelf(spriteBatch);
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
float num2 = dimensions.Width + 1f;
|
||||
Vector2 vector2 = new Vector2(dimensions.X, dimensions.Y);
|
||||
Vector2 baseScale = new Vector2(0.8f);
|
||||
Color baseColor = Color.Lerp(this.IsMouseHovering ? Color.White : Color.Silver, Color.White, this.IsMouseHovering ? 0.5f : 0.0f);
|
||||
Color color = this.IsMouseHovering ? this._color : this._color.MultiplyRGBA(new Color(180, 180, 180));
|
||||
Vector2 position = vector2;
|
||||
Utils.DrawSettings2Panel(spriteBatch, position, num2, color);
|
||||
position.X += 8f;
|
||||
position.Y += 2f + num1;
|
||||
string text = this._GetTextFunction();
|
||||
Vector2 stringSize = ChatManager.GetStringSize(Main.fontItemStack, text, baseScale);
|
||||
position.X = (float) ((double) dimensions.X + (double) dimensions.Width / 2.0 - (double) stringSize.X / 2.0);
|
||||
ChatManager.DrawColorCodedStringWithShadow(spriteBatch, Main.fontItemStack, text, position, baseColor, 0.0f, Vector2.Zero, baseScale, num2);
|
||||
}
|
||||
}
|
||||
}
|
90
GameContent/UI/Elements/UIKeybindingSliderItem.cs
Normal file
90
GameContent/UI/Elements/UIKeybindingSliderItem.cs
Normal file
|
@ -0,0 +1,90 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIKeybindingSliderItem
|
||||
// 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.GameInput;
|
||||
using Terraria.Graphics;
|
||||
using Terraria.UI;
|
||||
using Terraria.UI.Chat;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIKeybindingSliderItem : UIElement
|
||||
{
|
||||
private Color _color;
|
||||
private Func<string> _TextDisplayFunction;
|
||||
private Func<float> _GetStatusFunction;
|
||||
private Action<float> _SlideKeyboardAction;
|
||||
private Action _SlideGamepadAction;
|
||||
private int _sliderIDInPage;
|
||||
private Texture2D _toggleTexture;
|
||||
|
||||
public UIKeybindingSliderItem(
|
||||
Func<string> getText,
|
||||
Func<float> getStatus,
|
||||
Action<float> setStatusKeyboard,
|
||||
Action setStatusGamepad,
|
||||
int sliderIDInPage,
|
||||
Color color)
|
||||
{
|
||||
this._color = color;
|
||||
this._toggleTexture = TextureManager.Load("Images/UI/Settings_Toggle");
|
||||
this._TextDisplayFunction = getText != null ? getText : (Func<string>) (() => "???");
|
||||
this._GetStatusFunction = getStatus != null ? getStatus : (Func<float>) (() => 0.0f);
|
||||
this._SlideKeyboardAction = setStatusKeyboard != null ? setStatusKeyboard : (Action<float>) (s => { });
|
||||
this._SlideGamepadAction = setStatusGamepad != null ? setStatusGamepad : (Action) (() => { });
|
||||
this._sliderIDInPage = sliderIDInPage;
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
float num1 = 6f;
|
||||
base.DrawSelf(spriteBatch);
|
||||
int lockState = 0;
|
||||
IngameOptions.rightHover = -1;
|
||||
if (!Main.mouseLeft)
|
||||
IngameOptions.rightLock = -1;
|
||||
if (IngameOptions.rightLock == this._sliderIDInPage)
|
||||
lockState = 1;
|
||||
else if (IngameOptions.rightLock != -1)
|
||||
lockState = 2;
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
float num2 = dimensions.Width + 1f;
|
||||
Vector2 vector2 = new Vector2(dimensions.X, dimensions.Y);
|
||||
bool flag = this.IsMouseHovering;
|
||||
if (lockState == 1)
|
||||
flag = true;
|
||||
if (lockState == 2)
|
||||
flag = false;
|
||||
Vector2 baseScale = new Vector2(0.8f);
|
||||
Color baseColor = Color.Lerp(false ? Color.Gold : (flag ? Color.White : Color.Silver), Color.White, flag ? 0.5f : 0.0f);
|
||||
Color color = flag ? this._color : this._color.MultiplyRGBA(new Color(180, 180, 180));
|
||||
Vector2 position = vector2;
|
||||
Utils.DrawSettingsPanel(spriteBatch, position, num2, color);
|
||||
position.X += 8f;
|
||||
position.Y += 2f + num1;
|
||||
ChatManager.DrawColorCodedStringWithShadow(spriteBatch, Main.fontItemStack, this._TextDisplayFunction(), position, baseColor, 0.0f, Vector2.Zero, baseScale, num2);
|
||||
position.X -= 17f;
|
||||
Main.colorBarTexture.Frame();
|
||||
position = new Vector2((float) ((double) dimensions.X + (double) dimensions.Width - 10.0), dimensions.Y + 10f + num1);
|
||||
IngameOptions.valuePosition = position;
|
||||
float num3 = IngameOptions.DrawValueBar(spriteBatch, 1f, this._GetStatusFunction(), lockState);
|
||||
if (IngameOptions.inBar || IngameOptions.rightLock == this._sliderIDInPage)
|
||||
{
|
||||
IngameOptions.rightHover = this._sliderIDInPage;
|
||||
if (PlayerInput.Triggers.Current.MouseLeft && PlayerInput.CurrentProfile.AllowEditting && !PlayerInput.UsingGamepad && IngameOptions.rightLock == this._sliderIDInPage)
|
||||
this._SlideKeyboardAction(num3);
|
||||
}
|
||||
if (IngameOptions.rightHover != -1 && IngameOptions.rightLock == -1)
|
||||
IngameOptions.rightLock = IngameOptions.rightHover;
|
||||
if (!this.IsMouseHovering || !PlayerInput.CurrentProfile.AllowEditting)
|
||||
return;
|
||||
this._SlideGamepadAction();
|
||||
}
|
||||
}
|
||||
}
|
53
GameContent/UI/Elements/UIKeybindingToggleListItem.cs
Normal file
53
GameContent/UI/Elements/UIKeybindingToggleListItem.cs
Normal file
|
@ -0,0 +1,53 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIKeybindingToggleListItem
|
||||
// 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.Graphics;
|
||||
using Terraria.UI;
|
||||
using Terraria.UI.Chat;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIKeybindingToggleListItem : UIElement
|
||||
{
|
||||
private Color _color;
|
||||
private Func<string> _TextDisplayFunction;
|
||||
private Func<bool> _IsOnFunction;
|
||||
private Texture2D _toggleTexture;
|
||||
|
||||
public UIKeybindingToggleListItem(Func<string> getText, Func<bool> getStatus, Color color)
|
||||
{
|
||||
this._color = color;
|
||||
this._toggleTexture = TextureManager.Load("Images/UI/Settings_Toggle");
|
||||
this._TextDisplayFunction = getText != null ? getText : (Func<string>) (() => "???");
|
||||
this._IsOnFunction = getStatus != null ? getStatus : (Func<bool>) (() => false);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
float num1 = 6f;
|
||||
base.DrawSelf(spriteBatch);
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
float num2 = dimensions.Width + 1f;
|
||||
Vector2 vector2_1 = new Vector2(dimensions.X, dimensions.Y);
|
||||
Vector2 baseScale = new Vector2(0.8f);
|
||||
Color baseColor = Color.Lerp(false ? Color.Gold : (this.IsMouseHovering ? Color.White : Color.Silver), Color.White, this.IsMouseHovering ? 0.5f : 0.0f);
|
||||
Color color = this.IsMouseHovering ? this._color : this._color.MultiplyRGBA(new Color(180, 180, 180));
|
||||
Vector2 position = vector2_1;
|
||||
Utils.DrawSettingsPanel(spriteBatch, position, num2, color);
|
||||
position.X += 8f;
|
||||
position.Y += 2f + num1;
|
||||
ChatManager.DrawColorCodedStringWithShadow(spriteBatch, Main.fontItemStack, this._TextDisplayFunction(), position, baseColor, 0.0f, Vector2.Zero, baseScale, num2);
|
||||
position.X -= 17f;
|
||||
Rectangle rectangle = new Rectangle(this._IsOnFunction() ? (this._toggleTexture.Width - 2) / 2 + 2 : 0, 0, (this._toggleTexture.Width - 2) / 2, this._toggleTexture.Height);
|
||||
Vector2 vector2_2 = new Vector2((float) rectangle.Width, 0.0f);
|
||||
position = new Vector2((float) ((double) dimensions.X + (double) dimensions.Width - (double) vector2_2.X - 10.0), dimensions.Y + 2f + num1);
|
||||
spriteBatch.Draw(this._toggleTexture, position, new Rectangle?(rectangle), Color.White, 0.0f, Vector2.Zero, Vector2.One, SpriteEffects.None, 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
156
GameContent/UI/Elements/UIList.cs
Normal file
156
GameContent/UI/Elements/UIList.cs
Normal file
|
@ -0,0 +1,156 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIList
|
||||
// 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.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIList : UIElement
|
||||
{
|
||||
protected List<UIElement> _items = new List<UIElement>();
|
||||
protected UIScrollbar _scrollbar;
|
||||
private UIElement _innerList = (UIElement) new UIList.UIInnerList();
|
||||
private float _innerListHeight;
|
||||
public float ListPadding = 5f;
|
||||
|
||||
public int Count => this._items.Count;
|
||||
|
||||
public UIList()
|
||||
{
|
||||
this._innerList.OverflowHidden = false;
|
||||
this._innerList.Width.Set(0.0f, 1f);
|
||||
this._innerList.Height.Set(0.0f, 1f);
|
||||
this.OverflowHidden = true;
|
||||
this.Append(this._innerList);
|
||||
}
|
||||
|
||||
public float GetTotalHeight() => this._innerListHeight;
|
||||
|
||||
public void Goto(UIList.ElementSearchMethod searchMethod)
|
||||
{
|
||||
for (int index = 0; index < this._items.Count; ++index)
|
||||
{
|
||||
if (searchMethod(this._items[index]))
|
||||
{
|
||||
this._scrollbar.ViewPosition = this._items[index].Top.Pixels;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Add(UIElement item)
|
||||
{
|
||||
this._items.Add(item);
|
||||
this._innerList.Append(item);
|
||||
this.UpdateOrder();
|
||||
this._innerList.Recalculate();
|
||||
}
|
||||
|
||||
public virtual bool Remove(UIElement item)
|
||||
{
|
||||
this._innerList.RemoveChild(item);
|
||||
this.UpdateOrder();
|
||||
return this._items.Remove(item);
|
||||
}
|
||||
|
||||
public virtual void Clear()
|
||||
{
|
||||
this._innerList.RemoveAllChildren();
|
||||
this._items.Clear();
|
||||
}
|
||||
|
||||
public override void Recalculate()
|
||||
{
|
||||
base.Recalculate();
|
||||
this.UpdateScrollbar();
|
||||
}
|
||||
|
||||
public override void ScrollWheel(UIScrollWheelEvent evt)
|
||||
{
|
||||
base.ScrollWheel(evt);
|
||||
if (this._scrollbar == null)
|
||||
return;
|
||||
this._scrollbar.ViewPosition -= (float) evt.ScrollWheelValue;
|
||||
}
|
||||
|
||||
public override void RecalculateChildren()
|
||||
{
|
||||
base.RecalculateChildren();
|
||||
float pixels = 0.0f;
|
||||
for (int index = 0; index < this._items.Count; ++index)
|
||||
{
|
||||
this._items[index].Top.Set(pixels, 0.0f);
|
||||
this._items[index].Recalculate();
|
||||
CalculatedStyle outerDimensions = this._items[index].GetOuterDimensions();
|
||||
pixels += outerDimensions.Height + this.ListPadding;
|
||||
}
|
||||
this._innerListHeight = pixels;
|
||||
}
|
||||
|
||||
private void UpdateScrollbar()
|
||||
{
|
||||
if (this._scrollbar == null)
|
||||
return;
|
||||
this._scrollbar.SetView(this.GetInnerDimensions().Height, this._innerListHeight);
|
||||
}
|
||||
|
||||
public void SetScrollbar(UIScrollbar scrollbar)
|
||||
{
|
||||
this._scrollbar = scrollbar;
|
||||
this.UpdateScrollbar();
|
||||
}
|
||||
|
||||
public void UpdateOrder()
|
||||
{
|
||||
this._items.Sort(new Comparison<UIElement>(this.SortMethod));
|
||||
this.UpdateScrollbar();
|
||||
}
|
||||
|
||||
public int SortMethod(UIElement item1, UIElement item2) => item1.CompareTo((object) item2);
|
||||
|
||||
public override List<SnapPoint> GetSnapPoints()
|
||||
{
|
||||
List<SnapPoint> snapPointList = new List<SnapPoint>();
|
||||
SnapPoint point;
|
||||
if (this.GetSnapPoint(out point))
|
||||
snapPointList.Add(point);
|
||||
foreach (UIElement uiElement in this._items)
|
||||
snapPointList.AddRange((IEnumerable<SnapPoint>) uiElement.GetSnapPoints());
|
||||
return snapPointList;
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
if (this._scrollbar != null)
|
||||
this._innerList.Top.Set(-this._scrollbar.GetValue(), 0.0f);
|
||||
this.Recalculate();
|
||||
}
|
||||
|
||||
public delegate bool ElementSearchMethod(UIElement element);
|
||||
|
||||
private class UIInnerList : UIElement
|
||||
{
|
||||
public override bool ContainsPoint(Vector2 point) => true;
|
||||
|
||||
protected override void DrawChildren(SpriteBatch spriteBatch)
|
||||
{
|
||||
Vector2 position1 = this.Parent.GetDimensions().Position();
|
||||
Vector2 dimensions1 = new Vector2(this.Parent.GetDimensions().Width, this.Parent.GetDimensions().Height);
|
||||
foreach (UIElement element in this.Elements)
|
||||
{
|
||||
Vector2 position2 = element.GetDimensions().Position();
|
||||
Vector2 dimensions2 = new Vector2(element.GetDimensions().Width, element.GetDimensions().Height);
|
||||
if (Collision.CheckAABBvAABBCollision(position1, dimensions1, position2, dimensions2))
|
||||
element.Draw(spriteBatch);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
56
GameContent/UI/Elements/UIPanel.cs
Normal file
56
GameContent/UI/Elements/UIPanel.cs
Normal file
|
@ -0,0 +1,56 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIPanel
|
||||
// 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.Graphics;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIPanel : UIElement
|
||||
{
|
||||
private static int CORNER_SIZE = 12;
|
||||
private static int BAR_SIZE = 4;
|
||||
private static Texture2D _borderTexture;
|
||||
private static Texture2D _backgroundTexture;
|
||||
public Color BorderColor = Color.Black;
|
||||
public Color BackgroundColor = new Color(63, 82, 151) * 0.7f;
|
||||
|
||||
public UIPanel()
|
||||
{
|
||||
if (UIPanel._borderTexture == null)
|
||||
UIPanel._borderTexture = TextureManager.Load("Images/UI/PanelBorder");
|
||||
if (UIPanel._backgroundTexture == null)
|
||||
UIPanel._backgroundTexture = TextureManager.Load("Images/UI/PanelBackground");
|
||||
this.SetPadding((float) UIPanel.CORNER_SIZE);
|
||||
}
|
||||
|
||||
private void DrawPanel(SpriteBatch spriteBatch, Texture2D texture, Color color)
|
||||
{
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
Point point1 = new Point((int) dimensions.X, (int) dimensions.Y);
|
||||
Point point2 = new Point(point1.X + (int) dimensions.Width - UIPanel.CORNER_SIZE, point1.Y + (int) dimensions.Height - UIPanel.CORNER_SIZE);
|
||||
int width = point2.X - point1.X - UIPanel.CORNER_SIZE;
|
||||
int height = point2.Y - point1.Y - UIPanel.CORNER_SIZE;
|
||||
spriteBatch.Draw(texture, new Rectangle(point1.X, point1.Y, UIPanel.CORNER_SIZE, UIPanel.CORNER_SIZE), new Rectangle?(new Rectangle(0, 0, UIPanel.CORNER_SIZE, UIPanel.CORNER_SIZE)), color);
|
||||
spriteBatch.Draw(texture, new Rectangle(point2.X, point1.Y, UIPanel.CORNER_SIZE, UIPanel.CORNER_SIZE), new Rectangle?(new Rectangle(UIPanel.CORNER_SIZE + UIPanel.BAR_SIZE, 0, UIPanel.CORNER_SIZE, UIPanel.CORNER_SIZE)), color);
|
||||
spriteBatch.Draw(texture, new Rectangle(point1.X, point2.Y, UIPanel.CORNER_SIZE, UIPanel.CORNER_SIZE), new Rectangle?(new Rectangle(0, UIPanel.CORNER_SIZE + UIPanel.BAR_SIZE, UIPanel.CORNER_SIZE, UIPanel.CORNER_SIZE)), color);
|
||||
spriteBatch.Draw(texture, new Rectangle(point2.X, point2.Y, UIPanel.CORNER_SIZE, UIPanel.CORNER_SIZE), new Rectangle?(new Rectangle(UIPanel.CORNER_SIZE + UIPanel.BAR_SIZE, UIPanel.CORNER_SIZE + UIPanel.BAR_SIZE, UIPanel.CORNER_SIZE, UIPanel.CORNER_SIZE)), color);
|
||||
spriteBatch.Draw(texture, new Rectangle(point1.X + UIPanel.CORNER_SIZE, point1.Y, width, UIPanel.CORNER_SIZE), new Rectangle?(new Rectangle(UIPanel.CORNER_SIZE, 0, UIPanel.BAR_SIZE, UIPanel.CORNER_SIZE)), color);
|
||||
spriteBatch.Draw(texture, new Rectangle(point1.X + UIPanel.CORNER_SIZE, point2.Y, width, UIPanel.CORNER_SIZE), new Rectangle?(new Rectangle(UIPanel.CORNER_SIZE, UIPanel.CORNER_SIZE + UIPanel.BAR_SIZE, UIPanel.BAR_SIZE, UIPanel.CORNER_SIZE)), color);
|
||||
spriteBatch.Draw(texture, new Rectangle(point1.X, point1.Y + UIPanel.CORNER_SIZE, UIPanel.CORNER_SIZE, height), new Rectangle?(new Rectangle(0, UIPanel.CORNER_SIZE, UIPanel.CORNER_SIZE, UIPanel.BAR_SIZE)), color);
|
||||
spriteBatch.Draw(texture, new Rectangle(point2.X, point1.Y + UIPanel.CORNER_SIZE, UIPanel.CORNER_SIZE, height), new Rectangle?(new Rectangle(UIPanel.CORNER_SIZE + UIPanel.BAR_SIZE, UIPanel.CORNER_SIZE, UIPanel.CORNER_SIZE, UIPanel.BAR_SIZE)), color);
|
||||
spriteBatch.Draw(texture, new Rectangle(point1.X + UIPanel.CORNER_SIZE, point1.Y + UIPanel.CORNER_SIZE, width, height), new Rectangle?(new Rectangle(UIPanel.CORNER_SIZE, UIPanel.CORNER_SIZE, UIPanel.BAR_SIZE, UIPanel.BAR_SIZE)), color);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
this.DrawPanel(spriteBatch, UIPanel._backgroundTexture, this.BackgroundColor);
|
||||
this.DrawPanel(spriteBatch, UIPanel._borderTexture, this.BorderColor);
|
||||
}
|
||||
}
|
||||
}
|
50
GameContent/UI/Elements/UIProgressBar.cs
Normal file
50
GameContent/UI/Elements/UIProgressBar.cs
Normal file
|
@ -0,0 +1,50 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIProgressBar
|
||||
// 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.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIProgressBar : UIElement
|
||||
{
|
||||
private UIProgressBar.UIInnerProgressBar _progressBar = new UIProgressBar.UIInnerProgressBar();
|
||||
private float _visualProgress;
|
||||
private float _targetProgress;
|
||||
|
||||
public UIProgressBar()
|
||||
{
|
||||
this._progressBar.Height.Precent = 1f;
|
||||
this._progressBar.Recalculate();
|
||||
this.Append((UIElement) this._progressBar);
|
||||
}
|
||||
|
||||
public void SetProgress(float value)
|
||||
{
|
||||
this._targetProgress = value;
|
||||
if ((double) value >= (double) this._visualProgress)
|
||||
return;
|
||||
this._visualProgress = value;
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
this._visualProgress = (float) ((double) this._visualProgress * 0.949999988079071 + 0.0500000007450581 * (double) this._targetProgress);
|
||||
this._progressBar.Width.Precent = this._visualProgress;
|
||||
this._progressBar.Recalculate();
|
||||
}
|
||||
|
||||
private class UIInnerProgressBar : UIElement
|
||||
{
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
spriteBatch.Draw(Main.magicPixel, new Vector2(dimensions.X, dimensions.Y), new Rectangle?(), Color.Blue, 0.0f, Vector2.Zero, new Vector2(dimensions.Width, dimensions.Height / 1000f), SpriteEffects.None, 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
113
GameContent/UI/Elements/UIScrollbar.cs
Normal file
113
GameContent/UI/Elements/UIScrollbar.cs
Normal file
|
@ -0,0 +1,113 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIScrollbar
|
||||
// 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.Graphics;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIScrollbar : UIElement
|
||||
{
|
||||
private float _viewPosition;
|
||||
private float _viewSize = 1f;
|
||||
private float _maxViewSize = 20f;
|
||||
private bool _isDragging;
|
||||
private bool _isHoveringOverHandle;
|
||||
private float _dragYOffset;
|
||||
private Texture2D _texture;
|
||||
private Texture2D _innerTexture;
|
||||
|
||||
public float ViewPosition
|
||||
{
|
||||
get => this._viewPosition;
|
||||
set => this._viewPosition = MathHelper.Clamp(value, 0.0f, this._maxViewSize - this._viewSize);
|
||||
}
|
||||
|
||||
public UIScrollbar()
|
||||
{
|
||||
this.Width.Set(20f, 0.0f);
|
||||
this.MaxWidth.Set(20f, 0.0f);
|
||||
this._texture = TextureManager.Load("Images/UI/Scrollbar");
|
||||
this._innerTexture = TextureManager.Load("Images/UI/ScrollbarInner");
|
||||
this.PaddingTop = 5f;
|
||||
this.PaddingBottom = 5f;
|
||||
}
|
||||
|
||||
public void SetView(float viewSize, float maxViewSize)
|
||||
{
|
||||
viewSize = MathHelper.Clamp(viewSize, 0.0f, maxViewSize);
|
||||
this._viewPosition = MathHelper.Clamp(this._viewPosition, 0.0f, maxViewSize - viewSize);
|
||||
this._viewSize = viewSize;
|
||||
this._maxViewSize = maxViewSize;
|
||||
}
|
||||
|
||||
public float GetValue() => this._viewPosition;
|
||||
|
||||
private Rectangle GetHandleRectangle()
|
||||
{
|
||||
CalculatedStyle innerDimensions = this.GetInnerDimensions();
|
||||
if ((double) this._maxViewSize == 0.0 && (double) this._viewSize == 0.0)
|
||||
{
|
||||
this._viewSize = 1f;
|
||||
this._maxViewSize = 1f;
|
||||
}
|
||||
return new Rectangle((int) innerDimensions.X, (int) ((double) innerDimensions.Y + (double) innerDimensions.Height * ((double) this._viewPosition / (double) this._maxViewSize)) - 3, 20, (int) ((double) innerDimensions.Height * ((double) this._viewSize / (double) this._maxViewSize)) + 7);
|
||||
}
|
||||
|
||||
private void DrawBar(
|
||||
SpriteBatch spriteBatch,
|
||||
Texture2D texture,
|
||||
Rectangle dimensions,
|
||||
Color color)
|
||||
{
|
||||
spriteBatch.Draw(texture, new Rectangle(dimensions.X, dimensions.Y - 6, dimensions.Width, 6), new Rectangle?(new Rectangle(0, 0, texture.Width, 6)), color);
|
||||
spriteBatch.Draw(texture, new Rectangle(dimensions.X, dimensions.Y, dimensions.Width, dimensions.Height), new Rectangle?(new Rectangle(0, 6, texture.Width, 4)), color);
|
||||
spriteBatch.Draw(texture, new Rectangle(dimensions.X, dimensions.Y + dimensions.Height, dimensions.Width, 6), new Rectangle?(new Rectangle(0, texture.Height - 6, texture.Width, 6)), color);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
CalculatedStyle innerDimensions = this.GetInnerDimensions();
|
||||
if (this._isDragging)
|
||||
this._viewPosition = MathHelper.Clamp((UserInterface.ActiveInstance.MousePosition.Y - innerDimensions.Y - this._dragYOffset) / innerDimensions.Height * this._maxViewSize, 0.0f, this._maxViewSize - this._viewSize);
|
||||
Rectangle handleRectangle = this.GetHandleRectangle();
|
||||
Vector2 mousePosition = UserInterface.ActiveInstance.MousePosition;
|
||||
int num = this._isHoveringOverHandle ? 1 : 0;
|
||||
this._isHoveringOverHandle = handleRectangle.Contains(new Point((int) mousePosition.X, (int) mousePosition.Y));
|
||||
if (num == 0 && this._isHoveringOverHandle && Main.hasFocus)
|
||||
Main.PlaySound(12);
|
||||
this.DrawBar(spriteBatch, this._texture, dimensions.ToRectangle(), Color.White);
|
||||
this.DrawBar(spriteBatch, this._innerTexture, handleRectangle, Color.White * (this._isDragging || this._isHoveringOverHandle ? 1f : 0.85f));
|
||||
}
|
||||
|
||||
public override void MouseDown(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseDown(evt);
|
||||
if (evt.Target != this)
|
||||
return;
|
||||
Rectangle handleRectangle = this.GetHandleRectangle();
|
||||
if (handleRectangle.Contains(new Point((int) evt.MousePosition.X, (int) evt.MousePosition.Y)))
|
||||
{
|
||||
this._isDragging = true;
|
||||
this._dragYOffset = evt.MousePosition.Y - (float) handleRectangle.Y;
|
||||
}
|
||||
else
|
||||
{
|
||||
CalculatedStyle innerDimensions = this.GetInnerDimensions();
|
||||
this._viewPosition = MathHelper.Clamp((UserInterface.ActiveInstance.MousePosition.Y - innerDimensions.Y - (float) (handleRectangle.Height >> 1)) / innerDimensions.Height * this._maxViewSize, 0.0f, this._maxViewSize - this._viewSize);
|
||||
}
|
||||
}
|
||||
|
||||
public override void MouseUp(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseUp(evt);
|
||||
this._isDragging = false;
|
||||
}
|
||||
}
|
||||
}
|
75
GameContent/UI/Elements/UIText.cs
Normal file
75
GameContent/UI/Elements/UIText.cs
Normal file
|
@ -0,0 +1,75 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIText
|
||||
// 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.Localization;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIText : UIElement
|
||||
{
|
||||
private object _text = (object) "";
|
||||
private float _textScale = 1f;
|
||||
private Vector2 _textSize = Vector2.Zero;
|
||||
private bool _isLarge;
|
||||
private Color _color = Color.White;
|
||||
|
||||
public string Text => this._text.ToString();
|
||||
|
||||
public Color TextColor
|
||||
{
|
||||
get => this._color;
|
||||
set => this._color = value;
|
||||
}
|
||||
|
||||
public UIText(string text, float textScale = 1f, bool large = false) => this.InternalSetText((object) text, textScale, large);
|
||||
|
||||
public UIText(LocalizedText text, float textScale = 1f, bool large = false) => this.InternalSetText((object) text, textScale, large);
|
||||
|
||||
public override void Recalculate()
|
||||
{
|
||||
this.InternalSetText(this._text, this._textScale, this._isLarge);
|
||||
base.Recalculate();
|
||||
}
|
||||
|
||||
public void SetText(string text) => this.InternalSetText((object) text, this._textScale, this._isLarge);
|
||||
|
||||
public void SetText(LocalizedText text) => this.InternalSetText((object) text, this._textScale, this._isLarge);
|
||||
|
||||
public void SetText(string text, float textScale, bool large) => this.InternalSetText((object) text, textScale, large);
|
||||
|
||||
public void SetText(LocalizedText text, float textScale, bool large) => this.InternalSetText((object) text, textScale, large);
|
||||
|
||||
private void InternalSetText(object text, float textScale, bool large)
|
||||
{
|
||||
Vector2 vector2 = new Vector2((large ? Main.fontDeathText : Main.fontMouseText).MeasureString(text.ToString()).X, large ? 32f : 16f) * textScale;
|
||||
this._text = text;
|
||||
this._textScale = textScale;
|
||||
this._textSize = vector2;
|
||||
this._isLarge = large;
|
||||
this.MinWidth.Set(vector2.X + this.PaddingLeft + this.PaddingRight, 0.0f);
|
||||
this.MinHeight.Set(vector2.Y + this.PaddingTop + this.PaddingBottom, 0.0f);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
base.DrawSelf(spriteBatch);
|
||||
CalculatedStyle innerDimensions = this.GetInnerDimensions();
|
||||
Vector2 pos = innerDimensions.Position();
|
||||
if (this._isLarge)
|
||||
pos.Y -= 10f * this._textScale;
|
||||
else
|
||||
pos.Y -= 2f * this._textScale;
|
||||
pos.X += (float) (((double) innerDimensions.Width - (double) this._textSize.X) * 0.5);
|
||||
if (this._isLarge)
|
||||
Utils.DrawBorderStringBig(spriteBatch, this.Text, pos, this._color, this._textScale);
|
||||
else
|
||||
Utils.DrawBorderString(spriteBatch, this.Text, pos, this._color, this._textScale);
|
||||
}
|
||||
}
|
||||
}
|
83
GameContent/UI/Elements/UITextBox.cs
Normal file
83
GameContent/UI/Elements/UITextBox.cs
Normal file
|
@ -0,0 +1,83 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UITextBox
|
||||
// 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.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
internal class UITextBox : UITextPanel<string>
|
||||
{
|
||||
private int _cursor;
|
||||
private int _frameCount;
|
||||
private int _maxLength = 20;
|
||||
|
||||
public UITextBox(string text, float textScale = 1f, bool large = false)
|
||||
: base(text, textScale, large)
|
||||
{
|
||||
}
|
||||
|
||||
public void Write(string text)
|
||||
{
|
||||
this.SetText(this.Text.Insert(this._cursor, text));
|
||||
this._cursor += text.Length;
|
||||
}
|
||||
|
||||
public override void SetText(string text, float textScale, bool large)
|
||||
{
|
||||
if (text.ToString().Length > this._maxLength)
|
||||
text = text.ToString().Substring(0, this._maxLength);
|
||||
base.SetText(text, textScale, large);
|
||||
this._cursor = Math.Min(this.Text.Length, this._cursor);
|
||||
}
|
||||
|
||||
public void SetTextMaxLength(int maxLength) => this._maxLength = maxLength;
|
||||
|
||||
public void Backspace()
|
||||
{
|
||||
if (this._cursor == 0)
|
||||
return;
|
||||
this.SetText(this.Text.Substring(0, this.Text.Length - 1));
|
||||
}
|
||||
|
||||
public void CursorLeft()
|
||||
{
|
||||
if (this._cursor == 0)
|
||||
return;
|
||||
--this._cursor;
|
||||
}
|
||||
|
||||
public void CursorRight()
|
||||
{
|
||||
if (this._cursor >= this.Text.Length)
|
||||
return;
|
||||
++this._cursor;
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
this._cursor = this.Text.Length;
|
||||
base.DrawSelf(spriteBatch);
|
||||
++this._frameCount;
|
||||
if ((this._frameCount %= 40) > 20)
|
||||
return;
|
||||
CalculatedStyle innerDimensions = this.GetInnerDimensions();
|
||||
Vector2 pos = innerDimensions.Position();
|
||||
Vector2 vector2 = new Vector2((this.IsLarge ? Main.fontDeathText : Main.fontMouseText).MeasureString(this.Text.Substring(0, this._cursor)).X, this.IsLarge ? 32f : 16f) * this.TextScale;
|
||||
if (this.IsLarge)
|
||||
pos.Y -= 8f * this.TextScale;
|
||||
else
|
||||
pos.Y += 2f * this.TextScale;
|
||||
pos.X += (float) (((double) innerDimensions.Width - (double) this.TextSize.X) * 0.5 + (double) vector2.X - (this.IsLarge ? 8.0 : 4.0) * (double) this.TextScale + 6.0);
|
||||
if (this.IsLarge)
|
||||
Utils.DrawBorderStringBig(spriteBatch, "|", pos, this.TextColor, this.TextScale);
|
||||
else
|
||||
Utils.DrawBorderString(spriteBatch, "|", pos, this.TextColor, this.TextScale);
|
||||
}
|
||||
}
|
||||
}
|
84
GameContent/UI/Elements/UITextPanel`1.cs
Normal file
84
GameContent/UI/Elements/UITextPanel`1.cs
Normal file
|
@ -0,0 +1,84 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UITextPanel`1
|
||||
// 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.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UITextPanel<T> : UIPanel
|
||||
{
|
||||
private T _text;
|
||||
private float _textScale = 1f;
|
||||
private Vector2 _textSize = Vector2.Zero;
|
||||
private bool _isLarge;
|
||||
private Color _color = Color.White;
|
||||
private bool _drawPanel = true;
|
||||
|
||||
public bool IsLarge => this._isLarge;
|
||||
|
||||
public bool DrawPanel
|
||||
{
|
||||
get => this._drawPanel;
|
||||
set => this._drawPanel = value;
|
||||
}
|
||||
|
||||
public float TextScale
|
||||
{
|
||||
get => this._textScale;
|
||||
set => this._textScale = value;
|
||||
}
|
||||
|
||||
public Vector2 TextSize => this._textSize;
|
||||
|
||||
public string Text => (object) this._text != null ? this._text.ToString() : "";
|
||||
|
||||
public Color TextColor
|
||||
{
|
||||
get => this._color;
|
||||
set => this._color = value;
|
||||
}
|
||||
|
||||
public UITextPanel(T text, float textScale = 1f, bool large = false) => this.SetText(text, textScale, large);
|
||||
|
||||
public override void Recalculate()
|
||||
{
|
||||
this.SetText(this._text, this._textScale, this._isLarge);
|
||||
base.Recalculate();
|
||||
}
|
||||
|
||||
public void SetText(T text) => this.SetText(text, this._textScale, this._isLarge);
|
||||
|
||||
public virtual void SetText(T text, float textScale, bool large)
|
||||
{
|
||||
Vector2 vector2 = new Vector2((large ? Main.fontDeathText : Main.fontMouseText).MeasureString(text.ToString()).X, large ? 32f : 16f) * textScale;
|
||||
this._text = text;
|
||||
this._textScale = textScale;
|
||||
this._textSize = vector2;
|
||||
this._isLarge = large;
|
||||
this.MinWidth.Set(vector2.X + this.PaddingLeft + this.PaddingRight, 0.0f);
|
||||
this.MinHeight.Set(vector2.Y + this.PaddingTop + this.PaddingBottom, 0.0f);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
if (this._drawPanel)
|
||||
base.DrawSelf(spriteBatch);
|
||||
CalculatedStyle innerDimensions = this.GetInnerDimensions();
|
||||
Vector2 pos = innerDimensions.Position();
|
||||
if (this._isLarge)
|
||||
pos.Y -= 10f * this._textScale * this._textScale;
|
||||
else
|
||||
pos.Y -= 2f * this._textScale;
|
||||
pos.X += (float) (((double) innerDimensions.Width - (double) this._textSize.X) * 0.5);
|
||||
if (this._isLarge)
|
||||
Utils.DrawBorderStringBig(spriteBatch, this.Text, pos, this._color, this._textScale);
|
||||
else
|
||||
Utils.DrawBorderString(spriteBatch, this.Text, pos, this._color, this._textScale);
|
||||
}
|
||||
}
|
||||
}
|
71
GameContent/UI/Elements/UIToggleImage.cs
Normal file
71
GameContent/UI/Elements/UIToggleImage.cs
Normal file
|
@ -0,0 +1,71 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIToggleImage
|
||||
// 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.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIToggleImage : UIElement
|
||||
{
|
||||
private Texture2D _onTexture;
|
||||
private Texture2D _offTexture;
|
||||
private int _drawWidth;
|
||||
private int _drawHeight;
|
||||
private Point _onTextureOffset = Point.Zero;
|
||||
private Point _offTextureOffset = Point.Zero;
|
||||
private bool _isOn;
|
||||
|
||||
public bool IsOn => this._isOn;
|
||||
|
||||
public UIToggleImage(
|
||||
Texture2D texture,
|
||||
int width,
|
||||
int height,
|
||||
Point onTextureOffset,
|
||||
Point offTextureOffset)
|
||||
{
|
||||
this._onTexture = texture;
|
||||
this._offTexture = texture;
|
||||
this._offTextureOffset = offTextureOffset;
|
||||
this._onTextureOffset = onTextureOffset;
|
||||
this._drawWidth = width;
|
||||
this._drawHeight = height;
|
||||
this.Width.Set((float) width, 0.0f);
|
||||
this.Height.Set((float) height, 0.0f);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
Texture2D texture;
|
||||
Point point;
|
||||
if (this._isOn)
|
||||
{
|
||||
texture = this._onTexture;
|
||||
point = this._onTextureOffset;
|
||||
}
|
||||
else
|
||||
{
|
||||
texture = this._offTexture;
|
||||
point = this._offTextureOffset;
|
||||
}
|
||||
Color color = this.IsMouseHovering ? Color.White : Color.Silver;
|
||||
spriteBatch.Draw(texture, new Rectangle((int) dimensions.X, (int) dimensions.Y, this._drawWidth, this._drawHeight), new Rectangle?(new Rectangle(point.X, point.Y, this._drawWidth, this._drawHeight)), color);
|
||||
}
|
||||
|
||||
public override void Click(UIMouseEvent evt)
|
||||
{
|
||||
this.Toggle();
|
||||
base.Click(evt);
|
||||
}
|
||||
|
||||
public void SetState(bool value) => this._isOn = value;
|
||||
|
||||
public void Toggle() => this._isOn = !this._isOn;
|
||||
}
|
||||
}
|
297
GameContent/UI/Elements/UIWorldListItem.cs
Normal file
297
GameContent/UI/Elements/UIWorldListItem.cs
Normal file
|
@ -0,0 +1,297 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIWorldListItem
|
||||
// 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.OS;
|
||||
using Terraria.Graphics;
|
||||
using Terraria.IO;
|
||||
using Terraria.Localization;
|
||||
using Terraria.Social;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIWorldListItem : UIPanel
|
||||
{
|
||||
private WorldFileData _data;
|
||||
private Texture2D _dividerTexture;
|
||||
private Texture2D _innerPanelTexture;
|
||||
private UIImage _worldIcon;
|
||||
private UIText _buttonLabel;
|
||||
private UIText _deleteButtonLabel;
|
||||
private Texture2D _buttonCloudActiveTexture;
|
||||
private Texture2D _buttonCloudInactiveTexture;
|
||||
private Texture2D _buttonFavoriteActiveTexture;
|
||||
private Texture2D _buttonFavoriteInactiveTexture;
|
||||
private Texture2D _buttonPlayTexture;
|
||||
private Texture2D _buttonSeedTexture;
|
||||
private Texture2D _buttonDeleteTexture;
|
||||
private UIImageButton _deleteButton;
|
||||
|
||||
public bool IsFavorite => this._data.IsFavorite;
|
||||
|
||||
public UIWorldListItem(WorldFileData data, int snapPointIndex)
|
||||
{
|
||||
this._data = data;
|
||||
this.LoadTextures();
|
||||
this.InitializeAppearance();
|
||||
this._worldIcon = new UIImage(this.GetIcon());
|
||||
this._worldIcon.Left.Set(4f, 0.0f);
|
||||
this._worldIcon.OnDoubleClick += new UIElement.MouseEvent(this.PlayGame);
|
||||
this.Append((UIElement) this._worldIcon);
|
||||
float pixels1 = 4f;
|
||||
UIImageButton uiImageButton1 = new UIImageButton(this._buttonPlayTexture);
|
||||
uiImageButton1.VAlign = 1f;
|
||||
uiImageButton1.Left.Set(pixels1, 0.0f);
|
||||
uiImageButton1.OnClick += new UIElement.MouseEvent(this.PlayGame);
|
||||
this.OnDoubleClick += new UIElement.MouseEvent(this.PlayGame);
|
||||
uiImageButton1.OnMouseOver += new UIElement.MouseEvent(this.PlayMouseOver);
|
||||
uiImageButton1.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut);
|
||||
this.Append((UIElement) uiImageButton1);
|
||||
float pixels2 = pixels1 + 24f;
|
||||
UIImageButton uiImageButton2 = new UIImageButton(this._data.IsFavorite ? this._buttonFavoriteActiveTexture : this._buttonFavoriteInactiveTexture);
|
||||
uiImageButton2.VAlign = 1f;
|
||||
uiImageButton2.Left.Set(pixels2, 0.0f);
|
||||
uiImageButton2.OnClick += new UIElement.MouseEvent(this.FavoriteButtonClick);
|
||||
uiImageButton2.OnMouseOver += new UIElement.MouseEvent(this.FavoriteMouseOver);
|
||||
uiImageButton2.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut);
|
||||
uiImageButton2.SetVisibility(1f, this._data.IsFavorite ? 0.8f : 0.4f);
|
||||
this.Append((UIElement) uiImageButton2);
|
||||
float pixels3 = pixels2 + 24f;
|
||||
if (SocialAPI.Cloud != null)
|
||||
{
|
||||
UIImageButton uiImageButton3 = new UIImageButton(this._data.IsCloudSave ? this._buttonCloudActiveTexture : this._buttonCloudInactiveTexture);
|
||||
uiImageButton3.VAlign = 1f;
|
||||
uiImageButton3.Left.Set(pixels3, 0.0f);
|
||||
uiImageButton3.OnClick += new UIElement.MouseEvent(this.CloudButtonClick);
|
||||
uiImageButton3.OnMouseOver += new UIElement.MouseEvent(this.CloudMouseOver);
|
||||
uiImageButton3.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut);
|
||||
uiImageButton3.SetSnapPoint("Cloud", snapPointIndex);
|
||||
this.Append((UIElement) uiImageButton3);
|
||||
pixels3 += 24f;
|
||||
}
|
||||
if (Main.UseSeedUI && this._data.WorldGeneratorVersion != 0UL)
|
||||
{
|
||||
UIImageButton uiImageButton4 = new UIImageButton(this._buttonSeedTexture);
|
||||
uiImageButton4.VAlign = 1f;
|
||||
uiImageButton4.Left.Set(pixels3, 0.0f);
|
||||
uiImageButton4.OnClick += new UIElement.MouseEvent(this.SeedButtonClick);
|
||||
uiImageButton4.OnMouseOver += new UIElement.MouseEvent(this.SeedMouseOver);
|
||||
uiImageButton4.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut);
|
||||
uiImageButton4.SetSnapPoint("Seed", snapPointIndex);
|
||||
this.Append((UIElement) uiImageButton4);
|
||||
pixels3 += 24f;
|
||||
}
|
||||
UIImageButton uiImageButton5 = new UIImageButton(this._buttonDeleteTexture);
|
||||
uiImageButton5.VAlign = 1f;
|
||||
uiImageButton5.HAlign = 1f;
|
||||
uiImageButton5.OnClick += new UIElement.MouseEvent(this.DeleteButtonClick);
|
||||
uiImageButton5.OnMouseOver += new UIElement.MouseEvent(this.DeleteMouseOver);
|
||||
uiImageButton5.OnMouseOut += new UIElement.MouseEvent(this.DeleteMouseOut);
|
||||
this._deleteButton = uiImageButton5;
|
||||
if (!this._data.IsFavorite)
|
||||
this.Append((UIElement) uiImageButton5);
|
||||
float pixels4 = pixels3 + 4f;
|
||||
this._buttonLabel = new UIText("");
|
||||
this._buttonLabel.VAlign = 1f;
|
||||
this._buttonLabel.Left.Set(pixels4, 0.0f);
|
||||
this._buttonLabel.Top.Set(-3f, 0.0f);
|
||||
this.Append((UIElement) this._buttonLabel);
|
||||
this._deleteButtonLabel = new UIText("");
|
||||
this._deleteButtonLabel.VAlign = 1f;
|
||||
this._deleteButtonLabel.HAlign = 1f;
|
||||
this._deleteButtonLabel.Left.Set(-30f, 0.0f);
|
||||
this._deleteButtonLabel.Top.Set(-3f, 0.0f);
|
||||
this.Append((UIElement) this._deleteButtonLabel);
|
||||
uiImageButton1.SetSnapPoint("Play", snapPointIndex);
|
||||
uiImageButton2.SetSnapPoint("Favorite", snapPointIndex);
|
||||
uiImageButton5.SetSnapPoint("Delete", snapPointIndex);
|
||||
}
|
||||
|
||||
private void LoadTextures()
|
||||
{
|
||||
this._dividerTexture = TextureManager.Load("Images/UI/Divider");
|
||||
this._innerPanelTexture = TextureManager.Load("Images/UI/InnerPanelBackground");
|
||||
this._buttonCloudActiveTexture = TextureManager.Load("Images/UI/ButtonCloudActive");
|
||||
this._buttonCloudInactiveTexture = TextureManager.Load("Images/UI/ButtonCloudInactive");
|
||||
this._buttonFavoriteActiveTexture = TextureManager.Load("Images/UI/ButtonFavoriteActive");
|
||||
this._buttonFavoriteInactiveTexture = TextureManager.Load("Images/UI/ButtonFavoriteInactive");
|
||||
this._buttonPlayTexture = TextureManager.Load("Images/UI/ButtonPlay");
|
||||
this._buttonSeedTexture = TextureManager.Load("Images/UI/ButtonSeed");
|
||||
this._buttonDeleteTexture = TextureManager.Load("Images/UI/ButtonDelete");
|
||||
}
|
||||
|
||||
private void InitializeAppearance()
|
||||
{
|
||||
this.Height.Set(96f, 0.0f);
|
||||
this.Width.Set(0.0f, 1f);
|
||||
this.SetPadding(6f);
|
||||
this.BorderColor = new Color(89, 116, 213) * 0.7f;
|
||||
}
|
||||
|
||||
private Texture2D GetIcon() => TextureManager.Load("Images/UI/Icon" + (this._data.IsHardMode ? "Hallow" : "") + (this._data.HasCorruption ? "Corruption" : "Crimson"));
|
||||
|
||||
private void FavoriteMouseOver(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
if (this._data.IsFavorite)
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.Unfavorite"));
|
||||
else
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.Favorite"));
|
||||
}
|
||||
|
||||
private void CloudMouseOver(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
if (this._data.IsCloudSave)
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.MoveOffCloud"));
|
||||
else
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.MoveToCloud"));
|
||||
}
|
||||
|
||||
private void PlayMouseOver(UIMouseEvent evt, UIElement listeningElement) => this._buttonLabel.SetText(Language.GetTextValue("UI.Play"));
|
||||
|
||||
private void SeedMouseOver(UIMouseEvent evt, UIElement listeningElement) => this._buttonLabel.SetText(Language.GetTextValue("UI.CopySeed", (object) this._data.SeedText));
|
||||
|
||||
private void DeleteMouseOver(UIMouseEvent evt, UIElement listeningElement) => this._deleteButtonLabel.SetText(Language.GetTextValue("UI.Delete"));
|
||||
|
||||
private void DeleteMouseOut(UIMouseEvent evt, UIElement listeningElement) => this._deleteButtonLabel.SetText("");
|
||||
|
||||
private void ButtonMouseOut(UIMouseEvent evt, UIElement listeningElement) => this._buttonLabel.SetText("");
|
||||
|
||||
private void CloudButtonClick(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
if (this._data.IsCloudSave)
|
||||
this._data.MoveToLocal();
|
||||
else
|
||||
this._data.MoveToCloud();
|
||||
((UIImageButton) evt.Target).SetImage(this._data.IsCloudSave ? this._buttonCloudActiveTexture : this._buttonCloudInactiveTexture);
|
||||
if (this._data.IsCloudSave)
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.MoveOffCloud"));
|
||||
else
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.MoveToCloud"));
|
||||
}
|
||||
|
||||
private void DeleteButtonClick(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
for (int index = 0; index < Main.WorldList.Count; ++index)
|
||||
{
|
||||
if (Main.WorldList[index] == this._data)
|
||||
{
|
||||
Main.PlaySound(10);
|
||||
Main.selectedWorld = index;
|
||||
Main.menuMode = 9;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void PlayGame(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
if (listeningElement != evt.Target)
|
||||
return;
|
||||
this._data.SetAsActive();
|
||||
Main.PlaySound(10);
|
||||
Main.GetInputText("");
|
||||
Main.menuMode = !Main.menuMultiplayer || SocialAPI.Network == null ? (!Main.menuMultiplayer ? 10 : 30) : 889;
|
||||
if (Main.menuMultiplayer)
|
||||
return;
|
||||
WorldGen.playWorld();
|
||||
}
|
||||
|
||||
private void FavoriteButtonClick(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
this._data.ToggleFavorite();
|
||||
((UIImageButton) evt.Target).SetImage(this._data.IsFavorite ? this._buttonFavoriteActiveTexture : this._buttonFavoriteInactiveTexture);
|
||||
((UIImageButton) evt.Target).SetVisibility(1f, this._data.IsFavorite ? 0.8f : 0.4f);
|
||||
if (this._data.IsFavorite)
|
||||
{
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.Unfavorite"));
|
||||
this.RemoveChild((UIElement) this._deleteButton);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.Favorite"));
|
||||
this.Append((UIElement) this._deleteButton);
|
||||
}
|
||||
if (!(this.Parent.Parent is UIList parent))
|
||||
return;
|
||||
parent.UpdateOrder();
|
||||
}
|
||||
|
||||
private void SeedButtonClick(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
((Platform) Platform.Current).Clipboard = this._data.SeedText;
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.SeedCopied"));
|
||||
}
|
||||
|
||||
public override int CompareTo(object obj)
|
||||
{
|
||||
if (!(obj is UIWorldListItem uiWorldListItem))
|
||||
return base.CompareTo(obj);
|
||||
if (this.IsFavorite && !uiWorldListItem.IsFavorite)
|
||||
return -1;
|
||||
if (!this.IsFavorite && uiWorldListItem.IsFavorite)
|
||||
return 1;
|
||||
return this._data.Name.CompareTo(uiWorldListItem._data.Name) != 0 ? this._data.Name.CompareTo(uiWorldListItem._data.Name) : this._data.GetFileName().CompareTo(uiWorldListItem._data.GetFileName());
|
||||
}
|
||||
|
||||
public override void MouseOver(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseOver(evt);
|
||||
this.BackgroundColor = new Color(73, 94, 171);
|
||||
this.BorderColor = new Color(89, 116, 213);
|
||||
}
|
||||
|
||||
public override void MouseOut(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseOut(evt);
|
||||
this.BackgroundColor = new Color(63, 82, 151) * 0.7f;
|
||||
this.BorderColor = new Color(89, 116, 213) * 0.7f;
|
||||
}
|
||||
|
||||
private void DrawPanel(SpriteBatch spriteBatch, Vector2 position, float width)
|
||||
{
|
||||
spriteBatch.Draw(this._innerPanelTexture, position, new Rectangle?(new Rectangle(0, 0, 8, this._innerPanelTexture.Height)), Color.White);
|
||||
spriteBatch.Draw(this._innerPanelTexture, new Vector2(position.X + 8f, position.Y), new Rectangle?(new Rectangle(8, 0, 8, this._innerPanelTexture.Height)), Color.White, 0.0f, Vector2.Zero, new Vector2((float) (((double) width - 16.0) / 8.0), 1f), SpriteEffects.None, 0.0f);
|
||||
spriteBatch.Draw(this._innerPanelTexture, new Vector2((float) ((double) position.X + (double) width - 8.0), position.Y), new Rectangle?(new Rectangle(16, 0, 8, this._innerPanelTexture.Height)), Color.White);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
base.DrawSelf(spriteBatch);
|
||||
CalculatedStyle innerDimensions = this.GetInnerDimensions();
|
||||
CalculatedStyle dimensions = this._worldIcon.GetDimensions();
|
||||
float x1 = dimensions.X + dimensions.Width;
|
||||
Color color = this._data.IsValid ? Color.White : Color.Red;
|
||||
Utils.DrawBorderString(spriteBatch, this._data.Name, new Vector2(x1 + 6f, dimensions.Y - 2f), color);
|
||||
spriteBatch.Draw(this._dividerTexture, new Vector2(x1, innerDimensions.Y + 21f), new Rectangle?(), Color.White, 0.0f, Vector2.Zero, new Vector2((float) (((double) this.GetDimensions().X + (double) this.GetDimensions().Width - (double) x1) / 8.0), 1f), SpriteEffects.None, 0.0f);
|
||||
Vector2 position = new Vector2(x1 + 6f, innerDimensions.Y + 29f);
|
||||
float width1 = 100f;
|
||||
this.DrawPanel(spriteBatch, position, width1);
|
||||
string text = this._data.IsExpertMode ? Language.GetTextValue("UI.Expert") : Language.GetTextValue("UI.Normal");
|
||||
float x2 = Main.fontMouseText.MeasureString(text).X;
|
||||
float x3 = (float) ((double) width1 * 0.5 - (double) x2 * 0.5);
|
||||
Utils.DrawBorderString(spriteBatch, text, position + new Vector2(x3, 3f), this._data.IsExpertMode ? new Color(217, 143, 244) : Color.White);
|
||||
position.X += width1 + 5f;
|
||||
float width2 = 150f;
|
||||
if (!GameCulture.English.IsActive)
|
||||
width2 += 40f;
|
||||
this.DrawPanel(spriteBatch, position, width2);
|
||||
string textValue1 = Language.GetTextValue("UI.WorldSizeFormat", (object) this._data.WorldSizeName);
|
||||
float x4 = Main.fontMouseText.MeasureString(textValue1).X;
|
||||
float x5 = (float) ((double) width2 * 0.5 - (double) x4 * 0.5);
|
||||
Utils.DrawBorderString(spriteBatch, textValue1, position + new Vector2(x5, 3f), Color.White);
|
||||
position.X += width2 + 5f;
|
||||
float width3 = innerDimensions.X + innerDimensions.Width - position.X;
|
||||
this.DrawPanel(spriteBatch, position, width3);
|
||||
string textValue2 = Language.GetTextValue("UI.WorldCreatedFormat", !GameCulture.English.IsActive ? (object) this._data.CreationTime.ToShortDateString() : (object) this._data.CreationTime.ToString("d MMMM yyyy"));
|
||||
float x6 = Main.fontMouseText.MeasureString(textValue2).X;
|
||||
float x7 = (float) ((double) width3 * 0.5 - (double) x6 * 0.5);
|
||||
Utils.DrawBorderString(spriteBatch, textValue2, position + new Vector2(x7, 3f), Color.White);
|
||||
position.X += width3 + 5f;
|
||||
}
|
||||
}
|
||||
}
|
800
GameContent/UI/EmoteBubble.cs
Normal file
800
GameContent/UI/EmoteBubble.cs
Normal file
|
@ -0,0 +1,800 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.EmoteBubble
|
||||
// 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.Events;
|
||||
using Terraria.ID;
|
||||
|
||||
namespace Terraria.GameContent.UI
|
||||
{
|
||||
public class EmoteBubble
|
||||
{
|
||||
private static int[] CountNPCs = new int[580];
|
||||
public static Dictionary<int, EmoteBubble> byID = new Dictionary<int, EmoteBubble>();
|
||||
private static List<int> toClean = new List<int>();
|
||||
public static int NextID;
|
||||
public int ID;
|
||||
public WorldUIAnchor anchor;
|
||||
public int lifeTime;
|
||||
public int lifeTimeStart;
|
||||
public int emote;
|
||||
public int metadata;
|
||||
private const int frameSpeed = 8;
|
||||
public int frameCounter;
|
||||
public int frame;
|
||||
|
||||
public static void UpdateAll()
|
||||
{
|
||||
lock (EmoteBubble.byID)
|
||||
{
|
||||
EmoteBubble.toClean.Clear();
|
||||
foreach (KeyValuePair<int, EmoteBubble> keyValuePair in EmoteBubble.byID)
|
||||
{
|
||||
keyValuePair.Value.Update();
|
||||
if (keyValuePair.Value.lifeTime <= 0)
|
||||
EmoteBubble.toClean.Add(keyValuePair.Key);
|
||||
}
|
||||
foreach (int key in EmoteBubble.toClean)
|
||||
EmoteBubble.byID.Remove(key);
|
||||
EmoteBubble.toClean.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
public static void DrawAll(SpriteBatch sb)
|
||||
{
|
||||
lock (EmoteBubble.byID)
|
||||
{
|
||||
foreach (KeyValuePair<int, EmoteBubble> keyValuePair in EmoteBubble.byID)
|
||||
keyValuePair.Value.Draw(sb);
|
||||
}
|
||||
}
|
||||
|
||||
public static Tuple<int, int> SerializeNetAnchor(WorldUIAnchor anch)
|
||||
{
|
||||
if (anch.type != WorldUIAnchor.AnchorType.Entity)
|
||||
return Tuple.Create<int, int>(0, 0);
|
||||
int num = 0;
|
||||
if (anch.entity is NPC)
|
||||
num = 0;
|
||||
else if (anch.entity is Player)
|
||||
num = 1;
|
||||
else if (anch.entity is Projectile)
|
||||
num = 2;
|
||||
return Tuple.Create<int, int>(num, anch.entity.whoAmI);
|
||||
}
|
||||
|
||||
public static WorldUIAnchor DeserializeNetAnchor(int type, int meta)
|
||||
{
|
||||
if (type == 0)
|
||||
return new WorldUIAnchor((Entity) Main.npc[meta]);
|
||||
if (type == 1)
|
||||
return new WorldUIAnchor((Entity) Main.player[meta]);
|
||||
if (type == 2)
|
||||
return new WorldUIAnchor((Entity) Main.projectile[meta]);
|
||||
throw new Exception("How did you end up getting this?");
|
||||
}
|
||||
|
||||
public static int AssignNewID() => EmoteBubble.NextID++;
|
||||
|
||||
public static int NewBubble(int emoticon, WorldUIAnchor bubbleAnchor, int time)
|
||||
{
|
||||
EmoteBubble emoteBubble = new EmoteBubble(emoticon, bubbleAnchor, time)
|
||||
{
|
||||
ID = EmoteBubble.AssignNewID()
|
||||
};
|
||||
EmoteBubble.byID[emoteBubble.ID] = emoteBubble;
|
||||
if (Main.netMode == 2)
|
||||
{
|
||||
Tuple<int, int> tuple = EmoteBubble.SerializeNetAnchor(bubbleAnchor);
|
||||
NetMessage.SendData(91, number: emoteBubble.ID, number2: ((float) tuple.Item1), number3: ((float) tuple.Item2), number4: ((float) time), number5: emoticon);
|
||||
}
|
||||
return emoteBubble.ID;
|
||||
}
|
||||
|
||||
public static int NewBubbleNPC(WorldUIAnchor bubbleAnchor, int time, WorldUIAnchor other = null)
|
||||
{
|
||||
EmoteBubble emoteBubble = new EmoteBubble(0, bubbleAnchor, time)
|
||||
{
|
||||
ID = EmoteBubble.AssignNewID()
|
||||
};
|
||||
EmoteBubble.byID[emoteBubble.ID] = emoteBubble;
|
||||
emoteBubble.PickNPCEmote(other);
|
||||
if (Main.netMode == 2)
|
||||
{
|
||||
Tuple<int, int> tuple = EmoteBubble.SerializeNetAnchor(bubbleAnchor);
|
||||
NetMessage.SendData(91, number: emoteBubble.ID, number2: ((float) tuple.Item1), number3: ((float) tuple.Item2), number4: ((float) time), number5: emoteBubble.emote, number6: emoteBubble.metadata);
|
||||
}
|
||||
return emoteBubble.ID;
|
||||
}
|
||||
|
||||
public EmoteBubble(int emotion, WorldUIAnchor bubbleAnchor, int time = 180)
|
||||
{
|
||||
this.anchor = bubbleAnchor;
|
||||
this.emote = emotion;
|
||||
this.lifeTime = time;
|
||||
this.lifeTimeStart = time;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (--this.lifeTime <= 0 || ++this.frameCounter < 8)
|
||||
return;
|
||||
this.frameCounter = 0;
|
||||
if (++this.frame < 2)
|
||||
return;
|
||||
this.frame = 0;
|
||||
}
|
||||
|
||||
private void Draw(SpriteBatch sb)
|
||||
{
|
||||
Texture2D texture2D = Main.extraTexture[48];
|
||||
SpriteEffects effect = SpriteEffects.None;
|
||||
Vector2 vector2 = this.GetPosition(out effect);
|
||||
bool flag = this.lifeTime < 6 || this.lifeTimeStart - this.lifeTime < 6;
|
||||
Rectangle rectangle = texture2D.Frame(8, 33, flag ? 0 : 1);
|
||||
Vector2 origin = new Vector2((float) (rectangle.Width / 2), (float) rectangle.Height);
|
||||
if ((double) Main.player[Main.myPlayer].gravDir == -1.0)
|
||||
{
|
||||
origin.Y = 0.0f;
|
||||
effect |= SpriteEffects.FlipVertically;
|
||||
vector2 = Main.ReverseGravitySupport(vector2);
|
||||
}
|
||||
sb.Draw(texture2D, vector2, new Rectangle?(rectangle), Color.White, 0.0f, origin, 1f, effect, 0.0f);
|
||||
if (flag)
|
||||
return;
|
||||
if (this.emote >= 0)
|
||||
{
|
||||
if (this.emote == 87)
|
||||
effect = SpriteEffects.None;
|
||||
sb.Draw(texture2D, vector2, new Rectangle?(texture2D.Frame(8, 35, this.emote * 2 % 8 + this.frame, 1 + this.emote / 4)), Color.White, 0.0f, origin, 1f, effect, 0.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.emote != -1)
|
||||
return;
|
||||
Texture2D texture = Main.npcHeadTexture[this.metadata];
|
||||
float scale = 1f;
|
||||
if ((double) texture.Width / 22.0 > 1.0)
|
||||
scale = 22f / (float) texture.Width;
|
||||
if ((double) texture.Height / 16.0 > 1.0 / (double) scale)
|
||||
scale = 16f / (float) texture.Height;
|
||||
sb.Draw(texture, vector2 + new Vector2(effect.HasFlag((Enum) SpriteEffects.FlipHorizontally) ? 1f : -1f, (float) (-rectangle.Height + 3)), new Rectangle?(), Color.White, 0.0f, new Vector2((float) (texture.Width / 2), 0.0f), scale, effect, 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
private Vector2 GetPosition(out SpriteEffects effect)
|
||||
{
|
||||
switch (this.anchor.type)
|
||||
{
|
||||
case WorldUIAnchor.AnchorType.Entity:
|
||||
effect = this.anchor.entity.direction == -1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
|
||||
return this.anchor.entity.Top + new Vector2((float) (-this.anchor.entity.direction * this.anchor.entity.width) * 0.75f, 2f) - Main.screenPosition;
|
||||
case WorldUIAnchor.AnchorType.Tile:
|
||||
effect = SpriteEffects.None;
|
||||
return this.anchor.pos - Main.screenPosition + new Vector2(0.0f, (float) (-(double) this.anchor.size.Y / 2.0));
|
||||
case WorldUIAnchor.AnchorType.Pos:
|
||||
effect = SpriteEffects.None;
|
||||
return this.anchor.pos - Main.screenPosition;
|
||||
default:
|
||||
effect = SpriteEffects.None;
|
||||
return new Vector2((float) Main.screenWidth, (float) Main.screenHeight) / 2f;
|
||||
}
|
||||
}
|
||||
|
||||
public void PickNPCEmote(WorldUIAnchor other = null)
|
||||
{
|
||||
Player plr = Main.player[(int) Player.FindClosest(this.anchor.entity.Center, 0, 0)];
|
||||
List<int> list = new List<int>();
|
||||
bool flag = false;
|
||||
for (int index = 0; index < 200; ++index)
|
||||
{
|
||||
if (Main.npc[index].active && Main.npc[index].boss)
|
||||
flag = true;
|
||||
}
|
||||
if (!flag)
|
||||
{
|
||||
if (Main.rand.Next(3) == 0)
|
||||
this.ProbeTownNPCs(list);
|
||||
if (Main.rand.Next(3) == 0)
|
||||
this.ProbeEmotions(list);
|
||||
if (Main.rand.Next(3) == 0)
|
||||
this.ProbeBiomes(list, plr);
|
||||
if (Main.rand.Next(2) == 0)
|
||||
this.ProbeCritters(list);
|
||||
if (Main.rand.Next(2) == 0)
|
||||
this.ProbeItems(list, plr);
|
||||
if (Main.rand.Next(5) == 0)
|
||||
this.ProbeBosses(list);
|
||||
if (Main.rand.Next(2) == 0)
|
||||
this.ProbeDebuffs(list, plr);
|
||||
if (Main.rand.Next(2) == 0)
|
||||
this.ProbeEvents(list);
|
||||
if (Main.rand.Next(2) == 0)
|
||||
this.ProbeWeather(list, plr);
|
||||
this.ProbeExceptions(list, plr, other);
|
||||
}
|
||||
else
|
||||
this.ProbeCombat(list);
|
||||
if (list.Count <= 0)
|
||||
return;
|
||||
this.emote = list[Main.rand.Next(list.Count)];
|
||||
}
|
||||
|
||||
private void ProbeCombat(List<int> list)
|
||||
{
|
||||
list.Add(16);
|
||||
list.Add(1);
|
||||
list.Add(2);
|
||||
list.Add(91);
|
||||
list.Add(93);
|
||||
list.Add(84);
|
||||
list.Add(84);
|
||||
}
|
||||
|
||||
private void ProbeWeather(List<int> list, Player plr)
|
||||
{
|
||||
if ((double) Main.cloudBGActive > 0.0)
|
||||
list.Add(96);
|
||||
if ((double) Main.cloudAlpha > 0.0)
|
||||
{
|
||||
if (!Main.dayTime)
|
||||
list.Add(5);
|
||||
list.Add(4);
|
||||
if (plr.ZoneSnow)
|
||||
list.Add(98);
|
||||
if ((double) plr.position.X < 4000.0 || (double) plr.position.X > (double) (Main.maxTilesX * 16 - 4000) && (double) plr.position.Y < Main.worldSurface / 16.0)
|
||||
list.Add(97);
|
||||
}
|
||||
else
|
||||
list.Add(95);
|
||||
if (!plr.ZoneHoly)
|
||||
return;
|
||||
list.Add(6);
|
||||
}
|
||||
|
||||
private void ProbeEvents(List<int> list)
|
||||
{
|
||||
if (BirthdayParty.PartyIsUp && Main.rand.Next(3) == 0)
|
||||
list.Add(Utils.SelectRandom<int>(Main.rand, (int) sbyte.MaxValue, 128, 129, 126));
|
||||
if (Main.bloodMoon || !Main.dayTime && Main.rand.Next(4) == 0)
|
||||
list.Add(18);
|
||||
if (Main.eclipse || Main.hardMode && Main.rand.Next(4) == 0)
|
||||
list.Add(19);
|
||||
if ((!Main.dayTime || WorldGen.spawnMeteor) && WorldGen.shadowOrbSmashed)
|
||||
list.Add(99);
|
||||
if (Main.pumpkinMoon || (NPC.downedHalloweenKing || NPC.downedHalloweenTree) && !Main.dayTime)
|
||||
list.Add(20);
|
||||
if (Main.snowMoon || (NPC.downedChristmasIceQueen || NPC.downedChristmasSantank || NPC.downedChristmasTree) && !Main.dayTime)
|
||||
list.Add(21);
|
||||
if (!DD2Event.Ongoing && !DD2Event.DownedInvasionAnyDifficulty)
|
||||
return;
|
||||
list.Add(133);
|
||||
}
|
||||
|
||||
private void ProbeDebuffs(List<int> list, Player plr)
|
||||
{
|
||||
if ((double) plr.Center.Y > (double) (Main.maxTilesY * 16 - 3200) || plr.onFire || ((NPC) this.anchor.entity).onFire || plr.onFire2)
|
||||
list.Add(9);
|
||||
if (Main.rand.Next(2) == 0)
|
||||
list.Add(11);
|
||||
if (plr.poisoned || ((NPC) this.anchor.entity).poisoned || plr.ZoneJungle)
|
||||
list.Add(8);
|
||||
if (plr.inventory[plr.selectedItem].type != 215 && Main.rand.Next(3) != 0)
|
||||
return;
|
||||
list.Add(10);
|
||||
}
|
||||
|
||||
private void ProbeItems(List<int> list, Player plr)
|
||||
{
|
||||
list.Add(7);
|
||||
list.Add(73);
|
||||
list.Add(74);
|
||||
list.Add(75);
|
||||
list.Add(78);
|
||||
list.Add(90);
|
||||
if (plr.statLife >= plr.statLifeMax2 / 2)
|
||||
return;
|
||||
list.Add(84);
|
||||
}
|
||||
|
||||
private void ProbeTownNPCs(List<int> list)
|
||||
{
|
||||
for (int index = 0; index < 580; ++index)
|
||||
EmoteBubble.CountNPCs[index] = 0;
|
||||
for (int index = 0; index < 200; ++index)
|
||||
{
|
||||
if (Main.npc[index].active)
|
||||
++EmoteBubble.CountNPCs[Main.npc[index].type];
|
||||
}
|
||||
int type = ((NPC) this.anchor.entity).type;
|
||||
for (int index = 0; index < 580; ++index)
|
||||
{
|
||||
if (NPCID.Sets.FaceEmote[index] > 0 && EmoteBubble.CountNPCs[index] > 0 && index != type)
|
||||
list.Add(NPCID.Sets.FaceEmote[index]);
|
||||
}
|
||||
}
|
||||
|
||||
private void ProbeBiomes(List<int> list, Player plr)
|
||||
{
|
||||
if ((double) plr.position.Y / 16.0 < Main.worldSurface * 0.45)
|
||||
list.Add(22);
|
||||
else if ((double) plr.position.Y / 16.0 > Main.rockLayer + (double) (Main.maxTilesY / 2) - 100.0)
|
||||
list.Add(31);
|
||||
else if ((double) plr.position.Y / 16.0 > Main.rockLayer)
|
||||
list.Add(30);
|
||||
else if (plr.ZoneHoly)
|
||||
list.Add(27);
|
||||
else if (plr.ZoneCorrupt)
|
||||
list.Add(26);
|
||||
else if (plr.ZoneCrimson)
|
||||
list.Add(25);
|
||||
else if (plr.ZoneJungle)
|
||||
list.Add(24);
|
||||
else if (plr.ZoneSnow)
|
||||
list.Add(32);
|
||||
else if ((double) plr.position.Y / 16.0 < Main.worldSurface && ((double) plr.position.X < 4000.0 || (double) plr.position.X > (double) (16 * (Main.maxTilesX - 250))))
|
||||
list.Add(29);
|
||||
else if (plr.ZoneDesert)
|
||||
list.Add(28);
|
||||
else
|
||||
list.Add(23);
|
||||
}
|
||||
|
||||
private void ProbeCritters(List<int> list)
|
||||
{
|
||||
Vector2 center = this.anchor.entity.Center;
|
||||
float num1 = 1f;
|
||||
float num2 = 1f;
|
||||
if ((double) center.Y < Main.rockLayer * 16.0)
|
||||
num2 = 0.2f;
|
||||
else
|
||||
num1 = 0.2f;
|
||||
if ((double) Main.rand.NextFloat() <= (double) num1)
|
||||
{
|
||||
if (Main.dayTime)
|
||||
{
|
||||
list.Add(13);
|
||||
list.Add(12);
|
||||
list.Add(68);
|
||||
list.Add(62);
|
||||
list.Add(63);
|
||||
list.Add(69);
|
||||
list.Add(70);
|
||||
}
|
||||
if (!Main.dayTime || Main.dayTime && (Main.time < 5400.0 || Main.time > 48600.0))
|
||||
list.Add(61);
|
||||
if (NPC.downedGoblins)
|
||||
list.Add(64);
|
||||
if (NPC.downedFrost)
|
||||
list.Add(66);
|
||||
if (NPC.downedPirates)
|
||||
list.Add(65);
|
||||
if (NPC.downedMartians)
|
||||
list.Add(71);
|
||||
if (WorldGen.crimson)
|
||||
list.Add(67);
|
||||
}
|
||||
if ((double) Main.rand.NextFloat() > (double) num2)
|
||||
return;
|
||||
list.Add(72);
|
||||
list.Add(69);
|
||||
}
|
||||
|
||||
private void ProbeEmotions(List<int> list)
|
||||
{
|
||||
list.Add(0);
|
||||
list.Add(1);
|
||||
list.Add(2);
|
||||
list.Add(3);
|
||||
list.Add(15);
|
||||
list.Add(16);
|
||||
list.Add(17);
|
||||
list.Add(87);
|
||||
list.Add(91);
|
||||
if (!Main.bloodMoon || Main.dayTime)
|
||||
return;
|
||||
int num = Utils.SelectRandom<int>(Main.rand, 16, 1);
|
||||
list.Add(num);
|
||||
list.Add(num);
|
||||
list.Add(num);
|
||||
}
|
||||
|
||||
private void ProbeBosses(List<int> list)
|
||||
{
|
||||
int num = 0;
|
||||
if (!NPC.downedBoss1 && !Main.dayTime || NPC.downedBoss1)
|
||||
num = 1;
|
||||
if (NPC.downedBoss2)
|
||||
num = 2;
|
||||
if (NPC.downedQueenBee || NPC.downedBoss3)
|
||||
num = 3;
|
||||
if (Main.hardMode)
|
||||
num = 4;
|
||||
if (NPC.downedMechBossAny)
|
||||
num = 5;
|
||||
if (NPC.downedPlantBoss)
|
||||
num = 6;
|
||||
if (NPC.downedGolemBoss)
|
||||
num = 7;
|
||||
if (NPC.downedAncientCultist)
|
||||
num = 8;
|
||||
int maxValue = 10;
|
||||
if (NPC.downedMoonlord)
|
||||
maxValue = 1;
|
||||
if (num >= 1 && num <= 2 || num >= 1 && Main.rand.Next(maxValue) == 0)
|
||||
{
|
||||
list.Add(39);
|
||||
if (WorldGen.crimson)
|
||||
list.Add(41);
|
||||
else
|
||||
list.Add(40);
|
||||
list.Add(51);
|
||||
}
|
||||
if (num >= 2 && num <= 3 || num >= 2 && Main.rand.Next(maxValue) == 0)
|
||||
{
|
||||
list.Add(43);
|
||||
list.Add(42);
|
||||
}
|
||||
if (num >= 4 && num <= 5 || num >= 4 && Main.rand.Next(maxValue) == 0)
|
||||
{
|
||||
list.Add(44);
|
||||
list.Add(47);
|
||||
list.Add(45);
|
||||
list.Add(46);
|
||||
}
|
||||
if (num >= 5 && num <= 6 || num >= 5 && Main.rand.Next(maxValue) == 0)
|
||||
{
|
||||
if (!NPC.downedMechBoss1)
|
||||
list.Add(47);
|
||||
if (!NPC.downedMechBoss2)
|
||||
list.Add(45);
|
||||
if (!NPC.downedMechBoss3)
|
||||
list.Add(46);
|
||||
list.Add(48);
|
||||
}
|
||||
if (num == 6 || num >= 6 && Main.rand.Next(maxValue) == 0)
|
||||
{
|
||||
list.Add(48);
|
||||
list.Add(49);
|
||||
list.Add(50);
|
||||
}
|
||||
if (num == 7 || num >= 7 && Main.rand.Next(maxValue) == 0)
|
||||
{
|
||||
list.Add(49);
|
||||
list.Add(50);
|
||||
list.Add(52);
|
||||
}
|
||||
if (num == 8 || num >= 8 && Main.rand.Next(maxValue) == 0)
|
||||
{
|
||||
list.Add(52);
|
||||
list.Add(53);
|
||||
}
|
||||
if (NPC.downedPirates && Main.expertMode)
|
||||
list.Add(59);
|
||||
if (NPC.downedMartians)
|
||||
list.Add(60);
|
||||
if (NPC.downedChristmasIceQueen)
|
||||
list.Add(57);
|
||||
if (NPC.downedChristmasSantank)
|
||||
list.Add(58);
|
||||
if (NPC.downedChristmasTree)
|
||||
list.Add(56);
|
||||
if (NPC.downedHalloweenKing)
|
||||
list.Add(55);
|
||||
if (!NPC.downedHalloweenTree)
|
||||
return;
|
||||
list.Add(54);
|
||||
}
|
||||
|
||||
private void ProbeExceptions(List<int> list, Player plr, WorldUIAnchor other)
|
||||
{
|
||||
NPC entity = (NPC) this.anchor.entity;
|
||||
if (entity.type == 17)
|
||||
{
|
||||
list.Add(80);
|
||||
list.Add(85);
|
||||
list.Add(85);
|
||||
list.Add(85);
|
||||
list.Add(85);
|
||||
}
|
||||
else if (entity.type == 18)
|
||||
{
|
||||
list.Add(73);
|
||||
list.Add(73);
|
||||
list.Add(84);
|
||||
list.Add(75);
|
||||
}
|
||||
else if (entity.type == 19)
|
||||
{
|
||||
if (other != null && ((NPC) other.entity).type == 22)
|
||||
{
|
||||
list.Add(1);
|
||||
list.Add(1);
|
||||
list.Add(93);
|
||||
list.Add(92);
|
||||
}
|
||||
else if (other != null && ((NPC) other.entity).type == 22)
|
||||
{
|
||||
list.Add(1);
|
||||
list.Add(1);
|
||||
list.Add(93);
|
||||
list.Add(92);
|
||||
}
|
||||
else
|
||||
{
|
||||
list.Add(82);
|
||||
list.Add(82);
|
||||
list.Add(85);
|
||||
list.Add(85);
|
||||
list.Add(77);
|
||||
list.Add(93);
|
||||
}
|
||||
}
|
||||
else if (entity.type == 20)
|
||||
{
|
||||
if (list.Contains(121))
|
||||
{
|
||||
list.Add(121);
|
||||
list.Add(121);
|
||||
}
|
||||
list.Add(14);
|
||||
list.Add(14);
|
||||
}
|
||||
else if (entity.type == 22)
|
||||
{
|
||||
if (!Main.bloodMoon)
|
||||
{
|
||||
if (other != null && ((NPC) other.entity).type == 19)
|
||||
{
|
||||
list.Add(1);
|
||||
list.Add(1);
|
||||
list.Add(93);
|
||||
list.Add(92);
|
||||
}
|
||||
else
|
||||
list.Add(79);
|
||||
}
|
||||
if (!Main.dayTime)
|
||||
{
|
||||
list.Add(16);
|
||||
list.Add(16);
|
||||
list.Add(16);
|
||||
}
|
||||
}
|
||||
else if (entity.type == 37)
|
||||
{
|
||||
list.Add(43);
|
||||
list.Add(43);
|
||||
list.Add(43);
|
||||
list.Add(72);
|
||||
list.Add(72);
|
||||
}
|
||||
else if (entity.type == 38)
|
||||
{
|
||||
if (Main.bloodMoon)
|
||||
{
|
||||
list.Add(77);
|
||||
list.Add(77);
|
||||
list.Add(77);
|
||||
list.Add(81);
|
||||
}
|
||||
else
|
||||
{
|
||||
list.Add(77);
|
||||
list.Add(77);
|
||||
list.Add(81);
|
||||
list.Add(81);
|
||||
list.Add(81);
|
||||
list.Add(90);
|
||||
list.Add(90);
|
||||
}
|
||||
}
|
||||
else if (entity.type == 54)
|
||||
{
|
||||
if (Main.bloodMoon)
|
||||
{
|
||||
list.Add(43);
|
||||
list.Add(72);
|
||||
list.Add(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (list.Contains(111))
|
||||
list.Add(111);
|
||||
list.Add(17);
|
||||
}
|
||||
}
|
||||
else if (entity.type == 107)
|
||||
{
|
||||
if (other != null && ((NPC) other.entity).type == 124)
|
||||
{
|
||||
list.Remove(111);
|
||||
list.Add(0);
|
||||
list.Add(0);
|
||||
list.Add(0);
|
||||
list.Add(17);
|
||||
list.Add(17);
|
||||
list.Add(86);
|
||||
list.Add(88);
|
||||
list.Add(88);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (list.Contains(111))
|
||||
{
|
||||
list.Add(111);
|
||||
list.Add(111);
|
||||
list.Add(111);
|
||||
}
|
||||
list.Add(91);
|
||||
list.Add(92);
|
||||
list.Add(91);
|
||||
list.Add(92);
|
||||
}
|
||||
}
|
||||
else if (entity.type == 108)
|
||||
{
|
||||
list.Add(100);
|
||||
list.Add(89);
|
||||
list.Add(11);
|
||||
}
|
||||
if (entity.type == 124)
|
||||
{
|
||||
if (other != null && ((NPC) other.entity).type == 107)
|
||||
{
|
||||
list.Remove(111);
|
||||
list.Add(0);
|
||||
list.Add(0);
|
||||
list.Add(0);
|
||||
list.Add(17);
|
||||
list.Add(17);
|
||||
list.Add(88);
|
||||
list.Add(88);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (list.Contains(109))
|
||||
{
|
||||
list.Add(109);
|
||||
list.Add(109);
|
||||
list.Add(109);
|
||||
}
|
||||
if (list.Contains(108))
|
||||
{
|
||||
list.Remove(108);
|
||||
if (Main.hardMode)
|
||||
{
|
||||
list.Add(108);
|
||||
list.Add(108);
|
||||
}
|
||||
else
|
||||
{
|
||||
list.Add(106);
|
||||
list.Add(106);
|
||||
}
|
||||
}
|
||||
list.Add(43);
|
||||
list.Add(2);
|
||||
}
|
||||
}
|
||||
else if (entity.type == 142)
|
||||
{
|
||||
list.Add(32);
|
||||
list.Add(66);
|
||||
list.Add(17);
|
||||
list.Add(15);
|
||||
list.Add(15);
|
||||
}
|
||||
else if (entity.type == 160)
|
||||
{
|
||||
list.Add(10);
|
||||
list.Add(89);
|
||||
list.Add(94);
|
||||
list.Add(8);
|
||||
}
|
||||
else if (entity.type == 178)
|
||||
{
|
||||
list.Add(83);
|
||||
list.Add(83);
|
||||
}
|
||||
else if (entity.type == 207)
|
||||
{
|
||||
list.Add(28);
|
||||
list.Add(95);
|
||||
list.Add(93);
|
||||
}
|
||||
else if (entity.type == 208)
|
||||
{
|
||||
list.Add(94);
|
||||
list.Add(17);
|
||||
list.Add(3);
|
||||
list.Add(77);
|
||||
}
|
||||
else if (entity.type == 209)
|
||||
{
|
||||
list.Add(48);
|
||||
list.Add(83);
|
||||
list.Add(5);
|
||||
list.Add(5);
|
||||
}
|
||||
else if (entity.type == 227)
|
||||
{
|
||||
list.Add(63);
|
||||
list.Add(68);
|
||||
}
|
||||
else if (entity.type == 228)
|
||||
{
|
||||
list.Add(24);
|
||||
list.Add(24);
|
||||
list.Add(95);
|
||||
list.Add(8);
|
||||
}
|
||||
else if (entity.type == 229)
|
||||
{
|
||||
list.Add(93);
|
||||
list.Add(9);
|
||||
list.Add(65);
|
||||
list.Add(120);
|
||||
list.Add(59);
|
||||
}
|
||||
else if (entity.type == 353)
|
||||
{
|
||||
if (list.Contains(104))
|
||||
{
|
||||
list.Add(104);
|
||||
list.Add(104);
|
||||
}
|
||||
if (list.Contains(111))
|
||||
{
|
||||
list.Add(111);
|
||||
list.Add(111);
|
||||
}
|
||||
list.Add(67);
|
||||
}
|
||||
else if (entity.type == 368)
|
||||
{
|
||||
list.Add(85);
|
||||
list.Add(7);
|
||||
list.Add(79);
|
||||
}
|
||||
else if (entity.type == 369)
|
||||
{
|
||||
if (Main.bloodMoon)
|
||||
return;
|
||||
list.Add(70);
|
||||
list.Add(70);
|
||||
list.Add(76);
|
||||
list.Add(76);
|
||||
list.Add(79);
|
||||
list.Add(79);
|
||||
if ((double) entity.position.Y >= Main.worldSurface)
|
||||
return;
|
||||
list.Add(29);
|
||||
}
|
||||
else if (entity.type == 453)
|
||||
{
|
||||
list.Add(72);
|
||||
list.Add(69);
|
||||
list.Add(87);
|
||||
list.Add(3);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (entity.type != 441)
|
||||
return;
|
||||
list.Add(100);
|
||||
list.Add(100);
|
||||
list.Add(1);
|
||||
list.Add(1);
|
||||
list.Add(1);
|
||||
list.Add(87);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
148
GameContent/UI/EmoteID.cs
Normal file
148
GameContent/UI/EmoteID.cs
Normal file
|
@ -0,0 +1,148 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.EmoteID
|
||||
// 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.GameContent.UI
|
||||
{
|
||||
public class EmoteID
|
||||
{
|
||||
public const int ItemDisplay = -1;
|
||||
public const int Count = 126;
|
||||
public const int RPSWinScissors = 33;
|
||||
public const int RPSWinRock = 34;
|
||||
public const int RPSWinPaper = 35;
|
||||
public const int RPSScissors = 36;
|
||||
public const int RPSRock = 37;
|
||||
public const int RPSPaper = 38;
|
||||
public const int WeatherRain = 4;
|
||||
public const int WeatherLightning = 5;
|
||||
public const int WeatherRainbow = 6;
|
||||
public const int WeatherSunny = 95;
|
||||
public const int WeatherCloudy = 96;
|
||||
public const int WeatherStorming = 97;
|
||||
public const int WeatherSnowstorm = 98;
|
||||
public const int EventBloodmoon = 18;
|
||||
public const int EventEclipse = 19;
|
||||
public const int EventPumpkin = 20;
|
||||
public const int EventSnow = 21;
|
||||
public const int EventMeteor = 99;
|
||||
public const int ItemRing = 7;
|
||||
public const int ItemLifePotion = 73;
|
||||
public const int ItemManaPotion = 74;
|
||||
public const int ItemSoup = 75;
|
||||
public const int ItemCookedFish = 76;
|
||||
public const int ItemAle = 77;
|
||||
public const int ItemSword = 78;
|
||||
public const int ItemFishingRod = 79;
|
||||
public const int ItemBugNet = 80;
|
||||
public const int ItemDynamite = 81;
|
||||
public const int ItemMinishark = 82;
|
||||
public const int ItemCog = 83;
|
||||
public const int ItemTombstone = 84;
|
||||
public const int ItemGoldpile = 85;
|
||||
public const int ItemDiamondRing = 86;
|
||||
public const int ItemPickaxe = 90;
|
||||
public const int DebuffPoison = 8;
|
||||
public const int DebuffBurn = 9;
|
||||
public const int DebuffSilence = 10;
|
||||
public const int DebuffCurse = 11;
|
||||
public const int CritterBee = 12;
|
||||
public const int CritterSlime = 13;
|
||||
public const int CritterZombie = 61;
|
||||
public const int CritterBunny = 62;
|
||||
public const int CritterButterfly = 63;
|
||||
public const int CritterGoblin = 64;
|
||||
public const int CritterPirate = 65;
|
||||
public const int CritterSnowman = 66;
|
||||
public const int CritterSpider = 67;
|
||||
public const int CritterBird = 68;
|
||||
public const int CritterMouse = 69;
|
||||
public const int CritterGoldfish = 70;
|
||||
public const int CritterMartian = 71;
|
||||
public const int CritterSkeleton = 72;
|
||||
public const int BossEoC = 39;
|
||||
public const int BossEoW = 40;
|
||||
public const int BossBoC = 41;
|
||||
public const int BossKingSlime = 51;
|
||||
public const int BossQueenBee = 42;
|
||||
public const int BossSkeletron = 43;
|
||||
public const int BossWoF = 44;
|
||||
public const int BossDestroyer = 45;
|
||||
public const int BossSkeletronPrime = 46;
|
||||
public const int BossTwins = 47;
|
||||
public const int BossPlantera = 48;
|
||||
public const int BossGolem = 49;
|
||||
public const int BossFishron = 50;
|
||||
public const int BossCultist = 52;
|
||||
public const int BossMoonmoon = 53;
|
||||
public const int BossMourningWood = 54;
|
||||
public const int BossPumpking = 55;
|
||||
public const int BossEverscream = 56;
|
||||
public const int BossIceQueen = 57;
|
||||
public const int BossSantank = 58;
|
||||
public const int BossPirateship = 59;
|
||||
public const int BossMartianship = 60;
|
||||
public const int EmotionLove = 0;
|
||||
public const int EmotionAnger = 1;
|
||||
public const int EmotionCry = 2;
|
||||
public const int EmotionAlert = 3;
|
||||
public const int EmoteLaugh = 15;
|
||||
public const int EmoteFear = 16;
|
||||
public const int EmoteNote = 17;
|
||||
public const int EmoteConfused = 87;
|
||||
public const int EmoteKiss = 88;
|
||||
public const int EmoteSleep = 89;
|
||||
public const int EmoteRun = 91;
|
||||
public const int EmoteKick = 92;
|
||||
public const int EmoteFight = 93;
|
||||
public const int EmoteEating = 94;
|
||||
public const int MiscTree = 14;
|
||||
public const int MiscFire = 100;
|
||||
public const int BiomeSky = 22;
|
||||
public const int BiomeOtherworld = 23;
|
||||
public const int BiomeJungle = 24;
|
||||
public const int BiomeCrimson = 25;
|
||||
public const int BiomeCorruption = 26;
|
||||
public const int BiomeHallow = 27;
|
||||
public const int BiomeDesert = 28;
|
||||
public const int BiomeBeach = 29;
|
||||
public const int BiomeRocklayer = 30;
|
||||
public const int BiomeLavalayer = 31;
|
||||
public const int BiomeSnow = 32;
|
||||
public const int TownMerchant = 101;
|
||||
public const int TownNurse = 102;
|
||||
public const int TownArmsDealer = 103;
|
||||
public const int TownDryad = 104;
|
||||
public const int TownGuide = 105;
|
||||
public const int TownOldman = 106;
|
||||
public const int TownDemolitionist = 107;
|
||||
public const int TownClothier = 108;
|
||||
public const int TownGoblinTinkerer = 109;
|
||||
public const int TownWizard = 110;
|
||||
public const int TownMechanic = 111;
|
||||
public const int TownSanta = 112;
|
||||
public const int TownTruffle = 113;
|
||||
public const int TownSteampunker = 114;
|
||||
public const int TownDyeTrader = 115;
|
||||
public const int TownPartyGirl = 116;
|
||||
public const int TownCyborg = 117;
|
||||
public const int TownPainter = 118;
|
||||
public const int TownWitchDoctor = 119;
|
||||
public const int TownPirate = 120;
|
||||
public const int TownStylist = 121;
|
||||
public const int TownTravellingMerchant = 122;
|
||||
public const int TownAngler = 123;
|
||||
public const int TownSkeletonMerchant = 124;
|
||||
public const int TownTaxCollector = 125;
|
||||
public const int PartyPresent = 126;
|
||||
public const int PartyBalloons = 127;
|
||||
public const int PartyCake = 128;
|
||||
public const int PartyHats = 129;
|
||||
public const int TownBartender = 130;
|
||||
public const int ItemBeer = 131;
|
||||
public const int ItemDefenderMedal = 132;
|
||||
public const int EventOldOnesArmy = 133;
|
||||
}
|
||||
}
|
39
GameContent/UI/ItemRarity.cs
Normal file
39
GameContent/UI/ItemRarity.cs
Normal file
|
@ -0,0 +1,39 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.ItemRarity
|
||||
// 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.Collections.Generic;
|
||||
using Terraria.ID;
|
||||
|
||||
namespace Terraria.GameContent.UI
|
||||
{
|
||||
public class ItemRarity
|
||||
{
|
||||
private static Dictionary<int, Color> _rarities = new Dictionary<int, Color>();
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
ItemRarity._rarities.Clear();
|
||||
ItemRarity._rarities.Add(-11, Colors.RarityAmber);
|
||||
ItemRarity._rarities.Add(-1, Colors.RarityTrash);
|
||||
ItemRarity._rarities.Add(1, Colors.RarityBlue);
|
||||
ItemRarity._rarities.Add(2, Colors.RarityGreen);
|
||||
ItemRarity._rarities.Add(3, Colors.RarityOrange);
|
||||
ItemRarity._rarities.Add(4, Colors.RarityRed);
|
||||
ItemRarity._rarities.Add(5, Colors.RarityPink);
|
||||
ItemRarity._rarities.Add(6, Colors.RarityPurple);
|
||||
ItemRarity._rarities.Add(7, Colors.RarityLime);
|
||||
ItemRarity._rarities.Add(8, Colors.RarityYellow);
|
||||
ItemRarity._rarities.Add(9, Colors.RarityCyan);
|
||||
}
|
||||
|
||||
public static Color GetColor(int rarity)
|
||||
{
|
||||
Color color = new Color((int) Main.mouseTextColor, (int) Main.mouseTextColor, (int) Main.mouseTextColor, (int) Main.mouseTextColor);
|
||||
return ItemRarity._rarities.ContainsKey(rarity) ? ItemRarity._rarities[rarity] : color;
|
||||
}
|
||||
}
|
||||
}
|
221
GameContent/UI/States/UIAchievementsMenu.cs
Normal file
221
GameContent/UI/States/UIAchievementsMenu.cs
Normal file
|
@ -0,0 +1,221 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.States.UIAchievementsMenu
|
||||
// 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.GameContent.UI.Elements;
|
||||
using Terraria.GameInput;
|
||||
using Terraria.Graphics;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI;
|
||||
using Terraria.UI.Gamepad;
|
||||
|
||||
namespace Terraria.GameContent.UI.States
|
||||
{
|
||||
public class UIAchievementsMenu : UIState
|
||||
{
|
||||
private UIList _achievementsList;
|
||||
private List<UIAchievementListItem> _achievementElements = new List<UIAchievementListItem>();
|
||||
private List<UIToggleImage> _categoryButtons = new List<UIToggleImage>();
|
||||
private UIElement _backpanel;
|
||||
private UIElement _outerContainer;
|
||||
|
||||
public void InitializePage()
|
||||
{
|
||||
this.RemoveAllChildren();
|
||||
this._categoryButtons.Clear();
|
||||
this._achievementElements.Clear();
|
||||
this._achievementsList = (UIList) null;
|
||||
bool largeForOtherLanguages = true;
|
||||
int num = largeForOtherLanguages.ToInt() * 100;
|
||||
UIElement element1 = new UIElement();
|
||||
element1.Width.Set(0.0f, 0.8f);
|
||||
element1.MaxWidth.Set(800f + (float) num, 0.0f);
|
||||
element1.MinWidth.Set(600f + (float) num, 0.0f);
|
||||
element1.Top.Set(220f, 0.0f);
|
||||
element1.Height.Set(-220f, 1f);
|
||||
element1.HAlign = 0.5f;
|
||||
this._outerContainer = element1;
|
||||
this.Append(element1);
|
||||
UIPanel uiPanel = new UIPanel();
|
||||
uiPanel.Width.Set(0.0f, 1f);
|
||||
uiPanel.Height.Set(-110f, 1f);
|
||||
uiPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f;
|
||||
uiPanel.PaddingTop = 0.0f;
|
||||
element1.Append((UIElement) uiPanel);
|
||||
this._achievementsList = new UIList();
|
||||
this._achievementsList.Width.Set(-25f, 1f);
|
||||
this._achievementsList.Height.Set(-50f, 1f);
|
||||
this._achievementsList.Top.Set(50f, 0.0f);
|
||||
this._achievementsList.ListPadding = 5f;
|
||||
uiPanel.Append((UIElement) this._achievementsList);
|
||||
UITextPanel<LocalizedText> uiTextPanel1 = new UITextPanel<LocalizedText>(Language.GetText("UI.Achievements"), large: true);
|
||||
uiTextPanel1.HAlign = 0.5f;
|
||||
uiTextPanel1.Top.Set(-33f, 0.0f);
|
||||
uiTextPanel1.SetPadding(13f);
|
||||
uiTextPanel1.BackgroundColor = new Color(73, 94, 171);
|
||||
element1.Append((UIElement) uiTextPanel1);
|
||||
UITextPanel<LocalizedText> uiTextPanel2 = new UITextPanel<LocalizedText>(Language.GetText("UI.Back"), 0.7f, true);
|
||||
uiTextPanel2.Width.Set(-10f, 0.5f);
|
||||
uiTextPanel2.Height.Set(50f, 0.0f);
|
||||
uiTextPanel2.VAlign = 1f;
|
||||
uiTextPanel2.HAlign = 0.5f;
|
||||
uiTextPanel2.Top.Set(-45f, 0.0f);
|
||||
uiTextPanel2.OnMouseOver += new UIElement.MouseEvent(this.FadedMouseOver);
|
||||
uiTextPanel2.OnMouseOut += new UIElement.MouseEvent(this.FadedMouseOut);
|
||||
uiTextPanel2.OnClick += new UIElement.MouseEvent(this.GoBackClick);
|
||||
element1.Append((UIElement) uiTextPanel2);
|
||||
this._backpanel = (UIElement) uiTextPanel2;
|
||||
List<Achievement> achievementsList = Main.Achievements.CreateAchievementsList();
|
||||
for (int index = 0; index < achievementsList.Count; ++index)
|
||||
{
|
||||
UIAchievementListItem achievementListItem = new UIAchievementListItem(achievementsList[index], largeForOtherLanguages);
|
||||
this._achievementsList.Add((UIElement) achievementListItem);
|
||||
this._achievementElements.Add(achievementListItem);
|
||||
}
|
||||
UIScrollbar scrollbar = new UIScrollbar();
|
||||
scrollbar.SetView(100f, 1000f);
|
||||
scrollbar.Height.Set(-50f, 1f);
|
||||
scrollbar.Top.Set(50f, 0.0f);
|
||||
scrollbar.HAlign = 1f;
|
||||
uiPanel.Append((UIElement) scrollbar);
|
||||
this._achievementsList.SetScrollbar(scrollbar);
|
||||
UIElement element2 = new UIElement();
|
||||
element2.Width.Set(0.0f, 1f);
|
||||
element2.Height.Set(32f, 0.0f);
|
||||
element2.Top.Set(10f, 0.0f);
|
||||
Texture2D texture = TextureManager.Load("Images/UI/Achievement_Categories");
|
||||
for (int index = 0; index < 4; ++index)
|
||||
{
|
||||
UIToggleImage uiToggleImage = new UIToggleImage(texture, 32, 32, new Point(34 * index, 0), new Point(34 * index, 34));
|
||||
uiToggleImage.Left.Set((float) (index * 36 + 8), 0.0f);
|
||||
uiToggleImage.SetState(true);
|
||||
uiToggleImage.OnClick += new UIElement.MouseEvent(this.FilterList);
|
||||
this._categoryButtons.Add(uiToggleImage);
|
||||
element2.Append((UIElement) uiToggleImage);
|
||||
}
|
||||
uiPanel.Append(element2);
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
base.Draw(spriteBatch);
|
||||
for (int index = 0; index < this._categoryButtons.Count; ++index)
|
||||
{
|
||||
if (this._categoryButtons[index].IsMouseHovering)
|
||||
{
|
||||
string textValue;
|
||||
switch (index)
|
||||
{
|
||||
case -1:
|
||||
textValue = Language.GetTextValue("Achievements.NoCategory");
|
||||
break;
|
||||
case 0:
|
||||
textValue = Language.GetTextValue("Achievements.SlayerCategory");
|
||||
break;
|
||||
case 1:
|
||||
textValue = Language.GetTextValue("Achievements.CollectorCategory");
|
||||
break;
|
||||
case 2:
|
||||
textValue = Language.GetTextValue("Achievements.ExplorerCategory");
|
||||
break;
|
||||
case 3:
|
||||
textValue = Language.GetTextValue("Achievements.ChallengerCategory");
|
||||
break;
|
||||
default:
|
||||
textValue = Language.GetTextValue("Achievements.NoCategory");
|
||||
break;
|
||||
}
|
||||
float x = Main.fontMouseText.MeasureString(textValue).X;
|
||||
Vector2 vector2 = new Vector2((float) Main.mouseX, (float) Main.mouseY) + new Vector2(16f);
|
||||
if ((double) vector2.Y > (double) (Main.screenHeight - 30))
|
||||
vector2.Y = (float) (Main.screenHeight - 30);
|
||||
if ((double) vector2.X > (double) Main.screenWidth - (double) x)
|
||||
vector2.X = (float) (Main.screenWidth - 460);
|
||||
Utils.DrawBorderStringFourWay(spriteBatch, Main.fontMouseText, textValue, vector2.X, vector2.Y, new Color((int) Main.mouseTextColor, (int) Main.mouseTextColor, (int) Main.mouseTextColor, (int) Main.mouseTextColor), Color.Black, Vector2.Zero);
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.SetupGamepadPoints(spriteBatch);
|
||||
}
|
||||
|
||||
public void GotoAchievement(Achievement achievement) => this._achievementsList.Goto((UIList.ElementSearchMethod) (element => element is UIAchievementListItem achievementListItem && achievementListItem.GetAchievement() == achievement));
|
||||
|
||||
private void GoBackClick(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
Main.menuMode = 0;
|
||||
IngameFancyUI.Close();
|
||||
}
|
||||
|
||||
private void FadedMouseOver(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
Main.PlaySound(12);
|
||||
((UIPanel) evt.Target).BackgroundColor = new Color(73, 94, 171);
|
||||
}
|
||||
|
||||
private void FadedMouseOut(UIMouseEvent evt, UIElement listeningElement) => ((UIPanel) evt.Target).BackgroundColor = new Color(63, 82, 151) * 0.8f;
|
||||
|
||||
private void FilterList(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
this._achievementsList.Clear();
|
||||
foreach (UIAchievementListItem achievementElement in this._achievementElements)
|
||||
{
|
||||
if (this._categoryButtons[(int) achievementElement.GetAchievement().Category].IsOn)
|
||||
this._achievementsList.Add((UIElement) achievementElement);
|
||||
}
|
||||
this.Recalculate();
|
||||
}
|
||||
|
||||
public override void OnActivate()
|
||||
{
|
||||
this.InitializePage();
|
||||
if (Main.gameMenu)
|
||||
{
|
||||
this._outerContainer.Top.Set(220f, 0.0f);
|
||||
this._outerContainer.Height.Set(-220f, 1f);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._outerContainer.Top.Set(120f, 0.0f);
|
||||
this._outerContainer.Height.Set(-120f, 1f);
|
||||
}
|
||||
this._achievementsList.UpdateOrder();
|
||||
if (!PlayerInput.UsingGamepadUI)
|
||||
return;
|
||||
UILinkPointNavigator.ChangePoint(3002);
|
||||
}
|
||||
|
||||
private void SetupGamepadPoints(SpriteBatch spriteBatch)
|
||||
{
|
||||
UILinkPointNavigator.Shortcuts.BackButtonCommand = 3;
|
||||
int ID = 3000;
|
||||
UILinkPointNavigator.SetPosition(ID, this._backpanel.GetInnerDimensions().ToRectangle().Center.ToVector2());
|
||||
UILinkPointNavigator.SetPosition(ID + 1, this._outerContainer.GetInnerDimensions().ToRectangle().Center.ToVector2());
|
||||
int key = ID;
|
||||
UILinkPoint point1 = UILinkPointNavigator.Points[key];
|
||||
point1.Unlink();
|
||||
point1.Up = key + 1;
|
||||
int num = key + 1;
|
||||
UILinkPoint point2 = UILinkPointNavigator.Points[num];
|
||||
point2.Unlink();
|
||||
point2.Up = num + 1;
|
||||
point2.Down = num - 1;
|
||||
for (int index = 0; index < this._categoryButtons.Count; ++index)
|
||||
{
|
||||
++num;
|
||||
UILinkPointNavigator.Shortcuts.FANCYUI_HIGHEST_INDEX = num;
|
||||
UILinkPointNavigator.SetPosition(num, this._categoryButtons[index].GetInnerDimensions().ToRectangle().Center.ToVector2());
|
||||
UILinkPoint point3 = UILinkPointNavigator.Points[num];
|
||||
point3.Unlink();
|
||||
point3.Left = index == 0 ? -3 : num - 1;
|
||||
point3.Right = index == this._categoryButtons.Count - 1 ? -4 : num + 1;
|
||||
point3.Down = ID;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
268
GameContent/UI/States/UICharacterSelect.cs
Normal file
268
GameContent/UI/States/UICharacterSelect.cs
Normal file
|
@ -0,0 +1,268 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.States.UICharacterSelect
|
||||
// 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 System.Linq;
|
||||
using Terraria.GameContent.UI.Elements;
|
||||
using Terraria.GameInput;
|
||||
using Terraria.IO;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI;
|
||||
using Terraria.UI.Gamepad;
|
||||
|
||||
namespace Terraria.GameContent.UI.States
|
||||
{
|
||||
public class UICharacterSelect : UIState
|
||||
{
|
||||
private static string noteToEveryone = "This code is terrible and you will risk cancer reading it --Yoraiz0r";
|
||||
private UIList _playerList;
|
||||
private UITextPanel<LocalizedText> _backPanel;
|
||||
private UITextPanel<LocalizedText> _newPanel;
|
||||
private UIPanel _containerPanel;
|
||||
private List<Tuple<string, bool>> favoritesCache = new List<Tuple<string, bool>>();
|
||||
private bool skipDraw;
|
||||
|
||||
public override void OnInitialize()
|
||||
{
|
||||
UIElement element = new UIElement();
|
||||
element.Width.Set(0.0f, 0.8f);
|
||||
element.MaxWidth.Set(650f, 0.0f);
|
||||
element.Top.Set(220f, 0.0f);
|
||||
element.Height.Set(-220f, 1f);
|
||||
element.HAlign = 0.5f;
|
||||
UIPanel uiPanel = new UIPanel();
|
||||
uiPanel.Width.Set(0.0f, 1f);
|
||||
uiPanel.Height.Set(-110f, 1f);
|
||||
uiPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f;
|
||||
this._containerPanel = uiPanel;
|
||||
element.Append((UIElement) uiPanel);
|
||||
this._playerList = new UIList();
|
||||
this._playerList.Width.Set(-25f, 1f);
|
||||
this._playerList.Height.Set(0.0f, 1f);
|
||||
this._playerList.ListPadding = 5f;
|
||||
uiPanel.Append((UIElement) this._playerList);
|
||||
UIScrollbar scrollbar = new UIScrollbar();
|
||||
scrollbar.SetView(100f, 1000f);
|
||||
scrollbar.Height.Set(0.0f, 1f);
|
||||
scrollbar.HAlign = 1f;
|
||||
uiPanel.Append((UIElement) scrollbar);
|
||||
this._playerList.SetScrollbar(scrollbar);
|
||||
UITextPanel<LocalizedText> uiTextPanel1 = new UITextPanel<LocalizedText>(Language.GetText("UI.SelectPlayer"), 0.8f, true);
|
||||
uiTextPanel1.HAlign = 0.5f;
|
||||
uiTextPanel1.Top.Set(-35f, 0.0f);
|
||||
uiTextPanel1.SetPadding(15f);
|
||||
uiTextPanel1.BackgroundColor = new Color(73, 94, 171);
|
||||
element.Append((UIElement) uiTextPanel1);
|
||||
UITextPanel<LocalizedText> uiTextPanel2 = new UITextPanel<LocalizedText>(Language.GetText("UI.Back"), 0.7f, true);
|
||||
uiTextPanel2.Width.Set(-10f, 0.5f);
|
||||
uiTextPanel2.Height.Set(50f, 0.0f);
|
||||
uiTextPanel2.VAlign = 1f;
|
||||
uiTextPanel2.Top.Set(-45f, 0.0f);
|
||||
uiTextPanel2.OnMouseOver += new UIElement.MouseEvent(this.FadedMouseOver);
|
||||
uiTextPanel2.OnMouseOut += new UIElement.MouseEvent(this.FadedMouseOut);
|
||||
uiTextPanel2.OnClick += new UIElement.MouseEvent(this.GoBackClick);
|
||||
uiTextPanel2.SetSnapPoint("Back", 0);
|
||||
element.Append((UIElement) uiTextPanel2);
|
||||
this._backPanel = uiTextPanel2;
|
||||
UITextPanel<LocalizedText> uiTextPanel3 = new UITextPanel<LocalizedText>(Language.GetText("UI.New"), 0.7f, true);
|
||||
uiTextPanel3.CopyStyle((UIElement) uiTextPanel2);
|
||||
uiTextPanel3.HAlign = 1f;
|
||||
uiTextPanel3.OnMouseOver += new UIElement.MouseEvent(this.FadedMouseOver);
|
||||
uiTextPanel3.OnMouseOut += new UIElement.MouseEvent(this.FadedMouseOut);
|
||||
uiTextPanel3.OnClick += new UIElement.MouseEvent(this.NewCharacterClick);
|
||||
element.Append((UIElement) uiTextPanel3);
|
||||
uiTextPanel2.SetSnapPoint("New", 0);
|
||||
this._newPanel = uiTextPanel3;
|
||||
this.Append(element);
|
||||
}
|
||||
|
||||
private void NewCharacterClick(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
Main.PlaySound(10);
|
||||
Player player = new Player();
|
||||
player.inventory[0].SetDefaults(3507);
|
||||
player.inventory[0].Prefix(-1);
|
||||
player.inventory[1].SetDefaults(3509);
|
||||
player.inventory[1].Prefix(-1);
|
||||
player.inventory[2].SetDefaults(3506);
|
||||
player.inventory[2].Prefix(-1);
|
||||
Main.PendingPlayer = player;
|
||||
Main.menuMode = 2;
|
||||
}
|
||||
|
||||
private void GoBackClick(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
Main.PlaySound(11);
|
||||
Main.menuMode = 0;
|
||||
}
|
||||
|
||||
private void FadedMouseOver(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
Main.PlaySound(12);
|
||||
((UIPanel) evt.Target).BackgroundColor = new Color(73, 94, 171);
|
||||
}
|
||||
|
||||
private void FadedMouseOut(UIMouseEvent evt, UIElement listeningElement) => ((UIPanel) evt.Target).BackgroundColor = new Color(63, 82, 151) * 0.7f;
|
||||
|
||||
public override void OnActivate()
|
||||
{
|
||||
Main.ClearPendingPlayerSelectCallbacks();
|
||||
Main.LoadPlayers();
|
||||
this.UpdatePlayersList();
|
||||
if (!PlayerInput.UsingGamepadUI)
|
||||
return;
|
||||
UILinkPointNavigator.ChangePoint(3000 + (this._playerList.Count == 0 ? 1 : 2));
|
||||
}
|
||||
|
||||
private void UpdatePlayersList()
|
||||
{
|
||||
this._playerList.Clear();
|
||||
List<PlayerFileData> playerFileDataList = new List<PlayerFileData>((IEnumerable<PlayerFileData>) Main.PlayerList);
|
||||
playerFileDataList.Sort((Comparison<PlayerFileData>) ((x, y) =>
|
||||
{
|
||||
if (x.IsFavorite && !y.IsFavorite)
|
||||
return -1;
|
||||
if (!x.IsFavorite && y.IsFavorite)
|
||||
return 1;
|
||||
return x.Name.CompareTo(y.Name) != 0 ? x.Name.CompareTo(y.Name) : x.GetFileName().CompareTo(y.GetFileName());
|
||||
}));
|
||||
int num = 0;
|
||||
foreach (PlayerFileData data in playerFileDataList)
|
||||
this._playerList.Add((UIElement) new UICharacterListItem(data, num++));
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
if (this.skipDraw)
|
||||
{
|
||||
this.skipDraw = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.UpdateFavoritesCache())
|
||||
{
|
||||
this.skipDraw = true;
|
||||
Main.MenuUI.Draw(spriteBatch, new GameTime());
|
||||
}
|
||||
base.Draw(spriteBatch);
|
||||
this.SetupGamepadPoints(spriteBatch);
|
||||
}
|
||||
}
|
||||
|
||||
private bool UpdateFavoritesCache()
|
||||
{
|
||||
List<PlayerFileData> playerFileDataList = new List<PlayerFileData>((IEnumerable<PlayerFileData>) Main.PlayerList);
|
||||
playerFileDataList.Sort((Comparison<PlayerFileData>) ((x, y) =>
|
||||
{
|
||||
if (x.IsFavorite && !y.IsFavorite)
|
||||
return -1;
|
||||
if (!x.IsFavorite && y.IsFavorite)
|
||||
return 1;
|
||||
return x.Name.CompareTo(y.Name) != 0 ? x.Name.CompareTo(y.Name) : x.GetFileName().CompareTo(y.GetFileName());
|
||||
}));
|
||||
bool flag = false;
|
||||
if (!flag && playerFileDataList.Count != this.favoritesCache.Count)
|
||||
flag = true;
|
||||
if (!flag)
|
||||
{
|
||||
for (int index = 0; index < this.favoritesCache.Count; ++index)
|
||||
{
|
||||
Tuple<string, bool> tuple = this.favoritesCache[index];
|
||||
if (!(playerFileDataList[index].Name == tuple.Item1) || playerFileDataList[index].IsFavorite != tuple.Item2)
|
||||
{
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
this.favoritesCache.Clear();
|
||||
foreach (PlayerFileData playerFileData in playerFileDataList)
|
||||
this.favoritesCache.Add(Tuple.Create<string, bool>(playerFileData.Name, playerFileData.IsFavorite));
|
||||
this.UpdatePlayersList();
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
private void SetupGamepadPoints(SpriteBatch spriteBatch)
|
||||
{
|
||||
UILinkPointNavigator.Shortcuts.BackButtonCommand = 1;
|
||||
int num1 = 3000;
|
||||
UILinkPointNavigator.SetPosition(num1, this._backPanel.GetInnerDimensions().ToRectangle().Center.ToVector2());
|
||||
UILinkPointNavigator.SetPosition(num1 + 1, this._newPanel.GetInnerDimensions().ToRectangle().Center.ToVector2());
|
||||
int key1 = num1;
|
||||
UILinkPoint point1 = UILinkPointNavigator.Points[key1];
|
||||
point1.Unlink();
|
||||
point1.Right = key1 + 1;
|
||||
int key2 = num1 + 1;
|
||||
UILinkPoint point2 = UILinkPointNavigator.Points[key2];
|
||||
point2.Unlink();
|
||||
point2.Left = key2 - 1;
|
||||
Rectangle clippingRectangle = this._containerPanel.GetClippingRectangle(spriteBatch);
|
||||
Vector2 minimum = clippingRectangle.TopLeft();
|
||||
Vector2 maximum = clippingRectangle.BottomRight();
|
||||
List<SnapPoint> snapPoints = this.GetSnapPoints();
|
||||
for (int index = 0; index < snapPoints.Count; ++index)
|
||||
{
|
||||
if (!snapPoints[index].Position.Between(minimum, maximum))
|
||||
{
|
||||
snapPoints.Remove(snapPoints[index]);
|
||||
--index;
|
||||
}
|
||||
}
|
||||
SnapPoint[,] snapPointArray = new SnapPoint[this._playerList.Count, 4];
|
||||
foreach (SnapPoint snapPoint in snapPoints.Where<SnapPoint>((Func<SnapPoint, bool>) (a => a.Name == "Play")))
|
||||
snapPointArray[snapPoint.ID, 0] = snapPoint;
|
||||
foreach (SnapPoint snapPoint in snapPoints.Where<SnapPoint>((Func<SnapPoint, bool>) (a => a.Name == "Favorite")))
|
||||
snapPointArray[snapPoint.ID, 1] = snapPoint;
|
||||
foreach (SnapPoint snapPoint in snapPoints.Where<SnapPoint>((Func<SnapPoint, bool>) (a => a.Name == "Cloud")))
|
||||
snapPointArray[snapPoint.ID, 2] = snapPoint;
|
||||
foreach (SnapPoint snapPoint in snapPoints.Where<SnapPoint>((Func<SnapPoint, bool>) (a => a.Name == "Delete")))
|
||||
snapPointArray[snapPoint.ID, 3] = snapPoint;
|
||||
int num2 = num1 + 2;
|
||||
int[] numArray = new int[this._playerList.Count];
|
||||
for (int index = 0; index < numArray.Length; ++index)
|
||||
numArray[index] = -1;
|
||||
for (int index1 = 0; index1 < 4; ++index1)
|
||||
{
|
||||
int key3 = -1;
|
||||
for (int index2 = 0; index2 < snapPointArray.GetLength(0); ++index2)
|
||||
{
|
||||
if (snapPointArray[index2, index1] != null)
|
||||
{
|
||||
UILinkPoint point3 = UILinkPointNavigator.Points[num2];
|
||||
point3.Unlink();
|
||||
UILinkPointNavigator.SetPosition(num2, snapPointArray[index2, index1].Position);
|
||||
if (key3 != -1)
|
||||
{
|
||||
point3.Up = key3;
|
||||
UILinkPointNavigator.Points[key3].Down = num2;
|
||||
}
|
||||
if (numArray[index2] != -1)
|
||||
{
|
||||
point3.Left = numArray[index2];
|
||||
UILinkPointNavigator.Points[numArray[index2]].Right = num2;
|
||||
}
|
||||
point3.Down = num1;
|
||||
if (index1 == 0)
|
||||
UILinkPointNavigator.Points[num1].Up = UILinkPointNavigator.Points[num1 + 1].Up = num2;
|
||||
key3 = num2;
|
||||
numArray[index2] = num2;
|
||||
UILinkPointNavigator.Shortcuts.FANCYUI_HIGHEST_INDEX = num2;
|
||||
++num2;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!PlayerInput.UsingGamepadUI || this._playerList.Count != 0 || UILinkPointNavigator.CurrentPoint <= 3001)
|
||||
return;
|
||||
UILinkPointNavigator.ChangePoint(3001);
|
||||
}
|
||||
}
|
||||
}
|
1065
GameContent/UI/States/UIManageControls.cs
Normal file
1065
GameContent/UI/States/UIManageControls.cs
Normal file
File diff suppressed because it is too large
Load diff
19
GameContent/UI/States/UISortableElement.cs
Normal file
19
GameContent/UI/States/UISortableElement.cs
Normal file
|
@ -0,0 +1,19 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.States.UISortableElement
|
||||
// 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 Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.States
|
||||
{
|
||||
public class UISortableElement : UIElement
|
||||
{
|
||||
public int OrderIndex;
|
||||
|
||||
public UISortableElement(int index) => this.OrderIndex = index;
|
||||
|
||||
public override int CompareTo(object obj) => obj is UISortableElement uiSortableElement ? this.OrderIndex.CompareTo(uiSortableElement.OrderIndex) : base.CompareTo(obj);
|
||||
}
|
||||
}
|
789
GameContent/UI/States/UIVirtualKeyboard.cs
Normal file
789
GameContent/UI/States/UIVirtualKeyboard.cs
Normal file
|
@ -0,0 +1,789 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.States.UIVirtualKeyboard
|
||||
// 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.GameContent.UI.Elements;
|
||||
using Terraria.GameInput;
|
||||
using Terraria.Graphics;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI;
|
||||
using Terraria.UI.Gamepad;
|
||||
|
||||
namespace Terraria.GameContent.UI.States
|
||||
{
|
||||
public class UIVirtualKeyboard : UIState
|
||||
{
|
||||
private static UIVirtualKeyboard _currentInstance;
|
||||
private static string _cancelCacheSign = "";
|
||||
private static string _cancelCacheChest = "";
|
||||
private const string DEFAULT_KEYS = "1234567890qwertyuiopasdfghjkl'zxcvbnm,.?";
|
||||
private const string SHIFT_KEYS = "1234567890QWERTYUIOPASDFGHJKL'ZXCVBNM,.?";
|
||||
private const string SYMBOL_KEYS = "1234567890!@#$%^&*()-_+=/\\{}[]<>;:\"`|~£¥";
|
||||
private const float KEY_SPACING = 4f;
|
||||
private const float KEY_WIDTH = 48f;
|
||||
private const float KEY_HEIGHT = 37f;
|
||||
private UITextPanel<object>[] _keyList = new UITextPanel<object>[50];
|
||||
private UITextPanel<object> _shiftButton;
|
||||
private UITextPanel<object> _symbolButton;
|
||||
private UITextBox _textBox;
|
||||
private UITextPanel<LocalizedText> _submitButton;
|
||||
private UITextPanel<LocalizedText> _cancelButton;
|
||||
private UIText _label;
|
||||
private UITextPanel<object> _enterButton;
|
||||
private UITextPanel<object> _spacebarButton;
|
||||
private UITextPanel<object> _restoreButton;
|
||||
private Texture2D _textureShift;
|
||||
private Texture2D _textureBackspace;
|
||||
private Color _internalBorderColor = new Color(89, 116, 213);
|
||||
private Color _internalBorderColorSelected = Main.OurFavoriteColor;
|
||||
private UITextPanel<LocalizedText> _submitButton2;
|
||||
private UITextPanel<LocalizedText> _cancelButton2;
|
||||
private UIElement outerLayer1;
|
||||
private UIElement outerLayer2;
|
||||
private bool _allowEmpty;
|
||||
private UIVirtualKeyboard.KeyState _keyState;
|
||||
private UIVirtualKeyboard.KeyboardSubmitEvent _submitAction;
|
||||
private Action _cancelAction;
|
||||
private int _lastOffsetDown;
|
||||
public static int OffsetDown = 0;
|
||||
private int _keyboardContext;
|
||||
private bool _edittingSign;
|
||||
private bool _edittingChest;
|
||||
private float _textBoxHeight;
|
||||
private float _labelHeight;
|
||||
private bool _canSubmit;
|
||||
|
||||
public string Text
|
||||
{
|
||||
get => this._textBox.Text;
|
||||
set
|
||||
{
|
||||
this._textBox.SetText(value);
|
||||
this.ValidateText();
|
||||
}
|
||||
}
|
||||
|
||||
public UIVirtualKeyboard(
|
||||
string labelText,
|
||||
string startingText,
|
||||
UIVirtualKeyboard.KeyboardSubmitEvent submitAction,
|
||||
Action cancelAction,
|
||||
int inputMode = 0,
|
||||
bool allowEmpty = false)
|
||||
{
|
||||
this._keyboardContext = inputMode;
|
||||
this._allowEmpty = allowEmpty;
|
||||
UIVirtualKeyboard.OffsetDown = 0;
|
||||
this._lastOffsetDown = 0;
|
||||
this._edittingSign = this._keyboardContext == 1;
|
||||
this._edittingChest = this._keyboardContext == 2;
|
||||
UIVirtualKeyboard._currentInstance = this;
|
||||
this._submitAction = submitAction;
|
||||
this._cancelAction = cancelAction;
|
||||
this._textureShift = TextureManager.Load("Images/UI/VK_Shift");
|
||||
this._textureBackspace = TextureManager.Load("Images/UI/VK_Backspace");
|
||||
this.Top.Pixels = (float) this._lastOffsetDown;
|
||||
float num1 = (float) (-5000 * this._edittingSign.ToInt());
|
||||
float maxValue = (float) byte.MaxValue;
|
||||
float num2 = 0.0f;
|
||||
float num3 = 516f;
|
||||
UIElement element = new UIElement();
|
||||
element.Width.Pixels = (float) ((double) num3 + 8.0 + 16.0);
|
||||
element.Top.Precent = num2;
|
||||
element.Top.Pixels = maxValue;
|
||||
element.Height.Pixels = 266f;
|
||||
element.HAlign = 0.5f;
|
||||
element.SetPadding(0.0f);
|
||||
this.outerLayer1 = element;
|
||||
UIElement uiElement = new UIElement();
|
||||
uiElement.Width.Pixels = (float) ((double) num3 + 8.0 + 16.0);
|
||||
uiElement.Top.Precent = num2;
|
||||
uiElement.Top.Pixels = maxValue;
|
||||
uiElement.Height.Pixels = 266f;
|
||||
uiElement.HAlign = 0.5f;
|
||||
uiElement.SetPadding(0.0f);
|
||||
this.outerLayer2 = uiElement;
|
||||
UIPanel mainPanel = new UIPanel();
|
||||
mainPanel.Width.Precent = 1f;
|
||||
mainPanel.Height.Pixels = 225f;
|
||||
mainPanel.BackgroundColor = new Color(23, 33, 69) * 0.7f;
|
||||
element.Append((UIElement) mainPanel);
|
||||
float num4 = -79f;
|
||||
this._textBox = new UITextBox("", 0.78f, true);
|
||||
this._textBox.BackgroundColor = Color.Transparent;
|
||||
this._textBox.BorderColor = Color.Transparent;
|
||||
this._textBox.HAlign = 0.5f;
|
||||
this._textBox.Width.Pixels = num3;
|
||||
this._textBox.Top.Pixels = (float) ((double) num4 + (double) maxValue - 10.0) + num1;
|
||||
this._textBox.Top.Precent = num2;
|
||||
this._textBox.Height.Pixels = 37f;
|
||||
this.Append((UIElement) this._textBox);
|
||||
for (int x = 0; x < 10; ++x)
|
||||
{
|
||||
for (int y = 0; y < 4; ++y)
|
||||
{
|
||||
UITextPanel<object> keyboardButton = this.CreateKeyboardButton((object) "1234567890qwertyuiopasdfghjkl'zxcvbnm,.?"[y * 10 + x].ToString(), x, y);
|
||||
keyboardButton.OnClick += new UIElement.MouseEvent(this.TypeText);
|
||||
mainPanel.Append((UIElement) keyboardButton);
|
||||
}
|
||||
}
|
||||
this._shiftButton = this.CreateKeyboardButton((object) "", 0, 4, style: false);
|
||||
this._shiftButton.PaddingLeft = 0.0f;
|
||||
this._shiftButton.PaddingRight = 0.0f;
|
||||
this._shiftButton.PaddingBottom = this._shiftButton.PaddingTop = 0.0f;
|
||||
this._shiftButton.BackgroundColor = new Color(63, 82, 151) * 0.7f;
|
||||
this._shiftButton.BorderColor = this._internalBorderColor * 0.7f;
|
||||
this._shiftButton.OnMouseOver += (UIElement.MouseEvent) ((evt, listeningElement) =>
|
||||
{
|
||||
this._shiftButton.BorderColor = this._internalBorderColorSelected;
|
||||
if (this._keyState == UIVirtualKeyboard.KeyState.Shift)
|
||||
return;
|
||||
this._shiftButton.BackgroundColor = new Color(73, 94, 171);
|
||||
});
|
||||
this._shiftButton.OnMouseOut += (UIElement.MouseEvent) ((evt, listeningElement) =>
|
||||
{
|
||||
this._shiftButton.BorderColor = this._internalBorderColor * 0.7f;
|
||||
if (this._keyState == UIVirtualKeyboard.KeyState.Shift)
|
||||
return;
|
||||
this._shiftButton.BackgroundColor = new Color(63, 82, 151) * 0.7f;
|
||||
});
|
||||
this._shiftButton.OnClick += (UIElement.MouseEvent) ((evt, listeningElement) =>
|
||||
{
|
||||
Main.PlaySound(12);
|
||||
this.SetKeyState(this._keyState == UIVirtualKeyboard.KeyState.Shift ? UIVirtualKeyboard.KeyState.Default : UIVirtualKeyboard.KeyState.Shift);
|
||||
});
|
||||
UIImage uiImage1 = new UIImage(this._textureShift);
|
||||
uiImage1.HAlign = 0.5f;
|
||||
uiImage1.VAlign = 0.5f;
|
||||
uiImage1.ImageScale = 0.85f;
|
||||
this._shiftButton.Append((UIElement) uiImage1);
|
||||
mainPanel.Append((UIElement) this._shiftButton);
|
||||
this._symbolButton = this.CreateKeyboardButton((object) "@%", 1, 4, style: false);
|
||||
this._symbolButton.PaddingLeft = 0.0f;
|
||||
this._symbolButton.PaddingRight = 0.0f;
|
||||
this._symbolButton.BackgroundColor = new Color(63, 82, 151) * 0.7f;
|
||||
this._symbolButton.BorderColor = this._internalBorderColor * 0.7f;
|
||||
this._symbolButton.OnMouseOver += (UIElement.MouseEvent) ((evt, listeningElement) =>
|
||||
{
|
||||
this._symbolButton.BorderColor = this._internalBorderColorSelected;
|
||||
if (this._keyState == UIVirtualKeyboard.KeyState.Symbol)
|
||||
return;
|
||||
this._symbolButton.BackgroundColor = new Color(73, 94, 171);
|
||||
});
|
||||
this._symbolButton.OnMouseOut += (UIElement.MouseEvent) ((evt, listeningElement) =>
|
||||
{
|
||||
this._symbolButton.BorderColor = this._internalBorderColor * 0.7f;
|
||||
if (this._keyState == UIVirtualKeyboard.KeyState.Symbol)
|
||||
return;
|
||||
this._symbolButton.BackgroundColor = new Color(63, 82, 151) * 0.7f;
|
||||
});
|
||||
this._symbolButton.OnClick += (UIElement.MouseEvent) ((evt, listeningElement) =>
|
||||
{
|
||||
Main.PlaySound(12);
|
||||
this.SetKeyState(this._keyState == UIVirtualKeyboard.KeyState.Symbol ? UIVirtualKeyboard.KeyState.Default : UIVirtualKeyboard.KeyState.Symbol);
|
||||
});
|
||||
mainPanel.Append((UIElement) this._symbolButton);
|
||||
this.BuildSpaceBarArea(mainPanel);
|
||||
this._submitButton = new UITextPanel<LocalizedText>(this._edittingSign || this._edittingChest ? Language.GetText("UI.Save") : Language.GetText("UI.Submit"), 0.4f, true);
|
||||
this._submitButton.Height.Pixels = 37f;
|
||||
this._submitButton.Width.Precent = 0.4f;
|
||||
this._submitButton.HAlign = 1f;
|
||||
this._submitButton.VAlign = 1f;
|
||||
this._submitButton.PaddingLeft = 0.0f;
|
||||
this._submitButton.PaddingRight = 0.0f;
|
||||
this.ValidateText();
|
||||
this._submitButton.OnMouseOver += (UIElement.MouseEvent) ((evt, listeningElement) => this.ValidateText());
|
||||
this._submitButton.OnMouseOut += (UIElement.MouseEvent) ((evt, listeningElement) => this.ValidateText());
|
||||
this._submitButton.OnClick += (UIElement.MouseEvent) ((evt, listeningElement) =>
|
||||
{
|
||||
string text = this.Text.Trim();
|
||||
if (text.Length <= 0 && !this._edittingSign && !this._edittingChest && !this._allowEmpty)
|
||||
return;
|
||||
Main.PlaySound(10);
|
||||
this._submitAction(text);
|
||||
});
|
||||
element.Append((UIElement) this._submitButton);
|
||||
this._cancelButton = new UITextPanel<LocalizedText>(Language.GetText("UI.Cancel"), 0.4f, true);
|
||||
this.StyleKey<LocalizedText>(this._cancelButton, true);
|
||||
this._cancelButton.Height.Pixels = 37f;
|
||||
this._cancelButton.Width.Precent = 0.4f;
|
||||
this._cancelButton.VAlign = 1f;
|
||||
this._cancelButton.OnClick += (UIElement.MouseEvent) ((evt, listeningElement) =>
|
||||
{
|
||||
Main.PlaySound(11);
|
||||
this._cancelAction();
|
||||
});
|
||||
element.Append((UIElement) this._cancelButton);
|
||||
this._submitButton2 = new UITextPanel<LocalizedText>(this._edittingSign || this._edittingChest ? Language.GetText("UI.Save") : Language.GetText("UI.Submit"), 0.72f, true);
|
||||
this._submitButton2.TextColor = Color.Silver;
|
||||
this._submitButton2.DrawPanel = false;
|
||||
this._submitButton2.Height.Pixels = 60f;
|
||||
this._submitButton2.Width.Precent = 0.4f;
|
||||
this._submitButton2.HAlign = 0.5f;
|
||||
this._submitButton2.VAlign = 0.0f;
|
||||
this._submitButton2.OnMouseOver += (UIElement.MouseEvent) ((a, b) =>
|
||||
{
|
||||
((UITextPanel<LocalizedText>) b).TextScale = 0.85f;
|
||||
((UITextPanel<LocalizedText>) b).TextColor = Color.White;
|
||||
});
|
||||
this._submitButton2.OnMouseOut += (UIElement.MouseEvent) ((a, b) =>
|
||||
{
|
||||
((UITextPanel<LocalizedText>) b).TextScale = 0.72f;
|
||||
((UITextPanel<LocalizedText>) b).TextColor = Color.Silver;
|
||||
});
|
||||
this._submitButton2.Top.Pixels = 50f;
|
||||
this._submitButton2.PaddingLeft = 0.0f;
|
||||
this._submitButton2.PaddingRight = 0.0f;
|
||||
this.ValidateText();
|
||||
this._submitButton2.OnMouseOver += (UIElement.MouseEvent) ((evt, listeningElement) => this.ValidateText());
|
||||
this._submitButton2.OnMouseOut += (UIElement.MouseEvent) ((evt, listeningElement) => this.ValidateText());
|
||||
this._submitButton2.OnClick += (UIElement.MouseEvent) ((evt, listeningElement) =>
|
||||
{
|
||||
string text = this.Text.Trim();
|
||||
if (text.Length <= 0 && !this._edittingSign && !this._edittingChest && !this._allowEmpty)
|
||||
return;
|
||||
Main.PlaySound(10);
|
||||
this._submitAction(text);
|
||||
});
|
||||
this.outerLayer2.Append((UIElement) this._submitButton2);
|
||||
this._cancelButton2 = new UITextPanel<LocalizedText>(Language.GetText("UI.Cancel"), 0.72f, true);
|
||||
this._cancelButton2.TextColor = Color.Silver;
|
||||
this._cancelButton2.DrawPanel = false;
|
||||
this._cancelButton2.OnMouseOver += (UIElement.MouseEvent) ((a, b) =>
|
||||
{
|
||||
((UITextPanel<LocalizedText>) b).TextScale = 0.85f;
|
||||
((UITextPanel<LocalizedText>) b).TextColor = Color.White;
|
||||
});
|
||||
this._cancelButton2.OnMouseOut += (UIElement.MouseEvent) ((a, b) =>
|
||||
{
|
||||
((UITextPanel<LocalizedText>) b).TextScale = 0.72f;
|
||||
((UITextPanel<LocalizedText>) b).TextColor = Color.Silver;
|
||||
});
|
||||
this._cancelButton2.Height.Pixels = 60f;
|
||||
this._cancelButton2.Width.Precent = 0.4f;
|
||||
this._cancelButton2.Top.Pixels = 114f;
|
||||
this._cancelButton2.VAlign = 0.0f;
|
||||
this._cancelButton2.HAlign = 0.5f;
|
||||
this._cancelButton2.OnClick += (UIElement.MouseEvent) ((evt, listeningElement) =>
|
||||
{
|
||||
Main.PlaySound(11);
|
||||
this._cancelAction();
|
||||
});
|
||||
this.outerLayer2.Append((UIElement) this._cancelButton2);
|
||||
UITextPanel<object> keyboardButton1 = this.CreateKeyboardButton((object) "", 8, 4, 2);
|
||||
keyboardButton1.OnClick += (UIElement.MouseEvent) ((evt, listeningElement) =>
|
||||
{
|
||||
Main.PlaySound(12);
|
||||
this._textBox.Backspace();
|
||||
this.ValidateText();
|
||||
});
|
||||
keyboardButton1.PaddingLeft = 0.0f;
|
||||
keyboardButton1.PaddingRight = 0.0f;
|
||||
keyboardButton1.PaddingBottom = keyboardButton1.PaddingTop = 0.0f;
|
||||
UIImage uiImage2 = new UIImage(this._textureBackspace);
|
||||
uiImage2.HAlign = 0.5f;
|
||||
uiImage2.VAlign = 0.5f;
|
||||
uiImage2.ImageScale = 0.92f;
|
||||
keyboardButton1.Append((UIElement) uiImage2);
|
||||
mainPanel.Append((UIElement) keyboardButton1);
|
||||
UIText uiText = new UIText(labelText, 0.75f, true);
|
||||
uiText.HAlign = 0.5f;
|
||||
uiText.Width.Pixels = num3;
|
||||
uiText.Top.Pixels = (float) ((double) num4 - 37.0 - 4.0) + maxValue + num1;
|
||||
uiText.Top.Precent = num2;
|
||||
uiText.Height.Pixels = 37f;
|
||||
this.Append((UIElement) uiText);
|
||||
this._label = uiText;
|
||||
this.Append(element);
|
||||
this._textBox.SetTextMaxLength(this._edittingSign ? 99999 : 20);
|
||||
this.Text = startingText;
|
||||
if (this.Text.Length == 0)
|
||||
this.SetKeyState(UIVirtualKeyboard.KeyState.Shift);
|
||||
UIVirtualKeyboard.OffsetDown = 9999;
|
||||
this.UpdateOffsetDown();
|
||||
}
|
||||
|
||||
private void BuildSpaceBarArea(UIPanel mainPanel)
|
||||
{
|
||||
Action createTheseTwo = (Action) (() =>
|
||||
{
|
||||
bool flag = this.CanRestore();
|
||||
int x = flag ? 4 : 5;
|
||||
bool edittingSign = this._edittingSign;
|
||||
int width = flag & edittingSign ? 2 : 3;
|
||||
UITextPanel<object> keyboardButton1 = this.CreateKeyboardButton((object) Language.GetText("UI.SpaceButton"), 2, 4, this._edittingSign || this._edittingChest & flag ? width : 6);
|
||||
keyboardButton1.OnClick += (UIElement.MouseEvent) ((evt, listeningElement) =>
|
||||
{
|
||||
Main.PlaySound(12);
|
||||
this._textBox.Write(" ");
|
||||
this.ValidateText();
|
||||
});
|
||||
mainPanel.Append((UIElement) keyboardButton1);
|
||||
this._spacebarButton = keyboardButton1;
|
||||
if (!edittingSign)
|
||||
return;
|
||||
UITextPanel<object> keyboardButton2 = this.CreateKeyboardButton((object) Language.GetText("UI.EnterButton"), x, 4, width);
|
||||
keyboardButton2.OnClick += (UIElement.MouseEvent) ((evt, listeningElement) =>
|
||||
{
|
||||
Main.PlaySound(12);
|
||||
this._textBox.Write("\n");
|
||||
this.ValidateText();
|
||||
});
|
||||
mainPanel.Append((UIElement) keyboardButton2);
|
||||
this._enterButton = keyboardButton2;
|
||||
});
|
||||
createTheseTwo();
|
||||
if (!this.CanRestore())
|
||||
return;
|
||||
UITextPanel<object> restoreBar = this.CreateKeyboardButton((object) Language.GetText("UI.RestoreButton"), 6, 4, 2);
|
||||
restoreBar.OnClick += (UIElement.MouseEvent) ((evt, listeningElement) =>
|
||||
{
|
||||
Main.PlaySound(12);
|
||||
this.RestoreCancelledInput(this._keyboardContext);
|
||||
this.ValidateText();
|
||||
restoreBar.Remove();
|
||||
this._enterButton.Remove();
|
||||
this._spacebarButton.Remove();
|
||||
createTheseTwo();
|
||||
});
|
||||
mainPanel.Append((UIElement) restoreBar);
|
||||
this._restoreButton = restoreBar;
|
||||
}
|
||||
|
||||
private bool CanRestore()
|
||||
{
|
||||
if (this._edittingSign)
|
||||
return UIVirtualKeyboard._cancelCacheSign.Length > 0;
|
||||
return this._edittingChest && UIVirtualKeyboard._cancelCacheChest.Length > 0;
|
||||
}
|
||||
|
||||
private void TypeText(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
Main.PlaySound(12);
|
||||
int num = this.Text.Length == 0 ? 1 : 0;
|
||||
this._textBox.Write(((UITextPanel<object>) listeningElement).Text);
|
||||
this.ValidateText();
|
||||
if (num == 0 || this.Text.Length <= 0 || this._keyState != UIVirtualKeyboard.KeyState.Shift)
|
||||
return;
|
||||
this.SetKeyState(UIVirtualKeyboard.KeyState.Default);
|
||||
}
|
||||
|
||||
public void SetKeyState(UIVirtualKeyboard.KeyState keyState)
|
||||
{
|
||||
UITextPanel<object> uiTextPanel1 = (UITextPanel<object>) null;
|
||||
switch (this._keyState)
|
||||
{
|
||||
case UIVirtualKeyboard.KeyState.Symbol:
|
||||
uiTextPanel1 = this._symbolButton;
|
||||
break;
|
||||
case UIVirtualKeyboard.KeyState.Shift:
|
||||
uiTextPanel1 = this._shiftButton;
|
||||
break;
|
||||
}
|
||||
if (uiTextPanel1 != null)
|
||||
{
|
||||
if (uiTextPanel1.IsMouseHovering)
|
||||
uiTextPanel1.BackgroundColor = new Color(73, 94, 171);
|
||||
else
|
||||
uiTextPanel1.BackgroundColor = new Color(63, 82, 151) * 0.7f;
|
||||
}
|
||||
string str = (string) null;
|
||||
UITextPanel<object> uiTextPanel2 = (UITextPanel<object>) null;
|
||||
switch (keyState)
|
||||
{
|
||||
case UIVirtualKeyboard.KeyState.Default:
|
||||
str = "1234567890qwertyuiopasdfghjkl'zxcvbnm,.?";
|
||||
break;
|
||||
case UIVirtualKeyboard.KeyState.Symbol:
|
||||
str = "1234567890!@#$%^&*()-_+=/\\{}[]<>;:\"`|~£¥";
|
||||
uiTextPanel2 = this._symbolButton;
|
||||
break;
|
||||
case UIVirtualKeyboard.KeyState.Shift:
|
||||
str = "1234567890QWERTYUIOPASDFGHJKL'ZXCVBNM,.?";
|
||||
uiTextPanel2 = this._shiftButton;
|
||||
break;
|
||||
}
|
||||
for (int index = 0; index < str.Length; ++index)
|
||||
this._keyList[index].SetText((object) str[index].ToString());
|
||||
this._keyState = keyState;
|
||||
if (uiTextPanel2 == null)
|
||||
return;
|
||||
uiTextPanel2.BackgroundColor = new Color(93, 114, 191);
|
||||
}
|
||||
|
||||
private void ValidateText()
|
||||
{
|
||||
if (this.Text.Trim().Length > 0 || this._edittingSign || this._edittingChest || this._allowEmpty)
|
||||
{
|
||||
this._canSubmit = true;
|
||||
this._submitButton.TextColor = Color.White;
|
||||
if (this._submitButton.IsMouseHovering)
|
||||
this._submitButton.BackgroundColor = new Color(73, 94, 171);
|
||||
else
|
||||
this._submitButton.BackgroundColor = new Color(63, 82, 151) * 0.7f;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._canSubmit = false;
|
||||
this._submitButton.TextColor = Color.Gray;
|
||||
if (this._submitButton.IsMouseHovering)
|
||||
this._submitButton.BackgroundColor = new Color(180, 60, 60) * 0.85f;
|
||||
else
|
||||
this._submitButton.BackgroundColor = new Color(150, 40, 40) * 0.85f;
|
||||
}
|
||||
}
|
||||
|
||||
private void StyleKey<T>(UITextPanel<T> button, bool external = false)
|
||||
{
|
||||
button.PaddingLeft = 0.0f;
|
||||
button.PaddingRight = 0.0f;
|
||||
button.BackgroundColor = new Color(63, 82, 151) * 0.7f;
|
||||
if (!external)
|
||||
button.BorderColor = this._internalBorderColor * 0.7f;
|
||||
button.OnMouseOver += (UIElement.MouseEvent) ((evt, listeningElement) =>
|
||||
{
|
||||
((UIPanel) listeningElement).BackgroundColor = new Color(73, 94, 171) * 0.85f;
|
||||
if (external)
|
||||
return;
|
||||
((UIPanel) listeningElement).BorderColor = this._internalBorderColorSelected * 0.85f;
|
||||
});
|
||||
button.OnMouseOut += (UIElement.MouseEvent) ((evt, listeningElement) =>
|
||||
{
|
||||
((UIPanel) listeningElement).BackgroundColor = new Color(63, 82, 151) * 0.7f;
|
||||
if (external)
|
||||
return;
|
||||
((UIPanel) listeningElement).BorderColor = this._internalBorderColor * 0.7f;
|
||||
});
|
||||
}
|
||||
|
||||
private UITextPanel<object> CreateKeyboardButton(
|
||||
object text,
|
||||
int x,
|
||||
int y,
|
||||
int width = 1,
|
||||
bool style = true)
|
||||
{
|
||||
float num = 516f;
|
||||
UITextPanel<object> button = new UITextPanel<object>(text, 0.4f, true);
|
||||
button.Width.Pixels = (float) (48.0 * (double) width + 4.0 * (double) (width - 1));
|
||||
button.Height.Pixels = 37f;
|
||||
button.Left.Precent = 0.5f;
|
||||
button.Left.Pixels = (float) (52.0 * (double) x - (double) num * 0.5);
|
||||
button.Top.Pixels = 41f * (float) y;
|
||||
if (style)
|
||||
this.StyleKey<object>(button);
|
||||
for (int index = 0; index < width; ++index)
|
||||
this._keyList[y * 10 + x + index] = button;
|
||||
return button;
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
if (Main.gameMenu)
|
||||
{
|
||||
if (PlayerInput.UsingGamepad)
|
||||
{
|
||||
this.outerLayer2.Remove();
|
||||
if (!this.Elements.Contains(this.outerLayer1))
|
||||
this.Append(this.outerLayer1);
|
||||
this.outerLayer1.Activate();
|
||||
this.outerLayer2.Deactivate();
|
||||
this.Recalculate();
|
||||
this.RecalculateChildren();
|
||||
if ((double) this._labelHeight != 0.0)
|
||||
{
|
||||
this._textBox.Top.Pixels = this._textBoxHeight;
|
||||
this._label.Top.Pixels = this._labelHeight;
|
||||
this._textBox.Recalculate();
|
||||
this._label.Recalculate();
|
||||
this._labelHeight = this._textBoxHeight = 0.0f;
|
||||
UserInterface.ActiveInstance.ResetLasts();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.outerLayer1.Remove();
|
||||
if (!this.Elements.Contains(this.outerLayer2))
|
||||
this.Append(this.outerLayer2);
|
||||
this.outerLayer2.Activate();
|
||||
this.outerLayer1.Deactivate();
|
||||
this.Recalculate();
|
||||
this.RecalculateChildren();
|
||||
if ((double) this._textBoxHeight == 0.0)
|
||||
{
|
||||
this._textBoxHeight = this._textBox.Top.Pixels;
|
||||
this._labelHeight = this._label.Top.Pixels;
|
||||
this._textBox.Top.Pixels += 50f;
|
||||
this._label.Top.Pixels += 50f;
|
||||
this._textBox.Recalculate();
|
||||
this._label.Recalculate();
|
||||
UserInterface.ActiveInstance.ResetLasts();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!Main.editSign && this._edittingSign)
|
||||
IngameFancyUI.Close();
|
||||
else if (!Main.editChest && this._edittingChest)
|
||||
{
|
||||
IngameFancyUI.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
base.DrawSelf(spriteBatch);
|
||||
this.UpdateOffsetDown();
|
||||
UIVirtualKeyboard.OffsetDown = 0;
|
||||
this.SetupGamepadPoints(spriteBatch);
|
||||
PlayerInput.WritingText = true;
|
||||
Main.instance.HandleIME();
|
||||
Vector2 position;
|
||||
ref Vector2 local1 = ref position;
|
||||
double num1 = (double) (Main.screenWidth / 2);
|
||||
Rectangle rectangle = this._textBox.GetDimensions().ToRectangle();
|
||||
double num2 = (double) (rectangle.Bottom + 32);
|
||||
local1 = new Vector2((float) num1, (float) num2);
|
||||
Main.instance.DrawWindowsIMEPanel(position, 0.5f);
|
||||
string inputText = Main.GetInputText(this.Text);
|
||||
if (this._edittingSign && Main.inputTextEnter)
|
||||
{
|
||||
inputText += "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this._edittingChest && Main.inputTextEnter)
|
||||
{
|
||||
ChestUI.RenameChestSubmit(Main.player[Main.myPlayer]);
|
||||
IngameFancyUI.Close();
|
||||
return;
|
||||
}
|
||||
if (Main.inputTextEnter && UIVirtualKeyboard.CanSubmit)
|
||||
UIVirtualKeyboard.Submit();
|
||||
else if (Main.inputTextEscape)
|
||||
{
|
||||
if (this._edittingSign)
|
||||
Main.InputTextSignCancel();
|
||||
if (this._edittingChest)
|
||||
ChestUI.RenameChestCancel();
|
||||
IngameFancyUI.Close();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (IngameFancyUI.CanShowVirtualKeyboard(this._keyboardContext))
|
||||
{
|
||||
if (inputText != this.Text)
|
||||
this.Text = inputText;
|
||||
if (this._edittingSign)
|
||||
this.CopyTextToSign();
|
||||
if (this._edittingChest)
|
||||
this.CopyTextToChest();
|
||||
}
|
||||
byte num3 = (byte) (((int) byte.MaxValue + (int) Main.tileColor.R * 2) / 3);
|
||||
Color color = new Color((int) num3, (int) num3, (int) num3, (int) byte.MaxValue);
|
||||
this._textBox.TextColor = Color.Lerp(Color.White, color, 0.2f);
|
||||
this._label.TextColor = Color.Lerp(Color.White, color, 0.2f);
|
||||
ref Vector2 local2 = ref position;
|
||||
double num4 = (double) (Main.screenWidth / 2);
|
||||
rectangle = this._textBox.GetDimensions().ToRectangle();
|
||||
double num5 = (double) (rectangle.Bottom + 32);
|
||||
local2 = new Vector2((float) num4, (float) num5);
|
||||
Main.instance.DrawWindowsIMEPanel(position, 0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateOffsetDown()
|
||||
{
|
||||
int num1 = UIVirtualKeyboard.OffsetDown - this._lastOffsetDown;
|
||||
int num2 = num1;
|
||||
if (Math.Abs(num1) < 10)
|
||||
num2 = num1;
|
||||
this._lastOffsetDown += num2;
|
||||
if (num2 == 0)
|
||||
return;
|
||||
this.Top.Pixels += (float) num2;
|
||||
this.Recalculate();
|
||||
}
|
||||
|
||||
public override void OnActivate()
|
||||
{
|
||||
if (!PlayerInput.UsingGamepadUI || this._restoreButton == null)
|
||||
return;
|
||||
UILinkPointNavigator.ChangePoint(3002);
|
||||
}
|
||||
|
||||
public override void OnDeactivate()
|
||||
{
|
||||
base.OnDeactivate();
|
||||
PlayerInput.WritingText = false;
|
||||
UILinkPointNavigator.Shortcuts.FANCYUI_SPECIAL_INSTRUCTIONS = 0;
|
||||
}
|
||||
|
||||
private void SetupGamepadPoints(SpriteBatch spriteBatch)
|
||||
{
|
||||
UILinkPointNavigator.Shortcuts.BackButtonCommand = 6;
|
||||
UILinkPointNavigator.Shortcuts.FANCYUI_SPECIAL_INSTRUCTIONS = 1;
|
||||
int num1 = 3002;
|
||||
UILinkPointNavigator.SetPosition(3000, this._cancelButton.GetDimensions().Center());
|
||||
UILinkPoint point1 = UILinkPointNavigator.Points[3000];
|
||||
point1.Unlink();
|
||||
point1.Right = 3001;
|
||||
point1.Up = num1 + 40;
|
||||
UILinkPointNavigator.SetPosition(3001, this._submitButton.GetDimensions().Center());
|
||||
UILinkPoint point2 = UILinkPointNavigator.Points[3001];
|
||||
point2.Unlink();
|
||||
point2.Left = 3000;
|
||||
point2.Up = num1 + 49;
|
||||
for (int index1 = 0; index1 < 5; ++index1)
|
||||
{
|
||||
for (int index2 = 0; index2 < 10; ++index2)
|
||||
{
|
||||
int index3 = index1 * 10 + index2;
|
||||
int num2 = num1 + index3;
|
||||
if (this._keyList[index3] != null)
|
||||
{
|
||||
UILinkPointNavigator.SetPosition(num2, this._keyList[index3].GetDimensions().Center());
|
||||
UILinkPoint point3 = UILinkPointNavigator.Points[num2];
|
||||
point3.Unlink();
|
||||
int num3 = index2 - 1;
|
||||
while (num3 >= 0 && this._keyList[index1 * 10 + num3] == this._keyList[index3])
|
||||
--num3;
|
||||
point3.Left = num3 == -1 ? index1 * 10 + 9 + num1 : index1 * 10 + num3 + num1;
|
||||
int index4 = index2 + 1;
|
||||
while (index4 <= 9 && this._keyList[index1 * 10 + index4] == this._keyList[index3])
|
||||
++index4;
|
||||
point3.Right = index4 == 10 || this._keyList[index3] == this._keyList[index4] ? index1 * 10 + num1 : index1 * 10 + index4 + num1;
|
||||
if (index1 != 0)
|
||||
point3.Up = num2 - 10;
|
||||
point3.Down = index1 == 4 ? (index2 < 5 ? 3000 : 3001) : num2 + 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void CycleSymbols()
|
||||
{
|
||||
if (UIVirtualKeyboard._currentInstance == null)
|
||||
return;
|
||||
switch (UIVirtualKeyboard._currentInstance._keyState)
|
||||
{
|
||||
case UIVirtualKeyboard.KeyState.Default:
|
||||
UIVirtualKeyboard._currentInstance.SetKeyState(UIVirtualKeyboard.KeyState.Shift);
|
||||
break;
|
||||
case UIVirtualKeyboard.KeyState.Symbol:
|
||||
UIVirtualKeyboard._currentInstance.SetKeyState(UIVirtualKeyboard.KeyState.Default);
|
||||
break;
|
||||
case UIVirtualKeyboard.KeyState.Shift:
|
||||
UIVirtualKeyboard._currentInstance.SetKeyState(UIVirtualKeyboard.KeyState.Symbol);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void BackSpace()
|
||||
{
|
||||
if (UIVirtualKeyboard._currentInstance == null)
|
||||
return;
|
||||
Main.PlaySound(12);
|
||||
UIVirtualKeyboard._currentInstance._textBox.Backspace();
|
||||
UIVirtualKeyboard._currentInstance.ValidateText();
|
||||
}
|
||||
|
||||
public static bool CanSubmit => UIVirtualKeyboard._currentInstance != null && UIVirtualKeyboard._currentInstance._canSubmit;
|
||||
|
||||
public static void Submit()
|
||||
{
|
||||
if (UIVirtualKeyboard._currentInstance == null)
|
||||
return;
|
||||
string text = UIVirtualKeyboard._currentInstance.Text.Trim();
|
||||
if (text.Length <= 0)
|
||||
return;
|
||||
Main.PlaySound(10);
|
||||
UIVirtualKeyboard._currentInstance._submitAction(text);
|
||||
}
|
||||
|
||||
public static void Cancel()
|
||||
{
|
||||
if (UIVirtualKeyboard._currentInstance == null)
|
||||
return;
|
||||
Main.PlaySound(11);
|
||||
UIVirtualKeyboard._currentInstance._cancelAction();
|
||||
}
|
||||
|
||||
public static void Write(string text)
|
||||
{
|
||||
if (UIVirtualKeyboard._currentInstance == null)
|
||||
return;
|
||||
Main.PlaySound(12);
|
||||
int num = UIVirtualKeyboard._currentInstance.Text.Length == 0 ? 1 : 0;
|
||||
UIVirtualKeyboard._currentInstance._textBox.Write(text);
|
||||
UIVirtualKeyboard._currentInstance.ValidateText();
|
||||
if (num == 0 || UIVirtualKeyboard._currentInstance.Text.Length <= 0 || UIVirtualKeyboard._currentInstance._keyState != UIVirtualKeyboard.KeyState.Shift)
|
||||
return;
|
||||
UIVirtualKeyboard._currentInstance.SetKeyState(UIVirtualKeyboard.KeyState.Default);
|
||||
}
|
||||
|
||||
public static void CursorLeft()
|
||||
{
|
||||
if (UIVirtualKeyboard._currentInstance == null)
|
||||
return;
|
||||
Main.PlaySound(12);
|
||||
UIVirtualKeyboard._currentInstance._textBox.CursorLeft();
|
||||
}
|
||||
|
||||
public static void CursorRight()
|
||||
{
|
||||
if (UIVirtualKeyboard._currentInstance == null)
|
||||
return;
|
||||
Main.PlaySound(12);
|
||||
UIVirtualKeyboard._currentInstance._textBox.CursorRight();
|
||||
}
|
||||
|
||||
public static bool CanDisplay(int keyboardContext) => keyboardContext != 1 || Main.screenHeight > 700;
|
||||
|
||||
public static int KeyboardContext => UIVirtualKeyboard._currentInstance == null ? -1 : UIVirtualKeyboard._currentInstance._keyboardContext;
|
||||
|
||||
public static void CacheCancelledInput(int cacheMode)
|
||||
{
|
||||
if (cacheMode != 1)
|
||||
return;
|
||||
UIVirtualKeyboard._cancelCacheSign = Main.npcChatText;
|
||||
}
|
||||
|
||||
private void RestoreCancelledInput(int cacheMode)
|
||||
{
|
||||
if (cacheMode != 1)
|
||||
return;
|
||||
Main.npcChatText = UIVirtualKeyboard._cancelCacheSign;
|
||||
this.Text = Main.npcChatText;
|
||||
UIVirtualKeyboard._cancelCacheSign = "";
|
||||
}
|
||||
|
||||
private void CopyTextToSign()
|
||||
{
|
||||
if (!this._edittingSign)
|
||||
return;
|
||||
int sign = Main.player[Main.myPlayer].sign;
|
||||
if (sign < 0 || Main.sign[sign] == null)
|
||||
return;
|
||||
Main.npcChatText = this.Text;
|
||||
}
|
||||
|
||||
private void CopyTextToChest()
|
||||
{
|
||||
if (!this._edittingChest)
|
||||
return;
|
||||
Main.npcChatText = this.Text;
|
||||
}
|
||||
|
||||
public delegate void KeyboardSubmitEvent(string text);
|
||||
|
||||
public enum KeyState
|
||||
{
|
||||
Default,
|
||||
Symbol,
|
||||
Shift,
|
||||
}
|
||||
}
|
||||
}
|
62
GameContent/UI/States/UIWorldLoad.cs
Normal file
62
GameContent/UI/States/UIWorldLoad.cs
Normal file
|
@ -0,0 +1,62 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.States.UIWorldLoad
|
||||
// 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.GameContent.UI.Elements;
|
||||
using Terraria.GameInput;
|
||||
using Terraria.UI;
|
||||
using Terraria.UI.Gamepad;
|
||||
using Terraria.World.Generation;
|
||||
|
||||
namespace Terraria.GameContent.UI.States
|
||||
{
|
||||
public class UIWorldLoad : UIState
|
||||
{
|
||||
private UIGenProgressBar _progressBar = new UIGenProgressBar();
|
||||
private UIHeader _progressMessage = new UIHeader();
|
||||
private GenerationProgress _progress;
|
||||
|
||||
public UIWorldLoad(GenerationProgress progress)
|
||||
{
|
||||
this._progressBar.Top.Pixels = 370f;
|
||||
this._progressBar.HAlign = 0.5f;
|
||||
this._progressBar.VAlign = 0.0f;
|
||||
this._progressBar.Recalculate();
|
||||
this._progressMessage.CopyStyle((UIElement) this._progressBar);
|
||||
this._progressMessage.Top.Pixels -= 70f;
|
||||
this._progressMessage.Recalculate();
|
||||
this._progress = progress;
|
||||
this.Append((UIElement) this._progressBar);
|
||||
this.Append((UIElement) this._progressMessage);
|
||||
}
|
||||
|
||||
public override void OnActivate()
|
||||
{
|
||||
if (!PlayerInput.UsingGamepadUI)
|
||||
return;
|
||||
UILinkPointNavigator.Points[3000].Unlink();
|
||||
UILinkPointNavigator.ChangePoint(3000);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
this._progressBar.SetProgress(this._progress.TotalProgress, this._progress.Value);
|
||||
this._progressMessage.Text = this._progress.Message;
|
||||
this.UpdateGamepadSquiggle();
|
||||
}
|
||||
|
||||
private void UpdateGamepadSquiggle()
|
||||
{
|
||||
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.Points[3000].Unlink();
|
||||
UILinkPointNavigator.SetPosition(3000, new Vector2((float) Main.screenWidth, (float) Main.screenHeight) / 2f + vector2);
|
||||
}
|
||||
|
||||
public string GetStatusText() => string.Format("{0:0.0%} - " + this._progress.Message + " - {1:0.0%}", (object) this._progress.TotalProgress, (object) this._progress.Value);
|
||||
}
|
||||
}
|
259
GameContent/UI/States/UIWorldSelect.cs
Normal file
259
GameContent/UI/States/UIWorldSelect.cs
Normal file
|
@ -0,0 +1,259 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.States.UIWorldSelect
|
||||
// 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 System.Linq;
|
||||
using Terraria.GameContent.UI.Elements;
|
||||
using Terraria.GameInput;
|
||||
using Terraria.IO;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI;
|
||||
using Terraria.UI.Gamepad;
|
||||
|
||||
namespace Terraria.GameContent.UI.States
|
||||
{
|
||||
public class UIWorldSelect : UIState
|
||||
{
|
||||
private UIList _worldList;
|
||||
private UITextPanel<LocalizedText> _backPanel;
|
||||
private UITextPanel<LocalizedText> _newPanel;
|
||||
private UIPanel _containerPanel;
|
||||
private List<Tuple<string, bool>> favoritesCache = new List<Tuple<string, bool>>();
|
||||
private bool skipDraw;
|
||||
|
||||
public override void OnInitialize()
|
||||
{
|
||||
UIElement element = new UIElement();
|
||||
element.Width.Set(0.0f, 0.8f);
|
||||
element.MaxWidth.Set(650f, 0.0f);
|
||||
element.Top.Set(220f, 0.0f);
|
||||
element.Height.Set(-220f, 1f);
|
||||
element.HAlign = 0.5f;
|
||||
UIPanel uiPanel = new UIPanel();
|
||||
uiPanel.Width.Set(0.0f, 1f);
|
||||
uiPanel.Height.Set(-110f, 1f);
|
||||
uiPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f;
|
||||
element.Append((UIElement) uiPanel);
|
||||
this._containerPanel = uiPanel;
|
||||
this._worldList = new UIList();
|
||||
this._worldList.Width.Set(-25f, 1f);
|
||||
this._worldList.Height.Set(0.0f, 1f);
|
||||
this._worldList.ListPadding = 5f;
|
||||
uiPanel.Append((UIElement) this._worldList);
|
||||
UIScrollbar scrollbar = new UIScrollbar();
|
||||
scrollbar.SetView(100f, 1000f);
|
||||
scrollbar.Height.Set(0.0f, 1f);
|
||||
scrollbar.HAlign = 1f;
|
||||
uiPanel.Append((UIElement) scrollbar);
|
||||
this._worldList.SetScrollbar(scrollbar);
|
||||
UITextPanel<LocalizedText> uiTextPanel1 = new UITextPanel<LocalizedText>(Language.GetText("UI.SelectWorld"), 0.8f, true);
|
||||
uiTextPanel1.HAlign = 0.5f;
|
||||
uiTextPanel1.Top.Set(-35f, 0.0f);
|
||||
uiTextPanel1.SetPadding(15f);
|
||||
uiTextPanel1.BackgroundColor = new Color(73, 94, 171);
|
||||
element.Append((UIElement) uiTextPanel1);
|
||||
UITextPanel<LocalizedText> uiTextPanel2 = new UITextPanel<LocalizedText>(Language.GetText("UI.Back"), 0.7f, true);
|
||||
uiTextPanel2.Width.Set(-10f, 0.5f);
|
||||
uiTextPanel2.Height.Set(50f, 0.0f);
|
||||
uiTextPanel2.VAlign = 1f;
|
||||
uiTextPanel2.Top.Set(-45f, 0.0f);
|
||||
uiTextPanel2.OnMouseOver += new UIElement.MouseEvent(this.FadedMouseOver);
|
||||
uiTextPanel2.OnMouseOut += new UIElement.MouseEvent(this.FadedMouseOut);
|
||||
uiTextPanel2.OnClick += new UIElement.MouseEvent(this.GoBackClick);
|
||||
element.Append((UIElement) uiTextPanel2);
|
||||
this._backPanel = uiTextPanel2;
|
||||
UITextPanel<LocalizedText> uiTextPanel3 = new UITextPanel<LocalizedText>(Language.GetText("UI.New"), 0.7f, true);
|
||||
uiTextPanel3.CopyStyle((UIElement) uiTextPanel2);
|
||||
uiTextPanel3.HAlign = 1f;
|
||||
uiTextPanel3.OnMouseOver += new UIElement.MouseEvent(this.FadedMouseOver);
|
||||
uiTextPanel3.OnMouseOut += new UIElement.MouseEvent(this.FadedMouseOut);
|
||||
uiTextPanel3.OnClick += new UIElement.MouseEvent(this.NewWorldClick);
|
||||
element.Append((UIElement) uiTextPanel3);
|
||||
this._newPanel = uiTextPanel3;
|
||||
this.Append(element);
|
||||
}
|
||||
|
||||
private void NewWorldClick(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
Main.PlaySound(10);
|
||||
Main.menuMode = 16;
|
||||
Main.newWorldName = Lang.gen[57].Value + " " + (object) (Main.WorldList.Count + 1);
|
||||
}
|
||||
|
||||
private void GoBackClick(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
Main.PlaySound(11);
|
||||
Main.menuMode = Main.menuMultiplayer ? 12 : 1;
|
||||
}
|
||||
|
||||
private void FadedMouseOver(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
Main.PlaySound(12);
|
||||
((UIPanel) evt.Target).BackgroundColor = new Color(73, 94, 171);
|
||||
}
|
||||
|
||||
private void FadedMouseOut(UIMouseEvent evt, UIElement listeningElement) => ((UIPanel) evt.Target).BackgroundColor = new Color(63, 82, 151) * 0.7f;
|
||||
|
||||
public override void OnActivate()
|
||||
{
|
||||
Main.LoadWorlds();
|
||||
this.UpdateWorldsList();
|
||||
if (!PlayerInput.UsingGamepadUI)
|
||||
return;
|
||||
UILinkPointNavigator.ChangePoint(3000 + (this._worldList.Count == 0 ? 1 : 2));
|
||||
}
|
||||
|
||||
private void UpdateWorldsList()
|
||||
{
|
||||
this._worldList.Clear();
|
||||
List<WorldFileData> worldFileDataList = new List<WorldFileData>((IEnumerable<WorldFileData>) Main.WorldList);
|
||||
worldFileDataList.Sort((Comparison<WorldFileData>) ((x, y) =>
|
||||
{
|
||||
if (x.IsFavorite && !y.IsFavorite)
|
||||
return -1;
|
||||
if (!x.IsFavorite && y.IsFavorite)
|
||||
return 1;
|
||||
return x.Name.CompareTo(y.Name) != 0 ? x.Name.CompareTo(y.Name) : x.GetFileName().CompareTo(y.GetFileName());
|
||||
}));
|
||||
int num = 0;
|
||||
foreach (WorldFileData data in worldFileDataList)
|
||||
this._worldList.Add((UIElement) new UIWorldListItem(data, num++));
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
if (this.skipDraw)
|
||||
{
|
||||
this.skipDraw = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.UpdateFavoritesCache())
|
||||
{
|
||||
this.skipDraw = true;
|
||||
Main.MenuUI.Draw(spriteBatch, new GameTime());
|
||||
}
|
||||
base.Draw(spriteBatch);
|
||||
this.SetupGamepadPoints(spriteBatch);
|
||||
}
|
||||
}
|
||||
|
||||
private bool UpdateFavoritesCache()
|
||||
{
|
||||
List<WorldFileData> worldFileDataList = new List<WorldFileData>((IEnumerable<WorldFileData>) Main.WorldList);
|
||||
worldFileDataList.Sort((Comparison<WorldFileData>) ((x, y) =>
|
||||
{
|
||||
if (x.IsFavorite && !y.IsFavorite)
|
||||
return -1;
|
||||
if (!x.IsFavorite && y.IsFavorite)
|
||||
return 1;
|
||||
return x.Name.CompareTo(y.Name) != 0 ? x.Name.CompareTo(y.Name) : x.GetFileName().CompareTo(y.GetFileName());
|
||||
}));
|
||||
bool flag = false;
|
||||
if (!flag && worldFileDataList.Count != this.favoritesCache.Count)
|
||||
flag = true;
|
||||
if (!flag)
|
||||
{
|
||||
for (int index = 0; index < this.favoritesCache.Count; ++index)
|
||||
{
|
||||
Tuple<string, bool> tuple = this.favoritesCache[index];
|
||||
if (!(worldFileDataList[index].Name == tuple.Item1) || worldFileDataList[index].IsFavorite != tuple.Item2)
|
||||
{
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
this.favoritesCache.Clear();
|
||||
foreach (WorldFileData worldFileData in worldFileDataList)
|
||||
this.favoritesCache.Add(Tuple.Create<string, bool>(worldFileData.Name, worldFileData.IsFavorite));
|
||||
this.UpdateWorldsList();
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
private void SetupGamepadPoints(SpriteBatch spriteBatch)
|
||||
{
|
||||
UILinkPointNavigator.Shortcuts.BackButtonCommand = 2;
|
||||
int num1 = 3000;
|
||||
UILinkPointNavigator.SetPosition(num1, this._backPanel.GetInnerDimensions().ToRectangle().Center.ToVector2());
|
||||
UILinkPointNavigator.SetPosition(num1 + 1, this._newPanel.GetInnerDimensions().ToRectangle().Center.ToVector2());
|
||||
int key1 = num1;
|
||||
UILinkPoint point1 = UILinkPointNavigator.Points[key1];
|
||||
point1.Unlink();
|
||||
point1.Right = key1 + 1;
|
||||
int key2 = num1 + 1;
|
||||
UILinkPoint point2 = UILinkPointNavigator.Points[key2];
|
||||
point2.Unlink();
|
||||
point2.Left = key2 - 1;
|
||||
Rectangle clippingRectangle = this._containerPanel.GetClippingRectangle(spriteBatch);
|
||||
Vector2 minimum = clippingRectangle.TopLeft();
|
||||
Vector2 maximum = clippingRectangle.BottomRight();
|
||||
List<SnapPoint> snapPoints = this.GetSnapPoints();
|
||||
for (int index = 0; index < snapPoints.Count; ++index)
|
||||
{
|
||||
if (!snapPoints[index].Position.Between(minimum, maximum))
|
||||
{
|
||||
snapPoints.Remove(snapPoints[index]);
|
||||
--index;
|
||||
}
|
||||
}
|
||||
SnapPoint[,] snapPointArray = new SnapPoint[this._worldList.Count, 5];
|
||||
foreach (SnapPoint snapPoint in snapPoints.Where<SnapPoint>((Func<SnapPoint, bool>) (a => a.Name == "Play")))
|
||||
snapPointArray[snapPoint.ID, 0] = snapPoint;
|
||||
foreach (SnapPoint snapPoint in snapPoints.Where<SnapPoint>((Func<SnapPoint, bool>) (a => a.Name == "Favorite")))
|
||||
snapPointArray[snapPoint.ID, 1] = snapPoint;
|
||||
foreach (SnapPoint snapPoint in snapPoints.Where<SnapPoint>((Func<SnapPoint, bool>) (a => a.Name == "Cloud")))
|
||||
snapPointArray[snapPoint.ID, 2] = snapPoint;
|
||||
foreach (SnapPoint snapPoint in snapPoints.Where<SnapPoint>((Func<SnapPoint, bool>) (a => a.Name == "Seed")))
|
||||
snapPointArray[snapPoint.ID, 3] = snapPoint;
|
||||
foreach (SnapPoint snapPoint in snapPoints.Where<SnapPoint>((Func<SnapPoint, bool>) (a => a.Name == "Delete")))
|
||||
snapPointArray[snapPoint.ID, 4] = snapPoint;
|
||||
int num2 = num1 + 2;
|
||||
int[] numArray = new int[this._worldList.Count];
|
||||
for (int index = 0; index < numArray.Length; ++index)
|
||||
numArray[index] = -1;
|
||||
for (int index1 = 0; index1 < 5; ++index1)
|
||||
{
|
||||
int key3 = -1;
|
||||
for (int index2 = 0; index2 < snapPointArray.GetLength(0); ++index2)
|
||||
{
|
||||
if (snapPointArray[index2, index1] != null)
|
||||
{
|
||||
UILinkPoint point3 = UILinkPointNavigator.Points[num2];
|
||||
point3.Unlink();
|
||||
UILinkPointNavigator.SetPosition(num2, snapPointArray[index2, index1].Position);
|
||||
if (key3 != -1)
|
||||
{
|
||||
point3.Up = key3;
|
||||
UILinkPointNavigator.Points[key3].Down = num2;
|
||||
}
|
||||
if (numArray[index2] != -1)
|
||||
{
|
||||
point3.Left = numArray[index2];
|
||||
UILinkPointNavigator.Points[numArray[index2]].Right = num2;
|
||||
}
|
||||
point3.Down = num1;
|
||||
if (index1 == 0)
|
||||
UILinkPointNavigator.Points[num1].Up = UILinkPointNavigator.Points[num1 + 1].Up = num2;
|
||||
key3 = num2;
|
||||
numArray[index2] = num2;
|
||||
UILinkPointNavigator.Shortcuts.FANCYUI_HIGHEST_INDEX = num2;
|
||||
++num2;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!PlayerInput.UsingGamepadUI || this._worldList.Count != 0 || UILinkPointNavigator.CurrentPoint <= 3001)
|
||||
return;
|
||||
UILinkPointNavigator.ChangePoint(3001);
|
||||
}
|
||||
}
|
||||
}
|
595
GameContent/UI/WiresUI.cs
Normal file
595
GameContent/UI/WiresUI.cs
Normal file
|
@ -0,0 +1,595 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.WiresUI
|
||||
// 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.GameInput;
|
||||
|
||||
namespace Terraria.GameContent.UI
|
||||
{
|
||||
public class WiresUI
|
||||
{
|
||||
private static WiresUI.WiresRadial radial = new WiresUI.WiresRadial();
|
||||
|
||||
public static bool Open => WiresUI.radial.active;
|
||||
|
||||
public static void HandleWiresUI(SpriteBatch spriteBatch)
|
||||
{
|
||||
WiresUI.radial.Update();
|
||||
WiresUI.radial.Draw(spriteBatch);
|
||||
}
|
||||
|
||||
public static class Settings
|
||||
{
|
||||
public static WiresUI.Settings.MultiToolMode ToolMode = WiresUI.Settings.MultiToolMode.Red;
|
||||
private static int _lastActuatorEnabled = 0;
|
||||
|
||||
public static bool DrawWires
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Main.player[Main.myPlayer].inventory[Main.player[Main.myPlayer].selectedItem].mech)
|
||||
return true;
|
||||
return Main.player[Main.myPlayer].InfoAccMechShowWires && Main.player[Main.myPlayer].builderAccStatus[8] == 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool HideWires => Main.player[Main.myPlayer].inventory[Main.player[Main.myPlayer].selectedItem].type == 3620;
|
||||
|
||||
public static bool DrawToolModeUI
|
||||
{
|
||||
get
|
||||
{
|
||||
int type = Main.player[Main.myPlayer].inventory[Main.player[Main.myPlayer].selectedItem].type;
|
||||
return type == 3611 || type == 3625;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool DrawToolAllowActuators
|
||||
{
|
||||
get
|
||||
{
|
||||
int type = Main.player[Main.myPlayer].inventory[Main.player[Main.myPlayer].selectedItem].type;
|
||||
if (type == 3611)
|
||||
WiresUI.Settings._lastActuatorEnabled = 2;
|
||||
if (type == 3625)
|
||||
WiresUI.Settings._lastActuatorEnabled = 1;
|
||||
return WiresUI.Settings._lastActuatorEnabled == 2;
|
||||
}
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum MultiToolMode
|
||||
{
|
||||
Red = 1,
|
||||
Green = 2,
|
||||
Blue = 4,
|
||||
Yellow = 8,
|
||||
Actuator = 16, // 0x00000010
|
||||
Cutter = 32, // 0x00000020
|
||||
}
|
||||
}
|
||||
|
||||
public class WiresRadial
|
||||
{
|
||||
public Vector2 position;
|
||||
public bool active;
|
||||
public bool OnWiresMenu;
|
||||
private float _lineOpacity;
|
||||
|
||||
public void Update()
|
||||
{
|
||||
this.FlowerUpdate();
|
||||
this.LineUpdate();
|
||||
}
|
||||
|
||||
private void LineUpdate()
|
||||
{
|
||||
bool flag1 = true;
|
||||
float min = 0.75f;
|
||||
Player player = Main.player[Main.myPlayer];
|
||||
if (!WiresUI.Settings.DrawToolModeUI || Main.drawingPlayerChat)
|
||||
{
|
||||
flag1 = false;
|
||||
min = 0.0f;
|
||||
}
|
||||
bool flag2;
|
||||
if (player.dead || Main.mouseItem.type > 0)
|
||||
{
|
||||
flag2 = false;
|
||||
this._lineOpacity = 0.0f;
|
||||
}
|
||||
else if (player.showItemIcon && player.showItemIcon2 != 0 && player.showItemIcon2 != 3625)
|
||||
{
|
||||
flag2 = false;
|
||||
this._lineOpacity = 0.0f;
|
||||
}
|
||||
else if (!player.showItemIcon && (!PlayerInput.UsingGamepad && !WiresUI.Settings.DrawToolAllowActuators || player.mouseInterface || player.lastMouseInterface) || Main.ingameOptionsWindow || Main.InGameUI.IsVisible)
|
||||
{
|
||||
flag2 = false;
|
||||
this._lineOpacity = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
float num = Utils.Clamp<float>(this._lineOpacity + 0.05f * (float) flag1.ToDirectionInt(), min, 1f);
|
||||
this._lineOpacity += 0.05f * (float) Math.Sign(num - this._lineOpacity);
|
||||
if ((double) Math.Abs(this._lineOpacity - num) >= 0.0500000007450581)
|
||||
return;
|
||||
this._lineOpacity = num;
|
||||
}
|
||||
}
|
||||
|
||||
private void FlowerUpdate()
|
||||
{
|
||||
Player player = Main.player[Main.myPlayer];
|
||||
if (!WiresUI.Settings.DrawToolModeUI)
|
||||
this.active = false;
|
||||
else if ((player.mouseInterface || player.lastMouseInterface) && !this.OnWiresMenu)
|
||||
this.active = false;
|
||||
else if (player.dead || Main.mouseItem.type > 0)
|
||||
{
|
||||
this.active = false;
|
||||
this.OnWiresMenu = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.OnWiresMenu = false;
|
||||
if (!Main.mouseRight || !Main.mouseRightRelease || PlayerInput.LockTileUseButton || player.noThrow != 0 || Main.HoveringOverAnNPC || player.talkNPC != -1)
|
||||
return;
|
||||
if (this.active)
|
||||
{
|
||||
this.active = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Main.SmartInteractShowingGenuine)
|
||||
return;
|
||||
this.active = true;
|
||||
this.position = Main.MouseScreen;
|
||||
if (!PlayerInput.UsingGamepad || !Main.SmartCursorEnabled)
|
||||
return;
|
||||
this.position = new Vector2((float) Main.screenWidth, (float) Main.screenHeight) / 2f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
this.DrawFlower(spriteBatch);
|
||||
this.DrawCursorArea(spriteBatch);
|
||||
}
|
||||
|
||||
private void DrawLine(SpriteBatch spriteBatch)
|
||||
{
|
||||
if (this.active || (double) this._lineOpacity == 0.0)
|
||||
return;
|
||||
Vector2 vector2_1 = Main.MouseScreen;
|
||||
Vector2 vector2_2 = new Vector2((float) (Main.screenWidth / 2), (float) (Main.screenHeight - 70));
|
||||
if (PlayerInput.UsingGamepad)
|
||||
vector2_1 = Vector2.Zero;
|
||||
Vector2 v = vector2_1 - vector2_2;
|
||||
double num1 = (double) Vector2.Dot(Vector2.Normalize(v), Vector2.UnitX);
|
||||
double num2 = (double) Vector2.Dot(Vector2.Normalize(v), Vector2.UnitY);
|
||||
double rotation = (double) v.ToRotation();
|
||||
double num3 = (double) v.Length();
|
||||
bool flag1 = false;
|
||||
bool toolAllowActuators = WiresUI.Settings.DrawToolAllowActuators;
|
||||
for (int index = 0; index < 6; ++index)
|
||||
{
|
||||
if (toolAllowActuators || index != 5)
|
||||
{
|
||||
bool flag2 = WiresUI.Settings.ToolMode.HasFlag((Enum) (WiresUI.Settings.MultiToolMode) (1 << index));
|
||||
if (index == 5)
|
||||
flag2 = WiresUI.Settings.ToolMode.HasFlag((Enum) WiresUI.Settings.MultiToolMode.Actuator);
|
||||
Vector2 vector2_3 = vector2_2 + Vector2.UnitX * (float) (45.0 * ((double) index - 1.5));
|
||||
int num4 = index;
|
||||
if (index == 0)
|
||||
num4 = 3;
|
||||
if (index == 3)
|
||||
num4 = 0;
|
||||
switch (num4)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
vector2_3 = vector2_2 + new Vector2((float) (45.0 + (toolAllowActuators ? 15.0 : 0.0)) * (float) (2 - num4), 0.0f) * this._lineOpacity;
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
vector2_3 = vector2_2 + new Vector2((float) -(45.0 + (toolAllowActuators ? 15.0 : 0.0)) * (float) (num4 - 1), 0.0f) * this._lineOpacity;
|
||||
break;
|
||||
case 4:
|
||||
flag2 = false;
|
||||
vector2_3 = vector2_2 - new Vector2(0.0f, toolAllowActuators ? 22f : 0.0f) * this._lineOpacity;
|
||||
break;
|
||||
case 5:
|
||||
vector2_3 = vector2_2 + new Vector2(0.0f, 22f) * this._lineOpacity;
|
||||
break;
|
||||
}
|
||||
bool flag3 = false;
|
||||
if (!PlayerInput.UsingGamepad)
|
||||
flag3 = (double) Vector2.Distance(vector2_3, vector2_1) < 19.0 * (double) this._lineOpacity;
|
||||
if (flag1)
|
||||
flag3 = false;
|
||||
if (flag3)
|
||||
flag1 = true;
|
||||
Texture2D texture2D1 = Main.wireUITexture[(WiresUI.Settings.ToolMode.HasFlag((Enum) WiresUI.Settings.MultiToolMode.Cutter) ? 8 : 0) + (flag3 ? 1 : 0)];
|
||||
Texture2D texture2D2 = (Texture2D) null;
|
||||
switch (index)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
texture2D2 = Main.wireUITexture[2 + index];
|
||||
break;
|
||||
case 4:
|
||||
texture2D2 = Main.wireUITexture[WiresUI.Settings.ToolMode.HasFlag((Enum) WiresUI.Settings.MultiToolMode.Cutter) ? 7 : 6];
|
||||
break;
|
||||
case 5:
|
||||
texture2D2 = Main.wireUITexture[10];
|
||||
break;
|
||||
}
|
||||
Color color1 = Color.White;
|
||||
Color color2 = Color.White;
|
||||
if (!flag2 && index != 4)
|
||||
{
|
||||
if (flag3)
|
||||
{
|
||||
color2 = new Color(100, 100, 100);
|
||||
color2 = new Color(120, 120, 120);
|
||||
color1 = new Color(200, 200, 200);
|
||||
}
|
||||
else
|
||||
{
|
||||
color2 = new Color(150, 150, 150);
|
||||
color2 = new Color(80, 80, 80);
|
||||
color1 = new Color(100, 100, 100);
|
||||
}
|
||||
}
|
||||
Utils.CenteredRectangle(vector2_3, new Vector2(40f));
|
||||
if (flag3)
|
||||
{
|
||||
if (Main.mouseLeft && Main.mouseLeftRelease)
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case 0:
|
||||
WiresUI.Settings.ToolMode ^= WiresUI.Settings.MultiToolMode.Red;
|
||||
break;
|
||||
case 1:
|
||||
WiresUI.Settings.ToolMode ^= WiresUI.Settings.MultiToolMode.Green;
|
||||
break;
|
||||
case 2:
|
||||
WiresUI.Settings.ToolMode ^= WiresUI.Settings.MultiToolMode.Blue;
|
||||
break;
|
||||
case 3:
|
||||
WiresUI.Settings.ToolMode ^= WiresUI.Settings.MultiToolMode.Yellow;
|
||||
break;
|
||||
case 4:
|
||||
WiresUI.Settings.ToolMode ^= WiresUI.Settings.MultiToolMode.Cutter;
|
||||
break;
|
||||
case 5:
|
||||
WiresUI.Settings.ToolMode ^= WiresUI.Settings.MultiToolMode.Actuator;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!Main.mouseLeft || Main.player[Main.myPlayer].mouseInterface)
|
||||
Main.player[Main.myPlayer].mouseInterface = true;
|
||||
this.OnWiresMenu = true;
|
||||
}
|
||||
int num5 = flag3 ? 1 : 0;
|
||||
spriteBatch.Draw(texture2D1, vector2_3, new Rectangle?(), color1 * this._lineOpacity, 0.0f, texture2D1.Size() / 2f, this._lineOpacity, SpriteEffects.None, 0.0f);
|
||||
spriteBatch.Draw(texture2D2, vector2_3, new Rectangle?(), color2 * this._lineOpacity, 0.0f, texture2D2.Size() / 2f, this._lineOpacity, SpriteEffects.None, 0.0f);
|
||||
}
|
||||
}
|
||||
if (!Main.mouseLeft || !Main.mouseLeftRelease || flag1)
|
||||
return;
|
||||
this.active = false;
|
||||
}
|
||||
|
||||
private void DrawFlower(SpriteBatch spriteBatch)
|
||||
{
|
||||
if (!this.active)
|
||||
return;
|
||||
Vector2 vector2_1 = Main.MouseScreen;
|
||||
Vector2 position = this.position;
|
||||
if (PlayerInput.UsingGamepad && Main.SmartCursorEnabled)
|
||||
vector2_1 = !(PlayerInput.GamepadThumbstickRight != Vector2.Zero) ? (!(PlayerInput.GamepadThumbstickLeft != Vector2.Zero) ? this.position : this.position + PlayerInput.GamepadThumbstickLeft * 40f) : this.position + PlayerInput.GamepadThumbstickRight * 40f;
|
||||
Vector2 v = vector2_1 - position;
|
||||
double num1 = (double) Vector2.Dot(Vector2.Normalize(v), Vector2.UnitX);
|
||||
double num2 = (double) Vector2.Dot(Vector2.Normalize(v), Vector2.UnitY);
|
||||
float rotation = v.ToRotation();
|
||||
float num3 = v.Length();
|
||||
bool flag1 = false;
|
||||
bool toolAllowActuators = WiresUI.Settings.DrawToolAllowActuators;
|
||||
float num4 = (float) (4 + toolAllowActuators.ToInt());
|
||||
float num5 = toolAllowActuators ? 11f : -0.5f;
|
||||
for (int index = 0; index < 6; ++index)
|
||||
{
|
||||
if (toolAllowActuators || index != 5)
|
||||
{
|
||||
bool flag2 = WiresUI.Settings.ToolMode.HasFlag((Enum) (WiresUI.Settings.MultiToolMode) (1 << index));
|
||||
if (index == 5)
|
||||
flag2 = WiresUI.Settings.ToolMode.HasFlag((Enum) WiresUI.Settings.MultiToolMode.Actuator);
|
||||
Vector2 vector2_2 = position + Vector2.UnitX * (float) (45.0 * ((double) index - 1.5));
|
||||
switch (index)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
float num6 = (float) index;
|
||||
if (index == 0)
|
||||
num6 = 3f;
|
||||
if (index == 3)
|
||||
num6 = 0.0f;
|
||||
vector2_2 = position + Vector2.UnitX.RotatedBy((double) num6 * 6.28318548202515 / (double) num4 - 3.14159274101257 / (double) num5) * 45f;
|
||||
break;
|
||||
case 4:
|
||||
flag2 = false;
|
||||
vector2_2 = position;
|
||||
break;
|
||||
case 5:
|
||||
vector2_2 = position + Vector2.UnitX.RotatedBy((double) (index - 1) * 6.28318548202515 / (double) num4 - 3.14159274101257 / (double) num5) * 45f;
|
||||
break;
|
||||
}
|
||||
bool flag3 = false;
|
||||
if (index == 4)
|
||||
flag3 = (double) num3 < 20.0;
|
||||
switch (index)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 5:
|
||||
float num7 = (vector2_2 - position).ToRotation().AngleTowards(rotation, (float) (6.28318548202515 / ((double) num4 * 2.0))) - rotation;
|
||||
if ((double) num3 >= 20.0 && (double) Math.Abs(num7) < 0.00999999977648258)
|
||||
{
|
||||
flag3 = true;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
flag3 = (double) num3 < 20.0;
|
||||
break;
|
||||
}
|
||||
if (!PlayerInput.UsingGamepad)
|
||||
flag3 = (double) Vector2.Distance(vector2_2, vector2_1) < 19.0;
|
||||
if (flag1)
|
||||
flag3 = false;
|
||||
if (flag3)
|
||||
flag1 = true;
|
||||
Texture2D texture2D1 = Main.wireUITexture[(WiresUI.Settings.ToolMode.HasFlag((Enum) WiresUI.Settings.MultiToolMode.Cutter) ? 8 : 0) + (flag3 ? 1 : 0)];
|
||||
Texture2D texture2D2 = (Texture2D) null;
|
||||
switch (index)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
texture2D2 = Main.wireUITexture[2 + index];
|
||||
break;
|
||||
case 4:
|
||||
texture2D2 = Main.wireUITexture[WiresUI.Settings.ToolMode.HasFlag((Enum) WiresUI.Settings.MultiToolMode.Cutter) ? 7 : 6];
|
||||
break;
|
||||
case 5:
|
||||
texture2D2 = Main.wireUITexture[10];
|
||||
break;
|
||||
}
|
||||
Color color1 = Color.White;
|
||||
Color color2 = Color.White;
|
||||
if (!flag2 && index != 4)
|
||||
{
|
||||
if (flag3)
|
||||
{
|
||||
color2 = new Color(100, 100, 100);
|
||||
color2 = new Color(120, 120, 120);
|
||||
color1 = new Color(200, 200, 200);
|
||||
}
|
||||
else
|
||||
{
|
||||
color2 = new Color(150, 150, 150);
|
||||
color2 = new Color(80, 80, 80);
|
||||
color1 = new Color(100, 100, 100);
|
||||
}
|
||||
}
|
||||
Utils.CenteredRectangle(vector2_2, new Vector2(40f));
|
||||
if (flag3)
|
||||
{
|
||||
if (Main.mouseLeft && Main.mouseLeftRelease)
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case 0:
|
||||
WiresUI.Settings.ToolMode ^= WiresUI.Settings.MultiToolMode.Red;
|
||||
break;
|
||||
case 1:
|
||||
WiresUI.Settings.ToolMode ^= WiresUI.Settings.MultiToolMode.Green;
|
||||
break;
|
||||
case 2:
|
||||
WiresUI.Settings.ToolMode ^= WiresUI.Settings.MultiToolMode.Blue;
|
||||
break;
|
||||
case 3:
|
||||
WiresUI.Settings.ToolMode ^= WiresUI.Settings.MultiToolMode.Yellow;
|
||||
break;
|
||||
case 4:
|
||||
WiresUI.Settings.ToolMode ^= WiresUI.Settings.MultiToolMode.Cutter;
|
||||
break;
|
||||
case 5:
|
||||
WiresUI.Settings.ToolMode ^= WiresUI.Settings.MultiToolMode.Actuator;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Main.player[Main.myPlayer].mouseInterface = true;
|
||||
this.OnWiresMenu = true;
|
||||
}
|
||||
int num8 = flag3 ? 1 : 0;
|
||||
spriteBatch.Draw(texture2D1, vector2_2, new Rectangle?(), color1, 0.0f, texture2D1.Size() / 2f, 1f, SpriteEffects.None, 0.0f);
|
||||
spriteBatch.Draw(texture2D2, vector2_2, new Rectangle?(), color2, 0.0f, texture2D2.Size() / 2f, 1f, SpriteEffects.None, 0.0f);
|
||||
}
|
||||
}
|
||||
if (!Main.mouseLeft || !Main.mouseLeftRelease || flag1)
|
||||
return;
|
||||
this.active = false;
|
||||
}
|
||||
|
||||
private void DrawCursorArea(SpriteBatch spriteBatch)
|
||||
{
|
||||
if (this.active || (double) this._lineOpacity == 0.0)
|
||||
return;
|
||||
Vector2 vector2 = Main.MouseScreen + new Vector2((float) (10 - 9 * PlayerInput.UsingGamepad.ToInt()), 25f);
|
||||
Color color1 = new Color(50, 50, 50);
|
||||
bool toolAllowActuators = WiresUI.Settings.DrawToolAllowActuators;
|
||||
if (!toolAllowActuators)
|
||||
{
|
||||
if (!PlayerInput.UsingGamepad)
|
||||
vector2 += new Vector2(-20f, 10f);
|
||||
else
|
||||
vector2 += new Vector2(0.0f, 10f);
|
||||
}
|
||||
Texture2D builderAccTexture = Main.builderAccTexture;
|
||||
Texture2D texture = builderAccTexture;
|
||||
Rectangle r1 = new Rectangle(140, 2, 6, 6);
|
||||
Rectangle r2 = new Rectangle(148, 2, 6, 6);
|
||||
Rectangle r3 = new Rectangle(128, 0, 10, 10);
|
||||
float num1 = 1f;
|
||||
float scale = 1f;
|
||||
bool flag1 = false;
|
||||
if (flag1 && !toolAllowActuators)
|
||||
num1 *= Main.cursorScale;
|
||||
float lineOpacity = this._lineOpacity;
|
||||
if (PlayerInput.UsingGamepad)
|
||||
lineOpacity *= Main.GamepadCursorAlpha;
|
||||
for (int index = 0; index < 5; ++index)
|
||||
{
|
||||
if (toolAllowActuators || index != 4)
|
||||
{
|
||||
float num2 = lineOpacity;
|
||||
Vector2 vec = vector2 + Vector2.UnitX * (float) (45.0 * ((double) index - 1.5));
|
||||
int num3 = index;
|
||||
if (index == 0)
|
||||
num3 = 3;
|
||||
if (index == 1)
|
||||
num3 = 2;
|
||||
if (index == 2)
|
||||
num3 = 1;
|
||||
if (index == 3)
|
||||
num3 = 0;
|
||||
if (index == 4)
|
||||
num3 = 5;
|
||||
int num4 = num3;
|
||||
switch (num4)
|
||||
{
|
||||
case 1:
|
||||
num4 = 2;
|
||||
break;
|
||||
case 2:
|
||||
num4 = 1;
|
||||
break;
|
||||
}
|
||||
bool flag2 = WiresUI.Settings.ToolMode.HasFlag((Enum) (WiresUI.Settings.MultiToolMode) (1 << num4));
|
||||
if (num4 == 5)
|
||||
flag2 = WiresUI.Settings.ToolMode.HasFlag((Enum) WiresUI.Settings.MultiToolMode.Actuator);
|
||||
Color color2 = Color.HotPink;
|
||||
switch (num3)
|
||||
{
|
||||
case 0:
|
||||
color2 = new Color(253, 58, 61);
|
||||
break;
|
||||
case 1:
|
||||
color2 = new Color(83, 180, 253);
|
||||
break;
|
||||
case 2:
|
||||
color2 = new Color(83, 253, 153);
|
||||
break;
|
||||
case 3:
|
||||
color2 = new Color(253, 254, 83);
|
||||
break;
|
||||
case 5:
|
||||
color2 = Color.WhiteSmoke;
|
||||
break;
|
||||
}
|
||||
if (!flag2)
|
||||
color2 = Color.Lerp(color2, Color.Black, 0.65f);
|
||||
if (flag1)
|
||||
{
|
||||
if (toolAllowActuators)
|
||||
{
|
||||
switch (num3)
|
||||
{
|
||||
case 0:
|
||||
vec = vector2 + new Vector2(-12f, 0.0f) * num1;
|
||||
break;
|
||||
case 1:
|
||||
vec = vector2 + new Vector2(-6f, 12f) * num1;
|
||||
break;
|
||||
case 2:
|
||||
vec = vector2 + new Vector2(6f, 12f) * num1;
|
||||
break;
|
||||
case 3:
|
||||
vec = vector2 + new Vector2(12f, 0.0f) * num1;
|
||||
break;
|
||||
case 5:
|
||||
vec = vector2 + new Vector2(0.0f, 0.0f) * num1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
vec = vector2 + new Vector2((float) (12 * (num3 + 1)), (float) (12 * (3 - num3))) * num1;
|
||||
}
|
||||
else if (toolAllowActuators)
|
||||
{
|
||||
switch (num3)
|
||||
{
|
||||
case 0:
|
||||
vec = vector2 + new Vector2(-12f, 0.0f) * num1;
|
||||
break;
|
||||
case 1:
|
||||
vec = vector2 + new Vector2(-6f, 12f) * num1;
|
||||
break;
|
||||
case 2:
|
||||
vec = vector2 + new Vector2(6f, 12f) * num1;
|
||||
break;
|
||||
case 3:
|
||||
vec = vector2 + new Vector2(12f, 0.0f) * num1;
|
||||
break;
|
||||
case 5:
|
||||
vec = vector2 + new Vector2(0.0f, 0.0f) * num1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float num5 = 0.7f;
|
||||
switch (num3)
|
||||
{
|
||||
case 0:
|
||||
vec = vector2 + new Vector2(0.0f, -12f) * num1 * num5;
|
||||
break;
|
||||
case 1:
|
||||
vec = vector2 + new Vector2(-12f, 0.0f) * num1 * num5;
|
||||
break;
|
||||
case 2:
|
||||
vec = vector2 + new Vector2(0.0f, 12f) * num1 * num5;
|
||||
break;
|
||||
case 3:
|
||||
vec = vector2 + new Vector2(12f, 0.0f) * num1 * num5;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Vector2 position = vec.Floor();
|
||||
spriteBatch.Draw(texture, position, new Rectangle?(r3), color1 * num2, 0.0f, r3.Size() / 2f, scale, SpriteEffects.None, 0.0f);
|
||||
spriteBatch.Draw(builderAccTexture, position, new Rectangle?(r1), color2 * num2, 0.0f, r1.Size() / 2f, scale, SpriteEffects.None, 0.0f);
|
||||
if (WiresUI.Settings.ToolMode.HasFlag((Enum) WiresUI.Settings.MultiToolMode.Cutter))
|
||||
spriteBatch.Draw(builderAccTexture, position, new Rectangle?(r2), color1 * num2, 0.0f, r2.Size() / 2f, scale, SpriteEffects.None, 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
63
GameContent/UI/WorldUIAnchor.cs
Normal file
63
GameContent/UI/WorldUIAnchor.cs
Normal file
|
@ -0,0 +1,63 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.WorldUIAnchor
|
||||
// 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.GameContent.UI
|
||||
{
|
||||
public class WorldUIAnchor
|
||||
{
|
||||
public WorldUIAnchor.AnchorType type;
|
||||
public Entity entity;
|
||||
public Vector2 pos = Vector2.Zero;
|
||||
public Vector2 size = Vector2.Zero;
|
||||
|
||||
public WorldUIAnchor() => this.type = WorldUIAnchor.AnchorType.None;
|
||||
|
||||
public WorldUIAnchor(Entity anchor)
|
||||
{
|
||||
this.type = WorldUIAnchor.AnchorType.Entity;
|
||||
this.entity = anchor;
|
||||
}
|
||||
|
||||
public WorldUIAnchor(Vector2 anchor)
|
||||
{
|
||||
this.type = WorldUIAnchor.AnchorType.Pos;
|
||||
this.pos = anchor;
|
||||
}
|
||||
|
||||
public WorldUIAnchor(int topLeftX, int topLeftY, int width, int height)
|
||||
{
|
||||
this.type = WorldUIAnchor.AnchorType.Tile;
|
||||
this.pos = new Vector2((float) topLeftX + (float) width / 2f, (float) topLeftY + (float) height / 2f) * 16f;
|
||||
this.size = new Vector2((float) width, (float) height) * 16f;
|
||||
}
|
||||
|
||||
public bool InRange(Vector2 target, float tileRangeX, float tileRangeY)
|
||||
{
|
||||
switch (this.type)
|
||||
{
|
||||
case WorldUIAnchor.AnchorType.Entity:
|
||||
return (double) Math.Abs(target.X - this.entity.Center.X) <= (double) tileRangeX * 16.0 + (double) this.entity.width / 2.0 && (double) Math.Abs(target.Y - this.entity.Center.Y) <= (double) tileRangeY * 16.0 + (double) this.entity.height / 2.0;
|
||||
case WorldUIAnchor.AnchorType.Tile:
|
||||
return (double) Math.Abs(target.X - this.pos.X) <= (double) tileRangeX * 16.0 + (double) this.size.X / 2.0 && (double) Math.Abs(target.Y - this.pos.Y) <= (double) tileRangeY * 16.0 + (double) this.size.Y / 2.0;
|
||||
case WorldUIAnchor.AnchorType.Pos:
|
||||
return (double) Math.Abs(target.X - this.pos.X) <= (double) tileRangeX * 16.0 && (double) Math.Abs(target.Y - this.pos.Y) <= (double) tileRangeY * 16.0;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public enum AnchorType
|
||||
{
|
||||
Entity,
|
||||
Tile,
|
||||
Pos,
|
||||
None,
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue