Terraria 1.4.0.5 Source Code
This commit is contained in:
commit
05205f009e
1059 changed files with 563450 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.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria.Achievements;
|
||||
using Terraria.UI;
|
||||
using Terraria.UI.Chat;
|
||||
|
||||
namespace Terraria.GameContent.UI.Chat
|
||||
{
|
||||
public class AchievementTagHandler : ITagHandler
|
||||
{
|
||||
TextSnippet ITagHandler.Parse(
|
||||
string text,
|
||||
Color baseColor,
|
||||
string options)
|
||||
{
|
||||
Achievement achievement = Main.Achievements.GetAchievement(text);
|
||||
return achievement == null ? new TextSnippet(text) : (TextSnippet) new AchievementTagHandler.AchievementSnippet(achievement);
|
||||
}
|
||||
|
||||
public static string GenerateTag(Achievement achievement) => "[a:" + achievement.Name + "]";
|
||||
|
||||
private class AchievementSnippet : TextSnippet
|
||||
{
|
||||
private Achievement _achievement;
|
||||
|
||||
public AchievementSnippet(Achievement achievement)
|
||||
: base(achievement.FriendlyName.Value, Color.LightBlue)
|
||||
{
|
||||
this.CheckForHover = true;
|
||||
this._achievement = achievement;
|
||||
}
|
||||
|
||||
public override void OnClick()
|
||||
{
|
||||
IngameOptions.Close();
|
||||
IngameFancyUI.OpenAchievementsAndGoto(this._achievement);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
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.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using Terraria.UI.Chat;
|
||||
|
||||
namespace Terraria.GameContent.UI.Chat
|
||||
{
|
||||
public class ColorTagHandler : ITagHandler
|
||||
{
|
||||
TextSnippet ITagHandler.Parse(
|
||||
string text,
|
||||
Color baseColor,
|
||||
string options)
|
||||
{
|
||||
TextSnippet textSnippet = new TextSnippet(text);
|
||||
int result;
|
||||
if (!int.TryParse(options, NumberStyles.AllowHexSpecifier, (IFormatProvider) CultureInfo.InvariantCulture, out result))
|
||||
return textSnippet;
|
||||
textSnippet.Color = new Color(result >> 16 & (int) byte.MaxValue, result >> 8 & (int) byte.MaxValue, result & (int) byte.MaxValue);
|
||||
return textSnippet;
|
||||
}
|
||||
}
|
||||
}
|
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.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using ReLogic.Graphics;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.UI.Chat;
|
||||
|
||||
namespace Terraria.GameContent.UI.Chat
|
||||
{
|
||||
public class GlyphTagHandler : ITagHandler
|
||||
{
|
||||
private const int GlyphsPerLine = 25;
|
||||
private const int MaxGlyphs = 26;
|
||||
public static float GlyphsScale = 1f;
|
||||
private static Dictionary<string, int> GlyphIndexes = new Dictionary<string, int>()
|
||||
{
|
||||
{
|
||||
Buttons.A.ToString(),
|
||||
0
|
||||
},
|
||||
{
|
||||
Buttons.B.ToString(),
|
||||
1
|
||||
},
|
||||
{
|
||||
Buttons.Back.ToString(),
|
||||
4
|
||||
},
|
||||
{
|
||||
Buttons.DPadDown.ToString(),
|
||||
15
|
||||
},
|
||||
{
|
||||
Buttons.DPadLeft.ToString(),
|
||||
14
|
||||
},
|
||||
{
|
||||
Buttons.DPadRight.ToString(),
|
||||
13
|
||||
},
|
||||
{
|
||||
Buttons.DPadUp.ToString(),
|
||||
16
|
||||
},
|
||||
{
|
||||
Buttons.LeftShoulder.ToString(),
|
||||
6
|
||||
},
|
||||
{
|
||||
Buttons.LeftStick.ToString(),
|
||||
10
|
||||
},
|
||||
{
|
||||
Buttons.LeftThumbstickDown.ToString(),
|
||||
20
|
||||
},
|
||||
{
|
||||
Buttons.LeftThumbstickLeft.ToString(),
|
||||
17
|
||||
},
|
||||
{
|
||||
Buttons.LeftThumbstickRight.ToString(),
|
||||
18
|
||||
},
|
||||
{
|
||||
Buttons.LeftThumbstickUp.ToString(),
|
||||
19
|
||||
},
|
||||
{
|
||||
Buttons.LeftTrigger.ToString(),
|
||||
8
|
||||
},
|
||||
{
|
||||
Buttons.RightShoulder.ToString(),
|
||||
7
|
||||
},
|
||||
{
|
||||
Buttons.RightStick.ToString(),
|
||||
11
|
||||
},
|
||||
{
|
||||
Buttons.RightThumbstickDown.ToString(),
|
||||
24
|
||||
},
|
||||
{
|
||||
Buttons.RightThumbstickLeft.ToString(),
|
||||
21
|
||||
},
|
||||
{
|
||||
Buttons.RightThumbstickRight.ToString(),
|
||||
22
|
||||
},
|
||||
{
|
||||
Buttons.RightThumbstickUp.ToString(),
|
||||
23
|
||||
},
|
||||
{
|
||||
Buttons.RightTrigger.ToString(),
|
||||
9
|
||||
},
|
||||
{
|
||||
Buttons.Start.ToString(),
|
||||
5
|
||||
},
|
||||
{
|
||||
Buttons.X.ToString(),
|
||||
2
|
||||
},
|
||||
{
|
||||
Buttons.Y.ToString(),
|
||||
3
|
||||
},
|
||||
{
|
||||
"LR",
|
||||
25
|
||||
}
|
||||
};
|
||||
|
||||
TextSnippet ITagHandler.Parse(
|
||||
string text,
|
||||
Color baseColor,
|
||||
string options)
|
||||
{
|
||||
int result;
|
||||
if (!int.TryParse(text, out result) || result >= 26)
|
||||
return new TextSnippet(text);
|
||||
GlyphTagHandler.GlyphSnippet glyphSnippet = new GlyphTagHandler.GlyphSnippet(result);
|
||||
glyphSnippet.DeleteWhole = true;
|
||||
glyphSnippet.Text = "[g:" + (object) result + "]";
|
||||
return (TextSnippet) glyphSnippet;
|
||||
}
|
||||
|
||||
public static string GenerateTag(int index) => "[g" + ":" + (object) index + "]";
|
||||
|
||||
public static string GenerateTag(string keyname)
|
||||
{
|
||||
int index;
|
||||
return GlyphTagHandler.GlyphIndexes.TryGetValue(keyname, out index) ? GlyphTagHandler.GenerateTag(index) : keyname;
|
||||
}
|
||||
|
||||
private class GlyphSnippet : TextSnippet
|
||||
{
|
||||
private int _glyphIndex;
|
||||
|
||||
public GlyphSnippet(int index)
|
||||
: base()
|
||||
{
|
||||
this._glyphIndex = index;
|
||||
this.Color = Color.White;
|
||||
}
|
||||
|
||||
public override bool UniqueDraw(
|
||||
bool justCheckingString,
|
||||
out Vector2 size,
|
||||
SpriteBatch spriteBatch,
|
||||
Vector2 position = default (Vector2),
|
||||
Color color = default (Color),
|
||||
float scale = 1f)
|
||||
{
|
||||
if (!justCheckingString && color != Color.Black)
|
||||
{
|
||||
int frameX = this._glyphIndex;
|
||||
if (this._glyphIndex == 25)
|
||||
frameX = (double) Main.GlobalTimeWrappedHourly % 0.600000023841858 < 0.300000011920929 ? 17 : 18;
|
||||
Texture2D texture2D = TextureAssets.TextGlyph[0].Value;
|
||||
spriteBatch.Draw(texture2D, position, new Rectangle?(texture2D.Frame(25, frameX: frameX, frameY: (frameX / 25))), color, 0.0f, Vector2.Zero, GlyphTagHandler.GlyphsScale, SpriteEffects.None, 0.0f);
|
||||
}
|
||||
size = new Vector2(26f) * GlyphTagHandler.GlyphsScale;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override float GetStringLength(DynamicSpriteFont font) => 26f * GlyphTagHandler.GlyphsScale;
|
||||
}
|
||||
}
|
||||
}
|
29
GameContent/UI/Chat/IChatMonitor.cs
Normal file
29
GameContent/UI/Chat/IChatMonitor.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Chat.IChatMonitor
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace Terraria.GameContent.UI.Chat
|
||||
{
|
||||
public interface IChatMonitor
|
||||
{
|
||||
void NewText(string newText, byte R = 255, byte G = 255, byte B = 255);
|
||||
|
||||
void NewTextMultiline(string text, bool force = false, Color c = default (Color), int WidthLimit = -1);
|
||||
|
||||
void DrawChat(bool drawingPlayerChat);
|
||||
|
||||
void Clear();
|
||||
|
||||
void Update();
|
||||
|
||||
void Offset(int linesOffset);
|
||||
|
||||
void ResetOffset();
|
||||
|
||||
void OnResolutionChange();
|
||||
}
|
||||
}
|
134
GameContent/UI/Chat/ItemTagHandler.cs
Normal file
134
GameContent/UI/Chat/ItemTagHandler.cs
Normal file
|
@ -0,0 +1,134 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Chat.ItemTagHandler
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Graphics;
|
||||
using Terraria.UI;
|
||||
using Terraria.UI.Chat;
|
||||
|
||||
namespace Terraria.GameContent.UI.Chat
|
||||
{
|
||||
public class ItemTagHandler : ITagHandler
|
||||
{
|
||||
TextSnippet ITagHandler.Parse(
|
||||
string text,
|
||||
Color baseColor,
|
||||
string options)
|
||||
{
|
||||
Item obj = new Item();
|
||||
int result1;
|
||||
if (int.TryParse(text, out result1))
|
||||
obj.netDefaults(result1);
|
||||
if (obj.type <= 0)
|
||||
return new TextSnippet(text);
|
||||
obj.stack = 1;
|
||||
if (options != null)
|
||||
{
|
||||
string[] strArray = options.Split(',');
|
||||
for (int index = 0; index < strArray.Length; ++index)
|
||||
{
|
||||
if (strArray[index].Length != 0)
|
||||
{
|
||||
switch (strArray[index][0])
|
||||
{
|
||||
case 'p':
|
||||
int result2;
|
||||
if (int.TryParse(strArray[index].Substring(1), out result2))
|
||||
{
|
||||
obj.Prefix((int) (byte) Utils.Clamp<int>(result2, 0, 85));
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
case 's':
|
||||
case 'x':
|
||||
int result3;
|
||||
if (int.TryParse(strArray[index].Substring(1), out result3))
|
||||
{
|
||||
obj.stack = Utils.Clamp<int>(result3, 1, obj.maxStack);
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
string str = "";
|
||||
if (obj.stack > 1)
|
||||
str = " (" + (object) obj.stack + ")";
|
||||
ItemTagHandler.ItemSnippet itemSnippet = new ItemTagHandler.ItemSnippet(obj);
|
||||
itemSnippet.Text = "[" + obj.AffixName() + str + "]";
|
||||
itemSnippet.CheckForHover = true;
|
||||
itemSnippet.DeleteWhole = true;
|
||||
return (TextSnippet) itemSnippet;
|
||||
}
|
||||
|
||||
public static string GenerateTag(Item I)
|
||||
{
|
||||
string str = "[i";
|
||||
if (I.prefix != (byte) 0)
|
||||
str = str + "/p" + (object) I.prefix;
|
||||
if (I.stack != 1)
|
||||
str = str + "/s" + (object) I.stack;
|
||||
return str + ":" + (object) I.netID + "]";
|
||||
}
|
||||
|
||||
private class ItemSnippet : TextSnippet
|
||||
{
|
||||
private Item _item;
|
||||
|
||||
public ItemSnippet(Item item)
|
||||
: base()
|
||||
{
|
||||
this._item = item;
|
||||
this.Color = ItemRarity.GetColor(item.rare);
|
||||
}
|
||||
|
||||
public override void OnHover()
|
||||
{
|
||||
Main.HoverItem = this._item.Clone();
|
||||
Main.instance.MouseText(this._item.Name, this._item.rare);
|
||||
}
|
||||
|
||||
public override bool UniqueDraw(
|
||||
bool justCheckingString,
|
||||
out Vector2 size,
|
||||
SpriteBatch spriteBatch,
|
||||
Vector2 position = default (Vector2),
|
||||
Color color = default (Color),
|
||||
float scale = 1f)
|
||||
{
|
||||
float num1 = 1f;
|
||||
float num2 = 1f;
|
||||
if (Main.netMode != 2 && !Main.dedServ)
|
||||
{
|
||||
Main.instance.LoadItem(this._item.type);
|
||||
Texture2D texture2D = TextureAssets.Item[this._item.type].Value;
|
||||
Rectangle rectangle = Main.itemAnimations[this._item.type] == null ? texture2D.Frame() : Main.itemAnimations[this._item.type].GetFrame(texture2D);
|
||||
if (rectangle.Height > 32)
|
||||
num2 = 32f / (float) rectangle.Height;
|
||||
}
|
||||
float num3 = num2 * scale;
|
||||
float num4 = num1 * num3;
|
||||
if ((double) num4 > 0.75)
|
||||
num4 = 0.75f;
|
||||
if (!justCheckingString && color != Color.Black)
|
||||
{
|
||||
double inventoryScale = (double) Main.inventoryScale;
|
||||
Main.inventoryScale = scale * num4;
|
||||
ItemSlot.Draw(spriteBatch, ref this._item, 14, position - new Vector2(10f) * scale * num4, Color.White);
|
||||
Main.inventoryScale = (float) inventoryScale;
|
||||
}
|
||||
size = new Vector2(32f) * scale * num4;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override float GetStringLength(DynamicSpriteFont font) => (float) (32.0 * (double) this.Scale * 0.649999976158142);
|
||||
}
|
||||
}
|
||||
}
|
188
GameContent/UI/Chat/LegacyChatMonitor.cs
Normal file
188
GameContent/UI/Chat/LegacyChatMonitor.cs
Normal file
|
@ -0,0 +1,188 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Chat.LegacyChatMonitor
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.Audio;
|
||||
using Terraria.UI.Chat;
|
||||
|
||||
namespace Terraria.GameContent.UI.Chat
|
||||
{
|
||||
public class LegacyChatMonitor : IChatMonitor
|
||||
{
|
||||
private int numChatLines;
|
||||
private ChatLine[] chatLine;
|
||||
private int chatLength;
|
||||
private int showCount;
|
||||
private int startChatLine;
|
||||
|
||||
public int TextMaxLengthForScreen => Main.screenWidth - 320;
|
||||
|
||||
public void OnResolutionChange()
|
||||
{
|
||||
}
|
||||
|
||||
public LegacyChatMonitor()
|
||||
{
|
||||
this.showCount = 10;
|
||||
this.numChatLines = 500;
|
||||
this.chatLength = 600;
|
||||
this.chatLine = new ChatLine[this.numChatLines];
|
||||
for (int index = 0; index < this.numChatLines; ++index)
|
||||
this.chatLine[index] = new ChatLine();
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
for (int index = 0; index < this.numChatLines; ++index)
|
||||
this.chatLine[index] = new ChatLine();
|
||||
}
|
||||
|
||||
public void ResetOffset() => this.startChatLine = 0;
|
||||
|
||||
public void Update()
|
||||
{
|
||||
for (int index = 0; index < this.numChatLines; ++index)
|
||||
this.chatLine[index].UpdateTimeLeft();
|
||||
}
|
||||
|
||||
public void Offset(int linesOffset)
|
||||
{
|
||||
this.showCount = (int) ((double) (Main.screenHeight / 3) / (double) FontAssets.MouseText.Value.MeasureString("1").Y) - 1;
|
||||
switch (linesOffset)
|
||||
{
|
||||
case -1:
|
||||
--this.startChatLine;
|
||||
if (this.startChatLine >= 0)
|
||||
break;
|
||||
this.startChatLine = 0;
|
||||
break;
|
||||
case 1:
|
||||
++this.startChatLine;
|
||||
if (this.startChatLine + this.showCount >= this.numChatLines - 1)
|
||||
this.startChatLine = this.numChatLines - this.showCount - 1;
|
||||
if (!(this.chatLine[this.startChatLine + this.showCount].originalText == ""))
|
||||
break;
|
||||
--this.startChatLine;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void NewText(string newText, byte R = 255, byte G = 255, byte B = 255) => this.NewTextMultiline(newText, false, new Color((int) R, (int) G, (int) B), -1);
|
||||
|
||||
public void NewTextInternal(string newText, byte R = 255, byte G = 255, byte B = 255, bool force = false)
|
||||
{
|
||||
int maxTextSize = 80;
|
||||
if (!force && newText.Length > maxTextSize)
|
||||
{
|
||||
string oldText = newText;
|
||||
string newText1 = this.TrimIntoMultipleLines(R, G, B, maxTextSize, oldText);
|
||||
if (newText1.Length <= 0)
|
||||
return;
|
||||
this.NewTextInternal(newText1, R, G, B, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int index = this.numChatLines - 1; index > 0; --index)
|
||||
this.chatLine[index].Copy(this.chatLine[index - 1]);
|
||||
this.chatLine[0].color = new Color((int) R, (int) G, (int) B);
|
||||
this.chatLine[0].originalText = newText;
|
||||
this.chatLine[0].parsedText = ChatManager.ParseMessage(this.chatLine[0].originalText, this.chatLine[0].color).ToArray();
|
||||
this.chatLine[0].showTime = this.chatLength;
|
||||
SoundEngine.PlaySound(12);
|
||||
}
|
||||
}
|
||||
|
||||
private string TrimIntoMultipleLines(byte R, byte G, byte B, int maxTextSize, string oldText)
|
||||
{
|
||||
while (oldText.Length > maxTextSize)
|
||||
{
|
||||
int num = maxTextSize;
|
||||
int startIndex = num;
|
||||
while (oldText.Substring(startIndex, 1) != " ")
|
||||
{
|
||||
--startIndex;
|
||||
if (startIndex < 1)
|
||||
break;
|
||||
}
|
||||
if (startIndex == 0)
|
||||
{
|
||||
while (oldText.Substring(num, 1) != " ")
|
||||
{
|
||||
++num;
|
||||
if (num >= oldText.Length - 1)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
num = startIndex;
|
||||
if (num >= oldText.Length - 1)
|
||||
num = oldText.Length;
|
||||
this.NewTextInternal(oldText.Substring(0, num), R, G, B, true);
|
||||
oldText = oldText.Substring(num);
|
||||
if (oldText.Length > 0)
|
||||
{
|
||||
while (oldText.Substring(0, 1) == " ")
|
||||
oldText = oldText.Substring(1);
|
||||
}
|
||||
}
|
||||
return oldText;
|
||||
}
|
||||
|
||||
public void NewTextMultiline(string text, bool force = false, Color c = default (Color), int WidthLimit = -1)
|
||||
{
|
||||
if (c == new Color())
|
||||
c = Color.White;
|
||||
List<List<TextSnippet>> textSnippetListList = WidthLimit == -1 ? Utils.WordwrapStringSmart(text, c, FontAssets.MouseText.Value, this.TextMaxLengthForScreen, 10) : Utils.WordwrapStringSmart(text, c, FontAssets.MouseText.Value, WidthLimit, 10);
|
||||
for (int index = 0; index < textSnippetListList.Count; ++index)
|
||||
this.NewText(textSnippetListList[index]);
|
||||
}
|
||||
|
||||
public void NewText(List<TextSnippet> snippets)
|
||||
{
|
||||
for (int index = this.numChatLines - 1; index > 0; --index)
|
||||
this.chatLine[index].Copy(this.chatLine[index - 1]);
|
||||
this.chatLine[0].originalText = "this is a hack because draw checks length is higher than 0";
|
||||
this.chatLine[0].parsedText = snippets.ToArray();
|
||||
this.chatLine[0].showTime = this.chatLength;
|
||||
SoundEngine.PlaySound(12);
|
||||
}
|
||||
|
||||
public void DrawChat(bool drawingPlayerChat)
|
||||
{
|
||||
int num1 = this.startChatLine;
|
||||
int num2 = this.startChatLine + this.showCount;
|
||||
if (num2 >= this.numChatLines)
|
||||
{
|
||||
num2 = --this.numChatLines;
|
||||
num1 = num2 - this.showCount;
|
||||
}
|
||||
int num3 = 0;
|
||||
int index1 = -1;
|
||||
int index2 = -1;
|
||||
for (int index3 = num1; index3 < num2; ++index3)
|
||||
{
|
||||
if (drawingPlayerChat || this.chatLine[index3].showTime > 0 && this.chatLine[index3].parsedText.Length != 0)
|
||||
{
|
||||
int hoveredSnippet = -1;
|
||||
ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, FontAssets.MouseText.Value, this.chatLine[index3].parsedText, new Vector2(88f, (float) (Main.screenHeight - 30 - 28 - num3 * 21)), 0.0f, Vector2.Zero, Vector2.One, out hoveredSnippet);
|
||||
if (hoveredSnippet >= 0 && this.chatLine[index3].parsedText[hoveredSnippet].CheckForHover)
|
||||
{
|
||||
index1 = index3;
|
||||
index2 = hoveredSnippet;
|
||||
}
|
||||
}
|
||||
++num3;
|
||||
}
|
||||
if (index1 <= -1)
|
||||
return;
|
||||
this.chatLine[index1].parsedText[index2].OnHover();
|
||||
if (!Main.mouseLeft || !Main.mouseLeftRelease)
|
||||
return;
|
||||
this.chatLine[index1].parsedText[index2].OnClick();
|
||||
}
|
||||
}
|
||||
}
|
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.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria.UI.Chat;
|
||||
|
||||
namespace Terraria.GameContent.UI.Chat
|
||||
{
|
||||
public class NameTagHandler : ITagHandler
|
||||
{
|
||||
TextSnippet ITagHandler.Parse(
|
||||
string text,
|
||||
Color baseColor,
|
||||
string options)
|
||||
{
|
||||
return new TextSnippet("<" + text.Replace("\\[", "[").Replace("\\]", "]") + ">", baseColor);
|
||||
}
|
||||
|
||||
public static string GenerateTag(string name) => "[n:" + name.Replace("[", "\\[").Replace("]", "\\]") + "]";
|
||||
}
|
||||
}
|
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.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria.UI.Chat;
|
||||
|
||||
namespace Terraria.GameContent.UI.Chat
|
||||
{
|
||||
public class PlainTagHandler : ITagHandler
|
||||
{
|
||||
TextSnippet ITagHandler.Parse(
|
||||
string text,
|
||||
Color baseColor,
|
||||
string options)
|
||||
{
|
||||
return (TextSnippet) new PlainTagHandler.PlainSnippet(text);
|
||||
}
|
||||
|
||||
public class PlainSnippet : TextSnippet
|
||||
{
|
||||
public PlainSnippet(string text = "")
|
||||
: base(text)
|
||||
{
|
||||
}
|
||||
|
||||
public PlainSnippet(string text, Color color, float scale = 1f)
|
||||
: base(text, color, scale)
|
||||
{
|
||||
}
|
||||
|
||||
public override Color GetVisibleColor() => this.Color;
|
||||
}
|
||||
}
|
||||
}
|
156
GameContent/UI/Chat/RemadeChatMonitor.cs
Normal file
156
GameContent/UI/Chat/RemadeChatMonitor.cs
Normal file
|
@ -0,0 +1,156 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Chat.RemadeChatMonitor
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.UI.Chat;
|
||||
|
||||
namespace Terraria.GameContent.UI.Chat
|
||||
{
|
||||
public class RemadeChatMonitor : IChatMonitor
|
||||
{
|
||||
private const int MaxMessages = 500;
|
||||
private int _showCount;
|
||||
private int _startChatLine;
|
||||
private List<ChatMessageContainer> _messages;
|
||||
private bool _recalculateOnNextUpdate;
|
||||
|
||||
public RemadeChatMonitor()
|
||||
{
|
||||
this._showCount = 10;
|
||||
this._startChatLine = 0;
|
||||
this._messages = new List<ChatMessageContainer>();
|
||||
}
|
||||
|
||||
public void NewText(string newText, byte R = 255, byte G = 255, byte B = 255) => this.AddNewMessage(newText, new Color((int) R, (int) G, (int) B));
|
||||
|
||||
public void NewTextMultiline(string text, bool force = false, Color c = default (Color), int WidthLimit = -1) => this.AddNewMessage(text, c, WidthLimit);
|
||||
|
||||
public void AddNewMessage(string text, Color color, int widthLimitInPixels = -1)
|
||||
{
|
||||
ChatMessageContainer messageContainer = new ChatMessageContainer();
|
||||
messageContainer.SetContents(text, color, widthLimitInPixels);
|
||||
this._messages.Insert(0, messageContainer);
|
||||
while (this._messages.Count > 500)
|
||||
this._messages.RemoveAt(this._messages.Count - 1);
|
||||
}
|
||||
|
||||
public void DrawChat(bool drawingPlayerChat)
|
||||
{
|
||||
int startChatLine = this._startChatLine;
|
||||
int index = 0;
|
||||
int snippetIndex1 = 0;
|
||||
while (startChatLine > 0 && index < this._messages.Count)
|
||||
{
|
||||
int num = Math.Min(startChatLine, this._messages[index].LineCount);
|
||||
startChatLine -= num;
|
||||
snippetIndex1 += num;
|
||||
if (snippetIndex1 == this._messages[index].LineCount)
|
||||
{
|
||||
snippetIndex1 = 0;
|
||||
++index;
|
||||
}
|
||||
}
|
||||
int num1 = 0;
|
||||
int? nullable1 = new int?();
|
||||
int snippetIndex2 = -1;
|
||||
int? nullable2 = new int?();
|
||||
int hoveredSnippet = -1;
|
||||
while (num1 < this._showCount && index < this._messages.Count)
|
||||
{
|
||||
ChatMessageContainer message = this._messages[index];
|
||||
if (message.Prepared && drawingPlayerChat | message.CanBeShownWhenChatIsClosed)
|
||||
{
|
||||
TextSnippet[] withInversedIndex = message.GetSnippetWithInversedIndex(snippetIndex1);
|
||||
ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, FontAssets.MouseText.Value, withInversedIndex, new Vector2(88f, (float) (Main.screenHeight - 30 - 28 - num1 * 21)), 0.0f, Vector2.Zero, Vector2.One, out hoveredSnippet);
|
||||
if (hoveredSnippet >= 0)
|
||||
{
|
||||
nullable2 = new int?(hoveredSnippet);
|
||||
nullable1 = new int?(index);
|
||||
snippetIndex2 = snippetIndex1;
|
||||
}
|
||||
++num1;
|
||||
++snippetIndex1;
|
||||
if (snippetIndex1 >= message.LineCount)
|
||||
{
|
||||
snippetIndex1 = 0;
|
||||
++index;
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (!nullable1.HasValue || !nullable2.HasValue)
|
||||
return;
|
||||
TextSnippet[] withInversedIndex1 = this._messages[nullable1.Value].GetSnippetWithInversedIndex(snippetIndex2);
|
||||
withInversedIndex1[nullable2.Value].OnHover();
|
||||
if (!Main.mouseLeft || !Main.mouseLeftRelease)
|
||||
return;
|
||||
withInversedIndex1[nullable2.Value].OnClick();
|
||||
}
|
||||
|
||||
public void Clear() => this._messages.Clear();
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (this._recalculateOnNextUpdate)
|
||||
{
|
||||
this._recalculateOnNextUpdate = false;
|
||||
for (int index = 0; index < this._messages.Count; ++index)
|
||||
this._messages[index].MarkToNeedRefresh();
|
||||
}
|
||||
for (int index = 0; index < this._messages.Count; ++index)
|
||||
this._messages[index].Update();
|
||||
}
|
||||
|
||||
public void Offset(int linesOffset)
|
||||
{
|
||||
this._startChatLine += linesOffset;
|
||||
this.ClampMessageIndex();
|
||||
}
|
||||
|
||||
private void ClampMessageIndex()
|
||||
{
|
||||
int num1 = 0;
|
||||
int index = 0;
|
||||
int num2 = 0;
|
||||
int num3 = this._startChatLine + this._showCount;
|
||||
while (num1 < num3 && index < this._messages.Count)
|
||||
{
|
||||
int num4 = Math.Min(num3 - num1, this._messages[index].LineCount);
|
||||
num1 += num4;
|
||||
if (num1 < num3)
|
||||
{
|
||||
++index;
|
||||
num2 = 0;
|
||||
}
|
||||
else
|
||||
num2 = num4;
|
||||
}
|
||||
int showCount = this._showCount;
|
||||
while (showCount > 0 && num1 > 0)
|
||||
{
|
||||
--num2;
|
||||
--showCount;
|
||||
--num1;
|
||||
if (num2 < 0)
|
||||
{
|
||||
--index;
|
||||
if (index != -1)
|
||||
num2 = this._messages[index].LineCount - 1;
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
this._startChatLine = num1;
|
||||
}
|
||||
|
||||
public void ResetOffset() => this._startChatLine = 0;
|
||||
|
||||
public void OnResolutionChange() => this._recalculateOnNextUpdate = true;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue