-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
845 additions
and
414 deletions.
There are no files selected for viewing
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file removed
BIN
-2.12 KB
VPtool编写工具/VPtool-2.11/LANG/__pycache__/custom_lang.cpython-311.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from .zh_cn import zhguitext,zh_func_tc_text,zh_gui_tca_text,zh_func_lse_text | ||
from .custom_lang import zdyguitext,zdyconfig,zdy_gui_tc_text,zdy_gui_tca_text,zdy_gui_lse_text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
def zdyconfig(): | ||
zdy = "繁体中文" | ||
a0 = "0x404" | ||
return zdy,a0 | ||
def zdyguitext(): | ||
info = "*-*<適配版本:1.2.10+>*-*\n項目地址:github-/KlparetlR/Vault-Patcher-Grocery-Store \n專門為VP模組而生的配寘編寫工具github-3093FengMing/VaultPatcher \n作者及版權方:晴笙墨染(莫安)、KlparetlR、捂脸Wulian、3093FengMing,科技輔助:XDawned\nFabric通用:github-LocalizedMC/HardcodeTextPatcher-Fabric \n彈窗使用github-rdbende/Sun-Valley-messageboxes" | ||
a1 ="處理的檔案" | ||
a2 ="選擇要保存的資料夾地址" | ||
a3 ="(必填)" | ||
a4 ="(選填)" | ||
a5 ="你需要選擇一個txt檔案和一個資料夾。" | ||
a6 ="你需要選擇一個txt檔案。" | ||
a7 ="你需要選擇一個資料夾。" | ||
a8 ="GUI語言" | ||
a9 ="保存的資料夾" | ||
a10 ="選擇" | ||
a11 ="翻譯作者-署名" | ||
a12 ="此翻譯名稱" | ||
a13 ="此翻譯描述" | ||
a14 ="翻譯的模組" | ||
a15 ="選定" | ||
a16 ="生成" | ||
a17 ="2.10版-文字轉json" | ||
a18 ="asm版-文字轉json" | ||
a19 ="模組全字串選取" | ||
a20 ="開始運行功能:" | ||
a21 ="功能選擇" | ||
return info,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,a21 | ||
def zdy_gui_tc_text(): | ||
vp1 ="硬編碼配寘" | ||
vp2 ="轉換時出現錯誤!請檢查類匹配的#END有沒有漏!\nERROR for <%s>" | ||
vp3 ="轉換時出現問題!方法名不在類匹配的範圍內!\nERROR for <&%s;>,是否繼續轉化?" | ||
vp4 ="錯誤!檔案路徑遺失!" | ||
vp5 ="VPtool成功將 %s.txt 檔案轉換為 VP或HP模組 的配寘格式。\n並儲存在%s目錄中。" | ||
vp6 = "轉換時出現問題!堆鍵深度值不在類匹配的範圍內!\nERROR for <&%s;>,是否繼續轉化?" | ||
vp7 = "檔案無法訪問,可能是資料夾設為只讀或其它問題!" | ||
return vp1,vp2,vp3,vp4,vp5,vp6,vp7 | ||
def zdy_gui_tca_text(): | ||
vp8 = "key:%s,不在類匹配範圍內,囙此替換不生效,是否跳過該key" | ||
return vp8 | ||
def zdy_gui_lse_text(): | ||
lse1 ="開始工作!(0/3)" | ||
lse2 ="開始選取檔案!(1/3)" | ||
lse3 ="跳過選取步驟" | ||
lse4 ="開始反編譯檔案!(2/3)" | ||
lse5 ="無法訪問,可能是java環境沒設定全或其它問題!" | ||
lse6 ="按回車鍵退出…" | ||
lse7 ="反編譯失敗,因為結果為無!" | ||
lse8 ="跳過該類!" | ||
lse9 ="開始輸出檔案!(3/3)" | ||
lse10 ="輸出檔案至" | ||
lse11 ="模組原始檔案:%s.jar" | ||
lse12 ="輸出Json地址:%s" | ||
lse13 ="臨時Jar緩存資料夾:extracted" | ||
lse14 ="你可以跳過解壓步驟," | ||
lse15 ="通過創建選取的目錄。" | ||
lse16 ="JAVA_HOME:可能不存在,請設定" | ||
lse17 ="按回車鍵繼續…" | ||
lse18 ="完成!" | ||
return lse1,lse2,lse3,lse4,lse5,lse6,lse7,lse8,lse9,lse10,lse11,lse12,lse13,lse14,lse15,lse16,lse17,lse18 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
def zhguitext(): | ||
info = "*-*<适配版本:1.2.10+>*-*\n项目地址:github-KlparetlR/Vault-Patcher-Grocery-Store \n专门为VP模组而生的配置编写工具github-3093FengMing/VaultPatcher\n作者及版权方:晴笙墨染(莫安)、KlparetlR、捂脸Wulian、3093FengMing, 技术辅助:XDawned\nFabric通用github-LocalizedMC/HardcodeTextPatcher-Fabric\n弹窗使用github-rdbende/Sun-Valley-messageboxes" | ||
a1 = "处理的文件" | ||
a2 = "选择要保存的文件夹地址" | ||
a3 = "(必填)" | ||
a4 = "(选填)" | ||
a5 = "你需要选择一个txt文件和一个文件夹。" | ||
a6 = "你需要选择一个txt文件。" | ||
a7 = "你需要选择一个文件夹。" | ||
a8 = "GUI语言" | ||
a9 = "保存的文件夹" | ||
a10 = "选择" | ||
a11 = "翻译作者-署名" | ||
a12 = "此翻译名称" | ||
a13 = "此翻译描述" | ||
a14 = "翻译的模组" | ||
a15 = "选定" | ||
a16 = "生成" | ||
a17 = "2.10版-文本转json" | ||
a18 = "asm版-文本转json" | ||
a19 = "模组全字符串提取" | ||
a20 = "开始运行功能:" | ||
a21 = "功能选择" | ||
return info,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,a21 | ||
def zh_func_tc_text(): | ||
vp1 = "硬编码配置" | ||
vp2 = "转换时出现错误!请检查类匹配的#END有没有漏!\nERROR for <%s>" | ||
vp3 = "转换时出现问题!方法名不在类匹配的范围内!\nERROR for <&%s;>,是否继续转化?" | ||
vp4 = "错误!文件路径丢失!" | ||
vp5 = "VPtool 成功将 %s.txt 文件转换为 VP或HP模组 的配置格式。\n并储存在 %s 目录中。" | ||
vp6 = "转换时出现问题!堆键深度值不在类匹配的范围内!\nERROR for <&%s;>,是否继续转化?" | ||
vp7 = "文件无法访问,可能是文件夹设为只读或其它问题!" | ||
return vp1,vp2,vp3,vp4,vp5,vp6,vp7 | ||
def zh_gui_tca_text(): | ||
vp8 = "key:%s,不在类匹配范围内,因此替换不生效,是否跳过该key" | ||
return vp8 | ||
def zh_func_lse_text(): | ||
lse1 = "开始工作!(0/3)" | ||
lse2 = "开始提取文件!(1/3)" | ||
lse3 = "跳过提取步骤" | ||
lse4 = "开始反编译文件!(2/3)" | ||
lse5 = "无法访问,可能是java环境没设置全或其它问题!" | ||
lse6 = "按回车键退出..." | ||
lse7 = "反编译失败,因为结果为无!" | ||
lse8 = "跳过该类!" | ||
lse9 = "开始输出文件!(3/3)" | ||
lse10 = "输出文件至" | ||
lse11 = "模组源文件: %s.jar" | ||
lse12 = "输出Json地址:%s" | ||
lse13 = "临时Jar缓存文件夹: extracted" | ||
lse14 = "你可以跳过解压步骤," | ||
lse15 = "通过创建提取的目录。" | ||
lse16 = "JAVA_HOME:可能不存在,请设置" | ||
lse17 = "按回车键继续..." | ||
lse18 = "完成!" | ||
return lse1,lse2,lse3,lse4,lse5,lse6,lse7,lse8,lse9,lse10,lse11,lse12,lse13,lse14,lse15,lse16,lse17,lse18 |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from .text_conversion import tc | ||
from .text_conversion_asm import tca | ||
from .ldcStringExtractor import lse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
import os,time,zipfile,re,json | ||
from datetime import datetime | ||
from LANG import zh_func_lse_text,zdy_gui_lse_text,zdyconfig | ||
|
||
class Method: | ||
def __init__(self, name, code): | ||
self.name = name | ||
self.code = code | ||
class Field: | ||
def __init__(self, name): | ||
self.name = name | ||
class Code: | ||
def __init__(self, instructions): | ||
self.instructions = instructions | ||
|
||
def lse(FileGUI,icon_var,cGuilang_entry): | ||
global CONST_SOURCE,CONST_JAR,filePath,fileName | ||
CONST_SOURCE = icon_var | ||
fileName = os.path.basename(os.path.splitext(icon_var)[0]) | ||
CONST_JAR = FileGUI+"/extracted" | ||
filePath = FileGUI+"/output.json" | ||
def runtcGui(): | ||
global zdy,a0,lse1,lse2,lse3,lse4,lse5,lse6,lse7,lse8,lse9,lse10,lse11,lse12,lse13,lse14,lse15,lse16,lse17,lse18 | ||
zdy,a0 = zdyconfig() | ||
if cGuilang_entry == "中文简体": | ||
lse1,lse2,lse3,lse4,lse5,lse6,lse7,lse8,lse9,lse10,lse11,lse12,lse13,lse14,lse15,lse16,lse17,lse18 = zh_func_lse_text() | ||
if cGuilang_entry == f"{zdy}": | ||
lse1,lse2,lse3,lse4,lse5,lse6,lse7,lse8,lse9,lse10,lse11,lse12,lse13,lse14,lse15,lse16,lse17,lse18 = zdy_gui_lse_text() | ||
runtcGui() | ||
aaeeoo() | ||
|
||
logt = '' | ||
def logs(s): | ||
global logt | ||
now = datetime.now() | ||
logt = ''.join([logt, f'[{now.hour:02d}:{now.minute:02d}:{now.second:02d}] {s}\n']) | ||
print(f'[{now.hour:02d}:{now.minute:02d}:{now.second:02d}] {s}') | ||
def parse_string(s): | ||
lines = s.split('\n')[1:] | ||
g = re.search(r'class (.*) {', lines[0]) | ||
if g is None: | ||
return [None, None, None] | ||
class_name = g.group(1) | ||
methods = [] | ||
fields = [] | ||
for i in range(1, len(lines)): | ||
line = lines[i].strip().replace('static {};', 'public staticMethod();') | ||
k = None | ||
if line.startswith('public'): | ||
k = 'public' | ||
elif line.startswith('private'): | ||
k = 'private' | ||
elif line.startswith('protected'): | ||
k = 'protected' | ||
if k is not None: | ||
if '(' in line: | ||
method_name = re.search(k + r' (.*)\(', line).group(1) | ||
code_lines = [] | ||
i += 1 | ||
while not lines[i] == '': | ||
code_lines.append(lines[i]) | ||
i += 1 | ||
code_str = '\n'.join(code_lines) | ||
instructions = re.findall(r'\d+: (.*)', code_str) | ||
code = Code(instructions) | ||
method = Method(method_name, code) | ||
methods.append(method) | ||
elif 'Code:' not in line: | ||
field_name = re.search(k + r' (.*) (.*);', line).group(2) | ||
field = Field(field_name) | ||
fields.append(field) | ||
else: | ||
method_name = re.search(r'(.*);', line).group(1) | ||
code_lines = [] | ||
i += 1 | ||
while not lines[i].startswith('}'): | ||
code_lines.append(lines[i]) | ||
i += 1 | ||
code_str = '\n'.join(code_lines) | ||
instructions = re.findall(r'\d+: (.*)', code_str) | ||
code = Code(instructions) | ||
method = Method(method_name, code) | ||
methods.append(method) | ||
return [class_name, methods, fields] | ||
def main(): | ||
logs(f'{lse1}') | ||
time.sleep(2) | ||
if not os.path.exists("extracted"): | ||
logs(f'{lse2}') | ||
zf = zipfile.ZipFile(CONST_SOURCE) | ||
zf.extractall(path=CONST_JAR) | ||
logs(f'{lse3}') | ||
time.sleep(1) | ||
ar = [{ | ||
"authors": "FengMing", | ||
"name": "ldcStringExtractor-output", | ||
"desc": "Automatically generated by ldcStringExtractor.\nThe output is only for one class", | ||
"mods": f"{fileName}" | ||
}] | ||
logs(f'{lse4}') | ||
for root, dirs, files in os.walk(CONST_JAR): | ||
for f in files: | ||
if os.path.splitext(f)[1] == ".class": | ||
logs("Decompile... {}".format(os.path.join(root, f))) | ||
try: | ||
resultC = os.popen('javap -c "' + os.path.join(root, f) + '"') | ||
except: | ||
logs(f'{lse5}') | ||
input(f'{lse6}') | ||
cms = [] | ||
if resultC is not None: | ||
name, methods, fields = parse_string(resultC.read()) | ||
if name is None or methods is None or fields is None: | ||
resultC.close() | ||
continue | ||
for m in methods: | ||
if ' ' in m.name: | ||
m.name = m.name.split(' ')[-1] | ||
if '.' in m.name: | ||
m.name = '<init>' | ||
if m.name == 'staticMethod': | ||
m.name = '<clinit>' | ||
# logs(m.name + '-----------') | ||
for c in m.code.instructions: | ||
if c.startswith("ldc") or c.startswith("ldc_w"): | ||
pos = c.rfind('// String ') | ||
if pos < 0: | ||
continue | ||
cms.append([name, m.name, c[pos + 10:]]) | ||
# logs(c) | ||
resultC.close() | ||
else: | ||
logs(f"{lse7}") | ||
return | ||
if not cms: | ||
logs(f"{lse8}") | ||
continue | ||
for i in range(0, len(cms)): | ||
ar.append({ | ||
'key': cms[i][2], | ||
'value': "vaultpatcher.modify.ldc" + str(i), | ||
'target_class': { | ||
'name': cms[i][0], | ||
'method': cms[i][1] | ||
} | ||
}) | ||
logs(f'{lse9}') | ||
with open(filePath, "w") as jf: | ||
logs(f'{lse10}{filePath}') | ||
json.dump(ar, jf) | ||
# logs(ar) | ||
def inita(): | ||
logs('--------ldcStringExtractor--------') | ||
logs('By FengMing V1.0') | ||
logs(f'{lse11}' % (fileName)) | ||
logs(f'{lse12}' % (filePath)) | ||
logs(f'{lse13}') | ||
logs(f'{lse14}') | ||
logs(f'{lse15}') | ||
javah = os.environ.get('JAVA_HOME') | ||
if javah: | ||
logs(f'JAVA_HOME: {javah}') | ||
else: | ||
logs(f'{lse16}') | ||
logs('--------ldcStringExtractor--------') | ||
input(f'{lse17}') | ||
def aaeeoo(): | ||
inita() | ||
main() | ||
logs(f'{lse18}') | ||
with open(CONST_JAR+"/logs.txt", "w") as lf: | ||
lf.write(logt) | ||
input(f'{lse6}') |
Oops, something went wrong.