Skip to content

Commit

Permalink
277 current map redesign (#287)
Browse files Browse the repository at this point in the history
  • Loading branch information
araszka authored Aug 22, 2024
1 parent ed4c794 commit ebb9267
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 48 deletions.
17 changes: 10 additions & 7 deletions src/Modules/CurrentMapModule/Services/CurrentMapService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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);

Expand All @@ -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");
}
}
50 changes: 30 additions & 20 deletions src/Modules/CurrentMapModule/Templates/CurrentMapWidget.mt
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,40 @@
<import component="EvoSC.Style.UIStyle" as="UIStyle"/>

<property type="ICurrentMapSettings" name="settings"/>
<property type="IMap?" name="map" default="null"/>
<property type="string" name="mapAuthor" default="null"/>
<property type="IMap" name="map"/>
<property type="string" name="mapAuthor"/>
<property type="int" name="authorTime"/>

<template>
<UIStyle/>
<Widget header="current map" height="10" position="{{ settings.Position }}" y="{{ settings.Y }}">
<Widget height="9" position="{{ settings.Position }}" y="{{ settings.Y + 4.5 }}">
<template slot="body">
<frame pos='{{ settings.Position=="right" ? settings.Width-2.0 : 0 }} 0'>
<label text="{{ map?.Name }}"
class="text-primary"
pos="0 -3"
valign="center"
halign="right"
size="{{ settings.Width-2 }} 5"
/>
<label text="$<$tby {{ mapAuthor }}$>"
class="text-primary"
textsize="0.75"
pos="0 -6.5"
valign="center"
halign="right"
size="{{ settings.Width-2 }} 5"
/>
</frame>
<label text="{{ map.Name }}"
textfont="{{ Font.Bold }}"
textsize="0.75"
class="text-primary"
pos="{{ settings.Width/2.0 }} -2.5"
halign="center"
valign="center"
size="{{ settings.Width-4 }} 5"
/>
<label text="{{ Icons.User }} $<{{ mapAuthor.ToUpper() }}$>"
textprefix="$t"
textfont="{{ Font.Thin }}"
class="text-primary"
textsize="0.35"
pos="2.0 -5.5"
size="{{ settings.Width/2.0 }} 5"
/>
<label text="{{ RaceTime.FromMilliseconds(authorTime) }} {{ Icons.ClockO }}"
textprefix="$t"
textfont="{{ Font.Thin }}"
class="text-primary"
textsize="0.35"
pos="{{ settings.Width - 1.5 }} -5.5"
size="{{ settings.Width/2.0 }} 5"
halign="right"
/>
</template>
</Widget>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
41 changes: 21 additions & 20 deletions src/Modules/NextMapModule/Templates/NextMap.mt
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,31 @@
<import component="EvoSC.Style.UIStyle" as="UIStyle"/>

<property type="INextMapSettings" name="settings" />
<property type="string" name="mapName" />
<property type="string" name="author" />
<property type="string" name="mapName"/>
<property type="string" name="mapAuthor"/>

<template>
<UIStyle/>
<Widget header="upcoming map" height="10" position="{{ settings.Position }}" y="{{ settings.Y }}">
<Widget header="upcoming map" height="9" position="{{ settings.Position }}" y="{{ settings.Y + 4.5 }}">
<template slot="body">
<frame pos='{{ settings.Position=="right" ? settings.Width-2.0 : 0 }} 0'>
<label text="{{ mapName }}"
class="text-primary"
pos="0 -3"
valign="center"
halign="right"
size="{{ settings.Width-2 }} 5"
/>
<label text="$<$tby {{ author }}$>"
class="text-primary"
textsize="0.75"
pos="0 -6.5"
valign="center"
halign="right"
size="{{ settings.Width-2 }} 5"
/>
</frame>
<label text="{{ mapName }}"
textfont="{{ Font.Bold }}"
textsize="0.75"
class="text-primary"
pos="{{ settings.Width/2.0 }} -2.5"
halign="center"
valign="center"
size="{{ settings.Width-4 }} 5"
/>
<label text="{{ Icons.User }} $<{{ mapAuthor.ToUpper() }}$>"
textprefix="$t"
textfont="{{ Font.Thin }}"
class="text-primary"
textsize="0.35"
halign="center"
pos="{{ settings.Width/2.0 }} -5.5"
size="{{ settings.Width/2.0 }} 5"
/>
</template>
</Widget>
</template>
Expand Down

0 comments on commit ebb9267

Please sign in to comment.