Terraria 1.3.5.3 Source Code
This commit is contained in:
commit
4b21dac4b6
503 changed files with 409032 additions and 0 deletions
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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue