public CompendiumItemsOverviewPage() { InitializeComponent(); Refresh = new Command(async() => { Entries.ReplaceRange(new List <string>()); if (IsBusy) { return; } IsBusy = true; await PCLSourceManager.InitAsync(); ConfigManager config = await Context.LoadConfigAsync(await PCLSourceManager.Data.GetFileAsync("Config.xml").ConfigureAwait(false)).ConfigureAwait(false); DependencyService.Get <IHTMLService>().Reset(config); Entries.Add("Items"); foreach (string s in await PCLImport.EnumerateCategories(Context, Context.Config.Items_Directory)) { Entries.Add(s); } IsBusy = false; }); Title = "Item Categories"; BindingContext = this; }
private async void MenuItem_Clicked(object sender, EventArgs e) { await Navigation.PushAsync(new CustomTextEntryPage("New Item Category", new Command(async(par) => { if (par is string s) { String iname = string.Join("_", s.Split(ConfigManager.InvalidChars)); IFolder b = await PCLSourceManager.Data.CreateFolderAsync(Context.Config.DefaultSource ?? "No Source", CreationCollisionOption.OpenIfExists); if ((sender as MenuItem).BindingContext is string t) { b = await PCLSourceManager.GetFolder(b, t + "/" + iname).ConfigureAwait(false); } else { b = await PCLSourceManager.GetFolder(b, Context.Config.Items_Directory + "/" + iname).ConfigureAwait(false); } Refresh.Execute(null); } }))); }
public CompendiumBackgroundsPage() { InitializeComponent(); Refresh = new Command(async() => { Entries.ReplaceRange(new List <Background>()); if (IsBusy) { return; } IsBusy = true; await PCLSourceManager.InitAsync(); ConfigManager config = await Context.LoadConfigAsync(await PCLSourceManager.Data.GetFileAsync("Config.xml").ConfigureAwait(false)).ConfigureAwait(false); DependencyService.Get <IHTMLService>().Reset(config); await PCLImport.ImportBackgroundsAsync(Context); UpdateEntries(); IsBusy = false; }); Title = "Backgrounds"; BindingContext = this; }
public async Task Load(CancellationToken token = default(CancellationToken)) { double count = 18; double cur = 0; Text = "Sources"; Percentage = cur++ / count; token.ThrowIfCancellationRequested(); await PCLSourceManager.InitAsync().ConfigureAwait(false); foreach (IFile z in PCLSourceManager.Zips) { String s = System.IO.Path.ChangeExtension(z.Name, null); if (!Context.ExcludedSources.Contains(s, StringComparer.OrdinalIgnoreCase)) { count++; } } Text = "Config"; Percentage = cur++ / count; token.ThrowIfCancellationRequested(); ConfigManager config = await Context.LoadConfigAsync(await PCLSourceManager.Data.GetFileAsync("Config.xml").ConfigureAwait(false)).ConfigureAwait(false); DependencyService.Get <IHTMLService>().Reset(config); Text = "Levels"; Percentage = cur++ / count; token.ThrowIfCancellationRequested(); await Context.LoadLevelAsync(await PCLSourceManager.Data.GetFileAsync(config.Levels).ConfigureAwait(false)).ConfigureAwait(false); Text = "AbilityScores"; Percentage = cur++ / count; token.ThrowIfCancellationRequested(); await Context.LoadAbilityScoresAsync(await PCLSourceManager.Data.GetFileAsync(config.AbilityScores).ConfigureAwait(false)).ConfigureAwait(false); Text = "Zip Modules"; Context.CleanUp(); foreach (IFile z in PCLSourceManager.Zips) { Text = z.Name; String s = System.IO.Path.ChangeExtension(z.Name, null); if (Context.ExcludedSources.Contains(s, StringComparer.OrdinalIgnoreCase)) { continue; } Percentage = cur++ / count; token.ThrowIfCancellationRequested(); await Context.ImportZip(z, false).ConfigureAwait(true); } Text = "Skills"; Percentage = cur++ / count; token.ThrowIfCancellationRequested(); await Context.ImportSkillsAsync(false).ConfigureAwait(true); Text = "Languages"; Percentage = cur++ / count; token.ThrowIfCancellationRequested(); await Context.ImportLanguagesAsync(false).ConfigureAwait(true); Text = "Spells"; Percentage = cur++ / count; token.ThrowIfCancellationRequested(); await Context.ImportSpellsAsync(false).ConfigureAwait(true); Text = "Items"; Percentage = cur++ / count; token.ThrowIfCancellationRequested(); await Context.ImportItemsAsync(false).ConfigureAwait(true); Text = "Backgrounds"; Percentage = cur++ / count; token.ThrowIfCancellationRequested(); await Context.ImportBackgroundsAsync(false).ConfigureAwait(true); Text = "Races"; Percentage = cur++ / count; token.ThrowIfCancellationRequested(); await Context.ImportRacesAsync(false).ConfigureAwait(true); Text = "Subraces"; Percentage = cur++ / count; token.ThrowIfCancellationRequested(); await Context.ImportSubRacesAsync(false).ConfigureAwait(true); Text = "Feats and Features"; Percentage = cur++ / count; token.ThrowIfCancellationRequested(); await Context.ImportStandaloneFeaturesAsync(false).ConfigureAwait(true); Text = "Conditions"; Percentage = cur++ / count; token.ThrowIfCancellationRequested(); await Context.ImportConditionsAsync(false).ConfigureAwait(true); Text = "Magic Properties"; Percentage = cur++ / count; token.ThrowIfCancellationRequested(); await Context.ImportMagicAsync(false).ConfigureAwait(true); Text = "Classes"; Percentage = cur++ / count; token.ThrowIfCancellationRequested(); foreach (ClassDefinition c in Context.Classes.Values) { c.ApplyKeywords(Context); } await Context.ImportClassesAsync(false, true).ConfigureAwait(true); Text = "Subclasses"; Percentage = cur++ / count; token.ThrowIfCancellationRequested(); foreach (SubClass c in Context.SubClasses.Values) { c.ApplyKeywords(Context); } await Context.ImportSubClassesAsync(false, true).ConfigureAwait(true); Text = "Monsters"; Percentage = cur++ / count; token.ThrowIfCancellationRequested(); await Context.ImportMonstersAsync(false).ConfigureAwait(true); Text = "UI"; Percentage = 1; }
public async Task Load(CancellationToken token = default(CancellationToken)) { double count = 16; double cur = 0; Text = "Sources"; Percentage = cur++ / count; token.ThrowIfCancellationRequested(); await PCLSourceManager.InitAsync().ConfigureAwait(false); Text = "Config"; Percentage = cur++ / count; token.ThrowIfCancellationRequested(); ConfigManager config = await Context.LoadConfigAsync(await PCLSourceManager.Data.GetFileAsync("Config.xml").ConfigureAwait(false)).ConfigureAwait(false); DependencyService.Get <IHTMLService>().Reset(config); Text = "Levels"; Percentage = cur++ / count; token.ThrowIfCancellationRequested(); await Context.LoadLevelAsync(await PCLSourceManager.Data.GetFileAsync(config.Levels).ConfigureAwait(false)).ConfigureAwait(false); Text = "AbilityScores"; Percentage = cur++ / count; token.ThrowIfCancellationRequested(); await Context.LoadAbilityScoresAsync(await PCLSourceManager.Data.GetFileAsync(config.AbilityScores).ConfigureAwait(false)).ConfigureAwait(false); Text = "Skills"; Percentage = cur++ / count; token.ThrowIfCancellationRequested(); await Context.ImportSkillsAsync().ConfigureAwait(true); Text = "Languages"; Percentage = cur++ / count; token.ThrowIfCancellationRequested(); await Context.ImportLanguagesAsync().ConfigureAwait(true); Text = "Spells"; Percentage = cur++ / count; token.ThrowIfCancellationRequested(); await Context.ImportSpellsAsync().ConfigureAwait(true); Text = "Items"; Percentage = cur++ / count; token.ThrowIfCancellationRequested(); await Context.ImportItemsAsync().ConfigureAwait(true); Text = "Backgrounds"; Percentage = cur++ / count; token.ThrowIfCancellationRequested(); await Context.ImportBackgroundsAsync().ConfigureAwait(true); Text = "Races"; Percentage = cur++ / count; token.ThrowIfCancellationRequested(); await Context.ImportRacesAsync().ConfigureAwait(true); Text = "Subraces"; Percentage = cur++ / count; token.ThrowIfCancellationRequested(); await Context.ImportSubRacesAsync().ConfigureAwait(true); Text = "Feats and Features"; Percentage = cur++ / count; token.ThrowIfCancellationRequested(); await Context.ImportStandaloneFeaturesAsync().ConfigureAwait(true); Text = "Conditions"; Percentage = cur++ / count; token.ThrowIfCancellationRequested(); await Context.ImportConditionsAsync().ConfigureAwait(true); Text = "Magic Properties"; Percentage = cur++ / count; token.ThrowIfCancellationRequested(); await Context.ImportMagicAsync().ConfigureAwait(true); Text = "Classes"; Percentage = cur++ / count; token.ThrowIfCancellationRequested(); await Context.ImportClassesAsync(true).ConfigureAwait(true); Text = "Subclasses"; Percentage = cur++ / count; token.ThrowIfCancellationRequested(); await Context.ImportSubClassesAsync(true).ConfigureAwait(true); Text = "UI"; Percentage = 1; }
private async void ListView_ItemSelected(object sender, SelectedItemChangedEventArgs e) { if (e.SelectedItem is string s) { if (s == "Races") { await Navigation.PushAsync(new CompendiumRacesPage()); } else if (s == "Subraces") { await Navigation.PushAsync(new CompendiumSubRacesPage()); } else if (s == "Classes") { await Navigation.PushAsync(new CompendiumClassesPage()); } else if (s == "Subclasses") { await Navigation.PushAsync(new CompendiumSubClassPage()); } else if (s == "Skills") { await Navigation.PushAsync(new CompendiumSkillsPage()); } else if (s == "Backgrounds") { await Navigation.PushAsync(new CompendiumBackgroundsPage()); } else if (s == "Conditions") { await Navigation.PushAsync(new CompendiumConditionsPage()); } else if (s == "Spells") { await Navigation.PushAsync(new CompendiumSpellsPage()); } else if (s == "Languages") { await Navigation.PushAsync(new CompendiumLanguagesPage()); } else if (s == "Items") { await Navigation.PushAsync(new CompendiumItemsOverviewPage()); } else if (s == "Standalone Features") { await Navigation.PushAsync(new CompendiumFeatsOverviewPage()); } else if (s == "Magic Items") { await Navigation.PushAsync(new CompendiumMagicOverviewPage()); } else if (s == "Monsters") { await Navigation.PushAsync(new CompendiumMonstersPage()); } else if (s == "Level") { OGLContext context = new OGLContext(); await PCLSourceManager.InitAsync(); ConfigManager config = await context.LoadConfigAsync(await PCLSourceManager.Data.GetFileAsync("Config.xml")); DependencyService.Get <IHTMLService>().Reset(config); await context.LoadLevelAsync(await PCLSourceManager.Data.GetFileAsync(config.Levels)); LevelEditModel m = new LevelEditModel(context); TabbedPage t = new TabbedPage(); t.Children.Add(new NavigationPage(new IntListPage(m, "Experience", "Level ", "0", Keyboard.Numeric, true, true)) { Title = "Experience" }); t.Children.Add(new NavigationPage(new IntListPage(m, "Proficiency", "Level ", "+#;-#;0", Keyboard.Telephone, true, true)) { Title = "Proficiency" }); m.TrackChanges = true; await Navigation.PushModalAsync(t); } else if (s == "Ability Scores") { OGLContext context = new OGLContext(); await PCLSourceManager.InitAsync(); ConfigManager config = await context.LoadConfigAsync(await PCLSourceManager.Data.GetFileAsync("Config.xml")); DependencyService.Get <IHTMLService>().Reset(config); await context.LoadAbilityScoresAsync(await PCLSourceManager.Data.GetFileAsync(config.AbilityScores)); ScoresEditModel m = new ScoresEditModel(context); TabbedPage t = new TabbedPage(); t.Children.Add(new NavigationPage(new EditScores(m)) { Title = "Scores" }); t.Children.Add(new NavigationPage(new StringListPage(m, "Arrays", null, true)) { Title = "Arrays" }); IntListPage p = new IntListPage(m, "PointBuyCost", "", "0 points", Keyboard.Telephone, true, false, m.PointBuyMinScore); t.Children.Add(new NavigationPage(p) { Title = "Point Buy Cost" }); m.PropertyChanged += (o, ee) => { if (ee.PropertyName == "" || ee.PropertyName == null || ee.PropertyName == "PointBuyMinScore") { p.Offset = m.PointBuyMinScore; } }; await Navigation.PushModalAsync(t); } else if (s == "Settings") { OGLContext context = new OGLContext(); await PCLSourceManager.InitAsync(); ConfigManager config = await context.LoadConfigAsync(await PCLSourceManager.Data.GetFileAsync("Config.xml")); DependencyService.Get <IHTMLService>().Reset(config); SettingsEditModel m = new SettingsEditModel(context); TabbedPage t = new TabbedPage(); t.Children.Add(new NavigationPage(new EditSettings(m)) { Title = "Settings" }); t.Children.Add(new NavigationPage(new StringListPage(m, "EqiupmentSlots", null, true)) { Title = "Slots" }); t.Children.Add(new NavigationPage(new StringListPage(m, "PDFExporters", null, true)) { Title = "PDF" }); t.Children.Add(new NavigationPage(new FeatureListPage(m, "CommonFeatures")) { Title = "Common Features" }); t.Children.Add(new NavigationPage(new FeatureListPage(m, "MulticlassingFeatures")) { Title = "Features (Multiclassing)" }); await Navigation.PushModalAsync(t); } } (sender as ListView).SelectedItem = null; }
async Task ExecuteLoadItemsCommand() { if (IsBusy) { return; } IsBusy = true; try { Items.Clear(); await PCLSourceManager.InitAsync().ConfigureAwait(false); BuilderContext TinyContext = new BuilderContext(); ConfigManager config = await TinyContext.LoadConfigAsync(await PCLSourceManager.Data.GetFileAsync("Config.xml").ConfigureAwait(false)).ConfigureAwait(false); await TinyContext.LoadLevelAsync(await PCLSourceManager.Data.GetFileAsync(config.Levels).ConfigureAwait(false)).ConfigureAwait(false); await TinyContext.ImportClassesAsync(false).ConfigureAwait(true); await TinyContext.ImportSubClassesAsync(false).ConfigureAwait(true); ExistenceCheckResult res = await App.Storage.CheckExistsAsync("Characters"); IFolder characters = await App.Storage.CreateFolderAsync("Characters", CreationCollisionOption.OpenIfExists); if (res == ExistenceCheckResult.NotFound) { IFile example = await characters.CreateFileAsync("Ex Ample.cb5", CreationCollisionOption.ReplaceExisting); var assembly = typeof(PCLSourceManager).GetTypeInfo().Assembly; using (Stream stream = assembly.GetManifestResourceStream("CB_5e.Ex Ample.cb5")) { using (Stream ex = await example.OpenAsync(FileAccess.ReadAndWrite)) { await stream.CopyToAsync(ex); } } } items.Clear(); foreach (IFile c in await characters.GetFilesAsync().ConfigureAwait(false)) { if (!c.Name.EndsWith(".cb5", StringComparison.OrdinalIgnoreCase)) { continue; } try { Player p = await TinyContext.LoadPlayerAsync(c); items.Add(new Character(p)); //{ // Player = p //}); } catch (Exception e) { ConfigManager.LogError(e); } } UpdateItems(); } catch (Exception ex) { Debug.WriteLine(ex); MessagingCenter.Send(new MessagingCenterAlert { Title = "Error", Message = "Unable to load items.", Cancel = "OK" }, "message"); } finally { IsBusy = false; } }