Exemplo n.º 1
0
        public static List <SkillEditor> CreateEditors(PathfinderSheet ps, Window?owner = null)
        {
            List <SkillEditor> eds = new List <SkillEditor>();

            foreach (var item in SkillEntries)
            {
                SkillEditor se = new SkillEditor();

                se.SkillName         = item.Value.name;
                se.SkillAbility      = item.Value.modifier;
                se.CanEditTitle      = item.Value.canEdit;
                se.SkillInternalName = item.Key;

                se.OwnerWindow = owner;

                // set skill name to use with d20pfsrd.com
                string snl = se.SkillName.ToLowerInvariant();

                if (snl.Contains("knowledge"))
                {
                    se.SkillOnlineName = "knowledge";
                }
                else
                {
                    se.SkillOnlineName = snl.Replace(' ', '-');
                }

                if (ps.Skills != null)
                {
                    try
                    {
                        Skill s = ps.Skills[item.Key] ?? new Skill();
                        se.LoadSkillData(s);
                    }
                    catch (KeyNotFoundException)
                    {
                        Skill s = new Skill();
                        s.Total      = "0";
                        s.Ranks      = "0";
                        s.ClassSkill = false;
                        se.LoadSkillData(s);
                    }
                }
                else
                {
                    Skill s = new Skill();
                    s.Total      = "0";
                    s.Ranks      = "0";
                    s.ClassSkill = false;
                    se.LoadSkillData(s);
                }

                eds.Add(se);
            }

            return(eds);
        }
Exemplo n.º 2
0
        private void btnImport_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog();
            ofd.Title  = "Import Data from File";
            ofd.Filter = "Pathfinder Character Sheet|*.json|All Files|*.*";

            if (ofd.ShowDialog() ?? false == true)
            {
                string          filename = ofd.FileName;
                PathfinderSheet ps       = PathfinderSheet.LoadJsonFile(filename);
                LoadUserData(ps.Player ?? new UserData(true));
            }
        }
Exemplo n.º 3
0
        private void btnCreate_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(txtCharacterName.Text) || string.IsNullOrWhiteSpace(txtCharacterLevel.Text))
            {
                MessageDialog md = new MessageDialog(ColorScheme);
                md.Image   = MessageDialogImage.Error;
                md.Message = "Either the character's name or class/level is missing. Please enter those before continuing.";
                md.Title   = "Missing Data";
                md.Owner   = this;
                md.ShowDialog();
                return;
            }

            // Create Pathfinder sheet
            // Including ability scores
            // (I also set up the RawAbilities property despite it not really being used, in case it may become an issue later on)
            Sheet              = PathfinderSheet.CreateNewSheet(txtCharacterName.Text, txtCharacterLevel.Text, ud);
            Sheet.Charisma     = txtCha.Value;
            Sheet.Constitution = txtCon.Value;
            Sheet.Dexterity    = txtDex.Value;
            Sheet.Intelligence = txtInt.Value;
            Sheet.Strength     = txtStr.Value;
            Sheet.Wisdom       = txtWis.Value;

            Dictionary <string, string> abilities = new Dictionary <string, string>
            {
                { "str", txtStr.Value.ToString() },
                { "dex", txtDex.Value.ToString() },
                { "cha", txtCha.Value.ToString() },
                { "con", txtCon.Value.ToString() },
                { "int", txtInt.Value.ToString() },
                { "wis", txtWis.Value.ToString() }
            };

            Sheet.RawAbilities = abilities;

            if (!string.IsNullOrEmpty(FileLocation))
            {
                Sheet.SaveJsonFile(FileLocation, App.Settings.IndentJsonData);
            }

            DialogResult = true;
            Close();
        }
Exemplo n.º 4
0
        private void btnImportData_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog();
            ofd.Title  = "Import Data from File";
            ofd.Filter = "Pathfinder Character Sheet|*.json|All Files|*.*";

            if (ofd.ShowDialog() ?? false == true)
            {
                string          filename = ofd.FileName;
                PathfinderSheet ps       = PathfinderSheet.LoadJsonFile(filename);
                ud = ps.Player ?? new UserData(true);
                if (!string.IsNullOrEmpty(ud.DisplayName))
                {
                    txtPlayerName.Text = ud.DisplayName;
                }
                else
                {
                    txtPlayerName.Text = "(not set)";
                }
            }
        }