Upload 11 files
Browse files- v-corpus-zh/Silky'sPlus/流景之海的艾佩理雅/本体@萌AI同好会/AP_.txt.gz +3 -0
- v-corpus-zh/Silky'sPlus/流景之海的艾佩理雅/本体@萌AI同好会/INT.txt.gz +3 -0
- v-corpus-zh/Silky'sPlus/流景之海的艾佩理雅/本体@萌AI同好会/S00.txt.gz +3 -0
- v-corpus-zh/Silky'sPlus/流景之海的艾佩理雅/本体@萌AI同好会/S01.txt.gz +3 -0
- v-corpus-zh/Silky'sPlus/流景之海的艾佩理雅/本体@萌AI同好会/S02.txt.gz +3 -0
- v-corpus-zh/Silky'sPlus/流景之海的艾佩理雅/本体@萌AI同好会/S03.txt.gz +3 -0
- v-corpus-zh/Silky'sPlus/流景之海的艾佩理雅/本体@萌AI同好会/S04.txt.gz +3 -0
- v-corpus-zh/Silky'sPlus/流景之海的艾佩理雅/本体@萌AI同好会/S05.txt.gz +3 -0
- v-corpus-zh/Silky'sPlus/流景之海的艾佩理雅/本体@萌AI同好会/S06.txt.gz +3 -0
- v-corpus-zh/Silky'sPlus/流景之海的艾佩理雅/本体@萌AI同好会/silky_mes.py +612 -0
- v-corpus-zh/Silky'sPlus/流景之海的艾佩理雅/本体@萌AI同好会/流景之海的艾佩理雅_mes.py +196 -0
v-corpus-zh/Silky'sPlus/流景之海的艾佩理雅/本体@萌AI同好会/AP_.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:dc8e67d1537e61cba3e418bbe234bff865d5343233794825dff666598aa77891
|
3 |
+
size 283304
|
v-corpus-zh/Silky'sPlus/流景之海的艾佩理雅/本体@萌AI同好会/INT.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5bba628fd234ceb007cae3bbf771724e41718f5f2086bae08d9e5473214efd89
|
3 |
+
size 12441
|
v-corpus-zh/Silky'sPlus/流景之海的艾佩理雅/本体@萌AI同好会/S00.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:28e15f3b4822e1cde6dac3df7eb4cd7ece55b28d9f671c57511c54276632d843
|
3 |
+
size 277162
|
v-corpus-zh/Silky'sPlus/流景之海的艾佩理雅/本体@萌AI同好会/S01.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0916cc103a7e07aa2e3d5505826b3cbd7eb0f7cb0c095e6838fc1db37bece492
|
3 |
+
size 200985
|
v-corpus-zh/Silky'sPlus/流景之海的艾佩理雅/本体@萌AI同好会/S02.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ceb5d04d6ec990fd6029c9dcd68951a51dc0b997544108bbdb3c7efe518e7d77
|
3 |
+
size 130202
|
v-corpus-zh/Silky'sPlus/流景之海的艾佩理雅/本体@萌AI同好会/S03.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e6665d7db16404172bd1043bcb0a45ed427b6afa6a8d190145ffc99d83209b27
|
3 |
+
size 119643
|
v-corpus-zh/Silky'sPlus/流景之海的艾佩理雅/本体@萌AI同好会/S04.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9f7e00cb3bba135ba2d4c51cb92a54c308a27069a6336f59a5613e2446f922df
|
3 |
+
size 136009
|
v-corpus-zh/Silky'sPlus/流景之海的艾佩理雅/本体@萌AI同好会/S05.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:86773327d6cbff58fe62e485c5d5b64d8a08db88109b74b1b51e150c804f9e7b
|
3 |
+
size 161944
|
v-corpus-zh/Silky'sPlus/流景之海的艾佩理雅/本体@萌AI同好会/S06.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1e6b3d95cf7a3a728eb5d8ffbcaf8a9a7fa3e86cfa2070e39042f15e1d1c057b
|
3 |
+
size 2127
|
v-corpus-zh/Silky'sPlus/流景之海的艾佩理雅/本体@萌AI同好会/silky_mes.py
ADDED
@@ -0,0 +1,612 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# https://github.com/TesterTesterov/mesScriptAsseAndDisassembler
|
2 |
+
|
3 |
+
import struct
|
4 |
+
import os
|
5 |
+
import json
|
6 |
+
|
7 |
+
|
8 |
+
class SilkyMesScript:
|
9 |
+
default_encoding = "cp936"
|
10 |
+
technical_instances = (">", "<")
|
11 |
+
|
12 |
+
# [Opcode, struct, name].
|
13 |
+
command_library = (
|
14 |
+
(0x00, '', 'RETURN'),
|
15 |
+
(0x01, 'I', ''), # Found only in LIBLARY.LIB
|
16 |
+
(0x02, '', ''),
|
17 |
+
(0x03, '', ''), # Found only in LIBLARY.LIB
|
18 |
+
(0x04, '', ''),
|
19 |
+
(0x05, '', ''),
|
20 |
+
(0x06, '', ''), # Found only in LIBLARY.LIB
|
21 |
+
|
22 |
+
(0x0A, 'S', 'STR_CRYPT'),
|
23 |
+
(0x0B, 'S', 'STR_UNCRYPT'),
|
24 |
+
(0x0C, '', ''),
|
25 |
+
(0x0D, '', ''),
|
26 |
+
(0x0E, '', ''),
|
27 |
+
(0x0F, '', ''),
|
28 |
+
|
29 |
+
(0x10, 'B', ''),
|
30 |
+
(0x11, '', ''),
|
31 |
+
(0x14, '>I', 'JUMP'),
|
32 |
+
(0x15, '>I', 'MSG_OFSETTER'),
|
33 |
+
(0x16, '>I', 'SPEC_OFSETTER'), # Found only in LIBLARY.LIB
|
34 |
+
(0x17, '', ''),
|
35 |
+
(0x18, '', ''),
|
36 |
+
(0x19, '>I', 'MESSAGE'),
|
37 |
+
(0x1A, '>I', ''),
|
38 |
+
(0x1B, '>I', ''),
|
39 |
+
(0x1C, 'B', 'TO_NEW_STRING'),
|
40 |
+
|
41 |
+
(0x32, 'i', 'PUSH'),
|
42 |
+
(0x33, 'S', 'PUSH_STR'),
|
43 |
+
(0x34, '', ''),
|
44 |
+
(0x35, '', ''),
|
45 |
+
(0x36, 'B', 'JUMP_2'),
|
46 |
+
(0x37, '', ''),
|
47 |
+
(0x38, '', ''),
|
48 |
+
(0x3A, '', ''),
|
49 |
+
(0x3B, '', ''),
|
50 |
+
(0x3C, '', ''),
|
51 |
+
(0x3D, '', ''),
|
52 |
+
(0x3E, '', ''),
|
53 |
+
(0x3F, '', ''),
|
54 |
+
|
55 |
+
(0x40, '', ''),
|
56 |
+
(0x41, '', ''),
|
57 |
+
(0x42, '', ''),
|
58 |
+
(0x43, '', ''),
|
59 |
+
|
60 |
+
(0xFA, '', ''),
|
61 |
+
(0xFB, '', ''),
|
62 |
+
(0xFC, '', ''),
|
63 |
+
(0xFD, '', ''),
|
64 |
+
(0xFE, '', ''),
|
65 |
+
(0xFF, '', ''),
|
66 |
+
)
|
67 |
+
offsets_library = (
|
68 |
+
(0x14, 0),
|
69 |
+
(0x15, 0),
|
70 |
+
(0x16, 0),
|
71 |
+
(0x1b, 0),
|
72 |
+
)
|
73 |
+
|
74 |
+
def __init__(self, mes_name: str, txt_name: str, encoding: str = "", debug: bool = False, verbose: bool = False,
|
75 |
+
hackerman_mode: bool = False):
|
76 |
+
"""Prms:
|
77 |
+
mes_name -- name (and path) of mes script.
|
78 |
+
txt_name -- name (and path) of txt file.
|
79 |
+
encoding (not required) -- name of encoding.
|
80 |
+
debug -- push debug data in the script.
|
81 |
+
verbose -- print data about the class operations.
|
82 |
+
hackerman_mode -- for true hackers; helps hacking unsupported mes scripts."""
|
83 |
+
self._verbose = verbose
|
84 |
+
if encoding == "":
|
85 |
+
self.encoding = self.default_encoding
|
86 |
+
else:
|
87 |
+
self.encoding = encoding
|
88 |
+
self._hackerman_mode = hackerman_mode
|
89 |
+
self._debug = debug # For printing debug info, such as commands offsets.
|
90 |
+
self._mes_name = mes_name # Name of mes script file (with path).
|
91 |
+
self._txt_name = txt_name # Name of txt file (with path).
|
92 |
+
self._prm = [0, 0] # Parameters of mes script. # [Header entries number, padding???]
|
93 |
+
self._offsets = [] # Offsets of mes script.
|
94 |
+
self._first_offsets = [] # Offsets in the first section of header of mes script.
|
95 |
+
self._second_offsets = [] # Offsets in the second section of header of mes script.
|
96 |
+
|
97 |
+
self.get_I.instances = ("I", "i")
|
98 |
+
self.get_H.instances = ("H", "h")
|
99 |
+
self.get_B.instances = ("B", "b")
|
100 |
+
self.get_S.instances = ("S",)
|
101 |
+
self.set_I.instances = self.get_I.instances
|
102 |
+
self.set_H.instances = self.get_H.instances
|
103 |
+
self.set_B.instances = self.get_B.instances
|
104 |
+
self.set_S.instances = self.get_S.instances
|
105 |
+
|
106 |
+
# User methods.
|
107 |
+
|
108 |
+
def disassemble(self) -> None:
|
109 |
+
"""Disassemble Silky Engine mes script."""
|
110 |
+
self._offsets = []
|
111 |
+
self._prm, self._first_offsets, self._second_offsets = self._diss_header()
|
112 |
+
self._diss_other_offsets()
|
113 |
+
if self._verbose:
|
114 |
+
print("Parameters:", self._prm)
|
115 |
+
print("First offsets:", len(self._first_offsets), self._first_offsets)
|
116 |
+
print("Second offsets:", len(self._second_offsets), self._second_offsets)
|
117 |
+
print("True offsets:", len(self._offsets), self._offsets)
|
118 |
+
self._disassemble_commands()
|
119 |
+
|
120 |
+
def assemble(self) -> None:
|
121 |
+
"""Assemble Silky Engine mes script."""
|
122 |
+
|
123 |
+
self._prm, self._first_offsets, self._second_offsets, self._offsets = self._assemble_offsets_and_parameters()
|
124 |
+
|
125 |
+
if self._verbose:
|
126 |
+
print("Parameters:", self._prm)
|
127 |
+
print("First offsets:", self._first_offsets)
|
128 |
+
print("True offsets:", self._offsets)
|
129 |
+
self._assemble_script_file()
|
130 |
+
|
131 |
+
# Technical methods for assembling.
|
132 |
+
|
133 |
+
def _assemble_script_file(self) -> None:
|
134 |
+
in_file = open(self._txt_name, 'r', encoding=self.encoding)
|
135 |
+
try:
|
136 |
+
os.rename(self._mes_name, self._mes_name + '.bak')
|
137 |
+
except OSError:
|
138 |
+
pass
|
139 |
+
out_file = open(self._mes_name, 'wb')
|
140 |
+
|
141 |
+
message_count = 0
|
142 |
+
search_offset = [i[0] for i in self._offsets]
|
143 |
+
|
144 |
+
for parameter in self._prm:
|
145 |
+
out_file.write(struct.pack('I', parameter))
|
146 |
+
for first_offset in self._first_offsets:
|
147 |
+
out_file.write(struct.pack('I', first_offset))
|
148 |
+
for second_offset in self._second_offsets:
|
149 |
+
out_file.write(struct.pack('I', second_offset))
|
150 |
+
|
151 |
+
while True:
|
152 |
+
line = in_file.readline()
|
153 |
+
if line == '': # EOF.
|
154 |
+
break
|
155 |
+
if len(line) == 1: # To evade some nasty errors.
|
156 |
+
continue
|
157 |
+
if (line == '\n') or (line[0] == '$'):
|
158 |
+
continue
|
159 |
+
if line[1] == '0':
|
160 |
+
out_file.write(bytes.fromhex(line[2:-1]))
|
161 |
+
elif line[1] == '1':
|
162 |
+
command_string = line[3:-1]
|
163 |
+
command_index = -1
|
164 |
+
for num, lib_entry in enumerate(self.command_library): # Check if it is written by name.
|
165 |
+
if command_string == lib_entry[2]:
|
166 |
+
command_index = num
|
167 |
+
break
|
168 |
+
if command_index == -1: # Check if it is written by hex.
|
169 |
+
command_string = int(command_string, 16)
|
170 |
+
for num, lib_entry in enumerate(self.command_library):
|
171 |
+
if command_string == lib_entry[0]:
|
172 |
+
command_index = num
|
173 |
+
break
|
174 |
+
if command_index == -1: # There is no such command (text). But this should be impossible!
|
175 |
+
raise SilkyMesArchiveError("Error! There is no such command.\n{}".format(command_string))
|
176 |
+
out_file.write(struct.pack('B', self.command_library[command_index][0]))
|
177 |
+
|
178 |
+
line = in_file.readline()
|
179 |
+
|
180 |
+
argument_list = json.loads(line)
|
181 |
+
|
182 |
+
this_command = self.command_library[command_index][0]
|
183 |
+
offset_set = -1
|
184 |
+
if this_command == 0x19:
|
185 |
+
argument_list[0] = message_count
|
186 |
+
message_count += 1
|
187 |
+
else:
|
188 |
+
for offset_entry in self.offsets_library:
|
189 |
+
if this_command == offset_entry[0]:
|
190 |
+
offset_set = offset_entry[1]
|
191 |
+
break
|
192 |
+
|
193 |
+
if offset_set != -1:
|
194 |
+
indexer = search_offset.index(argument_list[offset_set])
|
195 |
+
argument_list[offset_set] = self._offsets[indexer][1]
|
196 |
+
|
197 |
+
argument_bytes = self.set_args(argument_list, self.command_library[command_index][1], self.encoding)
|
198 |
+
out_file.write(argument_bytes)
|
199 |
+
|
200 |
+
in_file.close()
|
201 |
+
out_file.close()
|
202 |
+
|
203 |
+
def _assemble_offsets_and_parameters(self) -> tuple:
|
204 |
+
"""Assemble offsets and parameters of Silky Engine's mes archive."""
|
205 |
+
in_file = open(self._txt_name, 'r', encoding=self.encoding)
|
206 |
+
|
207 |
+
first_offsets = []
|
208 |
+
second_offsets = []
|
209 |
+
offsets = []
|
210 |
+
prm = [0, 0] # First shall be changed.
|
211 |
+
|
212 |
+
pointer = 0
|
213 |
+
message_count = 0
|
214 |
+
|
215 |
+
while True:
|
216 |
+
line = in_file.readline()
|
217 |
+
if line == '': # EOF.
|
218 |
+
break
|
219 |
+
if len(line) == 1: # To evade some nasty errors.
|
220 |
+
continue
|
221 |
+
if (line == '\n') or (line[0] == '$'): # Line without text or comment should not be parsed as script.
|
222 |
+
continue
|
223 |
+
|
224 |
+
# Actually code strings logic.
|
225 |
+
|
226 |
+
if line[1] == '0': # "Free bytes".
|
227 |
+
pointer += len(line[2:-1].split(' '))
|
228 |
+
elif line[1] == '1': # Command.
|
229 |
+
command_string = line[3:-1]
|
230 |
+
command_index = -1
|
231 |
+
for num, lib_entry in enumerate(self.command_library): # Check if it is written by name.
|
232 |
+
if command_string == lib_entry[2]:
|
233 |
+
command_index = num
|
234 |
+
break
|
235 |
+
if command_index == -1: # Check if it is written by hex.
|
236 |
+
command_string = int(command_string, 16)
|
237 |
+
for num, lib_entry in enumerate(self.command_library):
|
238 |
+
if command_string == lib_entry[0]:
|
239 |
+
command_index = num
|
240 |
+
break
|
241 |
+
if command_index == -1: # There is no such command (text). But this should be impossible!
|
242 |
+
raise SilkyMesArchiveError("Error! There is no such command.\n{}".format(command_string))
|
243 |
+
|
244 |
+
if self.command_library[command_index][0] == 0x19: # Since header save offsets to messages.
|
245 |
+
message_count += 1
|
246 |
+
first_offsets.append(pointer)
|
247 |
+
|
248 |
+
pointer += 1
|
249 |
+
|
250 |
+
# Okay, now is the time for getting arguments length!
|
251 |
+
line = in_file.readline()
|
252 |
+
argument_list = json.loads(line)
|
253 |
+
if self.command_library[command_index][0] == 0x19: # For this to not cause any errors.
|
254 |
+
argument_list[0] = 0
|
255 |
+
argument_bytes = self.set_args(argument_list, self.command_library[command_index][1], self.encoding)
|
256 |
+
pointer += len(argument_bytes)
|
257 |
+
|
258 |
+
elif line[1] == '2': # If label (of true offset).
|
259 |
+
offset_array = []
|
260 |
+
|
261 |
+
offset_number = int(line[3:-1])
|
262 |
+
offset_array.append(offset_number)
|
263 |
+
offset_array.append(pointer)
|
264 |
+
|
265 |
+
offsets.append(offset_array)
|
266 |
+
|
267 |
+
elif line[1] == '3': # If special header's label.
|
268 |
+
second_offsets.append(pointer)
|
269 |
+
in_file.close()
|
270 |
+
|
271 |
+
prm[0] = message_count
|
272 |
+
prm[1] = len(second_offsets)
|
273 |
+
|
274 |
+
return prm, first_offsets, second_offsets, offsets
|
275 |
+
|
276 |
+
# Technical methods for disassembling.
|
277 |
+
|
278 |
+
def _disassemble_commands(self) -> None:
|
279 |
+
"""Disassemble Silky Engine mes script commands."""
|
280 |
+
commands = []
|
281 |
+
args = []
|
282 |
+
# [Opcode, struct, name].
|
283 |
+
pointer = self.get_true_offset(0)
|
284 |
+
stringer = ''
|
285 |
+
these_indices = []
|
286 |
+
|
287 |
+
out_file = open(self._txt_name, 'w', encoding=self.encoding)
|
288 |
+
in_file = open(self._mes_name, 'rb')
|
289 |
+
in_file.seek(pointer, 0)
|
290 |
+
|
291 |
+
sorted_offset = sorted(list(enumerate(self._offsets)), key=lambda x: x[1])
|
292 |
+
# Sorted by offsets, but with index saving.
|
293 |
+
search_offset = [i[1] for i in sorted_offset]
|
294 |
+
initial_sorted_offset = sorted_offset.copy()
|
295 |
+
initial_search_offset = search_offset.copy()
|
296 |
+
# I know, you may say it's pointless, but that's for the sake of optimization.
|
297 |
+
|
298 |
+
second_offsets = [self.get_true_offset(i) for i in self._second_offsets]
|
299 |
+
|
300 |
+
while True:
|
301 |
+
pointer = in_file.tell() # To get current position before the command.
|
302 |
+
|
303 |
+
# Offsets functionality.
|
304 |
+
# I did try my best to optimize it. It may be looked as bad, but...
|
305 |
+
# I have managed to drastically decrease the number of iterations.
|
306 |
+
# From some hundreds to about 1-2.
|
307 |
+
these_indices.clear()
|
308 |
+
speedy_crutch = -1
|
309 |
+
for pos, offset in sorted_offset:
|
310 |
+
speedy_crutch += 1
|
311 |
+
if pointer == offset:
|
312 |
+
these_indices.append(speedy_crutch)
|
313 |
+
if self._debug:
|
314 |
+
out_file.write("#2-{} {}\n".format(pos, pointer))
|
315 |
+
else:
|
316 |
+
out_file.write("#2-{}\n".format(pos))
|
317 |
+
break
|
318 |
+
elif pointer > offset:
|
319 |
+
break
|
320 |
+
for used in these_indices:
|
321 |
+
sorted_offset.pop(used)
|
322 |
+
search_offset.pop(used)
|
323 |
+
for offset in second_offsets: # Should be fine since it is rare and not lengthy.
|
324 |
+
if pointer == offset:
|
325 |
+
if self._debug:
|
326 |
+
out_file.write("#3 {}\n".format(pointer))
|
327 |
+
else:
|
328 |
+
out_file.write("#3\n")
|
329 |
+
break
|
330 |
+
|
331 |
+
# Commands functionality.
|
332 |
+
|
333 |
+
current_byte = in_file.read(1)
|
334 |
+
if current_byte == b'':
|
335 |
+
break
|
336 |
+
current_byte = current_byte[0]
|
337 |
+
args.append([])
|
338 |
+
commands.append(current_byte)
|
339 |
+
analyzer = str(hex(current_byte))[2:]
|
340 |
+
if (len(analyzer) == 1):
|
341 |
+
analyzer = '0' + analyzer
|
342 |
+
|
343 |
+
lib_index = -1
|
344 |
+
for i in range(len(self.command_library)):
|
345 |
+
if current_byte == self.command_library[i][0]:
|
346 |
+
lib_index = i
|
347 |
+
break
|
348 |
+
if lib_index != -1:
|
349 |
+
if stringer != '':
|
350 |
+
stringer = stringer.lstrip(' ')
|
351 |
+
stringer = '#0-{}\n'.format(stringer)
|
352 |
+
out_file.write(stringer)
|
353 |
+
stringer = ''
|
354 |
+
|
355 |
+
out_file.write("#1-")
|
356 |
+
if self.command_library[lib_index][2] == '':
|
357 |
+
out_file.write(analyzer)
|
358 |
+
else:
|
359 |
+
if self.command_library[lib_index][2] == 'STR_CRYPT':
|
360 |
+
out_file.write('STR_UNCRYPT')
|
361 |
+
else:
|
362 |
+
out_file.write(self.command_library[lib_index][2])
|
363 |
+
if self._debug:
|
364 |
+
out_file.write(' {}\n'.format(pointer))
|
365 |
+
else:
|
366 |
+
out_file.write('\n')
|
367 |
+
|
368 |
+
arguments_list = self.get_args(in_file, self.command_library[lib_index][1], current_byte, self.encoding)
|
369 |
+
|
370 |
+
what_index = -1
|
371 |
+
for entry_pos, offsets_entry in enumerate(self.offsets_library):
|
372 |
+
if current_byte == offsets_entry[0]:
|
373 |
+
what_index = entry_pos
|
374 |
+
|
375 |
+
if what_index != -1:
|
376 |
+
first_indexer = self.offsets_library[what_index][1]
|
377 |
+
evil_offset = self.get_true_offset(arguments_list[first_indexer])
|
378 |
+
indexer = initial_search_offset.index(evil_offset)
|
379 |
+
arguments_list[first_indexer] = initial_sorted_offset[indexer][0]
|
380 |
+
|
381 |
+
if self.command_library[lib_index][0] == 0x19:
|
382 |
+
arguments_list[0] = "*MESSAGE_NUMBER*"
|
383 |
+
json.dump(arguments_list, out_file, ensure_ascii=False)
|
384 |
+
out_file.write('\n')
|
385 |
+
|
386 |
+
else:
|
387 |
+
stringer += ' ' + analyzer
|
388 |
+
pointer += 1
|
389 |
+
if stringer != '': # Print remaining free bytes.
|
390 |
+
stringer = stringer.lstrip(' ')
|
391 |
+
stringer = '#0-' + stringer
|
392 |
+
out_file.write(stringer)
|
393 |
+
|
394 |
+
out_file.close()
|
395 |
+
|
396 |
+
def _diss_other_offsets(self) -> None:
|
397 |
+
"""Disassemble other offsets from the Silky Engine script."""
|
398 |
+
pointer = self.get_true_offset(0)
|
399 |
+
in_file = open(self._mes_name, 'rb')
|
400 |
+
in_file.seek(pointer, 0)
|
401 |
+
|
402 |
+
if self._hackerman_mode:
|
403 |
+
out_file = open("HACK.txt", 'w', encoding=self.encoding)
|
404 |
+
|
405 |
+
while True:
|
406 |
+
pointer = in_file.tell()
|
407 |
+
current_byte = in_file.read(1)
|
408 |
+
if current_byte == b'':
|
409 |
+
break
|
410 |
+
current_byte = current_byte[0] # Get int from byte in the fastest way possible.
|
411 |
+
lib_index = -1
|
412 |
+
for i in range(len(self.command_library)):
|
413 |
+
if (current_byte == self.command_library[i][0]):
|
414 |
+
lib_index = i
|
415 |
+
break
|
416 |
+
if lib_index != -1:
|
417 |
+
arguments_list = self.get_args(in_file, self.command_library[lib_index][1], current_byte,
|
418 |
+
self.encoding)
|
419 |
+
|
420 |
+
if self._hackerman_mode:
|
421 |
+
out_file.write("#1-{} {}\n".format(hex(current_byte), pointer))
|
422 |
+
out_file.write(str(arguments_list))
|
423 |
+
out_file.write("\n")
|
424 |
+
|
425 |
+
what_index = -1
|
426 |
+
for entry_pos, offsets_entry in enumerate(self.offsets_library):
|
427 |
+
if current_byte == offsets_entry[0]:
|
428 |
+
what_index = entry_pos
|
429 |
+
if what_index != -1:
|
430 |
+
not_here = True
|
431 |
+
good_offset = self.get_true_offset(arguments_list[self.offsets_library[what_index][1]])
|
432 |
+
for i in range(len(self._offsets)):
|
433 |
+
if good_offset == self._offsets[i]:
|
434 |
+
not_here = False
|
435 |
+
if not_here:
|
436 |
+
self._offsets.append(good_offset)
|
437 |
+
else:
|
438 |
+
if self._hackerman_mode:
|
439 |
+
out_file.write("#0-{} {}\n".format(hex(current_byte), pointer))
|
440 |
+
|
441 |
+
in_file.close()
|
442 |
+
if self._hackerman_mode:
|
443 |
+
out_file.close()
|
444 |
+
|
445 |
+
def _diss_header(self) -> tuple:
|
446 |
+
"""Disassemble Silky Engine mes header."""
|
447 |
+
first_offsets = []
|
448 |
+
second_offsets = []
|
449 |
+
with open(self._mes_name, 'rb') as mes_file:
|
450 |
+
prm = list(struct.unpack('II', mes_file.read(8)))
|
451 |
+
for i in range(prm[0]):
|
452 |
+
first_offsets.append(struct.unpack('I', mes_file.read(4))[0])
|
453 |
+
for i in range(prm[1]):
|
454 |
+
second_offsets.append(struct.unpack('I', mes_file.read(4))[0])
|
455 |
+
|
456 |
+
return prm, first_offsets, second_offsets
|
457 |
+
|
458 |
+
# Offsets methods.
|
459 |
+
|
460 |
+
def get_true_offset(self, raw_offset: int) -> int:
|
461 |
+
"""Get true offset (as it is factically in the file)."""
|
462 |
+
return raw_offset + self._prm[0] * 4 + self._prm[1] * 4 + 8
|
463 |
+
|
464 |
+
def set_true_offset(self, raw_offset):
|
465 |
+
"""Set true offset (as it is factically in the arguments)."""
|
466 |
+
return raw_offset - self._prm[0] * 4 - self._prm[1] * 4 - 8
|
467 |
+
|
468 |
+
# Structure packing technicals methods.
|
469 |
+
|
470 |
+
@staticmethod
|
471 |
+
def set_args(argument_list, args: str, current_encoding: str) -> bytes:
|
472 |
+
args_bytes = b''
|
473 |
+
appendix = ""
|
474 |
+
current_argument = 0
|
475 |
+
for argument in args: # self.command_library[lib_index][1]
|
476 |
+
if argument in SilkyMesScript.technical_instances:
|
477 |
+
appendix = argument
|
478 |
+
continue
|
479 |
+
|
480 |
+
# argument number changing.
|
481 |
+
|
482 |
+
if argument in SilkyMesScript.set_I.instances:
|
483 |
+
args_bytes += SilkyMesScript.set_I(argument_list[current_argument], appendix+argument)
|
484 |
+
elif argument in SilkyMesScript.set_H.instances:
|
485 |
+
args_bytes += SilkyMesScript.set_H(argument_list[current_argument], appendix+argument)
|
486 |
+
elif argument in SilkyMesScript.set_B.instances:
|
487 |
+
args_bytes += SilkyMesScript.set_B(argument_list[current_argument], appendix+argument)
|
488 |
+
elif argument in SilkyMesScript.set_S.instances:
|
489 |
+
args_bytes += SilkyMesScript.set_S(argument_list[current_argument], current_encoding)
|
490 |
+
current_argument += 1 # Since argument may not change with new command.
|
491 |
+
|
492 |
+
return args_bytes
|
493 |
+
|
494 |
+
@staticmethod
|
495 |
+
def set_B(arguments: int, command: str) -> bytes:
|
496 |
+
return struct.pack(command, arguments)
|
497 |
+
|
498 |
+
@staticmethod
|
499 |
+
def set_H(arguments: int, command: str) -> bytes:
|
500 |
+
return struct.pack(command, arguments)
|
501 |
+
|
502 |
+
@staticmethod
|
503 |
+
def set_I(arguments: int, command: str) -> bytes:
|
504 |
+
return struct.pack(command, arguments)
|
505 |
+
|
506 |
+
@staticmethod
|
507 |
+
def set_S(arguments: str, encoding: str) -> bytes:
|
508 |
+
arg_bytes = arguments.encode(encoding) + b'\x00'
|
509 |
+
return arg_bytes
|
510 |
+
|
511 |
+
# Structure extraction technical methods.
|
512 |
+
|
513 |
+
@staticmethod
|
514 |
+
def get_args(in_file, args: str, current_byte: int, current_encoding: str) -> list:
|
515 |
+
arguments_list = []
|
516 |
+
appendix = ""
|
517 |
+
for argument in args: # self.command_library[lib_index][1]
|
518 |
+
if argument in SilkyMesScript.technical_instances:
|
519 |
+
appendix = argument
|
520 |
+
elif argument in SilkyMesScript.get_I.instances:
|
521 |
+
arguments_list.append(SilkyMesScript.get_I(in_file, appendix+argument))
|
522 |
+
elif argument in SilkyMesScript.get_H.instances:
|
523 |
+
arguments_list.append(SilkyMesScript.get_H(in_file, appendix+argument))
|
524 |
+
elif argument in SilkyMesScript.get_B.instances:
|
525 |
+
arguments_list.append(SilkyMesScript.get_B(in_file, appendix+argument))
|
526 |
+
elif argument in SilkyMesScript.get_S.instances:
|
527 |
+
leng, result = SilkyMesScript.get_S(current_byte, in_file, current_encoding)
|
528 |
+
arguments_list.append(result)
|
529 |
+
return arguments_list
|
530 |
+
|
531 |
+
@staticmethod
|
532 |
+
def get_B(file_in, definer: str) -> int:
|
533 |
+
"""Extract B/b structure."""
|
534 |
+
dummy = struct.unpack(definer, file_in.read(1))[0]
|
535 |
+
return dummy
|
536 |
+
|
537 |
+
@staticmethod
|
538 |
+
def get_H(file_in, definer: str) -> int:
|
539 |
+
"""Extract H/h structure."""
|
540 |
+
dummy = struct.unpack(definer, file_in.read(2))[0]
|
541 |
+
return dummy
|
542 |
+
|
543 |
+
@staticmethod
|
544 |
+
def get_I(file_in, definer: str) -> int:
|
545 |
+
"""Extract I/i structure."""
|
546 |
+
dummy = struct.unpack(definer, file_in.read(4))[0]
|
547 |
+
return dummy
|
548 |
+
|
549 |
+
@staticmethod
|
550 |
+
def get_S(mode: int, in_file, encoding: str) -> tuple:
|
551 |
+
"""Get string from the mode and input file (pointer at the start of stirng)."""
|
552 |
+
# 0x0A, 0x0B, 0x33.
|
553 |
+
length = 0
|
554 |
+
string = b''
|
555 |
+
byte = in_file.read(1)
|
556 |
+
while byte != b'\x00':
|
557 |
+
string += byte
|
558 |
+
length += 1
|
559 |
+
byte = in_file.read(1)
|
560 |
+
|
561 |
+
if mode == 0x0A:
|
562 |
+
# list_bytes = string.hex(' ').split(' ')
|
563 |
+
# string = b''
|
564 |
+
# i = 0
|
565 |
+
# while i < len(list_bytes):
|
566 |
+
# number = int(list_bytes[i], 16)
|
567 |
+
# if number < 0x81:
|
568 |
+
# zlo = number - 0x7D62
|
569 |
+
# high = (zlo & 0xff00) >> 8
|
570 |
+
# low = zlo & 0xff
|
571 |
+
# marbas = str(hex(high))[2:]
|
572 |
+
# if len(marbas) == 1:
|
573 |
+
# marbas = "0" + marbas
|
574 |
+
# string += byte.fromhex(marbas)
|
575 |
+
# marbas = str(hex(low))[2:]
|
576 |
+
# if len(marbas) == 1:
|
577 |
+
# marbas = "0" + marbas
|
578 |
+
# string += byte.fromhex(marbas)
|
579 |
+
# i += 1
|
580 |
+
# else:
|
581 |
+
# high = int(list_bytes[i], 16)
|
582 |
+
# marbas = str(hex(high))[2:]
|
583 |
+
# if len(marbas) == 1:
|
584 |
+
# marbas = "0" + marbas
|
585 |
+
# string += byte.fromhex(marbas)
|
586 |
+
# if (i + 1) < len(list_bytes):
|
587 |
+
# i += 1
|
588 |
+
# low = int(list_bytes[i], 16)
|
589 |
+
# marbas = str(hex(low))[2:]
|
590 |
+
# if len(marbas) == 1:
|
591 |
+
# marbas = "0" + marbas
|
592 |
+
# string += byte.fromhex(marbas)
|
593 |
+
# i += 1
|
594 |
+
try:
|
595 |
+
return length, (string.decode(encoding))
|
596 |
+
except UnicodeDecodeError:
|
597 |
+
print("Decode error:", string)
|
598 |
+
return length, string.hex(' ')
|
599 |
+
elif (mode == 0x33) or (mode == 0x0B):
|
600 |
+
try:
|
601 |
+
return length, string.decode(encoding)
|
602 |
+
except UnicodeDecodeError:
|
603 |
+
print("Decode error:", string)
|
604 |
+
return length, string
|
605 |
+
else:
|
606 |
+
return length, string
|
607 |
+
|
608 |
+
|
609 |
+
class SilkyMesArchiveError(Exception):
|
610 |
+
def __init__(self, message: str):
|
611 |
+
self.message = message
|
612 |
+
super().__init__(message)
|
v-corpus-zh/Silky'sPlus/流景之海的艾佩理雅/本体@萌AI同好会/流景之海的艾佩理雅_mes.py
ADDED
@@ -0,0 +1,196 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
def get_all_files_in_directory(directory, ext=''):
|
2 |
+
import os
|
3 |
+
import re
|
4 |
+
custom_sort_key_re = re.compile('([0-9]+)')
|
5 |
+
|
6 |
+
def custom_sort_key(s):
|
7 |
+
# 将字符串中的数字部分转换为整数,然后进行排序
|
8 |
+
return [int(x) if x.isdigit() else x for x in custom_sort_key_re.split(s)]
|
9 |
+
|
10 |
+
all_files = []
|
11 |
+
for root, dirs, files in os.walk(directory):
|
12 |
+
for file in files:
|
13 |
+
if file.endswith(ext):
|
14 |
+
file_path = os.path.join(root, file)
|
15 |
+
all_files.append(file_path)
|
16 |
+
return sorted(all_files, key=custom_sort_key)
|
17 |
+
|
18 |
+
|
19 |
+
def clearT():
|
20 |
+
import unicodedata
|
21 |
+
from opencc import OpenCC
|
22 |
+
|
23 |
+
def full2half(input_str):
|
24 |
+
return ''.join([unicodedata.normalize('NFKC', char) for char in input_str])
|
25 |
+
|
26 |
+
cc = OpenCC('t2s') # 't2s'表示繁体转简体
|
27 |
+
|
28 |
+
def _clearT(s):
|
29 |
+
s = cc.convert(full2half(s))
|
30 |
+
return s.strip().strip(r'\n').replace('\n', '\\n')
|
31 |
+
|
32 |
+
return _clearT
|
33 |
+
|
34 |
+
|
35 |
+
clearT = clearT()
|
36 |
+
|
37 |
+
# =================
|
38 |
+
|
39 |
+
a = get_all_files_in_directory(r'E:\tmp\Apeiria\txt', ext='.txt')
|
40 |
+
b = r'D:\datasets\tmp'
|
41 |
+
|
42 |
+
# =================
|
43 |
+
|
44 |
+
sc = {}
|
45 |
+
|
46 |
+
_n = {
|
47 |
+
"零一": "零一",
|
48 |
+
"艾佩理雅": "艾佩理雅",
|
49 |
+
"女孩": "女孩",
|
50 |
+
"女孩&零一": "女孩&零一",
|
51 |
+
"三羽": "三羽",
|
52 |
+
"久远": "久远",
|
53 |
+
"???": "?",
|
54 |
+
"抖M变态": "抖M变态",
|
55 |
+
"真白": "真白",
|
56 |
+
"久远&真白": "久远&真白",
|
57 |
+
"Thinker": "Thinker",
|
58 |
+
"护士": "护士",
|
59 |
+
"七海": "七海",
|
60 |
+
"沙罗": "沙罗",
|
61 |
+
"AI": "AI",
|
62 |
+
"工作人员": "工作人员",
|
63 |
+
"零一&久远": "零一&久远",
|
64 |
+
"奇美拉": "奇美拉",
|
65 |
+
"继母": "继母",
|
66 |
+
"主治医生": "主治医生",
|
67 |
+
"空观": "空观",
|
68 |
+
"永久子": "永久子",
|
69 |
+
"警报": "警报",
|
70 |
+
"老爸": "老爸",
|
71 |
+
"急救队员": "急救队员",
|
72 |
+
"医师": "医师",
|
73 |
+
"病毒": "病毒",
|
74 |
+
"AV女优": "AV女优",
|
75 |
+
"零一&三羽": "零一&三羽",
|
76 |
+
"列车长": "列车长",
|
77 |
+
"三羽&零一": "三羽&零一",
|
78 |
+
"众人": "众人",
|
79 |
+
"Kosmos": "Kosmos",
|
80 |
+
"武器店老板": "武器店老板",
|
81 |
+
"龙": "龙",
|
82 |
+
"龙&真白": "龙&真白",
|
83 |
+
"龙&久远": "龙&久远",
|
84 |
+
"男性冒险者": "男性冒险者",
|
85 |
+
"克里斯蒂娜": "克里斯蒂娜",
|
86 |
+
"艾佩理雅&真白&久远&三羽": "艾佩理雅&真白&久远&三羽",
|
87 |
+
"万龙之母": "万龙之母",
|
88 |
+
"万龙之母&真白": "万龙之母&真白",
|
89 |
+
"零一&久远&三羽&艾佩理雅": "零一&久远&三羽&艾佩理雅",
|
90 |
+
"村姑": "村姑",
|
91 |
+
"酒吧的看板娘": "酒吧的看板娘",
|
92 |
+
"男冒险者": "男冒险者",
|
93 |
+
"武士": "武士",
|
94 |
+
"女骑士": "女骑士",
|
95 |
+
"正圆": "正圆",
|
96 |
+
"五人": "五人",
|
97 |
+
"新闻": "新闻",
|
98 |
+
"接线员": "接线员",
|
99 |
+
"骑士1": "骑士1",
|
100 |
+
"骑士2": "骑士2",
|
101 |
+
"骑士3": "骑士3",
|
102 |
+
"零一&女骑士": "零一&女骑士",
|
103 |
+
"剑士": "剑士",
|
104 |
+
"战士": "战士",
|
105 |
+
"魔法师": "魔法师",
|
106 |
+
"威严的男人": "威严的男人",
|
107 |
+
"Bookman": "Bookma",
|
108 |
+
"零一&Bookman": "零一&Bookma",
|
109 |
+
"真白&久远": "真白&久远",
|
110 |
+
"Scholar1": "Scholar1",
|
111 |
+
"Scholar2": "Scholar2",
|
112 |
+
"众骑士": "众骑士",
|
113 |
+
"艾佩理雅&久远&三羽&真白": "艾佩理雅&久远&三羽&真白",
|
114 |
+
"骑士1&骑士2&骑士3": "骑士1&骑士2&骑士3",
|
115 |
+
"沙罗&零一": "沙罗&零一",
|
116 |
+
"沙罗&七海": "沙罗&七海",
|
117 |
+
"Scholar": "Scholar",
|
118 |
+
"精灵们": "精灵们",
|
119 |
+
"Kosmos&真白": "Kosmos&真白",
|
120 |
+
"Kosmos&久远": "Kosmos&久远",
|
121 |
+
"零一&久远&艾佩理雅": "零一&久远&艾佩理雅",
|
122 |
+
"上古巨岩": "上古巨岩",
|
123 |
+
"零一&三羽&艾佩理雅": "零一&三羽&艾佩理雅",
|
124 |
+
"零一&艾佩理雅&三羽": "零一&艾佩理雅&三羽",
|
125 |
+
"Kosmos&三羽": "Kosmos&三羽",
|
126 |
+
"看起来像魔法使的女人": "看起来像魔法使的女人",
|
127 |
+
"七海&沙罗": "七海&沙罗",
|
128 |
+
"Adenine": "Adenine",
|
129 |
+
"Thymine": "Thymine",
|
130 |
+
"Guanine": "Guanine",
|
131 |
+
"Cytosine": "Cytosine",
|
132 |
+
}
|
133 |
+
|
134 |
+
# =================
|
135 |
+
for path in a:
|
136 |
+
name = path[path.rindex('\\'):]
|
137 |
+
name = name[:4]
|
138 |
+
if name not in sc:
|
139 |
+
sc[name] = []
|
140 |
+
print(name)
|
141 |
+
# =================
|
142 |
+
|
143 |
+
with open(path, 'r', encoding='gbk') as f:
|
144 |
+
data = [x.strip() for x in f.readlines()]
|
145 |
+
|
146 |
+
w_i = -1
|
147 |
+
nn = '旁白'
|
148 |
+
while w_i < len(data) - 1:
|
149 |
+
w_i += 1
|
150 |
+
line = data[w_i]
|
151 |
+
if line.endswith('STR_UNCRYPT'):
|
152 |
+
w_i += 1
|
153 |
+
line = data[w_i]
|
154 |
+
line = eval(line)
|
155 |
+
assert len(line) == 1
|
156 |
+
line = line[0]
|
157 |
+
# print(nn, line)
|
158 |
+
# if line.startswith('「'):
|
159 |
+
# assert nn != '旁白'
|
160 |
+
line = clearT(line)
|
161 |
+
if not line:
|
162 |
+
continue
|
163 |
+
sc[name].append(nn + ':' + line)
|
164 |
+
if line.endswith('」'):
|
165 |
+
nn = '旁白'
|
166 |
+
elif line.endswith('PUSH_STR'):
|
167 |
+
w_i += 1
|
168 |
+
line = data[w_i]
|
169 |
+
n = eval(line)
|
170 |
+
assert len(n) == 1
|
171 |
+
n = n[0]
|
172 |
+
if (n.isascii() and '.' in n) or '.ogg' in n:
|
173 |
+
continue
|
174 |
+
if n in _n:
|
175 |
+
nn = _n[n]
|
176 |
+
else:
|
177 |
+
# _n[n] = clearT(n)
|
178 |
+
if not n.isascii():
|
179 |
+
# sc[name].append('旁白:' + clearT(n))
|
180 |
+
pass
|
181 |
+
elif line.startswith('#'):
|
182 |
+
w_i += 1
|
183 |
+
else:
|
184 |
+
continue
|
185 |
+
|
186 |
+
|
187 |
+
# =================
|
188 |
+
|
189 |
+
for k, v in sc.items():
|
190 |
+
if v:
|
191 |
+
with open(b + f'\\{k}.txt', 'w', encoding='utf-8') as f:
|
192 |
+
f.write('\n'.join(v))
|
193 |
+
|
194 |
+
# =================
|
195 |
+
import json
|
196 |
+
tmp = json.dumps(_n, ensure_ascii=False, indent=4)
|