Skip to content

Commit

Permalink
Feature.quiz-UI-fullscreen (#4)
Browse files Browse the repository at this point in the history
Change quiz ui layout:
set video player to fullscreen
change answer options to a horizontal layout instead of vertical layout
include cover image with every answer option
update quote background image
Add setting for fullscreen video player

* Exit automatically after downloading imdb data

* Move video player settings to separate category
  • Loading branch information
seveerekaj committed Jan 11, 2024
1 parent b67d397 commit ca4ccca
Show file tree
Hide file tree
Showing 14 changed files with 298 additions and 239 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
*.pyo
.idea/
venv/
__pycache__/
.venv/
__pycache__/
11 changes: 7 additions & 4 deletions addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.moviequiz" name="Movie Quiz" version="2.0.0" provider-name="twinther, seveerekaj">
<addon id="script.moviequiz" name="Movie Quiz" version="2.1.0" provider-name="twinther, seveerekaj">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
<import addon="script.module.buggalo" version="1.2.0"/>
Expand Down Expand Up @@ -44,11 +44,14 @@
<website>https://github.com/seveerekaj/script.moviequiz</website>
<forum>https://forum.kodi.tv/showthread.php?tid=364172</forum>
<source>https://github.com/seveerekaj/script.moviequiz</source>
<news>v2.0.0 (2021-08-26)
- Complete overhaul of the addon to get it working in Kodi 19 Matrix, add new features, and remove old non-essential features.
<news>v2.1.0 (2024-01-02)
- The quiz interface has a new look! The answers are now in a horizontal layout, with a cover image for each answer option. The video player can now be toggled full screen.

v2.0.0 (2021-08-26)
- Complete overhaul of the addon to get it working in Kodi 19 Matrix, add new features, and remove old non-essential features.
</news>
<assets>
<icon>resources/media/images/icon.png</icon>
</assets>
</extension>
</addon>
</addon>
44 changes: 27 additions & 17 deletions resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -123,20 +123,18 @@ msgid "Downloading IMDB data... (%d of %d)"
msgstr ""

msgctxt "#32111"
msgid "IMDB data downloaded and ready for use. Please exit addon then reopen for quotes to be loaded in game."
msgid "IMDB data downloaded and ready for use. Please reopen addon for quotes to be loaded in game."
msgstr ""

msgctxt "#32112"
msgid ""
"I found this addon in a non-working state and the original developer seemed to have abandoned the project. "
"In Kodi v18 and earlier the addon required only a few small code tweaks to get it working reasonably well; "
"however, when Kodi v19 was released, the code required major refactoring to upgrade it from Python2 to Python3. "
"I decided to take on that venture and have enjoyed the results! I hope you do as well. \n\n"
"To submit feature requests or bug reports, see the Kodi forum:\n"
"[B]https://forum.kodi.tv/showthread.php?tid=364172[/B]\n\n"
"This is a fork of the original (now inactive) addon by twinther. It includes bug fixes and new features. Bug reports and feature requests are welcome! "
"Although I may not get to them right away because I usually end up in the mountains instead of coding during my free time :)\n\n"
"[B]github.com/seveerekaj/script.moviequiz[/B]\n"
"[B]forum.kodi.tv/showthread.php?tid=364172[/B]\n\n"
"--Jake Reeves\n"
"2021.08.28\n\n\n"
"[I]This is the original 'about' summary from the original developer:[/I]\n\n"
"[I]This is the original summary from twinther:[/I]\n\n"
"[B]Thanks for trying the Movie Quiz, I hope you are enjoying it.[/B]\n\n"
"I initially started working on the addon in January 2011, when my girlfriend got they idea for guessing a movie based on a random clip. "
"Since then it has evolved into many questions for both movies and tv shows as well as features such as online highscores, etc.\n\n"
Expand Down Expand Up @@ -291,12 +289,10 @@ msgid "General"
msgstr ""

msgctxt "#32501"
msgid "Movies"
msgid "Content Limits"
msgstr ""

msgctxt "#32502"
msgid "TV Shows"
msgstr ""
#empty string with id 32502

msgctxt "#32503"
msgid "Questions"
Expand Down Expand Up @@ -434,14 +430,28 @@ msgctxt "#32585"
msgid "What TV show is this theme from?"
msgstr ""

msgctxt "#32586"
#empty strings from id 32586 to 32599

msgctxt "#32600"
msgid "Video Player"
msgstr ""

msgctxt "#32601"
msgid "Play videos full screen"
msgstr ""

msgctxt "#32602"
msgid "Minimum start %"
msgstr ""

msgctxt "#32587"
msgctxt "#32603"
msgid "Maximum start %"
msgstr ""

msgctxt "#32588"
msgid "Duration (in seconds)"
msgstr ""
msgctxt "#32604"
msgid "Video clip length (seconds)"
msgstr ""

msgctxt "#32605"
msgid "These settings apply to question types that play a clip from a movie or TV show."
msgstr ""
57 changes: 22 additions & 35 deletions resources/lib/quizlib/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ def onClick(self, controlId):
return
elif action == MenuGui.ACTION_DOWNLOAD_IMDB:
imdb.downloadData()
# force a quit/reopen as quotes are only loaded once in QuizGui.onInit
self.quizGui.close()
self.close()
return
elif action == MenuGui.ACTION_OPEN_SETTINGS:
ADDON.openSettings()
self.validateSettings()
Expand All @@ -198,10 +202,10 @@ def onClick(self, controlId):
class QuizGui(xbmcgui.WindowXML):
C_MAIN_FIRST_ANSWER = 4000
C_MAIN_LAST_ANSWER = 4003
C_MAIN_REPLAY = 4010
C_MAIN_EXIT = 4011
C_MAIN_FIRST_ANSWER_COVER_IMAGE = 4010
C_MAIN_REPLAY = 4301
C_MAIN_EXIT = 4302
C_MAIN_LOADING = 4020
C_MAIN_COVER_IMAGE = 4200
C_MAIN_QUESTION_LABEL = 4300
C_MAIN_PHOTO = 4400
C_MAIN_MOVIE_BACKGROUND = 4500
Expand All @@ -215,13 +219,13 @@ class QuizGui(xbmcgui.WindowXML):
C_MAIN_PHOTO_LABEL_3 = 4713
C_MAIN_VIDEO_FILE_NOT_FOUND = 4800
C_MAIN_VIDEO_VISIBILITY = 5000
C_MAIN_VIDEO_FULLSCREEN_VISIBILITY = 5007
C_MAIN_PHOTO_VISIBILITY = 5001
C_MAIN_QUOTE_VISIBILITY = 5004
C_MAIN_THREE_PHOTOS_VISIBILITY = 5006
C_MAIN_CORRECT_VISIBILITY = 5002
C_MAIN_INCORRECT_VISIBILITY = 5003
C_MAIN_LOADING_VISIBILITY = 5005
C_MAIN_COVER_IMAGE_VISIBILITY = 5007

STATE_SPLASH = 1
STATE_LOADING = 2
Expand All @@ -242,12 +246,12 @@ def __init__(self):
self.lastClickTime = -1
self.delayedNewQuestionTimer = None
self.uiState = self.STATE_SPLASH
self.onSettingsChanged()

def onSettingsChanged(self):
minPercent = ADDON.getSettingInt('question.whatmovieisthis.min_percent')
maxPercent = ADDON.getSettingInt('question.whatmovieisthis.max_percent')
duration = ADDON.getSettingInt('question.whatmovieisthis.duration')
minPercent = ADDON.getSettingInt('video.player.min_percent')
maxPercent = ADDON.getSettingInt('video.player.max_percent')
duration = ADDON.getSettingInt('video.player.duration')
self.getControl(self.C_MAIN_VIDEO_FULLSCREEN_VISIBILITY).setVisible(ADDON.getSettingBool('video.fullscreen.enabled'))
if self.player is None:
self.player = player.TimeLimitedPlayer(min(minPercent, maxPercent), max(minPercent, maxPercent), duration)
else:
Expand All @@ -259,6 +263,7 @@ def onSettingsChanged(self):

@buggalo.buggalo_try_except()
def onInit(self):
self.onSettingsChanged()
self.getControl(2).setVisible(False)
startTime = datetime.datetime.now()
question.IMDB.loadData()
Expand Down Expand Up @@ -307,9 +312,8 @@ def newGame(self, gameInstance):
self.onNewQuestion()

def close(self):
if self.player:
if self.player.isPlaying():
self.player.stopPlayback(True)
if self.player and self.player.isPlaying():
self.player.stopPlayback(True)
super().close()

@buggalo.buggalo_try_except()
Expand Down Expand Up @@ -356,7 +360,7 @@ def onClick(self, controlId):

@buggalo.buggalo_try_except()
def onFocus(self, controlId):
self.onThumbChanged(controlId)
pass

def onGameOver(self):
if self.uiState == self.STATE_GAME_OVER:
Expand Down Expand Up @@ -390,8 +394,11 @@ def onNewQuestion(self):
else:
button.setLabel(answers[idx].text, textColor='0xFFFFFFFF')
button.setVisible(True)

self.onThumbChanged()
coverImage = self.getControl(self.C_MAIN_FIRST_ANSWER_COVER_IMAGE + idx)
if answers[idx].coverFile is not None:
coverImage.setImage(answers[idx].coverFile)
else:
coverImage.setImage(NO_PHOTO_IMAGE)

displayType = self.question.getDisplayType()
if self.question.getFanartFile():
Expand All @@ -403,7 +410,7 @@ def onNewQuestion(self):

if isinstance(displayType, question.VideoDisplayType):
self.getControl(self.C_MAIN_VIDEO_FILE_NOT_FOUND).setVisible(False)
xbmc.sleep(1500) # give skin animation time to execute
xbmc.sleep(1000) # give skin animation time to execute
if not self.player.playWindowed(displayType.getVideoFile()):
self.getControl(self.C_MAIN_VIDEO_FILE_NOT_FOUND).setVisible(True)

Expand Down Expand Up @@ -493,7 +500,6 @@ def onQuestionAnswered(self, answer):
if answerIter.correct:
self.getControl(self.C_MAIN_FIRST_ANSWER + idx).setLabel('[B]%s[/B]' % answerIter.text)
self.setFocusId(self.C_MAIN_FIRST_ANSWER + idx)
self.onThumbChanged(self.C_MAIN_FIRST_ANSWER + idx)
else:
self.getControl(self.C_MAIN_FIRST_ANSWER + idx).setLabel(textColor='0x88888888')

Expand All @@ -508,25 +514,6 @@ def onQuestionAnswered(self, answer):
else:
self.onNewQuestion()

def onThumbChanged(self, controlId=None):
if self.question is None:
return # not initialized yet

if controlId is None:
controlId = self.getFocusId()

if self.C_MAIN_FIRST_ANSWER <= controlId <= self.C_MAIN_LAST_ANSWER:
answer = self.question.getAnswer(controlId - self.C_MAIN_FIRST_ANSWER)
coverImage = self.getControl(self.C_MAIN_COVER_IMAGE)
if answer is not None and answer.coverFile is not None:
self.getControl(self.C_MAIN_COVER_IMAGE_VISIBILITY).setVisible(False)
coverImage.setImage(answer.coverFile)
elif answer is not None and answer.coverFile is not None:
self.getControl(self.C_MAIN_COVER_IMAGE_VISIBILITY).setVisible(False)
coverImage.setImage(NO_PHOTO_IMAGE)
else:
self.getControl(self.C_MAIN_COVER_IMAGE_VISIBILITY).setVisible(True)

@buggalo.buggalo_try_except()
def onQuestionAnswerFeedbackTimer(self):
"""
Expand Down
6 changes: 3 additions & 3 deletions resources/lib/quizlib/imdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import xbmcgui
import xbmcvfs

from resources.lib.quizlib import logger
from . import logger
from .strings import *


Expand Down Expand Up @@ -76,7 +76,7 @@ def getRandomQuote(self, name, year=None, season=None, episode=None, maxLength=N
def _createQuotesIndex(self, line):
"""
Creates an index file of the QUOTES_LIST file. The index contains
byte offsets of each movie title to make it possible to load just
byte offsets of each movie title to make it possible to load just
part of the QUOTES_LIST file.
@param line: a line from QUOTES_LIST
Expand Down Expand Up @@ -213,4 +213,4 @@ def progress(self, received, size, percentage):
except Exception as ex:
d.close()
del d
xbmcgui.Dialog().ok(strings(M_DOWNLOADING_IMDB_DATA), str(ex))
xbmcgui.Dialog().ok(strings(M_DOWNLOADING_IMDB_DATA), str(ex))
2 changes: 1 addition & 1 deletion resources/lib/quizlib/logger.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import xbmc

def log(message, level=xbmc.LOGDEBUG):
xbmc.log("script.moviequiz >> " + message, xbmc.LOGDEBUG)
xbmc.log("script.moviequiz >> " + message, level)

0 comments on commit ca4ccca

Please sign in to comment.