93 lines
3.8 KiB
Python
93 lines
3.8 KiB
Python
import npyscreen
|
|
import sys
|
|
|
|
from Handler import Handler
|
|
|
|
|
|
class QuitButton(npyscreen.ButtonPress):
|
|
def whenPressed(self):
|
|
sys.exit(0)
|
|
|
|
|
|
class GameNavigator(npyscreen.FormBaseNew):
|
|
# def afterEditing(self):
|
|
# it self.parentApp.setNextForm('GAME')
|
|
|
|
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)
|