Skip to content

Commit

Permalink
Fix: tools
Browse files Browse the repository at this point in the history
  • Loading branch information
moesnow committed Nov 29, 2024
1 parent 716abd8 commit 6566875
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 11 deletions.
13 changes: 12 additions & 1 deletion app/card/pushsettingcard1.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from PyQt5.QtCore import Qt, pyqtSignal
from PyQt5.QtGui import QIcon, QKeyEvent
from PyQt5.QtWidgets import QPushButton
from qfluentwidgets import SettingCard, FluentIconBase
from qfluentwidgets import SettingCard, FluentIconBase, InfoBar, InfoBarPosition
from .messagebox_custom import MessageBoxEdit, MessageBoxEditMultiple, MessageBoxDate, MessageBoxInstance, MessageBoxNotifyTemplate, MessageBoxTeam, MessageBoxFriends
from tasks.base.tasks import start_task
from module.config import cfg
Expand Down Expand Up @@ -39,6 +39,7 @@ def __onclicked(self):
class PushSettingCardCode(PushSettingCard):
def __init__(self, text, icon: Union[str, QIcon, FluentIconBase], title, configname, parent=None):
self.configvalue = '\n'.join(cfg.get_value(configname))
self.parent = parent
super().__init__(text, icon, title, configname, "批量使用兑换码,每行一个,自动过滤空格等无效字符", parent)
self.button.clicked.connect(self.__onclicked)

Expand All @@ -52,6 +53,16 @@ def __onclicked(self):
self.configvalue = '\n'.join(code)
if code != []:
start_task("redemption")
else:
InfoBar.warning(
self.tr('兑换码为空'),
self.tr(''),
orient=Qt.Horizontal,
isClosable=True,
position=InfoBarPosition.TOP,
duration=1000,
parent=self.parent
)


class PushSettingCardEval(PushSettingCard):
Expand Down
13 changes: 7 additions & 6 deletions app/tools_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ def __init__(self, parent=None):
self.tr('执行'),
FIF.SPEED_HIGH,
self.tr("兑换码"),
"redemption_code"
"redemption_code",
self
)

self.__initWidget()
Expand Down Expand Up @@ -86,7 +87,7 @@ def __onUnlockfpsCardClicked(self):
if fps == 120:
set_game_fps(60)
InfoBar.success(
title=self.tr('恢复60成功(^∀^●)'),
title=self.tr('恢复60成功 (^∀^●)'),
content="",
orient=Qt.Horizontal,
isClosable=True,
Expand All @@ -97,7 +98,7 @@ def __onUnlockfpsCardClicked(self):
else:
set_game_fps(120)
InfoBar.success(
title=self.tr('解锁120成功(^∀^●)'),
title=self.tr('解锁120成功 (^∀^●)'),
content="",
orient=Qt.Horizontal,
isClosable=True,
Expand All @@ -107,12 +108,12 @@ def __onUnlockfpsCardClicked(self):
)
except:
InfoBar.warning(
title=self.tr('解锁失败(╥╯﹏╰╥)'),
content="",
title=self.tr('解锁失败'),
content="可尝试手动切换一次游戏帧率后重试",
orient=Qt.Horizontal,
isClosable=True,
position=InfoBarPosition.TOP,
duration=1000,
duration=5000,
parent=self
)

Expand Down
1 change: 1 addition & 0 deletions assets/docs/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

### 修复
- “日常任务” 会在每次启动时被错误清空
- “自动对话” 状态不会变化和速度过慢
- 降低角色头像匹配阈值 [#356](https://github.com/moesnow/March7thAssistant/issues/356)

## v2.6.3
Expand Down
9 changes: 5 additions & 4 deletions tasks/tool/autoplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def update_status_label(self, is_clicking):
status_color = "green" if is_clicking else "red"
if hasattr(self, 'status_label'):
self.status_label.config(text=status_text, fg=status_color)
self.root.update() # 强制刷新界面
else:
self.status_label = tk.Label(self.root, text=status_text, fg=status_color)
self.status_label.pack()
Expand All @@ -76,10 +77,10 @@ def check_game_status(self):
if auto.find_element(img, "image", 0.9, take_screenshot=False):
self.start_clicking()
auto.click_element(self.select_img, "image", 0.9, crop=(1290.0 / 1920, 442.0 / 1080, 74.0 / 1920, 400.0 / 1080))
break
self.stop_clicking()
else:
self.stop_clicking()
self.root.after(500, self.check_game_status)
return

self.stop_clicking()

# 每隔一段时间重新检查游戏状态
self.root.after(500, self.check_game_status)
Expand Down
16 changes: 16 additions & 0 deletions tasks/tool/screenshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from tkinter import messagebox
from PIL import ImageTk, Image
import pyperclip
import pyautogui
import os


Expand Down Expand Up @@ -30,6 +31,21 @@ def setup_root(self, root, screenshot: Image.Image):
self.root.geometry(f"{screenshot.width}x{screenshot.height+60}")
self.screenshot = screenshot

self.screen_resolution = pyautogui.size()
screen_width, screen_height = self.screen_resolution
if screen_width <= 1920 and screen_height <= 1080:
# 最大化窗口
self.root.state('zoomed')
# 设置窗口始终位于最前面
self.root.attributes("-topmost", 1)

# 通过延时恢复原始状态(不再保持在最前面)
self.root.after(100, self.remove_topmost)

def remove_topmost(self):
# 取消保持最前面状态
self.root.attributes("-topmost", 0)

def setup_canvas(self):
"""
在根窗口中创建并配置画布用于显示截图。
Expand Down

0 comments on commit 6566875

Please sign in to comment.