Music questions are working now
This commit is contained in:
parent
f321312a64
commit
649a714bb3
3
music.py
3
music.py
|
@ -18,7 +18,8 @@ class MusicBox(object):
|
|||
|
||||
@classmethod
|
||||
def add_music(clazz, name, media_path):
|
||||
clazz.media[name] = phonon.Phonon.MediaSource(media_path)
|
||||
if name not in clazz.media.iterkeys():
|
||||
clazz.media[name] = phonon.Phonon.MediaSource(media_path)
|
||||
|
||||
@classmethod
|
||||
def play_music(clazz, name):
|
||||
|
|
19
windows.py
19
windows.py
|
@ -21,7 +21,9 @@ class QuestionWindow(QtGui.QDialog):
|
|||
self.answers = QuestionAnswers(self.section, self.qnumber)
|
||||
|
||||
if not self.answers.is_answered():
|
||||
MusicBox.play_music("questionSong")
|
||||
if self.question["Type"] != "Music":
|
||||
MusicBox.play_music("questionSong")
|
||||
|
||||
if self.dj:
|
||||
self.answers.set_dj_points(self.dj[1])
|
||||
playerNo = self.players.index(self.dj[0])+1
|
||||
|
@ -31,6 +33,11 @@ class QuestionWindow(QtGui.QDialog):
|
|||
self.setWindowTitle("Seopardy - %s - %d" % (section, qnumber*100))
|
||||
self._inWindow = False
|
||||
|
||||
if self.question["Type"] == "Music":
|
||||
tag = "%s-%s" % (self.section, self.qnumber)
|
||||
MusicBox.add_music(tag, self.question["Question"])
|
||||
MusicBox.play_music(tag)
|
||||
|
||||
def get_answers(self):
|
||||
return self.answers
|
||||
|
||||
|
@ -89,6 +96,10 @@ class QuestionWindow(QtGui.QDialog):
|
|||
def event(self, e):
|
||||
if e.type() == ButtonEvent.eventType:
|
||||
if e.get_playerno() <= len(self.players) and not self._inWindow:
|
||||
done = False
|
||||
if self.question["Type"] == "Music":
|
||||
MusicBox.stop_music()
|
||||
|
||||
self._inWindow = True
|
||||
player = self.players[e.get_playerno()-1]
|
||||
qawin = QuestionAnswerWindow(player, self)
|
||||
|
@ -96,10 +107,16 @@ class QuestionWindow(QtGui.QDialog):
|
|||
if res == QuestionAnswerWindow.CORRECT:
|
||||
self.answers.add_try(player, correct=True)
|
||||
self._inWindow = False
|
||||
done = True
|
||||
self.close()
|
||||
elif res == QuestionAnswerWindow.WRONG:
|
||||
self.answers.add_try(player, correct=False)
|
||||
self._inWindow = False
|
||||
|
||||
if self.question["Type"] == "Music" and not done:
|
||||
# restart music if question was not answered
|
||||
MusicBox.play_music("%s-%s" % (self.section, self.qnumber))
|
||||
|
||||
return True
|
||||
else:
|
||||
return super(QuestionWindow, self).event(e)
|
||||
|
|
Loading…
Reference in New Issue