Mercurial > touhou
annotate pytouhou/menu.py @ 570:f0252cf111d8
Don’t traceback when GTK+ isn’t available.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Thu, 10 Jul 2014 13:53:46 +0200 |
parents | e7a4731a278b |
children | 7f113f15300b |
rev | line source |
---|---|
568
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
1 # -*- encoding: utf-8 -*- |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
2 ## |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
3 ## Copyright (C) 2014 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
4 ## |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
5 ## This program is free software; you can redistribute it and/or modify |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
6 ## it under the terms of the GNU General Public License as published |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
7 ## by the Free Software Foundation; version 3 only. |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
8 ## |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
9 ## This program is distributed in the hope that it will be useful, |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
12 ## GNU General Public License for more details. |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
13 ## |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
14 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
15 from pytouhou.utils.helpers import get_logger |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
16 logger = get_logger(__name__) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
17 |
570
f0252cf111d8
Don’t traceback when GTK+ isn’t available.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
568
diff
changeset
|
18 from gi.repository import Gtk, Gdk |
568
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
19 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
20 import sys |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
21 import re |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
22 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
23 GL_VERSION_REGEX = re.compile(r'^\d\.\d$') |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
24 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
25 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
26 class Handler(object): |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
27 def __init__(self, config, args): |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
28 self.config = config |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
29 self.args = args |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
30 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
31 def init_gtk(self, builder): |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
32 self.start_window = builder.get_object('start_window') |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
33 self.game_window = builder.get_object('game_window') |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
34 self.options_window = builder.get_object('options_window') |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
35 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
36 self.replay_filechooserdialog = builder.get_object('replay_filechooserdialog') |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
37 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
38 # Game widgets |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
39 self.difficulty_box = builder.get_object('difficulty_box') |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
40 self.character_box = builder.get_object('character_box') |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
41 self.stage_box = builder.get_object('stage_box') |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
42 self.boss_rush_checkbutton = builder.get_object('boss_rush_checkbutton') |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
43 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
44 self.difficulty_comboboxtext = builder.get_object('difficulty_comboboxtext') |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
45 self.character_comboboxtext = builder.get_object('character_comboboxtext') |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
46 self.stage_comboboxtext = builder.get_object('stage_comboboxtext') |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
47 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
48 # Options widgets |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
49 self.path_filechooserbutton = builder.get_object('path_filechooserbutton') |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
50 self.backend_comboboxtext = builder.get_object('backend_comboboxtext') |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
51 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
52 # OpenGL backend |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
53 self.opengl_grid = builder.get_object('opengl_grid') |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
54 self.flavor_comboboxtext = builder.get_object('flavor_comboboxtext') |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
55 self.version_entry = builder.get_object('version_entry') |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
56 self.double_buffer_checkbutton = builder.get_object('double_buffer_checkbutton') |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
57 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
58 # SDL backend |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
59 self.sdl_grid = builder.get_object('sdl_grid') |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
60 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
61 self.fps_entry = builder.get_object('fps_entry') |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
62 self.no_background_checkbutton = builder.get_object('no_background_checkbutton') |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
63 self.no_particles_checkbutton = builder.get_object('no_particles_checkbutton') |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
64 self.no_sound_checkbutton = builder.get_object('no_sound_checkbutton') |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
65 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
66 self.difficulty_comboboxtext.set_active_id(str(self.args.rank)) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
67 self.character_comboboxtext.set_active_id(str(self.args.character)) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
68 self.stage_comboboxtext.set_active_id(str(self.args.stage)) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
69 self.boss_rush_checkbutton.set_active(self.args.boss_rush) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
70 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
71 self.path_filechooserbutton.set_filename(self.args.path) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
72 self.backend_comboboxtext.set_active_id(' '.join(self.args.backend)) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
73 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
74 self.flavor_comboboxtext.set_active_id(self.args.gl_flavor) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
75 self.version_entry.set_text(str(self.args.gl_version)) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
76 if self.args.double_buffer is None: |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
77 self.double_buffer_checkbutton.set_inconsistent(True) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
78 else: |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
79 self.double_buffer_checkbutton.set_inconsistent(False) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
80 self.double_buffer_checkbutton.set_active(self.args.double_buffer) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
81 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
82 self.fps_entry.set_text(str(self.args.fps_limit)) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
83 self.no_background_checkbutton.set_active(self.args.no_background) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
84 self.no_particles_checkbutton.set_active(self.args.no_particles) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
85 self.no_sound_checkbutton.set_active(self.args.no_sound) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
86 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
87 def hide_and_play(self, window): |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
88 window.hide() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
89 Gtk.main_quit() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
90 print('Play!') |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
91 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
92 def on_quit(self, *args): |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
93 Gtk.main_quit(*args) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
94 sys.exit(0) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
95 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
96 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
97 # Main menu |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
98 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
99 def on_start_window_key_press_event(self, window, event_key): |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
100 if (event_key.keyval == Gdk.KEY_Escape or |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
101 event_key.state == Gdk.ModifierType.CONTROL_MASK and event_key.keyval == Gdk.KEY_q): |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
102 self.on_quit() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
103 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
104 def on_start_button_clicked(self, _): |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
105 self.difficulty_box.show() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
106 self.character_box.show() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
107 self.stage_box.hide() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
108 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
109 self.stage_comboboxtext.set_active_id(None) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
110 self.args.stage = None |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
111 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
112 self.start_window.hide() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
113 self.game_window.show() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
114 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
115 def on_extra_start_button_clicked(self, _): |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
116 self.difficulty_box.hide() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
117 self.character_box.show() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
118 self.stage_box.hide() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
119 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
120 self.difficulty_comboboxtext.set_active_id('4') |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
121 self.stage_comboboxtext.set_active_id('7') |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
122 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
123 self.start_window.hide() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
124 self.game_window.show() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
125 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
126 def on_practice_start_button_clicked(self, _): |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
127 self.difficulty_box.show() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
128 self.character_box.show() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
129 self.stage_box.show() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
130 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
131 self.start_window.hide() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
132 self.game_window.show() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
133 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
134 def on_options_button_clicked(self, _): |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
135 self.start_window.hide() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
136 self.options_window.show() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
137 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
138 def on_replay_button_clicked(self, _): |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
139 self.start_window.hide() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
140 self.replay_filechooserdialog.show() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
141 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
142 def on_inactive_button_clicked(self, _): |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
143 raise NotImplementedError('Menu not implemented') |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
144 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
145 on_netplay_start_button_clicked = on_inactive_button_clicked |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
146 on_score_button_clicked = on_inactive_button_clicked |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
147 on_music_room_button_clicked = on_inactive_button_clicked |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
148 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
149 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
150 # Game menu |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
151 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
152 def on_game_back_button_clicked(self, _): |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
153 self.game_window.hide() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
154 self.start_window.show() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
155 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
156 def on_play_button_clicked(self, _): |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
157 self.hide_and_play(self.game_window) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
158 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
159 def on_game_window_key_press_event(self, window, event_key): |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
160 if event_key.keyval == Gdk.KEY_Escape: |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
161 self.game_window.hide() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
162 self.start_window.show() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
163 elif event_key.state == Gdk.ModifierType.CONTROL_MASK and event_key.keyval == Gdk.KEY_q: |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
164 self.on_quit() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
165 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
166 def on_difficulty_comboboxtext_changed(self, item): |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
167 active = item.get_active_id() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
168 difficulty = int(active) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
169 self.config.set('rank', active if difficulty < 4 else None) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
170 self.args.rank = difficulty |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
171 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
172 def on_character_comboboxtext_changed(self, item): |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
173 character = int(item.get_active_id()) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
174 self.config.set('character', character) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
175 self.args.character = character |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
176 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
177 def on_stage_comboboxtext_changed(self, item): |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
178 stage = item.get_active_id() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
179 self.args.stage = int(stage) if stage is not None else None |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
180 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
181 def on_boss_rush_checkbutton_toggled(self, boss_rush_checkbutton): |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
182 active = boss_rush_checkbutton.get_active() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
183 self.config.set('boss-rush', active) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
184 self.args.boss_rush = active |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
185 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
186 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
187 # Replay dialog |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
188 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
189 def on_replay_filechooserdialog_close(self, _): |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
190 self.replay_filechooserdialog.hide() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
191 self.start_window.show() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
192 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
193 on_replay_cancel_button_clicked = on_replay_filechooserdialog_close |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
194 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
195 def on_replay_open_button_clicked(self, button): |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
196 try: |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
197 open(self.args.replay, 'rb').close() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
198 except (IOError, TypeError): |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
199 return |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
200 self.hide_and_play(self.replay_filechooserdialog) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
201 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
202 def on_replay_filechooserdialog_selection_changed(self, dialog): |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
203 self.args.replay = dialog.get_filename() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
204 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
205 def on_replay_filechooserdialog_file_activated(self, window): |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
206 self.args.replay = window.get_filename() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
207 self.hide_and_play(self.replay_filechooserdialog) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
208 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
209 def on_replay_filechooserdialog_key_press_event(self, window, event_key): |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
210 if event_key.keyval == Gdk.KEY_Escape: |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
211 self.replay_filechooserdialog.hide() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
212 self.start_window.show() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
213 elif event_key.state == Gdk.ModifierType.CONTROL_MASK and event_key.keyval == Gdk.KEY_q: |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
214 self.on_quit() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
215 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
216 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
217 # Options menu |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
218 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
219 def on_options_back_button_clicked(self, _): |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
220 self.options_window.hide() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
221 self.start_window.show() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
222 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
223 def on_options_window_key_press_event(self, window, event_key): |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
224 if event_key.keyval == Gdk.KEY_Escape: |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
225 self.options_window.hide() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
226 self.start_window.show() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
227 elif event_key.state == Gdk.ModifierType.CONTROL_MASK and event_key.keyval == Gdk.KEY_q: |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
228 self.on_quit() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
229 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
230 def on_path_filechooserbutton_file_set(self, path_filechooserbutton): |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
231 path = path_filechooserbutton.get_filename() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
232 self.config.set('path', path) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
233 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
234 def on_backend_comboboxtext_changed(self, backend_comboboxtext): |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
235 active = backend_comboboxtext.get_active_id() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
236 self.config.set('backend', active) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
237 backends = active.split() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
238 new_grids = [getattr(self, backend + '_grid') for backend in backends] |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
239 for grid in [self.opengl_grid, self.sdl_grid]: |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
240 if grid not in new_grids: |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
241 grid.hide() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
242 else: |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
243 grid.show() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
244 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
245 def on_flavor_comboboxtext_changed(self, flavor_comboboxtext): |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
246 active = flavor_comboboxtext.get_active_id() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
247 self.config.set('gl-flavor', active) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
248 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
249 def on_version_entry_changed(self, version_entry): |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
250 text = version_entry.get_text() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
251 if not GL_VERSION_REGEX.match(text): |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
252 raise ValueError('“%s” is not <digit>.<digit>' % text) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
253 self.config.set('gl-version', text) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
254 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
255 def on_double_buffer_checkbutton_clicked(self, double_buffer_checkbutton): |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
256 inconsistent = double_buffer_checkbutton.get_inconsistent() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
257 active = double_buffer_checkbutton.get_active() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
258 if inconsistent: |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
259 active = False |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
260 inconsistent = False |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
261 elif active: |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
262 active = True |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
263 else: |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
264 inconsistent = True |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
265 double_buffer_checkbutton.set_active(active) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
266 double_buffer_checkbutton.set_inconsistent(inconsistent) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
267 self.config.set('double-buffer', None if inconsistent else active) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
268 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
269 def on_fps_entry_changed(self, fps_entry): |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
270 text = fps_entry.get_text() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
271 try: |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
272 int(text) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
273 except ValueError: |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
274 raise ValueError('“%s” is not integer' % text) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
275 else: |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
276 self.config.set('fps-limit', text) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
277 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
278 def on_no_background_checkbutton_toggled(self, checkbutton): |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
279 active = checkbutton.get_active() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
280 self.config.set('no-background', not active) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
281 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
282 def on_no_particles_checkbutton_toggled(self, checkbutton): |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
283 active = checkbutton.get_active() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
284 self.config.set('no-particles', active) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
285 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
286 def on_no_sound_checkbutton_toggled(self, checkbutton): |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
287 active = checkbutton.get_active() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
288 self.config.set('no-sound', active) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
289 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
290 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
291 def menu(config, args): |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
292 assert Gtk |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
293 handler = Handler(config, args) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
294 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
295 builder = Gtk.Builder() |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
296 builder.add_from_file('data/menu.glade') |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
297 builder.connect_signals(handler) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
298 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
299 handler.init_gtk(builder) |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
300 |
e7a4731a278b
Add a GTK+ main menu, mimicking the original EoSD one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
301 Gtk.main() |