import npyscreen import sys from Handler import Handler class QuitButton(npyscreen.ButtonPress): def whenPressed(self): sys.exit(0) class GameNavigator(npyscreen.FormBaseNew): """ This class handles all the drawing and 'graphics' of our game. only basic logic like initial loading should happen here. re-drawing and game logic should be done in Handler.py TODO: Find a fix for initial room startup TODO: Find a way to reset the cursor after a user hits sendButton """ def update_log(self, newline): self.logList.append('> ' + newline) # Append the newline self.logList = self.logList[-7:] # Truncate to only the last 5 lines res = '' # Convert the list to a string for element in self.logList: res = res + str(element) + '\n' res = res.upper() # Log is always uppercase self.logBox.value = res # Set the logbox to that value def create(self): top_division_height = 20 inventory_width = 20 art_width = 100 self.logList = [] self.artBox = self.add(npyscreen.BoxBasic, name='ArtBox', max_width=art_width, max_height=top_division_height, rely=2, relx=inventory_width + 1, editable=False) self.artContent = self.add(npyscreen.MultiLineEdit, rely=3, relx=inventory_width + 2, max_width=art_width - 2, max_height=top_division_height - 2, value=self.parentApp.gamelib['menu']['graphics']['not_found'], editable=False) self.artBox.footer = 'Unknown Location' self.artBox = self.add(npyscreen.BoxBasic, name='Inventory', max_width=inventory_width, max_height=top_division_height, relx=1, rely=2, editable=False) self.logBoxOutline = self.add(npyscreen.BoxBasic, max_width=inventory_width + art_width, max_height=9, relx=1, rely=top_division_height + 2, editable=False) self.logBox = self.add(npyscreen.MultiLineEdit, max_width=inventory_width + art_width - 7, max_height=7, relx=2, rely=top_division_height + 3, editable=False) self.dialogueBoxOutline = self.add(npyscreen.BoxBasic, max_width=inventory_width + art_width, max_height=3, relx=1, rely=top_division_height + 2 + 9, editable=False) self.dialogueBox = self.add(npyscreen.Textfield, name='Type Here', max_width=inventory_width + art_width - 14, max_height=1, relx=2, rely=top_division_height + 3 + 9) self.sendButton = self.add(Handler, name="Send", relx=inventory_width + art_width - 7, rely=top_division_height + 3 + 9) self.quitButton = self.add(QuitButton, name="Quit", relx=1, rely=1) """ We've reached end of __init__ basicly by this point its up to Handler.py to actually play the game, but we should do some basic initalization here """ #TODO: load art from the last place the player was in #TODO: load up inventory #TODO: Expand this by loding the text from the game #WARN: THIS MAY REQUIRE REWRITING HANDLER.PY TO INTALIZE THE ROOM OBJECT OUTSIDE OF HANDLER.PY self.update_log('Welcome back! Try "LOOK AROUND" to get started.') self.update_log('>>Note from joe: Welcome! you\'re playing the demo! Please dont mind text issues like |this| and *this*\ni have yet to implement color!')