Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Give json settings the touch" #591

Merged
merged 1 commit into from
Jul 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion PoGo.NecroBot.CLI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private static void Main()

machine.SetFailureState(new LoginState());

GlobalSettings settings = GlobalSettings.Load("\\configs\\config.json");
GlobalSettings settings = GlobalSettings.Load("\\config\\config.json");

var context = new Context(new ClientSettings(settings), new LogicSettings(settings));
context.Client.Login.GoogleDeviceCodeEvent += LoginWithGoogle;
Expand Down
30 changes: 15 additions & 15 deletions PoGo.NecroBot.CLI/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ namespace PoGo.NecroBot.CLI
{
internal class AuthSettings
{
//Default Auth Settings
public AuthType AuthType = AuthType.Google;
public string GoogleRefreshToken = "";
public string PtcPassword = "username2";
public string PtcUsername = "pw";

[JsonIgnore]
private string _filePath;
private string FilePath;

public void Load(string path)
{
_filePath = path;
FilePath = path;

if (File.Exists(_filePath))
if (File.Exists(FilePath))
{
var input = File.ReadAllText(_filePath);
//if the file exists, load the settings
var input = File.ReadAllText(FilePath);

JsonSerializerSettings settings = new JsonSerializerSettings();
settings.Converters.Add(new StringEnumConverter { CamelCaseText = true });
Expand All @@ -43,7 +43,7 @@ public void Load(string path)
}
else
{
Save(_filePath);
Save(FilePath);
}
}

Expand All @@ -62,9 +62,9 @@ public void Save(string path)

public void Save()
{
if(!string.IsNullOrEmpty(_filePath))
if(!string.IsNullOrEmpty(FilePath))
{
Save(_filePath);
Save(FilePath);
}
}
}
Expand All @@ -73,9 +73,6 @@ public class GlobalSettings
{
public static GlobalSettings Default => new GlobalSettings();

[JsonIgnore]
internal AuthSettings Auth = new AuthSettings();

private static string GetAuthPath(string path)
{
var fullPath = Directory.GetCurrentDirectory() + path;
Expand All @@ -92,6 +89,7 @@ public static GlobalSettings Load(string path)
GlobalSettings settings = null;
if (File.Exists(fullPath))
{
//if the file exists, load the settings
var input = File.ReadAllText(fullPath);

JsonSerializerSettings jsonSettings = new JsonSerializerSettings();
Expand Down Expand Up @@ -125,7 +123,6 @@ public void Save(string path)
File.WriteAllText(fullPath, output);
}

//Default Global Settings
public double DefaultAltitude = 10;
public double DefaultLatitude = 52.379189;
public double DefaultLongitude = 4.899431;
Expand All @@ -145,7 +142,10 @@ public void Save(string path)
public bool UseLuckyEggsWhileEvolving = false;
public bool UsePokemonToNotCatchFilter = false;
public double WalkingSpeedInKilometerPerHour = 50;


[JsonIgnore]
internal AuthSettings Auth = new AuthSettings();

public List<KeyValuePair<ItemId, int>> ItemRecycleFilter = new List<KeyValuePair<ItemId, int>>
{
new KeyValuePair<ItemId, int>(ItemId.ItemUnknown, 0),
Expand Down Expand Up @@ -208,7 +208,7 @@ public void Save(string path)

public class ClientSettings : ISettings
{
private readonly GlobalSettings _settings;
private GlobalSettings _settings;

public ClientSettings(GlobalSettings settings)
{
Expand Down Expand Up @@ -238,7 +238,7 @@ public string GoogleRefreshToken

public class LogicSettings : ILogicSettings
{
private readonly GlobalSettings _settings;
private GlobalSettings _settings;

public LogicSettings(GlobalSettings settings)
{
Expand Down