Music questions are working now

This commit is contained in:
Sebastian Lohff 2013-12-02 02:46:33 +01:00
parent f321312a64
commit 649a714bb3
2 changed files with 20 additions and 2 deletions

View File

@ -18,6 +18,7 @@ class MusicBox(object):
@classmethod
def add_music(clazz, name, media_path):
if name not in clazz.media.iterkeys():
clazz.media[name] = phonon.Phonon.MediaSource(media_path)
@classmethod

View File

@ -21,7 +21,9 @@ class QuestionWindow(QtGui.QDialog):
self.answers = QuestionAnswers(self.section, self.qnumber)
if not self.answers.is_answered():
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)