Skip to content

Commit

Permalink
Merge pull request #7 from bigbang1112-cz/dev
Browse files Browse the repository at this point in the history
Clip Checkpoint 1.3.1
  • Loading branch information
BigBang1112 committed Nov 24, 2023
2 parents bfa8501 + 52deac7 commit db09d0c
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 8 deletions.
4 changes: 2 additions & 2 deletions ClipCheckpoint/ClipCheckpoint.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<AssemblyTitle>Clip Checkpoint</AssemblyTitle>
<Authors>Petr 'BigBang1112' Pivoňka</Authors>
<Copyright>Copyright © Petr 'BigBang1112' Pivoňka</Copyright>
<Version>1.3.0</Version>
<Version>1.3.1</Version>
</PropertyGroup>

<PropertyGroup>
Expand All @@ -22,7 +22,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="GbxToolAPI" Version="1.0.4" />
<PackageReference Include="GbxToolAPI" Version="1.0.6" />
</ItemGroup>

<ItemGroup>
Expand Down
9 changes: 9 additions & 0 deletions ClipCheckpoint/ClipCheckpointConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ public class ClipCheckpointConfig : Config, IHasTextDictionary<ClipCheckpointDic
[YamlMember(Description = "Scale of the delta time text (multiplied on Scale).")]
public Vec2 DeltaTimeScale { get; set; } = (0.75f, 0.75f);

[YamlMember(Description = "Position offset of the delta delta time text (added on Position).")]
public Vec2 DeltaDeltaTimePositionOffset { get; set; } = (0, -0.17f);

[YamlMember(Description = "Scale of the delta delta time text (multiplied on Scale).")]
public Vec2 DeltaDeltaTimeScale { get; set; } = (0.75f, 0.75f);

[YamlMember(Description = "Color of the delta minus checkpoint time text.")]
[Color]
public Vec4 DeltaNegativeColor { get; set; } = (0, 0, 1, 1);
Expand Down Expand Up @@ -111,6 +117,9 @@ public class ClipCheckpointConfig : Config, IHasTextDictionary<ClipCheckpointDic
[YamlMember(Description = "If the lap counter should be included.")]
public bool IncludeLapCounter { get; set; } = true;

[YamlMember(Description = "If the delta of delta should be included.")]
public bool IncludeDeltaDelta { get; set; } = false;

[YamlMember(Description = "Format of the main checkpoint time text. {0} is the time (X:XX.XXX or X:XX.XX)")]
public string TextCheckpointFormat { get; set; } = "$o$n{0}";

Expand Down
3 changes: 3 additions & 0 deletions ClipCheckpoint/ClipCheckpointDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public class ClipCheckpointDictionary : ITextDictionary
[YamlMember(Description = "Name of the checkpoint delta text track.")]
public string MediaTrackerTrackCheckpointDelta { get; set; } = "CC: Delta";

[YamlMember(Description = "Name of the checkpoint delta delta text track.")]
public string MediaTrackerTrackCheckpointDeltaDelta { get; set; } = "CC: Delta Delta";

[YamlMember(Description = "Name of the lap cross text track.")]
public string MediaTrackerTrackCheckpointLapCross { get; set; } = "CC: Lap Cross";

Expand Down
35 changes: 31 additions & 4 deletions ClipCheckpoint/ClipCheckpointTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,15 @@ public NodeFile<CGameCtnMediaClip> Produce()
var textShadowMediaBlocks = new CGameCtnMediaBlockText[checkpointCount]; // TODO: layering
var textMultilapMediaBlocks = new CGameCtnMediaBlockText[checkpoints.Length - checkpointCountPerLap];
var textDeltaMediaBlocks = new CGameCtnMediaBlockText[deltaGhost is null ? 0 : checkpoints.Length];
var textDeltaDeltaMediaBlocks = new CGameCtnMediaBlockText[deltaGhost is null ? 0 : checkpoints.Length - 1];
var soundMediaBlocks = new CGameCtnMediaBlockSound[Config.IncludeSound ? checkpointCount : 0];

var textMultilapCrossMediaBlocks = new CGameCtnMediaBlockText[laps > 0 ? laps - 1 : 0];
var textMultilapCounterMediaBlocks = new CGameCtnMediaBlockText[isMultilap ? laps : 0];
var lapCounterStartTime = TimeSingle.Zero;

