def __init_widgets(self):
        save_label = widgets.Label(util.Size(200, 30),
                                   text="Choose a file to load:",
                                   font_size=25,
                                   color=(0, 0, 0, 0),
                                   selectable=False)
        self.add_widget(
            (int(self.rect.width / 2 - save_label.rect.width / 2), 5),
            save_label)

        file_list = widgets.ListBox(util.Size(self.rect.width - 50,
                                              self.rect.height - 100),
                                    color=self.COLOR)
        self.add_widget(("center", 45), file_list)
        self.add_border(file_list)

        for file in os.listdir(con.SAVE_DIR):
            if isfile(join(con.SAVE_DIR, file)) and file.endswith(".save"):
                file_button = widgets.Button(util.Size(file_list.rect.width,
                                                       25),
                                             text=file,
                                             font_size=25,
                                             color=self.COLOR)
                file_button.add_key_event_listener(1,
                                                   self.load_file,
                                                   values=[file],
                                                   types=["unpressed"])
                file_list.add_widget(file_button)
    def __init_widgets(self, message):
        for index, line in enumerate(message.split("\n")):
            message_lbl = widgets.Label(util.Size(self.rect.width - 20, 25),
                                        color=self.COLOR,
                                        text=line,
                                        font_size=18,
                                        selectable=False)
            self.add_widget((10, index * 18 + 5), message_lbl)

        oke_button = widgets.Button(util.Size(self.rect.width / 2 - 25, 25),
                                    text="OK",
                                    font_size=25)
        oke_button.add_key_event_listener(1,
                                          self.__set_response_true,
                                          types=["unpressed"])
        self.add_widget((20, 60), oke_button)

        cancel_button = widgets.Button(util.Size(self.rect.width / 2 - 25, 25),
                                       text="CANCEL",
                                       font_size=25)
        cancel_button.add_key_event_listener(1,
                                             self._close_window,
                                             types=["unpressed"])
        self.add_widget((self.rect.width - cancel_button.rect.width - 20, 60),
                        cancel_button)
    def __init_widgets(self):
        self.input_line = widgets.MultilineTextBox(util.Size(150, 25),
                                                   lines=1,
                                                   font_size=25)
        self.add_widget((25, 5), self.input_line)

        self._incorect_lbl = widgets.Label(util.Size(self.rect.width - 50, 25),
                                           color=self.COLOR)
        self.add_widget((25, 35), self._incorect_lbl)

        oke_button = widgets.Button(util.Size(self.rect.width / 2 - 25, 25),
                                    text="OK",
                                    font_size=25)
        oke_button.add_key_event_listener(1,
                                          self._set_name_response,
                                          types=["unpressed"])
        self.add_widget((20, 60), oke_button)

        cancel_button = widgets.Button(util.Size(self.rect.width / 2 - 25, 25),
                                       text="CANCEL",
                                       font_size=25)
        cancel_button.add_key_event_listener(1,
                                             self._close_window,
                                             types=["unpressed"])
        self.add_widget((self.rect.width - cancel_button.rect.width - 20, 60),
                        cancel_button)
    def __add_top_border(self, size: util.Size, title: Union[str, None]):
        """Add the top bar of the window with the exit button"""
        top_label = widgets.Label(util.Size(
            size.width - self.EXIT_BUTTON_SIZE.width, self.TOP_SIZE.height),
                                  color=self.TOP_BAR_COLOR,
                                  selectable=False)
        # add the move listeners
        top_label.add_key_event_listener(1,
                                         self.__top_label_action,
                                         values=[True],
                                         types=["pressed"])
        top_label.add_key_event_listener(1,
                                         self.__top_label_action,
                                         values=[False],
                                         types=["unpressed"])
        self.add_widget((0, 0), top_label, adjust=False)

        if title is not None:
            top_label.set_text(title, (10, 5), self.TEXT_COLOR, font_size=25)
        button_image = image_handlers.image_sheets["general"].image_at(
            (20, 0), self.EXIT_BUTTON_SIZE)
        hover_image = image_handlers.image_sheets["general"].image_at(
            (45, 0), self.EXIT_BUTTON_SIZE)
        exit_button = widgets.Button(self.EXIT_BUTTON_SIZE,
                                     image=button_image,
                                     hover_image=hover_image,
                                     selectable=False)
        exit_button.add_key_event_listener(1,
                                           self._close_window,
                                           types=["unpressed"])
        self.add_widget((size.width - self.EXIT_BUTTON_SIZE.width, 0),
                        exit_button,
                        adjust=False)
