Add SCHALE.Toolbox and implement gacha (wip)

This commit is contained in:
mkbka 2024-06-02 23:38:08 +08:00
parent 2024bae0a1
commit c2da3d21d2
23 changed files with 1369 additions and 47 deletions

View File

@ -759,16 +759,16 @@ namespace SCHALE.Common.Database
[Key]
public long ServerId { get; set; }
public long UniqueId { get; set; }
public int StarGrade { get; set; }
public int Level { get; set; }
public long Exp { get; set; }
public int FavorRank { get; set; }
public long FavorExp { get; set; }
public int PublicSkillLevel { get; set; }
public int ExSkillLevel { get; set; }
public int PassiveSkillLevel { get; set; }
public int ExtraPassiveSkillLevel { get; set; }
public int LeaderSkillLevel { get; set; }
public int StarGrade { get; set; } = 1;
public int Level { get; set; } = 1;
public long Exp { get; set; } = 0;
public int FavorRank { get; set; } = 1;
public long FavorExp { get; set; } = 0;
public int PublicSkillLevel { get; set; } = 1;
public int ExSkillLevel { get; set; } = 1;
public int PassiveSkillLevel { get; set; } = 1;
public int ExtraPassiveSkillLevel { get; set; } = 1;
public int LeaderSkillLevel { get; set; } = 1;
[NotMapped]
public bool IsNew { get; set; }

View File

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SCHALE.Common.FlatData;
namespace SCHALE.Common.Extensions
{
public enum StudentType
{
Normal,
Unique,
Event,
}
public static class CharacterExcelTExt
{
public static StudentType GetStudentType(this CharacterExcelT ch)
{
if (!ch.CollectionVisibleEndDate.StartsWith("2099"))
{
return StudentType.Unique;
} else if (ch.CombineRecipeId == 0)
{
return StudentType.Event;
}
return StudentType.Normal;
}
}
}

View File

