From 7839082c307837db2a841111f8037e71243e6ae0 Mon Sep 17 00:00:00 2001 From: FeTetra Date: Tue, 10 Sep 2024 16:24:21 -0400 Subject: [PATCH 1/6] Implement checkboxes in slot settings to toggle various slot properties --- .../Pages/SlotSettingsPage.cshtml | 28 +++++++++++++++++ .../Pages/SlotSettingsPage.cshtml.cs | 30 ++++++++++++++++++- 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/ProjectLighthouse.Servers.Website/Pages/SlotSettingsPage.cshtml b/ProjectLighthouse.Servers.Website/Pages/SlotSettingsPage.cshtml index 97d078261..85384367d 100644 --- a/ProjectLighthouse.Servers.Website/Pages/SlotSettingsPage.cshtml +++ b/ProjectLighthouse.Servers.Website/Pages/SlotSettingsPage.cshtml @@ -60,6 +60,34 @@ function onSubmit(){ +
+ + + @if (Model.Slot.GameVersion != GameVersion.LittleBigPlanet1) + { + + } + else + { + + } + @if (Model.Slot.GameVersion != GameVersion.LittleBigPlanet1) {
diff --git a/ProjectLighthouse.Servers.Website/Pages/SlotSettingsPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/SlotSettingsPage.cshtml.cs index b461d9825..0fe2eab32 100644 --- a/ProjectLighthouse.Servers.Website/Pages/SlotSettingsPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/SlotSettingsPage.cshtml.cs @@ -5,6 +5,7 @@ using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Types.Entities.Level; +using LBPUnion.ProjectLighthouse.Types.Users; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; @@ -17,7 +18,18 @@ public class SlotSettingsPage : BaseLayout public SlotSettingsPage(DatabaseContext database) : base(database) {} - public async Task OnPost([FromRoute] int slotId, [FromForm] string? avatar, [FromForm] string? name, [FromForm] string? description, string? labels) + public async Task OnPost + ( + [FromRoute] int slotId, + [FromForm] string? avatar, + [FromForm] string? name, + [FromForm] string? description, + [FromForm] string? labels, + [FromForm] bool initiallyLocked, + [FromForm] int shareable, + [FromForm] bool subLevel, + [FromForm] bool lbp1Only + ) { this.Slot = await this.Database.Slots.FirstOrDefaultAsync(u => u.SlotId == slotId); if (this.Slot == null) return this.NotFound(); @@ -55,6 +67,22 @@ public async Task OnPost([FromRoute] int slotId, [FromForm] strin this.Slot.AuthorLabels = labels; } + if (this.Slot.InitiallyLocked != initiallyLocked) this.Slot.InitiallyLocked = initiallyLocked; + + if (this.Slot.Shareable != shareable) this.Slot.Shareable = shareable; + + if (this.Slot.SubLevel != subLevel) + { + if (this.Slot.GameVersion != GameVersion.LittleBigPlanet1) + this.Slot.SubLevel = subLevel; + } + + if (this.Slot.Lbp1Only != lbp1Only) + { + if (this.Slot.GameVersion == GameVersion.LittleBigPlanet1) + this.Slot.Lbp1Only = lbp1Only; + } + // ReSharper disable once InvertIf if (this.Database.ChangeTracker.HasChanges()) { From 07aee8347ddd131efaf1c1b0ec9b869198f79389 Mon Sep 17 00:00:00 2001 From: FeTetra Date: Thu, 26 Sep 2024 01:07:10 -0400 Subject: [PATCH 2/6] Fix UI inconsistencies in checkboxes --- .../Pages/SlotSettingsPage.cshtml | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/ProjectLighthouse.Servers.Website/Pages/SlotSettingsPage.cshtml b/ProjectLighthouse.Servers.Website/Pages/SlotSettingsPage.cshtml index 85384367d..1cb19be18 100644 --- a/ProjectLighthouse.Servers.Website/Pages/SlotSettingsPage.cshtml +++ b/ProjectLighthouse.Servers.Website/Pages/SlotSettingsPage.cshtml @@ -61,30 +61,30 @@ function onSubmit(){
-