Example #5
0
    def __init_widgets(self):
        self.mode_label = widgets.Label((self.rect.width - 10, 30),
                                        color=(150, 150, 150),
                                        border=True)
        self.add_widget((5, 5), self.mode_label)

        self.item_label = widgets.ItemDisplay(
            (self.rect.width - 50, self.rect.height - 50), color=self.COLOR)
        self.add_widget((25, 45), self.item_label)
Example #6
0
 def __init_widgets(self):
     self.__loading_frame = widgets.Frame((0, 0),
                                          util.Size(*self.rect.size),
                                          self.sprite_group,
                                          color=(173, 94, 29),
                                          static=False)
     self.__progress_label = widgets.Label((500, 20), (173, 94, 29))
     self.__loading_frame.add_widget(("center", "center"),
                                     self.__progress_label)
Example #7
0
 def __check_tasks(self):
     if len(self._worker.task_queue) != self._previous_number_tasks:
         self._previous_number_tasks = len(self._worker.task_queue)
         for widget in self._task_information_pane.widgets:
             print(widget)
             self._task_information_pane.remove_widget(widget)
         for task in self._worker.task_queue.tasks:
             task_label = widgets.Label(util.Size(130, 10),
                                        text=str(task),
                                        text_pos=["west", "center"],
                                        selectable=False)
             self._task_information_pane.add_widget(task_label)
Example #8
0
    def __init_widgets(self):
        self.loading_frame = widgets.Frame((0, 0),
                                           util.Size(*self.rect.size),
                                           self.sprite_group,
                                           color=(173, 94, 29),
                                           static=False)
        frame_rect = self.loading_frame.rect
        save_label = widgets.Label(util.Size(frame_rect.width, 30),
                                   text="Choose a file to load:",
                                   font_size=25,
                                   color=(0, 0, 0, 0),
                                   selectable=False)
        self.loading_frame.add_widget(
            (int(frame_rect.width / 2 - save_label.rect.width / 2), 5),
            save_label)

        file_list = widgets.ListBox(util.Size(frame_rect.width - 200,
                                              self.rect.height - 300),
                                    color=(173, 94, 29))
        self.loading_frame.add_widget(("center", 75), file_list)
        self.loading_frame.add_border(file_list)

        for file in os.listdir(con.SAVE_DIR):
            if isfile(join(con.SAVE_DIR, file)) and file.endswith(".save"):
                file_button = widgets.Button(util.Size(file_list.rect.width,
                                                       25),
                                             text=file,
                                             font_size=25,
                                             color=(173, 94, 29))
                file_button.add_key_event_listener(1,
                                                   self.load_file,
                                                   values=[file],
                                                   types=["unpressed"])
                file_list.add_widget(file_button)

        back_button = widgets.Button((200, 30),
                                     text="BACK",
                                     font_size=25,
                                     color=(150, 150, 150))
        back_button.add_key_event_listener(1,
                                           self.__back_to_main,
                                           types=["unpressed"])
        self.loading_frame.add_widget(("center", self.rect.height - 100),
                                      back_button)
Example #9
0
    def __init_widgets(self):
        self.settings_menu_frame = widgets.Frame((0, 0),
                                                 util.Size(*self.rect.size),
                                                 self.sprite_group,
                                                 color=(173, 94, 29),
                                                 static=False)
        frame_rect = self.settings_menu_frame.rect

        widget_size = util.Size(100, 40)
        color = (173, 94, 29)
        y_coord = 100

        # GENERAL OPTIONS
        generel_options_pane = widgets.Pane((frame_rect.width - 100, 100),
                                            border=True,
                                            border_width=4,
                                            color=color)
        self.settings_menu_frame.add_widget(("center", y_coord),
                                            generel_options_pane)
        local_y = 10
        local_x = int((generel_options_pane.rect.width / 2) + 5)
        self.__game_name_textbox = widgets.MultilineTextBox(
            (200, con.FONTS[22].get_linesize() + 6), font_size=22, lines=1)
        generel_options_pane.add_widget((local_x, local_y),
                                        self.__game_name_textbox)

        local_x = int((generel_options_pane.rect.width / 2) - 135)
        game_name_label = widgets.Label((140, con.FONTS[22].get_linesize()),
                                        color=color,
                                        text="Name:",
                                        font_size=22,
                                        text_pos=("W", "C"),
                                        selectable=False)
        generel_options_pane.add_widget((local_x, local_y), game_name_label)

        # GENERATION OPTIONS
        y_coord += generel_options_pane.rect.height + 10
        generation_values_pane = widgets.Pane((frame_rect.width - 100, 300),
                                              border=True,
                                              border_width=4,
                                              color=color)
        self.settings_menu_frame.add_widget(("center", y_coord),
                                            generation_values_pane)

        # Biome size selection
        local_y = 10
        local_x = int((generation_values_pane.rect.width / 2) + 5)
        self.__biome_size_selection_list =\
            widgets.SelectionList(self.sprite_group, color=(150, 150, 150),
                                  options=list(generation.BoardGenerator.BIOME_SIZES.keys()))
        self.__biome_size_selection_list.select_option("normal")
        generation_values_pane.add_widget((local_x, local_y),
                                          self.__biome_size_selection_list)

        biome_size_label = widgets.Label(
            (100, self.__biome_size_selection_list.LINE_HEIGHT),
            color=color,
            text="Biome Size:",
            font_size=22,
            text_pos=("W", "C"),
            selectable=False)
        biome_size_tooltip = widgets.Tooltip(self.sprite_group,
                                             color=(150, 150, 150),
                                             text="Average size of biomes")
        biome_size_label.add_tooltip(biome_size_tooltip)
        local_x = int((generation_values_pane.rect.width / 2) - 135)
        generation_values_pane.add_widget((local_x, local_y), biome_size_label)

        # Biome blend selection
        local_y += self.__biome_size_selection_list.LINE_HEIGHT + 10
        local_x = int((generation_values_pane.rect.width / 2) + 5)
        self.__biome_blend_selection_list = \
            widgets.SelectionList(self.sprite_group, color=(150, 150, 150),
                                  options=list(generation.BoardGenerator.BIOME_BLEND.keys()))
        self.__biome_blend_selection_list.select_option("normal")
        generation_values_pane.add_widget((local_x, local_y),
                                          self.__biome_blend_selection_list)

        biome_blend_label = widgets.Label(
            (100, self.__biome_blend_selection_list.LINE_HEIGHT),
            color=color,
            text="Biome Blend:",
            font_size=22,
            text_pos=("W", "C"),
            selectable=False)
        biome_blend_tooltip = widgets.Tooltip(
            self.sprite_group,
            color=(150, 150, 150),
            text="The level to which biomes\ncan blend trough one another")
        biome_blend_label.add_tooltip(biome_blend_tooltip)
        local_x = int((generation_values_pane.rect.width / 2) - 135)
        generation_values_pane.add_widget((local_x, local_y),
                                          biome_blend_label)

        # Max Caves selection
        local_y += self.__biome_blend_selection_list.LINE_HEIGHT + 10
        local_x = int((generation_values_pane.rect.width / 2) + 5)
        self.__max_caves_selection_list = \
            widgets.SelectionList(self.sprite_group, color=(150, 150, 150),
                                  options=list(generation.BoardGenerator.MAX_CAVES.keys()))
        self.__max_caves_selection_list.select_option("normal")
        generation_values_pane.add_widget((local_x, local_y),
                                          self.__max_caves_selection_list)

        max_caves_label = widgets.Label(
            (140, self.__max_caves_selection_list.LINE_HEIGHT),
            color=color,
            text="Number of Caves:",
            font_size=22,
            text_pos=("W", "C"),
            selectable=False)
        max_caves_tooltip = widgets.Tooltip(
            self.sprite_group,
            color=(150, 150, 150),
            text="The amount of caves present on the map")
        max_caves_label.add_tooltip(max_caves_tooltip)
        local_x = int((generation_values_pane.rect.width / 2) - 135)
        generation_values_pane.add_widget((local_x, local_y), max_caves_label)

        # Cave length selection
        local_y += self.__max_caves_selection_list.LINE_HEIGHT + 10
        local_x = int((generation_values_pane.rect.width / 2) + 5)
        self.__cave_length_selection_list =\
            widgets.SelectionList(self.sprite_group, color=(150, 150, 150),
                                  options=list(generation.BoardGenerator.CAVE_LENGTH.keys()))
        self.__cave_length_selection_list.select_option("normal")
        generation_values_pane.add_widget((local_x, local_y),
                                          self.__cave_length_selection_list)

        cave_length_label = widgets.Label(
            (140, self.__cave_length_selection_list.LINE_HEIGHT),
            color=color,
            text="Length of Caves:",
            font_size=22,
            text_pos=("W", "C"),
            selectable=False)
        cave_length_tooltip = widgets.Tooltip(self.sprite_group,
                                              color=(150, 150, 150),
                                              text="The lenght of the caves")
        cave_length_label.add_tooltip(cave_length_tooltip)
        local_x = int((generation_values_pane.rect.width / 2) - 135)
        generation_values_pane.add_widget((local_x, local_y),
                                          cave_length_label)

        # Cave width selection
        local_y += self.__max_caves_selection_list.LINE_HEIGHT + 10
        local_x = int((generation_values_pane.rect.width / 2) + 5)
        self.__cave_width_selection_list = \
            widgets.SelectionList(self.sprite_group, color=(150, 150, 150),
                                  options=list(generation.BoardGenerator.CAVE_STOP_SPREAD_CHANCE.keys()))
        self.__cave_width_selection_list.select_option("normal")
        generation_values_pane.add_widget((local_x, local_y),
                                          self.__cave_width_selection_list)

        cave_width_label = widgets.Label(
            (140, self.__cave_width_selection_list.LINE_HEIGHT),
            color=color,
            text="Width of Caves:",
            font_size=22,
            text_pos=("W", "C"),
            selectable=False)
        cave_width_tooltip = widgets.Tooltip(self.sprite_group,
                                             color=(150, 150, 150),
                                             text="How wide a cave is")
        cave_width_label.add_tooltip(cave_width_tooltip)
        local_x = int((generation_values_pane.rect.width / 2) - 135)
        generation_values_pane.add_widget((local_x, local_y), cave_width_label)

        # general buttons
        y_coord += generation_values_pane.rect.height + 20
        x_coord = (frame_rect.width / 2) - widget_size.width - 5
        start_game_btn = widgets.Button(widget_size,
                                        color=(100, 100, 100),
                                        text="START",
                                        font_size=30)
        start_game_btn.add_key_event_listener(1, self.__start_game)
        self.settings_menu_frame.add_widget((x_coord, y_coord), start_game_btn)

        x_coord = int((frame_rect.width / 2) + 5)
        back_btn = widgets.Button(widget_size,
                                  color=(100, 100, 100),
                                  text="BACK",
                                  font_size=30)
        back_btn.add_key_event_listener(1, self.__back_to_main)
        self.settings_menu_frame.add_widget((x_coord, y_coord), back_btn)
Example #10
0
    def _init_widgets(self):
        # general information
        self._general_information_pane = widgets.Pane(
            util.Size(150, self.orig_rect.height / 2) - (30, 30),
            selectable=False,
            color=(150, 150, 150))
        self.add_widget((15, 15), self._general_information_pane, adjust=True)
        self.add_border(self._general_information_pane)

        y = 0
        info_name_lbl = widgets.Label(util.Size(150, 15),
                                      text="INFO",
                                      text_pos=(43, "center"),
                                      font_size=20,
                                      selectable=False)
        self._general_information_pane.add_widget((0, 0), info_name_lbl)
        self._general_information_pane.add_border(info_name_lbl)

        y += 25
        name_name_lbl = widgets.Label(util.Size(60, 10),
                                      text="Name: ",
                                      text_pos=("west", "center"),
                                      selectable=False,
                                      color=(150, 150, 150))
        self._general_information_pane.add_widget((5, y), name_name_lbl)

        self._name_lbl = widgets.MultilineTextBox(util.Size(80, 13))
        self._name_lbl.active_line.set_line_text(self._worker.name)
        self._general_information_pane.add_widget((38, y - 2), self._name_lbl)

        y += 15
        speed_name_lbl = widgets.Label(util.Size(60, 10),
                                       text="Speed: ",
                                       text_pos=("west", "center"),
                                       selectable=False,
                                       color=(150, 150, 150))
        self._general_information_pane.add_widget((5, y), speed_name_lbl)

        self._speed_lbl = widgets.Label(
            util.Size(75, 10),
            text=f"{self._previous_speed[0]}, {self._previous_speed[1]}",
            text_pos=("west", "center"),
            selectable=False,
            color=(150, 150, 150))
        self._general_information_pane.add_widget((45, y), self._speed_lbl)

        y += 15
        max_speed_name_lbl = widgets.Label(util.Size(60, 10),
                                           text="Max speed: ",
                                           text_pos=("west", "center"),
                                           selectable=False,
                                           color=(150, 150, 150))
        self._general_information_pane.add_widget((5, y), max_speed_name_lbl)

        self._max_speed_lbl = widgets.Label(util.Size(75, 10),
                                            text=str(self._worker.max_speed),
                                            text_pos=("west", "center"),
                                            selectable=False,
                                            color=(150, 150, 150))
        self._general_information_pane.add_widget((65, y), self._max_speed_lbl)

        y += 15
        location_name_lbl = widgets.Label(util.Size(60, 10),
                                          text="Location: ",
                                          text_pos=("west", "center"),
                                          selectable=False,
                                          color=(150, 150, 150))
        self._general_information_pane.add_widget((5, y), location_name_lbl)

        self._location_lbl = widgets.Label(
            util.Size(75, 10),
            text=
            f"{self._worker.orig_rect.left}, {self._worker.orig_rect.right}",
            text_pos=("west", "center"),
            selectable=False,
            color=(150, 150, 150))
        self._general_information_pane.add_widget((52, y), self._location_lbl)

        y += 15
        wheight_name_lbl = widgets.Label(util.Size(60, 10),
                                         text="Wheight: ",
                                         text_pos=("west", "center"),
                                         selectable=False,
                                         color=(150, 150, 150))
        self._general_information_pane.add_widget((5, y), wheight_name_lbl)

        self._wheight_lbl = widgets.Label(util.Size(75, 10),
                                          text=str(self._previous_wheight),
                                          text_pos=("west", "center"),
                                          selectable=False,
                                          color=(150, 150, 150))
        self._general_information_pane.add_widget((50, y), self._wheight_lbl)

        task_name_lbl = widgets.Label(util.Size(120, 15),
                                      text="TASK QUEUE",
                                      text_pos=(20, "center"),
                                      font_size=20,
                                      selectable=False,
                                      color=(150, 150, 150))
        self.add_widget((165, 15), task_name_lbl, adjust=True)
        self.add_border(task_name_lbl)

        # task information
        self._task_information_pane = widgets.ScrollPane(
            util.Size(150, self.orig_rect.height / 2) - (30, 48),
            selectable=False)
        self.add_widget((165, 33), self._task_information_pane, adjust=True)
        self.add_border(self._task_information_pane)

        # inventory pane
        self._inventory_pane = widgets.ScrollPane(
            util.Size(300, self.orig_rect.height / 2) - (30, 50),
            color=self.COLOR,
            selectable=False)
        self.add_widget((15, int(self.orig_rect.height / 2) + 10),
                        self._inventory_pane,
                        adjust=True)
        self.add_border(self._inventory_pane)