-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrgg.py
132 lines (102 loc) · 3.65 KB
/
rgg.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
# -*- coding: utf-8 -*-
'''
This file is part of RandomGameGenerator.
RandomGameGenerator is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
RandomGameGenerator is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with RandomGameGenerator. If not, see <http://www.gnu.org/licenses/>.
'''
if __name__ == '__main__':
def fatalError(error):
'''Displays a dialog about a fatal launch error and exits RGG.'''
try:
try:
import Tkinter as tkinter
except ImportError:
import tkinter
root = tkinter.Tk()
root.withdraw()
import tkMessageBox
tkMessageBox.showerror("RGG: Fatal Error", error)
except Exception:
#If even tk isn't available, just print the error to console.
print("RGG: Fatal Error: " + error)
from sys import exit
exit()
from sys import version_info
if version_info < (3,):
fatalError("RGG must be run with Python 3, not Python 2.")
try:
from PyQt5.QtWidgets import QProgressDialog, QApplication
except:
fatalError("PyQt5 not found. Please ensure it is installed and available.")
application = QApplication(['RGG'])
progress = QProgressDialog("Loading...", "Exit", 0, 9)
progress.setWindowTitle("RGG Loading")
progress.setWindowModality(2)
progress.setWindowFlags(progress.windowFlags() | 262144)
progress.setMinimumDuration(1)
progress.setValue(1)
progress.setLabelText("Loading internals...")
from sys import version_info
from os import path
try:
from libraries.rggQt import QTranslator, QGLFormat, QTimer
except ImportError:
fatalError("PyQt5 could not be loaded fully. Please ensure it is properly installed and available.")
try:
import OpenGL
except ImportError:
fatalError("PyOpenGL not found. Please ensure it is installed and available.")
QApplication.processEvents()
from libraries.rggSystem import injectMain
from libraries.rggJson import loadString, jsonload
from libraries.rggConstants import SAVE_DIR
QApplication.processEvents()
fieldtemp = ["English"]
try:
js = jsonload(path.join(SAVE_DIR, "lang_settings.rgs"))
fieldtemp[0] = loadString('lang.language', js.get('language'))
except:
pass
if fieldtemp[0] != "English":
transfile = ""
if fieldtemp[0] == "Japanese":
transfile = "rgg_py_ja"
if fieldtemp[0] == "Dutch":
transfile = "rgg_py_nl"
if fieldtemp[0] == "German":
transfile = "rgg_py_de"
trans = QTranslator()
if not trans.load(transfile):
print(transfile + " not found")
application.installTranslator(trans)
QApplication.processEvents()
qgf = QGLFormat.defaultFormat()
qgf.setSampleBuffers(True)
QGLFormat.setDefaultFormat(qgf)
QApplication.processEvents()
main = injectMain()
QApplication.processEvents()
from libraries.rggLoadMain import loadMain, APPLICATION, MAIN, CLIENT, PROGRESS
QApplication.processEvents()
APPLICATION[0] = application
MAIN[0] = main
PROGRESS[0] = progress
progress = None
QApplication.processEvents()
loadTimer = QTimer.singleShot(10, loadMain)
# Start execution
try:
main.show()
application.exec_()
finally:
from libraries.rggViews.session import autosaveSession
autosaveSession()
CLIENT[0].close()