npyscreen-adventure-game #8
|
@ -1,19 +1,14 @@
|
||||||
import npyscreen
|
import npyscreen
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from Handler import Handler
|
||||||
|
|
||||||
|
|
||||||
class QuitButton(npyscreen.ButtonPress):
|
class QuitButton(npyscreen.ButtonPress):
|
||||||
def whenPressed(self):
|
def whenPressed(self):
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
class Render(npyscreen.ButtonPress):
|
|
||||||
def whenPressed(self):
|
|
||||||
self.parent.artContent.value = 'Undraw!'
|
|
||||||
self.parent.artContent.display()
|
|
||||||
self.parent.parentApp.switchForm('GAME')
|
|
||||||
|
|
||||||
|
|
||||||
class GameNavigator(npyscreen.FormBaseNew):
|
class GameNavigator(npyscreen.FormBaseNew):
|
||||||
# def afterEditing(self):
|
# def afterEditing(self):
|
||||||
# it self.parentApp.setNextForm('GAME')
|
# it self.parentApp.setNextForm('GAME')
|
||||||
|
@ -55,7 +50,6 @@ class GameNavigator(npyscreen.FormBaseNew):
|
||||||
editable=False)
|
editable=False)
|
||||||
|
|
||||||
self.logBox = self.add(npyscreen.Textfield,
|
self.logBox = self.add(npyscreen.Textfield,
|
||||||
name='Type Here',
|
|
||||||
max_width=inventory_width + art_width - 7,
|
max_width=inventory_width + art_width - 7,
|
||||||
max_height=7,
|
max_height=7,
|
||||||
relx=2,
|
relx=2,
|
||||||
|
@ -76,7 +70,7 @@ class GameNavigator(npyscreen.FormBaseNew):
|
||||||
relx=2,
|
relx=2,
|
||||||
rely=top_division_height + 3 + 9)
|
rely=top_division_height + 3 + 9)
|
||||||
|
|
||||||
self.sendButton = self.add(Render,
|
self.sendButton = self.add(Handler,
|
||||||
name="Send",
|
name="Send",
|
||||||
relx=inventory_width + art_width - 7,
|
relx=inventory_width + art_width - 7,
|
||||||
rely=top_division_height + 3 + 9)
|
rely=top_division_height + 3 + 9)
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
import npyscreen
|
||||||
|
|
||||||
|
|
||||||
|
class Handler(npyscreen.ButtonPress):
|
||||||
|
"""
|
||||||
|
Very important, called when the player hits send, there are several things we need to do here:
|
||||||
|
1: handle the player's input, and run logic, this is done in handler.py
|
||||||
|
2: prepare new items to display on the screen
|
||||||
|
3: re-render the screen
|
||||||
|
"""
|
||||||
|
def whenPressed(self):
|
||||||
|
self.parent.logBox.value = self.parent.dialogueBox.value
|
||||||
|
self.parent.dialogueBox.value = ''
|
||||||
|
self.parent.artContent.display()
|
||||||
|
self.parent.parentApp.switchForm('GAME')
|
Loading…
Reference in New Issue