@if (showLink)
@@ -25,7 +28,7 @@
}
- @Model.Status
+ @Model.Status.ToTranslatedString(language)
@Model.Hearts
diff --git a/ProjectLighthouse.Servers.Website/Pages/PhotosPage.cshtml b/ProjectLighthouse.Servers.Website/Pages/PhotosPage.cshtml
index 1d532362..c89184b8 100644
--- a/ProjectLighthouse.Servers.Website/Pages/PhotosPage.cshtml
+++ b/ProjectLighthouse.Servers.Website/Pages/PhotosPage.cshtml
@@ -1,11 +1,12 @@
@page "/photos/{pageNumber:int}"
+@using LBPUnion.ProjectLighthouse.Localization.StringLists
@using LBPUnion.ProjectLighthouse.PlayerData
@using LBPUnion.ProjectLighthouse.Types
@model LBPUnion.ProjectLighthouse.Servers.Website.Pages.PhotosPage
@{
Layout = "Layouts/BaseLayout";
- Model.Title = "Photos";
+ Model.Title = Model.Translate(BaseLayoutStrings.HeaderPhotos);
}
There are @Model.PhotoCount total photos!
diff --git a/ProjectLighthouse.Servers.Website/Pages/ReportPage.cshtml b/ProjectLighthouse.Servers.Website/Pages/ReportPage.cshtml
new file mode 100644
index 00000000..738d1dd1
--- /dev/null
+++ b/ProjectLighthouse.Servers.Website/Pages/ReportPage.cshtml
@@ -0,0 +1,18 @@
+@page "/admin/report/{reportId:int}"
+@model LBPUnion.ProjectLighthouse.Servers.Website.Pages.ReportPage
+
+@{
+ Layout = "Layouts/BaseLayout";
+ Model.Title = $"Report {Model.Report.ReportId}";
+}
+
+
+
+@await Html.PartialAsync("Partials/ReportPartial", Model.Report)
+@await Html.PartialAsync("Partials/RenderReportBoundsPartial")
\ No newline at end of file
diff --git a/ProjectLighthouse.Servers.Website/Pages/ReportPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/ReportPage.cshtml.cs
new file mode 100644
index 00000000..20f5cb4f
--- /dev/null
+++ b/ProjectLighthouse.Servers.Website/Pages/ReportPage.cshtml.cs
@@ -0,0 +1,42 @@
+using System.Text.Json;
+using LBPUnion.ProjectLighthouse.Administration.Reports;
+using LBPUnion.ProjectLighthouse.PlayerData.Profiles;
+using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc.RazorPages;
+using Microsoft.EntityFrameworkCore;
+
+namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages;
+
+public class ReportPage : BaseLayout
+{
+ public ReportPage(Database database) : base(database)
+ {}
+
+ public GriefReport Report;
+
+ public async Task
OnGet([FromRoute] int reportId)
+ {
+ User? user = this.Database.UserFromWebRequest(this.Request);
+ if (user == null) return this.Redirect("~/login");
+ if (!user.IsAdmin) return this.NotFound();
+
+ GriefReport? report = await this.Database.Reports
+ .Include(r => r.ReportingPlayer)
+ .FirstOrDefaultAsync(r => r.ReportId == reportId);
+ if (report == null) return this.NotFound();
+
+ report.XmlPlayers = (ReportPlayer[])JsonSerializer.Deserialize(report.Players,
+ typeof(ReportPlayer[]))!;
+
+ report.XmlBounds = new Marqee
+ {
+ Rect = (Rectangle)JsonSerializer.Deserialize(report.Bounds,
+ typeof(Rectangle))!,
+ };
+
+ this.Report = report;
+
+ return this.Page();
+ }
+}
\ No newline at end of file
diff --git a/ProjectLighthouse.Servers.Website/Pages/SlotsPage.cshtml b/ProjectLighthouse.Servers.Website/Pages/SlotsPage.cshtml
index 4d736f29..69fb3073 100644
--- a/ProjectLighthouse.Servers.Website/Pages/SlotsPage.cshtml
+++ b/ProjectLighthouse.Servers.Website/Pages/SlotsPage.cshtml
@@ -1,11 +1,12 @@
@page "/slots/{pageNumber:int}"
@using LBPUnion.ProjectLighthouse.Extensions
@using LBPUnion.ProjectLighthouse.Levels
+@using LBPUnion.ProjectLighthouse.Localization.StringLists
@model LBPUnion.ProjectLighthouse.Servers.Website.Pages.SlotsPage
@{
Layout = "Layouts/BaseLayout";
- Model.Title = "Levels";
+ Model.Title = Model.Translate(BaseLayoutStrings.HeaderSlots);
}
There are @Model.SlotCount total levels!
diff --git a/ProjectLighthouse.Servers.Website/Pages/UserPage.cshtml b/ProjectLighthouse.Servers.Website/Pages/UserPage.cshtml
index fdd3135d..fae97ecd 100644
--- a/ProjectLighthouse.Servers.Website/Pages/UserPage.cshtml
+++ b/ProjectLighthouse.Servers.Website/Pages/UserPage.cshtml
@@ -46,6 +46,9 @@
{
"IsMobile", Model.Request.IsMobile()
},
+ {
+ "Language", Model.GetLanguage()
+ }
})
diff --git a/ProjectLighthouse.Servers.Website/Pages/UsersPage.cshtml b/ProjectLighthouse.Servers.Website/Pages/UsersPage.cshtml
index f59d9874..db8f7a46 100644
--- a/ProjectLighthouse.Servers.Website/Pages/UsersPage.cshtml
+++ b/ProjectLighthouse.Servers.Website/Pages/UsersPage.cshtml
@@ -1,12 +1,13 @@
@page "/users/{pageNumber:int}"
@using LBPUnion.ProjectLighthouse.Extensions
+@using LBPUnion.ProjectLighthouse.Localization.StringLists
@using LBPUnion.ProjectLighthouse.PlayerData.Profiles
@using LBPUnion.ProjectLighthouse.Types
@model LBPUnion.ProjectLighthouse.Servers.Website.Pages.UsersPage
@{
Layout = "Layouts/BaseLayout";
- Model.Title = "Users";
+ Model.Title = Model.Translate(BaseLayoutStrings.HeaderUsers);
}
There are @Model.UserCount total users.
@@ -31,6 +32,9 @@
{
"IsMobile", isMobile
},
+ {
+ "Language", Model.GetLanguage()
+ },
})
}
diff --git a/ProjectLighthouse.Tests.GameApiTests/Tests/AuthenticationTests.cs b/ProjectLighthouse.Tests.GameApiTests/Tests/AuthenticationTests.cs
index acfbfb6b..70fcf8bc 100644
--- a/ProjectLighthouse.Tests.GameApiTests/Tests/AuthenticationTests.cs
+++ b/ProjectLighthouse.Tests.GameApiTests/Tests/AuthenticationTests.cs
@@ -26,7 +26,7 @@ public class AuthenticationTests : LighthouseServerTest
Assert.True(response.IsSuccessStatusCode);
string responseContent = await response.Content.ReadAsStringAsync();
Assert.Contains("MM_AUTH=", responseContent);
- Assert.Contains(VersionHelper.FullVersion, responseContent);
+ Assert.Contains(VersionHelper.EnvVer, responseContent);
}
[DatabaseFact]
@@ -39,7 +39,7 @@ public class AuthenticationTests : LighthouseServerTest
Assert.NotNull(loginResult.ServerBrand);
Assert.Contains("MM_AUTH=", loginResult.AuthTicket);
- Assert.Equal(VersionHelper.FullVersion, loginResult.ServerBrand);
+ Assert.Equal(VersionHelper.EnvVer, loginResult.ServerBrand);
}
[DatabaseFact]
diff --git a/ProjectLighthouse.sln.DotSettings b/ProjectLighthouse.sln.DotSettings
index 040fb4e0..3277a838 100644
--- a/ProjectLighthouse.sln.DotSettings
+++ b/ProjectLighthouse.sln.DotSettings
@@ -58,7 +58,7 @@
NEXT_LINE
True
False
-
WRAP_IF_LONG
+
CHOP_IF_LONG
CHOP_IF_LONG
True
True
diff --git a/ProjectLighthouse/Configuration/ConfigurationCategories/CustomizationConfiguration.cs b/ProjectLighthouse/Configuration/ConfigurationCategories/CustomizationConfiguration.cs
index 027c1753..ee6b17e4 100644
--- a/ProjectLighthouse/Configuration/ConfigurationCategories/CustomizationConfiguration.cs
+++ b/ProjectLighthouse/Configuration/ConfigurationCategories/CustomizationConfiguration.cs
@@ -3,4 +3,5 @@ namespace LBPUnion.ProjectLighthouse.Configuration.ConfigurationCategories;
public class CustomizationConfiguration
{
public string ServerName { get; set; } = "Project Lighthouse";
+ public string EnvironmentName { get; set; } = "project-lighthouse";
}
\ No newline at end of file
diff --git a/ProjectLighthouse/Configuration/ConfigurationCategories/DiscordIntegrationConfiguration.cs b/ProjectLighthouse/Configuration/ConfigurationCategories/DiscordIntegrationConfiguration.cs
index 92246899..1454338d 100644
--- a/ProjectLighthouse/Configuration/ConfigurationCategories/DiscordIntegrationConfiguration.cs
+++ b/ProjectLighthouse/Configuration/ConfigurationCategories/DiscordIntegrationConfiguration.cs
@@ -8,4 +8,6 @@ public class DiscordIntegrationConfiguration
public bool DiscordIntegrationEnabled { get; set; }
public string Url { get; set; } = "";
+
+ public string ModerationUrl { get; set; } = "";
}
\ No newline at end of file
diff --git a/ProjectLighthouse/Configuration/ServerConfiguration.cs b/ProjectLighthouse/Configuration/ServerConfiguration.cs
index 30c5ee41..f7d4aa05 100644
--- a/ProjectLighthouse/Configuration/ServerConfiguration.cs
+++ b/ProjectLighthouse/Configuration/ServerConfiguration.cs
@@ -23,7 +23,7 @@ public class ServerConfiguration
// You can use an ObsoleteAttribute instead. Make sure you set it to error, though.
//
// Thanks for listening~
- public const int CurrentConfigVersion = 7;
+ public const int CurrentConfigVersion = 10;
#region Meta
diff --git a/ProjectLighthouse/Helpers/VersionHelper.cs b/ProjectLighthouse/Helpers/VersionHelper.cs
index 212eb091..f78bf858 100644
--- a/ProjectLighthouse/Helpers/VersionHelper.cs
+++ b/ProjectLighthouse/Helpers/VersionHelper.cs
@@ -8,10 +8,13 @@ public static class VersionHelper
{
static VersionHelper()
{
+ string commitNumber = "invalid";
try
{
CommitHash = ResourceHelper.ReadManifestFile("gitVersion.txt");
Branch = ResourceHelper.ReadManifestFile("gitBranch.txt");
+ commitNumber = $"{CommitHash}_{Build}";
+ FullRevision = (Branch == "main") ? $"r{commitNumber}" : $"{Branch}_r{commitNumber}";
string remotesFile = ResourceHelper.ReadManifestFile("gitRemotes.txt");
@@ -54,7 +57,15 @@ public static class VersionHelper
public static string CommitHash { get; set; }
public static string Branch { get; set; }
- public static string FullVersion => $"Project Lighthouse {Branch}@{CommitHash} {Build} ({ServerConfiguration.Instance.Customization.ServerName})";
+ ///
+ /// The full revision string. States current revision hash and, if not main, the branch.
+ ///
+ public static string FullRevision { get; set; }
+ ///
+ /// The server's branding (environment version) to show to LBP clients. Shows the environment name next to the revision.
+ ///
+ public static string EnvVer => $"{ServerConfiguration.Instance.Customization.EnvironmentName} {FullRevision}";
+ public static string FullVersion => $"Project Lighthouse {ServerConfiguration.Instance.Customization.EnvironmentName} {Branch}@{CommitHash} {Build}";
public static bool IsDirty => CommitHash.EndsWith("-dirty") || CommitsOutOfDate != 1 || CommitHash == "invalid" || Branch == "invalid";
public static int CommitsOutOfDate { get; set; }
public static bool CanCheckForUpdates { get; set; }
diff --git a/ProjectLighthouse/Helpers/WebhookHelper.cs b/ProjectLighthouse/Helpers/WebhookHelper.cs
index 031a79de..d54026c2 100644
--- a/ProjectLighthouse/Helpers/WebhookHelper.cs
+++ b/ProjectLighthouse/Helpers/WebhookHelper.cs
@@ -1,3 +1,4 @@
+using System;
using System.Threading.Tasks;
using Discord;
using Discord.Webhook;
@@ -7,17 +8,44 @@ namespace LBPUnion.ProjectLighthouse.Helpers;
public static class WebhookHelper
{
- private static readonly DiscordWebhookClient client = (ServerConfiguration.Instance.DiscordIntegration.DiscordIntegrationEnabled
+ ///
+ /// The destination of the webhook post.
+ ///
+ public enum WebhookDestination : byte
+ {
+ ///
+ /// A channel intended for public viewing; where new levels and photos are sent.
+ ///
+ Public,
+ ///
+ /// A channel intended for moderators; where grief reports are sent.
+ ///
+ Moderation,
+ }
+
+ private static readonly DiscordWebhookClient publicClient = (ServerConfiguration.Instance.DiscordIntegration.DiscordIntegrationEnabled
? new DiscordWebhookClient(ServerConfiguration.Instance.DiscordIntegration.Url)
: null);
+ private static readonly DiscordWebhookClient moderationClient = (ServerConfiguration.Instance.DiscordIntegration.DiscordIntegrationEnabled
+ ? new DiscordWebhookClient(ServerConfiguration.Instance.DiscordIntegration.ModerationUrl)
+ : null);
+
public static readonly Color UnionColor = new(0, 140, 255);
- public static Task SendWebhook(EmbedBuilder builder) => SendWebhook(builder.Build());
+ public static Task SendWebhook(EmbedBuilder builder, WebhookDestination dest = WebhookDestination.Public)
+ => SendWebhook(builder.Build(), dest);
- public static async Task SendWebhook(Embed embed)
+ public static async Task SendWebhook(Embed embed, WebhookDestination dest = WebhookDestination.Public)
{
if (!ServerConfiguration.Instance.DiscordIntegration.DiscordIntegrationEnabled) return;
+
+ DiscordWebhookClient client = dest switch
+ {
+ WebhookDestination.Public => publicClient,
+ WebhookDestination.Moderation => moderationClient,
+ _ => throw new ArgumentOutOfRangeException(nameof(dest), dest, null),
+ };
await client.SendMessageAsync
(
@@ -28,7 +56,7 @@ public static class WebhookHelper
);
}
- public static Task SendWebhook(string title, string description)
+ public static Task SendWebhook(string title, string description, WebhookDestination dest = WebhookDestination.Public)
=> SendWebhook
(
new EmbedBuilder
@@ -36,6 +64,7 @@ public static class WebhookHelper
Title = title,
Description = description,
Color = UnionColor,
- }
+ },
+ dest
);
}
\ No newline at end of file
diff --git a/ProjectLighthouse/PlayerData/Profiles/UserStatus.cs b/ProjectLighthouse/PlayerData/Profiles/UserStatus.cs
index 91c0083a..a01a5f31 100644
--- a/ProjectLighthouse/PlayerData/Profiles/UserStatus.cs
+++ b/ProjectLighthouse/PlayerData/Profiles/UserStatus.cs
@@ -1,6 +1,8 @@
#nullable enable
using System.Linq;
using LBPUnion.ProjectLighthouse.Helpers;
+using LBPUnion.ProjectLighthouse.Localization;
+using LBPUnion.ProjectLighthouse.Localization.StringLists;
using LBPUnion.ProjectLighthouse.Match.Rooms;
namespace LBPUnion.ProjectLighthouse.PlayerData.Profiles;
@@ -34,15 +36,17 @@ public class UserStatus
this.CurrentRoom = RoomHelper.FindRoomByUserId(userId);
}
- public override string ToString()
+ public string ToTranslatedString(string language)
{
this.CurrentVersion ??= GameVersion.Unknown;
this.CurrentPlatform ??= Platform.Unknown;
+
return this.StatusType switch
{
- StatusType.Online => $"Currently online on {((GameVersion)this.CurrentVersion).ToPrettyString()} on {((Platform)this.CurrentPlatform)}",
- StatusType.Offline => "Offline",
- _ => "Unknown",
+ StatusType.Online => StatusStrings.CurrentlyOnline.Translate(language,
+ ((GameVersion)this.CurrentVersion).ToPrettyString(), ((Platform)this.CurrentPlatform)),
+ StatusType.Offline => StatusStrings.Offline.Translate(language),
+ _ => GeneralStrings.Unknown.Translate(language),
};
}
}
\ No newline at end of file
diff --git a/ProjectLighthouse/ProjectLighthouse.csproj b/ProjectLighthouse/ProjectLighthouse.csproj
index 94563456..bee4e972 100644
--- a/ProjectLighthouse/ProjectLighthouse.csproj
+++ b/ProjectLighthouse/ProjectLighthouse.csproj
@@ -1,4 +1,4 @@
-
+
Linux
net6.0
@@ -28,26 +28,26 @@
-
-
- Always
-
-
-
- Always
-
-
-
- Always
-
-
-
- Always
-
-
-
- Always
-
+
+
+ Always
+
+
+
+ Always
+
+
+
+ Always
+
+
+
+ Always
+
+
+
+ Always
+
@@ -55,9 +55,9 @@
-
-
-
-
+
+
+
+