npyscreen-adventure-game #8

Manually merged
Kenwood merged 29 commits from npyscreen-adventure-game into adventure-game 2021-02-23 13:43:20 -05:00
3 changed files with 68 additions and 18 deletions
Showing only changes of commit e79fda1bb9 - Show all commits

View File

@ -10,4 +10,9 @@ menu:
/ ____/ | / |/ / ____/ / ____/ | / |/ / ____/
/ / __/ /| | / /|_/ / __/ / / __/ /| | / /|_/ / __/
/ /_/ / ___ |/ / / / /___ / /_/ / ___ |/ / / / /___
\____/_/ |_/_/ /_/_____/ \____/_/ |_/_/ /_/_____/
not_found: |
. / \
/ ! \
/ \

View File

@ -1,17 +1,24 @@
import npyscreen import npyscreen
from npyscreen import NotEnoughSpaceForWidget
from yaml_parser import parse_datafile as parse from yaml_parser import parse_datafile as parse
class GameNavigator(npyscreen.Form): class GameNavigator(npyscreen.Form):
def afterEditing(self): def afterEditing(self):
# TODO: the game needs to happen after this inital main menu self.parentApp.setNextForm(None) # Nothing to do after this but exit the game.
self.parentApp.setNextForm(None)
def create(self): def create(self):
self.myName = self.add(npyscreen.TitleText, name='Name') self.artBox = self.add(npyscreen.BoxBasic, name='ArtBox', max_width=100, max_height=20, relx=2,)
self.myDepartment = self.add(npyscreen.TitleSelectOne, scroll_exit=True, max_height=3, name='Department', self.artBox.footer = 'Unknown Location'
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=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): class MainMenu(npyscreen.Form):
@ -34,26 +41,29 @@ class AlphaWarning(npyscreen.Popup):
'kitsunehosting.net'], editable=False) 'kitsunehosting.net'], editable=False)
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') # 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 # Draw game windows
self.addForm('GAME', GameNavigator, name='Unnamed Adventure Game') 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 # TODO: Create a 'splash screen' or, traditional "main menu"
self.addForm('MENU', MainMenu, name='Welcome to the 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__': if __name__ == '__main__':
# Make a new adventure game if not imported # Make a new adventure game if not imported
adventure_game = AdventureGame() adventure_game = AdventureGame()
# Run the game! # 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')

View File

@ -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()