11c6e48696259039bb380aff0f1d92828f2f2680
1 from direct
.gui
.DirectGui
import DirectButton
2 from ya2
.utils
.gfx
import DirectGuiMixin
3 from pmachines
.gui
.base_page
import BasePage
6 class PlayPage(BasePage
):
8 def __init__(self
, menu
, test_positions
, gui_args
, scenes
, option_file
, running_functional_tests
, application_fsm
):
9 super().__init
__(menu
, running_functional_tests
)
10 self
._test
_positions
= test_positions
12 self
._option
_file
= option_file
13 self
._application
_fsm
= application_fsm
14 for k
in list(self
._test
_positions
.keys()): del self
._test
_positions
[k
]
16 cmn
= gui_args
.button
.copy() |
{
17 'frameSize': (-2.4, 2.4, -2.4, 2.4),
18 'frameColor': (1, 1, 1, .8),
20 left
= - (dx
:= .8) * (min(4, len(self
._scenes
)) - 1) / 2
21 from pmachines
.scene
.scene
import Scene
22 for i
, scene_name
in enumerate(self
._scenes
):
23 top
= .1 if len(self
._scenes
) < 5 else .6
24 row
= 0 if i
< 4 else 1
26 if Scene
.is_done(scene_name
):
27 new_cmn
['frameColor'] = (1, 1, 1, .4)
28 new_cmn
['text_fg'] = (.9, .9, .9, .4)
29 self
._widgets
+= [DirectButton(
30 text
=Scene
.name(scene_name
), pos
=(left
+ dx
* (i
% 4), 1, top
- dx
* row
),
31 command
=self
.start
, extraArgs
=[scene_name
], text_wordwrap
=6,
32 frameTexture
='assets/images/scenes/%s.dds' % scene_name
,
34 self
._widgets
[-1].__class
__ = type('DirectButtonMixed', (DirectButton
, DirectGuiMixin
), {})
35 name
= scene_name
.lower()
36 self
._test
_positions
[name
] = self
._widgets
[-1].pos_pixel()
38 tnode
= self
._widgets
[-1].component('text%s' % j
).textNode
39 height
= - tnode
.getLineHeight() / 2
40 height
+= (tnode
.get_height() - tnode
.get_line_height()) / 2
41 self
._widgets
[-1].component('text%s' % j
).set_pos(0, 0, height
)
42 self
._widgets
+= [DirectButton(
43 text
=_('Back'), pos
=(0, 1, -.8), command
=self
.on_back
,
45 self
._widgets
[-1].__class
__ = type('DirectButtonMixed', (DirectButton
, DirectGuiMixin
), {})
46 self
._test
_positions
['back'] = self
._widgets
[-1].pos_pixel()
49 self
._application
_fsm
.demand('Scene', cls
)