Esempio n. 1
0
        private void exportToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Ability a   = abilities[abilityBox.SelectedIndex];
            string  txt = $"{a.id},{a.intname},{a.name},\"{a.description}\"";

            SuperForm.exportFile($"ability{a.id}.txt", txt);
        }
Esempio n. 2
0
        private void exportToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Class  c   = classes[classBox.SelectedIndex];
            string ret = $"{c.id},{c.intname},{c.name},{c.money},{c.bgmusic},{c.victorymusic},{c.intromusic},{c.gender},{c.skill},";

            SuperForm.exportFile($"trainertype{c.id}.txt", ret);
        }
Esempio n. 3
0
        private void exportToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            classes.Sort(delegate(Class c1, Class c2) { return(c1.id.CompareTo(c2.id)); });
            classBinder.ResetBindings(false);
            string ret = null;

            for (int a = 0; a < classes.Count; a++)
            {
                Class c = classes[a];
                ret += $"{c.id},{c.intname},{c.name},{c.money},{c.bgmusic},{c.victorymusic},{c.intromusic},{c.gender},{c.skill},"; if (a != classes.Count - 1)
                {
                    ret += "\r\n";
                }
            }
            SuperForm.exportFile("trainertypes.txt", ret);
        }
Esempio n. 4
0
 private void overwriteToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Are you sure you want to overwrite \"trainertypes.txt\"?\r\nA backup of the current file will be saved in a new folder.", "Continue?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         classes.Sort(delegate(Class c1, Class c2) { return(c1.id.CompareTo(c2.id)); });
         classBinder.ResetBindings(false);
         string ret = null;
         for (int a = 0; a < classes.Count; a++)
         {
             Class c = classes[a];
             ret += $"{c.id},{c.intname},{c.name},{c.money},{c.bgmusic},{c.victorymusic},{c.intromusic},{c.gender},{c.skill},"; if (a != classes.Count - 1)
             {
                 ret += "\r\n";
             }
         }
         SuperForm.pbsFile("trainertypes.txt", ret);
     }
 }
Esempio n. 5
0
        private void overwriteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            abilities.Sort(delegate(Ability a1, Ability a2) { return(a1.id.CompareTo(a2.id)); });
            abilityBinder.ResetBindings(false);
            string ret = null;

            for (int i = 0; i < abilities.Count; i++)
            {
                Ability a = abilities[i];
                if (i != abilities.Count - 1)
                {
                    ret += $"{a.id},{a.intname},{a.name},\"{a.description}\"\r\n";
                }
                else
                {
                    ret += $"{a.id},{a.intname},{a.name},\"{a.description}\"";
                }
            }
            SuperForm.pbsFile("abilitites.txt", ret);
        }
