Skip to content

Commit c9032eb

Browse files
<feature> improve unpack overwrite option which will skip if exist
update version to v2.5.2
1 parent 034f444 commit c9032eb

4 files changed

Lines changed: 27 additions & 1 deletion

File tree

src/game_unpacker_form.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ def __init__(self, parent=None):
120120
f.close()
121121
max_thread_num = 12
122122
is_script_only = True
123+
is_skip_if_exist = True
123124
for idx, _line in enumerate(_read_lines):
124125
if _line.startswith(' MAX_UNPACK_THREADS = '):
125126
max_thread_num = _line[len(' MAX_UNPACK_THREADS = '):].strip().strip('\n')
@@ -128,8 +129,13 @@ def __init__(self, parent=None):
128129
if _line.startswith(' SCRIPT_ONLY = '):
129130
is_script_only = _line[len(' SCRIPT_ONLY = '):].strip().strip('\n') == 'True'
130131
break
132+
for idx, _line in enumerate(_read_lines):
133+
if _line.startswith(' SKIP_IF_EXIST = '):
134+
is_skip_if_exist = _line[len(' SKIP_IF_EXIST = '):].strip().strip('\n') == 'True'
135+
break
131136
self.maxThreadsLineEdit.setText(str(max_thread_num))
132137
self.unpackAllCheckBox.setChecked(not is_script_only)
138+
self.overwriteCheckBox.setChecked(not is_skip_if_exist)
133139
_thread.start_new_thread(self.update, ())
134140

135141
def closeEvent(self, event):
@@ -169,6 +175,10 @@ def unpack(self):
169175
if _line.startswith(' SCRIPT_ONLY = '):
170176
_read_lines[idx] = f' SCRIPT_ONLY = {str(not self.unpackAllCheckBox.isChecked())}\n'
171177
break
178+
for idx, _line in enumerate(_read_lines):
179+
if _line.startswith(' SKIP_IF_EXIST = '):
180+
_read_lines[idx] = f' SKIP_IF_EXIST = {str(not self.overwriteCheckBox.isChecked())}\n'
181+
break
172182

173183
f = io.open(dir + '/game/' + hook_script, mode='w', encoding='utf-8')
174184
f.writelines(_read_lines)

src/hook_unrpa.rpy

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ init python early hide:
1616
MAX_UNPACK_THREADS = 12
1717
global SCRIPT_ONLY
1818
SCRIPT_ONLY = False
19+
global SKIP_IF_EXIST
20+
SKIP_IF_EXIST = True
1921
global unpack_semaphore
2022
unpack_semaphore = threading.Semaphore(MAX_UNPACK_THREADS)
2123
non_ascii_file_list = []
@@ -42,6 +44,10 @@ init python early hide:
4244
global write_out_to_file
4345
def write_out_to_file(semaphore, name, write_path, _write_data):
4446
with semaphore:
47+
if SKIP_IF_EXIST:
48+
if os.path.isfile(write_path[:-1]) or os.path.isfile(write_path):
49+
print(write_path + ' skip due to exist')
50+
return
4551
if is_ascii(name):
4652
print(write_path)
4753
else:

src/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
sourceDic = dict()
5656
translator = QTranslator()
5757

58-
VERSION = '2.5.1'
58+
VERSION = '2.5.2'
5959

6060
class MyProxyForm(QDialog, Ui_ProxyDialog):
6161
def __init__(self, parent=None):

src/one_key_translate_form.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ def __init__(self, parent=None):
7979
f.close()
8080
max_thread_num = 12
8181
is_script_only = True
82+
is_skip_if_exist = True
8283
for idx, _line in enumerate(_read_lines):
8384
if _line.startswith(' MAX_UNPACK_THREADS = '):
8485
max_thread_num = _line[len(' MAX_UNPACK_THREADS = '):].strip().strip('\n')
@@ -87,9 +88,14 @@ def __init__(self, parent=None):
8788
if _line.startswith(' SCRIPT_ONLY = '):
8889
is_script_only = _line[len(' SCRIPT_ONLY = '):].strip().strip('\n') == 'True'
8990
break
91+
for idx, _line in enumerate(_read_lines):
92+
if _line.startswith(' SKIP_IF_EXIST = '):
93+
is_skip_if_exist = _line[len(' SKIP_IF_EXIST = '):].strip().strip('\n') == 'True'
94+
break
9095
self.maxThreadsLineEdit.setText(str(max_thread_num))
9196

9297
self.unpackAllCheckBox.setChecked(not is_script_only)
98+
self.overwriteCheckBox.setChecked(not is_skip_if_exist)
9399
_thread.start_new_thread(self.update, ())
94100

95101
def on_tl_path_changed(self):
@@ -413,6 +419,10 @@ def unpack(self):
413419
if _line.startswith(' SCRIPT_ONLY = '):
414420
_read_lines[idx] = f' SCRIPT_ONLY = {str(not self.unpackAllCheckBox.isChecked())}\n'
415421
break
422+
for idx, _line in enumerate(_read_lines):
423+
if _line.startswith(' SKIP_IF_EXIST = '):
424+
_read_lines[idx] = f' SKIP_IF_EXIST = {str(not self.overwriteCheckBox.isChecked())}\n'
425+
break
416426
f = io.open(dir + '/game/' + game_unpacker_form.hook_script, mode='w', encoding='utf-8')
417427
f.writelines(_read_lines)
418428
f.close()

0 commit comments

Comments
 (0)