var prevDeltaTime = default(TimeInt32?);

for (var i = 0; i < checkpoints.Length; i++)
{
//Console.WriteLine("Checkpoint {0}:", i + 1);
Expand Down Expand Up @@ -180,6 +183,13 @@ public NodeFile<CGameCtnMediaClip> Produce()
var interval = cp.Time.GetValueOrDefault() - otherGhostTime;

textDeltaMediaBlocks[i] = CreateDeltaMediaBlock(time, isFromTM2, interval);

if (prevDeltaTime.HasValue)
{
textDeltaDeltaMediaBlocks[i - 1] = CreateDeltaDeltaMediaBlock(time, isFromTM2, interval - prevDeltaTime.Value);
}

prevDeltaTime = interval;
}

// If the REAL checkpoint count was reached, ignore the rest of the checkpoints array
Expand Down Expand Up @@ -241,6 +251,13 @@ public NodeFile<CGameCtnMediaClip> Produce()
//Console.Write("Creating media track for the delta text media blocks... ");
trackList.Add(CreateMediaTrack(textDeltaMediaBlocks, name: Config.Dictionary.MediaTrackerTrackCheckpointDelta));
//Console.WriteLine("Done");

if (Config.IncludeDeltaDelta)
{
//Console.Write("Creating media track for the delta delta text media blocks... ");
trackList.Add(CreateMediaTrack(textDeltaDeltaMediaBlocks, name: Config.Dictionary.MediaTrackerTrackCheckpointDeltaDelta));
//Console.WriteLine("Done");
}
}

if (Config.IncludeSound)
Expand Down Expand Up @@ -284,7 +301,7 @@ public NodeFile<CGameCtnMediaClip> Produce()
return new(clip, $"{dir}/{validFileName}", forManiaPlanet);
}

private CGameCtnMediaBlockText CreateDeltaMediaBlock(TimeSpan time, bool isFromTM2, TimeSpan interval)
private CGameCtnMediaBlockText CreateDeltaMediaBlock(TimeSpan time, bool isFromTM2, TimeSpan interval, Vec2 offsetPosition, Vec2 scale)
{
var deltaTimeStr = interval.ToTmString(useHundredths: !isFromTM2);
var isPositiveDelta = interval > TimeSpan.Zero;
Expand All @@ -302,14 +319,24 @@ private CGameCtnMediaBlockText CreateDeltaMediaBlock(TimeSpan time, bool isFromT
//Console.Write("-> Creating checkpoint delta text media block ({0})... ", deltaTimeTextWithoutFormat);
var mediaBlock = CreateCheckpointTextMediaBlock(time,
deltaTimeText,
offsetPosition: Config.DeltaTimePositionOffset,
offsetPosition: offsetPosition,
color: deltaColor,
scale: Config.DeltaTimeScale);
scale: scale);
//Console.WriteLine("Done");

return mediaBlock;
}


private CGameCtnMediaBlockText CreateDeltaMediaBlock(TimeSpan time, bool isFromTM2, TimeSpan interval)
{
return CreateDeltaMediaBlock(time, isFromTM2, interval, Config.DeltaTimePositionOffset, Config.DeltaTimeScale);
}

private CGameCtnMediaBlockText CreateDeltaDeltaMediaBlock(TimeSpan time, bool isFromTM2, TimeSpan interval)
{
return CreateDeltaMediaBlock(time, isFromTM2, interval, Config.DeltaDeltaTimePositionOffset, Config.DeltaDeltaTimeScale);
}

private void ClearOverlappingOnText(params CGameCtnMediaBlockText[][] textMediaBlockSets)
{
foreach (var mediaBlocks in textMediaBlockSets)
Expand Down
4 changes: 2 additions & 2 deletions ClipCheckpointCLI/ClipCheckpointCLI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<AssemblyTitle>Clip Checkpoint CLI</AssemblyTitle>
<Authors>Petr 'BigBang1112' Pivoňka</Authors>
<Copyright>Copyright © Petr 'BigBang1112' Pivoňka</Copyright>
<Version>1.3.0</Version>
<Version>1.3.1</Version>
</PropertyGroup>

<PropertyGroup>
Expand All @@ -25,7 +25,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="GbxToolAPI.CLI" Version="1.0.9" />
<PackageReference Include="GbxToolAPI.CLI" Version="1.0.10" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit db09d0c

Please sign in to comment.