87 lines
2.9 KiB
Python
87 lines
2.9 KiB
Python
import curses
|
|
from curses.textpad import Textbox, rectangle
|
|
|
|
|
|
class AdventureGame:
|
|
def __init__(self, stdscr):
|
|
# Self.stdrscr is our parent standard screen
|
|
self.stdscr = stdscr
|
|
|
|
# This is just done once at startup to get inital windows sizes
|
|
# TODO: handle live window resize!
|
|
self.height, self.width = self.stdscr.getmaxyx()
|
|
|
|
self.command = 0
|
|
|
|
# Clear and refresh the screen
|
|
self.stdscr.clear()
|
|
self.stdscr.refresh()
|
|
|
|
# Setup some colors!
|
|
# Start some curses colors
|
|
curses.start_color()
|
|
curses.init_pair(1, curses.COLOR_CYAN, curses.COLOR_BLACK)
|
|
curses.init_pair(2, curses.COLOR_RED, curses.COLOR_BLACK)
|
|
curses.init_pair(3, curses.COLOR_BLACK, curses.COLOR_WHITE)
|
|
|
|
# Setup art_win
|
|
art_win_width = int((self.width / 3) * 2)
|
|
art_win_begin_x = int(self.width - art_win_width)
|
|
art_win_begin_y = 1 # Must be at least 1 (to allow header)
|
|
art_win_height = int(self.height / 2)
|
|
|
|
art_win = curses.newwin(art_win_height, art_win_width, art_win_begin_y, art_win_begin_x)
|
|
|
|
# Setup dialogue_win
|
|
dialogue_win_width = self.width
|
|
dialogue_win_begin_x = 0
|
|
dialogue_win_begin_y = art_win_height + 1 # Fits 1 underneath the art box above.
|
|
dialogue_win_height = self.height - art_win_height - 2 # Fits 2 underneath the bottom box,
|
|
|
|
dialogue_win = curses.newwin(dialogue_win_height, dialogue_win_width, dialogue_win_begin_y,
|
|
dialogue_win_begin_x)
|
|
|
|
while self.command != ord('q'):
|
|
# Get the height of everything
|
|
self.height, self.width = self.stdscr.getmaxyx()
|
|
|
|
self.title = 'Untitled Adventure Game PRE ALPHA'[:self.width - 1]
|
|
self.statusbarstr = "Press 'q' to exit "
|
|
|
|
# Render status bar
|
|
self.stdscr.attron(curses.color_pair(3))
|
|
self.stdscr.addstr(self.height - 1, 0, self.statusbarstr)
|
|
self.stdscr.addstr(self.height - 1, len(self.statusbarstr), ' ' * (self.width - len(self.statusbarstr) - 1))
|
|
self.stdscr.attroff(curses.color_pair(3))
|
|
|
|
# Render major game windows
|
|
self.draw_art_window(art_win)
|
|
self.command = self.draw_dialogue_box(dialogue_win)
|
|
|
|
# Refresh the screen
|
|
self.stdscr.refresh()
|
|
|
|
# Wait for next input
|
|
# self.command = self.stdscr.getch()
|
|
curses.echo()
|
|
#self.command = self.stdscr.getstr(0, 0)
|
|
|
|
def draw_main_menu(self):
|
|
pass
|
|
|
|
def draw_art_window(self, window):
|
|
window.addstr(0, 0, "Wip")
|
|
window.box()
|
|
window.refresh()
|
|
|
|
def draw_dialogue_box(self, window):
|
|
window.box()
|
|
window.refresh()
|
|
|
|
textbox = Textbox(window)
|
|
return textbox.gather()
|
|
|
|
|
|
if __name__ == '__main__':
|
|
curses.wrapper(AdventureGame)
|