From ebb9267db7518f1d2dd81006e5730dc479df94d9 Mon Sep 17 00:00:00 2001
From: braker <7152322+araszka@users.noreply.github.com>
Date: Thu, 22 Aug 2024 18:56:02 +0200
Subject: [PATCH] 277 current map redesign (#287)
---
.../Services/CurrentMapService.cs | 17 ++++---
.../Templates/CurrentMapWidget.mt | 50 +++++++++++--------
.../Controllers/NextMapEventController.cs | 2 +-
.../NextMapModule/Templates/NextMap.mt | 41 +++++++--------
4 files changed, 62 insertions(+), 48 deletions(-)
diff --git a/src/Modules/CurrentMapModule/Services/CurrentMapService.cs b/src/Modules/CurrentMapModule/Services/CurrentMapService.cs
index 5ce9d636f..3e4ce7032 100644
--- a/src/Modules/CurrentMapModule/Services/CurrentMapService.cs
+++ b/src/Modules/CurrentMapModule/Services/CurrentMapService.cs
@@ -25,12 +25,12 @@ ICurrentMapSettings settings
public async Task ShowWidgetAsync()
{
var map = await client.Remote.GetCurrentMapInfoAsync();
- await ShowManialinkAsync(map.UId);
+ await ShowManialinkAsync(map.UId, map.AuthorTime);
}
public async Task ShowWidgetAsync(MapGbxEventArgs args)
{
- await ShowManialinkAsync(args.Map.Uid);
+ await ShowManialinkAsync(args.Map.Uid, args.Map.AuthorTime);
}
public async Task HideWidgetAsync()
@@ -39,7 +39,7 @@ public async Task HideWidgetAsync()
logger.LogDebug("Hiding current map widget");
}
- private async Task ShowManialinkAsync(string mapUId)
+ private async Task ShowManialinkAsync(string mapUId, int authorTime)
{
var dbMap = await mapRepository.GetMapByUidAsync(mapUId);
@@ -48,16 +48,19 @@ private async Task ShowManialinkAsync(string mapUId)
return;
}
- var author = dbMap.Author?.NickName;
+ var authorNickName = dbMap.Author?.NickName ?? "Unknown";
- if (dbMap.Author?.NickName == dbMap.Author?.AccountId)
+ if (authorNickName == dbMap.Author?.AccountId)
{
var serverMap = await client.Remote.GetCurrentMapInfoAsync();
- author = serverMap.AuthorNickname.Length > 0 ? serverMap.AuthorNickname : serverMap.Author;
+ authorNickName = serverMap.AuthorNickname.Length > 0 ? serverMap.AuthorNickname : serverMap.Author;
}
+ logger.LogDebug("Current map {mapName} by {author} ({authorTime}).", dbMap.Name, authorNickName, authorTime);
+
await manialinkManager.SendPersistentManialinkAsync("CurrentMapModule.CurrentMapWidget",
- new { map = dbMap, mapAuthor = author, settings });
+ new { map = dbMap, mapAuthor = authorNickName, authorTime, settings });
+
logger.LogDebug("Showing current map widget");
}
}
diff --git a/src/Modules/CurrentMapModule/Templates/CurrentMapWidget.mt b/src/Modules/CurrentMapModule/Templates/CurrentMapWidget.mt
index eb3816eb2..4ee877e8f 100644
--- a/src/Modules/CurrentMapModule/Templates/CurrentMapWidget.mt
+++ b/src/Modules/CurrentMapModule/Templates/CurrentMapWidget.mt
@@ -6,30 +6,40 @@
-
-
+
+
+
-
+
-
-
-
-
+
+
+
diff --git a/src/Modules/NextMapModule/Controllers/NextMapEventController.cs b/src/Modules/NextMapModule/Controllers/NextMapEventController.cs
index 924198a57..543449b28 100644
--- a/src/Modules/NextMapModule/Controllers/NextMapEventController.cs
+++ b/src/Modules/NextMapModule/Controllers/NextMapEventController.cs
@@ -25,7 +25,7 @@ public async Task ShowNextMapOnPodiumStartAsync(object sender, PodiumEventArgs a
{
var nextMap = await nextMapService.GetNextMapAsync();
await manialinkManager.SendManialinkAsync(Template,
- new { mapName = nextMap.Name, author = nextMap.Author?.NickName, settings });
+ new { mapName = nextMap.Name, mapAuthor = nextMap.Author?.NickName ?? "Unknown", settings });
}
[Subscribe(GbxRemoteEvent.BeginMap)]
diff --git a/src/Modules/NextMapModule/Templates/NextMap.mt b/src/Modules/NextMapModule/Templates/NextMap.mt
index a601d30e8..fe7781b15 100644
--- a/src/Modules/NextMapModule/Templates/NextMap.mt
+++ b/src/Modules/NextMapModule/Templates/NextMap.mt
@@ -6,30 +6,31 @@
-
-
+
+
-
+
-
-
-
-
+
+