Esempio n. 6
0
        private void TrainerClassForm_Load(object sender, EventArgs e)
        {
            if (File.Exists(@"PBS\trainertypes.txt"))
            {
                try {
                    StreamReader sr  = new StreamReader(File.OpenRead(@"PBS\trainertypes.txt"));
                    string       dat = sr.ReadToEnd();
                    sr.Close();
                    if (string.IsNullOrEmpty(dat))
                    {
                        emptyFile("Trainer Class Editor", "trainertypes");
                        terminate = true;
                        Close();
                        return;
                    }
                    List <string> entries = dat.Split(new string[] { "\r\n" }, StringSplitOptions.None).ToList();
                    for (int i = 0; i < entries.Count; i++)
                    {
                        try
                        {
                            if (!entries[i].StartsWith("#") && !entries[i].StartsWith(" ") && !entries[i].StartsWith("\r\n") && entries[i].Length > 0)
                            {
                                bool          cont         = true;
                                List <string> line         = entries[i].Split(',').ToList();
                                int           id           = Convert.ToInt32(line[0]);
                                string        name         = line[2];
                                string        intname      = line[1];
                                int?          money        = null;
                                string        bgmusic      = null;
                                string        victorymusic = null;
                                string        intromusic   = null;
                                string        gender       = null;
                                int?          skill        = null;
                                try { money = Convert.ToInt32(line[3]); }
                                catch (Exception) {
                                    money        = null;
                                    bgmusic      = null;
                                    victorymusic = null;
                                    intromusic   = null;
                                    gender       = null;
                                    skill        = null;
                                    cont         = false;
                                }
                                if (cont)
                                {
                                    try { bgmusic = line[4]; }
                                    catch (Exception) {
                                        bgmusic      = null;
                                        victorymusic = null;
                                        intromusic   = null;
                                        gender       = null;
                                        skill        = null;
                                        cont         = false;
                                    }
                                }
                                if (cont)
                                {
                                    try { victorymusic = line[5]; }
                                    catch (Exception) {
                                        victorymusic = null;
                                        intromusic   = null;
                                        gender       = null;
                                        skill        = null;
                                        cont         = false;
                                    }
                                }
                                if (cont)
                                {
                                    try { intromusic = line[6]; }
                                    catch (Exception) {
                                        intromusic = null;
                                        gender     = null;
                                        skill      = null;
                                        cont       = false;
                                    }
                                }
                                if (cont)
                                {
                                    try { gender = line[7]; }
                                    catch (Exception) {
                                        gender = null;
                                        skill  = null;
                                        cont   = false;
                                    }
                                }
                                if (cont)
                                {
                                    try { skill = Convert.ToInt32(line[8]); }
                                    catch (Exception) {
                                        skill = null;
                                        cont  = false;
                                    }
                                }
                                classes.Add(new Class(id, name, intname, money, bgmusic, victorymusic, intromusic, gender, skill));
                            }
                        }
                        catch (Exception)
                        {
                            SuperForm.invalidLine("trainertypes", entries[i], "Trainer Class Editor");
                            terminate = true;
                            Close();
                            return;
                        }
                    }
                }
                catch (Exception) {
                    MessageBox.Show("Something went wrong while converting data inside \"trainertypes.txt\".", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    terminate = true;
                    Close();
                    return;
                }
            }
            else
            {
                SuperForm.fileNotFound("trainertypes", "Trainer Class Editor");
                terminate = true;
                Close();
                return;
            }

            classBinder.DataSource = classes;
            classBox.DataSource    = classBinder;
            classBox.DisplayMember = "intname";
            Class c = classes[0];

            switch (Properties.Settings.Default.ClassSortMethod)
            {
            case "ID": classes.Sort(delegate(Class c1, Class c2) { return(c1.id.CompareTo(c2.id)); }); break;

            case "DisplayName": classes.Sort(delegate(Class c1, Class c2) { return(c1.name.CompareTo(c2.name)); }); break;

            case "InternalName": classes.Sort(delegate(Class c1, Class c2) { return(c1.intname.CompareTo(c2.intname)); }); break;

            case "Money": classes.Sort(delegate(Class c1, Class c2) { return(c1.getSortableMoney().CompareTo(c2.getSortableMoney())); }); classes.Reverse(); break;

            case "BGMusic": classes.Sort(delegate(Class c1, Class c2) { return(c1.getSortableMusic(1).CompareTo(c2.getSortableMusic(1))); }); classes.Reverse(); break;

            case "VictoryMusic": classes.Sort(delegate(Class c1, Class c2) { return(c1.getSortableMusic(2).CompareTo(c2.getSortableMusic(2))); }); classes.Reverse(); break;

            case "IntroMusic": classes.Sort(delegate(Class c1, Class c2) { return(c1.getSortableMusic(3).CompareTo(c2.getSortableMusic(3))); }); classes.Reverse(); break;

            case "Gender": classes.Sort(delegate(Class c1, Class c2) { return(c1.getSortableGender().CompareTo(c2.getSortableGender())); }); break;

            case "Skill": classes.Sort(delegate(Class c1, Class c2) { return(c1.getSortableSkill().CompareTo(c2.getSortableSkill())); }); classes.Reverse(); break;

            default: Properties.Settings.Default.ClassSortMethod = "InternalName"; break;
            }
            classBinder.ResetBindings(false);
            classBox.SelectedIndex = classes.IndexOf(c);
            try
            {
                player = new WindowsMediaPlayer();
            }
            catch (Exception)
            {
                canPlay = false;
            }
        }