Skip to content

Commit

Permalink
Move large maniascripts to separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
araszka committed Nov 30, 2024
1 parent 712e7fb commit 26141b0
Show file tree
Hide file tree
Showing 11 changed files with 201 additions and 273 deletions.
2 changes: 1 addition & 1 deletion src/EvoSC/InternalModules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static class InternalModules
typeof(ServerManagementModule),
typeof(TeamInfoModule),
typeof(TeamChatModule),
typeof(RoundRankingModule)
// typeof(RoundRankingModule)
];

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,68 +52,5 @@
</frame>
</template>

<script once="true"><!--
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 Integer EvoSC_RoundNumber for UI = -1;
declare Integer EvoSC_RoundsPerMap for UI = -1;
return TL::ToUpperCase("Round " ^ EvoSC_RoundNumber ^ " of " ^ EvoSC_RoundsPerMap);
}

Text GetRoundsLabelWarmUpText() {
declare Integer EvoSC_RoundNumber for UI = -1;
declare Integer EvoSC_WarmUpCount for UI = -1;
return "$f90" ^ TL::ToUpperCase("Round " ^ EvoSC_RoundNumber ^ " of " ^ EvoSC_WarmUpCount);
}

Text GetPointsLimitText() {
declare Integer EvoSC_PointsLimit for UI = -1;
return TL::ToUpperCase("Points Limit " ^ EvoSC_PointsLimit);
}

Text GetPointsLimitWarmUpText() {
return "$f90WARM UP";
}

Void UpdateHeader() {
declare Boolean EvoSC_WarmUpActive for UI = False;

HeaderContentFrame_TextLeft.Value = TL::StripFormatting(CurrentServerName);
HeaderContentFrame_TextRight.Value = TL::StripFormatting(TL::Trim(Map.MapName ^ " by " ^ Map.AuthorNickName));

if(EvoSC_WarmUpActive){
HeaderContentFrame_TextLeftSmall.Value = GetPointsLimitWarmUpText();
HeaderContentFrame_TextRightSmall.Value = GetRoundsLabelWarmUpText();
}else{
HeaderContentFrame_TextLeftSmall.Value = GetPointsLimitText();
HeaderContentFrame_TextRightSmall.Value = GetRoundsLabelText();
}
}
--></script>

<script><!--
*** OnInitialization ***
***
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 ***
***
if(Now > HeaderContentFrameLastUpdate + 1000){
HeaderContentFrameLastUpdate = Now;
UpdateHeader();
}
***
--></script>
<script resource="ScoreboardModule.Scripts.Header" />
</component>
100 changes: 1 addition & 99 deletions src/Modules/ScoreboardModule/Templates/Components/Row/Framemodel.mt
Original file line number Diff line number Diff line change
Expand Up @@ -142,103 +142,5 @@
</framemodel>
</template>

<script once="true">
<!--
Void ShowPlayerActions(CMlFrame playerRow) {
declare playerActions = (playerRow.GetFirstChild("player_actions") as CMlFrame);
declare detailsWrapper = (playerRow.GetFirstChild("details_wrapper") as CMlFrame);
declare backgroundWrapper = (playerRow.GetFirstChild("player_row_bg") as CMlFrame);
playerActions.Show();
detailsWrapper.Hide();
backgroundWrapper.Size.X = ({{ (w - positionBoxWidth) - actionButtonCount*(rowHeight*1.2) - actionButtonCount*rowSpacing - 0.1 }}) * 1.0;
}

Void HidePlayerActions(CMlFrame playerRow) {
declare playerActions = (playerRow.GetFirstChild("player_actions") as CMlFrame);
declare detailsWrapper = (playerRow.GetFirstChild("details_wrapper") as CMlFrame);
declare backgroundWrapper = (playerRow.GetFirstChild("player_row_bg") as CMlFrame);
playerActions.Hide();
detailsWrapper.Show();
backgroundWrapper.Size.X = {{ (w - positionBoxWidth) }} * 1.0;
}

Void ResetPlayerActions() {
declare playerRows <=> (Page.MainFrame.GetFirstChild("frame_scroll") as CMlFrame);
foreach(playerRowControl in playerRows.Controls){
declare playerRow = (playerRowControl as CMlFrame);
HidePlayerActions(playerRow);
declare Boolean RowIsLocked for playerRow = False;
RowIsLocked = False;
}
}

Void TogglePlayerActions(CMlFrame playerRow) {
declare Boolean RowIsLocked for playerRow = False;

if(RowIsLocked){
RowIsLocked = False;
HidePlayerActions(playerRow);
}else{
ResetPlayerActions();
RowIsLocked = True;
ShowPlayerActions(playerRow);
}
}

Vec3 GetCustomLabelColor(Text value, Text defaultColorHex){
declare customLabelColorHex = "";
switch(value){
case _("|Status|Winner"): customLabelColorHex = "{{ Theme.ScoreboardModule_WinnerColor }}";
case _("|Status|Finalist"): customLabelColorHex = "{{ Theme.ScoreboardModule_FinalistColor }}";
}

if(customLabelColorHex == ""){
customLabelColorHex = defaultColorHex;
}

return CL::HexToRgb(customLabelColorHex);
}

