コード例 #1
0
ファイル: ui.py プロジェクト: freneticmonkey/Epsilon
    def _build_ui(self):
        
        stats_layout = FoldingBox('stats', content=
                        # each box needs a content layout
                        VLayout(children =
                        [
                            Label('0000.0 fps', name='fps_label'),
                            HLayout(children=
                            [
                                Label('MoUI:', hexpand=False),
                                Label('', name='mouse_over')
                            ]),
                            ])
                        )
        
        wf = False
        sg = True
        sb = False
        uf = True
        if Settings.has_option('RenderSettings','wireframe'):
            wf = Settings.get('RenderSettings','wireframe')

        if Settings.has_option('RenderSettings','grid'):
            sg = Settings.get('RenderSettings','grid')

        if Settings.has_option('RenderSettings','draw_bounds'):
            sb = Settings.get('RenderSettings','draw_bounds')

        if Settings.has_option('RenderSettings','update_frustum'):
            uf = Settings.get('RenderSettings','update_frustum')
        
        settings_layout = FoldingBox('settings', content=
                                VLayout(children=
                                [
                                    # a checkbox, note the action function is provided directly
                                    Checkbox('Show wireframe', h=100, action=self.show_wireframe_action, value=wf),
                                    Checkbox('Show Grid', h=100, action=self.show_grid_action,value=sg),
                                    Checkbox('Show Bounds', h=100, action=self.show_bounds_action,value=sb),
                                    Checkbox('Update Frustum', h=100, action=self.update_frustum_action,value=uf),
                                    Button('Quit', action=self.quit_action),
                                ])
                            )
        
        self._dialog = Dialogue('Inspector',
                                x=20,
                                y=550, 
                                content=
                                VLayout(autosizex=True, 
                                        hpadding=0, 
                                        children=
                                        [
                                         stats_layout,
                                         settings_layout
                                        ])
                                )
        
        # self._console = Dialogue('Python console', 
        self._console = Console('Python Console',
                                 x=20, 
                                 y=50,
                                 # content=VLayout(autosizex=True,
                                 #                 hpadding=0,
                                 #                 children=
                                 #                 [
                                 #                    Label('text\nsome\nthing',w=390, h=300),
                                 #                    TextInput(text=">>>", w=390)
                                 #                 ])
                                )
        
        
        self._frame.add(self._dialog)

        # Setup the UI console logger
        self._ui_log_listener = LogListener()
        self._ui_log_listener.set_log_func(self._console.new_line)
        self._frame.add(self._console)
        
        self._mouse_over_label = self._frame.get_element_by_name('mouse_over')
        self._fps_label = self._frame.get_element_by_name('fps_label')
コード例 #2
0
ファイル: ui.py プロジェクト: freneticmonkey/Epsilon
class MainUI(UIBaseWindow):
        
    def _setup_ui(self):
        
        self._camera = None
        
        self._listener = UIListener(self)
        self._build_ui()
        
    def _build_ui(self):
        
        stats_layout = FoldingBox('stats', content=
                        # each box needs a content layout
                        VLayout(children =
                        [
                            Label('0000.0 fps', name='fps_label'),
                            HLayout(children=
                            [
                                Label('MoUI:', hexpand=False),
                                Label('', name='mouse_over')
                            ]),
                            ])
                        )
        
        wf = False
        sg = True
        sb = False
        uf = True
        if Settings.has_option('RenderSettings','wireframe'):
            wf = Settings.get('RenderSettings','wireframe')

        if Settings.has_option('RenderSettings','grid'):
            sg = Settings.get('RenderSettings','grid')

        if Settings.has_option('RenderSettings','draw_bounds'):
            sb = Settings.get('RenderSettings','draw_bounds')

        if Settings.has_option('RenderSettings','update_frustum'):
            uf = Settings.get('RenderSettings','update_frustum')
        
        settings_layout = FoldingBox('settings', content=
                                VLayout(children=
                                [
                                    # a checkbox, note the action function is provided directly
                                    Checkbox('Show wireframe', h=100, action=self.show_wireframe_action, value=wf),
                                    Checkbox('Show Grid', h=100, action=self.show_grid_action,value=sg),
                                    Checkbox('Show Bounds', h=100, action=self.show_bounds_action,value=sb),
                                    Checkbox('Update Frustum', h=100, action=self.update_frustum_action,value=uf),
                                    Button('Quit', action=self.quit_action),
                                ])
                            )
        
        self._dialog = Dialogue('Inspector',
                                x=20,
                                y=550, 
                                content=
                                VLayout(autosizex=True, 
                                        hpadding=0, 
                                        children=
                                        [
                                         stats_layout,
                                         settings_layout
                                        ])
                                )
        
        # self._console = Dialogue('Python console', 
        self._console = Console('Python Console',
                                 x=20, 
                                 y=50,
                                 # content=VLayout(autosizex=True,
                                 #                 hpadding=0,
                                 #                 children=
                                 #                 [
                                 #                    Label('text\nsome\nthing',w=390, h=300),
                                 #                    TextInput(text=">>>", w=390)
                                 #                 ])
                                )
        
        
        self._frame.add(self._dialog)

        # Setup the UI console logger
        self._ui_log_listener = LogListener()
        self._ui_log_listener.set_log_func(self._console.new_line)
        self._frame.add(self._console)
        
        self._mouse_over_label = self._frame.get_element_by_name('mouse_over')
        self._fps_label = self._frame.get_element_by_name('fps_label')
        #self._camera_pos_label = self._frame.get_element_by_name('camera_pos_label')
    
    def button_action(self, button):
        Logger.Log("A button was clicked!")
        
    def show_wireframe_action(self, checkbox):
        #RenderSettings.set_setting("wireframe",checkbox.value)
        Settings.set('RenderSettings','wireframe', checkbox.value)
        
    def show_grid_action(self, checkbox):
        #RenderSettings.set_setting("grid",checkbox.value)
        Settings.set('RenderSettings','grid', checkbox.value)
        
    def show_bounds_action(self, checkbox):
        #RenderSettings.set_setting("draw_bounds",checkbox.value)
        Settings.set('RenderSettings','draw_bounds', checkbox.value)

    def update_frustum_action(self, checkbox):
        #RenderSettings.set_setting("update_frustum",checkbox.value)
        Settings.set('RenderSettings','update_frustum', checkbox.value)

    def quit_action(self, button):
        QuitEvent().send()
        
    # UIListener accessors
    def set_mouse_over(self, mouse_over):
        text = "Mouse Off"
        if mouse_over:
            text = "Mouse On"
        
        if not self._mouse_over_label is None:
            self._mouse_over_label.text = text

    def update_frustum_status(self, data):
        for i in range(0, len(data)):
            self._fcbs[i].value = data[i]

    def draw(self):
        #self._window.clear()
        self._fps_label.text = "FPS: %3.2f " % Time.fps
        self._frame.draw()