-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathForm1.cs
109 lines (102 loc) · 4.79 KB
/
Form1.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
namespace Nioh_2_Save_Converter
{
public partial class Form1 : Form
{
Byte[] loadedOldSaveGame;
Byte[] loadedNewSaveGame;
string saveFolder;
public Form1()
{
InitializeComponent();
MessageBox.Show("Informations: \nYou should have created a new savegame (and be sure to backed up the old one!!!) \n The program refer Original Save as the savegame you want to convert, and New Save as the new file it'll be converted from, you imperatively need to create a new save (and BACKUP ORIGINAL SAVE) before using this program.\nConverted Save will erase newly created savegame. \n You should do that for SAVEDATAXX (XX=Slot Number) and for SYSTEMSAVEDATAXX.");
}
private void LoadOriginalSave_Click(object sender, EventArgs e)
{
var filePath = string.Empty;
using (OpenFileDialog openFileDialog = new OpenFileDialog())
{
string DocumentsFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
openFileDialog.InitialDirectory = DocumentsFolder + "\\KoeiTecmo\\NIOH2\\SaveData";
openFileDialog.Filter = "SAVEDATA.BIN (*.BIN)|*.bin";
openFileDialog.FilterIndex = 2;
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
filePath = openFileDialog.FileName;
loadedOldSaveGame = File.ReadAllBytes(filePath);
//Checking if it a valid safe file by comparing first and second byte
if (loadedOldSaveGame[0] != 0x7F && loadedOldSaveGame[1] != 0x9C)
{
MessageBox.Show("Error, this isn't a valid save file!");
Array.Clear(loadedOldSaveGame, 0, loadedOldSaveGame.Length);
}
else
{
originalSaveFileName.Text = openFileDialog.FileName;
}
}
}
}
private void ConvertButton_Click(object sender, EventArgs e)
{
if (loadedOldSaveGame?.Length > 0 && loadedNewSaveGame?.Length > 0)
{
DialogResult confirmDialog = MessageBox.Show($"The save will convert \n {originalSaveFileName.Text} (Your true save game)\n " +
$"to\n{newSaveFileName.Text} (New save)\nAre you sure you want to proceed ?", "Confirm ?", MessageBoxButtons.YesNoCancel);
if (confirmDialog == DialogResult.Yes)
{
Array.Copy(loadedNewSaveGame, 0x10, loadedOldSaveGame, 0x10, 4);
try
{
File.WriteAllBytes(saveFolder, loadedOldSaveGame);
MessageBox.Show("Complete!");
}
catch (Exception exception)
{
MessageBox.Show($"{exception.Message}");
}
}
}
else
{
MessageBox.Show("Error, one of the file have not been loaded !");
}
}
private void LoadNewSave_Click(object sender, EventArgs e)
{
var filePath = string.Empty;
using (OpenFileDialog openFileDialog = new OpenFileDialog())
{
string DocumentsFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
openFileDialog.InitialDirectory = DocumentsFolder + "\\KoeiTecmo\\NIOH2\\SaveData";
openFileDialog.Filter = "SAVEDATA.BIN (*.BIN)|*.bin";
openFileDialog.FilterIndex = 2;
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
filePath = openFileDialog.FileName;
loadedNewSaveGame = File.ReadAllBytes(filePath);
//Checking if it a valid safe file by comparing first and second byte
if (loadedNewSaveGame[0] != 0x7F && loadedNewSaveGame[1] != 0x9C)
{
MessageBox.Show("Error, this isn't a valid save file!");
Array.Clear(loadedNewSaveGame, 0, loadedNewSaveGame.Length);
}
else
{
newSaveFileName.Text = openFileDialog.FileName;
}
saveFolder = filePath;
}
}
}
}
}