62 lines
2.6 KiB
Python
62 lines
2.6 KiB
Python
import npyscreen, sys
|
|
from npyscreen import NotEnoughSpaceForWidget
|
|
from os import system
|
|
|
|
from yaml_parser import parse_datafile as parse
|
|
from GameNavigator import GameNavigator
|
|
|
|
|
|
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
|
|
|
|
# Set screen size before drawing windows
|
|
dimensions = self.gamelib['menu']['graphics']['dimensions']
|
|
system('mode con: cols={0} lines={1}'.format(
|
|
dimensions['inventory_width']+dimensions['art_width'],
|
|
30)) # TODO: Finish setting this up.
|
|
|
|
# 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')
|