3
3
using System . IO ;
4
4
using Terraria ;
5
5
using Terraria . IO ;
6
+ using Terraria . ModLoader ;
6
7
7
8
namespace VanillaTweaks
8
9
{
9
10
public static class Config
10
11
{
11
12
public static bool GladiatorArmorTweak = true ;
13
+ const string GladiatorArmorTweakKey = "GladiatorArmorTweak" ;
14
+
12
15
public static bool ObsidianArmorTweak = true ;
16
+ const string ObsidianArmorTweakKey = "ObsidianArmorTweak" ;
17
+
13
18
public static bool MeteorArmorTweak = true ;
19
+ const string MeteorArmorTweakKey = "MeteorArmorTweak" ;
20
+
21
+ public static bool EskimoArmorTweak = true ;
22
+ const string EskimoArmorTweakKey = "EskimoArmorTweak" ;
23
+
14
24
public static bool RainArmorTweak = true ;
25
+ const string RainArmorTweakKey = "RainArmorTweak" ;
26
+
15
27
public static bool HammerTweaks = true ;
28
+ const string HammerTweaksKey = "HammerTweaks" ;
29
+
16
30
public static bool NightsEdgeAutoswing = true ;
31
+ const string NightsEdgeAutoswingKey = "NightsEdgeAutoswing" ;
32
+
17
33
public static bool TrueSwordsAutoswing = true ;
34
+ const string TrueSwordsAutoswingKey = "TrueSwordsAutoswing" ;
35
+
18
36
public static bool SwatHelmetTweak = true ;
37
+ const string SwatHelmetTweakKey = "SwatHelmetTweak" ;
38
+
19
39
public static bool SkullTweak = true ;
40
+ const string SkullTweakKey = "SkullTweak" ;
41
+
20
42
public static bool FishBowlTweak = true ;
43
+ const string FishBowlTweakKey = "FishBowlTweak" ;
44
+
21
45
public static bool SandstoneRename = true ;
46
+ const string SandstoneRenameKey = "SandstoneRename" ;
47
+
22
48
public static bool CobaltShieldRename = true ;
49
+ const string CobaltShieldRenameKey = "CobaltShieldRename" ;
50
+
23
51
public static bool BoneBlockFix = true ;
52
+ const string BoneBlockFixKey = "BoneBlockFix" ;
53
+
24
54
public static bool GoldCritterDropTweak = true ;
25
- public static float ExtractSpeedMultipltier = 5f ;
55
+ const string GoldCritterDropTweakKey = "GoldCritterDropTweak" ;
56
+
57
+ public static float ExtractSpeedMultiplier = 5f ;
58
+ const string ExtractSpeedMultiplierKey = "ExtractSpeedMultiplier" ;
59
+
60
+ public static int JestersArrowCraft = 50 ;
61
+ const string JestersArrowCraftKey = "JestersArrowCraft" ;
62
+
63
+ public static bool FavoriteTooltipRemove = true ;
64
+ const string FavoriteTooltipRemoveKey = "FavoriteTooltipRemove" ;
26
65
27
66
static string ConfigPath = Path . Combine ( Main . SavePath , "Mod Configs" , "Vanilla Tweaks.json" ) ;
28
67
@@ -42,68 +81,194 @@ public static void Load()
42
81
File . Move ( OldConfigPath , ConfigPath ) ;
43
82
}
44
83
if ( File . Exists ( OldConfigVersionPath ) )
45
- {
46
84
File . Delete ( OldConfigVersionPath ) ;
47
- }
48
85
if ( Directory . GetFiles ( OldConfigFolderPath ) . Length == 0 && Directory . GetDirectories ( OldConfigFolderPath ) . Length == 0 )
49
- {
50
86
Directory . Delete ( OldConfigFolderPath ) ;
51
- }
52
87
else
53
- {
54
88
VanillaTweaks . Log ( "Old config folder still cotains some files/directories. They will not get deleted." ) ;
55
- }
56
89
}
57
90
if ( ! ReadConfig ( ) )
58
- {
59
91
VanillaTweaks . Log ( "Failed to read config file! Recreating config..." ) ;
60
- }
61
92
SaveConfig ( ) ;
62
93
}
63
94
64
- static bool ReadConfig ( )
95
+ public static bool ReadConfig ( )
65
96
{
66
97
if ( Configuration . Load ( ) )
67
98
{
68
- Configuration . Get ( "GladiatorArmorTweak" , ref GladiatorArmorTweak ) ;
69
- Configuration . Get ( "ObsidianArmorTweak" , ref ObsidianArmorTweak ) ;
70
- Configuration . Get ( "MeteorArmorTweak" , ref MeteorArmorTweak ) ;
71
- Configuration . Get ( "HammerTweaks" , ref HammerTweaks ) ;
72
- Configuration . Get ( "NightsEdgeAutoswing" , ref NightsEdgeAutoswing ) ;
73
- Configuration . Get ( "TrueSwordsAutoswing" , ref TrueSwordsAutoswing ) ;
74
- Configuration . Get ( "SwatHelmetTweak" , ref SwatHelmetTweak ) ;
75
- Configuration . Get ( "SkullTweak" , ref SkullTweak ) ;
76
- Configuration . Get ( "FishBowlTweak" , ref FishBowlTweak ) ;
77
- Configuration . Get ( "SandstoneRename" , ref SandstoneRename ) ;
78
- Configuration . Get ( "CobaltShieldRename" , ref CobaltShieldRename ) ;
79
- Configuration . Get ( "BoneBlockFix" , ref BoneBlockFix ) ;
80
- Configuration . Get ( "SwatHelmetTweak" , ref SwatHelmetTweak ) ;
81
- Configuration . Get ( "GoldCritterDropTweak" , ref GoldCritterDropTweak ) ;
82
- Configuration . Get ( "ExtractSpeedMulitplier" , ref ExtractSpeedMultipltier ) ;
99
+ Configuration . Get ( GladiatorArmorTweakKey , ref GladiatorArmorTweak ) ;
100
+ Configuration . Get ( ObsidianArmorTweakKey , ref ObsidianArmorTweak ) ;
101
+ Configuration . Get ( MeteorArmorTweakKey , ref MeteorArmorTweak ) ;
102
+ Configuration . Get ( EskimoArmorTweakKey , ref EskimoArmorTweak ) ;
103
+ Configuration . Get ( RainArmorTweakKey , ref RainArmorTweak ) ;
104
+ Configuration . Get ( HammerTweaksKey , ref HammerTweaks ) ;
105
+ Configuration . Get ( NightsEdgeAutoswingKey , ref NightsEdgeAutoswing ) ;
106
+ Configuration . Get ( TrueSwordsAutoswingKey , ref TrueSwordsAutoswing ) ;
107
+ Configuration . Get ( SwatHelmetTweakKey , ref SwatHelmetTweak ) ;
108
+ Configuration . Get ( SkullTweakKey , ref SkullTweak ) ;
109
+ Configuration . Get ( FishBowlTweakKey , ref FishBowlTweak ) ;
110
+ Configuration . Get ( SandstoneRenameKey , ref SandstoneRename ) ;
111
+ Configuration . Get ( CobaltShieldRenameKey , ref CobaltShieldRename ) ;
112
+ Configuration . Get ( BoneBlockFixKey , ref BoneBlockFix ) ;
113
+ Configuration . Get ( GoldCritterDropTweakKey , ref GoldCritterDropTweak ) ;
114
+ Configuration . Get ( "ExtractSpeedMulitplier" , ref ExtractSpeedMultiplier ) ; //bit of a typo there :P
115
+ Configuration . Get ( ExtractSpeedMultiplierKey , ref ExtractSpeedMultiplier ) ;
116
+ Configuration . Get ( JestersArrowCraftKey , ref JestersArrowCraft ) ;
117
+ Configuration . Get ( FavoriteTooltipRemoveKey , ref FavoriteTooltipRemove ) ;
83
118
return true ;
84
119
}
85
120
return false ;
86
121
}
87
122
88
- static void SaveConfig ( )
123
+ public static void SaveConfig ( )
89
124
{
90
125
Configuration . Clear ( ) ;
91
- Configuration . Put ( "GladiatorArmorTweak" , GladiatorArmorTweak ) ;
92
- Configuration . Put ( "ObsidianArmorTweak" , ObsidianArmorTweak ) ;
93
- Configuration . Put ( "MeteorArmorTweak" , MeteorArmorTweak ) ;
94
- Configuration . Put ( "HammerTweaks" , HammerTweaks ) ;
95
- Configuration . Put ( "NightsEdgeAutoswing" , NightsEdgeAutoswing ) ;
96
- Configuration . Put ( "TrueSwordsAutoswing" , TrueSwordsAutoswing ) ;
97
- Configuration . Put ( "SwatHelmetTweak" , SwatHelmetTweak ) ;
98
- Configuration . Put ( "SkullTweak" , SkullTweak ) ;
99
- Configuration . Put ( "FishBowlTweak" , FishBowlTweak ) ;
100
- Configuration . Put ( "SandstoneRename" , SandstoneRename ) ;
101
- Configuration . Put ( "CobaltShieldRename" , CobaltShieldRename ) ;
102
- Configuration . Put ( "BoneBlockFix" , BoneBlockFix ) ;
103
- Configuration . Put ( "SwatHelmetTweak" , SwatHelmetTweak ) ;
104
- Configuration . Put ( "GoldCritterDropTweak" , GoldCritterDropTweak ) ;
105
- Configuration . Put ( "ExtractSpeedMulitplier" , ExtractSpeedMultipltier ) ;
126
+ Configuration . Put ( GladiatorArmorTweakKey , GladiatorArmorTweak ) ;
127
+ Configuration . Put ( ObsidianArmorTweakKey , ObsidianArmorTweak ) ;
128
+ Configuration . Put ( MeteorArmorTweakKey , MeteorArmorTweak ) ;
129
+ Configuration . Put ( EskimoArmorTweakKey , EskimoArmorTweak ) ;
130
+ Configuration . Put ( RainArmorTweakKey , RainArmorTweak ) ;
131
+ Configuration . Put ( HammerTweaksKey , HammerTweaks ) ;
132
+ Configuration . Put ( NightsEdgeAutoswingKey , NightsEdgeAutoswing ) ;
133
+ Configuration . Put ( TrueSwordsAutoswingKey , TrueSwordsAutoswing ) ;
134
+ Configuration . Put ( SwatHelmetTweakKey , SwatHelmetTweak ) ;
135
+ Configuration . Put ( SkullTweakKey , SkullTweak ) ;
136
+ Configuration . Put ( FishBowlTweakKey , FishBowlTweak ) ;
137
+ Configuration . Put ( SandstoneRenameKey , SandstoneRename ) ;
138
+ Configuration . Put ( CobaltShieldRenameKey , CobaltShieldRename ) ;
139
+ Configuration . Put ( BoneBlockFixKey , BoneBlockFix ) ;
140
+ Configuration . Put ( GoldCritterDropTweakKey , GoldCritterDropTweak ) ;
141
+ Configuration . Put ( ExtractSpeedMultiplierKey , ExtractSpeedMultiplier ) ;
142
+ Configuration . Put ( JestersArrowCraftKey , JestersArrowCraft ) ;
143
+ Configuration . Put ( FavoriteTooltipRemoveKey , FavoriteTooltipRemove ) ;
106
144
Configuration . Save ( ) ;
107
145
}
146
+
147
+ //TODO: Transmations
148
+ public static void LoadFKConfig ( Mod mod )
149
+ {
150
+ var setting = FKTModSettings . ModSettingsAPI . CreateModSettingConfig ( mod ) ;
151
+
152
+ setting . AddComment ( "Features marked with an asterisk (*) require an item reset to update properly.\n " +
153
+ "An item can be reset by either re-entering the world or by placing it into an Item Frame, Weapon Rack or Mannequin." ) ;
154
+ setting . AddComment ( "Features marked with two asterisks (**) require a mod reload to update properly." ) ;
155
+ setting . AddComment ( "Most values are only modifiable in singleplayer." ) ;
156
+
157
+ const float commentScale = 0.8f ;
158
+
159
+ setting . AddComment ( "Defense increased*, set bonus: +15% crit chance" , commentScale ) ;
160
+ setting . AddBool ( GladiatorArmorTweakKey , "Gladiator Armor Tweaks" , false ) ;
161
+ setting . AddComment ( "+3% ranged crit chance for each piece, set bonus: +10% move speed and shadow trail" , commentScale ) ;
162
+ setting . AddBool ( ObsidianArmorTweakKey , "Obsidian Armor Tweaks" , false ) ;
163
+ setting . AddComment ( "Defense decreased*, no magic bonuses" , commentScale ) ;
164
+ setting . AddBool ( MeteorArmorTweakKey , "Meteor Armor Tweaks" , false ) ;
165
+ setting . AddComment ( "Defense increased*, immunity to cold water, set bonus: Warmth buff, immunity to Frostburn, Chilled and Frozen" , commentScale ) ;
166
+ setting . AddBool ( EskimoArmorTweakKey , "Eskimo Armor Tweaks" , false ) ;
167
+ setting . AddComment ( "Set bonus: +1 defense, immunity to being wet" , commentScale ) ;
168
+ setting . AddBool ( RainArmorTweakKey , "Rain Armor Tweaks" , false ) ;
169
+ setting . AddComment ( "Rebalances a few hammers/hamaxes" , commentScale ) ;
170
+ setting . AddBool ( HammerTweaksKey , "Hammer Tweaks*" , false ) ;
171
+ setting . AddBool ( NightsEdgeAutoswingKey , "Night's Edge Autoswing*" , true ) ;
172
+ setting . AddBool ( TrueSwordsAutoswingKey , "True Swords Autoswing*" , true ) ;
173
+ setting . AddComment ( "+14 defense, +15% ranged damage (all types), +5% ranged crit chance\n " +
174
+ "If Miscellania is installed, equipping a SWAT Helmet and a Reinforced Vest grants a set bonus" , commentScale ) ;
175
+ setting . AddBool ( SwatHelmetTweakKey , "SWAT Helmet Tweaks*" , false ) ;
176
+ setting . AddComment ( "Flips the Skull sprite so that it faces to the right like other armor/vanity" , commentScale ) ;
177
+ setting . AddBool ( SkullTweakKey , "Skull Flip" , true ) ;
178
+ setting . AddComment ( "+1 defense" , commentScale ) ;
179
+ setting . AddBool ( FishBowlTweakKey , "Fish Bowl Tweaks*" , false ) ;
180
+ setting . AddComment ( "Renames items such as Sandstone Brick to Sand Brick" , commentScale ) ;
181
+ setting . AddBool ( SandstoneRenameKey , "Rename Sandstone Items**" , true ) ;
182
+ setting . AddComment ( "Renames the Cobalt Shield to Guardian's Shield" , commentScale ) ;
183
+ setting . AddBool ( CobaltShieldRenameKey , "Rename Cobalt Shield**" , true ) ;
184
+ setting . AddComment ( "Bone Block Walls craft back into Bones**, Bone Blocks drop raw Bones when mined" , commentScale ) ;
185
+ setting . AddBool ( BoneBlockFixKey , "Bone Block Fix" , false ) ;
186
+ setting . AddComment ( "Gold critters drop 1 Gold when killed (as opposed to 5 Gold when sold)" , commentScale ) ;
187
+ setting . AddBool ( GoldCritterDropTweakKey , "Gold Critters Drop Coins" , false ) ;
188
+ setting . AddFloat ( ExtractSpeedMultiplierKey , "Extractinator Speed Multiplier" , 0f , 5f , false ) ;
189
+ setting . AddBool ( FavoriteTooltipRemoveKey , "Remove \" Favorite Item\" Tooltips" , true ) ;
190
+ setting . AddComment ( "Setting this value to 0 will remove the recipe entirely" , commentScale ) ;
191
+ setting . AddInt ( JestersArrowCraftKey , "Jester's Arrows Crafted per Star**" , 0 , 100 , false ) ;
192
+ }
193
+
194
+ public static void UpdateFKConfig ( Mod mod )
195
+ {
196
+ FKTModSettings . ModSetting setting ;
197
+ if ( FKTModSettings . ModSettingsAPI . TryGetModSetting ( mod , out setting ) )
198
+ {
199
+ setting . Get ( GladiatorArmorTweakKey , ref GladiatorArmorTweak ) ;
200
+ setting . Get ( ObsidianArmorTweakKey , ref ObsidianArmorTweak ) ;
201
+ setting . Get ( MeteorArmorTweakKey , ref MeteorArmorTweak ) ;
202
+ setting . Get ( EskimoArmorTweakKey , ref EskimoArmorTweak ) ;
203
+ setting . Get ( RainArmorTweakKey , ref RainArmorTweak ) ;
204
+ setting . Get ( HammerTweaksKey , ref HammerTweaks ) ;
205
+ setting . Get ( NightsEdgeAutoswingKey , ref NightsEdgeAutoswing ) ;
206
+ setting . Get ( TrueSwordsAutoswingKey , ref TrueSwordsAutoswing ) ;
207
+ setting . Get ( SwatHelmetTweakKey , ref SwatHelmetTweak ) ;
208
+ setting . Get ( SkullTweakKey , ref SkullTweak ) ;
209
+ setting . Get ( FishBowlTweakKey , ref FishBowlTweak ) ;
210
+ setting . Get ( SandstoneRenameKey , ref SandstoneRename ) ;
211
+ setting . Get ( CobaltShieldRenameKey , ref CobaltShieldRename ) ;
212
+ setting . Get ( BoneBlockFixKey , ref BoneBlockFix ) ;
213
+ setting . Get ( GoldCritterDropTweakKey , ref GoldCritterDropTweak ) ;
214
+ setting . Get ( ExtractSpeedMultiplierKey , ref ExtractSpeedMultiplier ) ;
215
+ setting . Get ( FavoriteTooltipRemoveKey , ref FavoriteTooltipRemove ) ;
216
+ setting . Get ( JestersArrowCraftKey , ref JestersArrowCraft ) ;
217
+ }
218
+ }
219
+
220
+ class MultiplayerSyncWorld : ModWorld
221
+ {
222
+ public override void NetSend ( BinaryWriter writer )
223
+ {
224
+ var data = new BitsByte ( ) ;
225
+ data [ 0 ] = GladiatorArmorTweak ;
226
+ data [ 1 ] = ObsidianArmorTweak ;
227
+ data [ 2 ] = MeteorArmorTweak ;
228
+ data [ 3 ] = RainArmorTweak ;
229
+ data [ 4 ] = HammerTweaks ;
230
+ data [ 5 ] = NightsEdgeAutoswing ;
231
+ data [ 6 ] = TrueSwordsAutoswing ;
232
+ data [ 7 ] = SwatHelmetTweak ;
233
+ writer . Write ( ( byte ) data ) ;
234
+ data . ClearAll ( ) ;
235
+ data [ 0 ] = FishBowlTweak ;
236
+ data [ 1 ] = BoneBlockFix ;
237
+ data [ 2 ] = GoldCritterDropTweak ;
238
+ data [ 3 ] = EskimoArmorTweak ;
239
+ writer . Write ( ( byte ) data ) ;
240
+ writer . Write ( ExtractSpeedMultiplier ) ;
241
+ writer . Write ( ( short ) JestersArrowCraft ) ;
242
+ }
243
+
244
+ public override void NetReceive ( BinaryReader reader )
245
+ {
246
+ SaveConfig ( ) ;
247
+ var data = ( BitsByte ) reader . ReadByte ( ) ;
248
+ GladiatorArmorTweak = data [ 0 ] ;
249
+ ObsidianArmorTweak = data [ 1 ] ;
250
+ MeteorArmorTweak = data [ 2 ] ;
251
+ RainArmorTweak = data [ 3 ] ;
252
+ HammerTweaks = data [ 4 ] ;
253
+ NightsEdgeAutoswing = data [ 5 ] ;
254
+ TrueSwordsAutoswing = data [ 6 ] ;
255
+ SwatHelmetTweak = data [ 7 ] ;
256
+ data = ( BitsByte ) reader . ReadByte ( ) ;
257
+ FishBowlTweak = data [ 0 ] ;
258
+ BoneBlockFix = data [ 1 ] ;
259
+ GoldCritterDropTweak = data [ 2 ] ;
260
+ EskimoArmorTweak = data [ 3 ] ;
261
+ ExtractSpeedMultiplier = reader . ReadSingle ( ) ;
262
+ JestersArrowCraft = reader . ReadInt16 ( ) ;
263
+ }
264
+ }
265
+
266
+ class MultiplayerSyncPlayer : ModPlayer
267
+ {
268
+ public override void PlayerDisconnect ( Player player )
269
+ {
270
+ ReadConfig ( ) ;
271
+ }
272
+ }
108
273
}
109
274
}
0 commit comments