示例#1
0
def add_wait_for_start_popupbox(game):
    # Всплывающее окно "Ожидайте начала игры":
    popupbox = PopupBox(game.window_surface, pos=(game.window_surface.get_width() / 2 - 150,
                                                  game.window_surface.get_height() / 2 - 75, 300, 150),
                        color=MAIN_MENU_BACKGROUND_COLOR)
    label_popupbox_title = Label(game.window_surface,
                                 pos=(popupbox.rect.x + popupbox.rect.w / 2,
                                      popupbox.rect.y + 15,
                                      0, 0),
                                 text="Вы подключёны к серверу", text_color=MENU_WHITE,
                                 font_size=20, font="main_menu")
    label_popupbox_title_shadow = Label(game.window_surface,
                                        pos=(popupbox.rect.x + popupbox.rect.w / 2 + 2,
                                             popupbox.rect.y + 17, 0, 0),
                                        text="Вы подключёны к серверу", text_color=BLACK,
                                        font_size=20, font="main_menu")
    label_popupbox_title2 = Label(game.window_surface,
                                  pos=(popupbox.rect.x + popupbox.rect.w / 2,
                                       popupbox.rect.y + 45,
                                       0, 0),
                                  text="Ожидайте начала игры", text_color=BUTTON_YELLOW,
                                  font_size=28, font="main_menu")
    label_popupbox_title2_shadow = Label(game.window_surface,
                                         pos=(popupbox.rect.x + popupbox.rect.w / 2 + 2,
                                              popupbox.rect.y + 47, 0, 0),
                                         text="Ожидайте начала игры", text_color=BLACK,
                                         font_size=28, font="main_menu")
    label_popupbox_esc = Label(game.window_surface,
                               pos=(popupbox.rect.x + popupbox.rect.w / 2,
                                    popupbox.rect.y + 125,
                                    0, 0),
                               text="Нажмите ESC, чтобы отключиться", text_color=BUTTON_YELLOW,
                               font_size=16, font="main_menu")
    label_popupbox_esc_shadow = Label(game.window_surface,
                                      pos=(popupbox.rect.x + popupbox.rect.w / 2 + 2,
                                           popupbox.rect.y + 127, 0, 0),
                                      text="Нажмите ESC, чтобы отключиться", text_color=BLACK,
                                      font_size=16, font="main_menu")
    buttontrigger_popupbox_quit_esc = ButtonTrigger(key=pygame.K_ESCAPE,
                                                    function_list=[
                                                        remove_wait_popupbox_and_return_to_menu],
                                                    args_list=[game])

    popupbox.add_object(buttontrigger_popupbox_quit_esc)
    popupbox.add_object(label_popupbox_title_shadow)
    popupbox.add_object(label_popupbox_title)
    popupbox.add_object(label_popupbox_title2_shadow)
    popupbox.add_object(label_popupbox_title2)
    popupbox.add_object(label_popupbox_esc_shadow)
    popupbox.add_object(label_popupbox_esc)

    with game.any_popup_box_lock:
        game.any_popup_box = None
        game.any_popup_box = popupbox
示例#2
0
def add_you_win_popupbox(game):
    # Всплывающее окно "Победа! Ваша миссия в данном регионе окончена!":
    popupbox = PopupBox(game.window_surface, pos=(game.window_surface.get_width() / 2 - 100,
                                                  game.window_surface.get_height() / 2 - 50, 200, 100),
                        color=MAIN_MENU_BACKGROUND_COLOR)
    label_popupbox_title = Label(game.window_surface,
                                 pos=(popupbox.rect.x + popupbox.rect.w / 2,
                                      popupbox.rect.y + 15,
                                      0, 0),
                                 text="Победа!".upper(), text_color=MENU_WHITE,
                                 font_size=20, font="main_menu")
    label_popupbox_title_shadow = Label(game.window_surface,
                                        pos=(popupbox.rect.x + popupbox.rect.w / 2 + 2,
                                             popupbox.rect.y + 17, 0, 0),
                                        text="Победа!".upper(), text_color=BLACK,
                                        font_size=20, font="main_menu")
    label_popupbox_title2 = Label(game.window_surface,
                                  pos=(popupbox.rect.x + popupbox.rect.w / 2,
                                       popupbox.rect.y + 45,
                                       0, 0),
                                  text="Ваша миссия в данном регионе окончена!", text_color=BUTTON_YELLOW,
                                  font_size=28, font="main_menu")
    label_popupbox_title2_shadow = Label(game.window_surface,
                                         pos=(popupbox.rect.x + popupbox.rect.w / 2 + 2,
                                              popupbox.rect.y + 47, 0, 0),
                                         text="Ваша миссия в данном регионе окончена!", text_color=BLACK,
                                         font_size=28, font="main_menu")
    label_popupbox_esc = Label(game.window_surface,
                               pos=(popupbox.rect.x + popupbox.rect.w / 2,
                                    popupbox.rect.y + 85,
                                    0, 0),
                               text="Нажмите ESC, чтобы вернуться в меню", text_color=BUTTON_YELLOW,
                               font_size=16, font="main_menu")
    label_popupbox_esc_shadow = Label(game.window_surface,
                                      pos=(popupbox.rect.x + popupbox.rect.w / 2 + 2,
                                           popupbox.rect.y + 87, 0, 0),
                                      text="Нажмите ESC, чтобы вернуться в меню", text_color=BLACK,
                                      font_size=16, font="main_menu")
    buttontrigger_popupbox_quit_esc = ButtonTrigger(key=pygame.K_ESCAPE,
                                                    function_list=[
                                                        remove_popupbox_and_return_to_menu],
                                                    args_list=[game])

    popupbox.add_object(buttontrigger_popupbox_quit_esc)
    popupbox.add_object(label_popupbox_title_shadow)
    popupbox.add_object(label_popupbox_title)
    popupbox.add_object(label_popupbox_title2_shadow)
    popupbox.add_object(label_popupbox_title2)
    popupbox.add_object(label_popupbox_esc_shadow)
    popupbox.add_object(label_popupbox_esc)

    with game.any_popup_box_lock:
        game.any_popup_box = None
        game.any_popup_box = popupbox
