Skip to content

Commit

Permalink
Merge pull request #2 from developerrowan/main
Browse files Browse the repository at this point in the history
feat(settings): Add checkbox to settings to enable or disable component
  • Loading branch information
therungg authored Dec 22, 2022
2 parents eed570d + 813d6c6 commit a255911
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 10 deletions.
Binary file modified Components/LiveSplit.TheRun.dll
Binary file not shown.
8 changes: 6 additions & 2 deletions UI/Components/CollectorComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public async void HandleResume(object sender, object e)
// TODO: Log or tell user when splits are invalid or when an error occurs. Don't just continue silently.
public async void HandleSplit(object sender, object e)
{
if (!AreSplitsValid()) return;
if (!AreSplitsValid() || !Settings.IsLiveTrackingEnabled) return;

try
{
Expand All @@ -181,7 +181,9 @@ public async void HandleReset(object sender, TimerPhase value)
try
{
SetGameAndCategory();
await UpdateSplitsState();
if (Settings.IsLiveTrackingEnabled)
await UpdateSplitsState();

await UploadSplits();
}
catch { }
Expand All @@ -194,6 +196,8 @@ private bool AreSplitsValid()

public async Task UploadSplits()
{
if (!Settings.IsStatsUploadingEnabled) return;

string UploadKey = Settings.Path;
string FileName = HttpUtility.UrlEncode(GameName) + "-" + HttpUtility.UrlEncode(CategoryName) + ".lss";
string FileUploadUrl = FileUploadBaseUrl + "?filename=" + FileName + "&uploadKey=" + UploadKey;
Expand Down
2 changes: 1 addition & 1 deletion UI/Components/CollectorFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ public class CollectorFactory : IComponentFactory
public string UpdateURL => "https://raw.githubusercontent.com/therungg/LiveSplit.TheRun/main/";
public string XMLURL => UpdateURL + "update.LiveSplit.TheRun.xml";

public Version Version => Version.Parse("0.1.7");
public Version Version => Version.Parse("0.2.0");
}
}
44 changes: 38 additions & 6 deletions UI/Components/CollectorSettings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion UI/Components/CollectorSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,22 @@ public partial class CollectorSettings : UserControl
public LayoutMode Mode { get; set; }

public string Path { get; set; }
public bool IsStatsUploadingEnabled { get; set; }
public bool IsLiveTrackingEnabled { get; set; }

public CollectorSettings()
{
InitializeComponent();

txtPath.DataBindings.Add("Text", this, "Path", false, DataSourceUpdateMode.OnPropertyChanged);
chkStatsUploadEnabled.DataBindings.Add("Checked", this, "IsStatsUploadingEnabled",
false, DataSourceUpdateMode.OnPropertyChanged);
chkLiveTrackingEnabled.DataBindings.Add("Checked", this, "IsLiveTrackingEnabled",
false, DataSourceUpdateMode.OnPropertyChanged);

Path = "";
IsStatsUploadingEnabled = true;
IsLiveTrackingEnabled = true;
}

public void SetSettings(XmlNode node)
Expand All @@ -26,6 +34,8 @@ public void SetSettings(XmlNode node)

Version version = SettingsHelper.ParseVersion(element["Version"]);
Path = SettingsHelper.ParseString(element["Path"]);
IsStatsUploadingEnabled = SettingsHelper.ParseBool(element["IsStatsUploadingEnabled"]);
IsLiveTrackingEnabled = SettingsHelper.ParseBool(element["IsLiveTrackingEnabled"]);
}

public XmlNode GetSettings(XmlDocument document)
Expand All @@ -43,7 +53,11 @@ public int GetSettingsHashCode()
private int CreateSettingsNode(XmlDocument document, XmlElement parent)
{
return SettingsHelper.CreateSetting(document, parent, "Version", "1.0.0") ^
SettingsHelper.CreateSetting(document, parent, "Path", Path);
SettingsHelper.CreateSetting(document, parent, "Path", Path) ^
SettingsHelper.CreateSetting(document, parent,
"IsStatsUploadingEnabled", IsStatsUploadingEnabled) ^
SettingsHelper.CreateSetting(document, parent,
"IsLiveTrackingEnabled", IsLiveTrackingEnabled);
}

private void txtPath_TextChanged(object sender, EventArgs e)
Expand Down
9 changes: 9 additions & 0 deletions update.LiveSplit.TheRun.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
<updates>
<update version="0.2.0">
<files>
<file path="Components/LiveSplit.TheRun.dll" status="changed" />
</files>
<changelog>
<change>Added checkbox to layout settings to enable / disable stats uploading.</change>
<change>Added checkbox to layout settings to enable / disable live tracking.</change>
</changelog>
</update>
<update version="0.1.7">
<files>
<file path="Components/LiveSplit.TheRun.dll" status="changed" />
Expand Down

0 comments on commit a255911

Please sign in to comment.