Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Team settings #245

Merged
merged 78 commits into from
Jul 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
efd6b7c
initial
snixtho Jan 2, 2024
bb7d777
implement async deque
snixtho Jan 3, 2024
a41f9f6
implement queue controller
snixtho Jan 3, 2024
c25dbcf
Add container and panel ML components.
snixtho Jan 5, 2024
0c56550
add border to panel
snixtho Jan 5, 2024
b363a64
convert opacity based on 4-byte color
snixtho Jan 15, 2024
0df0e3b
add chip
snixtho Jan 16, 2024
e799aa5
separator
snixtho Jan 16, 2024
7d1d6e9
add placeholder for textinput
snixtho Jan 24, 2024
0ca5557
smol save
snixtho Jan 27, 2024
e6d67d7
adfg
snixtho Feb 7, 2024
7c6fde9
map list module project file
snixtho Feb 8, 2024
541607c
local save
snixtho Feb 9, 2024
0be57df
changes
snixtho Feb 16, 2024
22b665e
map row tweaks
snixtho Feb 29, 2024
ff584be
basic scrollbar
snixtho Mar 4, 2024
67c5bea
scrollbar can now control the scrolling element
snixtho Mar 5, 2024
2d4302e
fix relative drag position of scrollbar
snixtho Mar 5, 2024
d2735df
begin using map data objects
snixtho Mar 5, 2024
d6a8218
actually show the current map list
snixtho Mar 7, 2024
91ab4f0
save map details to db
snixtho Mar 12, 2024
5f99ddc
Optimize GetCurrentMapListAsync
snixtho Mar 14, 2024
82e6971
Add ability to queue maps from the maplist.
snixtho Mar 14, 2024
10a0cda
add widget prototype with new style
snixtho Apr 12, 2024
13ee3f2
starting new style
snixtho Apr 18, 2024
ec217ba
new button and dropdown
snixtho May 14, 2024
ad22b40
text input
snixtho May 15, 2024
03e85c8
huh
snixtho May 15, 2024
ec85050
alert
snixtho May 15, 2024
af259f7
updated checkbox
snixtho May 15, 2024
8d2cca8
update radiobutton
snixtho May 15, 2024
fe7bcec
some fixes and improvements
snixtho May 15, 2024
8425e08
switch
snixtho May 15, 2024
b40c669
update window
snixtho May 15, 2024
567ce95
fix tags
snixtho May 15, 2024
239e507
fix chip
snixtho May 17, 2024
4777533
fix rating
snixtho May 17, 2024
dcc2b69
fix link button
snixtho May 17, 2024
cd581b7
fix separator
snixtho May 17, 2024
ffef7ab
add utility colors to the ui demo
snixtho May 17, 2024
a07cf0d
add round buttons
snixtho May 17, 2024
1995103
separate namespace for containers
snixtho May 17, 2024
fff2743
add some breathing room for window icon
snixtho May 17, 2024
70e5d0a
make simple maplist ui
snixtho May 17, 2024
21116f7
add close button back to windows
snixtho May 18, 2024
163b634
documentation for components
snixtho May 18, 2024
5b07e4e
Update SetName templates to work with new default design
araszka May 22, 2024
5941881
Add TeamSettingsModule
araszka May 25, 2024
8c18b45
Add services and controllers for TeamSettings
araszka May 31, 2024
d447e67
Fix component default id
araszka Jun 8, 2024
09a6420
Fix fallthrough attributes for button component
araszka Jun 8, 2024
94ca907
Remove redundant dataId from window component
araszka Jun 8, 2024
380ad3f
Fix pass case sensitive attribute to rectangle component
araszka Jun 8, 2024
e2a9393
Update ManiaTemplates to 0.0.24-alpha and use raw expressions where n…
araszka Jun 8, 2024
7d8e2e0
Remove redundant scriptevents attribute
araszka Jun 8, 2024
65a0a78
Fix pass script events to rectangle and quarter circle component
araszka Jun 8, 2024
e4eb53c
Merge branch 'refs/heads/bugfix/fallthrough-attributes-causing-proble…
araszka Jun 9, 2024
115b8ac
Implement edit team settings via manialink
araszka Jun 22, 2024
98418ec
Parse club link URL instead of loading team infos from RPC to get cor…
araszka Jun 22, 2024
3b25a8c
Add constants for default team values
araszka Jun 22, 2024
84d9147
Prevent exception on empty club link URL
araszka Jun 22, 2024
8e1cf80
Add custom data annotations for team settings
araszka Jun 22, 2024
a96732e
Add ColorInput form element to team settings form
araszka Jun 22, 2024
3713feb
Add script for team settings color picker
araszka Jul 4, 2024
3e5fc61
Update color preview in team setting when using color picker
araszka Jul 4, 2024
217ff35
Use circle for color input preview
araszka Jul 6, 2024
cc34e03
Set color preview on entry submit
araszka Jul 6, 2024
7bc0b40
Add proper color code validation for team settings
araszka Jul 6, 2024
e46d9b1
Add doc comments to ITeamSettingsService
araszka Jul 6, 2024
266dcf7
Merge remote-tracking branch 'origin/master' into team-settings
araszka Jul 9, 2024
eceb915
Remove HideTeamSettingsForEveryoneAsync
araszka Jul 9, 2024
9b02f57
Add TeamSettingsModule.Tests project
araszka Jul 9, 2024
76fab57
Add test for generating and parsing club link URLs
araszka Jul 10, 2024
3ea1dba
Add test for set club link urls
araszka Jul 10, 2024
af4cb8c
Add test for TeamSettingsManialinkController
araszka Jul 10, 2024
d637504
Add test for updating team settings with invalid form data
araszka Jul 13, 2024
4e7ee67
Update module name
araszka Jul 13, 2024
26fc2aa
Add test for getting current team settings for the editor
araszka Jul 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion EvoSC.sln
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LocalRecordsModule", "src/M
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LocalRecordsModule.Tests", "tests\Modules\LocalRecordsModule.Tests\LocalRecordsModule.Tests.csproj", "{7401429B-B842-4316-B7A2-B77E9AD966CB}"
EndProject

Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeamSettingsModule", "src\Modules\TeamSettingsModule\TeamSettingsModule.csproj", "{C10A11E5-4AD8-4229-81F1-57D7DC364E27}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeamSettingsModule.Tests", "tests\Modules\TeamSettingsModule.Tests\TeamSettingsModule.Tests.csproj", "{B1745099-0081-4443-BF79-26A888765E16}"
EndProject



