1# Copyright 2004-2021 Tom Rothamel <pytom@bishoujo.us>
2#
3# Permission is hereby granted, free of charge, to any person
4# obtaining a copy of this software and associated documentation files
5# (the "Software"), to deal in the Software without restriction,
6# including without limitation the rights to use, copy, modify, merge,
7# publish, distribute, sublicense, and/or sell copies of the Software,
8# and to permit persons to whom the Software is furnished to do so,
9# subject to the following conditions:
10#
11# The above copyright notice and this permission notice shall be
12# included in all copies or substantial portions of the Software.
13#
14# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22init python:
23
24    style.menu_button = Style(style.button, heavy=True, help='Buttons that are part of the main or game menus.')
25    style.menu_button_text = Style(style.button_text, heavy=True, help='The label of buttons that are part of the main or game menus.')
26
27    style.thin_hbox = Style(style.hbox, heavy=True, help='A hbox with a small amount of spacing.')
28    style.thick_hbox = Style(style.hbox, heavy=True, help='A hbox with a large amount of spacing.')
29    style.thin_vbox = Style(style.vbox, heavy=True, help='A vbox with a small amount of spacing.')
30    style.thick_vbox = Style(style.vbox, heavy=True, help='A vbox with a large amount of spacing.')
31
32    style.mm_menu_frame = Style(style.default, heavy=True, help='The frame containing the main menu.')
33    style.mm_menu_frame_vbox = Style(style.thin_vbox, heavy=True, help='The vbox containing the main menu.')
34    style.mm_button = Style(style.menu_button, heavy=True, help='A main menu button.')
35    style.mm_button_text = Style(style.menu_button_text, heavy=True, help='A main menu button label.')
36    style.default.drop_shadow = (1, 1)
37
38    style.gm_nav_frame = Style(style.default, heavy=True, help='The frame containing the navigation buttons.')
39    style.gm_nav_vbox = Style(style.thin_vbox, heavy=True, help='The vbox containing the navigation buttons.')
40    style.gm_nav_button = Style(style.menu_button, heavy=True, help='A navigation button.')
41    style.gm_nav_button_text = Style(style.menu_button_text, heavy=True, help='A navigation button label.')
42
43    style.file_picker_entry = Style(style.menu_button, heavy=True, help='A button you click to save or load a file.')
44    style.file_picker_entry_box = Style(style.thin_hbox, heavy=True, help='The box inside that button.')
45    style.file_picker_text = Style(style.default, heavy=True, help='Base style for text inside a file picker entry.')
46    style.file_picker_new = Style(style.file_picker_text, heavy=True, help='The number of the newest file.')
47    style.file_picker_old = Style(style.file_picker_text, heavy=True, help='The number of non-newest files.')
48    style.file_picker_extra_info = Style(style.file_picker_text, heavy=True, help='Extra text (the date and save info) of a file.')
49    style.file_picker_empty_slot = Style(style.file_picker_text, heavy=True, help='The style of "Empty Slot" text.')
50    style.file_picker_frame = Style(style.default, heavy=True, help='The frame containing the file picker.')
51    style.file_picker_frame_vbox = Style(style.thin_vbox, heavy=True, help='The box containing file picker navigation and the file picker grid.')
52    style.file_picker_navbox = Style(style.thick_hbox, heavy=True, help='The box containing the file picker navigation buttons.')
53    style.file_picker_nav_button = Style(style.menu_button, heavy=True, help='A file picker navigation button.')
54    style.file_picker_nav_button_text = Style(style.menu_button_text, heavy=True, help='A file picker navigation button label.')
55    style.file_picker_grid = Style(style.default, heavy=True, help='The grid containing the entries in the file picker.')
56
57    style.yesno_frame = Style(style.default, heavy=True, help='The frame containing the yes/no dialog.')
58    style.yesno_frame_vbox = Style(style.thick_vbox, heavy=True, help='Separates the label from the buttons in a yes/no dialog.')
59    style.yesno_label = Style(style.default, heavy=True, help='The label of a yes/no dialog.')
60    style.yesno_button_hbox = Style(style.thick_hbox, heavy=True, help="The box containing the Yes and No buttons.")
61    style.yesno_button = Style(style.menu_button, heavy=True, help='A Yes/No button.')
62    style.yesno_button_text = Style(style.menu_button_text, heavy=True, help='A Yes/No button label.')
63
64    style.prefs_frame = Style(style.default, heavy=True, help='')
65    style.prefs_pref_frame = Style(style.default, heavy=True, help='')
66    style.prefs_pref_vbox = Style(style.thin_vbox, heavy=True, help='')
67    style.prefs_label = Style(style.default, heavy=True, help='')
68    style.prefs_hbox = Style(style.default, heavy=True, help='')
69    style.prefs_button = Style(style.menu_button, heavy=True, help='')
70    style.prefs_button_text = Style(style.menu_button_text, heavy=True, help='')
71    style.soundtest_button = Style(style.prefs_button, heavy=True, help='')
72    style.soundtest_button_text = Style(style.prefs_button_text, heavy=True, help='')
73    style.prefs_slider = Style(style.bar, heavy=True, help='')
74    style.prefs_volume_slider = Style(style.prefs_slider, heavy=True, help='')
75    style.prefs_spinner = Style(style.default, heavy=True, help='')
76    style.prefs_spinner_label = Style(style.prefs_label, heavy=True, help='')
77    style.prefs_spinner_button = Style(style.prefs_button, heavy=True, help='')
78    style.prefs_spinner_button_text = Style(style.prefs_button_text, heavy=True, help='')
79    style.prefs_js_frame = Style(style.prefs_pref_frame, heavy=True, help='')
80    style.prefs_js_vbox = Style(style.prefs_pref_vbox, heavy=True, help='')
81    style.prefs_js_button = Style(style.prefs_button, heavy=True, help='')
82    style.prefs_js_button_text = Style(style.prefs_button_text, heavy=True, help='')
83    style.js_frame = Style(style.prefs_frame, heavy=True, help='')
84    style.js_frame_vbox = Style(style.thick_vbox, heavy=True, help='')
85    style.js_function_label = Style(style.prefs_label, heavy=True, help='')
86    style.js_prompt_label = Style(style.prefs_label, heavy=True, help='')
87    style.prefs_jump = Style(style.prefs_pref_frame, heavy=True, help='')
88    style.prefs_jump_button = Style(style.prefs_button, heavy=True, help='')
89    style.prefs_jump_button_text = Style(style.prefs_button_text, heavy=True, help='')
90    style.prefs_column = Style(style.default, heavy=True, help='')
91    style.prefs_left = Style(style.prefs_column, heavy=True, help='')
92    style.prefs_center = Style(style.prefs_column, heavy=True, help='')
93    style.prefs_right = Style(style.prefs_column, heavy=True, help='')
94    style.prefs_joystick = Style(style.prefs_center, heavy=True, help='')
95
96    style.thin_hbox.spacing = 3
97    style.thick_hbox.spacing = 30
98    style.thin_vbox.spacing = 0
99    style.thick_vbox.spacing = 30
100
101    dark_cyan = (0, 192, 255, 255)
102    bright_cyan = (0, 255, 255, 255)
103    dark_red = (255, 128, 128, 255)
104    bright_red = (255, 64, 64, 255)
105    green = (0, 128, 0, 255)
106
107    # Frames.
108    style.frame.background = Solid((0, 0, 128, 128))
109    style.frame.xpadding = 10
110    style.frame.ypadding = 5
111    style.frame.xmargin = 10
112    style.frame.ymargin = 5
113
114
115    ######################################################################
116    # Buttons.
117
118    style.button_text.color = dark_cyan
119    style.button_text.hover_color = bright_cyan
120    style.button_text.insensitive_color = (192, 192, 192, 255)
121    style.button_text.size = 24
122    style.button_text.drop_shadow = (2, 2)
123
124    style.button_text.selected_color = dark_red
125    style.button_text.selected_hover_color = bright_red
126
127    style.button_text.xpos = 0.5
128    style.button_text.xanchor = 0.5
129
130    style.menu_button.xpos = 0.5
131    style.menu_button.xanchor = 0.5
132
133
134    ######################################################################
135    # Bar.
136
137    style.bar.ymaximum = 22
138
139    style.bar.left_bar = Solid(bright_cyan)
140    style.bar.right_bar = Solid((0, 0, 0, 128))
141    style.bar.bottom_bar = Solid(bright_cyan)
142    style.bar.top_bar = Solid((0, 0, 0, 128))
143    style.bar.left_gutter = 0
144    style.bar.right_gutter = 0
145    style.bar.thumb = None
146    style.bar.thumb_offset = 0
147    style.bar.thumb_shadow = None
148
149    style.vbar.xmaximum = 22
150
151    style.vbar.left_bar = Solid(bright_cyan)
152    style.vbar.right_bar = Solid((0, 0, 0, 128))
153    style.vbar.bottom_bar = Solid(bright_cyan)
154    style.vbar.top_bar = Solid((0, 0, 0, 128))
155    style.vbar.left_gutter = 0
156    style.vbar.right_gutter = 0
157    style.vbar.bottom_gutter = 0
158    style.vbar.top_gutter = 0
159    style.vbar.thumb = None
160    style.vbar.thumb_offset = 0
161    style.vbar.thumb_shadow = None
162
163    style.vscrollbar.set_parent(style.vbar)
164    style.scrollbar.set_parent(style.bar)
165
166    style.vscrollbar.bottom_bar = Solid((0, 0, 0, 128))
167    style.vscrollbar.top_bar = Solid(bright_cyan)
168
169    style.slider.ymaximum = 1
170    style.vslider.xmaximum = 1
171
172    ######################################################################
173    # Main menu.
174
175    style.mm_menu_frame.xpos = 0.9
176    style.mm_menu_frame.xanchor = 1.0
177    style.mm_menu_frame.ypos = 0.9
178    style.mm_menu_frame.yanchor = 1.0
179
180
181    ######################################################################
182    # Game menu common.
183
184    style.gm_nav_frame.xpos = 0.95
185    style.gm_nav_frame.xanchor = 1.0
186    style.gm_nav_frame.ypos = 0.95
187    style.gm_nav_frame.yanchor = 1.0
188
189
190    ##############################################################################
191    # File picker.
192
193    style.file_picker_frame.xpos = 0
194    style.file_picker_frame.xanchor = 0.0
195    style.file_picker_frame.ypos = 0
196    style.file_picker_frame.yanchor = 0.0
197    style.file_picker_frame.xpadding = 5
198
199    style.file_picker_navbox.xpos = 10
200
201    style.file_picker_grid.xfill = True
202
203    style.file_picker_entry.xpadding = 5
204    style.file_picker_entry.ypadding = 2
205    style.file_picker_entry.xmargin = 5
206    style.file_picker_entry.xfill = True
207    style.file_picker_entry.ymargin = 2
208    style.file_picker_entry.background = Solid((255, 255, 255, 255))
209    style.file_picker_entry.hover_background = Solid((255, 255, 192, 255))
210
211    style.file_picker_text.size = 16
212    style.file_picker_text.color = dark_cyan
213    style.file_picker_text.hover_color = bright_cyan
214
215    style.file_picker_new.hover_color = bright_red
216    style.file_picker_new.idle_color = dark_red
217
218    style.file_picker_new.minwidth = 40
219    style.file_picker_old.minwidth = 40
220
221    style.file_picker_new.text_align = 1.0
222    style.file_picker_old.text_align = 1.0
223
224
225    ######################################################################
226    # Yes/No Dialog
227
228    style.yesno_label.color = green
229    style.yesno_label.textalign = 0.5
230    style.yesno_label.xpos = 0.5
231    style.yesno_label.xanchor = 0.5
232
233    style.yesno_frame.xfill = True
234    style.yesno_frame.yminimum = 0.5
235    style.yesno_frame.xmargin = .1
236
237    style.yesno_frame_vbox.xpos = 0.5
238    style.yesno_frame_vbox.xanchor = 0.5
239    style.yesno_frame_vbox.ypos = 0.5
240    style.yesno_frame_vbox.yanchor = 0.5
241
242    style.yesno_button_hbox.xalign = 0.5
243    style.yesno_button_hbox.spacing = 100
244
245    ##############################################################################
246    # Preferences.
247
248
249    style.prefs_pref_frame.xpos = 0.5
250    style.prefs_pref_frame.xanchor = 0.5
251    style.prefs_pref_frame.bottom_margin = 10
252
253    style.prefs_label.xpos = 0.5
254    style.prefs_label.xanchor = 0.5
255    style.prefs_label.color = green
256
257    style.prefs_slider.xmaximum=200
258    style.prefs_slider.ymaximum=22
259    style.prefs_slider.xpos = 0.5
260    style.prefs_slider.xanchor = 0.5
261
262    style.prefs_hbox.xpos = 0.5
263    style.prefs_hbox.xanchor = 0.5
264
265    style.prefs_button.xpos = 0.5
266    style.prefs_button.xanchor = 0.5
267
268    style.prefs_button.selected_xpos = 0.5
269    style.prefs_button.selected_xanchor = 0.5
270
271    style.prefs_frame.xfill=True
272    style.prefs_frame.ypadding = 0.05
273
274    style.prefs_column.spacing = 6
275
276    style.prefs_left.xanchor = 0.5
277    style.prefs_left.xpos = 1.0 / 6.0
278
279    style.prefs_center.xanchor = 0.5
280    style.prefs_center.xpos = 3.0 / 6.0
281
282    style.prefs_right.xanchor = 0.5
283    style.prefs_right.xpos = 5.0 / 6.0
284
285    style.prefs_spinner.xpos = 0.5
286    style.prefs_spinner.xanchor = 0.5
287
288    style.prefs_spinner_label.minwidth = 100
289    style.prefs_spinner_label.textalign = 0.5
290
291    style.prefs_js_button_text.size = 18
292    style.prefs_js_button_text.drop_shadow = (1, 1)
293
294    style.js_function_label.textalign = 0.5
295    style.js_prompt_label.textalign = 0.5
296
297    style.js_frame.xfill = True
298    style.js_frame.yminimum = 0.5
299    style.js_frame.xmargin = .1
300
301    style.js_frame_vbox.xpos = 0.5
302    style.js_frame_vbox.xanchor = 0.5
303    style.js_frame_vbox.ypos = 0.5
304    style.js_frame_vbox.yanchor = 0.5
305
306    style.soundtest_button.activate_sound = None
307
308    style.window.background = Solid((0, 0, 128, 128))
309    style.window.xpadding = 10
310    style.window.ypadding = 5
311    style.window.xmargin = 10
312    style.window.ymargin = 5
313    style.window.xfill = True
314    style.window.yfill = False
315    style.window.xminimum = 0 # Includes margins and padding.
316    style.window.yminimum = 150 # Includes margins and padding.
317
318
319
320    ######################################################################
321    # Compatibility names for renamed styles.
322    style.file_picker_window_vbox = style.file_picker_frame_vbox
323    style.prefs_window = style.prefs_frame
324    style.mm_root_window = style.mm_root
325    style.file_picker_window = style.file_picker_frame
326    style.prefs_pref = style.prefs_pref_frame
327    style.gm_root_window = style.gm_root
328    style.yesno_window_vbox = style.yesno_frame_vbox
329    style.joyprompt_label = style.js_prompt_label
330    style.gm_nav_window = style.gm_nav_frame
331    style.joy_window = style.js_frame
332    style.mm_menu_window = style.mm_menu_frame
333    style.error_window = style.error_root
334    style.joyfunc_label = style.js_function_label
335    style.joy_vbox = style.js_frame_vbox
336    style.yesno_window = style.yesno_frame
337    style.mm_menu_window_vbox = style.mm_menu_frame_vbox
338    style.menu_choice_button_text = style.menu_choice
339    style.menu_choice_chosen_button_text = style.menu_choice_chosen
340
341    store._selected_compat = [ ]
342
343    class _SelectedCompat(object):
344
345        _is_style_compat = True
346
347        def __init__(self, target):
348            self.target = target
349            _selected_compat.append(self)
350
351        def clear(self):
352            self.__dict__ = { "target" : self.target }
353
354
355    style.selected_button = _SelectedCompat('button')
356    style.selected_button_text = _SelectedCompat('button_text')
357    style.gm_nav_selected_button = _SelectedCompat('gm_nav_button')
358    style.gm_nav_selected_button_text = _SelectedCompat('gm_nav_button_text')
359    style.prefs_selected_button = _SelectedCompat('prefs_button')
360    style.prefs_selected_button_text = _SelectedCompat('prefs_button_text')
361
362    def _apply_selected_compat():
363        for scs in _selected_compat:
364            target = getattr(style, scs.target)
365
366            for k, v in scs.__dict__.items():
367                if k == "target":
368                    continue
369
370                setattr(target, k, v)
371
372    layout.compat_funcs.append(_apply_selected_compat)
373