-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmain.py
More file actions
149 lines (124 loc) · 8.5 KB
/
main.py
File metadata and controls
149 lines (124 loc) · 8.5 KB
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
"""
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ┃
┃ Polsu's Overlay ┃
┃ ┃
┃ ┃
┃ • A Hypixel Bedwars Overlay in Python, 100% free and open source! ┃
┃ > https://github.com/Polsu-Development/PolsuOverlay ┃
┃ • Made by Polsu's Development Team ┃
┃ ┃
┃ ┃
┃ ┃
┃ © 2023 - 2024, Polsu Development - All rights reserved ┃
┃ ┃
┃ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the ┃
┃ following conditions are met: ┃
┃ ┃
┃ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the ┃
┃ following disclaimer. ┃
┃ ┃
┃ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the ┃
┃ following disclaimer in the documentation and/or other materials provided with the distribution. ┃
┃ ┃
┃ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, ┃
┃ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ┃
┃ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ┃
┃ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ┃
┃ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ┃
┃ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE ┃
┃ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
"""
from src import DEV_MODE
from src.updater import Updater
from src.overlay import Overlay
from src.components.logger import Logger
from src.utils.path import resource_path
from PyQt5.QtWidgets import QApplication, QMessageBox
from PyQt5.QtGui import QIcon
from PyQt5.QtCore import Qt
import sys
import os
import traceback
import datetime
from time import sleep
if getattr(sys, 'frozen', False):
import pyi_splash
def run(window: Updater, logger: Logger) -> None:
"""
Run the overlay, depending on the value of the Updater window
:param window: The Updater window
:param logger: The logger
"""
if window.value == "Clean":
window.progressBar.setMaximum(100)
window.progressBar.setValue(100)
sleep(1)
window.close()
errorWindow = QMessageBox()
errorWindow.setWindowTitle("Update successful!")
errorWindow.setWindowIcon(QIcon(f"{resource_path('assets')}/polsu/Polsu_.png"))
errorWindow.setIcon(QMessageBox.Information)
errorWindow.setText("The overlay has been updated successfully!\n\nPlease restart the overlay to apply the changes.")
errorWindow.setFocus()
errorWindow.exec_()
elif window.value:
window.close()
try:
Overlay(logger).show()
except:
logger.critical(f"An error occurred while running the overlay!\n\nTraceback: {traceback.format_exc()}")
errorWindow = QMessageBox()
errorWindow.setWindowTitle("An error occurred!")
errorWindow.setWindowIcon(QIcon(f"{resource_path('assets')}/polsu/Polsu_.png"))
errorWindow.setIcon(QMessageBox.Critical)
errorWindow.setText("Something went wrong while running the overlay!\nPlease report this issue on GitHub or our Discord server.\nhttps://discord.polsu.xyz")
errorWindow.setInformativeText(traceback.format_exception_only(type(sys.exc_info()[1]), sys.exc_info()[1])[0])
errorWindow.setDetailedText(traceback.format_exc())
errorWindow.setFocus()
errorWindow.exec_()
else:
window.close()
if __name__ == '__main__':
# DO NOT REMOVE THE FOLLOWING LINES!
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
os.environ["QT_AUTO_SCREEN_SCALE_FACTOR"] = "1"
#
# This is a fix for the DPI scaling on Windows
# Removing this might break the overlay window.
try:
logger = Logger()
except PermissionError:
app = QApplication(sys.argv)
if getattr(sys, 'frozen', False):
pyi_splash.close()
errorWindow = QMessageBox()
errorWindow.setWindowTitle("An error occurred!")
errorWindow.setWindowIcon(QIcon(f"{resource_path('assets')}/polsu/Polsu_.png"))
errorWindow.setIcon(QMessageBox.Critical)
errorWindow.setText("An internal error occured...\nPlease make sure you have the required permissions to create files in the directory of the overlay.\n\nTo fix this issue, please run the overlay as an administrator for the first time.")
errorWindow.setInformativeText(traceback.format_exception_only(type(sys.exc_info()[1]), sys.exc_info()[1])[0])
errorWindow.setDetailedText(traceback.format_exc())
errorWindow.setFocus()
errorWindow.show()
sys.exit(app.exec_())
else:
logger.info("-----------------------------------------------------------------------------------------------------")
logger.info(f"Polsu Overlay - {datetime.datetime.utcnow().strftime('%d/%m/%Y %H:%M:%S')}")
logger.info(f"Python version: {sys.version}")
logger.info(f"OS: {sys.platform}")
logger.info(f"Running in: {'Development' if DEV_MODE else 'Production'} mode")
logger.info("-----------------------------------------------------------------------------------------------------")
logger.info("Starting Polsu Overlay...")
app = QApplication(sys.argv)
try:
if getattr(sys, 'frozen', False):
pyi_splash.close()
window = Updater(logger)
window.ended.connect(run)
window.show()
except:
logger.critical(f"An error occurred while updating the overlay!\n\nTraceback: {traceback.format_exc()}")
sys.exit(app.exec_())