-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
CheatSheetWorld.cs
143 lines (127 loc) · 4.86 KB
/
CheatSheetWorld.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
using CheatSheet.Menus;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Terraria;
using Terraria.GameContent;
using Terraria.ModLoader;
using Terraria.UI;
namespace CheatSheet
{
internal class CheatSheetWorld : ModSystem
{
internal static string CSText(string key, string category = "ExtraAccessorySlots") => CheatSheet.CSText(category, key);
public override void OnWorldLoad() {
if (!Main.dedServ && Main.LocalPlayer.name != "") {
try {
CheatSheet.instance.hotbar.bCycleExtraAccessorySlots.Tooltip = CSText("ExtraAccessorySlots") + " " + Main.LocalPlayer.GetModPlayer<CheatSheetPlayer>().numberExtraAccessoriesEnabled;
CheatSheet.instance.paintToolsHotbar.UndoHistory.Clear();
CheatSheet.instance.paintToolsHotbar.UpdateUndoTooltip();
}
catch (Exception e) {
CheatSheetUtilities.ReportException(e);
}
}
// CheatSheet.instance.hotbar.ChangedBossDowner();
}
public override void OnWorldUnload() {
if (!Main.dedServ && Main.LocalPlayer.name != "") {
try {
CheatSheet.instance.hotbar.bCycleExtraAccessorySlots.Tooltip = CSText("ExtraAccessorySlots") + " " + Main.LocalPlayer.GetModPlayer<CheatSheetPlayer>().numberExtraAccessoriesEnabled;
CheatSheet.instance.paintToolsHotbar.UndoHistory.Clear();
CheatSheet.instance.paintToolsHotbar.UpdateUndoTooltip();
}
catch (Exception e) {
CheatSheetUtilities.ReportException(e);
}
}
// CheatSheet.instance.hotbar.ChangedBossDowner();
}
public override void NetSend(BinaryWriter writer) {
writer.Write7BitEncodedInt((int)NPCBrowser.filteredNPCSlots.Count);
foreach (var item in NPCBrowser.filteredNPCSlots) {
writer.Write7BitEncodedInt((int)item);
}
}
public override void NetReceive(BinaryReader reader) {
NPCBrowser.filteredNPCSlots.Clear();
int numFiltered = reader.Read7BitEncodedInt();
for (int i = 0; i < numFiltered; i++) {
NPCBrowser.filteredNPCSlots.Add(reader.Read7BitEncodedInt());
}
NPCBrowser.needsUpdate = true;
}
public override void UpdateUI(GameTime gameTime) {
base.UpdateUI(gameTime);
if (Main.netMode == 1 && ModContent.GetInstance<CheatSheetServerConfig>().DisableCheatsForNonHostUsers && !CheatSheet.IsPlayerLocalServerOwner(Main.LocalPlayer))
return;
if (PaintToolsEx.schematicsToLoad != null && CheatSheet.instance.numberOnlineToLoad > 0 && CheatSheet.instance.paintToolsUI.view.childrenToRemove.Count == 0) {
PaintToolsEx.LoadSingleSchematic();
//CheatSheet.instance.paintToolsUI.view.ReorderSlots();
}
if (PaintToolsSlot.updateNeeded) {
bool oneUpdated = false;
foreach (var item in CheatSheet.instance.paintToolsUI.view.slotList) {
if (item.texture == TextureAssets.MagicPixel.Value) {
item.texture = item.MakeThumbnail(item.stampInfo);
oneUpdated = true;
break;
}
}
if (!oneUpdated)
PaintToolsSlot.updateNeeded = false;
}
}
//public override void PostDrawFullscreenMap(ref string mouseText)
//{
// Main.spriteBatch.DrawString(FontAssets.MouseText.Value, "Testing Testing", new Vector2(Main.screenWidth / 2, Main.screenHeight / 2), Color.Pink, 0.0f, new Vector2(), 0.8f, SpriteEffects.None, 0.0f);
//}
private int lastmode = -1;
public override void ModifyInterfaceLayers(List<GameInterfaceLayer> layers) {
if (Main.netMode == 1 && ModContent.GetInstance<CheatSheetServerConfig>().DisableCheatsForNonHostUsers && !CheatSheet.IsPlayerLocalServerOwner(Main.LocalPlayer))
return;
if (Main.netMode != lastmode) {
lastmode = Main.netMode;
if (Main.netMode == 0) {
SpawnRateMultiplier.HasPermission = true;
foreach (var key in CheatSheet.instance.herosPermissions.Keys.ToList()) {
CheatSheet.instance.herosPermissions[key] = true;
}
}
CheatSheet.instance.hotbar.ChangedConfiguration();
}
int MouseTextIndex = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Mouse Text"));
if (MouseTextIndex != -1) {
layers.Insert(MouseTextIndex, new LegacyGameInterfaceLayer(
"CheatSheet: All Cheat Sheet",
delegate {
ModContent.GetInstance<AllItemsMenu>().DrawUpdateAll(Main.spriteBatch);
return true;
},
InterfaceScaleType.UI)
);
layers.Insert(MouseTextIndex, new LegacyGameInterfaceLayer(
"CheatSheet: Paint Tools",
delegate {
ModContent.GetInstance<AllItemsMenu>().DrawUpdatePaintTools(Main.spriteBatch);
return true;
},
InterfaceScaleType.Game)
);
}
MouseTextIndex = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Inventory"));
if (MouseTextIndex != -1) {
layers.Insert(MouseTextIndex, new LegacyGameInterfaceLayer(
"CheatSheet: Extra Accessories",
delegate {
ModContent.GetInstance<AllItemsMenu>().DrawUpdateExtraAccessories(Main.spriteBatch);
return true;
},
InterfaceScaleType.UI)
);
}
}
}
}