Void SetCustomLabel(CMlFrame playerRow, Text value, Text hexColor){
declare customLabel = (playerRow.GetFirstChild("custom_label") as CMlLabel);
customLabel.Value = value;
customLabel.TextColor = GetCustomLabelColor(value, hexColor);
SetPlayerHighlightColor(playerRow, customLabel.TextColor);
}

Void HideCustomLabel(CMlFrame playerRow){
declare customLabel = (playerRow.GetFirstChild("custom_label") as CMlLabel);
customLabel.Value = "";
ResetPlayerHighlightColor(playerRow);
}

*** OnMouseClick ***
***
if(Event.Control.ControlId == "player_row_trigger"){
TogglePlayerActions(Event.Control.Parent as CMlFrame);
continue;
}
***

*** OnMouseOver ***
***
if(Event.Control.ControlId == "player_row_trigger"){
declare parentFrame = (Event.Control.Parent as CMlFrame);
declare backgroundFrame <=> (parentFrame.GetFirstChild("player_row_bg") as CMlFrame);
RowMouseOver(backgroundFrame);
continue;
}
***

*** OnMouseOut ***
***
if(Event.Control.ControlId == "player_row_trigger"){
declare parentFrame = (Event.Control.Parent as CMlFrame);
declare backgroundFrame <=> (parentFrame.GetFirstChild("player_row_bg") as CMlFrame);
RowMouseOut(backgroundFrame);
continue;
}
***
-->
</script>
<script resource="ScoreboardModule.Scripts.Framemodel" once="true" />
</component>
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,5 @@
</frame>
</template>

<script once="true">
<!--
Void RowMouseOver(CMlFrame backgroundFrame) {
declare backgroundQuad = (backgroundFrame.Controls[0] as CMlQuad);
backgroundQuad.BgColor = {! Color.ToMlColor(Theme.ScoreboardModule_Background_Hover_Color) !};
backgroundQuad.Opacity = {{ Theme.ScoreboardModule_Background_Hover_Opacity }};
}

Void RowMouseOut(CMlFrame backgroundFrame) {
declare backgroundQuad = (backgroundFrame.Controls[0] as CMlQuad);
backgroundQuad.BgColor = {! Color.ToMlColor(Theme.ScoreboardModule_Background_Row_Color) !};
backgroundQuad.Opacity = {{ Theme.ScoreboardModule_Background_Row_Opacity }};
}

Void SetPlayerHighlightColor(CMlFrame playerRow, Vec3 color) {
declare customGradient = (playerRow.GetFirstChild("custom_gradient") as CMlQuad);
customGradient.ModulateColor = color;
customGradient.Show();
}

Void ResetPlayerHighlightColor(CMlFrame playerRow) {
declare customGradient = (playerRow.GetFirstChild("custom_gradient") as CMlQuad);
customGradient.Hide();
}
-->
</script>
<script resource="ScoreboardModule.Scripts.PlayerRowBg" once="true" />
</component>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<component>
<import component="ScoreboardModule.Components.Header.HeaderBackground" as="Background"/>
<import component="ScoreboardModule.Components.Header.HeaderContent" as="Content"/>
<import component="ScoreboardModule.Components.Header.HeaderBackground" as="HeaderBackground"/>
<import component="ScoreboardModule.Components.Header.HeaderContent" as="HeaderContent"/>

<property type="int" name="maxPlayers" default="0"/>
<property type="int" name="pointsLimit" default="0"/>
Expand All @@ -9,9 +9,12 @@
<property type="double" name="height"/>

<template>
<Background width="{{ width }}" height="{{ height }}"/>
<Content
width="{{ width }}"
<HeaderBackground
width="{{ width }}"
height="{{ height }}"
/>
<HeaderContent
width="{{ width }}"
height="{{ height }}"
/>
</template>
Expand Down
62 changes: 0 additions & 62 deletions src/Modules/ScoreboardModule/Templates/Components/Settings/Form.mt

This file was deleted.

This file was deleted.

10 changes: 6 additions & 4 deletions src/Modules/ScoreboardModule/Templates/Scoreboard.mt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<using namespace="System.Linq"/>

<import component="EvoSC.Style.UIStyle" as="UIStyle"/>
<import component="ScoreboardModule.Components.ScoreboardHeader" as="Header"/>
<import component="ScoreboardModule.Components.ScoreboardHeader" as="ScoreboardHeader"/>
<import component="ScoreboardModule.Components.ScoreboardBody" as="Body"/>
<import component="ScoreboardModule.Components.ScoreboardBg" as="ScoreboardBg"/>
<import component="ScoreboardModule.Components.Row.Framemodel" as="PlayerRowFramemodel"/>
Expand Down Expand Up @@ -43,12 +43,14 @@
<!-- Scoreboard Content -->
<frame pos="{{ settings.Width / -2.0 }} {{ settings.Height / 2.0 }}">
<!-- Background -->
<ScoreboardBg width="{{ settings.Width }}"
height="{{ settings.Height }}"
<ScoreboardBg
width="{{ settings.Width }}"
height="{{ settings.Height }}"
/>

<!-- Header -->
<Header width="{{ settings.Width }}"
<ScoreboardHeader
width="{{ settings.Width }}"
height="{{ headerHeight }}"
/>

Expand Down
Loading

0 comments on commit 26141b0

Please sign in to comment.