예제 #1
0
        // Convert button
        private void btnImport_Click(object sender, EventArgs e)
        {
            if (sourcePath.Text == "")
            {
                MessageBox.Show("Select a game save data path first", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (tbxSourceSaveFile.Text == "")
            {
                MessageBox.Show("Select a source save file first", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (cbxSlotsSelect.SelectedItem == null || cbxSlotsSelect.SelectedItem.ToString() == "")
            {
                MessageBox.Show("Select a slot first", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            var choice = MessageBox.Show("It will overwrite your save data on your save data path. Are you sure?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (choice == DialogResult.Yes)
            {
                string baseFinalPath = $"{sourcePath.Text}\\data00{cbxSlotsSelect.SelectedItem.ToString()}.bin";

                Debug.WriteLine($"Saving to {baseFinalPath}");

                // Pick the binslot first
                Binslot binslot = new Binslot($"{baseFinalPath}slot");

                // Calculating new hash
                byte[] newHash = HashMD5.getMd5BytesHash(File.ReadAllBytes(tbxSourceSaveFile.Text));
                string strHash = HashMD5.getMd5StringHash(File.ReadAllBytes(tbxSourceSaveFile.Text));

                Debug.WriteLine($"New hash: {strHash}");

                // Storing the newer hash
                binslot.saveFileHash = newHash;

                // Saving the new file binslot
                binslot.saveBinslot();

                // Copying the save into save file path
                File.Copy(tbxSourceSaveFile.Text, baseFinalPath, true);

                MessageBox.Show("Save import finished", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }