Added in yaml

This works, but has a few minor bugs. it lays the foundation though for more stuff to be added
This commit is contained in:
Joe S 2021-02-16 20:23:26 -05:00
parent db78cca216
commit 1999e8b8ec
4 changed files with 31 additions and 2 deletions

View File

@ -0,0 +1,13 @@
menu:
graphics:
logo: |
__ __ __ ___ __ __
/ / / /___ ____ ____ _____ ___ ___ ____/ / / | ____/ / _____ ____ / /___ __________
/ / / / __ \/ __ \/ __ `/ __ `__ \/ _ \/ __ / / /| |/ __ / | / / _ \/ __ \/ __/ / / / ___/ _ \
/ /_/ / / / / / / / /_/ / / / / / / __/ /_/ / / ___ / /_/ /| |/ / __/ / / / /_/ /_/ / / / __/
\____/_/ /_/_/ /_/\__,_/_/ /_/ /_/\___/\__,_/ /_/ |_\__,_/ |___/\___/_/ /_/\__/\__,_/_/ \___/
_________ __ _________
/ ____/ | / |/ / ____/
/ / __/ /| | / /|_/ / __/
/ /_/ / ___ |/ / / / /___
\____/_/ |_/_/ /_/_____/

View File

@ -1,4 +1,5 @@
import npyscreen
from yaml_parser import parse_datafile as parse
class GameNavigator(npyscreen.Form):
@ -20,7 +21,7 @@ class MainMenu(npyscreen.Form):
def create(self):
self.playerSaveLocation = self.add(npyscreen.TitleFilenameCombo, name="Filename:")
self.add(npyscreen.MultiLineEdit, value='Test', editable=False)
self.add(npyscreen.MultiLineEdit, value=self.parentApp.gamelib['menu']['graphics']['logo'], editable=False)
class AlphaWarning(npyscreen.Popup):
@ -37,6 +38,8 @@ class AlphaWarning(npyscreen.Popup):
class AdventureGame(npyscreen.NPSAppManaged):
# Do on creation
def onStart(self):
self.gamelib = parse('gamedata/gamelib.yaml')
# Intalize a game renderer for most game windows
self.addForm('GAME', GameNavigator, name='Unnamed Adventure Game')

View File

@ -0,0 +1,12 @@
import yaml
def parse_datafile(file):
# With the file open
with open(file, 'r') as stream:
# Try to read it and return it
try:
content = yaml.safe_load(stream)
return content
except yaml.YAMLError as exc:
return exc

View File

@ -1 +1,2 @@
npyscreen~=4.10.5
npyscreen~=4.10.5
PyYAML~=5.1.2