Skip to content

Commit 689852b

Browse files
committed
Fix broken things, move config file
1 parent 1415903 commit 689852b

File tree

4 files changed

+38
-56
lines changed

4 files changed

+38
-56
lines changed

Config.cs

Lines changed: 25 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -23,54 +23,41 @@ public static class Config
2323
public static bool BoneBlockFix = true;
2424
public static bool GoldCritterDropTweak = true;
2525

26-
static int ConfigVersion;
27-
const int LatestVersion = 1;
28-
static string ConfigFolderPath = Path.Combine(Main.SavePath, "Mod Configs", "Vanilla Tweaks");
29-
static string ConfigPath = Path.Combine(ConfigFolderPath, "config.json");
30-
static string ConfigVersionPath = Path.Combine(ConfigFolderPath, "config.version");
26+
static string ConfigPath = Path.Combine(Main.SavePath, "Mod Configs", "Vanilla Tweaks.json");
27+
28+
static string OldConfigFolderPath = Path.Combine(Main.SavePath, "Mod Configs", "Vanilla Tweaks");
29+
static string OldConfigPath = Path.Combine(OldConfigFolderPath, "config.json");
30+
static string OldConfigVersionPath = Path.Combine(OldConfigFolderPath, "config.version");
3131

3232
static readonly Preferences Configuration = new Preferences(ConfigPath);
3333

3434
public static void Load()
3535
{
36-
if(File.Exists(ConfigVersionPath))
37-
{
38-
try
39-
{
40-
int.TryParse(File.ReadAllText(ConfigVersionPath), out ConfigVersion);
41-
}
42-
catch(Exception e)
43-
{
44-
VanillaTweaks.Log("Unable to read config version!");
45-
VanillaTweaks.Log(e.ToString());
46-
ConfigVersion = 0;
47-
}
48-
}
49-
else
50-
{
51-
ConfigVersion = 0;
52-
}
53-
54-
if(ConfigVersion < LatestVersion)
55-
{
56-
VanillaTweaks.Log("Config is outdated! Current version: {0} Latest version: {1}", ConfigVersion, LatestVersion);
57-
}
58-
if(ConfigVersion > LatestVersion)
59-
{
60-
VanillaTweaks.Log("Config is from the future?! Current version: {0} Latest version: {1}", ConfigVersion, LatestVersion);
61-
}
62-
// BossExpertise.Log("Reading config...");
36+
if(Directory.Exists(OldConfigFolderPath))
37+
{
38+
if(File.Exists(OldConfigPath))
39+
{
40+
VanillaTweaks.Log("Found config file in old folder! Moving config...");
41+
File.Move(OldConfigPath, ConfigPath);
42+
}
43+
if(File.Exists(OldConfigVersionPath))
44+
{
45+
File.Delete(OldConfigVersionPath);
46+
}
47+
if(Directory.GetFiles(OldConfigFolderPath).Length == 0 && Directory.GetDirectories(OldConfigFolderPath).Length == 0)
48+
{
49+
Directory.Delete(OldConfigFolderPath);
50+
}
51+
else
52+
{
53+
VanillaTweaks.Log("Old config folder still cotains some files/directories. They will not get deleted.");
54+
}
55+
}
6356
if(!ReadConfig())
6457
{
6558
VanillaTweaks.Log("Failed to read config file! Recreating config...");
6659
SaveConfig();
6760
}
68-
else if(ConfigVersion != LatestVersion)
69-
{
70-
VanillaTweaks.Log("Replacing config with newest version...");
71-
File.WriteAllText(ConfigVersionPath, LatestVersion.ToString());
72-
SaveConfig();
73-
}
7461
}
7562

7663
static bool ReadConfig()

ItemTweaks.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Terraria.Localization;
77
using Terraria.ModLoader;
88
using Terraria.ID;
9+
using Terraria.UI;
910

