forked from vipoo/iRacingReplayOverlay.net
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
897 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule iRacingDirector.Plugin.Support
deleted from
96a770
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
*.suo | ||
*.userprefs | ||
**/bin/* | ||
**/obj/* | ||
**/SampleRaceStream.bin | ||
packages/ | ||
TestResult.xml | ||
iRacingReplayOverlay.net.Tests.VisualState.xml | ||
publish/ | ||
publish-beta/ | ||
**/*.csproj.user | ||
**/*.log | ||
deploy/* | ||
!deploy/.keep | ||
!deploy/test/.keep | ||
Application Files | ||
setup.exe | ||
iRacingReplayOverlay.test.application | ||
.vs/* | ||
tools/encrypt.cmd | ||
Aws/AwsKeyActual.cs | ||
iRacingDirector.Plugin.StandardOverlays | ||
|
25 changes: 25 additions & 0 deletions
25
plugins/iRacingDirector.Plugin.Support/iRacingDirector.Plugin.Support.nuspec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0"?> | ||
<package > | ||
<metadata> | ||
<id>iRacingDirector.Plugin.Support</id> | ||
<version>$version$</version> | ||
<title>iRacingDirector.Plugin.Support</title> | ||
<authors>Dean Netherton</authors> | ||
<owners>Dean Netherton</owners> | ||
<projectUrl>https://github.com/vipoo/iRacingDirector.Plugin.Support.Net</projectUrl> | ||
<licenseUrl>https://github.com/vipoo/iRacingDirector.Plugin.Support.Net/blob/master/LICENSE.txt</licenseUrl> | ||
<requireLicenseAcceptance>false</requireLicenseAcceptance> | ||
<description> | ||
Testing tools and support library for building plugins for iRacing Replay Director application | ||
</description> | ||
<copyright>Copyright 2016</copyright> | ||
<tags>iRacing, Replay Director, iRacingDirector.Plugin.Tester</tags> | ||
<dependencies> | ||
<dependency id="iRacingSDK" version="1.0.0.36" /> | ||
</dependencies> | ||
</metadata> | ||
<files> | ||
<file src="iRacingDirector.Plugin.Support\bin\Release\iRacingDirector.Plugin.Support.dll" target="lib\net40-client" /> | ||
<file src="iRacingDirector.Plugin.Support\bin\Release\iRacingDirector.Plugin.Support.pdb" target="lib\net40-client" /> | ||
</files> | ||
</package> |
55 changes: 55 additions & 0 deletions
55
plugins/iRacingDirector.Plugin.Support/iRacingDirector.Plugin.Support.sln
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 14 | ||
VisualStudioVersion = 14.0.24720.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "iRacingDirector.Plugin.Tester", "iRacingDirector.Plugin.Tester\iRacingDirector.Plugin.Tester.csproj", "{96FA1C80-396C-4792-9E8B-C7CBFC25833D}" | ||
ProjectSection(ProjectDependencies) = postProject | ||
{5916B84C-0264-4102-9CCC-28006D84E4FA} = {5916B84C-0264-4102-9CCC-28006D84E4FA} | ||
EndProjectSection | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{47DC23CA-4D17-4C6D-B37A-3D8C7674E19A}" | ||
ProjectSection(SolutionItems) = preProject | ||
iRacingDirector.Plugin.Support.nuspec = iRacingDirector.Plugin.Support.nuspec | ||
todo.txt = todo.txt | ||
EndProjectSection | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{042C5E84-A181-4765-B28F-4670347793E7}" | ||
ProjectSection(SolutionItems) = preProject | ||
tools\download-main-app.cmd = tools\download-main-app.cmd | ||
tools\package.cmd = tools\package.cmd | ||
EndProjectSection | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "iRacingDirector.Plugin.StandardOverlays", "iRacingDirector.Plugin.StandardOverlays\iRacingDirector.Plugin.StandardOverlays.csproj", "{5916B84C-0264-4102-9CCC-28006D84E4FA}" | ||
ProjectSection(ProjectDependencies) = postProject | ||
{CEC2BB31-324D-41E3-83C8-A5C35C63129B} = {CEC2BB31-324D-41E3-83C8-A5C35C63129B} | ||
EndProjectSection | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "iRacingDirector.Plugin.Support", "iRacingDirector.Plugin.Support\iRacingDirector.Plugin.Support.csproj", "{CEC2BB31-324D-41E3-83C8-A5C35C63129B}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{96FA1C80-396C-4792-9E8B-C7CBFC25833D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{96FA1C80-396C-4792-9E8B-C7CBFC25833D}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{96FA1C80-396C-4792-9E8B-C7CBFC25833D}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{96FA1C80-396C-4792-9E8B-C7CBFC25833D}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{5916B84C-0264-4102-9CCC-28006D84E4FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{5916B84C-0264-4102-9CCC-28006D84E4FA}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{5916B84C-0264-4102-9CCC-28006D84E4FA}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{5916B84C-0264-4102-9CCC-28006D84E4FA}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{CEC2BB31-324D-41E3-83C8-A5C35C63129B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{CEC2BB31-324D-41E3-83C8-A5C35C63129B}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{CEC2BB31-324D-41E3-83C8-A5C35C63129B}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{CEC2BB31-324D-41E3-83C8-A5C35C63129B}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(NestedProjects) = preSolution | ||
{042C5E84-A181-4765-B28F-4670347793E7} = {47DC23CA-4D17-4C6D-B37A-3D8C7674E19A} | ||
EndGlobalSection | ||
EndGlobal |
77 changes: 77 additions & 0 deletions
77
plugins/iRacingDirector.Plugin.Support/iRacingDirector.Plugin.Support/CenterGraphicRect.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// This file is part of iRacingReplayOverlay. | ||
// | ||
// Copyright 2014 Dean Netherton | ||
// https://github.com/vipoo/iRacingReplayOverlay.net | ||
// | ||
// iRacingReplayOverlay is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// iRacingReplayOverlay is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with iRacingReplayOverlay. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
|
||
using System; | ||
using System.Drawing; | ||
using System.Drawing.Drawing2D; | ||
using System.Windows.Forms; | ||
|
||
namespace iRacingDirector.Plugin | ||
{ | ||
public class CenterGraphicRect : GraphicRect | ||
{ | ||
readonly int left; | ||
readonly int right; | ||
|
||
public CenterGraphicRect(Graphics g, Rectangle r, Brush b, Pen p, Font f, StringFormat sf, int lo, int to) | ||
: base( g, r, b, p, f, sf, lo, to) | ||
{ | ||
this.left = int.MaxValue; | ||
this.right = int.MinValue; | ||
} | ||
|
||
public CenterGraphicRect(Graphics g, Rectangle r, Brush b, Pen p, Font f, StringFormat sf, int lo, int to, int left, int right) | ||
: base( g, r, b, p, f, sf, lo, to) | ||
{ | ||
this.left = left; | ||
this.right = right; | ||
} | ||
|
||
protected override GraphicRect New(Graphics g, Rectangle r, Brush b, Pen p, Font f, StringFormat sf, int lo, int to) | ||
{ | ||
return new CenterGraphicRect(g, r, b, p, f, sf, lo, to, left, right); | ||
} | ||
|
||
internal int Width { get { return right-left; } } | ||
|
||
public override GraphicRect DrawText(string text, int? leftOffset = 0, int? topOffset = 0) | ||
{ | ||
var lo = this.leftOffset; | ||
var to = this.topOffset; | ||
|
||
if (leftOffset.HasValue) | ||
lo = leftOffset.Value; | ||
|
||
if (topOffset.HasValue) | ||
to = topOffset.Value; | ||
|
||
var size = TextRenderer.MeasureText(g, text, f, r.Size, TextFormatFlags.NoPadding); | ||
|
||
var newleft = Math.Min(r.Left + lo, left); | ||
var newRight = Math.Max(right, r.Left + lo + (int)size.Width); | ||
|
||
return new CenterGraphicRect(g, r, b, p, f, sf, lo, to, newleft, newRight); | ||
} | ||
|
||
public override GraphicRect DrawRectangleWithBorder() | ||
{ | ||
return this; | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...ins/iRacingDirector.Plugin.Support/iRacingDirector.Plugin.Support/DescriptionAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
|
||
namespace iRacingDirector.Plugin | ||
{ | ||
[AttributeUsage(AttributeTargets.Field)] | ||
public class DescriptionAttribute : Attribute | ||
{ | ||
public string Description { get; private set; } | ||
|
||
public DescriptionAttribute(string description) | ||
{ | ||
this.Description = description; | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
plugins/iRacingDirector.Plugin.Support/iRacingDirector.Plugin.Support/EventData.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using iRacingSDK; | ||
using System.Linq; | ||
|
||
namespace iRacingDirector.Plugin | ||
{ | ||
public class EventData | ||
{ | ||
private SessionData sessionData; | ||
|
||
public EventData(SessionData sessionData) | ||
{ | ||
this.sessionData = sessionData; | ||
} | ||
|
||
public SessionData._WeekendInfo WeekendInfo | ||
{ get { return sessionData.WeekendInfo; } } | ||
|
||
public SessionData._SessionInfo._Sessions._ResultsPositions[] QualifyingResults | ||
{ get { return sessionData.SessionInfo.Sessions.Qualifying().ResultsPositions; } } | ||
|
||
public SessionData._DriverInfo._Drivers[] CompetingDrivers | ||
{ get { return sessionData.DriverInfo.Drivers; } } | ||
|
||
public SessionData._DriverInfo._Drivers GetCompetingDriverByIndex(long carIdx) | ||
{ | ||
return carIdx < CompetingDrivers.Length ? CompetingDrivers[carIdx] : new SessionData._DriverInfo._Drivers { UserName = "---", CarNumber = "---" }; | ||
} | ||
|
||
public SessionData._SessionInfo._Sessions Race | ||
{ get { return sessionData.SessionInfo.Sessions.First(s => s.SessionType.ToLower().Contains("race")); } } | ||
|
||
public SessionData._SessionInfo._Sessions._ResultsPositions[] Results | ||
{ get { return Race.ResultsPositions ?? new SessionData._SessionInfo._Sessions._ResultsPositions[0]; } } | ||
|
||
public SessionData Raw { get { return sessionData; } } | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
plugins/iRacingDirector.Plugin.Support/iRacingDirector.Plugin.Support/Extensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// This file is part of iRacingReplayOverlay. | ||
// | ||
// Copyright 2014 Dean Netherton | ||
// https://github.com/vipoo/iRacingReplayOverlay.net | ||
// | ||
// iRacingReplayOverlay is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// iRacingReplayOverlay is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with iRacingReplayOverlay. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace iRacingDirector.Plugin | ||
{ | ||
public static class Extensions | ||
{ | ||
public static string Ordinal(this int num) | ||
{ | ||
return Ordinal((long)num); | ||
} | ||
|
||
public static string Ordinal(this long num) | ||
{ | ||
switch (num % 100) | ||
{ | ||
case 11: | ||
case 12: | ||
case 13: | ||
return "th"; | ||
} | ||
|
||
switch (num % 10) | ||
{ | ||
case 1: | ||
return "st"; | ||
case 2: | ||
return "nd"; | ||
case 3: | ||
return "rd"; | ||
default: | ||
return "th"; | ||
} | ||
} | ||
|
||
public static int IndexOf<T>(this IEnumerable<T> self, Func<T, bool> fn) | ||
{ | ||
int i = 0; | ||
foreach (var e in self) | ||
{ | ||
if (fn(e)) | ||
return i; | ||
|
||
i++; | ||
} | ||
|
||
return -1; | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...RacingDirector.Plugin.Support/iRacingDirector.Plugin.Support/FlashCardPagingCalculator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System; | ||
|
||
namespace iRacingDirector.Plugin | ||
{ | ||
public class FlashCardPagingCalculator | ||
{ | ||
static int GetNumberOfPages(EventData eventData, int driversPerPage) | ||
{ | ||
var numberOfDrivers = eventData.CompetingDrivers.Length - 1; | ||
var numberOfPages = Math.Min(numberOfDrivers / driversPerPage, 3); | ||
if (((float)numberOfDrivers % driversPerPage) != 0) | ||
numberOfPages++; | ||
|
||
return numberOfPages; | ||
} | ||
|
||
public static int GetPageNumber(EventData eventData, int driversPerPage, long duration, long timestamp) | ||
{ | ||
var pagePeriod = (float)timestamp / duration; | ||
|
||
var numberOfPages = GetNumberOfPages(eventData, driversPerPage); | ||
var page = (int)Math.Floor(pagePeriod * numberOfPages); | ||
return Math.Min(page, numberOfPages - 1); | ||
} | ||
} | ||
} |
Oops, something went wrong.