forked from BrentWJacobs/PKHeX.Web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
55 lines (47 loc) · 1.85 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
43
44
45
46
47
48
49
50
51
52
53
54
55
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 PKHeX.Core.Moves;
using PKHeX.Core.Editing;
using PKHeX.Core.Game;
using PKHeX.Core.Items;
using PKHeX.Core.PKM;
using PKHeX.Core.Util;
using PKHeX.Core.Saves;
using PKHeX.Core.Resources;
using PKHeX.Core.PersonalInfo;
using PKHeX.Drawing;
using PKHeX.Drawing.Misc;
using PKHeX.Drawing.PokeSprite;
using PKHeX.WinForms;
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();