Update module_main

Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com>
This commit is contained in:
2023-02-12 13:13:21 +07:00
parent bcb5cd03e6
commit 8888a80b0c
3 changed files with 12 additions and 16 deletions

BIN
SII_Decrypt.dll Normal file

Binary file not shown.

Binary file not shown.

View File

@@ -1,10 +1,12 @@
#!/usr/bin/python3 #!/usr/bin/python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from os import system, remove from os import remove
from PyQt5.QtCore import Qt, QRegExp from PyQt5.QtCore import Qt, QRegExp
from PyQt5.QtGui import QRegExpValidator from PyQt5.QtGui import QRegExpValidator
from PyQt5.QtWidgets import QDialog, QFileDialog from PyQt5.QtWidgets import QDialog, QFileDialog
from ctypes import WinDLL
from os import getcwd
from .form import Ui_MainWindow from .form import Ui_MainWindow
from util import * from util import *
from dataIO import dataIO from dataIO import dataIO
@@ -127,22 +129,16 @@ class MainWindow(QDialog, Ui_MainWindow):
self.ui.backup.setEnabled(False) self.ui.backup.setEnabled(False)
self.ui.second_window.setEnabled(False) self.ui.second_window.setEnabled(False)
def get_file_data(self, file): def get_file_data(self, file_path):
try: sii_lib = WinDLL("{}\SII_Decrypt.dll".format(os.getcwd()))
with open(file) as f: bytes_file_path = file_path.replace("/", "\\").encode("utf-8")
self.old_file = f.read() if sii_lib.GetFileFormat(bytes_file_path) == 2:
except UnicodeDecodeError: if sii_lib.DecryptAndDecodeFile(bytes_file_path, bytes_file_path) != 0:
try: QMessageBox.critical(self, "Error", "Something went wrong with decrypting file. Try again.")
system("SII_Decrypt.exe --on_file -i \"{}\"".format(file))
with open(file) as f:
self.old_file = f.read()
QMessageBox.information(self, "Success", "File successfully decrypted.")
except UnicodeDecodeError:
QMessageBox.critical(self, "Error", "Error to decrypt and open file. "
"Try again.\nIf you still get error on this step, "
"try to change \"uset g_save_format\" to 2, resave "
"game and try again.")
return return
with open(file_path) as f:
self.old_file = f.read()
util.set_lines(self.old_file.split("\n")) util.set_lines(self.old_file.split("\n"))
if self.owns is not False: if self.owns is not False: