Terraria 1.4.0.5 Source Code
This commit is contained in:
commit
05205f009e
1059 changed files with 563450 additions and 0 deletions
229
GameContent/UI/States/UIAchievementsMenu.cs
Normal file
229
GameContent/UI/States/UIAchievementsMenu.cs
Normal file
|
@ -0,0 +1,229 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.States.UIAchievementsMenu
|
||||
// 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.Achievements;
|
||||
using Terraria.Audio;
|
||||
using Terraria.GameContent.UI.Elements;
|
||||
using Terraria.GameInput;
|
||||
using Terraria.ID;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI;
|
||||
using Terraria.UI.Gamepad;
|
||||
|
||||
namespace Terraria.GameContent.UI.States
|
||||
{
|
||||
public class UIAchievementsMenu : UIState
|
||||
{
|
||||
private UIList _achievementsList;
|
||||
private List<UIAchievementListItem> _achievementElements = new List<UIAchievementListItem>();
|
||||
private List<UIToggleImage> _categoryButtons = new List<UIToggleImage>();
|
||||
private UIElement _backpanel;
|
||||
private UIElement _outerContainer;
|
||||
|
||||
public void InitializePage()
|
||||
{
|
||||
this.RemoveAllChildren();
|
||||
this._categoryButtons.Clear();
|
||||
this._achievementElements.Clear();
|
||||
this._achievementsList = (UIList) null;
|
||||
bool largeForOtherLanguages = true;
|
||||
int num = largeForOtherLanguages.ToInt() * 100;
|
||||
UIElement element1 = new UIElement();
|
||||
element1.Width.Set(0.0f, 0.8f);
|
||||
element1.MaxWidth.Set(800f + (float) num, 0.0f);
|
||||
element1.MinWidth.Set(600f + (float) num, 0.0f);
|
||||
element1.Top.Set(220f, 0.0f);
|
||||
element1.Height.Set(-220f, 1f);
|
||||
element1.HAlign = 0.5f;
|
||||
this._outerContainer = element1;
|
||||
this.Append(element1);
|
||||
UIPanel uiPanel = new UIPanel();
|
||||
uiPanel.Width.Set(0.0f, 1f);
|
||||
uiPanel.Height.Set(-110f, 1f);
|
||||
uiPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f;
|
||||
uiPanel.PaddingTop = 0.0f;
|
||||
element1.Append((UIElement) uiPanel);
|
||||
this._achievementsList = new UIList();
|
||||
this._achievementsList.Width.Set(-25f, 1f);
|
||||
this._achievementsList.Height.Set(-50f, 1f);
|
||||
this._achievementsList.Top.Set(50f, 0.0f);
|
||||
this._achievementsList.ListPadding = 5f;
|
||||
uiPanel.Append((UIElement) this._achievementsList);
|
||||
UITextPanel<LocalizedText> uiTextPanel1 = new UITextPanel<LocalizedText>(Language.GetText("UI.Achievements"), large: true);
|
||||
uiTextPanel1.HAlign = 0.5f;
|
||||
uiTextPanel1.Top.Set(-33f, 0.0f);
|
||||
uiTextPanel1.SetPadding(13f);
|
||||
uiTextPanel1.BackgroundColor = new Color(73, 94, 171);
|
||||
element1.Append((UIElement) uiTextPanel1);
|
||||
UITextPanel<LocalizedText> uiTextPanel2 = new UITextPanel<LocalizedText>(Language.GetText("UI.Back"), 0.7f, true);
|
||||
uiTextPanel2.Width.Set(-10f, 0.5f);
|
||||
uiTextPanel2.Height.Set(50f, 0.0f);
|
||||
uiTextPanel2.VAlign = 1f;
|
||||
uiTextPanel2.HAlign = 0.5f;
|
||||
uiTextPanel2.Top.Set(-45f, 0.0f);
|
||||
uiTextPanel2.OnMouseOver += new UIElement.MouseEvent(this.FadedMouseOver);
|
||||
uiTextPanel2.OnMouseOut += new UIElement.MouseEvent(this.FadedMouseOut);
|
||||
uiTextPanel2.OnClick += new UIElement.MouseEvent(this.GoBackClick);
|
||||
element1.Append((UIElement) uiTextPanel2);
|
||||
this._backpanel = (UIElement) uiTextPanel2;
|
||||
List<Achievement> achievementsList = Main.Achievements.CreateAchievementsList();
|
||||
for (int index = 0; index < achievementsList.Count; ++index)
|
||||
{
|
||||
UIAchievementListItem achievementListItem = new UIAchievementListItem(achievementsList[index], largeForOtherLanguages);
|
||||
this._achievementsList.Add((UIElement) achievementListItem);
|
||||
this._achievementElements.Add(achievementListItem);
|
||||
}
|
||||
UIScrollbar scrollbar = new UIScrollbar();
|
||||
scrollbar.SetView(100f, 1000f);
|
||||
scrollbar.Height.Set(-50f, 1f);
|
||||
scrollbar.Top.Set(50f, 0.0f);
|
||||
scrollbar.HAlign = 1f;
|
||||
uiPanel.Append((UIElement) scrollbar);
|
||||
this._achievementsList.SetScrollbar(scrollbar);
|
||||
UIElement element2 = new UIElement();
|
||||
element2.Width.Set(0.0f, 1f);
|
||||
element2.Height.Set(32f, 0.0f);
|
||||
element2.Top.Set(10f, 0.0f);
|
||||
Asset<Texture2D> texture = Main.Assets.Request<Texture2D>("Images/UI/Achievement_Categories", (AssetRequestMode) 1);
|
||||
for (int index = 0; index < 4; ++index)
|
||||
{
|
||||
UIToggleImage uiToggleImage = new UIToggleImage(texture, 32, 32, new Point(34 * index, 0), new Point(34 * index, 34));
|
||||
uiToggleImage.Left.Set((float) (index * 36 + 8), 0.0f);
|
||||
uiToggleImage.SetState(true);
|
||||
uiToggleImage.OnClick += new UIElement.MouseEvent(this.FilterList);
|
||||
this._categoryButtons.Add(uiToggleImage);
|
||||
element2.Append((UIElement) uiToggleImage);
|
||||
}
|
||||
uiPanel.Append(element2);
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
base.Draw(spriteBatch);
|
||||
for (int index = 0; index < this._categoryButtons.Count; ++index)
|
||||
{
|
||||
if (this._categoryButtons[index].IsMouseHovering)
|
||||
{
|
||||
string textValue;
|
||||
switch (index)
|
||||
{
|
||||
case -1:
|
||||
textValue = Language.GetTextValue("Achievements.NoCategory");
|
||||
break;
|
||||
case 0:
|
||||
textValue = Language.GetTextValue("Achievements.SlayerCategory");
|
||||
break;
|
||||
case 1:
|
||||
textValue = Language.GetTextValue("Achievements.CollectorCategory");
|
||||
break;
|
||||
case 2:
|
||||
textValue = Language.GetTextValue("Achievements.ExplorerCategory");
|
||||
break;
|
||||
case 3:
|
||||
textValue = Language.GetTextValue("Achievements.ChallengerCategory");
|
||||
break;
|
||||
default:
|
||||
textValue = Language.GetTextValue("Achievements.NoCategory");
|
||||
break;
|
||||
}
|
||||
float x = FontAssets.MouseText.Value.MeasureString(textValue).X;
|
||||
Vector2 vector2 = new Vector2((float) Main.mouseX, (float) Main.mouseY) + new Vector2(16f);
|
||||
if ((double) vector2.Y > (double) (Main.screenHeight - 30))
|
||||
vector2.Y = (float) (Main.screenHeight - 30);
|
||||
if ((double) vector2.X > (double) Main.screenWidth - (double) x)
|
||||
vector2.X = (float) (Main.screenWidth - 460);
|
||||
Utils.DrawBorderStringFourWay(spriteBatch, FontAssets.MouseText.Value, textValue, vector2.X, vector2.Y, new Color((int) Main.mouseTextColor, (int) Main.mouseTextColor, (int) Main.mouseTextColor, (int) Main.mouseTextColor), Color.Black, Vector2.Zero);
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.SetupGamepadPoints(spriteBatch);
|
||||
}
|
||||
|
||||
public void GotoAchievement(Achievement achievement) => this._achievementsList.Goto((UIList.ElementSearchMethod) (element => element is UIAchievementListItem achievementListItem && achievementListItem.GetAchievement() == achievement));
|
||||
|
||||
private void GoBackClick(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
Main.menuMode = 0;
|
||||
IngameFancyUI.Close();
|
||||
}
|
||||
|
||||
private void FadedMouseOver(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
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 FilterList(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
SoundEngine.PlaySound(12);
|
||||
this._achievementsList.Clear();
|
||||
foreach (UIAchievementListItem achievementElement in this._achievementElements)
|
||||
{
|
||||
if (this._categoryButtons[(int) achievementElement.GetAchievement().Category].IsOn)
|
||||
this._achievementsList.Add((UIElement) achievementElement);
|
||||
}
|
||||
this.Recalculate();
|
||||
}
|
||||
|
||||
public override void OnActivate()
|
||||
{
|
||||
this.InitializePage();
|
||||
if (Main.gameMenu)
|
||||
{
|
||||
this._outerContainer.Top.Set(220f, 0.0f);
|
||||
this._outerContainer.Height.Set(-220f, 1f);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._outerContainer.Top.Set(120f, 0.0f);
|
||||
this._outerContainer.Height.Set(-120f, 1f);
|
||||
}
|
||||
this._achievementsList.UpdateOrder();
|
||||
if (!PlayerInput.UsingGamepadUI)
|
||||
return;
|
||||
UILinkPointNavigator.ChangePoint(3002);
|
||||
}
|
||||
|
||||
private void SetupGamepadPoints(SpriteBatch spriteBatch)
|
||||
{
|
||||
UILinkPointNavigator.Shortcuts.BackButtonCommand = 3;
|
||||
int ID = 3000;
|
||||
UILinkPointNavigator.SetPosition(ID, this._backpanel.GetInnerDimensions().ToRectangle().Center.ToVector2());
|
||||
UILinkPointNavigator.SetPosition(ID + 1, this._outerContainer.GetInnerDimensions().ToRectangle().Center.ToVector2());
|
||||
int key = ID;
|
||||
UILinkPoint point1 = UILinkPointNavigator.Points[key];
|
||||
point1.Unlink();
|
||||
point1.Up = key + 1;
|
||||
int num = key + 1;
|
||||
UILinkPoint point2 = UILinkPointNavigator.Points[num];
|
||||
point2.Unlink();
|
||||
point2.Up = num + 1;
|
||||
point2.Down = num - 1;
|
||||
for (int index = 0; index < this._categoryButtons.Count; ++index)
|
||||
{
|
||||
++num;
|
||||
UILinkPointNavigator.Shortcuts.FANCYUI_HIGHEST_INDEX = num;
|
||||
UILinkPointNavigator.SetPosition(num, this._categoryButtons[index].GetInnerDimensions().ToRectangle().Center.ToVector2());
|
||||
UILinkPoint point3 = UILinkPointNavigator.Points[num];
|
||||
point3.Unlink();
|
||||
point3.Left = index == 0 ? -3 : num - 1;
|
||||
point3.Right = index == this._categoryButtons.Count - 1 ? -4 : num + 1;
|
||||
point3.Down = ID;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
844
GameContent/UI/States/UIBestiaryTest.cs
Normal file
844
GameContent/UI/States/UIBestiaryTest.cs
Normal file
|
@ -0,0 +1,844 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.States.UIBestiaryTest
|
||||
// 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.Bestiary;
|
||||
using Terraria.GameContent.UI.Elements;
|
||||
using Terraria.GameInput;
|
||||
using Terraria.ID;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI;
|
||||
using Terraria.UI.Gamepad;
|
||||
|
||||
namespace Terraria.GameContent.UI.States
|
||||
{
|
||||
public class UIBestiaryTest : UIState
|
||||
{
|
||||
private UIElement _bestiarySpace;
|
||||
private UIBestiaryEntryInfoPage _infoSpace;
|
||||
private UIBestiaryEntryButton _selectedEntryButton;
|
||||
private List<BestiaryEntry> _originalEntriesList;
|
||||
private List<BestiaryEntry> _workingSetEntries;
|
||||
private UIText _indexesRangeText;
|
||||
private EntryFilterer<BestiaryEntry, IBestiaryEntryFilter> _filterer = new EntryFilterer<BestiaryEntry, IBestiaryEntryFilter>();
|
||||
private EntrySorter<BestiaryEntry, IBestiarySortStep> _sorter = new EntrySorter<BestiaryEntry, IBestiarySortStep>();
|
||||
private UIBestiaryEntryGrid _entryGrid;
|
||||
private UIBestiarySortingOptionsGrid _sortingGrid;
|
||||
private UIBestiaryFilteringOptionsGrid _filteringGrid;
|
||||
private UISearchBar _searchBar;
|
||||
private UIPanel _searchBoxPanel;
|
||||
private UIText _sortingText;
|
||||
private UIText _filteringText;
|
||||
private string _searchString;
|
||||
private BestiaryUnlockProgressReport _progressReport;
|
||||
private UIText _progressPercentText;
|
||||
private UIColoredSliderSimple _unlocksProgressBar;
|
||||
|
||||
public UIBestiaryTest(BestiaryDatabase database)
|
||||
{
|
||||
this._filterer.SetSearchFilterObject<Filters.BySearch>(new Filters.BySearch());
|
||||
this._originalEntriesList = new List<BestiaryEntry>((IEnumerable<BestiaryEntry>) database.Entries);
|
||||
this._workingSetEntries = new List<BestiaryEntry>((IEnumerable<BestiaryEntry>) this._originalEntriesList);
|
||||
this._filterer.AddFilters(database.Filters);
|
||||
this._sorter.AddSortSteps(database.SortSteps);
|
||||
this.BuildPage();
|
||||
}
|
||||
|
||||
public void OnOpenPage() => this.UpdateBestiaryContents();
|
||||
|
||||
private void BuildPage()
|
||||
{
|
||||
this.RemoveAllChildren();
|
||||
int num1 = true.ToInt() * 100;
|
||||
UIElement uiElement1 = new UIElement();
|
||||
uiElement1.Width.Set(0.0f, 0.875f);
|
||||
uiElement1.MaxWidth.Set(800f + (float) num1, 0.0f);
|
||||
uiElement1.MinWidth.Set(600f + (float) num1, 0.0f);
|
||||
uiElement1.Top.Set(220f, 0.0f);
|
||||
uiElement1.Height.Set(-220f, 1f);
|
||||
uiElement1.HAlign = 0.5f;
|
||||
this.Append(uiElement1);
|
||||
this.MakeExitButton(uiElement1);
|
||||
UIPanel uiPanel = new UIPanel();
|
||||
uiPanel.Width.Set(0.0f, 1f);
|
||||
uiPanel.Height.Set(-90f, 1f);
|
||||
uiPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f;
|
||||
uiElement1.Append((UIElement) uiPanel);
|
||||
uiPanel.PaddingTop -= 4f;
|
||||
uiPanel.PaddingBottom -= 4f;
|
||||
int num2 = 24;
|
||||
UIElement uiElement2 = new UIElement()
|
||||
{
|
||||
Width = new StyleDimension(0.0f, 1f),
|
||||
Height = new StyleDimension((float) num2, 0.0f),
|
||||
VAlign = 0.0f
|
||||
};
|
||||
uiElement2.SetPadding(0.0f);
|
||||
uiPanel.Append(uiElement2);
|
||||
UIBestiaryEntryInfoPage bestiaryEntryInfoPage = new UIBestiaryEntryInfoPage();
|
||||
bestiaryEntryInfoPage.Height = new StyleDimension(12f, 1f);
|
||||
bestiaryEntryInfoPage.HAlign = 1f;
|
||||
UIBestiaryEntryInfoPage infoSpace = bestiaryEntryInfoPage;
|
||||
this.AddSortAndFilterButtons(uiElement2, infoSpace);
|
||||
this.AddSearchBar(uiElement2, infoSpace);
|
||||
int num3 = 20;
|
||||
UIElement element1 = new UIElement()
|
||||
{
|
||||
Width = new StyleDimension(0.0f, 1f),
|
||||
Height = new StyleDimension((float) (-num2 - 6 - num3), 1f),
|
||||
VAlign = 1f,
|
||||
Top = new StyleDimension((float) -num3, 0.0f)
|
||||
};
|
||||
element1.SetPadding(0.0f);
|
||||
uiPanel.Append(element1);
|
||||
UIElement uiElement3 = new UIElement()
|
||||
{
|
||||
Width = new StyleDimension(0.0f, 1f),
|
||||
Height = new StyleDimension(20f, 0.0f),
|
||||
VAlign = 1f
|
||||
};
|
||||
uiPanel.Append(uiElement3);
|
||||
uiElement3.SetPadding(0.0f);
|
||||
this.FillProgressBottomBar(uiElement3);
|
||||
UIElement element2 = new UIElement()
|
||||
{
|
||||
Width = new StyleDimension(-12f - infoSpace.Width.Pixels, 1f),
|
||||
Height = new StyleDimension(-4f, 1f),
|
||||
VAlign = 1f
|
||||
};
|
||||
element1.Append(element2);
|
||||
element2.SetPadding(0.0f);
|
||||
this._bestiarySpace = element2;
|
||||
UIBestiaryEntryGrid bestiaryEntryGrid = new UIBestiaryEntryGrid(this._workingSetEntries, new UIElement.MouseEvent(this.Click_SelectEntryButton));
|
||||
element2.Append((UIElement) bestiaryEntryGrid);
|
||||
this._entryGrid = bestiaryEntryGrid;
|
||||
this._entryGrid.OnGridContentsChanged += new Action(this.UpdateBestiaryGridRange);
|
||||
element1.Append((UIElement) infoSpace);
|
||||
this._infoSpace = infoSpace;
|
||||
this.AddBackAndForwardButtons(uiElement2);
|
||||
this._sortingGrid = new UIBestiarySortingOptionsGrid(this._sorter);
|
||||
this._sortingGrid.OnClick += new UIElement.MouseEvent(this.Click_CloseSortingGrid);
|
||||
this._sortingGrid.OnClickingOption += new Action(this.UpdateBestiaryContents);
|
||||
this._filteringGrid = new UIBestiaryFilteringOptionsGrid(this._filterer);
|
||||
this._filteringGrid.OnClick += new UIElement.MouseEvent(this.Click_CloseFilteringGrid);
|
||||
this._filteringGrid.OnClickingOption += new Action(this.UpdateBestiaryContents);
|
||||
this._filteringGrid.SetupAvailabilityTest(this._originalEntriesList);
|
||||
this._searchBar.SetContents((string) null, true);
|
||||
this.UpdateBestiaryContents();
|
||||
}
|
||||
|
||||
private void FillProgressBottomBar(UIElement container)
|
||||
{
|
||||
UIText uiText = new UIText("", 0.8f);
|
||||
uiText.HAlign = 0.0f;
|
||||
uiText.VAlign = 1f;
|
||||
uiText.TextOriginX = 0.0f;
|
||||
this._progressPercentText = uiText;
|
||||
UIColoredSliderSimple coloredSliderSimple1 = new UIColoredSliderSimple();
|
||||
coloredSliderSimple1.Width = new StyleDimension(0.0f, 1f);
|
||||
coloredSliderSimple1.Height = new StyleDimension(15f, 0.0f);
|
||||
coloredSliderSimple1.VAlign = 1f;
|
||||
coloredSliderSimple1.FilledColor = new Color(51, 137, (int) byte.MaxValue);
|
||||
coloredSliderSimple1.EmptyColor = new Color(35, 43, 81);
|
||||
coloredSliderSimple1.FillPercent = 0.0f;
|
||||
UIColoredSliderSimple coloredSliderSimple2 = coloredSliderSimple1;
|
||||
coloredSliderSimple2.OnUpdate += new UIElement.ElementEvent(this.ShowStats_Completion);
|
||||
this._unlocksProgressBar = coloredSliderSimple2;
|
||||
container.Append((UIElement) coloredSliderSimple2);
|
||||
}
|
||||
|
||||
private void ShowStats_Completion(UIElement element)
|
||||
{
|
||||
if (!element.IsMouseHovering)
|
||||
return;
|
||||
string completionPercentText = this.GetCompletionPercentText();
|
||||
Main.instance.MouseText(completionPercentText);
|
||||
}
|
||||
|
||||
private string GetCompletionPercentText() => Language.GetTextValueWith("BestiaryInfo.PercentCollected", (object) new
|
||||
{
|
||||
Percent = Utils.PrettifyPercentDisplay(this.GetProgressPercent(), "P2")
|
||||
});
|
||||
|
||||
private float GetProgressPercent() => this._progressReport.CompletionPercent;
|
||||
|
||||
private void EmptyInteraction(float input)
|
||||
{
|
||||
}
|
||||
|
||||
private void EmptyInteraction2()
|
||||
{
|
||||
}
|
||||
|
||||
private Color GetColorAtBlip(float percentile) => (double) percentile < (double) this.GetProgressPercent() ? new Color(51, 137, (int) byte.MaxValue) : new Color(35, 40, 83);
|
||||
|
||||
private void AddBackAndForwardButtons(UIElement innerTopContainer)
|
||||
{
|
||||
UIImageButton uiImageButton1 = new UIImageButton(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Button_Back", (AssetRequestMode) 1));
|
||||
uiImageButton1.SetHoverImage(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Button_Border", (AssetRequestMode) 1));
|
||||
uiImageButton1.SetVisibility(1f, 1f);
|
||||
uiImageButton1.SetSnapPoint("BackPage", 0);
|
||||
this._entryGrid.MakeButtonGoByOffset((UIElement) uiImageButton1, -1);
|
||||
innerTopContainer.Append((UIElement) uiImageButton1);
|
||||
UIImageButton uiImageButton2 = new UIImageButton(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Button_Forward", (AssetRequestMode) 1));
|
||||
uiImageButton2.Left = new StyleDimension(uiImageButton1.Width.Pixels + 1f, 0.0f);
|
||||
UIImageButton uiImageButton3 = uiImageButton2;
|
||||
uiImageButton3.SetHoverImage(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Button_Border", (AssetRequestMode) 1));
|
||||
uiImageButton3.SetVisibility(1f, 1f);
|
||||
uiImageButton3.SetSnapPoint("NextPage", 0);
|
||||
this._entryGrid.MakeButtonGoByOffset((UIElement) uiImageButton3, 1);
|
||||
innerTopContainer.Append((UIElement) uiImageButton3);
|
||||
UIPanel uiPanel1 = new UIPanel();
|
||||
uiPanel1.Left = new StyleDimension((float) ((double) uiImageButton1.Width.Pixels + 1.0 + (double) uiImageButton3.Width.Pixels + 3.0), 0.0f);
|
||||
uiPanel1.Width = new StyleDimension(135f, 0.0f);
|
||||
uiPanel1.Height = new StyleDimension(0.0f, 1f);
|
||||
uiPanel1.VAlign = 0.5f;
|
||||
UIPanel uiPanel2 = uiPanel1;
|
||||
uiPanel2.BackgroundColor = new Color(35, 40, 83);
|
||||
uiPanel2.BorderColor = new Color(35, 40, 83);
|
||||
uiPanel2.SetPadding(0.0f);
|
||||
innerTopContainer.Append((UIElement) uiPanel2);
|
||||
UIText uiText1 = new UIText("9000-9999 (9001)", 0.8f);
|
||||
uiText1.HAlign = 0.5f;
|
||||
uiText1.VAlign = 0.5f;
|
||||
UIText uiText2 = uiText1;
|
||||
uiPanel2.Append((UIElement) uiText2);
|
||||
this._indexesRangeText = uiText2;
|
||||
}
|
||||
|
||||
private void AddSortAndFilterButtons(
|
||||
UIElement innerTopContainer,
|
||||
UIBestiaryEntryInfoPage infoSpace)
|
||||
{
|
||||
int num = 17;
|
||||
UIImageButton uiImageButton1 = new UIImageButton(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Button_Filtering", (AssetRequestMode) 1));
|
||||
uiImageButton1.Left = new StyleDimension(-infoSpace.Width.Pixels - (float) num, 0.0f);
|
||||
uiImageButton1.HAlign = 1f;
|
||||
UIImageButton uiImageButton2 = uiImageButton1;
|
||||
uiImageButton2.SetHoverImage(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Button_Wide_Border", (AssetRequestMode) 1));
|
||||
uiImageButton2.SetVisibility(1f, 1f);
|
||||
uiImageButton2.SetSnapPoint("FilterButton", 0);
|
||||
uiImageButton2.OnClick += new UIElement.MouseEvent(this.OpenOrCloseFilteringGrid);
|
||||
innerTopContainer.Append((UIElement) uiImageButton2);
|
||||
UIText uiText1 = new UIText("", 0.8f);
|
||||
uiText1.Left = new StyleDimension(34f, 0.0f);
|
||||
uiText1.Top = new StyleDimension(2f, 0.0f);
|
||||
uiText1.VAlign = 0.5f;
|
||||
uiText1.TextOriginX = 0.0f;
|
||||
UIText uiText2 = uiText1;
|
||||
uiImageButton2.Append((UIElement) uiText2);
|
||||
this._filteringText = uiText2;
|
||||
UIImageButton uiImageButton3 = new UIImageButton(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Button_Sorting", (AssetRequestMode) 1));
|
||||
uiImageButton3.Left = new StyleDimension((float) (-(double) infoSpace.Width.Pixels - (double) uiImageButton2.Width.Pixels - 3.0) - (float) num, 0.0f);
|
||||
uiImageButton3.HAlign = 1f;
|
||||
UIImageButton uiImageButton4 = uiImageButton3;
|
||||
uiImageButton4.SetHoverImage(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Button_Wide_Border", (AssetRequestMode) 1));
|
||||
uiImageButton4.SetVisibility(1f, 1f);
|
||||
uiImageButton4.SetSnapPoint("SortButton", 0);
|
||||
uiImageButton4.OnClick += new UIElement.MouseEvent(this.OpenOrCloseSortingOptions);
|
||||
innerTopContainer.Append((UIElement) uiImageButton4);
|
||||
UIText uiText3 = new UIText("", 0.8f);
|
||||
uiText3.Left = new StyleDimension(34f, 0.0f);
|
||||
uiText3.Top = new StyleDimension(2f, 0.0f);
|
||||
uiText3.VAlign = 0.5f;
|
||||
uiText3.TextOriginX = 0.0f;
|
||||
UIText uiText4 = uiText3;
|
||||
uiImageButton4.Append((UIElement) uiText4);
|
||||
this._sortingText = uiText4;
|
||||
}
|
||||
|
||||
private void AddSearchBar(UIElement innerTopContainer, UIBestiaryEntryInfoPage infoSpace)
|
||||
{
|
||||
UIImageButton uiImageButton1 = new UIImageButton(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Button_Search", (AssetRequestMode) 1));
|
||||
uiImageButton1.Left = new StyleDimension(-infoSpace.Width.Pixels, 1f);
|
||||
uiImageButton1.VAlign = 0.5f;
|
||||
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("SearchButton", 0);
|
||||
innerTopContainer.Append((UIElement) uiImageButton2);
|
||||
UIPanel uiPanel1 = new UIPanel();
|
||||
uiPanel1.Left = new StyleDimension((float) (-(double) infoSpace.Width.Pixels + (double) uiImageButton2.Width.Pixels + 3.0), 1f);
|
||||
uiPanel1.Width = new StyleDimension((float) ((double) infoSpace.Width.Pixels - (double) uiImageButton2.Width.Pixels - 3.0), 0.0f);
|
||||
uiPanel1.Height = new StyleDimension(0.0f, 1f);
|
||||
uiPanel1.VAlign = 0.5f;
|
||||
UIPanel uiPanel2 = uiPanel1;
|
||||
this._searchBoxPanel = uiPanel2;
|
||||
uiPanel2.BackgroundColor = new Color(35, 40, 83);
|
||||
uiPanel2.BorderColor = new Color(35, 40, 83);
|
||||
uiPanel2.SetPadding(0.0f);
|
||||
innerTopContainer.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);
|
||||
}
|
||||
|
||||
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), allowEmpty: true);
|
||||
uiVirtualKeyboard.SetMaxInputLength(length);
|
||||
UserInterface.ActiveInstance.SetState((UIState) uiVirtualKeyboard);
|
||||
}
|
||||
|
||||
private void OnFinishedSettingName(string name)
|
||||
{
|
||||
this._searchBar.SetContents(name.Trim());
|
||||
this.GoBackHere();
|
||||
}
|
||||
|
||||
private void GoBackHere()
|
||||
{
|
||||
UserInterface.ActiveInstance.SetState((UIState) this);
|
||||
this._searchBar.ToggleTakingText();
|
||||
}
|
||||
|
||||
private void OnStartTakingInput() => this._searchBoxPanel.BorderColor = Main.OurFavoriteColor;
|
||||
|
||||
private void OnEndTakingInput() => this._searchBoxPanel.BorderColor = new Color(35, 40, 83);
|
||||
|
||||
private void OnSearchContentsChanged(string contents)
|
||||
{
|
||||
this._searchString = contents;
|
||||
this._filterer.SetSearchFilter(contents);
|
||||
this.UpdateBestiaryContents();
|
||||
}
|
||||
|
||||
private void Click_SearchArea(UIMouseEvent evt, UIElement listeningElement) => this._searchBar.ToggleTakingText();
|
||||
|
||||
private void FilterEntries()
|
||||
{
|
||||
this._workingSetEntries.Clear();
|
||||
this._workingSetEntries.AddRange(this._originalEntriesList.Where<BestiaryEntry>(new Func<BestiaryEntry, bool>(this._filterer.FitsFilter)));
|
||||
}
|
||||
|
||||
private void SortEntries() => this._workingSetEntries.Sort((IComparer<BestiaryEntry>) this._sorter);
|
||||
|
||||
private void FillBestiarySpaceWithEntries()
|
||||
{
|
||||
if (this._entryGrid == null || this._entryGrid.Parent == null)
|
||||
return;
|
||||
this.DeselectEntryButton();
|
||||
this._progressReport = this.GetUnlockProgress();
|
||||
this._entryGrid.FillBestiarySpaceWithEntries();
|
||||
}
|
||||
|
||||
public void UpdateBestiaryGridRange() => this._indexesRangeText.SetText(this._entryGrid.GetRangeText());
|
||||
|
||||
public override void Recalculate()
|
||||
{
|
||||
base.Recalculate();
|
||||
this.FillBestiarySpaceWithEntries();
|
||||
}
|
||||
|
||||
private void GetEntriesToShow(
|
||||
out int maxEntriesWidth,
|
||||
out int maxEntriesHeight,
|
||||
out int maxEntriesToHave)
|
||||
{
|
||||
Rectangle rectangle = this._bestiarySpace.GetDimensions().ToRectangle();
|
||||
maxEntriesWidth = rectangle.Width / 72;
|
||||
maxEntriesHeight = rectangle.Height / 72;
|
||||
int num = 0;
|
||||
maxEntriesToHave = maxEntriesWidth * maxEntriesHeight - num;
|
||||
}
|
||||
|
||||
private void MakeExitButton(UIElement outerContainer)
|
||||
{
|
||||
UITextPanel<LocalizedText> uiTextPanel1 = new UITextPanel<LocalizedText>(Language.GetText("UI.Back"), 0.7f, true);
|
||||
uiTextPanel1.Width = StyleDimension.FromPixelsAndPercent(-10f, 0.5f);
|
||||
uiTextPanel1.Height = StyleDimension.FromPixels(50f);
|
||||
uiTextPanel1.VAlign = 1f;
|
||||
uiTextPanel1.HAlign = 0.5f;
|
||||
uiTextPanel1.Top = StyleDimension.FromPixels(-25f);
|
||||
UITextPanel<LocalizedText> uiTextPanel2 = uiTextPanel1;
|
||||
uiTextPanel2.OnMouseOver += new UIElement.MouseEvent(this.FadedMouseOver);
|
||||
uiTextPanel2.OnMouseOut += new UIElement.MouseEvent(this.FadedMouseOut);
|
||||
uiTextPanel2.OnMouseDown += new UIElement.MouseEvent(this.Click_GoBack);
|
||||
uiTextPanel2.SetSnapPoint("ExitButton", 0);
|
||||
outerContainer.Append((UIElement) uiTextPanel2);
|
||||
}
|
||||
|
||||
private void Click_GoBack(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
SoundEngine.PlaySound(11);
|
||||
if (Main.gameMenu)
|
||||
Main.menuMode = 0;
|
||||
else
|
||||
IngameFancyUI.Close();
|
||||
}
|
||||
|
||||
private void OpenOrCloseSortingOptions(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
if (this._sortingGrid.Parent != null)
|
||||
{
|
||||
this.CloseSortingGrid();
|
||||
}
|
||||
else
|
||||
{
|
||||
this._bestiarySpace.RemoveChild((UIElement) this._sortingGrid);
|
||||
this._bestiarySpace.RemoveChild((UIElement) this._filteringGrid);
|
||||
this._bestiarySpace.Append((UIElement) this._sortingGrid);
|
||||
}
|
||||
}
|
||||
|
||||
private void OpenOrCloseFilteringGrid(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
if (this._filteringGrid.Parent != null)
|
||||
{
|
||||
this.CloseFilteringGrid();
|
||||
}
|
||||
else
|
||||
{
|
||||
this._bestiarySpace.RemoveChild((UIElement) this._sortingGrid);
|
||||
this._bestiarySpace.RemoveChild((UIElement) this._filteringGrid);
|
||||
this._bestiarySpace.Append((UIElement) this._filteringGrid);
|
||||
}
|
||||
}
|
||||
|
||||
private void Click_CloseFilteringGrid(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
if (evt.Target != this._filteringGrid)
|
||||
return;
|
||||
this.CloseFilteringGrid();
|
||||
}
|
||||
|
||||
private void CloseFilteringGrid()
|
||||
{
|
||||
this.UpdateBestiaryContents();
|
||||
this._bestiarySpace.RemoveChild((UIElement) this._filteringGrid);
|
||||
}
|
||||
|
||||
private void UpdateBestiaryContents()
|
||||
{
|
||||
this._filteringGrid.UpdateAvailability();
|
||||
this._sortingText.SetText(this._sorter.GetDisplayName());
|
||||
this._filteringText.SetText(this._filterer.GetDisplayName());
|
||||
this.FilterEntries();
|
||||
this.SortEntries();
|
||||
this.FillBestiarySpaceWithEntries();
|
||||
this._progressReport = this.GetUnlockProgress();
|
||||
this._progressPercentText.SetText(this.GetCompletionPercentText());
|
||||
this._unlocksProgressBar.FillPercent = this.GetProgressPercent();
|
||||
}
|
||||
|
||||
private void Click_CloseSortingGrid(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
if (evt.Target != this._sortingGrid)
|
||||
return;
|
||||
this.CloseSortingGrid();
|
||||
}
|
||||
|
||||
private void CloseSortingGrid()
|
||||
{
|
||||
this.UpdateBestiaryContents();
|
||||
this._bestiarySpace.RemoveChild((UIElement) this._sortingGrid);
|
||||
}
|
||||
|
||||
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 Click_SelectEntryButton(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
UIBestiaryEntryButton button = (UIBestiaryEntryButton) listeningElement;
|
||||
if (button == null)
|
||||
return;
|
||||
this.SelectEntryButton(button);
|
||||
}
|
||||
|
||||
private void SelectEntryButton(UIBestiaryEntryButton button)
|
||||
{
|
||||
this.DeselectEntryButton();
|
||||
this._selectedEntryButton = button;
|
||||
this._infoSpace.FillInfoForEntry(button.Entry, new ExtraBestiaryInfoPageInformation()
|
||||
{
|
||||
BestiaryProgressReport = this._progressReport
|
||||
});
|
||||
}
|
||||
|
||||
private void DeselectEntryButton() => this._infoSpace.FillInfoForEntry((BestiaryEntry) null, new ExtraBestiaryInfoPageInformation());
|
||||
|
||||
public BestiaryUnlockProgressReport GetUnlockProgress()
|
||||
{
|
||||
float num1 = 0.0f;
|
||||
int num2 = 0;
|
||||
List<BestiaryEntry> originalEntriesList = this._originalEntriesList;
|
||||
for (int index = 0; index < originalEntriesList.Count; ++index)
|
||||
{
|
||||
int num3 = originalEntriesList[index].UIInfoProvider.GetEntryUICollectionInfo().UnlockState > BestiaryEntryUnlockState.NotKnownAtAll_0 ? 1 : 0;
|
||||
++num2;
|
||||
num1 += (float) num3;
|
||||
}
|
||||
return new BestiaryUnlockProgressReport()
|
||||
{
|
||||
EntriesTotal = num2,
|
||||
CompletionAmountTotal = num1
|
||||
};
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
base.Draw(spriteBatch);
|
||||
this.SetupGamepadPoints(spriteBatch);
|
||||
}
|
||||
|
||||
private void SetupGamepadPoints(SpriteBatch spriteBatch)
|
||||
{
|
||||
UILinkPointNavigator.Shortcuts.BackButtonCommand = 1;
|
||||
int num1 = 3000;
|
||||
int num2 = num1;
|
||||
List<SnapPoint> snapPoints = this.GetSnapPoints();
|
||||
SnapPoint snap1 = (SnapPoint) null;
|
||||
SnapPoint snap2 = (SnapPoint) null;
|
||||
SnapPoint snap3 = (SnapPoint) null;
|
||||
SnapPoint snap4 = (SnapPoint) null;
|
||||
SnapPoint snap5 = (SnapPoint) null;
|
||||
SnapPoint snap6 = (SnapPoint) null;
|
||||
for (int index = 0; index < snapPoints.Count; ++index)
|
||||
{
|
||||
SnapPoint snapPoint = snapPoints[index];
|
||||
string name = snapPoint.Name;
|
||||
if (!(name == "BackPage"))
|
||||
{
|
||||
if (!(name == "NextPage"))
|
||||
{
|
||||
if (!(name == "ExitButton"))
|
||||
{
|
||||
if (!(name == "FilterButton"))
|
||||
{
|
||||
if (!(name == "SortButton"))
|
||||
{
|
||||
if (name == "SearchButton")
|
||||
snap5 = snapPoint;
|
||||
}
|
||||
else
|
||||
snap3 = snapPoint;
|
||||
}
|
||||
else
|
||||
snap4 = snapPoint;
|
||||
}
|
||||
else
|
||||
snap6 = snapPoint;
|
||||
}
|
||||
else
|
||||
snap2 = snapPoint;
|
||||
}
|
||||
else
|
||||
snap1 = snapPoint;
|
||||
}
|
||||
int id1 = num2;
|
||||
int num3 = id1 + 1;
|
||||
UILinkPoint uiLinkPoint1 = this.MakeLinkPointFromSnapPoint(id1, snap1);
|
||||
int id2 = num3;
|
||||
int num4 = id2 + 1;
|
||||
UILinkPoint uiLinkPoint2 = this.MakeLinkPointFromSnapPoint(id2, snap2);
|
||||
int id3 = num4;
|
||||
int num5 = id3 + 1;
|
||||
UILinkPoint downSide1 = this.MakeLinkPointFromSnapPoint(id3, snap6);
|
||||
int id4 = num5;
|
||||
int num6 = id4 + 1;
|
||||
UILinkPoint uiLinkPoint3 = this.MakeLinkPointFromSnapPoint(id4, snap4);
|
||||
int id5 = num6;
|
||||
int num7 = id5 + 1;
|
||||
UILinkPoint uiLinkPoint4 = this.MakeLinkPointFromSnapPoint(id5, snap3);
|
||||
int id6 = num7;
|
||||
int currentID = id6 + 1;
|
||||
UILinkPoint rightSide = this.MakeLinkPointFromSnapPoint(id6, snap5);
|
||||
this.PairLeftRight(uiLinkPoint1, uiLinkPoint2);
|
||||
this.PairLeftRight(uiLinkPoint2, uiLinkPoint4);
|
||||
this.PairLeftRight(uiLinkPoint4, uiLinkPoint3);
|
||||
this.PairLeftRight(uiLinkPoint3, rightSide);
|
||||
downSide1.Up = uiLinkPoint2.ID;
|
||||
UILinkPoint[,] gridPoints = new UILinkPoint[1, 1];
|
||||
if (this._filteringGrid.Parent != null)
|
||||
{
|
||||
int gridWidth;
|
||||
int gridHeight;
|
||||
this.SetupPointsForFilterGrid(ref currentID, snapPoints, out gridWidth, out gridHeight, out gridPoints);
|
||||
this.PairUpDown(uiLinkPoint2, downSide1);
|
||||
this.PairUpDown(uiLinkPoint1, downSide1);
|
||||
for (int index = gridWidth - 1; index >= 0; --index)
|
||||
{
|
||||
UILinkPoint upSide1 = gridPoints[index, gridHeight - 1];
|
||||
if (upSide1 != null)
|
||||
this.PairUpDown(upSide1, downSide1);
|
||||
UILinkPoint upSide2 = gridPoints[index, gridHeight - 2];
|
||||
if (upSide2 != null && upSide1 == null)
|
||||
this.PairUpDown(upSide2, downSide1);
|
||||
UILinkPoint downSide2 = gridPoints[index, 0];
|
||||
if (downSide2 != null)
|
||||
{
|
||||
if (index < gridWidth - 3)
|
||||
this.PairUpDown(uiLinkPoint4, downSide2);
|
||||
else
|
||||
this.PairUpDown(uiLinkPoint3, downSide2);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (this._sortingGrid.Parent != null)
|
||||
{
|
||||
int gridWidth;
|
||||
int gridHeight;
|
||||
this.SetupPointsForSortingGrid(ref currentID, snapPoints, out gridWidth, out gridHeight, out gridPoints);
|
||||
this.PairUpDown(uiLinkPoint2, downSide1);
|
||||
this.PairUpDown(uiLinkPoint1, downSide1);
|
||||
for (int index = gridWidth - 1; index >= 0; --index)
|
||||
{
|
||||
UILinkPoint upSide = gridPoints[index, gridHeight - 1];
|
||||
if (upSide != null)
|
||||
this.PairUpDown(upSide, downSide1);
|
||||
UILinkPoint downSide3 = gridPoints[index, 0];
|
||||
if (downSide3 != null)
|
||||
{
|
||||
this.PairUpDown(uiLinkPoint3, downSide3);
|
||||
this.PairUpDown(uiLinkPoint4, downSide3);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (this._entryGrid.Parent != null)
|
||||
{
|
||||
int gridWidth;
|
||||
int gridHeight;
|
||||
this.SetupPointsForEntryGrid(ref currentID, snapPoints, out gridWidth, out gridHeight, out gridPoints);
|
||||
for (int index = 0; index < gridWidth; ++index)
|
||||
{
|
||||
if (gridHeight - 1 >= 0)
|
||||
{
|
||||
UILinkPoint upSide3 = gridPoints[index, gridHeight - 1];
|
||||
if (upSide3 != null)
|
||||
this.PairUpDown(upSide3, downSide1);
|
||||
if (gridHeight - 2 >= 0)
|
||||
{
|
||||
UILinkPoint upSide4 = gridPoints[index, gridHeight - 2];
|
||||
if (upSide4 != null && upSide3 == null)
|
||||
this.PairUpDown(upSide4, downSide1);
|
||||
}
|
||||
}
|
||||
UILinkPoint downSide4 = gridPoints[index, 0];
|
||||
if (downSide4 != null)
|
||||
{
|
||||
if (index < gridWidth / 2)
|
||||
this.PairUpDown(uiLinkPoint2, downSide4);
|
||||
else if (index == gridWidth - 1)
|
||||
this.PairUpDown(uiLinkPoint3, downSide4);
|
||||
else
|
||||
this.PairUpDown(uiLinkPoint4, downSide4);
|
||||
}
|
||||
}
|
||||
UILinkPoint downSide5 = gridPoints[0, 0];
|
||||
if (downSide5 != null)
|
||||
{
|
||||
this.PairUpDown(uiLinkPoint2, downSide5);
|
||||
this.PairUpDown(uiLinkPoint1, downSide5);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.PairUpDown(uiLinkPoint2, downSide1);
|
||||
this.PairUpDown(uiLinkPoint1, downSide1);
|
||||
this.PairUpDown(uiLinkPoint3, downSide1);
|
||||
this.PairUpDown(uiLinkPoint4, downSide1);
|
||||
}
|
||||
}
|
||||
List<UILinkPoint> lostrefpoints = new List<UILinkPoint>();
|
||||
for (int key = num1; key < currentID; ++key)
|
||||
lostrefpoints.Add(UILinkPointNavigator.Points[key]);
|
||||
if (!PlayerInput.UsingGamepadUI || UILinkPointNavigator.CurrentPoint < currentID)
|
||||
return;
|
||||
this.MoveToVisuallyClosestPoint(lostrefpoints);
|
||||
}
|
||||
|
||||
private void MoveToVisuallyClosestPoint(List<UILinkPoint> lostrefpoints)
|
||||
{
|
||||
Dictionary<int, UILinkPoint> points = UILinkPointNavigator.Points;
|
||||
Vector2 mouseScreen = Main.MouseScreen;
|
||||
UILinkPoint uiLinkPoint = (UILinkPoint) null;
|
||||
foreach (UILinkPoint lostrefpoint in lostrefpoints)
|
||||
{
|
||||
if (uiLinkPoint == null || (double) Vector2.Distance(mouseScreen, uiLinkPoint.Position) > (double) Vector2.Distance(mouseScreen, lostrefpoint.Position))
|
||||
uiLinkPoint = lostrefpoint;
|
||||
}
|
||||
if (uiLinkPoint == null)
|
||||
return;
|
||||
UILinkPointNavigator.ChangePoint(uiLinkPoint.ID);
|
||||
}
|
||||
|
||||
private void SetupPointsForEntryGrid(
|
||||
ref int currentID,
|
||||
List<SnapPoint> pts,
|
||||
out int gridWidth,
|
||||
out int gridHeight,
|
||||
out UILinkPoint[,] gridPoints)
|
||||
{
|
||||
List<SnapPoint> pointsByCategoryName = UIBestiaryTest.GetOrderedPointsByCategoryName(pts, "Entries");
|
||||
this._entryGrid.GetEntriesToShow(out gridWidth, out gridHeight, out int _);
|
||||
gridPoints = new UILinkPoint[gridWidth, gridHeight];
|
||||
for (int index1 = 0; index1 < pointsByCategoryName.Count; ++index1)
|
||||
{
|
||||
int index2 = index1 % gridWidth;
|
||||
int index3 = index1 / gridWidth;
|
||||
gridPoints[index2, index3] = this.MakeLinkPointFromSnapPoint(currentID++, pointsByCategoryName[index1]);
|
||||
}
|
||||
for (int index4 = 0; index4 < gridWidth; ++index4)
|
||||
{
|
||||
for (int index5 = 0; index5 < gridHeight; ++index5)
|
||||
{
|
||||
UILinkPoint uiLinkPoint = gridPoints[index4, index5];
|
||||
if (index4 < gridWidth - 1)
|
||||
{
|
||||
UILinkPoint rightSide = gridPoints[index4 + 1, index5];
|
||||
if (uiLinkPoint != null && rightSide != null)
|
||||
this.PairLeftRight(uiLinkPoint, rightSide);
|
||||
}
|
||||
if (index5 < gridHeight - 1)
|
||||
{
|
||||
UILinkPoint downSide = gridPoints[index4, index5 + 1];
|
||||
if (uiLinkPoint != null && downSide != null)
|
||||
this.PairUpDown(uiLinkPoint, downSide);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SetupPointsForFilterGrid(
|
||||
ref int currentID,
|
||||
List<SnapPoint> pts,
|
||||
out int gridWidth,
|
||||
out int gridHeight,
|
||||
out UILinkPoint[,] gridPoints)
|
||||
{
|
||||
List<SnapPoint> pointsByCategoryName = UIBestiaryTest.GetOrderedPointsByCategoryName(pts, "Filters");
|
||||
this._filteringGrid.GetEntriesToShow(out gridWidth, out gridHeight, out int _);
|
||||
gridPoints = new UILinkPoint[gridWidth, gridHeight];
|
||||
for (int index1 = 0; index1 < pointsByCategoryName.Count; ++index1)
|
||||
{
|
||||
int index2 = index1 % gridWidth;
|
||||
int index3 = index1 / gridWidth;
|
||||
gridPoints[index2, index3] = this.MakeLinkPointFromSnapPoint(currentID++, pointsByCategoryName[index1]);
|
||||
}
|
||||
for (int index4 = 0; index4 < gridWidth; ++index4)
|
||||
{
|
||||
for (int index5 = 0; index5 < gridHeight; ++index5)
|
||||
{
|
||||
UILinkPoint uiLinkPoint = gridPoints[index4, index5];
|
||||
if (index4 < gridWidth - 1)
|
||||
{
|
||||
UILinkPoint rightSide = gridPoints[index4 + 1, index5];
|
||||
if (uiLinkPoint != null && rightSide != null)
|
||||
this.PairLeftRight(uiLinkPoint, rightSide);
|
||||
}
|
||||
if (index5 < gridHeight - 1)
|
||||
{
|
||||
UILinkPoint downSide = gridPoints[index4, index5 + 1];
|
||||
if (uiLinkPoint != null && downSide != null)
|
||||
this.PairUpDown(uiLinkPoint, downSide);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SetupPointsForSortingGrid(
|
||||
ref int currentID,
|
||||
List<SnapPoint> pts,
|
||||
out int gridWidth,
|
||||
out int gridHeight,
|
||||
out UILinkPoint[,] gridPoints)
|
||||
{
|
||||
List<SnapPoint> pointsByCategoryName = UIBestiaryTest.GetOrderedPointsByCategoryName(pts, "SortSteps");
|
||||
this._sortingGrid.GetEntriesToShow(out gridWidth, out gridHeight, out int _);
|
||||
gridPoints = new UILinkPoint[gridWidth, gridHeight];
|
||||
for (int index1 = 0; index1 < pointsByCategoryName.Count; ++index1)
|
||||
{
|
||||
int index2 = index1 % gridWidth;
|
||||
int index3 = index1 / gridWidth;
|
||||
gridPoints[index2, index3] = this.MakeLinkPointFromSnapPoint(currentID++, pointsByCategoryName[index1]);
|
||||
}
|
||||
for (int index4 = 0; index4 < gridWidth; ++index4)
|
||||
{
|
||||
for (int index5 = 0; index5 < gridHeight; ++index5)
|
||||
{
|
||||
UILinkPoint uiLinkPoint = gridPoints[index4, index5];
|
||||
if (index4 < gridWidth - 1)
|
||||
{
|
||||
UILinkPoint rightSide = gridPoints[index4 + 1, index5];
|
||||
if (uiLinkPoint != null && rightSide != null)
|
||||
this.PairLeftRight(uiLinkPoint, rightSide);
|
||||
}
|
||||
if (index5 < gridHeight - 1)
|
||||
{
|
||||
UILinkPoint downSide = gridPoints[index4, index5 + 1];
|
||||
if (uiLinkPoint != null && downSide != null)
|
||||
this.PairUpDown(uiLinkPoint, downSide);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static List<SnapPoint> GetOrderedPointsByCategoryName(
|
||||
List<SnapPoint> pts,
|
||||
string name)
|
||||
{
|
||||
return pts.Where<SnapPoint>((Func<SnapPoint, bool>) (x => x.Name == name)).OrderBy<SnapPoint, int>((Func<SnapPoint, int>) (x => x.Id)).ToList<SnapPoint>();
|
||||
}
|
||||
|
||||
private void PairLeftRight(UILinkPoint leftSide, UILinkPoint rightSide)
|
||||
{
|
||||
leftSide.Right = rightSide.ID;
|
||||
rightSide.Left = leftSide.ID;
|
||||
}
|
||||
|
||||
private void PairUpDown(UILinkPoint upSide, UILinkPoint downSide)
|
||||
{
|
||||
upSide.Down = downSide.ID;
|
||||
downSide.Up = upSide.ID;
|
||||
}
|
||||
|
||||
private UILinkPoint MakeLinkPointFromSnapPoint(int id, SnapPoint snap)
|
||||
{
|
||||
UILinkPointNavigator.SetPosition(id, snap.Position);
|
||||
UILinkPoint point = UILinkPointNavigator.Points[id];
|
||||
point.Unlink();
|
||||
return point;
|
||||
}
|
||||
|
||||
public override void ScrollWheel(UIScrollWheelEvent evt)
|
||||
{
|
||||
base.ScrollWheel(evt);
|
||||
this._infoSpace.UpdateScrollbar(evt.ScrollWheelValue);
|
||||
}
|
||||
|
||||
public void TryMovingPages(int direction) => this._entryGrid.OffsetLibraryByPages(direction);
|
||||
}
|
||||
}
|
1512
GameContent/UI/States/UICharacterCreation.cs
Normal file
1512
GameContent/UI/States/UICharacterCreation.cs
Normal file
File diff suppressed because it is too large
Load diff
290
GameContent/UI/States/UICharacterSelect.cs
Normal file
290
GameContent/UI/States/UICharacterSelect.cs
Normal file
|
@ -0,0 +1,290 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.States.UICharacterSelect
|
||||
// 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 System.Linq;
|
||||
using Terraria.Audio;
|
||||
using Terraria.GameContent.UI.Elements;
|
||||
using Terraria.GameInput;
|
||||
using Terraria.ID;
|
||||
using Terraria.IO;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI;
|
||||
using Terraria.UI.Gamepad;
|
||||
|
||||
namespace Terraria.GameContent.UI.States
|
||||
{
|
||||
public class UICharacterSelect : UIState
|
||||
{
|
||||
private UIList _playerList;
|
||||
private UITextPanel<LocalizedText> _backPanel;
|
||||
private UITextPanel<LocalizedText> _newPanel;
|
||||
private UIPanel _containerPanel;
|
||||
private UIScrollbar _scrollbar;
|
||||
private bool _isScrollbarAttached;
|
||||
private List<Tuple<string, bool>> favoritesCache = new List<Tuple<string, bool>>();
|
||||
private bool skipDraw;
|
||||
|
||||
public override void OnInitialize()
|
||||
{
|
||||
UIElement element = new UIElement();
|
||||
element.Width.Set(0.0f, 0.8f);
|
||||
element.MaxWidth.Set(650f, 0.0f);
|
||||
element.Top.Set(220f, 0.0f);
|
||||
element.Height.Set(-220f, 1f);
|
||||
element.HAlign = 0.5f;
|
||||
UIPanel uiPanel = new UIPanel();
|
||||
uiPanel.Width.Set(0.0f, 1f);
|
||||
uiPanel.Height.Set(-110f, 1f);
|
||||
uiPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f;
|
||||
this._containerPanel = uiPanel;
|
||||
element.Append((UIElement) uiPanel);
|
||||
this._playerList = new UIList();
|
||||
this._playerList.Width.Set(0.0f, 1f);
|
||||
this._playerList.Height.Set(0.0f, 1f);
|
||||
this._playerList.ListPadding = 5f;
|
||||
uiPanel.Append((UIElement) this._playerList);
|
||||
this._scrollbar = new UIScrollbar();
|
||||
this._scrollbar.SetView(100f, 1000f);
|
||||
this._scrollbar.Height.Set(0.0f, 1f);
|
||||
this._scrollbar.HAlign = 1f;
|
||||
this._playerList.SetScrollbar(this._scrollbar);
|
||||
UITextPanel<LocalizedText> uiTextPanel1 = new UITextPanel<LocalizedText>(Language.GetText("UI.SelectPlayer"), 0.8f, true);
|
||||
uiTextPanel1.HAlign = 0.5f;
|
||||
uiTextPanel1.Top.Set(-40f, 0.0f);
|
||||
uiTextPanel1.SetPadding(15f);
|
||||
uiTextPanel1.BackgroundColor = new Color(73, 94, 171);
|
||||
element.Append((UIElement) uiTextPanel1);
|
||||
UITextPanel<LocalizedText> uiTextPanel2 = new UITextPanel<LocalizedText>(Language.GetText("UI.Back"), 0.7f, true);
|
||||
uiTextPanel2.Width.Set(-10f, 0.5f);
|
||||
uiTextPanel2.Height.Set(50f, 0.0f);
|
||||
uiTextPanel2.VAlign = 1f;
|
||||
uiTextPanel2.Top.Set(-45f, 0.0f);
|
||||
uiTextPanel2.OnMouseOver += new UIElement.MouseEvent(this.FadedMouseOver);
|
||||
uiTextPanel2.OnMouseOut += new UIElement.MouseEvent(this.FadedMouseOut);
|
||||
uiTextPanel2.OnClick += new UIElement.MouseEvent(this.GoBackClick);
|
||||
uiTextPanel2.SetSnapPoint("Back", 0);
|
||||
element.Append((UIElement) uiTextPanel2);
|
||||
this._backPanel = uiTextPanel2;
|
||||
UITextPanel<LocalizedText> uiTextPanel3 = new UITextPanel<LocalizedText>(Language.GetText("UI.New"), 0.7f, true);
|
||||
uiTextPanel3.CopyStyle((UIElement) uiTextPanel2);
|
||||
uiTextPanel3.HAlign = 1f;
|
||||
uiTextPanel3.OnMouseOver += new UIElement.MouseEvent(this.FadedMouseOver);
|
||||
uiTextPanel3.OnMouseOut += new UIElement.MouseEvent(this.FadedMouseOut);
|
||||
uiTextPanel3.OnClick += new UIElement.MouseEvent(this.NewCharacterClick);
|
||||
element.Append((UIElement) uiTextPanel3);
|
||||
uiTextPanel2.SetSnapPoint("New", 0);
|
||||
this._newPanel = uiTextPanel3;
|
||||
this.Append(element);
|
||||
}
|
||||
|
||||
public override void Recalculate()
|
||||
{
|
||||
if (this._scrollbar != null)
|
||||
{
|
||||
if (this._isScrollbarAttached && !this._scrollbar.CanScroll)
|
||||
{
|
||||
this._containerPanel.RemoveChild((UIElement) this._scrollbar);
|
||||
this._isScrollbarAttached = false;
|
||||
this._playerList.Width.Set(0.0f, 1f);
|
||||
}
|
||||
else if (!this._isScrollbarAttached && this._scrollbar.CanScroll)
|
||||
{
|
||||
this._containerPanel.Append((UIElement) this._scrollbar);
|
||||
this._isScrollbarAttached = true;
|
||||
this._playerList.Width.Set(-25f, 1f);
|
||||
}
|
||||
}
|
||||
base.Recalculate();
|
||||
}
|
||||
|
||||
private void NewCharacterClick(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
SoundEngine.PlaySound(10);
|
||||
Main.PendingPlayer = new Player();
|
||||
Main.MenuUI.SetState((UIState) new UICharacterCreation(Main.PendingPlayer));
|
||||
Main.menuMode = 888;
|
||||
}
|
||||
|
||||
private void GoBackClick(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
SoundEngine.PlaySound(11);
|
||||
Main.menuMode = 0;
|
||||
}
|
||||
|
||||
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.7f;
|
||||
((UIPanel) evt.Target).BorderColor = Color.Black;
|
||||
}
|
||||
|
||||
public override void OnActivate()
|
||||
{
|
||||
Main.LoadPlayers();
|
||||
Main.ActivePlayerFileData = new PlayerFileData();
|
||||
this.UpdatePlayersList();
|
||||
if (!PlayerInput.UsingGamepadUI)
|
||||
return;
|
||||
UILinkPointNavigator.ChangePoint(3000 + (this._playerList.Count == 0 ? 1 : 2));
|
||||
}
|
||||
|
||||
private void UpdatePlayersList()
|
||||
{
|
||||
this._playerList.Clear();
|
||||
List<PlayerFileData> playerFileDataList = new List<PlayerFileData>((IEnumerable<PlayerFileData>) Main.PlayerList);
|
||||
playerFileDataList.Sort((Comparison<PlayerFileData>) ((x, y) =>
|
||||
{
|
||||
if (x.IsFavorite && !y.IsFavorite)
|
||||
return -1;
|
||||
if (!x.IsFavorite && y.IsFavorite)
|
||||
return 1;
|
||||
return x.Name.CompareTo(y.Name) != 0 ? x.Name.CompareTo(y.Name) : x.GetFileName().CompareTo(y.GetFileName());
|
||||
}));
|
||||
int num = 0;
|
||||
foreach (PlayerFileData data in playerFileDataList)
|
||||
this._playerList.Add((UIElement) new UICharacterListItem(data, num++));
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
if (this.skipDraw)
|
||||
{
|
||||
this.skipDraw = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.UpdateFavoritesCache())
|
||||
{
|
||||
this.skipDraw = true;
|
||||
Main.MenuUI.Draw(spriteBatch, new GameTime());
|
||||
}
|
||||
base.Draw(spriteBatch);
|
||||
this.SetupGamepadPoints(spriteBatch);
|
||||
}
|
||||
}
|
||||
|
||||
private bool UpdateFavoritesCache()
|
||||
{
|
||||
List<PlayerFileData> playerFileDataList = new List<PlayerFileData>((IEnumerable<PlayerFileData>) Main.PlayerList);
|
||||
playerFileDataList.Sort((Comparison<PlayerFileData>) ((x, y) =>
|
||||
{
|
||||
if (x.IsFavorite && !y.IsFavorite)
|
||||
return -1;
|
||||
if (!x.IsFavorite && y.IsFavorite)
|
||||
return 1;
|
||||
return x.Name.CompareTo(y.Name) != 0 ? x.Name.CompareTo(y.Name) : x.GetFileName().CompareTo(y.GetFileName());
|
||||
}));
|
||||
bool flag = false;
|
||||
if (!flag && playerFileDataList.Count != this.favoritesCache.Count)
|
||||
flag = true;
|
||||
if (!flag)
|
||||
{
|
||||
for (int index = 0; index < this.favoritesCache.Count; ++index)
|
||||
{
|
||||
Tuple<string, bool> tuple = this.favoritesCache[index];
|
||||
if (!(playerFileDataList[index].Name == tuple.Item1) || playerFileDataList[index].IsFavorite != tuple.Item2)
|
||||
{
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
this.favoritesCache.Clear();
|
||||
foreach (PlayerFileData playerFileData in playerFileDataList)
|
||||
this.favoritesCache.Add(Tuple.Create<string, bool>(playerFileData.Name, playerFileData.IsFavorite));
|
||||
this.UpdatePlayersList();
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
private void SetupGamepadPoints(SpriteBatch spriteBatch)
|
||||
{
|
||||
UILinkPointNavigator.Shortcuts.BackButtonCommand = 1;
|
||||
int num1 = 3000;
|
||||
UILinkPointNavigator.SetPosition(num1, this._backPanel.GetInnerDimensions().ToRectangle().Center.ToVector2());
|
||||
UILinkPointNavigator.SetPosition(num1 + 1, this._newPanel.GetInnerDimensions().ToRectangle().Center.ToVector2());
|
||||
int key1 = num1;
|
||||
UILinkPoint point1 = UILinkPointNavigator.Points[key1];
|
||||
point1.Unlink();
|
||||
point1.Right = key1 + 1;
|
||||
int key2 = num1 + 1;
|
||||
UILinkPoint point2 = UILinkPointNavigator.Points[key2];
|
||||
point2.Unlink();
|
||||
point2.Left = key2 - 1;
|
||||
float num2 = 1f / Main.UIScale;
|
||||
Rectangle clippingRectangle = this._containerPanel.GetClippingRectangle(spriteBatch);
|
||||
Vector2 minimum = clippingRectangle.TopLeft() * num2;
|
||||
Vector2 maximum = clippingRectangle.BottomRight() * num2;
|
||||
List<SnapPoint> snapPoints = this.GetSnapPoints();
|
||||
for (int index = 0; index < snapPoints.Count; ++index)
|
||||
{
|
||||
if (!snapPoints[index].Position.Between(minimum, maximum))
|
||||
{
|
||||
snapPoints.Remove(snapPoints[index]);
|
||||
--index;
|
||||
}
|
||||
}
|
||||
SnapPoint[,] snapPointArray = new SnapPoint[this._playerList.Count, 4];
|
||||
foreach (SnapPoint snapPoint in snapPoints.Where<SnapPoint>((Func<SnapPoint, bool>) (a => a.Name == "Play")))
|
||||
snapPointArray[snapPoint.Id, 0] = snapPoint;
|
||||
foreach (SnapPoint snapPoint in snapPoints.Where<SnapPoint>((Func<SnapPoint, bool>) (a => a.Name == "Favorite")))
|
||||
snapPointArray[snapPoint.Id, 1] = snapPoint;
|
||||
foreach (SnapPoint snapPoint in snapPoints.Where<SnapPoint>((Func<SnapPoint, bool>) (a => a.Name == "Cloud")))
|
||||
snapPointArray[snapPoint.Id, 2] = snapPoint;
|
||||
foreach (SnapPoint snapPoint in snapPoints.Where<SnapPoint>((Func<SnapPoint, bool>) (a => a.Name == "Delete")))
|
||||
snapPointArray[snapPoint.Id, 3] = snapPoint;
|
||||
int num3 = num1 + 2;
|
||||
int[] numArray = new int[this._playerList.Count];
|
||||
for (int index = 0; index < numArray.Length; ++index)
|
||||
numArray[index] = -1;
|
||||
for (int index1 = 0; index1 < 4; ++index1)
|
||||
{
|
||||
int key3 = -1;
|
||||
for (int index2 = 0; index2 < snapPointArray.GetLength(0); ++index2)
|
||||
{
|
||||
if (snapPointArray[index2, index1] != null)
|
||||
{
|
||||
UILinkPoint point3 = UILinkPointNavigator.Points[num3];
|
||||
point3.Unlink();
|
||||
UILinkPointNavigator.SetPosition(num3, snapPointArray[index2, index1].Position);
|
||||
if (key3 != -1)
|
||||
{
|
||||
point3.Up = key3;
|
||||
UILinkPointNavigator.Points[key3].Down = num3;
|
||||
}
|
||||
if (numArray[index2] != -1)
|
||||
{
|
||||
point3.Left = numArray[index2];
|
||||
UILinkPointNavigator.Points[numArray[index2]].Right = num3;
|
||||
}
|
||||
point3.Down = num1;
|
||||
if (index1 == 0)
|
||||
UILinkPointNavigator.Points[num1].Up = UILinkPointNavigator.Points[num1 + 1].Up = num3;
|
||||
key3 = num3;
|
||||
numArray[index2] = num3;
|
||||
UILinkPointNavigator.Shortcuts.FANCYUI_HIGHEST_INDEX = num3;
|
||||
++num3;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!PlayerInput.UsingGamepadUI || this._playerList.Count != 0 || UILinkPointNavigator.CurrentPoint <= 3001)
|
||||
return;
|
||||
UILinkPointNavigator.ChangePoint(3001);
|
||||
}
|
||||
}
|
||||
}
|
481
GameContent/UI/States/UICreativePowersMenu.cs
Normal file
481
GameContent/UI/States/UICreativePowersMenu.cs
Normal file
|
@ -0,0 +1,481 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.States.UICreativePowersMenu
|
||||
// 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.GameContent.Creative;
|
||||
using Terraria.GameContent.UI.Elements;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI;
|
||||
using Terraria.UI.Gamepad;
|
||||
|
||||
namespace Terraria.GameContent.UI.States
|
||||
{
|
||||
public class UICreativePowersMenu : UIState
|
||||
{
|
||||
private bool _hovered;
|
||||
private PowerStripUIElement _mainPowerStrip;
|
||||
private PowerStripUIElement _timePowersStrip;
|
||||
private PowerStripUIElement _weatherPowersStrip;
|
||||
private PowerStripUIElement _personalPowersStrip;
|
||||
private UICreativeInfiniteItemsDisplay _infiniteItemsWindow;
|
||||
private UIElement _container;
|
||||
private UICreativePowersMenu.MenuTree<UICreativePowersMenu.OpenMainSubCategory> _mainCategory = new UICreativePowersMenu.MenuTree<UICreativePowersMenu.OpenMainSubCategory>(UICreativePowersMenu.OpenMainSubCategory.None);
|
||||
private UICreativePowersMenu.MenuTree<UICreativePowersMenu.WeatherSubcategory> _weatherCategory = new UICreativePowersMenu.MenuTree<UICreativePowersMenu.WeatherSubcategory>(UICreativePowersMenu.WeatherSubcategory.None);
|
||||
private UICreativePowersMenu.MenuTree<UICreativePowersMenu.TimeSubcategory> _timeCategory = new UICreativePowersMenu.MenuTree<UICreativePowersMenu.TimeSubcategory>(UICreativePowersMenu.TimeSubcategory.None);
|
||||
private UICreativePowersMenu.MenuTree<UICreativePowersMenu.PersonalSubcategory> _personalCategory = new UICreativePowersMenu.MenuTree<UICreativePowersMenu.PersonalSubcategory>(UICreativePowersMenu.PersonalSubcategory.None);
|
||||
private const int INITIAL_LEFT_PIXELS = 20;
|
||||
private const int LEFT_PIXELS_PER_STRIP_DEPTH = 60;
|
||||
private const string STRIP_MAIN = "strip 0";
|
||||
private const string STRIP_DEPTH_1 = "strip 1";
|
||||
private const string STRIP_DEPTH_2 = "strip 2";
|
||||
private UIGamepadHelper _helper;
|
||||
|
||||
public bool IsShowingResearchMenu => this._mainCategory.CurrentOption == 2;
|
||||
|
||||
public override void OnActivate() => this.InitializePage();
|
||||
|
||||
private void InitializePage()
|
||||
{
|
||||
int num1 = 270;
|
||||
int num2 = 20;
|
||||
this._container = new UIElement()
|
||||
{
|
||||
HAlign = 0.0f,
|
||||
VAlign = 0.0f,
|
||||
Width = new StyleDimension(0.0f, 1f),
|
||||
Height = new StyleDimension((float) (-num1 - num2), 1f),
|
||||
Top = new StyleDimension((float) num1, 0.0f)
|
||||
};
|
||||
this.Append(this._container);
|
||||
PowerStripUIElement powerStripUiElement1 = new PowerStripUIElement("strip 0", this.CreateMainPowerStrip());
|
||||
powerStripUiElement1.HAlign = 0.0f;
|
||||
powerStripUiElement1.VAlign = 0.5f;
|
||||
powerStripUiElement1.Left = new StyleDimension(20f, 0.0f);
|
||||
PowerStripUIElement powerStripUiElement2 = powerStripUiElement1;
|
||||
powerStripUiElement2.OnMouseOver += new UIElement.MouseEvent(this.strip_OnMouseOver);
|
||||
powerStripUiElement2.OnMouseOut += new UIElement.MouseEvent(this.strip_OnMouseOut);
|
||||
this._mainPowerStrip = powerStripUiElement2;
|
||||
PowerStripUIElement powerStripUiElement3 = new PowerStripUIElement("strip 1", this.CreateTimePowerStrip());
|
||||
powerStripUiElement3.HAlign = 0.0f;
|
||||
powerStripUiElement3.VAlign = 0.5f;
|
||||
powerStripUiElement3.Left = new StyleDimension(80f, 0.0f);
|
||||
PowerStripUIElement powerStripUiElement4 = powerStripUiElement3;
|
||||
powerStripUiElement4.OnMouseOver += new UIElement.MouseEvent(this.strip_OnMouseOver);
|
||||
powerStripUiElement4.OnMouseOut += new UIElement.MouseEvent(this.strip_OnMouseOut);
|
||||
this._timePowersStrip = powerStripUiElement4;
|
||||
PowerStripUIElement powerStripUiElement5 = new PowerStripUIElement("strip 1", this.CreateWeatherPowerStrip());
|
||||
powerStripUiElement5.HAlign = 0.0f;
|
||||
powerStripUiElement5.VAlign = 0.5f;
|
||||
powerStripUiElement5.Left = new StyleDimension(80f, 0.0f);
|
||||
PowerStripUIElement powerStripUiElement6 = powerStripUiElement5;
|
||||
powerStripUiElement6.OnMouseOver += new UIElement.MouseEvent(this.strip_OnMouseOver);
|
||||
powerStripUiElement6.OnMouseOut += new UIElement.MouseEvent(this.strip_OnMouseOut);
|
||||
this._weatherPowersStrip = powerStripUiElement6;
|
||||
PowerStripUIElement powerStripUiElement7 = new PowerStripUIElement("strip 1", this.CreatePersonalPowerStrip());
|
||||
powerStripUiElement7.HAlign = 0.0f;
|
||||
powerStripUiElement7.VAlign = 0.5f;
|
||||
powerStripUiElement7.Left = new StyleDimension(80f, 0.0f);
|
||||
PowerStripUIElement powerStripUiElement8 = powerStripUiElement7;
|
||||
powerStripUiElement8.OnMouseOver += new UIElement.MouseEvent(this.strip_OnMouseOver);
|
||||
powerStripUiElement8.OnMouseOut += new UIElement.MouseEvent(this.strip_OnMouseOut);
|
||||
this._personalPowersStrip = powerStripUiElement8;
|
||||
UICreativeInfiniteItemsDisplay infiniteItemsDisplay = new UICreativeInfiniteItemsDisplay((UIState) this);
|
||||
infiniteItemsDisplay.HAlign = 0.0f;
|
||||
infiniteItemsDisplay.VAlign = 0.5f;
|
||||
infiniteItemsDisplay.Left = new StyleDimension(80f, 0.0f);
|
||||
infiniteItemsDisplay.Width = new StyleDimension(480f, 0.0f);
|
||||
infiniteItemsDisplay.Height = new StyleDimension(-88f, 1f);
|
||||
this._infiniteItemsWindow = infiniteItemsDisplay;
|
||||
this.RefreshElementsOrder();
|
||||
this.OnUpdate += new UIElement.ElementEvent(this.UICreativePowersMenu_OnUpdate);
|
||||
}
|
||||
|
||||
private List<UIElement> CreateMainPowerStrip()
|
||||
{
|
||||
UICreativePowersMenu.MenuTree<UICreativePowersMenu.OpenMainSubCategory> mainCategory = this._mainCategory;
|
||||
mainCategory.Buttons.Clear();
|
||||
List<UIElement> elements = new List<UIElement>();
|
||||
CreativePowerUIElementRequestInfo request = new CreativePowerUIElementRequestInfo()
|
||||
{
|
||||
PreferredButtonWidth = 40,
|
||||
PreferredButtonHeight = 40
|
||||
};
|
||||
GroupOptionButton<int> categoryButton1 = CreativePowersHelper.CreateCategoryButton<int>(request, 1, 0);
|
||||
categoryButton1.Append((UIElement) CreativePowersHelper.GetIconImage(CreativePowersHelper.CreativePowerIconLocations.ItemDuplication));
|
||||
categoryButton1.OnClick += new UIElement.MouseEvent(this.MainCategoryButtonClick);
|
||||
categoryButton1.OnUpdate += new UIElement.ElementEvent(this.itemsWindowButton_OnUpdate);
|
||||
mainCategory.Buttons.Add(1, categoryButton1);
|
||||
elements.Add((UIElement) categoryButton1);
|
||||
GroupOptionButton<int> categoryButton2 = CreativePowersHelper.CreateCategoryButton<int>(request, 2, 0);
|
||||
categoryButton2.Append((UIElement) CreativePowersHelper.GetIconImage(CreativePowersHelper.CreativePowerIconLocations.ItemResearch));
|
||||
categoryButton2.OnClick += new UIElement.MouseEvent(this.MainCategoryButtonClick);
|
||||
categoryButton2.OnUpdate += new UIElement.ElementEvent(this.researchWindowButton_OnUpdate);
|
||||
mainCategory.Buttons.Add(2, categoryButton2);
|
||||
elements.Add((UIElement) categoryButton2);
|
||||
GroupOptionButton<int> categoryButton3 = CreativePowersHelper.CreateCategoryButton<int>(request, 3, 0);
|
||||
categoryButton3.Append((UIElement) CreativePowersHelper.GetIconImage(CreativePowersHelper.CreativePowerIconLocations.TimeCategory));
|
||||
categoryButton3.OnClick += new UIElement.MouseEvent(this.MainCategoryButtonClick);
|
||||
categoryButton3.OnUpdate += new UIElement.ElementEvent(this.timeCategoryButton_OnUpdate);
|
||||
mainCategory.Buttons.Add(3, categoryButton3);
|
||||
elements.Add((UIElement) categoryButton3);
|
||||
GroupOptionButton<int> categoryButton4 = CreativePowersHelper.CreateCategoryButton<int>(request, 4, 0);
|
||||
categoryButton4.Append((UIElement) CreativePowersHelper.GetIconImage(CreativePowersHelper.CreativePowerIconLocations.WeatherCategory));
|
||||
categoryButton4.OnClick += new UIElement.MouseEvent(this.MainCategoryButtonClick);
|
||||
categoryButton4.OnUpdate += new UIElement.ElementEvent(this.weatherCategoryButton_OnUpdate);
|
||||
mainCategory.Buttons.Add(4, categoryButton4);
|
||||
elements.Add((UIElement) categoryButton4);
|
||||
GroupOptionButton<int> categoryButton5 = CreativePowersHelper.CreateCategoryButton<int>(request, 6, 0);
|
||||
categoryButton5.Append((UIElement) CreativePowersHelper.GetIconImage(CreativePowersHelper.CreativePowerIconLocations.PersonalCategory));
|
||||
categoryButton5.OnClick += new UIElement.MouseEvent(this.MainCategoryButtonClick);
|
||||
categoryButton5.OnUpdate += new UIElement.ElementEvent(this.personalCategoryButton_OnUpdate);
|
||||
mainCategory.Buttons.Add(6, categoryButton5);
|
||||
elements.Add((UIElement) categoryButton5);
|
||||
CreativePowerManager.Instance.GetPower<CreativePowers.StopBiomeSpreadPower>().ProvidePowerButtons(request, elements);
|
||||
GroupOptionButton<int> subcategoryButton = this.CreateSubcategoryButton<CreativePowers.DifficultySliderPower>(ref request, 1, "strip 1", 5, 0, mainCategory.Buttons, mainCategory.Sliders);
|
||||
subcategoryButton.OnClick += new UIElement.MouseEvent(this.MainCategoryButtonClick);
|
||||
elements.Add((UIElement) subcategoryButton);
|
||||
return elements;
|
||||
}
|
||||
|
||||
private static void CategoryButton_OnUpdate_DisplayTooltips(
|
||||
UIElement affectedElement,
|
||||
string categoryNameKey)
|
||||
{
|
||||
GroupOptionButton<int> groupOptionButton = affectedElement as GroupOptionButton<int>;
|
||||
if (!affectedElement.IsMouseHovering)
|
||||
return;
|
||||
string textValue = Language.GetTextValue(groupOptionButton.IsSelected ? categoryNameKey + "Opened" : categoryNameKey + "Closed");
|
||||
CreativePowersHelper.AddDescriptionIfNeeded(ref textValue, categoryNameKey);
|
||||
Main.instance.MouseTextNoOverride(textValue);
|
||||
}
|
||||
|
||||
private void itemsWindowButton_OnUpdate(UIElement affectedElement) => UICreativePowersMenu.CategoryButton_OnUpdate_DisplayTooltips(affectedElement, "CreativePowers.InfiniteItemsCategory");
|
||||
|
||||
private void researchWindowButton_OnUpdate(UIElement affectedElement) => UICreativePowersMenu.CategoryButton_OnUpdate_DisplayTooltips(affectedElement, "CreativePowers.ResearchItemsCategory");
|
||||
|
||||
private void timeCategoryButton_OnUpdate(UIElement affectedElement) => UICreativePowersMenu.CategoryButton_OnUpdate_DisplayTooltips(affectedElement, "CreativePowers.TimeCategory");
|
||||
|
||||
private void weatherCategoryButton_OnUpdate(UIElement affectedElement) => UICreativePowersMenu.CategoryButton_OnUpdate_DisplayTooltips(affectedElement, "CreativePowers.WeatherCategory");
|
||||
|
||||
private void personalCategoryButton_OnUpdate(UIElement affectedElement) => UICreativePowersMenu.CategoryButton_OnUpdate_DisplayTooltips(affectedElement, "CreativePowers.PersonalCategory");
|
||||
|
||||
private void UICreativePowersMenu_OnUpdate(UIElement affectedElement)
|
||||
{
|
||||
if (!this._hovered)
|
||||
return;
|
||||
Main.LocalPlayer.mouseInterface = true;
|
||||
}
|
||||
|
||||
private void strip_OnMouseOut(UIMouseEvent evt, UIElement listeningElement) => this._hovered = false;
|
||||
|
||||
private void strip_OnMouseOver(UIMouseEvent evt, UIElement listeningElement) => this._hovered = true;
|
||||
|
||||
private void MainCategoryButtonClick(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
this.ToggleMainCategory((listeningElement as GroupOptionButton<int>).OptionValue);
|
||||
this.RefreshElementsOrder();
|
||||
}
|
||||
|
||||
private void ToggleMainCategory(int option) => this.ToggleCategory<UICreativePowersMenu.OpenMainSubCategory>(this._mainCategory, option, UICreativePowersMenu.OpenMainSubCategory.None);
|
||||
|
||||
private void ToggleWeatherCategory(int option) => this.ToggleCategory<UICreativePowersMenu.WeatherSubcategory>(this._weatherCategory, option, UICreativePowersMenu.WeatherSubcategory.None);
|
||||
|
||||
private void ToggleTimeCategory(int option) => this.ToggleCategory<UICreativePowersMenu.TimeSubcategory>(this._timeCategory, option, UICreativePowersMenu.TimeSubcategory.None);
|
||||
|
||||
private void TogglePersonalCategory(int option) => this.ToggleCategory<UICreativePowersMenu.PersonalSubcategory>(this._personalCategory, option, UICreativePowersMenu.PersonalSubcategory.None);
|
||||
|
||||
private void ToggleCategory<TEnum>(
|
||||
UICreativePowersMenu.MenuTree<TEnum> tree,
|
||||
int option,
|
||||
TEnum defaultOption)
|
||||
where TEnum : struct, IConvertible
|
||||
{
|
||||
if (tree.CurrentOption == option)
|
||||
option = defaultOption.ToInt32((IFormatProvider) null);
|
||||
tree.CurrentOption = option;
|
||||
foreach (GroupOptionButton<int> groupOptionButton in tree.Buttons.Values)
|
||||
groupOptionButton.SetCurrentOption(option);
|
||||
}
|
||||
|
||||
private List<UIElement> CreateTimePowerStrip()
|
||||
{
|
||||
UICreativePowersMenu.MenuTree<UICreativePowersMenu.TimeSubcategory> timeCategory = this._timeCategory;
|
||||
List<UIElement> elements = new List<UIElement>();
|
||||
CreativePowerUIElementRequestInfo request = new CreativePowerUIElementRequestInfo()
|
||||
{
|
||||
PreferredButtonWidth = 40,
|
||||
PreferredButtonHeight = 40
|
||||
};
|
||||
CreativePowerManager.Instance.GetPower<CreativePowers.FreezeTime>().ProvidePowerButtons(request, elements);
|
||||
CreativePowerManager.Instance.GetPower<CreativePowers.StartDayImmediately>().ProvidePowerButtons(request, elements);
|
||||
CreativePowerManager.Instance.GetPower<CreativePowers.StartNoonImmediately>().ProvidePowerButtons(request, elements);
|
||||
CreativePowerManager.Instance.GetPower<CreativePowers.StartNightImmediately>().ProvidePowerButtons(request, elements);
|
||||
CreativePowerManager.Instance.GetPower<CreativePowers.StartMidnightImmediately>().ProvidePowerButtons(request, elements);
|
||||
GroupOptionButton<int> subcategoryButton = this.CreateSubcategoryButton<CreativePowers.ModifyTimeRate>(ref request, 2, "strip 2", 1, 0, timeCategory.Buttons, timeCategory.Sliders);
|
||||
subcategoryButton.OnClick += new UIElement.MouseEvent(this.TimeCategoryButtonClick);
|
||||
elements.Add((UIElement) subcategoryButton);
|
||||
return elements;
|
||||
}
|
||||
|
||||
private List<UIElement> CreatePersonalPowerStrip()
|
||||
{
|
||||
UICreativePowersMenu.MenuTree<UICreativePowersMenu.PersonalSubcategory> personalCategory = this._personalCategory;
|
||||
List<UIElement> elements = new List<UIElement>();
|
||||
CreativePowerUIElementRequestInfo request = new CreativePowerUIElementRequestInfo()
|
||||
{
|
||||
PreferredButtonWidth = 40,
|
||||
PreferredButtonHeight = 40
|
||||
};
|
||||
CreativePowerManager.Instance.GetPower<CreativePowers.GodmodePower>().ProvidePowerButtons(request, elements);
|
||||
CreativePowerManager.Instance.GetPower<CreativePowers.FarPlacementRangePower>().ProvidePowerButtons(request, elements);
|
||||
GroupOptionButton<int> subcategoryButton = this.CreateSubcategoryButton<CreativePowers.SpawnRateSliderPerPlayerPower>(ref request, 2, "strip 2", 1, 0, personalCategory.Buttons, personalCategory.Sliders);
|
||||
subcategoryButton.OnClick += new UIElement.MouseEvent(this.PersonalCategoryButtonClick);
|
||||
elements.Add((UIElement) subcategoryButton);
|
||||
return elements;
|
||||
}
|
||||
|
||||
private List<UIElement> CreateWeatherPowerStrip()
|
||||
{
|
||||
UICreativePowersMenu.MenuTree<UICreativePowersMenu.WeatherSubcategory> weatherCategory = this._weatherCategory;
|
||||
List<UIElement> elements = new List<UIElement>();
|
||||
CreativePowerUIElementRequestInfo request = new CreativePowerUIElementRequestInfo()
|
||||
{
|
||||
PreferredButtonWidth = 40,
|
||||
PreferredButtonHeight = 40
|
||||
};
|
||||
GroupOptionButton<int> subcategoryButton1 = this.CreateSubcategoryButton<CreativePowers.ModifyWindDirectionAndStrength>(ref request, 2, "strip 2", 1, 0, weatherCategory.Buttons, weatherCategory.Sliders);
|
||||
subcategoryButton1.OnClick += new UIElement.MouseEvent(this.WeatherCategoryButtonClick);
|
||||
elements.Add((UIElement) subcategoryButton1);
|
||||
CreativePowerManager.Instance.GetPower<CreativePowers.FreezeWindDirectionAndStrength>().ProvidePowerButtons(request, elements);
|
||||
GroupOptionButton<int> subcategoryButton2 = this.CreateSubcategoryButton<CreativePowers.ModifyRainPower>(ref request, 2, "strip 2", 2, 0, weatherCategory.Buttons, weatherCategory.Sliders);
|
||||
subcategoryButton2.OnClick += new UIElement.MouseEvent(this.WeatherCategoryButtonClick);
|
||||
elements.Add((UIElement) subcategoryButton2);
|
||||
CreativePowerManager.Instance.GetPower<CreativePowers.FreezeRainPower>().ProvidePowerButtons(request, elements);
|
||||
return elements;
|
||||
}
|
||||
|
||||
private GroupOptionButton<int> CreateSubcategoryButton<T>(
|
||||
ref CreativePowerUIElementRequestInfo request,
|
||||
int subcategoryDepth,
|
||||
string subcategoryName,
|
||||
int subcategoryIndex,
|
||||
int currentSelectedInSubcategory,
|
||||
Dictionary<int, GroupOptionButton<int>> subcategoryButtons,
|
||||
Dictionary<int, UIElement> slidersSet)
|
||||
where T : ICreativePower, IProvideSliderElement, IPowerSubcategoryElement
|
||||
{
|
||||
T power = CreativePowerManager.Instance.GetPower<T>();
|
||||
UIElement uiElement = power.ProvideSlider();
|
||||
uiElement.Left = new StyleDimension((float) (20 + subcategoryDepth * 60), 0.0f);
|
||||
slidersSet[subcategoryIndex] = uiElement;
|
||||
uiElement.SetSnapPoint(subcategoryName, 0, new Vector2?(new Vector2(0.0f, 0.5f)), new Vector2?(new Vector2(28f, 0.0f)));
|
||||
GroupOptionButton<int> optionButton = power.GetOptionButton(request, subcategoryIndex, currentSelectedInSubcategory);
|
||||
subcategoryButtons[subcategoryIndex] = optionButton;
|
||||
CreativePowersHelper.UpdateUnlockStateByPower((ICreativePower) power, (UIElement) optionButton, CreativePowersHelper.CommonSelectedColor);
|
||||
return optionButton;
|
||||
}
|
||||
|
||||
private void WeatherCategoryButtonClick(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
GroupOptionButton<int> groupOptionButton = listeningElement as GroupOptionButton<int>;
|
||||
switch (groupOptionButton.OptionValue)
|
||||
{
|
||||
case 1:
|
||||
if (!CreativePowerManager.Instance.GetPower<CreativePowers.ModifyWindDirectionAndStrength>().GetIsUnlocked())
|
||||
return;
|
||||
break;
|
||||
case 2:
|
||||
if (!CreativePowerManager.Instance.GetPower<CreativePowers.ModifyRainPower>().GetIsUnlocked())
|
||||
return;
|
||||
break;
|
||||
}
|
||||
this.ToggleWeatherCategory(groupOptionButton.OptionValue);
|
||||
this.RefreshElementsOrder();
|
||||
}
|
||||
|
||||
private void TimeCategoryButtonClick(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
GroupOptionButton<int> groupOptionButton = listeningElement as GroupOptionButton<int>;
|
||||
if (groupOptionButton.OptionValue == 1 && !CreativePowerManager.Instance.GetPower<CreativePowers.ModifyTimeRate>().GetIsUnlocked())
|
||||
return;
|
||||
this.ToggleTimeCategory(groupOptionButton.OptionValue);
|
||||
this.RefreshElementsOrder();
|
||||
}
|
||||
|
||||
private void PersonalCategoryButtonClick(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
GroupOptionButton<int> groupOptionButton = listeningElement as GroupOptionButton<int>;
|
||||
if (groupOptionButton.OptionValue == 1 && !CreativePowerManager.Instance.GetPower<CreativePowers.SpawnRateSliderPerPlayerPower>().GetIsUnlocked())
|
||||
return;
|
||||
this.TogglePersonalCategory(groupOptionButton.OptionValue);
|
||||
this.RefreshElementsOrder();
|
||||
}
|
||||
|
||||
private void RefreshElementsOrder()
|
||||
{
|
||||
this._container.RemoveAllChildren();
|
||||
this._container.Append((UIElement) this._mainPowerStrip);
|
||||
UIElement element = (UIElement) null;
|
||||
UICreativePowersMenu.MenuTree<UICreativePowersMenu.OpenMainSubCategory> mainCategory = this._mainCategory;
|
||||
if (mainCategory.Sliders.TryGetValue(mainCategory.CurrentOption, out element))
|
||||
this._container.Append(element);
|
||||
if (mainCategory.CurrentOption == 1)
|
||||
{
|
||||
this._infiniteItemsWindow.SetPageTypeToShow(UICreativeInfiniteItemsDisplay.InfiniteItemsDisplayPage.InfiniteItemsPickup);
|
||||
this._container.Append((UIElement) this._infiniteItemsWindow);
|
||||
}
|
||||
if (mainCategory.CurrentOption == 2)
|
||||
{
|
||||
this._infiniteItemsWindow.SetPageTypeToShow(UICreativeInfiniteItemsDisplay.InfiniteItemsDisplayPage.InfiniteItemsResearch);
|
||||
this._container.Append((UIElement) this._infiniteItemsWindow);
|
||||
}
|
||||
if (mainCategory.CurrentOption == 3)
|
||||
{
|
||||
this._container.Append((UIElement) this._timePowersStrip);
|
||||
UICreativePowersMenu.MenuTree<UICreativePowersMenu.TimeSubcategory> timeCategory = this._timeCategory;
|
||||
if (timeCategory.Sliders.TryGetValue(timeCategory.CurrentOption, out element))
|
||||
this._container.Append(element);
|
||||
}
|
||||
if (mainCategory.CurrentOption == 4)
|
||||
{
|
||||
this._container.Append((UIElement) this._weatherPowersStrip);
|
||||
UICreativePowersMenu.MenuTree<UICreativePowersMenu.WeatherSubcategory> weatherCategory = this._weatherCategory;
|
||||
if (weatherCategory.Sliders.TryGetValue(weatherCategory.CurrentOption, out element))
|
||||
this._container.Append(element);
|
||||
}
|
||||
if (mainCategory.CurrentOption != 6)
|
||||
return;
|
||||
this._container.Append((UIElement) this._personalPowersStrip);
|
||||
UICreativePowersMenu.MenuTree<UICreativePowersMenu.PersonalSubcategory> personalCategory = this._personalCategory;
|
||||
if (!personalCategory.Sliders.TryGetValue(personalCategory.CurrentOption, out element))
|
||||
return;
|
||||
this._container.Append(element);
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
base.Draw(spriteBatch);
|
||||
this.SetupGamepadPoints(spriteBatch);
|
||||
}
|
||||
|
||||
private void SetupGamepadPoints(SpriteBatch spriteBatch)
|
||||
{
|
||||
int currentID = 10000;
|
||||
List<SnapPoint> snapPoints = this.GetSnapPoints();
|
||||
List<SnapPoint> pointsByCategoryName1 = this._helper.GetOrderedPointsByCategoryName(snapPoints, "strip 0");
|
||||
List<SnapPoint> pointsByCategoryName2 = this._helper.GetOrderedPointsByCategoryName(snapPoints, "strip 1");
|
||||
List<SnapPoint> pointsByCategoryName3 = this._helper.GetOrderedPointsByCategoryName(snapPoints, "strip 2");
|
||||
UILinkPoint[] uiLinkPointArray1 = (UILinkPoint[]) null;
|
||||
UILinkPoint[] uiLinkPointArray2 = (UILinkPoint[]) null;
|
||||
UILinkPoint[] stripOnRight = (UILinkPoint[]) null;
|
||||
if (pointsByCategoryName1.Count > 0)
|
||||
uiLinkPointArray1 = this._helper.CreateUILinkStripVertical(ref currentID, pointsByCategoryName1);
|
||||
if (pointsByCategoryName2.Count > 0)
|
||||
uiLinkPointArray2 = this._helper.CreateUILinkStripVertical(ref currentID, pointsByCategoryName2);
|
||||
if (pointsByCategoryName3.Count > 0)
|
||||
stripOnRight = this._helper.CreateUILinkStripVertical(ref currentID, pointsByCategoryName3);
|
||||
if (uiLinkPointArray1 != null && uiLinkPointArray2 != null)
|
||||
this._helper.LinkVerticalStrips(uiLinkPointArray1, uiLinkPointArray2, (uiLinkPointArray1.Length - uiLinkPointArray2.Length) / 2);
|
||||
if (uiLinkPointArray2 != null && stripOnRight != null)
|
||||
this._helper.LinkVerticalStrips(uiLinkPointArray2, stripOnRight, (uiLinkPointArray1.Length - uiLinkPointArray2.Length) / 2);
|
||||
UILinkPoint downSide = (UILinkPoint) null;
|
||||
UILinkPoint uiLinkPoint = (UILinkPoint) null;
|
||||
for (int index = 0; index < snapPoints.Count; ++index)
|
||||
{
|
||||
SnapPoint snap = snapPoints[index];
|
||||
string name = snap.Name;
|
||||
if (!(name == "CreativeSacrificeConfirm"))
|
||||
{
|
||||
if (name == "CreativeInfinitesSearch")
|
||||
{
|
||||
uiLinkPoint = this._helper.MakeLinkPointFromSnapPoint(currentID++, snap);
|
||||
Main.CreativeMenu.GamepadPointIdForInfiniteItemSearchHack = uiLinkPoint.ID;
|
||||
}
|
||||
}
|
||||
else
|
||||
downSide = this._helper.MakeLinkPointFromSnapPoint(currentID++, snap);
|
||||
}
|
||||
UILinkPoint point = UILinkPointNavigator.Points[15000];
|
||||
List<SnapPoint> pointsByCategoryName4 = this._helper.GetOrderedPointsByCategoryName(snapPoints, "CreativeInfinitesFilter");
|
||||
if (pointsByCategoryName4.Count > 0)
|
||||
{
|
||||
UILinkPoint[] linkStripHorizontal = this._helper.CreateUILinkStripHorizontal(ref currentID, pointsByCategoryName4);
|
||||
if (uiLinkPoint != null)
|
||||
{
|
||||
uiLinkPoint.Up = linkStripHorizontal[0].ID;
|
||||
for (int index = 0; index < linkStripHorizontal.Length; ++index)
|
||||
linkStripHorizontal[index].Down = uiLinkPoint.ID;
|
||||
}
|
||||
}
|
||||
List<SnapPoint> pointsByCategoryName5 = this._helper.GetOrderedPointsByCategoryName(snapPoints, "CreativeInfinitesSlot");
|
||||
UILinkPoint[,] uiLinkPointArray3 = (UILinkPoint[,]) null;
|
||||
if (pointsByCategoryName5.Count > 0)
|
||||
{
|
||||
uiLinkPointArray3 = this._helper.CreateUILinkPointGrid(ref currentID, pointsByCategoryName5, this._infiniteItemsWindow.GetItemsPerLine(), uiLinkPoint, uiLinkPointArray1[0]);
|
||||
this._helper.LinkVerticalStripRightSideToSingle(uiLinkPointArray1, uiLinkPointArray3[0, 0]);
|
||||
}
|
||||
else if (uiLinkPoint != null)
|
||||
this._helper.LinkVerticalStripRightSideToSingle(uiLinkPointArray1, uiLinkPoint);
|
||||
if (uiLinkPoint != null && uiLinkPointArray3 != null)
|
||||
this._helper.PairUpDown(uiLinkPoint, uiLinkPointArray3[0, 0]);
|
||||
if (point != null && this.IsShowingResearchMenu)
|
||||
this._helper.LinkVerticalStripRightSideToSingle(uiLinkPointArray1, point);
|
||||
if (downSide != null)
|
||||
{
|
||||
this._helper.PairUpDown(point, downSide);
|
||||
downSide.Left = uiLinkPointArray1[0].ID;
|
||||
}
|
||||
if (!Main.CreativeMenu.GamepadMoveToSearchButtonHack)
|
||||
return;
|
||||
Main.CreativeMenu.GamepadMoveToSearchButtonHack = false;
|
||||
if (uiLinkPoint == null)
|
||||
return;
|
||||
UILinkPointNavigator.ChangePoint(uiLinkPoint.ID);
|
||||
}
|
||||
|
||||
private class MenuTree<TEnum> where TEnum : struct, IConvertible
|
||||
{
|
||||
public int CurrentOption;
|
||||
public Dictionary<int, GroupOptionButton<int>> Buttons = new Dictionary<int, GroupOptionButton<int>>();
|
||||
public Dictionary<int, UIElement> Sliders = new Dictionary<int, UIElement>();
|
||||
|
||||
public MenuTree(TEnum defaultValue) => this.CurrentOption = defaultValue.ToInt32((IFormatProvider) null);
|
||||
}
|
||||
|
||||
private enum OpenMainSubCategory
|
||||
{
|
||||
None,
|
||||
InfiniteItems,
|
||||
ResearchWindow,
|
||||
Time,
|
||||
Weather,
|
||||
EnemyStrengthSlider,
|
||||
PersonalPowers,
|
||||
}
|
||||
|
||||
private enum WeatherSubcategory
|
||||
{
|
||||
None,
|
||||
WindSlider,
|
||||
RainSlider,
|
||||
}
|
||||
|
||||
private enum TimeSubcategory
|
||||
{
|
||||
None,
|
||||
TimeRate,
|
||||
}
|
||||
|
||||
private enum PersonalSubcategory
|
||||
{
|
||||
None,
|
||||
EnemySpawnRateSlider,
|
||||
}
|
||||
}
|
||||
}
|
633
GameContent/UI/States/UIEmotesMenu.cs
Normal file
633
GameContent/UI/States/UIEmotesMenu.cs
Normal file
|
@ -0,0 +1,633 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.States.UIEmotesMenu
|
||||
// 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 System.Linq;
|
||||
using Terraria.Audio;
|
||||
using Terraria.GameContent.Events;
|
||||
using Terraria.GameContent.UI.Elements;
|
||||
using Terraria.ID;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI;
|
||||
using Terraria.UI.Gamepad;
|
||||
|
||||
namespace Terraria.GameContent.UI.States
|
||||
{
|
||||
public class UIEmotesMenu : UIState
|
||||
{
|
||||
private UIElement _outerContainer;
|
||||
private UIElement _backPanel;
|
||||
private UIElement _container;
|
||||
private UIList _list;
|
||||
private UIScrollbar _scrollBar;
|
||||
private bool _isScrollbarAttached;
|
||||
|
||||
public override void OnActivate()
|
||||
{
|
||||
this.InitializePage();
|
||||
if (Main.gameMenu)
|
||||
{
|
||||
this._outerContainer.Top.Set(220f, 0.0f);
|
||||
this._outerContainer.Height.Set(-220f, 1f);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._outerContainer.Top.Set(120f, 0.0f);
|
||||
this._outerContainer.Height.Set(-120f, 1f);
|
||||
}
|
||||
}
|
||||
|
||||
public void InitializePage()
|
||||
{
|
||||
this.RemoveAllChildren();
|
||||
UIElement element = new UIElement();
|
||||
element.Width.Set(590f, 0.0f);
|
||||
element.Top.Set(220f, 0.0f);
|
||||
element.Height.Set(-220f, 1f);
|
||||
element.HAlign = 0.5f;
|
||||
this._outerContainer = element;
|
||||
this.Append(element);
|
||||
UIPanel uiPanel = new UIPanel();
|
||||
uiPanel.Width.Set(0.0f, 1f);
|
||||
uiPanel.Height.Set(-110f, 1f);
|
||||
uiPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f;
|
||||
uiPanel.PaddingTop = 0.0f;
|
||||
element.Append((UIElement) uiPanel);
|
||||
this._container = (UIElement) uiPanel;
|
||||
UIList uiList = new UIList();
|
||||
uiList.Width.Set(-25f, 1f);
|
||||
uiList.Height.Set(-50f, 1f);
|
||||
uiList.Top.Set(50f, 0.0f);
|
||||
uiList.HAlign = 0.5f;
|
||||
uiList.ListPadding = 14f;
|
||||
uiPanel.Append((UIElement) uiList);
|
||||
this._list = uiList;
|
||||
UIScrollbar scrollbar = new UIScrollbar();
|
||||
scrollbar.SetView(100f, 1000f);
|
||||
scrollbar.Height.Set(-20f, 1f);
|
||||
scrollbar.HAlign = 1f;
|
||||
scrollbar.VAlign = 1f;
|
||||
scrollbar.Top = StyleDimension.FromPixels(-5f);
|
||||
uiList.SetScrollbar(scrollbar);
|
||||
this._scrollBar = scrollbar;
|
||||
UITextPanel<LocalizedText> uiTextPanel = new UITextPanel<LocalizedText>(Language.GetText("UI.Back"), 0.7f, true);
|
||||
uiTextPanel.Width.Set(-10f, 0.5f);
|
||||
uiTextPanel.Height.Set(50f, 0.0f);
|
||||
uiTextPanel.VAlign = 1f;
|
||||
uiTextPanel.HAlign = 0.5f;
|
||||
uiTextPanel.Top.Set(-45f, 0.0f);
|
||||
uiTextPanel.OnMouseOver += new UIElement.MouseEvent(this.FadedMouseOver);
|
||||
uiTextPanel.OnMouseOut += new UIElement.MouseEvent(this.FadedMouseOut);
|
||||
uiTextPanel.OnClick += new UIElement.MouseEvent(this.GoBackClick);
|
||||
uiTextPanel.SetSnapPoint("Back", 0);
|
||||
element.Append((UIElement) uiTextPanel);
|
||||
this._backPanel = (UIElement) uiTextPanel;
|
||||
int currentGroupIndex = 0;
|
||||
this.TryAddingList(Language.GetText("UI.EmoteCategoryGeneral"), ref currentGroupIndex, 10, this.GetEmotesGeneral());
|
||||
this.TryAddingList(Language.GetText("UI.EmoteCategoryRPS"), ref currentGroupIndex, 10, this.GetEmotesRPS());
|
||||
this.TryAddingList(Language.GetText("UI.EmoteCategoryItems"), ref currentGroupIndex, 11, this.GetEmotesItems());
|
||||
this.TryAddingList(Language.GetText("UI.EmoteCategoryBiomesAndEvents"), ref currentGroupIndex, 8, this.GetEmotesBiomesAndEvents());
|
||||
this.TryAddingList(Language.GetText("UI.EmoteCategoryTownNPCs"), ref currentGroupIndex, 9, this.GetEmotesTownNPCs());
|
||||
this.TryAddingList(Language.GetText("UI.EmoteCategoryCritters"), ref currentGroupIndex, 7, this.GetEmotesCritters());
|
||||
this.TryAddingList(Language.GetText("UI.EmoteCategoryBosses"), ref currentGroupIndex, 8, this.GetEmotesBosses());
|
||||
}
|
||||
|
||||
private void TryAddingList(
|
||||
LocalizedText title,
|
||||
ref int currentGroupIndex,
|
||||
int maxEmotesPerRow,
|
||||
List<int> emoteIds)
|
||||
{
|
||||
if (emoteIds == null || emoteIds.Count == 0)
|
||||
return;
|
||||
this._list.Add((UIElement) new EmotesGroupListItem(title, currentGroupIndex++, maxEmotesPerRow, emoteIds.ToArray()));
|
||||
}
|
||||
|
||||
private List<int> GetEmotesGeneral() => new List<int>()
|
||||
{
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
15,
|
||||
136,
|
||||
94,
|
||||
16,
|
||||
135,
|
||||
134,
|
||||
137,
|
||||
138,
|
||||
139,
|
||||
17,
|
||||
87,
|
||||
88,
|
||||
89,
|
||||
91,
|
||||
92,
|
||||
93,
|
||||
8,
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
14,
|
||||
100
|
||||
};
|
||||
|
||||
private List<int> GetEmotesRPS() => new List<int>()
|
||||
{
|
||||
36,
|
||||
37,
|
||||
38,
|
||||
33,
|
||||
34,
|
||||
35
|
||||
};
|
||||
|
||||
private List<int> GetEmotesItems() => new List<int>()
|
||||
{
|
||||
7,
|
||||
73,
|
||||
74,
|
||||
75,
|
||||
76,
|
||||
131,
|
||||
78,
|
||||
79,
|
||||
80,
|
||||
81,
|
||||
82,
|
||||
83,
|
||||
84,
|
||||
85,
|
||||
86,
|
||||
90,
|
||||
132,
|
||||
126,
|
||||
(int) sbyte.MaxValue,
|
||||
128,
|
||||
129
|
||||
};
|
||||
|
||||
private List<int> GetEmotesBiomesAndEvents() => new List<int>()
|
||||
{
|
||||
22,
|
||||
23,
|
||||
24,
|
||||
25,
|
||||
26,
|
||||
27,
|
||||
28,
|
||||
29,
|
||||
30,
|
||||
31,
|
||||
32,
|
||||
18,
|
||||
19,
|
||||
20,
|
||||
21,
|
||||
99,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
95,
|
||||
96,
|
||||
97,
|
||||
98
|
||||
};
|
||||
|
||||
private List<int> GetEmotesTownNPCs() => new List<int>()
|
||||
{
|
||||
101,
|
||||
102,
|
||||
103,
|
||||
104,
|
||||
105,
|
||||
106,
|
||||
107,
|
||||
108,
|
||||
109,
|
||||
110,
|
||||
111,
|
||||
112,
|
||||
113,
|
||||
114,
|
||||
115,
|
||||
116,
|
||||
117,
|
||||
118,
|
||||
119,
|
||||
120,
|
||||
121,
|
||||
122,
|
||||
123,
|
||||
124,
|
||||
125,
|
||||
130,
|
||||
140,
|
||||
141,
|
||||
142
|
||||
};
|
||||
|
||||
private List<int> GetEmotesCritters()
|
||||
{
|
||||
List<int> intList = new List<int>();
|
||||
intList.AddRange((IEnumerable<int>) new int[5]
|
||||
{
|
||||
12,
|
||||
13,
|
||||
61,
|
||||
62,
|
||||
63
|
||||
});
|
||||
intList.AddRange((IEnumerable<int>) new int[4]
|
||||
{
|
||||
67,
|
||||
68,
|
||||
69,
|
||||
70
|
||||
});
|
||||
intList.Add(72);
|
||||
if (NPC.downedGoblins)
|
||||
intList.Add(64);
|
||||
if (NPC.downedFrost)
|
||||
intList.Add(66);
|
||||
if (NPC.downedPirates)
|
||||
intList.Add(65);
|
||||
if (NPC.downedMartians)
|
||||
intList.Add(71);
|
||||
return intList;
|
||||
}
|
||||
|
||||
private List<int> GetEmotesBosses()
|
||||
{
|
||||
List<int> intList = new List<int>();
|
||||
if (NPC.downedBoss1)
|
||||
intList.Add(39);
|
||||
if (NPC.downedBoss2)
|
||||
{
|
||||
intList.Add(40);
|
||||
intList.Add(41);
|
||||
}
|
||||
if (NPC.downedSlimeKing)
|
||||
intList.Add(51);
|
||||
if (NPC.downedQueenBee)
|
||||
intList.Add(42);
|
||||
if (NPC.downedBoss3)
|
||||
intList.Add(43);
|
||||
if (Main.hardMode)
|
||||
intList.Add(44);
|
||||
if (NPC.downedQueenSlime)
|
||||
intList.Add(144);
|
||||
if (NPC.downedMechBoss1)
|
||||
intList.Add(45);
|
||||
if (NPC.downedMechBoss3)
|
||||
intList.Add(46);
|
||||
if (NPC.downedMechBoss2)
|
||||
intList.Add(47);
|
||||
if (NPC.downedPlantBoss)
|
||||
intList.Add(48);
|
||||
if (NPC.downedGolemBoss)
|
||||
intList.Add(49);
|
||||
if (NPC.downedFishron)
|
||||
intList.Add(50);
|
||||
if (NPC.downedEmpressOfLight)
|
||||
intList.Add(143);
|
||||
if (NPC.downedAncientCultist)
|
||||
intList.Add(52);
|
||||
if (NPC.downedMoonlord)
|
||||
intList.Add(53);
|
||||
if (NPC.downedHalloweenTree)
|
||||
intList.Add(54);
|
||||
if (NPC.downedHalloweenKing)
|
||||
intList.Add(55);
|
||||
if (NPC.downedChristmasTree)
|
||||
intList.Add(56);
|
||||
if (NPC.downedChristmasIceQueen)
|
||||
intList.Add(57);
|
||||
if (NPC.downedChristmasSantank)
|
||||
intList.Add(58);
|
||||
if (NPC.downedPirates)
|
||||
intList.Add(59);
|
||||
if (NPC.downedMartians)
|
||||
intList.Add(60);
|
||||
if (DD2Event.DownedInvasionAnyDifficulty)
|
||||
intList.Add(133);
|
||||
return intList;
|
||||
}
|
||||
|
||||
public override void Recalculate()
|
||||
{
|
||||
if (this._scrollBar != null)
|
||||
{
|
||||
if (this._isScrollbarAttached && !this._scrollBar.CanScroll)
|
||||
{
|
||||
this._container.RemoveChild((UIElement) this._scrollBar);
|
||||
this._isScrollbarAttached = false;
|
||||
this._list.Width.Set(0.0f, 1f);
|
||||
}
|
||||
else if (!this._isScrollbarAttached && this._scrollBar.CanScroll)
|
||||
{
|
||||
this._container.Append((UIElement) this._scrollBar);
|
||||
this._isScrollbarAttached = true;
|
||||
this._list.Width.Set(-25f, 1f);
|
||||
}
|
||||
}
|
||||
base.Recalculate();
|
||||
}
|
||||
|
||||
private void GoBackClick(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
Main.menuMode = 0;
|
||||
IngameFancyUI.Close();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
base.Draw(spriteBatch);
|
||||
this.SetupGamepadPoints2(spriteBatch);
|
||||
}
|
||||
|
||||
private void SetupGamepadPoints2(SpriteBatch spriteBatch)
|
||||
{
|
||||
int num1 = 7;
|
||||
UILinkPointNavigator.Shortcuts.BackButtonCommand = 1;
|
||||
int ID;
|
||||
int key1 = ID = 3001;
|
||||
List<SnapPoint> snapPoints = this.GetSnapPoints();
|
||||
this.RemoveSnapPointsOutOfScreen(spriteBatch, snapPoints);
|
||||
Vector2 vector2 = this._backPanel.GetInnerDimensions().ToRectangle().Center.ToVector2();
|
||||
UILinkPointNavigator.SetPosition(ID, vector2);
|
||||
UILinkPoint point1 = UILinkPointNavigator.Points[key1];
|
||||
point1.Unlink();
|
||||
point1.Up = key1 + 1;
|
||||
UILinkPoint uiLinkPoint = point1;
|
||||
int num2 = key1 + 1;
|
||||
int length = 0;
|
||||
List<List<SnapPoint>> snapPointListList = new List<List<SnapPoint>>();
|
||||
for (int groupIndex = 0; groupIndex < num1; ++groupIndex)
|
||||
{
|
||||
List<SnapPoint> emoteGroup = this.GetEmoteGroup(snapPoints, groupIndex);
|
||||
if (emoteGroup.Count > 0)
|
||||
snapPointListList.Add(emoteGroup);
|
||||
length += (int) Math.Ceiling((double) emoteGroup.Count / 14.0);
|
||||
}
|
||||
SnapPoint[,] snapPointArray = new SnapPoint[14, length];
|
||||
int num3 = 0;
|
||||
for (int index1 = 0; index1 < snapPointListList.Count; ++index1)
|
||||
{
|
||||
List<SnapPoint> snapPointList = snapPointListList[index1];
|
||||
for (int index2 = 0; index2 < snapPointList.Count; ++index2)
|
||||
{
|
||||
int index3 = num3 + index2 / 14;
|
||||
int index4 = index2 % 14;
|
||||
snapPointArray[index4, index3] = snapPointList[index2];
|
||||
}
|
||||
num3 += (int) Math.Ceiling((double) snapPointList.Count / 14.0);
|
||||
}
|
||||
int[,] grid = new int[14, length];
|
||||
int num4 = 0;
|
||||
for (int index5 = 0; index5 < snapPointArray.GetLength(1); ++index5)
|
||||
{
|
||||
for (int index6 = 0; index6 < snapPointArray.GetLength(0); ++index6)
|
||||
{
|
||||
SnapPoint snapPoint = snapPointArray[index6, index5];
|
||||
if (snapPoint != null)
|
||||
{
|
||||
UILinkPointNavigator.Points[num2].Unlink();
|
||||
UILinkPointNavigator.SetPosition(num2, snapPoint.Position);
|
||||
grid[index6, index5] = num2;
|
||||
if (index6 == 0)
|
||||
num4 = num2;
|
||||
++num2;
|
||||
}
|
||||
}
|
||||
}
|
||||
uiLinkPoint.Up = num4;
|
||||
for (int y1 = 0; y1 < snapPointArray.GetLength(1); ++y1)
|
||||
{
|
||||
for (int x1 = 0; x1 < snapPointArray.GetLength(0); ++x1)
|
||||
{
|
||||
int key2 = grid[x1, y1];
|
||||
if (key2 != 0)
|
||||
{
|
||||
UILinkPoint point2 = UILinkPointNavigator.Points[key2];
|
||||
if (this.TryGetPointOnGrid(grid, x1, y1, -1, 0))
|
||||
{
|
||||
point2.Left = grid[x1 - 1, y1];
|
||||
}
|
||||
else
|
||||
{
|
||||
point2.Left = point2.ID;
|
||||
for (int x2 = x1; x2 < snapPointArray.GetLength(0); ++x2)
|
||||
{
|
||||
if (this.TryGetPointOnGrid(grid, x2, y1, 0, 0))
|
||||
point2.Left = grid[x2, y1];
|
||||
}
|
||||
}
|
||||
if (this.TryGetPointOnGrid(grid, x1, y1, 1, 0))
|
||||
{
|
||||
point2.Right = grid[x1 + 1, y1];
|
||||
}
|
||||
else
|
||||
{
|
||||
point2.Right = point2.ID;
|
||||
for (int x3 = x1; x3 >= 0; --x3)
|
||||
{
|
||||
if (this.TryGetPointOnGrid(grid, x3, y1, 0, 0))
|
||||
point2.Right = grid[x3, y1];
|
||||
}
|
||||
}
|
||||
if (this.TryGetPointOnGrid(grid, x1, y1, 0, -1))
|
||||
{
|
||||
point2.Up = grid[x1, y1 - 1];
|
||||
}
|
||||
else
|
||||
{
|
||||
point2.Up = point2.ID;
|
||||
for (int y2 = y1 - 1; y2 >= 0; --y2)
|
||||
{
|
||||
if (this.TryGetPointOnGrid(grid, x1, y2, 0, 0))
|
||||
{
|
||||
point2.Up = grid[x1, y2];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.TryGetPointOnGrid(grid, x1, y1, 0, 1))
|
||||
{
|
||||
point2.Down = grid[x1, y1 + 1];
|
||||
}
|
||||
else
|
||||
{
|
||||
point2.Down = point2.ID;
|
||||
for (int y3 = y1 + 1; y3 < snapPointArray.GetLength(1); ++y3)
|
||||
{
|
||||
if (this.TryGetPointOnGrid(grid, x1, y3, 0, 0))
|
||||
{
|
||||
point2.Down = grid[x1, y3];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (point2.Down == point2.ID)
|
||||
point2.Down = uiLinkPoint.ID;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool TryGetPointOnGrid(int[,] grid, int x, int y, int offsetX, int offsetY) => x + offsetX >= 0 && x + offsetX < grid.GetLength(0) && y + offsetY >= 0 && y + offsetY < grid.GetLength(1) && grid[x + offsetX, y + offsetY] != 0;
|
||||
|
||||
private void RemoveSnapPointsOutOfScreen(SpriteBatch spriteBatch, List<SnapPoint> pts)
|
||||
{
|
||||
float num = 1f / Main.UIScale;
|
||||
Rectangle clippingRectangle = this._container.GetClippingRectangle(spriteBatch);
|
||||
Vector2 minimum = clippingRectangle.TopLeft() * num;
|
||||
Vector2 maximum = clippingRectangle.BottomRight() * num;
|
||||
for (int index = 0; index < pts.Count; ++index)
|
||||
{
|
||||
if (!pts[index].Position.Between(minimum, maximum))
|
||||
{
|
||||
pts.Remove(pts[index]);
|
||||
--index;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SetupGamepadPoints(SpriteBatch spriteBatch)
|
||||
{
|
||||
UILinkPointNavigator.Shortcuts.BackButtonCommand = 1;
|
||||
int ID = 3001;
|
||||
int key = ID;
|
||||
List<SnapPoint> snapPoints = this.GetSnapPoints();
|
||||
UILinkPointNavigator.SetPosition(ID, this._backPanel.GetInnerDimensions().ToRectangle().Center.ToVector2());
|
||||
UILinkPoint point1 = UILinkPointNavigator.Points[key];
|
||||
point1.Unlink();
|
||||
point1.Up = key + 1;
|
||||
UILinkPoint uiLinkPoint = point1;
|
||||
int num1 = key + 1;
|
||||
float num2 = 1f / Main.UIScale;
|
||||
Rectangle clippingRectangle = this._container.GetClippingRectangle(spriteBatch);
|
||||
Vector2 minimum = clippingRectangle.TopLeft() * num2;
|
||||
Vector2 maximum = clippingRectangle.BottomRight() * num2;
|
||||
for (int index = 0; index < snapPoints.Count; ++index)
|
||||
{
|
||||
if (!snapPoints[index].Position.Between(minimum, maximum))
|
||||
{
|
||||
snapPoints.Remove(snapPoints[index]);
|
||||
--index;
|
||||
}
|
||||
}
|
||||
int num3 = 0;
|
||||
int num4 = 7;
|
||||
List<List<SnapPoint>> snapPointListList = new List<List<SnapPoint>>();
|
||||
for (int groupIndex = 0; groupIndex < num4; ++groupIndex)
|
||||
{
|
||||
List<SnapPoint> emoteGroup = this.GetEmoteGroup(snapPoints, groupIndex);
|
||||
if (emoteGroup.Count > 0)
|
||||
snapPointListList.Add(emoteGroup);
|
||||
}
|
||||
List<SnapPoint>[] array = snapPointListList.ToArray();
|
||||
for (int index1 = 0; index1 < array.Length; ++index1)
|
||||
{
|
||||
List<SnapPoint> snapPointList = array[index1];
|
||||
int num5 = snapPointList.Count / 14;
|
||||
if (snapPointList.Count % 14 > 0)
|
||||
++num5;
|
||||
int num6 = 14;
|
||||
if (snapPointList.Count % 14 != 0)
|
||||
num6 = snapPointList.Count % 14;
|
||||
for (int index2 = 0; index2 < snapPointList.Count; ++index2)
|
||||
{
|
||||
UILinkPoint point2 = UILinkPointNavigator.Points[num1];
|
||||
point2.Unlink();
|
||||
UILinkPointNavigator.SetPosition(num1, snapPointList[index2].Position);
|
||||
int num7 = 14;
|
||||
if (index2 / 14 == num5 - 1 && snapPointList.Count % 14 != 0)
|
||||
num7 = snapPointList.Count % 14;
|
||||
int num8 = index2 % 14;
|
||||
point2.Left = num1 - 1;
|
||||
point2.Right = num1 + 1;
|
||||
point2.Up = num1 - 14;
|
||||
point2.Down = num1 + 14;
|
||||
if (num8 == num7 - 1)
|
||||
point2.Right = num1 - num7 + 1;
|
||||
if (num8 == 0)
|
||||
point2.Left = num1 + num7 - 1;
|
||||
if (num8 == 0)
|
||||
uiLinkPoint.Up = num1;
|
||||
if (index2 < 14)
|
||||
{
|
||||
if (num3 == 0)
|
||||
{
|
||||
point2.Up = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
point2.Up = num1 - 14;
|
||||
if (num8 >= num3)
|
||||
point2.Up -= 14;
|
||||
for (int index3 = index1 - 1; index3 > 0 && array[index3].Count <= num8; --index3)
|
||||
point2.Up -= 14;
|
||||
}
|
||||
}
|
||||
int num9 = ID;
|
||||
if (index1 == array.Length - 1)
|
||||
{
|
||||
if (index2 / 14 < num5 - 1 && num8 >= snapPointList.Count % 14)
|
||||
point2.Down = num9;
|
||||
if (index2 / 14 == num5 - 1)
|
||||
point2.Down = num9;
|
||||
}
|
||||
else if (index2 / 14 == num5 - 1)
|
||||
{
|
||||
point2.Down = num1 + 14;
|
||||
for (int index4 = index1 + 1; index4 < array.Length && array[index4].Count <= num8; ++index4)
|
||||
point2.Down += 14;
|
||||
if (index1 == array.Length - 1)
|
||||
point2.Down = num9;
|
||||
}
|
||||
else if (num8 >= num6)
|
||||
{
|
||||
point2.Down = num1 + 14 + 14;
|
||||
for (int index5 = index1 + 1; index5 < array.Length && array[index5].Count <= num8; ++index5)
|
||||
point2.Down += 14;
|
||||
}
|
||||
++num1;
|
||||
}
|
||||
num3 = num6;
|
||||
int num10 = 14 - num3;
|
||||
num1 += num10;
|
||||
}
|
||||
}
|
||||
|
||||
private List<SnapPoint> GetEmoteGroup(List<SnapPoint> ptsOnPage, int groupIndex)
|
||||
{
|
||||
string groupName = "Group " + (object) groupIndex;
|
||||
List<SnapPoint> list = ptsOnPage.Where<SnapPoint>((Func<SnapPoint, bool>) (a => a.Name == groupName)).ToList<SnapPoint>();
|
||||
list.Sort(new Comparison<SnapPoint>(this.SortPoints));
|
||||
return list;
|
||||
}
|
||||
|
||||
private int SortPoints(SnapPoint a, SnapPoint b) => a.Id.CompareTo(b.Id);
|
||||
}
|
||||
}
|
237
GameContent/UI/States/UIGamepadHelper.cs
Normal file
237
GameContent/UI/States/UIGamepadHelper.cs
Normal file
|
@ -0,0 +1,237 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.States.UIGamepadHelper
|
||||
// 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 System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using Terraria.GameInput;
|
||||
using Terraria.UI;
|
||||
using Terraria.UI.Gamepad;
|
||||
|
||||
namespace Terraria.GameContent.UI.States
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Size = 1)]
|
||||
public struct UIGamepadHelper
|
||||
{
|
||||
public UILinkPoint[,] CreateUILinkPointGrid(
|
||||
ref int currentID,
|
||||
List<SnapPoint> pointsForGrid,
|
||||
int pointsPerLine,
|
||||
UILinkPoint topLinkPoint,
|
||||
UILinkPoint leftLinkPoint)
|
||||
{
|
||||
int length = (int) Math.Ceiling((double) pointsForGrid.Count / (double) pointsPerLine);
|
||||
UILinkPoint[,] uiLinkPointArray = new UILinkPoint[pointsPerLine, length];
|
||||
for (int index1 = 0; index1 < pointsForGrid.Count; ++index1)
|
||||
{
|
||||
int index2 = index1 % pointsPerLine;
|
||||
int index3 = index1 / pointsPerLine;
|
||||
uiLinkPointArray[index2, index3] = this.MakeLinkPointFromSnapPoint(currentID++, pointsForGrid[index1]);
|
||||
}
|
||||
for (int index4 = 0; index4 < uiLinkPointArray.GetLength(0); ++index4)
|
||||
{
|
||||
for (int index5 = 0; index5 < uiLinkPointArray.GetLength(1); ++index5)
|
||||
{
|
||||
UILinkPoint uiLinkPoint = uiLinkPointArray[index4, index5];
|
||||
if (uiLinkPoint != null)
|
||||
{
|
||||
if (index4 < uiLinkPointArray.GetLength(0) - 1)
|
||||
{
|
||||
UILinkPoint rightSide = uiLinkPointArray[index4 + 1, index5];
|
||||
if (rightSide != null)
|
||||
this.PairLeftRight(uiLinkPoint, rightSide);
|
||||
}
|
||||
if (index5 < uiLinkPointArray.GetLength(1) - 1)
|
||||
{
|
||||
UILinkPoint downSide = uiLinkPointArray[index4, index5 + 1];
|
||||
if (downSide != null)
|
||||
this.PairUpDown(uiLinkPoint, downSide);
|
||||
}
|
||||
if (index4 == 0)
|
||||
uiLinkPoint.Left = leftLinkPoint.ID;
|
||||
if (index5 == 0)
|
||||
uiLinkPoint.Up = topLinkPoint.ID;
|
||||
}
|
||||
}
|
||||
}
|
||||
return uiLinkPointArray;
|
||||
}
|
||||
|
||||
public void LinkVerticalStrips(
|
||||
UILinkPoint[] stripOnLeft,
|
||||
UILinkPoint[] stripOnRight,
|
||||
int leftStripStartOffset)
|
||||
{
|
||||
if (stripOnLeft == null || stripOnRight == null)
|
||||
return;
|
||||
int num1 = Math.Max(stripOnLeft.Length, stripOnRight.Length);
|
||||
int num2 = Math.Min(stripOnLeft.Length, stripOnRight.Length);
|
||||
for (int index = 0; index < leftStripStartOffset; ++index)
|
||||
this.PairLeftRight(stripOnLeft[index], stripOnRight[0]);
|
||||
for (int index = 0; index < num2; ++index)
|
||||
this.PairLeftRight(stripOnLeft[index + leftStripStartOffset], stripOnRight[index]);
|
||||
for (int index = num2; index < num1; ++index)
|
||||
{
|
||||
if (stripOnLeft.Length > index)
|
||||
stripOnLeft[index].Right = stripOnRight[stripOnRight.Length - 1].ID;
|
||||
if (stripOnRight.Length > index)
|
||||
stripOnRight[index].Left = stripOnLeft[stripOnLeft.Length - 1].ID;
|
||||
}
|
||||
}
|
||||
|
||||
public void LinkVerticalStripRightSideToSingle(UILinkPoint[] strip, UILinkPoint theSingle)
|
||||
{
|
||||
if (strip == null || theSingle == null)
|
||||
return;
|
||||
int num1 = Math.Max(strip.Length, 1);
|
||||
int num2 = Math.Min(strip.Length, 1);
|
||||
for (int index = 0; index < num2; ++index)
|
||||
this.PairLeftRight(strip[index], theSingle);
|
||||
for (int index = num2; index < num1; ++index)
|
||||
{
|
||||
if (strip.Length > index)
|
||||
strip[index].Right = theSingle.ID;
|
||||
}
|
||||
}
|
||||
|
||||
public void LinkVerticalStripBottomSideToSingle(UILinkPoint[] strip, UILinkPoint theSingle)
|
||||
{
|
||||
if (strip == null || theSingle == null)
|
||||
return;
|
||||
this.PairUpDown(strip[strip.Length - 1], theSingle);
|
||||
}
|
||||
|
||||
public UILinkPoint[] CreateUILinkStripVertical(
|
||||
ref int currentID,
|
||||
List<SnapPoint> currentStrip)
|
||||
{
|
||||
UILinkPoint[] uiLinkPointArray = new UILinkPoint[currentStrip.Count];
|
||||
for (int index = 0; index < currentStrip.Count; ++index)
|
||||
uiLinkPointArray[index] = this.MakeLinkPointFromSnapPoint(currentID++, currentStrip[index]);
|
||||
for (int index = 0; index < currentStrip.Count - 1; ++index)
|
||||
this.PairUpDown(uiLinkPointArray[index], uiLinkPointArray[index + 1]);
|
||||
return uiLinkPointArray;
|
||||
}
|
||||
|
||||
public UILinkPoint[] CreateUILinkStripHorizontal(
|
||||
ref int currentID,
|
||||
List<SnapPoint> currentStrip)
|
||||
{
|
||||
UILinkPoint[] uiLinkPointArray = new UILinkPoint[currentStrip.Count];
|
||||
for (int index = 0; index < currentStrip.Count; ++index)
|
||||
uiLinkPointArray[index] = this.MakeLinkPointFromSnapPoint(currentID++, currentStrip[index]);
|
||||
for (int index = 0; index < currentStrip.Count - 1; ++index)
|
||||
this.PairLeftRight(uiLinkPointArray[index], uiLinkPointArray[index + 1]);
|
||||
return uiLinkPointArray;
|
||||
}
|
||||
|
||||
public void TryMovingBackIntoCreativeGridIfOutOfIt(int start, int currentID)
|
||||
{
|
||||
List<UILinkPoint> lostrefpoints = new List<UILinkPoint>();
|
||||
for (int key = start; key < currentID; ++key)
|
||||
lostrefpoints.Add(UILinkPointNavigator.Points[key]);
|
||||
if (!PlayerInput.UsingGamepadUI || UILinkPointNavigator.CurrentPoint < currentID)
|
||||
return;
|
||||
this.MoveToVisuallyClosestPoint(lostrefpoints);
|
||||
}
|
||||
|
||||
public void MoveToVisuallyClosestPoint(List<UILinkPoint> lostrefpoints)
|
||||
{
|
||||
Dictionary<int, UILinkPoint> points = UILinkPointNavigator.Points;
|
||||
Vector2 mouseScreen = Main.MouseScreen;
|
||||
UILinkPoint uiLinkPoint = (UILinkPoint) null;
|
||||
foreach (UILinkPoint lostrefpoint in lostrefpoints)
|
||||
{
|
||||
if (uiLinkPoint == null || (double) Vector2.Distance(mouseScreen, uiLinkPoint.Position) > (double) Vector2.Distance(mouseScreen, lostrefpoint.Position))
|
||||
uiLinkPoint = lostrefpoint;
|
||||
}
|
||||
if (uiLinkPoint == null)
|
||||
return;
|
||||
UILinkPointNavigator.ChangePoint(uiLinkPoint.ID);
|
||||
}
|
||||
|
||||
public List<SnapPoint> GetOrderedPointsByCategoryName(
|
||||
List<SnapPoint> pts,
|
||||
string name)
|
||||
{
|
||||
return pts.Where<SnapPoint>((Func<SnapPoint, bool>) (x => x.Name == name)).OrderBy<SnapPoint, int>((Func<SnapPoint, int>) (x => x.Id)).ToList<SnapPoint>();
|
||||
}
|
||||
|
||||
public void PairLeftRight(UILinkPoint leftSide, UILinkPoint rightSide)
|
||||
{
|
||||
leftSide.Right = rightSide.ID;
|
||||
rightSide.Left = leftSide.ID;
|
||||
}
|
||||
|
||||
public void PairUpDown(UILinkPoint upSide, UILinkPoint downSide)
|
||||
{
|
||||
upSide.Down = downSide.ID;
|
||||
downSide.Up = upSide.ID;
|
||||
}
|
||||
|
||||
public UILinkPoint MakeLinkPointFromSnapPoint(int id, SnapPoint snap)
|
||||
{
|
||||
UILinkPointNavigator.SetPosition(id, snap.Position);
|
||||
UILinkPoint point = UILinkPointNavigator.Points[id];
|
||||
point.Unlink();
|
||||
return point;
|
||||
}
|
||||
|
||||
public UILinkPoint[] GetVerticalStripFromCategoryName(
|
||||
ref int currentID,
|
||||
List<SnapPoint> pts,
|
||||
string categoryName)
|
||||
{
|
||||
List<SnapPoint> pointsByCategoryName = this.GetOrderedPointsByCategoryName(pts, categoryName);
|
||||
UILinkPoint[] uiLinkPointArray = (UILinkPoint[]) null;
|
||||
if (pointsByCategoryName.Count > 0)
|
||||
uiLinkPointArray = this.CreateUILinkStripVertical(ref currentID, pointsByCategoryName);
|
||||
return uiLinkPointArray;
|
||||
}
|
||||
|
||||
public void MoveToVisuallyClosestPoint(int idRangeStartInclusive, int idRangeEndExclusive)
|
||||
{
|
||||
if (UILinkPointNavigator.CurrentPoint >= idRangeStartInclusive && UILinkPointNavigator.CurrentPoint < idRangeEndExclusive)
|
||||
return;
|
||||
Dictionary<int, UILinkPoint> points = UILinkPointNavigator.Points;
|
||||
Vector2 mouseScreen = Main.MouseScreen;
|
||||
UILinkPoint uiLinkPoint1 = (UILinkPoint) null;
|
||||
for (int key = idRangeStartInclusive; key < idRangeEndExclusive; ++key)
|
||||
{
|
||||
UILinkPoint uiLinkPoint2;
|
||||
if (!points.TryGetValue(key, out uiLinkPoint2))
|
||||
return;
|
||||
if (uiLinkPoint1 == null || (double) Vector2.Distance(mouseScreen, uiLinkPoint1.Position) > (double) Vector2.Distance(mouseScreen, uiLinkPoint2.Position))
|
||||
uiLinkPoint1 = uiLinkPoint2;
|
||||
}
|
||||
if (uiLinkPoint1 == null)
|
||||
return;
|
||||
UILinkPointNavigator.ChangePoint(uiLinkPoint1.ID);
|
||||
}
|
||||
|
||||
public void CullPointsOutOfElementArea(
|
||||
SpriteBatch spriteBatch,
|
||||
List<SnapPoint> pointsAtMiddle,
|
||||
UIElement container)
|
||||
{
|
||||
float num = 1f / Main.UIScale;
|
||||
Rectangle clippingRectangle = container.GetClippingRectangle(spriteBatch);
|
||||
Vector2 minimum = clippingRectangle.TopLeft() * num;
|
||||
Vector2 maximum = clippingRectangle.BottomRight() * num;
|
||||
for (int index = 0; index < pointsAtMiddle.Count; ++index)
|
||||
{
|
||||
if (!pointsAtMiddle[index].Position.Between(minimum, maximum))
|
||||
{
|
||||
pointsAtMiddle.Remove(pointsAtMiddle[index]);
|
||||
--index;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
1078
GameContent/UI/States/UIManageControls.cs
Normal file
1078
GameContent/UI/States/UIManageControls.cs
Normal file
File diff suppressed because it is too large
Load diff
209
GameContent/UI/States/UIResourcePackInfoMenu.cs
Normal file
209
GameContent/UI/States/UIResourcePackInfoMenu.cs
Normal file
|
@ -0,0 +1,209 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.States.UIResourcePackInfoMenu
|
||||
// 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.UI.Elements;
|
||||
using Terraria.GameInput;
|
||||
using Terraria.ID;
|
||||
using Terraria.IO;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI;
|
||||
using Terraria.UI.Gamepad;
|
||||
|
||||
namespace Terraria.GameContent.UI.States
|
||||
{
|
||||
public class UIResourcePackInfoMenu : UIState
|
||||
{
|
||||
private UIResourcePackSelectionMenu _resourceMenu;
|
||||
private ResourcePack _pack;
|
||||
private UIElement _container;
|
||||
private UIList _list;
|
||||
private UIScrollbar _scrollbar;
|
||||
private bool _isScrollbarAttached;
|
||||
private const string _backPointName = "GoBack";
|
||||
private UIGamepadHelper _helper;
|
||||
|
||||
public UIResourcePackInfoMenu(UIResourcePackSelectionMenu parent, ResourcePack pack)
|
||||
{
|
||||
this._resourceMenu = parent;
|
||||
this._pack = pack;
|
||||
this.BuildPage();
|
||||
}
|
||||
|
||||
private void BuildPage()
|
||||
{
|
||||
this.RemoveAllChildren();
|
||||
UIElement element1 = new UIElement();
|
||||
element1.Width.Set(0.0f, 0.8f);
|
||||
element1.MaxWidth.Set(500f, 0.0f);
|
||||
element1.MinWidth.Set(300f, 0.0f);
|
||||
element1.Top.Set(230f, 0.0f);
|
||||
element1.Height.Set(-element1.Top.Pixels, 1f);
|
||||
element1.HAlign = 0.5f;
|
||||
this.Append(element1);
|
||||
UIPanel uiPanel = new UIPanel();
|
||||
uiPanel.Width.Set(0.0f, 1f);
|
||||
uiPanel.Height.Set(-110f, 1f);
|
||||
uiPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f;
|
||||
element1.Append((UIElement) uiPanel);
|
||||
UIElement element2 = new UIElement()
|
||||
{
|
||||
Width = StyleDimension.Fill,
|
||||
Height = StyleDimension.FromPixelsAndPercent(0.0f, 1f)
|
||||
};
|
||||
uiPanel.Append(element2);
|
||||
UIElement element3 = new UIElement()
|
||||
{
|
||||
Width = new StyleDimension(0.0f, 1f),
|
||||
Height = new StyleDimension(52f, 0.0f)
|
||||
};
|
||||
element3.SetPadding(0.0f);
|
||||
element2.Append(element3);
|
||||
UIText uiText1 = new UIText(this._pack.Name, 0.7f, true)
|
||||
{
|
||||
TextColor = Color.Gold
|
||||
};
|
||||
uiText1.HAlign = 0.5f;
|
||||
uiText1.VAlign = 0.0f;
|
||||
element3.Append((UIElement) uiText1);
|
||||
UIText uiText2 = new UIText(Language.GetTextValue("UI.Author", (object) this._pack.Author), 0.9f);
|
||||
uiText2.HAlign = 0.0f;
|
||||
uiText2.VAlign = 1f;
|
||||
UIText uiText3 = uiText2;
|
||||
uiText3.Top.Set(-6f, 0.0f);
|
||||
element3.Append((UIElement) uiText3);
|
||||
UIText uiText4 = new UIText(Language.GetTextValue("UI.Version", (object) this._pack.Version.GetFormattedVersion()), 0.9f);
|
||||
uiText4.HAlign = 1f;
|
||||
uiText4.VAlign = 1f;
|
||||
uiText4.TextColor = Color.Silver;
|
||||
UIText uiText5 = uiText4;
|
||||
uiText5.Top.Set(-6f, 0.0f);
|
||||
element3.Append((UIElement) uiText5);
|
||||
Asset<Texture2D> asset = Main.Assets.Request<Texture2D>("Images/UI/Divider", (AssetRequestMode) 1);
|
||||
UIImage uiImage1 = new UIImage(asset);
|
||||
uiImage1.Width = StyleDimension.FromPixelsAndPercent(0.0f, 1f);
|
||||
uiImage1.Height = StyleDimension.FromPixels((float) asset.Height());
|
||||
uiImage1.ScaleToFit = true;
|
||||
UIImage uiImage2 = uiImage1;
|
||||
uiImage2.Top.Set(52f, 0.0f);
|
||||
uiImage2.SetPadding(6f);
|
||||
element2.Append((UIElement) uiImage2);
|
||||
UIElement element4 = new UIElement()
|
||||
{
|
||||
HAlign = 0.5f,
|
||||
VAlign = 1f,
|
||||
Width = StyleDimension.FromPixelsAndPercent(0.0f, 1f),
|
||||
Height = StyleDimension.FromPixelsAndPercent(-74f, 1f)
|
||||
};
|
||||
element2.Append(element4);
|
||||
this._container = element4;
|
||||
UIText uiText6 = new UIText(this._pack.Description);
|
||||
uiText6.HAlign = 0.5f;
|
||||
uiText6.VAlign = 0.0f;
|
||||
uiText6.Width = StyleDimension.FromPixelsAndPercent(0.0f, 1f);
|
||||
uiText6.Height = StyleDimension.FromPixelsAndPercent(0.0f, 0.0f);
|
||||
uiText6.IsWrapped = true;
|
||||
uiText6.WrappedTextBottomPadding = 0.0f;
|
||||
UIText uiText7 = uiText6;
|
||||
UIList uiList1 = new UIList();
|
||||
uiList1.HAlign = 0.5f;
|
||||
uiList1.VAlign = 0.0f;
|
||||
uiList1.Width = StyleDimension.FromPixelsAndPercent(0.0f, 1f);
|
||||
uiList1.Height = StyleDimension.FromPixelsAndPercent(0.0f, 1f);
|
||||
uiList1.PaddingRight = 20f;
|
||||
UIList uiList2 = uiList1;
|
||||
uiList2.ListPadding = 5f;
|
||||
uiList2.Add((UIElement) uiText7);
|
||||
element4.Append((UIElement) uiList2);
|
||||
this._list = uiList2;
|
||||
UIScrollbar scrollbar = new UIScrollbar();
|
||||
scrollbar.SetView(100f, 1000f);
|
||||
scrollbar.Height.Set(0.0f, 1f);
|
||||
scrollbar.HAlign = 1f;
|
||||
this._scrollbar = scrollbar;
|
||||
uiList2.SetScrollbar(scrollbar);
|
||||
UITextPanel<LocalizedText> uiTextPanel = new UITextPanel<LocalizedText>(Language.GetText("UI.Back"), 0.7f, true);
|
||||
uiTextPanel.Width.Set(-10f, 0.5f);
|
||||
uiTextPanel.Height.Set(50f, 0.0f);
|
||||
uiTextPanel.VAlign = 1f;
|
||||
uiTextPanel.HAlign = 0.5f;
|
||||
uiTextPanel.Top.Set(-45f, 0.0f);
|
||||
uiTextPanel.OnMouseOver += new UIElement.MouseEvent(UIResourcePackInfoMenu.FadedMouseOver);
|
||||
uiTextPanel.OnMouseOut += new UIElement.MouseEvent(UIResourcePackInfoMenu.FadedMouseOut);
|
||||
uiTextPanel.OnClick += new UIElement.MouseEvent(this.GoBackClick);
|
||||
uiTextPanel.SetSnapPoint("GoBack", 0);
|
||||
element1.Append((UIElement) uiTextPanel);
|
||||
}
|
||||
|
||||
public override void Recalculate()
|
||||
{
|
||||
if (this._scrollbar != null)
|
||||
{
|
||||
if (this._isScrollbarAttached && !this._scrollbar.CanScroll)
|
||||
{
|
||||
this._container.RemoveChild((UIElement) this._scrollbar);
|
||||
this._isScrollbarAttached = false;
|
||||
this._list.Width.Set(0.0f, 1f);
|
||||
}
|
||||
else if (!this._isScrollbarAttached && this._scrollbar.CanScroll)
|
||||
{
|
||||
this._container.Append((UIElement) this._scrollbar);
|
||||
this._isScrollbarAttached = true;
|
||||
this._list.Width.Set(-25f, 1f);
|
||||
}
|
||||
}
|
||||
base.Recalculate();
|
||||
}
|
||||
|
||||
private void GoBackClick(UIMouseEvent evt, UIElement listeningElement) => Main.MenuUI.SetState((UIState) this._resourceMenu);
|
||||
|
||||
private static 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 static void FadedMouseOut(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
((UIPanel) evt.Target).BackgroundColor = new Color(63, 82, 151) * 0.8f;
|
||||
((UIPanel) evt.Target).BorderColor = Color.Black;
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
base.Draw(spriteBatch);
|
||||
this.SetupGamepadPoints(spriteBatch);
|
||||
}
|
||||
|
||||
private void SetupGamepadPoints(SpriteBatch spriteBatch)
|
||||
{
|
||||
UILinkPointNavigator.Shortcuts.BackButtonCommand = 1;
|
||||
int idRangeStartInclusive = 3000;
|
||||
int idRangeEndExclusive = idRangeStartInclusive;
|
||||
List<SnapPoint> snapPoints = this.GetSnapPoints();
|
||||
UILinkPoint uiLinkPoint = (UILinkPoint) null;
|
||||
for (int index = 0; index < snapPoints.Count; ++index)
|
||||
{
|
||||
SnapPoint snap = snapPoints[index];
|
||||
if (snap.Name == "GoBack")
|
||||
uiLinkPoint = this._helper.MakeLinkPointFromSnapPoint(idRangeEndExclusive++, snap);
|
||||
}
|
||||
if (PlayerInput.UsingGamepadUI)
|
||||
this._helper.MoveToVisuallyClosestPoint(idRangeStartInclusive, idRangeEndExclusive);
|
||||
if (!Main.CreativeMenu.GamepadMoveToSearchButtonHack)
|
||||
return;
|
||||
Main.CreativeMenu.GamepadMoveToSearchButtonHack = false;
|
||||
if (uiLinkPoint == null)
|
||||
return;
|
||||
UILinkPointNavigator.ChangePoint(uiLinkPoint.ID);
|
||||
}
|
||||
}
|
||||
}
|
516
GameContent/UI/States/UIResourcePackSelectionMenu.cs
Normal file
516
GameContent/UI/States/UIResourcePackSelectionMenu.cs
Normal file
|
@ -0,0 +1,516 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.States.UIResourcePackSelectionMenu
|
||||
// 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 Newtonsoft.Json.Linq;
|
||||
using ReLogic.Content;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Terraria.Audio;
|
||||
using Terraria.GameContent.UI.Elements;
|
||||
using Terraria.GameInput;
|
||||
using Terraria.ID;
|
||||
using Terraria.Initializers;
|
||||
using Terraria.IO;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI;
|
||||
using Terraria.UI.Gamepad;
|
||||
|
||||
namespace Terraria.GameContent.UI.States
|
||||
{
|
||||
public class UIResourcePackSelectionMenu : UIState
|
||||
{
|
||||
private readonly AssetSourceController _sourceController;
|
||||
private UIList _availablePacksList;
|
||||
private UIList _enabledPacksList;
|
||||
private ResourcePackList _packsList;
|
||||
private UIText _titleAvailable;
|
||||
private UIText _titleEnabled;
|
||||
private const string _snapCategory_ToggleFromOffToOn = "ToggleToOn";
|
||||
private const string _snapCategory_ToggleFromOnToOff = "ToggleToOff";
|
||||
private const string _snapCategory_InfoWhenOff = "InfoOff";
|
||||
private const string _snapCategory_InfoWhenOn = "InfoOn";
|
||||
private const string _snapCategory_OffsetOrderUp = "OrderUp";
|
||||
private const string _snapCategory_OffsetOrderDown = "OrderDown";
|
||||
private const string _snapPointName_goBack = "GoBack";
|
||||
private const string _snapPointName_openFolder = "OpenFolder";
|
||||
private UIGamepadHelper _helper;
|
||||
|
||||
public UIResourcePackSelectionMenu(
|
||||
AssetSourceController sourceController,
|
||||
ResourcePackList currentResourcePackList)
|
||||
{
|
||||
this._sourceController = sourceController;
|
||||
this.BuildPage();
|
||||
this._packsList = currentResourcePackList;
|
||||
this.PopulatePackList();
|
||||
}
|
||||
|
||||
private void PopulatePackList()
|
||||
{
|
||||
this._availablePacksList.Clear();
|
||||
this._enabledPacksList.Clear();
|
||||
this.CleanUpResourcePackPriority();
|
||||
IEnumerable<ResourcePack> enabledPacks = this._packsList.EnabledPacks;
|
||||
IEnumerable<ResourcePack> disabledPacks = this._packsList.DisabledPacks;
|
||||
int num1 = 0;
|
||||
foreach (ResourcePack resourcePack in disabledPacks)
|
||||
{
|
||||
UIResourcePack uiResourcePack1 = new UIResourcePack(resourcePack, num1);
|
||||
uiResourcePack1.Width = StyleDimension.FromPixelsAndPercent(0.0f, 1f);
|
||||
UIResourcePack uiResourcePack2 = uiResourcePack1;
|
||||
UIElement packToggleButton = this.CreatePackToggleButton(resourcePack);
|
||||
packToggleButton.OnUpdate += new UIElement.ElementEvent(this.EnablePackUpdate);
|
||||
packToggleButton.SetSnapPoint("ToggleToOn", num1);
|
||||
uiResourcePack2.ContentPanel.Append(packToggleButton);
|
||||
UIElement packInfoButton = this.CreatePackInfoButton(resourcePack);
|
||||
packInfoButton.OnUpdate += new UIElement.ElementEvent(this.SeeInfoUpdate);
|
||||
packInfoButton.SetSnapPoint("InfoOff", num1);
|
||||
uiResourcePack2.ContentPanel.Append(packInfoButton);
|
||||
this._availablePacksList.Add((UIElement) uiResourcePack2);
|
||||
++num1;
|
||||
}
|
||||
int num2 = 0;
|
||||
foreach (ResourcePack resourcePack in enabledPacks)
|
||||
{
|
||||
UIResourcePack uiResourcePack3 = new UIResourcePack(resourcePack, num2);
|
||||
uiResourcePack3.Width = StyleDimension.FromPixelsAndPercent(0.0f, 1f);
|
||||
UIResourcePack uiResourcePack4 = uiResourcePack3;
|
||||
if (resourcePack.IsEnabled)
|
||||
{
|
||||
UIElement packToggleButton = this.CreatePackToggleButton(resourcePack);
|
||||
packToggleButton.Left = new StyleDimension(0.0f, 0.0f);
|
||||
packToggleButton.Width = new StyleDimension(0.0f, 0.5f);
|
||||
packToggleButton.OnUpdate += new UIElement.ElementEvent(this.DisablePackUpdate);
|
||||
packToggleButton.SetSnapPoint("ToggleToOff", num2);
|
||||
uiResourcePack4.ContentPanel.Append(packToggleButton);
|
||||
UIElement packInfoButton = this.CreatePackInfoButton(resourcePack);
|
||||
packInfoButton.OnUpdate += new UIElement.ElementEvent(this.SeeInfoUpdate);
|
||||
packInfoButton.Left = new StyleDimension(0.0f, 0.5f);
|
||||
packInfoButton.Width = new StyleDimension(0.0f, 0.1666667f);
|
||||
packInfoButton.SetSnapPoint("InfoOn", num2);
|
||||
uiResourcePack4.ContentPanel.Append(packInfoButton);
|
||||
UIElement offsetButton1 = this.CreateOffsetButton(resourcePack, -1);
|
||||
offsetButton1.Left = new StyleDimension(0.0f, 0.6666667f);
|
||||
offsetButton1.Width = new StyleDimension(0.0f, 0.1666667f);
|
||||
offsetButton1.SetSnapPoint("OrderUp", num2);
|
||||
uiResourcePack4.ContentPanel.Append(offsetButton1);
|
||||
UIElement offsetButton2 = this.CreateOffsetButton(resourcePack, 1);
|
||||
offsetButton2.Left = new StyleDimension(0.0f, 0.8333334f);
|
||||
offsetButton2.Width = new StyleDimension(0.0f, 0.1666667f);
|
||||
offsetButton2.SetSnapPoint("OrderDown", num2);
|
||||
uiResourcePack4.ContentPanel.Append(offsetButton2);
|
||||
}
|
||||
this._enabledPacksList.Add((UIElement) uiResourcePack4);
|
||||
++num2;
|
||||
}
|
||||
this.UpdateTitles();
|
||||
}
|
||||
|
||||
private UIElement CreateOffsetButton(ResourcePack resourcePack, int offset)
|
||||
{
|
||||
GroupOptionButton<bool> groupOptionButton1 = new GroupOptionButton<bool>(true, (LocalizedText) null, (LocalizedText) null, Color.White, (string) null, 0.8f);
|
||||
groupOptionButton1.Left = StyleDimension.FromPercent(0.5f);
|
||||
groupOptionButton1.Width = StyleDimension.FromPixelsAndPercent(0.0f, 0.5f);
|
||||
groupOptionButton1.Height = StyleDimension.Fill;
|
||||
GroupOptionButton<bool> groupOptionButton2 = groupOptionButton1;
|
||||
int num = (offset != -1 ? 0 : (resourcePack.SortingOrder == 0 ? 1 : 0)) | (offset != 1 ? 0 : (resourcePack.SortingOrder == this._packsList.EnabledPacks.Count<ResourcePack>() - 1 ? 1 : 0));
|
||||
Color lightCyan = Color.LightCyan;
|
||||
groupOptionButton2.SetColorsBasedOnSelectionState(lightCyan, lightCyan, 0.7f, 0.7f);
|
||||
groupOptionButton2.ShowHighlightWhenSelected = false;
|
||||
groupOptionButton2.SetPadding(0.0f);
|
||||
Asset<Texture2D> asset = Main.Assets.Request<Texture2D>("Images/UI/TexturePackButtons", (AssetRequestMode) 1);
|
||||
UIImageFramed uiImageFramed1 = new UIImageFramed(asset, asset.Frame(2, 2, offset == 1 ? 1 : 0));
|
||||
uiImageFramed1.HAlign = 0.5f;
|
||||
uiImageFramed1.VAlign = 0.5f;
|
||||
uiImageFramed1.IgnoresMouseInteraction = true;
|
||||
UIImageFramed uiImageFramed2 = uiImageFramed1;
|
||||
groupOptionButton2.Append((UIElement) uiImageFramed2);
|
||||
groupOptionButton2.OnMouseOver += (UIElement.MouseEvent) ((evt, listeningElement) => SoundEngine.PlaySound(12));
|
||||
int offsetLocalForLambda = offset;
|
||||
if (num != 0)
|
||||
groupOptionButton2.OnClick += (UIElement.MouseEvent) ((evt, listeningElement) => SoundEngine.PlaySound(12));
|
||||
else
|
||||
groupOptionButton2.OnClick += (UIElement.MouseEvent) ((evt, listeningElement) =>
|
||||
{
|
||||
SoundEngine.PlaySound(12);
|
||||
this.OffsetResourcePackPriority(resourcePack, offsetLocalForLambda);
|
||||
this.PopulatePackList();
|
||||
Main.instance.TilePaintSystem.Reset();
|
||||
});
|
||||
if (offset == 1)
|
||||
groupOptionButton2.OnUpdate += new UIElement.ElementEvent(this.OffsetFrontwardUpdate);
|
||||
else
|
||||
groupOptionButton2.OnUpdate += new UIElement.ElementEvent(this.OffsetBackwardUpdate);
|
||||
return (UIElement) groupOptionButton2;
|
||||
}
|
||||
|
||||
private UIElement CreatePackToggleButton(ResourcePack resourcePack)
|
||||
{
|
||||
Language.GetText(resourcePack.IsEnabled ? "GameUI.Enabled" : "GameUI.Disabled");
|
||||
GroupOptionButton<bool> groupOptionButton = new GroupOptionButton<bool>(true, (LocalizedText) null, (LocalizedText) null, Color.White, (string) null, 0.8f);
|
||||
groupOptionButton.Left = StyleDimension.FromPercent(0.5f);
|
||||
groupOptionButton.Width = StyleDimension.FromPixelsAndPercent(0.0f, 0.5f);
|
||||
groupOptionButton.Height = StyleDimension.Fill;
|
||||
groupOptionButton.SetColorsBasedOnSelectionState(Color.LightGreen, Color.PaleVioletRed, 0.7f, 0.7f);
|
||||
groupOptionButton.SetCurrentOption(resourcePack.IsEnabled);
|
||||
groupOptionButton.ShowHighlightWhenSelected = false;
|
||||
groupOptionButton.SetPadding(0.0f);
|
||||
Asset<Texture2D> asset = Main.Assets.Request<Texture2D>("Images/UI/TexturePackButtons", (AssetRequestMode) 1);
|
||||
UIImageFramed uiImageFramed = new UIImageFramed(asset, asset.Frame(2, 2, resourcePack.IsEnabled ? 0 : 1, 1));
|
||||
uiImageFramed.HAlign = 0.5f;
|
||||
uiImageFramed.VAlign = 0.5f;
|
||||
uiImageFramed.IgnoresMouseInteraction = true;
|
||||
groupOptionButton.Append((UIElement) uiImageFramed);
|
||||
groupOptionButton.OnMouseOver += (UIElement.MouseEvent) ((evt, listeningElement) => SoundEngine.PlaySound(12));
|
||||
groupOptionButton.OnClick += (UIElement.MouseEvent) ((evt, listeningElement) =>
|
||||
{
|
||||
SoundEngine.PlaySound(12);
|
||||
resourcePack.IsEnabled = !resourcePack.IsEnabled;
|
||||
this.SetResourcePackAsTopPriority(resourcePack);
|
||||
this.PopulatePackList();
|
||||
Main.instance.TilePaintSystem.Reset();
|
||||
});
|
||||
return (UIElement) groupOptionButton;
|
||||
}
|
||||
|
||||
private void SetResourcePackAsTopPriority(ResourcePack resourcePack)
|
||||
{
|
||||
if (!resourcePack.IsEnabled)
|
||||
return;
|
||||
int num = -1;
|
||||
foreach (ResourcePack enabledPack in this._packsList.EnabledPacks)
|
||||
{
|
||||
if (num < enabledPack.SortingOrder && enabledPack != resourcePack)
|
||||
num = enabledPack.SortingOrder;
|
||||
}
|
||||
resourcePack.SortingOrder = num + 1;
|
||||
}
|
||||
|
||||
private void OffsetResourcePackPriority(ResourcePack resourcePack, int offset)
|
||||
{
|
||||
if (!resourcePack.IsEnabled)
|
||||
return;
|
||||
List<ResourcePack> list = this._packsList.EnabledPacks.ToList<ResourcePack>();
|
||||
int index1 = list.IndexOf(resourcePack);
|
||||
int index2 = Utils.Clamp<int>(index1 + offset, 0, list.Count - 1);
|
||||
if (index2 == index1)
|
||||
return;
|
||||
int sortingOrder = list[index1].SortingOrder;
|
||||
list[index1].SortingOrder = list[index2].SortingOrder;
|
||||
list[index2].SortingOrder = sortingOrder;
|
||||
}
|
||||
|
||||
private UIElement CreatePackInfoButton(ResourcePack resourcePack)
|
||||
{
|
||||
UIResourcePackInfoButton<string> resourcePackInfoButton = new UIResourcePackInfoButton<string>("", 0.8f);
|
||||
resourcePackInfoButton.Width = StyleDimension.FromPixelsAndPercent(0.0f, 0.5f);
|
||||
resourcePackInfoButton.Height = StyleDimension.Fill;
|
||||
resourcePackInfoButton.ResourcePack = resourcePack;
|
||||
resourcePackInfoButton.SetPadding(0.0f);
|
||||
UIImage uiImage = new UIImage(Main.Assets.Request<Texture2D>("Images/UI/CharCreation/CharInfo", (AssetRequestMode) 1));
|
||||
uiImage.HAlign = 0.5f;
|
||||
uiImage.VAlign = 0.5f;
|
||||
uiImage.IgnoresMouseInteraction = true;
|
||||
resourcePackInfoButton.Append((UIElement) uiImage);
|
||||
resourcePackInfoButton.OnMouseOver += (UIElement.MouseEvent) ((evt, listeningElement) => SoundEngine.PlaySound(12));
|
||||
resourcePackInfoButton.OnClick += new UIElement.MouseEvent(this.Click_Info);
|
||||
return (UIElement) resourcePackInfoButton;
|
||||
}
|
||||
|
||||
private void Click_Info(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
if (!(listeningElement is UIResourcePackInfoButton<string> resourcePackInfoButton))
|
||||
return;
|
||||
SoundEngine.PlaySound(10);
|
||||
Main.MenuUI.SetState((UIState) new UIResourcePackInfoMenu(this, resourcePackInfoButton.ResourcePack));
|
||||
}
|
||||
|
||||
private void ApplyListChanges() => this._sourceController.UseResourcePacks(new ResourcePackList(this._enabledPacksList.Select<UIElement, ResourcePack>((Func<UIElement, ResourcePack>) (uiPack => ((UIResourcePack) uiPack).ResourcePack))));
|
||||
|
||||
private void CleanUpResourcePackPriority()
|
||||
{
|
||||
IOrderedEnumerable<ResourcePack> orderedEnumerable = this._packsList.EnabledPacks.OrderBy<ResourcePack, int>((Func<ResourcePack, int>) (pack => pack.SortingOrder));
|
||||
int num = 0;
|
||||
foreach (ResourcePack resourcePack in (IEnumerable<ResourcePack>) orderedEnumerable)
|
||||
resourcePack.SortingOrder = num++;
|
||||
}
|
||||
|
||||
private void BuildPage()
|
||||
{
|
||||
this.RemoveAllChildren();
|
||||
UIElement uiElement = new UIElement();
|
||||
uiElement.Width.Set(0.0f, 0.8f);
|
||||
uiElement.MaxWidth.Set(800f, 0.0f);
|
||||
uiElement.MinWidth.Set(600f, 0.0f);
|
||||
uiElement.Top.Set(240f, 0.0f);
|
||||
uiElement.Height.Set(-240f, 1f);
|
||||
uiElement.HAlign = 0.5f;
|
||||
this.Append(uiElement);
|
||||
UIPanel uiPanel1 = new UIPanel();
|
||||
uiPanel1.Width = StyleDimension.Fill;
|
||||
uiPanel1.Height = new StyleDimension(-110f, 1f);
|
||||
uiPanel1.BackgroundColor = new Color(33, 43, 79) * 0.8f;
|
||||
uiPanel1.PaddingRight = 0.0f;
|
||||
uiPanel1.PaddingLeft = 0.0f;
|
||||
UIPanel uiPanel2 = uiPanel1;
|
||||
uiElement.Append((UIElement) uiPanel2);
|
||||
int num1 = 35;
|
||||
int num2 = num1;
|
||||
int num3 = 30;
|
||||
UIElement element1 = new UIElement()
|
||||
{
|
||||
Width = StyleDimension.Fill,
|
||||
Height = StyleDimension.FromPixelsAndPercent((float) -(num3 + 4 + 5), 1f),
|
||||
VAlign = 1f
|
||||
};
|
||||
element1.SetPadding(0.0f);
|
||||
uiPanel2.Append(element1);
|
||||
UIElement element2 = new UIElement()
|
||||
{
|
||||
Width = new StyleDimension(-20f, 0.5f),
|
||||
Height = new StyleDimension(0.0f, 1f),
|
||||
Left = new StyleDimension(10f, 0.0f)
|
||||
};
|
||||
element2.SetPadding(0.0f);
|
||||
element1.Append(element2);
|
||||
UIElement element3 = new UIElement()
|
||||
{
|
||||
Width = new StyleDimension(-20f, 0.5f),
|
||||
Height = new StyleDimension(0.0f, 1f),
|
||||
Left = new StyleDimension(-10f, 0.0f),
|
||||
HAlign = 1f
|
||||
};
|
||||
element3.SetPadding(0.0f);
|
||||
element1.Append(element3);
|
||||
UIList uiList1 = new UIList();
|
||||
uiList1.Width = new StyleDimension(-25f, 1f);
|
||||
uiList1.Height = new StyleDimension(0.0f, 1f);
|
||||
uiList1.ListPadding = 5f;
|
||||
uiList1.HAlign = 1f;
|
||||
UIList uiList2 = uiList1;
|
||||
element2.Append((UIElement) uiList2);
|
||||
this._availablePacksList = uiList2;
|
||||
UIList uiList3 = new UIList();
|
||||
uiList3.Width = new StyleDimension(-25f, 1f);
|
||||
uiList3.Height = new StyleDimension(0.0f, 1f);
|
||||
uiList3.ListPadding = 5f;
|
||||
uiList3.HAlign = 0.0f;
|
||||
uiList3.Left = new StyleDimension(0.0f, 0.0f);
|
||||
UIList uiList4 = uiList3;
|
||||
element3.Append((UIElement) uiList4);
|
||||
this._enabledPacksList = uiList4;
|
||||
UIText uiText1 = new UIText(Language.GetText("UI.AvailableResourcePacksTitle"));
|
||||
uiText1.HAlign = 0.0f;
|
||||
uiText1.Left = new StyleDimension(25f, 0.0f);
|
||||
uiText1.Width = new StyleDimension(-25f, 0.5f);
|
||||
uiText1.VAlign = 0.0f;
|
||||
uiText1.Top = new StyleDimension(10f, 0.0f);
|
||||
UIText uiText2 = uiText1;
|
||||
this._titleAvailable = uiText2;
|
||||
uiPanel2.Append((UIElement) uiText2);
|
||||
UIText uiText3 = new UIText(Language.GetText("UI.EnabledResourcePacksTitle"));
|
||||
uiText3.HAlign = 1f;
|
||||
uiText3.Left = new StyleDimension(-25f, 0.0f);
|
||||
uiText3.Width = new StyleDimension(-25f, 0.5f);
|
||||
uiText3.VAlign = 0.0f;
|
||||
uiText3.Top = new StyleDimension(10f, 0.0f);
|
||||
UIText uiText4 = uiText3;
|
||||
this._titleEnabled = uiText4;
|
||||
uiPanel2.Append((UIElement) uiText4);
|
||||
UITextPanel<LocalizedText> uiTextPanel1 = new UITextPanel<LocalizedText>(Language.GetText("UI.ResourcePacks"), large: true);
|
||||
uiTextPanel1.HAlign = 0.5f;
|
||||
uiTextPanel1.VAlign = 0.0f;
|
||||
uiTextPanel1.Top = new StyleDimension(-44f, 0.0f);
|
||||
uiTextPanel1.BackgroundColor = new Color(73, 94, 171);
|
||||
UITextPanel<LocalizedText> uiTextPanel2 = uiTextPanel1;
|
||||
uiTextPanel2.SetPadding(13f);
|
||||
uiElement.Append((UIElement) uiTextPanel2);
|
||||
UIScrollbar uiScrollbar1 = new UIScrollbar();
|
||||
uiScrollbar1.Height = new StyleDimension(0.0f, 1f);
|
||||
uiScrollbar1.HAlign = 0.0f;
|
||||
uiScrollbar1.Left = new StyleDimension(0.0f, 0.0f);
|
||||
UIScrollbar scrollbar1 = uiScrollbar1;
|
||||
element2.Append((UIElement) scrollbar1);
|
||||
this._availablePacksList.SetScrollbar(scrollbar1);
|
||||
UIVerticalSeparator verticalSeparator1 = new UIVerticalSeparator();
|
||||
verticalSeparator1.Height = new StyleDimension(-12f, 1f);
|
||||
verticalSeparator1.HAlign = 0.5f;
|
||||
verticalSeparator1.VAlign = 1f;
|
||||
verticalSeparator1.Color = new Color(89, 116, 213, (int) byte.MaxValue) * 0.9f;
|
||||
UIVerticalSeparator verticalSeparator2 = verticalSeparator1;
|
||||
uiPanel2.Append((UIElement) verticalSeparator2);
|
||||
UIHorizontalSeparator horizontalSeparator1 = new UIHorizontalSeparator();
|
||||
horizontalSeparator1.Width = new StyleDimension((float) -num2, 0.5f);
|
||||
horizontalSeparator1.VAlign = 0.0f;
|
||||
horizontalSeparator1.HAlign = 0.0f;
|
||||
horizontalSeparator1.Color = new Color(89, 116, 213, (int) byte.MaxValue) * 0.9f;
|
||||
horizontalSeparator1.Top = new StyleDimension((float) num3, 0.0f);
|
||||
horizontalSeparator1.Left = new StyleDimension((float) num1, 0.0f);
|
||||
UIHorizontalSeparator horizontalSeparator2 = new UIHorizontalSeparator();
|
||||
horizontalSeparator2.Width = new StyleDimension((float) -num2, 0.5f);
|
||||
horizontalSeparator2.VAlign = 0.0f;
|
||||
horizontalSeparator2.HAlign = 1f;
|
||||
horizontalSeparator2.Color = new Color(89, 116, 213, (int) byte.MaxValue) * 0.9f;
|
||||
horizontalSeparator2.Top = new StyleDimension((float) num3, 0.0f);
|
||||
horizontalSeparator2.Left = new StyleDimension((float) -num1, 0.0f);
|
||||
UIScrollbar uiScrollbar2 = new UIScrollbar();
|
||||
uiScrollbar2.Height = new StyleDimension(0.0f, 1f);
|
||||
uiScrollbar2.HAlign = 1f;
|
||||
UIScrollbar scrollbar2 = uiScrollbar2;
|
||||
element3.Append((UIElement) scrollbar2);
|
||||
this._enabledPacksList.SetScrollbar(scrollbar2);
|
||||
this.AddBackAndFolderButtons(uiElement);
|
||||
}
|
||||
|
||||
private void UpdateTitles()
|
||||
{
|
||||
this._titleAvailable.SetText(Language.GetText("UI.AvailableResourcePacksTitle").FormatWith((object) new
|
||||
{
|
||||
Amount = this._availablePacksList.Count
|
||||
}));
|
||||
this._titleEnabled.SetText(Language.GetText("UI.EnabledResourcePacksTitle").FormatWith((object) new
|
||||
{
|
||||
Amount = this._enabledPacksList.Count
|
||||
}));
|
||||
}
|
||||
|
||||
private void AddBackAndFolderButtons(UIElement outerContainer)
|
||||
{
|
||||
UITextPanel<LocalizedText> uiTextPanel1 = new UITextPanel<LocalizedText>(Language.GetText("UI.Back"), 0.7f, true);
|
||||
uiTextPanel1.Width = new StyleDimension(-8f, 0.5f);
|
||||
uiTextPanel1.Height = new StyleDimension(50f, 0.0f);
|
||||
uiTextPanel1.VAlign = 1f;
|
||||
uiTextPanel1.HAlign = 0.0f;
|
||||
uiTextPanel1.Top = new StyleDimension(-45f, 0.0f);
|
||||
UITextPanel<LocalizedText> uiTextPanel2 = uiTextPanel1;
|
||||
uiTextPanel2.OnMouseOver += new UIElement.MouseEvent(UIResourcePackSelectionMenu.FadedMouseOver);
|
||||
uiTextPanel2.OnMouseOut += new UIElement.MouseEvent(UIResourcePackSelectionMenu.FadedMouseOut);
|
||||
uiTextPanel2.OnClick += new UIElement.MouseEvent(this.GoBackClick);
|
||||
uiTextPanel2.SetSnapPoint("GoBack", 0);
|
||||
outerContainer.Append((UIElement) uiTextPanel2);
|
||||
UITextPanel<LocalizedText> uiTextPanel3 = new UITextPanel<LocalizedText>(Language.GetText("GameUI.OpenFileFolder"), 0.7f, true);
|
||||
uiTextPanel3.Width = new StyleDimension(-8f, 0.5f);
|
||||
uiTextPanel3.Height = new StyleDimension(50f, 0.0f);
|
||||
uiTextPanel3.VAlign = 1f;
|
||||
uiTextPanel3.HAlign = 1f;
|
||||
uiTextPanel3.Top = new StyleDimension(-45f, 0.0f);
|
||||
UITextPanel<LocalizedText> uiTextPanel4 = uiTextPanel3;
|
||||
uiTextPanel4.OnMouseOver += new UIElement.MouseEvent(UIResourcePackSelectionMenu.FadedMouseOver);
|
||||
uiTextPanel4.OnMouseOut += new UIElement.MouseEvent(UIResourcePackSelectionMenu.FadedMouseOut);
|
||||
uiTextPanel4.OnClick += new UIElement.MouseEvent(this.OpenFoldersClick);
|
||||
uiTextPanel4.SetSnapPoint("OpenFolder", 0);
|
||||
outerContainer.Append((UIElement) uiTextPanel4);
|
||||
}
|
||||
|
||||
private void OpenFoldersClick(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
string resourcePackFolder;
|
||||
AssetInitializer.GetResourcePacksFolderPathAndConfirmItExists(out JArray _, out resourcePackFolder);
|
||||
SoundEngine.PlaySound(12);
|
||||
Utils.OpenFolder(resourcePackFolder);
|
||||
}
|
||||
|
||||
private void GoBackClick(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
this.ApplyListChanges();
|
||||
Main.SaveSettings();
|
||||
Main.menuMode = 0;
|
||||
IngameFancyUI.Close();
|
||||
}
|
||||
|
||||
private static 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 static 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 OffsetBackwardUpdate(UIElement affectedElement) => UIResourcePackSelectionMenu.DisplayMouseTextIfHovered(affectedElement, "UI.OffsetTexturePackPriorityDown");
|
||||
|
||||
private void OffsetFrontwardUpdate(UIElement affectedElement) => UIResourcePackSelectionMenu.DisplayMouseTextIfHovered(affectedElement, "UI.OffsetTexturePackPriorityUp");
|
||||
|
||||
private void EnablePackUpdate(UIElement affectedElement) => UIResourcePackSelectionMenu.DisplayMouseTextIfHovered(affectedElement, "UI.EnableTexturePack");
|
||||
|
||||
private void DisablePackUpdate(UIElement affectedElement) => UIResourcePackSelectionMenu.DisplayMouseTextIfHovered(affectedElement, "UI.DisableTexturePack");
|
||||
|
||||
private void SeeInfoUpdate(UIElement affectedElement) => UIResourcePackSelectionMenu.DisplayMouseTextIfHovered(affectedElement, "UI.SeeTexturePackInfo");
|
||||
|
||||
private static void DisplayMouseTextIfHovered(UIElement affectedElement, string textKey)
|
||||
{
|
||||
if (!affectedElement.IsMouseHovering)
|
||||
return;
|
||||
string textValue = Language.GetTextValue(textKey);
|
||||
Main.instance.MouseText(textValue);
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
base.Draw(spriteBatch);
|
||||
this.SetupGamepadPoints(spriteBatch);
|
||||
}
|
||||
|
||||
private void SetupGamepadPoints(SpriteBatch spriteBatch)
|
||||
{
|
||||
UILinkPointNavigator.Shortcuts.BackButtonCommand = 1;
|
||||
int idRangeStartInclusive = 3000;
|
||||
int currentID = idRangeStartInclusive;
|
||||
List<SnapPoint> snapPoints1 = this.GetSnapPoints();
|
||||
List<SnapPoint> snapPoints2 = this._availablePacksList.GetSnapPoints();
|
||||
this._helper.CullPointsOutOfElementArea(spriteBatch, snapPoints2, (UIElement) this._availablePacksList);
|
||||
List<SnapPoint> snapPoints3 = this._enabledPacksList.GetSnapPoints();
|
||||
this._helper.CullPointsOutOfElementArea(spriteBatch, snapPoints3, (UIElement) this._enabledPacksList);
|
||||
UILinkPoint[] fromCategoryName1 = this._helper.GetVerticalStripFromCategoryName(ref currentID, snapPoints2, "ToggleToOn");
|
||||
UILinkPoint[] fromCategoryName2 = this._helper.GetVerticalStripFromCategoryName(ref currentID, snapPoints2, "InfoOff");
|
||||
UILinkPoint[] fromCategoryName3 = this._helper.GetVerticalStripFromCategoryName(ref currentID, snapPoints3, "ToggleToOff");
|
||||
UILinkPoint[] fromCategoryName4 = this._helper.GetVerticalStripFromCategoryName(ref currentID, snapPoints3, "InfoOn");
|
||||
UILinkPoint[] fromCategoryName5 = this._helper.GetVerticalStripFromCategoryName(ref currentID, snapPoints3, "OrderUp");
|
||||
UILinkPoint[] fromCategoryName6 = this._helper.GetVerticalStripFromCategoryName(ref currentID, snapPoints3, "OrderDown");
|
||||
UILinkPoint uiLinkPoint1 = (UILinkPoint) null;
|
||||
UILinkPoint uiLinkPoint2 = (UILinkPoint) null;
|
||||
for (int index = 0; index < snapPoints1.Count; ++index)
|
||||
{
|
||||
SnapPoint snap = snapPoints1[index];
|
||||
string name = snap.Name;
|
||||
if (!(name == "GoBack"))
|
||||
{
|
||||
if (name == "OpenFolder")
|
||||
uiLinkPoint2 = this._helper.MakeLinkPointFromSnapPoint(currentID++, snap);
|
||||
}
|
||||
else
|
||||
uiLinkPoint1 = this._helper.MakeLinkPointFromSnapPoint(currentID++, snap);
|
||||
}
|
||||
this._helper.LinkVerticalStrips(fromCategoryName2, fromCategoryName1, 0);
|
||||
this._helper.LinkVerticalStrips(fromCategoryName1, fromCategoryName3, 0);
|
||||
this._helper.LinkVerticalStrips(fromCategoryName3, fromCategoryName4, 0);
|
||||
this._helper.LinkVerticalStrips(fromCategoryName4, fromCategoryName5, 0);
|
||||
this._helper.LinkVerticalStrips(fromCategoryName5, fromCategoryName6, 0);
|
||||
this._helper.LinkVerticalStripBottomSideToSingle(fromCategoryName1, uiLinkPoint1);
|
||||
this._helper.LinkVerticalStripBottomSideToSingle(fromCategoryName2, uiLinkPoint1);
|
||||
this._helper.LinkVerticalStripBottomSideToSingle(fromCategoryName5, uiLinkPoint2);
|
||||
this._helper.LinkVerticalStripBottomSideToSingle(fromCategoryName6, uiLinkPoint2);
|
||||
this._helper.LinkVerticalStripBottomSideToSingle(fromCategoryName3, uiLinkPoint2);
|
||||
this._helper.LinkVerticalStripBottomSideToSingle(fromCategoryName4, uiLinkPoint2);
|
||||
this._helper.PairLeftRight(uiLinkPoint1, uiLinkPoint2);
|
||||
if (PlayerInput.UsingGamepadUI)
|
||||
this._helper.MoveToVisuallyClosestPoint(idRangeStartInclusive, currentID);
|
||||
if (!Main.CreativeMenu.GamepadMoveToSearchButtonHack)
|
||||
return;
|
||||
Main.CreativeMenu.GamepadMoveToSearchButtonHack = false;
|
||||
if (uiLinkPoint1 == null)
|
||||
return;
|
||||
UILinkPointNavigator.ChangePoint(uiLinkPoint1.ID);
|
||||
}
|
||||
}
|
||||
}
|
19
GameContent/UI/States/UISortableElement.cs
Normal file
19
GameContent/UI/States/UISortableElement.cs
Normal file
|
@ -0,0 +1,19 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.States.UISortableElement
|
||||
// Assembly: Terraria, Version=1.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.States
|
||||
{
|
||||
public class UISortableElement : UIElement
|
||||
{
|
||||
public int OrderIndex;
|
||||
|
||||
public UISortableElement(int index) => this.OrderIndex = index;
|
||||
|
||||
public override int CompareTo(object obj) => obj is UISortableElement uiSortableElement ? this.OrderIndex.CompareTo(uiSortableElement.OrderIndex) : base.CompareTo(obj);
|
||||
}
|
||||
}
|
808
GameContent/UI/States/UIVirtualKeyboard.cs
Normal file
808
GameContent/UI/States/UIVirtualKeyboard.cs
Normal file
|
@ -0,0 +1,808 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.States.UIVirtualKeyboard
|
||||
// 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.GameContent.UI.Elements;
|
||||
using Terraria.GameInput;
|
||||
using Terraria.ID;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI;
|
||||
using Terraria.UI.Gamepad;
|
||||
|
||||
namespace Terraria.GameContent.UI.States
|
||||
{
|
||||
public class UIVirtualKeyboard : UIState
|
||||
{
|
||||
private static UIVirtualKeyboard _currentInstance;
|
||||
private static string _cancelCacheSign = "";
|
||||
private static string _cancelCacheChest = "";
|
||||
private const string DEFAULT_KEYS = "1234567890qwertyuiopasdfghjkl'zxcvbnm,.?";
|
||||
private const string SHIFT_KEYS = "1234567890QWERTYUIOPASDFGHJKL'ZXCVBNM,.?";
|
||||
private const string SYMBOL_KEYS = "1234567890!@#$%^&*()-_+=/\\{}[]<>;:\"`|~£¥";
|
||||
private const float KEY_SPACING = 4f;
|
||||
private const float KEY_WIDTH = 48f;
|
||||
private const float KEY_HEIGHT = 37f;
|
||||
private UITextPanel<object>[] _keyList = new UITextPanel<object>[50];
|
||||
private UITextPanel<object> _shiftButton;
|
||||
private UITextPanel<object> _symbolButton;
|
||||
private UITextBox _textBox;
|
||||
private UITextPanel<LocalizedText> _submitButton;
|
||||
private UITextPanel<LocalizedText> _cancelButton;
|
||||
private UIText _label;
|
||||
private UITextPanel<object> _enterButton;
|
||||
private UITextPanel<object> _spacebarButton;
|
||||
private UITextPanel<object> _restoreButton;
|
||||
private Asset<Texture2D> _textureShift;
|
||||
private Asset<Texture2D> _textureBackspace;
|
||||
private Color _internalBorderColor = new Color(89, 116, 213);
|
||||
private Color _internalBorderColorSelected = Main.OurFavoriteColor;
|
||||
private UITextPanel<LocalizedText> _submitButton2;
|
||||
private UITextPanel<LocalizedText> _cancelButton2;
|
||||
private UIElement outerLayer1;
|
||||
private UIElement outerLayer2;
|
||||
private bool _allowEmpty;
|
||||
private UIVirtualKeyboard.KeyState _keyState;
|
||||
private UIVirtualKeyboard.KeyboardSubmitEvent _submitAction;
|
||||
private Action _cancelAction;
|
||||
private int _lastOffsetDown;
|
||||
public static int OffsetDown;
|
||||
public static bool ShouldHideText;
|
||||
private int _keyboardContext;
|
||||
private bool _edittingSign;
|
||||
private bool _edittingChest;
|
||||
private float _textBoxHeight;
|
||||
private float _labelHeight;
|
||||
private bool _canSubmit;
|
||||
|
||||
public string Text
|
||||
{
|
||||
get => this._textBox.Text;
|
||||
set
|
||||
{
|
||||
this._textBox.SetText(value);
|
||||
this.ValidateText();
|
||||
}
|
||||
}
|
||||
|
||||
public UIVirtualKeyboard(
|
||||
string labelText,
|
||||
string startingText,
|
||||
UIVirtualKeyboard.KeyboardSubmitEvent submitAction,
|
||||
Action cancelAction,
|
||||
int inputMode = 0,
|
||||
bool allowEmpty = false)
|
||||
{
|
||||
this._keyboardContext = inputMode;
|
||||
this._allowEmpty = allowEmpty;
|
||||
UIVirtualKeyboard.OffsetDown = 0;
|
||||
UIVirtualKeyboard.ShouldHideText = false;
|
||||
this._lastOffsetDown = 0;
|
||||
this._edittingSign = this._keyboardContext == 1;
|
||||
this._edittingChest = this._keyboardContext == 2;
|
||||
UIVirtualKeyboard._currentInstance = this;
|
||||
this._submitAction = submitAction;
|
||||
this._cancelAction = cancelAction;
|
||||
this._textureShift = Main.Assets.Request<Texture2D>("Images/UI/VK_Shift", (AssetRequestMode) 1);
|
||||
this._textureBackspace = Main.Assets.Request<Texture2D>("Images/UI/VK_Backspace", (AssetRequestMode) 1);
|
||||
this.Top.Pixels = (float) this._lastOffsetDown;
|
||||
float num1 = (float) (-5000 * this._edittingSign.ToInt());
|
||||
float num2 = 270f;
|
||||
float num3 = 0.0f;
|
||||
float num4 = 516f;
|
||||
UIElement element = new UIElement();
|
||||
element.Width.Pixels = (float) ((double) num4 + 8.0 + 16.0);
|
||||
element.Top.Precent = num3;
|
||||
element.Top.Pixels = num2;
|
||||
element.Height.Pixels = 266f;
|
||||
element.HAlign = 0.5f;
|
||||
element.SetPadding(0.0f);
|
||||
this.outerLayer1 = element;
|
||||
UIElement uiElement = new UIElement();
|
||||
uiElement.Width.Pixels = (float) ((double) num4 + 8.0 + 16.0);
|
||||
uiElement.Top.Precent = num3;
|
||||
uiElement.Top.Pixels = num2;
|
||||
uiElement.Height.Pixels = 266f;
|
||||
uiElement.HAlign = 0.5f;
|
||||
uiElement.SetPadding(0.0f);
|
||||
this.outerLayer2 = uiElement;
|
||||
UIPanel mainPanel = new UIPanel();
|
||||
mainPanel.Width.Precent = 1f;
|
||||
mainPanel.Height.Pixels = 225f;
|
||||
mainPanel.BackgroundColor = new Color(23, 33, 69) * 0.7f;
|
||||
element.Append((UIElement) mainPanel);
|
||||
float num5 = -50f;
|
||||
this._textBox = new UITextBox("", 0.78f, true);
|
||||
this._textBox.BackgroundColor = Color.Transparent;
|
||||
this._textBox.BorderColor = Color.Transparent;
|
||||
this._textBox.HAlign = 0.5f;
|
||||
this._textBox.Width.Pixels = num4;
|
||||
this._textBox.Top.Pixels = (float) ((double) num5 + (double) num2 - 10.0) + num1;
|
||||
this._textBox.Top.Precent = num3;
|
||||
this._textBox.Height.Pixels = 37f;
|
||||
this.Append((UIElement) this._textBox);
|
||||
for (int x = 0; x < 10; ++x)
|
||||
{
|
||||
for (int y = 0; y < 4; ++y)
|
||||
{
|
||||
UITextPanel<object> keyboardButton = this.CreateKeyboardButton((object) "1234567890qwertyuiopasdfghjkl'zxcvbnm,.?"[y * 10 + x].ToString(), x, y);
|
||||
keyboardButton.OnClick += new UIElement.MouseEvent(this.TypeText);
|
||||
mainPanel.Append((UIElement) keyboardButton);
|
||||
}
|
||||
}
|
||||
this._shiftButton = this.CreateKeyboardButton((object) "", 0, 4, style: false);
|
||||
this._shiftButton.PaddingLeft = 0.0f;
|
||||
this._shiftButton.PaddingRight = 0.0f;
|
||||
this._shiftButton.PaddingBottom = this._shiftButton.PaddingTop = 0.0f;
|
||||
this._shiftButton.BackgroundColor = new Color(63, 82, 151) * 0.7f;
|
||||
this._shiftButton.BorderColor = this._internalBorderColor * 0.7f;
|
||||
this._shiftButton.OnMouseOver += (UIElement.MouseEvent) ((evt, listeningElement) =>
|
||||
{
|
||||
this._shiftButton.BorderColor = this._internalBorderColorSelected;
|
||||
if (this._keyState == UIVirtualKeyboard.KeyState.Shift)
|
||||
return;
|
||||
this._shiftButton.BackgroundColor = new Color(73, 94, 171);
|
||||
});
|
||||
this._shiftButton.OnMouseOut += (UIElement.MouseEvent) ((evt, listeningElement) =>
|
||||
{
|
||||
this._shiftButton.BorderColor = this._internalBorderColor * 0.7f;
|
||||
if (this._keyState == UIVirtualKeyboard.KeyState.Shift)
|
||||
return;
|
||||
this._shiftButton.BackgroundColor = new Color(63, 82, 151) * 0.7f;
|
||||
});
|
||||
this._shiftButton.OnClick += (UIElement.MouseEvent) ((evt, listeningElement) =>
|
||||
{
|
||||
SoundEngine.PlaySound(12);
|
||||
this.SetKeyState(this._keyState == UIVirtualKeyboard.KeyState.Shift ? UIVirtualKeyboard.KeyState.Default : UIVirtualKeyboard.KeyState.Shift);
|
||||
});
|
||||
UIImage uiImage1 = new UIImage(this._textureShift);
|
||||
uiImage1.HAlign = 0.5f;
|
||||
uiImage1.VAlign = 0.5f;
|
||||
uiImage1.ImageScale = 0.85f;
|
||||
this._shiftButton.Append((UIElement) uiImage1);
|
||||
mainPanel.Append((UIElement) this._shiftButton);
|
||||
this._symbolButton = this.CreateKeyboardButton((object) "@%", 1, 4, style: false);
|
||||
this._symbolButton.PaddingLeft = 0.0f;
|
||||
this._symbolButton.PaddingRight = 0.0f;
|
||||
this._symbolButton.BackgroundColor = new Color(63, 82, 151) * 0.7f;
|
||||
this._symbolButton.BorderColor = this._internalBorderColor * 0.7f;
|
||||
this._symbolButton.OnMouseOver += (UIElement.MouseEvent) ((evt, listeningElement) =>
|
||||
{
|
||||
this._symbolButton.BorderColor = this._internalBorderColorSelected;
|
||||
if (this._keyState == UIVirtualKeyboard.KeyState.Symbol)
|
||||
return;
|
||||
this._symbolButton.BackgroundColor = new Color(73, 94, 171);
|
||||
});
|
||||
this._symbolButton.OnMouseOut += (UIElement.MouseEvent) ((evt, listeningElement) =>
|
||||
{
|
||||
this._symbolButton.BorderColor = this._internalBorderColor * 0.7f;
|
||||
if (this._keyState == UIVirtualKeyboard.KeyState.Symbol)
|
||||
return;
|
||||
this._symbolButton.BackgroundColor = new Color(63, 82, 151) * 0.7f;
|
||||
});
|
||||
this._symbolButton.OnClick += (UIElement.MouseEvent) ((evt, listeningElement) =>
|
||||
{
|
||||
SoundEngine.PlaySound(12);
|
||||
this.SetKeyState(this._keyState == UIVirtualKeyboard.KeyState.Symbol ? UIVirtualKeyboard.KeyState.Default : UIVirtualKeyboard.KeyState.Symbol);
|
||||
});
|
||||
mainPanel.Append((UIElement) this._symbolButton);
|
||||
this.BuildSpaceBarArea(mainPanel);
|
||||
this._submitButton = new UITextPanel<LocalizedText>(this._edittingSign || this._edittingChest ? Language.GetText("UI.Save") : Language.GetText("UI.Submit"), 0.4f, true);
|
||||
this._submitButton.Height.Pixels = 37f;
|
||||
this._submitButton.Width.Precent = 0.4f;
|
||||
this._submitButton.HAlign = 1f;
|
||||
this._submitButton.VAlign = 1f;
|
||||
this._submitButton.PaddingLeft = 0.0f;
|
||||
this._submitButton.PaddingRight = 0.0f;
|
||||
this.ValidateText();
|
||||
this._submitButton.OnMouseOver += new UIElement.MouseEvent(this.FadedMouseOver);
|
||||
this._submitButton.OnMouseOut += new UIElement.MouseEvent(this.FadedMouseOut);
|
||||
this._submitButton.OnMouseOver += (UIElement.MouseEvent) ((evt, listeningElement) => this.ValidateText());
|
||||
this._submitButton.OnMouseOut += (UIElement.MouseEvent) ((evt, listeningElement) => this.ValidateText());
|
||||
this._submitButton.OnClick += (UIElement.MouseEvent) ((evt, listeningElement) => UIVirtualKeyboard.Submit());
|
||||
element.Append((UIElement) this._submitButton);
|
||||
this._cancelButton = new UITextPanel<LocalizedText>(Language.GetText("UI.Cancel"), 0.4f, true);
|
||||
this.StyleKey<LocalizedText>(this._cancelButton, true);
|
||||
this._cancelButton.Height.Pixels = 37f;
|
||||
this._cancelButton.Width.Precent = 0.4f;
|
||||
this._cancelButton.VAlign = 1f;
|
||||
this._cancelButton.OnClick += (UIElement.MouseEvent) ((evt, listeningElement) =>
|
||||
{
|
||||
SoundEngine.PlaySound(11);
|
||||
this._cancelAction();
|
||||
});
|
||||
this._cancelButton.OnMouseOver += new UIElement.MouseEvent(this.FadedMouseOver);
|
||||
this._cancelButton.OnMouseOut += new UIElement.MouseEvent(this.FadedMouseOut);
|
||||
element.Append((UIElement) this._cancelButton);
|
||||
this._submitButton2 = new UITextPanel<LocalizedText>(this._edittingSign || this._edittingChest ? Language.GetText("UI.Save") : Language.GetText("UI.Submit"), 0.72f, true);
|
||||
this._submitButton2.TextColor = Color.Silver;
|
||||
this._submitButton2.DrawPanel = false;
|
||||
this._submitButton2.Height.Pixels = 60f;
|
||||
this._submitButton2.Width.Precent = 0.4f;
|
||||
this._submitButton2.HAlign = 0.5f;
|
||||
this._submitButton2.VAlign = 0.0f;
|
||||
this._submitButton2.OnMouseOver += (UIElement.MouseEvent) ((a, b) =>
|
||||
{
|
||||
((UITextPanel<LocalizedText>) b).TextScale = 0.85f;
|
||||
((UITextPanel<LocalizedText>) b).TextColor = Color.White;
|
||||
});
|
||||
this._submitButton2.OnMouseOut += (UIElement.MouseEvent) ((a, b) =>
|
||||
{
|
||||
((UITextPanel<LocalizedText>) b).TextScale = 0.72f;
|
||||
((UITextPanel<LocalizedText>) b).TextColor = Color.Silver;
|
||||
});
|
||||
this._submitButton2.Top.Pixels = 50f;
|
||||
this._submitButton2.PaddingLeft = 0.0f;
|
||||
this._submitButton2.PaddingRight = 0.0f;
|
||||
this.ValidateText();
|
||||
this._submitButton2.OnMouseOver += (UIElement.MouseEvent) ((evt, listeningElement) => this.ValidateText());
|
||||
this._submitButton2.OnMouseOut += (UIElement.MouseEvent) ((evt, listeningElement) => this.ValidateText());
|
||||
this._submitButton2.OnMouseOver += new UIElement.MouseEvent(this.FadedMouseOver);
|
||||
this._submitButton2.OnMouseOut += new UIElement.MouseEvent(this.FadedMouseOut);
|
||||
this._submitButton2.OnClick += (UIElement.MouseEvent) ((evt, listeningElement) =>
|
||||
{
|
||||
string text = this.Text.Trim();
|
||||
if (text.Length <= 0 && !this._edittingSign && !this._edittingChest && !this._allowEmpty)
|
||||
return;
|
||||
SoundEngine.PlaySound(10);
|
||||
this._submitAction(text);
|
||||
});
|
||||
this.outerLayer2.Append((UIElement) this._submitButton2);
|
||||
this._cancelButton2 = new UITextPanel<LocalizedText>(Language.GetText("UI.Cancel"), 0.72f, true);
|
||||
this._cancelButton2.TextColor = Color.Silver;
|
||||
this._cancelButton2.DrawPanel = false;
|
||||
this._cancelButton2.OnMouseOver += (UIElement.MouseEvent) ((a, b) =>
|
||||
{
|
||||
((UITextPanel<LocalizedText>) b).TextScale = 0.85f;
|
||||
((UITextPanel<LocalizedText>) b).TextColor = Color.White;
|
||||
});
|
||||
this._cancelButton2.OnMouseOut += (UIElement.MouseEvent) ((a, b) =>
|
||||
{
|
||||
((UITextPanel<LocalizedText>) b).TextScale = 0.72f;
|
||||
((UITextPanel<LocalizedText>) b).TextColor = Color.Silver;
|
||||
});
|
||||
this._cancelButton2.Height.Pixels = 60f;
|
||||
this._cancelButton2.Width.Precent = 0.4f;
|
||||
this._cancelButton2.Top.Pixels = 114f;
|
||||
this._cancelButton2.VAlign = 0.0f;
|
||||
this._cancelButton2.HAlign = 0.5f;
|
||||
this._cancelButton2.OnClick += (UIElement.MouseEvent) ((evt, listeningElement) =>
|
||||
{
|
||||
SoundEngine.PlaySound(11);
|
||||
this._cancelAction();
|
||||
});
|
||||
this.outerLayer2.Append((UIElement) this._cancelButton2);
|
||||
UITextPanel<object> keyboardButton1 = this.CreateKeyboardButton((object) "", 8, 4, 2);
|
||||
keyboardButton1.OnClick += (UIElement.MouseEvent) ((evt, listeningElement) =>
|
||||
{
|
||||
SoundEngine.PlaySound(12);
|
||||
this._textBox.Backspace();
|
||||
this.ValidateText();
|
||||
});
|
||||
keyboardButton1.PaddingLeft = 0.0f;
|
||||
keyboardButton1.PaddingRight = 0.0f;
|
||||
keyboardButton1.PaddingBottom = keyboardButton1.PaddingTop = 0.0f;
|
||||
UIImage uiImage2 = new UIImage(this._textureBackspace);
|
||||
uiImage2.HAlign = 0.5f;
|
||||
uiImage2.VAlign = 0.5f;
|
||||
uiImage2.ImageScale = 0.92f;
|
||||
keyboardButton1.Append((UIElement) uiImage2);
|
||||
mainPanel.Append((UIElement) keyboardButton1);
|
||||
UIText uiText = new UIText(labelText, 0.75f, true);
|
||||
uiText.HAlign = 0.5f;
|
||||
uiText.Width.Pixels = num4;
|
||||
uiText.Top.Pixels = (float) ((double) num5 - 37.0 - 4.0) + num2 + num1;
|
||||
uiText.Top.Precent = num3;
|
||||
uiText.Height.Pixels = 37f;
|
||||
this.Append((UIElement) uiText);
|
||||
this._label = uiText;
|
||||
this.Append(element);
|
||||
this._textBox.SetTextMaxLength(this._edittingSign ? 1200 : 20);
|
||||
this.Text = startingText;
|
||||
if (this.Text.Length == 0)
|
||||
this.SetKeyState(UIVirtualKeyboard.KeyState.Shift);
|
||||
UIVirtualKeyboard.ShouldHideText = true;
|
||||
UIVirtualKeyboard.OffsetDown = 9999;
|
||||
this.UpdateOffsetDown();
|
||||
}
|
||||
|
||||
public void SetMaxInputLength(int length) => this._textBox.SetTextMaxLength(length);
|
||||
|
||||
private void BuildSpaceBarArea(UIPanel mainPanel)
|
||||
{
|
||||
Action createTheseTwo = (Action) (() =>
|
||||
{
|
||||
bool flag = this.CanRestore();
|
||||
int x = flag ? 4 : 5;
|
||||
bool edittingSign = this._edittingSign;
|
||||
int width = flag & edittingSign ? 2 : 3;
|
||||
UITextPanel<object> keyboardButton1 = this.CreateKeyboardButton((object) Language.GetText("UI.SpaceButton"), 2, 4, this._edittingSign || this._edittingChest & flag ? width : 6);
|
||||
keyboardButton1.OnClick += (UIElement.MouseEvent) ((evt, listeningElement) =>
|
||||
{
|
||||
SoundEngine.PlaySound(12);
|
||||
this._textBox.Write(" ");
|
||||
this.ValidateText();
|
||||
});
|
||||
mainPanel.Append((UIElement) keyboardButton1);
|
||||
this._spacebarButton = keyboardButton1;
|
||||
if (!edittingSign)
|
||||
return;
|
||||
UITextPanel<object> keyboardButton2 = this.CreateKeyboardButton((object) Language.GetText("UI.EnterButton"), x, 4, width);
|
||||
keyboardButton2.OnClick += (UIElement.MouseEvent) ((evt, listeningElement) =>
|
||||
{
|
||||
SoundEngine.PlaySound(12);
|
||||
this._textBox.Write("\n");
|
||||
this.ValidateText();
|
||||
});
|
||||
mainPanel.Append((UIElement) keyboardButton2);
|
||||
this._enterButton = keyboardButton2;
|
||||
});
|
||||
createTheseTwo();
|
||||
if (!this.CanRestore())
|
||||
return;
|
||||
UITextPanel<object> restoreBar = this.CreateKeyboardButton((object) Language.GetText("UI.RestoreButton"), 6, 4, 2);
|
||||
restoreBar.OnClick += (UIElement.MouseEvent) ((evt, listeningElement) =>
|
||||
{
|
||||
SoundEngine.PlaySound(12);
|
||||
this.RestoreCancelledInput(this._keyboardContext);
|
||||
this.ValidateText();
|
||||
restoreBar.Remove();
|
||||
this._enterButton.Remove();
|
||||
this._spacebarButton.Remove();
|
||||
createTheseTwo();
|
||||
});
|
||||
mainPanel.Append((UIElement) restoreBar);
|
||||
this._restoreButton = restoreBar;
|
||||
}
|
||||
|
||||
private bool CanRestore()
|
||||
{
|
||||
if (this._edittingSign)
|
||||
return UIVirtualKeyboard._cancelCacheSign.Length > 0;
|
||||
return this._edittingChest && UIVirtualKeyboard._cancelCacheChest.Length > 0;
|
||||
}
|
||||
|
||||
private void TypeText(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
SoundEngine.PlaySound(12);
|
||||
int num = this.Text.Length == 0 ? 1 : 0;
|
||||
this._textBox.Write(((UITextPanel<object>) listeningElement).Text);
|
||||
this.ValidateText();
|
||||
if (num == 0 || this.Text.Length <= 0 || this._keyState != UIVirtualKeyboard.KeyState.Shift)
|
||||
return;
|
||||
this.SetKeyState(UIVirtualKeyboard.KeyState.Default);
|
||||
}
|
||||
|
||||
public void SetKeyState(UIVirtualKeyboard.KeyState keyState)
|
||||
{
|
||||
UITextPanel<object> uiTextPanel1 = (UITextPanel<object>) null;
|
||||
switch (this._keyState)
|
||||
{
|
||||
case UIVirtualKeyboard.KeyState.Symbol:
|
||||
uiTextPanel1 = this._symbolButton;
|
||||
break;
|
||||
case UIVirtualKeyboard.KeyState.Shift:
|
||||
uiTextPanel1 = this._shiftButton;
|
||||
break;
|
||||
}
|
||||
if (uiTextPanel1 != null)
|
||||
{
|
||||
if (uiTextPanel1.IsMouseHovering)
|
||||
uiTextPanel1.BackgroundColor = new Color(73, 94, 171);
|
||||
else
|
||||
uiTextPanel1.BackgroundColor = new Color(63, 82, 151) * 0.7f;
|
||||
}
|
||||
string str = (string) null;
|
||||
UITextPanel<object> uiTextPanel2 = (UITextPanel<object>) null;
|
||||
switch (keyState)
|
||||
{
|
||||
case UIVirtualKeyboard.KeyState.Default:
|
||||
str = "1234567890qwertyuiopasdfghjkl'zxcvbnm,.?";
|
||||
break;
|
||||
case UIVirtualKeyboard.KeyState.Symbol:
|
||||
str = "1234567890!@#$%^&*()-_+=/\\{}[]<>;:\"`|~£¥";
|
||||
uiTextPanel2 = this._symbolButton;
|
||||
break;
|
||||
case UIVirtualKeyboard.KeyState.Shift:
|
||||
str = "1234567890QWERTYUIOPASDFGHJKL'ZXCVBNM,.?";
|
||||
uiTextPanel2 = this._shiftButton;
|
||||
break;
|
||||
}
|
||||
for (int index = 0; index < str.Length; ++index)
|
||||
this._keyList[index].SetText((object) str[index].ToString());
|
||||
this._keyState = keyState;
|
||||
if (uiTextPanel2 == null)
|
||||
return;
|
||||
uiTextPanel2.BackgroundColor = new Color(93, 114, 191);
|
||||
}
|
||||
|
||||
private void ValidateText()
|
||||
{
|
||||
if (this.Text.Trim().Length > 0 || this._edittingSign || this._edittingChest || this._allowEmpty)
|
||||
{
|
||||
this._canSubmit = true;
|
||||
this._submitButton.TextColor = Color.White;
|
||||
if (this._submitButton.IsMouseHovering)
|
||||
this._submitButton.BackgroundColor = new Color(73, 94, 171);
|
||||
else
|
||||
this._submitButton.BackgroundColor = new Color(63, 82, 151) * 0.7f;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._canSubmit = false;
|
||||
this._submitButton.TextColor = Color.Gray;
|
||||
if (this._submitButton.IsMouseHovering)
|
||||
this._submitButton.BackgroundColor = new Color(180, 60, 60) * 0.85f;
|
||||
else
|
||||
this._submitButton.BackgroundColor = new Color(150, 40, 40) * 0.85f;
|
||||
}
|
||||
}
|
||||
|
||||
private void StyleKey<T>(UITextPanel<T> button, bool external = false)
|
||||
{
|
||||
button.PaddingLeft = 0.0f;
|
||||
button.PaddingRight = 0.0f;
|
||||
button.BackgroundColor = new Color(63, 82, 151) * 0.7f;
|
||||
if (!external)
|
||||
button.BorderColor = this._internalBorderColor * 0.7f;
|
||||
button.OnMouseOver += (UIElement.MouseEvent) ((evt, listeningElement) =>
|
||||
{
|
||||
((UIPanel) listeningElement).BackgroundColor = new Color(73, 94, 171) * 0.85f;
|
||||
if (external)
|
||||
return;
|
||||
((UIPanel) listeningElement).BorderColor = this._internalBorderColorSelected * 0.85f;
|
||||
});
|
||||
button.OnMouseOut += (UIElement.MouseEvent) ((evt, listeningElement) =>
|
||||
{
|
||||
((UIPanel) listeningElement).BackgroundColor = new Color(63, 82, 151) * 0.7f;
|
||||
if (external)
|
||||
return;
|
||||
((UIPanel) listeningElement).BorderColor = this._internalBorderColor * 0.7f;
|
||||
});
|
||||
}
|
||||
|
||||
private UITextPanel<object> CreateKeyboardButton(
|
||||
object text,
|
||||
int x,
|
||||
int y,
|
||||
int width = 1,
|
||||
bool style = true)
|
||||
{
|
||||
float num = 516f;
|
||||
UITextPanel<object> button = new UITextPanel<object>(text, 0.4f, true);
|
||||
button.Width.Pixels = (float) (48.0 * (double) width + 4.0 * (double) (width - 1));
|
||||
button.Height.Pixels = 37f;
|
||||
button.Left.Precent = 0.5f;
|
||||
button.Left.Pixels = (float) (52.0 * (double) x - (double) num * 0.5);
|
||||
button.Top.Pixels = 41f * (float) y;
|
||||
if (style)
|
||||
this.StyleKey<object>(button);
|
||||
for (int index = 0; index < width; ++index)
|
||||
this._keyList[y * 10 + x + index] = button;
|
||||
return button;
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
if (Main.gameMenu)
|
||||
{
|
||||
if (PlayerInput.UsingGamepad)
|
||||
{
|
||||
this.outerLayer2.Remove();
|
||||
if (!this.Elements.Contains(this.outerLayer1))
|
||||
this.Append(this.outerLayer1);
|
||||
this.outerLayer1.Activate();
|
||||
this.outerLayer2.Deactivate();
|
||||
this.Recalculate();
|
||||
this.RecalculateChildren();
|
||||
if ((double) this._labelHeight != 0.0)
|
||||
{
|
||||
this._textBox.Top.Pixels = this._textBoxHeight;
|
||||
this._label.Top.Pixels = this._labelHeight;
|
||||
this._textBox.Recalculate();
|
||||
this._label.Recalculate();
|
||||
this._labelHeight = this._textBoxHeight = 0.0f;
|
||||
UserInterface.ActiveInstance.ResetLasts();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.outerLayer1.Remove();
|
||||
if (!this.Elements.Contains(this.outerLayer2))
|
||||
this.Append(this.outerLayer2);
|
||||
this.outerLayer2.Activate();
|
||||
this.outerLayer1.Deactivate();
|
||||
this.Recalculate();
|
||||
this.RecalculateChildren();
|
||||
if ((double) this._textBoxHeight == 0.0)
|
||||
{
|
||||
this._textBoxHeight = this._textBox.Top.Pixels;
|
||||
this._labelHeight = this._label.Top.Pixels;
|
||||
this._textBox.Top.Pixels += 50f;
|
||||
this._label.Top.Pixels += 50f;
|
||||
this._textBox.Recalculate();
|
||||
this._label.Recalculate();
|
||||
UserInterface.ActiveInstance.ResetLasts();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!Main.editSign && this._edittingSign)
|
||||
IngameFancyUI.Close();
|
||||
else if (!Main.editChest && this._edittingChest)
|
||||
{
|
||||
IngameFancyUI.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
base.DrawSelf(spriteBatch);
|
||||
this.UpdateOffsetDown();
|
||||
UIVirtualKeyboard.OffsetDown = 0;
|
||||
UIVirtualKeyboard.ShouldHideText = false;
|
||||
this.SetupGamepadPoints(spriteBatch);
|
||||
PlayerInput.WritingText = true;
|
||||
Main.instance.HandleIME();
|
||||
Vector2 position = new Vector2((float) (Main.screenWidth / 2), (float) (this._textBox.GetDimensions().ToRectangle().Bottom + 32));
|
||||
Main.instance.DrawWindowsIMEPanel(position, 0.5f);
|
||||
string inputText = Main.GetInputText(this.Text, this._edittingSign);
|
||||
if (this._edittingSign && Main.inputTextEnter)
|
||||
{
|
||||
inputText += "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this._edittingChest && Main.inputTextEnter)
|
||||
{
|
||||
ChestUI.RenameChestSubmit(Main.player[Main.myPlayer]);
|
||||
IngameFancyUI.Close();
|
||||
return;
|
||||
}
|
||||
if (Main.inputTextEnter && UIVirtualKeyboard.CanSubmit)
|
||||
UIVirtualKeyboard.Submit();
|
||||
else if (this._edittingChest && Main.player[Main.myPlayer].chest < 0)
|
||||
ChestUI.RenameChestCancel();
|
||||
else if (Main.inputTextEscape)
|
||||
{
|
||||
if (this._edittingSign)
|
||||
Main.InputTextSignCancel();
|
||||
if (this._edittingChest)
|
||||
ChestUI.RenameChestCancel();
|
||||
IngameFancyUI.Close();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (IngameFancyUI.CanShowVirtualKeyboard(this._keyboardContext))
|
||||
{
|
||||
if (inputText != this.Text)
|
||||
this.Text = inputText;
|
||||
if (this._edittingSign)
|
||||
this.CopyTextToSign();
|
||||
if (this._edittingChest)
|
||||
this.CopyTextToChest();
|
||||
}
|
||||
byte num = (byte) (((int) byte.MaxValue + (int) Main.tileColor.R * 2) / 3);
|
||||
Color color = new Color((int) num, (int) num, (int) num, (int) byte.MaxValue);
|
||||
this._textBox.TextColor = Color.Lerp(Color.White, color, 0.2f);
|
||||
this._label.TextColor = Color.Lerp(Color.White, color, 0.2f);
|
||||
position = new Vector2((float) (Main.screenWidth / 2), (float) (this._textBox.GetDimensions().ToRectangle().Bottom + 32));
|
||||
Main.instance.DrawWindowsIMEPanel(position, 0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateOffsetDown()
|
||||
{
|
||||
this._textBox.HideSelf = UIVirtualKeyboard.ShouldHideText;
|
||||
int num1 = UIVirtualKeyboard.OffsetDown - this._lastOffsetDown;
|
||||
int num2 = num1;
|
||||
if (Math.Abs(num1) < 10)
|
||||
num2 = num1;
|
||||
this._lastOffsetDown += num2;
|
||||
if (num2 == 0)
|
||||
return;
|
||||
this.Top.Pixels += (float) num2;
|
||||
this.Recalculate();
|
||||
}
|
||||
|
||||
public override void OnActivate()
|
||||
{
|
||||
if (!PlayerInput.UsingGamepadUI || this._restoreButton == null)
|
||||
return;
|
||||
UILinkPointNavigator.ChangePoint(3002);
|
||||
}
|
||||
|
||||
public override void OnDeactivate()
|
||||
{
|
||||
base.OnDeactivate();
|
||||
PlayerInput.WritingText = false;
|
||||
UILinkPointNavigator.Shortcuts.FANCYUI_SPECIAL_INSTRUCTIONS = 0;
|
||||
}
|
||||
|
||||
private void SetupGamepadPoints(SpriteBatch spriteBatch)
|
||||
{
|
||||
UILinkPointNavigator.Shortcuts.BackButtonCommand = 6;
|
||||
UILinkPointNavigator.Shortcuts.FANCYUI_SPECIAL_INSTRUCTIONS = 1;
|
||||
int num1 = 3002;
|
||||
UILinkPointNavigator.SetPosition(3000, this._cancelButton.GetDimensions().Center());
|
||||
UILinkPoint point1 = UILinkPointNavigator.Points[3000];
|
||||
point1.Unlink();
|
||||
point1.Right = 3001;
|
||||
point1.Up = num1 + 40;
|
||||
UILinkPointNavigator.SetPosition(3001, this._submitButton.GetDimensions().Center());
|
||||
UILinkPoint point2 = UILinkPointNavigator.Points[3001];
|
||||
point2.Unlink();
|
||||
point2.Left = 3000;
|
||||
point2.Up = num1 + 49;
|
||||
for (int index1 = 0; index1 < 5; ++index1)
|
||||
{
|
||||
for (int index2 = 0; index2 < 10; ++index2)
|
||||
{
|
||||
int index3 = index1 * 10 + index2;
|
||||
int num2 = num1 + index3;
|
||||
if (this._keyList[index3] != null)
|
||||
{
|
||||
UILinkPointNavigator.SetPosition(num2, this._keyList[index3].GetDimensions().Center());
|
||||
UILinkPoint point3 = UILinkPointNavigator.Points[num2];
|
||||
point3.Unlink();
|
||||
int num3 = index2 - 1;
|
||||
while (num3 >= 0 && this._keyList[index1 * 10 + num3] == this._keyList[index3])
|
||||
--num3;
|
||||
point3.Left = num3 == -1 ? index1 * 10 + 9 + num1 : index1 * 10 + num3 + num1;
|
||||
int index4 = index2 + 1;
|
||||
while (index4 <= 9 && this._keyList[index1 * 10 + index4] == this._keyList[index3])
|
||||
++index4;
|
||||
point3.Right = index4 == 10 || this._keyList[index3] == this._keyList[index4] ? index1 * 10 + num1 : index1 * 10 + index4 + num1;
|
||||
if (index1 != 0)
|
||||
point3.Up = num2 - 10;
|
||||
point3.Down = index1 == 4 ? (index2 < 5 ? 3000 : 3001) : num2 + 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void CycleSymbols()
|
||||
{
|
||||
if (UIVirtualKeyboard._currentInstance == null)
|
||||
return;
|
||||
switch (UIVirtualKeyboard._currentInstance._keyState)
|
||||
{
|
||||
case UIVirtualKeyboard.KeyState.Default:
|
||||
UIVirtualKeyboard._currentInstance.SetKeyState(UIVirtualKeyboard.KeyState.Shift);
|
||||
break;
|
||||
case UIVirtualKeyboard.KeyState.Symbol:
|
||||
UIVirtualKeyboard._currentInstance.SetKeyState(UIVirtualKeyboard.KeyState.Default);
|
||||
break;
|
||||
case UIVirtualKeyboard.KeyState.Shift:
|
||||
UIVirtualKeyboard._currentInstance.SetKeyState(UIVirtualKeyboard.KeyState.Symbol);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void BackSpace()
|
||||
{
|
||||
if (UIVirtualKeyboard._currentInstance == null)
|
||||
return;
|
||||
SoundEngine.PlaySound(12);
|
||||
UIVirtualKeyboard._currentInstance._textBox.Backspace();
|
||||
UIVirtualKeyboard._currentInstance.ValidateText();
|
||||
}
|
||||
|
||||
public static bool CanSubmit => UIVirtualKeyboard._currentInstance != null && UIVirtualKeyboard._currentInstance._canSubmit;
|
||||
|
||||
public static void Submit()
|
||||
{
|
||||
if (UIVirtualKeyboard._currentInstance == null)
|
||||
return;
|
||||
UIVirtualKeyboard._currentInstance.InternalSubmit();
|
||||
}
|
||||
|
||||
private void InternalSubmit()
|
||||
{
|
||||
string text = this.Text.Trim();
|
||||
if (text.Length <= 0 && !this._edittingSign && !this._edittingChest && !this._allowEmpty)
|
||||
return;
|
||||
SoundEngine.PlaySound(10);
|
||||
this._submitAction(text);
|
||||
}
|
||||
|
||||
public static void Cancel()
|
||||
{
|
||||
if (UIVirtualKeyboard._currentInstance == null)
|
||||
return;
|
||||
SoundEngine.PlaySound(11);
|
||||
UIVirtualKeyboard._currentInstance._cancelAction();
|
||||
}
|
||||
|
||||
public static void Write(string text)
|
||||
{
|
||||
if (UIVirtualKeyboard._currentInstance == null)
|
||||
return;
|
||||
SoundEngine.PlaySound(12);
|
||||
int num = UIVirtualKeyboard._currentInstance.Text.Length == 0 ? 1 : 0;
|
||||
UIVirtualKeyboard._currentInstance._textBox.Write(text);
|
||||
UIVirtualKeyboard._currentInstance.ValidateText();
|
||||
if (num == 0 || UIVirtualKeyboard._currentInstance.Text.Length <= 0 || UIVirtualKeyboard._currentInstance._keyState != UIVirtualKeyboard.KeyState.Shift)
|
||||
return;
|
||||
UIVirtualKeyboard._currentInstance.SetKeyState(UIVirtualKeyboard.KeyState.Default);
|
||||
}
|
||||
|
||||
public static void CursorLeft()
|
||||
{
|
||||
if (UIVirtualKeyboard._currentInstance == null)
|
||||
return;
|
||||
SoundEngine.PlaySound(12);
|
||||
UIVirtualKeyboard._currentInstance._textBox.CursorLeft();
|
||||
}
|
||||
|
||||
public static void CursorRight()
|
||||
{
|
||||
if (UIVirtualKeyboard._currentInstance == null)
|
||||
return;
|
||||
SoundEngine.PlaySound(12);
|
||||
UIVirtualKeyboard._currentInstance._textBox.CursorRight();
|
||||
}
|
||||
|
||||
public static bool CanDisplay(int keyboardContext) => keyboardContext != 1 || Main.screenHeight > 700;
|
||||
|
||||
public static int KeyboardContext => UIVirtualKeyboard._currentInstance == null ? -1 : UIVirtualKeyboard._currentInstance._keyboardContext;
|
||||
|
||||
public static void CacheCancelledInput(int cacheMode)
|
||||
{
|
||||
if (cacheMode != 1)
|
||||
return;
|
||||
UIVirtualKeyboard._cancelCacheSign = Main.npcChatText;
|
||||
}
|
||||
|
||||
private void RestoreCancelledInput(int cacheMode)
|
||||
{
|
||||
if (cacheMode != 1)
|
||||
return;
|
||||
Main.npcChatText = UIVirtualKeyboard._cancelCacheSign;
|
||||
this.Text = Main.npcChatText;
|
||||
UIVirtualKeyboard._cancelCacheSign = "";
|
||||
}
|
||||
|
||||
private void CopyTextToSign()
|
||||
{
|
||||
if (!this._edittingSign)
|
||||
return;
|
||||
int sign = Main.player[Main.myPlayer].sign;
|
||||
if (sign < 0 || Main.sign[sign] == null)
|
||||
return;
|
||||
Main.npcChatText = this.Text;
|
||||
}
|
||||
|
||||
private void CopyTextToChest()
|
||||
{
|
||||
if (!this._edittingChest)
|
||||
return;
|
||||
Main.npcChatText = this.Text;
|
||||
}
|
||||
|
||||
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.7f;
|
||||
((UIPanel) evt.Target).BorderColor = Color.Black;
|
||||
}
|
||||
|
||||
public delegate void KeyboardSubmitEvent(string text);
|
||||
|
||||
public enum KeyState
|
||||
{
|
||||
Default,
|
||||
Symbol,
|
||||
Shift,
|
||||
}
|
||||
}
|
||||
}
|
927
GameContent/UI/States/UIWorldCreation.cs
Normal file
927
GameContent/UI/States/UIWorldCreation.cs
Normal file
|
@ -0,0 +1,927 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.States.UIWorldCreation
|
||||
// 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.UI.Elements;
|
||||
using Terraria.ID;
|
||||
using Terraria.IO;
|
||||
using Terraria.Localization;
|
||||
using Terraria.Social;
|
||||
using Terraria.UI;
|
||||
using Terraria.UI.Gamepad;
|
||||
|
||||
namespace Terraria.GameContent.UI.States
|
||||
{
|
||||
public class UIWorldCreation : UIState
|
||||
{
|
||||
private UIWorldCreation.WorldSizeId _optionSize;
|
||||
private UIWorldCreation.WorldDifficultyId _optionDifficulty;
|
||||
private UIWorldCreation.WorldEvilId _optionEvil;
|
||||
private string _optionwWorldName;
|
||||
private string _optionSeed;
|
||||
private UICharacterNameButton _namePlate;
|
||||
private UICharacterNameButton _seedPlate;
|
||||
private UIWorldCreationPreview _previewPlate;
|
||||
private GroupOptionButton<UIWorldCreation.WorldSizeId>[] _sizeButtons;
|
||||
private GroupOptionButton<UIWorldCreation.WorldDifficultyId>[] _difficultyButtons;
|
||||
private GroupOptionButton<UIWorldCreation.WorldEvilId>[] _evilButtons;
|
||||
private UIText _descriptionText;
|
||||
private const int MAX_NAME_LENGTH = 27;
|
||||
private const int MAX_SEED_LENGTH = 40;
|
||||
|
||||
public UIWorldCreation() => this.BuildPage();
|
||||
|
||||
private void BuildPage()
|
||||
{
|
||||
int num = 18;
|
||||
this.RemoveAllChildren();
|
||||
UIElement uiElement1 = new UIElement()
|
||||
{
|
||||
Width = StyleDimension.FromPixels(500f),
|
||||
Height = StyleDimension.FromPixels(434f + (float) num),
|
||||
Top = StyleDimension.FromPixels(170f - (float) num),
|
||||
HAlign = 0.5f,
|
||||
VAlign = 0.0f
|
||||
};
|
||||
uiElement1.SetPadding(0.0f);
|
||||
this.Append(uiElement1);
|
||||
UIPanel uiPanel1 = new UIPanel();
|
||||
uiPanel1.Width = StyleDimension.FromPercent(1f);
|
||||
uiPanel1.Height = StyleDimension.FromPixels((float) (280 + num));
|
||||
uiPanel1.Top = StyleDimension.FromPixels(50f);
|
||||
uiPanel1.BackgroundColor = new Color(33, 43, 79) * 0.8f;
|
||||
UIPanel uiPanel2 = uiPanel1;
|
||||
uiPanel2.SetPadding(0.0f);
|
||||
uiElement1.Append((UIElement) uiPanel2);
|
||||
this.MakeBackAndCreatebuttons(uiElement1);
|
||||
UIElement uiElement2 = new UIElement()
|
||||
{
|
||||
Top = StyleDimension.FromPixelsAndPercent(0.0f, 0.0f),
|
||||
Width = StyleDimension.FromPixelsAndPercent(0.0f, 1f),
|
||||
Height = StyleDimension.FromPixelsAndPercent(0.0f, 1f),
|
||||
HAlign = 1f
|
||||
};
|
||||
uiElement2.SetPadding(0.0f);
|
||||
uiElement2.PaddingTop = 8f;
|
||||
uiElement2.PaddingBottom = 12f;
|
||||
uiPanel2.Append(uiElement2);
|
||||
this.MakeInfoMenu(uiElement2);
|
||||
}
|
||||
|
||||
private void MakeInfoMenu(UIElement parentContainer)
|
||||
{
|
||||
UIElement uiElement = new UIElement()
|
||||
{
|
||||
Width = StyleDimension.FromPixelsAndPercent(0.0f, 1f),
|
||||
Height = StyleDimension.FromPixelsAndPercent(0.0f, 1f),
|
||||
HAlign = 0.5f,
|
||||
VAlign = 0.0f
|
||||
};
|
||||
uiElement.SetPadding(10f);
|
||||
uiElement.PaddingBottom = 0.0f;
|
||||
uiElement.PaddingTop = 0.0f;
|
||||
parentContainer.Append(uiElement);
|
||||
float pixels1 = 0.0f;
|
||||
float num1 = 44f;
|
||||
float num2 = (float) (88.0 + (double) num1);
|
||||
float pixels2 = num1;
|
||||
GroupOptionButton<bool> groupOptionButton1 = new GroupOptionButton<bool>(true, (LocalizedText) null, Language.GetText("UI.WorldCreationRandomizeNameDescription"), Color.White, "Images/UI/WorldCreation/IconRandomName");
|
||||
groupOptionButton1.Width = StyleDimension.FromPixelsAndPercent(40f, 0.0f);
|
||||
groupOptionButton1.Height = new StyleDimension(40f, 0.0f);
|
||||
groupOptionButton1.HAlign = 0.0f;
|
||||
groupOptionButton1.Top = StyleDimension.FromPixelsAndPercent(pixels1, 0.0f);
|
||||
groupOptionButton1.ShowHighlightWhenSelected = false;
|
||||
GroupOptionButton<bool> groupOptionButton2 = groupOptionButton1;
|
||||
groupOptionButton2.OnMouseDown += new UIElement.MouseEvent(this.ClickRandomizeName);
|
||||
groupOptionButton2.OnMouseOver += new UIElement.MouseEvent(this.ShowOptionDescription);
|
||||
groupOptionButton2.OnMouseOut += new UIElement.MouseEvent(this.ClearOptionDescription);
|
||||
groupOptionButton2.SetSnapPoint("RandomizeName", 0);
|
||||
uiElement.Append((UIElement) groupOptionButton2);
|
||||
UICharacterNameButton characterNameButton1 = new UICharacterNameButton(Language.GetText("UI.WorldCreationName"), Language.GetText("UI.WorldCreationNameEmpty"), Language.GetText("UI.WorldDescriptionName"));
|
||||
characterNameButton1.Width = StyleDimension.FromPixelsAndPercent(-num2, 1f);
|
||||
characterNameButton1.HAlign = 0.0f;
|
||||
characterNameButton1.Left = new StyleDimension(pixels2, 0.0f);
|
||||
characterNameButton1.Top = StyleDimension.FromPixelsAndPercent(pixels1, 0.0f);
|
||||
UICharacterNameButton characterNameButton2 = characterNameButton1;
|
||||
characterNameButton2.OnMouseDown += new UIElement.MouseEvent(this.Click_SetName);
|
||||
characterNameButton2.OnMouseOver += new UIElement.MouseEvent(this.ShowOptionDescription);
|
||||
characterNameButton2.OnMouseOut += new UIElement.MouseEvent(this.ClearOptionDescription);
|
||||
characterNameButton2.SetSnapPoint("Name", 0);
|
||||
uiElement.Append((UIElement) characterNameButton2);
|
||||
this._namePlate = characterNameButton2;
|
||||
CalculatedStyle dimensions1 = characterNameButton2.GetDimensions();
|
||||
float pixels3 = pixels1 + (dimensions1.Height + 4f);
|
||||
GroupOptionButton<bool> groupOptionButton3 = new GroupOptionButton<bool>(true, (LocalizedText) null, Language.GetText("UI.WorldCreationRandomizeSeedDescription"), Color.White, "Images/UI/WorldCreation/IconRandomSeed");
|
||||
groupOptionButton3.Width = StyleDimension.FromPixelsAndPercent(40f, 0.0f);
|
||||
groupOptionButton3.Height = new StyleDimension(40f, 0.0f);
|
||||
groupOptionButton3.HAlign = 0.0f;
|
||||
groupOptionButton3.Top = StyleDimension.FromPixelsAndPercent(pixels3, 0.0f);
|
||||
groupOptionButton3.ShowHighlightWhenSelected = false;
|
||||
GroupOptionButton<bool> groupOptionButton4 = groupOptionButton3;
|
||||
groupOptionButton4.OnMouseDown += new UIElement.MouseEvent(this.ClickRandomizeSeed);
|
||||
groupOptionButton4.OnMouseOver += new UIElement.MouseEvent(this.ShowOptionDescription);
|
||||
groupOptionButton4.OnMouseOut += new UIElement.MouseEvent(this.ClearOptionDescription);
|
||||
groupOptionButton4.SetSnapPoint("RandomizeSeed", 0);
|
||||
uiElement.Append((UIElement) groupOptionButton4);
|
||||
UICharacterNameButton characterNameButton3 = new UICharacterNameButton(Language.GetText("UI.WorldCreationSeed"), Language.GetText("UI.WorldCreationSeedEmpty"), Language.GetText("UI.WorldDescriptionSeed"));
|
||||
characterNameButton3.Width = StyleDimension.FromPixelsAndPercent(-num2, 1f);
|
||||
characterNameButton3.HAlign = 0.0f;
|
||||
characterNameButton3.Left = new StyleDimension(pixels2, 0.0f);
|
||||
characterNameButton3.Top = StyleDimension.FromPixelsAndPercent(pixels3, 0.0f);
|
||||
characterNameButton3.DistanceFromTitleToOption = 29f;
|
||||
UICharacterNameButton characterNameButton4 = characterNameButton3;
|
||||
characterNameButton4.OnMouseDown += new UIElement.MouseEvent(this.Click_SetSeed);
|
||||
characterNameButton4.OnMouseOver += new UIElement.MouseEvent(this.ShowOptionDescription);
|
||||
characterNameButton4.OnMouseOut += new UIElement.MouseEvent(this.ClearOptionDescription);
|
||||
characterNameButton4.SetSnapPoint("Seed", 0);
|
||||
uiElement.Append((UIElement) characterNameButton4);
|
||||
this._seedPlate = characterNameButton4;
|
||||
UIWorldCreationPreview worldCreationPreview1 = new UIWorldCreationPreview();
|
||||
worldCreationPreview1.Width = StyleDimension.FromPixels(84f);
|
||||
worldCreationPreview1.Height = StyleDimension.FromPixels(84f);
|
||||
worldCreationPreview1.HAlign = 1f;
|
||||
worldCreationPreview1.VAlign = 0.0f;
|
||||
UIWorldCreationPreview worldCreationPreview2 = worldCreationPreview1;
|
||||
uiElement.Append((UIElement) worldCreationPreview2);
|
||||
this._previewPlate = worldCreationPreview2;
|
||||
CalculatedStyle dimensions2 = characterNameButton4.GetDimensions();
|
||||
float accumualtedHeight1 = pixels3 + (dimensions2.Height + 10f);
|
||||
UIWorldCreation.AddHorizontalSeparator(uiElement, accumualtedHeight1 + 2f);
|
||||
float usableWidthPercent = 1f;
|
||||
this.AddWorldSizeOptions(uiElement, accumualtedHeight1, new UIElement.MouseEvent(this.ClickSizeOption), "size", usableWidthPercent);
|
||||
float accumualtedHeight2 = accumualtedHeight1 + 48f;
|
||||
UIWorldCreation.AddHorizontalSeparator(uiElement, accumualtedHeight2);
|
||||
this.AddWorldDifficultyOptions(uiElement, accumualtedHeight2, new UIElement.MouseEvent(this.ClickDifficultyOption), "difficulty", usableWidthPercent);
|
||||
float accumualtedHeight3 = accumualtedHeight2 + 48f;
|
||||
UIWorldCreation.AddHorizontalSeparator(uiElement, accumualtedHeight3);
|
||||
this.AddWorldEvilOptions(uiElement, accumualtedHeight3, new UIElement.MouseEvent(this.ClickEvilOption), "evil", usableWidthPercent);
|
||||
float num3 = accumualtedHeight3 + 48f;
|
||||
UIWorldCreation.AddHorizontalSeparator(uiElement, num3);
|
||||
this.AddDescriptionPanel(uiElement, num3, "desc");
|
||||
this.SetDefaultOptions();
|
||||
}
|
||||
|
||||
private static void AddHorizontalSeparator(UIElement Container, float accumualtedHeight)
|
||||
{
|
||||
UIHorizontalSeparator horizontalSeparator1 = new UIHorizontalSeparator();
|
||||
horizontalSeparator1.Width = StyleDimension.FromPercent(1f);
|
||||
horizontalSeparator1.Top = StyleDimension.FromPixels(accumualtedHeight - 8f);
|
||||
horizontalSeparator1.Color = Color.Lerp(Color.White, new Color(63, 65, 151, (int) byte.MaxValue), 0.85f) * 0.9f;
|
||||
UIHorizontalSeparator horizontalSeparator2 = horizontalSeparator1;
|
||||
Container.Append((UIElement) horizontalSeparator2);
|
||||
}
|
||||
|
||||
private void SetDefaultOptions()
|
||||
{
|
||||
this.AssignRandomWorldName();
|
||||
this.AssignRandomWorldSeed();
|
||||
this.UpdateInputFields();
|
||||
foreach (GroupOptionButton<UIWorldCreation.WorldSizeId> sizeButton in this._sizeButtons)
|
||||
sizeButton.SetCurrentOption(UIWorldCreation.WorldSizeId.Small);
|
||||
if (Main.ActivePlayerFileData.Player.difficulty == (byte) 3)
|
||||
{
|
||||
foreach (GroupOptionButton<UIWorldCreation.WorldDifficultyId> difficultyButton in this._difficultyButtons)
|
||||
difficultyButton.SetCurrentOption(UIWorldCreation.WorldDifficultyId.Creative);
|
||||
this._optionDifficulty = UIWorldCreation.WorldDifficultyId.Creative;
|
||||
this.UpdatePreviewPlate();
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (GroupOptionButton<UIWorldCreation.WorldDifficultyId> difficultyButton in this._difficultyButtons)
|
||||
difficultyButton.SetCurrentOption(UIWorldCreation.WorldDifficultyId.Normal);
|
||||
}
|
||||
foreach (GroupOptionButton<UIWorldCreation.WorldEvilId> evilButton in this._evilButtons)
|
||||
evilButton.SetCurrentOption(UIWorldCreation.WorldEvilId.Random);
|
||||
}
|
||||
|
||||
private void AddDescriptionPanel(UIElement container, float accumulatedHeight, string tagGroup)
|
||||
{
|
||||
float num = 0.0f;
|
||||
UISlicedImage uiSlicedImage1 = new UISlicedImage(Main.Assets.Request<Texture2D>("Images/UI/CharCreation/CategoryPanelHighlight", (AssetRequestMode) 1));
|
||||
uiSlicedImage1.HAlign = 0.5f;
|
||||
uiSlicedImage1.VAlign = 1f;
|
||||
uiSlicedImage1.Width = StyleDimension.FromPixelsAndPercent((float) (-(double) num * 2.0), 1f);
|
||||
uiSlicedImage1.Left = StyleDimension.FromPixels(-num);
|
||||
uiSlicedImage1.Height = StyleDimension.FromPixelsAndPercent(40f, 0.0f);
|
||||
uiSlicedImage1.Top = StyleDimension.FromPixels(2f);
|
||||
UISlicedImage uiSlicedImage2 = uiSlicedImage1;
|
||||
uiSlicedImage2.SetSliceDepths(10);
|
||||
uiSlicedImage2.Color = Color.LightGray * 0.7f;
|
||||
container.Append((UIElement) uiSlicedImage2);
|
||||
UIText uiText1 = new UIText(Language.GetText("UI.WorldDescriptionDefault"), 0.82f);
|
||||
uiText1.HAlign = 0.0f;
|
||||
uiText1.VAlign = 0.0f;
|
||||
uiText1.Width = StyleDimension.FromPixelsAndPercent(0.0f, 1f);
|
||||
uiText1.Height = StyleDimension.FromPixelsAndPercent(0.0f, 1f);
|
||||
uiText1.Top = StyleDimension.FromPixelsAndPercent(5f, 0.0f);
|
||||
UIText uiText2 = uiText1;
|
||||
uiText2.PaddingLeft = 20f;
|
||||
uiText2.PaddingRight = 20f;
|
||||
uiText2.PaddingTop = 6f;
|
||||
uiSlicedImage2.Append((UIElement) uiText2);
|
||||
this._descriptionText = uiText2;
|
||||
}
|
||||
|
||||
private void AddWorldSizeOptions(
|
||||
UIElement container,
|
||||
float accumualtedHeight,
|
||||
UIElement.MouseEvent clickEvent,
|
||||
string tagGroup,
|
||||
float usableWidthPercent)
|
||||
{
|
||||
UIWorldCreation.WorldSizeId[] worldSizeIdArray = new UIWorldCreation.WorldSizeId[3]
|
||||
{
|
||||
UIWorldCreation.WorldSizeId.Small,
|
||||
UIWorldCreation.WorldSizeId.Medium,
|
||||
UIWorldCreation.WorldSizeId.Large
|
||||
};
|
||||
LocalizedText[] localizedTextArray1 = new LocalizedText[3]
|
||||
{
|
||||
Lang.menu[92],
|
||||
Lang.menu[93],
|
||||
Lang.menu[94]
|
||||
};
|
||||
LocalizedText[] localizedTextArray2 = new LocalizedText[3]
|
||||
{
|
||||
Language.GetText("UI.WorldDescriptionSizeSmall"),
|
||||
Language.GetText("UI.WorldDescriptionSizeMedium"),
|
||||
Language.GetText("UI.WorldDescriptionSizeLarge")
|
||||
};
|
||||
Color[] colorArray = new Color[3]
|
||||
{
|
||||
Color.Cyan,
|
||||
Color.Lerp(Color.Cyan, Color.LimeGreen, 0.5f),
|
||||
Color.LimeGreen
|
||||
};
|
||||
string[] strArray = new string[3]
|
||||
{
|
||||
"Images/UI/WorldCreation/IconSizeSmall",
|
||||
"Images/UI/WorldCreation/IconSizeMedium",
|
||||
"Images/UI/WorldCreation/IconSizeLarge"
|
||||
};
|
||||
GroupOptionButton<UIWorldCreation.WorldSizeId>[] groupOptionButtonArray = new GroupOptionButton<UIWorldCreation.WorldSizeId>[worldSizeIdArray.Length];
|
||||
for (int id = 0; id < groupOptionButtonArray.Length; ++id)
|
||||
{
|
||||
GroupOptionButton<UIWorldCreation.WorldSizeId> groupOptionButton = new GroupOptionButton<UIWorldCreation.WorldSizeId>(worldSizeIdArray[id], localizedTextArray1[id], localizedTextArray2[id], colorArray[id], strArray[id], titleAlignmentX: 1f, titleWidthReduction: 16f);
|
||||
groupOptionButton.Width = StyleDimension.FromPixelsAndPercent((float) (-4 * (groupOptionButtonArray.Length - 1)), 1f / (float) groupOptionButtonArray.Length * usableWidthPercent);
|
||||
groupOptionButton.Left = StyleDimension.FromPercent(1f - usableWidthPercent);
|
||||
groupOptionButton.HAlign = (float) id / (float) (groupOptionButtonArray.Length - 1);
|
||||
groupOptionButton.Top.Set(accumualtedHeight, 0.0f);
|
||||
groupOptionButton.OnMouseDown += clickEvent;
|
||||
groupOptionButton.OnMouseOver += new UIElement.MouseEvent(this.ShowOptionDescription);
|
||||
groupOptionButton.OnMouseOut += new UIElement.MouseEvent(this.ClearOptionDescription);
|
||||
groupOptionButton.SetSnapPoint(tagGroup, id);
|
||||
container.Append((UIElement) groupOptionButton);
|
||||
groupOptionButtonArray[id] = groupOptionButton;
|
||||
}
|
||||
this._sizeButtons = groupOptionButtonArray;
|
||||
}
|
||||
|
||||
private void AddWorldDifficultyOptions(
|
||||
UIElement container,
|
||||
float accumualtedHeight,
|
||||
UIElement.MouseEvent clickEvent,
|
||||
string tagGroup,
|
||||
float usableWidthPercent)
|
||||
{
|
||||
UIWorldCreation.WorldDifficultyId[] worldDifficultyIdArray = new UIWorldCreation.WorldDifficultyId[4]
|
||||
{
|
||||
UIWorldCreation.WorldDifficultyId.Creative,
|
||||
UIWorldCreation.WorldDifficultyId.Normal,
|
||||
UIWorldCreation.WorldDifficultyId.Expert,
|
||||
UIWorldCreation.WorldDifficultyId.Master
|
||||
};
|
||||
LocalizedText[] localizedTextArray1 = new LocalizedText[4]
|
||||
{
|
||||
Language.GetText("UI.Creative"),
|
||||
Language.GetText("UI.Normal"),
|
||||
Language.GetText("UI.Expert"),
|
||||
Language.GetText("UI.Master")
|
||||
};
|
||||
LocalizedText[] localizedTextArray2 = new LocalizedText[4]
|
||||
{
|
||||
Language.GetText("UI.WorldDescriptionCreative"),
|
||||
Language.GetText("UI.WorldDescriptionNormal"),
|
||||
Language.GetText("UI.WorldDescriptionExpert"),
|
||||
Language.GetText("UI.WorldDescriptionMaster")
|
||||
};
|
||||
Color[] colorArray = new Color[4]
|
||||
{
|
||||
Main.creativeModeColor,
|
||||
Color.White,
|
||||
Main.mcColor,
|
||||
Main.hcColor
|
||||
};
|
||||
string[] strArray = new string[4]
|
||||
{
|
||||
"Images/UI/WorldCreation/IconDifficultyCreative",
|
||||
"Images/UI/WorldCreation/IconDifficultyNormal",
|
||||
"Images/UI/WorldCreation/IconDifficultyExpert",
|
||||
"Images/UI/WorldCreation/IconDifficultyMaster"
|
||||
};
|
||||
GroupOptionButton<UIWorldCreation.WorldDifficultyId>[] groupOptionButtonArray = new GroupOptionButton<UIWorldCreation.WorldDifficultyId>[worldDifficultyIdArray.Length];
|
||||
for (int id = 0; id < groupOptionButtonArray.Length; ++id)
|
||||
{
|
||||
GroupOptionButton<UIWorldCreation.WorldDifficultyId> groupOptionButton = new GroupOptionButton<UIWorldCreation.WorldDifficultyId>(worldDifficultyIdArray[id], localizedTextArray1[id], localizedTextArray2[id], colorArray[id], strArray[id], titleAlignmentX: 1f, titleWidthReduction: 16f);
|
||||
groupOptionButton.Width = StyleDimension.FromPixelsAndPercent((float) (-1 * (groupOptionButtonArray.Length - 1)), 1f / (float) groupOptionButtonArray.Length * usableWidthPercent);
|
||||
groupOptionButton.Left = StyleDimension.FromPercent(1f - usableWidthPercent);
|
||||
groupOptionButton.HAlign = (float) id / (float) (groupOptionButtonArray.Length - 1);
|
||||
groupOptionButton.Top.Set(accumualtedHeight, 0.0f);
|
||||
groupOptionButton.OnMouseDown += clickEvent;
|
||||
groupOptionButton.OnMouseOver += new UIElement.MouseEvent(this.ShowOptionDescription);
|
||||
groupOptionButton.OnMouseOut += new UIElement.MouseEvent(this.ClearOptionDescription);
|
||||
groupOptionButton.SetSnapPoint(tagGroup, id);
|
||||
container.Append((UIElement) groupOptionButton);
|
||||
groupOptionButtonArray[id] = groupOptionButton;
|
||||
}
|
||||
this._difficultyButtons = groupOptionButtonArray;
|
||||
}
|
||||
|
||||
private void AddWorldEvilOptions(
|
||||
UIElement container,
|
||||
float accumualtedHeight,
|
||||
UIElement.MouseEvent clickEvent,
|
||||
string tagGroup,
|
||||
float usableWidthPercent)
|
||||
{
|
||||
UIWorldCreation.WorldEvilId[] worldEvilIdArray = new UIWorldCreation.WorldEvilId[3]
|
||||
{
|
||||
UIWorldCreation.WorldEvilId.Random,
|
||||
UIWorldCreation.WorldEvilId.Corruption,
|
||||
UIWorldCreation.WorldEvilId.Crimson
|
||||
};
|
||||
LocalizedText[] localizedTextArray1 = new LocalizedText[3]
|
||||
{
|
||||
Lang.misc[103],
|
||||
Lang.misc[101],
|
||||
Lang.misc[102]
|
||||
};
|
||||
LocalizedText[] localizedTextArray2 = new LocalizedText[3]
|
||||
{
|
||||
Language.GetText("UI.WorldDescriptionEvilRandom"),
|
||||
Language.GetText("UI.WorldDescriptionEvilCorrupt"),
|
||||
Language.GetText("UI.WorldDescriptionEvilCrimson")
|
||||
};
|
||||
Color[] colorArray = new Color[3]
|
||||
{
|
||||
Color.White,
|
||||
Color.MediumPurple,
|
||||
Color.IndianRed
|
||||
};
|
||||
string[] strArray = new string[3]
|
||||
{
|
||||
"Images/UI/WorldCreation/IconEvilRandom",
|
||||
"Images/UI/WorldCreation/IconEvilCorruption",
|
||||
"Images/UI/WorldCreation/IconEvilCrimson"
|
||||
};
|
||||
GroupOptionButton<UIWorldCreation.WorldEvilId>[] groupOptionButtonArray = new GroupOptionButton<UIWorldCreation.WorldEvilId>[worldEvilIdArray.Length];
|
||||
for (int id = 0; id < groupOptionButtonArray.Length; ++id)
|
||||
{
|
||||
GroupOptionButton<UIWorldCreation.WorldEvilId> groupOptionButton = new GroupOptionButton<UIWorldCreation.WorldEvilId>(worldEvilIdArray[id], localizedTextArray1[id], localizedTextArray2[id], colorArray[id], strArray[id], titleAlignmentX: 1f, titleWidthReduction: 16f);
|
||||
groupOptionButton.Width = StyleDimension.FromPixelsAndPercent((float) (-4 * (groupOptionButtonArray.Length - 1)), 1f / (float) groupOptionButtonArray.Length * usableWidthPercent);
|
||||
groupOptionButton.Left = StyleDimension.FromPercent(1f - usableWidthPercent);
|
||||
groupOptionButton.HAlign = (float) id / (float) (groupOptionButtonArray.Length - 1);
|
||||
groupOptionButton.Top.Set(accumualtedHeight, 0.0f);
|
||||
groupOptionButton.OnMouseDown += clickEvent;
|
||||
groupOptionButton.OnMouseOver += new UIElement.MouseEvent(this.ShowOptionDescription);
|
||||
groupOptionButton.OnMouseOut += new UIElement.MouseEvent(this.ClearOptionDescription);
|
||||
groupOptionButton.SetSnapPoint(tagGroup, id);
|
||||
container.Append((UIElement) groupOptionButton);
|
||||
groupOptionButtonArray[id] = groupOptionButton;
|
||||
}
|
||||
this._evilButtons = groupOptionButtonArray;
|
||||
}
|
||||
|
||||
private void ClickRandomizeName(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
this.AssignRandomWorldName();
|
||||
this.UpdateInputFields();
|
||||
this.UpdateSliders();
|
||||
this.UpdatePreviewPlate();
|
||||
}
|
||||
|
||||
private void ClickRandomizeSeed(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
this.AssignRandomWorldSeed();
|
||||
this.UpdateInputFields();
|
||||
this.UpdateSliders();
|
||||
this.UpdatePreviewPlate();
|
||||
}
|
||||
|
||||
private void ClickSizeOption(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
GroupOptionButton<UIWorldCreation.WorldSizeId> groupOptionButton = (GroupOptionButton<UIWorldCreation.WorldSizeId>) listeningElement;
|
||||
this._optionSize = groupOptionButton.OptionValue;
|
||||
foreach (GroupOptionButton<UIWorldCreation.WorldSizeId> sizeButton in this._sizeButtons)
|
||||
sizeButton.SetCurrentOption(groupOptionButton.OptionValue);
|
||||
this.UpdatePreviewPlate();
|
||||
}
|
||||
|
||||
private void ClickDifficultyOption(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
GroupOptionButton<UIWorldCreation.WorldDifficultyId> groupOptionButton = (GroupOptionButton<UIWorldCreation.WorldDifficultyId>) listeningElement;
|
||||
this._optionDifficulty = groupOptionButton.OptionValue;
|
||||
foreach (GroupOptionButton<UIWorldCreation.WorldDifficultyId> difficultyButton in this._difficultyButtons)
|
||||
difficultyButton.SetCurrentOption(groupOptionButton.OptionValue);
|
||||
this.UpdatePreviewPlate();
|
||||
}
|
||||
|
||||
private void ClickEvilOption(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
GroupOptionButton<UIWorldCreation.WorldEvilId> groupOptionButton = (GroupOptionButton<UIWorldCreation.WorldEvilId>) listeningElement;
|
||||
this._optionEvil = groupOptionButton.OptionValue;
|
||||
foreach (GroupOptionButton<UIWorldCreation.WorldEvilId> evilButton in this._evilButtons)
|
||||
evilButton.SetCurrentOption(groupOptionButton.OptionValue);
|
||||
this.UpdatePreviewPlate();
|
||||
}
|
||||
|
||||
private void UpdatePreviewPlate() => this._previewPlate.UpdateOption((byte) this._optionDifficulty, (byte) this._optionEvil, (byte) this._optionSize);
|
||||
|
||||
private void UpdateSliders()
|
||||
{
|
||||
foreach (GroupOptionButton<UIWorldCreation.WorldSizeId> sizeButton in this._sizeButtons)
|
||||
sizeButton.SetCurrentOption(this._optionSize);
|
||||
foreach (GroupOptionButton<UIWorldCreation.WorldDifficultyId> difficultyButton in this._difficultyButtons)
|
||||
difficultyButton.SetCurrentOption(this._optionDifficulty);
|
||||
foreach (GroupOptionButton<UIWorldCreation.WorldEvilId> evilButton in this._evilButtons)
|
||||
evilButton.SetCurrentOption(this._optionEvil);
|
||||
}
|
||||
|
||||
public void ShowOptionDescription(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
LocalizedText text = (LocalizedText) null;
|
||||
if (listeningElement is GroupOptionButton<UIWorldCreation.WorldSizeId> groupOptionButton1)
|
||||
text = groupOptionButton1.Description;
|
||||
if (listeningElement is GroupOptionButton<UIWorldCreation.WorldDifficultyId> groupOptionButton2)
|
||||
text = groupOptionButton2.Description;
|
||||
if (listeningElement is GroupOptionButton<UIWorldCreation.WorldEvilId> groupOptionButton3)
|
||||
text = groupOptionButton3.Description;
|
||||
if (listeningElement is UICharacterNameButton characterNameButton)
|
||||
text = characterNameButton.Description;
|
||||
if (listeningElement is GroupOptionButton<bool> groupOptionButton4)
|
||||
text = groupOptionButton4.Description;
|
||||
if (text == null)
|
||||
return;
|
||||
this._descriptionText.SetText(text);
|
||||
}
|
||||
|
||||
public void ClearOptionDescription(UIMouseEvent evt, UIElement listeningElement) => this._descriptionText.SetText(Language.GetText("UI.WorldDescriptionDefault"));
|
||||
|
||||
private void MakeBackAndCreatebuttons(UIElement outerContainer)
|
||||
{
|
||||
UITextPanel<LocalizedText> uiTextPanel1 = new UITextPanel<LocalizedText>(Language.GetText("UI.Back"), 0.7f, true);
|
||||
uiTextPanel1.Width = StyleDimension.FromPixelsAndPercent(-10f, 0.5f);
|
||||
uiTextPanel1.Height = StyleDimension.FromPixels(50f);
|
||||
uiTextPanel1.VAlign = 1f;
|
||||
uiTextPanel1.HAlign = 0.0f;
|
||||
uiTextPanel1.Top = StyleDimension.FromPixels(-45f);
|
||||
UITextPanel<LocalizedText> uiTextPanel2 = uiTextPanel1;
|
||||
uiTextPanel2.OnMouseOver += new UIElement.MouseEvent(this.FadedMouseOver);
|
||||
uiTextPanel2.OnMouseOut += new UIElement.MouseEvent(this.FadedMouseOut);
|
||||
uiTextPanel2.OnMouseDown += new UIElement.MouseEvent(this.Click_GoBack);
|
||||
uiTextPanel2.SetSnapPoint("Back", 0);
|
||||
outerContainer.Append((UIElement) uiTextPanel2);
|
||||
UITextPanel<LocalizedText> uiTextPanel3 = new UITextPanel<LocalizedText>(Language.GetText("UI.Create"), 0.7f, true);
|
||||
uiTextPanel3.Width = StyleDimension.FromPixelsAndPercent(-10f, 0.5f);
|
||||
uiTextPanel3.Height = StyleDimension.FromPixels(50f);
|
||||
uiTextPanel3.VAlign = 1f;
|
||||
uiTextPanel3.HAlign = 1f;
|
||||
uiTextPanel3.Top = StyleDimension.FromPixels(-45f);
|
||||
UITextPanel<LocalizedText> uiTextPanel4 = uiTextPanel3;
|
||||
uiTextPanel4.OnMouseOver += new UIElement.MouseEvent(this.FadedMouseOver);
|
||||
uiTextPanel4.OnMouseOut += new UIElement.MouseEvent(this.FadedMouseOut);
|
||||
uiTextPanel4.OnMouseDown += new UIElement.MouseEvent(this.Click_NamingAndCreating);
|
||||
uiTextPanel4.SetSnapPoint("Create", 0);
|
||||
outerContainer.Append((UIElement) uiTextPanel4);
|
||||
}
|
||||
|
||||
private void Click_GoBack(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
SoundEngine.PlaySound(11);
|
||||
Main.OpenWorldSelectUI();
|
||||
}
|
||||
|
||||
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 Click_SetName(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
SoundEngine.PlaySound(10);
|
||||
Main.clrInput();
|
||||
UIVirtualKeyboard uiVirtualKeyboard = new UIVirtualKeyboard(Lang.menu[48].Value, "", new UIVirtualKeyboard.KeyboardSubmitEvent(this.OnFinishedSettingName), new Action(this.GoBackHere), allowEmpty: true);
|
||||
uiVirtualKeyboard.SetMaxInputLength(27);
|
||||
Main.MenuUI.SetState((UIState) uiVirtualKeyboard);
|
||||
}
|
||||
|
||||
private void Click_SetSeed(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
SoundEngine.PlaySound(10);
|
||||
Main.clrInput();
|
||||
UIVirtualKeyboard uiVirtualKeyboard = new UIVirtualKeyboard(Language.GetTextValue("UI.EnterSeed"), "", new UIVirtualKeyboard.KeyboardSubmitEvent(this.OnFinishedSettingSeed), new Action(this.GoBackHere), allowEmpty: true);
|
||||
uiVirtualKeyboard.SetMaxInputLength(40);
|
||||
Main.MenuUI.SetState((UIState) uiVirtualKeyboard);
|
||||
}
|
||||
|
||||
private void Click_NamingAndCreating(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
SoundEngine.PlaySound(10);
|
||||
if (string.IsNullOrEmpty(this._optionwWorldName))
|
||||
{
|
||||
this._optionwWorldName = "";
|
||||
Main.clrInput();
|
||||
UIVirtualKeyboard uiVirtualKeyboard = new UIVirtualKeyboard(Lang.menu[48].Value, "", new UIVirtualKeyboard.KeyboardSubmitEvent(this.OnFinishedNamingAndCreating), new Action(this.GoBackHere));
|
||||
uiVirtualKeyboard.SetMaxInputLength(27);
|
||||
Main.MenuUI.SetState((UIState) uiVirtualKeyboard);
|
||||
}
|
||||
else
|
||||
this.FinishCreatingWorld();
|
||||
}
|
||||
|
||||
private void OnFinishedSettingName(string name)
|
||||
{
|
||||
this._optionwWorldName = name.Trim();
|
||||
this.UpdateInputFields();
|
||||
this.GoBackHere();
|
||||
}
|
||||
|
||||
private void UpdateInputFields()
|
||||
{
|
||||
this._namePlate.SetContents(this._optionwWorldName);
|
||||
this._namePlate.TrimDisplayIfOverElementDimensions(27);
|
||||
this._namePlate.Recalculate();
|
||||
this._seedPlate.SetContents(this._optionSeed);
|
||||
this._seedPlate.TrimDisplayIfOverElementDimensions(40);
|
||||
this._seedPlate.Recalculate();
|
||||
}
|
||||
|
||||
private void OnFinishedSettingSeed(string seed)
|
||||
{
|
||||
this._optionSeed = seed.Trim();
|
||||
string processedSeed;
|
||||
this.ProcessSeed(out processedSeed);
|
||||
this._optionSeed = processedSeed;
|
||||
this.UpdateInputFields();
|
||||
this.UpdateSliders();
|
||||
this.UpdatePreviewPlate();
|
||||
this.GoBackHere();
|
||||
}
|
||||
|
||||
private void GoBackHere() => Main.MenuUI.SetState((UIState) this);
|
||||
|
||||
private void OnFinishedNamingAndCreating(string name)
|
||||
{
|
||||
this.OnFinishedSettingName(name);
|
||||
this.FinishCreatingWorld();
|
||||
}
|
||||
|
||||
private void FinishCreatingWorld()
|
||||
{
|
||||
string processedSeed;
|
||||
this.ProcessSeed(out processedSeed);
|
||||
switch (this._optionSize)
|
||||
{
|
||||
case UIWorldCreation.WorldSizeId.Small:
|
||||
Main.maxTilesX = 4200;
|
||||
Main.maxTilesY = 1200;
|
||||
break;
|
||||
case UIWorldCreation.WorldSizeId.Medium:
|
||||
Main.maxTilesX = 6400;
|
||||
Main.maxTilesY = 1800;
|
||||
break;
|
||||
case UIWorldCreation.WorldSizeId.Large:
|
||||
Main.maxTilesX = 8400;
|
||||
Main.maxTilesY = 2400;
|
||||
break;
|
||||
}
|
||||
WorldGen.setWorldSize();
|
||||
switch (this._optionDifficulty)
|
||||
{
|
||||
case UIWorldCreation.WorldDifficultyId.Normal:
|
||||
Main.GameMode = 0;
|
||||
break;
|
||||
case UIWorldCreation.WorldDifficultyId.Expert:
|
||||
Main.GameMode = 1;
|
||||
break;
|
||||
case UIWorldCreation.WorldDifficultyId.Master:
|
||||
Main.GameMode = 2;
|
||||
break;
|
||||
case UIWorldCreation.WorldDifficultyId.Creative:
|
||||
Main.GameMode = 3;
|
||||
break;
|
||||
}
|
||||
switch (this._optionEvil)
|
||||
{
|
||||
case UIWorldCreation.WorldEvilId.Random:
|
||||
WorldGen.WorldGenParam_Evil = -1;
|
||||
break;
|
||||
case UIWorldCreation.WorldEvilId.Corruption:
|
||||
WorldGen.WorldGenParam_Evil = 0;
|
||||
break;
|
||||
case UIWorldCreation.WorldEvilId.Crimson:
|
||||
WorldGen.WorldGenParam_Evil = 1;
|
||||
break;
|
||||
}
|
||||
Main.ActiveWorldFileData = WorldFile.CreateMetadata(Main.worldName = this._optionwWorldName.Trim(), SocialAPI.Cloud != null && SocialAPI.Cloud.EnabledByDefault, Main.GameMode);
|
||||
if (processedSeed.Length == 0)
|
||||
Main.ActiveWorldFileData.SetSeedToRandom();
|
||||
else
|
||||
Main.ActiveWorldFileData.SetSeed(processedSeed);
|
||||
Main.menuMode = 10;
|
||||
WorldGen.CreateNewWorld();
|
||||
}
|
||||
|
||||
private void ProcessSeed(out string processedSeed)
|
||||
{
|
||||
processedSeed = this._optionSeed;
|
||||
WorldGen.notTheBees = processedSeed.ToLower() == "not the bees" || processedSeed.ToLower() == "not the bees!";
|
||||
WorldGen.getGoodWorldGen = processedSeed.ToLower() == "for the worthy";
|
||||
string[] strArray = this._optionSeed.Split('.');
|
||||
if (strArray.Length != 4)
|
||||
return;
|
||||
int result;
|
||||
if (int.TryParse(strArray[0], out result))
|
||||
{
|
||||
switch (result)
|
||||
{
|
||||
case 1:
|
||||
this._optionSize = UIWorldCreation.WorldSizeId.Small;
|
||||
break;
|
||||
case 2:
|
||||
this._optionSize = UIWorldCreation.WorldSizeId.Medium;
|
||||
break;
|
||||
case 3:
|
||||
this._optionSize = UIWorldCreation.WorldSizeId.Large;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (int.TryParse(strArray[1], out result))
|
||||
{
|
||||
switch (result)
|
||||
{
|
||||
case 1:
|
||||
this._optionDifficulty = UIWorldCreation.WorldDifficultyId.Normal;
|
||||
break;
|
||||
case 2:
|
||||
this._optionDifficulty = UIWorldCreation.WorldDifficultyId.Expert;
|
||||
break;
|
||||
case 3:
|
||||
this._optionDifficulty = UIWorldCreation.WorldDifficultyId.Master;
|
||||
break;
|
||||
case 4:
|
||||
this._optionDifficulty = UIWorldCreation.WorldDifficultyId.Creative;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (int.TryParse(strArray[2], out result))
|
||||
{
|
||||
switch (result)
|
||||
{
|
||||
case 1:
|
||||
this._optionEvil = UIWorldCreation.WorldEvilId.Corruption;
|
||||
break;
|
||||
case 2:
|
||||
this._optionEvil = UIWorldCreation.WorldEvilId.Crimson;
|
||||
break;
|
||||
}
|
||||
}
|
||||
processedSeed = strArray[3];
|
||||
}
|
||||
|
||||
private void AssignRandomWorldName()
|
||||
{
|
||||
do
|
||||
{
|
||||
LocalizedText localizedText = Language.SelectRandom(Lang.CreateDialogFilter("RandomWorldName_Composition."));
|
||||
var data = new
|
||||
{
|
||||
Adjective = Language.SelectRandom(Lang.CreateDialogFilter("RandomWorldName_Adjective.")).Value,
|
||||
Location = Language.SelectRandom(Lang.CreateDialogFilter("RandomWorldName_Location.")).Value,
|
||||
Noun = Language.SelectRandom(Lang.CreateDialogFilter("RandomWorldName_Noun.")).Value
|
||||
};
|
||||
this._optionwWorldName = localizedText.FormatWith((object) data);
|
||||
}
|
||||
while (this._optionwWorldName.Length > 27);
|
||||
}
|
||||
|
||||
private void AssignRandomWorldSeed() => this._optionSeed = Main.rand.Next().ToString();
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
base.Draw(spriteBatch);
|
||||
this.SetupGamepadPoints(spriteBatch);
|
||||
}
|
||||
|
||||
private void SetupGamepadPoints(SpriteBatch spriteBatch)
|
||||
{
|
||||
UILinkPointNavigator.Shortcuts.BackButtonCommand = 1;
|
||||
int num1 = 3000;
|
||||
List<SnapPoint> snapPoints = this.GetSnapPoints();
|
||||
SnapPoint snapPoint1 = (SnapPoint) null;
|
||||
SnapPoint snapPoint2 = (SnapPoint) null;
|
||||
SnapPoint snapPoint3 = (SnapPoint) null;
|
||||
SnapPoint snapPoint4 = (SnapPoint) null;
|
||||
SnapPoint snapPoint5 = (SnapPoint) null;
|
||||
SnapPoint snapPoint6 = (SnapPoint) null;
|
||||
for (int index = 0; index < snapPoints.Count; ++index)
|
||||
{
|
||||
SnapPoint snapPoint7 = snapPoints[index];
|
||||
string name = snapPoint7.Name;
|
||||
if (!(name == "Back"))
|
||||
{
|
||||
if (!(name == "Create"))
|
||||
{
|
||||
if (!(name == "Name"))
|
||||
{
|
||||
if (!(name == "Seed"))
|
||||
{
|
||||
if (!(name == "RandomizeName"))
|
||||
{
|
||||
if (name == "RandomizeSeed")
|
||||
snapPoint6 = snapPoint7;
|
||||
}
|
||||
else
|
||||
snapPoint5 = snapPoint7;
|
||||
}
|
||||
else
|
||||
snapPoint4 = snapPoint7;
|
||||
}
|
||||
else
|
||||
snapPoint3 = snapPoint7;
|
||||
}
|
||||
else
|
||||
snapPoint2 = snapPoint7;
|
||||
}
|
||||
else
|
||||
snapPoint1 = snapPoint7;
|
||||
}
|
||||
List<SnapPoint> snapGroup1 = this.GetSnapGroup(snapPoints, "size");
|
||||
List<SnapPoint> snapGroup2 = this.GetSnapGroup(snapPoints, "difficulty");
|
||||
List<SnapPoint> snapGroup3 = this.GetSnapGroup(snapPoints, "evil");
|
||||
UILinkPointNavigator.SetPosition(num1, snapPoint1.Position);
|
||||
UILinkPoint point1 = UILinkPointNavigator.Points[num1];
|
||||
point1.Unlink();
|
||||
UILinkPoint uiLinkPoint1 = point1;
|
||||
int num2 = num1 + 1;
|
||||
UILinkPointNavigator.SetPosition(num2, snapPoint2.Position);
|
||||
UILinkPoint point2 = UILinkPointNavigator.Points[num2];
|
||||
point2.Unlink();
|
||||
UILinkPoint uiLinkPoint2 = point2;
|
||||
int num3 = num2 + 1;
|
||||
UILinkPointNavigator.SetPosition(num3, snapPoint5.Position);
|
||||
UILinkPoint point3 = UILinkPointNavigator.Points[num3];
|
||||
point3.Unlink();
|
||||
UILinkPoint uiLinkPoint3 = point3;
|
||||
int num4 = num3 + 1;
|
||||
UILinkPointNavigator.SetPosition(num4, snapPoint3.Position);
|
||||
UILinkPoint point4 = UILinkPointNavigator.Points[num4];
|
||||
point4.Unlink();
|
||||
UILinkPoint uiLinkPoint4 = point4;
|
||||
int num5 = num4 + 1;
|
||||
UILinkPointNavigator.SetPosition(num5, snapPoint6.Position);
|
||||
UILinkPoint point5 = UILinkPointNavigator.Points[num5];
|
||||
point5.Unlink();
|
||||
UILinkPoint uiLinkPoint5 = point5;
|
||||
int num6 = num5 + 1;
|
||||
UILinkPointNavigator.SetPosition(num6, snapPoint4.Position);
|
||||
UILinkPoint point6 = UILinkPointNavigator.Points[num6];
|
||||
point6.Unlink();
|
||||
UILinkPoint uiLinkPoint6 = point6;
|
||||
int num7 = num6 + 1;
|
||||
UILinkPoint[] uiLinkPointArray1 = new UILinkPoint[snapGroup1.Count];
|
||||
for (int index = 0; index < snapGroup1.Count; ++index)
|
||||
{
|
||||
UILinkPointNavigator.SetPosition(num7, snapGroup1[index].Position);
|
||||
UILinkPoint point7 = UILinkPointNavigator.Points[num7];
|
||||
point7.Unlink();
|
||||
uiLinkPointArray1[index] = point7;
|
||||
++num7;
|
||||
}
|
||||
UILinkPoint[] uiLinkPointArray2 = new UILinkPoint[snapGroup2.Count];
|
||||
for (int index = 0; index < snapGroup2.Count; ++index)
|
||||
{
|
||||
UILinkPointNavigator.SetPosition(num7, snapGroup2[index].Position);
|
||||
UILinkPoint point8 = UILinkPointNavigator.Points[num7];
|
||||
point8.Unlink();
|
||||
uiLinkPointArray2[index] = point8;
|
||||
++num7;
|
||||
}
|
||||
UILinkPoint[] uiLinkPointArray3 = new UILinkPoint[snapGroup3.Count];
|
||||
for (int index = 0; index < snapGroup3.Count; ++index)
|
||||
{
|
||||
UILinkPointNavigator.SetPosition(num7, snapGroup3[index].Position);
|
||||
UILinkPoint point9 = UILinkPointNavigator.Points[num7];
|
||||
point9.Unlink();
|
||||
uiLinkPointArray3[index] = point9;
|
||||
++num7;
|
||||
}
|
||||
this.LoopHorizontalLineLinks(uiLinkPointArray1);
|
||||
this.LoopHorizontalLineLinks(uiLinkPointArray2);
|
||||
this.EstablishUpDownRelationship(uiLinkPointArray1, uiLinkPointArray2);
|
||||
for (int index = 0; index < uiLinkPointArray1.Length; ++index)
|
||||
uiLinkPointArray1[index].Up = uiLinkPoint6.ID;
|
||||
if (true)
|
||||
{
|
||||
this.LoopHorizontalLineLinks(uiLinkPointArray3);
|
||||
this.EstablishUpDownRelationship(uiLinkPointArray2, uiLinkPointArray3);
|
||||
for (int index = 0; index < uiLinkPointArray3.Length; ++index)
|
||||
uiLinkPointArray3[index].Down = uiLinkPoint1.ID;
|
||||
uiLinkPointArray3[uiLinkPointArray3.Length - 1].Down = uiLinkPoint2.ID;
|
||||
uiLinkPoint2.Up = uiLinkPointArray3[uiLinkPointArray3.Length - 1].ID;
|
||||
uiLinkPoint1.Up = uiLinkPointArray3[0].ID;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int index = 0; index < uiLinkPointArray2.Length; ++index)
|
||||
uiLinkPointArray2[index].Down = uiLinkPoint1.ID;
|
||||
uiLinkPointArray2[uiLinkPointArray2.Length - 1].Down = uiLinkPoint2.ID;
|
||||
uiLinkPoint2.Up = uiLinkPointArray2[uiLinkPointArray2.Length - 1].ID;
|
||||
uiLinkPoint1.Up = uiLinkPointArray2[0].ID;
|
||||
}
|
||||
uiLinkPoint2.Left = uiLinkPoint1.ID;
|
||||
uiLinkPoint1.Right = uiLinkPoint2.ID;
|
||||
uiLinkPoint4.Down = uiLinkPoint6.ID;
|
||||
uiLinkPoint4.Left = uiLinkPoint3.ID;
|
||||
uiLinkPoint3.Right = uiLinkPoint4.ID;
|
||||
uiLinkPoint6.Up = uiLinkPoint4.ID;
|
||||
uiLinkPoint6.Down = uiLinkPointArray1[0].ID;
|
||||
uiLinkPoint6.Left = uiLinkPoint5.ID;
|
||||
uiLinkPoint5.Right = uiLinkPoint6.ID;
|
||||
uiLinkPoint5.Up = uiLinkPoint3.ID;
|
||||
uiLinkPoint5.Down = uiLinkPointArray1[0].ID;
|
||||
uiLinkPoint3.Down = uiLinkPoint5.ID;
|
||||
}
|
||||
|
||||
private void EstablishUpDownRelationship(UILinkPoint[] topSide, UILinkPoint[] bottomSide)
|
||||
{
|
||||
int num = Math.Max(topSide.Length, bottomSide.Length);
|
||||
for (int val1 = 0; val1 < num; ++val1)
|
||||
{
|
||||
int index1 = Math.Min(val1, topSide.Length - 1);
|
||||
int index2 = Math.Min(val1, bottomSide.Length - 1);
|
||||
topSide[index1].Down = bottomSide[index2].ID;
|
||||
bottomSide[index2].Up = topSide[index1].ID;
|
||||
}
|
||||
}
|
||||
|
||||
private void LoopHorizontalLineLinks(UILinkPoint[] pointsLine)
|
||||
{
|
||||
for (int index = 1; index < pointsLine.Length - 1; ++index)
|
||||
{
|
||||
pointsLine[index - 1].Right = pointsLine[index].ID;
|
||||
pointsLine[index].Left = pointsLine[index - 1].ID;
|
||||
pointsLine[index].Right = pointsLine[index + 1].ID;
|
||||
pointsLine[index + 1].Left = pointsLine[index].ID;
|
||||
}
|
||||
}
|
||||
|
||||
private List<SnapPoint> GetSnapGroup(List<SnapPoint> ptsOnPage, string groupName)
|
||||
{
|
||||
List<SnapPoint> list = ptsOnPage.Where<SnapPoint>((Func<SnapPoint, bool>) (a => a.Name == groupName)).ToList<SnapPoint>();
|
||||
list.Sort(new Comparison<SnapPoint>(this.SortPoints));
|
||||
return list;
|
||||
}
|
||||
|
||||
private int SortPoints(SnapPoint a, SnapPoint b) => a.Id.CompareTo(b.Id);
|
||||
|
||||
private enum WorldSizeId
|
||||
{
|
||||
Small,
|
||||
Medium,
|
||||
Large,
|
||||
}
|
||||
|
||||
private enum WorldDifficultyId
|
||||
{
|
||||
Normal,
|
||||
Expert,
|
||||
Master,
|
||||
Creative,
|
||||
}
|
||||
|
||||
private enum WorldEvilId
|
||||
{
|
||||
Random,
|
||||
Corruption,
|
||||
Crimson,
|
||||
}
|
||||
}
|
||||
}
|
108
GameContent/UI/States/UIWorldLoad.cs
Normal file
108
GameContent/UI/States/UIWorldLoad.cs
Normal file
|
@ -0,0 +1,108 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.States.UIWorldLoad
|
||||
// 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.GameContent.UI.Elements;
|
||||
using Terraria.GameInput;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI;
|
||||
using Terraria.UI.Gamepad;
|
||||
using Terraria.WorldBuilding;
|
||||
|
||||
namespace Terraria.GameContent.UI.States
|
||||
{
|
||||
public class UIWorldLoad : UIState
|
||||
{
|
||||
private UIGenProgressBar _progressBar = new UIGenProgressBar();
|
||||
private UIHeader _progressMessage = new UIHeader();
|
||||
private GenerationProgress _progress;
|
||||
|
||||
public UIWorldLoad()
|
||||
{
|
||||
this._progressBar.Top.Pixels = 270f;
|
||||
this._progressBar.HAlign = 0.5f;
|
||||
this._progressBar.VAlign = 0.0f;
|
||||
this._progressBar.Recalculate();
|
||||
this._progressMessage.CopyStyle((UIElement) this._progressBar);
|
||||
this._progressMessage.Top.Pixels -= 70f;
|
||||
this._progressMessage.Recalculate();
|
||||
this.Append((UIElement) this._progressBar);
|
||||
this.Append((UIElement) this._progressMessage);
|
||||
}
|
||||
|
||||
public override void OnActivate()
|
||||
{
|
||||
if (!PlayerInput.UsingGamepadUI)
|
||||
return;
|
||||
UILinkPointNavigator.Points[3000].Unlink();
|
||||
UILinkPointNavigator.ChangePoint(3000);
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
this._progressBar.Top.Pixels = MathHelper.Lerp(270f, 370f, Utils.GetLerpValue(600f, 700f, (float) Main.screenHeight, true));
|
||||
this._progressMessage.Top.Pixels = this._progressBar.Top.Pixels - 70f;
|
||||
this._progressBar.Recalculate();
|
||||
this._progressMessage.Recalculate();
|
||||
base.Update(gameTime);
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
this._progress = WorldGenerator.CurrentGenerationProgress;
|
||||
if (this._progress == null)
|
||||
return;
|
||||
base.Draw(spriteBatch);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
float overallProgress = 0.0f;
|
||||
float currentProgress = 0.0f;
|
||||
string str1 = string.Empty;
|
||||
if (this._progress != null)
|
||||
{
|
||||
overallProgress = this._progress.TotalProgress;
|
||||
currentProgress = this._progress.Value;
|
||||
str1 = this._progress.Message;
|
||||
}
|
||||
this._progressBar.SetProgress(overallProgress, currentProgress);
|
||||
this._progressMessage.Text = str1;
|
||||
if (WorldGen.drunkWorldGenText && !WorldGen.placingTraps)
|
||||
{
|
||||
this._progressMessage.Text = string.Concat((object) Main.rand.Next(999999999));
|
||||
for (int index = 0; index < 3; ++index)
|
||||
{
|
||||
if (Main.rand.Next(2) == 0)
|
||||
this._progressMessage.Text += (string) (object) Main.rand.Next(999999999);
|
||||
}
|
||||
}
|
||||
if (WorldGen.notTheBees)
|
||||
this._progressMessage.Text = Language.GetTextValue("UI.WorldGenEasterEgg_GeneratingBees");
|
||||
if (WorldGen.getGoodWorldGen)
|
||||
{
|
||||
string str2 = "";
|
||||
for (int startIndex = this._progressMessage.Text.Length - 1; startIndex >= 0; --startIndex)
|
||||
str2 += this._progressMessage.Text.Substring(startIndex, 1);
|
||||
this._progressMessage.Text = str2;
|
||||
}
|
||||
Main.gameTips.Update();
|
||||
Main.gameTips.Draw();
|
||||
this.UpdateGamepadSquiggle();
|
||||
}
|
||||
|
||||
private void UpdateGamepadSquiggle()
|
||||
{
|
||||
Vector2 vector2 = new Vector2((float) Math.Cos((double) Main.GlobalTimeWrappedHourly * 6.28318548202515), (float) Math.Sin((double) Main.GlobalTimeWrappedHourly * 6.28318548202515 * 2.0)) * new Vector2(30f, 15f) + Vector2.UnitY * 20f;
|
||||
UILinkPointNavigator.Points[3000].Unlink();
|
||||
UILinkPointNavigator.SetPosition(3000, new Vector2((float) Main.screenWidth, (float) Main.screenHeight) / 2f + vector2);
|
||||
}
|
||||
|
||||
public string GetStatusText() => this._progress == null ? string.Format("{0:0.0%} - ... - {1:0.0%}", (object) 0, (object) 0) : string.Format("{0:0.0%} - " + this._progress.Message + " - {1:0.0%}", (object) this._progress.TotalProgress, (object) this._progress.Value);
|
||||
}
|
||||
}
|
283
GameContent/UI/States/UIWorldSelect.cs
Normal file
283
GameContent/UI/States/UIWorldSelect.cs
Normal file
|
@ -0,0 +1,283 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.States.UIWorldSelect
|
||||
// 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 System.Linq;
|
||||
using Terraria.Audio;
|
||||
using Terraria.GameContent.UI.Elements;
|
||||
using Terraria.GameInput;
|
||||
using Terraria.ID;
|
||||
using Terraria.IO;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI;
|
||||
using Terraria.UI.Gamepad;
|
||||
|
||||
namespace Terraria.GameContent.UI.States
|
||||
{
|
||||
public class UIWorldSelect : UIState
|
||||
{
|
||||
private UIList _worldList;
|
||||
private UITextPanel<LocalizedText> _backPanel;
|
||||
private UITextPanel<LocalizedText> _newPanel;
|
||||
private UIPanel _containerPanel;
|
||||
private UIScrollbar _scrollbar;
|
||||
private bool _isScrollbarAttached;
|
||||
private List<Tuple<string, bool>> favoritesCache = new List<Tuple<string, bool>>();
|
||||
private bool skipDraw;
|
||||
|
||||
public override void OnInitialize()
|
||||
{
|
||||
UIElement element = new UIElement();
|
||||
element.Width.Set(0.0f, 0.8f);
|
||||
element.MaxWidth.Set(650f, 0.0f);
|
||||
element.Top.Set(220f, 0.0f);
|
||||
element.Height.Set(-220f, 1f);
|
||||
element.HAlign = 0.5f;
|
||||
UIPanel uiPanel = new UIPanel();
|
||||
uiPanel.Width.Set(0.0f, 1f);
|
||||
uiPanel.Height.Set(-110f, 1f);
|
||||
uiPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f;
|
||||
element.Append((UIElement) uiPanel);
|
||||
this._containerPanel = uiPanel;
|
||||
this._worldList = new UIList();
|
||||
this._worldList.Width.Set(0.0f, 1f);
|
||||
this._worldList.Height.Set(0.0f, 1f);
|
||||
this._worldList.ListPadding = 5f;
|
||||
uiPanel.Append((UIElement) this._worldList);
|
||||
this._scrollbar = new UIScrollbar();
|
||||
this._scrollbar.SetView(100f, 1000f);
|
||||
this._scrollbar.Height.Set(0.0f, 1f);
|
||||
this._scrollbar.HAlign = 1f;
|
||||
this._worldList.SetScrollbar(this._scrollbar);
|
||||
UITextPanel<LocalizedText> uiTextPanel1 = new UITextPanel<LocalizedText>(Language.GetText("UI.SelectWorld"), 0.8f, true);
|
||||
uiTextPanel1.HAlign = 0.5f;
|
||||
uiTextPanel1.Top.Set(-40f, 0.0f);
|
||||
uiTextPanel1.SetPadding(15f);
|
||||
uiTextPanel1.BackgroundColor = new Color(73, 94, 171);
|
||||
element.Append((UIElement) uiTextPanel1);
|
||||
UITextPanel<LocalizedText> uiTextPanel2 = new UITextPanel<LocalizedText>(Language.GetText("UI.Back"), 0.7f, true);
|
||||
uiTextPanel2.Width.Set(-10f, 0.5f);
|
||||
uiTextPanel2.Height.Set(50f, 0.0f);
|
||||
uiTextPanel2.VAlign = 1f;
|
||||
uiTextPanel2.Top.Set(-45f, 0.0f);
|
||||
uiTextPanel2.OnMouseOver += new UIElement.MouseEvent(this.FadedMouseOver);
|
||||
uiTextPanel2.OnMouseOut += new UIElement.MouseEvent(this.FadedMouseOut);
|
||||
uiTextPanel2.OnClick += new UIElement.MouseEvent(this.GoBackClick);
|
||||
element.Append((UIElement) uiTextPanel2);
|
||||
this._backPanel = uiTextPanel2;
|
||||
UITextPanel<LocalizedText> uiTextPanel3 = new UITextPanel<LocalizedText>(Language.GetText("UI.New"), 0.7f, true);
|
||||
uiTextPanel3.CopyStyle((UIElement) uiTextPanel2);
|
||||
uiTextPanel3.HAlign = 1f;
|
||||
uiTextPanel3.OnMouseOver += new UIElement.MouseEvent(this.FadedMouseOver);
|
||||
uiTextPanel3.OnMouseOut += new UIElement.MouseEvent(this.FadedMouseOut);
|
||||
uiTextPanel3.OnClick += new UIElement.MouseEvent(this.NewWorldClick);
|
||||
element.Append((UIElement) uiTextPanel3);
|
||||
this._newPanel = uiTextPanel3;
|
||||
this.Append(element);
|
||||
}
|
||||
|
||||
public override void Recalculate()
|
||||
{
|
||||
if (this._scrollbar != null)
|
||||
{
|
||||
if (this._isScrollbarAttached && !this._scrollbar.CanScroll)
|
||||
{
|
||||
this._containerPanel.RemoveChild((UIElement) this._scrollbar);
|
||||
this._isScrollbarAttached = false;
|
||||
this._worldList.Width.Set(0.0f, 1f);
|
||||
}
|
||||
else if (!this._isScrollbarAttached && this._scrollbar.CanScroll)
|
||||
{
|
||||
this._containerPanel.Append((UIElement) this._scrollbar);
|
||||
this._isScrollbarAttached = true;
|
||||
this._worldList.Width.Set(-25f, 1f);
|
||||
}
|
||||
}
|
||||
base.Recalculate();
|
||||
}
|
||||
|
||||
private void NewWorldClick(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
SoundEngine.PlaySound(10);
|
||||
Main.newWorldName = Lang.gen[57].Value + " " + (object) (Main.WorldList.Count + 1);
|
||||
Main.MenuUI.SetState((UIState) new UIWorldCreation());
|
||||
Main.menuMode = 888;
|
||||
}
|
||||
|
||||
private void GoBackClick(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
SoundEngine.PlaySound(11);
|
||||
Main.menuMode = Main.menuMultiplayer ? 12 : 1;
|
||||
}
|
||||
|
||||
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.7f;
|
||||
((UIPanel) evt.Target).BorderColor = Color.Black;
|
||||
}
|
||||
|
||||
public override void OnActivate()
|
||||
{
|
||||
Main.LoadWorlds();
|
||||
this.UpdateWorldsList();
|
||||
if (!PlayerInput.UsingGamepadUI)
|
||||
return;
|
||||
UILinkPointNavigator.ChangePoint(3000 + (this._worldList.Count == 0 ? 1 : 2));
|
||||
}
|
||||
|
||||
private void UpdateWorldsList()
|
||||
{
|
||||
this._worldList.Clear();
|
||||
IOrderedEnumerable<WorldFileData> orderedEnumerable = new List<WorldFileData>((IEnumerable<WorldFileData>) Main.WorldList).OrderByDescending<WorldFileData, bool>(new Func<WorldFileData, bool>(this.CanWorldBePlayed)).ThenByDescending<WorldFileData, bool>((Func<WorldFileData, bool>) (x => x.IsFavorite)).ThenBy<WorldFileData, string>((Func<WorldFileData, string>) (x => x.Name)).ThenBy<WorldFileData, string>((Func<WorldFileData, string>) (x => x.GetFileName()));
|
||||
int num = 0;
|
||||
foreach (WorldFileData worldFileData in (IEnumerable<WorldFileData>) orderedEnumerable)
|
||||
this._worldList.Add((UIElement) new UIWorldListItem(worldFileData, num++, this.CanWorldBePlayed(worldFileData)));
|
||||
}
|
||||
|
||||
private bool CanWorldBePlayed(WorldFileData file) => Main.ActivePlayerFileData.Player.difficulty == (byte) 3 == (file.GameMode == 3);
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
if (this.skipDraw)
|
||||
{
|
||||
this.skipDraw = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.UpdateFavoritesCache())
|
||||
{
|
||||
this.skipDraw = true;
|
||||
Main.MenuUI.Draw(spriteBatch, new GameTime());
|
||||
}
|
||||
base.Draw(spriteBatch);
|
||||
this.SetupGamepadPoints(spriteBatch);
|
||||
}
|
||||
}
|
||||
|
||||
private bool UpdateFavoritesCache()
|
||||
{
|
||||
List<WorldFileData> worldFileDataList = new List<WorldFileData>((IEnumerable<WorldFileData>) Main.WorldList);
|
||||
worldFileDataList.Sort((Comparison<WorldFileData>) ((x, y) =>
|
||||
{
|
||||
if (x.IsFavorite && !y.IsFavorite)
|
||||
return -1;
|
||||
if (!x.IsFavorite && y.IsFavorite)
|
||||
return 1;
|
||||
return x.Name.CompareTo(y.Name) != 0 ? x.Name.CompareTo(y.Name) : x.GetFileName().CompareTo(y.GetFileName());
|
||||
}));
|
||||
bool flag = false;
|
||||
if (!flag && worldFileDataList.Count != this.favoritesCache.Count)
|
||||
flag = true;
|
||||
if (!flag)
|
||||
{
|
||||
for (int index = 0; index < this.favoritesCache.Count; ++index)
|
||||
{
|
||||
Tuple<string, bool> tuple = this.favoritesCache[index];
|
||||
if (!(worldFileDataList[index].Name == tuple.Item1) || worldFileDataList[index].IsFavorite != tuple.Item2)
|
||||
{
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
this.favoritesCache.Clear();
|
||||
foreach (WorldFileData worldFileData in worldFileDataList)
|
||||
this.favoritesCache.Add(Tuple.Create<string, bool>(worldFileData.Name, worldFileData.IsFavorite));
|
||||
this.UpdateWorldsList();
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
private void SetupGamepadPoints(SpriteBatch spriteBatch)
|
||||
{
|
||||
UILinkPointNavigator.Shortcuts.BackButtonCommand = 2;
|
||||
int num1 = 3000;
|
||||
UILinkPointNavigator.SetPosition(num1, this._backPanel.GetInnerDimensions().ToRectangle().Center.ToVector2());
|
||||
UILinkPointNavigator.SetPosition(num1 + 1, this._newPanel.GetInnerDimensions().ToRectangle().Center.ToVector2());
|
||||
int key1 = num1;
|
||||
UILinkPoint point1 = UILinkPointNavigator.Points[key1];
|
||||
point1.Unlink();
|
||||
point1.Right = key1 + 1;
|
||||
int key2 = num1 + 1;
|
||||
UILinkPoint point2 = UILinkPointNavigator.Points[key2];
|
||||
point2.Unlink();
|
||||
point2.Left = key2 - 1;
|
||||
float num2 = 1f / Main.UIScale;
|
||||
Rectangle clippingRectangle = this._containerPanel.GetClippingRectangle(spriteBatch);
|
||||
Vector2 minimum = clippingRectangle.TopLeft() * num2;
|
||||
Vector2 maximum = clippingRectangle.BottomRight() * num2;
|
||||
List<SnapPoint> snapPoints = this.GetSnapPoints();
|
||||
for (int index = 0; index < snapPoints.Count; ++index)
|
||||
{
|
||||
if (!snapPoints[index].Position.Between(minimum, maximum))
|
||||
{
|
||||
snapPoints.Remove(snapPoints[index]);
|
||||
--index;
|
||||
}
|
||||
}
|
||||
SnapPoint[,] snapPointArray = new SnapPoint[this._worldList.Count, 5];
|
||||
foreach (SnapPoint snapPoint in snapPoints.Where<SnapPoint>((Func<SnapPoint, bool>) (a => a.Name == "Play")))
|
||||
snapPointArray[snapPoint.Id, 0] = snapPoint;
|
||||
foreach (SnapPoint snapPoint in snapPoints.Where<SnapPoint>((Func<SnapPoint, bool>) (a => a.Name == "Favorite")))
|
||||
snapPointArray[snapPoint.Id, 1] = snapPoint;
|
||||
foreach (SnapPoint snapPoint in snapPoints.Where<SnapPoint>((Func<SnapPoint, bool>) (a => a.Name == "Cloud")))
|
||||
snapPointArray[snapPoint.Id, 2] = snapPoint;
|
||||
foreach (SnapPoint snapPoint in snapPoints.Where<SnapPoint>((Func<SnapPoint, bool>) (a => a.Name == "Seed")))
|
||||
snapPointArray[snapPoint.Id, 3] = snapPoint;
|
||||
foreach (SnapPoint snapPoint in snapPoints.Where<SnapPoint>((Func<SnapPoint, bool>) (a => a.Name == "Delete")))
|
||||
snapPointArray[snapPoint.Id, 4] = snapPoint;
|
||||
int num3 = num1 + 2;
|
||||
int[] numArray = new int[this._worldList.Count];
|
||||
for (int index = 0; index < numArray.Length; ++index)
|
||||
numArray[index] = -1;
|
||||
for (int index1 = 0; index1 < 5; ++index1)
|
||||
{
|
||||
int key3 = -1;
|
||||
for (int index2 = 0; index2 < snapPointArray.GetLength(0); ++index2)
|
||||
{
|
||||
if (snapPointArray[index2, index1] != null)
|
||||
{
|
||||
UILinkPoint point3 = UILinkPointNavigator.Points[num3];
|
||||
point3.Unlink();
|
||||
UILinkPointNavigator.SetPosition(num3, snapPointArray[index2, index1].Position);
|
||||
if (key3 != -1)
|
||||
{
|
||||
point3.Up = key3;
|
||||
UILinkPointNavigator.Points[key3].Down = num3;
|
||||
}
|
||||
if (numArray[index2] != -1)
|
||||
{
|
||||
point3.Left = numArray[index2];
|
||||
UILinkPointNavigator.Points[numArray[index2]].Right = num3;
|
||||
}
|
||||
point3.Down = num1;
|
||||
if (index1 == 0)
|
||||
UILinkPointNavigator.Points[num1].Up = UILinkPointNavigator.Points[num1 + 1].Up = num3;
|
||||
key3 = num3;
|
||||
numArray[index2] = num3;
|
||||
UILinkPointNavigator.Shortcuts.FANCYUI_HIGHEST_INDEX = num3;
|
||||
++num3;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!PlayerInput.UsingGamepadUI || this._worldList.Count != 0 || UILinkPointNavigator.CurrentPoint <= 3001)
|
||||
return;
|
||||
UILinkPointNavigator.ChangePoint(3001);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue