Warning is being displayed if not all the files are same in the room

This commit is contained in:
Uriziel 2013-01-13 17:00:59 +01:00
parent c91ff941fa
commit b11b10eb67
2 changed files with 31 additions and 3 deletions

View File

@ -193,7 +193,6 @@ class SyncplayClient(object):
def _checkRoomForSameFiles(self, paused):
roomFilesDiffer = not self.userlist.areAllFilesInRoomSameOnFirstUnpause()
if (paused == False and roomFilesDiffer):
self.userlist.roomCheckedForDifferentFiles()
self.ui.showMessage(getMessage("en", "room-files-not-same"), True)
self.__scheduleDifferentFilesWarningOSDDisplay()
@ -209,7 +208,25 @@ class SyncplayClient(object):
else:
self.__differentFileMessageDisplayedFor = 0
self.__differentFileMessageTimer.stop()
def _checkIfYouReAloneInTheRoom(self, paused):
aloneInRoom = self.userlist.areYouAloneInRoomOnFirstUnpause()
if (paused == False and aloneInRoom):
self.ui.showMessage(getMessage("en", "alone-in-the-room"), True)
self.__scheduleAloneInTheRoomWarningOSDDisplay()
def __scheduleAloneInTheRoomWarningOSDDisplay(self): #TODO: refactor
self.__aloneInTheRoomMessageTimer = task.LoopingCall(self.__displayAloneInTheRoomMessageOnOSD)
self.__aloneInTheRoomMessageDisplayedFor = 0
self.__aloneInTheRoomMessageTimer.start(constants.WARNING_OSD_MESSAGES_LOOP_INTERVAL, True)
def __displayAloneInTheRoomMessageOnOSD(self):
if (constants.DIFFERENT_FILE_MESSAGE_DURATION > self.__aloneInTheRoomMessageDisplayedFor):
self._player.displayMessage(getMessage("en", "alone-in-the-room"))
self.__aloneInTheRoomMessageDisplayedFor += constants.WARNING_OSD_MESSAGES_LOOP_INTERVAL
else:
self.__aloneInTheRoomMessageDisplayedFor = 0
self.__aloneInTheRoomMessageTimer.stop()
def _changePlayerStateAccordingToGlobalState(self, position, paused, doSeek, setBy):
madeChangeOnPlayer = False
@ -231,6 +248,9 @@ class SyncplayClient(object):
elif (paused == True and pauseChanged):
madeChangeOnPlayer = self._serverPaused(setBy, diff)
self._checkRoomForSameFiles(paused)
self._checkIfYouReAloneInTheRoom(paused)
if(paused == False):
self.userlist.roomCheckedOnFirstUnpause()
return madeChangeOnPlayer
def updateGlobalState(self, position, paused, doSeek, setBy, latency):
@ -238,7 +258,6 @@ class SyncplayClient(object):
self.__getUserlistOnLogon = False
self.getUserList()
madeChangeOnPlayer = False
if(not paused):
position += latency
if(self._player):
@ -516,7 +535,15 @@ class SyncplayUserlist(object):
return False
return True
def roomCheckedForDifferentFiles(self):
def areYouAloneInRoomOnFirstUnpause(self):
if(self._wasChangeInRoomSinceLastRoomCheck):
for user in self._users.itervalues():
if(user.room == self.currentUser.room):
return False
return True
return False
def roomCheckedOnFirstUnpause(self):
self._wasChangeInRoomSinceLastRoomCheck = False
def showUserList(self):

View File

@ -28,6 +28,7 @@ en = {
"file-different-notification" : "File you are playing appears to be different from <{}>'s", #User
"file-differences-notification" : "Your file differs in the following way(s): ",
"room-files-not-same" : "Not all files played in the room are the same",
"alone-in-the-room": "You're alone in the room",
"different-filesize-notification" : " (their file size is different from yours!)",
"file-played-by-notification" : "File: {} is being played by:", #File