Skip to content

Commit

Permalink
v0.2.17
Browse files Browse the repository at this point in the history
  • Loading branch information
SkywalkerJi committed Jun 11, 2022
1 parent 4a2c12e commit 7dc6f8d
Show file tree
Hide file tree
Showing 5 changed files with 379 additions and 19 deletions.
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Yu-Gi-Oh! Master Duel Translation Script
* i18n,支持简体中文和繁体中文。
* 高兼容性,点开即用,支持各种游戏内语言,最低可支持win7。
* 支持内存检测和图像指纹两种识别模式。
* 一键导出Master Duel游戏卡组,兼容YGOpro格式。同时提供在线转换YGOpro格式导入
* 支持ydk格式卡组导入
* 可一键直达网页卡查和官方数据库,MDT也有 [Secret Pack查询工具](https://ygo.xn--uesr8qr0rdwk.cn/)
* 支持全屏置顶、无边框、半透明。
* 支持对重要UR,主流断点进行警示。
Expand All @@ -27,7 +27,7 @@ Yu-Gi-Oh! Master Duel Translation Script

如果是Windows7系统请下载后缀`_win7`的版本,如果想使用CLI请下载`_CLI`的版本。

中国大陆用户可在 [蓝奏云下载](https://wwi.lanzouj.com/b0176jyjc) 密码:5j6f
中国大陆用户可在 [蓝奏云](https://wwi.lanzouj.com/b0176jyjc) 密码:5j6f 或者 [Microsoft OneDrive](https://1drv.ms/u/s!Apo8OlF1smGK6nS7sXukI9Bt9xOd?e=bbzDea) 分流下载。

你可以通过 [YGO.御坂美琴.CN](https://ygo.xn--uesr8qr0rdwk.cn/) 访问MDT网页工具。

Expand Down Expand Up @@ -354,6 +354,15 @@ CLI版本在MDT v0.2.3版本进行拆分,拆分后对CLI版本只做基础可

## Changelog

*v0.2.17*
* 图像模式更新6月10日新卡hash。by wtof1996
* 修复识别线程失效问题。by chunibyo
* 将效果框置为只读。by funnyvalentine2363
* 去除了失效的卡组导出功能。(可能需要新的实现方式)

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

*v0.2.16*
* 对游戏steam版本V1.1.1进行支持。

Expand All @@ -363,9 +372,6 @@ CLI版本在MDT v0.2.3版本进行拆分,拆分后对CLI版本只做基础可
*v0.2.14 beta*
* 支持4月新卡图像识别。感谢@wtof1996 的贡献。

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

*v0.2.13*
* 自定义BGM支持,在选中一张卡牌时,自动播放BGM或召唤词。样例为青眼亚白龙。可以在设置中开启。
* 分词处理。
Expand Down
2 changes: 1 addition & 1 deletion mdt_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import win32gui
import pyautogui
import pyperclip
from mdt import get_current_cid, status_change
from mdt import get_current_cid
import mdt_deck_reader

from mdt_cv import get_reset_button_postion, get_scale, get_search_button_postion
Expand Down
27 changes: 14 additions & 13 deletions mdt_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def main():
background_color="#3F3F3F",
text_color="white",
write_only=True,
disabled = True,
disabled=True,
auto_refresh=True,
rstrip=True,
no_scrollbar=no_scrollbar,
Expand Down Expand Up @@ -405,7 +405,7 @@ def main():
],
]
window = sg.Window(
"MDT v0.2.16 GPLv3",
"MDT v0.2.17 GPLv3",
card_frame,
default_element_size=(12, 1),
font=("Microsoft YaHei", font_size),
Expand Down Expand Up @@ -437,6 +437,7 @@ def main():
window["-desc-"].Widget.configure(wrap="char")
if cid != cid_temp and cid:
cid_temp = cid
print(cid)
try:
card_t = cards_db[str(cid)]
window["-cn_name-"].update(card_t["cn_name"])
Expand Down Expand Up @@ -715,17 +716,17 @@ def main():
]
]
),
sg.Column(
[
[
sg.Button(
_("导出卡组"),
button_color=("white", "#238636"),
border_width=1,
)
]
]
),
# sg.Column(
# [
# [
# sg.Button(
# _("导出卡组"),
# button_color=("white", "#238636"),
# border_width=1,
# )
# ]
# ]
# ),
sg.Column(
[
[
Expand Down
98 changes: 98 additions & 0 deletions win7/mdt_control.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import time
import win32gui
import pyautogui
import pyperclip
from mdt import get_current_cid
import mdt_deck_reader

from mdt_cv import get_reset_button_postion, get_scale, get_search_button_postion

# pyautogui 强制关闭
pyautogui.FAILSAFE = True

# 1920x1080 分辨率下的偏移量,可以通过分辨率换算进行变换
blank_offset = (0, -150)
clear_offset = (335, 0)
card_offset = (0, 170)
card_width_offset = 89
card_height_offset = 144


def _add(a: tuple, b: tuple, scale=1.0):
return a[0] + b[0] * scale, a[1] + b[1] * scale


def ydk_converter(ydk_deck: list, locale: str, window, callback=None):
"""
Convert YDK deck list to MDT deck.
"""
# TODO: background click
# TODO: 清空当前牌组
# TODO: 等待搜索时间可调
if ydk_deck is None or ydk_deck == []:
return

try:
hWnd = win32gui.FindWindow(None, "masterduel")
win32gui.SetForegroundWindow(hWnd)
box = win32gui.ClientToScreen(hWnd, (0, 0))

scale = get_scale()
# 先横后竖
search = get_search_button_postion()
search = _add(search, box)
reset = get_reset_button_postion()
reset = _add(reset, box)
blank = _add(search, blank_offset, scale)
clear = _add(search, clear_offset, scale)
card = _add(search, card_offset, scale)
target_card_position = None

pyautogui.click(reset, interval=0.5)
for index, tup in enumerate(ydk_deck):
element, cid = tup
if index == 0 or element != ydk_deck[index - 1][0]:
pyautogui.click(clear, interval=0.1)
pyautogui.click(blank, interval=0.1)
pyautogui.click(search)
# 粘贴卡片名
pyperclip.copy(element)
pyperclip.paste()
pyautogui.hotkey("ctrl", "v")
pyautogui.press("enter")
# 等待搜索完成
time.sleep(1.2)
# 处理搜索得到多卡片的情况
target_card_position = travel_through_deck(
card, card_width_offset * scale, card_height_offset * scale, int(cid)
)
if target_card_position is None:
continue

print(f"{element}\n")
pyautogui.rightClick(target_card_position)

# 对卡组进行校验
result = mdt_deck_reader.check_deck([int(i[1]) for i in ydk_deck], locale)
if len(result["error1"]) != 0 or len(result["error2"]) != 0:
window.write_event_value("DECK_CHECK_ERROR", result)
else:
window.write_event_value("DECK_CHECK_OK", result)
except Exception as e:
print(e)
finally:
callback()


def travel_through_deck(start, width_step, height_step, target_cid=-1):
# 竖
for i in range(5):
# 横
for j in range(6):
click_position = start[0] + width_step * j, start[1] + height_step * i
pyautogui.click(click_position)
cid = get_current_cid()
if cid == target_cid:
return click_position

return None
Loading

0 comments on commit 7dc6f8d

Please sign in to comment.