adventure-game #3
|
@ -11,3 +11,8 @@ menu:
|
|||
/ / __/ /| | / /|_/ / __/
|
||||
/ /_/ / ___ |/ / / / /___
|
||||
\____/_/ |_/_/ /_/_____/
|
||||
|
||||
not_found: |
|
||||
. / \
|
||||
/ ! \
|
||||
/ \
|
|
@ -1,17 +1,24 @@
|
|||
import npyscreen
|
||||
from npyscreen import NotEnoughSpaceForWidget
|
||||
|
||||
from yaml_parser import parse_datafile as parse
|
||||
|
||||
|
||||
class GameNavigator(npyscreen.Form):
|
||||
def afterEditing(self):
|
||||
# TODO: the game needs to happen after this inital main menu
|
||||
self.parentApp.setNextForm(None)
|
||||
self.parentApp.setNextForm(None) # Nothing to do after this but exit the game.
|
||||
|
||||
def create(self):
|
||||
self.myName = self.add(npyscreen.TitleText, name='Name')
|
||||
self.myDepartment = self.add(npyscreen.TitleSelectOne, scroll_exit=True, max_height=3, name='Department',
|
||||
values=['Department 1', 'Department 2', 'Department 3'])
|
||||
self.myDate = self.add(npyscreen.TitleDateCombo, name='Date Employed')
|
||||
self.artBox = self.add(npyscreen.BoxBasic, name='ArtBox', max_width=100, max_height=20, relx=2,)
|
||||
self.artBox.footer = 'Unknown Location'
|
||||
|
||||
self.artBox = self.add(npyscreen.BoxBasic, name='ArtBox', max_width=100, max_height=20, relx=32, rely=2)
|
||||
self.artBox.footer = 'Unknown Location'
|
||||
|
||||
#self.myName = self.add(npyscreen.TitleText, name='Name')
|
||||
#self.myDepartment = self.add(npyscreen.TitleSelectOne, scroll_exit=True, max_height=3, name='Department',
|
||||
# values=['Department 1', 'Department 2', 'Department 3'])
|
||||
#self.myDate = self.add(npyscreen.TitleDateCombo, name='Date Employed')
|
||||
|
||||
|
||||
class MainMenu(npyscreen.Form):
|
||||
|
@ -34,26 +41,29 @@ class AlphaWarning(npyscreen.Popup):
|
|||
'kitsunehosting.net'], editable=False)
|
||||
|
||||
|
||||
|
||||
class AdventureGame(npyscreen.NPSAppManaged):
|
||||
# Do on creation
|
||||
def onStart(self):
|
||||
self.gamelib = parse('gamedata/gamelib.yaml')
|
||||
# Setup some important 'globa' 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
|
||||
|
||||
# Intalize a game renderer for most game windows
|
||||
self.addForm('GAME', GameNavigator, name='Unnamed Adventure Game')
|
||||
# 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
|
||||
|
||||
# Initalize a savegameSelector that allows a user to choose a savegame
|
||||
self.addForm('MENU', MainMenu, name='Welcome to the main menu')
|
||||
# TODO: Create a 'splash screen' or, traditional "main menu"
|
||||
|
||||
# Initalize a savegameSelector that allows a user to choose a savegame
|
||||
self.addForm('MAIN', AlphaWarning, name='Welcome to 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!
|
||||
adventure_game.run()
|
||||
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')
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
import npyscreen
|
||||
|
||||
|
||||
# npyscreen.disableColor()
|
||||
class TestApp(npyscreen.NPSApp):
|
||||
def main(self):
|
||||
F = npyscreen.Form(name="Welcome to Npyscreen", )
|
||||
t = F.add(npyscreen.BoxBasic, name="Basic Box:", max_width=30, relx=2, max_height=3)
|
||||
t.footer = "This is a footer"
|
||||
|
||||
t1 = F.add(npyscreen.BoxBasic, name="Basic Box:", rely=2, relx=32, max_width=30, max_height=3)
|
||||
|
||||
t2 = F.add(npyscreen.BoxTitle, name="Box Title:", max_height=6)
|
||||
t3 = F.add(npyscreen.BoxTitle, name="Box Title2:", max_height=6,
|
||||
scroll_exit=True,
|
||||
contained_widget_arguments={
|
||||
'color': "WARNING",
|
||||
'widgets_inherit_color': True, }
|
||||
)
|
||||
|
||||
t2.entry_widget.scroll_exit = True
|
||||
t2.values = ["Hello",
|
||||
"This is a Test",
|
||||
"This is another test",
|
||||
"And here is another line",
|
||||
"And here is another line, which is really very long. abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz",
|
||||
"And one more."]
|
||||
t3.values = t2.values
|
||||
|
||||
F.edit()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
App = TestApp()
|
||||
App.run()
|
Loading…
Reference in New Issue