Expand Down Expand Up @@ -343,6 +346,14 @@ Global
{7401429B-B842-4316-B7A2-B77E9AD966CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7401429B-B842-4316-B7A2-B77E9AD966CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7401429B-B842-4316-B7A2-B77E9AD966CB}.Release|Any CPU.Build.0 = Release|Any CPU
{C10A11E5-4AD8-4229-81F1-57D7DC364E27}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C10A11E5-4AD8-4229-81F1-57D7DC364E27}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C10A11E5-4AD8-4229-81F1-57D7DC364E27}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C10A11E5-4AD8-4229-81F1-57D7DC364E27}.Release|Any CPU.Build.0 = Release|Any CPU
{B1745099-0081-4443-BF79-26A888765E16}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B1745099-0081-4443-BF79-26A888765E16}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B1745099-0081-4443-BF79-26A888765E16}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B1745099-0081-4443-BF79-26A888765E16}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -397,5 +408,7 @@ Global
{098D1F9B-054D-4158-BB6C-AC908C4595F6} = {6D75D6A2-6ECD-4DE4-96C5-CAD7D134407A}
{1D8DBFC8-EC21-4DDA-9D88-DE7CA04C8449} = {DC47658A-F421-4BA4-B617-090A7DFB3900}
{7401429B-B842-4316-B7A2-B77E9AD966CB} = {6D75D6A2-6ECD-4DE4-96C5-CAD7D134407A}
{C10A11E5-4AD8-4229-81F1-57D7DC364E27} = {DC47658A-F421-4BA4-B617-090A7DFB3900}
{B1745099-0081-4443-BF79-26A888765E16} = {6D75D6A2-6ECD-4DE4-96C5-CAD7D134407A}
EndGlobalSection
EndGlobal
2 changes: 2 additions & 0 deletions src/EvoSC.Common/Database/Repository/Maps/MapRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using EvoSC.Common.Interfaces.Models;
using EvoSC.Common.Models.Maps;
using LinqToDB;
using LinqToDB.DataProvider.MySql;
using LinqToDB.Tools;
using Microsoft.Extensions.Logging;

