From 689852b3a95fa21dd70e10ce4afd3d5ed901a592 Mon Sep 17 00:00:00 2001 From: goldenapple3 Date: Sun, 25 Jun 2017 18:46:24 +0300 Subject: [PATCH] Fix broken things, move config file --- Config.cs | 63 ++++++++++++++++++-------------------------- ItemTweaks.cs | 5 ++-- LangTweaks.cs | 23 +++++++--------- VanillaTweaks.csproj | 3 --- 4 files changed, 38 insertions(+), 56 deletions(-) diff --git a/Config.cs b/Config.cs index d90f2f5..bad0f19 100644 --- a/Config.cs +++ b/Config.cs @@ -23,54 +23,41 @@ public static class Config public static bool BoneBlockFix = true; public static bool GoldCritterDropTweak = true; - static int ConfigVersion; - const int LatestVersion = 1; - static string ConfigFolderPath = Path.Combine(Main.SavePath, "Mod Configs", "Vanilla Tweaks"); - static string ConfigPath = Path.Combine(ConfigFolderPath, "config.json"); - static string ConfigVersionPath = Path.Combine(ConfigFolderPath, "config.version"); + static string ConfigPath = Path.Combine(Main.SavePath, "Mod Configs", "Vanilla Tweaks.json"); + + static string OldConfigFolderPath = Path.Combine(Main.SavePath, "Mod Configs", "Vanilla Tweaks"); + static string OldConfigPath = Path.Combine(OldConfigFolderPath, "config.json"); + static string OldConfigVersionPath = Path.Combine(OldConfigFolderPath, "config.version"); static readonly Preferences Configuration = new Preferences(ConfigPath); public static void Load() { - if(File.Exists(ConfigVersionPath)) - { - try - { - int.TryParse(File.ReadAllText(ConfigVersionPath), out ConfigVersion); - } - catch(Exception e) - { - VanillaTweaks.Log("Unable to read config version!"); - VanillaTweaks.Log(e.ToString()); - ConfigVersion = 0; - } - } - else - { - ConfigVersion = 0; - } - - if(ConfigVersion < LatestVersion) - { - VanillaTweaks.Log("Config is outdated! Current version: {0} Latest version: {1}", ConfigVersion, LatestVersion); - } - if(ConfigVersion > LatestVersion) - { - VanillaTweaks.Log("Config is from the future?! Current version: {0} Latest version: {1}", ConfigVersion, LatestVersion); - } -// BossExpertise.Log("Reading config..."); + if(Directory.Exists(OldConfigFolderPath)) + { + if(File.Exists(OldConfigPath)) + { + VanillaTweaks.Log("Found config file in old folder! Moving config..."); + File.Move(OldConfigPath, ConfigPath); + } + if(File.Exists(OldConfigVersionPath)) + { + File.Delete(OldConfigVersionPath); + } + if(Directory.GetFiles(OldConfigFolderPath).Length == 0 && Directory.GetDirectories(OldConfigFolderPath).Length == 0) + { + Directory.Delete(OldConfigFolderPath); + } + else + { + VanillaTweaks.Log("Old config folder still cotains some files/directories. They will not get deleted."); + } + } if(!ReadConfig()) { VanillaTweaks.Log("Failed to read config file! Recreating config..."); SaveConfig(); } - else if(ConfigVersion != LatestVersion) - { - VanillaTweaks.Log("Replacing config with newest version..."); - File.WriteAllText(ConfigVersionPath, LatestVersion.ToString()); - SaveConfig(); - } } static bool ReadConfig() diff --git a/ItemTweaks.cs b/ItemTweaks.cs index 5a3d940..c0dc844 100644 --- a/ItemTweaks.cs +++ b/ItemTweaks.cs @@ -6,6 +6,7 @@ using Terraria.Localization; using Terraria.ModLoader; using Terraria.ID; +using Terraria.UI; namespace VanillaTweaks { @@ -198,7 +199,7 @@ public override void UpdateArmorSet(Player player, string armorSet) } else if(armorSet == ObsidianSet && Config.ObsidianArmorTweak) { - player.setBonus = Language.GetTextValue("Mods.VanillaTweaks.ArmorSet.Obsidian") + player.setBonus = Language.GetTextValue("Mods.VanillaTweaks.ArmorSet.Obsidian"); player.moveSpeed += 0.1f; } else if(armorSet == RainSet && Config.RainArmorTweak) @@ -209,7 +210,7 @@ public override void UpdateArmorSet(Player player, string armorSet) } else if(armorSet == SWATSet && Config.SwatHelmetTweak) { - player.setBonus = Language.GetTextValue("Mods.VanillaTweaks.ArmorSet.Swat") + player.setBonus = Language.GetTextValue("Mods.VanillaTweaks.ArmorSet.Swat"); player.endurance += 0.25f; player.rangedDamage += 0.2f; player.ammoCost80 = true; diff --git a/LangTweaks.cs b/LangTweaks.cs index 1060f9f..f71c46d 100644 --- a/LangTweaks.cs +++ b/LangTweaks.cs @@ -75,20 +75,17 @@ public static void EditTooltips(LanguageManager manager) var bindFlags = BindingFlags.Static | BindingFlags.NonPublic; var tooltipsField = typeof(Lang).GetField("_itemTooltipCache", bindFlags); var tooltips = (ItemTooltip[])tooltipsField.GetValue(null); - if(manager.ActiveCulture == GameCulture.English) + if(Config.ObsidianArmorTweak) { - if(Config.ObsidianArmorTweak) - { - tooltips[ItemID.ObsidianHelm] = ItemTooltip.FromLanguageKey("Mods.VanillaTweaks.ItemTooltip.ObsidianArmor"); - tooltips[ItemID.ObsidianSink] = ItemTooltip.FromLanguageKey("Mods.VanillaTweaks.ItemTooltip.ObsidianArmor"); - tooltips[ItemID.ObsidianPants] = ItemTooltip.FromLanguageKey("Mods.VanillaTweaks.ItemTooltip.ObsidianArmor"); - } - if(Config.MeteorArmorTweak) - { - tooltips[ItemID.MeteorHelmet] = null; - tooltips[ItemID.MeteorSuit] = null; - tooltips[ItemID.MeteorLeggings] = null; - } + tooltips[ItemID.ObsidianHelm] = ItemTooltip.FromLanguageKey("Mods.VanillaTweaks.ItemTooltip.ObsidianArmor"); + tooltips[ItemID.ObsidianShirt] = ItemTooltip.FromLanguageKey("Mods.VanillaTweaks.ItemTooltip.ObsidianArmor"); + tooltips[ItemID.ObsidianPants] = ItemTooltip.FromLanguageKey("Mods.VanillaTweaks.ItemTooltip.ObsidianArmor"); + } + if(Config.MeteorArmorTweak) + { + tooltips[ItemID.MeteorHelmet] = null; + tooltips[ItemID.MeteorSuit] = null; + tooltips[ItemID.MeteorLeggings] = null; } } } diff --git a/VanillaTweaks.csproj b/VanillaTweaks.csproj index 6e33e91..717cebb 100644 --- a/VanillaTweaks.csproj +++ b/VanillaTweaks.csproj @@ -46,9 +46,6 @@ 3.5 - - ..\..\..\..\Steam\SteamApps\common\Terraria\Terraria.exe - ..\..\..\..\..\..\..\Yurik\Steam\SteamApps\common\Terraria\tModLoader.exe