예제 #1
0
    def __set_layout(self, model, surface_manager, action_factory, rng,
                     rules_engine, configuration):
        """
        Set layout of this window
        """
        layout = QVBoxLayout()
        status_layout = QHBoxLayout()

        self.hit_points_widget = HitPointsWidget(
            parent=self, surface_manager=surface_manager)
        self.effects_widget = EffectsWidget(parent=self,
                                            surface_manager=surface_manager)

        self.spell_selector = SpellSelectorWidget(
            parent=self, surface_manager=surface_manager)

        self.map_widget = PlayMapWidget(parent=self,
                                        model=model,
                                        surface_manager=surface_manager,
                                        action_factory=action_factory,
                                        rng=rng,
                                        rules_engine=rules_engine,
                                        configuration=configuration)
        self.map_widget.MenuRequested.connect(self.on_menu_requested)
        self.map_widget.EndScreenRequested.connect(
            self.on_end_screen_requested)
        self.map_widget.NextSpellRequested.connect(self.on_next_spell)
        self.map_widget.PreviousSpellRequested.connect(self.on_previous_spell)

        self.message_widget = EventMessageWidget(parent=self)
        self.message_widget.setMaximumHeight(100)

        status_layout.addWidget(self.hit_points_widget)
        status_layout.addWidget(self.spell_selector)
        status_layout.addWidget(self.effects_widget)
        status_layout.addStretch()

        layout.addLayout(status_layout)
        layout.addWidget(self.map_widget)
        layout.addWidget(self.message_widget)
        self.setLayout(layout)
        self.resize(QSize(640, 480))
예제 #2
0
파일: map.py 프로젝트: tuturto/pyherc
    def __set_layout(self, model, surface_manager, action_factory, rng,
                     rules_engine, configuration):
        """
        Set layout of this window
        """
        layout = QVBoxLayout()
        status_layout = QHBoxLayout()

        self.hit_points_widget = HitPointsWidget(parent = self,
                                                 surface_manager = surface_manager)
        self.effects_widget = EffectsWidget(parent = self,
                                            surface_manager = surface_manager)

        self.spell_selector = SpellSelectorWidget(parent = self,
                                                  surface_manager = surface_manager)

        self.map_widget = PlayMapWidget(parent = self,
                                        model = model,
                                        surface_manager = surface_manager,
                                        action_factory = action_factory,
                                        rng = rng,
                                        rules_engine = rules_engine,
                                        configuration = configuration)
        self.map_widget.MenuRequested.connect(self.on_menu_requested)
        self.map_widget.EndScreenRequested.connect(self.on_end_screen_requested)
        self.map_widget.NextSpellRequested.connect(self.on_next_spell)
        self.map_widget.PreviousSpellRequested.connect(self.on_previous_spell)

        self.message_widget = EventMessageWidget(parent = self)
        self.message_widget.setMaximumHeight(100)

        status_layout.addWidget(self.hit_points_widget)
        status_layout.addWidget(self.spell_selector)
        status_layout.addWidget(self.effects_widget)
        status_layout.addStretch()

        layout.addLayout(status_layout)
        layout.addWidget(self.map_widget)
        layout.addWidget(self.message_widget)
        self.setLayout(layout)
        self.resize(QSize(640, 480))
