Hard Reset I guess

This commit is contained in:
Lani Aung
2024-02-11 21:30:36 -07:00
parent 2a1449ff2f
commit a8d3afd2a8
19 changed files with 376 additions and 2463 deletions
+28 -29
View File
@@ -7,41 +7,40 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace fxl.codes.kisekae.Controllers namespace fxl.codes.kisekae.Controllers;
public class HomeController : Controller
{ {
public class HomeController : Controller private readonly DatabaseService _databaseService;
private readonly ILogger<HomeController> _logger;
public HomeController(ILogger<HomeController> logger, DatabaseService databaseService)
{ {
private readonly DatabaseService _databaseService; _logger = logger;
private readonly ILogger<HomeController> _logger; _databaseService = databaseService;
}
public HomeController(ILogger<HomeController> logger, DatabaseService databaseService) public IActionResult Index()
{ {
_logger = logger; var files = _databaseService.GetAll();
_databaseService = databaseService; return View(files.Select(x => new KisekaeModel(x)));
} }
public IActionResult Index() [HttpPost]
{ public IActionResult Upload(IFormFile file)
var files = _databaseService.GetAll(); {
return View(files.Select(x => new KisekaeModel(x))); _logger.LogTrace($"File uploaded: {file?.FileName}");
} if (!(file?.FileName.EndsWith("lzh", StringComparison.InvariantCultureIgnoreCase) ?? false))
throw new Exception("Please select a *.lzh file");
[HttpPost] _databaseService.StoreToDatabase(file);
public IActionResult Upload(IFormFile file)
{
_logger.LogTrace($"File uploaded: {file?.FileName}");
if (!(file?.FileName.EndsWith("lzh", StringComparison.InvariantCultureIgnoreCase) ?? false))
throw new Exception("Please select a *.lzh file");
_databaseService.StoreToDatabase(file); return Redirect("~/");
}
return View(); [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
} public IActionResult Error()
{
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
} }
} }
-367
View File
@@ -1,367 +0,0 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using fxl.codes.kisekae;
#nullable disable
namespace fxl.codes.kisekae.Migrations
{
[DbContext(typeof(KisekaeContext))]
[Migration("20211120044959_Startup")]
partial class Startup
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "6.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("fxl.codes.kisekae.Entities.Action", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int?>("ConfigurationId")
.HasColumnType("integer");
b.Property<string>("Name")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ConfigurationId");
b.ToTable("Action");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Cel", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<byte[]>("Data")
.HasColumnType("bytea");
b.Property<string>("FileName")
.HasColumnType("text");
b.Property<int>("Height")
.HasColumnType("integer");
b.Property<int?>("KisekaeId")
.HasColumnType("integer");
b.Property<int>("OffsetX")
.HasColumnType("integer");
b.Property<int>("OffsetY")
.HasColumnType("integer");
b.Property<int>("Width")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("KisekaeId");
b.ToTable("Cels");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.CelConfig", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int?>("CelId")
.HasColumnType("integer");
b.Property<string>("Comment")
.HasColumnType("text");
b.Property<int?>("ConfigurationId")
.HasColumnType("integer");
b.Property<int>("Fix")
.HasColumnType("integer");
b.Property<int>("Mark")
.HasColumnType("integer");
b.Property<int>("PaletteGroup")
.HasColumnType("integer");
b.Property<int?>("PaletteId")
.HasColumnType("integer");
b.Property<int>("Sets")
.HasColumnType("integer");
b.Property<int>("Transparency")
.HasColumnType("integer");
b.Property<int>("X")
.HasColumnType("integer");
b.Property<int>("Y")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("CelId");
b.HasIndex("ConfigurationId");
b.HasIndex("PaletteId");
b.ToTable("CelConfigs");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Configuration", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("BorderIndex")
.HasColumnType("integer");
b.Property<string>("Data")
.HasColumnType("text");
b.Property<int>("Height")
.HasColumnType("integer");
b.Property<int?>("KisekaeId")
.HasColumnType("integer");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<int>("Width")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("KisekaeId");
b.ToTable("Configurations");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Kisekae", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("CheckSum")
.HasColumnType("text");
b.Property<string>("FileName")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("KisekaeSets");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Palette", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Comment")
.HasColumnType("text");
b.Property<byte[]>("Data")
.HasColumnType("bytea");
b.Property<string>("FileName")
.HasColumnType("text");
b.Property<int?>("KisekaeId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("KisekaeId");
b.ToTable("Palettes");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.PaletteColor", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("Group")
.HasColumnType("integer");
b.Property<string>("Hex")
.HasColumnType("text");
b.Property<int?>("PaletteId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("PaletteId");
b.ToTable("PaletteColors");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Render", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int?>("CelId")
.HasColumnType("integer");
b.Property<byte[]>("Image")
.HasColumnType("bytea");
b.Property<int?>("PaletteId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("CelId");
b.HasIndex("PaletteId");
b.ToTable("Renders");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Action", b =>
{
b.HasOne("fxl.codes.kisekae.Entities.Configuration", null)
.WithMany("Actions")
.HasForeignKey("ConfigurationId");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Cel", b =>
{
b.HasOne("fxl.codes.kisekae.Entities.Kisekae", "Kisekae")
.WithMany("Cels")
.HasForeignKey("KisekaeId");
b.Navigation("Kisekae");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.CelConfig", b =>
{
b.HasOne("fxl.codes.kisekae.Entities.Cel", "Cel")
.WithMany()
.HasForeignKey("CelId");
b.HasOne("fxl.codes.kisekae.Entities.Configuration", "Configuration")
.WithMany("Cels")
.HasForeignKey("ConfigurationId");
b.HasOne("fxl.codes.kisekae.Entities.Palette", "Palette")
.WithMany()
.HasForeignKey("PaletteId");
b.Navigation("Cel");
b.Navigation("Configuration");
b.Navigation("Palette");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Configuration", b =>
{
b.HasOne("fxl.codes.kisekae.Entities.Kisekae", "Kisekae")
.WithMany("Configurations")
.HasForeignKey("KisekaeId");
b.Navigation("Kisekae");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Palette", b =>
{
b.HasOne("fxl.codes.kisekae.Entities.Kisekae", "Kisekae")
.WithMany("Palettes")
.HasForeignKey("KisekaeId");
b.Navigation("Kisekae");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.PaletteColor", b =>
{
b.HasOne("fxl.codes.kisekae.Entities.Palette", "Palette")
.WithMany("Colors")
.HasForeignKey("PaletteId");
b.Navigation("Palette");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Render", b =>
{
b.HasOne("fxl.codes.kisekae.Entities.Cel", "Cel")
.WithMany()
.HasForeignKey("CelId");
b.HasOne("fxl.codes.kisekae.Entities.Palette", "Palette")
.WithMany()
.HasForeignKey("PaletteId");
b.Navigation("Cel");
b.Navigation("Palette");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Configuration", b =>
{
b.Navigation("Actions");
b.Navigation("Cels");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Kisekae", b =>
{
b.Navigation("Cels");
b.Navigation("Configurations");
b.Navigation("Palettes");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Palette", b =>
{
b.Navigation("Colors");
});
#pragma warning restore 612, 618
}
}
}
-372
View File
@@ -1,372 +0,0 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using fxl.codes.kisekae;
#nullable disable
namespace fxl.codes.kisekae.Migrations
{
[DbContext(typeof(KisekaeContext))]
[Migration("20211120052043_Renders")]
partial class Renders
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "6.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("fxl.codes.kisekae.Entities.Action", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int?>("ConfigurationId")
.HasColumnType("integer");
b.Property<string>("Name")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ConfigurationId");
b.ToTable("Action");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Cel", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<byte[]>("Data")
.HasColumnType("bytea");
b.Property<string>("FileName")
.HasColumnType("text");
b.Property<int>("Height")
.HasColumnType("integer");
b.Property<int?>("KisekaeId")
.HasColumnType("integer");
b.Property<int>("OffsetX")
.HasColumnType("integer");
b.Property<int>("OffsetY")
.HasColumnType("integer");
b.Property<int>("Width")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("KisekaeId");
b.ToTable("Cels");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.CelConfig", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int?>("CelId")
.HasColumnType("integer");
b.Property<string>("Comment")
.HasColumnType("text");
b.Property<int?>("ConfigurationId")
.HasColumnType("integer");
b.Property<int>("Fix")
.HasColumnType("integer");
b.Property<int>("Mark")
.HasColumnType("integer");
b.Property<int>("PaletteGroup")
.HasColumnType("integer");
b.Property<int?>("PaletteId")
.HasColumnType("integer");
b.Property<int>("Sets")
.HasColumnType("integer");
b.Property<int>("Transparency")
.HasColumnType("integer");
b.Property<int>("X")
.HasColumnType("integer");
b.Property<int>("Y")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("CelId");
b.HasIndex("ConfigurationId");
b.HasIndex("PaletteId");
b.ToTable("CelConfigs");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Configuration", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("BorderIndex")
.HasColumnType("integer");
b.Property<string>("Data")
.HasColumnType("text");
b.Property<int>("Height")
.HasColumnType("integer");
b.Property<int?>("KisekaeId")
.HasColumnType("integer");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<int>("Width")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("KisekaeId");
b.ToTable("Configurations");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Kisekae", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("CheckSum")
.HasColumnType("text");
b.Property<string>("FileName")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("KisekaeSets");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Palette", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Comment")
.HasColumnType("text");
b.Property<byte[]>("Data")
.HasColumnType("bytea");
b.Property<string>("FileName")
.HasColumnType("text");
b.Property<int?>("KisekaeId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("KisekaeId");
b.ToTable("Palettes");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.PaletteColor", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("Group")
.HasColumnType("integer");
b.Property<string>("Hex")
.HasColumnType("text");
b.Property<int?>("PaletteId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("PaletteId");
b.ToTable("PaletteColors");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Render", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int?>("CelId")
.HasColumnType("integer");
b.Property<byte[]>("Image")
.HasColumnType("bytea");
b.Property<int?>("PaletteId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("CelId");
b.HasIndex("PaletteId");
b.ToTable("Renders");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Action", b =>
{
b.HasOne("fxl.codes.kisekae.Entities.Configuration", null)
.WithMany("Actions")
.HasForeignKey("ConfigurationId");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Cel", b =>
{
b.HasOne("fxl.codes.kisekae.Entities.Kisekae", "Kisekae")
.WithMany("Cels")
.HasForeignKey("KisekaeId");
b.Navigation("Kisekae");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.CelConfig", b =>
{
b.HasOne("fxl.codes.kisekae.Entities.Cel", "Cel")
.WithMany()
.HasForeignKey("CelId");
b.HasOne("fxl.codes.kisekae.Entities.Configuration", "Configuration")
.WithMany("Cels")
.HasForeignKey("ConfigurationId");
b.HasOne("fxl.codes.kisekae.Entities.Palette", "Palette")
.WithMany()
.HasForeignKey("PaletteId");
b.Navigation("Cel");
b.Navigation("Configuration");
b.Navigation("Palette");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Configuration", b =>
{
b.HasOne("fxl.codes.kisekae.Entities.Kisekae", "Kisekae")
.WithMany("Configurations")
.HasForeignKey("KisekaeId");
b.Navigation("Kisekae");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Palette", b =>
{
b.HasOne("fxl.codes.kisekae.Entities.Kisekae", "Kisekae")
.WithMany("Palettes")
.HasForeignKey("KisekaeId");
b.Navigation("Kisekae");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.PaletteColor", b =>
{
b.HasOne("fxl.codes.kisekae.Entities.Palette", "Palette")
.WithMany("Colors")
.HasForeignKey("PaletteId");
b.Navigation("Palette");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Render", b =>
{
b.HasOne("fxl.codes.kisekae.Entities.Cel", "Cel")
.WithMany("Renders")
.HasForeignKey("CelId");
b.HasOne("fxl.codes.kisekae.Entities.Palette", "Palette")
.WithMany()
.HasForeignKey("PaletteId");
b.Navigation("Cel");
b.Navigation("Palette");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Cel", b =>
{
b.Navigation("Renders");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Configuration", b =>
{
b.Navigation("Actions");
b.Navigation("Cels");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Kisekae", b =>
{
b.Navigation("Cels");
b.Navigation("Configurations");
b.Navigation("Palettes");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Palette", b =>
{
b.Navigation("Colors");
});
#pragma warning restore 612, 618
}
}
}
-19
View File
@@ -1,19 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace fxl.codes.kisekae.Migrations
{
public partial class Renders : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
}
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}
-353
View File
@@ -1,353 +0,0 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using fxl.codes.kisekae;
#nullable disable
namespace fxl.codes.kisekae.Migrations
{
[DbContext(typeof(KisekaeContext))]
[Migration("20211120054914_RendersP2")]
partial class RendersP2
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "6.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("fxl.codes.kisekae.Entities.Action", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int?>("ConfigurationId")
.HasColumnType("integer");
b.Property<string>("Name")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ConfigurationId");
b.ToTable("Action");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Cel", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<byte[]>("Data")
.HasColumnType("bytea");
b.Property<string>("FileName")
.HasColumnType("text");
b.Property<int>("Height")
.HasColumnType("integer");
b.Property<int?>("KisekaeId")
.HasColumnType("integer");
b.Property<int>("OffsetX")
.HasColumnType("integer");
b.Property<int>("OffsetY")
.HasColumnType("integer");
b.Property<int>("Width")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("KisekaeId");
b.ToTable("Cels");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.CelConfig", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int?>("CelId")
.HasColumnType("integer");
b.Property<string>("Comment")
.HasColumnType("text");
b.Property<int?>("ConfigurationId")
.HasColumnType("integer");
b.Property<int>("Fix")
.HasColumnType("integer");
b.Property<int>("Mark")
.HasColumnType("integer");
b.Property<int>("PaletteGroup")
.HasColumnType("integer");
b.Property<int?>("PaletteId")
.HasColumnType("integer");
b.Property<int?>("RenderId")
.HasColumnType("integer");
b.Property<int>("Sets")
.HasColumnType("integer");
b.Property<int>("Transparency")
.HasColumnType("integer");
b.Property<int>("X")
.HasColumnType("integer");
b.Property<int>("Y")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("CelId");
b.HasIndex("ConfigurationId");
b.HasIndex("PaletteId");
b.HasIndex("RenderId");
b.ToTable("CelConfigs");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Configuration", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("BorderIndex")
.HasColumnType("integer");
b.Property<string>("Data")
.HasColumnType("text");
b.Property<int>("Height")
.HasColumnType("integer");
b.Property<int?>("KisekaeId")
.HasColumnType("integer");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<int>("Width")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("KisekaeId");
b.ToTable("Configurations");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Kisekae", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("CheckSum")
.HasColumnType("text");
b.Property<string>("FileName")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("KisekaeSets");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Palette", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Comment")
.HasColumnType("text");
b.Property<byte[]>("Data")
.HasColumnType("bytea");
b.Property<string>("FileName")
.HasColumnType("text");
b.Property<int?>("KisekaeId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("KisekaeId");
b.ToTable("Palettes");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.PaletteColor", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("Group")
.HasColumnType("integer");
b.Property<string>("Hex")
.HasColumnType("text");
b.Property<int?>("PaletteId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("PaletteId");
b.ToTable("PaletteColors");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Render", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<byte[]>("Image")
.HasColumnType("bytea");
b.HasKey("Id");
b.ToTable("Renders");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Action", b =>
{
b.HasOne("fxl.codes.kisekae.Entities.Configuration", null)
.WithMany("Actions")
.HasForeignKey("ConfigurationId");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Cel", b =>
{
b.HasOne("fxl.codes.kisekae.Entities.Kisekae", "Kisekae")
.WithMany("Cels")
.HasForeignKey("KisekaeId");
b.Navigation("Kisekae");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.CelConfig", b =>
{
b.HasOne("fxl.codes.kisekae.Entities.Cel", "Cel")
.WithMany()
.HasForeignKey("CelId");
b.HasOne("fxl.codes.kisekae.Entities.Configuration", "Configuration")
.WithMany("Cels")
.HasForeignKey("ConfigurationId");
b.HasOne("fxl.codes.kisekae.Entities.Palette", "Palette")
.WithMany()
.HasForeignKey("PaletteId");
b.HasOne("fxl.codes.kisekae.Entities.Render", "Render")
.WithMany()
.HasForeignKey("RenderId");
b.Navigation("Cel");
b.Navigation("Configuration");
b.Navigation("Palette");
b.Navigation("Render");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Configuration", b =>
{
b.HasOne("fxl.codes.kisekae.Entities.Kisekae", "Kisekae")
.WithMany("Configurations")
.HasForeignKey("KisekaeId");
b.Navigation("Kisekae");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Palette", b =>
{
b.HasOne("fxl.codes.kisekae.Entities.Kisekae", "Kisekae")
.WithMany("Palettes")
.HasForeignKey("KisekaeId");
b.Navigation("Kisekae");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.PaletteColor", b =>
{
b.HasOne("fxl.codes.kisekae.Entities.Palette", "Palette")
.WithMany("Colors")
.HasForeignKey("PaletteId");
b.Navigation("Palette");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Configuration", b =>
{
b.Navigation("Actions");
b.Navigation("Cels");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Kisekae", b =>
{
b.Navigation("Cels");
b.Navigation("Configurations");
b.Navigation("Palettes");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Palette", b =>
{
b.Navigation("Colors");
});
#pragma warning restore 612, 618
}
}
}
-105
View File
@@ -1,105 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace fxl.codes.kisekae.Migrations
{
public partial class RendersP2 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Renders_Cels_CelId",
table: "Renders");
migrationBuilder.DropForeignKey(
name: "FK_Renders_Palettes_PaletteId",
table: "Renders");
migrationBuilder.DropIndex(
name: "IX_Renders_CelId",
table: "Renders");
migrationBuilder.DropIndex(
name: "IX_Renders_PaletteId",
table: "Renders");
migrationBuilder.DropColumn(
name: "CelId",
table: "Renders");
migrationBuilder.DropColumn(
name: "PaletteId",
table: "Renders");
migrationBuilder.AddColumn<int>(
name: "RenderId",
table: "CelConfigs",
type: "integer",
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_CelConfigs_RenderId",
table: "CelConfigs",
column: "RenderId");
migrationBuilder.AddForeignKey(
name: "FK_CelConfigs_Renders_RenderId",
table: "CelConfigs",
column: "RenderId",
principalTable: "Renders",
principalColumn: "Id");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_CelConfigs_Renders_RenderId",
table: "CelConfigs");
migrationBuilder.DropIndex(
name: "IX_CelConfigs_RenderId",
table: "CelConfigs");
migrationBuilder.DropColumn(
name: "RenderId",
table: "CelConfigs");
migrationBuilder.AddColumn<int>(
name: "CelId",
table: "Renders",
type: "integer",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "PaletteId",
table: "Renders",
type: "integer",
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_Renders_CelId",
table: "Renders",
column: "CelId");
migrationBuilder.CreateIndex(
name: "IX_Renders_PaletteId",
table: "Renders",
column: "PaletteId");
migrationBuilder.AddForeignKey(
name: "FK_Renders_Cels_CelId",
table: "Renders",
column: "CelId",
principalTable: "Cels",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Renders_Palettes_PaletteId",
table: "Renders",
column: "PaletteId",
principalTable: "Palettes",
principalColumn: "Id");
}
}
}
-353
View File
@@ -1,353 +0,0 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using fxl.codes.kisekae;
#nullable disable
namespace fxl.codes.kisekae.Migrations
{
[DbContext(typeof(KisekaeContext))]
[Migration("20211120201836_UseBackgroundHex")]
partial class UseBackgroundHex
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "6.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("fxl.codes.kisekae.Entities.Action", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int?>("ConfigurationId")
.HasColumnType("integer");
b.Property<string>("Name")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ConfigurationId");
b.ToTable("Action");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Cel", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<byte[]>("Data")
.HasColumnType("bytea");
b.Property<string>("FileName")
.HasColumnType("text");
b.Property<int>("Height")
.HasColumnType("integer");
b.Property<int?>("KisekaeId")
.HasColumnType("integer");
b.Property<int>("OffsetX")
.HasColumnType("integer");
b.Property<int>("OffsetY")
.HasColumnType("integer");
b.Property<int>("Width")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("KisekaeId");
b.ToTable("Cels");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.CelConfig", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int?>("CelId")
.HasColumnType("integer");
b.Property<string>("Comment")
.HasColumnType("text");
b.Property<int?>("ConfigurationId")
.HasColumnType("integer");
b.Property<int>("Fix")
.HasColumnType("integer");
b.Property<int>("Mark")
.HasColumnType("integer");
b.Property<int>("PaletteGroup")
.HasColumnType("integer");
b.Property<int?>("PaletteId")
.HasColumnType("integer");
b.Property<int?>("RenderId")
.HasColumnType("integer");
b.Property<int>("Sets")
.HasColumnType("integer");
b.Property<int>("Transparency")
.HasColumnType("integer");
b.Property<int>("X")
.HasColumnType("integer");
b.Property<int>("Y")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("CelId");
b.HasIndex("ConfigurationId");
b.HasIndex("PaletteId");
b.HasIndex("RenderId");
b.ToTable("CelConfigs");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Configuration", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("BackgroundColorHex")
.HasColumnType("text");
b.Property<string>("Data")
.HasColumnType("text");
b.Property<int>("Height")
.HasColumnType("integer");
b.Property<int?>("KisekaeId")
.HasColumnType("integer");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<int>("Width")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("KisekaeId");
b.ToTable("Configurations");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Kisekae", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("CheckSum")
.HasColumnType("text");
b.Property<string>("FileName")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("KisekaeSets");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Palette", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Comment")
.HasColumnType("text");
b.Property<byte[]>("Data")
.HasColumnType("bytea");
b.Property<string>("FileName")
.HasColumnType("text");
b.Property<int?>("KisekaeId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("KisekaeId");
b.ToTable("Palettes");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.PaletteColor", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("Group")
.HasColumnType("integer");
b.Property<string>("Hex")
.HasColumnType("text");
b.Property<int?>("PaletteId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("PaletteId");
b.ToTable("PaletteColors");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Render", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<byte[]>("Image")
.HasColumnType("bytea");
b.HasKey("Id");
b.ToTable("Renders");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Action", b =>
{
b.HasOne("fxl.codes.kisekae.Entities.Configuration", null)
.WithMany("Actions")
.HasForeignKey("ConfigurationId");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Cel", b =>
{
b.HasOne("fxl.codes.kisekae.Entities.Kisekae", "Kisekae")
.WithMany("Cels")
.HasForeignKey("KisekaeId");
b.Navigation("Kisekae");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.CelConfig", b =>
{
b.HasOne("fxl.codes.kisekae.Entities.Cel", "Cel")
.WithMany()
.HasForeignKey("CelId");
b.HasOne("fxl.codes.kisekae.Entities.Configuration", "Configuration")
.WithMany("Cels")
.HasForeignKey("ConfigurationId");
b.HasOne("fxl.codes.kisekae.Entities.Palette", "Palette")
.WithMany()
.HasForeignKey("PaletteId");
b.HasOne("fxl.codes.kisekae.Entities.Render", "Render")
.WithMany()
.HasForeignKey("RenderId");
b.Navigation("Cel");
b.Navigation("Configuration");
b.Navigation("Palette");
b.Navigation("Render");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Configuration", b =>
{
b.HasOne("fxl.codes.kisekae.Entities.Kisekae", "Kisekae")
.WithMany("Configurations")
.HasForeignKey("KisekaeId");
b.Navigation("Kisekae");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Palette", b =>
{
b.HasOne("fxl.codes.kisekae.Entities.Kisekae", "Kisekae")
.WithMany("Palettes")
.HasForeignKey("KisekaeId");
b.Navigation("Kisekae");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.PaletteColor", b =>
{
b.HasOne("fxl.codes.kisekae.Entities.Palette", "Palette")
.WithMany("Colors")
.HasForeignKey("PaletteId");
b.Navigation("Palette");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Configuration", b =>
{
b.Navigation("Actions");
b.Navigation("Cels");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Kisekae", b =>
{
b.Navigation("Cels");
b.Navigation("Configurations");
b.Navigation("Palettes");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Palette", b =>
{
b.Navigation("Colors");
});
#pragma warning restore 612, 618
}
}
}
@@ -1,36 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace fxl.codes.kisekae.Migrations
{
public partial class UseBackgroundHex : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "BorderIndex",
table: "Configurations");
migrationBuilder.AddColumn<string>(
name: "BackgroundColorHex",
table: "Configurations",
type: "text",
nullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "BackgroundColorHex",
table: "Configurations");
migrationBuilder.AddColumn<int>(
name: "BorderIndex",
table: "Configurations",
type: "integer",
nullable: false,
defaultValue: 0);
}
}
}
-386
View File
@@ -1,386 +0,0 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using fxl.codes.kisekae;
#nullable disable
namespace fxl.codes.kisekae.Migrations
{
[DbContext(typeof(KisekaeContext))]
[Migration("20211121011039_Positions")]
partial class Positions
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "6.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("fxl.codes.kisekae.Entities.Action", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int?>("ConfigurationId")
.HasColumnType("integer");
b.Property<string>("Name")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ConfigurationId");
b.ToTable("Action");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Cel", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<byte[]>("Data")
.HasColumnType("bytea");
b.Property<string>("FileName")
.HasColumnType("text");
b.Property<int>("Height")
.HasColumnType("integer");
b.Property<int?>("KisekaeId")
.HasColumnType("integer");
b.Property<int>("OffsetX")
.HasColumnType("integer");
b.Property<int>("OffsetY")
.HasColumnType("integer");
b.Property<int>("Width")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("KisekaeId");
b.ToTable("Cels");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.CelConfig", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int?>("CelId")
.HasColumnType("integer");
b.Property<string>("Comment")
.HasColumnType("text");
b.Property<int?>("ConfigurationId")
.HasColumnType("integer");
b.Property<int>("Fix")
.HasColumnType("integer");
b.Property<int>("Mark")
.HasColumnType("integer");
b.Property<int>("PaletteGroup")
.HasColumnType("integer");
b.Property<int?>("PaletteId")
.HasColumnType("integer");
b.Property<int?>("RenderId")
.HasColumnType("integer");
b.Property<int>("Sets")
.HasColumnType("integer");
b.Property<int>("Transparency")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("CelId");
b.HasIndex("ConfigurationId");
b.HasIndex("PaletteId");
b.HasIndex("RenderId");
b.ToTable("CelConfigs");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.CelPosition", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int?>("CelConfigId")
.HasColumnType("integer");
b.Property<int>("Set")
.HasColumnType("integer");
b.Property<int>("X")
.HasColumnType("integer");
b.Property<int>("Y")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("CelConfigId");
b.ToTable("CelPosition");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Configuration", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("BackgroundColorHex")
.HasColumnType("text");
b.Property<string>("Data")
.HasColumnType("text");
b.Property<int>("Height")
.HasColumnType("integer");
b.Property<int?>("KisekaeId")
.HasColumnType("integer");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<int>("Width")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("KisekaeId");
b.ToTable("Configurations");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Kisekae", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("CheckSum")
.HasColumnType("text");
b.Property<string>("FileName")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("KisekaeSets");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Palette", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Comment")
.HasColumnType("text");
b.Property<byte[]>("Data")
.HasColumnType("bytea");
b.Property<string>("FileName")
.HasColumnType("text");
b.Property<int?>("KisekaeId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("KisekaeId");
b.ToTable("Palettes");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.PaletteColor", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("Group")
.HasColumnType("integer");
b.Property<string>("Hex")
.HasColumnType("text");
b.Property<int?>("PaletteId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("PaletteId");
b.ToTable("PaletteColors");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Render", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<byte[]>("Image")
.HasColumnType("bytea");
b.HasKey("Id");
b.ToTable("Renders");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Action", b =>
{
b.HasOne("fxl.codes.kisekae.Entities.Configuration", null)
.WithMany("Actions")
.HasForeignKey("ConfigurationId");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Cel", b =>
{
b.HasOne("fxl.codes.kisekae.Entities.Kisekae", "Kisekae")
.WithMany("Cels")
.HasForeignKey("KisekaeId");
b.Navigation("Kisekae");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.CelConfig", b =>
{
b.HasOne("fxl.codes.kisekae.Entities.Cel", "Cel")
.WithMany()
.HasForeignKey("CelId");
b.HasOne("fxl.codes.kisekae.Entities.Configuration", "Configuration")
.WithMany("Cels")
.HasForeignKey("ConfigurationId");
b.HasOne("fxl.codes.kisekae.Entities.Palette", "Palette")
.WithMany()
.HasForeignKey("PaletteId");
b.HasOne("fxl.codes.kisekae.Entities.Render", "Render")
.WithMany()
.HasForeignKey("RenderId");
b.Navigation("Cel");
b.Navigation("Configuration");
b.Navigation("Palette");
b.Navigation("Render");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.CelPosition", b =>
{
b.HasOne("fxl.codes.kisekae.Entities.CelConfig", null)
.WithMany("Positions")
.HasForeignKey("CelConfigId");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Configuration", b =>
{
b.HasOne("fxl.codes.kisekae.Entities.Kisekae", "Kisekae")
.WithMany("Configurations")
.HasForeignKey("KisekaeId");
b.Navigation("Kisekae");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Palette", b =>
{
b.HasOne("fxl.codes.kisekae.Entities.Kisekae", "Kisekae")
.WithMany("Palettes")
.HasForeignKey("KisekaeId");
b.Navigation("Kisekae");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.PaletteColor", b =>
{
b.HasOne("fxl.codes.kisekae.Entities.Palette", "Palette")
.WithMany("Colors")
.HasForeignKey("PaletteId");
b.Navigation("Palette");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.CelConfig", b =>
{
b.Navigation("Positions");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Configuration", b =>
{
b.Navigation("Actions");
b.Navigation("Cels");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Kisekae", b =>
{
b.Navigation("Cels");
b.Navigation("Configurations");
b.Navigation("Palettes");
});
modelBuilder.Entity("fxl.codes.kisekae.Entities.Palette", b =>
{
b.Navigation("Colors");
});
#pragma warning restore 612, 618
}
}
}
-67
View File
@@ -1,67 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace fxl.codes.kisekae.Migrations
{
public partial class Positions : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "X",
table: "CelConfigs");
migrationBuilder.DropColumn(
name: "Y",
table: "CelConfigs");
migrationBuilder.CreateTable(
name: "CelPosition",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Set = table.Column<int>(type: "integer", nullable: false),
X = table.Column<int>(type: "integer", nullable: false),
Y = table.Column<int>(type: "integer", nullable: false),
CelConfigId = table.Column<int>(type: "integer", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_CelPosition", x => x.Id);
table.ForeignKey(
name: "FK_CelPosition_CelConfigs_CelConfigId",
column: x => x.CelConfigId,
principalTable: "CelConfigs",
principalColumn: "Id");
});
migrationBuilder.CreateIndex(
name: "IX_CelPosition_CelConfigId",
table: "CelPosition",
column: "CelConfigId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "CelPosition");
migrationBuilder.AddColumn<int>(
name: "X",
table: "CelConfigs",
type: "integer",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "Y",
table: "CelConfigs",
type: "integer",
nullable: false,
defaultValue: 0);
}
}
}
-36
View File
@@ -1,36 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace fxl.codes.kisekae.Migrations
{
public partial class SimplifySets : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Comment",
table: "Palettes");
migrationBuilder.DropColumn(
name: "Sets",
table: "CelConfigs");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Comment",
table: "Palettes",
type: "text",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "Sets",
table: "CelConfigs",
type: "integer",
nullable: false,
defaultValue: 0);
}
}
}
@@ -12,14 +12,15 @@ using fxl.codes.kisekae;
namespace fxl.codes.kisekae.Migrations namespace fxl.codes.kisekae.Migrations
{ {
[DbContext(typeof(KisekaeContext))] [DbContext(typeof(KisekaeContext))]
[Migration("20211122002625_SimplifySets")] [Migration("20240212041548_init")]
partial class SimplifySets partial class init
{ {
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasAnnotation("ProductVersion", "6.0.0") .HasAnnotation("ProductVersion", "8.0.1")
.HasAnnotation("Relational:MaxIdentifierLength", 63); .HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
@@ -1,13 +1,14 @@
using System; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable #nullable disable
namespace fxl.codes.kisekae.Migrations namespace fxl.codes.kisekae.Migrations
{ {
public partial class Startup : Migration /// <inheritdoc />
public partial class init : Migration
{ {
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
@@ -24,6 +25,19 @@ namespace fxl.codes.kisekae.Migrations
table.PrimaryKey("PK_KisekaeSets", x => x.Id); table.PrimaryKey("PK_KisekaeSets", x => x.Id);
}); });
migrationBuilder.CreateTable(
name: "Renders",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Image = table.Column<byte[]>(type: "bytea", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Renders", x => x.Id);
});
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "Cels", name: "Cels",
columns: table => new columns: table => new
@@ -59,7 +73,7 @@ namespace fxl.codes.kisekae.Migrations
Data = table.Column<string>(type: "text", nullable: true), Data = table.Column<string>(type: "text", nullable: true),
Height = table.Column<int>(type: "integer", nullable: false), Height = table.Column<int>(type: "integer", nullable: false),
Width = table.Column<int>(type: "integer", nullable: false), Width = table.Column<int>(type: "integer", nullable: false),
BorderIndex = table.Column<int>(type: "integer", nullable: false) BackgroundColorHex = table.Column<string>(type: "text", nullable: true)
}, },
constraints: table => constraints: table =>
{ {
@@ -79,7 +93,6 @@ namespace fxl.codes.kisekae.Migrations
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
KisekaeId = table.Column<int>(type: "integer", nullable: true), KisekaeId = table.Column<int>(type: "integer", nullable: true),
FileName = table.Column<string>(type: "text", nullable: true), FileName = table.Column<string>(type: "text", nullable: true),
Comment = table.Column<string>(type: "text", nullable: true),
Data = table.Column<byte[]>(type: "bytea", nullable: true) Data = table.Column<byte[]>(type: "bytea", nullable: true)
}, },
constraints: table => constraints: table =>
@@ -124,10 +137,8 @@ namespace fxl.codes.kisekae.Migrations
PaletteId = table.Column<int>(type: "integer", nullable: true), PaletteId = table.Column<int>(type: "integer", nullable: true),
PaletteGroup = table.Column<int>(type: "integer", nullable: false), PaletteGroup = table.Column<int>(type: "integer", nullable: false),
Comment = table.Column<string>(type: "text", nullable: true), Comment = table.Column<string>(type: "text", nullable: true),
X = table.Column<int>(type: "integer", nullable: false),
Y = table.Column<int>(type: "integer", nullable: false),
Transparency = table.Column<int>(type: "integer", nullable: false), Transparency = table.Column<int>(type: "integer", nullable: false),
Sets = table.Column<int>(type: "integer", nullable: false) RenderId = table.Column<int>(type: "integer", nullable: true)
}, },
constraints: table => constraints: table =>
{ {
@@ -147,6 +158,11 @@ namespace fxl.codes.kisekae.Migrations
column: x => x.PaletteId, column: x => x.PaletteId,
principalTable: "Palettes", principalTable: "Palettes",
principalColumn: "Id"); principalColumn: "Id");
table.ForeignKey(
name: "FK_CelConfigs_Renders_RenderId",
column: x => x.RenderId,
principalTable: "Renders",
principalColumn: "Id");
}); });
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
@@ -170,27 +186,23 @@ namespace fxl.codes.kisekae.Migrations
}); });
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "Renders", name: "CelPosition",
columns: table => new columns: table => new
{ {
Id = table.Column<int>(type: "integer", nullable: false) Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
CelId = table.Column<int>(type: "integer", nullable: true), Set = table.Column<int>(type: "integer", nullable: false),
PaletteId = table.Column<int>(type: "integer", nullable: true), X = table.Column<int>(type: "integer", nullable: false),
Image = table.Column<byte[]>(type: "bytea", nullable: true) Y = table.Column<int>(type: "integer", nullable: false),
CelConfigId = table.Column<int>(type: "integer", nullable: true)
}, },
constraints: table => constraints: table =>
{ {
table.PrimaryKey("PK_Renders", x => x.Id); table.PrimaryKey("PK_CelPosition", x => x.Id);
table.ForeignKey( table.ForeignKey(
name: "FK_Renders_Cels_CelId", name: "FK_CelPosition_CelConfigs_CelConfigId",
column: x => x.CelId, column: x => x.CelConfigId,
principalTable: "Cels", principalTable: "CelConfigs",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Renders_Palettes_PaletteId",
column: x => x.PaletteId,
principalTable: "Palettes",
principalColumn: "Id"); principalColumn: "Id");
}); });
@@ -214,6 +226,16 @@ namespace fxl.codes.kisekae.Migrations
table: "CelConfigs", table: "CelConfigs",
column: "PaletteId"); column: "PaletteId");
migrationBuilder.CreateIndex(
name: "IX_CelConfigs_RenderId",
table: "CelConfigs",
column: "RenderId");
migrationBuilder.CreateIndex(
name: "IX_CelPosition_CelConfigId",
table: "CelPosition",
column: "CelConfigId");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_Cels_KisekaeId", name: "IX_Cels_KisekaeId",
table: "Cels", table: "Cels",
@@ -233,41 +255,35 @@ namespace fxl.codes.kisekae.Migrations
name: "IX_Palettes_KisekaeId", name: "IX_Palettes_KisekaeId",
table: "Palettes", table: "Palettes",
column: "KisekaeId"); column: "KisekaeId");
migrationBuilder.CreateIndex(
name: "IX_Renders_CelId",
table: "Renders",
column: "CelId");
migrationBuilder.CreateIndex(
name: "IX_Renders_PaletteId",
table: "Renders",
column: "PaletteId");
} }
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder) protected override void Down(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Action"); name: "Action");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "CelConfigs"); name: "CelPosition");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "PaletteColors"); name: "PaletteColors");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Renders"); name: "CelConfigs");
migrationBuilder.DropTable(
name: "Configurations");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Cels"); name: "Cels");
migrationBuilder.DropTable(
name: "Configurations");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Palettes"); name: "Palettes");
migrationBuilder.DropTable(
name: "Renders");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "KisekaeSets"); name: "KisekaeSets");
} }
+1 -1
View File
@@ -17,7 +17,7 @@ namespace fxl.codes.kisekae.Migrations
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasAnnotation("ProductVersion", "6.0.0") .HasAnnotation("ProductVersion", "8.0.1")
.HasAnnotation("Relational:MaxIdentifierLength", 63); .HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
+6 -7
View File
@@ -20,11 +20,6 @@ export class PlaySpace {
}); });
this.canvas.setZoom(this.canvas.width / model.width); this.canvas.setZoom(this.canvas.width / model.width);
this.canvas.on("mouse:down", event => {
if (!event.target) return;
console.log(event.target);
});
} }
async selectSet(set?: number) { async selectSet(set?: number) {
@@ -68,9 +63,13 @@ export class PlaySpace {
for (let key in groups) { for (let key in groups) {
const group = groups[key]; const group = groups[key];
const length = group.length; const length = group.length;
if (length < 2) continue;
const top = group.pop(); const top = group.pop();
if (length < 2) {
top.set({hoverCursor: "move"});
continue;
}
if (!top.selectable) continue; if (!top.selectable) continue;
top.set({hoverCursor: "move"}); top.set({hoverCursor: "move"});
+134 -134
View File
@@ -6,156 +6,156 @@ using System.Text.RegularExpressions;
using fxl.codes.kisekae.Entities; using fxl.codes.kisekae.Entities;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace fxl.codes.kisekae.Services namespace fxl.codes.kisekae.Services;
public class ConfigurationReaderService
{ {
public class ConfigurationReaderService private const string CelRegex = @"#(?<Mark>\d*)\.?(?<Fix>\d*)\s*(?<FileName>[\w\d\-]*\.[cCeElL]*)\s*\*?"
+ @"(?<PaletteIndex>\d*)?\s*\:?(?<Sets>[\d\s]*)?;?(?<Comment>[\w\d\-\s\%]*)";
private const string ResolutionRegexPattern = @"\((?<Width>[0-9]*).(?<Height>[0-9]*)\)";
private readonly ILogger<ConfigurationReaderService> _logger;
public ConfigurationReaderService(ILogger<ConfigurationReaderService> logger)
{ {
private const string CelRegex = @"#(?<Mark>\d*)\.?(?<Fix>\d*)\s*(?<FileName>[\w\d\-]*\.[cCeElL]*)\s*\*?" _logger = logger;
+ @"(?<PaletteIndex>\d*)?\s*\:?(?<Sets>[\d\s]*)?;?(?<Comment>[\w\d\-\s\%]*)"; }
private const string ResolutionRegexPattern = @"\((?<Width>[0-9]*).(?<Height>[0-9]*)\)"; public void ReadConfiguration(Configuration dto,
IDictionary<Configuration, int> backgroundColors,
IDictionary<string, Cel> cels,
Dictionary<string, Palette> palettes)
{
_logger.LogInformation($"Reading {dto.Name}");
var initialPositions = new StringBuilder();
var backgroundColorIndex = 0;
var paletteOrder = new List<Palette>();
var celLines = new List<string>();
private readonly ILogger<ConfigurationReaderService> _logger; foreach (var line in dto.Data.Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries))
switch (line.ToCharArray()[0])
public ConfigurationReaderService(ILogger<ConfigurationReaderService> logger)
{
_logger = logger;
}
public void ReadConfiguration(Configuration dto,
IDictionary<Configuration, int> backgroundColors,
IDictionary<string, Cel> cels,
Dictionary<string, Palette> palettes)
{
_logger.LogInformation($"Reading {dto.Name}");
var initialPositions = new StringBuilder();
var backgroundColorIndex = 0;
var paletteOrder = new List<Palette>();
var celLines = new List<string>();
foreach (var line in dto.Data.Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries))
switch (line.ToCharArray()[0])
{
case '(':
var resolutionRegex = new Regex(ResolutionRegexPattern);
var resolutionMatch = resolutionRegex.Match(line);
dto.Width = int.Parse(resolutionMatch.Groups["Width"].Value);
dto.Height = int.Parse(resolutionMatch.Groups["Height"].Value);
break;
case '[':
var borderValue = line[1..];
if (borderValue.Contains(';')) borderValue = borderValue.Split(';')[0].Trim();
backgroundColorIndex = int.Parse(borderValue);
break;
case '%':
SetPaletteOrder(line, palettes, paletteOrder);
break;
case '#':
celLines.Add(line);
break;
case '$':
case ' ':
initialPositions.Append(line);
break;
}
foreach (var line in celLines) dto.Cels.Add(SetCelConfig(line, dto, cels, paletteOrder));
SetInitialPositions(dto, initialPositions.ToString());
backgroundColors.Add(dto, backgroundColorIndex);
}
private static CelConfig SetCelConfig(string line, Configuration configuration, IDictionary<string, Cel> cels, IReadOnlyList<Palette> palettes)
{
var cel = new CelConfig
{ {
Configuration = configuration case '(':
}; var resolutionRegex = new Regex(ResolutionRegexPattern);
var resolutionMatch = resolutionRegex.Match(line);
if (line.Contains("%t")) dto.Width = int.Parse(resolutionMatch.Groups["Width"].Value);
{ dto.Height = int.Parse(resolutionMatch.Groups["Height"].Value);
var opacity = line[line.IndexOf("%t", StringComparison.InvariantCultureIgnoreCase)..].Trim(); break;
opacity = opacity.Split(';', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries)[0]; case '[':
opacity = opacity.Split(' ', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries)[0]; var borderValue = line[1..];
opacity = opacity.Replace("%t", ""); if (borderValue.Contains(';')) borderValue = borderValue.Split(';')[0].Trim();
cel.Transparency = int.Parse(opacity); backgroundColorIndex = int.Parse(borderValue);
break;
case '%':
SetPaletteOrder(line, palettes, paletteOrder);
break;
case '#':
celLines.Add(line);
break;
case '$':
case ' ':
initialPositions.Append(line);
break;
} }
var matcher = new Regex(CelRegex); foreach (var line in celLines) dto.Cels.Add(SetCelConfig(line, dto, cels, paletteOrder));
var match = matcher.Match(line); SetInitialPositions(dto, initialPositions.ToString());
backgroundColors.Add(dto, backgroundColorIndex);
}
foreach (var groupName in matcher.GetGroupNames()) private static CelConfig SetCelConfig(string line, Configuration configuration, IDictionary<string, Cel> cels, IReadOnlyList<Palette> palettes)
{
var cel = new CelConfig
{
Configuration = configuration
};
if (line.Contains("%t"))
{
var opacity = line[line.IndexOf("%t", StringComparison.InvariantCultureIgnoreCase)..].Trim();
opacity = opacity.Split(';', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries)[0];
opacity = opacity.Split(' ', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries)[0];
opacity = opacity.Replace("%t", "");
cel.Transparency = int.Parse(opacity);
}
var matcher = new Regex(CelRegex);
var match = matcher.Match(line);
foreach (var groupName in matcher.GetGroupNames())
{
match.Groups.TryGetValue(groupName, out var group);
if (string.IsNullOrEmpty(group?.Value)) continue;
if (string.Equals(groupName, "FileName"))
{ {
match.Groups.TryGetValue(groupName, out var group); cel.Cel = cels[group.Value.ToLowerInvariant()];
if (string.IsNullOrEmpty(group?.Value)) continue; continue;
if (string.Equals(groupName, "FileName"))
{
cel.Cel = cels[group.Value.ToLowerInvariant()];
continue;
}
if (string.Equals(groupName, "PaletteIndex"))
{
cel.Palette = palettes[int.Parse(group.Value)];
continue;
}
var property = typeof(CelConfig).GetProperty(groupName);
if (property == null) continue;
var value = group.Value.Trim();
if (property.PropertyType == typeof(string)) property.SetValue(cel, value);
if (property.PropertyType == typeof(int)) property.SetValue(cel, int.Parse(value));
if (property.PropertyType != cel.Sets.GetType()) continue;
foreach (var id in value.Split(' ', StringSplitOptions.RemoveEmptyEntries))
{
var success = int.TryParse(id, out var result);
if (!success) continue;
cel.Sets[result] = true;
}
} }
cel.Palette ??= palettes[0]; if (string.Equals(groupName, "PaletteIndex"))
if (!cel.Sets.Max()) Array.Fill(cel.Sets, true);
return cel;
}
private static void SetPaletteOrder(string line, IReadOnlyDictionary<string, Palette> palettes, ICollection<Palette> paletteOrder)
{
var parts = line.Split(';');
var palette = palettes[parts[0].Trim().ToLowerInvariant().Replace("%", "")];
paletteOrder.Add(palette);
}
private static void SetInitialPositions(Configuration dto, string positions)
{
var sets = positions.Split('$', StringSplitOptions.RemoveEmptyEntries);
for (var index = 0; index < sets.Length; index++)
{ {
var set = sets[index]; cel.Palette = palettes[int.Parse(group.Value)];
var value = set.Split(' ', StringSplitOptions.RemoveEmptyEntries); continue;
var paletteGroup = int.Parse(value[0]); }
for (var innerIndex = 1; innerIndex < value.Length; innerIndex++) var property = typeof(CelConfig).GetProperty(groupName);
if (property == null) continue;
var value = group.Value.Trim();
if (property.PropertyType == typeof(string)) property.SetValue(cel, value);
if (property.PropertyType == typeof(int)) property.SetValue(cel, int.Parse(value));
if (property.PropertyType != cel.Sets.GetType()) continue;
foreach (var id in value.Split(' ', StringSplitOptions.RemoveEmptyEntries))
{
var success = int.TryParse(id, out var result);
if (!success) continue;
cel.Sets[result] = true;
}
}
cel.Palette ??= palettes[0];
if (!cel.Sets.Max()) Array.Fill(cel.Sets, true);
return cel;
}
private static void SetPaletteOrder(string line, IReadOnlyDictionary<string, Palette> palettes, ICollection<Palette> paletteOrder)
{
var parts = line.Split(';');
var palette = palettes[parts[0].Trim().ToLowerInvariant().Replace("%", "")];
paletteOrder.Add(palette);
}
private static void SetInitialPositions(Configuration dto, string positions)
{
positions = Regex.Replace(positions, "[\\s]+", "|");
var sets = positions.Split('$', StringSplitOptions.RemoveEmptyEntries);
for (var index = 0; index < sets.Length; index++)
{
var set = sets[index];
var value = set.Split('|', StringSplitOptions.RemoveEmptyEntries);
var paletteGroup = int.Parse(value[0]);
for (var innerIndex = 1; innerIndex < value.Length; innerIndex++)
{
if (value[innerIndex].Contains('*')) continue;
var point = value[innerIndex].Trim().Split(',', StringSplitOptions.RemoveEmptyEntries);
foreach (var cel in dto.Cels.Where(x => x.Mark == innerIndex - 1))
{ {
if (value[innerIndex].Contains('*')) continue; cel.PaletteGroup = paletteGroup;
var point = value[innerIndex].Trim().Split(',', StringSplitOptions.RemoveEmptyEntries);
foreach (var cel in dto.Cels.Where(x => x.Mark == innerIndex - 1)) if (!cel.Sets[index]) continue;
cel.Positions.Add(new CelPosition
{ {
cel.PaletteGroup = paletteGroup; Set = index,
X = int.Parse(point[0]),
if (!cel.Sets[index]) continue; Y = int.Parse(point[1])
cel.Positions.Add(new CelPosition });
{
Set = index,
X = int.Parse(point[0]),
Y = int.Parse(point[1])
});
}
} }
} }
} }
+148 -152
View File
@@ -11,26 +11,26 @@ using Microsoft.Extensions.Logging;
using SixLabors.ImageSharp; using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
namespace fxl.codes.kisekae.Services namespace fxl.codes.kisekae.Services;
public class FileParserService
{ {
public class FileParserService private static readonly byte[] KissHeader = "KiSS"u8.ToArray();
private static readonly Color Transparent = Color.Black.WithAlpha(0);
private readonly ILogger<FileParserService> _logger;
private readonly IsolatedStorageFile _storage;
public FileParserService(ILogger<FileParserService> logger)
{ {
private static readonly byte[] KissHeader = "KiSS"u8.ToArray(); _logger = logger;
private static readonly Color Transparent = Color.Black.WithAlpha(0); _storage = IsolatedStorageFile.GetUserStoreForApplication();
}
private readonly ILogger<FileParserService> _logger; public void UnzipLzh(IFormFile file, MemoryStream memoryStream = null)
private readonly IsolatedStorageFile _storage; {
if (!_storage.FileExists(file.FileName))
public FileParserService(ILogger<FileParserService> logger)
{ {
_logger = logger;
_storage = IsolatedStorageFile.GetUserStoreForApplication();
}
public void UnzipLzh(IFormFile file, MemoryStream memoryStream = null)
{
if (_storage.FileExists(file.FileName)) _storage.DeleteFile(file.FileName);
using var writer = _storage.CreateFile(file.FileName); using var writer = _storage.CreateFile(file.FileName);
if (memoryStream != null) if (memoryStream != null)
@@ -40,166 +40,162 @@ namespace fxl.codes.kisekae.Services
writer.Flush(); writer.Flush();
writer.Close(); writer.Close();
var root = _storage.GetType()
.GetProperty("RootDirectory", BindingFlags.Instance | BindingFlags.NonPublic)?
.GetValue(_storage)?
.ToString() ?? "";
var directory = Path.GetFileNameWithoutExtension(file.FileName);
if (_storage.DirectoryExists(directory))
{
var allFiles = _storage.GetFileNames(Path.Combine(directory, "*"));
foreach (var existingFile in allFiles) _storage.DeleteFile(Path.Combine(directory, existingFile));
_storage.DeleteDirectory(directory);
}
_storage.CreateDirectory(directory);
var process = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "7z",
Arguments = $"x {Path.Combine(root, file.FileName)} -o{Path.Combine(root, directory)}",
UseShellExecute = false,
RedirectStandardError = true,
RedirectStandardOutput = true
}
};
if (!process.Start()) throw new InvalidDataException("Unable to call p7zip to extract archive");
while (!process.StandardOutput.EndOfStream) _logger.LogTrace(process.StandardOutput.ReadLine());
process.WaitForExit();
_storage.DeleteFile(file.FileName);
} }
public Color[] ParsePalette(Palette palette, out int groups, out int colorsPerGroup) var root = _storage.GetType()
.GetProperty("RootDirectory", BindingFlags.Instance | BindingFlags.NonPublic)?
.GetValue(_storage)?
.ToString() ?? "";
var directory = Path.GetFileNameWithoutExtension(file.FileName);
if (_storage.DirectoryExists(directory)) return;
_storage.CreateDirectory(directory);
var process = new Process
{ {
groups = 0; StartInfo = new ProcessStartInfo
colorsPerGroup = 0; {
FileName = "7z",
Arguments = $"x {Path.Combine(root, file.FileName)} -o{Path.Combine(root, directory)}",
UseShellExecute = false,
RedirectStandardError = true,
RedirectStandardOutput = true
}
};
if (palette.Data.Length == 0) return null; if (!process.Start()) throw new InvalidDataException("Unable to call p7zip to extract archive");
if (!palette.Data[..KissHeader.Length].SequenceEqual(KissHeader)) return GetColors(palette.Data);
// Verify palette mark? while (!process.StandardOutput.EndOfStream) _logger.LogTrace(process.StandardOutput.ReadLine());
if (palette.Data[4] != 16) _logger.LogError($"{palette.FileName} is not a valid palette file"); process.WaitForExit();
}
var colorDepth = Convert.ToInt32(palette.Data[5]); public Color[] ParsePalette(Palette palette, out int groups, out int colorsPerGroup)
colorsPerGroup = BitConverter.ToInt16(palette.Data, 8); {
groups = BitConverter.ToInt16(palette.Data, 10); groups = 0;
colorsPerGroup = 0;
return GetColors(palette.Data[32..], colorDepth, colorsPerGroup, groups); if (palette.Data.Length == 0) return null;
if (!palette.Data[..KissHeader.Length].SequenceEqual(KissHeader)) return GetColors(palette.Data);
// Verify palette mark?
if (palette.Data[4] != 16) _logger.LogError($"{palette.FileName} is not a valid palette file");
var colorDepth = Convert.ToInt32(palette.Data[5]);
colorsPerGroup = BitConverter.ToInt16(palette.Data, 8);
groups = BitConverter.ToInt16(palette.Data, 10);
return GetColors(palette.Data[32..], colorDepth, colorsPerGroup, groups);
}
public void RenderCel(CelConfig celConfig)
{
_logger.LogTrace($"Reading cel {celConfig.Cel.FileName}");
var buffer = celConfig.Cel?.Data?.ToArray();
if (buffer == null || buffer.Length == 0) return;
if (buffer[..KissHeader.Length].SequenceEqual(KissHeader))
{
// Verify cel mark?
if (buffer[4] != 32) _logger.LogError($"{celConfig.Cel.FileName} is not a valid cel file");
var pixelBits = Convert.ToInt32(buffer[5]);
var width = BitConverter.ToInt16(buffer, 8);
var height = BitConverter.ToInt16(buffer, 10);
var xOffset = BitConverter.ToInt16(buffer, 12);
var yOffset = BitConverter.ToInt16(buffer, 14);
celConfig.Cel.OffsetX = xOffset;
celConfig.Cel.OffsetY = yOffset;
celConfig.Cel.Height = height;
celConfig.Cel.Width = width;
celConfig.Render = GetCelImage(buffer[32..], celConfig.Palette, width, height, pixelBits);
}
else
{
var width = BitConverter.ToInt16(buffer, 0);
var height = BitConverter.ToInt16(buffer, 2);
celConfig.Cel.Height = height;
celConfig.Cel.Width = width;
celConfig.Render = GetCelImage(buffer[4..], celConfig.Palette, width, height);
}
}
private Color[] GetColors(IReadOnlyCollection<byte> bytes, int depth = 12, int colorsPerGroup = 16, int groups = 10)
{
_logger.LogTrace("Converting byte array to colors");
var colorValues = GetValues(bytes, depth / 3);
var colors = new Color[colorsPerGroup * groups];
var length = depth == 12 ? 4 : 3;
var multiplier = depth == 12 ? 16 : 1;
// Nibbles order for 12 bits: R, B, 0, G
for (var groupIndex = 0; groupIndex < groups; groupIndex++)
for (var colorIndex = 0; colorIndex < colorsPerGroup; colorIndex++)
{
var start = (groupIndex + colorIndex) * length;
var red = colorValues[start] * multiplier;
var green = colorValues[start + (depth == 12 ? 3 : 1)] * multiplier;
var blue = colorValues[start + (depth == 12 ? 1 : 2)] * multiplier;
colors[groupIndex + colorIndex] = Color.FromRgb(Convert.ToByte(red), Convert.ToByte(green), Convert.ToByte(blue));
} }
public void RenderCel(CelConfig celConfig) return colors;
}
private Render GetCelImage(IReadOnlyCollection<byte> bytes,
Palette palette,
int width,
int height,
int pixelBits = 4)
{
_logger.LogTrace("Converting byte array to base64 encoded gifs per palette");
var values = GetValues(bytes, pixelBits);
using var bitmap = new Image<Rgba32>(width, height);
bitmap.ProcessPixelRows(processor =>
{ {
_logger.LogTrace($"Reading cel {celConfig.Cel.FileName}");
var buffer = celConfig.Cel?.Data?.ToArray();
if (buffer == null || buffer.Length == 0) return;
if (buffer[..KissHeader.Length].SequenceEqual(KissHeader))
{
// Verify cel mark?
if (buffer[4] != 32) _logger.LogError($"{celConfig.Cel.FileName} is not a valid cel file");
var pixelBits = Convert.ToInt32(buffer[5]);
var width = BitConverter.ToInt16(buffer, 8);
var height = BitConverter.ToInt16(buffer, 10);
var xOffset = BitConverter.ToInt16(buffer, 12);
var yOffset = BitConverter.ToInt16(buffer, 14);
celConfig.Cel.OffsetX = xOffset;
celConfig.Cel.OffsetY = yOffset;
celConfig.Cel.Height = height;
celConfig.Cel.Width = width;
celConfig.Render = GetCelImage(buffer[32..], celConfig.Palette, width, height, pixelBits);
}
else
{
var width = BitConverter.ToInt16(buffer, 0);
var height = BitConverter.ToInt16(buffer, 2);
celConfig.Cel.Height = height;
celConfig.Cel.Width = width;
celConfig.Render = GetCelImage(buffer[4..], celConfig.Palette, width, height);
}
}
private Color[] GetColors(IReadOnlyCollection<byte> bytes, int depth = 12, int colorsPerGroup = 16, int groups = 10)
{
_logger.LogTrace("Converting byte array to colors");
var colorValues = GetValues(bytes, depth / 3);
var colors = new Color[colorsPerGroup * groups];
var length = depth == 12 ? 4 : 3;
var multiplier = depth == 12 ? 16 : 1;
// Nibbles order for 12 bits: R, B, 0, G
for (var groupIndex = 0; groupIndex < groups; groupIndex++)
for (var colorIndex = 0; colorIndex < colorsPerGroup; colorIndex++)
{
var start = (groupIndex + colorIndex) * length;
var red = colorValues[start] * multiplier;
var green = colorValues[start + (depth == 12 ? 3 : 1)] * multiplier;
var blue = colorValues[start + (depth == 12 ? 1 : 2)] * multiplier;
colors[groupIndex + colorIndex] = Color.FromRgb(Convert.ToByte(red), Convert.ToByte(green), Convert.ToByte(blue));
}
return colors;
}
private Render GetCelImage(IReadOnlyCollection<byte> bytes,
Palette palette,
int width,
int height,
int pixelBits = 4)
{
_logger.LogTrace("Converting byte array to base64 encoded gifs per palette");
var values = GetValues(bytes, pixelBits);
using var bitmap = new Image<Rgba32>(width, height);
var index = 0; var index = 0;
for (var y = 0; y < processor.Height; y++)
for (var row = 0; row < height; row++)
{ {
for (var column = 0; column < width; column++) var row = processor.GetRowSpan(y);
for (var x = 0; x < row.Length; x++)
{ {
var value = values[index]; var value = values[index];
bitmap[row, column] = value == 0 || value >= palette.Colors.Count ? Transparent : Color.ParseHex(palette.Colors[value].Hex); var isTransparent = value == 0 || value >= palette.Colors.Count;
row[x] = isTransparent ? Transparent : Color.ParseHex(palette.Colors[value].Hex);
index++; index++;
} }
if (width % 2 != 0 && pixelBits == 4) index++; if (width % 2 != 0 && pixelBits == 4) index++;
} }
});
using var memory = new MemoryStream(); using var memory = new MemoryStream();
bitmap.SaveAsGif(memory); bitmap.SaveAsGif(memory);
return new Render return new Render
{
Image = memory.ToArray()
};
}
private static int[] GetValues(IReadOnlyCollection<byte> bytes, int bits = 4)
{ {
if (bits != 4) return bytes.Select(Convert.ToInt32).ToArray(); Image = memory.ToArray()
};
}
var values = new int[bytes.Count * 2]; private static int[] GetValues(IReadOnlyCollection<byte> bytes, int bits = 4)
var index = 0; {
foreach (var slice in bytes) if (bits != 4) return bytes.Select(Convert.ToInt32).ToArray();
{
var nib1 = (slice >> 4) & 0x0F;
var nib2 = slice & 0x0F;
values[index] = nib1;
values[index + 1] = nib2;
index += 2;
}
return values; var values = new int[bytes.Count * 2];
var index = 0;
foreach (var slice in bytes)
{
var nib1 = (slice >> 4) & 0x0F;
var nib2 = slice & 0x0F;
values[index] = nib1;
values[index + 1] = nib2;
index += 2;
} }
return values;
} }
} }
+2 -6
View File
@@ -7,6 +7,7 @@
<form enctype="multipart/form-data" method="post" asp-action="Upload" id="file_upload"> <form enctype="multipart/form-data" method="post" asp-action="Upload" id="file_upload">
<fieldset> <fieldset>
<input type="file" name="file" multiple accept=".lzh"> <input type="file" name="file" multiple accept=".lzh">
<input type="submit" value="Upload">
</fieldset> </fieldset>
</form> </form>
@@ -25,9 +26,4 @@
</ul> </ul>
</li> </li>
} }
</ul> </ul>
@section Scripts
{
}
+1 -1
View File
File diff suppressed because one or more lines are too long