-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4a14fdf
commit f714ee8
Showing
7 changed files
with
196 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System.IO; | ||
using System.Linq; | ||
using System.Reflection; | ||
using Terraria; | ||
|
||
namespace InvTweaks | ||
{ | ||
public static class Config | ||
{ | ||
private static readonly FieldInfo[] fields = typeof(Config).GetFields(BindingFlags.Static | BindingFlags.Public); | ||
private static readonly string path = Path.Combine(Main.SavePath, "InvTweaksConf.json"); | ||
|
||
public static bool cursorFill = true; | ||
public static bool helmetSlot = true; | ||
// public static bool shopClick | ||
public static bool lifeCrystalDevour = true; | ||
// public static bool saplingPlacer; | ||
|
||
public static void Load() | ||
{ | ||
if (File.Exists(path)) | ||
{ | ||
string[] array = File.ReadAllLines(path); | ||
for (int i = 0; i < array.Length; i++) | ||
{ | ||
string item = array[i]; | ||
var split = item.Split(':'); | ||
var key = split[0].Trim(); | ||
var value = split.Last().Trim(); | ||
if (fields.Any(x => x.Name == key) && bool.TryParse(value, out bool result)) | ||
{ | ||
fields.FirstOrDefault(x => x.Name == key).SetValue(null, result); | ||
} | ||
} | ||
} | ||
Write(); | ||
} | ||
|
||
public static void Write() | ||
{ | ||
var writer = new StreamWriter(File.Create(path)); | ||
for (int i = 0; i < fields.Length; i++) | ||
{ | ||
FieldInfo fld = fields[i]; | ||
writer.WriteLine(fld.Name + " : " + ((bool)fld.GetValue(null) ? bool.TrueString : bool.FalseString)); | ||
} | ||
writer.Close(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters