Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into atomic-bugfixes
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/EvoSC.Common/Database/MigrationManager.cs
#	src/EvoSC.Common/Database/Migrations/202309211312_XPEvoValues.cs
  • Loading branch information
Alexander Raszka committed Sep 22, 2023
2 parents 09162c9 + b3754cd commit 59e8fd0
Show file tree
Hide file tree
Showing 24 changed files with 622 additions and 30 deletions.
7 changes: 7 additions & 0 deletions EvoSC.sln
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MatchReadyModule.Tests", "t
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModuleManagerModule", "src\Modules\ModuleManagerModule\ModuleManagerModule.csproj", "{65F795D5-058D-4F8D-B8E0-BE3F64E14CDF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SponsorsModule", "src\Modules\SponsorsModule\SponsorsModule.csproj", "{1F628FDD-289C-48C3-B736-B5A13D7EC9F2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -312,6 +314,10 @@ Global
{65F795D5-058D-4F8D-B8E0-BE3F64E14CDF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{65F795D5-058D-4F8D-B8E0-BE3F64E14CDF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{65F795D5-058D-4F8D-B8E0-BE3F64E14CDF}.Release|Any CPU.Build.0 = Release|Any CPU
{1F628FDD-289C-48C3-B736-B5A13D7EC9F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1F628FDD-289C-48C3-B736-B5A13D7EC9F2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1F628FDD-289C-48C3-B736-B5A13D7EC9F2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1F628FDD-289C-48C3-B736-B5A13D7EC9F2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -362,5 +368,6 @@ Global
{1D3B25FA-F807-4428-A520-878A582DCF28} = {DC47658A-F421-4BA4-B617-090A7DFB3900}
{42BCE01C-EBEF-4DB6-A61C-35B63C915AD3} = {6D75D6A2-6ECD-4DE4-96C5-CAD7D134407A}
{65F795D5-058D-4F8D-B8E0-BE3F64E14CDF} = {DC47658A-F421-4BA4-B617-090A7DFB3900}
{1F628FDD-289C-48C3-B736-B5A13D7EC9F2} = {DC47658A-F421-4BA4-B617-090A7DFB3900}
EndGlobalSection
EndGlobal
8 changes: 8 additions & 0 deletions src/EvoSC.Manialinks/Interfaces/IManialinkManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@ public Task SendManialinkAsync(IEnumerable<IPlayer> players, string name) =>
/// <returns></returns>
public Task HideManialinkAsync(IPlayer player, string name);

/// <summary>
/// Hide a manialink from a player.
/// </summary>
/// <param name="playerLogin">The player to hide the manialink from.</param>
/// <param name="name">Name of the manialink to hide.</param>
/// <returns></returns>
public Task HideManialinkAsync(string playerLogin, string name);

/// <summary>
/// Hide a manialink from a set of players.
/// </summary>
Expand Down
6 changes: 6 additions & 0 deletions src/EvoSC.Manialinks/ManialinkManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,12 @@ public Task HideManialinkAsync(IPlayer player, string name)
return _server.Remote.SendDisplayManialinkPageToLoginAsync(player.GetLogin(), manialinkOutput, 3, true);
}

public Task HideManialinkAsync(string playerLogin, string name)
{
var manialinkOutput = CreateHideManialink(name);
return _server.Remote.SendDisplayManialinkPageToLoginAsync(playerLogin, manialinkOutput, 3, true);
}

public Task HideManialinkAsync(IEnumerable<IPlayer> players, string name)
{
var manialinkOutput = CreateHideManialink(name);
Expand Down
1 change: 1 addition & 0 deletions src/EvoSC/EvoSC.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<ProjectReference Include="..\Modules\MatchManagerModule\MatchManagerModule.csproj" />
<ProjectReference Include="..\Modules\ASayModule\ASayModule.csproj" />
<ProjectReference Include="..\Modules\SpectatorTargetInfo\SpectatorTargetInfo.csproj" />
<ProjectReference Include="..\Modules\SponsorsModule\SponsorsModule.csproj" />
<ProjectReference Include="..\Modules\WorldRecordModule\WorldRecordModule.csproj" />
<ProjectReference Include="..\Modules\MotdModule\MotdModule.csproj" />
<ProjectReference Include="..\Modules\Player\Player.csproj" />
Expand Down
4 changes: 3 additions & 1 deletion src/EvoSC/InternalModules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using EvoSC.Modules.Official.PlayerRecords;
using EvoSC.Modules.Official.Scoreboard;
using EvoSC.Modules.Official.SetName;
using EvoSC.Modules.Official.SponsorsModule;
using EvoSC.Modules.Official.WorldRecordModule;
using EvoSC.Modules.Official.XPEvoAdminControl;
using FluentMigrator.Runner.Exceptions;
Expand Down Expand Up @@ -49,7 +50,8 @@ public static class InternalModules
typeof(LiveRankingModule),
typeof(MatchRankingModule),
typeof(ASayModule),
typeof(SpectatorTargetInfoModule)
typeof(SpectatorTargetInfoModule),
typeof(SponsorsModule)
};

/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions src/Modules/MatchTrackerModule/Services/MatchTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ public MatchTracker(ITrackerSettings settings, IPlayerManagerService players, IT

public async Task TrackScoresAsync(ScoresEventArgs scoreArgs)
{
await VerifyTracker();

if (!IsTracking)
{
return;
}

await VerifyTracker();

IMatchState state;

switch (scoreArgs.Section)
Expand Down Expand Up @@ -185,7 +185,7 @@ await _events.RaiseAsync(MatchTrackerEvent.StateTracked,
return _currentTimeline;
}

private async Task VerifyTracker()
private async Task VerifyTracker()
{
if (!_settings.AutomaticTracking && !IsTracking)
{
Expand Down
41 changes: 41 additions & 0 deletions src/Modules/Scoreboard/Controllers/ScoreboardCommandsController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using EvoSC.Commands.Attributes;
using EvoSC.Commands.Interfaces;
using EvoSC.Common.Controllers;
using EvoSC.Common.Controllers.Attributes;
using EvoSC.Common.Interfaces;
using EvoSC.Common.Util;
using EvoSC.Modules.Official.MatchManagerModule.Permissions;
using EvoSC.Modules.Official.Scoreboard.Interfaces;

namespace EvoSC.Modules.Official.Scoreboard.Controllers;

[Controller]
public class ScoreboardCommandsController : EvoScController<ICommandInteractionContext>
{
private readonly IServerClient _server;
private readonly IScoreboardService _scoreboardService;

public ScoreboardCommandsController(IServerClient server, IScoreboardService scoreboardService)
{
_server = server;
_scoreboardService = scoreboardService;
}

[ChatCommand("sb", "[Command.ShowScoreboard]")]
public async Task ShowScoreboard()
{
await _scoreboardService.ShowScoreboard(Context.Player.GetLogin());
}

[ChatCommand("fake", "[Command.FakePlayer]", MatchManagerPermissions.LoadMatchSettings)]
public async Task FakePlayer()
{
await _server.Remote.ConnectFakePlayerAsync();
await _server.Remote.ConnectFakePlayerAsync();
await _server.Remote.ConnectFakePlayerAsync();
await _server.Remote.ConnectFakePlayerAsync();
await _server.Remote.ConnectFakePlayerAsync();
await _server.Remote.ConnectFakePlayerAsync();
await _server.Remote.ConnectFakePlayerAsync();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using EvoSC.Common.Controllers.Attributes;
using EvoSC.Common.Util;
using EvoSC.Manialinks;
using EvoSC.Modules.Official.Scoreboard.Interfaces;

namespace EvoSC.Modules.Official.Scoreboard.Controllers;

[Controller]
public class ScoreboardManialinkController : ManialinkController
{
private readonly IScoreboardService _scoreboardService;

public ScoreboardManialinkController(IScoreboardService scoreboardService)
{
_scoreboardService = scoreboardService;
}

public Task ResendScoreboardAsync()
{
return _scoreboardService.ShowScoreboard(Context.Player.GetLogin());
}
}
4 changes: 4 additions & 0 deletions src/Modules/Scoreboard/Interfaces/IScoreboardService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ public interface IScoreboardService
/// </summary>
public Task ShowScoreboard();
/// <summary>
/// Sends the scoreboard manialink to a specific players.
/// </summary>
public Task ShowScoreboard(string playerLogin);
/// <summary>
/// Hide the default game scoreboard.
/// </summary>
public Task HideNadeoScoreboard();
Expand Down
5 changes: 5 additions & 0 deletions src/Modules/Scoreboard/Services/ScoreboardService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ public async Task ShowScoreboard()
await _manialinks.SendPersistentManialinkAsync("Scoreboard.Scoreboard", await GetData());
}

public async Task ShowScoreboard(string playerLogin)
{
await _manialinks.SendManialinkAsync(playerLogin, "Scoreboard.Scoreboard", await GetData());
}

private Task<dynamic> GetData()
{
return Task.FromResult<dynamic>(new
Expand Down
6 changes: 6 additions & 0 deletions src/Modules/Scoreboard/Templates/Scoreboard.mt
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,12 @@
ToggleShowSettings();
}
***

*** OnScriptExecutionFinished ***
***
sleep(5000);
TriggerPageAction("ScoreboardManialinkController/ResendScoreboard");
***
-->
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using EvoSC.Common.Controllers.Context;
using EvoSC.Common.Events.Attributes;
using EvoSC.Common.Remote;
using EvoSC.Common.Remote.EventArgsModels;
using GbxRemoteNet.Events;
using SpectatorTargetInfo.Interfaces;

Expand All @@ -21,4 +22,16 @@ public SpectatorTargetInfoEventController(ISpectatorTargetInfoService spectatorT
[Subscribe(GbxRemoteEvent.PlayerConnect)]
public Task OnPlayerConnect(object x, PlayerConnectGbxEventArgs args) =>
_spectatorTargetInfoService.SendManiaLink(args.Login);

[Subscribe(ModeScriptEvent.WayPoint)]
public Task OnWayPoint(object sender, WayPointEventArgs wayPointEventArgs) =>
_spectatorTargetInfoService.ForwardCheckpointTimeToClients(wayPointEventArgs);

[Subscribe(ModeScriptEvent.StartRoundStart)]
public Task OnNewRound(object sender, RoundEventArgs roundEventArgs) =>
_spectatorTargetInfoService.ResetCheckpointTimes();

[Subscribe(ModeScriptEvent.GiveUp)]
public Task OnPlayerGiveUp(object sender, PlayerUpdateEventArgs playerUpdateEventArgs) =>
_spectatorTargetInfoService.ForwardDnf(playerUpdateEventArgs);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace SpectatorTargetInfo.Interfaces;
using EvoSC.Common.Remote.EventArgsModels;

namespace SpectatorTargetInfo.Interfaces;

public interface ISpectatorTargetInfoService
{
Expand All @@ -22,4 +24,16 @@ public interface ISpectatorTargetInfoService
/// Shows the default spectator info.
/// </summary>
public Task ShowNadeoSpectatorInfo();
/// <summary>
/// Maps wayPointEventArgs and sends data to clients.
/// </summary>
public Task ForwardCheckpointTimeToClients(WayPointEventArgs wayPointEventArgs);
/// <summary>
/// Clears the checkpoint times for the clients.
/// </summary>
public Task ResetCheckpointTimes();
/// <summary>
/// Sends players DNF to clients.
/// </summary>
public Task ForwardDnf(PlayerUpdateEventArgs playerUpdateEventArgs);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using EvoSC.Common.Config.Models;
using EvoSC.Common.Interfaces;
using EvoSC.Common.Remote.EventArgsModels;
using EvoSC.Common.Services.Attributes;
using EvoSC.Common.Services.Models;
using EvoSC.Manialinks.Interfaces;
Expand Down Expand Up @@ -37,8 +38,8 @@ private async Task<dynamic> GetWidgetData()
{
return new
{
primaryColor = _config.Theme.UI.PrimaryColor,
backgroundColor = _config.Theme.UI.BackgroundColor,
primaryColor = _config.Theme.UI.PrimaryColor,
backgroundColor = _config.Theme.UI.BackgroundColor,
headerColor = _config.Theme.UI.HeaderBackgroundColor
};
}
Expand Down Expand Up @@ -84,4 +85,31 @@ public Task ShowNadeoSpectatorInfo()

return _server.Remote.TriggerModeScriptEventArrayAsync("Common.UIModules.SetProperties", hudSettings.ToArray());
}

public Task ForwardCheckpointTimeToClients(WayPointEventArgs wayPointEventArgs)
{
return _manialinks.SendManialinkAsync("SpectatorTargetInfo.NewCpTime",
new
{
accountId = wayPointEventArgs.AccountId,
time = wayPointEventArgs.RaceTime,
cpIndex = wayPointEventArgs.CheckpointInRace
});
}

public Task ResetCheckpointTimes()
{
_manialinks.HideManialinkAsync("SpectatorTargetInfo.NewCpTime");
return _manialinks.SendManialinkAsync("SpectatorTargetInfo.ResetCpTimes");
}

public Task ForwardDnf(PlayerUpdateEventArgs playerUpdateEventArgs)
{
return _manialinks.SendManialinkAsync("SpectatorTargetInfo.NewCpTime", new
{
accountId = playerUpdateEventArgs.AccountId,
time = 0,
cpIndex = -1
});
}
}
24 changes: 24 additions & 0 deletions src/Modules/SpectatorTargetInfo/Templates/NewCpTime.mt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<component>
<property type="string" name="accountId" />
<property type="int" name="cpIndex" />
<property type="int" name="time" />

<template>
</template>

<script><!--
#Struct EvoSC_CheckpointTime {
Text AccountId;
Integer CpIndex;
Integer Time;
}

main() {
declare EvoSC_CheckpointTime[Text] EvoCheckpointTimes for UI;
declare Integer EvoCheckpointTimesUpdate for UI;

EvoCheckpointTimes["{{ accountId }}"] = EvoSC_CheckpointTime{ AccountId = "{{ accountId }}", Time = {{ time }}, CpIndex = {{ cpIndex }} };
EvoCheckpointTimesUpdate = Now;
}
--></script>
</component>
22 changes: 22 additions & 0 deletions src/Modules/SpectatorTargetInfo/Templates/ResetCpTimes.mt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<component>
<template>
</template>

<script><!--
#Struct EvoSC_CheckpointTime {
Text AccountId;
Integer CpIndex;
Integer Time;
}

main() {
declare EvoSC_CheckpointTime[Text] EvoCheckpointTimes for UI;
declare Integer EvoCheckpointTimesUpdate for UI;
declare Boolean EvoCheckpointTimesReset for UI = False;

EvoCheckpointTimes = EvoSC_CheckpointTime[Text];
EvoCheckpointTimesUpdate = Now;
EvoCheckpointTimesReset = True;
}
--></script>
</component>
Loading

0 comments on commit 59e8fd0

Please sign in to comment.