forked from ChaozhongLiu/DyberPet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_DyberPet.py
167 lines (126 loc) · 6.41 KB
/
run_DyberPet.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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
import sys
from sys import platform
import ctypes
from tendo import singleton
import os
from DyberPet.utils import read_json
from DyberPet.DyberPet import PetWidget
from DyberPet.Notification import DPNote
from DyberPet.Accessory import DPAccessory
from PySide6.QtWidgets import QApplication
from PySide6 import QtCore
from PySide6.QtCore import Qt, QLocale
from qfluentwidgets import FluentTranslator, setThemeColor
from DyberPet.DyberSettings.DyberControlPanel import ControlMainWindow
from DyberPet.Dashboard.DashboardUI import DashboardMainWindow
try:
size_factor = 1 #ctypes.windll.shcore.GetScaleFactorForDevice(0) / 100
except:
size_factor = 1
import DyberPet.settings as settings
# For translation:
# pylupdate5 langs.pro
# lrelease langs.zh_CN.ts
# For .exe:
# Now we use pyinstaller 6.5.0
# pyinstaller --noconsole --hidden-import="pynput.mouse._win32" --hidden-import="pynput.keyboard._win32" run_DyberPet.py
class DyberPetApp(QApplication):
def __init__(self, *args, **kwargs):
super(DyberPetApp, self).__init__(*args, **kwargs)
self.setQuitOnLastWindowClosed(False)
screens = self.screens()
primary_screen = self.primaryScreen()
if primary_screen in screens:
screens.insert(0, screens.pop(screens.index(primary_screen)))
else:
screens.insert(0, primary_screen)
# internationalization
fluentTranslator = FluentTranslator(QLocale(settings.language_code))
self.installTranslator(fluentTranslator)
self.installTranslator(settings.translator)
if settings.themeColor:
setThemeColor(settings.themeColor)
# Pet Object
self.p = PetWidget(screens=screens)
# Notification System
self.note = DPNote()
# Accessory System
self.acc = DPAccessory()
# System Panel
self.conp = ControlMainWindow()
# Dashboard
self.board = DashboardMainWindow()
# Signal Links
self.__connectSignalToSlot()
def __connectSignalToSlot(self):
# Main Widget - others
self.p.setup_notification.connect(self.note.setup_notification)
self.p.change_note.connect(self.note.change_pet)
self.p.change_note.connect(self.conp.charCardInterface._finishStateTooltip)
self.p.hptier_changed_main_note.connect(self.note.hpchange_note)
self.p.fvlvl_changed_main_note.connect(self.note.fvchange_note)
self.p.setup_acc.connect(self.acc.setup_accessory)
self.p.move_sig.connect(self.acc.send_main_movement)
self.p.close_all_accs.connect(self.acc.closeAll)
# System Widgets - others
self.conp.settingInterface.ontop_changed.connect(self.acc.ontop_changed)
self.conp.settingInterface.scale_changed.connect(self.acc.reset_size_sig)
self.conp.settingInterface.ontop_changed.connect(self.p.ontop_update)
#self.conp.settingInterface.scale_changed.connect(self.p.set_img)
self.conp.settingInterface.scale_changed.connect(self.p.reset_size)
self.conp.settingInterface.lang_changed.connect(self.p.lang_changed)
self.conp.charCardInterface.change_pet.connect(self.p._change_pet)
self.p.show_controlPanel.connect(self.conp.show_window)
self.conp.gamesaveInterface.refresh_pet.connect(self.p.refresh_pet)
# Dashboard - others
self.p.show_dashboard.connect(self.board.show_window)
self.note.noteToLog.connect(self.board.statusInterface._addNote)
self.p.hp_updated.connect(self.board.statusInterface.StatusCard._updateHP)
self.p.fv_updated.connect(self.board.statusInterface.StatusCard._updateFV)
self.p.change_note.connect(self.board.statusInterface._changePet)
self.board.statusInterface.changeStatus.connect(self.p._change_status)
self.p.stopAllThread.connect(self.board.statusInterface.stopBuffThread)
self.acc.acc_withdrawed.connect(self.board.backpackInterface.acc_withdrawed)
self.board.backpackInterface.use_item_inven.connect(self.p.use_item)
self.board.backpackInterface.item_note.connect(self.p.register_notification)
self.board.backpackInterface.item_drop.connect(self.p.item_drop_anim)
self.p.fvlvl_changed_main_inve.connect(self.board.backpackInterface.fvchange)
self.p.fvlvl_changed_main_inve.connect(self.board.shopInterface.fvchange)
self.p.addItem_toInven.connect(self.board.backpackInterface.add_items)
self.p.compensate_rewards.connect(self.board.backpackInterface.compensate_rewards)
self.p.refresh_bag.connect(self.board.backpackInterface.refresh_bag)
self.p.refresh_bag.connect(self.board.shopInterface.refresh_shop)
self.p.addCoins.connect(self.board.backpackInterface.addCoins)
# Tasks and Timer
self.board.taskInterface.focusPanel.start_pomodoro.connect(self.p.run_tomato)
self.board.taskInterface.focusPanel.cancel_pomodoro.connect(self.p.cancel_tomato)
self.board.taskInterface.focusPanel.start_focus.connect(self.p.run_focus)
self.board.taskInterface.focusPanel.cancel_focus.connect(self.p.cancel_focus)
self.p.taskUI_Timer_update.connect(self.board.taskInterface.focusPanel.update_Timer)
self.p.taskUI_task_end.connect(self.board.taskInterface.focusPanel.taskFinished)
self.p.single_pomo_done.connect(self.board.taskInterface.focusPanel.single_pomo_done)
# Animation Panel
self.board.animInterface.animatPanel.updateList.connect(self.p.updateList)
self.board.animInterface.animatPanel.playAct.connect(self.p._show_act)
self.p.refresh_acts.connect(self.board.animInterface.animatPanel.updateAct)
self.p.refresh_acts.connect(self.board.animInterface.updateDesignUI)
self.board.animInterface.loadNewAct.connect(self.p._addNewAct)
self.board.animInterface.deletewAct.connect(self.p._deleteAct)
if platform == 'win32':
basedir = ''
else:
basedir = os.path.dirname(__file__)
if __name__ == '__main__':
# Avoid multiple process
try:
me = singleton.SingleInstance()
except:
sys.exit()
# Create App
QApplication.setHighDpiScaleFactorRoundingPolicy(
Qt.HighDpiScaleFactorRoundingPolicy.PassThrough)
#QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
#QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)
app = DyberPetApp(sys.argv)
app.setAttribute(Qt.AA_DontCreateNativeWidgetSiblings)
sys.exit(app.exec())