@ -7,6 +7,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SCHALE.GameServer", "SCHALE
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SCHALE.Common", "SCHALE.Common\SCHALE.Common.csproj", "{D8ED8CB5-EA39-46BE-9236-7FC1F46FE15B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SCHALE.Toolbox", "SCHALE.Toolbox\SCHALE.Toolbox.csproj", "{989DC049-A118-4EDB-8C21-5E56E6ADAAB0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -21,6 +23,10 @@ Global
{D8ED8CB5-EA39-46BE-9236-7FC1F46FE15B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D8ED8CB5-EA39-46BE-9236-7FC1F46FE15B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D8ED8CB5-EA39-46BE-9236-7FC1F46FE15B}.Release|Any CPU.Build.0 = Release|Any CPU
{989DC049-A118-4EDB-8C21-5E56E6ADAAB0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{989DC049-A118-4EDB-8C21-5E56E6ADAAB0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{989DC049-A118-4EDB-8C21-5E56E6ADAAB0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{989DC049-A118-4EDB-8C21-5E56E6ADAAB0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -1,4 +1,5 @@
using SCHALE.Common.Database;
using SCHALE.Common.Database.ModelExtensions;
using SCHALE.Common.NetworkProtocol;
using SCHALE.GameServer.Services;
@ -6,16 +7,18 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
{
public class Shop : ProtocolHandlerBase
{
private readonly ISessionKeyService sessionKeyService;
private readonly SCHALEContext context;
private readonly ISessionKeyService _sessionKeyService;
private readonly SCHALEContext _context;
private readonly SharedDataCacheService _sharedData;
// TODO: temp storage until gacha management
public List<long> SavedGachaResults { get; set; } = [];
public Shop(IProtocolHandlerFactory protocolHandlerFactory, ISessionKeyService _sessionKeyService, SCHALEContext _context) : base(protocolHandlerFactory)
public Shop(IProtocolHandlerFactory protocolHandlerFactory, ISessionKeyService sessionKeyService, SCHALEContext context, SharedDataCacheService sharedData) : base(protocolHandlerFactory)
{
sessionKeyService = _sessionKeyService;
context = _context;
_sessionKeyService = sessionKeyService;
_context = context;
_sharedData = sharedData;
}
[ProtocolHandler(Protocol.Shop_BeforehandGachaGet)]
@ -57,7 +60,7 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
[ProtocolHandler(Protocol.Shop_BeforehandGachaPick)]
public ResponsePacket BeforehandGachaPickHandler(ShopBeforehandGachaPickRequest req)
{
var account = sessionKeyService.GetAccount(req.SessionKey);
var account = _sessionKeyService.GetAccount(req.SessionKey);
var GachaResults = new List<GachaResult>();
foreach (var charId in SavedGachaResults)
@ -92,37 +95,123 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
[ProtocolHandler(Protocol.Shop_BuyGacha3)]
public ResponsePacket ShopBuyGacha3ResponseHandler(ShopBuyGacha3Request req)
{
var gachaResults = new List<GachaResult>();
var account = _sessionKeyService.GetAccount(req.SessionKey);
var accountCharacters = account.Characters.Select(x => x.UniqueId).ToHashSet();
for (int i = 0; i < 10; i++)
{
long id = 10000 + new Random().Next(0, 94);
// TODO: Implement FES Gacha
// TODO: Check Gacha currency
// TODO: even more...
// Type Rate Acc.R
// -------------------------
// Current SSR 0.7% 0.7%
// Other SSR 2.3% 3.0%ServerId
// SR 18.5% 21.5%
// R 78.5% 100.%
gachaResults.Add(new(id)
var rateUpChId = 10094; // 10094, 10095
var rateUpIsNormalStudent = false;
var gachaList = new List<GachaResult>(10);
var newChList = new List<CharacterDB>();
for (int i = 0; i < 10; ++i)
{
Character = new() // hardcoded util proper db
var randomNumber = Random.Shared.NextInt64(1000);
if (randomNumber < 7)
{
ServerId = req.AccountId,
UniqueId = id,
// always 3 star
var isNew = accountCharacters.Add(rateUpChId);
gachaList.Add(new(rateUpChId)
{
Character = new()
{
AccountServerId = account.ServerId,
UniqueId = rateUpChId,
StarGrade = 3,
Level = 1,
FavorRank = 1,
PublicSkillLevel = 1,
ExSkillLevel = 1,
PassiveSkillLevel = 1,
ExtraPassiveSkillLevel = 1,
LeaderSkillLevel = 1,
IsNew = true,
IsLocked = true
IsNew = isNew,
IsLocked = true,
}
});
if (isNew) newChList.Add(gachaList[i].Character);
}
else if (randomNumber < 30)
{
var normalSSRList = _sharedData.CharaListSSRNormal;
var poolSize = normalSSRList.Count;
if (rateUpIsNormalStudent) poolSize--;
var randomPoolIdx = (int)Random.Shared.NextInt64(poolSize);
if (normalSSRList[randomPoolIdx].Id == rateUpChId) randomPoolIdx++;
var chId = normalSSRList[randomPoolIdx].Id;
var isNew = accountCharacters.Add(chId);
gachaList.Add(new(chId)
{
Character = new()
{
AccountServerId = account.ServerId,
UniqueId = chId,
StarGrade = 3,
IsNew = isNew,
IsLocked = true,
}
});
if (isNew) newChList.Add(gachaList[i].Character);
}
else if (randomNumber < 215 ||
(i == 9 && gachaList.All(x => x.Character.StarGrade == 1)))
{
var normalSRList = _sharedData.CharaListSRNormal;
var randomPoolIdx = (int)Random.Shared.NextInt64(normalSRList.Count);
var chId = normalSRList[randomPoolIdx].Id;
var isNew = accountCharacters.Add(chId);
gachaList.Add(new(chId)
{
Character = new()
{
AccountServerId = account.ServerId,
UniqueId = chId,
StarGrade = 2,
IsNew = isNew,
IsLocked = true,
}
});
if (isNew) newChList.Add(gachaList[i].Character);
}
else
{
var normalRList = _sharedData.CharaListRNormal;
var randomPoolIdx = (int)Random.Shared.NextInt64(normalRList.Count);
var chId = normalRList[randomPoolIdx].Id;
var isNew = accountCharacters.Add(chId);
gachaList.Add(new(chId)
{
Character = new()
{
AccountServerId = account.ServerId,
UniqueId = chId,
StarGrade = 1,
IsNew = isNew,
IsLocked = true,
}
});
if (isNew) newChList.Add(gachaList[i].Character);
}
}
foreach (var ch in newChList)
{
ch.AccountServerId = account.ServerId;
}
_context.Characters.AddRange(newChList);
_context.SaveChanges();
return new ShopBuyGacha3Response()
{
GachaResults = gachaResults,
GachaResults = gachaList,
UpdateTime = DateTime.UtcNow,
GemBonusRemain = long.MaxValue,
GemBonusRemain = int.MaxValue,
ConsumedItems = [],
AcquiredItems = [],
MissionProgressDBs = [],

View File

@ -87,6 +87,7 @@ namespace SCHALE.GameServer
builder.Services.AddMemorySessionKeyService();
builder.Services.AddExcelTableService();
builder.Services.AddIrcService();
builder.Services.AddSharedDataCache();
// Add all Handler Groups
var handlerGroups = Assembly

View File

@ -17,11 +17,13 @@ namespace SCHALE.GameServer.Services
private readonly ILogger<ExcelTableService> logger = _logger;
private readonly Dictionary<Type, object> caches = [];
public static async Task LoadExcels()
public static async Task LoadExcels(string excelDirectory = "")
{
var excelZipUrl = $"https://prod-clientpatch.bluearchiveyostar.com/{Config.Instance.VersionId}/TableBundles/Excel.zip";
var excelDir = $"{Path.GetDirectoryName(AppContext.BaseDirectory)}/Resources/excel/";
var excelDir = string.IsNullOrWhiteSpace(excelDirectory)
? Path.Join(Path.GetDirectoryName(AppContext.BaseDirectory), "Resources/excel")
: excelDirectory;
var excelZipPath = Path.Combine(excelDir, "Excel.zip");
if (Directory.Exists(excelDir))
@ -53,14 +55,17 @@ namespace SCHALE.GameServer.Services
/// <typeparam name="T"></typeparam>
/// <returns></returns>
/// <exception cref="FileNotFoundException"></exception>
public T GetTable<T>() where T : IFlatbufferObject
public T GetTable<T>(bool bypassCache = false, string excelDirectory = "") where T : IFlatbufferObject
{
var type = typeof(T);
if (caches.TryGetValue(type, out var cache))
if (!bypassCache && caches.TryGetValue(type, out var cache))
return (T)cache;
var bytesFilePath = Path.Join(Path.GetDirectoryName(AppContext.BaseDirectory), "Resources/excel/", $"{type.Name.ToLower()}.bytes");
var excelDir = string.IsNullOrWhiteSpace(excelDirectory)
? Path.Join(Path.GetDirectoryName(AppContext.BaseDirectory), "Resources/excel")
: excelDirectory;
var bytesFilePath = Path.Join(excelDir, $"{type.Name.ToLower()}.bytes");
if (!File.Exists(bytesFilePath))
{
throw new FileNotFoundException($"bytes files for {type.Name} not found");

View File

@ -0,0 +1,66 @@
using SCHALE.Common.Extensions;
using SCHALE.Common.FlatData;
namespace SCHALE.GameServer.Services
{
public class SharedDataCacheService
{
private readonly ILogger<SharedDataCacheService> _logger;
private readonly ExcelTableService _excelTable;
private readonly List<CharacterExcelT> _charaList;
private readonly List<CharacterExcelT> _charaListR;
private readonly List<CharacterExcelT> _charaListSR;
private readonly List<CharacterExcelT> _charaListSSR;
private readonly List<CharacterExcelT> _charaListRNormal;
private readonly List<CharacterExcelT> _charaListSRNormal;
private readonly List<CharacterExcelT> _charaListSSRNormal;
private readonly List<CharacterExcelT> _charaListUnique;
private readonly List<CharacterExcelT> _charaListEvent;
public IReadOnlyList<CharacterExcelT> CharaList => _charaList;
public IReadOnlyList<CharacterExcelT> CharaListR => _charaListR;
public IReadOnlyList<CharacterExcelT> CharaListSR => _charaListSR;
public IReadOnlyList<CharacterExcelT> CharaListSSR => _charaListSSR;
public IReadOnlyList<CharacterExcelT> CharaListRNormal=> _charaListRNormal;
public IReadOnlyList<CharacterExcelT> CharaListSRNormal=> _charaListSRNormal;
public IReadOnlyList<CharacterExcelT> CharaListSSRNormal=> _charaListSSRNormal;
public IReadOnlyList<CharacterExcelT> CharaListUnique => _charaListUnique;
public IReadOnlyList<CharacterExcelT> CharaListEvent => _charaListEvent;
public SharedDataCacheService(ILogger<SharedDataCacheService> logger, ExcelTableService excelTable)
{
_logger = logger;
_excelTable = excelTable;
_charaList = excelTable
.GetTable<CharacterExcelTable>()
.UnPack()
.DataList!
.Where(x => x is
{
IsPlayable: true,
IsPlayableCharacter: true,
IsDummy: false,
IsNPC: false,
ProductionStep: ProductionStep.Release,
})
.ToList();
_charaListR = _charaList.Where(x => x.Rarity == Rarity.R).ToList();
_charaListSR = _charaList.Where(x => x.Rarity == Rarity.SR).ToList();
_charaListSSR = _charaList.Where(x => x.Rarity == Rarity.SSR).ToList();
_charaListRNormal = _charaListR.Where(x => x.GetStudentType() == StudentType.Normal).ToList();
_charaListSRNormal = _charaListSR.Where(x => x.GetStudentType() == StudentType.Normal).ToList();
_charaListSSRNormal = _charaListSSR.Where(x => x.GetStudentType() == StudentType.Normal).ToList();
_charaListUnique = _charaListR.Where(x => x.GetStudentType() == StudentType.Unique).ToList();
_charaListEvent = _charaListR.Where(x => x.GetStudentType() == StudentType.Event).ToList();
}
}
internal static class DataCacheServiceExtensions
{
public static void AddSharedDataCache(this IServiceCollection services)
{
services.AddSingleton<SharedDataCacheService>();
}
}
}

View File

@ -17,10 +17,15 @@ namespace SCHALE.Common.Utils
var context = connection.Context;
var characterExcel = connection.ExcelTableService.GetTable<CharacterExcelTable>().UnPack().DataList;
var allCharacters = characterExcel.Where(x => x.IsPlayable && x.IsPlayableCharacter && x.CollectionVisible && !account.Characters.Any(c => c.UniqueId == x.Id)).Select(x =>
var allCharacters = characterExcel.Where(x =>
x is
{
return CreateMaxCharacterFromId(x.Id);
}).ToList();
IsPlayable: true,
IsPlayableCharacter: true,
IsNPC: false,
ProductionStep: ProductionStep.Release,
}
).Select(x => CreateMaxCharacterFromId(x.Id)).ToList();
account.AddCharacters(context, [.. allCharacters]);
context.SaveChanges();

15
SCHALE.Toolbox/App.config Normal file
View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="SCHALE.Toolbox.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<SCHALE.Toolbox.Properties.Settings>
<setting name="ExcelDirectory" serializeAs="String">
<value />
</setting>
</SCHALE.Toolbox.Properties.Settings>
</userSettings>
</configuration>

View File

@ -0,0 +1,191 @@
namespace SCHALE.Toolbox.Forms
{
partial class ExcelEditorForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
downloadButton = new Button();
reloadButton = new Button();
propertyGrid1 = new PropertyGrid();
splitContainer1 = new SplitContainer();
splitContainer2 = new SplitContainer();
tableListView = new ListView();
columnHeader1 = new ColumnHeader();
itemListView = new ListView();
button1 = new Button();
columnHeader2 = new ColumnHeader();
((System.ComponentModel.ISupportInitialize)splitContainer1).BeginInit();
splitContainer1.Panel1.SuspendLayout();
splitContainer1.Panel2.SuspendLayout();
splitContainer1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)splitContainer2).BeginInit();
splitContainer2.Panel1.SuspendLayout();
splitContainer2.Panel2.SuspendLayout();
splitContainer2.SuspendLayout();
SuspendLayout();
//
// downloadButton
//
downloadButton.Location = new Point(12, 12);
downloadButton.Name = "downloadButton";
downloadButton.Size = new Size(188, 44);
downloadButton.TabIndex = 0;
downloadButton.Text = "Download Excels";
downloadButton.UseVisualStyleBackColor = true;
downloadButton.Click += downloadButton_Click;
//
// reloadButton
//
reloadButton.Location = new Point(206, 12);
reloadButton.Name = "reloadButton";
reloadButton.Size = new Size(188, 44);
reloadButton.TabIndex = 1;
reloadButton.Text = "Reload Excels";
reloadButton.UseVisualStyleBackColor = true;
reloadButton.Click += reloadButton_Click;
//
// propertyGrid1
//
propertyGrid1.Dock = DockStyle.Fill;
propertyGrid1.Location = new Point(0, 0);
propertyGrid1.Name = "propertyGrid1";
propertyGrid1.Size = new Size(695, 831);
propertyGrid1.TabIndex = 4;
//
// splitContainer1
//
splitContainer1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
splitContainer1.Location = new Point(12, 62);
splitContainer1.Name = "splitContainer1";
//
// splitContainer1.Panel1
//
splitContainer1.Panel1.Controls.Add(splitContainer2);
//
// splitContainer1.Panel2
//
splitContainer1.Panel2.Controls.Add(propertyGrid1);
splitContainer1.Size = new Size(1048, 831);
splitContainer1.SplitterDistance = 349;
splitContainer1.TabIndex = 5;
//
// splitContainer2
//
splitContainer2.Dock = DockStyle.Fill;
splitContainer2.Location = new Point(0, 0);
splitContainer2.Name = "splitContainer2";
splitContainer2.Orientation = Orientation.Horizontal;
//
// splitContainer2.Panel1
//
splitContainer2.Panel1.Controls.Add(tableListView);
//
// splitContainer2.Panel2
//
splitContainer2.Panel2.Controls.Add(itemListView);
splitContainer2.Size = new Size(349, 831);
splitContainer2.SplitterDistance = 373;
splitContainer2.TabIndex = 0;
//
// tableListView
//
tableListView.Columns.AddRange(new ColumnHeader[] { columnHeader1 });
tableListView.Dock = DockStyle.Fill;
tableListView.HeaderStyle = ColumnHeaderStyle.None;
tableListView.Location = new Point(0, 0);
tableListView.MultiSelect = false;
tableListView.Name = "tableListView";
tableListView.Size = new Size(349, 373);
tableListView.TabIndex = 0;
tableListView.UseCompatibleStateImageBehavior = false;
tableListView.View = View.Details;
tableListView.SelectedIndexChanged += tableListView_SelectedIndexChanged;
//
// columnHeader1
//
columnHeader1.Text = "";
columnHeader1.Width = 240;
//
// itemListView
//
itemListView.Columns.AddRange(new ColumnHeader[] { columnHeader2 });
itemListView.Dock = DockStyle.Fill;
itemListView.HeaderStyle = ColumnHeaderStyle.None;
itemListView.Location = new Point(0, 0);
itemListView.MultiSelect = false;
itemListView.Name = "itemListView";
itemListView.Size = new Size(349, 454);
itemListView.TabIndex = 0;
itemListView.UseCompatibleStateImageBehavior = false;
itemListView.View = View.Details;
//
// button1
//
button1.Location = new Point(872, 12);
button1.Name = "button1";
button1.Size = new Size(188, 44);
button1.TabIndex = 6;
button1.Text = "Save";
button1.UseVisualStyleBackColor = true;
//
// ExcelEditorForm
//
AutoScaleDimensions = new SizeF(10F, 25F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1072, 905);
Controls.Add(button1);
Controls.Add(splitContainer1);
Controls.Add(reloadButton);
Controls.Add(downloadButton);
Name = "ExcelEditorForm";
Text = "ExcelEditor";
Load += ExcelEditorForm_Load;
splitContainer1.Panel1.ResumeLayout(false);
splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)splitContainer1).EndInit();
splitContainer1.ResumeLayout(false);
splitContainer2.Panel1.ResumeLayout(false);
splitContainer2.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)splitContainer2).EndInit();
splitContainer2.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private Button downloadButton;
private Button reloadButton;
private PropertyGrid propertyGrid1;
private SplitContainer splitContainer1;
private SplitContainer splitContainer2;
private ListView tableListView;
private ListView itemListView;
private Button button1;
private ColumnHeader columnHeader1;
private ColumnHeader columnHeader2;
}
}

View File

@ -0,0 +1,112 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Google.FlatBuffers;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using SCHALE.GameServer.Services;
using Serilog;
using Serilog.Extensions.Logging;
using SCHALE.Common;
using SCHALE.Common.Crypto;
using SCHALE.Common.FlatData;
using Form = System.Windows.Forms.Form;
namespace SCHALE.Toolbox.Forms
{
public partial class ExcelEditorForm : Form
{
private readonly ExcelTableService _tableService;
private readonly ILogger<ExcelEditorForm> _logger;
private string _excelDirectory;
public ExcelEditorForm()
{
InitializeComponent();
var logFactory = new SerilogLoggerFactory(Log.Logger);
_logger = logFactory.CreateLogger<ExcelEditorForm>();
_tableService = new ExcelTableService(logFactory.CreateLogger<ExcelTableService>());
_excelDirectory = Path.Join(Path.GetDirectoryName(AppContext.BaseDirectory), "Resources/excel");
_logger.LogInformation("Set excel directory to {excelDir}", _excelDirectory);
}
private void ExcelEditorForm_Load(object sender, EventArgs e)
{
}
private async void downloadButton_Click(object sender, EventArgs e)
{
this.Enabled = false;
await ExcelTableService.LoadExcels(_excelDirectory);
_logger.LogInformation("Excel downloaded");
this.Enabled = true;
}
private void reloadButton_Click(object sender, EventArgs e)
{
ReloadExcels();
}
private void tableListView_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void ReloadExcels()
{
var assembly = Assembly.GetAssembly(typeof(AcademyFavorScheduleExcelTable))!;
var types = assembly.GetTypes().Where(
t => t.IsAssignableTo(typeof(IFlatbufferObject)) && t.Name.EndsWith("ExcelTable"));
var validTypes = new List<Type>();
foreach (var t in types)
{
var filePath = Path.Join(_excelDirectory, $"{t.Name.ToLower()}.bytes");
var fbPath = Path.Join(_excelDirectory, $"{t.Name.ToLower()}.fb");
if (!File.Exists(filePath)) continue;
if (File.Exists(fbPath))
{
validTypes.Add(t);
continue;
}
var bytes = File.ReadAllBytes(filePath);
TableEncryptionService.XOR(t.Name, bytes);
// save decrypted
File.WriteAllBytes(fbPath, bytes);
_logger.LogInformation("Decrypted excel table {TableName}", t.Name);
// save json
var inst = t.GetMethod($"GetRootAs{t.Name}", BindingFlags.Static | BindingFlags.Public,
[typeof(ByteBuffer)])!.Invoke(null, [new ByteBuffer(bytes)]);
var obj = t.GetMethod("UnPack", BindingFlags.Instance | BindingFlags.Public)!.Invoke(inst, null);
var jsonPath = Path.Join(_excelDirectory, $"{t.Name.ToLower()}.json");
File.WriteAllText(jsonPath, JsonConvert.SerializeObject(obj, Formatting.Indented, new StringEnumConverter()));
}
tableListView.Items.Clear();
itemListView.Items.Clear();
foreach (var t in validTypes)
{
var item = new ListViewItem(t.Name);
item.Tag = t;
tableListView.Items.Add(item);
}
tableListView.Columns[0].Width = -1;
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,62 @@
namespace SCHALE.Toolbox.Forms
{
partial class MainForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
functionListView = new ListView();
SuspendLayout();
//
// functionListView
//
functionListView.Dock = DockStyle.Fill;
functionListView.Location = new Point(0, 0);
functionListView.Name = "functionListView";
functionListView.Size = new Size(889, 751);
functionListView.TabIndex = 0;
functionListView.UseCompatibleStateImageBehavior = false;
functionListView.View = View.List;
functionListView.DoubleClick += functionListView_DoubleClick;
//
// MainForm
//
AutoScaleDimensions = new SizeF(10F, 25F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(889, 751);
Controls.Add(functionListView);
Name = "MainForm";
Text = "SCHALE Toolbox";
FormClosing += MainForm_FormClosing;
Load += MainForm_Load;
ResumeLayout(false);
}
#endregion
private ListView functionListView;
}
}

View File

@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SCHALE.Toolbox.Forms
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
Application.Exit();
}
private void MainForm_Load(object sender, EventArgs e)
{
AddFormItem<ExcelEditorForm>("Excel Editor");
AddFormItem<PlayableCharacterForm>("Playable Characters");
new ExcelEditorForm().Show();
}
private void AddFormItem<T>(string description)
{
var item = new ListViewItem();
item.Text = description;
item.Tag = typeof(T);
functionListView.Items.Add(item);
}
private void functionListView_DoubleClick(object sender, EventArgs e)
{
var items = functionListView.SelectedItems;
if (items.Count < 1) return;
var item = items[0];
var formType = item.Tag as Type;
if (formType == null) return;
var form = Activator.CreateInstance(formType) as Form;
if (form == null) return;
form.Show();
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,141 @@
namespace SCHALE.Toolbox.Forms
{
partial class PlayableCharacterForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
loadButton = new Button();
splitContainer1 = new SplitContainer();
chListView = new ListView();
columnHeader1 = new ColumnHeader();
chPropertyGrid = new PropertyGrid();
exportButton = new Button();
flowLayoutPanel1 = new FlowLayoutPanel();
((System.ComponentModel.ISupportInitialize)splitContainer1).BeginInit();
splitContainer1.Panel1.SuspendLayout();
splitContainer1.Panel2.SuspendLayout();
splitContainer1.SuspendLayout();
flowLayoutPanel1.SuspendLayout();
SuspendLayout();
//
// loadButton
//
loadButton.Location = new Point(3, 3);
loadButton.Name = "loadButton";
loadButton.Size = new Size(280, 59);
loadButton.TabIndex = 0;
loadButton.Text = "Load from excel CharacterExcelTable";
loadButton.UseVisualStyleBackColor = true;
loadButton.Click += loadButton_Click;
//
// splitContainer1
//
splitContainer1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
splitContainer1.Location = new Point(12, 77);
splitContainer1.Name = "splitContainer1";
//
// splitContainer1.Panel1
//
splitContainer1.Panel1.Controls.Add(chListView);
//
// splitContainer1.Panel2
//
splitContainer1.Panel2.Controls.Add(chPropertyGrid);
splitContainer1.Size = new Size(1086, 901);
splitContainer1.SplitterDistance = 362;
splitContainer1.TabIndex = 1;
//
// chListView
//
chListView.Columns.AddRange(new ColumnHeader[] { columnHeader1 });
chListView.Dock = DockStyle.Fill;
chListView.HeaderStyle = ColumnHeaderStyle.None;
chListView.Location = new Point(0, 0);
chListView.MultiSelect = false;
chListView.Name = "chListView";
chListView.Size = new Size(362, 901);
chListView.TabIndex = 0;
chListView.UseCompatibleStateImageBehavior = false;
chListView.View = View.Details;
chListView.SelectedIndexChanged += chListView_SelectedIndexChanged;
//
// chPropertyGrid
//
chPropertyGrid.Dock = DockStyle.Fill;
chPropertyGrid.Location = new Point(0, 0);
chPropertyGrid.Name = "chPropertyGrid";
chPropertyGrid.Size = new Size(720, 901);
chPropertyGrid.TabIndex = 0;
//
// exportButton
//
exportButton.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
exportButton.Location = new Point(289, 3);
exportButton.Name = "exportButton";
exportButton.Size = new Size(280, 59);
exportButton.TabIndex = 2;
exportButton.Text = "Export";
exportButton.UseVisualStyleBackColor = true;
//
// flowLayoutPanel1
//
flowLayoutPanel1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
flowLayoutPanel1.Controls.Add(loadButton);
flowLayoutPanel1.Controls.Add(exportButton);
flowLayoutPanel1.Location = new Point(12, 5);
flowLayoutPanel1.Name = "flowLayoutPanel1";
flowLayoutPanel1.Size = new Size(1086, 66);
flowLayoutPanel1.TabIndex = 3;
//
// PlayableCharacterForm
//
AutoScaleDimensions = new SizeF(10F, 25F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1110, 990);
Controls.Add(flowLayoutPanel1);
Controls.Add(splitContainer1);
Name = "PlayableCharacterForm";
Text = "PlayableCharacter";
splitContainer1.Panel1.ResumeLayout(false);
splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)splitContainer1).EndInit();
splitContainer1.ResumeLayout(false);
flowLayoutPanel1.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private Button loadButton;
private SplitContainer splitContainer1;
private ListView chListView;
private ColumnHeader columnHeader1;
private PropertyGrid chPropertyGrid;
private Button exportButton;
private FlowLayoutPanel flowLayoutPanel1;
}
}

View File

@ -0,0 +1,112 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using SCHALE.Common.Extensions;
using SCHALE.Common.FlatData;
using SCHALE.GameServer.Services;
using SCHALE.Toolbox.Models.SchaleDB;
using Serilog;
using Serilog.Extensions.Logging;
using Form = System.Windows.Forms.Form;
namespace SCHALE.Toolbox.Forms
{
public partial class PlayableCharacterForm : Form
{
private readonly ExcelTableService _tableService;
private readonly ILogger<PlayableCharacterForm> _logger;
private string _excelDirectory;
private ListViewGroup _viewGroupNormal;
private ListViewGroup _viewGroupUnique;
private ListViewGroup _viewGroupEvent;
public PlayableCharacterForm()
{
InitializeComponent();
var logFactory = new SerilogLoggerFactory(Log.Logger);
_logger = logFactory.CreateLogger<PlayableCharacterForm>();
_tableService = new ExcelTableService(logFactory.CreateLogger<ExcelTableService>());
_viewGroupNormal = new ListViewGroup("Normal");
_viewGroupUnique = new ListViewGroup("Unique");
_viewGroupEvent = new ListViewGroup("Event");
chListView.Groups.Add(_viewGroupNormal);
chListView.Groups.Add(_viewGroupUnique);
chListView.Groups.Add(_viewGroupEvent);
_excelDirectory = Path.Join(Path.GetDirectoryName(AppContext.BaseDirectory), "Resources/excel");
_logger.LogInformation("Set excel directory to {excelDir}", _excelDirectory);
}
private void loadButton_Click(object sender, EventArgs e)
{
chPropertyGrid.SelectedObject = null;
chListView.Items.Clear();
// load schaledb json
List<StudentInfo>? studentList = null;
try
{
studentList = JsonConvert.DeserializeObject<List<StudentInfo>>(File.ReadAllText("Misc/students.json", Encoding.UTF8));
}
catch (Exception ex)
{
_logger.LogWarning("Failed to read SchaleDB student info: {ErrorMessage}", ex.Message);
}
var table = _tableService.GetTable<CharacterExcelTable>();
var chList = table.UnPack().DataList;
chList = chList
.Where(x =>
x is
{
IsPlayable: true,
IsPlayableCharacter: true,
IsDummy: false,
IsNPC: false,
ProductionStep: ProductionStep.Release,
})
.ToList();
var listItems = chList
.Select(x =>
{
var studentName = studentList?.FirstOrDefault(info => info.Id == x.Id)?.Name ?? "(Unknown)";
return new ListViewItem($"{x.Id} {studentName}", x.GetStudentType() switch
{
StudentType.Unique => _viewGroupUnique,
StudentType.Event => _viewGroupEvent,
_ => _viewGroupNormal,
})
{
Tag = x
};
}).ToArray();
chListView.Items.AddRange(listItems);
chListView.Columns[0].Width = -1;
_logger.LogInformation("Loaded {count} items", listItems.Length);
if (studentList?.Count > listItems.Length)
{
_logger.LogWarning("Student list has {Count} items, excel data may be outdated", studentList.Count);
}
}
private void chListView_SelectedIndexChanged(object sender, EventArgs e)
{
var selectedItems = chListView.SelectedItems;
if (selectedItems.Count < 1) return;
var item = selectedItems[0].Tag as CharacterExcelT;
if (item == null) return;
chPropertyGrid.SelectedObject = item;
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,3 @@
#!/usr/bin/env pwsh
$schaleDbUrl = 'https://beta.schaledb.com/data/cn/students.min.json'
Invoke-WebRequest $schaleDbUrl -OutFile students.json

View File

@ -0,0 +1,8 @@
namespace SCHALE.Toolbox.Models.SchaleDB;
public class StudentInfo
{
public int Id { get; set; } = 0;
public string DevName { get; set; } = "";
public string Name { get; set; } = "";
}

24
SCHALE.Toolbox/Program.cs Normal file
View File

@ -0,0 +1,24 @@
using SCHALE.Toolbox.Forms;
using Serilog;
namespace SCHALE.Toolbox
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Log.Logger = new LoggerConfiguration()
.WriteTo.Console()
.CreateLogger();
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new MainForm());
}
}
}

View File

@ -0,0 +1,34 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<PackageOutputPath>$(ProjectDir)</PackageOutputPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Serilog" Version="4.0.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SCHALE.Common\SCHALE.Common.csproj" />
<ProjectReference Include="..\SCHALE.GameServer\SCHALE.GameServer.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Misc\" />
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
<None Update="Misc\students.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>