Instructions and credits menu options now working.
This commit is contained in:
parent
fd93c993c1
commit
99d26b7951
@ -27,7 +27,7 @@ class pygstormgames:
|
|||||||
|
|
||||||
# Initialize core systems
|
# Initialize core systems
|
||||||
self.config = Config(gameTitle)
|
self.config = Config(gameTitle)
|
||||||
self.display = Display(gameTitle)
|
self.display = Display(self)
|
||||||
self.speech = Speech()
|
self.speech = Speech()
|
||||||
self.sound = Sound(self)
|
self.sound = Sound(self)
|
||||||
self.scoreboard = Scoreboard(self)
|
self.scoreboard = Scoreboard(self)
|
||||||
|
42
display.py
42
display.py
@ -17,16 +17,17 @@ import wx
|
|||||||
class Display:
|
class Display:
|
||||||
"""Handles display and text navigation systems."""
|
"""Handles display and text navigation systems."""
|
||||||
|
|
||||||
def __init__(self, gameTitle):
|
def __init__(self, game):
|
||||||
"""Initialize display system.
|
"""Initialize display system.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
gameTitle (str): Title of the game
|
game (PygStormGames): Reference to main game object
|
||||||
"""
|
"""
|
||||||
self.window = pyglet.window.Window(800, 600, caption=gameTitle)
|
self.game = game
|
||||||
|
self.window = pyglet.window.Window(800, 600, caption=game.gameTitle)
|
||||||
self.currentText = []
|
self.currentText = []
|
||||||
self.currentIndex = 0
|
self.currentIndex = 0
|
||||||
self.gameTitle = gameTitle
|
self.gameTitle = game.gameTitle
|
||||||
|
|
||||||
def display_text(self, text, speech):
|
def display_text(self, text, speech):
|
||||||
"""Display and navigate text with speech output.
|
"""Display and navigate text with speech output.
|
||||||
@ -53,31 +54,44 @@ class Display:
|
|||||||
self.currentIndex = 0
|
self.currentIndex = 0
|
||||||
speech.speak(self.navText[self.currentIndex])
|
speech.speak(self.navText[self.currentIndex])
|
||||||
|
|
||||||
@self.window.event
|
# Use the game's existing input handlers
|
||||||
def on_key_press(symbol, modifiers):
|
validKeys = [
|
||||||
if symbol in (key.ESCAPE, key.RETURN):
|
pyglet.window.key.ESCAPE,
|
||||||
self.window.remove_handler('on_key_press', on_key_press)
|
pyglet.window.key.RETURN,
|
||||||
return
|
pyglet.window.key.SPACE,
|
||||||
|
pyglet.window.key.UP,
|
||||||
|
pyglet.window.key.DOWN,
|
||||||
|
pyglet.window.key.W,
|
||||||
|
pyglet.window.key.S,
|
||||||
|
pyglet.window.key.C,
|
||||||
|
pyglet.window.key.T
|
||||||
|
]
|
||||||
|
|
||||||
if symbol in (key.DOWN, key.S) and self.currentIndex < len(self.navText) - 1:
|
while True:
|
||||||
|
key = self.game.wait(validKeys)
|
||||||
|
|
||||||
|
if key in (pyglet.window.key.ESCAPE, pyglet.window.key.RETURN):
|
||||||
|
break
|
||||||
|
|
||||||
|
if key in (pyglet.window.key.DOWN, pyglet.window.key.S) and self.currentIndex < len(self.navText) - 1:
|
||||||
self.currentIndex += 1
|
self.currentIndex += 1
|
||||||
speech.speak(self.navText[self.currentIndex])
|
speech.speak(self.navText[self.currentIndex])
|
||||||
|
|
||||||
if symbol in (key.UP, key.W) and self.currentIndex > 0:
|
if key in (pyglet.window.key.UP, pyglet.window.key.W) and self.currentIndex > 0:
|
||||||
self.currentIndex -= 1
|
self.currentIndex -= 1
|
||||||
speech.speak(self.navText[self.currentIndex])
|
speech.speak(self.navText[self.currentIndex])
|
||||||
|
|
||||||
if symbol == key.SPACE:
|
if key == pyglet.window.key.SPACE:
|
||||||
speech.speak('\n'.join(self.originalText[1:-1]))
|
speech.speak('\n'.join(self.originalText[1:-1]))
|
||||||
|
|
||||||
if symbol == key.C:
|
if key == pyglet.window.key.C:
|
||||||
try:
|
try:
|
||||||
pyperclip.copy(self.navText[self.currentIndex])
|
pyperclip.copy(self.navText[self.currentIndex])
|
||||||
speech.speak("Copied " + self.navText[self.currentIndex] + " to the clipboard.")
|
speech.speak("Copied " + self.navText[self.currentIndex] + " to the clipboard.")
|
||||||
except:
|
except:
|
||||||
speech.speak("Failed to copy the text to the clipboard.")
|
speech.speak("Failed to copy the text to the clipboard.")
|
||||||
|
|
||||||
if symbol == key.T:
|
if key == pyglet.window.key.T:
|
||||||
try:
|
try:
|
||||||
pyperclip.copy(''.join(self.originalText[2:-1]))
|
pyperclip.copy(''.join(self.originalText[2:-1]))
|
||||||
speech.speak("Copied entire message to the clipboard.")
|
speech.speak("Copied entire message to the clipboard.")
|
||||||
|
42
menu.py
42
menu.py
@ -111,7 +111,47 @@ class Menu:
|
|||||||
"exit"
|
"exit"
|
||||||
]
|
]
|
||||||
|
|
||||||
return self.show_menu(options, with_music=True)
|
while True:
|
||||||
|
selection = self.show_menu(options, with_music=True)
|
||||||
|
|
||||||
|
if selection == "play":
|
||||||
|
return selection
|
||||||
|
elif selection == "instructions":
|
||||||
|
# Pause menu music
|
||||||
|
if self.game.sound.currentBgm:
|
||||||
|
self.game.sound.currentBgm.pause()
|
||||||
|
|
||||||
|
self.game.display.instructions(self.game.speech)
|
||||||
|
|
||||||
|
# Resume menu music
|
||||||
|
if self.game.sound.currentBgm:
|
||||||
|
self.game.sound.currentBgm.play()
|
||||||
|
|
||||||
|
elif selection == "learn_sounds":
|
||||||
|
if self.learn_sounds() == "menu":
|
||||||
|
continue
|
||||||
|
|
||||||
|
elif selection == "credits":
|
||||||
|
# Pause menu music
|
||||||
|
if self.game.sound.currentBgm:
|
||||||
|
self.game.sound.currentBgm.pause()
|
||||||
|
|
||||||
|
self.game.display.credits(self.game.speech)
|
||||||
|
|
||||||
|
# Resume menu music
|
||||||
|
if self.game.sound.currentBgm:
|
||||||
|
self.game.sound.currentBgm.play()
|
||||||
|
|
||||||
|
elif selection == "donate":
|
||||||
|
# Pause menu music
|
||||||
|
if self.game.sound.currentBgm:
|
||||||
|
self.game.sound.currentBgm.pause()
|
||||||
|
|
||||||
|
self.game.display.donate(self.game.speech)
|
||||||
|
|
||||||
|
# Resume menu music
|
||||||
|
if self.game.sound.currentBgm:
|
||||||
|
self.game.sound.currentBgm.play()
|
||||||
|
|
||||||
def learn_sounds(self):
|
def learn_sounds(self):
|
||||||
"""Interactive menu for learning game sounds.
|
"""Interactive menu for learning game sounds.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user