namespace EvoSC.Common.Database.Repository.Maps;
Expand Down
2 changes: 2 additions & 0 deletions src/EvoSC.Common/Services/MatchSettingsService.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using EvoSC.Common.Config.Models;
using EvoSC.Common.Database.Repository.Maps;
using EvoSC.Common.Interfaces;
using EvoSC.Common.Interfaces.Models;
using EvoSC.Common.Interfaces.Services;
using EvoSC.Common.Interfaces.Util;
using EvoSC.Common.Models.Maps;
using EvoSC.Common.Util;
using EvoSC.Common.Util.MatchSettings;
using EvoSC.Common.Util.MatchSettings.Builders;
Expand Down
2 changes: 1 addition & 1 deletion src/EvoSC.Manialinks/Attributes/FormEntryModelAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace EvoSC.Manialinks.Attributes;

/// <summary>
/// Specifies that the annotated class is used as an Form Entry Model.
/// Specifies that the annotated class is used as a Form Entry Model.
/// </summary>
[AttributeUsage(AttributeTargets.Class)]
public class FormEntryModelAttribute : Attribute;
9 changes: 8 additions & 1 deletion src/EvoSC.Manialinks/Templates/Controls/TextInput.mt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ Basic text input control.

<!-- The name of the control. -->
<property type="string" name="id" />

<!-- Additional classes for the entry control. -->
<property type="string" name="classes" default="" />

<!-- The X position of the control. -->
<property type="double" name="x" default="0.0"/>
Expand Down Expand Up @@ -37,6 +40,9 @@ Basic text input control.
<!-- Default text to show when empty -->
<property type="string" name="placeholder" default="" />

<!-- Text to prepend inside the input -->
<property type="string" name="prefix" default="" />

<template>
<frame pos="{{ x }} {{ y }}" id="{{ id }}">
<Rectangle
Expand All @@ -51,13 +57,14 @@ Basic text input control.
focusareacolor1="00000000"
focusareacolor2="00000000"
textformat='{{ isPassword ? "Password" : "Basic" }}'
textprefix="{{ prefix }}"
name="{{ id }}"
data-id="{{ id }}"
default="{{ value }}"
selecttext="{{ autoSelect }}"
maxlen="{{ maxLength }}"
z-index="0"
class="txtinput-text"
class="txtinput-text {{ classes }}"
size="{{ width-2 }} {{ height }}"
pos="{{ 1 }} {{ -height/4 }}"
/>
Expand Down
24 changes: 15 additions & 9 deletions src/EvoSC.Manialinks/Templates/FormEntry.mt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<property type="int" name="zIndex" default="0"/>
<property type="string" name="label" default=""/>
<property type="double" name="w" default="0.0"/>
<property type="double" name="h" default="9.0"/>
<property type="double" name="h" default="20.0"/>
<property type="double" name="x" default="0.0"/>
<property type="double" name="y" default="0.0"/>
<property type="bool" name="isPassword" default="false"/>
Expand All @@ -23,28 +23,34 @@
<frame pos="{{ x }} {{ y }}" size="{{ w }} {{ h }}">
<Label
text="{{ label }}"
class="text-primary"
x="0"
y="0"
textsize="1"
halign="left" valign="top"
halign="left"
valign="top"
/>
<TextInput
x="0"
y="-3"
id="{{ name }}"
value='{{ value ?? "" }}'
width="{{ w }}"
height="3"
isPassword="{{ isPassword }}"
valueType="{{ valueType }}"
/>
<Label
text='$s$F00 {{ validationResults?.FirstOrDefault(v => v.IsInvalid)?.Message ?? "Invalid input." }}'
x="0"
y="-6"
textsize="0.5"
halign="left" valign="top"
<Label
if='validationResults?.Any(v => v.IsInvalid) ?? false'
text='$s$e11 {{ validationResults?.FirstOrDefault(v => v.IsInvalid)?.Message ?? "Invalid input." }}'
class="text-primary"
x="0"
y="-10"
w="{{ w }}"
h="10"
autonewline="1"
textsize="0.75"
halign="left"
valign="top"
/>
</frame>
</template>
Expand Down
1 change: 1 addition & 0 deletions src/EvoSC.Manialinks/Templates/Scripts/UIScripts.ms
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!--
#Include "TextLib" as TextLib
#Include "MathLib" as Math
#Include "ColorLib" as ColorLib

