Skip to content
This repository was archived by the owner on Jul 4, 2023. It is now read-only.

Commit 0fc10cb

Browse files
committed
🎨 Small improvement
1 parent 29c91d9 commit 0fc10cb

File tree

5 files changed

+101
-73
lines changed

5 files changed

+101
-73
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,4 @@ Launcher-main.exe
127127
/Error_Window.exe
128128
/YouLose.exe
129129
/ErrorWindow.exe
130+
/Json/save.json

cc_main.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def play(self):
159159
# start game
160160
print(f"[INFO] Trying to start the game with class {data['choose']}.")
161161
# import subprocess
162-
if os.path.isfile('Json/save.json'):
162+
if os.path.isfile("Json/save.json"):
163163
if CheckPyInstaller():
164164
if os.path.exists("start.exe"):
165165
try:
@@ -183,7 +183,7 @@ def play(self):
183183
open_github_website()
184184
# self.showNormal()
185185
time.sleep(1)
186-
elif not os.path.isfile('Json/save.json'):
186+
elif not os.path.isfile("Json/save.json"):
187187
if CheckPyInstaller():
188188
if os.path.exists("main.exe"):
189189
try:
@@ -208,8 +208,6 @@ def play(self):
208208
# self.showNormal()
209209
time.sleep(1)
210210

211-
212-
213211

214212
if __name__ == "__main__":
215213
import sys

main.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,9 @@ def CheckPyInstaller():
3939
if not os.path.isfile("Json/save.json"):
4040
lvl = 0
4141
else:
42-
with open("Json/save.json",'r')as s:
42+
with open("Json/save.json", "r") as s:
4343
save = json.load(s)
44-
lvl = int(save["level"])-1
45-
44+
lvl = int(save["level"]) - 1
4645

4746
try:
4847
while True:
@@ -57,15 +56,12 @@ def CheckPyInstaller():
5756
import pygame
5857

5958
pygame.quit()
59+
with open("Json/save.json", "w") as b:
60+
save = {"level": lvl}
61+
json.dump(save, b, indent=4)
6062
if not CheckPyInstaller():
61-
with open("Json/save.json",'w')as b:
62-
save={"level":lvl}
63-
json.dump(save,b,indent=4)
6463
subprocess.call(["python", "YouLose.py", "--lv", str(lvl)])
6564
else:
66-
with open("Json/save.json",'w')as b:
67-
save={"level":lvl}
68-
json.dump(save,b,indent=4)
6965
subprocess.call(["YouLose.exe", "--lv", str(lvl)])
7066
break
7167
else:
@@ -84,6 +80,9 @@ def CheckPyInstaller():
8480
with open("ErrorLog/traceback_{}_lv.{}.txt".format(date, lvl), "a") as f:
8581
f.write("Error Occurred on lv." + str(lvl) + "\n\n")
8682
f.write(error_data)
83+
with open("Json/save.json", "w") as b:
84+
save = {"level": lvl}
85+
json.dump(save, b, indent=4)
8786
if CheckPyInstaller():
8887
subprocess.call("ErrorWindow.exe")
8988
else:

start.py

Lines changed: 44 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
from asyncio import subprocess
2-
from re import sub
3-
from PySide2 import QtCore, QtWidgets, QtGui
1+
import json
2+
import os
3+
4+
from PySide2 import QtWidgets, QtCore, QtGui
45
from PySide2.QtCore import QProcess, Qt
56
from PySide2.QtGui import QFontDatabase, QPixmap
67
from PySide2.QtWidgets import QSplashScreen
7-
import json
8-
import os
98

109
from start_ui import Ui_Form
1110

12-
with open("Json/save.json")as f:
11+
with open("Json/save.json") as f:
1312
data = json.load(f)
1413

14+
1515
def CheckPyInstaller():
1616
if getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS"):
1717
print("[INFO] You are running from PyInstaller packed executable.")
@@ -20,6 +20,7 @@ def CheckPyInstaller():
2020
print("[INFO] You are running from normal Python source code.")
2121
return False
2222

23+
2324
def open_github_website():
2425
print(
2526
"[ERROR] Something went wrong while opening Select Class Window. I suggest you re-download game file"
@@ -33,16 +34,21 @@ def open_github_website():
3334
)
3435
del webbrowser
3536

37+
3638
class mainwindow(QtWidgets.QMainWindow):
3739
def __init__(self):
38-
super(mainwindow,self).__init__(None)
40+
super(mainwindow, self).__init__(None)
3941
self.ui = Ui_Form()
4042
self.ui.setupUi(self)
4143
QFontDatabase.addApplicationFont("Launcher Asset/unifont-14.0.01.ttf")
42-
text = "You have arrived the "+str(data["level"])+" level \n do you want continue?"
44+
text = (
45+
f"You have arrived the level {int(data['level'])} \n"
46+
"Do you want continue?"
47+
)
4348
self.ui.text.setText(text)
4449
self.ui.play1.clicked.connect(self.play1)
4550
self.ui.play2.clicked.connect(self.play2)
51+
4652
def play1(self):
4753
self.showMinimized()
4854
if CheckPyInstaller():
@@ -66,38 +72,50 @@ def play1(self):
6672
open_github_website()
6773
else:
6874
open_github_website()
75+
print("[ERROR] Unknown game error, please report to developer.")
6976
# self.showNormal()
77+
7078
def play2(self):
7179
self.showMinimized()
72-
with open("Json/save.json",'w') as s:
73-
level = {"level": 0 }
74-
json.dump(level,s,indent=4)
80+
with open("Json/save.json", "w") as s:
81+
level = {"level": 0}
82+
json.dump(level, s, indent=4)
83+
7584
if CheckPyInstaller():
76-
if os.path.exists("main.exe"):
77-
try:
78-
self.p = QProcess()
79-
self.p.setProcessChannelMode(QProcess.ForwardedChannels)
80-
self.p.start("main.exe")
81-
except FileNotFoundError:
82-
open_github_website()
83-
except:
84-
print("[ERROR] Unknown game error, please report to developer.")
85-
else:
85+
try:
86+
self.p = QProcess()
87+
self.p.setProcessChannelMode(QProcess.ForwardedChannels)
88+
self.p.start("main.exe")
89+
except FileNotFoundError:
8690
open_github_website()
87-
elif os.path.exists("main.py"):
91+
else:
8892
try:
8993
self.p = QProcess()
9094
self.p.setProcessChannelMode(QProcess.ForwardedChannels)
9195
self.p.start("python", ["main.py"])
9296
except FileNotFoundError:
9397
open_github_website()
94-
else:
95-
open_github_website()
9698
# self.showNormal()
9799

98-
if __name__=="__main__":
100+
101+
if __name__ == "__main__":
99102
import sys
103+
100104
app = QtWidgets.QApplication()
105+
pixmap = QPixmap("Launcher Asset/Logo_Splash.png")
106+
splash = QSplashScreen(pixmap)
107+
splashlabel = QtWidgets.QLabel(splash)
108+
splashgif = QtGui.QMovie("Launcher Asset/Logo_Splash.gif")
109+
splashlabel.setMovie(splashgif)
110+
splashgif.start()
111+
splash.show()
112+
splash.showMessage("Hope you have fun this time", Qt.AlignBottom, Qt.black)
113+
delayTime = 1.3
114+
timer = QtCore.QElapsedTimer()
115+
timer.start()
116+
while timer.elapsed() < delayTime * 1000:
117+
app.processEvents()
101118
window = mainwindow()
102119
window.show()
103-
sys.exit(app.exec_())
120+
splash.finish(window)
121+
sys.exit(app.exec_())

start_ui.py

Lines changed: 46 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,62 @@
11
# -*- coding: utf-8 -*-
22

3-
# Form implementation generated from reading ui file '.\start.ui',
4-
# licensing of '.\start.ui' applies.
5-
#
6-
# Created: Thu Jan 27 12:33:13 2022
7-
# by: pyside2-uic running on PySide2 5.13.2
8-
#
9-
# WARNING! All changes made in this file will be lost!
3+
################################################################################
4+
## Form generated from reading UI file 'start.ui'
5+
##
6+
## Created by: Qt User Interface Compiler version 5.15.2
7+
##
8+
## WARNING! All changes made in this file will be lost when recompiling UI file!
9+
################################################################################
10+
11+
from PySide2.QtCore import *
12+
from PySide2.QtGui import *
13+
from PySide2.QtWidgets import *
1014

