public void LoadSave(string path) { this.path = path; SlotData = Util.DeserializeObject <SlotData>(EncryptString.DecompressBytesToString(File.ReadAllBytes(path))); Boot = Util.DeserializeObject <BootSaveGameFormat>(EncryptString.DecompressBytesToString(SlotData.m_Dict["boot"])); OriginalRegion = Boot.m_SceneName; Global = new GlobalSaveGameData(EncryptString.DecompressBytesToString(SlotData.m_Dict["global"])); var pos = Global.PlayerManager.m_SaveGamePosition; originalPosition = new float[] { pos[0], pos[1], pos[2] }; }
static void Main(string[] args) { string path = @"E:\study\git\BuckUpToolsForTheLongDark\readBuckFile\readBuckFile\sandbox5"; var allFile = File.Create(new FileInfo(path).DirectoryName + "\\all.txt"); byte[] all = File.ReadAllBytes(path); //Console.WriteLine(BitConverter.ToString(all)); var all2 = EncryptString.DecompressBytesToString(all); //Console.WriteLine(all2); StreamWriter sr = new StreamWriter(allFile); sr.WriteLine(all2); sr.Close(); allFile.Close(); Console.Read(); }
/// <summary> /// 选中文件 /// </summary> /// <param name="file"></param> private void SelectFile(FileInfo file) { nowSelect = file; var data = new SlotData(); if (file.Extension == "") { pictureBox1.Visible = false; data = (SlotData)Item.DeserializeObject <SlotData>(EncryptString.DecompressBytesToString(File.ReadAllBytes(file.FullName))); Console.WriteLine(data.m_Dict["screenshot"].Length); var img = ((Screenshot)Item.DeserializeObject <Screenshot>(EncryptString.DecompressBytesToString(data.m_Dict["screenshot"]))).ToImage(); pictureBox1.Visible = true; pictureBox1.Image = img; } else if (file.Extension == ".png") { pictureBox1.Visible = true; pictureBox1.ImageLocation = file.FullName; var zipFile = ZipPath + file.NameWithoutExtension() + ".gz"; Console.WriteLine("file:" + zipFile); if (File.Exists(zipFile) == false) { MessageBox.Show("程序未找到文件:" + zipFile + "!\r\n请检查图片同名压缩包是否删除\r\n或者是否删除zippath文件夹", "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { Item.UnZipFile(zipFile, TempFolder + file.NameWithoutExtension()); data = Item.DeserializeObject <SlotData>(EncryptString.DecompressBytesToString(File.ReadAllBytes(TempFolder + file.NameWithoutExtension()))); } } ShowData(data); var bootData = Item.DeserializeObject <BootData>(EncryptString.DecompressBytesToString(data.m_Dict["boot"])); var proxy = Item.DeserializeObject <GlobalDataFormat>(EncryptString.DecompressBytesToString(data.m_Dict["global"])); //Console.WriteLine(EncryptString.DecompressBytesToString(data.m_Dict["global"])); }
/// <summary> /// 文件信息文件初始化 /// </summary> private void FolderInfoIniInit() { if (File.Exists(FolderInfoIni) == false) { File.Create(FolderInfoIni); var saveDatas = ""; var buckDatas = ""; var saveFiles = RemoveUsers(new DirectoryInfo(gameSavePath.val).GetFiles()); var buckFiles = RemoveUsers(new DirectoryInfo(buckUpPath.val).GetFiles()); foreach (var file in saveFiles) { SlotData data = new SlotData(); if (file.Extension == "") { data = Item.DeserializeObject <SlotData>(EncryptString.DecompressBytesToString(File.ReadAllBytes(file.FullName))); } else if (file.Extension == ".png") { var zipFile = ZipPath + file.NameWithoutExtension() + ".gz"; Console.WriteLine("file:" + zipFile); if (File.Exists(zipFile) == false) { //MessageBox.Show("程序未找到文件:" + zipFile + "!\r\n请检查图片同名压缩包是否删除\r\n或者是否删除zippath文件夹", "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning); //return; //data = new SlotData(); } else { Item.UnZipFile(zipFile, TempFolder + file.NameWithoutExtension()); data = Item.DeserializeObject <SlotData>(EncryptString.DecompressBytesToString(File.ReadAllBytes(TempFolder + file.NameWithoutExtension()))); } } saveDatas += data.ToBigDatas(file, false).ToString(true); } foreach (var file in buckFiles) { SlotData data = new SlotData(); if (file.Extension == "") { data = Item.DeserializeObject <SlotData>(EncryptString.DecompressBytesToString(File.ReadAllBytes(file.FullName))); } else if (file.Extension == ".png") { var zipFile = ZipPath + file.NameWithoutExtension() + ".gz"; Console.WriteLine("file:" + zipFile); if (File.Exists(zipFile) == false) { //MessageBox.Show("程序未找到文件:" + zipFile + "!\r\n请检查图片同名压缩包是否删除\r\n或者是否删除zippath文件夹", "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning); //return; //data = new SlotData(); } else { Item.UnZipFile(zipFile, TempFolder + file.NameWithoutExtension()); data = Item.DeserializeObject <SlotData>(EncryptString.DecompressBytesToString(File.ReadAllBytes(TempFolder + file.NameWithoutExtension()))); } } buckDatas += data.ToBigDatas(file, true).ToString(true); } AllFileInfo = new BigData("saveDatas", saveDatas).ToString() + new BigData("buckDatas", buckDatas).ToString(); var theFile = new FileInfo(FolderInfoIni).OpenWrite(); var sw = new StreamWriter(theFile); sw.Write(AllFileInfo); sw.Close(); theFile.Close(); } else { var theFile = new FileInfo(FolderInfoIni).OpenRead(); var sr = new StreamReader(theFile); AllFileInfo = sr.ReadToEnd(); sr.Close(); theFile.Close(); } }
public Profile(string path) { this.path = path; var bytes = File.ReadAllBytes(path); var json = EncryptString.DecompressBytesToString(bytes); int currentIndex = 0; #region Fix m_StatsDictionary // m_StatsDictionary is invalid json so we'll fix it // There's multiple instances of m_StatsDictionary // Ugly as f but works... for now while (true) { int statsDictStartIndex = json.IndexOf("m_StatsDictionary", currentIndex); if (statsDictStartIndex == -1) { break; } statsDictStartIndex = json.IndexOf('{', statsDictStartIndex); currentIndex = statsDictStartIndex; int statsDictEndIndex = json.IndexOf('}', statsDictStartIndex); // Save files contain json that has been serialized multiple times and not all m_StatsDictionarys are on the same depth var newStats = json.Substring(statsDictStartIndex, statsDictEndIndex - statsDictStartIndex); if (newStats.Length <= 2) { continue; } int depth = 0; int quoteIndex = newStats.IndexOf("\""); for (int i = quoteIndex - 1; newStats[i] == '\\'; i--, depth++) { } string escapes = new String('\\', depth); for (var i = 0; i < newStats.Length; i++) { var c = newStats[i]; if ((c == '-' || char.IsDigit(c))) { if (newStats[i - 1] != '"' && newStats[i - 1] != '.') { newStats = newStats.Insert(i, escapes + "\""); i += 2 + depth; while (char.IsDigit(newStats[i]) || newStats[i] == '-') { i++; } newStats = newStats.Insert(i, escapes + "\""); i += 1 + depth; } else { while (char.IsDigit(newStats[i]) || newStats[i] == '.' || newStats[i] == 'E' || newStats[i] == '-') { i++; } } } } json = json.Substring(0, statsDictStartIndex) + newStats + json.Substring(statsDictEndIndex); } #endregion Proxy = Util.DeserializeObject <ProfileState>(json); if (Proxy == null) { return; } Feats = new FeatsManager(Proxy.m_FeatsSerialized); }