mirror of
https://github.com/OMGeeky/ItemChecklist.git
synced 2025-12-27 06:29:25 +01:00
tmodPorter
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Terraria;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace ItemChecklist
|
||||
@@ -6,9 +7,9 @@ namespace ItemChecklist
|
||||
class ItemChecklistGlobalItem : GlobalItem
|
||||
{
|
||||
// OnPIckup only called on LocalPlayer: I think
|
||||
public override void OnCreate(Item item, ItemCreationContext context)
|
||||
public override void OnCreated(Item item, ItemCreationContext context)
|
||||
{
|
||||
if (context is RecipeCreationContext rContext) {
|
||||
if (context is RecipeItemCreationContext rContext) {
|
||||
ItemReceived(item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace ItemChecklist
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnEnterWorld(Player player)
|
||||
public override void OnEnterWorld()
|
||||
{
|
||||
var itemChecklistPlayer = Main.LocalPlayer.GetModPlayer<ItemChecklistPlayer>();
|
||||
ItemChecklistUI.Visible = false;
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace ItemChecklist
|
||||
buttonsHaveDummyTextures = true;
|
||||
|
||||
foundFilterButton = new UIHoverImageButton(TextureAssets.MagicPixel.Value, "Cycle Found Filter: ??");
|
||||
foundFilterButton.OnClick += (a, b) => ToggleFoundFilterButtonClicked(a, b, true);
|
||||
foundFilterButton.OnLeftClick += (a, b) => ToggleFoundFilterButtonClicked(a, b, true);
|
||||
foundFilterButton.OnRightClick += (a, b) => ToggleFoundFilterButtonClicked(a, b, false);
|
||||
foundFilterButton.Top.Pixels = top;
|
||||
checklistPanel.Append(foundFilterButton);
|
||||
@@ -123,7 +123,7 @@ namespace ItemChecklist
|
||||
//checklistPanel.Append(sortButton);
|
||||
|
||||
modFilterButton = new UIHoverImageButton(TextureAssets.MagicPixel.Value, "Cycle Mod Filter: ??");
|
||||
modFilterButton.OnClick += (a, b) => ToggleModFilterButtonClicked(a, b, true);
|
||||
modFilterButton.OnLeftClick += (a, b) => ToggleModFilterButtonClicked(a, b, true);
|
||||
modFilterButton.OnRightClick += (a, b) => ToggleModFilterButtonClicked(a, b, false);
|
||||
modFilterButton.Left.Pixels = left;
|
||||
modFilterButton.Top.Pixels = top;
|
||||
@@ -131,21 +131,21 @@ namespace ItemChecklist
|
||||
left += (int)spacing * 2 + 28;
|
||||
|
||||
muteButton = new UIToggleHoverImageButton(TextureAssets.MagicPixel.Value, ItemChecklist.instance.Assets.Request<Texture2D>("UIElements/closeButton", AssetRequestMode.ImmediateLoad).Value, "Toggle Messages", announce);
|
||||
muteButton.OnClick += ToggleMuteButtonClicked;
|
||||
muteButton.OnLeftClick += ToggleMuteButtonClicked;
|
||||
muteButton.Left.Pixels = left;
|
||||
muteButton.Top.Pixels = top;
|
||||
checklistPanel.Append(muteButton);
|
||||
left += (int)spacing * 2 + 28;
|
||||
|
||||
collectChestItemsButton = new UIToggleHoverImageButton(TextureAssets.MagicPixel.Value, ItemChecklist.instance.Assets.Request<Texture2D>("UIElements/closeButton", AssetRequestMode.ImmediateLoad).Value, "Toggle Collect Chest Items", collectChestItems);
|
||||
collectChestItemsButton.OnClick += ToggleFindChestItemsButtonClicked;
|
||||
collectChestItemsButton.OnLeftClick += ToggleFindChestItemsButtonClicked;
|
||||
collectChestItemsButton.Left.Pixels = left;
|
||||
collectChestItemsButton.Top.Pixels = top;
|
||||
checklistPanel.Append(collectChestItemsButton);
|
||||
left += (int)spacing * 2 + 28;
|
||||
|
||||
showBadgeButton = new UIToggleHoverImageButton(TextureAssets.MagicPixel.Value, ItemChecklist.instance.Assets.Request<Texture2D>("UIElements/closeButton", AssetRequestMode.ImmediateLoad).Value, "Show Sort Value Text", showBadge);
|
||||
showBadgeButton.OnClick += ToggleShowBadgeButtonClicked;
|
||||
showBadgeButton.OnLeftClick += ToggleShowBadgeButtonClicked;
|
||||
showBadgeButton.Left.Pixels = left;
|
||||
showBadgeButton.Top.Pixels = top;
|
||||
checklistPanel.Append(showBadgeButton);
|
||||
@@ -541,11 +541,11 @@ namespace ItemChecklist
|
||||
UserInterface.ActiveInstance = temp;
|
||||
}
|
||||
|
||||
public override void MouseDown(UIMouseEvent evt)
|
||||
public override void LeftMouseDown(UIMouseEvent evt)
|
||||
{
|
||||
UserInterface temp = UserInterface.ActiveInstance;
|
||||
UserInterface.ActiveInstance = ItemChecklist.ItemChecklistInterface;
|
||||
base.MouseDown(evt);
|
||||
base.LeftMouseDown(evt);
|
||||
UserInterface.ActiveInstance = temp;
|
||||
}
|
||||
}
|
||||
|
||||
19
SharedUI.cs
19
SharedUI.cs
@@ -12,6 +12,7 @@ using Terraria.GameContent.UI.States;
|
||||
using Terraria.ID;
|
||||
using static ItemChecklist.Utilities;
|
||||
using Terraria.ModLoader;
|
||||
using Terraria.WorldBuilding;
|
||||
|
||||
// Copied from my Recipe Browser mod.
|
||||
namespace ItemChecklist
|
||||
@@ -403,7 +404,7 @@ namespace ItemChecklist
|
||||
// Potions, other?
|
||||
// should inherit children?
|
||||
// should have other category?
|
||||
if (WorldGen.statueList == null)
|
||||
if (GenVars.statueList == null)
|
||||
WorldGen.SetupStatueList();
|
||||
|
||||
var vanity = new MutuallyExclusiveFilter("Vanity", x => x.vanity, smallVanity);
|
||||
@@ -461,7 +462,7 @@ namespace ItemChecklist
|
||||
{
|
||||
new Category("Containers", x=>x.createTile!=-1 && Main.tileContainer[x.createTile], smallContainer),
|
||||
new Category("Wiring", x=>ItemID.Sets.SortingPriorityWiring[x.type] > -1, smallWiring),
|
||||
new Category("Statues", x=>WorldGen.statueList.Any(point => point.X == x.createTile && point.Y == x.placeStyle), smallStatue),
|
||||
new Category("Statues", x=>GenVars.statueList.Any(point => point.X == x.createTile && point.Y == x.placeStyle), smallStatue),
|
||||
new Category("Doors", x=> x.createTile > 0 && TileID.Sets.RoomNeeds.CountsAsDoor.Contains(x.createTile), ResizeImage2424(TextureAssets.Item[ItemID.WoodenDoor])),
|
||||
new Category("Chairs", x=> x.createTile > 0 && TileID.Sets.RoomNeeds.CountsAsChair.Contains(x.createTile), ResizeImage2424(TextureAssets.Item[ItemID.WoodenChair])),
|
||||
new Category("Tables", x=> x.createTile > 0 && TileID.Sets.RoomNeeds.CountsAsTable.Contains(x.createTile), ResizeImage2424(TextureAssets.Item[ItemID.PalmWoodTable])),
|
||||
@@ -675,7 +676,7 @@ namespace ItemChecklist
|
||||
this.belongs = belongs;
|
||||
|
||||
this.button = new UISilentImageButton(texture, name);
|
||||
button.OnClick += (a, b) => {
|
||||
button.OnLeftClick += (a, b) => {
|
||||
button.selected = !button.selected;
|
||||
ItemChecklistUI.instance.UpdateNeeded();
|
||||
//Main.NewText("clicked on " + button.hoverText);
|
||||
@@ -688,7 +689,7 @@ namespace ItemChecklist
|
||||
List<Filter> exclusives;
|
||||
|
||||
public MutuallyExclusiveFilter(string name, Predicate<Item> belongs, Texture2D texture) : base(name, belongs, texture) {
|
||||
button.OnClick += (a, b) => {
|
||||
button.OnLeftClick += (a, b) => {
|
||||
if (button.selected) {
|
||||
foreach (var item in exclusives) {
|
||||
if (item != this)
|
||||
@@ -714,7 +715,7 @@ namespace ItemChecklist
|
||||
return belongs(item) ^ right;
|
||||
};
|
||||
button = new UIBadgedSilentImageButton(texture, name + " (RMB)");
|
||||
button.OnClick += (a, b) => {
|
||||
button.OnLeftClick += (a, b) => {
|
||||
button.selected = !button.selected;
|
||||
ItemChecklistUI.instance.UpdateNeeded();
|
||||
//Main.NewText("clicked on " + button.hoverText);
|
||||
@@ -746,14 +747,14 @@ namespace ItemChecklist
|
||||
//CycleFilter needs SharedUI.instance.updateNeeded to update image, since each filter acts independently.
|
||||
|
||||
var firstButton = new UISilentImageButton(texture, name);
|
||||
firstButton.OnClick += (a, b) => ButtonBehavior(true);
|
||||
firstButton.OnLeftClick += (a, b) => ButtonBehavior(true);
|
||||
firstButton.OnRightClick += (a, b) => ButtonBehavior(false);
|
||||
|
||||
buttons.Add(firstButton);
|
||||
|
||||
for (int i = 0; i < filters.Count; i++) {
|
||||
var buttonOption = new UISilentImageButton(filters[i].texture, filters[i].name);
|
||||
buttonOption.OnClick += (a, b) => ButtonBehavior(true);
|
||||
buttonOption.OnLeftClick += (a, b) => ButtonBehavior(true);
|
||||
buttonOption.OnRightClick += (a, b) => ButtonBehavior(false);
|
||||
buttonOption.OnMiddleClick += (a, b) => ButtonBehavior(false, true);
|
||||
buttons.Add(buttonOption);
|
||||
@@ -784,7 +785,7 @@ namespace ItemChecklist
|
||||
this.sort = sort;
|
||||
this.badge = badge;
|
||||
button = new UISilentImageButton(texture, hoverText);
|
||||
button.OnClick += (a, b) => {
|
||||
button.OnLeftClick += (a, b) => {
|
||||
SharedUI.instance.SelectedSort = this;
|
||||
};
|
||||
}
|
||||
@@ -832,7 +833,7 @@ namespace ItemChecklist
|
||||
this.belongs = belongs;
|
||||
|
||||
this.button = new UISilentImageButton(texture, name);
|
||||
button.OnClick += (a, b) => {
|
||||
button.OnLeftClick += (a, b) => {
|
||||
//Main.NewText("clicked on " + button.hoverText);
|
||||
SharedUI.instance.SelectedCategory = this;
|
||||
};
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace ItemChecklist.UIElements
|
||||
|
||||
Texture2D texture = ItemChecklist.instance.Assets.Request<Texture2D>("UIElements/closeButtonSmallWhite", AssetRequestMode.ImmediateLoad).Value;
|
||||
var closeButton = new UIHoverImageButton(texture, "");
|
||||
closeButton.OnClick += (a, b) => SetText("");
|
||||
closeButton.OnLeftClick += (a, b) => SetText("");
|
||||
closeButton.Left.Set(-20f, 1f);
|
||||
//closeButton.Top.Set(0f, .5f);
|
||||
closeButton.VAlign = 0.5f;
|
||||
@@ -59,10 +59,10 @@ namespace ItemChecklist.UIElements
|
||||
Append(closeButton);
|
||||
}
|
||||
|
||||
public override void Click(UIMouseEvent evt)
|
||||
public override void LeftClick(UIMouseEvent evt)
|
||||
{
|
||||
Focus();
|
||||
base.Click(evt);
|
||||
base.LeftClick(evt);
|
||||
}
|
||||
|
||||
public override void RightClick(UIMouseEvent evt)
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace ItemChecklist.UIElements
|
||||
text = " " + text;
|
||||
this.hoverText = hoverText;
|
||||
SetText(text);
|
||||
OnClick += UICheckbox_onLeftClick;
|
||||
OnLeftClick += UICheckbox_onLeftClick;
|
||||
Recalculate();
|
||||
}
|
||||
|
||||
|
||||
@@ -53,16 +53,16 @@ namespace ItemChecklist
|
||||
// this.maxY = max;
|
||||
//}
|
||||
|
||||
public override void MouseDown(UIMouseEvent evt)
|
||||
public override void LeftMouseDown(UIMouseEvent evt)
|
||||
{
|
||||
DragStart(evt);
|
||||
base.MouseDown(evt);
|
||||
base.LeftMouseDown(evt);
|
||||
}
|
||||
|
||||
public override void MouseUp(UIMouseEvent evt)
|
||||
public override void LeftMouseUp(UIMouseEvent evt)
|
||||
{
|
||||
DragEnd(evt);
|
||||
base.MouseUp(evt);
|
||||
base.LeftMouseUp(evt);
|
||||
}
|
||||
|
||||
private void DragStart(UIMouseEvent evt)
|
||||
|
||||
@@ -97,9 +97,9 @@ namespace ItemChecklist.UIElements
|
||||
this.DrawBar(spriteBatch, this._innerTexture, handleRectangle, Color.White * ((this._isDragging || this._isHoveringOverHandle) ? 1f : 0.85f));
|
||||
}
|
||||
|
||||
public override void MouseDown(UIMouseEvent evt)
|
||||
public override void LeftMouseDown(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseDown(evt);
|
||||
base.LeftMouseDown(evt);
|
||||
if (evt.Target == this)
|
||||
{
|
||||
Rectangle handleRectangle = this.GetHandleRectangle();
|
||||
@@ -115,9 +115,9 @@ namespace ItemChecklist.UIElements
|
||||
}
|
||||
}
|
||||
|
||||
public override void MouseUp(UIMouseEvent evt)
|
||||
public override void LeftMouseUp(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseUp(evt);
|
||||
base.LeftMouseUp(evt);
|
||||
this._isDragging = false;
|
||||
}
|
||||
}
|
||||
@@ -139,11 +139,11 @@ namespace ItemChecklist.UIElements
|
||||
UserInterface.ActiveInstance = temp;
|
||||
}
|
||||
|
||||
public override void MouseDown(UIMouseEvent evt)
|
||||
public override void LeftMouseDown(UIMouseEvent evt)
|
||||
{
|
||||
UserInterface temp = UserInterface.ActiveInstance;
|
||||
UserInterface.ActiveInstance = userInterface;
|
||||
base.MouseDown(evt);
|
||||
base.LeftMouseDown(evt);
|
||||
UserInterface.ActiveInstance = temp;
|
||||
}
|
||||
}
|
||||
@@ -162,11 +162,11 @@ namespace ItemChecklist.UIElements
|
||||
UserInterface.ActiveInstance = temp;
|
||||
}
|
||||
|
||||
public override void MouseDown(UIMouseEvent evt)
|
||||
public override void LeftMouseDown(UIMouseEvent evt)
|
||||
{
|
||||
UserInterface temp = UserInterface.ActiveInstance;
|
||||
UserInterface.ActiveInstance = userInterface;
|
||||
base.MouseDown(evt);
|
||||
base.LeftMouseDown(evt);
|
||||
UserInterface.ActiveInstance = temp;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user