Allow amount of allowed levels to be configured

Closes #67
This commit is contained in:
jvyden 2021-11-26 17:21:01 -05:00
commit f671267ed8
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
5 changed files with 16 additions and 15 deletions

View file

@ -41,7 +41,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers
.Include(s => s.Location)
.Where(s => s.Creator!.Username == user.Username)
.Skip(pageStart - 1)
.Take(Math.Min(pageSize, ServerStatics.EntitledSlots)),
.Take(Math.Min(pageSize, ServerSettings.Instance.EntitledSlots)),
string.Empty,
(current, slot) => current + slot.Serialize()
);
@ -55,7 +55,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers
new Dictionary<string, object>
{
{
"hint_start", pageStart + Math.Min(pageSize, ServerStatics.EntitledSlots)
"hint_start", pageStart + Math.Min(pageSize, ServerSettings.Instance.EntitledSlots)
},
{
"total", user.UsedSlots

View file

@ -17,7 +17,7 @@
<div class="userStats">
<i class="pink heart icon" title="Hearts"></i> <span>@Model.ProfileUser.Hearts</span>
<i class="blue comment icon" title="Comments"></i> <span>@Model.ProfileUser.Comments</span>
<i class="green upload icon" title="Uploaded Levels"></i><span>@Model.ProfileUser.UsedSlots / @ServerStatics.EntitledSlots</span>
<i class="green upload icon" title="Uploaded Levels"></i><span>@Model.ProfileUser.UsedSlots / @ServerSettings.Instance.EntitledSlots</span>
<i class="purple camera icon" title="Uploaded Photos"></i><span>@Model.ProfileUser.PhotosByMe</span>
</div>
</div>

View file

@ -63,7 +63,7 @@ namespace LBPUnion.ProjectLighthouse.Types.Settings
}
}
public const int CurrentConfigVersion = 9; // MUST BE INCREMENTED FOR EVERY CONFIG CHANGE!
public const int CurrentConfigVersion = 10; // MUST BE INCREMENTED FOR EVERY CONFIG CHANGE!
#region Meta
@ -95,5 +95,12 @@ namespace LBPUnion.ProjectLighthouse.Types.Settings
public bool CheckForUnsafeFiles { get; set; } = true;
public bool RegistrationEnabled { get; set; } = true;
/// <summary>
/// The maximum amount of slots allowed on users' earth
/// </summary>
public int EntitledSlots { get; set; } = 50;
public int ListsQuota { get; set; } = 50;
}
}

View file

@ -8,13 +8,6 @@ namespace LBPUnion.ProjectLighthouse.Types.Settings
{
public static class ServerStatics
{
/// <summary>
/// The maximum amount of slots allowed on users' earth
/// </summary>
public const int EntitledSlots = 50;
public const int ListsQuota = 50;
public const string ServerName = "ProjectLighthouse";
public static bool DbConnected {

View file

@ -120,7 +120,8 @@ namespace LBPUnion.ProjectLighthouse.Types
LbpSerializer.StringElement("game", this.Game) +
this.SerializeSlots(gameVersion == GameVersion.LittleBigPlanetVita) +
LbpSerializer.StringElement("lists", this.Lists) +
LbpSerializer.StringElement("lists_quota", ServerStatics.ListsQuota) + // technically not a part of the user but LBP expects it
LbpSerializer.StringElement
("lists_quota", ServerSettings.Instance.ListsQuota) + // technically not a part of the user but LBP expects it
LbpSerializer.StringElement("biography", this.Biography) +
LbpSerializer.StringElement("reviewCount", this.Reviews) +
LbpSerializer.StringElement("commentCount", this.Comments) +
@ -162,7 +163,7 @@ namespace LBPUnion.ProjectLighthouse.Types
/// <summary>
/// The number of slots remaining on the earth
/// </summary>
public int FreeSlots => ServerStatics.EntitledSlots - this.UsedSlots;
public int FreeSlots => ServerSettings.Instance.EntitledSlots - this.UsedSlots;
private static readonly string[] slotTypes =
{
@ -192,12 +193,12 @@ namespace LBPUnion.ProjectLighthouse.Types
slotTypesLocal = slotTypes;
}
slots += LbpSerializer.StringElement("entitledSlots", ServerStatics.EntitledSlots);
slots += LbpSerializer.StringElement("entitledSlots", ServerSettings.Instance.EntitledSlots);
slots += LbpSerializer.StringElement("freeSlots", this.FreeSlots);
foreach (string slotType in slotTypesLocal)
{
slots += LbpSerializer.StringElement(slotType + "EntitledSlots", ServerStatics.EntitledSlots);
slots += LbpSerializer.StringElement(slotType + "EntitledSlots", ServerSettings.Instance.EntitledSlots);
// ReSharper disable once StringLiteralTypo
slots += LbpSerializer.StringElement(slotType + slotType == "crossControl" ? "PurchsedSlots" : "PurchasedSlots", 0);
slots += LbpSerializer.StringElement(slotType + "FreeSlots", this.FreeSlots);