Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nicer menu formating #26

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions base/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ def __init__(self, console_manager, scene_manager, game_context):

@abc.abstractmethod
def render(self):
"""This will be called by the scene_manager."""
pass

@abc.abstractmethod
def handle_input(self):
"""Handle any player expected input here."""
pass

def transition_to(self, scene_name):
"""Tells the scene_manager to move to the provided scene."""
self.scene_manager.transition_to(scene_name)
9 changes: 3 additions & 6 deletions managers/console_manager.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Console Manager: handles the creation and rendering of all consoles.
"""
import textwrap

import tdl
import os
Expand Down Expand Up @@ -39,11 +40,7 @@ class Menu(Console):
"""
Create console for displaying choices to the player
"""
MENU_TEMPLATE = """
{menu_name}
{menu_text}
{options}
"""
MENU_TEMPLATE = "{menu_name}\n\n{menu_text}\n\n{options}"

OPTION_TEMPLATE = "({option_char:}) {option_description}"

Expand Down Expand Up @@ -72,7 +69,7 @@ def _build_options(self):
)
option_msg.append(option)
self.letter_index += 1
return "\n".join(option_msg)
return textwrap.indent("\n\n".join(option_msg), " ") # TODO: this could be nicer...

def print_str(self, text, pos_x, pos_y):
self.move(pos_x, pos_y)
Expand Down
3 changes: 2 additions & 1 deletion scenes/character_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def __init__(self, console_manager, scene_manager, game_context):
self.options,
self.main_console.width,
self.main_console.height)
# self.menu.create_menu(20, 20)
self.active_control = self.control_name

# TODO THIS should be in the menu itself.
Expand All @@ -74,7 +75,7 @@ def render_menu(self):

def render(self, **kwargs):
self.menu.clear()
self.menu.move(0, 0)
self.menu.move(20, 20)
for control in self.controls:
if self.active_control is None \
or self.controls.index(self.active_control) >= self.controls.index(control):
Expand Down
8 changes: 4 additions & 4 deletions ui/flavor_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
MAIN_MENU = {
"name": "Main Menu",
"text": """
Welcome to Python Roguelike Framework!
This '@' is you. Your goal is to explore the dungeon. Use caution though as there are
monsters lurking around every corner waiting to jump out and attack you!
Welcome to Python Roguelike Framework!

This '@' is you. Your goal is to explore the dungeon. Use caution though as there are
monsters lurking around every corner waiting to jump out and attack you!
""",
"options": ["Play", "Quit"]
}