forked from moesnow/March7thAssistant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_window.py
146 lines (123 loc) · 5.49 KB
/
main_window.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
from PyQt5.QtCore import Qt, QSize
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QApplication
from contextlib import redirect_stdout
with redirect_stdout(None):
from qfluentwidgets import NavigationItemPosition, MSFluentWindow, SplashScreen, setThemeColor, NavigationBarPushButton, toggleTheme, setTheme, Theme
from qfluentwidgets import FluentIcon as FIF
from qfluentwidgets import InfoBar, InfoBarPosition
from .home_interface import HomeInterface
from .help_interface import HelpInterface
# from .changelog_interface import ChangelogInterface
from .warp_interface import WarpInterface
from .tools_interface import ToolsInterface
from .setting_interface import SettingInterface
from .card.messagebox_custom import MessageBoxSupport
from .tools.check_update import checkUpdate
from .tools.announcement import checkAnnouncement
from .tools.disclaimer import disclaimer
from module.config import cfg
from utils.gamecontroller import GameController
import base64
class MainWindow(MSFluentWindow):
def __init__(self):
super().__init__()
self.initWindow()
self.initInterface()
self.initNavigation()
# 检查更新
checkUpdate(self, flag=True)
checkAnnouncement(self)
def initWindow(self):
setThemeColor('#f18cb9', lazy=True)
setTheme(Theme.AUTO, lazy=True)
self.setMicaEffectEnabled(False)
# 禁用最大化
self.titleBar.maxBtn.setHidden(True)
self.titleBar.maxBtn.setDisabled(True)
self.titleBar.setDoubleClickEnabled(False)
self.setResizeEnabled(False)
self.setWindowFlags(Qt.WindowMinimizeButtonHint | Qt.WindowCloseButtonHint)
self.resize(960, 640)
self.setWindowIcon(QIcon('./assets/logo/March7th.ico'))
self.setWindowTitle("March7th Assistant")
# 创建启动画面
self.splashScreen = SplashScreen(self.windowIcon(), self)
self.splashScreen.setIconSize(QSize(128, 128))
self.splashScreen.raise_()
desktop = QApplication.desktop().availableGeometry()
w, h = desktop.width(), desktop.height()
self.move(w // 2 - self.width() // 2, h // 2 - self.height() // 2)
self.show()
QApplication.processEvents()
def initInterface(self):
self.homeInterface = HomeInterface(self)
self.helpInterface = HelpInterface(self)
# self.changelogInterface = ChangelogInterface(self)
self.warpInterface = WarpInterface(self)
self.toolsInterface = ToolsInterface(self)
self.settingInterface = SettingInterface(self)
def initNavigation(self):
self.addSubInterface(self.homeInterface, FIF.HOME, self.tr('主页'))
self.addSubInterface(self.helpInterface, FIF.BOOK_SHELF, self.tr('帮助'))
# self.addSubInterface(self.changelogInterface, FIF.UPDATE, self.tr('更新日志'))
self.addSubInterface(self.warpInterface, FIF.SHARE, self.tr('抽卡记录'))
self.addSubInterface(self.toolsInterface, FIF.DEVELOPER_TOOLS, self.tr('工具箱'))
self.navigationInterface.addWidget(
'startGameButton',
NavigationBarPushButton(FIF.PLAY, '启动游戏', isSelectable=False),
self.startGame,
NavigationItemPosition.BOTTOM)
self.navigationInterface.addWidget(
'themeButton',
NavigationBarPushButton(FIF.BRUSH, '主题', isSelectable=False),
lambda: toggleTheme(lazy=True),
NavigationItemPosition.BOTTOM)
self.navigationInterface.addWidget(
'avatar',
NavigationBarPushButton(FIF.HEART, '赞赏', isSelectable=False),
lambda: MessageBoxSupport(
'支持作者🥰',
'此程序为免费开源项目,如果你付了钱请立刻退款\n如果喜欢本项目,可以微信赞赏送作者一杯咖啡☕\n您的支持就是作者开发和维护项目的动力🚀',
'./assets/app/images/sponsor.jpg',
self
).exec(),
NavigationItemPosition.BOTTOM
)
self.addSubInterface(self.settingInterface, FIF.SETTING, self.tr('设置'), position=NavigationItemPosition.BOTTOM)
self.splashScreen.finish()
if not cfg.get_value(base64.b64decode("YXV0b191cGRhdGU=").decode("utf-8")):
disclaimer(self)
def startGame(self):
game = GameController(cfg.game_path, cfg.game_process_name, cfg.game_title_name, 'UnityWndClass')
try:
if game.start_game():
InfoBar.success(
title=self.tr('启动成功(^∀^●)'),
content="",
orient=Qt.Horizontal,
isClosable=True,
position=InfoBarPosition.TOP,
duration=1000,
parent=self
)
else:
InfoBar.warning(
title=self.tr('启动失败(╥╯﹏╰╥)'),
content="",
orient=Qt.Horizontal,
isClosable=True,
position=InfoBarPosition.TOP,
duration=1000,
parent=self
)
except:
InfoBar.warning(
title=self.tr('启动失败(╥╯﹏╰╥)'),
content="",
orient=Qt.Horizontal,
isClosable=True,
position=InfoBarPosition.TOP,
duration=1000,
parent=self
)