import pathlib import npyscreen import logging from npyscreen import NotEnoughSpaceForWidget from os import system from yaml_parser import parse_datafile as parse from GameNavigator import GameNavigator from MainMenu import MainMenu 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): """ This is the 'root' of the entire game! """ # Do on creation def onStart(self): # Setup some important 'global' values we'll need later # Set the path all other files will follow self.mainPath = pathlib.Path(__file__).parent # Setup logging self.log = logging self.log.basicConfig(filename=self.mainPath / 'logs/AdventureGame.log', filemode='w', level=logging.DEBUG) self.log.info('Logging started!') # parse this data first (since it includes graphics for the main menu self.gamelib = parse( self.mainPath / 'gamedata/gamelib.yaml') self.log.debug('Gamelib at {0}'.format(self.mainPath / 'gamedata/gamelib.yaml')) # Intalize the player as none, the player will be created in the main menu. self.player = None # 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. # Set theme #TODO: modify custom theme? npyscreen.setTheme(npyscreen.Themes.ElegantTheme) # 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__': # Set the screen size bigger system('mode con: cols={0} lines={1}'.format(124, 36)) # 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')