Beispiel #1
0
    def translated_dialog_choice(self, game, action, contexts):
        """Asks the player to make a choice.

        :param game: The main game object that contains all the game's variables.
        :param action: The action (tuple) retrieved from the database that contains the action's
            parameters

        :type game: core.control.Control
        :type action: Tuple

        :rtype: None
        :returns: None

        Valid Parameters: choice1:choice2,var_key
        """
        def set_variable(game, player, var_key, var_value):
            player.game_variables[var_key] = var_value
            game.pop_state()
            game.pop_state()

        # Get the player object from the game.
        player = game.player1

        var_list = action.parameters[0].split(":")
        var_menu = list()
        for val in var_list:
            label = translator.translate(val).upper()
            var_menu.append((val, label, partial(set_variable, game=game, player=player, var_key=action.parameters[1], var_value=val)))
        dialog_context = contexts.get("dialog", None)
        if not dialog_context:
            dialog_context = DialogContext()
            contexts["dialog"] = dialog_context
        dialog_context.add_menu(var_menu)
Beispiel #2
0
    def startup(self, *args, **kwargs):
        super(StartState, self).startup(*args, **kwargs)

        def change_state(state, **kwargs):
            return partial(self.game.push_state, state, **kwargs)

        def new_game():
            self.game.player1 = prepare.player1
            self.game.replace_state("WorldState")
            self.game.push_state("InputMenu", prompt=translator.translate("input_name"))
            self.game.push_state("FadeInTransition")

        def options():
            pass

        def exit_game():
            self.game.exit = True

        menu_items_map = (
            ('menu_new_game', new_game),
            ('menu_load', change_state("LoadMenuState")),
            ('menu_options', options),
            ('exit', exit_game),
        )

        for key, callback in menu_items_map:
            label = translator.translate(key).upper()
            image = self.shadow_text(label)
            item = MenuItem(image, label, None, callback)
            self.add(item)
Beispiel #3
0
    def startup(self, *args, **kwargs):
        super(StartState, self).startup(*args, **kwargs)

        def change_state(state, **kwargs):
            return partial(self.game.push_state, state, **kwargs)

        def new_game():
            self.game.player1 = prepare.player1
            self.game.replace_state("WorldState")
            self.game.push_state("InputMenu",
                                 prompt=translator.translate("input_name"))
            self.game.push_state("FadeInTransition")

        def options():
            pass

        def exit_game():
            self.game.exit = True

        menu_items_map = (
            ('menu_new_game', new_game),
            ('menu_load', change_state("LoadMenuState")),
            ('menu_options', options),
            ('exit', exit_game),
        )

        for key, callback in menu_items_map:
            label = translator.translate(key).upper()
            image = self.shadow_text(label)
            item = MenuItem(image, label, None, callback)
            self.add(item)
Beispiel #4
0
    def initialize_items(self):
        menu_items_map = (('menu_fight', self.open_technique_menu),
                          ('menu_monster', self.open_swap_menu),
                          ('menu_item', self.open_item_menu), ('menu_run',
                                                               self.run))

        for key, callback in menu_items_map:
            label = translator.translate(key).upper()
            image = self.shadow_text(label)
            yield MenuItem(image, label, None, callback)
Beispiel #5
0
    def initialize_items(self):
        menu_items_map = (
            ('menu_fight', self.open_technique_menu),
            ('menu_monster', self.open_swap_menu),
            ('menu_item', self.open_item_menu),
            ('menu_run', self.run)
        )

        for key, callback in menu_items_map:
            label = translator.translate(key).upper()
            image = self.shadow_text(label)
            yield MenuItem(image, label, None, callback)
Beispiel #6
0
        def open_choice_menu():
            # open the menu for use/cancel
            menu = self.game.push_state("Menu")
            menu.shrink_to_items = True

            menu_items_map = (('item_confirm_use', confirm),
                              ('item_confirm_cancel', cancel))

            # add our options to the menu
            for key, callback in menu_items_map:
                label = translator.translate(key).upper()
                image = self.shadow_text(label)
                item = MenuItem(image, label, None, callback)
                menu.add(item)
Beispiel #7
0
        def open_choice_menu():
            # open the menu for use/cancel
            menu = self.game.push_state("Menu")
            menu.shrink_to_items = True

            menu_items_map = (
                ('item_confirm_use', confirm),
                ('item_confirm_cancel', cancel)
            )

            # add our options to the menu
            for key, callback in menu_items_map:
                label = translator.translate(key).upper()
                image = self.shadow_text(label)
                item = MenuItem(image, label, None, callback)
                menu.add(item)
Beispiel #8
0
 def not_implemented_dialog():
     open_dialog(self.game, [translator.translate('not_implemented')])
Beispiel #9
0
def add_menu_items(state, items):
    for key, callback in items:
        label = translator.translate(key).upper()
        image = state.shadow_text(label)
        item = MenuItem(image, label, None, callback)
        state.add(item)
Beispiel #10
0
 def open_monster_stats():
     open_dialog(self.game, [translator.translate('not_implemented')])
Beispiel #11
0
 def not_implemented_dialog():
     open_dialog(self.game, [translator.translate('not_implemented')])
Beispiel #12
0
def add_menu_items(state, items):
    for key, callback in items:
        label = translator.translate(key).upper()
        image = state.shadow_text(label)
        item = MenuItem(image, label, None, callback)
        state.add(item)
Beispiel #13
0
 def open_monster_stats():
     open_dialog(self.game, [translator.translate('not_implemented')])
Beispiel #14
0
 def new_game():
     self.game.player1 = prepare.player1
     self.game.replace_state("WorldState")
     self.game.push_state("InputMenu", prompt=translator.translate("input_name"))
     self.game.push_state("FadeInTransition")
Beispiel #15
0
 def new_game():
     self.game.player1 = prepare.player1
     self.game.replace_state("WorldState")
     self.game.push_state("InputMenu",
                          prompt=translator.translate("input_name"))
     self.game.push_state("FadeInTransition")