adventure-game #3
13
Adventure Game/adventure_game/gamedata/gamelib.yaml
Normal file
13
Adventure Game/adventure_game/gamedata/gamelib.yaml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
menu:
|
||||||
|
graphics:
|
||||||
|
logo: |
|
||||||
|
__ __ __ ___ __ __
|
||||||
|
/ / / /___ ____ ____ _____ ___ ___ ____/ / / | ____/ / _____ ____ / /___ __________
|
||||||
|
/ / / / __ \/ __ \/ __ `/ __ `__ \/ _ \/ __ / / /| |/ __ / | / / _ \/ __ \/ __/ / / / ___/ _ \
|
||||||
|
/ /_/ / / / / / / / /_/ / / / / / / __/ /_/ / / ___ / /_/ /| |/ / __/ / / / /_/ /_/ / / / __/
|
||||||
|
\____/_/ /_/_/ /_/\__,_/_/ /_/ /_/\___/\__,_/ /_/ |_\__,_/ |___/\___/_/ /_/\__/\__,_/_/ \___/
|
||||||
|
_________ __ _________
|
||||||
|
/ ____/ | / |/ / ____/
|
||||||
|
/ / __/ /| | / /|_/ / __/
|
||||||
|
/ /_/ / ___ |/ / / / /___
|
||||||
|
\____/_/ |_/_/ /_/_____/
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import npyscreen
|
import npyscreen
|
||||||
|
from yaml_parser import parse_datafile as parse
|
||||||
|
|
||||||
|
|
||||||
class GameNavigator(npyscreen.Form):
|
class GameNavigator(npyscreen.Form):
|
||||||
@@ -20,7 +21,7 @@ class MainMenu(npyscreen.Form):
|
|||||||
|
|
||||||
def create(self):
|
def create(self):
|
||||||
self.playerSaveLocation = self.add(npyscreen.TitleFilenameCombo, name="Filename:")
|
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):
|
class AlphaWarning(npyscreen.Popup):
|
||||||
@@ -37,6 +38,8 @@ class AlphaWarning(npyscreen.Popup):
|
|||||||
class AdventureGame(npyscreen.NPSAppManaged):
|
class AdventureGame(npyscreen.NPSAppManaged):
|
||||||
# Do on creation
|
# Do on creation
|
||||||
def onStart(self):
|
def onStart(self):
|
||||||
|
self.gamelib = parse('gamedata/gamelib.yaml')
|
||||||
|
|
||||||
# Intalize a game renderer for most game windows
|
# Intalize a game renderer for most game windows
|
||||||
self.addForm('GAME', GameNavigator, name='Unnamed Adventure Game')
|
self.addForm('GAME', GameNavigator, name='Unnamed Adventure Game')
|
||||||
|
|
||||||
|
|||||||
12
Adventure Game/adventure_game/yaml_parser.py
Normal file
12
Adventure Game/adventure_game/yaml_parser.py
Normal 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
|
||||||
@@ -1 +1,2 @@
|
|||||||
npyscreen~=4.10.5
|
npyscreen~=4.10.5
|
||||||
|
PyYAML~=5.1.2
|
||||||
Reference in New Issue
Block a user