-
Notifications
You must be signed in to change notification settings - Fork 8
/
AutoTrash.cs
51 lines (43 loc) · 1.63 KB
/
AutoTrash.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using System;
using Terraria;
using Terraria.Localization;
using Terraria.ModLoader;
using Terraria.UI;
namespace AutoTrash
{
internal class AutoTrash : Mod
{
// TODO: Pre-designed trash items sets. Sorting arrays?
internal static AutoTrash instance;
internal static UserInterface autoTrashUserInterface;
internal AutoTrashListUI autoTrashListUI;
public override void Load() {
instance = this;
}
public override void Unload() {
instance = null;
autoTrashUserInterface = null;
UICheckbox.checkboxTexture = null;
UICheckbox.checkmarkTexture = null;
}
public override void PostSetupContent() {
if (!Main.dedServ)
{
autoTrashListUI = new AutoTrashListUI();
autoTrashListUI.Activate();
autoTrashUserInterface = new UserInterface();
autoTrashUserInterface.SetState(autoTrashListUI);
UICheckbox.checkboxTexture = Assets.Request<Texture2D>("checkBox", AssetRequestMode.ImmediateLoad);
UICheckbox.checkmarkTexture = Assets.Request<Texture2D>("checkMark", AssetRequestMode.ImmediateLoad);
if (ModLoader.TryGetMod("RecipeBrowser", out Mod RecipeBrowser))
{
RecipeBrowser.Call("AddItemFilter", Language.GetTextValue("Mods.AutoTrash.RecipeBrowserFilterNotAutoTrashed"), "Weapons", Assets.Request<Texture2D>("RecipeBrowserFilterNotAutotrashedIcon", AssetRequestMode.ImmediateLoad).Value,
(Predicate<Item>)((Item item) => !Main.LocalPlayer.GetModPlayer<AutoTrashPlayer>().ShouldItemBeTrashed(item)));
// TODO: Update RecipeBrowser with LocalizedText support, maybe some way of triggering a refresh.
}
}
}
}
}