Void __DoNothing() {}

Expand Down
Empty file.
1 change: 1 addition & 0 deletions src/EvoSC/EvoSC.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<ProjectReference Include="..\Modules\MatchManagerModule\MatchManagerModule.csproj" />
<ProjectReference Include="..\Modules\ASayModule\ASayModule.csproj" />
<ProjectReference Include="..\Modules\SpectatorTargetInfoModule\SpectatorTargetInfoModule.csproj" />
<ProjectReference Include="..\Modules\TeamSettingsModule\TeamSettingsModule.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 @@ -21,6 +21,7 @@
using EvoSC.Modules.Official.Scoreboard;
using EvoSC.Modules.Official.SetName;
using EvoSC.Modules.Official.SpectatorTargetInfoModule;
using EvoSC.Modules.Official.TeamSettingsModule;
using EvoSC.Modules.Official.WorldRecordModule;
using FluentMigrator.Runner.Exceptions;

Expand Down Expand Up @@ -51,7 +52,8 @@ public static class InternalModules
typeof(SpectatorTargetInfoModule),
typeof(MapQueueModule),
typeof(MapListModule),
typeof(LocalRecordsModule)
typeof(LocalRecordsModule),
typeof(TeamSettingsModule)
};

/// <summary>
Expand Down
10 changes: 10 additions & 0 deletions src/Modules/MapListModule/Templates/Styles.mt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<component>
<template>
<stylesheet>
<style
class="maplistrow-linkbtn-btn-default"
textsize="0.3"
/>
</stylesheet>
</template>
</component>
18 changes: 18 additions & 0 deletions src/Modules/MapListModule/Themes/DefaultMapListTheme.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using EvoSC.Common.Interfaces.Themes;
using EvoSC.Common.Themes;
using EvoSC.Common.Themes.Attributes;
using EvoSC.Common.Util;

namespace EvoSC.Modules.Official.MapListModule.Themes;

[Theme(Name = "Map List", Description = "Default theme for the Map List.")]
public class DefaultMapListTheme(IThemeManager theme) : Theme<DefaultMapListTheme>
{
private readonly dynamic _theme = theme.Theme;

public override Task ConfigureAsync()
{

return Task.CompletedTask;
}
}
2 changes: 1 addition & 1 deletion src/Modules/SetName/Localization.resx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<value>$&lt;{0}$&gt; changed their nickname to $&lt;{1}$&gt;</value>
</data>
<data name="UI.EditYourNickname" xml:space="preserve">
<value>Edit your nickname</value>
<value>Change name</value>
</data>
<data name="UI.Nickname" xml:space="preserve">
<value>Nickname:</value>
Expand Down
13 changes: 8 additions & 5 deletions src/Modules/SetName/Templates/EditName.mt
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,27 @@
<UIStyle />

<Window
width="50"
height="23"
width="55"
height="{{ (Validation != null && !Validation.IsValid) ? 40 : 30 }}"
x="-25"
y="11.5"
title="{{ Locale.PlayerLanguage.UI_EditYourNickname }}"
icon=""
>
<FormEntry
validationResults='{{ Validation?.GetResult("Nickname") }}'
value='{{ Nickname }}'
name="Nickname"
label="{{ Locale.PlayerLanguage.UI_Nickname }}"
w="48"
w="49"
x="0"
y="0"
/>

