Ejemplo n.º 1
0
    def __init__(self, screen_factory: ScreenFactory, level_score: LevelScore):
        current_level_num = level_score.level_num
        last_level_completed = current_level_num == screen_factory.get_bundle(
        ).last_level

        next_level = TextMenuItem(
            "PLAY NEXT LEVEL", lambda: screen_factory.get_playfield_screen(
                screen_factory.get_player_profile().next_level_to_play(
                    current_level_num)))
        finish_game = TextMenuItem("FINISH GAME",
                                   screen_factory.get_victory_screen)
        restart_level = TextMenuItem(
            "RESTART LEVEL",
            lambda: screen_factory.get_playfield_screen(current_level_num,
                                                        skip_how_to_play=True))
        main_menu = TextMenuItem("BACK TO MAIN MENU",
                                 screen_factory.get_main_menu)

        more_levels_to_play_menu: Tuple[MenuItem,
                                        ...] = (next_level, restart_level,
                                                main_menu)
        last_level_finished_menu: Tuple[MenuItem,
                                        ...] = (finish_game, restart_level)
        screen = screen_factory.get_bundle().get_screen("level_completed")
        menu = Menu.with_defaults(
            last_level_finished_menu
            if last_level_completed else more_levels_to_play_menu,
            MenuLayout(position=screen.menu_position))

        super().__init__(menu=menu, screen=screen, semi_transparent=True)
        player_profile = screen_factory.get_player_profile()
        self.level_score = level_score
        self.prev_level_score = player_profile.complete_level(level_score)
Ejemplo n.º 2
0
 def __init__(self, message: str):
     self.error_message = self._build_error_message(message)
     self.frame_rect = self._get_frame_rect(self.error_message)
     menu = Menu.with_defaults(
         tuple([TextMenuItem("OK", lambda: None)]),
         MenuLayout(position=self._get_menu_position(self.frame_rect)))
     super().__init__(menu=menu)
Ejemplo n.º 3
0
    def __init__(self, screen_factory: ScreenFactory, level_num: int):
        screen = screen_factory.get_bundle().get_screen("game_paused")
        playing_last_level = level_num == screen_factory.get_bundle(
        ).last_level
        resume_game = TextMenuItem("RESUME GAME", lambda: None)
        restart_level = TextMenuItem(
            "RESTART LEVEL",
            lambda: screen_factory.get_playfield_screen(level_num,
                                                        skip_how_to_play=True))
        skip_level = TextMenuItem(
            "SKIP LEVEL", lambda: screen_factory.get_playfield_screen(
                screen_factory.get_player_profile().next_level_to_play(
                    level_num)))
        how_to_play = TextMenuItem("HOW TO PLAY",
                                   screen_factory.get_how_to_play_screen)
        main_menu = TextMenuItem("BACK TO MAIN MENU",
                                 screen_factory.get_main_menu)

        before_last_level_menu: Tuple[MenuItem, ...] = \
            (resume_game, restart_level, skip_level, how_to_play, main_menu)
        last_level_menu: Tuple[MenuItem, ...] = \
            (resume_game, restart_level, how_to_play, main_menu)

        menu = Menu.with_defaults(
            last_level_menu if playing_last_level else before_last_level_menu,
            MenuLayout(position=screen.menu_position))
        super().__init__(menu=menu,
                         allow_going_back=True,
                         screen=screen,
                         semi_transparent=True)
Ejemplo n.º 4
0
 def __init__(self, screen_factory: ScreenFactory):
     self.exiting = False
     self._get_exit_screen: Callable[[], ScreenController] = \
         lambda: screen_factory.get_exit_screen(self._exit_callback)
     level_to_play = screen_factory.get_player_profile().first_not_completed_level
     screen = screen_factory.get_bundle().get_screen("main_menu")
     menu = Menu.with_defaults((
         TextMenuItem("START GAME", lambda: screen_factory.get_playfield_screen(level_to_play)),
         TextMenuItem("CHOOSE LEVEL", screen_factory.get_choose_level_screen),
         TextMenuItem("EXIT", self._get_exit_screen)
     ), MenuLayout(position=screen.menu_position))
     super().__init__(menu=menu, allow_going_back=True, screen=screen)
Ejemplo n.º 5
0
 def __init__(self, screen_factory: ScreenFactory,
              exit_callback: Callable[[], None]):
     screen = screen_factory.get_bundle().get_screen("exit")
     menu = Menu.with_defaults(
         tuple([
             TextMenuItem("YES", self._exit),
             TextMenuItem("NO", lambda: None)
         ]),
         MenuLayout(columns=2,
                    position=screen.menu_position,
                    item_space=Size(8, 0)))
     super().__init__(menu=menu,
                      allow_going_back=True,
                      screen=screen,
                      semi_transparent=True)
     self.exit_callback = exit_callback
Ejemplo n.º 6
0
 def __init__(self, screen_factory: ScreenFactory):
     bundle = screen_factory.get_bundle()
     screen = bundle.get_screen("choose_level")
     item_space = bundle.get_gui_consts().get_position(
         GuiPosition.LEVEL_ITEM_SPACE)
     menu = Menu.with_defaults(
         tuple([
             LevelMenuItem(level_num, screen_factory)
             for level_num in range(bundle.num_levels)
         ]),
         MenuLayout(columns=5,
                    rows=4,
                    position=screen.menu_position,
                    item_space=Size(item_space.x, item_space.y)))
     super().__init__(menu=menu, allow_going_back=True, screen=screen)
     self.select_and_scroll_to_item(
         screen_factory.get_player_profile().last_played_level)
     self.level_selected_color = bundle.get_gui_consts().get_color(
         GuiColor.LEVEL_SELECTED_COLOR)
Ejemplo n.º 7
0
 def __init__(self, screen_factory: ScreenFactory):
     screen = screen_factory.get_bundle().get_screen("victory")
     menu = Menu.with_defaults(tuple([
         TextMenuItem("MAIN MENU", screen_factory.get_main_menu)
     ]), MenuLayout(position=screen.menu_position))
     super().__init__(menu=menu, screen=screen)
Ejemplo n.º 8
0
 def __init__(self, screen_factory: ScreenFactory):
     screen = screen_factory.get_bundle().get_screen("how_to_play")
     menu = Menu.with_defaults(tuple([
         TextMenuItem("OK", lambda: None)
     ]), MenuLayout(position=screen.menu_position))
     super().__init__(menu=menu, allow_going_back=True, screen=screen, semi_transparent=True)