101 lines
4.3 KiB
Python
101 lines
4.3 KiB
Python
import npyscreen
|
|
from npyscreen import NotEnoughSpaceForWidget
|
|
|
|
from yaml_parser import parse_datafile as parse
|
|
|
|
|
|
class GameNavigator(npyscreen.Form):
|
|
def afterEditing(self):
|
|
self.parentApp.setNextForm(None) # Nothing to do after this but exit the game.
|
|
|
|
def create(self):
|
|
top_division_height = 20
|
|
inventory_width = 20
|
|
art_width = 100
|
|
|
|
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.dialogueBoxOutline = self.add(npyscreen.BoxBasic,
|
|
max_width=inventory_width + art_width,
|
|
max_height=3,
|
|
relx=1,
|
|
rely=top_division_height + 2)
|
|
|
|
self.dialogueBox = self.add(npyscreen.Textfield,
|
|
name='Type Here',
|
|
max_width=inventory_width + art_width - 2,
|
|
max_height=1,
|
|
relx=2,
|
|
rely=top_division_height + 3)
|
|
|
|
|
|
class MainMenu(npyscreen.Form):
|
|
def afterEditing(self):
|
|
# TODO: the game needs to happen after this inital main menu
|
|
self.parentApp.setNextForm('GAME')
|
|
|
|
def create(self):
|
|
self.add(npyscreen.FixedText, value='You cannot select a file yet! Just hit OK', editable=False)
|
|
self.playerSaveLocation = self.add(npyscreen.TitleFilenameCombo, name="Your save file:")
|
|
self.add(npyscreen.MultiLineEdit, value=self.parentApp.gamelib['menu']['graphics']['logo'], editable=False)
|
|
|
|
|
|
class AlphaWarning(npyscreen.Popup):
|
|
def afterEditing(self):
|
|
self.parentApp.setNextForm('MENU')
|
|
|
|
def create(self):
|
|
self.add(npyscreen.Pager, values=['Welcome to Unnamed Adventure game!',
|
|
'Please enjoy your stay and report any bugs at',
|
|
'kitsunehosting.net'], editable=False)
|
|
|
|
|
|
class AdventureGame(npyscreen.NPSAppManaged):
|
|
# Do on creation
|
|
def onStart(self):
|
|
# Setup some important 'global' values we'll need later
|
|
self.gamelib = parse(
|
|
'gamedata/gamelib.yaml') # parse this data first (since it includes graphics for the main menu
|
|
self.playerSaveLocation = None # We'll load the save location after the player gets to the save select screen
|
|
|
|
# Draw game windows
|
|
self.addForm('GAME', GameNavigator, name='Unnamed Adventure Game') # This window should draw the actual game
|
|
self.addForm('MENU', MainMenu, name='Welcome to the main menu') # This window should draw the main menu
|
|
self.addForm('MAIN', AlphaWarning, name='Welcome to the alpha!') # This window is only needed for the ALPHA
|
|
|
|
# TODO: Create a 'splash screen' or, traditional "main menu"
|
|
|
|
|
|
if __name__ == '__main__':
|
|
# Make a new adventure game if not imported
|
|
adventure_game = AdventureGame()
|
|
|
|
# Run the game!
|
|
try:
|
|
adventure_game.run()
|
|
except NotEnoughSpaceForWidget:
|
|
# This exception should catch if a player tries to play in a screen that is too small.
|
|
print('Your screen is too small!\nOr, Joe has not fixed https://kitsunehosting.net/gitea/Kenwood/SNHU-IT-140/issues/7')
|