-
Notifications
You must be signed in to change notification settings - Fork 4
/
Program.cs
42 lines (34 loc) · 1.53 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using MudBlazor.Services;
using PKHeX.Web;
using PKHeX.Web.Services;
using PKHeX.Core;
using Blazored.LocalStorage;
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");
var httpClient = new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) };
builder.Services.AddScoped(sp => httpClient);
builder.Services.AddBlazoredLocalStorage();
builder.Services.AddMudServices();
builder.Services.AddSingleton<SavEdit>();
builder.Services.AddSingleton<SpriteService>();
builder.Services.AddSingleton<PkmEdit>();
var host = builder.Build();
// Loading json data for sprites
var spriteService = host.Services.GetRequiredService<SpriteService>();
await spriteService.InitializeServiceAsync(httpClient);
// Loading settings from localStorage and initializing blank SAV/PKM
var savEdit = host.Services.GetRequiredService<SavEdit>();
var pkmEdit = host.Services.GetRequiredService<PkmEdit>();
var localStorageService = host.Services.GetRequiredService<ILocalStorageService>();
var storedGameVersion = await localStorageService.GetItemAsync<GameVersion>("BlankVersion");
if (storedGameVersion == 0)
{
storedGameVersion = GameVersion.BD;
await localStorageService.SetItemAsync("BlankVersion", storedGameVersion);
}
savEdit.SAV = SaveUtil.GetBlankSAV(storedGameVersion, "PKHeX");
pkmEdit.PKM = savEdit.SAV.LoadTemplate();
await host.RunAsync();