Skip to content

Commit

Permalink
integrated standard overlay submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
kareem613 committed Jun 7, 2020
2 parents bc7a26e + 2698fdd commit 7260ef5
Show file tree
Hide file tree
Showing 19 changed files with 730 additions and 4 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
[submodule "SuperMFLib"]
path = SuperMFLib
url = git://github.com/vipoo/SuperMFLib.git
[submodule "plugins/iRacingDirector.Plugin.StandardOverlays"]
path = plugins/iRacingDirector.Plugin.StandardOverlays
url = git://github.com/vipoo/iRacingDirector.Plugin.StandardOverlays.git
[submodule "GitHubReleases"]
path = GitHubReleases
url = git://github.com/vipoo/GitHubReleases.git
Expand Down
1 change: 0 additions & 1 deletion plugins/iRacingDirector.Plugin.StandardOverlays
Submodule iRacingDirector.Plugin.StandardOverlays deleted from 2698fd
21 changes: 21 additions & 0 deletions plugins/iRacingDirector.Plugin.StandardOverlays/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
*.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
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System.Drawing;
using System.Drawing.Drawing2D;

namespace iRacingDirector.Plugin.StandardOverlays
{
public partial class MyPlugin
{
public Driver CamDriver;

void DrawCurrentDriverRow()
{
var position = CamDriver.Position != null ? CamDriver.Position.Value.ToString() : "";
var indicator = CamDriver.Position != null ? CamDriver.Position.Value.Ordinal() : "";

var offset = 5;

Graphics.InRectangle(1920 / 2 - 440 / 2, 980, 70, 40)
.WithBrush(Styles.YellowBrush)
.WithPen(Styles.BlackPen)
.DrawRectangleWithBorder()
.WithFontSizeOf(24)
.WithBrush(Styles.BlackBrush)
.WithStringFormat(StringAlignment.Near)
.Center(cg => cg
.DrawText(position, topOffset: offset)
.AfterText(position)
.MoveRight(3)
.WithFont(Settings.FontName, 18, FontStyle.Bold)
.DrawText(indicator, topOffset: offset)
)

.ToRight(width: 70)
.WithLinearGradientBrush(Styles.White, Styles.WhiteSmoke, LinearGradientMode.BackwardDiagonal)
.DrawRectangleWithBorder()
.WithStringFormat(StringAlignment.Center)
.WithBrush(Styles.BlackBrush)
.DrawText(CamDriver.CarNumber, topOffset: offset)

.ToRight(width: 300)
.WithLinearGradientBrush(Styles.White, Styles.WhiteSmoke, LinearGradientMode.BackwardDiagonal)
.DrawRectangleWithBorder()
.WithStringFormat(StringAlignment.Center)
.WithBrush(Styles.BlackBrush)
.DrawText(CamDriver.UserName, topOffset: offset);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using System;
using System.Drawing;
using System.Drawing.Drawing2D;

namespace iRacingDirector.Plugin.StandardOverlays
{
public static class MyPluginExtensions
{
public static string FormattedForLeaderboard(this string shortName)
{
var length = Math.Min(4, shortName.Length);
return shortName.Substring(0, length).ToUpper();
}

public static GraphicRect DrawGrayBackground(this GraphicRect rr)
{
return rr
.WithBrush(Styles.TransparentLightGray)
.WithPen(Styles.BlackPen)
.DrawRectangleWithBorder();
}

public static GraphicRect WithFontSizeOf(this GraphicRect rr, int fontSize)
{
return rr
.WithFont(Settings.FontName, fontSize, FontStyle.Bold);
}

public static GraphicRect DrawWhiteGradiantBox(this GraphicRect rr)
{
return rr
.WithLinearGradientBrush(Color.DarkGray, Color.White, LinearGradientMode.Vertical)
.WithPen(Styles.BlackPen)
.DrawRectangleWithBorder()
.WithBrush(Styles.BlackBrush);
}

public static GraphicRect DrawRedGradiantBox(this GraphicRect rr)
{
return rr
.WithHeight(rr.Rectangle.Height + 3)
.MoveUp(3)
.WithLinearGradientBrush(Styles.RedBannerDark, Styles.RedBannerLight, LinearGradientMode.Vertical)
.DrawRoundRectangle(5)
.WithBrush(Styles.WhiteBrush);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System;
using System.Drawing;

namespace iRacingDirector.Plugin.StandardOverlays
{
public partial class MyPlugin
{
public FastLap FastLap;

void DrawFastestLap()
{
if (FastLap == null)
return;

const int left = 1920 - 80 - 450;
const int top = 900;

Graphics.InRectangle(left, top + 34, 400, 34)
.DrawRedGradiantBox();

Graphics.InRectangle(left, top + 34, 250, 34)
.WithBrush(Styles.WhiteBrush)
.WithFontSizeOf(19)
.WithStringFormat(StringAlignment.Center)
.DrawText(FastLap.Driver.UserName, topOffset: 5)
.ToRight(width: 150)
.DrawText(TimeSpan.FromSeconds(FastLap.Time).ToString(@"mm\:ss\.fff"), topOffset: 5);

Graphics.InRectangle(left, top, 400, 34)
.DrawWhiteGradiantBox()
.WithBrush(Styles.BlackBrush)
.WithFontSizeOf(18)
.WithStringFormat(StringAlignment.Center)
.DrawText("New Fast Lap", topOffset: 5);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System.Drawing;

namespace iRacingDirector.Plugin.StandardOverlays
{
public partial class MyPlugin
{
GraphicRect DrawFlashCardHeading(string title)
{
var displayName = EventData.WeekendInfo.TrackDisplayName.ToUpper();

Graphics.InRectangle(FlashCardLeft, 250, FlashCardWidth, 575)
.DrawGrayBackground();

Graphics.InRectangle(FlashCardLeft - 10, 311 - 2, FlashCardWidth - 100, 48)
.DrawRedGradiantBox()
.MoveDown(7)
.MoveRight(20)
.WithFontSizeOf(23)
.WithStringFormat(StringAlignment.Near)
.DrawText(title, topOffset: 4);

Graphics.InRectangle(FlashCardLeft - 10, 240, FlashCardWidth - 100, 72)
.DrawWhiteGradiantBox()
.MoveDown(7)
.MoveRight(20)
.WithFontSizeOf(23)
.WithStringFormat(StringAlignment.Near)
.DrawText(displayName)
.MoveDown(32)
.WithFontSizeOf(17)
.WithStringFormat(StringAlignment.Near)
.DrawText(EventData.WeekendInfo.TrackCity.ToUpper() + ", " + EventData.WeekendInfo.TrackCountry.ToUpper());

return Graphics.InRectangle(FlashCardLeft + 30, 400, 60, 40)
.WithPen(Styles.BlackPen)
.WithBrush(Styles.BlackBrush)
.WithFontSizeOf(20)
.WithStringFormat(StringAlignment.Near);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using iRacingSDK;
using System;
using System.Drawing;
using System.Linq;

namespace iRacingDirector.Plugin.StandardOverlays
{
public partial class MyPlugin
{
void DrawIntroFlashCard(int page)
{
var r = DrawFlashCardHeading("Qualifying Results");

DrawFlashCardIntro(r, page);
}

void DrawFlashCardIntro(GraphicRect r, int page)
{
var totalWidth = FlashCardWidth;
var left = FlashCardLeft;

var thisPageOfQualifyingResults = EventData.QualifyingResults.Skip(page * DriversPerPage).Take(DriversPerPage);

var offset = 5;
Graphics.InRectangle(left, r.Rectangle.Top, totalWidth, 10)
.WithPen(Styles.ThickBlackPen)
.DrawLine(left + 8, r.Rectangle.Top - offset, left + totalWidth - 16, r.Rectangle.Top - offset);

foreach (var qualifier in thisPageOfQualifyingResults)
{
var driver = EventData.GetCompetingDriverByIndex(qualifier.CarIdx);

r.Center(cg => cg
.DrawText(qualifier.Position.ToString())
.AfterText(qualifier.Position.ToString())
.MoveRight(1)
.WithFont(Settings.FontName, 16, FontStyle.Bold)
.DrawText(qualifier.Position.Ordinal()))
.ToRight(width: 120, left: 30)
.DrawText(TimeSpan.FromSeconds(qualifier.FastestTime).ToString("mm\\:ss\\.ff"))
.ToRight(width: 60)
.DrawText(driver.CarNumber)
.ToRight(width: 300)
.DrawText(driver.UserName);

r = r.ToBelow();

Graphics.InRectangle(left, r.Rectangle.Top, totalWidth, 10)
.WithPen(Styles.ThickBlackPen)
.DrawLine(left + 8, r.Rectangle.Top - offset, left + totalWidth - 16, r.Rectangle.Top - offset);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using System;
using System.Drawing;
using System.Linq;

namespace iRacingDirector.Plugin.StandardOverlays
{
public partial class MyPlugin
{
public Driver[] PreferredDriverNames;

void DrawOutroFlashCard(int page)
{
var r = DrawFlashCardHeading("Race Results");

DrawFlashCardOutro(r, page);
}

void DrawFlashCardOutro(GraphicRect r, int page)
{
var rsession = EventData.Race;
var results = EventData.Results;

var offset = 5;
Graphics.InRectangle(FlashCardLeft, r.Rectangle.Top, FlashCardWidth, 10)
.WithPen(Styles.ThickBlackPen)
.DrawLine(FlashCardLeft + 8, r.Rectangle.Top - offset, FlashCardLeft + FlashCardWidth - 16, r.Rectangle.Top - offset);

var LeaderTime = TimeSpan.FromSeconds(results[0].Time);

foreach (var racerResult in results.Skip(DriversPerPage * page).Take(DriversPerPage))
{
var driver = EventData.GetCompetingDriverByIndex(racerResult.CarIdx);

var Gap = TimeSpan.FromSeconds(racerResult.Time) - LeaderTime; // Gap calculation
if (Gap == TimeSpan.Zero) //For the leader we want to display the race duration
Gap = LeaderTime;

r.WithBrush(PreferredDriverNames.Any(d => d.UserName == driver.UserName) ? Styles.RedBrush : Styles.BlackBrush);

r.Center(cg => cg
.DrawText(racerResult.Position.ToString())
.AfterText(racerResult.Position.ToString())
.MoveRight(1)
.WithFont(Settings.FontName, 16, FontStyle.Bold)
.DrawText(racerResult.Position.Ordinal()))
.ToRight(width: 190, left: 30)
.DrawText(Gap.ToString("hh\\:mm\\:ss\\.fff"))
.ToRight(width: 80, left: 20)
.DrawText(driver.CarNumber)
.ToRight(width: 350)
.DrawText(driver.UserName);

r = r.ToBelow();

Graphics.InRectangle(FlashCardLeft, r.Rectangle.Top, FlashCardWidth, 10)
.WithPen(Styles.ThickBlackPen)
.DrawLine(FlashCardLeft + 8, r.Rectangle.Top - offset, FlashCardLeft + FlashCardWidth - 16, r.Rectangle.Top - offset);
}
}
}
}
Loading

0 comments on commit 7260ef5

Please sign in to comment.