示例#3
0
def add_server_started_popupbox(game):
    # Всплывающее окно "Сервер закрыт":
    popupbox = PopupBox(game.window_surface, pos=(game.window_surface.get_width() / 2 - 100,
                                                  game.window_surface.get_height() / 2 - 50, 200, 100),
                        color=MAIN_MENU_BACKGROUND_COLOR)
    label_popupbox_title = Label(game.window_surface,
                                 pos=(popupbox.rect.x + popupbox.rect.w / 2,
                                      popupbox.rect.y + 15,
                                      0, 0),
                                 text="Сервер запущен", text_color=MENU_WHITE,
                                 font_size=20, font="main_menu")
    label_popupbox_title_shadow = Label(game.window_surface,
                                        pos=(popupbox.rect.x + popupbox.rect.w / 2 + 2,
                                             popupbox.rect.y + 17, 0, 0),
                                        text="Сервер запущен:", text_color=BLACK,
                                        font_size=20, font="main_menu")
    label_popupbox_title2 = Label(game.window_surface,
                                  pos=(popupbox.rect.x + popupbox.rect.w / 2,
                                       popupbox.rect.y + 45,
                                       0, 0),
                                  text="Ожидание клиентов", text_color=BUTTON_YELLOW,
                                  font_size=28, font="main_menu")
    label_popupbox_title2_shadow = Label(game.window_surface,
                                         pos=(popupbox.rect.x + popupbox.rect.w / 2 + 2,
                                              popupbox.rect.y + 47, 0, 0),
                                         text="Ожидание клиентов", text_color=BLACK,
                                         font_size=28, font="main_menu")
    label_popupbox_esc = Label(game.window_surface,
                               pos=(popupbox.rect.x + popupbox.rect.w / 2,
                                    popupbox.rect.y + 85,
                                    0, 0),
                               text="Нажмите ESC, чтобы закрыть сервер", text_color=BUTTON_YELLOW,
                               font_size=16, font="main_menu")
    label_popupbox_esc_shadow = Label(game.window_surface,
                                      pos=(popupbox.rect.x + popupbox.rect.w / 2 + 2,
                                           popupbox.rect.y + 87, 0, 0),
                                      text="Нажмите ESC, чтобы закрыть сервер", text_color=BLACK,
                                      font_size=16, font="main_menu")
    buttontrigger_popupbox_quit_esc = ButtonTrigger(key=pygame.K_ESCAPE,
                                                    function_list=[
                                                        remove_server_started_popupbox_and_return_to_menu],
                                                    args_list=[game])

    popupbox.add_object(buttontrigger_popupbox_quit_esc)
    popupbox.add_object(label_popupbox_title_shadow)
    popupbox.add_object(label_popupbox_title)
    popupbox.add_object(label_popupbox_title2_shadow)
    popupbox.add_object(label_popupbox_title2)
    popupbox.add_object(label_popupbox_esc_shadow)
    popupbox.add_object(label_popupbox_esc)

    with game.any_popup_box_lock:
        game.any_popup_box = None
        game.any_popup_box = popupbox
