Load/cache icon directly out of archive, don't rely on embedded manifest

This commit is contained in:
Pat Hartl 2023-01-16 00:01:50 -06:00
parent 1675d38f88
commit 89633c1096
9 changed files with 1145 additions and 3 deletions

View file

@ -357,6 +357,7 @@ namespace LANCommander.Controllers
game.Title = viewModel.Game.Title;
game.SortTitle = viewModel.Game.SortTitle;
game.DirectoryName = viewModel.Game.DirectoryName;
game.Icon = viewModel.Game.Icon;
game.Description = viewModel.Game.Description;
game.ReleasedOn = viewModel.Game.ReleasedOn;
game.Singleplayer = viewModel.Game.Singleplayer;

View file

@ -10,6 +10,7 @@ namespace LANCommander.Data.Models
public string Title { get; set; }
[Display(Name = "Sort Title")]
public string? SortTitle { get; set; }
public string? Icon { get; set; }
[Display(Name = "Directory Name")]
public string? DirectoryName { get; set; }
public string? Description { get; set; }

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,25 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace LANCommander.Migrations
{
public partial class AddIconField : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Icon",
table: "Games",
type: "TEXT",
nullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Icon",
table: "Games");
}
}
}

View file

@ -282,6 +282,9 @@ namespace LANCommander.Migrations
b.Property<long?>("IGDBId")
.HasColumnType("INTEGER");
b.Property<string>("Icon")
.HasColumnType("TEXT");
b.Property<DateTime?>("ReleasedOn")
.HasColumnType("TEXT");

View file

@ -121,8 +121,7 @@ namespace LANCommander.Services
Bitmap bitmap = null;
var manifest = ArchiveService.ReadManifest(archive.ObjectKey);
var iconReference = ArchiveService.ReadFile(archive.ObjectKey, manifest.Icon);
var iconReference = ArchiveService.ReadFile(archive.ObjectKey, game.Icon);
if (IsWinPEFile(iconReference))
{

View file

@ -41,6 +41,11 @@
<input asp-for="Game.SortTitle" class="form-control" />
<span asp-validation-for="Game.SortTitle" class="text-danger"></span>
</div>
<div class="mb-3">
<label asp-for="Game.Icon" class="control-label"></label>
<input asp-for="Game.Icon" class="form-control" />
<span asp-validation-for="Game.Icon" class="text-danger"></span>
</div>
<div class="mb-3">
<label asp-for="Game.Description" class="control-label"></label>
<textarea asp-for="Game.Description" class="form-control" data-bs-toggle="autosize"></textarea>

View file

@ -42,6 +42,11 @@
<input asp-for="Game.SortTitle" class="form-control" />
<span asp-validation-for="Game.SortTitle" class="text-danger"></span>
</div>
<div class="mb-3">
<label asp-for="Game.Icon" class="control-label"></label>
<input asp-for="Game.Icon" class="form-control" />
<span asp-validation-for="Game.Icon" class="text-danger"></span>
</div>
<div class="mb-3">
<label asp-for="Game.Description" class="control-label"></label>
<textarea asp-for="Game.Description" class="form-control" data-bs-toggle="autosize"></textarea>

View file

@ -63,7 +63,11 @@
@foreach (var item in Model)
{
<tr>
<td><img src="@Url.Action("GetIcon", "Games", new { id = item.Id })" /></td>
<td>
@if (!String.IsNullOrWhiteSpace(item.Icon)) {
<img src="@Url.Action("GetIcon", "Games", new { id = item.Id })" />
}
</td>
<td>
@Html.DisplayFor(modelItem => item.Title)
</td>