-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
95 lines (70 loc) · 2.74 KB
/
main.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
import json
import sys
from PyQt5 import QtCore, QtWidgets
from core.game.utils import *
from core.game.gui import Gui
from core.game.core import Core
from core.sold.gui import UISold
from core.sold.core import CoreSold
from start import UIStartInterface
class StartMenu(QtWidgets.QWidget, UIStartInterface):
def __init__(self):
super(StartMenu, self).__init__()
self.setupUi(self)
self.newGameButton.clicked.connect(self.newGame)
self.loadGameButton.clicked.connect(self.loadGame)
self.exitButton.clicked.connect(self.close)
def loadGame(self):
savePath, _ = QtWidgets.QFileDialog.getOpenFileName(self, "Open File", "", "Press Quest Save File (*.pq.json)")
if savePath:
playWindow.startGame(savePath)
def newGame(self):
soldWindow.show()
self.hide()
class SoldMenu(QtWidgets.QWidget, CoreSold, UISold):
def __init__(self):
super(SoldMenu, self).__init__()
self.setupUi(self, playWindow)
self.RollEm()
def closeEvent(self, event):
startWindow.show()
event.accept()
class Main(QtWidgets.QWidget, Core, Gui):
def __init__(self):
super(Main, self).__init__()
self.ExpBar = self.PlotBar = self.TaskBar = self.QuestBar = self.EncumBar = None
self.Traits = self.Stats = self.Spells = self.Equips = self.Inventory = self.Plots = self.Quests = None
self.Kill = None
self.setupUi(self)
self.AllBars = [self.ExpBar, self.PlotBar,
self.TaskBar, self.QuestBar, self.EncumBar]
self.AllLists = [self.Traits, self.Stats, self.Spells,
self.Equips, self.Inventory, self.Plots, self.Quests]
def startGame(self, path):
self.savePath = path
try:
with open(path, "r") as f:
content = json.load(f)
except:
QtWidgets.QMessageBox.critical(self, "Error", "Could not load game from " + path)
startWindow.show()
return
self.LoadGame(content)
soldWindow.close()
startWindow.close()
self.show()
self.lasttick = timeGetTime()
timer = QtCore.QTimer(self)
timer.timeout.connect(self.Progress)
timer.start(100)
def closeEvent(self, event):
self.SaveGame()
QtWidgets.QMessageBox.information(self, "Saved", "Game saved as " + self.savePath)
event.accept()
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
playWindow = Main()
soldWindow = SoldMenu()
startWindow = StartMenu()
startWindow.show()
sys.exit(app.exec_())