Skip to content

Commit

Permalink
-Readjusted config folder creation positioning for simplicity.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nagord committed Nov 22, 2022
1 parent 58157e7 commit 9d80f8a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion PulsarModLoader/SaveData/PMLSaveData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ public abstract class PMLSaveData
public abstract string Identifier();
public virtual uint VersionID => 0;
public abstract byte[] SaveData();
public abstract void LoadData(byte[] Aata, uint VersionID);
public abstract void LoadData(byte[] Data, uint VersionID);
}
}
18 changes: 8 additions & 10 deletions PulsarModLoader/SaveValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ internal class SaveValueManager
{
public static string GetConfigFolder()
{
return Path.Combine(Directory.GetCurrentDirectory(), "ModConfigs");
}
string ModConfigDir = Path.Combine(Directory.GetCurrentDirectory(), "ModConfigs");
if (!Directory.Exists(ModConfigDir))
{
Directory.CreateDirectory(ModConfigDir);
}
return ModConfigDir;
}

private static JsonSerializerSettings serializerSettings;
static SaveValueManager()
Expand Down Expand Up @@ -56,15 +61,8 @@ internal static T GetValueFor<T>(string id, Assembly mod, T @default)

private static string GetConfigFile(Assembly mod)
{
//Create ModConfigs Directory for SaveValue class
string ModConfigDir = GetConfigFolder();
if (!Directory.Exists(ModConfigDir))
{
Directory.CreateDirectory(ModConfigDir);
}

if (ModToConfigFile.ContainsKey(mod)) return ModToConfigFile[mod];
string newFile = Path.Combine(ModConfigDir, mod.GetName().Name + ".json");
string newFile = Path.Combine(GetConfigFolder(), mod.GetName().Name + ".json");
ModToConfigFile.Add(mod, newFile);
if (!ModToCacheValues.ContainsKey(mod) && File.Exists(newFile))
ModToCacheValues.Add(mod, JsonConvert.DeserializeObject<Dictionary<string, string>>(File.ReadAllText(newFile)));
Expand Down

0 comments on commit 9d80f8a

Please sign in to comment.