-
-
Notifications
You must be signed in to change notification settings - Fork 41
/
MCSL2.py
125 lines (97 loc) · 3.35 KB
/
MCSL2.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
# Copyright 2024, MCSL Team, mailto:[email protected]
#
# Part of "MCSL2", a simple and multifunctional Minecraft server launcher.
#
# Licensed under the GNU General Public License, Version 3.0, with our
# additional agreements. (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://github.com/MCSLTeam/MCSL2/raw/master/LICENSE
#
################################################################################
"""
Main entry.
"""
import sys
from PyQt5.QtCore import Qt, QLocale, QObject, QEvent
from PyQt5.QtWidgets import QApplication
# from viztracer import VizTracer
from MCSL2Lib.utils import MCSL2Logger
class MCSL2Application(QApplication):
def __init__(self, argv):
super().__init__(argv)
def notify(self, a0: QObject, a1: QEvent) -> bool:
try:
done = super().notify(a0, a1)
return done
except Exception as e:
MCSL2Logger.critical(e)
return False
if __name__ == "__main__":
# Debug
# tracer = VizTracer()
# tracer.enable_thread_tracing()
# tracer.start()
# Initialize
from MCSL2Lib.utils import initializeMCSL2
initializeMCSL2()
del initializeMCSL2
# Load config
from qfluentwidgets import qconfig
from MCSL2Lib.ProgramControllers.settingsController import cfg
qconfig.load(r"./MCSL2/MCSL2_Config.json", cfg)
# Verify dev mode
cfg.set(cfg.oldExecuteable, sys.executable.split("\\")[-1])
from MCSL2Lib.variables import GlobalMCSL2Variables
if (
cfg.get(cfg.oldExecuteable) == "python"
or cfg.get(cfg.oldExecuteable) == "python.exe"
or cfg.get(cfg.oldExecuteable) == "py"
or cfg.get(cfg.oldExecuteable) == "py.exe"
):
GlobalMCSL2Variables.devMode = True
else:
GlobalMCSL2Variables.devMode = False
# Try to delete old executable
from os import path as osp
if osp.exists(cfg.get(cfg.oldExecuteable)):
from MCSL2Lib.ProgramControllers.updateController import deleteOldMCSL2
deleteOldMCSL2()
del deleteOldMCSL2
# Analyze user
try:
from MCSL2Lib.verification import countUserAPI
except ImportError:
from MCSL2Lib.noVerification import countUserAPI
try:
countUserAPI()
except Exception:
pass
del countUserAPI
# High DPI scaling
MCSL2Application.setHighDpiScaleFactorRoundingPolicy(
Qt.HighDpiScaleFactorRoundingPolicy.PassThrough
)
MCSL2Application.setAttribute(Qt.AA_EnableHighDpiScaling)
MCSL2Application.setAttribute(Qt.AA_UseHighDpiPixmaps)
MCSL2Application.setAttribute(Qt.AA_DontCreateNativeWidgetSiblings)
MCSL2Application.setAttribute(Qt.AA_UseDesktopOpenGL)
MCSL2Application.setAttribute(Qt.AA_SynthesizeTouchForUnhandledMouseEvents)
MCSL2Application.setAttribute(Qt.AA_SynthesizeMouseForUnhandledTouchEvents)
# Construct QApplication
app = MCSL2Application(sys.argv)
# i18n
from qfluentwidgets import FluentTranslator
fluentTranslator = FluentTranslator(QLocale(QLocale.Chinese))
app.installTranslator(fluentTranslator)
# Main Window
from MCSL2Lib.windowInterface import Window
w = Window()
w.show()
import gc
gc.enable()
app.exec_()
# tracer.stop()
# tracer.save()
sys.exit()