Skip to content

Commit

Permalink
i18n deck reader
Browse files Browse the repository at this point in the history
  • Loading branch information
SkywalkerJi committed Feb 1, 2022
1 parent 8939e64 commit a27ee84
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 24 deletions.
38 changes: 29 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Yu-Gi-Oh! Master Duel Translation Script

* 自动切换,自动查卡,全面覆盖Deck、Duel、Solo、Replay模式。
* 一键导出Master Duel游戏卡组,支持ygopro格式。
* 高正确性,除非卡片数据本身有错。
* 超快识别速度,低于0.000001s。
* 极低占用,CPU占用忽略不计。
Expand Down Expand Up @@ -34,7 +35,7 @@ Yu-Gi-Oh! Master Duel Translation Script
1. 打开游戏。
2. 右键使用**管理员权限**运行`mdt.exe`
3. 在组卡界面点击一张卡。
4. 右键可打开设置。繁体中文用户右键切换语言。
4. 右键可打开更多功能。繁体中文用户右键切换语言。

**使用预打包的CLI版本**

Expand Down Expand Up @@ -169,6 +170,18 @@ python mdt_cli.py
不会。我第一赛季是白金1结算。另外这个游戏没有反作弊,从经济角度考虑一个99%依赖服务端的游戏根本必要进行检测,参考游戏王duel link。
</details>

<details>
<summary>Q4:CLI版本是否还会进行后续开发?</summary>
CLI版本在MDT v0.2.3版本进行拆分,拆分后对CLI版本只做基础可用性维护,原则上不再添加新功能。
</details>

