Skip to content

Commit

Permalink
Fixed output, added split index, added update info
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeyHen committed Oct 12, 2022
1 parent 12a33f3 commit cf5c01c
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 16 deletions.
5 changes: 4 additions & 1 deletion LiveSplit.TheRun.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,8 @@
<DependentUpon>CollectorSettings.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Content Include="update.LiveSplit.TheRun.xml" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
</Project>
Binary file added LiveSplit.TheRun.dll
Binary file not shown.
44 changes: 32 additions & 12 deletions UI/Components/CollectorComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public async Task UpdateSplitsState()
private object buildLiveRunData()
{
var run = State.Run;

TimeSpan? CurrentTime = State.CurrentTime[State.CurrentTimingMethod];
List<object> runData = new List<object>();

var MetaData = new
{
Expand All @@ -73,33 +73,53 @@ private object buildLiveRunData()
emulator = run.Metadata.UsesEmulator
};

List<object> runData = new List<object>();

foreach (var segment in run)
{
runData.Add(new
List<object> comparisons = new List<object>();

foreach (string key in segment.Comparisons.Keys)
{
comparisons.Add(new
{
name = key,
time = ConvertTime(segment.Comparisons[key])
});
}

runData.Add(new
{
name = segment.Name,
splitTime = segment.SplitTime,
pbSplitTime = segment.PersonalBestSplitTime,
bestPossible = segment.BestSegmentTime,
comparisons = segment.Comparisons
splitTime = ConvertTime(segment.SplitTime),
pbSplitTime = ConvertTime(segment.PersonalBestSplitTime),
bestPossible = ConvertTime(segment.BestSegmentTime),
comparisons = comparisons
});
}

return new
{
metadata = MetaData,
currentTime = State.CurrentTime,
currentTime = ConvertTime(State.CurrentTime),
currentSplitName = State.CurrentSplit != null ? State.CurrentSplit.Name : "",
currentSplitIndex = State.CurrentSplitIndex,
timingMethod = State.CurrentTimingMethod,
currentDuration = State.CurrentAttemptDuration,
startTime = State.AttemptStarted,
endTime = State.AttemptEnded,
currentDuration = State.CurrentAttemptDuration.TotalMilliseconds,
startTime = State.AttemptStarted.Time.ToUniversalTime(),
endTime = State.AttemptEnded.Time.ToUniversalTime(),
uploadKey = Settings.Path,
runData = runData
};
}

private double? ConvertTime(Time time)
{
if (time[State.CurrentTimingMethod] == null) return null;

TimeSpan timeSpan = (TimeSpan) time[State.CurrentTimingMethod];

return timeSpan.TotalMilliseconds;
}


// 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)
Expand Down
5 changes: 2 additions & 3 deletions UI/Components/CollectorFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ public class CollectorFactory : IComponentFactory

public string UpdateName => ComponentName;

public string XMLURL => "";

public string UpdateURL => "";
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.3");
}
Expand Down
12 changes: 12 additions & 0 deletions update.LiveSplit.TheRun.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<updates>
<update version="0.1.4">
<files>
<file path="Components/LiveSplit.TheRun.dll" status="changed" />
</files>
<changelog>
<change>
Initial release
</change>
</changelog>
</update>
</updates>

0 comments on commit cf5c01c

Please sign in to comment.