Esempio n. 1
0
        private void Read(string name)
        {
            string filename = PRTY_FILES_PATH + name + ".prty";

            using (var file = File.Open(filename, FileMode.OpenOrCreate, FileAccess.Read))
            {
                if (file.Length == 0)
                {
                    Initialize();
                }
                else
                {
                    NameInput.Text = ReadText(file);
                    EnvironmentInput.SelectedIndex = EnvironmentData.FindIndex(ReadShort(file));
                    NumberOfPlayers             = ReadByte(file);
                    NumberOfPlayersDisplay.Text = NumberOfPlayers.ToString();
                    for (int i = 0; i < NumberOfPlayers; i++)
                    {
                        Players[i].Read(file);
                        Players[i].Visible = true;
                    }
                    for (int i = NumberOfPlayers; i < MAX_NUMBER_OF_PLAYERS; i++)
                    {
                        Players[i].Initialize();
                        Players[i].Visible = false;
                    }
                    for (int i = 0; i < 6; i++)
                    {
                        Relations[i].SelectedIndex = ReadByte(file);
                    }
                    BattleInput.SelectedIndex = BattleData.FindIndex(ReadShort(file));
                }
            }
        }
Esempio n. 2
0
        private bool UnsavedChanges()
        {
            List <bool> unsaved  = new List <bool>();
            string      filename = PRTY_FILES_PATH + "Group" + (CurrentSelection + 1) + ".prty";

            using (var file = File.Open(filename, FileMode.OpenOrCreate, FileAccess.Read))
            {
                if (file.Length > 0)
                {
                    unsaved.Add(NameInput.Text != ReadText(file));
                    unsaved.Add(EnvironmentInput.SelectedIndex != EnvironmentData.FindIndex(ReadShort(file)));
                    unsaved.Add(NumberOfPlayers != ReadByte(file));
                    for (int i = 0; i < NumberOfPlayers; i++)
                    {
                        unsaved.Add(Players[i].UnsavedChanges(file));
                    }
                    for (int i = 0; i < 6; i++)
                    {
                        unsaved.Add(Relations[i].SelectedIndex != ReadByte(file));
                    }
                    unsaved.Add(BattleInput.SelectedIndex != BattleData.FindIndex(ReadShort(file)));
                }
            }
            if (unsaved.Count <= 0)
            {
                return(true);
            }
            for (int i = 0; i < unsaved.Count; i++)
            {
                if (unsaved[i])
                {
                    return(true);
                }
            }
            return(false);
        }