示例#4
0
def add_game_over_player_died_popupbox(game, player_name):
    # Всплывающее окно "Игра закончена Игрок # потерял все жизни.":
    popupbox = PopupBox(game.window_surface, pos=(game.window_surface.get_width() / 2 - 100,
                                                  game.window_surface.get_height() / 2 - 50, 200, 100),
                        color=MAIN_MENU_BACKGROUND_COLOR)
    label_popupbox_title = Label(game.window_surface,
                                 pos=(popupbox.rect.x + popupbox.rect.w / 2,
                                      popupbox.rect.y + 15,
                                      0, 0),
                                 text="Game over!".upper(), text_color=MENU_WHITE,
                                 font_size=20, font="main_menu")
    label_popupbox_title_shadow = Label(game.window_surface,
                                        pos=(popupbox.rect.x + popupbox.rect.w / 2 + 2,
                                             popupbox.rect.y + 17, 0, 0),
                                        text="Game over!".upper(), text_color=BLACK,
                                        font_size=20, font="main_menu")
    label_popupbox_title2 = Label(game.window_surface,
                                  pos=(popupbox.rect.x + popupbox.rect.w / 2,
                                       popupbox.rect.y + 45,
                                       0, 0),
                                  text=f"Игрок {player_name} потерял все доступные жизни!", text_color=BUTTON_YELLOW,
                                  font_size=28, font="main_menu")
    label_popupbox_title2_shadow = Label(game.window_surface,
                                         pos=(popupbox.rect.x + popupbox.rect.w / 2 + 2,
                                              popupbox.rect.y + 47, 0, 0),
                                         text=f"Игрок {player_name} потерял все доступные жизни!", text_color=BLACK,
                                         font_size=28, font="main_menu")
    label_popupbox_esc = Label(game.window_surface,
                               pos=(popupbox.rect.x + popupbox.rect.w / 2,
                                    popupbox.rect.y + 85,
                                    0, 0),
                               text="Нажмите ESC, чтобы вернуться в меню", text_color=BUTTON_YELLOW,
                               font_size=16, font="main_menu")
    label_popupbox_esc_shadow = Label(game.window_surface,
                                      pos=(popupbox.rect.x + popupbox.rect.w / 2 + 2,
                                           popupbox.rect.y + 87, 0, 0),
                                      text="Нажмите ESC, чтобы вернуться в меню", text_color=BLACK,
                                      font_size=16, font="main_menu")
    buttontrigger_popupbox_quit_esc = ButtonTrigger(key=pygame.K_ESCAPE,
                                                    function_list=[
                                                        remove_popupbox_and_return_to_menu],
                                                    args_list=[game])

    popupbox.add_object(buttontrigger_popupbox_quit_esc)
    popupbox.add_object(label_popupbox_title_shadow)
    popupbox.add_object(label_popupbox_title)
    popupbox.add_object(label_popupbox_title2_shadow)
    popupbox.add_object(label_popupbox_title2)
    popupbox.add_object(label_popupbox_esc_shadow)
    popupbox.add_object(label_popupbox_esc)

    with game.any_popup_box_lock:
        game.any_popup_box = None
        game.any_popup_box = popupbox
示例#5
0
    def setup_chat_sender(self) -> None:
        """
        Инициализирует поле chat_sender класса.
        """

        # class MessageSentState:
        #     message_sent = False

        # def send_msg(message_sent_state: MessageSentState):
        def send_msg():
            # if not message_sent_state.message_sent:
            #     message = textbox_message.text_str
            #     if len(message) > 0:
            #         self.parent_game.send_chat_message(message)
            #     textbox_message.text_str = ""
            #     self.hide_chat_sender()
            #     message_sent_state.message_sent = True
            message = textbox_message.text_str
            if len(message) > 0:
                self.parent_game.send_chat_message(message)
            textbox_message.text_str = ""
            self.hide_chat_sender()

        # mss = MessageSentState()

        self.chat_sender = PopupBox(self.parent_game.window_surface,
                                    pos=(0, 0, 0, 0),
                                    fill=False,
                                    darken_background=True)

        textbox_message = TextBox(self.parent_game.window_surface,
                                  pos=(chat_textbox_x, chat_textbox_y,
                                       chat_textbox_width,
                                       chat_textbox_height),
                                  empty_text="Введите сюда своё сообщение...",
                                  font="main_menu",
                                  font_size=chat_font_size,
                                  function_onEnter=send_msg,
                                  arg_onEnter=None,
                                  active=True)

        button_send_message_width = chat_textbox_width * 0.1
        button_send_message_x = chat_textbox_x + chat_textbox_width - button_send_message_width

        button_send_message_shadow = Label(
            self.parent_game.window_surface,
            pos=(button_send_message_x + 2, chat_textbox_y + 2,
                 button_send_message_width, chat_textbox_height),
            text=">>",
            text_color=BLACK,
            font_size=chat_font_size,
            font="main_menu")
        button_send_message = Button(
            self.parent_game.window_surface,
            pos=(button_send_message_x, chat_textbox_y,
                 button_send_message_width, chat_textbox_height),
            transparent=True,
            text_color=GREY,
            selected_text_color=MENU_WHITE,
            text=">>",
            font_size=chat_font_size,
            font="main_menu",
            function_onClick_list=[send_msg],
            args_list=[None])
        #                              args_list=[mss])

        buttontrigger_popupbox_quit_esc = ButtonTrigger(
            key=pygame.K_ESCAPE,
            function_list=[self.hide_chat_sender],
            args_list=[None])
        buttontrigger_send_message_enter = ButtonTrigger(
            key=pygame.K_RETURN, function_list=[send_msg], args_list=[None])
        #                              args_list=[mss])

        self.chat_sender.add_object(buttontrigger_popupbox_quit_esc)
        self.chat_sender.add_object(buttontrigger_send_message_enter)
        self.chat_sender.add_object(textbox_message)
        self.chat_sender.add_object(button_send_message_shadow)
        self.chat_sender.add_object(button_send_message)

        self.is_chat_sender_shown = False