Organize where the player() is initalized

This commit is contained in:
Joe S 2021-02-21 17:07:14 -05:00
parent 7eb8dfde07
commit eb70e4a438
2 changed files with 7 additions and 3 deletions

View File

@ -1,5 +1,9 @@
import npyscreen import npyscreen
from Player import Player
class MainMenu(npyscreen.Form): class MainMenu(npyscreen.Form):
def afterEditing(self): def afterEditing(self):
# TODO: the game needs to happen after this inital main menu # TODO: the game needs to happen after this inital main menu
@ -8,4 +12,6 @@ class MainMenu(npyscreen.Form):
def create(self): def create(self):
self.add(npyscreen.FixedText, value='You cannot select a file yet! Just hit OK', editable=False) 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.playerSaveLocation = self.add(npyscreen.TitleFilenameCombo, name="Your save file:")
self.parentApp.player = Player('playerdata/defaults/default_player.yaml')
self.add(npyscreen.MultiLineEdit, value=self.parentApp.gamelib['menu']['graphics']['logo'], editable=False) self.add(npyscreen.MultiLineEdit, value=self.parentApp.gamelib['menu']['graphics']['logo'], editable=False)

View File

@ -5,7 +5,6 @@ from os import system
from yaml_parser import parse_datafile as parse from yaml_parser import parse_datafile as parse
from GameNavigator import GameNavigator from GameNavigator import GameNavigator
from MainMenu import MainMenu from MainMenu import MainMenu
from Player import Player
class AlphaWarning(npyscreen.Popup): class AlphaWarning(npyscreen.Popup):
@ -24,9 +23,8 @@ class AdventureGame(npyscreen.NPSAppManaged):
# Setup some important 'global' values we'll need later # Setup some important 'global' values we'll need later
self.gamelib = parse( self.gamelib = parse(
'gamedata/gamelib.yaml') # parse this data first (since it includes graphics for the main menu 'gamedata/gamelib.yaml') # parse this data first (since it includes graphics for the main menu
self.playerSaveLocation = 'playerdata/defaults/default_player.yaml' #TODO: Actually load the player data
self.player = Player(self.playerSaveLocation) self.player = None # Intalize the player as none, the player will be created in the main menu.
# Set screen size before drawing windows # Set screen size before drawing windows
dimensions = self.gamelib['menu']['graphics']['dimensions'] dimensions = self.gamelib['menu']['graphics']['dimensions']