11-
from PySide2 import QtCore, QtGui, QtWidgets
1215

1316
class Ui_Form(object):
1417
def setupUi(self, Form):
15-
Form.setObjectName("Form")
18+
if not Form.objectName():
19+
Form.setObjectName(u"Form")
1620
Form.resize(640, 480)
17-
Form.setMinimumSize(QtCore.QSize(640, 480))
18-
Form.setMaximumSize(QtCore.QSize(640, 480))
19-
self.text = QtWidgets.QLabel(Form)
20-
self.text.setGeometry(QtCore.QRect(90, 50, 461, 101))
21-
font = QtGui.QFont()
22-
font.setFamily("Unifont")
21+
Form.setMinimumSize(QSize(640, 480))
22+
Form.setMaximumSize(QSize(640, 480))
23+
Form.setWindowTitle(u"Game Save Choose")
24+
icon = QIcon()
25+
icon.addFile(u"Launcher Asset/Logo.png", QSize(), QIcon.Normal, QIcon.Off)
26+
Form.setWindowIcon(icon)
27+
self.text = QLabel(Form)
28+
self.text.setObjectName(u"text")
29+
self.text.setGeometry(QRect(90, 50, 461, 101))
30+
self.text.setAlignment(Qt.AlignCenter)
31+
self.play1 = QPushButton(Form)
32+
self.play1.setObjectName(u"play1")
33+
self.play1.setGeometry(QRect(20, 310, 281, 131))
34+
font = QFont()
35+
font.setFamily(u"Unifont")
2336
font.setPointSize(18)
37+
# font.setStyleStrategy(QFont.NoAntialias)
2438
self.text.setFont(font)
25-
self.text.setObjectName("text")
26-
self.play1 = QtWidgets.QPushButton(Form)
27-
self.play1.setGeometry(QtCore.QRect(20, 310, 281, 131))
28-
font = QtGui.QFont()
29-
font.setFamily("Unifont")
30-
font.setPointSize(18)
3139
self.play1.setFont(font)
32-
self.play1.setObjectName("play1")
33-
self.play2 = QtWidgets.QPushButton(Form)
34-
self.play2.setGeometry(QtCore.QRect(340, 310, 281, 131))
35-
font = QtGui.QFont()
36-
font.setFamily("Unifont")
37-
font.setPointSize(18)
40+
self.play2 = QPushButton(Form)
41+
self.play2.setObjectName(u"play2")
42+
self.play2.setGeometry(QRect(340, 310, 281, 131))
3843
self.play2.setFont(font)
39-
self.play2.setObjectName("play2")
4044

4145
self.retranslateUi(Form)
42-
QtCore.QMetaObject.connectSlotsByName(Form)
46+
47+
QMetaObject.connectSlotsByName(Form)
48+
49+
# setupUi
4350

4451
def retranslateUi(self, Form):
45-
Form.setWindowTitle(QtWidgets.QApplication.translate("Form", "Form", None, -1))
46-
self.text.setText(QtWidgets.QApplication.translate("Form", "TextLabel", None, -1))
47-
self.play1.setText(QtWidgets.QApplication.translate("Form", "Yes,let me continue.", None, -1))
48-
self.play2.setText(QtWidgets.QApplication.translate("Form", "No,let me \n"
49-
"start from beginning.", None, -1))
52+
self.text.setText(QCoreApplication.translate("Form", u"TextLabel", None))
53+
self.play1.setText(
54+
QCoreApplication.translate("Form", u"Yes,let me continue.", None)
55+
)
56+
self.play2.setText(
57+
QCoreApplication.translate(
58+
"Form", u"No,let me \n" "start from beginning.", None
59+
)
60+
)
5061

62+
# retranslateUi

0 commit comments

Comments
 (0)