-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathopenalchemist-config
executable file
·143 lines (119 loc) · 5.71 KB
/
openalchemist-config
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
#!/usr/bin/python
# -*- coding: UTF-8 -*-
# Configuration tool (0.3 version)
# ===============
# Copyright (C) 2006, 2008, 2009 Guillaume Delhumeau
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, Or (at your option) any later version.
#
# This program 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 General Public License For more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# Contact me: guillaume.delhumeau [_at_] gmail [_dot_] com
# This program needs Python(http://www.python.org) of course, GTK+(http://www.gtk.org) and PyGTK 2.6 (http://www.pygtk.org).
import gtk, os, sys, struct, ConfigParser
OPENALCHEMIST_VERSION = "svn"
class App:
def __init__(self):
self.init_GUI()
self.readfile()
gtk.main()
def readfile(self):
ini = ConfigParser.SafeConfigParser()
try:
ini.read(os.getenv("HOME")+"/.openalchemist/preferences-"+OPENALCHEMIST_VERSION+".ini")
self.window.txt_fps.set_text(ini.get('Preferences', 'MaxFPS'))
if ini.get("Preferences", "OpenGL")=="True":
self.window.rbt_opengl.set_active(True)
self.window.rbt_sdl.set_active(False)
else:
self.window.rbt_opengl.set_active(False)
self.window.rbt_sdl.set_active(True)
if ini.get("Preferences", "Colorblind")=="True":
self.window.cb_colorblind.set_active(True)
if ini.get("Preferences", "Widescreen")=="True":
self.window.cb_widescreen.set_active(True)
else:
self.window.cb_widescreen.set_active(False)
except:
print "Error while reading ini file"
def init_GUI(self):
# Window creation
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.set_title('OpenAlchemist Config')
# Add events
self.window.connect("destroy", self._event_quit)
self.window.mainbox = gtk.VBox(homogeneous = False, spacing=10)
self.window.mainbox.set_border_width(10)
self.window.add(self.window.mainbox)
self.window.render_frame = gtk.Frame("Render")
self.window.mainbox.pack_start(self.window.render_frame, fill=False, expand=False)
self.window.render_box = gtk.VBox(homogeneous = True, spacing = 0)
self.window.render_box.set_border_width(10)
self.window.render_frame.add(self.window.render_box)
self.window.rbt_opengl = gtk.RadioButton(label="OpenGL")
self.window.render_box.pack_start(self.window.rbt_opengl, fill=False, expand=False)
self.window.rbt_sdl = gtk.RadioButton(label="SDL", group=self.window.rbt_opengl)
self.window.render_box.pack_start(self.window.rbt_sdl, fill=False, expand=False)
self.window.fps_frame = gtk.Frame("Limit framerate to :")
self.window.mainbox.pack_start(self.window.fps_frame, fill=False, expand=False)
self.window.fps_box = gtk.VBox()
self.window.fps_frame.add(self.window.fps_box)
self.window.fps_box.set_border_width(10)
self.window.txt_fps = gtk.Entry()
self.window.txt_fps.set_text("60")
self.window.fps_box.pack_start(self.window.txt_fps, fill=False, expand=False)
self.window.options_frame = gtk.Frame("Options")
self.window.mainbox.pack_start(self.window.options_frame, fill=False, expand=False)
self.window.options_box = gtk.VBox()
self.window.options_box.set_border_width(10)
self.window.options_frame.add(self.window.options_box)
self.window.cb_widescreen = gtk.CheckButton(label="Active 16:9 wide screen mode")
self.window.options_box.pack_start(self.window.cb_widescreen, fill=False, expand=False)
self.window.cb_colorblind = gtk.CheckButton(label="Active color blind mode")
self.window.options_box.pack_start(self.window.cb_colorblind, fill=False, expand=False)
self.window.bt_start = gtk.Button("Run game")
self.window.mainbox.pack_start(self.window.bt_start, fill=False, expand=False)
self.window.bt_start.connect("clicked", self._event_ok)
self.check_resolution()
# Show the window and start the main loop.
self.window.set_position(gtk.WIN_POS_CENTER)
self.window.show_all()
def check_resolution(self):
ratio = 0.0 + gtk.gdk.screen_width() / (0.0 + gtk.gdk.screen_height())
if 16.0 / 9.0 * 1.2 > ratio and 16.0 / 9.0 * 0.8 < ratio:
self.window.cb_widescreen.set_active(True)
else:
self.window.cb_widescreen.set_active(False)
def _event_quit(self, event):
gtk.main_quit()
def _event_ok(self, event):
os.system("cd " + sys.path[0])
options = ""
if self.window.rbt_opengl.get_active():
options = " --opengl"
else:
options = " --sdl"
if self.window.cb_colorblind.get_active():
options = options + " --cb"
else:
options = options + " --nocb"
if self.window.cb_widescreen.get_active():
options = options + " --wide"
else:
options = options + " --nowide"
options = options + " --maxfps " + self.window.txt_fps.get_text()
if os.path.exists("./openalchemist"):
os.system("./openalchemist" + options)
else:
os.system("openalchemist" + options)
app = App()