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

Add Settings Menu #31

Closed
wants to merge 9 commits into from
Closed
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
6 changes: 5 additions & 1 deletion Client/PresenceCommon/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ public static RichPresence CreateDiscordPresence(Title title, Timestamps time, s
presence.Details = $"Playing {title.Name}";
}
presence.Assets = assets;
presence.Timestamps = time;

if (time != null)
{
presence.Timestamps = time;
}

return presence;
}
Expand Down
59 changes: 55 additions & 4 deletions Client/SwitchPresence-Rewritten-GUI/Config.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,59 @@
namespace SwitchPresence_Rewritten_GUI
using Newtonsoft.Json;
using System.IO;

namespace SwitchPresence_Rewritten_GUI
{
public class Config
public class Config : ConfigData
{
public string IP, Client, BigKey, BigText, SmallKey, State;
public bool DisplayTimer, AllowTray, DisplayMainMenu, SeenAutoMacPrompt, AutoToMac;
public void LoadConfig()
{
if (File.Exists("Config.json"))
{
ConfigData save = JsonConvert.DeserializeObject<ConfigData>(File.ReadAllText("Config.json"));
IP = save.IP;
Client = save.Client;
BigKey = save.BigKey;
BigText = save.BigText;
SmallKey = save.SmallKey;
State = save.State;
DisplayTimer = save.DisplayTimer;
AllowTray = save.AllowTray;
DisplayMainMenu = save.DisplayMainMenu;
SeenAutoMacPrompt = save.SeenAutoMacPrompt;
AutoToMac = save.AutoToMac;
IsFirstRun = save.IsFirstRun;
AllowCustomKeyText = save.AllowCustomKeyText;
}
else
{
// A few defaults we want to set on first run go here.
DisplayTimer = true;
AllowTray = true;
SeenAutoMacPrompt = false;
IsFirstRun = true;
AllowCustomKeyText = true;
}
}

public void SaveConfig()
{
ConfigData cfg = new ConfigData()
{
IP = IP,
Client = Client,
BigKey = BigKey,
SmallKey = SmallKey,
State = State,
BigText = BigText,
DisplayTimer = DisplayTimer,
AllowTray = AllowTray,
DisplayMainMenu = DisplayMainMenu,
SeenAutoMacPrompt = SeenAutoMacPrompt,
AutoToMac = AutoToMac,
IsFirstRun = IsFirstRun,
AllowCustomKeyText = AllowCustomKeyText
};
File.WriteAllText("Config.json", JsonConvert.SerializeObject(cfg, Formatting.Indented));
}
}
}
9 changes: 9 additions & 0 deletions Client/SwitchPresence-Rewritten-GUI/ConfigData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace SwitchPresence_Rewritten_GUI
{
public class ConfigData
{
public string IP, Client, BigKey, BigText, SmallKey, State;
public bool DisplayTimer, AllowTray, DisplayMainMenu, SeenAutoMacPrompt,
AutoToMac, IsFirstRun, AllowCustomKeyText;
}
}
295 changes: 122 additions & 173 deletions Client/SwitchPresence-Rewritten-GUI/MainForm.Designer.cs

Large diffs are not rendered by default.

Loading