<details>
<summary>Q4:使用MDT时需要注意什么?</summary>
请遵循[GPLv3协议](https://github.com/SkywalkerJi/mdt/blob/master/LICENSE)

如果你参与我们的社区,请遵循[贡献者契约行为准则](https://github.com/SkywalkerJi/mdt/blob/master/CODE_OF_CONDUCT.md)
</details>

## Contributing

有其他指针或功能欢迎提交[issue](https://github.com/SkywalkerJi/mdt/issues/new)或Pull Request。
Expand All @@ -178,29 +191,32 @@ python mdt_cli.py
如果你有错误报告、建议、想法,请随时通过以下方式联系开发者:

* [issue](https://github.com/SkywalkerJi/mdt/issues/new)
* [Telegram](https://t.me/KancolleRTA_bot)
* [Twitter](https://twitter.com/Skywalker_Ji)
* [NGA](https://bbs.nga.cn/read.php?tid=30415633)
* [巴哈姆特](https://forum.gamer.com.tw/C.php?bsn=725&snA=54550&tnum=1)
* [Q群 710144213](https://jq.qq.com/?_wv=1027&k=uyFt3qi0)
* [Telegram](https://t.me/ygomasterduel)
* [Twitter](https://twitter.com/Skywalker_Ji)
* 或其他途径。

## Changelog

*v0.2.5*
* 添加无边框窗口支持。
* 悬停时添加右键提示。
* 拆分英日文卡名和卡类型显示选项,现在可以分别勾选。
* 支持masterduel卡组一键导出!由 @zealyahweh 贡献。可同时生成ygopro卡组`.ydk`格式和文本格式。
* 拆分英日文卡名和卡类型显示选项,现在可以分别勾选“原始卡名”和“卡片类型”。
* 主题配色改为暗色。
* 添加无边框模式,可更好融入游戏。
* 窗口整体可拖拽。
* 右键添加关闭选项。
* 鼠标悬停时添加右键提示。

<details>
<summary>展开过往版本</summary>

*v0.2.4*
* 添加对繁体中文的i18n支持。右键可以切换语言。UI文本由 @ranke96 贡献,卡片翻译来自 @stillfiy0529
* 针对重启游戏后无法检测的问题,可以右键重启检测。
* 未查询到卡片的状态下不再唤起网页卡查。

<details>
<summary>展开过往版本</summary>

*v0.2.3*
* 拆分GUI版本和CLI版本。
* 添加详情显示选项。关闭后只显示中文卡名+效果描述。
Expand Down Expand Up @@ -295,6 +311,10 @@ python mdt_cli.py

[GNU General Public License v3.0](https://github.com/SkywalkerJi/mdt/blob/master/LICENSE)

## Code of conduct

[Contributor Covenant Code of Conduct](https://github.com/SkywalkerJi/mdt/blob/master/CODE_OF_CONDUCT.md)

## Disclaimers

<ins>This project is not affiliated with or sponsored by Konami or its licensors.</ins>
Expand Down
9 changes: 8 additions & 1 deletion locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@
"无边框": "无边框",
"功能 & 设置": "功能 & 设置",
"保存卡组": "保存卡组",
"右键选择更多功能": "右键选择更多功能"
"右键选择更多功能": "右键选择更多功能",
"无法读取卡组信息": "无法读取卡组信息",
"主卡组": "主卡组",
"查无此卡": "查无此卡",
"该卡信息有缺失": "该卡信息有缺失",
"ygopro卡组": "ygopro卡组",
"卡组文本": "卡组文本",
"额外卡组": "额外卡组"
}
}
9 changes: 8 additions & 1 deletion locales/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@
"无边框": "無邊框",
"功能 & 设置": "功能 & 設定",
"保存卡组": "保存牌組",
"右键选择更多功能": "右鍵選擇更多功能"
"右键选择更多功能": "右鍵選擇更多功能",
"无法读取卡组信息": "無法讀取牌組資訊",
"主卡组": "主牌組",
"查无此卡": "查無此卡",
"该卡信息有缺失": "缺少此卡資訊",
"ygopro卡组": "ygopro牌組",
"卡组文本": "牌組文本",
"额外卡组": "額外牌組"
}
}
15 changes: 8 additions & 7 deletions mdt_deck_reader.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pymem
import json

import i18n
_ = i18n.t

def pointer_to_address(process, base, offsets):
offset_final = offsets.pop()
Expand Down Expand Up @@ -61,7 +62,7 @@ def get_deck_dict():
ma_cards_offsets = [0xB8, 0x00, 0xF8, 0x1C0, 0x90, 0x10, 0x20]
ex_cards_static = 0x01CCD278
ex_cards_offsets = [0xB8, 0x00, 0xF8, 0x1C0, 0x98, 0x10, 0x20]
deck_dict = {"error": "无法读取卡组信息"}
deck_dict = {"error": _("无法读取卡组信息")}
try:
pm = get_process(main_name)
base_address = get_base_address(pm, module_name)
Expand Down Expand Up @@ -99,15 +100,15 @@ def get_deck_dict():
return deck_dict


def get_deck_string():
db_name = "./locales/zh-CN/cards.json"
def get_deck_string(locale: str):
db_name = "./locales/"+locale+"/cards.json"
deck_string = ""
try:
cards_db = get_database(db_name)
deck = get_deck_dict()
except Exception as e:
print(e)
deck_string += "无法读取卡组信息"
deck_string += _("无法读取卡组信息")
return deck_string

deck_string += f"----------------主卡组: {deck['ma_count']}----------------\n"
Expand All @@ -125,7 +126,7 @@ def get_deck_string():
card_string += f"{card_info['jp_name']} "
card_string += f"{card_info['en_name']}"
except:
card_string += " 该卡信息有缺失"
card_string += " "+"该卡信息有缺失"
deck_string += f"{c:<2} {card_string}\n"

deck_string += f"----------------额外卡组: {deck['ex_count']}----------------\n"
Expand All @@ -143,7 +144,7 @@ def get_deck_string():
card_string += f"{card_info['jp_name']} "
card_string += f"{card_info['en_name']}"
except:
card_string += " 该卡信息有缺失"
card_string += " "+"该卡信息有缺失"
deck_string += f"{c:<2} {card_string}\n"

return deck_string
Expand Down
8 changes: 4 additions & 4 deletions mdt_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,20 +592,20 @@ def main():
set_ui_lock(settings_win, True)
else:
set_ui_lock(settings_win, False)
elif ev == "保存卡组":
elif ev == _("保存卡组"):
now = time.strftime("%Y%m%d%H%M%S", time.localtime(time.time()))
deck = service.get_deck_dict()
deck_string = service.get_deck_string()
deck_string = service.get_deck_string(locale)
ydk = "#created by MDT https://github.com/SkywalkerJi/mdt \n#main\n"
for cid in deck["ma_cid_list"]:
ydk += f"{cards_db[str(cid)]['id']}\n"
ydk += "#extra\n"
for cid in deck["ex_cid_list"]:
ydk += f"{cards_db[str(cid)]['id']}\n"
with open("ygopro卡组" + now + ".ydk", "w", encoding="utf8") as f:
with open(_("ygopro卡组") + now + ".ydk", "w", encoding="utf8") as f:
f.write(ydk)
f.close()
with open("卡组文本" + now + ".txt", "w", encoding="utf8") as f:
with open(_("卡组文本") + now + ".txt", "w", encoding="utf8") as f:
f.write(deck_string)
f.close()
service.exit()
Expand Down
4 changes: 2 additions & 2 deletions mdt_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ def get_deck_dict():
return reader.get_deck_dict()


def get_deck_string():
return reader.get_deck_string()
def get_deck_string(locale: str):
return reader.get_deck_string(locale)

0 comments on commit a27ee84

Please sign in to comment.