1011
namespace VanillaTweaks
1112
{
@@ -198,7 +199,7 @@ public override void UpdateArmorSet(Player player, string armorSet)
198199
}
199200
else if(armorSet == ObsidianSet && Config.ObsidianArmorTweak)
200201
{
201-
player.setBonus = Language.GetTextValue("Mods.VanillaTweaks.ArmorSet.Obsidian")
202+
player.setBonus = Language.GetTextValue("Mods.VanillaTweaks.ArmorSet.Obsidian");
202203
player.moveSpeed += 0.1f;
203204
}
204205
else if(armorSet == RainSet && Config.RainArmorTweak)
@@ -209,7 +210,7 @@ public override void UpdateArmorSet(Player player, string armorSet)
209210
}
210211
else if(armorSet == SWATSet && Config.SwatHelmetTweak)
211212
{
212-
player.setBonus = Language.GetTextValue("Mods.VanillaTweaks.ArmorSet.Swat")
213+
player.setBonus = Language.GetTextValue("Mods.VanillaTweaks.ArmorSet.Swat");
213214
player.endurance += 0.25f;
214215
player.rangedDamage += 0.2f;
215216
player.ammoCost80 = true;

LangTweaks.cs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,17 @@ public static void EditTooltips(LanguageManager manager)
7575
var bindFlags = BindingFlags.Static | BindingFlags.NonPublic;
7676
var tooltipsField = typeof(Lang).GetField("_itemTooltipCache", bindFlags);
7777
var tooltips = (ItemTooltip[])tooltipsField.GetValue(null);
78-
if(manager.ActiveCulture == GameCulture.English)
78+
if(Config.ObsidianArmorTweak)
7979
{
80-
if(Config.ObsidianArmorTweak)
81-
{
82-
tooltips[ItemID.ObsidianHelm] = ItemTooltip.FromLanguageKey("Mods.VanillaTweaks.ItemTooltip.ObsidianArmor");
83-
tooltips[ItemID.ObsidianSink] = ItemTooltip.FromLanguageKey("Mods.VanillaTweaks.ItemTooltip.ObsidianArmor");
84-
tooltips[ItemID.ObsidianPants] = ItemTooltip.FromLanguageKey("Mods.VanillaTweaks.ItemTooltip.ObsidianArmor");
85-
}
86-
if(Config.MeteorArmorTweak)
87-
{
88-
tooltips[ItemID.MeteorHelmet] = null;
89-
tooltips[ItemID.MeteorSuit] = null;
90-
tooltips[ItemID.MeteorLeggings] = null;
91-
}
80+
tooltips[ItemID.ObsidianHelm] = ItemTooltip.FromLanguageKey("Mods.VanillaTweaks.ItemTooltip.ObsidianArmor");
81+
tooltips[ItemID.ObsidianShirt] = ItemTooltip.FromLanguageKey("Mods.VanillaTweaks.ItemTooltip.ObsidianArmor");
82+
tooltips[ItemID.ObsidianPants] = ItemTooltip.FromLanguageKey("Mods.VanillaTweaks.ItemTooltip.ObsidianArmor");
83+
}
84+
if(Config.MeteorArmorTweak)
85+
{
86+
tooltips[ItemID.MeteorHelmet] = null;
87+
tooltips[ItemID.MeteorSuit] = null;
88+
tooltips[ItemID.MeteorLeggings] = null;
9289
}
9390
}
9491
}

VanillaTweaks.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@
4646
<Reference Include="System.Xml.Linq">
4747
<RequiredTargetFramework>3.5</RequiredTargetFramework>
4848
</Reference>
49-
<Reference Include="Terraria">
50-
<HintPath>..\..\..\..\Steam\SteamApps\common\Terraria\Terraria.exe</HintPath>
51-
</Reference>
5249
<Reference Include="tModLoader">
5350
<HintPath>..\..\..\..\..\..\..\Yurik\Steam\SteamApps\common\Terraria\tModLoader.exe</HintPath>
5451
</Reference>

0 commit comments

Comments
 (0)