예제 #3
0
파일: map.py 프로젝트: tuturto/pyherc
class PlayMapWindow(QWidget):
    """
    Window for displaying playing world

    .. versionadded:: 0.5
    """
    def __init__(self, parent, model, surface_manager, action_factory, rng,
                 rules_engine, configuration):
        """
        Default constructor
        """
        super().__init__(parent)

        self.model = model
        self.surface_manager = surface_manager
        self.action_factory = action_factory
        self.rng = rng
        self.current_level = None
        self.configuration = configuration

        self.hit_points_widget = None
        self.message_widget = None
        self.map_widget = None
        self.effects_widget = None
        self.spell_selector = None

        self.__set_layout(model, surface_manager, action_factory, rng,
                          rules_engine, configuration)

    MenuRequested = pyqtSignal(name='MenuRequested')
    EndScreenRequested = pyqtSignal(name='EndScreenRequested')

    def __set_layout(self, model, surface_manager, action_factory, rng,
                     rules_engine, configuration):
        """
        Set layout of this window
        """
        layout = QVBoxLayout()
        status_layout = QHBoxLayout()

        self.hit_points_widget = HitPointsWidget(parent = self,
                                                 surface_manager = surface_manager)
        self.effects_widget = EffectsWidget(parent = self,
                                            surface_manager = surface_manager)

        self.spell_selector = SpellSelectorWidget(parent = self,
                                                  surface_manager = surface_manager)

        self.map_widget = PlayMapWidget(parent = self,
                                        model = model,
                                        surface_manager = surface_manager,
                                        action_factory = action_factory,
                                        rng = rng,
                                        rules_engine = rules_engine,
                                        configuration = configuration)
        self.map_widget.MenuRequested.connect(self.on_menu_requested)
        self.map_widget.EndScreenRequested.connect(self.on_end_screen_requested)
        self.map_widget.NextSpellRequested.connect(self.on_next_spell)
        self.map_widget.PreviousSpellRequested.connect(self.on_previous_spell)

        self.message_widget = EventMessageWidget(parent = self)
        self.message_widget.setMaximumHeight(100)

        status_layout.addWidget(self.hit_points_widget)
        status_layout.addWidget(self.spell_selector)
        status_layout.addWidget(self.effects_widget)
        status_layout.addStretch()

        layout.addLayout(status_layout)
        layout.addWidget(self.map_widget)
        layout.addWidget(self.message_widget)
        self.setLayout(layout)
        self.resize(QSize(640, 480))

    def construct_scene(self):
        """
        Create scene to display
        """
        self.map_widget.construct_scene()
        self.model.player.register_event_listener(self.message_widget)
        self.message_widget.set_point_of_view(self.model.player)
        self.model.player.register_for_updates(self.effects_widget)

    def on_menu_requested(self):
        """
        Handle requesting menu window
        """
        self.MenuRequested.emit()

    def on_end_screen_requested(self):
        """
        Handle requesting end screen

        .. versionadded:: 0.8
        """
        self.EndScreenRequested.emit()

    def on_next_spell(self):
        """
        Handle selecting next spell

        .. versionadded:: 0.10
        """
        self.spell_selector.next_spell()

    def on_previous_spell(self):
        """
        Handle selecting previous spell

        .. versionadded:: 0.10
        """
        self.spell_selector.previous_spell()
예제 #4
0
class PlayMapWindow(QWidget):
    """
    Window for displaying playing world

    .. versionadded:: 0.5
    """
    def __init__(self, parent, model, surface_manager, action_factory, rng,
                 rules_engine, configuration):
        """
        Default constructor
        """
        super().__init__(parent)

        self.model = model
        self.surface_manager = surface_manager
        self.action_factory = action_factory
        self.rng = rng
        self.current_level = None
        self.configuration = configuration

        self.hit_points_widget = None
        self.message_widget = None
        self.map_widget = None
        self.effects_widget = None
        self.spell_selector = None

        self.__set_layout(model, surface_manager, action_factory, rng,
                          rules_engine, configuration)

    MenuRequested = pyqtSignal(name='MenuRequested')
    EndScreenRequested = pyqtSignal(name='EndScreenRequested')

    def __set_layout(self, model, surface_manager, action_factory, rng,
                     rules_engine, configuration):
        """
        Set layout of this window
        """
        layout = QVBoxLayout()
        status_layout = QHBoxLayout()

        self.hit_points_widget = HitPointsWidget(
            parent=self, surface_manager=surface_manager)
        self.effects_widget = EffectsWidget(parent=self,
                                            surface_manager=surface_manager)

        self.spell_selector = SpellSelectorWidget(
            parent=self, surface_manager=surface_manager)

        self.map_widget = PlayMapWidget(parent=self,
                                        model=model,
                                        surface_manager=surface_manager,
                                        action_factory=action_factory,
                                        rng=rng,
                                        rules_engine=rules_engine,
                                        configuration=configuration)
        self.map_widget.MenuRequested.connect(self.on_menu_requested)
        self.map_widget.EndScreenRequested.connect(
            self.on_end_screen_requested)
        self.map_widget.NextSpellRequested.connect(self.on_next_spell)
        self.map_widget.PreviousSpellRequested.connect(self.on_previous_spell)

        self.message_widget = EventMessageWidget(parent=self)
        self.message_widget.setMaximumHeight(100)

        status_layout.addWidget(self.hit_points_widget)
        status_layout.addWidget(self.spell_selector)
        status_layout.addWidget(self.effects_widget)
        status_layout.addStretch()

        layout.addLayout(status_layout)
        layout.addWidget(self.map_widget)
        layout.addWidget(self.message_widget)
        self.setLayout(layout)
        self.resize(QSize(640, 480))

    def construct_scene(self):
        """
        Create scene to display
        """
        self.map_widget.construct_scene()
        self.model.player.register_event_listener(self.message_widget)
        self.message_widget.set_point_of_view(self.model.player)
        self.model.player.register_for_updates(self.effects_widget)

    def on_menu_requested(self):
        """
        Handle requesting menu window
        """
        self.MenuRequested.emit()

    def on_end_screen_requested(self):
        """
        Handle requesting end screen

        .. versionadded:: 0.8
        """
        self.EndScreenRequested.emit()

    def on_next_spell(self):
        """
        Handle selecting next spell

        .. versionadded:: 0.10
        """
        self.spell_selector.next_spell()

    def on_previous_spell(self):
        """
        Handle selecting previous spell

        .. versionadded:: 0.10
        """
        self.spell_selector.previous_spell()