1 from collections
import namedtuple
2 from panda3d
.core
import TextNode
3 from direct
.gui
.DirectGuiGlobals
import FLAT
4 from ya2
.utils
.gui
import GuiTools
5 from ya2
.utils
.audio
import AudioTools
6 from pmachines
.gui
.main_page
import MainPage
7 from pmachines
.gui
.play_page
import PlayPage
8 from pmachines
.gui
.options_page
import OptionsPage
9 from pmachines
.gui
.credits_page
import CreditsPage
14 def __init__(self
, application_fsm
, language_manager
, option_file
,
16 running_functional_tests
, test_positions
):
18 self
.__application
_fsm
= application_fsm
19 self
.__language
_manager
= language_manager
20 self
.__option
_file
= option_file
21 self
.__gfx
_pipeline
= gfx_pipeline
22 self
.__scenes
= scenes
23 self
.__running
_functional
_tests
= running_functional_tests
24 self
.__test
_positions
= test_positions
25 self
.__gui
_args
= self
.__build
_gui
_args
()
29 def __build_gui_args(self
):
32 'text_font': GuiTools
.load_font('assets/fonts/Hanken-Book.ttf'),
33 'text_fg': (.9, .9, .9, 1),
35 'frameColor': (.4, .4, .4, .14),
36 'rolloverSound': AudioTools
.load_sfx('assets/audio/sfx/rollover.ogg'),
37 'clickSound': AudioTools
.load_sfx('assets/audio/sfx/click.ogg')}
38 button
= {'frameSize': (-4.8, 4.8, -.6, 1.2)} | base
39 h
= button
['frameColor']
40 h
= (h
[0] + .2, h
[1] + .2, h
[2] + .2, h
[3] + .2)
42 'item_frameColor': button
['frameColor'],
43 'popupMarker_frameColor': button
['frameColor'],
44 'item_relief': button
['relief'],
45 'item_text_font': button
['text_font'],
46 'item_text_fg': button
['text_fg'],
49 'text_align': TextNode
.A_center
,
51 f
= option
['frameSize']
52 option
['frameSize'] = f
[0], f
[1] - .56, f
[2], f
[3]
55 'thumb_frameColor': (.4, .4, .4, .4),
58 del slider
['rolloverSound']
59 del slider
['clickSound']
60 GuiArgs
= namedtuple('GuiArgs', 'button option slider')
61 gui_args
= GuiArgs(button
, option
, slider
)
64 def set_page(self
, page_name
):
66 if self
.__page
: self
.__page
.destroy()
68 case
'main': p
= MainPage(self
, self
.__test
_positions
, self
.__gui
_args
, self
.__running
_functional
_tests
, self
.__scenes
, self
.__application
_fsm
)
69 case
'credits': p
= CreditsPage(self
, self
.__test
_positions
, self
.__gui
_args
, self
.__option
_file
, self
.__running
_functional
_tests
)
70 case
'options': p
= OptionsPage(self
, self
.__test
_positions
, self
.__option
_file
, self
.__gui
_args
, self
.__language
_manager
, self
.__running
_functional
_tests
, self
.__gfx
_pipeline
)
71 case
'play': p
= PlayPage(self
, self
.__test
_positions
, self
.__gui
_args
, self
.__scenes
, self
.__option
_file
, self
.__running
_functional
_tests
, self
.__application
_fsm
)