Terraria 1.4.0.5 Source Code
This commit is contained in:
commit
05205f009e
1059 changed files with 563450 additions and 0 deletions
97
GameContent/UI/Elements/EmoteButton.cs
Normal file
97
GameContent/UI/Elements/EmoteButton.cs
Normal file
|
@ -0,0 +1,97 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.EmoteButton
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria.Audio;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class EmoteButton : UIElement
|
||||
{
|
||||
private Asset<Texture2D> _texture;
|
||||
private Asset<Texture2D> _textureBorder;
|
||||
private int _emoteIndex;
|
||||
private bool _hovered;
|
||||
private int _frameCounter;
|
||||
|
||||
public EmoteButton(int emoteIndex)
|
||||
{
|
||||
this._texture = Main.Assets.Request<Texture2D>("Images/Extra_" + (object) (short) 48, (AssetRequestMode) 1);
|
||||
this._textureBorder = Main.Assets.Request<Texture2D>("Images/UI/EmoteBubbleBorder", (AssetRequestMode) 1);
|
||||
this._emoteIndex = emoteIndex;
|
||||
Rectangle frame = this.GetFrame();
|
||||
this.Width.Set((float) frame.Width, 0.0f);
|
||||
this.Height.Set((float) frame.Height, 0.0f);
|
||||
}
|
||||
|
||||
private Rectangle GetFrame() => this._texture.Frame(8, 38, this._emoteIndex % 4 * 2 + (this._frameCounter >= 10 ? 1 : 0), this._emoteIndex / 4 + 1);
|
||||
|
||||
private void UpdateFrame()
|
||||
{
|
||||
if (++this._frameCounter < 20)
|
||||
return;
|
||||
this._frameCounter = 0;
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
this.UpdateFrame();
|
||||
base.Update(gameTime);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
Vector2 position = dimensions.Position() + new Vector2(dimensions.Width, dimensions.Height) / 2f;
|
||||
Rectangle frame = this.GetFrame();
|
||||
Rectangle rectangle = frame;
|
||||
rectangle.X = this._texture.Width() / 8;
|
||||
rectangle.Y = 0;
|
||||
Vector2 origin = frame.Size() / 2f;
|
||||
Color white = Color.White;
|
||||
Color color = Color.Black;
|
||||
if (this._hovered)
|
||||
color = Main.OurFavoriteColor;
|
||||
spriteBatch.Draw(this._texture.Value, position, new Rectangle?(rectangle), white, 0.0f, origin, 1f, SpriteEffects.None, 0.0f);
|
||||
spriteBatch.Draw(this._texture.Value, position, new Rectangle?(frame), white, 0.0f, origin, 1f, SpriteEffects.None, 0.0f);
|
||||
spriteBatch.Draw(this._textureBorder.Value, position - Vector2.One * 2f, new Rectangle?(), color, 0.0f, origin, 1f, SpriteEffects.None, 0.0f);
|
||||
if (!this._hovered)
|
||||
return;
|
||||
string cursorText = "/" + Language.GetTextValue("EmojiName." + EmoteID.Search.GetName(this._emoteIndex));
|
||||
Main.instance.MouseText(cursorText);
|
||||
}
|
||||
|
||||
public override void MouseOver(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseOver(evt);
|
||||
SoundEngine.PlaySound(12);
|
||||
this._hovered = true;
|
||||
}
|
||||
|
||||
public override void MouseOut(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseOut(evt);
|
||||
this._hovered = false;
|
||||
}
|
||||
|
||||
public override void Click(UIMouseEvent evt)
|
||||
{
|
||||
base.Click(evt);
|
||||
if (Main.netMode == 0)
|
||||
{
|
||||
EmoteBubble.NewBubble(this._emoteIndex, new WorldUIAnchor((Entity) Main.LocalPlayer), 360);
|
||||
EmoteBubble.CheckForNPCsToReactToEmoteBubble(this._emoteIndex, Main.LocalPlayer);
|
||||
}
|
||||
else
|
||||
NetMessage.SendData(120, number: Main.myPlayer, number2: ((float) this._emoteIndex));
|
||||
IngameFancyUI.Close();
|
||||
}
|
||||
}
|
||||
}
|
87
GameContent/UI/Elements/EmotesGroupListItem.cs
Normal file
87
GameContent/UI/Elements/EmotesGroupListItem.cs
Normal file
|
@ -0,0 +1,87 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.EmotesGroupListItem
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class EmotesGroupListItem : UIElement
|
||||
{
|
||||
private const int TITLE_HEIGHT = 20;
|
||||
private const int SEPARATOR_HEIGHT = 10;
|
||||
private const int SIZE_PER_EMOTE = 36;
|
||||
private Asset<Texture2D> _tempTex;
|
||||
private int _groupIndex;
|
||||
private int _maxEmotesPerRow = 10;
|
||||
|
||||
public EmotesGroupListItem(
|
||||
LocalizedText groupTitle,
|
||||
int groupIndex,
|
||||
int maxEmotesPerRow,
|
||||
params int[] emotes)
|
||||
{
|
||||
maxEmotesPerRow = 14;
|
||||
this.SetPadding(0.0f);
|
||||
this._groupIndex = groupIndex;
|
||||
this._maxEmotesPerRow = maxEmotesPerRow;
|
||||
this._tempTex = Main.Assets.Request<Texture2D>("Images/UI/ButtonFavoriteInactive", (AssetRequestMode) 1);
|
||||
int num1 = emotes.Length / this._maxEmotesPerRow;
|
||||
if (emotes.Length % this._maxEmotesPerRow != 0)
|
||||
++num1;
|
||||
this.Height.Set((float) (30 + 36 * num1), 0.0f);
|
||||
this.Width.Set(0.0f, 1f);
|
||||
UIElement element = new UIElement()
|
||||
{
|
||||
Height = StyleDimension.FromPixels(30f),
|
||||
Width = StyleDimension.FromPixelsAndPercent(-20f, 1f),
|
||||
HAlign = 0.5f
|
||||
};
|
||||
element.SetPadding(0.0f);
|
||||
this.Append(element);
|
||||
UIHorizontalSeparator horizontalSeparator1 = new UIHorizontalSeparator();
|
||||
horizontalSeparator1.Width = StyleDimension.FromPixelsAndPercent(0.0f, 1f);
|
||||
horizontalSeparator1.VAlign = 1f;
|
||||
horizontalSeparator1.HAlign = 0.5f;
|
||||
horizontalSeparator1.Color = Color.Lerp(Color.White, new Color(63, 65, 151, (int) byte.MaxValue), 0.85f) * 0.9f;
|
||||
UIHorizontalSeparator horizontalSeparator2 = horizontalSeparator1;
|
||||
element.Append((UIElement) horizontalSeparator2);
|
||||
UIText uiText1 = new UIText(groupTitle);
|
||||
uiText1.VAlign = 1f;
|
||||
uiText1.HAlign = 0.5f;
|
||||
uiText1.Top = StyleDimension.FromPixels(-6f);
|
||||
UIText uiText2 = uiText1;
|
||||
element.Append((UIElement) uiText2);
|
||||
float num2 = 6f;
|
||||
for (int id = 0; id < emotes.Length; ++id)
|
||||
{
|
||||
int emote = emotes[id];
|
||||
int num3 = id / this._maxEmotesPerRow;
|
||||
int num4 = id % this._maxEmotesPerRow;
|
||||
int num5 = emotes.Length % this._maxEmotesPerRow;
|
||||
if (emotes.Length / this._maxEmotesPerRow != num3)
|
||||
num5 = this._maxEmotesPerRow;
|
||||
if (num5 == 0)
|
||||
num5 = this._maxEmotesPerRow;
|
||||
float num6 = (float) (36.0 * ((double) num5 / 2.0)) - 16f;
|
||||
float num7 = -16f;
|
||||
EmoteButton emoteButton1 = new EmoteButton(emote);
|
||||
emoteButton1.HAlign = 0.0f;
|
||||
emoteButton1.VAlign = 0.0f;
|
||||
emoteButton1.Top = StyleDimension.FromPixels((float) (30 + num3 * 36) + num2);
|
||||
emoteButton1.Left = StyleDimension.FromPixels((float) (36 * num4) - num7);
|
||||
EmoteButton emoteButton2 = emoteButton1;
|
||||
this.Append((UIElement) emoteButton2);
|
||||
emoteButton2.SetSnapPoint("Group " + (object) groupIndex, id);
|
||||
}
|
||||
}
|
||||
|
||||
public override int CompareTo(object obj) => obj is EmotesGroupListItem emotesGroupListItem ? this._groupIndex.CompareTo(emotesGroupListItem._groupIndex) : base.CompareTo(obj);
|
||||
}
|
||||
}
|
15
GameContent/UI/Elements/ExtraBestiaryInfoPageInformation.cs
Normal file
15
GameContent/UI/Elements/ExtraBestiaryInfoPageInformation.cs
Normal file
|
@ -0,0 +1,15 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.ExtraBestiaryInfoPageInformation
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Terraria.GameContent.Bestiary;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public struct ExtraBestiaryInfoPageInformation
|
||||
{
|
||||
public BestiaryUnlockProgressReport BestiaryProgressReport;
|
||||
}
|
||||
}
|
169
GameContent/UI/Elements/GroupOptionButton`1.cs
Normal file
169
GameContent/UI/Elements/GroupOptionButton`1.cs
Normal file
|
@ -0,0 +1,169 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.GroupOptionButton`1
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using System;
|
||||
using Terraria.Audio;
|
||||
using Terraria.ID;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class GroupOptionButton<T> : UIElement, IGroupOptionButton where T : IConvertible
|
||||
{
|
||||
private T _currentOption;
|
||||
private readonly Asset<Texture2D> _BasePanelTexture;
|
||||
private readonly Asset<Texture2D> _selectedBorderTexture;
|
||||
private readonly Asset<Texture2D> _hoveredBorderTexture;
|
||||
private readonly Asset<Texture2D> _iconTexture;
|
||||
private readonly T _myOption;
|
||||
private Color _color;
|
||||
private Color _borderColor;
|
||||
public float FadeFromBlack = 1f;
|
||||
private float _whiteLerp = 0.7f;
|
||||
private float _opacity = 0.7f;
|
||||
private bool _hovered;
|
||||
private bool _soundedHover;
|
||||
public bool ShowHighlightWhenSelected = true;
|
||||
private bool _UseOverrideColors;
|
||||
private Color _overrideUnpickedColor = Color.White;
|
||||
private Color _overridePickedColor = Color.White;
|
||||
private float _overrideOpacityPicked;
|
||||
private float _overrideOpacityUnpicked;
|
||||
public readonly LocalizedText Description;
|
||||
private UIText _title;
|
||||
|
||||
public T OptionValue => this._myOption;
|
||||
|
||||
public bool IsSelected => this._currentOption.Equals((object) this._myOption);
|
||||
|
||||
public GroupOptionButton(
|
||||
T option,
|
||||
LocalizedText title,
|
||||
LocalizedText description,
|
||||
Color textColor,
|
||||
string iconTexturePath,
|
||||
float textSize = 1f,
|
||||
float titleAlignmentX = 0.5f,
|
||||
float titleWidthReduction = 10f)
|
||||
{
|
||||
this._borderColor = Color.White;
|
||||
this._currentOption = option;
|
||||
this._myOption = option;
|
||||
this.Description = description;
|
||||
this.Width = StyleDimension.FromPixels(44f);
|
||||
this.Height = StyleDimension.FromPixels(34f);
|
||||
this._BasePanelTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/PanelGrayscale", (AssetRequestMode) 1);
|
||||
this._selectedBorderTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/CategoryPanelHighlight", (AssetRequestMode) 1);
|
||||
this._hoveredBorderTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/CategoryPanelBorder", (AssetRequestMode) 1);
|
||||
if (iconTexturePath != null)
|
||||
this._iconTexture = Main.Assets.Request<Texture2D>(iconTexturePath, (AssetRequestMode) 1);
|
||||
this._color = Colors.InventoryDefaultColor;
|
||||
if (title == null)
|
||||
return;
|
||||
UIText uiText1 = new UIText(title, textSize);
|
||||
uiText1.HAlign = titleAlignmentX;
|
||||
uiText1.VAlign = 0.5f;
|
||||
uiText1.Width = StyleDimension.FromPixelsAndPercent(-titleWidthReduction, 1f);
|
||||
uiText1.Top = StyleDimension.FromPixels(0.0f);
|
||||
UIText uiText2 = uiText1;
|
||||
uiText2.TextColor = textColor;
|
||||
this.Append((UIElement) uiText2);
|
||||
this._title = uiText2;
|
||||
}
|
||||
|
||||
public void SetText(LocalizedText text, float textSize, Color color)
|
||||
{
|
||||
if (this._title != null)
|
||||
this._title.Remove();
|
||||
UIText uiText1 = new UIText(text, textSize);
|
||||
uiText1.HAlign = 0.5f;
|
||||
uiText1.VAlign = 0.5f;
|
||||
uiText1.Width = StyleDimension.FromPixelsAndPercent(-10f, 1f);
|
||||
uiText1.Top = StyleDimension.FromPixels(0.0f);
|
||||
UIText uiText2 = uiText1;
|
||||
uiText2.TextColor = color;
|
||||
this.Append((UIElement) uiText2);
|
||||
this._title = uiText2;
|
||||
}
|
||||
|
||||
public void SetCurrentOption(T option) => this._currentOption = option;
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
if (this._hovered)
|
||||
{
|
||||
if (!this._soundedHover)
|
||||
SoundEngine.PlaySound(12);
|
||||
this._soundedHover = true;
|
||||
}
|
||||
else
|
||||
this._soundedHover = false;
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
Color color1 = this._color;
|
||||
float num = this._opacity;
|
||||
bool isSelected = this.IsSelected;
|
||||
if (this._UseOverrideColors)
|
||||
{
|
||||
color1 = isSelected ? this._overridePickedColor : this._overrideUnpickedColor;
|
||||
num = isSelected ? this._overrideOpacityPicked : this._overrideOpacityUnpicked;
|
||||
}
|
||||
Utils.DrawSplicedPanel(spriteBatch, this._BasePanelTexture.Value, (int) dimensions.X, (int) dimensions.Y, (int) dimensions.Width, (int) dimensions.Height, 10, 10, 10, 10, Color.Lerp(Color.Black, color1, this.FadeFromBlack) * num);
|
||||
if (isSelected && this.ShowHighlightWhenSelected)
|
||||
Utils.DrawSplicedPanel(spriteBatch, this._selectedBorderTexture.Value, (int) dimensions.X + 7, (int) dimensions.Y + 7, (int) dimensions.Width - 14, (int) dimensions.Height - 14, 10, 10, 10, 10, Color.Lerp(color1, Color.White, this._whiteLerp) * num);
|
||||
if (this._hovered)
|
||||
Utils.DrawSplicedPanel(spriteBatch, this._hoveredBorderTexture.Value, (int) dimensions.X, (int) dimensions.Y, (int) dimensions.Width, (int) dimensions.Height, 10, 10, 10, 10, this._borderColor);
|
||||
if (this._iconTexture == null)
|
||||
return;
|
||||
Color color2 = Color.White;
|
||||
if (!this._hovered && !isSelected)
|
||||
color2 = Color.Lerp(color1, Color.White, this._whiteLerp) * num;
|
||||
spriteBatch.Draw(this._iconTexture.Value, new Vector2(dimensions.X + 1f, dimensions.Y + 1f), color2);
|
||||
}
|
||||
|
||||
public override void MouseDown(UIMouseEvent evt)
|
||||
{
|
||||
SoundEngine.PlaySound(12);
|
||||
base.MouseDown(evt);
|
||||
}
|
||||
|
||||
public override void MouseOver(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseOver(evt);
|
||||
this._hovered = true;
|
||||
}
|
||||
|
||||
public override void MouseOut(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseOut(evt);
|
||||
this._hovered = false;
|
||||
}
|
||||
|
||||
public void SetColor(Color color, float opacity)
|
||||
{
|
||||
this._color = color;
|
||||
this._opacity = opacity;
|
||||
}
|
||||
|
||||
public void SetColorsBasedOnSelectionState(
|
||||
Color pickedColor,
|
||||
Color unpickedColor,
|
||||
float opacityPicked,
|
||||
float opacityNotPicked)
|
||||
{
|
||||
this._UseOverrideColors = true;
|
||||
this._overridePickedColor = pickedColor;
|
||||
this._overrideUnpickedColor = unpickedColor;
|
||||
this._overrideOpacityPicked = opacityPicked;
|
||||
this._overrideOpacityUnpicked = opacityNotPicked;
|
||||
}
|
||||
|
||||
public void SetBorderColor(Color color) => this._borderColor = color;
|
||||
}
|
||||
}
|
15
GameContent/UI/Elements/IColorable.cs
Normal file
15
GameContent/UI/Elements/IColorable.cs
Normal file
|
@ -0,0 +1,15 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.IColorable
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public interface IColorable
|
||||
{
|
||||
Color Color { get; set; }
|
||||
}
|
||||
}
|
21
GameContent/UI/Elements/IGroupOptionButton.cs
Normal file
21
GameContent/UI/Elements/IGroupOptionButton.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.IGroupOptionButton
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public interface IGroupOptionButton
|
||||
{
|
||||
void SetColorsBasedOnSelectionState(
|
||||
Color pickedColor,
|
||||
Color unpickedColor,
|
||||
float opacityPicked,
|
||||
float opacityNotPicked);
|
||||
|
||||
void SetBorderColor(Color color);
|
||||
}
|
||||
}
|
13
GameContent/UI/Elements/IManuallyOrderedUIElement.cs
Normal file
13
GameContent/UI/Elements/IManuallyOrderedUIElement.cs
Normal file
|
@ -0,0 +1,13 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.IManuallyOrderedUIElement
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public interface IManuallyOrderedUIElement
|
||||
{
|
||||
int OrderInUIList { get; set; }
|
||||
}
|
||||
}
|
49
GameContent/UI/Elements/PowerStripUIElement.cs
Normal file
49
GameContent/UI/Elements/PowerStripUIElement.cs
Normal file
|
@ -0,0 +1,49 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.PowerStripUIElement
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class PowerStripUIElement : UIElement
|
||||
{
|
||||
private List<UIElement> _buttonsBySorting;
|
||||
private string _gamepadPointGroupname;
|
||||
|
||||
public PowerStripUIElement(string gamepadGroupName, List<UIElement> buttons)
|
||||
{
|
||||
this._buttonsBySorting = new List<UIElement>((IEnumerable<UIElement>) buttons);
|
||||
this._gamepadPointGroupname = gamepadGroupName;
|
||||
int count = buttons.Count;
|
||||
int num1 = 4;
|
||||
int num2 = 40;
|
||||
int num3 = 40;
|
||||
int num4 = num3 + num1;
|
||||
UIPanel uiPanel1 = new UIPanel();
|
||||
uiPanel1.Width = new StyleDimension((float) (num2 + num1 * 2), 0.0f);
|
||||
uiPanel1.Height = new StyleDimension((float) (num3 * count + num1 * (1 + count)), 0.0f);
|
||||
UIPanel uiPanel2 = uiPanel1;
|
||||
this.SetPadding(0.0f);
|
||||
this.Width = uiPanel2.Width;
|
||||
this.Height = uiPanel2.Height;
|
||||
uiPanel2.BorderColor = new Color(89, 116, 213, (int) byte.MaxValue) * 0.9f;
|
||||
uiPanel2.BackgroundColor = new Color(73, 94, 171) * 0.9f;
|
||||
uiPanel2.SetPadding(0.0f);
|
||||
this.Append((UIElement) uiPanel2);
|
||||
for (int index = 0; index < count; ++index)
|
||||
{
|
||||
UIElement button = buttons[index];
|
||||
button.HAlign = 0.5f;
|
||||
button.Top = new StyleDimension((float) (num1 + num4 * index), 0.0f);
|
||||
button.SetSnapPoint(this._gamepadPointGroupname, index);
|
||||
uiPanel2.Append(button);
|
||||
this._buttonsBySorting.Add(button);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
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.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using System;
|
||||
using Terraria.Achievements;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI;
|
||||
using Terraria.UI.Chat;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIAchievementListItem : UIPanel
|
||||
{
|
||||
private Achievement _achievement;
|
||||
private UIImageFramed _achievementIcon;
|
||||
private UIImage _achievementIconBorders;
|
||||
private const int _iconSize = 64;
|
||||
private const int _iconSizeWithSpace = 66;
|
||||
private const int _iconsPerRow = 8;
|
||||
private int _iconIndex;
|
||||
private Rectangle _iconFrame;
|
||||
private Rectangle _iconFrameUnlocked;
|
||||
private Rectangle _iconFrameLocked;
|
||||
private Asset<Texture2D> _innerPanelTopTexture;
|
||||
private Asset<Texture2D> _innerPanelBottomTexture;
|
||||
private Asset<Texture2D> _categoryTexture;
|
||||
private bool _locked;
|
||||
private bool _large;
|
||||
|
||||
public UIAchievementListItem(Achievement achievement, bool largeForOtherLanguages)
|
||||
{
|
||||
this._large = largeForOtherLanguages;
|
||||
this.BackgroundColor = new Color(26, 40, 89) * 0.8f;
|
||||
this.BorderColor = new Color(13, 20, 44) * 0.8f;
|
||||
float num = (float) (16 + this._large.ToInt() * 20);
|
||||
float pixels1 = (float) (this._large.ToInt() * 6);
|
||||
float pixels2 = (float) (this._large.ToInt() * 12);
|
||||
this._achievement = achievement;
|
||||
this.Height.Set(66f + num, 0.0f);
|
||||
this.Width.Set(0.0f, 1f);
|
||||
this.PaddingTop = 8f;
|
||||
this.PaddingLeft = 9f;
|
||||
int iconIndex = Main.Achievements.GetIconIndex(achievement.Name);
|
||||
this._iconIndex = iconIndex;
|
||||
this._iconFrameUnlocked = new Rectangle(iconIndex % 8 * 66, iconIndex / 8 * 66, 64, 64);
|
||||
this._iconFrameLocked = this._iconFrameUnlocked;
|
||||
this._iconFrameLocked.X += 528;
|
||||
this._iconFrame = this._iconFrameLocked;
|
||||
this.UpdateIconFrame();
|
||||
this._achievementIcon = new UIImageFramed(Main.Assets.Request<Texture2D>("Images/UI/Achievements", (AssetRequestMode) 1), this._iconFrame);
|
||||
this._achievementIcon.Left.Set(pixels1, 0.0f);
|
||||
this._achievementIcon.Top.Set(pixels2, 0.0f);
|
||||
this.Append((UIElement) this._achievementIcon);
|
||||
this._achievementIconBorders = new UIImage(Main.Assets.Request<Texture2D>("Images/UI/Achievement_Borders", (AssetRequestMode) 1));
|
||||
this._achievementIconBorders.Left.Set(pixels1 - 4f, 0.0f);
|
||||
this._achievementIconBorders.Top.Set(pixels2 - 4f, 0.0f);
|
||||
this.Append((UIElement) this._achievementIconBorders);
|
||||
this._innerPanelTopTexture = Main.Assets.Request<Texture2D>("Images/UI/Achievement_InnerPanelTop", (AssetRequestMode) 1);
|
||||
this._innerPanelBottomTexture = !this._large ? Main.Assets.Request<Texture2D>("Images/UI/Achievement_InnerPanelBottom", (AssetRequestMode) 1) : Main.Assets.Request<Texture2D>("Images/UI/Achievement_InnerPanelBottom_Large", (AssetRequestMode) 1);
|
||||
this._categoryTexture = Main.Assets.Request<Texture2D>("Images/UI/Achievement_Categories", (AssetRequestMode) 1);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
base.DrawSelf(spriteBatch);
|
||||
int num1 = this._large.ToInt() * 6;
|
||||
Vector2 vector2_1 = new Vector2((float) num1, 0.0f);
|
||||
this._locked = !this._achievement.IsCompleted;
|
||||
this.UpdateIconFrame();
|
||||
CalculatedStyle innerDimensions = this.GetInnerDimensions();
|
||||
CalculatedStyle dimensions = this._achievementIconBorders.GetDimensions();
|
||||
Vector2 vector2_2 = new Vector2(dimensions.X + dimensions.Width + 7f, innerDimensions.Y);
|
||||
Tuple<Decimal, Decimal> trackerValues = this.GetTrackerValues();
|
||||
bool flag = false;
|
||||
if ((!(trackerValues.Item1 == 0M) || !(trackerValues.Item2 == 0M)) && this._locked)
|
||||
flag = true;
|
||||
float num2 = (float) ((double) innerDimensions.Width - (double) dimensions.Width + 1.0) - (float) (num1 * 2);
|
||||
Vector2 baseScale1 = new Vector2(0.85f);
|
||||
Vector2 baseScale2 = new Vector2(0.92f);
|
||||
string wrappedText = FontAssets.ItemStack.Value.CreateWrappedText(this._achievement.Description.Value, (float) (((double) num2 - 20.0) * (1.0 / (double) baseScale2.X)), Language.ActiveCulture.CultureInfo);
|
||||
Vector2 stringSize1 = ChatManager.GetStringSize(FontAssets.ItemStack.Value, wrappedText, baseScale2, num2);
|
||||
if (!this._large)
|
||||
stringSize1 = ChatManager.GetStringSize(FontAssets.ItemStack.Value, this._achievement.Description.Value, baseScale2, num2);
|
||||
float num3 = (float) (38.0 + (this._large ? 20.0 : 0.0));
|
||||
if ((double) stringSize1.Y > (double) num3)
|
||||
baseScale2.Y *= num3 / stringSize1.Y;
|
||||
Color baseColor1 = Color.Lerp(this._locked ? Color.Silver : Color.Gold, Color.White, this.IsMouseHovering ? 0.5f : 0.0f);
|
||||
Color baseColor2 = Color.Lerp(this._locked ? Color.DarkGray : Color.Silver, Color.White, this.IsMouseHovering ? 1f : 0.0f);
|
||||
Color color1 = this.IsMouseHovering ? Color.White : Color.Gray;
|
||||
Vector2 position1 = vector2_2 - Vector2.UnitY * 2f + vector2_1;
|
||||
this.DrawPanelTop(spriteBatch, position1, num2, color1);
|
||||
AchievementCategory category = this._achievement.Category;
|
||||
position1.Y += 2f;
|
||||
position1.X += 4f;
|
||||
spriteBatch.Draw(this._categoryTexture.Value, position1, new Rectangle?(this._categoryTexture.Frame(4, 2, (int) category)), this.IsMouseHovering ? Color.White : Color.Silver, 0.0f, Vector2.Zero, 0.5f, SpriteEffects.None, 0.0f);
|
||||
position1.X += 4f;
|
||||
position1.X += 17f;
|
||||
ChatManager.DrawColorCodedStringWithShadow(spriteBatch, FontAssets.ItemStack.Value, this._achievement.FriendlyName.Value, position1, baseColor1, 0.0f, Vector2.Zero, baseScale1, num2);
|
||||
position1.X -= 17f;
|
||||
Vector2 position2 = vector2_2 + Vector2.UnitY * 27f + vector2_1;
|
||||
this.DrawPanelBottom(spriteBatch, position2, num2, color1);
|
||||
position2.X += 8f;
|
||||
position2.Y += 4f;
|
||||
ChatManager.DrawColorCodedStringWithShadow(spriteBatch, FontAssets.ItemStack.Value, wrappedText, position2, baseColor2, 0.0f, Vector2.Zero, baseScale2);
|
||||
if (!flag)
|
||||
return;
|
||||
Vector2 position3 = position1 + Vector2.UnitX * num2 + Vector2.UnitY;
|
||||
string text = ((int) trackerValues.Item1).ToString() + "/" + (object) (int) trackerValues.Item2;
|
||||
Vector2 baseScale3 = new Vector2(0.75f);
|
||||
Vector2 stringSize2 = ChatManager.GetStringSize(FontAssets.ItemStack.Value, text, baseScale3);
|
||||
float progress = (float) (trackerValues.Item1 / trackerValues.Item2);
|
||||
float Width = 80f;
|
||||
Color color2 = new Color(100, (int) byte.MaxValue, 100);
|
||||
if (!this.IsMouseHovering)
|
||||
color2 = Color.Lerp(color2, Color.Black, 0.25f);
|
||||
Color BackColor = new Color((int) byte.MaxValue, (int) byte.MaxValue, (int) byte.MaxValue);
|
||||
if (!this.IsMouseHovering)
|
||||
BackColor = Color.Lerp(BackColor, Color.Black, 0.25f);
|
||||
this.DrawProgressBar(spriteBatch, progress, position3 - Vector2.UnitX * Width * 0.7f, Width, BackColor, color2, color2.MultiplyRGBA(new Color(new Vector4(1f, 1f, 1f, 0.5f))));
|
||||
position3.X -= Width * 1.4f + stringSize2.X;
|
||||
ChatManager.DrawColorCodedStringWithShadow(spriteBatch, FontAssets.ItemStack.Value, text, position3, baseColor1, 0.0f, new Vector2(0.0f, 0.0f), baseScale3, 90f);
|
||||
}
|
||||
|
||||
private void UpdateIconFrame()
|
||||
{
|
||||
this._iconFrame = this._locked ? this._iconFrameLocked : this._iconFrameUnlocked;
|
||||
if (this._achievementIcon == null)
|
||||
return;
|
||||
this._achievementIcon.SetFrame(this._iconFrame);
|
||||
}
|
||||
|
||||
private void DrawPanelTop(SpriteBatch spriteBatch, Vector2 position, float width, Color color)
|
||||
{
|
||||
spriteBatch.Draw(this._innerPanelTopTexture.Value, position, new Rectangle?(new Rectangle(0, 0, 2, this._innerPanelTopTexture.Height())), color);
|
||||
spriteBatch.Draw(this._innerPanelTopTexture.Value, new Vector2(position.X + 2f, position.Y), new Rectangle?(new Rectangle(2, 0, 2, this._innerPanelTopTexture.Height())), color, 0.0f, Vector2.Zero, new Vector2((float) (((double) width - 4.0) / 2.0), 1f), SpriteEffects.None, 0.0f);
|
||||
spriteBatch.Draw(this._innerPanelTopTexture.Value, new Vector2((float) ((double) position.X + (double) width - 2.0), position.Y), new Rectangle?(new Rectangle(4, 0, 2, this._innerPanelTopTexture.Height())), color);
|
||||
}
|
||||
|
||||
private void DrawPanelBottom(
|
||||
SpriteBatch spriteBatch,
|
||||
Vector2 position,
|
||||
float width,
|
||||
Color color)
|
||||
{
|
||||
spriteBatch.Draw(this._innerPanelBottomTexture.Value, position, new Rectangle?(new Rectangle(0, 0, 6, this._innerPanelBottomTexture.Height())), color);
|
||||
spriteBatch.Draw(this._innerPanelBottomTexture.Value, new Vector2(position.X + 6f, position.Y), new Rectangle?(new Rectangle(6, 0, 7, this._innerPanelBottomTexture.Height())), color, 0.0f, Vector2.Zero, new Vector2((float) (((double) width - 12.0) / 7.0), 1f), SpriteEffects.None, 0.0f);
|
||||
spriteBatch.Draw(this._innerPanelBottomTexture.Value, new Vector2((float) ((double) position.X + (double) width - 6.0), position.Y), new Rectangle?(new Rectangle(13, 0, 6, this._innerPanelBottomTexture.Height())), color);
|
||||
}
|
||||
|
||||
public override void MouseOver(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseOver(evt);
|
||||
this.BackgroundColor = new Color(46, 60, 119);
|
||||
this.BorderColor = new Color(20, 30, 56);
|
||||
}
|
||||
|
||||
public override void MouseOut(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseOut(evt);
|
||||
this.BackgroundColor = new Color(26, 40, 89) * 0.8f;
|
||||
this.BorderColor = new Color(13, 20, 44) * 0.8f;
|
||||
}
|
||||
|
||||
public Achievement GetAchievement() => this._achievement;
|
||||
|
||||
private Tuple<Decimal, Decimal> GetTrackerValues()
|
||||
{
|
||||
if (!this._achievement.HasTracker)
|
||||
return Tuple.Create<Decimal, Decimal>(0M, 0M);
|
||||
IAchievementTracker tracker = this._achievement.GetTracker();
|
||||
if (tracker.GetTrackerType() == TrackerType.Int)
|
||||
{
|
||||
AchievementTracker<int> achievementTracker = (AchievementTracker<int>) tracker;
|
||||
return Tuple.Create<Decimal, Decimal>((Decimal) achievementTracker.Value, (Decimal) achievementTracker.MaxValue);
|
||||
}
|
||||
if (tracker.GetTrackerType() != TrackerType.Float)
|
||||
return Tuple.Create<Decimal, Decimal>(0M, 0M);
|
||||
AchievementTracker<float> achievementTracker1 = (AchievementTracker<float>) tracker;
|
||||
return Tuple.Create<Decimal, Decimal>((Decimal) achievementTracker1.Value, (Decimal) achievementTracker1.MaxValue);
|
||||
}
|
||||
|
||||
private void DrawProgressBar(
|
||||
SpriteBatch spriteBatch,
|
||||
float progress,
|
||||
Vector2 spot,
|
||||
float Width = 169f,
|
||||
Color BackColor = default (Color),
|
||||
Color FillingColor = default (Color),
|
||||
Color BlipColor = default (Color))
|
||||
{
|
||||
if (BlipColor == Color.Transparent)
|
||||
BlipColor = new Color((int) byte.MaxValue, 165, 0, (int) sbyte.MaxValue);
|
||||
if (FillingColor == Color.Transparent)
|
||||
FillingColor = new Color((int) byte.MaxValue, 241, 51);
|
||||
if (BackColor == Color.Transparent)
|
||||
FillingColor = new Color((int) byte.MaxValue, (int) byte.MaxValue, (int) byte.MaxValue);
|
||||
Texture2D texture1 = TextureAssets.ColorBar.Value;
|
||||
Texture2D texture2D = TextureAssets.ColorBlip.Value;
|
||||
Texture2D texture2 = TextureAssets.MagicPixel.Value;
|
||||
float num1 = MathHelper.Clamp(progress, 0.0f, 1f);
|
||||
float num2 = Width * 1f;
|
||||
float y = 8f;
|
||||
float x = num2 / 169f;
|
||||
Vector2 vector2 = spot + Vector2.UnitY * y + Vector2.UnitX * 1f;
|
||||
spriteBatch.Draw(texture1, spot, new Rectangle?(new Rectangle(5, 0, texture1.Width - 9, texture1.Height)), BackColor, 0.0f, new Vector2(84.5f, 0.0f), new Vector2(x, 1f), SpriteEffects.None, 0.0f);
|
||||
spriteBatch.Draw(texture1, spot + new Vector2((float) (-(double) x * 84.5 - 5.0), 0.0f), new Rectangle?(new Rectangle(0, 0, 5, texture1.Height)), BackColor, 0.0f, Vector2.Zero, Vector2.One, SpriteEffects.None, 0.0f);
|
||||
spriteBatch.Draw(texture1, spot + new Vector2(x * 84.5f, 0.0f), new Rectangle?(new Rectangle(texture1.Width - 4, 0, 4, texture1.Height)), BackColor, 0.0f, Vector2.Zero, Vector2.One, SpriteEffects.None, 0.0f);
|
||||
Vector2 position = vector2 + Vector2.UnitX * (num1 - 0.5f) * num2;
|
||||
--position.X;
|
||||
spriteBatch.Draw(texture2, position, new Rectangle?(new Rectangle(0, 0, 1, 1)), FillingColor, 0.0f, new Vector2(1f, 0.5f), new Vector2(num2 * num1, y), SpriteEffects.None, 0.0f);
|
||||
if ((double) progress != 0.0)
|
||||
spriteBatch.Draw(texture2, position, new Rectangle?(new Rectangle(0, 0, 1, 1)), BlipColor, 0.0f, new Vector2(1f, 0.5f), new Vector2(2f, y), SpriteEffects.None, 0.0f);
|
||||
spriteBatch.Draw(texture2, position, new Rectangle?(new Rectangle(0, 0, 1, 1)), Color.Black, 0.0f, new Vector2(0.0f, 0.5f), new Vector2(num2 * (1f - num1), y), SpriteEffects.None, 0.0f);
|
||||
}
|
||||
|
||||
public override int CompareTo(object obj)
|
||||
{
|
||||
if (!(obj is UIAchievementListItem achievementListItem))
|
||||
return 0;
|
||||
if (this._achievement.IsCompleted && !achievementListItem._achievement.IsCompleted)
|
||||
return -1;
|
||||
return !this._achievement.IsCompleted && achievementListItem._achievement.IsCompleted ? 1 : this._achievement.Id.CompareTo(achievementListItem._achievement.Id);
|
||||
}
|
||||
}
|
||||
}
|
155
GameContent/UI/Elements/UIBestiaryEntryButton.cs
Normal file
155
GameContent/UI/Elements/UIBestiaryEntryButton.cs
Normal file
|
@ -0,0 +1,155 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIBestiaryEntryButton
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Terraria.Audio;
|
||||
using Terraria.GameContent.Bestiary;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIBestiaryEntryButton : UIElement
|
||||
{
|
||||
private UIImage _bordersGlow;
|
||||
private UIImage _bordersOverlay;
|
||||
private UIImage _borders;
|
||||
private UIBestiaryEntryIcon _icon;
|
||||
|
||||
public BestiaryEntry Entry { get; private set; }
|
||||
|
||||
public UIBestiaryEntryButton(BestiaryEntry entry, bool isAPrettyPortrait)
|
||||
{
|
||||
this.Entry = entry;
|
||||
this.Height.Set(72f, 0.0f);
|
||||
this.Width.Set(72f, 0.0f);
|
||||
this.SetPadding(0.0f);
|
||||
UIElement element = new UIElement()
|
||||
{
|
||||
Width = new StyleDimension(-4f, 1f),
|
||||
Height = new StyleDimension(-4f, 1f),
|
||||
IgnoresMouseInteraction = true,
|
||||
OverflowHidden = true,
|
||||
HAlign = 0.5f,
|
||||
VAlign = 0.5f
|
||||
};
|
||||
element.SetPadding(0.0f);
|
||||
UIImage uiImage1 = new UIImage(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Slot_Back", (AssetRequestMode) 1));
|
||||
uiImage1.VAlign = 0.5f;
|
||||
uiImage1.HAlign = 0.5f;
|
||||
element.Append((UIElement) uiImage1);
|
||||
if (isAPrettyPortrait)
|
||||
{
|
||||
Asset<Texture2D> texture = this.TryGettingBackgroundImageProvider(entry);
|
||||
if (texture != null)
|
||||
{
|
||||
UIElement uiElement = element;
|
||||
UIImage uiImage2 = new UIImage(texture);
|
||||
uiImage2.HAlign = 0.5f;
|
||||
uiImage2.VAlign = 0.5f;
|
||||
uiElement.Append((UIElement) uiImage2);
|
||||
}
|
||||
}
|
||||
UIBestiaryEntryIcon bestiaryEntryIcon = new UIBestiaryEntryIcon(entry, isAPrettyPortrait);
|
||||
element.Append((UIElement) bestiaryEntryIcon);
|
||||
this.Append(element);
|
||||
this._icon = bestiaryEntryIcon;
|
||||
int? nullable = this.TryGettingDisplayIndex(entry);
|
||||
if (nullable.HasValue)
|
||||
{
|
||||
UIText uiText = new UIText(nullable.Value.ToString(), 0.9f);
|
||||
uiText.Top = new StyleDimension(10f, 0.0f);
|
||||
uiText.Left = new StyleDimension(10f, 0.0f);
|
||||
uiText.IgnoresMouseInteraction = true;
|
||||
this.Append((UIElement) uiText);
|
||||
}
|
||||
UIImage uiImage3 = new UIImage(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Slot_Selection", (AssetRequestMode) 1));
|
||||
uiImage3.VAlign = 0.5f;
|
||||
uiImage3.HAlign = 0.5f;
|
||||
uiImage3.IgnoresMouseInteraction = true;
|
||||
this._bordersGlow = uiImage3;
|
||||
UIImage uiImage4 = new UIImage(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Slot_Overlay", (AssetRequestMode) 1));
|
||||
uiImage4.VAlign = 0.5f;
|
||||
uiImage4.HAlign = 0.5f;
|
||||
uiImage4.IgnoresMouseInteraction = true;
|
||||
uiImage4.Color = Color.White * 0.6f;
|
||||
this._bordersOverlay = uiImage4;
|
||||
this.Append((UIElement) this._bordersOverlay);
|
||||
UIImage uiImage5 = new UIImage(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Slot_Front", (AssetRequestMode) 1));
|
||||
uiImage5.VAlign = 0.5f;
|
||||
uiImage5.HAlign = 0.5f;
|
||||
uiImage5.IgnoresMouseInteraction = true;
|
||||
this.Append((UIElement) uiImage5);
|
||||
this._borders = uiImage5;
|
||||
if (isAPrettyPortrait)
|
||||
this.RemoveChild((UIElement) this._bordersOverlay);
|
||||
if (isAPrettyPortrait)
|
||||
return;
|
||||
this.OnMouseOver += new UIElement.MouseEvent(this.MouseOver);
|
||||
this.OnMouseOut += new UIElement.MouseEvent(this.MouseOut);
|
||||
}
|
||||
|
||||
private Asset<Texture2D> TryGettingBackgroundImageProvider(BestiaryEntry entry)
|
||||
{
|
||||
IEnumerable<IBestiaryBackgroundImagePathAndColorProvider> source = entry.Info.Where<IBestiaryInfoElement>((Func<IBestiaryInfoElement, bool>) (x => x is IBestiaryBackgroundImagePathAndColorProvider)).Select<IBestiaryInfoElement, IBestiaryBackgroundImagePathAndColorProvider>((Func<IBestiaryInfoElement, IBestiaryBackgroundImagePathAndColorProvider>) (x => x as IBestiaryBackgroundImagePathAndColorProvider));
|
||||
IEnumerable<IPreferenceProviderElement> preferences = entry.Info.OfType<IPreferenceProviderElement>();
|
||||
foreach (IBestiaryBackgroundImagePathAndColorProvider andColorProvider in source.Where<IBestiaryBackgroundImagePathAndColorProvider>((Func<IBestiaryBackgroundImagePathAndColorProvider, bool>) (provider => preferences.Any<IPreferenceProviderElement>((Func<IPreferenceProviderElement, bool>) (preference => preference.Matches(provider))))))
|
||||
{
|
||||
Asset<Texture2D> backgroundImage = andColorProvider.GetBackgroundImage();
|
||||
if (backgroundImage != null)
|
||||
return backgroundImage;
|
||||
}
|
||||
foreach (IBestiaryBackgroundImagePathAndColorProvider andColorProvider in source)
|
||||
{
|
||||
Asset<Texture2D> backgroundImage = andColorProvider.GetBackgroundImage();
|
||||
if (backgroundImage != null)
|
||||
return backgroundImage;
|
||||
}
|
||||
return (Asset<Texture2D>) null;
|
||||
}
|
||||
|
||||
private int? TryGettingDisplayIndex(BestiaryEntry entry)
|
||||
{
|
||||
int? nullable = new int?();
|
||||
IBestiaryInfoElement bestiaryInfoElement = entry.Info.FirstOrDefault<IBestiaryInfoElement>((Func<IBestiaryInfoElement, bool>) (x => x is IBestiaryEntryDisplayIndex));
|
||||
if (bestiaryInfoElement != null)
|
||||
nullable = new int?((bestiaryInfoElement as IBestiaryEntryDisplayIndex).BestiaryDisplayIndex);
|
||||
return nullable;
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
if (!this.IsMouseHovering)
|
||||
return;
|
||||
Main.instance.MouseText(this._icon.GetHoverText());
|
||||
}
|
||||
|
||||
private void MouseOver(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
SoundEngine.PlaySound(12);
|
||||
this.RemoveChild((UIElement) this._borders);
|
||||
this.RemoveChild((UIElement) this._bordersGlow);
|
||||
this.RemoveChild((UIElement) this._bordersOverlay);
|
||||
this.Append((UIElement) this._borders);
|
||||
this.Append((UIElement) this._bordersGlow);
|
||||
this._icon.ForceHover = true;
|
||||
}
|
||||
|
||||
private void MouseOut(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
this.RemoveChild((UIElement) this._borders);
|
||||
this.RemoveChild((UIElement) this._bordersGlow);
|
||||
this.RemoveChild((UIElement) this._bordersOverlay);
|
||||
this.Append((UIElement) this._bordersOverlay);
|
||||
this.Append((UIElement) this._borders);
|
||||
this._icon.ForceHover = false;
|
||||
}
|
||||
}
|
||||
}
|
124
GameContent/UI/Elements/UIBestiaryEntryGrid.cs
Normal file
124
GameContent/UI/Elements/UIBestiaryEntryGrid.cs
Normal file
|
@ -0,0 +1,124 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIBestiaryEntryGrid
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.GameContent.Bestiary;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIBestiaryEntryGrid : UIElement
|
||||
{
|
||||
private List<BestiaryEntry> _workingSetEntries;
|
||||
private UIElement.MouseEvent _clickOnEntryEvent;
|
||||
private int _atEntryIndex;
|
||||
private int _lastEntry;
|
||||
|
||||
public event Action OnGridContentsChanged;
|
||||
|
||||
public UIBestiaryEntryGrid(
|
||||
List<BestiaryEntry> workingSet,
|
||||
UIElement.MouseEvent clickOnEntryEvent)
|
||||
{
|
||||
this.Width = new StyleDimension(0.0f, 1f);
|
||||
this.Height = new StyleDimension(0.0f, 1f);
|
||||
this._workingSetEntries = workingSet;
|
||||
this._clickOnEntryEvent = clickOnEntryEvent;
|
||||
this.SetPadding(0.0f);
|
||||
this.UpdateEntries();
|
||||
this.FillBestiarySpaceWithEntries();
|
||||
}
|
||||
|
||||
public void UpdateEntries() => this._lastEntry = this._workingSetEntries.Count;
|
||||
|
||||
public void FillBestiarySpaceWithEntries()
|
||||
{
|
||||
this.RemoveAllChildren();
|
||||
this.UpdateEntries();
|
||||
int maxEntriesWidth;
|
||||
int maxEntriesHeight;
|
||||
int maxEntriesToHave;
|
||||
this.GetEntriesToShow(out maxEntriesWidth, out maxEntriesHeight, out maxEntriesToHave);
|
||||
this.FixBestiaryRange(0, maxEntriesToHave);
|
||||
int atEntryIndex = this._atEntryIndex;
|
||||
int num1 = Math.Min(this._lastEntry, atEntryIndex + maxEntriesToHave);
|
||||
List<BestiaryEntry> bestiaryEntryList = new List<BestiaryEntry>();
|
||||
for (int index = atEntryIndex; index < num1; ++index)
|
||||
bestiaryEntryList.Add(this._workingSetEntries[index]);
|
||||
int num2 = 0;
|
||||
float num3 = 0.5f / (float) maxEntriesWidth;
|
||||
float num4 = 0.5f / (float) maxEntriesHeight;
|
||||
for (int index1 = 0; index1 < maxEntriesHeight; ++index1)
|
||||
{
|
||||
for (int index2 = 0; index2 < maxEntriesWidth && num2 < bestiaryEntryList.Count; ++index2)
|
||||
{
|
||||
UIElement element = (UIElement) new UIBestiaryEntryButton(bestiaryEntryList[num2], false);
|
||||
++num2;
|
||||
element.OnClick += this._clickOnEntryEvent;
|
||||
element.VAlign = element.HAlign = 0.5f;
|
||||
element.Left.Set(0.0f, (float) ((double) index2 / (double) maxEntriesWidth - 0.5) + num3);
|
||||
element.Top.Set(0.0f, (float) ((double) index1 / (double) maxEntriesHeight - 0.5) + num4);
|
||||
element.SetSnapPoint("Entries", num2, new Vector2?(new Vector2(0.2f, 0.7f)));
|
||||
this.Append(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Recalculate()
|
||||
{
|
||||
base.Recalculate();
|
||||
this.FillBestiarySpaceWithEntries();
|
||||
}
|
||||
|
||||
public void GetEntriesToShow(
|
||||
out int maxEntriesWidth,
|
||||
out int maxEntriesHeight,
|
||||
out int maxEntriesToHave)
|
||||
{
|
||||
Rectangle rectangle = this.GetDimensions().ToRectangle();
|
||||
maxEntriesWidth = rectangle.Width / 72;
|
||||
maxEntriesHeight = rectangle.Height / 72;
|
||||
int num = 0;
|
||||
maxEntriesToHave = maxEntriesWidth * maxEntriesHeight - num;
|
||||
}
|
||||
|
||||
public string GetRangeText()
|
||||
{
|
||||
int maxEntriesToHave;
|
||||
this.GetEntriesToShow(out int _, out int _, out maxEntriesToHave);
|
||||
int atEntryIndex = this._atEntryIndex;
|
||||
int val2 = Math.Min(this._lastEntry, atEntryIndex + maxEntriesToHave);
|
||||
return string.Format("{0}-{1} ({2})", (object) Math.Min(atEntryIndex + 1, val2), (object) val2, (object) this._lastEntry);
|
||||
}
|
||||
|
||||
public void MakeButtonGoByOffset(UIElement element, int howManyPages) => element.OnClick += (UIElement.MouseEvent) ((e, v) => this.OffsetLibraryByPages(howManyPages));
|
||||
|
||||
public void OffsetLibraryByPages(int howManyPages)
|
||||
{
|
||||
int maxEntriesToHave;
|
||||
this.GetEntriesToShow(out int _, out int _, out maxEntriesToHave);
|
||||
this.OffsetLibrary(howManyPages * maxEntriesToHave);
|
||||
}
|
||||
|
||||
public void OffsetLibrary(int offset)
|
||||
{
|
||||
int maxEntriesToHave;
|
||||
this.GetEntriesToShow(out int _, out int _, out maxEntriesToHave);
|
||||
this.FixBestiaryRange(offset, maxEntriesToHave);
|
||||
this.FillBestiarySpaceWithEntries();
|
||||
}
|
||||
|
||||
private void FixBestiaryRange(int offset, int maxEntriesToHave)
|
||||
{
|
||||
this._atEntryIndex = Utils.Clamp<int>(this._atEntryIndex + offset, 0, Math.Max(0, this._lastEntry - maxEntriesToHave));
|
||||
if (this.OnGridContentsChanged == null)
|
||||
return;
|
||||
this.OnGridContentsChanged();
|
||||
}
|
||||
}
|
||||
}
|
73
GameContent/UI/Elements/UIBestiaryEntryIcon.cs
Normal file
73
GameContent/UI/Elements/UIBestiaryEntryIcon.cs
Normal file
|
@ -0,0 +1,73 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIBestiaryEntryIcon
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria.GameContent.Bestiary;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIBestiaryEntryIcon : UIElement
|
||||
{
|
||||
private BestiaryEntry _entry;
|
||||
private Asset<Texture2D> _notUnlockedTexture;
|
||||
private bool _isPortrait;
|
||||
public bool ForceHover;
|
||||
private BestiaryUICollectionInfo _collectionInfo;
|
||||
|
||||
public UIBestiaryEntryIcon(BestiaryEntry entry, bool isPortrait)
|
||||
{
|
||||
this._entry = entry;
|
||||
this.IgnoresMouseInteraction = true;
|
||||
this.OverrideSamplerState = Main.DefaultSamplerState;
|
||||
this.UseImmediateMode = true;
|
||||
this.Width.Set(0.0f, 1f);
|
||||
this.Height.Set(0.0f, 1f);
|
||||
this._notUnlockedTexture = Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Icon_Locked", (AssetRequestMode) 1);
|
||||
this._isPortrait = isPortrait;
|
||||
this._collectionInfo = this._entry.UIInfoProvider.GetEntryUICollectionInfo();
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
this._collectionInfo = this._entry.UIInfoProvider.GetEntryUICollectionInfo();
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
bool flag = this.IsMouseHovering || this.ForceHover;
|
||||
this._entry.Icon.Update(this._collectionInfo, dimensions.ToRectangle(), new EntryIconDrawSettings()
|
||||
{
|
||||
iconbox = dimensions.ToRectangle(),
|
||||
IsPortrait = this._isPortrait,
|
||||
IsHovered = flag
|
||||
});
|
||||
base.Update(gameTime);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
int num = this._entry.Icon.GetUnlockState(this._collectionInfo) ? 1 : 0;
|
||||
bool flag = this.IsMouseHovering || this.ForceHover;
|
||||
if (num != 0)
|
||||
{
|
||||
this._entry.Icon.Draw(this._collectionInfo, spriteBatch, new EntryIconDrawSettings()
|
||||
{
|
||||
iconbox = dimensions.ToRectangle(),
|
||||
IsPortrait = this._isPortrait,
|
||||
IsHovered = flag
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Texture2D texture2D = this._notUnlockedTexture.Value;
|
||||
spriteBatch.Draw(texture2D, dimensions.Center(), new Rectangle?(), Color.White * 0.15f, 0.0f, texture2D.Size() / 2f, 1f, SpriteEffects.None, 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
public string GetHoverText() => this._entry.Icon.GetHoverText(this._collectionInfo);
|
||||
}
|
||||
}
|
188
GameContent/UI/Elements/UIBestiaryEntryInfoPage.cs
Normal file
188
GameContent/UI/Elements/UIBestiaryEntryInfoPage.cs
Normal file
|
@ -0,0 +1,188 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIBestiaryEntryInfoPage
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Terraria.GameContent.Bestiary;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIBestiaryEntryInfoPage : UIPanel
|
||||
{
|
||||
private UIList _list;
|
||||
private UIScrollbar _scrollbar;
|
||||
private bool _isScrollbarAttached;
|
||||
|
||||
public UIBestiaryEntryInfoPage()
|
||||
{
|
||||
this.Width.Set(230f, 0.0f);
|
||||
this.Height.Set(0.0f, 1f);
|
||||
this.SetPadding(0.0f);
|
||||
this.BorderColor = new Color(89, 116, 213, (int) byte.MaxValue);
|
||||
this.BackgroundColor = new Color(73, 94, 171);
|
||||
UIList uiList1 = new UIList();
|
||||
uiList1.Width = StyleDimension.FromPixelsAndPercent(0.0f, 1f);
|
||||
uiList1.Height = StyleDimension.FromPixelsAndPercent(0.0f, 1f);
|
||||
UIList uiList2 = uiList1;
|
||||
uiList2.SetPadding(2f);
|
||||
uiList2.PaddingBottom = 4f;
|
||||
uiList2.PaddingTop = 4f;
|
||||
this.Append((UIElement) uiList2);
|
||||
this._list = uiList2;
|
||||
uiList2.ListPadding = 4f;
|
||||
uiList2.ManualSortMethod = new Action<List<UIElement>>(this.ManualIfnoSortingMethod);
|
||||
UIScrollbar uiScrollbar = new UIScrollbar();
|
||||
uiScrollbar.SetView(100f, 1000f);
|
||||
uiScrollbar.Height.Set(-20f, 1f);
|
||||
uiScrollbar.HAlign = 1f;
|
||||
uiScrollbar.VAlign = 0.5f;
|
||||
uiScrollbar.Left.Set(-6f, 0.0f);
|
||||
this._scrollbar = uiScrollbar;
|
||||
this._list.SetScrollbar(this._scrollbar);
|
||||
this.CheckScrollBar();
|
||||
this.AppendBorderOverEverything();
|
||||
}
|
||||
|
||||
public void UpdateScrollbar(int scrollWheelValue)
|
||||
{
|
||||
if (this._scrollbar == null)
|
||||
return;
|
||||
this._scrollbar.ViewPosition -= (float) scrollWheelValue;
|
||||
}
|
||||
|
||||
private void AppendBorderOverEverything()
|
||||
{
|
||||
UIPanel uiPanel1 = new UIPanel();
|
||||
uiPanel1.Width = new StyleDimension(0.0f, 1f);
|
||||
uiPanel1.Height = new StyleDimension(0.0f, 1f);
|
||||
uiPanel1.IgnoresMouseInteraction = true;
|
||||
UIPanel uiPanel2 = uiPanel1;
|
||||
uiPanel2.BorderColor = new Color(89, 116, 213, (int) byte.MaxValue);
|
||||
uiPanel2.BackgroundColor = Color.Transparent;
|
||||
this.Append((UIElement) uiPanel2);
|
||||
}
|
||||
|
||||
private void ManualIfnoSortingMethod(List<UIElement> list)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Recalculate()
|
||||
{
|
||||
base.Recalculate();
|
||||
this.CheckScrollBar();
|
||||
}
|
||||
|
||||
private void CheckScrollBar()
|
||||
{
|
||||
if (this._scrollbar == null)
|
||||
return;
|
||||
bool canScroll = this._scrollbar.CanScroll;
|
||||
bool flag = true;
|
||||
if (this._isScrollbarAttached && !flag)
|
||||
{
|
||||
this.RemoveChild((UIElement) this._scrollbar);
|
||||
this._isScrollbarAttached = false;
|
||||
this._list.Width.Set(0.0f, 1f);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(!this._isScrollbarAttached & flag))
|
||||
return;
|
||||
this.Append((UIElement) this._scrollbar);
|
||||
this._isScrollbarAttached = true;
|
||||
this._list.Width.Set(-20f, 1f);
|
||||
}
|
||||
}
|
||||
|
||||
public void FillInfoForEntry(BestiaryEntry entry, ExtraBestiaryInfoPageInformation extraInfo)
|
||||
{
|
||||
this._list.Clear();
|
||||
if (entry == null)
|
||||
return;
|
||||
this.AddInfoToList(entry, extraInfo);
|
||||
this.Recalculate();
|
||||
}
|
||||
|
||||
private BestiaryUICollectionInfo GetUICollectionInfo(
|
||||
BestiaryEntry entry,
|
||||
ExtraBestiaryInfoPageInformation extraInfo)
|
||||
{
|
||||
IBestiaryUICollectionInfoProvider uiInfoProvider = entry.UIInfoProvider;
|
||||
BestiaryUICollectionInfo uiCollectionInfo = uiInfoProvider == null ? new BestiaryUICollectionInfo() : uiInfoProvider.GetEntryUICollectionInfo();
|
||||
uiCollectionInfo.OwnerEntry = entry;
|
||||
return uiCollectionInfo;
|
||||
}
|
||||
|
||||
private void AddInfoToList(BestiaryEntry entry, ExtraBestiaryInfoPageInformation extraInfo)
|
||||
{
|
||||
BestiaryUICollectionInfo uiCollectionInfo = this.GetUICollectionInfo(entry, extraInfo);
|
||||
IOrderedEnumerable<IGrouping<UIBestiaryEntryInfoPage.BestiaryInfoCategory, IBestiaryInfoElement>> orderedEnumerable = new List<IBestiaryInfoElement>((IEnumerable<IBestiaryInfoElement>) entry.Info).GroupBy<IBestiaryInfoElement, UIBestiaryEntryInfoPage.BestiaryInfoCategory>(new Func<IBestiaryInfoElement, UIBestiaryEntryInfoPage.BestiaryInfoCategory>(this.GetBestiaryInfoCategory)).OrderBy<IGrouping<UIBestiaryEntryInfoPage.BestiaryInfoCategory, IBestiaryInfoElement>, UIBestiaryEntryInfoPage.BestiaryInfoCategory>((Func<IGrouping<UIBestiaryEntryInfoPage.BestiaryInfoCategory, IBestiaryInfoElement>, UIBestiaryEntryInfoPage.BestiaryInfoCategory>) (x => x.Key));
|
||||
UIElement uiElement1 = (UIElement) null;
|
||||
foreach (IGrouping<UIBestiaryEntryInfoPage.BestiaryInfoCategory, IBestiaryInfoElement> source in (IEnumerable<IGrouping<UIBestiaryEntryInfoPage.BestiaryInfoCategory, IBestiaryInfoElement>>) orderedEnumerable)
|
||||
{
|
||||
if (source.Count<IBestiaryInfoElement>() != 0)
|
||||
{
|
||||
bool flag = false;
|
||||
foreach (IBestiaryInfoElement bestiaryInfoElement in (IEnumerable<IBestiaryInfoElement>) source)
|
||||
{
|
||||
UIElement uiElement2 = bestiaryInfoElement.ProvideUIElement(uiCollectionInfo);
|
||||
if (uiElement2 != null)
|
||||
{
|
||||
this._list.Add(uiElement2);
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
UIHorizontalSeparator horizontalSeparator1 = new UIHorizontalSeparator();
|
||||
horizontalSeparator1.Width = StyleDimension.FromPixelsAndPercent(0.0f, 1f);
|
||||
horizontalSeparator1.Color = new Color(89, 116, 213, (int) byte.MaxValue) * 0.9f;
|
||||
UIHorizontalSeparator horizontalSeparator2 = horizontalSeparator1;
|
||||
this._list.Add((UIElement) horizontalSeparator2);
|
||||
uiElement1 = (UIElement) horizontalSeparator2;
|
||||
}
|
||||
}
|
||||
}
|
||||
this._list.Remove(uiElement1);
|
||||
}
|
||||
|
||||
private UIBestiaryEntryInfoPage.BestiaryInfoCategory GetBestiaryInfoCategory(
|
||||
IBestiaryInfoElement element)
|
||||
{
|
||||
switch (element)
|
||||
{
|
||||
case NPCPortraitInfoElement _:
|
||||
return UIBestiaryEntryInfoPage.BestiaryInfoCategory.Portrait;
|
||||
case FlavorTextBestiaryInfoElement _:
|
||||
return UIBestiaryEntryInfoPage.BestiaryInfoCategory.FlavorText;
|
||||
case NamePlateInfoElement _:
|
||||
return UIBestiaryEntryInfoPage.BestiaryInfoCategory.Nameplate;
|
||||
case ItemFromCatchingNPCBestiaryInfoElement _:
|
||||
return UIBestiaryEntryInfoPage.BestiaryInfoCategory.ItemsFromCatchingNPC;
|
||||
case ItemDropBestiaryInfoElement _:
|
||||
return UIBestiaryEntryInfoPage.BestiaryInfoCategory.ItemsFromDrops;
|
||||
case NPCStatsReportInfoElement _:
|
||||
return UIBestiaryEntryInfoPage.BestiaryInfoCategory.Stats;
|
||||
default:
|
||||
return UIBestiaryEntryInfoPage.BestiaryInfoCategory.Misc;
|
||||
}
|
||||
}
|
||||
|
||||
private enum BestiaryInfoCategory
|
||||
{
|
||||
Nameplate,
|
||||
Portrait,
|
||||
FlavorText,
|
||||
Stats,
|
||||
ItemsFromCatchingNPC,
|
||||
ItemsFromDrops,
|
||||
Misc,
|
||||
}
|
||||
}
|
||||
}
|
244
GameContent/UI/Elements/UIBestiaryFilteringOptionsGrid.cs
Normal file
244
GameContent/UI/Elements/UIBestiaryFilteringOptionsGrid.cs
Normal file
|
@ -0,0 +1,244 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIBestiaryFilteringOptionsGrid
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.GameContent.Bestiary;
|
||||
using Terraria.ID;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIBestiaryFilteringOptionsGrid : UIPanel
|
||||
{
|
||||
private EntryFilterer<BestiaryEntry, IBestiaryEntryFilter> _filterer;
|
||||
private List<GroupOptionButton<int>> _filterButtons;
|
||||
private List<bool> _areFiltersAvailable;
|
||||
private List<List<BestiaryEntry>> _filterAvailabilityTests;
|
||||
private UIElement _container;
|
||||
|
||||
public event Action OnClickingOption;
|
||||
|
||||
public UIBestiaryFilteringOptionsGrid(
|
||||
EntryFilterer<BestiaryEntry, IBestiaryEntryFilter> filterer)
|
||||
{
|
||||
this._filterer = filterer;
|
||||
this._filterButtons = new List<GroupOptionButton<int>>();
|
||||
this._areFiltersAvailable = new List<bool>();
|
||||
this._filterAvailabilityTests = new List<List<BestiaryEntry>>();
|
||||
this.Width = new StyleDimension(0.0f, 1f);
|
||||
this.Height = new StyleDimension(0.0f, 1f);
|
||||
this.BackgroundColor = new Color(35, 40, 83) * 0.5f;
|
||||
this.BorderColor = new Color(35, 40, 83) * 0.5f;
|
||||
this.IgnoresMouseInteraction = false;
|
||||
this.SetPadding(0.0f);
|
||||
this.BuildContainer();
|
||||
}
|
||||
|
||||
private void BuildContainer()
|
||||
{
|
||||
int widthWithSpacing;
|
||||
int heightWithSpacing;
|
||||
int perRow;
|
||||
int howManyRows;
|
||||
this.GetDisplaySettings(out int _, out int _, out widthWithSpacing, out heightWithSpacing, out perRow, out float _, out float _, out howManyRows);
|
||||
UIPanel uiPanel1 = new UIPanel();
|
||||
uiPanel1.Width = new StyleDimension((float) (perRow * widthWithSpacing + 10), 0.0f);
|
||||
uiPanel1.Height = new StyleDimension((float) (howManyRows * heightWithSpacing + 10), 0.0f);
|
||||
uiPanel1.HAlign = 1f;
|
||||
uiPanel1.VAlign = 0.0f;
|
||||
uiPanel1.Left = new StyleDimension(0.0f, 0.0f);
|
||||
uiPanel1.Top = new StyleDimension(0.0f, 0.0f);
|
||||
UIPanel uiPanel2 = uiPanel1;
|
||||
uiPanel2.BorderColor = new Color(89, 116, 213, (int) byte.MaxValue) * 0.9f;
|
||||
uiPanel2.BackgroundColor = new Color(73, 94, 171) * 0.9f;
|
||||
uiPanel2.SetPadding(0.0f);
|
||||
this.Append((UIElement) uiPanel2);
|
||||
this._container = (UIElement) uiPanel2;
|
||||
}
|
||||
|
||||
public void SetupAvailabilityTest(List<BestiaryEntry> allAvailableEntries)
|
||||
{
|
||||
this._filterAvailabilityTests.Clear();
|
||||
for (int index1 = 0; index1 < this._filterer.AvailableFilters.Count; ++index1)
|
||||
{
|
||||
List<BestiaryEntry> bestiaryEntryList = new List<BestiaryEntry>();
|
||||
this._filterAvailabilityTests.Add(bestiaryEntryList);
|
||||
IBestiaryEntryFilter availableFilter = this._filterer.AvailableFilters[index1];
|
||||
for (int index2 = 0; index2 < allAvailableEntries.Count; ++index2)
|
||||
{
|
||||
if (availableFilter.FitsFilter(allAvailableEntries[index2]))
|
||||
bestiaryEntryList.Add(allAvailableEntries[index2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateAvailability()
|
||||
{
|
||||
int widthPerButton;
|
||||
int heightPerButton;
|
||||
int widthWithSpacing;
|
||||
int heightWithSpacing;
|
||||
int perRow;
|
||||
float offsetLeft;
|
||||
float offsetTop;
|
||||
this.GetDisplaySettings(out widthPerButton, out heightPerButton, out widthWithSpacing, out heightWithSpacing, out perRow, out offsetLeft, out offsetTop, out int _);
|
||||
this._container.RemoveAllChildren();
|
||||
this._filterButtons.Clear();
|
||||
this._areFiltersAvailable.Clear();
|
||||
int num1 = -1;
|
||||
int num2 = -1;
|
||||
for (int index = 0; index < this._filterer.AvailableFilters.Count; ++index)
|
||||
{
|
||||
int num3 = index / perRow;
|
||||
int num4 = index % perRow;
|
||||
IBestiaryEntryFilter availableFilter = this._filterer.AvailableFilters[index];
|
||||
List<BestiaryEntry> availabilityTest = this._filterAvailabilityTests[index];
|
||||
if (this.GetIsFilterAvailableForEntries(availableFilter, availabilityTest))
|
||||
{
|
||||
GroupOptionButton<int> groupOptionButton1 = new GroupOptionButton<int>(index, (LocalizedText) null, (LocalizedText) null, Color.White, (string) null);
|
||||
groupOptionButton1.Width = new StyleDimension((float) widthPerButton, 0.0f);
|
||||
groupOptionButton1.Height = new StyleDimension((float) heightPerButton, 0.0f);
|
||||
groupOptionButton1.HAlign = 0.0f;
|
||||
groupOptionButton1.VAlign = 0.0f;
|
||||
groupOptionButton1.Top = new StyleDimension(offsetTop + (float) (num3 * heightWithSpacing), 0.0f);
|
||||
groupOptionButton1.Left = new StyleDimension(offsetLeft + (float) (num4 * widthWithSpacing), 0.0f);
|
||||
GroupOptionButton<int> groupOptionButton2 = groupOptionButton1;
|
||||
groupOptionButton2.OnClick += new UIElement.MouseEvent(this.ClickOption);
|
||||
groupOptionButton2.SetSnapPoint("Filters", index);
|
||||
groupOptionButton2.ShowHighlightWhenSelected = false;
|
||||
this.AddOnHover(availableFilter, (UIElement) groupOptionButton2);
|
||||
this._container.Append((UIElement) groupOptionButton2);
|
||||
UIElement image = availableFilter.GetImage();
|
||||
if (image != null)
|
||||
{
|
||||
image.Left = new StyleDimension((float) num1, 0.0f);
|
||||
image.Top = new StyleDimension((float) num2, 0.0f);
|
||||
groupOptionButton2.Append(image);
|
||||
}
|
||||
this._filterButtons.Add(groupOptionButton2);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._filterer.ActiveFilters.Remove(availableFilter);
|
||||
GroupOptionButton<int> groupOptionButton3 = new GroupOptionButton<int>(-2, (LocalizedText) null, (LocalizedText) null, Color.White, (string) null);
|
||||
groupOptionButton3.Width = new StyleDimension((float) widthPerButton, 0.0f);
|
||||
groupOptionButton3.Height = new StyleDimension((float) heightPerButton, 0.0f);
|
||||
groupOptionButton3.HAlign = 0.0f;
|
||||
groupOptionButton3.VAlign = 0.0f;
|
||||
groupOptionButton3.Top = new StyleDimension(offsetTop + (float) (num3 * heightWithSpacing), 0.0f);
|
||||
groupOptionButton3.Left = new StyleDimension(offsetLeft + (float) (num4 * widthWithSpacing), 0.0f);
|
||||
groupOptionButton3.FadeFromBlack = 0.5f;
|
||||
GroupOptionButton<int> groupOptionButton4 = groupOptionButton3;
|
||||
groupOptionButton4.ShowHighlightWhenSelected = false;
|
||||
groupOptionButton4.SetPadding(0.0f);
|
||||
groupOptionButton4.SetSnapPoint("Filters", index);
|
||||
Asset<Texture2D> asset = Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Icon_Tags_Shadow", (AssetRequestMode) 1);
|
||||
UIImageFramed uiImageFramed1 = new UIImageFramed(asset, asset.Frame(16, 5, frameY: 4));
|
||||
uiImageFramed1.HAlign = 0.5f;
|
||||
uiImageFramed1.VAlign = 0.5f;
|
||||
uiImageFramed1.Color = Color.White * 0.2f;
|
||||
UIImageFramed uiImageFramed2 = uiImageFramed1;
|
||||
uiImageFramed2.Left = new StyleDimension((float) num1, 0.0f);
|
||||
uiImageFramed2.Top = new StyleDimension((float) num2, 0.0f);
|
||||
groupOptionButton4.Append((UIElement) uiImageFramed2);
|
||||
this._filterButtons.Add(groupOptionButton4);
|
||||
this._container.Append((UIElement) groupOptionButton4);
|
||||
}
|
||||
}
|
||||
this.UpdateButtonSelections();
|
||||
}
|
||||
|
||||
public void GetEntriesToShow(
|
||||
out int maxEntriesWidth,
|
||||
out int maxEntriesHeight,
|
||||
out int maxEntriesToHave)
|
||||
{
|
||||
int perRow;
|
||||
int howManyRows;
|
||||
this.GetDisplaySettings(out int _, out int _, out int _, out int _, out perRow, out float _, out float _, out howManyRows);
|
||||
maxEntriesWidth = perRow;
|
||||
maxEntriesHeight = howManyRows;
|
||||
maxEntriesToHave = this._filterer.AvailableFilters.Count;
|
||||
}
|
||||
|
||||
private void GetDisplaySettings(
|
||||
out int widthPerButton,
|
||||
out int heightPerButton,
|
||||
out int widthWithSpacing,
|
||||
out int heightWithSpacing,
|
||||
out int perRow,
|
||||
out float offsetLeft,
|
||||
out float offsetTop,
|
||||
out int howManyRows)
|
||||
{
|
||||
widthPerButton = 32;
|
||||
heightPerButton = 32;
|
||||
int num = 2;
|
||||
widthWithSpacing = widthPerButton + num;
|
||||
heightWithSpacing = heightPerButton + num;
|
||||
perRow = (int) Math.Ceiling(Math.Sqrt((double) this._filterer.AvailableFilters.Count));
|
||||
perRow = 12;
|
||||
howManyRows = (int) Math.Ceiling((double) this._filterer.AvailableFilters.Count / (double) perRow);
|
||||
offsetLeft = (float) (perRow * widthWithSpacing - num) * 0.5f;
|
||||
offsetTop = (float) (howManyRows * heightWithSpacing - num) * 0.5f;
|
||||
offsetLeft = 6f;
|
||||
offsetTop = 6f;
|
||||
}
|
||||
|
||||
private void UpdateButtonSelections()
|
||||
{
|
||||
foreach (GroupOptionButton<int> filterButton in this._filterButtons)
|
||||
{
|
||||
bool flag = this._filterer.IsFilterActive(filterButton.OptionValue);
|
||||
filterButton.SetCurrentOption(flag ? filterButton.OptionValue : -1);
|
||||
if (flag)
|
||||
filterButton.SetColor(new Color(152, 175, 235), 1f);
|
||||
else
|
||||
filterButton.SetColor(Colors.InventoryDefaultColor, 0.7f);
|
||||
}
|
||||
}
|
||||
|
||||
private bool GetIsFilterAvailableForEntries(
|
||||
IBestiaryEntryFilter filter,
|
||||
List<BestiaryEntry> entries)
|
||||
{
|
||||
bool? forcedDisplay = filter.ForcedDisplay;
|
||||
if (forcedDisplay.HasValue)
|
||||
return forcedDisplay.Value;
|
||||
for (int index = 0; index < entries.Count; ++index)
|
||||
{
|
||||
if (filter.FitsFilter(entries[index]) && entries[index].UIInfoProvider.GetEntryUICollectionInfo().UnlockState > BestiaryEntryUnlockState.NotKnownAtAll_0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void AddOnHover(IBestiaryEntryFilter filter, UIElement button) => button.OnUpdate += (UIElement.ElementEvent) (element => this.ShowButtonName(element, filter));
|
||||
|
||||
private void ShowButtonName(UIElement element, IBestiaryEntryFilter number)
|
||||
{
|
||||
if (!element.IsMouseHovering)
|
||||
return;
|
||||
string textValue = Language.GetTextValue(number.GetDisplayNameKey());
|
||||
Main.instance.MouseText(textValue);
|
||||
}
|
||||
|
||||
private void ClickOption(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
this._filterer.ToggleFilter(((GroupOptionButton<int>) listeningElement).OptionValue);
|
||||
this.UpdateButtonSelections();
|
||||
if (this.OnClickingOption == null)
|
||||
return;
|
||||
this.OnClickingOption();
|
||||
}
|
||||
}
|
||||
}
|
143
GameContent/UI/Elements/UIBestiaryInfoItemLine.cs
Normal file
143
GameContent/UI/Elements/UIBestiaryInfoItemLine.cs
Normal file
|
@ -0,0 +1,143 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIBestiaryInfoItemLine
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.Audio;
|
||||
using Terraria.GameContent.Bestiary;
|
||||
using Terraria.GameContent.ItemDropRules;
|
||||
using Terraria.ID;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIBestiaryInfoItemLine : UIPanel, IManuallyOrderedUIElement
|
||||
{
|
||||
private Item _infoDisplayItem;
|
||||
private bool _hideMouseOver;
|
||||
|
||||
public int OrderInUIList { get; set; }
|
||||
|
||||
public UIBestiaryInfoItemLine(
|
||||
DropRateInfo info,
|
||||
BestiaryUICollectionInfo uiinfo,
|
||||
float textScale = 1f)
|
||||
{
|
||||
this._infoDisplayItem = new Item();
|
||||
this._infoDisplayItem.SetDefaults(info.itemId);
|
||||
this.SetBestiaryNotesOnItemCache(info);
|
||||
this.SetPadding(0.0f);
|
||||
this.PaddingLeft = 10f;
|
||||
this.PaddingRight = 10f;
|
||||
this.Width.Set(-14f, 1f);
|
||||
this.Height.Set(32f, 0.0f);
|
||||
this.Left.Set(5f, 0.0f);
|
||||
this.OnMouseOver += new UIElement.MouseEvent(this.MouseOver);
|
||||
this.OnMouseOut += new UIElement.MouseEvent(this.MouseOut);
|
||||
this.BorderColor = new Color(89, 116, 213, (int) byte.MaxValue);
|
||||
string stackRange;
|
||||
string droprate;
|
||||
this.GetDropInfo(info, uiinfo, out stackRange, out droprate);
|
||||
if (uiinfo.UnlockState < BestiaryEntryUnlockState.CanShowDropsWithoutDropRates_3)
|
||||
{
|
||||
this._hideMouseOver = true;
|
||||
Asset<Texture2D> texture = Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Icon_Locked", (AssetRequestMode) 1);
|
||||
UIElement element = new UIElement()
|
||||
{
|
||||
Height = new StyleDimension(0.0f, 1f),
|
||||
Width = new StyleDimension(0.0f, 1f),
|
||||
HAlign = 0.5f,
|
||||
VAlign = 0.5f
|
||||
};
|
||||
element.SetPadding(0.0f);
|
||||
UIImage uiImage1 = new UIImage(texture);
|
||||
uiImage1.ImageScale = 0.55f;
|
||||
uiImage1.HAlign = 0.5f;
|
||||
uiImage1.VAlign = 0.5f;
|
||||
UIImage uiImage2 = uiImage1;
|
||||
element.Append((UIElement) uiImage2);
|
||||
this.Append(element);
|
||||
}
|
||||
else
|
||||
{
|
||||
UIItemIcon uiItemIcon = new UIItemIcon(this._infoDisplayItem, uiinfo.UnlockState < BestiaryEntryUnlockState.CanShowDropsWithoutDropRates_3);
|
||||
uiItemIcon.IgnoresMouseInteraction = true;
|
||||
uiItemIcon.HAlign = 0.0f;
|
||||
uiItemIcon.Left = new StyleDimension(4f, 0.0f);
|
||||
this.Append((UIElement) uiItemIcon);
|
||||
if (!string.IsNullOrEmpty(stackRange))
|
||||
droprate = stackRange + " " + droprate;
|
||||
UITextPanel<string> uiTextPanel = new UITextPanel<string>(droprate, textScale);
|
||||
uiTextPanel.IgnoresMouseInteraction = true;
|
||||
uiTextPanel.DrawPanel = false;
|
||||
uiTextPanel.HAlign = 1f;
|
||||
uiTextPanel.Top = new StyleDimension(-4f, 0.0f);
|
||||
this.Append((UIElement) uiTextPanel);
|
||||
}
|
||||
}
|
||||
|
||||
protected void GetDropInfo(
|
||||
DropRateInfo dropRateInfo,
|
||||
BestiaryUICollectionInfo uiinfo,
|
||||
out string stackRange,
|
||||
out string droprate)
|
||||
{
|
||||
stackRange = dropRateInfo.stackMin == dropRateInfo.stackMax ? (dropRateInfo.stackMin != 1 ? " (" + (object) dropRateInfo.stackMin + ")" : "") : string.Format(" ({0}-{1})", (object) dropRateInfo.stackMin, (object) dropRateInfo.stackMax);
|
||||
string originalFormat = "P";
|
||||
if ((double) dropRateInfo.dropRate < 0.001)
|
||||
originalFormat = "P4";
|
||||
droprate = (double) dropRateInfo.dropRate == 1.0 ? "100%" : Utils.PrettifyPercentDisplay(dropRateInfo.dropRate, originalFormat);
|
||||
if (uiinfo.UnlockState == BestiaryEntryUnlockState.CanShowDropsWithDropRates_4)
|
||||
return;
|
||||
droprate = "???";
|
||||
stackRange = "";
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
base.DrawSelf(spriteBatch);
|
||||
if (!this.IsMouseHovering || this._hideMouseOver)
|
||||
return;
|
||||
this.DrawMouseOver();
|
||||
}
|
||||
|
||||
private void DrawMouseOver()
|
||||
{
|
||||
Main.HoverItem = this._infoDisplayItem;
|
||||
Main.instance.MouseText("");
|
||||
Main.mouseText = true;
|
||||
}
|
||||
|
||||
public override int CompareTo(object obj) => obj is IManuallyOrderedUIElement orderedUiElement ? this.OrderInUIList.CompareTo(orderedUiElement.OrderInUIList) : base.CompareTo(obj);
|
||||
|
||||
private void SetBestiaryNotesOnItemCache(DropRateInfo info)
|
||||
{
|
||||
List<string> stringList = new List<string>();
|
||||
if (info.conditions == null)
|
||||
return;
|
||||
foreach (IProvideItemConditionDescription condition in info.conditions)
|
||||
{
|
||||
if (condition != null)
|
||||
{
|
||||
string conditionDescription = condition.GetConditionDescription();
|
||||
if (!string.IsNullOrWhiteSpace(conditionDescription))
|
||||
stringList.Add(conditionDescription);
|
||||
}
|
||||
}
|
||||
this._infoDisplayItem.BestiaryNotes = string.Join("\n", (IEnumerable<string>) stringList);
|
||||
}
|
||||
|
||||
private void MouseOver(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
SoundEngine.PlaySound(12);
|
||||
this.BorderColor = Colors.FancyUIFatButtonMouseOver;
|
||||
}
|
||||
|
||||
private void MouseOut(UIMouseEvent evt, UIElement listeningElement) => this.BorderColor = new Color(89, 116, 213, (int) byte.MaxValue);
|
||||
}
|
||||
}
|
69
GameContent/UI/Elements/UIBestiaryInfoLine`1.cs
Normal file
69
GameContent/UI/Elements/UIBestiaryInfoLine`1.cs
Normal file
|
@ -0,0 +1,69 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIBestiaryInfoLine`1
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIBestiaryInfoLine<T> : UIElement, IManuallyOrderedUIElement
|
||||
{
|
||||
private T _text;
|
||||
private float _textScale = 1f;
|
||||
private Vector2 _textSize = Vector2.Zero;
|
||||
private Color _color = Color.White;
|
||||
|
||||
public int OrderInUIList { get; set; }
|
||||
|
||||
public float TextScale
|
||||
{
|
||||
get => this._textScale;
|
||||
set => this._textScale = value;
|
||||
}
|
||||
|
||||
public Vector2 TextSize => this._textSize;
|
||||
|
||||
public string Text => (object) this._text != null ? this._text.ToString() : "";
|
||||
|
||||
public Color TextColor
|
||||
{
|
||||
get => this._color;
|
||||
set => this._color = value;
|
||||
}
|
||||
|
||||
public UIBestiaryInfoLine(T text, float textScale = 1f) => this.SetText(text, textScale);
|
||||
|
||||
public override void Recalculate()
|
||||
{
|
||||
this.SetText(this._text, this._textScale);
|
||||
base.Recalculate();
|
||||
}
|
||||
|
||||
public void SetText(T text) => this.SetText(text, this._textScale);
|
||||
|
||||
public virtual void SetText(T text, float textScale)
|
||||
{
|
||||
Vector2 vector2 = new Vector2(FontAssets.MouseText.Value.MeasureString(text.ToString()).X, 16f) * textScale;
|
||||
this._text = text;
|
||||
this._textScale = textScale;
|
||||
this._textSize = vector2;
|
||||
this.MinWidth.Set(vector2.X + this.PaddingLeft + this.PaddingRight, 0.0f);
|
||||
this.MinHeight.Set(vector2.Y + this.PaddingTop + this.PaddingBottom, 0.0f);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
CalculatedStyle innerDimensions = this.GetInnerDimensions();
|
||||
Vector2 pos = innerDimensions.Position();
|
||||
pos.Y -= 2f * this._textScale;
|
||||
pos.X += (float) (((double) innerDimensions.Width - (double) this._textSize.X) * 0.5);
|
||||
Utils.DrawBorderString(spriteBatch, this.Text, pos, this._color, this._textScale);
|
||||
}
|
||||
|
||||
public override int CompareTo(object obj) => obj is IManuallyOrderedUIElement orderedUiElement ? this.OrderInUIList.CompareTo(orderedUiElement.OrderInUIList) : base.CompareTo(obj);
|
||||
}
|
||||
}
|
76
GameContent/UI/Elements/UIBestiaryNPCEntryPortrait.cs
Normal file
76
GameContent/UI/Elements/UIBestiaryNPCEntryPortrait.cs
Normal file
|
@ -0,0 +1,76 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIBestiaryNPCEntryPortrait
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.GameContent.Bestiary;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIBestiaryNPCEntryPortrait : UIElement
|
||||
{
|
||||
public BestiaryEntry Entry { get; private set; }
|
||||
|
||||
public UIBestiaryNPCEntryPortrait(
|
||||
BestiaryEntry entry,
|
||||
Asset<Texture2D> portraitBackgroundAsset,
|
||||
Color portraitColor,
|
||||
List<IBestiaryBackgroundOverlayAndColorProvider> overlays)
|
||||
{
|
||||
this.Entry = entry;
|
||||
this.Height.Set(112f, 0.0f);
|
||||
this.Width.Set(193f, 0.0f);
|
||||
this.SetPadding(0.0f);
|
||||
UIElement element = new UIElement()
|
||||
{
|
||||
Width = new StyleDimension(-4f, 1f),
|
||||
Height = new StyleDimension(-4f, 1f),
|
||||
IgnoresMouseInteraction = true,
|
||||
OverflowHidden = true,
|
||||
HAlign = 0.5f,
|
||||
VAlign = 0.5f
|
||||
};
|
||||
element.SetPadding(0.0f);
|
||||
if (portraitBackgroundAsset != null)
|
||||
{
|
||||
UIElement uiElement = element;
|
||||
UIImage uiImage = new UIImage(portraitBackgroundAsset);
|
||||
uiImage.HAlign = 0.5f;
|
||||
uiImage.VAlign = 0.5f;
|
||||
uiImage.ScaleToFit = true;
|
||||
uiImage.Width = new StyleDimension(0.0f, 1f);
|
||||
uiImage.Height = new StyleDimension(0.0f, 1f);
|
||||
uiImage.Color = portraitColor;
|
||||
uiElement.Append((UIElement) uiImage);
|
||||
}
|
||||
for (int index = 0; index < overlays.Count; ++index)
|
||||
{
|
||||
Asset<Texture2D> backgroundOverlayImage = overlays[index].GetBackgroundOverlayImage();
|
||||
Color? backgroundOverlayColor = overlays[index].GetBackgroundOverlayColor();
|
||||
UIElement uiElement = element;
|
||||
UIImage uiImage = new UIImage(backgroundOverlayImage);
|
||||
uiImage.HAlign = 0.5f;
|
||||
uiImage.VAlign = 0.5f;
|
||||
uiImage.ScaleToFit = true;
|
||||
uiImage.Width = new StyleDimension(0.0f, 1f);
|
||||
uiImage.Height = new StyleDimension(0.0f, 1f);
|
||||
uiImage.Color = backgroundOverlayColor.HasValue ? backgroundOverlayColor.Value : Color.Lerp(Color.White, portraitColor, 0.5f);
|
||||
uiElement.Append((UIElement) uiImage);
|
||||
}
|
||||
UIBestiaryEntryIcon bestiaryEntryIcon = new UIBestiaryEntryIcon(entry, true);
|
||||
element.Append((UIElement) bestiaryEntryIcon);
|
||||
this.Append(element);
|
||||
UIImage uiImage1 = new UIImage(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Portrait_Front", (AssetRequestMode) 1));
|
||||
uiImage1.VAlign = 0.5f;
|
||||
uiImage1.HAlign = 0.5f;
|
||||
uiImage1.IgnoresMouseInteraction = true;
|
||||
this.Append((UIElement) uiImage1);
|
||||
}
|
||||
}
|
||||
}
|
118
GameContent/UI/Elements/UIBestiarySortingOptionsGrid.cs
Normal file
118
GameContent/UI/Elements/UIBestiarySortingOptionsGrid.cs
Normal file
|
@ -0,0 +1,118 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIBestiarySortingOptionsGrid
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.GameContent.Bestiary;
|
||||
using Terraria.ID;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIBestiarySortingOptionsGrid : UIPanel
|
||||
{
|
||||
private EntrySorter<BestiaryEntry, IBestiarySortStep> _sorter;
|
||||
private List<GroupOptionButton<int>> _buttonsBySorting;
|
||||
private int _currentSelected = -1;
|
||||
private int _defaultStepIndex;
|
||||
|
||||
public event Action OnClickingOption;
|
||||
|
||||
public UIBestiarySortingOptionsGrid(
|
||||
EntrySorter<BestiaryEntry, IBestiarySortStep> sorter)
|
||||
{
|
||||
this._sorter = sorter;
|
||||
this._buttonsBySorting = new List<GroupOptionButton<int>>();
|
||||
this.Width = new StyleDimension(0.0f, 1f);
|
||||
this.Height = new StyleDimension(0.0f, 1f);
|
||||
this.BackgroundColor = new Color(35, 40, 83) * 0.5f;
|
||||
this.BorderColor = new Color(35, 40, 83) * 0.5f;
|
||||
this.IgnoresMouseInteraction = false;
|
||||
this.SetPadding(0.0f);
|
||||
this.BuildGrid();
|
||||
}
|
||||
|
||||
private void BuildGrid()
|
||||
{
|
||||
int num1 = 2;
|
||||
int num2 = 26 + num1;
|
||||
int num3 = 0;
|
||||
for (int index = 0; index < this._sorter.Steps.Count; ++index)
|
||||
{
|
||||
if (!this._sorter.Steps[index].HiddenFromSortOptions)
|
||||
++num3;
|
||||
}
|
||||
UIPanel uiPanel1 = new UIPanel();
|
||||
uiPanel1.Width = new StyleDimension(126f, 0.0f);
|
||||
uiPanel1.Height = new StyleDimension((float) (num3 * num2 + 5 + 3), 0.0f);
|
||||
uiPanel1.HAlign = 1f;
|
||||
uiPanel1.VAlign = 0.0f;
|
||||
uiPanel1.Left = new StyleDimension(-118f, 0.0f);
|
||||
uiPanel1.Top = new StyleDimension(0.0f, 0.0f);
|
||||
UIPanel uiPanel2 = uiPanel1;
|
||||
uiPanel2.BorderColor = new Color(89, 116, 213, (int) byte.MaxValue) * 0.9f;
|
||||
uiPanel2.BackgroundColor = new Color(73, 94, 171) * 0.9f;
|
||||
uiPanel2.SetPadding(0.0f);
|
||||
this.Append((UIElement) uiPanel2);
|
||||
int id = 0;
|
||||
for (int index = 0; index < this._sorter.Steps.Count; ++index)
|
||||
{
|
||||
IBestiarySortStep step = this._sorter.Steps[index];
|
||||
if (!step.HiddenFromSortOptions)
|
||||
{
|
||||
GroupOptionButton<int> groupOptionButton1 = new GroupOptionButton<int>(index, Language.GetText(step.GetDisplayNameKey()), (LocalizedText) null, Color.White, (string) null, 0.8f);
|
||||
groupOptionButton1.Width = new StyleDimension(114f, 0.0f);
|
||||
groupOptionButton1.Height = new StyleDimension((float) (num2 - num1), 0.0f);
|
||||
groupOptionButton1.HAlign = 0.5f;
|
||||
groupOptionButton1.Top = new StyleDimension((float) (5 + num2 * id), 0.0f);
|
||||
GroupOptionButton<int> groupOptionButton2 = groupOptionButton1;
|
||||
groupOptionButton2.ShowHighlightWhenSelected = false;
|
||||
groupOptionButton2.OnClick += new UIElement.MouseEvent(this.ClickOption);
|
||||
groupOptionButton2.SetSnapPoint("SortSteps", id);
|
||||
uiPanel2.Append((UIElement) groupOptionButton2);
|
||||
this._buttonsBySorting.Add(groupOptionButton2);
|
||||
++id;
|
||||
}
|
||||
}
|
||||
foreach (GroupOptionButton<int> groupOptionButton in this._buttonsBySorting)
|
||||
groupOptionButton.SetCurrentOption(-1);
|
||||
}
|
||||
|
||||
private void ClickOption(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
int index = ((GroupOptionButton<int>) listeningElement).OptionValue;
|
||||
if (index == this._currentSelected)
|
||||
index = this._defaultStepIndex;
|
||||
foreach (GroupOptionButton<int> groupOptionButton in this._buttonsBySorting)
|
||||
{
|
||||
bool flag = index == groupOptionButton.OptionValue;
|
||||
groupOptionButton.SetCurrentOption(flag ? index : -1);
|
||||
if (flag)
|
||||
groupOptionButton.SetColor(new Color(152, 175, 235), 1f);
|
||||
else
|
||||
groupOptionButton.SetColor(Colors.InventoryDefaultColor, 0.7f);
|
||||
}
|
||||
this._currentSelected = index;
|
||||
this._sorter.SetPrioritizedStepIndex(index);
|
||||
if (this.OnClickingOption == null)
|
||||
return;
|
||||
this.OnClickingOption();
|
||||
}
|
||||
|
||||
public void GetEntriesToShow(
|
||||
out int maxEntriesWidth,
|
||||
out int maxEntriesHeight,
|
||||
out int maxEntriesToHave)
|
||||
{
|
||||
maxEntriesWidth = 1;
|
||||
maxEntriesHeight = this._buttonsBySorting.Count;
|
||||
maxEntriesToHave = this._buttonsBySorting.Count;
|
||||
}
|
||||
}
|
||||
}
|
79
GameContent/UI/Elements/UICharacter.cs
Normal file
79
GameContent/UI/Elements/UICharacter.cs
Normal file
|
@ -0,0 +1,79 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UICharacter
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UICharacter : UIElement
|
||||
{
|
||||
private Player _player;
|
||||
private Asset<Texture2D> _texture;
|
||||
private static Item _blankItem = new Item();
|
||||
private bool _animated;
|
||||
private bool _drawsBackPanel;
|
||||
private float _characterScale = 1f;
|
||||
private int _animationCounter;
|
||||
|
||||
public UICharacter(Player player, bool animated = false, bool hasBackPanel = true, float characterScale = 1f)
|
||||
{
|
||||
this._player = player;
|
||||
this.Width.Set(59f, 0.0f);
|
||||
this.Height.Set(58f, 0.0f);
|
||||
this._texture = Main.Assets.Request<Texture2D>("Images/UI/PlayerBackground", (AssetRequestMode) 1);
|
||||
this.UseImmediateMode = true;
|
||||
this._animated = animated;
|
||||
this._drawsBackPanel = hasBackPanel;
|
||||
this._characterScale = characterScale;
|
||||
this.OverrideSamplerState = SamplerState.PointClamp;
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
this._player.ResetEffects();
|
||||
this._player.ResetVisibleAccessories();
|
||||
this._player.UpdateMiscCounter();
|
||||
this._player.UpdateDyes();
|
||||
this._player.PlayerFrame();
|
||||
if (this._animated)
|
||||
++this._animationCounter;
|
||||
base.Update(gameTime);
|
||||
}
|
||||
|
||||
private void UpdateAnim()
|
||||
{
|
||||
if (!this._animated)
|
||||
{
|
||||
this._player.bodyFrame.Y = this._player.legFrame.Y = this._player.headFrame.Y = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._player.bodyFrame.Y = this._player.legFrame.Y = this._player.headFrame.Y = ((int) ((double) Main.GlobalTimeWrappedHourly / 0.0700000002980232) % 14 + 6) * 56;
|
||||
this._player.WingFrame(false);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
if (this._drawsBackPanel)
|
||||
spriteBatch.Draw(this._texture.Value, dimensions.Position(), Color.White);
|
||||
this.UpdateAnim();
|
||||
Vector2 vector2 = dimensions.Position() + new Vector2(dimensions.Width * 0.5f - (float) (this._player.width >> 1), dimensions.Height * 0.5f - (float) (this._player.height >> 1));
|
||||
Item obj = this._player.inventory[this._player.selectedItem];
|
||||
this._player.inventory[this._player.selectedItem] = UICharacter._blankItem;
|
||||
Main.PlayerRenderer.DrawPlayer(Main.Camera, this._player, vector2 + Main.screenPosition, 0.0f, Vector2.Zero, scale: this._characterScale);
|
||||
this._player.inventory[this._player.selectedItem] = obj;
|
||||
}
|
||||
|
||||
public void SetAnimated(bool animated) => this._animated = animated;
|
||||
|
||||
public bool IsAnimated => this._animated;
|
||||
}
|
||||
}
|
284
GameContent/UI/Elements/UICharacterListItem.cs
Normal file
284
GameContent/UI/Elements/UICharacterListItem.cs
Normal file
|
@ -0,0 +1,284 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UICharacterListItem
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using System;
|
||||
using Terraria.Audio;
|
||||
using Terraria.IO;
|
||||
using Terraria.Localization;
|
||||
using Terraria.Social;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UICharacterListItem : UIPanel
|
||||
{
|
||||
private PlayerFileData _data;
|
||||
private Asset<Texture2D> _dividerTexture;
|
||||
private Asset<Texture2D> _innerPanelTexture;
|
||||
private UICharacter _playerPanel;
|
||||
private UIText _buttonLabel;
|
||||
private UIText _deleteButtonLabel;
|
||||
private Asset<Texture2D> _buttonCloudActiveTexture;
|
||||
private Asset<Texture2D> _buttonCloudInactiveTexture;
|
||||
private Asset<Texture2D> _buttonFavoriteActiveTexture;
|
||||
private Asset<Texture2D> _buttonFavoriteInactiveTexture;
|
||||
private Asset<Texture2D> _buttonPlayTexture;
|
||||
private Asset<Texture2D> _buttonDeleteTexture;
|
||||
private UIImageButton _deleteButton;
|
||||
|
||||
public bool IsFavorite => this._data.IsFavorite;
|
||||
|
||||
public UICharacterListItem(PlayerFileData data, int snapPointIndex)
|
||||
{
|
||||
this.BorderColor = new Color(89, 116, 213) * 0.7f;
|
||||
this._dividerTexture = Main.Assets.Request<Texture2D>("Images/UI/Divider", (AssetRequestMode) 1);
|
||||
this._innerPanelTexture = Main.Assets.Request<Texture2D>("Images/UI/InnerPanelBackground", (AssetRequestMode) 1);
|
||||
this._buttonCloudActiveTexture = Main.Assets.Request<Texture2D>("Images/UI/ButtonCloudActive", (AssetRequestMode) 1);
|
||||
this._buttonCloudInactiveTexture = Main.Assets.Request<Texture2D>("Images/UI/ButtonCloudInactive", (AssetRequestMode) 1);
|
||||
this._buttonFavoriteActiveTexture = Main.Assets.Request<Texture2D>("Images/UI/ButtonFavoriteActive", (AssetRequestMode) 1);
|
||||
this._buttonFavoriteInactiveTexture = Main.Assets.Request<Texture2D>("Images/UI/ButtonFavoriteInactive", (AssetRequestMode) 1);
|
||||
this._buttonPlayTexture = Main.Assets.Request<Texture2D>("Images/UI/ButtonPlay", (AssetRequestMode) 1);
|
||||
this._buttonDeleteTexture = Main.Assets.Request<Texture2D>("Images/UI/ButtonDelete", (AssetRequestMode) 1);
|
||||
this.Height.Set(96f, 0.0f);
|
||||
this.Width.Set(0.0f, 1f);
|
||||
this.SetPadding(6f);
|
||||
this._data = data;
|
||||
this._playerPanel = new UICharacter(data.Player);
|
||||
this._playerPanel.Left.Set(4f, 0.0f);
|
||||
this._playerPanel.OnDoubleClick += new UIElement.MouseEvent(this.PlayGame);
|
||||
this.OnDoubleClick += new UIElement.MouseEvent(this.PlayGame);
|
||||
this.Append((UIElement) this._playerPanel);
|
||||
UIImageButton uiImageButton1 = new UIImageButton(this._buttonPlayTexture);
|
||||
uiImageButton1.VAlign = 1f;
|
||||
uiImageButton1.Left.Set(4f, 0.0f);
|
||||
uiImageButton1.OnClick += new UIElement.MouseEvent(this.PlayGame);
|
||||
uiImageButton1.OnMouseOver += new UIElement.MouseEvent(this.PlayMouseOver);
|
||||
uiImageButton1.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut);
|
||||
this.Append((UIElement) uiImageButton1);
|
||||
UIImageButton uiImageButton2 = new UIImageButton(this._data.IsFavorite ? this._buttonFavoriteActiveTexture : this._buttonFavoriteInactiveTexture);
|
||||
uiImageButton2.VAlign = 1f;
|
||||
uiImageButton2.Left.Set(28f, 0.0f);
|
||||
uiImageButton2.OnClick += new UIElement.MouseEvent(this.FavoriteButtonClick);
|
||||
uiImageButton2.OnMouseOver += new UIElement.MouseEvent(this.FavoriteMouseOver);
|
||||
uiImageButton2.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut);
|
||||
uiImageButton2.SetVisibility(1f, this._data.IsFavorite ? 0.8f : 0.4f);
|
||||
this.Append((UIElement) uiImageButton2);
|
||||
if (SocialAPI.Cloud != null)
|
||||
{
|
||||
UIImageButton uiImageButton3 = new UIImageButton(this._data.IsCloudSave ? this._buttonCloudActiveTexture : this._buttonCloudInactiveTexture);
|
||||
uiImageButton3.VAlign = 1f;
|
||||
uiImageButton3.Left.Set(52f, 0.0f);
|
||||
uiImageButton3.OnClick += new UIElement.MouseEvent(this.CloudButtonClick);
|
||||
uiImageButton3.OnMouseOver += new UIElement.MouseEvent(this.CloudMouseOver);
|
||||
uiImageButton3.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut);
|
||||
this.Append((UIElement) uiImageButton3);
|
||||
uiImageButton3.SetSnapPoint("Cloud", snapPointIndex);
|
||||
}
|
||||
UIImageButton uiImageButton4 = new UIImageButton(this._buttonDeleteTexture);
|
||||
uiImageButton4.VAlign = 1f;
|
||||
uiImageButton4.HAlign = 1f;
|
||||
if (!this._data.IsFavorite)
|
||||
uiImageButton4.OnClick += new UIElement.MouseEvent(this.DeleteButtonClick);
|
||||
uiImageButton4.OnMouseOver += new UIElement.MouseEvent(this.DeleteMouseOver);
|
||||
uiImageButton4.OnMouseOut += new UIElement.MouseEvent(this.DeleteMouseOut);
|
||||
this._deleteButton = uiImageButton4;
|
||||
this.Append((UIElement) uiImageButton4);
|
||||
this._buttonLabel = new UIText("");
|
||||
this._buttonLabel.VAlign = 1f;
|
||||
this._buttonLabel.Left.Set(80f, 0.0f);
|
||||
this._buttonLabel.Top.Set(-3f, 0.0f);
|
||||
this.Append((UIElement) this._buttonLabel);
|
||||
this._deleteButtonLabel = new UIText("");
|
||||
this._deleteButtonLabel.VAlign = 1f;
|
||||
this._deleteButtonLabel.HAlign = 1f;
|
||||
this._deleteButtonLabel.Left.Set(-30f, 0.0f);
|
||||
this._deleteButtonLabel.Top.Set(-3f, 0.0f);
|
||||
this.Append((UIElement) this._deleteButtonLabel);
|
||||
uiImageButton1.SetSnapPoint("Play", snapPointIndex);
|
||||
uiImageButton2.SetSnapPoint("Favorite", snapPointIndex);
|
||||
uiImageButton4.SetSnapPoint("Delete", snapPointIndex);
|
||||
}
|
||||
|
||||
private void FavoriteMouseOver(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
if (this._data.IsFavorite)
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.Unfavorite"));
|
||||
else
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.Favorite"));
|
||||
}
|
||||
|
||||
private void CloudMouseOver(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
if (this._data.IsCloudSave)
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.MoveOffCloud"));
|
||||
else
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.MoveToCloud"));
|
||||
}
|
||||
|
||||
private void PlayMouseOver(UIMouseEvent evt, UIElement listeningElement) => this._buttonLabel.SetText(Language.GetTextValue("UI.Play"));
|
||||
|
||||
private void DeleteMouseOver(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
if (this._data.IsFavorite)
|
||||
this._deleteButtonLabel.SetText(Language.GetTextValue("UI.CannotDeleteFavorited"));
|
||||
else
|
||||
this._deleteButtonLabel.SetText(Language.GetTextValue("UI.Delete"));
|
||||
}
|
||||
|
||||
private void DeleteMouseOut(UIMouseEvent evt, UIElement listeningElement) => this._deleteButtonLabel.SetText("");
|
||||
|
||||
private void ButtonMouseOut(UIMouseEvent evt, UIElement listeningElement) => this._buttonLabel.SetText("");
|
||||
|
||||
private void CloudButtonClick(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
if (this._data.IsCloudSave)
|
||||
this._data.MoveToLocal();
|
||||
else
|
||||
this._data.MoveToCloud();
|
||||
((UIImageButton) evt.Target).SetImage(this._data.IsCloudSave ? this._buttonCloudActiveTexture : this._buttonCloudInactiveTexture);
|
||||
if (this._data.IsCloudSave)
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.MoveOffCloud"));
|
||||
else
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.MoveToCloud"));
|
||||
}
|
||||
|
||||
private void DeleteButtonClick(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
for (int index = 0; index < Main.PlayerList.Count; ++index)
|
||||
{
|
||||
if (Main.PlayerList[index] == this._data)
|
||||
{
|
||||
SoundEngine.PlaySound(10);
|
||||
Main.selectedPlayer = index;
|
||||
Main.menuMode = 5;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void PlayGame(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
if (listeningElement != evt.Target || this._data.Player.loadStatus != 0)
|
||||
return;
|
||||
Main.SelectPlayer(this._data);
|
||||
}
|
||||
|
||||
private void FavoriteButtonClick(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
this._data.ToggleFavorite();
|
||||
((UIImageButton) evt.Target).SetImage(this._data.IsFavorite ? this._buttonFavoriteActiveTexture : this._buttonFavoriteInactiveTexture);
|
||||
((UIImageButton) evt.Target).SetVisibility(1f, this._data.IsFavorite ? 0.8f : 0.4f);
|
||||
if (this._data.IsFavorite)
|
||||
{
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.Unfavorite"));
|
||||
this._deleteButton.OnClick -= new UIElement.MouseEvent(this.DeleteButtonClick);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.Favorite"));
|
||||
this._deleteButton.OnClick += new UIElement.MouseEvent(this.DeleteButtonClick);
|
||||
}
|
||||
if (!(this.Parent.Parent is UIList parent))
|
||||
return;
|
||||
parent.UpdateOrder();
|
||||
}
|
||||
|
||||
public override int CompareTo(object obj)
|
||||
{
|
||||
if (!(obj is UICharacterListItem characterListItem))
|
||||
return base.CompareTo(obj);
|
||||
if (this.IsFavorite && !characterListItem.IsFavorite)
|
||||
return -1;
|
||||
if (!this.IsFavorite && characterListItem.IsFavorite)
|
||||
return 1;
|
||||
return this._data.Name.CompareTo(characterListItem._data.Name) != 0 ? this._data.Name.CompareTo(characterListItem._data.Name) : this._data.GetFileName().CompareTo(characterListItem._data.GetFileName());
|
||||
}
|
||||
|
||||
public override void MouseOver(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseOver(evt);
|
||||
this.BackgroundColor = new Color(73, 94, 171);
|
||||
this.BorderColor = new Color(89, 116, 213);
|
||||
this._playerPanel.SetAnimated(true);
|
||||
}
|
||||
|
||||
public override void MouseOut(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseOut(evt);
|
||||
this.BackgroundColor = new Color(63, 82, 151) * 0.7f;
|
||||
this.BorderColor = new Color(89, 116, 213) * 0.7f;
|
||||
this._playerPanel.SetAnimated(false);
|
||||
}
|
||||
|
||||
private void DrawPanel(SpriteBatch spriteBatch, Vector2 position, float width)
|
||||
{
|
||||
spriteBatch.Draw(this._innerPanelTexture.Value, position, new Rectangle?(new Rectangle(0, 0, 8, this._innerPanelTexture.Height())), Color.White);
|
||||
spriteBatch.Draw(this._innerPanelTexture.Value, new Vector2(position.X + 8f, position.Y), new Rectangle?(new Rectangle(8, 0, 8, this._innerPanelTexture.Height())), Color.White, 0.0f, Vector2.Zero, new Vector2((float) (((double) width - 16.0) / 8.0), 1f), SpriteEffects.None, 0.0f);
|
||||
spriteBatch.Draw(this._innerPanelTexture.Value, new Vector2((float) ((double) position.X + (double) width - 8.0), position.Y), new Rectangle?(new Rectangle(16, 0, 8, this._innerPanelTexture.Height())), Color.White);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
base.DrawSelf(spriteBatch);
|
||||
CalculatedStyle innerDimensions = this.GetInnerDimensions();
|
||||
CalculatedStyle dimensions = this._playerPanel.GetDimensions();
|
||||
float x = dimensions.X + dimensions.Width;
|
||||
Utils.DrawBorderString(spriteBatch, this._data.Name, new Vector2(x + 6f, dimensions.Y - 2f), Color.White);
|
||||
spriteBatch.Draw(this._dividerTexture.Value, new Vector2(x, innerDimensions.Y + 21f), new Rectangle?(), Color.White, 0.0f, Vector2.Zero, new Vector2((float) (((double) this.GetDimensions().X + (double) this.GetDimensions().Width - (double) x) / 8.0), 1f), SpriteEffects.None, 0.0f);
|
||||
Vector2 vector2 = new Vector2(x + 6f, innerDimensions.Y + 29f);
|
||||
float width1 = 200f;
|
||||
Vector2 position1 = vector2;
|
||||
this.DrawPanel(spriteBatch, position1, width1);
|
||||
spriteBatch.Draw(TextureAssets.Heart.Value, position1 + new Vector2(5f, 2f), Color.White);
|
||||
position1.X += 10f + (float) TextureAssets.Heart.Width();
|
||||
Utils.DrawBorderString(spriteBatch, this._data.Player.statLifeMax.ToString() + Language.GetTextValue("GameUI.PlayerLifeMax"), position1 + new Vector2(0.0f, 3f), Color.White);
|
||||
position1.X += 65f;
|
||||
spriteBatch.Draw(TextureAssets.Mana.Value, position1 + new Vector2(5f, 2f), Color.White);
|
||||
position1.X += 10f + (float) TextureAssets.Mana.Width();
|
||||
Utils.DrawBorderString(spriteBatch, this._data.Player.statManaMax.ToString() + Language.GetTextValue("GameUI.PlayerManaMax"), position1 + new Vector2(0.0f, 3f), Color.White);
|
||||
vector2.X += width1 + 5f;
|
||||
Vector2 position2 = vector2;
|
||||
float width2 = 140f;
|
||||
if (GameCulture.FromCultureName(GameCulture.CultureName.Russian).IsActive)
|
||||
width2 = 180f;
|
||||
this.DrawPanel(spriteBatch, position2, width2);
|
||||
string text1 = "";
|
||||
Color color = Color.White;
|
||||
switch (this._data.Player.difficulty)
|
||||
{
|
||||
case 0:
|
||||
text1 = Language.GetTextValue("UI.Softcore");
|
||||
break;
|
||||
case 1:
|
||||
text1 = Language.GetTextValue("UI.Mediumcore");
|
||||
color = Main.mcColor;
|
||||
break;
|
||||
case 2:
|
||||
text1 = Language.GetTextValue("UI.Hardcore");
|
||||
color = Main.hcColor;
|
||||
break;
|
||||
case 3:
|
||||
text1 = Language.GetTextValue("UI.Creative");
|
||||
color = Main.creativeModeColor;
|
||||
break;
|
||||
}
|
||||
Vector2 pos1 = position2 + new Vector2((float) ((double) width2 * 0.5 - (double) FontAssets.MouseText.Value.MeasureString(text1).X * 0.5), 3f);
|
||||
Utils.DrawBorderString(spriteBatch, text1, pos1, color);
|
||||
vector2.X += width2 + 5f;
|
||||
Vector2 position3 = vector2;
|
||||
float width3 = innerDimensions.X + innerDimensions.Width - position3.X;
|
||||
this.DrawPanel(spriteBatch, position3, width3);
|
||||
TimeSpan playTime = this._data.GetPlayTime();
|
||||
int num = playTime.Days * 24 + playTime.Hours;
|
||||
string text2 = (num < 10 ? (object) "0" : (object) "").ToString() + (object) num + playTime.ToString("\\:mm\\:ss");
|
||||
Vector2 pos2 = position3 + new Vector2((float) ((double) width3 * 0.5 - (double) FontAssets.MouseText.Value.MeasureString(text2).X * 0.5), 3f);
|
||||
Utils.DrawBorderString(spriteBatch, text2, pos2, Color.White);
|
||||
}
|
||||
}
|
||||
}
|
132
GameContent/UI/Elements/UICharacterNameButton.cs
Normal file
132
GameContent/UI/Elements/UICharacterNameButton.cs
Normal file
|
@ -0,0 +1,132 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UICharacterNameButton
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria.Audio;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UICharacterNameButton : UIElement
|
||||
{
|
||||
private readonly Asset<Texture2D> _BasePanelTexture;
|
||||
private readonly Asset<Texture2D> _selectedBorderTexture;
|
||||
private readonly Asset<Texture2D> _hoveredBorderTexture;
|
||||
private bool _hovered;
|
||||
private bool _soundedHover;
|
||||
private readonly LocalizedText _textToShowWhenEmpty;
|
||||
private string actualContents;
|
||||
private UIText _text;
|
||||
private UIText _title;
|
||||
public readonly LocalizedText Description;
|
||||
public float DistanceFromTitleToOption = 20f;
|
||||
|
||||
public UICharacterNameButton(
|
||||
LocalizedText titleText,
|
||||
LocalizedText emptyContentText,
|
||||
LocalizedText description = null)
|
||||
{
|
||||
this.Width = StyleDimension.FromPixels(400f);
|
||||
this.Height = StyleDimension.FromPixels(40f);
|
||||
this.Description = description;
|
||||
this._BasePanelTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/CategoryPanel", (AssetRequestMode) 1);
|
||||
this._selectedBorderTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/CategoryPanelHighlight", (AssetRequestMode) 1);
|
||||
this._hoveredBorderTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/CategoryPanelBorder", (AssetRequestMode) 1);
|
||||
this._textToShowWhenEmpty = emptyContentText;
|
||||
float textScale = 1f;
|
||||
UIText uiText1 = new UIText(titleText, textScale);
|
||||
uiText1.HAlign = 0.0f;
|
||||
uiText1.VAlign = 0.5f;
|
||||
uiText1.Left = StyleDimension.FromPixels(10f);
|
||||
UIText uiText2 = uiText1;
|
||||
this.Append((UIElement) uiText2);
|
||||
this._title = uiText2;
|
||||
UIText uiText3 = new UIText(Language.GetText("UI.PlayerNameSlot"), textScale);
|
||||
uiText3.HAlign = 0.0f;
|
||||
uiText3.VAlign = 0.5f;
|
||||
uiText3.Left = StyleDimension.FromPixels(150f);
|
||||
UIText uiText4 = uiText3;
|
||||
this.Append((UIElement) uiText4);
|
||||
this._text = uiText4;
|
||||
this.SetContents((string) null);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
if (this._hovered)
|
||||
{
|
||||
if (!this._soundedHover)
|
||||
SoundEngine.PlaySound(12);
|
||||
this._soundedHover = true;
|
||||
}
|
||||
else
|
||||
this._soundedHover = false;
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
Utils.DrawSplicedPanel(spriteBatch, this._BasePanelTexture.Value, (int) dimensions.X, (int) dimensions.Y, (int) dimensions.Width, (int) dimensions.Height, 10, 10, 10, 10, Color.White * 0.5f);
|
||||
if (!this._hovered)
|
||||
return;
|
||||
Utils.DrawSplicedPanel(spriteBatch, this._hoveredBorderTexture.Value, (int) dimensions.X, (int) dimensions.Y, (int) dimensions.Width, (int) dimensions.Height, 10, 10, 10, 10, Color.White);
|
||||
}
|
||||
|
||||
public void SetContents(string name)
|
||||
{
|
||||
this.actualContents = name;
|
||||
if (string.IsNullOrEmpty(this.actualContents))
|
||||
{
|
||||
this._text.TextColor = Color.Gray;
|
||||
this._text.SetText(this._textToShowWhenEmpty);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._text.TextColor = Color.White;
|
||||
this._text.SetText(this.actualContents);
|
||||
}
|
||||
this._text.Left = StyleDimension.FromPixels(this._title.GetInnerDimensions().Width + this.DistanceFromTitleToOption);
|
||||
}
|
||||
|
||||
public void TrimDisplayIfOverElementDimensions(int padding)
|
||||
{
|
||||
CalculatedStyle dimensions1 = this.GetDimensions();
|
||||
Point point1 = new Point((int) dimensions1.X, (int) dimensions1.Y);
|
||||
Point point2 = new Point(point1.X + (int) dimensions1.Width, point1.Y + (int) dimensions1.Height);
|
||||
Rectangle rectangle1 = new Rectangle(point1.X, point1.Y, point2.X - point1.X, point2.Y - point1.Y);
|
||||
CalculatedStyle dimensions2 = this._text.GetDimensions();
|
||||
Point point3 = new Point((int) dimensions2.X, (int) dimensions2.Y);
|
||||
Point point4 = new Point(point3.X + (int) dimensions2.Width, point3.Y + (int) dimensions2.Height);
|
||||
Rectangle rectangle2 = new Rectangle(point3.X, point3.Y, point4.X - point3.X, point4.Y - point3.Y);
|
||||
int num = 0;
|
||||
for (; rectangle2.Right > rectangle1.Right - padding; rectangle2 = new Rectangle(point3.X, point3.Y, point4.X - point3.X, point4.Y - point3.Y))
|
||||
{
|
||||
this._text.SetText(this._text.Text.Substring(0, this._text.Text.Length - 1));
|
||||
++num;
|
||||
this.RecalculateChildren();
|
||||
CalculatedStyle dimensions3 = this._text.GetDimensions();
|
||||
point3 = new Point((int) dimensions3.X, (int) dimensions3.Y);
|
||||
point4 = new Point(point3.X + (int) dimensions3.Width, point3.Y + (int) dimensions3.Height);
|
||||
}
|
||||
if (num <= 0)
|
||||
return;
|
||||
this._text.SetText(this._text.Text.Substring(0, this._text.Text.Length - 1) + "…");
|
||||
}
|
||||
|
||||
public override void MouseDown(UIMouseEvent evt) => base.MouseDown(evt);
|
||||
|
||||
public override void MouseOver(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseOver(evt);
|
||||
this._hovered = true;
|
||||
}
|
||||
|
||||
public override void MouseOut(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseOut(evt);
|
||||
this._hovered = false;
|
||||
}
|
||||
}
|
||||
}
|
91
GameContent/UI/Elements/UIClothStyleButton.cs
Normal file
91
GameContent/UI/Elements/UIClothStyleButton.cs
Normal file
|
@ -0,0 +1,91 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIClothStyleButton
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria.Audio;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIClothStyleButton : UIElement
|
||||
{
|
||||
private readonly Player _player;
|
||||
public readonly int ClothStyleId;
|
||||
private readonly Asset<Texture2D> _BasePanelTexture;
|
||||
private readonly Asset<Texture2D> _selectedBorderTexture;
|
||||
private readonly Asset<Texture2D> _hoveredBorderTexture;
|
||||
private readonly UICharacter _char;
|
||||
private bool _hovered;
|
||||
private bool _soundedHover;
|
||||
private int _realSkinVariant;
|
||||
|
||||
public UIClothStyleButton(Player player, int clothStyleId)
|
||||
{
|
||||
this._player = player;
|
||||
this.ClothStyleId = clothStyleId;
|
||||
this.Width = StyleDimension.FromPixels(44f);
|
||||
this.Height = StyleDimension.FromPixels(80f);
|
||||
this._BasePanelTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/CategoryPanel", (AssetRequestMode) 1);
|
||||
this._selectedBorderTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/CategoryPanelHighlight", (AssetRequestMode) 1);
|
||||
this._hoveredBorderTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/CategoryPanelBorder", (AssetRequestMode) 1);
|
||||
UICharacter uiCharacter = new UICharacter(this._player, hasBackPanel: false);
|
||||
uiCharacter.HAlign = 0.5f;
|
||||
uiCharacter.VAlign = 0.5f;
|
||||
this._char = uiCharacter;
|
||||
this.Append((UIElement) this._char);
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
this._realSkinVariant = this._player.skinVariant;
|
||||
this._player.skinVariant = this.ClothStyleId;
|
||||
base.Draw(spriteBatch);
|
||||
this._player.skinVariant = this._realSkinVariant;
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
if (this._hovered)
|
||||
{
|
||||
if (!this._soundedHover)
|
||||
SoundEngine.PlaySound(12);
|
||||
this._soundedHover = true;
|
||||
}
|
||||
else
|
||||
this._soundedHover = false;
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
Utils.DrawSplicedPanel(spriteBatch, this._BasePanelTexture.Value, (int) dimensions.X, (int) dimensions.Y, (int) dimensions.Width, (int) dimensions.Height, 10, 10, 10, 10, Color.White * 0.5f);
|
||||
if (this._realSkinVariant == this.ClothStyleId)
|
||||
Utils.DrawSplicedPanel(spriteBatch, this._selectedBorderTexture.Value, (int) dimensions.X + 3, (int) dimensions.Y + 3, (int) dimensions.Width - 6, (int) dimensions.Height - 6, 10, 10, 10, 10, Color.White);
|
||||
if (!this._hovered)
|
||||
return;
|
||||
Utils.DrawSplicedPanel(spriteBatch, this._hoveredBorderTexture.Value, (int) dimensions.X, (int) dimensions.Y, (int) dimensions.Width, (int) dimensions.Height, 10, 10, 10, 10, Color.White);
|
||||
}
|
||||
|
||||
public override void MouseDown(UIMouseEvent evt)
|
||||
{
|
||||
this._player.skinVariant = this.ClothStyleId;
|
||||
SoundEngine.PlaySound(12);
|
||||
base.MouseDown(evt);
|
||||
}
|
||||
|
||||
public override void MouseOver(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseOver(evt);
|
||||
this._hovered = true;
|
||||
this._char.SetAnimated(true);
|
||||
}
|
||||
|
||||
public override void MouseOut(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseOut(evt);
|
||||
this._hovered = false;
|
||||
this._char.SetAnimated(false);
|
||||
}
|
||||
}
|
||||
}
|
89
GameContent/UI/Elements/UIColoredImageButton.cs
Normal file
89
GameContent/UI/Elements/UIColoredImageButton.cs
Normal file
|
@ -0,0 +1,89 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIColoredImageButton
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria.Audio;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIColoredImageButton : UIElement
|
||||
{
|
||||
private Asset<Texture2D> _backPanelTexture;
|
||||
private Asset<Texture2D> _texture;
|
||||
private Asset<Texture2D> _middleTexture;
|
||||
private Asset<Texture2D> _backPanelHighlightTexture;
|
||||
private Asset<Texture2D> _backPanelBorderTexture;
|
||||
private Color _color;
|
||||
private float _visibilityActive = 1f;
|
||||
private float _visibilityInactive = 0.4f;
|
||||
private bool _selected;
|
||||
private bool _hovered;
|
||||
|
||||
public UIColoredImageButton(Asset<Texture2D> texture, bool isSmall = false)
|
||||
{
|
||||
this._color = Color.White;
|
||||
this._texture = texture;
|
||||
this._backPanelTexture = !isSmall ? Main.Assets.Request<Texture2D>("Images/UI/CharCreation/CategoryPanel", (AssetRequestMode) 1) : Main.Assets.Request<Texture2D>("Images/UI/CharCreation/SmallPanel", (AssetRequestMode) 1);
|
||||
this.Width.Set((float) this._backPanelTexture.Width(), 0.0f);
|
||||
this.Height.Set((float) this._backPanelTexture.Height(), 0.0f);
|
||||
this._backPanelHighlightTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/CategoryPanelHighlight", (AssetRequestMode) 1);
|
||||
if (isSmall)
|
||||
this._backPanelBorderTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/SmallPanelBorder", (AssetRequestMode) 1);
|
||||
else
|
||||
this._backPanelBorderTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/CategoryPanelBorder", (AssetRequestMode) 1);
|
||||
}
|
||||
|
||||
public void SetImage(Asset<Texture2D> texture)
|
||||
{
|
||||
this._texture = texture;
|
||||
this.Width.Set((float) this._texture.Width(), 0.0f);
|
||||
this.Height.Set((float) this._texture.Height(), 0.0f);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
Vector2 position = dimensions.Position() + new Vector2(dimensions.Width, dimensions.Height) / 2f;
|
||||
spriteBatch.Draw(this._backPanelTexture.Value, position, new Rectangle?(), Color.White * (this.IsMouseHovering ? this._visibilityActive : this._visibilityInactive), 0.0f, this._backPanelTexture.Size() / 2f, 1f, SpriteEffects.None, 0.0f);
|
||||
Color white = Color.White;
|
||||
if (this._hovered)
|
||||
spriteBatch.Draw(this._backPanelBorderTexture.Value, position, new Rectangle?(), Color.White, 0.0f, this._backPanelBorderTexture.Size() / 2f, 1f, SpriteEffects.None, 0.0f);
|
||||
if (this._selected)
|
||||
spriteBatch.Draw(this._backPanelHighlightTexture.Value, position, new Rectangle?(), Color.White, 0.0f, this._backPanelHighlightTexture.Size() / 2f, 1f, SpriteEffects.None, 0.0f);
|
||||
if (this._middleTexture != null)
|
||||
spriteBatch.Draw(this._middleTexture.Value, position, new Rectangle?(), Color.White, 0.0f, this._middleTexture.Size() / 2f, 1f, SpriteEffects.None, 0.0f);
|
||||
spriteBatch.Draw(this._texture.Value, position, new Rectangle?(), this._color, 0.0f, this._texture.Size() / 2f, 1f, SpriteEffects.None, 0.0f);
|
||||
}
|
||||
|
||||
public override void MouseOver(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseOver(evt);
|
||||
SoundEngine.PlaySound(12);
|
||||
this._hovered = true;
|
||||
}
|
||||
|
||||
public void SetVisibility(float whenActive, float whenInactive)
|
||||
{
|
||||
this._visibilityActive = MathHelper.Clamp(whenActive, 0.0f, 1f);
|
||||
this._visibilityInactive = MathHelper.Clamp(whenInactive, 0.0f, 1f);
|
||||
}
|
||||
|
||||
public void SetColor(Color color) => this._color = color;
|
||||
|
||||
public void SetMiddleTexture(Asset<Texture2D> texAsset) => this._middleTexture = texAsset;
|
||||
|
||||
public void SetSelected(bool selected) => this._selected = selected;
|
||||
|
||||
public override void MouseOut(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseOut(evt);
|
||||
this._hovered = false;
|
||||
}
|
||||
}
|
||||
}
|
150
GameContent/UI/Elements/UIColoredSlider.cs
Normal file
150
GameContent/UI/Elements/UIColoredSlider.cs
Normal file
|
@ -0,0 +1,150 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIColoredSlider
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Terraria.Audio;
|
||||
using Terraria.GameInput;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIColoredSlider : UISliderBase
|
||||
{
|
||||
private Color _color;
|
||||
private LocalizedText _textKey;
|
||||
private Func<float> _getStatusTextAct;
|
||||
private Action<float> _slideKeyboardAction;
|
||||
private Func<float, Color> _blipFunc;
|
||||
private Action _slideGamepadAction;
|
||||
private const bool BOTHER_WITH_TEXT = false;
|
||||
private bool _isReallyMouseOvered;
|
||||
private bool _alreadyHovered;
|
||||
private bool _soundedUsage;
|
||||
|
||||
public UIColoredSlider(
|
||||
LocalizedText textKey,
|
||||
Func<float> getStatus,
|
||||
Action<float> setStatusKeyboard,
|
||||
Action setStatusGamepad,
|
||||
Func<float, Color> blipColorFunction,
|
||||
Color color)
|
||||
{
|
||||
this._color = color;
|
||||
this._textKey = textKey;
|
||||
this._getStatusTextAct = getStatus != null ? getStatus : (Func<float>) (() => 0.0f);
|
||||
this._slideKeyboardAction = setStatusKeyboard != null ? setStatusKeyboard : (Action<float>) (s => { });
|
||||
this._blipFunc = blipColorFunction != null ? blipColorFunction : (Func<float, Color>) (s => Color.Lerp(Color.Black, Color.White, s));
|
||||
this._slideGamepadAction = setStatusGamepad;
|
||||
this._isReallyMouseOvered = false;
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
UISliderBase.CurrentAimedSlider = (UIElement) null;
|
||||
if (!Main.mouseLeft)
|
||||
UISliderBase.CurrentLockedSlider = (UIElement) null;
|
||||
int usageLevel = this.GetUsageLevel();
|
||||
float num1 = 8f;
|
||||
base.DrawSelf(spriteBatch);
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
float num2 = dimensions.Width + 1f;
|
||||
Vector2 vector2_1 = new Vector2(dimensions.X, dimensions.Y);
|
||||
bool flag1 = false;
|
||||
bool flag2 = this.IsMouseHovering;
|
||||
if (usageLevel == 2)
|
||||
flag2 = false;
|
||||
if (usageLevel == 1)
|
||||
flag2 = true;
|
||||
Vector2 vector2_2 = new Vector2(0.0f, 2f);
|
||||
Vector2 drawPosition = vector2_1 + vector2_2;
|
||||
Color.Lerp(flag1 ? Color.Gold : (flag2 ? Color.White : Color.Silver), Color.White, flag2 ? 0.5f : 0.0f);
|
||||
Vector2 vector2_3 = new Vector2(0.8f);
|
||||
drawPosition.X += 8f;
|
||||
drawPosition.Y += num1;
|
||||
drawPosition.X -= 17f;
|
||||
TextureAssets.ColorBar.Frame();
|
||||
drawPosition = new Vector2((float) ((double) dimensions.X + (double) dimensions.Width - 10.0), dimensions.Y + 10f + num1);
|
||||
bool wasInBar;
|
||||
float num3 = this.DrawValueBar(spriteBatch, drawPosition, 1f, this._getStatusTextAct(), usageLevel, out wasInBar, this._blipFunc);
|
||||
if (UISliderBase.CurrentLockedSlider == this | wasInBar)
|
||||
{
|
||||
UISliderBase.CurrentAimedSlider = (UIElement) this;
|
||||
if (PlayerInput.Triggers.Current.MouseLeft && !PlayerInput.UsingGamepad && UISliderBase.CurrentLockedSlider == this)
|
||||
{
|
||||
this._slideKeyboardAction(num3);
|
||||
if (!this._soundedUsage)
|
||||
SoundEngine.PlaySound(12);
|
||||
this._soundedUsage = true;
|
||||
}
|
||||
else
|
||||
this._soundedUsage = false;
|
||||
}
|
||||
if (UISliderBase.CurrentAimedSlider != null && UISliderBase.CurrentLockedSlider == null)
|
||||
UISliderBase.CurrentLockedSlider = UISliderBase.CurrentAimedSlider;
|
||||
if (!this._isReallyMouseOvered)
|
||||
return;
|
||||
this._slideGamepadAction();
|
||||
}
|
||||
|
||||
private float DrawValueBar(
|
||||
SpriteBatch sb,
|
||||
Vector2 drawPosition,
|
||||
float drawScale,
|
||||
float sliderPosition,
|
||||
int lockMode,
|
||||
out bool wasInBar,
|
||||
Func<float, Color> blipColorFunc)
|
||||
{
|
||||
Texture2D texture = TextureAssets.ColorBar.Value;
|
||||
Vector2 vector2 = new Vector2((float) texture.Width, (float) texture.Height) * drawScale;
|
||||
drawPosition.X -= (float) (int) vector2.X;
|
||||
Rectangle destinationRectangle1 = new Rectangle((int) drawPosition.X, (int) drawPosition.Y - (int) vector2.Y / 2, (int) vector2.X, (int) vector2.Y);
|
||||
Rectangle destinationRectangle2 = destinationRectangle1;
|
||||
sb.Draw(texture, destinationRectangle1, Color.White);
|
||||
float num1 = (float) destinationRectangle1.X + 5f * drawScale;
|
||||
float y = (float) destinationRectangle1.Y + 4f * drawScale;
|
||||
for (float num2 = 0.0f; (double) num2 < 167.0; ++num2)
|
||||
{
|
||||
float num3 = num2 / 167f;
|
||||
Color color = blipColorFunc(num3);
|
||||
sb.Draw(TextureAssets.ColorBlip.Value, new Vector2(num1 + num2 * drawScale, y), new Rectangle?(), color, 0.0f, Vector2.Zero, drawScale, SpriteEffects.None, 0.0f);
|
||||
}
|
||||
destinationRectangle1.X = (int) num1 - 2;
|
||||
destinationRectangle1.Y = (int) y;
|
||||
destinationRectangle1.Width -= 4;
|
||||
destinationRectangle1.Height -= 8;
|
||||
bool flag = destinationRectangle1.Contains(new Point(Main.mouseX, Main.mouseY));
|
||||
this._isReallyMouseOvered = flag;
|
||||
if (this.IgnoresMouseInteraction)
|
||||
flag = false;
|
||||
if (lockMode == 2)
|
||||
flag = false;
|
||||
if (flag || lockMode == 1)
|
||||
{
|
||||
sb.Draw(TextureAssets.ColorHighlight.Value, destinationRectangle2, Main.OurFavoriteColor);
|
||||
if (!this._alreadyHovered)
|
||||
SoundEngine.PlaySound(12);
|
||||
this._alreadyHovered = true;
|
||||
}
|
||||
else
|
||||
this._alreadyHovered = false;
|
||||
wasInBar = false;
|
||||
if (!this.IgnoresMouseInteraction)
|
||||
{
|
||||
sb.Draw(TextureAssets.ColorSlider.Value, new Vector2(num1 + 167f * drawScale * sliderPosition, y + 4f * drawScale), new Rectangle?(), Color.White, 0.0f, new Vector2(0.5f * (float) TextureAssets.ColorSlider.Value.Width, 0.5f * (float) TextureAssets.ColorSlider.Value.Height), drawScale, SpriteEffects.None, 0.0f);
|
||||
if (Main.mouseX >= destinationRectangle1.X && Main.mouseX <= destinationRectangle1.X + destinationRectangle1.Width)
|
||||
{
|
||||
wasInBar = flag;
|
||||
return (float) (Main.mouseX - destinationRectangle1.X) / (float) destinationRectangle1.Width;
|
||||
}
|
||||
}
|
||||
return destinationRectangle1.X >= Main.mouseX ? 0.0f : 1f;
|
||||
}
|
||||
}
|
||||
}
|
40
GameContent/UI/Elements/UIColoredSliderSimple.cs
Normal file
40
GameContent/UI/Elements/UIColoredSliderSimple.cs
Normal file
|
@ -0,0 +1,40 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIColoredSliderSimple
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIColoredSliderSimple : UIElement
|
||||
{
|
||||
public float FillPercent;
|
||||
public Color FilledColor = Main.OurFavoriteColor;
|
||||
public Color EmptyColor = Color.Black;
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch) => this.DrawValueBarDynamicWidth(spriteBatch);
|
||||
|
||||
private void DrawValueBarDynamicWidth(SpriteBatch sb)
|
||||
{
|
||||
Texture2D texture1 = TextureAssets.ColorBar.Value;
|
||||
Rectangle rectangle1 = this.GetDimensions().ToRectangle();
|
||||
Rectangle rectangle2 = new Rectangle(5, 4, 4, 4);
|
||||
Utils.DrawSplicedPanel(sb, texture1, rectangle1.X, rectangle1.Y, rectangle1.Width, rectangle1.Height, rectangle2.X, rectangle2.Width, rectangle2.Y, rectangle2.Height, Color.White);
|
||||
Rectangle destinationRectangle1 = rectangle1;
|
||||
destinationRectangle1.X += rectangle2.Left;
|
||||
destinationRectangle1.Width -= rectangle2.Right;
|
||||
destinationRectangle1.Y += rectangle2.Top;
|
||||
destinationRectangle1.Height -= rectangle2.Bottom;
|
||||
Texture2D texture2 = TextureAssets.MagicPixel.Value;
|
||||
Rectangle rectangle3 = new Rectangle(0, 0, 1, 1);
|
||||
sb.Draw(texture2, destinationRectangle1, new Rectangle?(rectangle3), this.EmptyColor);
|
||||
Rectangle destinationRectangle2 = destinationRectangle1;
|
||||
destinationRectangle2.Width = (int) ((double) destinationRectangle2.Width * (double) this.FillPercent);
|
||||
sb.Draw(texture2, destinationRectangle2, new Rectangle?(rectangle3), this.FilledColor);
|
||||
}
|
||||
}
|
||||
}
|
574
GameContent/UI/Elements/UICreativeInfiniteItemsDisplay.cs
Normal file
574
GameContent/UI/Elements/UICreativeInfiniteItemsDisplay.cs
Normal file
|
@ -0,0 +1,574 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UICreativeInfiniteItemsDisplay
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Terraria.Audio;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.GameContent.Creative;
|
||||
using Terraria.GameContent.UI.States;
|
||||
using Terraria.Graphics.Renderers;
|
||||
using Terraria.ID;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UICreativeInfiniteItemsDisplay : UIElement
|
||||
{
|
||||
private List<int> _itemIdsAvailableTotal;
|
||||
private List<int> _itemIdsAvailableToShow;
|
||||
private CreativeUnlocksTracker _lastTrackerCheckedForEdits;
|
||||
private int _lastCheckedVersionForEdits = -1;
|
||||
private UISearchBar _searchBar;
|
||||
private UIPanel _searchBoxPanel;
|
||||
private UIState _parentUIState;
|
||||
private string _searchString;
|
||||
private UIDynamicItemCollection _itemGrid;
|
||||
private EntryFilterer<Item, IItemEntryFilter> _filterer;
|
||||
private EntrySorter<int, ICreativeItemSortStep> _sorter;
|
||||
private UIElement _containerInfinites;
|
||||
private UIElement _containerSacrifice;
|
||||
private bool _showSacrificesInsteadOfInfinites;
|
||||
public const string SnapPointName_SacrificeSlot = "CreativeSacrificeSlot";
|
||||
public const string SnapPointName_SacrificeConfirmButton = "CreativeSacrificeConfirm";
|
||||
public const string SnapPointName_InfinitesFilter = "CreativeInfinitesFilter";
|
||||
public const string SnapPointName_InfinitesSearch = "CreativeInfinitesSearch";
|
||||
public const string SnapPointName_InfinitesItemSlot = "CreativeInfinitesSlot";
|
||||
private List<UIImage> _sacrificeCogsSmall = new List<UIImage>();
|
||||
private List<UIImage> _sacrificeCogsMedium = new List<UIImage>();
|
||||
private List<UIImage> _sacrificeCogsBig = new List<UIImage>();
|
||||
private UIImageFramed _sacrificePistons;
|
||||
private UIParticleLayer _pistonParticleSystem;
|
||||
private Asset<Texture2D> _pistonParticleAsset;
|
||||
private int _sacrificeAnimationTimeLeft;
|
||||
private bool _researchComplete;
|
||||
private bool _hovered;
|
||||
private int _lastItemIdSacrificed;
|
||||
private int _lastItemAmountWeHad;
|
||||
private int _lastItemAmountWeNeededTotal;
|
||||
|
||||
public UICreativeInfiniteItemsDisplay(UIState uiStateThatHoldsThis)
|
||||
{
|
||||
this._parentUIState = uiStateThatHoldsThis;
|
||||
this._itemIdsAvailableTotal = new List<int>();
|
||||
this._itemIdsAvailableToShow = new List<int>();
|
||||
this._filterer = new EntryFilterer<Item, IItemEntryFilter>();
|
||||
this._filterer.AddFilters(new List<IItemEntryFilter>()
|
||||
{
|
||||
(IItemEntryFilter) new ItemFilters.Weapon(),
|
||||
(IItemEntryFilter) new ItemFilters.Armor(),
|
||||
(IItemEntryFilter) new ItemFilters.BuildingBlock(),
|
||||
(IItemEntryFilter) new ItemFilters.GameplayItems(),
|
||||
(IItemEntryFilter) new ItemFilters.Accessories(),
|
||||
(IItemEntryFilter) new ItemFilters.Consumables(),
|
||||
(IItemEntryFilter) new ItemFilters.Materials()
|
||||
});
|
||||
this._filterer.SetSearchFilterObject<ItemFilters.BySearch>(new ItemFilters.BySearch());
|
||||
this._sorter = new EntrySorter<int, ICreativeItemSortStep>();
|
||||
this._sorter.AddSortSteps(new List<ICreativeItemSortStep>()
|
||||
{
|
||||
(ICreativeItemSortStep) new SortingSteps.ByCreativeSortingId(),
|
||||
(ICreativeItemSortStep) new SortingSteps.Alphabetical()
|
||||
});
|
||||
this._itemIdsAvailableTotal.AddRange((IEnumerable<int>) CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId.Keys.ToList<int>());
|
||||
this.BuildPage();
|
||||
}
|
||||
|
||||
private void BuildPage()
|
||||
{
|
||||
this._lastCheckedVersionForEdits = -1;
|
||||
this.RemoveAllChildren();
|
||||
this.SetPadding(0.0f);
|
||||
UIElement totalContainer1 = new UIElement()
|
||||
{
|
||||
Width = StyleDimension.Fill,
|
||||
Height = StyleDimension.Fill
|
||||
};
|
||||
totalContainer1.SetPadding(0.0f);
|
||||
this._containerInfinites = totalContainer1;
|
||||
UIElement totalContainer2 = new UIElement()
|
||||
{
|
||||
Width = StyleDimension.Fill,
|
||||
Height = StyleDimension.Fill
|
||||
};
|
||||
totalContainer2.SetPadding(0.0f);
|
||||
this._containerSacrifice = totalContainer2;
|
||||
this.BuildInfinitesMenuContents(totalContainer1);
|
||||
this.BuildSacrificeMenuContents(totalContainer2);
|
||||
this.UpdateContents();
|
||||
this.OnUpdate += new UIElement.ElementEvent(this.UICreativeInfiniteItemsDisplay_OnUpdate);
|
||||
}
|
||||
|
||||
private void Hover_OnUpdate(UIElement affectedElement)
|
||||
{
|
||||
if (!this._hovered)
|
||||
return;
|
||||
Main.LocalPlayer.mouseInterface = true;
|
||||
}
|
||||
|
||||
private void Hover_OnMouseOut(UIMouseEvent evt, UIElement listeningElement) => this._hovered = false;
|
||||
|
||||
private void Hover_OnMouseOver(UIMouseEvent evt, UIElement listeningElement) => this._hovered = true;
|
||||
|
||||
private static UIPanel CreateBasicPanel()
|
||||
{
|
||||
UIPanel uiPanel = new UIPanel();
|
||||
UICreativeInfiniteItemsDisplay.SetBasicSizesForCreativeSacrificeOrInfinitesPanel((UIElement) uiPanel);
|
||||
uiPanel.BackgroundColor *= 0.8f;
|
||||
uiPanel.BorderColor *= 0.8f;
|
||||
return uiPanel;
|
||||
}
|
||||
|
||||
private static void SetBasicSizesForCreativeSacrificeOrInfinitesPanel(UIElement element)
|
||||
{
|
||||
element.Width = new StyleDimension(0.0f, 1f);
|
||||
element.Height = new StyleDimension(-38f, 1f);
|
||||
element.Top = new StyleDimension(38f, 0.0f);
|
||||
}
|
||||
|
||||
private void BuildInfinitesMenuContents(UIElement totalContainer)
|
||||
{
|
||||
UIPanel basicPanel = UICreativeInfiniteItemsDisplay.CreateBasicPanel();
|
||||
totalContainer.Append((UIElement) basicPanel);
|
||||
basicPanel.OnUpdate += new UIElement.ElementEvent(this.Hover_OnUpdate);
|
||||
basicPanel.OnMouseOver += new UIElement.MouseEvent(this.Hover_OnMouseOver);
|
||||
basicPanel.OnMouseOut += new UIElement.MouseEvent(this.Hover_OnMouseOut);
|
||||
UIDynamicItemCollection dynamicItemCollection = new UIDynamicItemCollection();
|
||||
this._itemGrid = dynamicItemCollection;
|
||||
UIElement uiElement = new UIElement()
|
||||
{
|
||||
Height = new StyleDimension(24f, 0.0f),
|
||||
Width = new StyleDimension(0.0f, 1f)
|
||||
};
|
||||
uiElement.SetPadding(0.0f);
|
||||
basicPanel.Append(uiElement);
|
||||
this.AddSearchBar(uiElement);
|
||||
this._searchBar.SetContents((string) null, true);
|
||||
UIList uiList1 = new UIList();
|
||||
uiList1.Width = new StyleDimension(-25f, 1f);
|
||||
uiList1.Height = new StyleDimension(-28f, 1f);
|
||||
uiList1.VAlign = 1f;
|
||||
uiList1.HAlign = 0.0f;
|
||||
UIList uiList2 = uiList1;
|
||||
basicPanel.Append((UIElement) uiList2);
|
||||
float num = 4f;
|
||||
UIScrollbar uiScrollbar = new UIScrollbar();
|
||||
uiScrollbar.Height = new StyleDimension((float) (-28.0 - (double) num * 2.0), 1f);
|
||||
uiScrollbar.Top = new StyleDimension(-num, 0.0f);
|
||||
uiScrollbar.VAlign = 1f;
|
||||
uiScrollbar.HAlign = 1f;
|
||||
UIScrollbar scrollbar = uiScrollbar;
|
||||
basicPanel.Append((UIElement) scrollbar);
|
||||
uiList2.SetScrollbar(scrollbar);
|
||||
uiList2.Add((UIElement) dynamicItemCollection);
|
||||
UICreativeItemsInfiniteFilteringOptions filteringOptions = new UICreativeItemsInfiniteFilteringOptions(this._filterer, "CreativeInfinitesFilter");
|
||||
filteringOptions.OnClickingOption += new Action(this.filtersHelper_OnClickingOption);
|
||||
filteringOptions.Left = new StyleDimension(20f, 0.0f);
|
||||
totalContainer.Append((UIElement) filteringOptions);
|
||||
filteringOptions.OnUpdate += new UIElement.ElementEvent(this.Hover_OnUpdate);
|
||||
filteringOptions.OnMouseOver += new UIElement.MouseEvent(this.Hover_OnMouseOver);
|
||||
filteringOptions.OnMouseOut += new UIElement.MouseEvent(this.Hover_OnMouseOut);
|
||||
}
|
||||
|
||||
private void BuildSacrificeMenuContents(UIElement totalContainer)
|
||||
{
|
||||
UIPanel basicPanel = UICreativeInfiniteItemsDisplay.CreateBasicPanel();
|
||||
basicPanel.VAlign = 0.5f;
|
||||
basicPanel.Height = new StyleDimension(170f, 0.0f);
|
||||
basicPanel.Width = new StyleDimension(170f, 0.0f);
|
||||
basicPanel.Top = new StyleDimension();
|
||||
totalContainer.Append((UIElement) basicPanel);
|
||||
basicPanel.OnUpdate += new UIElement.ElementEvent(this.Hover_OnUpdate);
|
||||
basicPanel.OnMouseOver += new UIElement.MouseEvent(this.Hover_OnMouseOver);
|
||||
basicPanel.OnMouseOut += new UIElement.MouseEvent(this.Hover_OnMouseOut);
|
||||
this.AddCogsForSacrificeMenu((UIElement) basicPanel);
|
||||
this._pistonParticleAsset = Main.Assets.Request<Texture2D>("Images/UI/Creative/Research_Spark", (AssetRequestMode) 1);
|
||||
float pixels = 0.0f;
|
||||
UIImage uiImage1 = new UIImage(Main.Assets.Request<Texture2D>("Images/UI/Creative/Research_Slots", (AssetRequestMode) 1));
|
||||
uiImage1.HAlign = 0.5f;
|
||||
uiImage1.VAlign = 0.5f;
|
||||
uiImage1.Top = new StyleDimension(-20f, 0.0f);
|
||||
uiImage1.Left = new StyleDimension(pixels, 0.0f);
|
||||
UIImage uiImage2 = uiImage1;
|
||||
basicPanel.Append((UIElement) uiImage2);
|
||||
Asset<Texture2D> asset = Main.Assets.Request<Texture2D>("Images/UI/Creative/Research_FramedPistons", (AssetRequestMode) 1);
|
||||
UIImageFramed uiImageFramed1 = new UIImageFramed(asset, asset.Frame(verticalFrames: 9));
|
||||
uiImageFramed1.HAlign = 0.5f;
|
||||
uiImageFramed1.VAlign = 0.5f;
|
||||
uiImageFramed1.Top = new StyleDimension(-20f, 0.0f);
|
||||
uiImageFramed1.Left = new StyleDimension(pixels, 0.0f);
|
||||
uiImageFramed1.IgnoresMouseInteraction = true;
|
||||
UIImageFramed uiImageFramed2 = uiImageFramed1;
|
||||
basicPanel.Append((UIElement) uiImageFramed2);
|
||||
this._sacrificePistons = uiImageFramed2;
|
||||
UIParticleLayer uiParticleLayer = new UIParticleLayer();
|
||||
uiParticleLayer.Width = new StyleDimension(0.0f, 1f);
|
||||
uiParticleLayer.Height = new StyleDimension(0.0f, 1f);
|
||||
uiParticleLayer.AnchorPositionOffsetByPercents = Vector2.One / 2f;
|
||||
uiParticleLayer.AnchorPositionOffsetByPixels = Vector2.Zero;
|
||||
this._pistonParticleSystem = uiParticleLayer;
|
||||
uiImageFramed2.Append((UIElement) this._pistonParticleSystem);
|
||||
UIElement element = Main.CreativeMenu.ProvideItemSlotElement(0);
|
||||
element.HAlign = 0.5f;
|
||||
element.VAlign = 0.5f;
|
||||
element.Top = new StyleDimension(-15f, 0.0f);
|
||||
element.Left = new StyleDimension(pixels, 0.0f);
|
||||
element.SetSnapPoint("CreativeSacrificeSlot", 0);
|
||||
uiImage2.Append(element);
|
||||
UIText uiText1 = new UIText("(0/50)", 0.8f);
|
||||
uiText1.Top = new StyleDimension(10f, 0.0f);
|
||||
uiText1.Left = new StyleDimension(pixels, 0.0f);
|
||||
uiText1.HAlign = 0.5f;
|
||||
uiText1.VAlign = 0.5f;
|
||||
uiText1.IgnoresMouseInteraction = true;
|
||||
UIText uiText2 = uiText1;
|
||||
uiText2.OnUpdate += new UIElement.ElementEvent(this.descriptionText_OnUpdate);
|
||||
basicPanel.Append((UIElement) uiText2);
|
||||
UIPanel uiPanel1 = new UIPanel();
|
||||
uiPanel1.Top = new StyleDimension(0.0f, 0.0f);
|
||||
uiPanel1.Left = new StyleDimension(pixels, 0.0f);
|
||||
uiPanel1.HAlign = 0.5f;
|
||||
uiPanel1.VAlign = 1f;
|
||||
uiPanel1.Width = new StyleDimension(124f, 0.0f);
|
||||
uiPanel1.Height = new StyleDimension(30f, 0.0f);
|
||||
UIPanel uiPanel2 = uiPanel1;
|
||||
UIText uiText3 = new UIText(Language.GetText("CreativePowers.ConfirmInfiniteItemSacrifice"), 0.8f);
|
||||
uiText3.IgnoresMouseInteraction = true;
|
||||
uiText3.HAlign = 0.5f;
|
||||
uiText3.VAlign = 0.5f;
|
||||
UIText uiText4 = uiText3;
|
||||
uiPanel2.Append((UIElement) uiText4);
|
||||
uiPanel2.SetSnapPoint("CreativeSacrificeConfirm", 0);
|
||||
uiPanel2.OnClick += new UIElement.MouseEvent(this.sacrificeButton_OnClick);
|
||||
uiPanel2.OnMouseOver += new UIElement.MouseEvent(this.FadedMouseOver);
|
||||
uiPanel2.OnMouseOut += new UIElement.MouseEvent(this.FadedMouseOut);
|
||||
uiPanel2.OnUpdate += new UIElement.ElementEvent(this.research_OnUpdate);
|
||||
basicPanel.Append((UIElement) uiPanel2);
|
||||
basicPanel.OnUpdate += new UIElement.ElementEvent(this.sacrificeWindow_OnUpdate);
|
||||
}
|
||||
|
||||
private void research_OnUpdate(UIElement affectedElement)
|
||||
{
|
||||
if (!affectedElement.IsMouseHovering)
|
||||
return;
|
||||
Main.instance.MouseText(Language.GetTextValue("CreativePowers.ResearchButtonTooltip"));
|
||||
}
|
||||
|
||||
private void FadedMouseOver(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
SoundEngine.PlaySound(12);
|
||||
((UIPanel) evt.Target).BackgroundColor = new Color(73, 94, 171);
|
||||
((UIPanel) evt.Target).BorderColor = Colors.FancyUIFatButtonMouseOver;
|
||||
}
|
||||
|
||||
private void FadedMouseOut(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
((UIPanel) evt.Target).BackgroundColor = new Color(63, 82, 151) * 0.8f;
|
||||
((UIPanel) evt.Target).BorderColor = Color.Black;
|
||||
}
|
||||
|
||||
private void AddCogsForSacrificeMenu(UIElement sacrificesContainer)
|
||||
{
|
||||
UIElement uiElement = new UIElement();
|
||||
uiElement.IgnoresMouseInteraction = true;
|
||||
UICreativeInfiniteItemsDisplay.SetBasicSizesForCreativeSacrificeOrInfinitesPanel(uiElement);
|
||||
uiElement.VAlign = 0.5f;
|
||||
uiElement.Height = new StyleDimension(170f, 0.0f);
|
||||
uiElement.Width = new StyleDimension(280f, 0.0f);
|
||||
uiElement.Top = new StyleDimension();
|
||||
uiElement.SetPadding(0.0f);
|
||||
sacrificesContainer.Append(uiElement);
|
||||
Vector2 vector2 = new Vector2(-10f, -10f);
|
||||
this.AddSymetricalCogsPair(uiElement, new Vector2(22f, 1f) + vector2, "Images/UI/Creative/Research_GearC", this._sacrificeCogsSmall);
|
||||
this.AddSymetricalCogsPair(uiElement, new Vector2(1f, 28f) + vector2, "Images/UI/Creative/Research_GearB", this._sacrificeCogsMedium);
|
||||
this.AddSymetricalCogsPair(uiElement, new Vector2(5f, 5f) + vector2, "Images/UI/Creative/Research_GearA", this._sacrificeCogsBig);
|
||||
}
|
||||
|
||||
private void sacrificeWindow_OnUpdate(UIElement affectedElement)
|
||||
{
|
||||
float num1 = 0.05f;
|
||||
float animationProgress = this.GetSacrificeAnimationProgress();
|
||||
double lerpValue = (double) Utils.GetLerpValue(1f, 0.7f, animationProgress, true);
|
||||
float num2 = 1f + (float) (lerpValue * lerpValue) * 2f;
|
||||
float num3 = num1 * num2;
|
||||
float num4 = 1.142857f;
|
||||
float num5 = 1f;
|
||||
UICreativeInfiniteItemsDisplay.OffsetRotationsForCogs((float) (2.0 * (double) num3), this._sacrificeCogsSmall);
|
||||
UICreativeInfiniteItemsDisplay.OffsetRotationsForCogs(num4 * num3, this._sacrificeCogsMedium);
|
||||
UICreativeInfiniteItemsDisplay.OffsetRotationsForCogs(-num5 * num3, this._sacrificeCogsBig);
|
||||
int frameY = 0;
|
||||
if (this._sacrificeAnimationTimeLeft != 0)
|
||||
{
|
||||
float num6 = 0.1f;
|
||||
float num7 = 0.06666667f;
|
||||
frameY = (double) animationProgress < 1.0 - (double) num6 ? ((double) animationProgress < 1.0 - (double) num6 * 2.0 ? ((double) animationProgress < 1.0 - (double) num6 * 3.0 ? ((double) animationProgress < (double) num7 * 4.0 ? ((double) animationProgress < (double) num7 * 3.0 ? ((double) animationProgress < (double) num7 * 2.0 ? ((double) animationProgress < (double) num7 ? 1 : 2) : 3) : 4) : 5) : 6) : 7) : 8;
|
||||
if (this._sacrificeAnimationTimeLeft == 56)
|
||||
{
|
||||
SoundEngine.PlaySound(63);
|
||||
Vector2 vector2 = new Vector2(0.0f, 0.1635f);
|
||||
for (int index = 0; index < 15; ++index)
|
||||
{
|
||||
Vector2 initialVelocity = Main.rand.NextVector2Circular(4f, 3f);
|
||||
if ((double) initialVelocity.Y > 0.0)
|
||||
initialVelocity.Y = -initialVelocity.Y;
|
||||
initialVelocity.Y -= 2f;
|
||||
this._pistonParticleSystem.AddParticle((IParticle) new CreativeSacrificeParticle(this._pistonParticleAsset, new Rectangle?(), initialVelocity, Vector2.Zero)
|
||||
{
|
||||
AccelerationPerFrame = vector2,
|
||||
ScaleOffsetPerFrame = -0.01666667f
|
||||
});
|
||||
}
|
||||
}
|
||||
if (this._sacrificeAnimationTimeLeft == 40 && this._researchComplete)
|
||||
{
|
||||
this._researchComplete = false;
|
||||
SoundEngine.PlaySound(64);
|
||||
}
|
||||
}
|
||||
this._sacrificePistons.SetFrame(1, 9, 0, frameY, 0, 0);
|
||||
}
|
||||
|
||||
private static void OffsetRotationsForCogs(float rotationOffset, List<UIImage> cogsList)
|
||||
{
|
||||
cogsList[0].Rotation += rotationOffset;
|
||||
cogsList[1].Rotation -= rotationOffset;
|
||||
}
|
||||
|
||||
private void AddSymetricalCogsPair(
|
||||
UIElement sacrificesContainer,
|
||||
Vector2 cogOFfsetsInPixels,
|
||||
string assetPath,
|
||||
List<UIImage> imagesList)
|
||||
{
|
||||
Asset<Texture2D> asset = Main.Assets.Request<Texture2D>(assetPath, (AssetRequestMode) 1);
|
||||
cogOFfsetsInPixels += -asset.Size() / 2f;
|
||||
UIImage uiImage1 = new UIImage(asset);
|
||||
uiImage1.NormalizedOrigin = Vector2.One / 2f;
|
||||
uiImage1.Left = new StyleDimension(cogOFfsetsInPixels.X, 0.0f);
|
||||
uiImage1.Top = new StyleDimension(cogOFfsetsInPixels.Y, 0.0f);
|
||||
UIImage uiImage2 = uiImage1;
|
||||
imagesList.Add(uiImage2);
|
||||
sacrificesContainer.Append((UIElement) uiImage2);
|
||||
UIImage uiImage3 = new UIImage(asset);
|
||||
uiImage3.NormalizedOrigin = Vector2.One / 2f;
|
||||
uiImage3.HAlign = 1f;
|
||||
uiImage3.Left = new StyleDimension(-cogOFfsetsInPixels.X, 0.0f);
|
||||
uiImage3.Top = new StyleDimension(cogOFfsetsInPixels.Y, 0.0f);
|
||||
UIImage uiImage4 = uiImage3;
|
||||
imagesList.Add(uiImage4);
|
||||
sacrificesContainer.Append((UIElement) uiImage4);
|
||||
}
|
||||
|
||||
private void descriptionText_OnUpdate(UIElement affectedElement)
|
||||
{
|
||||
UIText uiText = affectedElement as UIText;
|
||||
int itemIdChecked;
|
||||
int amountWeHave;
|
||||
int amountNeededTotal;
|
||||
bool sacrificeNumbers = Main.CreativeMenu.GetSacrificeNumbers(out itemIdChecked, out amountWeHave, out amountNeededTotal);
|
||||
Main.CreativeMenu.ShouldDrawSacrificeArea();
|
||||
if (!Main.mouseItem.IsAir)
|
||||
this.ForgetItemSacrifice();
|
||||
if (itemIdChecked == 0)
|
||||
{
|
||||
if (this._lastItemIdSacrificed != 0 && this._lastItemAmountWeNeededTotal != this._lastItemAmountWeHad)
|
||||
uiText.SetText(string.Format("({0}/{1})", (object) this._lastItemAmountWeHad, (object) this._lastItemAmountWeNeededTotal));
|
||||
else
|
||||
uiText.SetText("???");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ForgetItemSacrifice();
|
||||
if (!sacrificeNumbers)
|
||||
uiText.SetText("X");
|
||||
else
|
||||
uiText.SetText(string.Format("({0}/{1})", (object) amountWeHave, (object) amountNeededTotal));
|
||||
}
|
||||
}
|
||||
|
||||
private void sacrificeButton_OnClick(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
int itemIdChecked;
|
||||
int amountWeHave;
|
||||
int amountNeededTotal;
|
||||
Main.CreativeMenu.GetSacrificeNumbers(out itemIdChecked, out amountWeHave, out amountNeededTotal);
|
||||
int amountWeSacrificed;
|
||||
switch (Main.CreativeMenu.SacrificeItem(out amountWeSacrificed))
|
||||
{
|
||||
case CreativeUI.ItemSacrificeResult.SacrificedButNotDone:
|
||||
this._researchComplete = false;
|
||||
this.BeginSacrificeAnimation();
|
||||
this.RememberItemSacrifice(itemIdChecked, amountWeHave + amountWeSacrificed, amountNeededTotal);
|
||||
break;
|
||||
case CreativeUI.ItemSacrificeResult.SacrificedAndDone:
|
||||
this._researchComplete = true;
|
||||
this.BeginSacrificeAnimation();
|
||||
this.RememberItemSacrifice(itemIdChecked, amountWeHave + amountWeSacrificed, amountNeededTotal);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void RememberItemSacrifice(int itemId, int amountWeHave, int amountWeNeedTotal)
|
||||
{
|
||||
this._lastItemIdSacrificed = itemId;
|
||||
this._lastItemAmountWeHad = amountWeHave;
|
||||
this._lastItemAmountWeNeededTotal = amountWeNeedTotal;
|
||||
}
|
||||
|
||||
private void ForgetItemSacrifice()
|
||||
{
|
||||
this._lastItemIdSacrificed = 0;
|
||||
this._lastItemAmountWeHad = 0;
|
||||
this._lastItemAmountWeNeededTotal = 0;
|
||||
}
|
||||
|
||||
private void BeginSacrificeAnimation() => this._sacrificeAnimationTimeLeft = 60;
|
||||
|
||||
private void UpdateSacrificeAnimation()
|
||||
{
|
||||
if (this._sacrificeAnimationTimeLeft <= 0)
|
||||
return;
|
||||
--this._sacrificeAnimationTimeLeft;
|
||||
}
|
||||
|
||||
private float GetSacrificeAnimationProgress() => Utils.GetLerpValue(60f, 0.0f, (float) this._sacrificeAnimationTimeLeft, true);
|
||||
|
||||
public void SetPageTypeToShow(
|
||||
UICreativeInfiniteItemsDisplay.InfiniteItemsDisplayPage page)
|
||||
{
|
||||
this._showSacrificesInsteadOfInfinites = page == UICreativeInfiniteItemsDisplay.InfiniteItemsDisplayPage.InfiniteItemsResearch;
|
||||
}
|
||||
|
||||
private void UICreativeInfiniteItemsDisplay_OnUpdate(UIElement affectedElement)
|
||||
{
|
||||
this.RemoveAllChildren();
|
||||
CreativeUnlocksTracker playerCreativeTracker = Main.LocalPlayerCreativeTracker;
|
||||
if (this._lastTrackerCheckedForEdits != playerCreativeTracker)
|
||||
{
|
||||
this._lastTrackerCheckedForEdits = playerCreativeTracker;
|
||||
this._lastCheckedVersionForEdits = -1;
|
||||
}
|
||||
int lastEditId = playerCreativeTracker.ItemSacrifices.LastEditId;
|
||||
if (this._lastCheckedVersionForEdits != lastEditId)
|
||||
{
|
||||
this._lastCheckedVersionForEdits = lastEditId;
|
||||
this.UpdateContents();
|
||||
}
|
||||
if (this._showSacrificesInsteadOfInfinites)
|
||||
this.Append(this._containerSacrifice);
|
||||
else
|
||||
this.Append(this._containerInfinites);
|
||||
this.UpdateSacrificeAnimation();
|
||||
}
|
||||
|
||||
private void filtersHelper_OnClickingOption() => this.UpdateContents();
|
||||
|
||||
private void UpdateContents()
|
||||
{
|
||||
this._itemIdsAvailableTotal.Clear();
|
||||
CreativeItemSacrificesCatalog.Instance.FillListOfItemsThatCanBeObtainedInfinitely(this._itemIdsAvailableTotal);
|
||||
this._itemIdsAvailableToShow.Clear();
|
||||
this._itemIdsAvailableToShow.AddRange(this._itemIdsAvailableTotal.Where<int>((Func<int, bool>) (x => this._filterer.FitsFilter(ContentSamples.ItemsByType[x]))));
|
||||
this._itemIdsAvailableToShow.Sort((IComparer<int>) this._sorter);
|
||||
this._itemGrid.SetContentsToShow(this._itemIdsAvailableToShow);
|
||||
}
|
||||
|
||||
private void AddSearchBar(UIElement searchArea)
|
||||
{
|
||||
UIImageButton uiImageButton1 = new UIImageButton(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Button_Search", (AssetRequestMode) 1));
|
||||
uiImageButton1.VAlign = 0.5f;
|
||||
uiImageButton1.HAlign = 0.0f;
|
||||
UIImageButton uiImageButton2 = uiImageButton1;
|
||||
uiImageButton2.OnClick += new UIElement.MouseEvent(this.Click_SearchArea);
|
||||
uiImageButton2.SetHoverImage(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Button_Search_Border", (AssetRequestMode) 1));
|
||||
uiImageButton2.SetVisibility(1f, 1f);
|
||||
uiImageButton2.SetSnapPoint("CreativeInfinitesSearch", 0);
|
||||
searchArea.Append((UIElement) uiImageButton2);
|
||||
UIPanel uiPanel1 = new UIPanel();
|
||||
uiPanel1.Width = new StyleDimension((float) (-(double) uiImageButton2.Width.Pixels - 3.0), 1f);
|
||||
uiPanel1.Height = new StyleDimension(0.0f, 1f);
|
||||
uiPanel1.VAlign = 0.5f;
|
||||
uiPanel1.HAlign = 1f;
|
||||
UIPanel uiPanel2 = uiPanel1;
|
||||
this._searchBoxPanel = uiPanel2;
|
||||
uiPanel2.BackgroundColor = new Color(35, 40, 83);
|
||||
uiPanel2.BorderColor = new Color(35, 40, 83);
|
||||
uiPanel2.SetPadding(0.0f);
|
||||
searchArea.Append((UIElement) uiPanel2);
|
||||
UISearchBar uiSearchBar1 = new UISearchBar(Language.GetText("UI.PlayerNameSlot"), 0.8f);
|
||||
uiSearchBar1.Width = new StyleDimension(0.0f, 1f);
|
||||
uiSearchBar1.Height = new StyleDimension(0.0f, 1f);
|
||||
uiSearchBar1.HAlign = 0.0f;
|
||||
uiSearchBar1.VAlign = 0.5f;
|
||||
uiSearchBar1.Left = new StyleDimension(0.0f, 0.0f);
|
||||
uiSearchBar1.IgnoresMouseInteraction = true;
|
||||
UISearchBar uiSearchBar2 = uiSearchBar1;
|
||||
this._searchBar = uiSearchBar2;
|
||||
uiPanel2.OnClick += new UIElement.MouseEvent(this.Click_SearchArea);
|
||||
uiSearchBar2.OnContentsChanged += new Action<string>(this.OnSearchContentsChanged);
|
||||
uiPanel2.Append((UIElement) uiSearchBar2);
|
||||
uiSearchBar2.OnStartTakingInput += new Action(this.OnStartTakingInput);
|
||||
uiSearchBar2.OnEndTakingInput += new Action(this.OnEndTakingInput);
|
||||
uiSearchBar2.OnNeedingVirtualKeyboard += new Action(this.OpenVirtualKeyboardWhenNeeded);
|
||||
uiSearchBar2.OnCancledTakingInput += new Action(this.OnCancledInput);
|
||||
}
|
||||
|
||||
private void OnCancledInput() => Main.LocalPlayer.ToggleInv();
|
||||
|
||||
private void Click_SearchArea(UIMouseEvent evt, UIElement listeningElement) => this._searchBar.ToggleTakingText();
|
||||
|
||||
private void OnSearchContentsChanged(string contents)
|
||||
{
|
||||
this._searchString = contents;
|
||||
this._filterer.SetSearchFilter(contents);
|
||||
this.UpdateContents();
|
||||
}
|
||||
|
||||
private void OnStartTakingInput() => this._searchBoxPanel.BorderColor = Main.OurFavoriteColor;
|
||||
|
||||
private void OnEndTakingInput() => this._searchBoxPanel.BorderColor = new Color(35, 40, 83);
|
||||
|
||||
private void OpenVirtualKeyboardWhenNeeded()
|
||||
{
|
||||
int length = 40;
|
||||
UIVirtualKeyboard uiVirtualKeyboard = new UIVirtualKeyboard(Language.GetText("UI.PlayerNameSlot").Value, this._searchString, new UIVirtualKeyboard.KeyboardSubmitEvent(this.OnFinishedSettingName), new Action(this.GoBackHere), 3, true);
|
||||
uiVirtualKeyboard.SetMaxInputLength(length);
|
||||
IngameFancyUI.OpenUIState((UIState) uiVirtualKeyboard);
|
||||
}
|
||||
|
||||
private static UserInterface GetCurrentInterface()
|
||||
{
|
||||
UserInterface activeInstance = UserInterface.ActiveInstance;
|
||||
return !Main.gameMenu ? Main.InGameUI : Main.MenuUI;
|
||||
}
|
||||
|
||||
private void OnFinishedSettingName(string name)
|
||||
{
|
||||
this._searchBar.SetContents(name.Trim());
|
||||
this.GoBackHere();
|
||||
}
|
||||
|
||||
private void GoBackHere()
|
||||
{
|
||||
IngameFancyUI.Close();
|
||||
this._searchBar.ToggleTakingText();
|
||||
Main.CreativeMenu.GamepadMoveToSearchButtonHack = true;
|
||||
}
|
||||
|
||||
public int GetItemsPerLine() => this._itemGrid.GetItemsPerLine();
|
||||
|
||||
public enum InfiniteItemsDisplayPage
|
||||
{
|
||||
InfiniteItemsPickup,
|
||||
InfiniteItemsResearch,
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,112 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UICreativeItemsInfiniteFilteringOptions
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.Audio;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.GameContent.Creative;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UICreativeItemsInfiniteFilteringOptions : UIElement
|
||||
{
|
||||
private EntryFilterer<Item, IItemEntryFilter> _filterer;
|
||||
private Dictionary<UIImageFramed, IItemEntryFilter> _filtersByButtons = new Dictionary<UIImageFramed, IItemEntryFilter>();
|
||||
private Dictionary<UIImageFramed, UIElement> _iconsByButtons = new Dictionary<UIImageFramed, UIElement>();
|
||||
private const int barFramesX = 2;
|
||||
private const int barFramesY = 4;
|
||||
|
||||
public event Action OnClickingOption;
|
||||
|
||||
public UICreativeItemsInfiniteFilteringOptions(
|
||||
EntryFilterer<Item, IItemEntryFilter> filterer,
|
||||
string snapPointsName)
|
||||
{
|
||||
this._filterer = filterer;
|
||||
int num1 = 40;
|
||||
int count = this._filterer.AvailableFilters.Count;
|
||||
int num2 = num1 * count;
|
||||
this.Height = new StyleDimension((float) num1, 0.0f);
|
||||
this.Width = new StyleDimension((float) num2, 0.0f);
|
||||
this.Top = new StyleDimension(4f, 0.0f);
|
||||
this.SetPadding(0.0f);
|
||||
Asset<Texture2D> asset = Main.Assets.Request<Texture2D>("Images/UI/Creative/Infinite_Tabs_B", (AssetRequestMode) 1);
|
||||
for (int index = 0; index < this._filterer.AvailableFilters.Count; ++index)
|
||||
{
|
||||
IItemEntryFilter availableFilter = this._filterer.AvailableFilters[index];
|
||||
asset.Frame(2, 4).OffsetSize(-2, -2);
|
||||
UIImageFramed uiImageFramed = new UIImageFramed(asset, asset.Frame(2, 4).OffsetSize(-2, -2));
|
||||
uiImageFramed.Left.Set((float) (num1 * index), 0.0f);
|
||||
uiImageFramed.OnClick += new UIElement.MouseEvent(this.singleFilterButtonClick);
|
||||
uiImageFramed.OnMouseOver += new UIElement.MouseEvent(this.button_OnMouseOver);
|
||||
uiImageFramed.SetPadding(0.0f);
|
||||
uiImageFramed.SetSnapPoint(snapPointsName, index);
|
||||
this.AddOnHover(availableFilter, (UIElement) uiImageFramed, index);
|
||||
UIElement image = availableFilter.GetImage();
|
||||
image.IgnoresMouseInteraction = true;
|
||||
image.Left = new StyleDimension(6f, 0.0f);
|
||||
image.HAlign = 0.0f;
|
||||
uiImageFramed.Append(image);
|
||||
this._filtersByButtons[uiImageFramed] = availableFilter;
|
||||
this._iconsByButtons[uiImageFramed] = image;
|
||||
this.Append((UIElement) uiImageFramed);
|
||||
this.UpdateVisuals(uiImageFramed, index);
|
||||
}
|
||||
}
|
||||
|
||||
private void button_OnMouseOver(UIMouseEvent evt, UIElement listeningElement) => SoundEngine.PlaySound(12);
|
||||
|
||||
private void singleFilterButtonClick(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
IItemEntryFilter itemEntryFilter;
|
||||
if (!(evt.Target is UIImageFramed target) || !this._filtersByButtons.TryGetValue(target, out itemEntryFilter))
|
||||
return;
|
||||
int num = this._filterer.AvailableFilters.IndexOf(itemEntryFilter);
|
||||
if (num == -1)
|
||||
return;
|
||||
if (!this._filterer.ActiveFilters.Contains(itemEntryFilter))
|
||||
this._filterer.ActiveFilters.Clear();
|
||||
this._filterer.ToggleFilter(num);
|
||||
this.UpdateVisuals(target, num);
|
||||
if (this.OnClickingOption == null)
|
||||
return;
|
||||
this.OnClickingOption();
|
||||
}
|
||||
|
||||
private void UpdateVisuals(UIImageFramed button, int indexOfFilter)
|
||||
{
|
||||
bool flag = this._filterer.IsFilterActive(indexOfFilter);
|
||||
bool isMouseHovering = button.IsMouseHovering;
|
||||
int frameX = flag.ToInt();
|
||||
int frameY = flag.ToInt() * 2 + isMouseHovering.ToInt();
|
||||
button.SetFrame(2, 4, frameX, frameY, -2, -2);
|
||||
if (!(this._iconsByButtons[button] is IColorable iconsByButton))
|
||||
return;
|
||||
Color color = flag ? Color.White : Color.White * 0.5f;
|
||||
iconsByButton.Color = color;
|
||||
}
|
||||
|
||||
private void AddOnHover(IItemEntryFilter filter, UIElement button, int indexOfFilter)
|
||||
{
|
||||
button.OnUpdate += (UIElement.ElementEvent) (element => this.ShowButtonName(element, filter, indexOfFilter));
|
||||
button.OnUpdate += (UIElement.ElementEvent) (element => this.UpdateVisuals(button as UIImageFramed, indexOfFilter));
|
||||
}
|
||||
|
||||
private void ShowButtonName(UIElement element, IItemEntryFilter number, int indexOfFilter)
|
||||
{
|
||||
if (!element.IsMouseHovering)
|
||||
return;
|
||||
string textValue = Language.GetTextValue(number.GetDisplayNameKey());
|
||||
Main.instance.MouseText(textValue);
|
||||
}
|
||||
}
|
||||
}
|
14
GameContent/UI/Elements/UICreativePowerButton.cs
Normal file
14
GameContent/UI/Elements/UICreativePowerButton.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UICreativePowerButton
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UICreativePowerButton : UIElement
|
||||
{
|
||||
}
|
||||
}
|
94
GameContent/UI/Elements/UIDifficultyButton.cs
Normal file
94
GameContent/UI/Elements/UIDifficultyButton.cs
Normal file
|
@ -0,0 +1,94 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIDifficultyButton
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria.Audio;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIDifficultyButton : UIElement
|
||||
{
|
||||
private readonly Player _player;
|
||||
private readonly Asset<Texture2D> _BasePanelTexture;
|
||||
private readonly Asset<Texture2D> _selectedBorderTexture;
|
||||
private readonly Asset<Texture2D> _hoveredBorderTexture;
|
||||
private readonly byte _difficulty;
|
||||
private readonly Color _color;
|
||||
private bool _hovered;
|
||||
private bool _soundedHover;
|
||||
|
||||
public UIDifficultyButton(
|
||||
Player player,
|
||||
LocalizedText title,
|
||||
LocalizedText description,
|
||||
byte difficulty,
|
||||
Color color)
|
||||
{
|
||||
this._player = player;
|
||||
this._difficulty = difficulty;
|
||||
this.Width = StyleDimension.FromPixels(44f);
|
||||
this.Height = StyleDimension.FromPixels(110f);
|
||||
this._BasePanelTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/PanelGrayscale", (AssetRequestMode) 1);
|
||||
this._selectedBorderTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/CategoryPanelHighlight", (AssetRequestMode) 1);
|
||||
this._hoveredBorderTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/CategoryPanelBorder", (AssetRequestMode) 1);
|
||||
this._color = color;
|
||||
UIText uiText = new UIText(title, 0.9f);
|
||||
uiText.HAlign = 0.5f;
|
||||
uiText.VAlign = 0.0f;
|
||||
uiText.Width = StyleDimension.FromPixelsAndPercent(-10f, 1f);
|
||||
uiText.Top = StyleDimension.FromPixels(5f);
|
||||
this.Append((UIElement) uiText);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
if (this._hovered)
|
||||
{
|
||||
if (!this._soundedHover)
|
||||
SoundEngine.PlaySound(12);
|
||||
this._soundedHover = true;
|
||||
}
|
||||
else
|
||||
this._soundedHover = false;
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
int num1 = 7;
|
||||
if ((double) dimensions.Height < 30.0)
|
||||
num1 = 5;
|
||||
int num2 = 10;
|
||||
int num3 = 10;
|
||||
int num4 = (int) this._difficulty == (int) this._player.difficulty ? 1 : 0;
|
||||
Utils.DrawSplicedPanel(spriteBatch, this._BasePanelTexture.Value, (int) dimensions.X, (int) dimensions.Y, (int) dimensions.Width, (int) dimensions.Height, num2, num2, num3, num3, Color.Lerp(Color.Black, this._color, 0.8f) * 0.5f);
|
||||
if (num4 != 0)
|
||||
Utils.DrawSplicedPanel(spriteBatch, this._BasePanelTexture.Value, (int) dimensions.X + num1, (int) dimensions.Y + num1 - 2, (int) dimensions.Width - num1 * 2, (int) dimensions.Height - num1 * 2, num2, num2, num3, num3, Color.Lerp(this._color, Color.White, 0.7f) * 0.5f);
|
||||
if (!this._hovered)
|
||||
return;
|
||||
Utils.DrawSplicedPanel(spriteBatch, this._hoveredBorderTexture.Value, (int) dimensions.X, (int) dimensions.Y, (int) dimensions.Width, (int) dimensions.Height, num2, num2, num3, num3, Color.White);
|
||||
}
|
||||
|
||||
public override void MouseDown(UIMouseEvent evt)
|
||||
{
|
||||
this._player.difficulty = this._difficulty;
|
||||
SoundEngine.PlaySound(12);
|
||||
base.MouseDown(evt);
|
||||
}
|
||||
|
||||
public override void MouseOver(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseOver(evt);
|
||||
this._hovered = true;
|
||||
}
|
||||
|
||||
public override void MouseOut(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseOut(evt);
|
||||
this._hovered = false;
|
||||
}
|
||||
}
|
||||
}
|
176
GameContent/UI/Elements/UIDynamicItemCollection.cs
Normal file
176
GameContent/UI/Elements/UIDynamicItemCollection.cs
Normal file
|
@ -0,0 +1,176 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIDynamicItemCollection
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.GameInput;
|
||||
using Terraria.ID;
|
||||
using Terraria.UI;
|
||||
using Terraria.UI.Gamepad;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIDynamicItemCollection : UIElement
|
||||
{
|
||||
private List<int> _itemIdsAvailableToShow = new List<int>();
|
||||
private List<int> _itemIdsToLoadTexturesFor = new List<int>();
|
||||
private int _itemsPerLine;
|
||||
private const int sizePerEntryX = 44;
|
||||
private const int sizePerEntryY = 44;
|
||||
private List<SnapPoint> _dummySnapPoints = new List<SnapPoint>();
|
||||
|
||||
public UIDynamicItemCollection()
|
||||
{
|
||||
this.Width = new StyleDimension(0.0f, 1f);
|
||||
this.HAlign = 0.5f;
|
||||
this.UpdateSize();
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
Main.inventoryScale = 0.8461539f;
|
||||
int startX;
|
||||
int startY;
|
||||
int startItemIndex;
|
||||
int endItemIndex;
|
||||
this.GetGridParameters(out startX, out startY, out startItemIndex, out endItemIndex);
|
||||
int itemsPerLine = this._itemsPerLine;
|
||||
for (int index = startItemIndex; index < endItemIndex; ++index)
|
||||
{
|
||||
int key = this._itemIdsAvailableToShow[index];
|
||||
Rectangle itemSlotHitbox = this.GetItemSlotHitbox(startX, startY, startItemIndex, index);
|
||||
Item inv = ContentSamples.ItemsByType[key];
|
||||
int context = 29;
|
||||
if (TextureAssets.Item[key].State == null)
|
||||
--itemsPerLine;
|
||||
bool flag = false;
|
||||
if (this.IsMouseHovering && itemSlotHitbox.Contains(Main.MouseScreen.ToPoint()) && !PlayerInput.IgnoreMouseInterface)
|
||||
{
|
||||
Main.LocalPlayer.mouseInterface = true;
|
||||
ItemSlot.OverrideHover(ref inv, context);
|
||||
ItemSlot.LeftClick(ref inv, context);
|
||||
ItemSlot.RightClick(ref inv, context);
|
||||
ItemSlot.MouseHover(ref inv, context);
|
||||
flag = true;
|
||||
}
|
||||
UILinkPointNavigator.Shortcuts.CREATIVE_ItemSlotShouldHighlightAsSelected = flag;
|
||||
ItemSlot.Draw(spriteBatch, ref inv, context, itemSlotHitbox.TopLeft());
|
||||
if (itemsPerLine <= 0)
|
||||
break;
|
||||
}
|
||||
while (this._itemIdsToLoadTexturesFor.Count > 0 && itemsPerLine > 0)
|
||||
{
|
||||
int i = this._itemIdsToLoadTexturesFor[0];
|
||||
this._itemIdsToLoadTexturesFor.RemoveAt(0);
|
||||
if (TextureAssets.Item[i].State == null)
|
||||
{
|
||||
Main.instance.LoadItem(i);
|
||||
itemsPerLine -= 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Rectangle GetItemSlotHitbox(
|
||||
int startX,
|
||||
int startY,
|
||||
int startItemIndex,
|
||||
int i)
|
||||
{
|
||||
int num1 = i - startItemIndex;
|
||||
int num2 = num1 % this._itemsPerLine;
|
||||
int num3 = num1 / this._itemsPerLine;
|
||||
return new Rectangle(startX + num2 * 44, startY + num3 * 44, 44, 44);
|
||||
}
|
||||
|
||||
private void GetGridParameters(
|
||||
out int startX,
|
||||
out int startY,
|
||||
out int startItemIndex,
|
||||
out int endItemIndex)
|
||||
{
|
||||
Rectangle rectangle = this.GetDimensions().ToRectangle();
|
||||
Rectangle viewCullingArea = this.Parent.GetViewCullingArea();
|
||||
int x = rectangle.Center.X;
|
||||
startX = x - (int) ((double) (44 * this._itemsPerLine) * 0.5);
|
||||
startY = rectangle.Top;
|
||||
startItemIndex = 0;
|
||||
endItemIndex = this._itemIdsAvailableToShow.Count;
|
||||
int num1 = (Math.Min(viewCullingArea.Top, rectangle.Top) - viewCullingArea.Top) / 44;
|
||||
startY += -num1 * 44;
|
||||
startItemIndex += -num1 * this._itemsPerLine;
|
||||
int num2 = (int) Math.Ceiling((double) viewCullingArea.Height / 44.0) * this._itemsPerLine;
|
||||
if (endItemIndex <= num2 + startItemIndex + this._itemsPerLine)
|
||||
return;
|
||||
endItemIndex = num2 + startItemIndex + this._itemsPerLine;
|
||||
}
|
||||
|
||||
public override void Recalculate()
|
||||
{
|
||||
base.Recalculate();
|
||||
this.UpdateSize();
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
base.Update(gameTime);
|
||||
if (!this.IsMouseHovering)
|
||||
return;
|
||||
Main.LocalPlayer.mouseInterface = true;
|
||||
}
|
||||
|
||||
public void SetContentsToShow(List<int> itemIdsToShow)
|
||||
{
|
||||
this._itemIdsAvailableToShow.Clear();
|
||||
this._itemIdsToLoadTexturesFor.Clear();
|
||||
this._itemIdsAvailableToShow.AddRange((IEnumerable<int>) itemIdsToShow);
|
||||
this._itemIdsToLoadTexturesFor.AddRange((IEnumerable<int>) itemIdsToShow);
|
||||
this.UpdateSize();
|
||||
}
|
||||
|
||||
public int GetItemsPerLine() => this._itemsPerLine;
|
||||
|
||||
public override List<SnapPoint> GetSnapPoints()
|
||||
{
|
||||
List<SnapPoint> snapPointList = new List<SnapPoint>();
|
||||
int startX;
|
||||
int startY;
|
||||
int startItemIndex;
|
||||
int endItemIndex;
|
||||
this.GetGridParameters(out startX, out startY, out startItemIndex, out endItemIndex);
|
||||
int itemsPerLine = this._itemsPerLine;
|
||||
Rectangle viewCullingArea = this.Parent.GetViewCullingArea();
|
||||
int num1 = endItemIndex - startItemIndex;
|
||||
while (this._dummySnapPoints.Count < num1)
|
||||
this._dummySnapPoints.Add(new SnapPoint("CreativeInfinitesSlot", 0, Vector2.Zero, Vector2.Zero));
|
||||
int num2 = 0;
|
||||
Vector2 vector2 = this.GetDimensions().Position();
|
||||
for (int i = startItemIndex; i < endItemIndex; ++i)
|
||||
{
|
||||
Point center = this.GetItemSlotHitbox(startX, startY, startItemIndex, i).Center;
|
||||
if (viewCullingArea.Contains(center))
|
||||
{
|
||||
SnapPoint dummySnapPoint = this._dummySnapPoints[num2];
|
||||
dummySnapPoint.ThisIsAHackThatChangesTheSnapPointsInfo(Vector2.Zero, center.ToVector2() - vector2, num2);
|
||||
dummySnapPoint.Calculate((UIElement) this);
|
||||
++num2;
|
||||
snapPointList.Add(dummySnapPoint);
|
||||
}
|
||||
}
|
||||
foreach (UIElement element in this.Elements)
|
||||
snapPointList.AddRange((IEnumerable<SnapPoint>) element.GetSnapPoints());
|
||||
return snapPointList;
|
||||
}
|
||||
|
||||
public void UpdateSize()
|
||||
{
|
||||
int num = this.GetDimensions().ToRectangle().Width / 44;
|
||||
this._itemsPerLine = num;
|
||||
this.MinHeight.Set((float) (44 * (int) Math.Ceiling((double) this._itemIdsAvailableToShow.Count / (double) num)), 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
124
GameContent/UI/Elements/UIGenProgressBar.cs
Normal file
124
GameContent/UI/Elements/UIGenProgressBar.cs
Normal file
|
@ -0,0 +1,124 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIGenProgressBar
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIGenProgressBar : UIElement
|
||||
{
|
||||
private Asset<Texture2D> _texOuterCrimson;
|
||||
private Asset<Texture2D> _texOuterCorrupt;
|
||||
private Asset<Texture2D> _texOuterLower;
|
||||
private float _visualOverallProgress;
|
||||
private float _targetOverallProgress;
|
||||
private float _visualCurrentProgress;
|
||||
private float _targetCurrentProgress;
|
||||
private int _smallBarWidth = 508;
|
||||
private int _longBarWidth = 570;
|
||||
|
||||
public UIGenProgressBar()
|
||||
{
|
||||
if (Main.netMode != 2)
|
||||
{
|
||||
this._texOuterCorrupt = Main.Assets.Request<Texture2D>("Images/UI/WorldGen/Outer_Corrupt", (AssetRequestMode) 1);
|
||||
this._texOuterCrimson = Main.Assets.Request<Texture2D>("Images/UI/WorldGen/Outer_Crimson", (AssetRequestMode) 1);
|
||||
this._texOuterLower = Main.Assets.Request<Texture2D>("Images/UI/WorldGen/Outer_Lower", (AssetRequestMode) 1);
|
||||
}
|
||||
this.Recalculate();
|
||||
}
|
||||
|
||||
public override void Recalculate()
|
||||
{
|
||||
this.Width.Precent = 0.0f;
|
||||
this.Height.Precent = 0.0f;
|
||||
this.Width.Pixels = 612f;
|
||||
this.Height.Pixels = 70f;
|
||||
base.Recalculate();
|
||||
}
|
||||
|
||||
public void SetProgress(float overallProgress, float currentProgress)
|
||||
{
|
||||
this._targetCurrentProgress = currentProgress;
|
||||
this._targetOverallProgress = overallProgress;
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
if (!this._texOuterCorrupt.IsLoaded || !this._texOuterCrimson.IsLoaded || !this._texOuterLower.IsLoaded)
|
||||
return;
|
||||
bool flag = WorldGen.crimson;
|
||||
if (WorldGen.drunkWorldGen && Main.rand.Next(2) == 0)
|
||||
flag = !flag;
|
||||
this._visualOverallProgress = this._targetOverallProgress;
|
||||
this._visualCurrentProgress = this._targetCurrentProgress;
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
int completedWidth1 = (int) ((double) this._visualOverallProgress * (double) this._longBarWidth);
|
||||
int completedWidth2 = (int) ((double) this._visualCurrentProgress * (double) this._smallBarWidth);
|
||||
Vector2 vector2 = new Vector2(dimensions.X, dimensions.Y);
|
||||
Color filled = new Color();
|
||||
filled.PackedValue = flag ? 4286836223U : 4283888223U;
|
||||
this.DrawFilling2(spriteBatch, vector2 + new Vector2(20f, 40f), 16, completedWidth1, this._longBarWidth, filled, Color.Lerp(filled, Color.Black, 0.5f), new Color(48, 48, 48));
|
||||
filled.PackedValue = 4290947159U;
|
||||
this.DrawFilling2(spriteBatch, vector2 + new Vector2(50f, 60f), 8, completedWidth2, this._smallBarWidth, filled, Color.Lerp(filled, Color.Black, 0.5f), new Color(33, 33, 33));
|
||||
Rectangle rectangle = this.GetDimensions().ToRectangle();
|
||||
rectangle.X -= 8;
|
||||
spriteBatch.Draw(flag ? this._texOuterCrimson.Value : this._texOuterCorrupt.Value, rectangle.TopLeft(), Color.White);
|
||||
spriteBatch.Draw(this._texOuterLower.Value, rectangle.TopLeft() + new Vector2(44f, 60f), Color.White);
|
||||
}
|
||||
|
||||
private void DrawFilling(
|
||||
SpriteBatch spritebatch,
|
||||
Texture2D tex,
|
||||
Texture2D texShadow,
|
||||
Vector2 topLeft,
|
||||
int completedWidth,
|
||||
int totalWidth,
|
||||
Color separator,
|
||||
Color empty)
|
||||
{
|
||||
if (completedWidth % 2 != 0)
|
||||
--completedWidth;
|
||||
Vector2 position = topLeft + (float) completedWidth * Vector2.UnitX;
|
||||
int num = completedWidth;
|
||||
Rectangle rectangle = tex.Frame();
|
||||
for (; num > 0; num -= rectangle.Width)
|
||||
{
|
||||
if (rectangle.Width > num)
|
||||
{
|
||||
rectangle.X += rectangle.Width - num;
|
||||
rectangle.Width = num;
|
||||
}
|
||||
spritebatch.Draw(tex, position, new Rectangle?(rectangle), Color.White, 0.0f, new Vector2((float) rectangle.Width, 0.0f), 1f, SpriteEffects.None, 0.0f);
|
||||
position.X -= (float) rectangle.Width;
|
||||
}
|
||||
if (texShadow != null)
|
||||
spritebatch.Draw(texShadow, topLeft, new Rectangle?(new Rectangle(0, 0, completedWidth, texShadow.Height)), Color.White);
|
||||
spritebatch.Draw(TextureAssets.MagicPixel.Value, new Rectangle((int) topLeft.X + completedWidth, (int) topLeft.Y, totalWidth - completedWidth, tex.Height), new Rectangle?(new Rectangle(0, 0, 1, 1)), empty);
|
||||
spritebatch.Draw(TextureAssets.MagicPixel.Value, new Rectangle((int) topLeft.X + completedWidth - 2, (int) topLeft.Y, 2, tex.Height), new Rectangle?(new Rectangle(0, 0, 1, 1)), separator);
|
||||
}
|
||||
|
||||
private void DrawFilling2(
|
||||
SpriteBatch spritebatch,
|
||||
Vector2 topLeft,
|
||||
int height,
|
||||
int completedWidth,
|
||||
int totalWidth,
|
||||
Color filled,
|
||||
Color separator,
|
||||
Color empty)
|
||||
{
|
||||
if (completedWidth % 2 != 0)
|
||||
--completedWidth;
|
||||
spritebatch.Draw(TextureAssets.MagicPixel.Value, new Rectangle((int) topLeft.X, (int) topLeft.Y, completedWidth, height), new Rectangle?(new Rectangle(0, 0, 1, 1)), filled);
|
||||
spritebatch.Draw(TextureAssets.MagicPixel.Value, new Rectangle((int) topLeft.X + completedWidth, (int) topLeft.Y, totalWidth - completedWidth, height), new Rectangle?(new Rectangle(0, 0, 1, 1)), empty);
|
||||
spritebatch.Draw(TextureAssets.MagicPixel.Value, new Rectangle((int) topLeft.X + completedWidth - 2, (int) topLeft.Y, 2, height), new Rectangle?(new Rectangle(0, 0, 1, 1)), separator);
|
||||
}
|
||||
}
|
||||
}
|
76
GameContent/UI/Elements/UIHairStyleButton.cs
Normal file
76
GameContent/UI/Elements/UIHairStyleButton.cs
Normal file
|
@ -0,0 +1,76 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIHairStyleButton
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria.Audio;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIHairStyleButton : UIImageButton
|
||||
{
|
||||
private readonly Player _player;
|
||||
public readonly int HairStyleId;
|
||||
private readonly Asset<Texture2D> _selectedBorderTexture;
|
||||
private readonly Asset<Texture2D> _hoveredBorderTexture;
|
||||
private bool _hovered;
|
||||
private bool _soundedHover;
|
||||
|
||||
public UIHairStyleButton(Player player, int hairStyleId)
|
||||
: base(Main.Assets.Request<Texture2D>("Images/UI/CharCreation/CategoryPanel", (AssetRequestMode) 1))
|
||||
{
|
||||
this._player = player;
|
||||
this.HairStyleId = hairStyleId;
|
||||
this.Width = StyleDimension.FromPixels(44f);
|
||||
this.Height = StyleDimension.FromPixels(44f);
|
||||
this._selectedBorderTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/CategoryPanelHighlight", (AssetRequestMode) 1);
|
||||
this._hoveredBorderTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/CategoryPanelBorder", (AssetRequestMode) 1);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
if (this._hovered)
|
||||
{
|
||||
if (!this._soundedHover)
|
||||
SoundEngine.PlaySound(12);
|
||||
this._soundedHover = true;
|
||||
}
|
||||
else
|
||||
this._soundedHover = false;
|
||||
Vector2 vector2 = new Vector2(-5f, -5f);
|
||||
base.DrawSelf(spriteBatch);
|
||||
if (this._player.hair == this.HairStyleId)
|
||||
spriteBatch.Draw(this._selectedBorderTexture.Value, this.GetDimensions().Center() - this._selectedBorderTexture.Size() / 2f, Color.White);
|
||||
if (this._hovered)
|
||||
spriteBatch.Draw(this._hoveredBorderTexture.Value, this.GetDimensions().Center() - this._hoveredBorderTexture.Size() / 2f, Color.White);
|
||||
int hair = this._player.hair;
|
||||
this._player.hair = this.HairStyleId;
|
||||
Main.PlayerRenderer.DrawPlayerHead(Main.Camera, this._player, this.GetDimensions().Center() + vector2);
|
||||
this._player.hair = hair;
|
||||
}
|
||||
|
||||
public override void MouseDown(UIMouseEvent evt)
|
||||
{
|
||||
this._player.hair = this.HairStyleId;
|
||||
SoundEngine.PlaySound(12);
|
||||
base.MouseDown(evt);
|
||||
}
|
||||
|
||||
public override void MouseOver(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseOver(evt);
|
||||
this._hovered = true;
|
||||
}
|
||||
|
||||
public override void MouseOut(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseOut(evt);
|
||||
this._hovered = false;
|
||||
}
|
||||
}
|
||||
}
|
50
GameContent/UI/Elements/UIHeader.cs
Normal file
50
GameContent/UI/Elements/UIHeader.cs
Normal file
|
@ -0,0 +1,50 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIHeader
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Graphics;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIHeader : UIElement
|
||||
{
|
||||
private string _text;
|
||||
|
||||
public string Text
|
||||
{
|
||||
get => this._text;
|
||||
set
|
||||
{
|
||||
if (!(this._text != value))
|
||||
return;
|
||||
this._text = value;
|
||||
Vector2 vector2 = FontAssets.DeathText.Value.MeasureString(this.Text);
|
||||
this.Width.Pixels = vector2.X;
|
||||
this.Height.Pixels = vector2.Y;
|
||||
this.Width.Precent = 0.0f;
|
||||
this.Height.Precent = 0.0f;
|
||||
this.Recalculate();
|
||||
}
|
||||
}
|
||||
|
||||
public UIHeader() => this.Text = "";
|
||||
|
||||
public UIHeader(string text) => this.Text = text;
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
float num = 1.2f;
|
||||
DynamicSpriteFontExtensionMethods.DrawString(spriteBatch, FontAssets.DeathText.Value, this.Text, new Vector2(dimensions.X - num, dimensions.Y - num), Color.Black);
|
||||
DynamicSpriteFontExtensionMethods.DrawString(spriteBatch, FontAssets.DeathText.Value, this.Text, new Vector2(dimensions.X + num, dimensions.Y - num), Color.Black);
|
||||
DynamicSpriteFontExtensionMethods.DrawString(spriteBatch, FontAssets.DeathText.Value, this.Text, new Vector2(dimensions.X - num, dimensions.Y + num), Color.Black);
|
||||
DynamicSpriteFontExtensionMethods.DrawString(spriteBatch, FontAssets.DeathText.Value, this.Text, new Vector2(dimensions.X + num, dimensions.Y + num), Color.Black);
|
||||
DynamicSpriteFontExtensionMethods.DrawString(spriteBatch, FontAssets.DeathText.Value, this.Text, new Vector2(dimensions.X, dimensions.Y), Color.White);
|
||||
}
|
||||
}
|
||||
}
|
36
GameContent/UI/Elements/UIHorizontalSeparator.cs
Normal file
36
GameContent/UI/Elements/UIHorizontalSeparator.cs
Normal file
|
@ -0,0 +1,36 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIHorizontalSeparator
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIHorizontalSeparator : UIElement
|
||||
{
|
||||
private Asset<Texture2D> _texture;
|
||||
public Color Color;
|
||||
public int EdgeWidth;
|
||||
|
||||
public UIHorizontalSeparator(int EdgeWidth = 2, bool highlightSideUp = true)
|
||||
{
|
||||
this.Color = Color.White;
|
||||
this._texture = !highlightSideUp ? Main.Assets.Request<Texture2D>("Images/UI/CharCreation/Separator2", (AssetRequestMode) 1) : Main.Assets.Request<Texture2D>("Images/UI/CharCreation/Separator1", (AssetRequestMode) 1);
|
||||
this.Width.Set((float) this._texture.Width(), 0.0f);
|
||||
this.Height.Set((float) this._texture.Height(), 0.0f);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
Utils.DrawPanel(this._texture.Value, this.EdgeWidth, 0, spriteBatch, dimensions.Position(), dimensions.Width, this.Color);
|
||||
}
|
||||
|
||||
public override bool ContainsPoint(Vector2 point) => false;
|
||||
}
|
||||
}
|
55
GameContent/UI/Elements/UIImage.cs
Normal file
55
GameContent/UI/Elements/UIImage.cs
Normal file
|
@ -0,0 +1,55 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIImage
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIImage : UIElement
|
||||
{
|
||||
private Asset<Texture2D> _texture;
|
||||
public float ImageScale = 1f;
|
||||
public float Rotation;
|
||||
public bool ScaleToFit;
|
||||
public Color Color = Color.White;
|
||||
public Vector2 NormalizedOrigin = Vector2.Zero;
|
||||
public bool RemoveFloatingPointsFromDrawPosition;
|
||||
|
||||
public UIImage(Asset<Texture2D> texture)
|
||||
{
|
||||
this._texture = texture;
|
||||
this.Width.Set((float) this._texture.Width(), 0.0f);
|
||||
this.Height.Set((float) this._texture.Height(), 0.0f);
|
||||
}
|
||||
|
||||
public void SetImage(Asset<Texture2D> texture)
|
||||
{
|
||||
this._texture = texture;
|
||||
this.Width.Set((float) this._texture.Width(), 0.0f);
|
||||
this.Height.Set((float) this._texture.Height(), 0.0f);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
if (this.ScaleToFit)
|
||||
{
|
||||
spriteBatch.Draw(this._texture.Value, dimensions.ToRectangle(), this.Color);
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector2 vector2_1 = this._texture.Value.Size();
|
||||
Vector2 vector2_2 = dimensions.Position() + vector2_1 * (1f - this.ImageScale) / 2f + vector2_1 * this.NormalizedOrigin;
|
||||
if (this.RemoveFloatingPointsFromDrawPosition)
|
||||
vector2_2 = vector2_2.Floor();
|
||||
spriteBatch.Draw(this._texture.Value, vector2_2, new Rectangle?(), this.Color, this.Rotation, vector2_1 * this.NormalizedOrigin, this.ImageScale, SpriteEffects.None, 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
61
GameContent/UI/Elements/UIImageButton.cs
Normal file
61
GameContent/UI/Elements/UIImageButton.cs
Normal file
|
@ -0,0 +1,61 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIImageButton
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria.Audio;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIImageButton : UIElement
|
||||
{
|
||||
private Asset<Texture2D> _texture;
|
||||
private float _visibilityActive = 1f;
|
||||
private float _visibilityInactive = 0.4f;
|
||||
private Asset<Texture2D> _borderTexture;
|
||||
|
||||
public UIImageButton(Asset<Texture2D> texture)
|
||||
{
|
||||
this._texture = texture;
|
||||
this.Width.Set((float) this._texture.Width(), 0.0f);
|
||||
this.Height.Set((float) this._texture.Height(), 0.0f);
|
||||
}
|
||||
|
||||
public void SetHoverImage(Asset<Texture2D> texture) => this._borderTexture = texture;
|
||||
|
||||
public void SetImage(Asset<Texture2D> texture)
|
||||
{
|
||||
this._texture = texture;
|
||||
this.Width.Set((float) this._texture.Width(), 0.0f);
|
||||
this.Height.Set((float) this._texture.Height(), 0.0f);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
spriteBatch.Draw(this._texture.Value, dimensions.Position(), Color.White * (this.IsMouseHovering ? this._visibilityActive : this._visibilityInactive));
|
||||
if (this._borderTexture == null || !this.IsMouseHovering)
|
||||
return;
|
||||
spriteBatch.Draw(this._borderTexture.Value, dimensions.Position(), Color.White);
|
||||
}
|
||||
|
||||
public override void MouseOver(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseOver(evt);
|
||||
SoundEngine.PlaySound(12);
|
||||
}
|
||||
|
||||
public override void MouseOut(UIMouseEvent evt) => base.MouseOut(evt);
|
||||
|
||||
public void SetVisibility(float whenActive, float whenInactive)
|
||||
{
|
||||
this._visibilityActive = MathHelper.Clamp(whenActive, 0.0f, 1f);
|
||||
this._visibilityInactive = MathHelper.Clamp(whenInactive, 0.0f, 1f);
|
||||
}
|
||||
}
|
||||
}
|
62
GameContent/UI/Elements/UIImageFramed.cs
Normal file
62
GameContent/UI/Elements/UIImageFramed.cs
Normal file
|
@ -0,0 +1,62 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIImageFramed
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIImageFramed : UIElement, IColorable
|
||||
{
|
||||
private Asset<Texture2D> _texture;
|
||||
private Rectangle _frame;
|
||||
|
||||
public Color Color { get; set; }
|
||||
|
||||
public UIImageFramed(Asset<Texture2D> texture, Rectangle frame)
|
||||
{
|
||||
this._texture = texture;
|
||||
this._frame = frame;
|
||||
this.Width.Set((float) this._frame.Width, 0.0f);
|
||||
this.Height.Set((float) this._frame.Height, 0.0f);
|
||||
this.Color = Color.White;
|
||||
}
|
||||
|
||||
public void SetImage(Asset<Texture2D> texture, Rectangle frame)
|
||||
{
|
||||
this._texture = texture;
|
||||
this._frame = frame;
|
||||
this.Width.Set((float) this._frame.Width, 0.0f);
|
||||
this.Height.Set((float) this._frame.Height, 0.0f);
|
||||
}
|
||||
|
||||
public void SetFrame(Rectangle frame)
|
||||
{
|
||||
this._frame = frame;
|
||||
this.Width.Set((float) this._frame.Width, 0.0f);
|
||||
this.Height.Set((float) this._frame.Height, 0.0f);
|
||||
}
|
||||
|
||||
public void SetFrame(
|
||||
int frameCountHorizontal,
|
||||
int frameCountVertical,
|
||||
int frameX,
|
||||
int frameY,
|
||||
int sizeOffsetX,
|
||||
int sizeOffsetY)
|
||||
{
|
||||
this.SetFrame(this._texture.Frame(frameCountHorizontal, frameCountVertical, frameX, frameY).OffsetSize(sizeOffsetX, sizeOffsetY));
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
spriteBatch.Draw(this._texture.Value, dimensions.Position(), new Rectangle?(this._frame), this.Color);
|
||||
}
|
||||
}
|
||||
}
|
32
GameContent/UI/Elements/UIItemIcon.cs
Normal file
32
GameContent/UI/Elements/UIItemIcon.cs
Normal file
|
@ -0,0 +1,32 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIItemIcon
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIItemIcon : UIElement
|
||||
{
|
||||
private Item _item;
|
||||
private bool _blackedOut;
|
||||
|
||||
public UIItemIcon(Item item, bool blackedOut)
|
||||
{
|
||||
this._item = item;
|
||||
this.Width.Set(32f, 0.0f);
|
||||
this.Height.Set(32f, 0.0f);
|
||||
this._blackedOut = blackedOut;
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
Main.DrawItemIcon(spriteBatch, this._item, dimensions.Center(), this._blackedOut ? Color.Black : Color.White, 32f);
|
||||
}
|
||||
}
|
||||
}
|
49
GameContent/UI/Elements/UIItemSlot.cs
Normal file
49
GameContent/UI/Elements/UIItemSlot.cs
Normal file
|
@ -0,0 +1,49 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIItemSlot
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIItemSlot : UIElement
|
||||
{
|
||||
private Item[] _itemArray;
|
||||
private int _itemIndex;
|
||||
private int _itemSlotContext;
|
||||
|
||||
public UIItemSlot(Item[] itemArray, int itemIndex, int itemSlotContext)
|
||||
{
|
||||
this._itemArray = itemArray;
|
||||
this._itemIndex = itemIndex;
|
||||
this._itemSlotContext = itemSlotContext;
|
||||
this.Width = new StyleDimension(48f, 0.0f);
|
||||
this.Height = new StyleDimension(48f, 0.0f);
|
||||
}
|
||||
|
||||
private void HandleItemSlotLogic()
|
||||
{
|
||||
if (!this.IsMouseHovering)
|
||||
return;
|
||||
Main.LocalPlayer.mouseInterface = true;
|
||||
Item inv = this._itemArray[this._itemIndex];
|
||||
ItemSlot.OverrideHover(ref inv, this._itemSlotContext);
|
||||
ItemSlot.LeftClick(ref inv, this._itemSlotContext);
|
||||
ItemSlot.RightClick(ref inv, this._itemSlotContext);
|
||||
ItemSlot.MouseHover(ref inv, this._itemSlotContext);
|
||||
this._itemArray[this._itemIndex] = inv;
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
this.HandleItemSlotLogic();
|
||||
Item inv = this._itemArray[this._itemIndex];
|
||||
Vector2 position = this.GetDimensions().Center() + new Vector2(52f, 52f) * -0.5f * Main.inventoryScale;
|
||||
ItemSlot.Draw(spriteBatch, ref inv, this._itemSlotContext, position);
|
||||
}
|
||||
}
|
||||
}
|
204
GameContent/UI/Elements/UIKeybindingListItem.cs
Normal file
204
GameContent/UI/Elements/UIKeybindingListItem.cs
Normal file
|
@ -0,0 +1,204 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIKeybindingListItem
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.GameContent.UI.Chat;
|
||||
using Terraria.GameInput;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI;
|
||||
using Terraria.UI.Chat;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIKeybindingListItem : UIElement
|
||||
{
|
||||
private InputMode _inputmode;
|
||||
private Color _color;
|
||||
private string _keybind;
|
||||
|
||||
public UIKeybindingListItem(string bind, InputMode mode, Color color)
|
||||
{
|
||||
this._keybind = bind;
|
||||
this._inputmode = mode;
|
||||
this._color = color;
|
||||
this.OnClick += new UIElement.MouseEvent(this.OnClickMethod);
|
||||
}
|
||||
|
||||
public void OnClickMethod(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
if (!(PlayerInput.ListeningTrigger != this._keybind))
|
||||
return;
|
||||
if (PlayerInput.CurrentProfile.AllowEditting)
|
||||
PlayerInput.ListenFor(this._keybind, this._inputmode);
|
||||
else
|
||||
PlayerInput.ListenFor((string) null, this._inputmode);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
float num1 = 6f;
|
||||
base.DrawSelf(spriteBatch);
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
float num2 = dimensions.Width + 1f;
|
||||
Vector2 vector2 = new Vector2(dimensions.X, dimensions.Y);
|
||||
bool flag = PlayerInput.ListeningTrigger == this._keybind;
|
||||
Vector2 baseScale = new Vector2(0.8f);
|
||||
Color baseColor = Color.Lerp(flag ? Color.Gold : (this.IsMouseHovering ? Color.White : Color.Silver), Color.White, this.IsMouseHovering ? 0.5f : 0.0f);
|
||||
Color color = this.IsMouseHovering ? this._color : this._color.MultiplyRGBA(new Color(180, 180, 180));
|
||||
Vector2 position = vector2;
|
||||
Utils.DrawSettingsPanel(spriteBatch, position, num2, color);
|
||||
position.X += 8f;
|
||||
position.Y += 2f + num1;
|
||||
ChatManager.DrawColorCodedStringWithShadow(spriteBatch, FontAssets.ItemStack.Value, this.GetFriendlyName(), position, baseColor, 0.0f, Vector2.Zero, baseScale, num2);
|
||||
position.X -= 17f;
|
||||
string text = this.GenInput(PlayerInput.CurrentProfile.InputModes[this._inputmode].KeyStatus[this._keybind]);
|
||||
if (string.IsNullOrEmpty(text))
|
||||
{
|
||||
text = Lang.menu[195].Value;
|
||||
if (!flag)
|
||||
baseColor = new Color(80, 80, 80);
|
||||
}
|
||||
Vector2 stringSize = ChatManager.GetStringSize(FontAssets.ItemStack.Value, text, baseScale);
|
||||
position = new Vector2((float) ((double) dimensions.X + (double) dimensions.Width - (double) stringSize.X - 10.0), dimensions.Y + 2f + num1);
|
||||
if (this._inputmode == InputMode.XBoxGamepad || this._inputmode == InputMode.XBoxGamepadUI)
|
||||
position += new Vector2(0.0f, -3f);
|
||||
GlyphTagHandler.GlyphsScale = 0.85f;
|
||||
ChatManager.DrawColorCodedStringWithShadow(spriteBatch, FontAssets.ItemStack.Value, text, position, baseColor, 0.0f, Vector2.Zero, baseScale, num2);
|
||||
GlyphTagHandler.GlyphsScale = 1f;
|
||||
}
|
||||
|
||||
private string GenInput(List<string> list)
|
||||
{
|
||||
if (list.Count == 0)
|
||||
return "";
|
||||
string str = "";
|
||||
switch (this._inputmode)
|
||||
{
|
||||
case InputMode.Keyboard:
|
||||
case InputMode.KeyboardUI:
|
||||
case InputMode.Mouse:
|
||||
str = list[0];
|
||||
for (int index = 1; index < list.Count; ++index)
|
||||
str = str + "/" + list[index];
|
||||
break;
|
||||
case InputMode.XBoxGamepad:
|
||||
case InputMode.XBoxGamepadUI:
|
||||
str = GlyphTagHandler.GenerateTag(list[0]);
|
||||
for (int index = 1; index < list.Count; ++index)
|
||||
str = str + "/" + GlyphTagHandler.GenerateTag(list[index]);
|
||||
break;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
private string GetFriendlyName()
|
||||
{
|
||||
switch (this._keybind)
|
||||
{
|
||||
case "Down":
|
||||
return Lang.menu[149].Value;
|
||||
case "DpadRadial1":
|
||||
return Lang.menu[186].Value;
|
||||
case "DpadRadial2":
|
||||
return Lang.menu[187].Value;
|
||||
case "DpadRadial3":
|
||||
return Lang.menu[188].Value;
|
||||
case "DpadRadial4":
|
||||
return Lang.menu[189].Value;
|
||||
case "DpadSnap1":
|
||||
return Lang.menu[191].Value;
|
||||
case "DpadSnap2":
|
||||
return Lang.menu[192].Value;
|
||||
case "DpadSnap3":
|
||||
return Lang.menu[193].Value;
|
||||
case "DpadSnap4":
|
||||
return Lang.menu[194].Value;
|
||||
case "Grapple":
|
||||
return Lang.menu[155].Value;
|
||||
case "Hotbar1":
|
||||
return Lang.menu[176].Value;
|
||||
case "Hotbar10":
|
||||
return Lang.menu[185].Value;
|
||||
case "Hotbar2":
|
||||
return Lang.menu[177].Value;
|
||||
case "Hotbar3":
|
||||
return Lang.menu[178].Value;
|
||||
case "Hotbar4":
|
||||
return Lang.menu[179].Value;
|
||||
case "Hotbar5":
|
||||
return Lang.menu[180].Value;
|
||||
case "Hotbar6":
|
||||
return Lang.menu[181].Value;
|
||||
case "Hotbar7":
|
||||
return Lang.menu[182].Value;
|
||||
case "Hotbar8":
|
||||
return Lang.menu[183].Value;
|
||||
case "Hotbar9":
|
||||
return Lang.menu[184].Value;
|
||||
case "HotbarMinus":
|
||||
return Lang.menu[174].Value;
|
||||
case "HotbarPlus":
|
||||
return Lang.menu[175].Value;
|
||||
case "Inventory":
|
||||
return Lang.menu[154].Value;
|
||||
case "Jump":
|
||||
return Lang.menu[152].Value;
|
||||
case "Left":
|
||||
return Lang.menu[150].Value;
|
||||
case "LockOn":
|
||||
return Lang.menu[231].Value;
|
||||
case "MapAlphaDown":
|
||||
return Lang.menu[170].Value;
|
||||
case "MapAlphaUp":
|
||||
return Lang.menu[171].Value;
|
||||
case "MapFull":
|
||||
return Lang.menu[173].Value;
|
||||
case "MapStyle":
|
||||
return Lang.menu[172].Value;
|
||||
case "MapZoomIn":
|
||||
return Lang.menu[168].Value;
|
||||
case "MapZoomOut":
|
||||
return Lang.menu[169].Value;
|
||||
case "MouseLeft":
|
||||
return Lang.menu[162].Value;
|
||||
case "MouseRight":
|
||||
return Lang.menu[163].Value;
|
||||
case "QuickBuff":
|
||||
return Lang.menu[157].Value;
|
||||
case "QuickHeal":
|
||||
return Lang.menu[159].Value;
|
||||
case "QuickMana":
|
||||
return Lang.menu[156].Value;
|
||||
case "QuickMount":
|
||||
return Lang.menu[158].Value;
|
||||
case "RadialHotbar":
|
||||
return Lang.menu[190].Value;
|
||||
case "RadialQuickbar":
|
||||
return Lang.menu[244].Value;
|
||||
case "Right":
|
||||
return Lang.menu[151].Value;
|
||||
case "SmartCursor":
|
||||
return Lang.menu[161].Value;
|
||||
case "SmartSelect":
|
||||
return Lang.menu[160].Value;
|
||||
case "Throw":
|
||||
return Lang.menu[153].Value;
|
||||
case "ToggleCreativeMenu":
|
||||
return Language.GetTextValue("UI.ToggleCreativeMenu");
|
||||
case "Up":
|
||||
return Lang.menu[148].Value;
|
||||
case "ViewZoomIn":
|
||||
return Language.GetTextValue("UI.ZoomIn");
|
||||
case "ViewZoomOut":
|
||||
return Language.GetTextValue("UI.ZoomOut");
|
||||
default:
|
||||
return this._keybind;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
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.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Terraria.UI;
|
||||
using Terraria.UI.Chat;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIKeybindingSimpleListItem : UIElement
|
||||
{
|
||||
private Color _color;
|
||||
private Func<string> _GetTextFunction;
|
||||
|
||||
public UIKeybindingSimpleListItem(Func<string> getText, Color color)
|
||||
{
|
||||
this._color = color;
|
||||
this._GetTextFunction = getText != null ? getText : (Func<string>) (() => "???");
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
float num1 = 6f;
|
||||
base.DrawSelf(spriteBatch);
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
float num2 = dimensions.Width + 1f;
|
||||
Vector2 vector2 = new Vector2(dimensions.X, dimensions.Y);
|
||||
Vector2 baseScale = new Vector2(0.8f);
|
||||
Color baseColor = Color.Lerp(this.IsMouseHovering ? Color.White : Color.Silver, Color.White, this.IsMouseHovering ? 0.5f : 0.0f);
|
||||
Color color = this.IsMouseHovering ? this._color : this._color.MultiplyRGBA(new Color(180, 180, 180));
|
||||
Vector2 position = vector2;
|
||||
Utils.DrawSettings2Panel(spriteBatch, position, num2, color);
|
||||
position.X += 8f;
|
||||
position.Y += 2f + num1;
|
||||
string text = this._GetTextFunction();
|
||||
Vector2 stringSize = ChatManager.GetStringSize(FontAssets.ItemStack.Value, text, baseScale);
|
||||
position.X = (float) ((double) dimensions.X + (double) dimensions.Width / 2.0 - (double) stringSize.X / 2.0);
|
||||
ChatManager.DrawColorCodedStringWithShadow(spriteBatch, FontAssets.ItemStack.Value, text, position, baseColor, 0.0f, Vector2.Zero, baseScale, num2);
|
||||
}
|
||||
}
|
||||
}
|
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.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using System;
|
||||
using Terraria.GameInput;
|
||||
using Terraria.UI;
|
||||
using Terraria.UI.Chat;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIKeybindingSliderItem : UIElement
|
||||
{
|
||||
private Color _color;
|
||||
private Func<string> _TextDisplayFunction;
|
||||
private Func<float> _GetStatusFunction;
|
||||
private Action<float> _SlideKeyboardAction;
|
||||
private Action _SlideGamepadAction;
|
||||
private int _sliderIDInPage;
|
||||
private Asset<Texture2D> _toggleTexture;
|
||||
|
||||
public UIKeybindingSliderItem(
|
||||
Func<string> getText,
|
||||
Func<float> getStatus,
|
||||
Action<float> setStatusKeyboard,
|
||||
Action setStatusGamepad,
|
||||
int sliderIDInPage,
|
||||
Color color)
|
||||
{
|
||||
this._color = color;
|
||||
this._toggleTexture = Main.Assets.Request<Texture2D>("Images/UI/Settings_Toggle", (AssetRequestMode) 1);
|
||||
this._TextDisplayFunction = getText != null ? getText : (Func<string>) (() => "???");
|
||||
this._GetStatusFunction = getStatus != null ? getStatus : (Func<float>) (() => 0.0f);
|
||||
this._SlideKeyboardAction = setStatusKeyboard != null ? setStatusKeyboard : (Action<float>) (s => { });
|
||||
this._SlideGamepadAction = setStatusGamepad != null ? setStatusGamepad : (Action) (() => { });
|
||||
this._sliderIDInPage = sliderIDInPage;
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
float num1 = 6f;
|
||||
base.DrawSelf(spriteBatch);
|
||||
int lockState = 0;
|
||||
IngameOptions.rightHover = -1;
|
||||
if (!Main.mouseLeft)
|
||||
IngameOptions.rightLock = -1;
|
||||
if (IngameOptions.rightLock == this._sliderIDInPage)
|
||||
lockState = 1;
|
||||
else if (IngameOptions.rightLock != -1)
|
||||
lockState = 2;
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
float num2 = dimensions.Width + 1f;
|
||||
Vector2 vector2 = new Vector2(dimensions.X, dimensions.Y);
|
||||
bool flag = this.IsMouseHovering;
|
||||
if (lockState == 1)
|
||||
flag = true;
|
||||
if (lockState == 2)
|
||||
flag = false;
|
||||
Vector2 baseScale = new Vector2(0.8f);
|
||||
Color baseColor = Color.Lerp(false ? Color.Gold : (flag ? Color.White : Color.Silver), Color.White, flag ? 0.5f : 0.0f);
|
||||
Color color = flag ? this._color : this._color.MultiplyRGBA(new Color(180, 180, 180));
|
||||
Vector2 position = vector2;
|
||||
Utils.DrawSettingsPanel(spriteBatch, position, num2, color);
|
||||
position.X += 8f;
|
||||
position.Y += 2f + num1;
|
||||
ChatManager.DrawColorCodedStringWithShadow(spriteBatch, FontAssets.ItemStack.Value, this._TextDisplayFunction(), position, baseColor, 0.0f, Vector2.Zero, baseScale, num2);
|
||||
position.X -= 17f;
|
||||
TextureAssets.ColorBar.Frame();
|
||||
position = new Vector2((float) ((double) dimensions.X + (double) dimensions.Width - 10.0), dimensions.Y + 10f + num1);
|
||||
IngameOptions.valuePosition = position;
|
||||
float num3 = IngameOptions.DrawValueBar(spriteBatch, 1f, this._GetStatusFunction(), lockState);
|
||||
if (IngameOptions.inBar || IngameOptions.rightLock == this._sliderIDInPage)
|
||||
{
|
||||
IngameOptions.rightHover = this._sliderIDInPage;
|
||||
if (PlayerInput.Triggers.Current.MouseLeft && PlayerInput.CurrentProfile.AllowEditting && !PlayerInput.UsingGamepad && IngameOptions.rightLock == this._sliderIDInPage)
|
||||
this._SlideKeyboardAction(num3);
|
||||
}
|
||||
if (IngameOptions.rightHover != -1 && IngameOptions.rightLock == -1)
|
||||
IngameOptions.rightLock = IngameOptions.rightHover;
|
||||
if (!this.IsMouseHovering || !PlayerInput.CurrentProfile.AllowEditting)
|
||||
return;
|
||||
this._SlideGamepadAction();
|
||||
}
|
||||
}
|
||||
}
|
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.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using System;
|
||||
using Terraria.UI;
|
||||
using Terraria.UI.Chat;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIKeybindingToggleListItem : UIElement
|
||||
{
|
||||
private Color _color;
|
||||
private Func<string> _TextDisplayFunction;
|
||||
private Func<bool> _IsOnFunction;
|
||||
private Asset<Texture2D> _toggleTexture;
|
||||
|
||||
public UIKeybindingToggleListItem(Func<string> getText, Func<bool> getStatus, Color color)
|
||||
{
|
||||
this._color = color;
|
||||
this._toggleTexture = Main.Assets.Request<Texture2D>("Images/UI/Settings_Toggle", (AssetRequestMode) 1);
|
||||
this._TextDisplayFunction = getText != null ? getText : (Func<string>) (() => "???");
|
||||
this._IsOnFunction = getStatus != null ? getStatus : (Func<bool>) (() => false);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
float num1 = 6f;
|
||||
base.DrawSelf(spriteBatch);
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
float num2 = dimensions.Width + 1f;
|
||||
Vector2 vector2_1 = new Vector2(dimensions.X, dimensions.Y);
|
||||
Vector2 baseScale = new Vector2(0.8f);
|
||||
Color baseColor = Color.Lerp(false ? Color.Gold : (this.IsMouseHovering ? Color.White : Color.Silver), Color.White, this.IsMouseHovering ? 0.5f : 0.0f);
|
||||
Color color = this.IsMouseHovering ? this._color : this._color.MultiplyRGBA(new Color(180, 180, 180));
|
||||
Vector2 position = vector2_1;
|
||||
Utils.DrawSettingsPanel(spriteBatch, position, num2, color);
|
||||
position.X += 8f;
|
||||
position.Y += 2f + num1;
|
||||
ChatManager.DrawColorCodedStringWithShadow(spriteBatch, FontAssets.ItemStack.Value, this._TextDisplayFunction(), position, baseColor, 0.0f, Vector2.Zero, baseScale, num2);
|
||||
position.X -= 17f;
|
||||
Rectangle rectangle = new Rectangle(this._IsOnFunction() ? (this._toggleTexture.Width() - 2) / 2 + 2 : 0, 0, (this._toggleTexture.Width() - 2) / 2, this._toggleTexture.Height());
|
||||
Vector2 vector2_2 = new Vector2((float) rectangle.Width, 0.0f);
|
||||
position = new Vector2((float) ((double) dimensions.X + (double) dimensions.Width - (double) vector2_2.X - 10.0), dimensions.Y + 2f + num1);
|
||||
spriteBatch.Draw(this._toggleTexture.Value, position, new Rectangle?(rectangle), Color.White, 0.0f, Vector2.Zero, Vector2.One, SpriteEffects.None, 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
168
GameContent/UI/Elements/UIList.cs
Normal file
168
GameContent/UI/Elements/UIList.cs
Normal file
|
@ -0,0 +1,168 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIList
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIList : UIElement, IEnumerable<UIElement>, IEnumerable
|
||||
{
|
||||
protected List<UIElement> _items = new List<UIElement>();
|
||||
protected UIScrollbar _scrollbar;
|
||||
private UIElement _innerList = (UIElement) new UIList.UIInnerList();
|
||||
private float _innerListHeight;
|
||||
public float ListPadding = 5f;
|
||||
public Action<List<UIElement>> ManualSortMethod;
|
||||
|
||||
public int Count => this._items.Count;
|
||||
|
||||
public UIList()
|
||||
{
|
||||
this._innerList.OverflowHidden = false;
|
||||
this._innerList.Width.Set(0.0f, 1f);
|
||||
this._innerList.Height.Set(0.0f, 1f);
|
||||
this.OverflowHidden = true;
|
||||
this.Append(this._innerList);
|
||||
}
|
||||
|
||||
public float GetTotalHeight() => this._innerListHeight;
|
||||
|
||||
public void Goto(UIList.ElementSearchMethod searchMethod)
|
||||
{
|
||||
for (int index = 0; index < this._items.Count; ++index)
|
||||
{
|
||||
if (searchMethod(this._items[index]))
|
||||
{
|
||||
this._scrollbar.ViewPosition = this._items[index].Top.Pixels;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Add(UIElement item)
|
||||
{
|
||||
this._items.Add(item);
|
||||
this._innerList.Append(item);
|
||||
this.UpdateOrder();
|
||||
this._innerList.Recalculate();
|
||||
}
|
||||
|
||||
public virtual bool Remove(UIElement item)
|
||||
{
|
||||
this._innerList.RemoveChild(item);
|
||||
this.UpdateOrder();
|
||||
return this._items.Remove(item);
|
||||
}
|
||||
|
||||
public virtual void Clear()
|
||||
{
|
||||
this._innerList.RemoveAllChildren();
|
||||
this._items.Clear();
|
||||
}
|
||||
|
||||
public override void Recalculate()
|
||||
{
|
||||
base.Recalculate();
|
||||
this.UpdateScrollbar();
|
||||
}
|
||||
|
||||
public override void ScrollWheel(UIScrollWheelEvent evt)
|
||||
{
|
||||
base.ScrollWheel(evt);
|
||||
if (this._scrollbar == null)
|
||||
return;
|
||||
this._scrollbar.ViewPosition -= (float) evt.ScrollWheelValue;
|
||||
}
|
||||
|
||||
public override void RecalculateChildren()
|
||||
{
|
||||
base.RecalculateChildren();
|
||||
float pixels = 0.0f;
|
||||
for (int index = 0; index < this._items.Count; ++index)
|
||||
{
|
||||
float num = this._items.Count == 1 ? 0.0f : this.ListPadding;
|
||||
this._items[index].Top.Set(pixels, 0.0f);
|
||||
this._items[index].Recalculate();
|
||||
CalculatedStyle outerDimensions = this._items[index].GetOuterDimensions();
|
||||
pixels += outerDimensions.Height + num;
|
||||
}
|
||||
this._innerListHeight = pixels;
|
||||
}
|
||||
|
||||
private void UpdateScrollbar()
|
||||
{
|
||||
if (this._scrollbar == null)
|
||||
return;
|
||||
this._scrollbar.SetView(this.GetInnerDimensions().Height, this._innerListHeight);
|
||||
}
|
||||
|
||||
public void SetScrollbar(UIScrollbar scrollbar)
|
||||
{
|
||||
this._scrollbar = scrollbar;
|
||||
this.UpdateScrollbar();
|
||||
}
|
||||
|
||||
public void UpdateOrder()
|
||||
{
|
||||
if (this.ManualSortMethod != null)
|
||||
this.ManualSortMethod(this._items);
|
||||
else
|
||||
this._items.Sort(new Comparison<UIElement>(this.SortMethod));
|
||||
this.UpdateScrollbar();
|
||||
}
|
||||
|
||||
public int SortMethod(UIElement item1, UIElement item2) => item1.CompareTo((object) item2);
|
||||
|
||||
public override List<SnapPoint> GetSnapPoints()
|
||||
{
|
||||
List<SnapPoint> snapPointList = new List<SnapPoint>();
|
||||
SnapPoint point;
|
||||
if (this.GetSnapPoint(out point))
|
||||
snapPointList.Add(point);
|
||||
foreach (UIElement uiElement in this._items)
|
||||
snapPointList.AddRange((IEnumerable<SnapPoint>) uiElement.GetSnapPoints());
|
||||
return snapPointList;
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
if (this._scrollbar != null)
|
||||
this._innerList.Top.Set(-this._scrollbar.GetValue(), 0.0f);
|
||||
this.Recalculate();
|
||||
}
|
||||
|
||||
public IEnumerator<UIElement> GetEnumerator() => ((IEnumerable<UIElement>) this._items).GetEnumerator();
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator() => (IEnumerator) ((IEnumerable<UIElement>) this._items).GetEnumerator();
|
||||
|
||||
public delegate bool ElementSearchMethod(UIElement element);
|
||||
|
||||
private class UIInnerList : UIElement
|
||||
{
|
||||
public override bool ContainsPoint(Vector2 point) => true;
|
||||
|
||||
protected override void DrawChildren(SpriteBatch spriteBatch)
|
||||
{
|
||||
Vector2 position1 = this.Parent.GetDimensions().Position();
|
||||
Vector2 dimensions1 = new Vector2(this.Parent.GetDimensions().Width, this.Parent.GetDimensions().Height);
|
||||
foreach (UIElement element in this.Elements)
|
||||
{
|
||||
Vector2 position2 = element.GetDimensions().Position();
|
||||
Vector2 dimensions2 = new Vector2(element.GetDimensions().Width, element.GetDimensions().Height);
|
||||
if (Collision.CheckAABBvAABBCollision(position1, dimensions1, position2, dimensions2))
|
||||
element.Draw(spriteBatch);
|
||||
}
|
||||
}
|
||||
|
||||
public override Rectangle GetViewCullingArea() => this.Parent.GetDimensions().ToRectangle();
|
||||
}
|
||||
}
|
||||
}
|
74
GameContent/UI/Elements/UIPanel.cs
Normal file
74
GameContent/UI/Elements/UIPanel.cs
Normal file
|
@ -0,0 +1,74 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIPanel
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIPanel : UIElement
|
||||
{
|
||||
private int _cornerSize = 12;
|
||||
private int _barSize = 4;
|
||||
private Asset<Texture2D> _borderTexture;
|
||||
private Asset<Texture2D> _backgroundTexture;
|
||||
public Color BorderColor = Color.Black;
|
||||
public Color BackgroundColor = new Color(63, 82, 151) * 0.7f;
|
||||
|
||||
public UIPanel()
|
||||
{
|
||||
if (this._borderTexture == null)
|
||||
this._borderTexture = Main.Assets.Request<Texture2D>("Images/UI/PanelBorder", (AssetRequestMode) 1);
|
||||
if (this._backgroundTexture == null)
|
||||
this._backgroundTexture = Main.Assets.Request<Texture2D>("Images/UI/PanelBackground", (AssetRequestMode) 1);
|
||||
this.SetPadding((float) this._cornerSize);
|
||||
}
|
||||
|
||||
public UIPanel(
|
||||
Asset<Texture2D> customBackground,
|
||||
Asset<Texture2D> customborder,
|
||||
int customCornerSize = 12,
|
||||
int customBarSize = 4)
|
||||
{
|
||||
if (this._borderTexture == null)
|
||||
this._borderTexture = customborder;
|
||||
if (this._backgroundTexture == null)
|
||||
this._backgroundTexture = customBackground;
|
||||
this._cornerSize = customCornerSize;
|
||||
this._barSize = customBarSize;
|
||||
this.SetPadding((float) this._cornerSize);
|
||||
}
|
||||
|
||||
private void DrawPanel(SpriteBatch spriteBatch, Texture2D texture, Color color)
|
||||
{
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
Point point1 = new Point((int) dimensions.X, (int) dimensions.Y);
|
||||
Point point2 = new Point(point1.X + (int) dimensions.Width - this._cornerSize, point1.Y + (int) dimensions.Height - this._cornerSize);
|
||||
int width = point2.X - point1.X - this._cornerSize;
|
||||
int height = point2.Y - point1.Y - this._cornerSize;
|
||||
spriteBatch.Draw(texture, new Rectangle(point1.X, point1.Y, this._cornerSize, this._cornerSize), new Rectangle?(new Rectangle(0, 0, this._cornerSize, this._cornerSize)), color);
|
||||
spriteBatch.Draw(texture, new Rectangle(point2.X, point1.Y, this._cornerSize, this._cornerSize), new Rectangle?(new Rectangle(this._cornerSize + this._barSize, 0, this._cornerSize, this._cornerSize)), color);
|
||||
spriteBatch.Draw(texture, new Rectangle(point1.X, point2.Y, this._cornerSize, this._cornerSize), new Rectangle?(new Rectangle(0, this._cornerSize + this._barSize, this._cornerSize, this._cornerSize)), color);
|
||||
spriteBatch.Draw(texture, new Rectangle(point2.X, point2.Y, this._cornerSize, this._cornerSize), new Rectangle?(new Rectangle(this._cornerSize + this._barSize, this._cornerSize + this._barSize, this._cornerSize, this._cornerSize)), color);
|
||||
spriteBatch.Draw(texture, new Rectangle(point1.X + this._cornerSize, point1.Y, width, this._cornerSize), new Rectangle?(new Rectangle(this._cornerSize, 0, this._barSize, this._cornerSize)), color);
|
||||
spriteBatch.Draw(texture, new Rectangle(point1.X + this._cornerSize, point2.Y, width, this._cornerSize), new Rectangle?(new Rectangle(this._cornerSize, this._cornerSize + this._barSize, this._barSize, this._cornerSize)), color);
|
||||
spriteBatch.Draw(texture, new Rectangle(point1.X, point1.Y + this._cornerSize, this._cornerSize, height), new Rectangle?(new Rectangle(0, this._cornerSize, this._cornerSize, this._barSize)), color);
|
||||
spriteBatch.Draw(texture, new Rectangle(point2.X, point1.Y + this._cornerSize, this._cornerSize, height), new Rectangle?(new Rectangle(this._cornerSize + this._barSize, this._cornerSize, this._cornerSize, this._barSize)), color);
|
||||
spriteBatch.Draw(texture, new Rectangle(point1.X + this._cornerSize, point1.Y + this._cornerSize, width, height), new Rectangle?(new Rectangle(this._cornerSize, this._cornerSize, this._barSize, this._barSize)), color);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
if (this._backgroundTexture != null)
|
||||
this.DrawPanel(spriteBatch, this._backgroundTexture.Value, this.BackgroundColor);
|
||||
if (this._borderTexture == null)
|
||||
return;
|
||||
this.DrawPanel(spriteBatch, this._borderTexture.Value, this.BorderColor);
|
||||
}
|
||||
}
|
||||
}
|
40
GameContent/UI/Elements/UIParticleLayer.cs
Normal file
40
GameContent/UI/Elements/UIParticleLayer.cs
Normal file
|
@ -0,0 +1,40 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIParticleLayer
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria.Graphics.Renderers;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIParticleLayer : UIElement
|
||||
{
|
||||
public ParticleRenderer ParticleSystem;
|
||||
public Vector2 AnchorPositionOffsetByPercents;
|
||||
public Vector2 AnchorPositionOffsetByPixels;
|
||||
|
||||
public UIParticleLayer()
|
||||
{
|
||||
this.IgnoresMouseInteraction = true;
|
||||
this.ParticleSystem = new ParticleRenderer();
|
||||
this.OnUpdate += new UIElement.ElementEvent(this.ParticleSystemUpdate);
|
||||
}
|
||||
|
||||
private void ParticleSystemUpdate(UIElement affectedElement) => this.ParticleSystem.Update();
|
||||
|
||||
public override void Recalculate()
|
||||
{
|
||||
base.Recalculate();
|
||||
Rectangle rectangle = this.GetDimensions().ToRectangle();
|
||||
this.ParticleSystem.Settings.AnchorPosition = rectangle.TopLeft() + this.AnchorPositionOffsetByPercents * rectangle.Size() + this.AnchorPositionOffsetByPixels;
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch) => this.ParticleSystem.Draw(spriteBatch);
|
||||
|
||||
public void AddParticle(IParticle particle) => this.ParticleSystem.Add(particle);
|
||||
}
|
||||
}
|
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.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIProgressBar : UIElement
|
||||
{
|
||||
private UIProgressBar.UIInnerProgressBar _progressBar = new UIProgressBar.UIInnerProgressBar();
|
||||
private float _visualProgress;
|
||||
private float _targetProgress;
|
||||
|
||||
public UIProgressBar()
|
||||
{
|
||||
this._progressBar.Height.Precent = 1f;
|
||||
this._progressBar.Recalculate();
|
||||
this.Append((UIElement) this._progressBar);
|
||||
}
|
||||
|
||||
public void SetProgress(float value)
|
||||
{
|
||||
this._targetProgress = value;
|
||||
if ((double) value >= (double) this._visualProgress)
|
||||
return;
|
||||
this._visualProgress = value;
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
this._visualProgress = (float) ((double) this._visualProgress * 0.949999988079071 + 0.0500000007450581 * (double) this._targetProgress);
|
||||
this._progressBar.Width.Precent = this._visualProgress;
|
||||
this._progressBar.Recalculate();
|
||||
}
|
||||
|
||||
private class UIInnerProgressBar : UIElement
|
||||
{
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
spriteBatch.Draw(TextureAssets.MagicPixel.Value, new Vector2(dimensions.X, dimensions.Y), new Rectangle?(), Color.Blue, 0.0f, Vector2.Zero, new Vector2(dimensions.Width, dimensions.Height / 1000f), SpriteEffects.None, 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
119
GameContent/UI/Elements/UIResourcePack.cs
Normal file
119
GameContent/UI/Elements/UIResourcePack.cs
Normal file
|
@ -0,0 +1,119 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIResourcePack
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria.IO;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIResourcePack : UIPanel
|
||||
{
|
||||
private const int PANEL_PADDING = 5;
|
||||
private const int ICON_SIZE = 64;
|
||||
private const int ICON_BORDER_PADDING = 4;
|
||||
private const int HEIGHT_FLUFF = 10;
|
||||
private const float HEIGHT = 102f;
|
||||
private const float MIN_WIDTH = 102f;
|
||||
private static readonly Color DefaultBackgroundColor = new Color(26, 40, 89) * 0.8f;
|
||||
private static readonly Color DefaultBorderColor = new Color(13, 20, 44) * 0.8f;
|
||||
private static readonly Color HoverBackgroundColor = new Color(46, 60, 119);
|
||||
private static readonly Color HoverBorderColor = new Color(20, 30, 56);
|
||||
public readonly ResourcePack ResourcePack;
|
||||
private readonly Asset<Texture2D> _iconBorderTexture;
|
||||
|
||||
public int Order { get; set; }
|
||||
|
||||
public UIElement ContentPanel { get; private set; }
|
||||
|
||||
public UIResourcePack(ResourcePack pack, int order)
|
||||
{
|
||||
this.ResourcePack = pack;
|
||||
this.Order = order;
|
||||
this.BackgroundColor = UIResourcePack.DefaultBackgroundColor;
|
||||
this.BorderColor = UIResourcePack.DefaultBorderColor;
|
||||
this.Height = StyleDimension.FromPixels(102f);
|
||||
this.MinHeight = this.Height;
|
||||
this.MaxHeight = this.Height;
|
||||
this.MinWidth = StyleDimension.FromPixels(102f);
|
||||
this.Width = StyleDimension.FromPercent(1f);
|
||||
this.SetPadding(5f);
|
||||
this._iconBorderTexture = Main.Assets.Request<Texture2D>("Images/UI/Achievement_Borders", (AssetRequestMode) 1);
|
||||
this.OverflowHidden = true;
|
||||
this.BuildChildren();
|
||||
}
|
||||
|
||||
private void BuildChildren()
|
||||
{
|
||||
StyleDimension styleDimension1 = StyleDimension.FromPixels(77f);
|
||||
StyleDimension styleDimension2 = StyleDimension.FromPixels(4f);
|
||||
UIText uiText1 = new UIText(this.ResourcePack.Name);
|
||||
uiText1.Left = styleDimension1;
|
||||
uiText1.Top = styleDimension2;
|
||||
UIText uiText2 = uiText1;
|
||||
this.Append((UIElement) uiText2);
|
||||
styleDimension2.Pixels += uiText2.GetOuterDimensions().Height + 6f;
|
||||
UIText uiText3 = new UIText(Language.GetTextValue("UI.Author", (object) this.ResourcePack.Author), 0.7f);
|
||||
uiText3.Left = styleDimension1;
|
||||
uiText3.Top = styleDimension2;
|
||||
UIText uiText4 = uiText3;
|
||||
this.Append((UIElement) uiText4);
|
||||
styleDimension2.Pixels += uiText4.GetOuterDimensions().Height + 10f;
|
||||
Asset<Texture2D> asset = Main.Assets.Request<Texture2D>("Images/UI/Divider", (AssetRequestMode) 1);
|
||||
UIImage uiImage1 = new UIImage(asset);
|
||||
uiImage1.Left = StyleDimension.FromPixels(72f);
|
||||
uiImage1.Top = styleDimension2;
|
||||
uiImage1.Height = StyleDimension.FromPixels((float) asset.Height());
|
||||
uiImage1.Width = StyleDimension.FromPixelsAndPercent(-80f, 1f);
|
||||
uiImage1.ScaleToFit = true;
|
||||
UIImage uiImage2 = uiImage1;
|
||||
this.Recalculate();
|
||||
this.Append((UIElement) uiImage2);
|
||||
styleDimension2.Pixels += uiImage2.GetOuterDimensions().Height + 5f;
|
||||
UIElement element = new UIElement()
|
||||
{
|
||||
Left = styleDimension1,
|
||||
Top = styleDimension2,
|
||||
Height = StyleDimension.FromPixels(92f - styleDimension2.Pixels),
|
||||
Width = StyleDimension.FromPixelsAndPercent(-styleDimension1.Pixels, 1f)
|
||||
};
|
||||
this.Append(element);
|
||||
this.ContentPanel = element;
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
base.DrawSelf(spriteBatch);
|
||||
this.DrawIcon(spriteBatch);
|
||||
}
|
||||
|
||||
private void DrawIcon(SpriteBatch spriteBatch)
|
||||
{
|
||||
CalculatedStyle innerDimensions = this.GetInnerDimensions();
|
||||
spriteBatch.Draw(this.ResourcePack.Icon, new Rectangle((int) innerDimensions.X + 4, (int) innerDimensions.Y + 4 + 10, 64, 64), Color.White);
|
||||
spriteBatch.Draw(this._iconBorderTexture.Value, new Rectangle((int) innerDimensions.X, (int) innerDimensions.Y + 10, 72, 72), Color.White);
|
||||
}
|
||||
|
||||
public override int CompareTo(object obj) => this.Order.CompareTo(((UIResourcePack) obj).Order);
|
||||
|
||||
public override void MouseOver(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseOver(evt);
|
||||
this.BackgroundColor = UIResourcePack.HoverBackgroundColor;
|
||||
this.BorderColor = UIResourcePack.HoverBorderColor;
|
||||
}
|
||||
|
||||
public override void MouseOut(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseOut(evt);
|
||||
this.BackgroundColor = UIResourcePack.DefaultBackgroundColor;
|
||||
this.BorderColor = UIResourcePack.DefaultBorderColor;
|
||||
}
|
||||
}
|
||||
}
|
48
GameContent/UI/Elements/UIResourcePackInfoButton`1.cs
Normal file
48
GameContent/UI/Elements/UIResourcePackInfoButton`1.cs
Normal file
|
@ -0,0 +1,48 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIResourcePackInfoButton`1
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria.IO;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIResourcePackInfoButton<T> : UITextPanel<T>
|
||||
{
|
||||
private readonly Asset<Texture2D> _BasePanelTexture;
|
||||
private readonly Asset<Texture2D> _hoveredBorderTexture;
|
||||
private ResourcePack _resourcePack;
|
||||
|
||||
public ResourcePack ResourcePack
|
||||
{
|
||||
get => this._resourcePack;
|
||||
set => this._resourcePack = value;
|
||||
}
|
||||
|
||||
public UIResourcePackInfoButton(T text, float textScale = 1f, bool large = false)
|
||||
: base(text, textScale, large)
|
||||
{
|
||||
this._BasePanelTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/PanelGrayscale", (AssetRequestMode) 1);
|
||||
this._hoveredBorderTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/CategoryPanelBorder", (AssetRequestMode) 1);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
if (this._drawPanel)
|
||||
{
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
int num1 = 10;
|
||||
int num2 = 10;
|
||||
Utils.DrawSplicedPanel(spriteBatch, this._BasePanelTexture.Value, (int) dimensions.X, (int) dimensions.Y, (int) dimensions.Width, (int) dimensions.Height, num1, num1, num2, num2, Color.Lerp(Color.Black, this._color, 0.8f) * 0.5f);
|
||||
if (this.IsMouseHovering)
|
||||
Utils.DrawSplicedPanel(spriteBatch, this._hoveredBorderTexture.Value, (int) dimensions.X, (int) dimensions.Y, (int) dimensions.Width, (int) dimensions.Height, num1, num1, num2, num2, Color.White);
|
||||
}
|
||||
this.DrawText(spriteBatch);
|
||||
}
|
||||
}
|
||||
}
|
116
GameContent/UI/Elements/UIScrollbar.cs
Normal file
116
GameContent/UI/Elements/UIScrollbar.cs
Normal file
|
@ -0,0 +1,116 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIScrollbar
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria.Audio;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIScrollbar : UIElement
|
||||
{
|
||||
private float _viewPosition;
|
||||
private float _viewSize = 1f;
|
||||
private float _maxViewSize = 20f;
|
||||
private bool _isDragging;
|
||||
private bool _isHoveringOverHandle;
|
||||
private float _dragYOffset;
|
||||
private Asset<Texture2D> _texture;
|
||||
private Asset<Texture2D> _innerTexture;
|
||||
|
||||
public float ViewPosition
|
||||
{
|
||||
get => this._viewPosition;
|
||||
set => this._viewPosition = MathHelper.Clamp(value, 0.0f, this._maxViewSize - this._viewSize);
|
||||
}
|
||||
|
||||
public bool CanScroll => (double) this._maxViewSize != (double) this._viewSize;
|
||||
|
||||
public UIScrollbar()
|
||||
{
|
||||
this.Width.Set(20f, 0.0f);
|
||||
this.MaxWidth.Set(20f, 0.0f);
|
||||
this._texture = Main.Assets.Request<Texture2D>("Images/UI/Scrollbar", (AssetRequestMode) 1);
|
||||
this._innerTexture = Main.Assets.Request<Texture2D>("Images/UI/ScrollbarInner", (AssetRequestMode) 1);
|
||||
this.PaddingTop = 5f;
|
||||
this.PaddingBottom = 5f;
|
||||
}
|
||||
|
||||
public void SetView(float viewSize, float maxViewSize)
|
||||
{
|
||||
viewSize = MathHelper.Clamp(viewSize, 0.0f, maxViewSize);
|
||||
this._viewPosition = MathHelper.Clamp(this._viewPosition, 0.0f, maxViewSize - viewSize);
|
||||
this._viewSize = viewSize;
|
||||
this._maxViewSize = maxViewSize;
|
||||
}
|
||||
|
||||
public float GetValue() => this._viewPosition;
|
||||
|
||||
private Rectangle GetHandleRectangle()
|
||||
{
|
||||
CalculatedStyle innerDimensions = this.GetInnerDimensions();
|
||||
if ((double) this._maxViewSize == 0.0 && (double) this._viewSize == 0.0)
|
||||
{
|
||||
this._viewSize = 1f;
|
||||
this._maxViewSize = 1f;
|
||||
}
|
||||
return new Rectangle((int) innerDimensions.X, (int) ((double) innerDimensions.Y + (double) innerDimensions.Height * ((double) this._viewPosition / (double) this._maxViewSize)) - 3, 20, (int) ((double) innerDimensions.Height * ((double) this._viewSize / (double) this._maxViewSize)) + 7);
|
||||
}
|
||||
|
||||
private void DrawBar(
|
||||
SpriteBatch spriteBatch,
|
||||
Texture2D texture,
|
||||
Rectangle dimensions,
|
||||
Color color)
|
||||
{
|
||||
spriteBatch.Draw(texture, new Rectangle(dimensions.X, dimensions.Y - 6, dimensions.Width, 6), new Rectangle?(new Rectangle(0, 0, texture.Width, 6)), color);
|
||||
spriteBatch.Draw(texture, new Rectangle(dimensions.X, dimensions.Y, dimensions.Width, dimensions.Height), new Rectangle?(new Rectangle(0, 6, texture.Width, 4)), color);
|
||||
spriteBatch.Draw(texture, new Rectangle(dimensions.X, dimensions.Y + dimensions.Height, dimensions.Width, 6), new Rectangle?(new Rectangle(0, texture.Height - 6, texture.Width, 6)), color);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
CalculatedStyle innerDimensions = this.GetInnerDimensions();
|
||||
if (this._isDragging)
|
||||
this._viewPosition = MathHelper.Clamp((UserInterface.ActiveInstance.MousePosition.Y - innerDimensions.Y - this._dragYOffset) / innerDimensions.Height * this._maxViewSize, 0.0f, this._maxViewSize - this._viewSize);
|
||||
Rectangle handleRectangle = this.GetHandleRectangle();
|
||||
Vector2 mousePosition = UserInterface.ActiveInstance.MousePosition;
|
||||
int num = this._isHoveringOverHandle ? 1 : 0;
|
||||
this._isHoveringOverHandle = handleRectangle.Contains(new Point((int) mousePosition.X, (int) mousePosition.Y));
|
||||
if (num == 0 && this._isHoveringOverHandle && Main.hasFocus)
|
||||
SoundEngine.PlaySound(12);
|
||||
this.DrawBar(spriteBatch, this._texture.Value, dimensions.ToRectangle(), Color.White);
|
||||
this.DrawBar(spriteBatch, this._innerTexture.Value, handleRectangle, Color.White * (this._isDragging || this._isHoveringOverHandle ? 1f : 0.85f));
|
||||
}
|
||||
|
||||
public override void MouseDown(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseDown(evt);
|
||||
if (evt.Target != this)
|
||||
return;
|
||||
Rectangle handleRectangle = this.GetHandleRectangle();
|
||||
if (handleRectangle.Contains(new Point((int) evt.MousePosition.X, (int) evt.MousePosition.Y)))
|
||||
{
|
||||
this._isDragging = true;
|
||||
this._dragYOffset = evt.MousePosition.Y - (float) handleRectangle.Y;
|
||||
}
|
||||
else
|
||||
{
|
||||
CalculatedStyle innerDimensions = this.GetInnerDimensions();
|
||||
this._viewPosition = MathHelper.Clamp((UserInterface.ActiveInstance.MousePosition.Y - innerDimensions.Y - (float) (handleRectangle.Height >> 1)) / innerDimensions.Height * this._maxViewSize, 0.0f, this._maxViewSize - this._viewSize);
|
||||
}
|
||||
}
|
||||
|
||||
public override void MouseUp(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseUp(evt);
|
||||
this._isDragging = false;
|
||||
}
|
||||
}
|
||||
}
|
170
GameContent/UI/Elements/UISearchBar.cs
Normal file
170
GameContent/UI/Elements/UISearchBar.cs
Normal file
|
@ -0,0 +1,170 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UISearchBar
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Terraria.Audio;
|
||||
using Terraria.GameInput;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UISearchBar : UIElement
|
||||
{
|
||||
private readonly LocalizedText _textToShowWhenEmpty;
|
||||
private UITextBox _text;
|
||||
private string actualContents;
|
||||
private float _textScale;
|
||||
private bool isWritingText;
|
||||
|
||||
public event Action<string> OnContentsChanged;
|
||||
|
||||
public event Action OnStartTakingInput;
|
||||
|
||||
public event Action OnEndTakingInput;
|
||||
|
||||
public event Action OnCancledTakingInput;
|
||||
|
||||
public event Action OnNeedingVirtualKeyboard;
|
||||
|
||||
public UISearchBar(LocalizedText emptyContentText, float scale)
|
||||
{
|
||||
this._textToShowWhenEmpty = emptyContentText;
|
||||
this._textScale = scale;
|
||||
UITextBox uiTextBox1 = new UITextBox("", scale);
|
||||
uiTextBox1.HAlign = 0.0f;
|
||||
uiTextBox1.VAlign = 0.5f;
|
||||
uiTextBox1.BackgroundColor = Color.Transparent;
|
||||
uiTextBox1.BorderColor = Color.Transparent;
|
||||
uiTextBox1.Width = new StyleDimension(0.0f, 1f);
|
||||
uiTextBox1.Height = new StyleDimension(0.0f, 1f);
|
||||
uiTextBox1.TextHAlign = 0.0f;
|
||||
uiTextBox1.ShowInputTicker = false;
|
||||
UITextBox uiTextBox2 = uiTextBox1;
|
||||
this.Append((UIElement) uiTextBox2);
|
||||
this._text = uiTextBox2;
|
||||
}
|
||||
|
||||
public void SetContents(string contents, bool forced = false)
|
||||
{
|
||||
if (this.actualContents == contents && !forced)
|
||||
return;
|
||||
this.actualContents = contents;
|
||||
if (string.IsNullOrEmpty(this.actualContents))
|
||||
{
|
||||
this._text.TextColor = Color.Gray;
|
||||
this._text.SetText(this._textToShowWhenEmpty.Value, this._textScale, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._text.TextColor = Color.White;
|
||||
this._text.SetText(this.actualContents);
|
||||
}
|
||||
this.TrimDisplayIfOverElementDimensions(0);
|
||||
if (this.OnContentsChanged == null)
|
||||
return;
|
||||
this.OnContentsChanged(contents);
|
||||
}
|
||||
|
||||
public void TrimDisplayIfOverElementDimensions(int padding)
|
||||
{
|
||||
CalculatedStyle dimensions1 = this.GetDimensions();
|
||||
if ((double) dimensions1.Width == 0.0 && (double) dimensions1.Height == 0.0)
|
||||
return;
|
||||
Point point1 = new Point((int) dimensions1.X, (int) dimensions1.Y);
|
||||
Point point2 = new Point(point1.X + (int) dimensions1.Width, point1.Y + (int) dimensions1.Height);
|
||||
Rectangle rectangle1 = new Rectangle(point1.X, point1.Y, point2.X - point1.X, point2.Y - point1.Y);
|
||||
CalculatedStyle dimensions2 = this._text.GetDimensions();
|
||||
Point point3 = new Point((int) dimensions2.X, (int) dimensions2.Y);
|
||||
Point point4 = new Point(point3.X + (int) dimensions2.Width, point3.Y + (int) dimensions2.Height);
|
||||
Rectangle rectangle2 = new Rectangle(point3.X, point3.Y, point4.X - point3.X, point4.Y - point3.Y);
|
||||
int num = 0;
|
||||
for (; rectangle2.Right > rectangle1.Right - padding && this._text.Text.Length > 0; rectangle2 = new Rectangle(point3.X, point3.Y, point4.X - point3.X, point4.Y - point3.Y))
|
||||
{
|
||||
this._text.SetText(this._text.Text.Substring(0, this._text.Text.Length - 1));
|
||||
++num;
|
||||
this.RecalculateChildren();
|
||||
CalculatedStyle dimensions3 = this._text.GetDimensions();
|
||||
point3 = new Point((int) dimensions3.X, (int) dimensions3.Y);
|
||||
point4 = new Point(point3.X + (int) dimensions3.Width, point3.Y + (int) dimensions3.Height);
|
||||
}
|
||||
if (num <= 0 || this._text.Text.Length <= 0)
|
||||
return;
|
||||
this._text.SetText(this._text.Text.Substring(0, this._text.Text.Length - 1) + "…");
|
||||
}
|
||||
|
||||
public override void MouseDown(UIMouseEvent evt) => base.MouseDown(evt);
|
||||
|
||||
public override void MouseOver(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseOver(evt);
|
||||
SoundEngine.PlaySound(12);
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
if (this.isWritingText)
|
||||
{
|
||||
if (this.NeedsVirtualkeyboard())
|
||||
{
|
||||
if (this.OnNeedingVirtualKeyboard == null)
|
||||
return;
|
||||
this.OnNeedingVirtualKeyboard();
|
||||
return;
|
||||
}
|
||||
PlayerInput.WritingText = true;
|
||||
Main.CurrentInputTextTakerOverride = (object) this;
|
||||
}
|
||||
base.Update(gameTime);
|
||||
}
|
||||
|
||||
private bool NeedsVirtualkeyboard() => PlayerInput.UsingGamepad;
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
base.DrawSelf(spriteBatch);
|
||||
if (!this.isWritingText)
|
||||
return;
|
||||
PlayerInput.WritingText = true;
|
||||
Main.instance.HandleIME();
|
||||
Vector2 position = new Vector2((float) (Main.screenWidth / 2), (float) (this._text.GetDimensions().ToRectangle().Bottom + 32));
|
||||
Main.instance.DrawWindowsIMEPanel(position, 0.5f);
|
||||
string inputText = Main.GetInputText(this.actualContents);
|
||||
if (Main.inputTextEnter)
|
||||
this.ToggleTakingText();
|
||||
else if (Main.inputTextEscape)
|
||||
{
|
||||
this.ToggleTakingText();
|
||||
if (this.OnCancledTakingInput != null)
|
||||
this.OnCancledTakingInput();
|
||||
}
|
||||
this.SetContents(inputText);
|
||||
position = new Vector2((float) (Main.screenWidth / 2), (float) (this._text.GetDimensions().ToRectangle().Bottom + 32));
|
||||
Main.instance.DrawWindowsIMEPanel(position, 0.5f);
|
||||
}
|
||||
|
||||
public void ToggleTakingText()
|
||||
{
|
||||
this.isWritingText = !this.isWritingText;
|
||||
this._text.ShowInputTicker = this.isWritingText;
|
||||
Main.clrInput();
|
||||
if (this.isWritingText)
|
||||
{
|
||||
if (this.OnStartTakingInput == null)
|
||||
return;
|
||||
this.OnStartTakingInput();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.OnEndTakingInput == null)
|
||||
return;
|
||||
this.OnEndTakingInput();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
51
GameContent/UI/Elements/UISelectableTextPanel`1.cs
Normal file
51
GameContent/UI/Elements/UISelectableTextPanel`1.cs
Normal file
|
@ -0,0 +1,51 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UISelectableTextPanel`1
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using System;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UISelectableTextPanel<T> : UITextPanel<T>
|
||||
{
|
||||
private readonly Asset<Texture2D> _BasePanelTexture;
|
||||
private readonly Asset<Texture2D> _hoveredBorderTexture;
|
||||
private Func<UISelectableTextPanel<T>, bool> _isSelected;
|
||||
|
||||
public Func<UISelectableTextPanel<T>, bool> IsSelected
|
||||
{
|
||||
get => this._isSelected;
|
||||
set => this._isSelected = value;
|
||||
}
|
||||
|
||||
public UISelectableTextPanel(T text, float textScale = 1f, bool large = false)
|
||||
: base(text, textScale, large)
|
||||
{
|
||||
this._BasePanelTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/PanelGrayscale", (AssetRequestMode) 1);
|
||||
this._hoveredBorderTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/CategoryPanelBorder", (AssetRequestMode) 1);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
if (this._drawPanel)
|
||||
{
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
int num1 = 4;
|
||||
int num2 = 10;
|
||||
int num3 = 10;
|
||||
Utils.DrawSplicedPanel(spriteBatch, this._BasePanelTexture.Value, (int) dimensions.X, (int) dimensions.Y, (int) dimensions.Width, (int) dimensions.Height, num2, num2, num3, num3, Color.Lerp(Color.Black, this._color, 0.8f) * 0.5f);
|
||||
if (this.IsSelected != null && this.IsSelected(this))
|
||||
Utils.DrawSplicedPanel(spriteBatch, this._BasePanelTexture.Value, (int) dimensions.X + num1, (int) dimensions.Y + num1, (int) dimensions.Width - num1 * 2, (int) dimensions.Height - num1 * 2, num2, num2, num3, num3, Color.Lerp(this._color, Color.White, 0.7f) * 0.5f);
|
||||
if (this.IsMouseHovering)
|
||||
Utils.DrawSplicedPanel(spriteBatch, this._hoveredBorderTexture.Value, (int) dimensions.X, (int) dimensions.Y, (int) dimensions.Width, (int) dimensions.Height, num2, num2, num3, num3, Color.White);
|
||||
}
|
||||
this.DrawText(spriteBatch);
|
||||
}
|
||||
}
|
||||
}
|
60
GameContent/UI/Elements/UISlicedImage.cs
Normal file
60
GameContent/UI/Elements/UISlicedImage.cs
Normal file
|
@ -0,0 +1,60 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UISlicedImage
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UISlicedImage : UIElement
|
||||
{
|
||||
private Asset<Texture2D> _texture;
|
||||
private Color _color;
|
||||
private int _leftSliceDepth;
|
||||
private int _rightSliceDepth;
|
||||
private int _topSliceDepth;
|
||||
private int _bottomSliceDepth;
|
||||
|
||||
public Color Color
|
||||
{
|
||||
get => this._color;
|
||||
set => this._color = value;
|
||||
}
|
||||
|
||||
public UISlicedImage(Asset<Texture2D> texture)
|
||||
{
|
||||
this._texture = texture;
|
||||
this.Width.Set((float) this._texture.Width(), 0.0f);
|
||||
this.Height.Set((float) this._texture.Height(), 0.0f);
|
||||
}
|
||||
|
||||
public void SetImage(Asset<Texture2D> texture) => this._texture = texture;
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
Utils.DrawSplicedPanel(spriteBatch, this._texture.Value, (int) dimensions.X, (int) dimensions.Y, (int) dimensions.Width, (int) dimensions.Height, this._leftSliceDepth, this._rightSliceDepth, this._topSliceDepth, this._bottomSliceDepth, this._color);
|
||||
}
|
||||
|
||||
public void SetSliceDepths(int top, int bottom, int left, int right)
|
||||
{
|
||||
this._leftSliceDepth = left;
|
||||
this._rightSliceDepth = right;
|
||||
this._topSliceDepth = top;
|
||||
this._bottomSliceDepth = bottom;
|
||||
}
|
||||
|
||||
public void SetSliceDepths(int fluff)
|
||||
{
|
||||
this._leftSliceDepth = fluff;
|
||||
this._rightSliceDepth = fluff;
|
||||
this._topSliceDepth = fluff;
|
||||
this._bottomSliceDepth = fluff;
|
||||
}
|
||||
}
|
||||
}
|
29
GameContent/UI/Elements/UISliderBase.cs
Normal file
29
GameContent/UI/Elements/UISliderBase.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UISliderBase
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UISliderBase : UIElement
|
||||
{
|
||||
internal const int UsageLevel_NotSelected = 0;
|
||||
internal const int UsageLevel_SelectedAndLocked = 1;
|
||||
internal const int UsageLevel_OtherElementIsLocked = 2;
|
||||
internal static UIElement CurrentLockedSlider;
|
||||
internal static UIElement CurrentAimedSlider;
|
||||
|
||||
internal int GetUsageLevel()
|
||||
{
|
||||
int num = 0;
|
||||
if (UISliderBase.CurrentLockedSlider == this)
|
||||
num = 1;
|
||||
else if (UISliderBase.CurrentLockedSlider != null)
|
||||
num = 2;
|
||||
return num;
|
||||
}
|
||||
}
|
||||
}
|
127
GameContent/UI/Elements/UIText.cs
Normal file
127
GameContent/UI/Elements/UIText.cs
Normal file
|
@ -0,0 +1,127 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIText
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Graphics;
|
||||
using System;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIText : UIElement
|
||||
{
|
||||
private object _text = (object) "";
|
||||
private float _textScale = 1f;
|
||||
private Vector2 _textSize = Vector2.Zero;
|
||||
private bool _isLarge;
|
||||
private Color _color = Color.White;
|
||||
private bool _isWrapped;
|
||||
public bool DynamicallyScaleDownToWidth;
|
||||
private string _visibleText;
|
||||
private string _lastTextReference;
|
||||
|
||||
public string Text => this._text.ToString();
|
||||
|
||||
public float TextOriginX { get; set; }
|
||||
|
||||
public float WrappedTextBottomPadding { get; set; }
|
||||
|
||||
public bool IsWrapped
|
||||
{
|
||||
get => this._isWrapped;
|
||||
set
|
||||
{
|
||||
this._isWrapped = value;
|
||||
this.InternalSetText(this._text, this._textScale, this._isLarge);
|
||||
}
|
||||
}
|
||||
|
||||
public event Action OnInternalTextChange;
|
||||
|
||||
public Color TextColor
|
||||
{
|
||||
get => this._color;
|
||||
set => this._color = value;
|
||||
}
|
||||
|
||||
public UIText(string text, float textScale = 1f, bool large = false)
|
||||
{
|
||||
this.TextOriginX = 0.5f;
|
||||
this.IsWrapped = false;
|
||||
this.WrappedTextBottomPadding = 20f;
|
||||
this.InternalSetText((object) text, textScale, large);
|
||||
}
|
||||
|
||||
public UIText(LocalizedText text, float textScale = 1f, bool large = false)
|
||||
{
|
||||
this.TextOriginX = 0.5f;
|
||||
this.IsWrapped = false;
|
||||
this.WrappedTextBottomPadding = 20f;
|
||||
this.InternalSetText((object) text, textScale, large);
|
||||
}
|
||||
|
||||
public override void Recalculate()
|
||||
{
|
||||
this.InternalSetText(this._text, this._textScale, this._isLarge);
|
||||
base.Recalculate();
|
||||
}
|
||||
|
||||
public void SetText(string text) => this.InternalSetText((object) text, this._textScale, this._isLarge);
|
||||
|
||||
public void SetText(LocalizedText text) => this.InternalSetText((object) text, this._textScale, this._isLarge);
|
||||
|
||||
public void SetText(string text, float textScale, bool large) => this.InternalSetText((object) text, textScale, large);
|
||||
|
||||
public void SetText(LocalizedText text, float textScale, bool large) => this.InternalSetText((object) text, textScale, large);
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
base.DrawSelf(spriteBatch);
|
||||
this.VerifyTextState();
|
||||
CalculatedStyle innerDimensions = this.GetInnerDimensions();
|
||||
Vector2 pos = innerDimensions.Position();
|
||||
if (this._isLarge)
|
||||
pos.Y -= 10f * this._textScale;
|
||||
else
|
||||
pos.Y -= 2f * this._textScale;
|
||||
pos.X += (innerDimensions.Width - this._textSize.X) * this.TextOriginX;
|
||||
float textScale = this._textScale;
|
||||
if (this.DynamicallyScaleDownToWidth && (double) this._textSize.X > (double) innerDimensions.Width)
|
||||
textScale *= innerDimensions.Width / this._textSize.X;
|
||||
if (this._isLarge)
|
||||
Utils.DrawBorderStringBig(spriteBatch, this._visibleText, pos, this._color, textScale);
|
||||
else
|
||||
Utils.DrawBorderString(spriteBatch, this._visibleText, pos, this._color, textScale);
|
||||
}
|
||||
|
||||
private void VerifyTextState()
|
||||
{
|
||||
if ((object) this._lastTextReference == (object) this.Text)
|
||||
return;
|
||||
this.InternalSetText(this._text, this._textScale, this._isLarge);
|
||||
}
|
||||
|
||||
private void InternalSetText(object text, float textScale, bool large)
|
||||
{
|
||||
DynamicSpriteFont dynamicSpriteFont = large ? FontAssets.DeathText.Value : FontAssets.MouseText.Value;
|
||||
this._text = text;
|
||||
this._isLarge = large;
|
||||
this._textScale = textScale;
|
||||
this._lastTextReference = this._text.ToString();
|
||||
this._visibleText = !this.IsWrapped ? this._lastTextReference : dynamicSpriteFont.CreateWrappedText(this._lastTextReference, this.GetInnerDimensions().Width / this._textScale);
|
||||
Vector2 vector2_1 = dynamicSpriteFont.MeasureString(this._visibleText);
|
||||
Vector2 vector2_2 = !this.IsWrapped ? new Vector2(vector2_1.X, large ? 32f : 16f) * textScale : new Vector2(vector2_1.X, vector2_1.Y + this.WrappedTextBottomPadding) * textScale;
|
||||
this._textSize = vector2_2;
|
||||
this.MinWidth.Set(vector2_2.X + this.PaddingLeft + this.PaddingRight, 0.0f);
|
||||
this.MinHeight.Set(vector2_2.Y + this.PaddingTop + this.PaddingBottom, 0.0f);
|
||||
if (this.OnInternalTextChange == null)
|
||||
return;
|
||||
this.OnInternalTextChange();
|
||||
}
|
||||
}
|
||||
}
|
89
GameContent/UI/Elements/UITextBox.cs
Normal file
89
GameContent/UI/Elements/UITextBox.cs
Normal file
|
@ -0,0 +1,89 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UITextBox
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
internal class UITextBox : UITextPanel<string>
|
||||
{
|
||||
private int _cursor;
|
||||
private int _frameCount;
|
||||
private int _maxLength = 20;
|
||||
public bool ShowInputTicker = true;
|
||||
public bool HideSelf;
|
||||
|
||||
public UITextBox(string text, float textScale = 1f, bool large = false)
|
||||
: base(text, textScale, large)
|
||||
{
|
||||
}
|
||||
|
||||
public void Write(string text)
|
||||
{
|
||||
this.SetText(this.Text.Insert(this._cursor, text));
|
||||
this._cursor += text.Length;
|
||||
}
|
||||
|
||||
public override void SetText(string text, float textScale, bool large)
|
||||
{
|
||||
if (text == null)
|
||||
text = "";
|
||||
if (text.Length > this._maxLength)
|
||||
text = text.Substring(0, this._maxLength);
|
||||
base.SetText(text, textScale, large);
|
||||
this._cursor = Math.Min(this.Text.Length, this._cursor);
|
||||
}
|
||||
|
||||
public void SetTextMaxLength(int maxLength) => this._maxLength = maxLength;
|
||||
|
||||
public void Backspace()
|
||||
{
|
||||
if (this._cursor == 0)
|
||||
return;
|
||||
this.SetText(this.Text.Substring(0, this.Text.Length - 1));
|
||||
}
|
||||
|
||||
public void CursorLeft()
|
||||
{
|
||||
if (this._cursor == 0)
|
||||
return;
|
||||
--this._cursor;
|
||||
}
|
||||
|
||||
public void CursorRight()
|
||||
{
|
||||
if (this._cursor >= this.Text.Length)
|
||||
return;
|
||||
++this._cursor;
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
if (this.HideSelf)
|
||||
return;
|
||||
this._cursor = this.Text.Length;
|
||||
base.DrawSelf(spriteBatch);
|
||||
++this._frameCount;
|
||||
if ((this._frameCount %= 40) > 20 || !this.ShowInputTicker)
|
||||
return;
|
||||
CalculatedStyle innerDimensions = this.GetInnerDimensions();
|
||||
Vector2 pos = innerDimensions.Position();
|
||||
Vector2 vector2 = new Vector2((this.IsLarge ? FontAssets.DeathText.Value : FontAssets.MouseText.Value).MeasureString(this.Text.Substring(0, this._cursor)).X, this.IsLarge ? 32f : 16f) * this.TextScale;
|
||||
if (this.IsLarge)
|
||||
pos.Y -= 8f * this.TextScale;
|
||||
else
|
||||
pos.Y -= 2f * this.TextScale;
|
||||
pos.X += (float) (((double) innerDimensions.Width - (double) this.TextSize.X) * (double) this.TextHAlign + (double) vector2.X - (this.IsLarge ? 8.0 : 4.0) * (double) this.TextScale + 6.0);
|
||||
if (this.IsLarge)
|
||||
Utils.DrawBorderStringBig(spriteBatch, "|", pos, this.TextColor, this.TextScale);
|
||||
else
|
||||
Utils.DrawBorderString(spriteBatch, "|", pos, this.TextColor, this.TextScale);
|
||||
}
|
||||
}
|
||||
}
|
90
GameContent/UI/Elements/UITextPanel`1.cs
Normal file
90
GameContent/UI/Elements/UITextPanel`1.cs
Normal file
|
@ -0,0 +1,90 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UITextPanel`1
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UITextPanel<T> : UIPanel
|
||||
{
|
||||
protected T _text;
|
||||
protected float _textScale = 1f;
|
||||
protected Vector2 _textSize = Vector2.Zero;
|
||||
protected bool _isLarge;
|
||||
protected Color _color = Color.White;
|
||||
protected bool _drawPanel = true;
|
||||
public float TextHAlign = 0.5f;
|
||||
|
||||
public bool IsLarge => this._isLarge;
|
||||
|
||||
public bool DrawPanel
|
||||
{
|
||||
get => this._drawPanel;
|
||||
set => this._drawPanel = value;
|
||||
}
|
||||
|
||||
public float TextScale
|
||||
{
|
||||
get => this._textScale;
|
||||
set => this._textScale = value;
|
||||
}
|
||||
|
||||
public Vector2 TextSize => this._textSize;
|
||||
|
||||
public string Text => (object) this._text != null ? this._text.ToString() : "";
|
||||
|
||||
public Color TextColor
|
||||
{
|
||||
get => this._color;
|
||||
set => this._color = value;
|
||||
}
|
||||
|
||||
public UITextPanel(T text, float textScale = 1f, bool large = false) => this.SetText(text, textScale, large);
|
||||
|
||||
public override void Recalculate()
|
||||
{
|
||||
this.SetText(this._text, this._textScale, this._isLarge);
|
||||
base.Recalculate();
|
||||
}
|
||||
|
||||
public void SetText(T text) => this.SetText(text, this._textScale, this._isLarge);
|
||||
|
||||
public virtual void SetText(T text, float textScale, bool large)
|
||||
{
|
||||
Vector2 vector2 = new Vector2((large ? FontAssets.DeathText.Value : FontAssets.MouseText.Value).MeasureString(text.ToString()).X, large ? 32f : 16f) * textScale;
|
||||
this._text = text;
|
||||
this._textScale = textScale;
|
||||
this._textSize = vector2;
|
||||
this._isLarge = large;
|
||||
this.MinWidth.Set(vector2.X + this.PaddingLeft + this.PaddingRight, 0.0f);
|
||||
this.MinHeight.Set(vector2.Y + this.PaddingTop + this.PaddingBottom, 0.0f);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
if (this._drawPanel)
|
||||
base.DrawSelf(spriteBatch);
|
||||
this.DrawText(spriteBatch);
|
||||
}
|
||||
|
||||
protected void DrawText(SpriteBatch spriteBatch)
|
||||
{
|
||||
CalculatedStyle innerDimensions = this.GetInnerDimensions();
|
||||
Vector2 pos = innerDimensions.Position();
|
||||
if (this._isLarge)
|
||||
pos.Y -= 10f * this._textScale * this._textScale;
|
||||
else
|
||||
pos.Y -= 2f * this._textScale;
|
||||
pos.X += (innerDimensions.Width - this._textSize.X) * this.TextHAlign;
|
||||
if (this._isLarge)
|
||||
Utils.DrawBorderStringBig(spriteBatch, this.Text, pos, this._color, this._textScale);
|
||||
else
|
||||
Utils.DrawBorderString(spriteBatch, this.Text, pos, this._color, this._textScale);
|
||||
}
|
||||
}
|
||||
}
|
72
GameContent/UI/Elements/UIToggleImage.cs
Normal file
72
GameContent/UI/Elements/UIToggleImage.cs
Normal file
|
@ -0,0 +1,72 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIToggleImage
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIToggleImage : UIElement
|
||||
{
|
||||
private Asset<Texture2D> _onTexture;
|
||||
private Asset<Texture2D> _offTexture;
|
||||
private int _drawWidth;
|
||||
private int _drawHeight;
|
||||
private Point _onTextureOffset = Point.Zero;
|
||||
private Point _offTextureOffset = Point.Zero;
|
||||
private bool _isOn;
|
||||
|
||||
public bool IsOn => this._isOn;
|
||||
|
||||
public UIToggleImage(
|
||||
Asset<Texture2D> texture,
|
||||
int width,
|
||||
int height,
|
||||
Point onTextureOffset,
|
||||
Point offTextureOffset)
|
||||
{
|
||||
this._onTexture = texture;
|
||||
this._offTexture = texture;
|
||||
this._offTextureOffset = offTextureOffset;
|
||||
this._onTextureOffset = onTextureOffset;
|
||||
this._drawWidth = width;
|
||||
this._drawHeight = height;
|
||||
this.Width.Set((float) width, 0.0f);
|
||||
this.Height.Set((float) height, 0.0f);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
Texture2D texture;
|
||||
Point point;
|
||||
if (this._isOn)
|
||||
{
|
||||
texture = this._onTexture.Value;
|
||||
point = this._onTextureOffset;
|
||||
}
|
||||
else
|
||||
{
|
||||
texture = this._offTexture.Value;
|
||||
point = this._offTextureOffset;
|
||||
}
|
||||
Color color = this.IsMouseHovering ? Color.White : Color.Silver;
|
||||
spriteBatch.Draw(texture, new Rectangle((int) dimensions.X, (int) dimensions.Y, this._drawWidth, this._drawHeight), new Rectangle?(new Rectangle(point.X, point.Y, this._drawWidth, this._drawHeight)), color);
|
||||
}
|
||||
|
||||
public override void Click(UIMouseEvent evt)
|
||||
{
|
||||
this.Toggle();
|
||||
base.Click(evt);
|
||||
}
|
||||
|
||||
public void SetState(bool value) => this._isOn = value;
|
||||
|
||||
public void Toggle() => this._isOn = !this._isOn;
|
||||
}
|
||||
}
|
36
GameContent/UI/Elements/UIVerticalSeparator.cs
Normal file
36
GameContent/UI/Elements/UIVerticalSeparator.cs
Normal file
|
@ -0,0 +1,36 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIVerticalSeparator
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIVerticalSeparator : UIElement
|
||||
{
|
||||
private Asset<Texture2D> _texture;
|
||||
public Color Color;
|
||||
public int EdgeWidth;
|
||||
|
||||
public UIVerticalSeparator()
|
||||
{
|
||||
this.Color = Color.White;
|
||||
this._texture = Main.Assets.Request<Texture2D>("Images/UI/OnePixel", (AssetRequestMode) 1);
|
||||
this.Width.Set((float) this._texture.Width(), 0.0f);
|
||||
this.Height.Set((float) this._texture.Height(), 0.0f);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
spriteBatch.Draw(this._texture.Value, dimensions.ToRectangle(), this.Color);
|
||||
}
|
||||
|
||||
public override bool ContainsPoint(Vector2 point) => false;
|
||||
}
|
||||
}
|
122
GameContent/UI/Elements/UIVerticalSlider.cs
Normal file
122
GameContent/UI/Elements/UIVerticalSlider.cs
Normal file
|
@ -0,0 +1,122 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIVerticalSlider
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Terraria.Audio;
|
||||
using Terraria.GameInput;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIVerticalSlider : UISliderBase
|
||||
{
|
||||
public float FillPercent;
|
||||
public Color FilledColor = Main.OurFavoriteColor;
|
||||
public Color EmptyColor = Color.Black;
|
||||
private Func<float> _getSliderValue;
|
||||
private Action<float> _slideKeyboardAction;
|
||||
private Func<float, Color> _blipFunc;
|
||||
private Action _slideGamepadAction;
|
||||
private bool _isReallyMouseOvered;
|
||||
private bool _soundedUsage;
|
||||
private bool _alreadyHovered;
|
||||
|
||||
public UIVerticalSlider(
|
||||
Func<float> getStatus,
|
||||
Action<float> setStatusKeyboard,
|
||||
Action setStatusGamepad,
|
||||
Color color)
|
||||
{
|
||||
this._getSliderValue = getStatus != null ? getStatus : (Func<float>) (() => 0.0f);
|
||||
this._slideKeyboardAction = setStatusKeyboard != null ? setStatusKeyboard : (Action<float>) (s => { });
|
||||
this._slideGamepadAction = setStatusGamepad;
|
||||
this._isReallyMouseOvered = false;
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
UISliderBase.CurrentAimedSlider = (UIElement) null;
|
||||
if (!Main.mouseLeft)
|
||||
UISliderBase.CurrentLockedSlider = (UIElement) null;
|
||||
this.GetUsageLevel();
|
||||
this.FillPercent = this._getSliderValue();
|
||||
float sliderValueThatWasSet = this.FillPercent;
|
||||
bool flag = false;
|
||||
if (this.DrawValueBarDynamicWidth(spriteBatch, out sliderValueThatWasSet))
|
||||
flag = true;
|
||||
if (UISliderBase.CurrentLockedSlider == this | flag)
|
||||
{
|
||||
UISliderBase.CurrentAimedSlider = (UIElement) this;
|
||||
if (PlayerInput.Triggers.Current.MouseLeft && !PlayerInput.UsingGamepad && UISliderBase.CurrentLockedSlider == this)
|
||||
{
|
||||
this._slideKeyboardAction(sliderValueThatWasSet);
|
||||
if (!this._soundedUsage)
|
||||
SoundEngine.PlaySound(12);
|
||||
this._soundedUsage = true;
|
||||
}
|
||||
else
|
||||
this._soundedUsage = false;
|
||||
}
|
||||
if (UISliderBase.CurrentAimedSlider != null && UISliderBase.CurrentLockedSlider == null)
|
||||
UISliderBase.CurrentLockedSlider = UISliderBase.CurrentAimedSlider;
|
||||
if (!this._isReallyMouseOvered)
|
||||
return;
|
||||
this._slideGamepadAction();
|
||||
}
|
||||
|
||||
private bool DrawValueBarDynamicWidth(SpriteBatch spriteBatch, out float sliderValueThatWasSet)
|
||||
{
|
||||
sliderValueThatWasSet = 0.0f;
|
||||
Texture2D texture1 = TextureAssets.ColorBar.Value;
|
||||
Rectangle rectangle1 = this.GetDimensions().ToRectangle();
|
||||
Rectangle rectangle2 = new Rectangle(5, 4, 4, 4);
|
||||
Utils.DrawSplicedPanel(spriteBatch, texture1, rectangle1.X, rectangle1.Y, rectangle1.Width, rectangle1.Height, rectangle2.X, rectangle2.Width, rectangle2.Y, rectangle2.Height, Color.White);
|
||||
Rectangle destinationRectangle1 = rectangle1;
|
||||
destinationRectangle1.X += rectangle2.Left;
|
||||
destinationRectangle1.Width -= rectangle2.Right;
|
||||
destinationRectangle1.Y += rectangle2.Top;
|
||||
destinationRectangle1.Height -= rectangle2.Bottom;
|
||||
Texture2D texture2 = TextureAssets.MagicPixel.Value;
|
||||
Rectangle rectangle3 = new Rectangle(0, 0, 1, 1);
|
||||
spriteBatch.Draw(texture2, destinationRectangle1, new Rectangle?(rectangle3), this.EmptyColor);
|
||||
Rectangle destinationRectangle2 = destinationRectangle1;
|
||||
destinationRectangle2.Height = (int) ((double) destinationRectangle2.Height * (double) this.FillPercent);
|
||||
destinationRectangle2.Y += destinationRectangle1.Height - destinationRectangle2.Height;
|
||||
spriteBatch.Draw(texture2, destinationRectangle2, new Rectangle?(rectangle3), this.FilledColor);
|
||||
Rectangle destinationRectangle3 = Utils.CenteredRectangle(new Vector2((float) (destinationRectangle2.Center.X + 1), (float) destinationRectangle2.Top), new Vector2((float) (destinationRectangle2.Width + 16), 4f));
|
||||
Rectangle destinationRectangle4 = destinationRectangle3;
|
||||
destinationRectangle4.Inflate(2, 2);
|
||||
spriteBatch.Draw(texture2, destinationRectangle4, new Rectangle?(rectangle3), Color.Black);
|
||||
spriteBatch.Draw(texture2, destinationRectangle3, new Rectangle?(rectangle3), Color.White);
|
||||
Rectangle rectangle4 = destinationRectangle1;
|
||||
rectangle4.Inflate(4, 0);
|
||||
bool flag1 = rectangle4.Contains(Main.MouseScreen.ToPoint());
|
||||
this._isReallyMouseOvered = flag1;
|
||||
bool flag2 = flag1;
|
||||
if (this.IgnoresMouseInteraction)
|
||||
flag2 = false;
|
||||
int usageLevel = this.GetUsageLevel();
|
||||
if (usageLevel == 2)
|
||||
flag2 = false;
|
||||
if (usageLevel == 1)
|
||||
flag2 = true;
|
||||
if (flag2 || usageLevel == 1)
|
||||
{
|
||||
if (!this._alreadyHovered)
|
||||
SoundEngine.PlaySound(12);
|
||||
this._alreadyHovered = true;
|
||||
}
|
||||
else
|
||||
this._alreadyHovered = false;
|
||||
if (!flag2)
|
||||
return false;
|
||||
sliderValueThatWasSet = Utils.GetLerpValue((float) destinationRectangle1.Bottom, (float) destinationRectangle1.Top, (float) Main.mouseY, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
124
GameContent/UI/Elements/UIWorldCreationPreview.cs
Normal file
124
GameContent/UI/Elements/UIWorldCreationPreview.cs
Normal file
|
@ -0,0 +1,124 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIWorldCreationPreview
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIWorldCreationPreview : UIElement
|
||||
{
|
||||
private readonly Asset<Texture2D> _BorderTexture;
|
||||
private readonly Asset<Texture2D> _BackgroundExpertTexture;
|
||||
private readonly Asset<Texture2D> _BackgroundNormalTexture;
|
||||
private readonly Asset<Texture2D> _BackgroundMasterTexture;
|
||||
private readonly Asset<Texture2D> _BunnyExpertTexture;
|
||||
private readonly Asset<Texture2D> _BunnyNormalTexture;
|
||||
private readonly Asset<Texture2D> _BunnyCreativeTexture;
|
||||
private readonly Asset<Texture2D> _BunnyMasterTexture;
|
||||
private readonly Asset<Texture2D> _EvilRandomTexture;
|
||||
private readonly Asset<Texture2D> _EvilCorruptionTexture;
|
||||
private readonly Asset<Texture2D> _EvilCrimsonTexture;
|
||||
private readonly Asset<Texture2D> _SizeSmallTexture;
|
||||
private readonly Asset<Texture2D> _SizeMediumTexture;
|
||||
private readonly Asset<Texture2D> _SizeLargeTexture;
|
||||
private byte _difficulty;
|
||||
private byte _evil;
|
||||
private byte _size;
|
||||
|
||||
public UIWorldCreationPreview()
|
||||
{
|
||||
this._BorderTexture = Main.Assets.Request<Texture2D>("Images/UI/WorldCreation/PreviewBorder", (AssetRequestMode) 1);
|
||||
this._BackgroundNormalTexture = Main.Assets.Request<Texture2D>("Images/UI/WorldCreation/PreviewDifficultyNormal1", (AssetRequestMode) 1);
|
||||
this._BackgroundExpertTexture = Main.Assets.Request<Texture2D>("Images/UI/WorldCreation/PreviewDifficultyExpert1", (AssetRequestMode) 1);
|
||||
this._BackgroundMasterTexture = Main.Assets.Request<Texture2D>("Images/UI/WorldCreation/PreviewDifficultyMaster1", (AssetRequestMode) 1);
|
||||
this._BunnyNormalTexture = Main.Assets.Request<Texture2D>("Images/UI/WorldCreation/PreviewDifficultyNormal2", (AssetRequestMode) 1);
|
||||
this._BunnyExpertTexture = Main.Assets.Request<Texture2D>("Images/UI/WorldCreation/PreviewDifficultyExpert2", (AssetRequestMode) 1);
|
||||
this._BunnyCreativeTexture = Main.Assets.Request<Texture2D>("Images/UI/WorldCreation/PreviewDifficultyCreative2", (AssetRequestMode) 1);
|
||||
this._BunnyMasterTexture = Main.Assets.Request<Texture2D>("Images/UI/WorldCreation/PreviewDifficultyMaster2", (AssetRequestMode) 1);
|
||||
this._EvilRandomTexture = Main.Assets.Request<Texture2D>("Images/UI/WorldCreation/PreviewEvilRandom", (AssetRequestMode) 1);
|
||||
this._EvilCorruptionTexture = Main.Assets.Request<Texture2D>("Images/UI/WorldCreation/PreviewEvilCorruption", (AssetRequestMode) 1);
|
||||
this._EvilCrimsonTexture = Main.Assets.Request<Texture2D>("Images/UI/WorldCreation/PreviewEvilCrimson", (AssetRequestMode) 1);
|
||||
this._SizeSmallTexture = Main.Assets.Request<Texture2D>("Images/UI/WorldCreation/PreviewSizeSmall", (AssetRequestMode) 1);
|
||||
this._SizeMediumTexture = Main.Assets.Request<Texture2D>("Images/UI/WorldCreation/PreviewSizeMedium", (AssetRequestMode) 1);
|
||||
this._SizeLargeTexture = Main.Assets.Request<Texture2D>("Images/UI/WorldCreation/PreviewSizeLarge", (AssetRequestMode) 1);
|
||||
this.Width.Set((float) this._BackgroundExpertTexture.Width(), 0.0f);
|
||||
this.Height.Set((float) this._BackgroundExpertTexture.Height(), 0.0f);
|
||||
}
|
||||
|
||||
public void UpdateOption(byte difficulty, byte evil, byte size)
|
||||
{
|
||||
this._difficulty = difficulty;
|
||||
this._evil = evil;
|
||||
this._size = size;
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
Vector2 position = new Vector2(dimensions.X + 4f, dimensions.Y + 4f);
|
||||
Color color = Color.White;
|
||||
switch (this._difficulty)
|
||||
{
|
||||
case 0:
|
||||
case 3:
|
||||
spriteBatch.Draw(this._BackgroundNormalTexture.Value, position, Color.White);
|
||||
color = Color.White;
|
||||
break;
|
||||
case 1:
|
||||
spriteBatch.Draw(this._BackgroundExpertTexture.Value, position, Color.White);
|
||||
color = Color.DarkGray;
|
||||
break;
|
||||
case 2:
|
||||
spriteBatch.Draw(this._BackgroundMasterTexture.Value, position, Color.White);
|
||||
color = Color.DarkGray;
|
||||
break;
|
||||
}
|
||||
switch (this._size)
|
||||
{
|
||||
case 0:
|
||||
spriteBatch.Draw(this._SizeSmallTexture.Value, position, color);
|
||||
break;
|
||||
case 1:
|
||||
spriteBatch.Draw(this._SizeMediumTexture.Value, position, color);
|
||||
break;
|
||||
case 2:
|
||||
spriteBatch.Draw(this._SizeLargeTexture.Value, position, color);
|
||||
break;
|
||||
}
|
||||
switch (this._evil)
|
||||
{
|
||||
case 0:
|
||||
spriteBatch.Draw(this._EvilRandomTexture.Value, position, color);
|
||||
break;
|
||||
case 1:
|
||||
spriteBatch.Draw(this._EvilCorruptionTexture.Value, position, color);
|
||||
break;
|
||||
case 2:
|
||||
spriteBatch.Draw(this._EvilCrimsonTexture.Value, position, color);
|
||||
break;
|
||||
}
|
||||
switch (this._difficulty)
|
||||
{
|
||||
case 0:
|
||||
spriteBatch.Draw(this._BunnyNormalTexture.Value, position, color);
|
||||
break;
|
||||
case 1:
|
||||
spriteBatch.Draw(this._BunnyExpertTexture.Value, position, color);
|
||||
break;
|
||||
case 2:
|
||||
spriteBatch.Draw(this._BunnyMasterTexture.Value, position, color * 1.2f);
|
||||
break;
|
||||
case 3:
|
||||
spriteBatch.Draw(this._BunnyCreativeTexture.Value, position, color);
|
||||
break;
|
||||
}
|
||||
spriteBatch.Draw(this._BorderTexture.Value, new Vector2(dimensions.X, dimensions.Y), Color.White);
|
||||
}
|
||||
}
|
||||
}
|
364
GameContent/UI/Elements/UIWorldListItem.cs
Normal file
364
GameContent/UI/Elements/UIWorldListItem.cs
Normal file
|
@ -0,0 +1,364 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIWorldListItem
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using ReLogic.OS;
|
||||
using Terraria.Audio;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.IO;
|
||||
using Terraria.Localization;
|
||||
using Terraria.Social;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIWorldListItem : UIPanel
|
||||
{
|
||||
private WorldFileData _data;
|
||||
private Asset<Texture2D> _dividerTexture;
|
||||
private Asset<Texture2D> _innerPanelTexture;
|
||||
private UIImage _worldIcon;
|
||||
private UIText _buttonLabel;
|
||||
private UIText _deleteButtonLabel;
|
||||
private Asset<Texture2D> _buttonCloudActiveTexture;
|
||||
private Asset<Texture2D> _buttonCloudInactiveTexture;
|
||||
private Asset<Texture2D> _buttonFavoriteActiveTexture;
|
||||
private Asset<Texture2D> _buttonFavoriteInactiveTexture;
|
||||
private Asset<Texture2D> _buttonPlayTexture;
|
||||
private Asset<Texture2D> _buttonSeedTexture;
|
||||
private Asset<Texture2D> _buttonDeleteTexture;
|
||||
private UIImageButton _deleteButton;
|
||||
private int _orderInList;
|
||||
private bool _canBePlayed;
|
||||
|
||||
public bool IsFavorite => this._data.IsFavorite;
|
||||
|
||||
public UIWorldListItem(WorldFileData data, int orderInList, bool canBePlayed)
|
||||
{
|
||||
this._orderInList = orderInList;
|
||||
this._data = data;
|
||||
this._canBePlayed = canBePlayed;
|
||||
this.LoadTextures();
|
||||
this.InitializeAppearance();
|
||||
this._worldIcon = new UIImage(this.GetIcon());
|
||||
this._worldIcon.Left.Set(4f, 0.0f);
|
||||
this._worldIcon.OnDoubleClick += new UIElement.MouseEvent(this.PlayGame);
|
||||
this.Append((UIElement) this._worldIcon);
|
||||
float pixels1 = 4f;
|
||||
UIImageButton uiImageButton1 = new UIImageButton(this._buttonPlayTexture);
|
||||
uiImageButton1.VAlign = 1f;
|
||||
uiImageButton1.Left.Set(pixels1, 0.0f);
|
||||
uiImageButton1.OnClick += new UIElement.MouseEvent(this.PlayGame);
|
||||
this.OnDoubleClick += new UIElement.MouseEvent(this.PlayGame);
|
||||
uiImageButton1.OnMouseOver += new UIElement.MouseEvent(this.PlayMouseOver);
|
||||
uiImageButton1.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut);
|
||||
this.Append((UIElement) uiImageButton1);
|
||||
float pixels2 = pixels1 + 24f;
|
||||
UIImageButton uiImageButton2 = new UIImageButton(this._data.IsFavorite ? this._buttonFavoriteActiveTexture : this._buttonFavoriteInactiveTexture);
|
||||
uiImageButton2.VAlign = 1f;
|
||||
uiImageButton2.Left.Set(pixels2, 0.0f);
|
||||
uiImageButton2.OnClick += new UIElement.MouseEvent(this.FavoriteButtonClick);
|
||||
uiImageButton2.OnMouseOver += new UIElement.MouseEvent(this.FavoriteMouseOver);
|
||||
uiImageButton2.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut);
|
||||
uiImageButton2.SetVisibility(1f, this._data.IsFavorite ? 0.8f : 0.4f);
|
||||
this.Append((UIElement) uiImageButton2);
|
||||
float pixels3 = pixels2 + 24f;
|
||||
if (SocialAPI.Cloud != null)
|
||||
{
|
||||
UIImageButton uiImageButton3 = new UIImageButton(this._data.IsCloudSave ? this._buttonCloudActiveTexture : this._buttonCloudInactiveTexture);
|
||||
uiImageButton3.VAlign = 1f;
|
||||
uiImageButton3.Left.Set(pixels3, 0.0f);
|
||||
uiImageButton3.OnClick += new UIElement.MouseEvent(this.CloudButtonClick);
|
||||
uiImageButton3.OnMouseOver += new UIElement.MouseEvent(this.CloudMouseOver);
|
||||
uiImageButton3.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut);
|
||||
uiImageButton3.SetSnapPoint("Cloud", orderInList);
|
||||
this.Append((UIElement) uiImageButton3);
|
||||
pixels3 += 24f;
|
||||
}
|
||||
if (this._data.WorldGeneratorVersion != 0UL)
|
||||
{
|
||||
UIImageButton uiImageButton4 = new UIImageButton(this._buttonSeedTexture);
|
||||
uiImageButton4.VAlign = 1f;
|
||||
uiImageButton4.Left.Set(pixels3, 0.0f);
|
||||
uiImageButton4.OnClick += new UIElement.MouseEvent(this.SeedButtonClick);
|
||||
uiImageButton4.OnMouseOver += new UIElement.MouseEvent(this.SeedMouseOver);
|
||||
uiImageButton4.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut);
|
||||
uiImageButton4.SetSnapPoint("Seed", orderInList);
|
||||
this.Append((UIElement) uiImageButton4);
|
||||
pixels3 += 24f;
|
||||
}
|
||||
UIImageButton uiImageButton5 = new UIImageButton(this._buttonDeleteTexture);
|
||||
uiImageButton5.VAlign = 1f;
|
||||
uiImageButton5.HAlign = 1f;
|
||||
if (!this._data.IsFavorite)
|
||||
uiImageButton5.OnClick += new UIElement.MouseEvent(this.DeleteButtonClick);
|
||||
uiImageButton5.OnMouseOver += new UIElement.MouseEvent(this.DeleteMouseOver);
|
||||
uiImageButton5.OnMouseOut += new UIElement.MouseEvent(this.DeleteMouseOut);
|
||||
this._deleteButton = uiImageButton5;
|
||||
this.Append((UIElement) uiImageButton5);
|
||||
float pixels4 = pixels3 + 4f;
|
||||
this._buttonLabel = new UIText("");
|
||||
this._buttonLabel.VAlign = 1f;
|
||||
this._buttonLabel.Left.Set(pixels4, 0.0f);
|
||||
this._buttonLabel.Top.Set(-3f, 0.0f);
|
||||
this.Append((UIElement) this._buttonLabel);
|
||||
this._deleteButtonLabel = new UIText("");
|
||||
this._deleteButtonLabel.VAlign = 1f;
|
||||
this._deleteButtonLabel.HAlign = 1f;
|
||||
this._deleteButtonLabel.Left.Set(-30f, 0.0f);
|
||||
this._deleteButtonLabel.Top.Set(-3f, 0.0f);
|
||||
this.Append((UIElement) this._deleteButtonLabel);
|
||||
uiImageButton1.SetSnapPoint("Play", orderInList);
|
||||
uiImageButton2.SetSnapPoint("Favorite", orderInList);
|
||||
uiImageButton5.SetSnapPoint("Delete", orderInList);
|
||||
}
|
||||
|
||||
private void LoadTextures()
|
||||
{
|
||||
this._dividerTexture = Main.Assets.Request<Texture2D>("Images/UI/Divider", (AssetRequestMode) 1);
|
||||
this._innerPanelTexture = Main.Assets.Request<Texture2D>("Images/UI/InnerPanelBackground", (AssetRequestMode) 1);
|
||||
this._buttonCloudActiveTexture = Main.Assets.Request<Texture2D>("Images/UI/ButtonCloudActive", (AssetRequestMode) 1);
|
||||
this._buttonCloudInactiveTexture = Main.Assets.Request<Texture2D>("Images/UI/ButtonCloudInactive", (AssetRequestMode) 1);
|
||||
this._buttonFavoriteActiveTexture = Main.Assets.Request<Texture2D>("Images/UI/ButtonFavoriteActive", (AssetRequestMode) 1);
|
||||
this._buttonFavoriteInactiveTexture = Main.Assets.Request<Texture2D>("Images/UI/ButtonFavoriteInactive", (AssetRequestMode) 1);
|
||||
this._buttonPlayTexture = Main.Assets.Request<Texture2D>("Images/UI/ButtonPlay", (AssetRequestMode) 1);
|
||||
this._buttonSeedTexture = Main.Assets.Request<Texture2D>("Images/UI/ButtonSeed", (AssetRequestMode) 1);
|
||||
this._buttonDeleteTexture = Main.Assets.Request<Texture2D>("Images/UI/ButtonDelete", (AssetRequestMode) 1);
|
||||
}
|
||||
|
||||
private void InitializeAppearance()
|
||||
{
|
||||
this.Height.Set(96f, 0.0f);
|
||||
this.Width.Set(0.0f, 1f);
|
||||
this.SetPadding(6f);
|
||||
this.SetColorsToNotHovered();
|
||||
}
|
||||
|
||||
private void SetColorsToHovered()
|
||||
{
|
||||
this.BackgroundColor = new Color(73, 94, 171);
|
||||
this.BorderColor = new Color(89, 116, 213);
|
||||
if (this._canBePlayed)
|
||||
return;
|
||||
this.BorderColor = new Color(150, 150, 150) * 1f;
|
||||
this.BackgroundColor = Color.Lerp(this.BackgroundColor, new Color(120, 120, 120), 0.5f) * 1f;
|
||||
}
|
||||
|
||||
private void SetColorsToNotHovered()
|
||||
{
|
||||
this.BackgroundColor = new Color(63, 82, 151) * 0.7f;
|
||||
this.BorderColor = new Color(89, 116, 213) * 0.7f;
|
||||
if (this._canBePlayed)
|
||||
return;
|
||||
this.BorderColor = new Color((int) sbyte.MaxValue, (int) sbyte.MaxValue, (int) sbyte.MaxValue) * 0.7f;
|
||||
this.BackgroundColor = Color.Lerp(new Color(63, 82, 151), new Color(80, 80, 80), 0.5f) * 0.7f;
|
||||
}
|
||||
|
||||
private Asset<Texture2D> GetIcon() => this._data.DrunkWorld ? Main.Assets.Request<Texture2D>("Images/UI/Icon" + (this._data.IsHardMode ? "Hallow" : "") + "CorruptionCrimson", (AssetRequestMode) 1) : Main.Assets.Request<Texture2D>("Images/UI/Icon" + (this._data.IsHardMode ? "Hallow" : "") + (this._data.HasCorruption ? "Corruption" : "Crimson"), (AssetRequestMode) 1);
|
||||
|
||||
private void FavoriteMouseOver(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
if (this._data.IsFavorite)
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.Unfavorite"));
|
||||
else
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.Favorite"));
|
||||
}
|
||||
|
||||
private void CloudMouseOver(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
if (this._data.IsCloudSave)
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.MoveOffCloud"));
|
||||
else
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.MoveToCloud"));
|
||||
}
|
||||
|
||||
private void PlayMouseOver(UIMouseEvent evt, UIElement listeningElement) => this._buttonLabel.SetText(Language.GetTextValue("UI.Play"));
|
||||
|
||||
private void SeedMouseOver(UIMouseEvent evt, UIElement listeningElement) => this._buttonLabel.SetText(Language.GetTextValue("UI.CopySeed", (object) this._data.GetFullSeedText()));
|
||||
|
||||
private void DeleteMouseOver(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
if (this._data.IsFavorite)
|
||||
this._deleteButtonLabel.SetText(Language.GetTextValue("UI.CannotDeleteFavorited"));
|
||||
else
|
||||
this._deleteButtonLabel.SetText(Language.GetTextValue("UI.Delete"));
|
||||
}
|
||||
|
||||
private void DeleteMouseOut(UIMouseEvent evt, UIElement listeningElement) => this._deleteButtonLabel.SetText("");
|
||||
|
||||
private void ButtonMouseOut(UIMouseEvent evt, UIElement listeningElement) => this._buttonLabel.SetText("");
|
||||
|
||||
private void CloudButtonClick(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
if (this._data.IsCloudSave)
|
||||
this._data.MoveToLocal();
|
||||
else
|
||||
this._data.MoveToCloud();
|
||||
((UIImageButton) evt.Target).SetImage(this._data.IsCloudSave ? this._buttonCloudActiveTexture : this._buttonCloudInactiveTexture);
|
||||
if (this._data.IsCloudSave)
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.MoveOffCloud"));
|
||||
else
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.MoveToCloud"));
|
||||
}
|
||||
|
||||
private void DeleteButtonClick(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
for (int index = 0; index < Main.WorldList.Count; ++index)
|
||||
{
|
||||
if (Main.WorldList[index] == this._data)
|
||||
{
|
||||
SoundEngine.PlaySound(10);
|
||||
Main.selectedWorld = index;
|
||||
Main.menuMode = 9;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void PlayGame(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
if (listeningElement != evt.Target || this.TryMovingToRejectionMenuIfNeeded(this._data.GameMode))
|
||||
return;
|
||||
this._data.SetAsActive();
|
||||
SoundEngine.PlaySound(10);
|
||||
Main.GetInputText("");
|
||||
Main.menuMode = !Main.menuMultiplayer || SocialAPI.Network == null ? (!Main.menuMultiplayer ? 10 : 30) : 889;
|
||||
if (Main.menuMultiplayer)
|
||||
return;
|
||||
WorldGen.playWorld();
|
||||
}
|
||||
|
||||
private bool TryMovingToRejectionMenuIfNeeded(int worldGameMode)
|
||||
{
|
||||
GameModeData gameModeData;
|
||||
if (!Main.RegisterdGameModes.TryGetValue(worldGameMode, out gameModeData))
|
||||
{
|
||||
SoundEngine.PlaySound(10);
|
||||
Main.statusText = Language.GetTextValue("UI.WorldCannotBeLoadedBecauseItHasAnInvalidGameMode");
|
||||
Main.menuMode = 1000000;
|
||||
return true;
|
||||
}
|
||||
bool flag = Main.ActivePlayerFileData.Player.difficulty == (byte) 3;
|
||||
bool isJourneyMode = gameModeData.IsJourneyMode;
|
||||
if (flag && !isJourneyMode)
|
||||
{
|
||||
SoundEngine.PlaySound(10);
|
||||
Main.statusText = Language.GetTextValue("UI.PlayerIsCreativeAndWorldIsNotCreative");
|
||||
Main.menuMode = 1000000;
|
||||
return true;
|
||||
}
|
||||
if (!(!flag & isJourneyMode))
|
||||
return false;
|
||||
SoundEngine.PlaySound(10);
|
||||
Main.statusText = Language.GetTextValue("UI.PlayerIsNotCreativeAndWorldIsCreative");
|
||||
Main.menuMode = 1000000;
|
||||
return true;
|
||||
}
|
||||
|
||||
private void FavoriteButtonClick(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
this._data.ToggleFavorite();
|
||||
((UIImageButton) evt.Target).SetImage(this._data.IsFavorite ? this._buttonFavoriteActiveTexture : this._buttonFavoriteInactiveTexture);
|
||||
((UIImageButton) evt.Target).SetVisibility(1f, this._data.IsFavorite ? 0.8f : 0.4f);
|
||||
if (this._data.IsFavorite)
|
||||
{
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.Unfavorite"));
|
||||
this._deleteButton.OnClick -= new UIElement.MouseEvent(this.DeleteButtonClick);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.Favorite"));
|
||||
this._deleteButton.OnClick += new UIElement.MouseEvent(this.DeleteButtonClick);
|
||||
}
|
||||
if (!(this.Parent.Parent is UIList parent))
|
||||
return;
|
||||
parent.UpdateOrder();
|
||||
}
|
||||
|
||||
private void SeedButtonClick(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
Platform.Get<IClipboard>().Value = this._data.GetFullSeedText();
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.SeedCopied"));
|
||||
}
|
||||
|
||||
public override int CompareTo(object obj) => obj is UIWorldListItem uiWorldListItem ? this._orderInList.CompareTo(uiWorldListItem._orderInList) : base.CompareTo(obj);
|
||||
|
||||
public override void MouseOver(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseOver(evt);
|
||||
this.SetColorsToHovered();
|
||||
}
|
||||
|
||||
public override void MouseOut(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseOut(evt);
|
||||
this.SetColorsToNotHovered();
|
||||
}
|
||||
|
||||
private void DrawPanel(SpriteBatch spriteBatch, Vector2 position, float width)
|
||||
{
|
||||
spriteBatch.Draw(this._innerPanelTexture.Value, position, new Rectangle?(new Rectangle(0, 0, 8, this._innerPanelTexture.Height())), Color.White);
|
||||
spriteBatch.Draw(this._innerPanelTexture.Value, new Vector2(position.X + 8f, position.Y), new Rectangle?(new Rectangle(8, 0, 8, this._innerPanelTexture.Height())), Color.White, 0.0f, Vector2.Zero, new Vector2((float) (((double) width - 16.0) / 8.0), 1f), SpriteEffects.None, 0.0f);
|
||||
spriteBatch.Draw(this._innerPanelTexture.Value, new Vector2((float) ((double) position.X + (double) width - 8.0), position.Y), new Rectangle?(new Rectangle(16, 0, 8, this._innerPanelTexture.Height())), Color.White);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
base.DrawSelf(spriteBatch);
|
||||
CalculatedStyle innerDimensions = this.GetInnerDimensions();
|
||||
CalculatedStyle dimensions = this._worldIcon.GetDimensions();
|
||||
float x1 = dimensions.X + dimensions.Width;
|
||||
Color color1 = this._data.IsValid ? Color.White : Color.Red;
|
||||
Utils.DrawBorderString(spriteBatch, this._data.Name, new Vector2(x1 + 6f, dimensions.Y - 2f), color1);
|
||||
spriteBatch.Draw(this._dividerTexture.Value, new Vector2(x1, innerDimensions.Y + 21f), new Rectangle?(), Color.White, 0.0f, Vector2.Zero, new Vector2((float) (((double) this.GetDimensions().X + (double) this.GetDimensions().Width - (double) x1) / 8.0), 1f), SpriteEffects.None, 0.0f);
|
||||
Vector2 position = new Vector2(x1 + 6f, innerDimensions.Y + 29f);
|
||||
float width1 = 100f;
|
||||
this.DrawPanel(spriteBatch, position, width1);
|
||||
Color color2 = Color.White;
|
||||
string textValue1;
|
||||
switch (this._data.GameMode)
|
||||
{
|
||||
case 1:
|
||||
textValue1 = Language.GetTextValue("UI.Expert");
|
||||
color2 = Main.mcColor;
|
||||
break;
|
||||
case 2:
|
||||
textValue1 = Language.GetTextValue("UI.Master");
|
||||
color2 = Main.hcColor;
|
||||
break;
|
||||
case 3:
|
||||
textValue1 = Language.GetTextValue("UI.Creative");
|
||||
color2 = Main.creativeModeColor;
|
||||
break;
|
||||
default:
|
||||
textValue1 = Language.GetTextValue("UI.Normal");
|
||||
break;
|
||||
}
|
||||
float x2 = FontAssets.MouseText.Value.MeasureString(textValue1).X;
|
||||
float x3 = (float) ((double) width1 * 0.5 - (double) x2 * 0.5);
|
||||
Utils.DrawBorderString(spriteBatch, textValue1, position + new Vector2(x3, 3f), color2);
|
||||
position.X += width1 + 5f;
|
||||
float width2 = 150f;
|
||||
if (!GameCulture.FromCultureName(GameCulture.CultureName.English).IsActive)
|
||||
width2 += 40f;
|
||||
this.DrawPanel(spriteBatch, position, width2);
|
||||
string textValue2 = Language.GetTextValue("UI.WorldSizeFormat", (object) this._data.WorldSizeName);
|
||||
float x4 = FontAssets.MouseText.Value.MeasureString(textValue2).X;
|
||||
float x5 = (float) ((double) width2 * 0.5 - (double) x4 * 0.5);
|
||||
Utils.DrawBorderString(spriteBatch, textValue2, position + new Vector2(x5, 3f), Color.White);
|
||||
position.X += width2 + 5f;
|
||||
float width3 = innerDimensions.X + innerDimensions.Width - position.X;
|
||||
this.DrawPanel(spriteBatch, position, width3);
|
||||
string textValue3 = Language.GetTextValue("UI.WorldCreatedFormat", !GameCulture.FromCultureName(GameCulture.CultureName.English).IsActive ? (object) this._data.CreationTime.ToShortDateString() : (object) this._data.CreationTime.ToString("d MMMM yyyy"));
|
||||
float x6 = FontAssets.MouseText.Value.MeasureString(textValue3).X;
|
||||
float x7 = (float) ((double) width3 * 0.5 - (double) x6 * 0.5);
|
||||
Utils.DrawBorderString(spriteBatch, textValue3, position + new Vector2(x7, 3f), Color.White);
|
||||
position.X += width3 + 5f;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue