Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

276 spec info #308

Merged
merged 70 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
676e475
Update current map design to fit mockup
araszka Aug 20, 2024
f669ff6
Update next map widget design
araszka Aug 20, 2024
fe7f07c
Center author name in next map widget
araszka Aug 20, 2024
1f3da08
Merge remote-tracking branch 'origin/master' into 277-current-map-red…
araszka Aug 24, 2024
7dd5d85
Show correct diffs in spectator target info and update design
araszka Aug 24, 2024
9b94fc4
Stash
araszka Aug 26, 2024
face066
Add SpectatorTargetInfo tests
araszka Sep 1, 2024
8795740
Add more spectator target info tests
araszka Sep 1, 2024
3b4644d
Send updated widget to spectators if target player changes or is updated
araszka Sep 1, 2024
05c6614
Reset spectator info widgets on new round and hide on podium start
araszka Sep 1, 2024
31e8358
Remove spectators on disconnect and do not update widget if spec targ…
araszka Sep 1, 2024
5a3bdbf
Add team colors in spectator target info
araszka Sep 3, 2024
4cf93fa
Implement change spec target
araszka Sep 7, 2024
63fd01c
Make spectator info module hide Nadeo counterpart
araszka Sep 11, 2024
485d64a
Add request current spectator target after controller start to show w…
araszka Sep 11, 2024
e6a3914
Add custom cam mode widget
araszka Sep 14, 2024
51ed44f
Improve spectator info pad/keyboard detections
araszka Sep 14, 2024
635b3fe
Improve showing/hiding of spectator target info
araszka Sep 14, 2024
1066869
Simplify spectator cam mode module
araszka Sep 15, 2024
06531c4
Add dropup to select cam mode
araszka Sep 15, 2024
68fade0
Add tests for SpectatorCamModeModule
araszka Sep 15, 2024
9eb15f3
Make cam mode menu hidden by default
araszka Sep 15, 2024
c34949f
Improve detection of spectator target and simplify code
araszka Sep 18, 2024
897133e
Use 1 default rank in spectator target
araszka Sep 18, 2024
dce72d3
Fix existing spectator target tests
araszka Sep 18, 2024
751e83a
Remove redundant spec target reporting
araszka Sep 18, 2024
3cf1b98
Add tests for spectator target manialink controller
araszka Sep 18, 2024
e2bf309
Add doc comments for ISpectatorTargetInfoService
araszka Sep 20, 2024
7bbd370
Clean up GameModeUiModule
araszka Sep 21, 2024
ffb3dd6
Remove unnecessary code and add another overload to GameModeUiModuleS…
araszka Sep 21, 2024
6a0bada
Use GameModeUiModule in Scoreboard
araszka Sep 21, 2024
abd2d0f
Load GameModeUiModule before any other module else depndency might fail
araszka Sep 21, 2024
ef652c4
Add SpectatorTargetEventControllerTests
araszka Sep 21, 2024
9cd5692
Add tests for SpectatorTargetInfoService
araszka Sep 21, 2024
e677517
Add tests for CheckpointGroup
araszka Sep 21, 2024
ae3f0db
Fix TeamInfoEventControllerTests
araszka Sep 21, 2024
d262fa5
Merge remote-tracking branch 'origin/master' into 276-spec-info
araszka Sep 21, 2024
0400dc5
Merge fix
araszka Sep 21, 2024
eae31c1
Revert "Merge fix"
araszka Sep 21, 2024
328d6a9
Update SpectatorTargetInfoServiceTests
araszka Sep 21, 2024
77e599f
Remove commented out code from tests
araszka Sep 21, 2024
87a6685
Convert constants to static readonly properties
araszka Sep 21, 2024
c9cd6f9
Replace Moq with EvoSC.Testing reference
araszka Sep 21, 2024
f0e7f13
Fix dependencies in csproj
araszka Sep 21, 2024
7108c29
Add async suffix to methods
araszka Sep 21, 2024
8cfebb9
Add async suffix
araszka Sep 21, 2024
9fa18f1
Use Find instead of FirstOrDefault on List
araszka Sep 21, 2024
bdc18d0
Add curly braces
araszka Sep 21, 2024
0177d13
Fix spectator target tests
araszka Sep 21, 2024
e2b6fc9
Rename tests project to fit module name
araszka Sep 21, 2024
5bb6510
Update src/EvoSC.Common/Interfaces/Models/IPlayer.cs
araszka Sep 29, 2024
c7b685a
Add property comments to GameModeUiComponentSettings
araszka Sep 29, 2024
dbac768
Remove debug code
araszka Sep 29, 2024
9cf59fb
Make GameModeUiModuleService transient lifecycle
araszka Sep 29, 2024
99f2b96
Change log level in SpectatorTargetInfoService
araszka Sep 29, 2024
d8a66e6
Move maniascript of spectator mode to own file
araszka Sep 29, 2024
28df54d
Move SpectatorTargetInfo maniascript to own file
araszka Sep 29, 2024
c14d11b
Follow AAA principle in tests
araszka Sep 29, 2024
92ce113
Fix tests
araszka Sep 29, 2024
f468a93
Add reference to script
araszka Sep 29, 2024
31fa165
Fox show cam mode widget in warmups and do not reset on each new round
araszka Sep 30, 2024
732d691
Make cam mode selection equal width
araszka Sep 30, 2024
2d2c9ce
Prevent script error when changing spec target with one player on server
araszka Sep 30, 2024
1bceaa1
Always format time the same way in spec info
araszka Sep 30, 2024
0d508c7
Add warmup round mode script events
araszka Sep 30, 2024
f5efb78
Reset spectator target info on new warmup rounds
araszka Sep 30, 2024
ebc1916
Resend spectator target info to spectators on new rounds
araszka Sep 30, 2024
c9adf6e
Only show spec info and cam selection if UI sequence "playing"
araszka Sep 30, 2024
69ebdad
Merge remote-tracking branch 'origin/master' into 276-spec-info
araszka Sep 30, 2024
4bf996f
Remove controller
araszka Sep 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/EvoSC.Common/Remote/EventArgsModels/WarmUpRoundEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace EvoSC.Common.Remote.EventArgsModels;

public class WarmUpRoundEventArgs: EventArgs
{
/// <summary>
/// The current warm-up round.
/// </summary>
public required int Current { get; init; }

/// <summary>
/// The total amount of warm-ups.
/// </summary>
public required int Total { get; init; }
}
12 changes: 12 additions & 0 deletions src/EvoSC.Common/Remote/ModeScriptEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ public enum ModeScriptEvent
[Identifier(Name = "ModeScript.WarmUpStart")]
WarmUpStart,

/// <summary>
/// When a warm-up round starts.
/// </summary>
[Identifier(Name = "ModeScript.WarmUpStartRound")]
WarmUpStartRound,

/// <summary>
/// When a warm-up round starts.
/// </summary>
[Identifier(Name = "ModeScript.WarmUpEndRound")]
WarmUpEndRound,

/// <summary>
/// When a player got eliminated by an obstacle.
/// </summary>
Expand Down
16 changes: 16 additions & 0 deletions src/EvoSC.Common/Remote/ServerCallbackHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,22 @@ await _events.RaiseAsync(ModeScriptEvent.StartLine,
case "Trackmania.WarmUp.Start":
await _events.RaiseAsync(ModeScriptEvent.WarmUpStart, EventArgs.Empty);
break;
case "Trackmania.WarmUp.StartRound":
await _events.RaiseAsync(ModeScriptEvent.WarmUpStartRound,
new WarmUpRoundEventArgs
{
Current = data.GetValue("current", StringComparison.Ordinal).ToObject<int>(),
Total = data.GetValue("total", StringComparison.Ordinal).ToObject<int>()
});
break;
case "Trackmania.WarmUp.EndRound":
await _events.RaiseAsync(ModeScriptEvent.WarmUpEndRound,
new WarmUpRoundEventArgs
{
Current = data.GetValue("current", StringComparison.Ordinal).ToObject<int>(),
Total = data.GetValue("total", StringComparison.Ordinal).ToObject<int>()
});
break;
case "Trackmania.Event.Eliminated":
await _events.RaiseAsync(ModeScriptEvent.Eliminated,
new PlayerUpdateEventArgs
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ public interface ISpectatorCamModeService
/// </summary>
/// <returns></returns>
public Task SendPersistentCamModeWidgetAsync();

/// <summary>
/// Hides the previously send widget.
/// </summary>
/// <returns></returns>
public Task HideCamModeWidgetAsync();

/// <summary>
/// Hides the default UI provided by the game mode.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ ISpectatorCamModeSettings settings
public Task SendPersistentCamModeWidgetAsync() =>
manialinks.SendPersistentManialinkAsync(WidgetTemplate, new { settings });

public Task HideCamModeWidgetAsync() =>
manialinks.HideManialinkAsync(WidgetTemplate);

public Task HideGameModeUiAsync() =>
gameModeUiModuleService.ApplyComponentSettingsAsync(GetGameModeUiSettings());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,24 @@ Void SetCamModeNameAndIcon(Integer _CamMode, CMlFrame camModeFrame) {
}

declare Real spacing = 1.0;
declare Real offset = 0.0;
declare Real width = 0.0;
if (camModeLabel != Null){
camModeLabel.Value = TextLib::ToUpperCase(Text_CamMode);
offset = spacing * 2.0 + camModeLabel.ComputeWidth(camModeLabel.Value);
width = spacing * 2.0 + camModeLabel.ComputeWidth(camModeLabel.Value);
}
if (camModeQuad != Null){
camModeQuad.ImageUrl = Icon_CamMode;
camModeQuad.RelativePosition_V3.X = offset + spacing;
width = width + spacing + camModeQuad.Size.X;
camModeQuad.RelativePosition_V3.X = {{ width }} * 1.0 - spacing - camModeQuad.Size.X;
}
if (camModeLabel != Null){
camModeLabel.Value = TextLib::ToUpperCase(Text_CamMode);
camModeLabel.RelativePosition_V3.X = camModeQuad.RelativePosition_V3.X - spacing;
}
width = width + spacing * 2.0;
camModeFrame.Size.X = width;
camModeBg.Size.X = width;
camModeFrame.Size.X = 32.0;
camModeBg.Size.X = 32.0;

declare Integer targetCamMode for camModeFrame;
targetCamMode = _CamMode;

if({{ settings.Alignment == WidgetPosition.Right ? "True" : "False" }}){
camModeFrame.RelativePosition_V3.X = width * -1.0;
camModeFrame.RelativePosition_V3.X = camModeFrame.Size.X * -1.0;
}else if({{ settings.Alignment == WidgetPosition.Center ? "True" : "False" }}){
camModeFrame.RelativePosition_V3.X = width / -2.0;
camModeFrame.RelativePosition_V3.X = camModeFrame.Size.X / -2.0;
}
}

Expand Down Expand Up @@ -236,7 +231,9 @@ main(){
while(True){
yield;

declare shouldBeDisplayed = InputPlayer != Null && InputPlayer.SpawnStatus == CSmPlayer::ESpawnStatus::NotSpawned;
declare shouldBeDisplayed = InputPlayer != Null
&& InputPlayer.SpawnStatus == CSmPlayer::ESpawnStatus::NotSpawned
&& UI.UISequence == CUIConfig::EUISequence::Playing;

if(!shouldBeDisplayed){
if(mainFrame.Visible){
Expand Down
11 changes: 6 additions & 5 deletions src/Modules/SpectatorCamModeModule/Templates/SpectatorMode.mt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<property type="ISpectatorCamModeSettings" name="settings"/>
<property type="double" name="width" default="32.0"/>
<property type="double" name="height" default="5.5"/>
<property type="double" name="opacityUnfocused" default="0.1"/>
<property type="double" name="opacityUnfocused" default="0.001"/>

<template>
<UIStyle/>
Expand All @@ -27,6 +27,7 @@
textfont="{{ Font.Bold }}"
text="CAM MODE"
valign="center2"
halign="right"
/>
<quad id="cam_mode_icon"
size="3.5 3.5"
Expand All @@ -43,10 +44,10 @@
size="{{ width }} {{ height * 3.0 }}"
hidden="1"
>
<frameinstance modelid="option"/>
<frameinstance modelid="option"/>
<frameinstance modelid="option"/>
<frameinstance modelid="option"/>
<frameinstance modelid="option" size="{{ width }} {{ height }}"/>
<frameinstance modelid="option" size="{{ width }} {{ height }}"/>
<frameinstance modelid="option" size="{{ width }} {{ height }}"/>
<frameinstance modelid="option" size="{{ width }} {{ height }}"/>
</frame>
</frame>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,14 @@ public async Task OnNewRoundAsync(object sender, RoundEventArgs roundEventArgs)
{
await spectatorTargetInfoService.ClearCheckpointsAsync();
await spectatorTargetInfoService.FetchAndCacheTeamInfoAsync();
await spectatorTargetInfoService.ResetWidgetForSpectatorsAsync();
}

[Subscribe(ModeScriptEvent.WarmUpStartRound)]
public async Task OnNewWarmUpRoundAsync(object sender, WarmUpRoundEventArgs roundEventArgs)
{
await spectatorTargetInfoService.ClearCheckpointsAsync();
await spectatorTargetInfoService.FetchAndCacheTeamInfoAsync();
await spectatorTargetInfoService.ResetWidgetForSpectatorsAsync();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,37 +70,37 @@ Void FocusPlayer(CSmPlayer _Player) {
}
}

Text SpecPrevious(CMlLabel button, Boolean focus){
Void SpecPrevious(CMlLabel button, Boolean focus){
AnimatePop(button);
declare CSmPlayer target <=> GetNextSpawnedPlayer();
if(focus){
if(target == Null && focus){
FocusPlayer(target);
}
return target.User.Login;
}

Text SpecNext(CMlLabel button, Boolean focus){
Void SpecNext(CMlLabel button, Boolean focus){
AnimatePop(button);
declare CSmPlayer target <=> GetNextSpawnedPlayer();
if(focus){
if(target != Null && focus){
FocusPlayer(target);
}
return target.User.Login;
}

main() {
declare mainFrame <=> (Page.MainFrame.GetFirstChild("main_frame") as CMlFrame);
declare previousButton <=> (Page.MainFrame.GetFirstChild("left_button") as CMlLabel);
declare nextButton <=> (Page.MainFrame.GetFirstChild("right_button") as CMlLabel);
declare targetLogin = "{{ playerLogin }}";

while(True){
yield;

if(GUIPlayer == Null){
declare shouldBeDisplayed = GUIPlayer != Null && UI.UISequence == CUIConfig::EUISequence::Playing;

if(!shouldBeDisplayed){
if(mainFrame.Visible){
mainFrame.Hide();
}
sleep(100);
continue;
}

Expand All @@ -122,10 +122,10 @@ main() {
foreach(Event in PendingEvents){
if(Event.Type == CMlScriptEvent::Type::MouseClick){
if(Event.Control == previousButton){
targetLogin = SpecPrevious(previousButton, True);
SpecPrevious(previousButton, True);
continue;
}else if(Event.Control == nextButton){
targetLogin = SpecNext(nextButton, True);
SpecNext(nextButton, True);
continue;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
size="{{ (h*3.4)*0.8 }} {{ h }}"
textsize="{{ Theme.UI_FontSize*2 }}"
textfont="{{ Font.Regular }}"
text='{{ timeDifference > 0 ? RaceTime.FromMilliseconds(timeDifference) : "000" }}'
text='{{ RaceTime.FromMilliseconds(timeDifference) }}'
textprefix="+"
halign="center"
valign="center2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,6 @@ public async Task SendsPersistentCamModeWidget()
m.SendPersistentManialinkAsync("SpectatorCamModeModule.SpectatorMode", It.IsAny<object>()), Times.Once);
}

[Fact]
public async Task HidesCamModeWidget()
{
var camModeService = CamModeServiceMock();
await camModeService.HideCamModeWidgetAsync();

_manialinkManager.Verify(m =>
m.HideManialinkAsync("SpectatorCamModeModule.SpectatorMode"), Times.Once);
}

[Fact]
public async Task HidesDefaultGameModeUi()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,13 @@ public async Task Resets_Collected_Data_On_New_Round()
_spectatorTargetService.Verify(sts => sts.ClearCheckpointsAsync());
_spectatorTargetService.Verify(sts => sts.FetchAndCacheTeamInfoAsync());
}

[Fact]
public async Task Resets_Collected_Data_On_New_Warm_Up_Round()
{
await Controller.OnNewWarmUpRoundAsync(null, new WarmUpRoundEventArgs { Total = 3, Current = 1 });

_spectatorTargetService.Verify(sts => sts.ClearCheckpointsAsync());
_spectatorTargetService.Verify(sts => sts.FetchAndCacheTeamInfoAsync());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0"/>
<PackageReference Include="xunit" Version="2.4.2"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
Expand Down
Loading