mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-09 21:38:43 +00:00
Merge branch 'LBPUnion:main' into main
This commit is contained in:
commit
a3f16c6e4d
4 changed files with 75 additions and 43 deletions
|
@ -1,4 +1,5 @@
|
||||||
#nullable enable
|
#nullable enable
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -39,7 +40,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
||||||
photo.CreatorId = user.UserId;
|
photo.CreatorId = user.UserId;
|
||||||
photo.Creator = user;
|
photo.Creator = user;
|
||||||
|
|
||||||
foreach (PhotoSubject subject in photo.Subjects)
|
foreach (PhotoSubject subject in photo.SubjectsXmlDontUse) // fine for here
|
||||||
{
|
{
|
||||||
subject.User = await this.database.Users.FirstOrDefaultAsync(u => u.Username == subject.Username);
|
subject.User = await this.database.Users.FirstOrDefaultAsync(u => u.Username == subject.Username);
|
||||||
|
|
||||||
|
@ -71,15 +72,41 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("photos/by")]
|
[HttpGet("photos/by")]
|
||||||
public async Task<IActionResult> UserPhotos([FromQuery] string user)
|
public async Task<IActionResult> UserPhotosBy([FromQuery] string user, [FromQuery] int pageStart, [FromQuery] int pageSize)
|
||||||
{
|
{
|
||||||
User? userFromQuery = await this.database.Users.FirstOrDefaultAsync(u => u.Username == user);
|
User? userFromQuery = await this.database.Users.FirstOrDefaultAsync(u => u.Username == user);
|
||||||
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
|
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
|
||||||
if (user == null) return this.NotFound();
|
if (user == null) return this.NotFound();
|
||||||
|
|
||||||
List<Photo> photos = await this.database.Photos.Where(p => p.CreatorId == userFromQuery.UserId).Take(10).ToListAsync();
|
List<Photo> photos = await this.database.Photos.Where(p => p.CreatorId == userFromQuery.UserId)
|
||||||
|
.OrderByDescending(s => s.Timestamp)
|
||||||
|
.Skip(pageStart - 1)
|
||||||
|
.Take(Math.Min(pageSize, 30))
|
||||||
|
.ToListAsync();
|
||||||
string response = photos.Aggregate(string.Empty, (s, photo) => s + photo.Serialize(0));
|
string response = photos.Aggregate(string.Empty, (s, photo) => s + photo.Serialize(0));
|
||||||
return this.Ok(LbpSerializer.StringElement("photos", response));
|
return this.Ok(LbpSerializer.StringElement("photos", response));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet("photos/with")]
|
||||||
|
public async Task<IActionResult> UserPhotosWith([FromQuery] string user, [FromQuery] int pageStart, [FromQuery] int pageSize)
|
||||||
|
{
|
||||||
|
User? userFromQuery = await this.database.Users.FirstOrDefaultAsync(u => u.Username == user);
|
||||||
|
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
|
||||||
|
if (user == null) return this.NotFound();
|
||||||
|
|
||||||
|
List<Photo> photos = new();
|
||||||
|
foreach (Photo photo in this.database.Photos)
|
||||||
|
{
|
||||||
|
photos.AddRange(photo.Subjects.Where(subject => subject.User.UserId == userFromQuery.UserId).Select(_ => photo));
|
||||||
|
}
|
||||||
|
|
||||||
|
string response = photos.OrderByDescending
|
||||||
|
(s => s.Timestamp)
|
||||||
|
.Skip(pageStart - 1)
|
||||||
|
.Take(Math.Min(pageSize, 30))
|
||||||
|
.Aggregate(string.Empty, (s, photo) => s + photo.Serialize(0));
|
||||||
|
|
||||||
|
return this.Ok(LbpSerializer.StringElement("photos", response));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -33,39 +33,23 @@ namespace LBPUnion.ProjectLighthouse.Types
|
||||||
[XmlElement("plan")]
|
[XmlElement("plan")]
|
||||||
public string PlanHash { get; set; }
|
public string PlanHash { get; set; }
|
||||||
|
|
||||||
// [XmlIgnore]
|
[NotMapped]
|
||||||
// public int SlotId { get; set; }
|
private List<PhotoSubject>? subjects;
|
||||||
//
|
|
||||||
// [XmlIgnore]
|
|
||||||
// [ForeignKey(nameof(SlotId))]
|
|
||||||
// public Slot Slot { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Only use when parsing from XML.
|
|
||||||
/// </summary>
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
[XmlArray("subjects")]
|
[XmlArray("subjects")]
|
||||||
[XmlArrayItem("subject")]
|
[XmlArrayItem("subject")]
|
||||||
public List<PhotoSubject> Subjects { get; set; }
|
public List<PhotoSubject> SubjectsXmlDontUse {
|
||||||
|
get => null!;
|
||||||
[NotMapped]
|
set => Subjects = value;
|
||||||
[XmlIgnore]
|
|
||||||
public string[] PhotoSubjectIds {
|
|
||||||
get => this.PhotoSubjectCollection.Split(",");
|
|
||||||
set => this.PhotoSubjectCollection = string.Join(',', value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string PhotoSubjectCollection { get; set; }
|
[NotMapped]
|
||||||
|
public List<PhotoSubject> Subjects {
|
||||||
|
get {
|
||||||
|
if (this.subjects != null) return this.subjects;
|
||||||
|
|
||||||
public int CreatorId { get; set; }
|
|
||||||
|
|
||||||
[ForeignKey(nameof(CreatorId))]
|
|
||||||
public User Creator { get; set; }
|
|
||||||
|
|
||||||
public List<PhotoSubject> GetSubjects()
|
|
||||||
{
|
|
||||||
List<PhotoSubject> response = new();
|
List<PhotoSubject> response = new();
|
||||||
|
|
||||||
using Database database = new();
|
using Database database = new();
|
||||||
|
|
||||||
foreach (string idStr in this.PhotoSubjectIds)
|
foreach (string idStr in this.PhotoSubjectIds)
|
||||||
|
@ -82,12 +66,28 @@ namespace LBPUnion.ProjectLighthouse.Types
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
set => this.subjects = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
|
[XmlIgnore]
|
||||||
|
public string[] PhotoSubjectIds {
|
||||||
|
get => this.PhotoSubjectCollection.Split(",");
|
||||||
|
set => this.PhotoSubjectCollection = string.Join(',', value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string PhotoSubjectCollection { get; set; }
|
||||||
|
|
||||||
|
public int CreatorId { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey(nameof(CreatorId))]
|
||||||
|
public User Creator { get; set; }
|
||||||
|
|
||||||
public string Serialize(int slotId)
|
public string Serialize(int slotId)
|
||||||
{
|
{
|
||||||
string slot = LbpSerializer.TaggedStringElement("slot", LbpSerializer.StringElement("id", slotId), "type", "user");
|
string slot = LbpSerializer.TaggedStringElement("slot", LbpSerializer.StringElement("id", slotId), "type", "user");
|
||||||
|
|
||||||
string subjects = this.GetSubjects().Aggregate(string.Empty, (s, subject) => s + subject.Serialize());
|
string subjectsAggregate = this.Subjects.Aggregate(string.Empty, (s, subject) => s + subject.Serialize());
|
||||||
|
|
||||||
string photo = LbpSerializer.StringElement("id", this.PhotoId) +
|
string photo = LbpSerializer.StringElement("id", this.PhotoId) +
|
||||||
LbpSerializer.StringElement("small", this.SmallHash) +
|
LbpSerializer.StringElement("small", this.SmallHash) +
|
||||||
|
@ -95,7 +95,7 @@ namespace LBPUnion.ProjectLighthouse.Types
|
||||||
LbpSerializer.StringElement("large", this.LargeHash) +
|
LbpSerializer.StringElement("large", this.LargeHash) +
|
||||||
LbpSerializer.StringElement("plan", this.PlanHash) +
|
LbpSerializer.StringElement("plan", this.PlanHash) +
|
||||||
LbpSerializer.StringElement("author", this.CreatorId) +
|
LbpSerializer.StringElement("author", this.CreatorId) +
|
||||||
LbpSerializer.StringElement("subjects", subjects) +
|
LbpSerializer.StringElement("subjects", subjectsAggregate) +
|
||||||
slot;
|
slot;
|
||||||
|
|
||||||
return LbpSerializer.TaggedStringElement("photo", photo, "timestamp", Timestamp * 1000);
|
return LbpSerializer.TaggedStringElement("photo", photo, "timestamp", Timestamp * 1000);
|
||||||
|
|
|
@ -37,7 +37,12 @@ namespace LBPUnion.ProjectLighthouse.Types
|
||||||
}
|
}
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public int PhotosWithMeCount { get; set; }
|
public int PhotosWithMeCount {
|
||||||
|
get {
|
||||||
|
using Database database = new();
|
||||||
|
return Enumerable.Sum(database.Photos, photo => photo.Subjects.Count(subject => subject.User.UserId == this.UserId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public bool CommentsEnabled { get; set; }
|
public bool CommentsEnabled { get; set; }
|
||||||
|
|
||||||
|
|
|
@ -75,10 +75,10 @@ Some modifications may require updates to the database schema. You can automatic
|
||||||
## Compatibility across games and platforms
|
## Compatibility across games and platforms
|
||||||
|
|
||||||
| Game | Console (PS3/Vita) | Emulator (RPCS3) | Next-Gen (PS4/PS5) |
|
| Game | Console (PS3/Vita) | Emulator (RPCS3) | Next-Gen (PS4/PS5) |
|
||||||
|----------|-----------------------------------|------------------------------------------------|--------------------|
|
|----------|-------------------------------------|------------------------------------------------|--------------------|
|
||||||
| LBP1 | Compatible | Incompatible, crashes on entering pod computer | N/A |
|
| LBP1 | Compatible | Incompatible, crashes on entering pod computer | N/A |
|
||||||
| LBP2 | Compatible | Compatible with patched RPCS3 | N/A |
|
| LBP2 | Compatible | Compatible with patched RPCS3 | N/A |
|
||||||
| LBP3 | Somewhat compatible | Somewhat compatible with workaround | Incompatible |
|
| LBP3 | Somewhat compatible | Somewhat compatible with workaround | Incompatible |
|
||||||
| LBP Vita | Potentially compatible | N/A | N/A |
|
| LBP Vita | Somewhat compatible with workaround | N/A | N/A |
|
||||||
|
|
||||||
Project Lighthouse is still a heavy work in progress, so this is subject to change at any point.
|
Project Lighthouse is still a heavy work in progress, so this is subject to change at any point.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue