예제 #1
0
    def render(self, console):
        if not self.hidden:
            console.draw_rect(x=self.x,
                              y=self.y,
                              height=self.height,
                              width=self.width,
                              ch=1,
                              bg=self.color)

            elements = [
                ui_elem.HeaderFooter(),
                ui_elem.Break(3),
                ui_elem.Text("   Esc: show escape menu"),
                ui_elem.Text("     F: show/hide fog of war"),
                ui_elem.Text("     H: show/hide UI"),
                ui_elem.Text("     E: show/hide entity panel"),
                ui_elem.Text(" Spc/P: pause game"),
                ui_elem.Break(2),
                ui_elem.Button("close_ctrls_btn", "Close", 13, self.width,
                               self.engine),
                ui_elem.Break(2),
                ui_elem.HeaderFooter(),
            ]

            self.base_render(console, elements, self.x, self.y, self.width)
            self.create_hitboxes(elements)
예제 #2
0
    def render(self, console):
        if not self.hidden:
            console.draw_rect(x=self.x,
                              y=self.y,
                              height=self.height,
                              width=self.width,
                              ch=1,
                              bg=self.color)

            elements = [
                ui_elem.HeaderFooter(),
                ui_elem.Break(3),
                ui_elem.Button("open_ctrls_btn", "Controls", self.button_width,
                               self.width, self.engine),
                ui_elem.Break(1),
                ui_elem.Button("save_btn", "Save Game", self.button_width,
                               self.width, self.engine),
                ui_elem.Break(1),
                ui_elem.Button("load_btn", "Load Game", self.button_width,
                               self.width, self.engine),
                ui_elem.Break(1),
                ui_elem.Button("exit_btn", "Exit", self.button_width,
                               self.width, self.engine),
                ui_elem.Break(3),
                ui_elem.HeaderFooter()
            ]

            self.base_render(console, elements, self.x, self.y, self.width)
            self.create_hitboxes(
                elements)  # TODO could maybe use decorator here
예제 #3
0
    def render(self, console):
        console.draw_rect(x=self.x,
                          y=self.y,
                          height=self.height,
                          width=self.width,
                          ch=1,
                          bg=self.color)

        elements = [
            ui_elem.HeaderFooter(),
            ui_elem.CenteredText(f"Day {self.engine.days_elapsed}"),
            ui_elem.CenteredText(self.engine.time_of_day.capitalize()),
            ui_elem.CenteredText(
                f"{self.format_game_time(self.engine.game_time)}"),
            ui_elem.Break(),
            ui_elem.Text(f"{self.engine.hunter.human_name}"),
            ui_elem.Text("The Hunter"),
            ui_elem.Break(),
            ui_elem.Text(f"Surv {self.engine.hunter.days_survived} days"),
            ui_elem.Break(),
            ui_elem.Text("Hlth {:02.0f}/{}".format(
                self.engine.hunter.curr_health,
                self.engine.hunter.max_health)),
            ui_elem.Text("Hngr {:02.0f}/{}".format(
                self.engine.hunter.curr_hunger,
                self.engine.hunter.max_hunger)),
            ui_elem.Text("Nrgy {:02.0f}/{}".format(
                self.engine.hunter.curr_energy,
                self.engine.hunter.max_energy)),
            ui_elem.Break(),
            ui_elem.Divider(),
            ui_elem.Divider(),
        ]

        self.base_render(console, elements, self.x, self.y, self.width)
예제 #4
0
    def render(self, console):
        console.draw_rect(x=self.x,
                          y=self.y,
                          height=self.height,
                          width=self.width,
                          ch=1,
                          bg=self.color)

        elements = []

        if self.tile != None:
            if self.tile.explored or not self.engine.settings["show-fog"]:
                elements.extend([
                    ui_elem.Break(),
                    ui_elem.Text("Tile"),
                    ui_elem.Text("Coord: ({:02.0f},{:02.0f})".format(
                        self.tile.x, self.tile.y)),
                    ui_elem.Text("Trrn: {}".format(
                        self.tile.terrain.__class__.__name__)),
                ])

                if len(self.tile.entities) == 0:
                    elements.append(ui_elem.Text("Entities: None"))
                else:
                    elements.append(ui_elem.Text("Entities:"))

                    for entity in self.tile.entities:
                        if isinstance(entity, htr.Hunter):
                            elements.append(ui_elem.Text("~Hntr"))
                        elif isinstance(entity, rbt.Rabbit):
                            elements.append(ui_elem.Text("~Rbbt"))
                        elif isinstance(entity, wlf.Wolf):
                            elements.append(ui_elem.Text("~Wolf"))
                        elif isinstance(entity, rbt.Burrow):
                            elements.append(ui_elem.Text("~Brrw"))
                        elif isinstance(entity, bb.BerryBush):
                            elements.extend([
                                ui_elem.Text("~BrryBsh"),
                                ui_elem.Text(
                                    f" ~Berries: {entity.num_berries}"),
                            ])
                        elif isinstance(entity, cp.Camp):
                            elements.append(ui_elem.Text("~Camp"))
                            for component in entity.components:
                                elements.append(
                                    ui_elem.Text(f" ~{component.name()}"))
            else:
                elements.extend([
                    ui_elem.Break(),
                    ui_elem.Text("???"),
                ])

        elements = self.pad_elements_with_breaks(elements, self.height)
        elements = self.truncate_elements(elements, 2)
        elements.append(ui_elem.Divider())
        elements.append(ui_elem.Divider())

        self.base_render(console, elements, self.x, self.y, self.width)
예제 #5
0
    def render(self, console):
        console.draw_rect(x=self.x,
                          y=self.y,
                          height=self.height,
                          width=self.width,
                          ch=1,
                          bg=self.color)

        elements = []

        if self.engine.selected_entity != None:
            if hasattr(self.engine.selected_entity, "selection_info"):
                elements.extend([
                    ui_elem.Break(),
                    ui_elem.Text("Selected:"),
                ])

                for info in self.engine.selected_entity.selection_info():
                    if isinstance(info, str):
                        elements.append(ui_elem.PaddedText(info, 1))
                    elif isinstance(info, dict):
                        for key, val in info.items():
                            elements.append(ui_elem.PaddedText(key, 1))

                            if isinstance(val, list):
                                for subval in val:
                                    elements.append(
                                        ui_elem.PaddedText("~" + subval, 2))
            elif hasattr(self.engine.selected_entity, "name"):
                elements.extend([
                    ui_elem.Break(),
                    ui_elem.Text("Selected:"),
                    ui_elem.PaddedText(self.engine.selected_entity.name, 1),
                ])
            else:
                elements.extend([
                    ui_elem.Break(),
                    ui_elem.Text("Selected:"),
                    ui_elem.Text("None"),
                ])
        else:
            elements.extend([
                ui_elem.Break(),
                ui_elem.Text("Selected:"),
                ui_elem.Text("None"),
            ])

        elements = self.pad_elements_with_breaks(elements, self.height)
        elements = self.truncate_elements(elements)
        elements.append(ui_elem.HeaderFooter())

        self.base_render(console, elements, self.x, self.y, self.width)
예제 #6
0
    def render(self, console):
        elements = []

        console.draw_rect(x=self.x,
                          y=self.y,
                          height=self.height,
                          width=self.width,
                          ch=1,
                          bg=self.color)

        action_log_target = self.engine.selected_entity

        if action_log_target == None or not gen.has_member(
                action_log_target, "recent_actions"):
            action_log_target = self.engine.hunter

        elements.extend([
            ui_elem.HeaderFooter(),
            ui_elem.Break(),
            ui_elem.Text(f"{action_log_target.entity_name} Action Log:"),
        ])

        num_actions_possible = self.height - 5
        recent_actions_subset = action_log_target.recent_actions[
            -num_actions_possible:]

        for action in recent_actions_subset:
            elements.append(ui_elem.PaddedText(action, 1))

        elements = self.pad_elements_with_breaks(elements, self.height)
        elements = self.truncate_elements(elements)
        elements.append(ui_elem.HeaderFooter())

        self.base_render(console, elements, self.x, self.y, self.width)
예제 #7
0
    def render(self, console):
        if not self.hidden:
            console.draw_rect(x=self.x,
                              y=self.y,
                              height=self.height,
                              width=self.width,
                              ch=1,
                              bg=self.color)

            counts = self.engine.get_entity_counts()
            key = "entity-visibility"

            elements = [
                ui_elem.HeaderFooter(),
                ui_elem.CenteredText(f"Entities"),
                ui_elem.CenteredText(f"Show / Hide"),
                ui_elem.Break(),
                ui_elem.Break(
                ),  # TODO fix bug with Break(2) causing height/border problems
                ui_elem.ToggleableTextOnlyButton(
                    "entity-hunter-btn", f" {counts[htr.Hunter]} Hunter",
                    self.engine, key),
                ui_elem.ToggleableTextOnlyButton(
                    "entity-rabbit-btn", f" {counts[rbt.Rabbit]} Rabbits",
                    self.engine, key),
                ui_elem.ToggleableTextOnlyButton(
                    "entity-wolf-btn", f" {counts[wlf.Wolf]}  Wolves",
                    self.engine, key),
                ui_elem.ToggleableTextOnlyButton(
                    "entity-deer-btn",
                    f" {counts[dr.Buck] + counts[dr.Doe]}  Deer", self.engine,
                    key),
                ui_elem.ToggleableTextOnlyButton(
                    "entity-berry-bush-btn",
                    f" {counts[bb.BerryBush]} Berry Bushes", self.engine, key),
            ]

            elements = self.pad_elements_with_breaks(elements, self.height)
            elements = self.truncate_elements(elements)
            elements.append(ui_elem.HeaderFooter())

            self.base_render(console, elements, self.x, self.y, self.width)
            self.create_hitboxes(elements)
예제 #8
0
    def pad_elements_with_breaks(self, elements, height):
        for i in range(height - len(elements)):
            elements.append(ui_elem.Break())

        return elements