Skip to content

Commit

Permalink
Update scoreboard header
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Raszka committed Oct 8, 2024
1 parent 4df9fbc commit 60f130f
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 7 deletions.
10 changes: 8 additions & 2 deletions src/Modules/ScoreboardModule/Services/ScoreboardService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using EvoSC.Common.Interfaces;
using EvoSC.Common.Interfaces.Services;
using EvoSC.Common.Services.Attributes;
using EvoSC.Common.Services.Models;
using EvoSC.Manialinks.Interfaces;
Expand All @@ -15,7 +16,8 @@ public class ScoreboardService(
IServerClient server,
IScoreboardNicknamesService nicknamesService,
IScoreboardSettings settings,
IGameModeUiModuleService gameModeUiModuleService
IGameModeUiModuleService gameModeUiModuleService,
IMatchSettingsService matchSettingsService
)
: IScoreboardService
{
Expand All @@ -31,10 +33,14 @@ private async Task<dynamic> GetDataAsync()
{
var currentNextMaxPlayers = await server.Remote.GetMaxPlayersAsync();
var currentNextMaxSpectators = await server.Remote.GetMaxSpectatorsAsync();
var modeScriptSettings = await matchSettingsService.GetCurrentScriptSettingsAsync();

return new
{
settings, MaxPlayers = currentNextMaxPlayers.CurrentValue + currentNextMaxSpectators.CurrentValue
settings,
MaxPlayers = currentNextMaxPlayers.CurrentValue + currentNextMaxSpectators.CurrentValue,
PointsLimit = (int)(modeScriptSettings?["S_PointsLimit"] ?? 0),
RoundsPerMap = (int)(modeScriptSettings?["S_RoundsPerMap"] ?? 0),
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,53 @@

<import component="ScoreboardModule.Components.Header.Logo" as="Logo"/>

<property type="int" name="maxPlayers" default="0"/>
<property type="int" name="pointsLimit" default="0"/>
<property type="int" name="roundsPerMap" default="0"/>
<property type="double" name="width"/>
<property type="double" name="height"/>
<property type="double" name="padding" default="3.4"/>

<template>
<frame id="header_content" pos="{{ width / 2.0 }} {{ height / -2.0 }}">
<label id="header_text_left"
pos="{{ float.Parse(Theme.ScoreboardModule_Logo_Width, CultureInfo.InvariantCulture) * -0.5 - 4.0 }}"
pos="{{ float.Parse(Theme.ScoreboardModule_Logo_Width, CultureInfo.InvariantCulture) * -0.5 - 4.0 }} 1.75"
size="{{ width/2.0-float.Parse(Theme.ScoreboardModule_Logo_Width, CultureInfo.InvariantCulture)-2.0 }} {{ height }}"
textcolor="{{ Theme.UI_TextPrimary }}"
class="text-lg"
textfont="{{ Font.Regular }}"
halign="right"
valign="center2"
/>
<label id="header_text_left_small"
pos="{{ float.Parse(Theme.ScoreboardModule_Logo_Width, CultureInfo.InvariantCulture) * -0.5 - 4.0 }} -1.75"
size="{{ width/2.0-float.Parse(Theme.ScoreboardModule_Logo_Width, CultureInfo.InvariantCulture)-2.0 }} {{ height }}"
textcolor="{{ Theme.UI_TextPrimary }}"
class="text-primary"
textfont="{{ Font.Regular }}"
textsize="{{ Theme.UI_FontSize*0.8 }}"
halign="right"
valign="center2"
opacity="0.8"
/>
<label id="header_text_right"
pos="{{ float.Parse(Theme.ScoreboardModule_Logo_Width, CultureInfo.InvariantCulture) * 0.5 + 4.0 }}"
pos="{{ float.Parse(Theme.ScoreboardModule_Logo_Width, CultureInfo.InvariantCulture) * 0.5 + 4.0 }} 1.75"
size="{{ width/2.0-float.Parse(Theme.ScoreboardModule_Logo_Width, CultureInfo.InvariantCulture)-2.0 }} {{ height }}"
textcolor="{{ Theme.UI_TextPrimary }}"
class="text-lg"
textfont="{{ Font.Regular }}"
valign="center2"
/>
<label id="header_text_right_small"
pos="{{ float.Parse(Theme.ScoreboardModule_Logo_Width, CultureInfo.InvariantCulture) * 0.5 + 4.0 }} -1.75"
size="{{ width/2.0-float.Parse(Theme.ScoreboardModule_Logo_Width, CultureInfo.InvariantCulture)-2.0 }} {{ height }}"
textcolor="{{ Theme.UI_TextPrimary }}"
class="text-primary"
textfont="{{ Font.Regular }}"
textsize="{{ Theme.UI_FontSize*0.8 }}"
valign="center2"
opacity="0.8"
/>

<Logo if='Theme.ScoreboardModule_Logo_URL != ""'/>
</frame>
Expand All @@ -33,11 +59,24 @@
declare Integer HeaderContentFrameLastUpdate;
declare CMlFrame HeaderContentFrame;
declare CMlLabel HeaderContentFrame_TextLeft;
declare CMlLabel HeaderContentFrame_TextLeftSmall;
declare CMlLabel HeaderContentFrame_TextRight;
declare CMlLabel HeaderContentFrame_TextRightSmall;

Text GetRoundsLabelText() {
declare currentRound = -1; //TODO: get current round
return TL::ToUpperCase("Round " ^ currentRound ^ " of {{ roundsPerMap }}");
}

Text GetPointsLimitTest() {
return TL::ToUpperCase("Points Limit {{ pointsLimit }}");
}

Void UpdateHeader() {
HeaderContentFrame_TextLeft.Value = CurrentServerName;
HeaderContentFrame_TextRight.Value = Map.MapName ^ " by " ^ Map.AuthorNickName;
HeaderContentFrame_TextLeft.Value = TL::StripFormatting(CurrentServerName);
HeaderContentFrame_TextRight.Value = TL::StripFormatting(TL::Trim(Map.MapName ^ " by " ^ Map.AuthorNickName));
HeaderContentFrame_TextLeftSmall.Value = GetPointsLimitTest();
HeaderContentFrame_TextRightSmall.Value = GetRoundsLabelText();
}
--></script>

Expand All @@ -47,7 +86,9 @@
HeaderContentFrameLastUpdate = 0;
HeaderContentFrame <=> (Page.MainFrame.GetFirstChild("header_content") as CMlFrame);
HeaderContentFrame_TextLeft <=> (HeaderContentFrame.GetFirstChild("header_text_left") as CMlLabel);
HeaderContentFrame_TextLeftSmall <=> (HeaderContentFrame.GetFirstChild("header_text_left_small") as CMlLabel);
HeaderContentFrame_TextRight <=> (HeaderContentFrame.GetFirstChild("header_text_right") as CMlLabel);
HeaderContentFrame_TextRightSmall <=> (HeaderContentFrame.GetFirstChild("header_text_right_small") as CMlLabel);
***

*** OnLoop ***
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,20 @@
<import component="ScoreboardModule.Components.Header.HeaderBackground" as="Background"/>
<import component="ScoreboardModule.Components.Header.HeaderContent" as="Content"/>

<property type="int" name="maxPlayers" default="0"/>
<property type="int" name="pointsLimit" default="0"/>
<property type="int" name="roundsPerMap" default="0"/>
<property type="double" name="width"/>
<property type="double" name="height"/>

<template>
<Background width="{{ width }}" height="{{ height }}"/>
<Content width="{{ width }}" height="{{ height }}"/>
<Content
width="{{ width }}"
height="{{ height }}"
maxPlayers="{{ maxPlayers }}"
pointsLimit="{{ pointsLimit }}"
roundsPerMap="{{ roundsPerMap }}"
/>
</template>
</component>
5 changes: 5 additions & 0 deletions src/Modules/ScoreboardModule/Templates/Scoreboard.mt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

<property type="IScoreboardSettings" name="settings"/>
<property type="int" name="MaxPlayers" default="0"/>
<property type="int" name="PointsLimit" default="0"/>
<property type="int" name="RoundsPerMap" default="0"/>

<property type="double" name="backgroundBorderRadius" default="3.0"/>
<property type="double" name="headerHeight" default="14.0"/>
Expand Down Expand Up @@ -50,6 +52,9 @@
<!-- Header -->
<Header width="{{ settings.Width }}"
height="{{ headerHeight }}"
maxPlayers="{{ MaxPlayers }}"
pointsLimit="{{ PointsLimit }}"
roundsPerMap="{{ RoundsPerMap }}"
/>

<!-- Body -->
Expand Down

0 comments on commit 60f130f

Please sign in to comment.