<Button id="btnEdit" text="{{ Locale.PlayerLanguage.UI_Submit }}" action="SetName/EditName" x="14" y="-8" />
<Button id="btnCancel" text="{{ Locale.PlayerLanguage.UI_Cancel }}" action="SetName/Cancel" x="32" y="-8" type="secondary" />
<frame pos="0 {{ (Validation != null && !Validation.IsValid) ? -10 : 0 }}">
<Button id="btnEdit" text="{{ Locale.PlayerLanguage.UI_Submit }}" action="SetName/EditName" x="0" y="-11" />
<Button id="btnCancel" text="{{ Locale.PlayerLanguage.UI_Cancel }}" action="SetName/Cancel" x="32" y="-11" type="secondary" />
</frame>
</Window>
</template>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using EvoSC.Commands.Attributes;
using EvoSC.Commands.Interfaces;
using EvoSC.Common.Controllers;
using EvoSC.Common.Controllers.Attributes;
using EvoSC.Modules.Official.TeamSettingsModule.Interfaces;

namespace EvoSC.Modules.Official.TeamSettingsModule.Controllers;

[Controller]
public class TeamSettingsCommandsController(ITeamSettingsService teamSettingsService) : EvoScController<ICommandInteractionContext>
{
[ChatCommand("teams", "[Command.TeamSettings]")]
public async Task EditTeamSettingsAsync()
{
await teamSettingsService.ShowTeamSettingsAsync(Context.Player, await teamSettingsService.GetCurrentTeamSettingsModel());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using EvoSC.Common.Controllers.Attributes;
using EvoSC.Common.Interfaces.Localization;
using EvoSC.Manialinks;
using EvoSC.Modules.Official.TeamSettingsModule.Interfaces;
using EvoSC.Modules.Official.TeamSettingsModule.Models;

namespace EvoSC.Modules.Official.TeamSettingsModule.Controllers;

[Controller]
public class TeamSettingsManialinkController(ITeamSettingsService teamSettingsService, Locale locale) : ManialinkController
{
public async Task SaveTeamSettingsAsync(TeamSettingsModel input)
{
if (!IsModelValid)
{
await ShowAsync(Context.Player, "TeamSettingsModule.EditTeamSettings",
new { Settings = input, Locale = locale }
);
return;
}

await teamSettingsService.SetTeamSettingsAsync(input);
await teamSettingsService.HideTeamSettingsAsync(Context.Player);

Context.AuditEvent
.Success()
.WithEventName("EditTeamSettings")
.HavingProperties(new { TeamSettings = input });
}
}
17 changes: 17 additions & 0 deletions src/Modules/TeamSettingsModule/DataAnnotations/ColorCode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.ComponentModel.DataAnnotations;
using System.Text.RegularExpressions;

namespace EvoSC.Modules.Official.TeamSettingsModule.DataAnnotations;

public partial class ColorCode : ValidationAttribute
{
public override bool IsValid(object? value)
{
var colorCode = value?.ToString() ?? "";

return ValidColorCodeRegex().IsMatch(colorCode);
}

[GeneratedRegex("^(?:[0-9a-fA-F]{3}){1,2}$")]
private static partial Regex ValidColorCodeRegex();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace EvoSC.Modules.Official.TeamSettingsModule.DataAnnotations;

public class NullableColorCode : ColorCode
{
public override bool IsValid(object? value)
{
return value?.ToString()?.Length == 0 || base.IsValid(value);
}
}
13 changes: 13 additions & 0 deletions src/Modules/TeamSettingsModule/DataAnnotations/NullableUrl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.ComponentModel.DataAnnotations;

namespace EvoSC.Modules.Official.TeamSettingsModule.DataAnnotations;

public class NullableUrl : ValidationAttribute
{
public override bool IsValid(object? value)
{
string url = value?.ToString()?.Trim() ?? "";

return url.Length == 0 || Uri.IsWellFormedUriString(url, UriKind.Absolute);
}
}
Loading
Loading