Exemplo n.º 1
0
    def __init__(self, windowres, fade_direction=""):
        '''
        Demarrage de l'ecran : chargement des images, polices d'ecriture, et variables globales (animations,
        etat et communication avec MainSC).
        '''
        self.bg_img = pygame.image.load("Images/landscape1.png")

        self.TitleFont = pygame.font.Font("Fonts/HelveticaNeue-UltraLight.ttf",
                                          180)
        self.SwipeFont = pygame.font.Font("Fonts/HelveticaNeue-Light.ttf", 25)
        self.TimeFont = pygame.font.Font("Fonts/HelveticaNeue-UltraLight.ttf",
                                         60)

        self.WindowRes = windowres
        self.ScreenStatus = "FADING_IN"
        self.fade_direction = fade_direction
        '''
        Create the animation structure
        '''
        self.animation = AnimationManager()
        self.bonjour_offset = 0.0
        self.bonjour_color = 0

        self.swipe_color = 0
        self.swipe_offset = 0.0

        self.time_color = 0
        self.time_offset = 0.0
        self.goto_sent = False
Exemplo n.º 2
0
    def __init__(self, windowres):
        self.WindowRes = windowres
        self.ScreenStatus = "OUT"
        self.chrono = AnimationManager()

        self.Locked = True
        self.InputCode = ""
        self.SecretCode = "1234"

        self.PannelsStatus = "SLEEP"  # SLEEP pour afficher l'ecran noir, LOCK pour le deverrouillage

        self.TitleFont = pygame.font.Font("Fonts/HelveticaNeue-UltraLight.ttf",
                                          88)
        self.TimeFont = pygame.font.Font("Fonts/HelveticaNeue-UltraLight.ttf",
                                         180)
        self.SecondsFont = pygame.font.Font(
            "Fonts/HelveticaNeue-UltraLight.ttf", 80)
        self.DateFont = pygame.font.Font("Fonts/HelveticaNeue-Light.ttf", 25)
        self.SwipeFont = pygame.font.Font("Fonts/HelveticaNeue-Light.ttf", 20)
        self.WarningFont = pygame.font.Font("Fonts/HelveticaNeue-Medium.ttf",
                                            12)

        self.bg = pygame.image.load("Images/lock_bg1.png")
        self.digitcounter_whiteimg = pygame.image.load(
            "Images/Numbers/round_square_white.png")
        self.digitcounter_darkimg = pygame.image.load(
            "Images/Numbers/round_square_dark.png")
        self.numbers_imgs = [
            pygame.image.load("Images/Numbers/zero.png"),
            pygame.image.load("Images/Numbers/one.png"),
            pygame.image.load("Images/Numbers/two.png"),
            pygame.image.load("Images/Numbers/three.png"),
            pygame.image.load("Images/Numbers/four.png"),
            pygame.image.load("Images/Numbers/five.png"),
            pygame.image.load("Images/Numbers/six.png"),
            pygame.image.load("Images/Numbers/seven.png"),
            pygame.image.load("Images/Numbers/eight.png"),
            pygame.image.load("Images/Numbers/nine.png"),
            pygame.image.load("Images/Numbers/back.png")
        ]

        self.chrono_warningbanner = AnimationManager()
        self.show_warningbanner = False

        self.general_transp = 0.0
        self.time_color = 0.0
        self.date_color = 0.0
        self.swipe_color = 0.0
        self.bg_transp = 0.0
        self.keypad_transp = 0.0
        self.warning_transp = 0.0
Exemplo n.º 3
0
def getImages(home='./'):
    # General Sprites
    IMAGESDICT = {}
    for root, dirs, files in os.walk(home + 'Sprites/General/'):
        for name in files:
            if name.endswith('.png'):
                full_name = os.path.join(root, name)
                IMAGESDICT[name[:-4]] = Engine.image_load(full_name, convert_alpha=True)

    # Icon Sprites
    loc = home + 'Sprites/Icons/'
    ICONDICT = {image[:-4]: Engine.image_load(loc + image, convert_alpha=True) for image in os.listdir(loc) if image.endswith('.png')}
    
    # Item and Skill and Status sprites
    loc = home + 'Data/Items/'
    ITEMDICT = {image[:-4]: Engine.image_load(loc + image, convert=True) for image in os.listdir(loc) if image.endswith('.png')}
    for image in ITEMDICT.values():
        Engine.set_colorkey(image, COLORKEY, rleaccel=True)

    # Unit Sprites
    UNITDICT = {}
    for root, dirs, files in os.walk(home + 'Data/Characters/'):
        for name in files:
            if name.endswith('.png'):
                full_name = os.path.join(root, name)
                image = Engine.image_load(full_name, convert=True)
                Engine.set_colorkey(image, COLORKEY, rleaccel=True)
                UNITDICT[name[:-4]] = image

    # Battle Animations
    ANIMDICT = AnimationManager.BattleAnimationManager(COLORKEY, home)

    return IMAGESDICT, UNITDICT, ICONDICT, ITEMDICT, ANIMDICT
Exemplo n.º 4
0
    def __init__(self, windowres):
        # Charger une image
        self.sunny_icon = pygame.image.load("Images/weather_sunny_transparent.png").convert_alpha()
        # position image (seulement pour animation)
        self.sunny_positionX = 80  # direction : 580
        self.sunny_positionY = 100  # direction : 200
        # texto
        self.ScreenStatus = "RUNNING"
        # police du texte( la rappeler qaund on ecrit le txt) -> temperature/humidite...
        self.TitleFont     = pygame.font.Font("Fonts/HelveticaNeue-Light.ttf", 55)
        self.TitleFont2    = pygame.font.Font("Fonts/HelveticaNeue-UltraLight.ttf", 100)
        self.WaitFont      = pygame.font.Font("Fonts/HelveticaNeue-UltraLight.ttf", 22)
        self.PostTitleFont = pygame.font.Font("Fonts/HelveticaNeue-Medium.ttf", 12, bold=False)

        self.Aujourdhui_color = 0

        self.TemperatureText = self.TitleFont2.render("15 C", True, (255, 255, 255))

        self.chrono = AnimationManager()
Exemplo n.º 5
0
 def Main(args):
     Program.irr = IrrDevice()
     Program.irr.CreateDevice(DriverType.Direct3D9, Dimension2Di(1024, 600))
     Program.animationManager = AnimationManager(Program.irr)
     Program.textureManager = TextureManager(Program.irr)
     Program.textureManager.OnTextureLoaded += Program.textureManager_OnTextureLoaded
     Program.irr.Lock()
     Program.irr.Device.SetWindowResizable(True)
     Program.irr.Device.OnEvent += Program.Device_OnEvent
     Program.irr.Scene.AddCameraSceneNode()
     Program.irr.Scene.AddEmptySceneNode(None, 1001)
     Program.irr.Scene.AddHillPlaneMesh("previewPlate", Dimension2Df(80),
                                        Dimension2Di(1))
     Program.initUI()
     Program.openFolder(Path.GetFullPath("../../media"))
     lastFPS = -1
     while Program.irr.Device.Run():
         Program.irr.Driver.BeginScene(True, True, Color(0x112233))
         Program.irr.Scene.DrawAll()
         if Program.selectedNode == None:
             Program.irr.GUI.DrawAll()
         Program.drawScrollPosition()
         Program.drawTextureManagerActivity()
         Program.drawPreviewPlateTooltip()
         Program.irr.Driver.EndScene()
         fps = Program.irr.Driver.FPS
         if lastFPS != fps:
             Program.irr.Device.SetWindowCaption(
                 String.Format(
                     "Image Browser - Irrlicht Lime [{0}] fps: {1}",
                     Program.irr.Driver.Name, fps))
             lastFPS = fps
         Program.irr.Unlock()
         Program.animationManager.Run()
         if Program.wantChangeFolder:
             Program.wantChangeFolder = False
             p = Program.irr.GUI.RootElement.GetElementFromID(1003).Text
             d = Windows.Forms.FolderBrowserDialog()
             d.SelectedPath = p
             if d.ShowDialog(
             ) == System.Windows.Forms.DialogResult.OK and d.SelectedPath != p:
                 Program.openFolder(d.SelectedPath)
         if Program.wantUpdateActiveCameraAspectRatio:
             Program.wantUpdateActiveCameraAspectRatio = False
             Program.irr.Scene.ActiveCamera.AspectRatio = Program.irr.DriverNoCheck.ScreenSize.Width / Program.irr.DriverNoCheck.ScreenSize.Height
         Program.irr.Lock()
     Program.irr.Unlock()
     Program.textureManager.Stop()
     Program.animationManager.Clear()
     Program.irr.Drop()
Exemplo n.º 6
0
    def __init__(self, titlefont, title, date, hour, link, descriptionfont,
                 description, image):
        '''
        Initialisation des elements dont la Card a besoin.
        '''
        self.CardSize = (329, 200)
        self.ActiveDraw = False

        self.Title = title
        self.Date = date
        self.Hour = hour
        self.Link = link
        self.Description = description

        self.Image = image
        print image.get_rect()
        self.Image = pygame.transform.scale(self.Image, (400, 200))
        print self.Image.get_width() * (self.Image.get_height() / 200)

        self.openonphone_img = pygame.image.load(
            "Images/NewsScreen/openInBrowser.png")
        self.more_img = pygame.image.load("Images/NewsScreen/more.png")
        self.sent_img = pygame.image.load("Images/NewsScreen/sent.png")

        self.TitleFont = titlefont
        self.DescriptionFont = descriptionfont

        self.drawpos = (2000, 2000)
        self.banner_extended = False
        self.banner_pos = 140

        self.requestpush = False
        self.sentpush = False
        self.pushchrono = AnimationManager()

        self.CardSurface = pygame.Surface((329, 200))
        self.reRender = True
Exemplo n.º 7
0
    def __init__(self, WindowRes):
        '''
        Demarrage et initialisation de l'application.
        Chargement d'images, recuperation des articles, demarrage de pushbullet.
        '''
        self.WindowRes = WindowRes
        self.ScreenStatus = "FADING_IN"
        self.bg = pygame.image.load("Images/news1.png")
        self.hamburger_img = pygame.image.load("Images/hamburger.png")
        self.home = pygame.image.load("Images/homenews.png")

        self.LMm_img = pygame.image.load("Images/NewsScreen/LeMondeM.png")
        self.LMfull_img = pygame.image.load(
            "Images/NewsScreen/LeMondeFull.png")
        self.FB_img = pygame.image.load("Images/NewsScreen/fb.png")

        self.ancrage = 0.0
        self.banner_chrono = AnimationManager()
        self.banner_extended = False
        self.banner_pos = 38.0
        '''
        Initialisation et connection au service qui permettra d'envoyer le lien de l'article clique au
        telephone portable associe au systeme : le service Pushbullet.
        '''
        self.connexion = True
        print "Starting pushbullet service..."
        try:
            self.pushbullet = PM()
            print "Connected."
        except:
            self.pushbullet = None
            self.connexion = False
            print "No Internet connection."
        '''
        Recuperation et classement des actualites chez LeMonde.fr
        '''
        itemTitleFont = pygame.font.Font("Fonts/HelveticaNeue-Light.ttf", 14)
        itemDescriptionFont = pygame.font.Font("Fonts/HelveticaNeue-Light.ttf",
                                               11)
        self.lemonde_items = []
        print "Getting LeMonde news..."
        for item in NewsCollector().get_lemonde_posts():
            '''
            On cree des objets poru chaque article de la classe mineure (voir en fin de fichier).
            '''
            self.lemonde_items.append(
                NewsItem(itemTitleFont, item[0], item[1], item[2], item[3],
                         itemDescriptionFont, item[4], item[5]))
Exemplo n.º 8
0
class SleepManager():
    def __init__(self, WindowRes):
        self.WindowRes = WindowRes
        self.chrono = AnimationManager()
        self.lock_screen = LockScreen(WindowRes)

        self.lockscreen_activated = False

    def Update(self, InputEvents):
        self.chrono.Update()
        if self.lock_screen.ScreenStatus is not "OUT":
            self.lock_screen.Update(InputEvents)

        for event in InputEvents:
            if "TOUCH" in event or "SCROLL" in event:
                self.chrono.reset()

        if self.chrono.elapsed_time(
        ) > 90 and self.lock_screen.ScreenStatus is "OUT":
            self.launch_lockscreen()
        else:
            self.unlock_lockscreen()

        if "RESET" in self.lock_screen.ScreenStatus:
            self.lock_screen = LockScreen(self.WindowRes)
            self.chrono.reset()
            self.lockscreen_activated = False

    def launch_lockscreen(self):
        if self.lockscreen_activated == False:
            self.lock_screen = LockScreen(self.WindowRes)
            self.lock_screen.Activate()
        self.lockscreen_activated = True

    def unlock_lockscreen(self):
        if self.lockscreen_activated == True:
            pass  #self.lock_screen.Deactivate()
        self.lockscreen_activated = False

    def Draw(self, gameDisplay):
        if self.lock_screen.ScreenStatus != "OUT":
            self.lock_screen.Draw(gameDisplay)
Exemplo n.º 9
0
    def run(self):
        self.__user_cmd_provider = UserCmdProvider.UserCmdProvider()

        self.__data_manager = DataManager.DataManager()
        self.__video_manager = VideoManager.VideoManager()
        self.__analyser_manager = AnalyserManager.AnalyserManager()
        self.__animation_manager = AnimationManager.AnimationManager()

        self.__data_manager.start()
        self.__video_manager.start()

        # scanner data receiver thread
        self.__data_receive_thread = threading.Thread(
            target=self.__data_manager.receive_scanner_data,
            args=(self.__scanner_data_queue,)
        )
        self.__data_receive_thread.start()

        # mp4 file names receiver thread
        self.__video_receive_thread = threading.Thread(
            target=self.__video_manager.receive_mp4_files,
            args=(self.__mp4_files_queue,)
        )
        self.__video_receive_thread.start()

        # transfer scanner data to be analysed
        self.__data_transfer_thread = threading.Thread(
            target=self.__analyser_manager.analyse_data,
            args=(self.__scanner_data_queue, self.__animations_queue, self.__notifications_queue,)
        )
        self.__data_transfer_thread.start()

        # transfer mp4 file names to be analysed
        self.__video_transfer_thread = threading.Thread(
            target=self.__analyser_manager.analyse_video,
            args=(self.__mp4_files_queue, self.__analysed_mp4_files_queue,)
        )
        self.__video_transfer_thread.start()

        # transfer analysed files to website location
        self.__transfer_analysed_thread = threading.Thread(
            target=self.__video_manager.transfer_analysed_files,
            args=(self.__analysed_mp4_files_queue,)
        )
        self.__transfer_analysed_thread.start()

        # notifications upload thread
        self.__notifications_thread = threading.Thread(
            target=self.upload_notifications,
            args=(self.__notifications_queue,)
        )
        self.__notifications_thread.start()

        # execute animations thread
        self.__animations_thread = threading.Thread(
            target=self.__animation_manager.animates,
            args=(self.__animations_queue,)
        )
        self.__animations_thread.start()

        self.__is_running_lock.acquire()
        self.__is_running = True
        self.__is_running_lock.release()
        self.__thread_timer = time.time()

        while True:
            if time.time() - self.__thread_timer > 1000.0 / 1000.0:
                self.__is_running_lock.acquire()
                condition = self.__is_running
                self.__is_running_lock.release()
                if bool(condition) is False:
                    break
                self.__thread_timer = time.time()

                video_condition = self.__user_cmd_provider.get_user_preference(
                    self.__user_cmd_provider.VIDEO_ENABLED
                )
                if video_condition is not None:
                    if int(video_condition) == 0:
                        self.__video_manager.enable_recording(False)
                    else:
                        self.__video_manager.enable_recording(True)

        # wait for every thread to finish their work
        self.__data_manager.stop()
        self.__data_manager.join()
        print '[Application Manager] data_manager stopped '

        self.__video_manager.stop()
        self.__video_manager.join()
        print '[Application Manager] video_manager stopped '

        self.__data_receive_thread.is_running = False
        self.__data_receive_thread.join()
        print '[Application Manager] data_receive_thread stopped '

        self.__video_receive_thread.is_running = False
        self.__video_receive_thread.join()
        print '[Application Manager] video_receive_thread stopped '

        self.__data_transfer_thread.is_running = False
        self.__data_transfer_thread.join()
        print '[Application Manager] data_transfer_thread stopped '

        self.__video_transfer_thread.is_running = False
        self.__video_transfer_thread.join()
        print '[Application Manager] video_transfer_thread stopped '

        self.__transfer_analysed_thread.is_running = False
        self.__transfer_analysed_thread.join()
        print '[Application Manager] transfer_analysed_thread stopped '

        self.__notifications_thread.is_running = False
        self.__notifications_thread.join()
        print '[Application Manager] notifications_thread stopped '

        self.__animations_thread.is_running = False
        self.__animations_thread.join()
        print '[Application Manager] animations_thread stopped '
Exemplo n.º 10
0
    def __init__(self, windowres, fadeorigin="APP"):
        '''
        On charge le fond d'ecran
        '''
        self.bg_img = pygame.image.load(
            "Images/landscape1.png").convert_alpha()
        self.horizontal_line = pygame.image.load(
            "Images/horizontal_separator.png").convert_alpha()
        '''
        On charge les polices qui permettent d'afficher du texte
        '''
        self.TimeFont = pygame.font.Font("Fonts/HelveticaNeue-UltraLight.ttf",
                                         180)
        self.SecondsFont = pygame.font.Font(
            "Fonts/HelveticaNeue-UltraLight.ttf", 80)
        self.AppsTitleFont = pygame.font.Font("Fonts/HelveticaNeue-Light.ttf",
                                              22)
        self.DateFont = pygame.font.Font("Fonts/HelveticaNeue-Light.ttf", 25)
        self.DescriptionFont = pygame.font.Font(
            "Fonts/HelveticaNeue-Light.ttf", 18)
        self.DisponibleFont = pygame.font.Font("Fonts/HelveticaNeue-Light.ttf",
                                               14)
        self.AppsHintFont = pygame.font.Font("Fonts/HelveticaNeue-Light.ttf",
                                             18)
        '''
        Variables qui servent a la communication entre MainSC et l'application (transitions et animations)
        '''
        self.WindowRes = windowres
        self.ScreenStatus = "FADING_IN"
        self.fade_direction = ""  # A ENLEVER, GARDER SELEMENT TRANSITIONDESTINATION
        self.TransitionDestination = ""
        self.fade_origin = fadeorigin
        self.arrow = SwipeArrow()

        # A ENLEVER, A OUBLIER
        self.hint_animation_activated = False
        self.hint_chrono = AnimationManager()
        '''
        On charge les icones des applications pour les dessiner dans le panneau correspondant.
        '''
        self.app_icons = [
            pygame.image.load(
                "Images/Icones_Apps/WeatherApp.png").convert_alpha(),
            pygame.image.load(
                "Images/Icones_Apps/CalendarApp.png").convert_alpha(),
            pygame.image.load(
                "Images/Icones_Apps/TimeApp.png").convert_alpha(),
            pygame.image.load(
                "Images/Icones_Apps/NewsApp.png").convert_alpha(),
            pygame.image.load(
                "Images/Icones_Apps/CalculatorApp.png").convert_alpha(),
            pygame.image.load(
                "Images/Icones_Apps/StocksApp.png").convert_alpha(),
            pygame.image.load(
                "Images/Icones_Apps/SnakeApp.png").convert_alpha(),
            pygame.image.load(
                "Images/Icones_Apps/AutomationApp.png").convert_alpha()
        ]

        self.blackicons = [
            None,
            None,
            None,
            None,  # TEMPORAIRE? ON GRISE LES APPLICATIONS QUI N4ONT PAS ENCORE ETE DEVELOPPEES
            pygame.image.load(
                "Images/Icones_Apps/CalculatorAppblack.png").convert_alpha(),
            pygame.image.load(
                "Images/Icones_Apps/StocksAppblack.png").convert_alpha(),
            pygame.image.load(
                "Images/Icones_Apps/SnakeAppblack.png").convert_alpha(),
            pygame.image.load(
                "Images/Icones_Apps/AutomationAppblack.png").convert_alpha()
        ]

        self.app_descriptions = [
            "Meteo",
            "Calendrier",
            "Horloges",
            "Actualites",
            "Calculatrice",
            "Bourse",
            "Snake",
            "Domotique",
        ]
        '''
        On cree un chronometre qui nous permet de faire avancer des animations
        Et des variables qui sont l'objet de ces animations
        '''
        self.animation = AnimationManager()
        self.time_color = 0
        self.date_color = 0
        self.bg_transp = 20.0
        self.widget_opacity = 0
        '''
        Variables pour gerer le swipe entre ecran d'acceuil et menu d'applications
        '''
        self.ancrage = 0
        self.scrolling = False

        self.widget_manager = WidgetManager(self.WindowRes)
Exemplo n.º 11
0
class HomeScreen():
    '''
    HOMESCREEN : C'est l'ecran d'accueil, qui affiche l'heure en grand, et la liste d'Applications
    ainsi que les widgets.
    '''
    def __init__(self, windowres, fadeorigin="APP"):
        '''
        On charge le fond d'ecran
        '''
        self.bg_img = pygame.image.load(
            "Images/landscape1.png").convert_alpha()
        self.horizontal_line = pygame.image.load(
            "Images/horizontal_separator.png").convert_alpha()
        '''
        On charge les polices qui permettent d'afficher du texte
        '''
        self.TimeFont = pygame.font.Font("Fonts/HelveticaNeue-UltraLight.ttf",
                                         180)
        self.SecondsFont = pygame.font.Font(
            "Fonts/HelveticaNeue-UltraLight.ttf", 80)
        self.AppsTitleFont = pygame.font.Font("Fonts/HelveticaNeue-Light.ttf",
                                              22)
        self.DateFont = pygame.font.Font("Fonts/HelveticaNeue-Light.ttf", 25)
        self.DescriptionFont = pygame.font.Font(
            "Fonts/HelveticaNeue-Light.ttf", 18)
        self.DisponibleFont = pygame.font.Font("Fonts/HelveticaNeue-Light.ttf",
                                               14)
        self.AppsHintFont = pygame.font.Font("Fonts/HelveticaNeue-Light.ttf",
                                             18)
        '''
        Variables qui servent a la communication entre MainSC et l'application (transitions et animations)
        '''
        self.WindowRes = windowres
        self.ScreenStatus = "FADING_IN"
        self.fade_direction = ""  # A ENLEVER, GARDER SELEMENT TRANSITIONDESTINATION
        self.TransitionDestination = ""
        self.fade_origin = fadeorigin
        self.arrow = SwipeArrow()

        # A ENLEVER, A OUBLIER
        self.hint_animation_activated = False
        self.hint_chrono = AnimationManager()
        '''
        On charge les icones des applications pour les dessiner dans le panneau correspondant.
        '''
        self.app_icons = [
            pygame.image.load(
                "Images/Icones_Apps/WeatherApp.png").convert_alpha(),
            pygame.image.load(
                "Images/Icones_Apps/CalendarApp.png").convert_alpha(),
            pygame.image.load(
                "Images/Icones_Apps/TimeApp.png").convert_alpha(),
            pygame.image.load(
                "Images/Icones_Apps/NewsApp.png").convert_alpha(),
            pygame.image.load(
                "Images/Icones_Apps/CalculatorApp.png").convert_alpha(),
            pygame.image.load(
                "Images/Icones_Apps/StocksApp.png").convert_alpha(),
            pygame.image.load(
                "Images/Icones_Apps/SnakeApp.png").convert_alpha(),
            pygame.image.load(
                "Images/Icones_Apps/AutomationApp.png").convert_alpha()
        ]

        self.blackicons = [
            None,
            None,
            None,
            None,  # TEMPORAIRE? ON GRISE LES APPLICATIONS QUI N4ONT PAS ENCORE ETE DEVELOPPEES
            pygame.image.load(
                "Images/Icones_Apps/CalculatorAppblack.png").convert_alpha(),
            pygame.image.load(
                "Images/Icones_Apps/StocksAppblack.png").convert_alpha(),
            pygame.image.load(
                "Images/Icones_Apps/SnakeAppblack.png").convert_alpha(),
            pygame.image.load(
                "Images/Icones_Apps/AutomationAppblack.png").convert_alpha()
        ]

        self.app_descriptions = [
            "Meteo",
            "Calendrier",
            "Horloges",
            "Actualites",
            "Calculatrice",
            "Bourse",
            "Snake",
            "Domotique",
        ]
        '''
        On cree un chronometre qui nous permet de faire avancer des animations
        Et des variables qui sont l'objet de ces animations
        '''
        self.animation = AnimationManager()
        self.time_color = 0
        self.date_color = 0
        self.bg_transp = 20.0
        self.widget_opacity = 0
        '''
        Variables pour gerer le swipe entre ecran d'acceuil et menu d'applications
        '''
        self.ancrage = 0
        self.scrolling = False

        self.widget_manager = WidgetManager(self.WindowRes)

    def Update(self, InputEvents):
        '''-------------------------------------------------------------------------------------------------------------
        ------------------------------------------------PARTIE SCROLL---------------------------------------------------
        -------------------------------------------------------------------------------------------------------------'''
        '''
        Partie qui recupere les entrees tactiles pour voir s'il y a un scroll, et ajuste le scroll de maniere generale :
            - Quand il y a scroll, bouge tous les panels dans la direction du scroll
            - Limite ce scroll entre la zone des deux panels pour eviter qu'on depasse et aille trop loin
            - Enregistre quand l'utilisateur a fini de scroller pour permettre a la partie suivante de code de se mettre
                a recentrer les panels dans le cas ou l'utilisateur a arrete son scroll en plein milieu
        '''
        for event in InputEvents:
            if "SCROLL " in event:
                self.scrolling = True
                scroll_distanceY = Helpers.get_message_x_y(event)[1]
                self.ancrage -= scroll_distanceY
                if self.ancrage < 0: self.ancrage = 0
                if self.ancrage > self.WindowRes[1]:
                    self.ancrage = self.WindowRes[1]
            if "ENDSCROLL" in event:
                self.scrolling = False
        '''
        Partie qui s'occupe de l'animation du retour de scrolling (quand on lache le doigt et que l'ecran se recentre
        automatiquement)
        '''
        if self.ancrage != 0 and self.ancrage != self.WindowRes[
                1] and self.scrolling == False:
            if self.ancrage > self.WindowRes[1] / 2:
                self.ancrage = Helpers.mathlerp(self.ancrage,
                                                self.WindowRes[1], 0.55)
                if self.ancrage > self.WindowRes[1] - 2:
                    self.ancrage = self.WindowRes[1]
            if self.ancrage <= self.WindowRes[1] / 2:
                self.ancrage = Helpers.mathlerp(self.ancrage, 0, 0.55)
                if self.ancrage < 2: self.ancrage = 0
        '''-------------------------------------------------------------------------------------------------------------
        ----------------------------------------------PARTIE TRANSITIONS -----------------------------------------------
        -------------------------------------------------------------------------------------------------------------'''
        '''
        Si l'utilisateur a fait un swype (et uniquement pendant qu'il est sur le panel ecran d'acceuil),
        On envoie un texto comme quoi on commence a disparaitre et on enregistre la direction de l'utilisateur
        pour plus tard (voir fade_out()).
        '''
        '''
        if "LEFT" in InputEvents and self.ancrage < 40:
            self.ScreenStatus = "FADING_OUT"
            self.fade_direction = "LEFT"
            self.animation.reset()
        if "RIGHT" in InputEvents and self.ancrage < 40:
            self.ScreenStatus = "FADING_OUT"
            self.fade_direction = "RIGHT"
            self.animation.reset()
        '''
        for event in InputEvents:
            if "TOUCH" in event:
                for line in range(0, 2):
                    for app in range(0, 4):
                        if Helpers.is_in_rect(pygame.mouse.get_pos(), [
                                50 + (app + 1) * 700 / 4 - 700 / 8 -
                                self.app_icons[app].get_rect().width / 2,
                                45 + line * 180 - 450 + self.ancrage, 140, 140
                        ]):
                            app_name = self.app_descriptions[app + line * 4]
                            print app_name
                            self.ScreenStatus = "FADING_OUT"
                            self.animation.reset()

                            if app_name is "Meteo":
                                self.TransitionDestination = "WEATHERSCREEN"
                            if app_name is "Calendrier":
                                self.TransitionDestination = "CALENDARSCREEN"
                            if app_name is "Horloges":
                                self.TransitionDestination = "TIMESCREEN"
                            if app_name is "Actualites":
                                self.TransitionDestination = "NEWSSCREEN"

                            if app_name is "Calculatrice":
                                self.TransitionDestination = "CALCULATORSCREEN"
                            if app_name is "Bourse":
                                self.TransitionDestination = "STOCKSSCREEN"
                            if app_name is "Snake":
                                self.TransitionDestination = "SNAKESCREEN"
                            if app_name is "Domotique":
                                self.TransitionDestination = "AUTOMATIONSCREEN"
                '''
                Si quelqu'un clique sur le texte APPLICATIONS en haut, on déclenche une animation qui l'indique qu'on peut
                glisser vers le bas.
                '''
                if Helpers.is_in_rect(
                        pygame.mouse.get_pos(),
                    [self.WindowRes[0] / 2 - 90, 0, 180, 35]):
                    self.hint_animation_activated = True
                    self.hint_chrono.reset()
                    print "activated"
        '''
        # Animation qu'on a retiree car trop moche, pour l'instant.
        if self.hint_animation_activated is True:
            x = self.hint_chrono.elapsed_time()
            if x > 0 and x < 1:
                s = 0.1
                self.ancrage = 30 *  (1 / (s * math.sqrt(2 * math.pi))) * math.exp(- (((x - 0.5) ** 2) / (2 * (s ** 2))))
                print "animation"
            elif x >= 1:
                self.hint_animation_activated = False
                self.ancrage = 0
        '''

        if self.ScreenStatus is "FADING_IN":
            self.fade_in()
        if self.ScreenStatus is "FADING_OUT":
            self.fade_out()
        '''-------------------------------------------------------------------------------------------------------------
        -------------------------------------------PARTIE FONCTIONNALITES-----------------------------------------------
        -------------------------------------------------------------------------------------------------------------'''
        '''
        On laisse le manager de widgets updater les widgets.
        HomeScreen ne s'occupe pas des widgets, seul WidgetManager dessine, update et distribue les inputs.
        '''
        self.widget_manager.Update(InputEvents)

    def Draw(self, gameDisplay):
        '''
        On affiche le fond d'ecran en fond (cad en premiere position dans le Draw())
        '''
        affine = -0.229166667 * self.ancrage + 180
        if self.ScreenStatus == "RUNNING":
            Helpers.blit_alpha(gameDisplay, self.bg_img, (0, 0), affine)
        if "FADING" in self.ScreenStatus:
            Helpers.blit_alpha(gameDisplay, self.bg_img, (0, 0), affine)
        '''-------------------------------------------------------------------------------------------------------------
        -------------------------------------------------PANEL HOME-----------------------------------------------------
        -------------------------------------------------------------------------------------------------------------'''
        '''
        Renders the Date and Time (date, Hours+Minutes, Seconds)
        '''
        timeSurface = self.TimeFont.render(strftime("%H:%M"), True,
                                           (255, 255, 255))
        secondsSurface = self.SecondsFont.render(strftime(":%S"), True,
                                                 (255, 255, 255))
        dateSurface = self.DateFont.render(
            "Today is " + strftime("%A %d, %B %Y"), True, (255, 255, 255))
        '''
        Calculs de positions pour simplifier les blit() en bas
        '''
        secondsWidth = self.SecondsFont.render(
            strftime(":00"), True, (255, 255, 255)).get_rect().width
        timePos = self.WindowRes[0] / 2 - (timeSurface.get_rect().width +
                                           secondsWidth) / 2
        '''
        On dessine tout, avec transparence
        '''
        # on dessine l'heure
        Helpers.blit_alpha(
            gameDisplay, timeSurface,
            (timePos, self.WindowRes[1] * 2 / 5 -
             timeSurface.get_rect().height / 2 - 60 + self.ancrage),
            self.time_color)

        # on dessine les secondes
        Helpers.blit_alpha(
            gameDisplay, secondsSurface,
            (timePos + timeSurface.get_rect().width,
             timeSurface.get_rect().bottom -
             timeSurface.get_rect().height * 1 / 5 - 45 + self.ancrage),
            self.time_color)

        # on dessine la date situee sous l'heure
        Helpers.blit_alpha(
            gameDisplay, dateSurface,
            (self.WindowRes[0] / 2 - dateSurface.get_rect().width / 2,
             self.WindowRes[1] * 3 / 5 - dateSurface.get_rect().height / 2 -
             60 + self.ancrage), self.date_color)
        '''
        On affiche la ligne separatrice au milieu des deux panels.
        De plus on la decale un petit peu en fonction de quel ecran on regarde pour constamment la cacher,
        sauf pendant qu'on scroll.
        '''
        self.off = -1
        if self.ancrage == self.WindowRes[1]:
            self.off = 0
        gameDisplay.blit(self.horizontal_line, (35, self.off + self.ancrage))
        '''
        Indication d'ou sont les applications
        '''
        appshint = self.AppsHintFont.render("APPLICATIONS", True,
                                            (255, 255, 255))
        Helpers.blit_alpha(gameDisplay, appshint,
                           (self.WindowRes[0] / 2 -
                            appshint.get_rect().width / 2, 10 + self.ancrage),
                           self.widget_opacity)

        self.arrow.Draw(
            gameDisplay,
            (self.WindowRes[0] / 2 - appshint.get_rect().width / 2 - 26,
             13 + self.ancrage), "DOWN", self.widget_opacity - 60)
        self.arrow.Draw(
            gameDisplay,
            (self.WindowRes[0] / 2 + appshint.get_rect().width / 2 + 10,
             13 + self.ancrage), "DOWN", self.widget_opacity - 60)

        self.widget_manager.Draw(gameDisplay, self.ancrage,
                                 self.widget_opacity)
        '''-------------------------------------------------------------------------------------------------------------
        ---------------------------------------------PANEL APPLICATIONS-------------------------------------------------
        -------------------------------------------------------------------------------------------------------------'''
        '''
        On genere et dessine le titre "applications" en haut du panel
        '''
        AppsTitleSurface = self.AppsTitleFont.render("Applications", True,
                                                     (255, 255, 255))
        gameDisplay.blit(
            AppsTitleSurface,
            (self.WindowRes[0] / 2 - AppsTitleSurface.get_rect().width / 2,
             7 + self.ancrage - self.WindowRes[1]))
        '''
        On dessine la ligne horizontale separatrice sous le titre "Applications"
        '''
        gameDisplay.blit(self.horizontal_line,
                         (35, 43 + self.ancrage - self.WindowRes[1]))
        '''
        TEMPORAIRE On dessine une petite description sympa
        '''
        #AppsTitleSurface    = self.DateFont.render("No apps here yet. Download them in the store !", True, (255, 255, 255))
        #gameDisplay.blit(AppsTitleSurface, (self.WindowRes[0] / 2 - AppsTitleSurface.get_rect().width / 2, 230 + self.ancrage - self.WindowRes[1]))
        '''
        On dessine les icones d'applications et les descriptions.
        '''
        prochainement = self.DisponibleFont.render("Prochainement", True,
                                                   (255, 255, 255))
        disponible = self.DisponibleFont.render("disponible", True,
                                                (255, 255, 255))
        for line in range(0, 2):
            for app in range(0, 4):
                gameDisplay.blit(self.app_icons[app + line * 4],
                                 (50 + (app + 1) * 700 / 4 - 700 / 8 -
                                  self.app_icons[app].get_rect().width / 2,
                                  45 + line * 180 - 450 + self.ancrage))

                description = self.DescriptionFont.render(
                    self.app_descriptions[app + line * 4], True,
                    (255, 255, 255))
                gameDisplay.blit(description,
                                 (50 + (app + 1) * 700 / 4 - 700 / 8 -
                                  description.get_rect().width / 2,
                                  45 + self.app_icons[app].get_rect().height -
                                  5 + line * 180 - 450 + self.ancrage))

                if line == 1:
                    Helpers.blit_alpha(
                        gameDisplay, self.blackicons[app + line * 4],
                        (50 + (app + 1) * 700 / 4 - 700 / 8 -
                         self.app_icons[app].get_rect().width / 2,
                         45 + line * 180 - 450 + self.ancrage), 190)
                    gameDisplay.blit(
                        prochainement,
                        (50 + (app + 1) * 700 / 4 - 700 / 8 -
                         prochainement.get_rect().width / 2,
                         70 + line * 180 - 450 + self.ancrage +
                         self.app_icons[app].get_rect().width / 2 -
                         prochainement.get_rect().width / 2))
                    gameDisplay.blit(
                        disponible,
                        (50 + (app + 1) * 700 / 4 - 700 / 8 -
                         disponible.get_rect().width / 2,
                         77 + line * 180 - 450 + self.ancrage +
                         self.app_icons[app].get_rect().height / 2 -
                         disponible.get_rect().width / 2))

    def fade_in(self):
        animTime = self.animation.elapsed_time()
        '''
        Animation du fond d'ecran. Si l'ecran precedent est STARTSCREEN, on ne fait pas d'animation (pour une transition
        plus jolie). Sinon, on fait apparaitre progressivement le fond d'ecran.

        TEMPORAIRE : Choisir l'animation ensemble, l'apparition progressive n'est que temporaire.
        '''
        if self.fade_origin is "STARTSCREEN":
            self.bg_transp = 180
        else:
            if animTime > 0 and animTime < 2:  # TEMPORAIRE transition au debut
                self.bg_transp = 160 / (
                    1 + math.exp(-(animTime - 1) /
                                 0.2)) + 20  # TEMPORAIRE transition au debut

        if animTime > 0 and animTime < 1:
            self.time_color = 255 / (1 + math.exp(-(animTime - 0.5) / 0.1))

        if animTime > 0.75 and animTime < 1.75:
            self.date_color = 255 / (1 + math.exp(-(animTime - 1.25) / 0.1))

        if animTime > 1.25 and animTime < 2.25:
            self.widget_opacity = 255 / (1 +
                                         math.exp(-(animTime - 1.75) / 0.1))
        '''
        Envoie un texto qui signale au MainSC que la transition est finie, et donc qu'il peut supprimer
        l'ecran occupe precedemment.
        '''
        if animTime > 3:
            self.ScreenStatus = "RUNNING"
        print self.ancrage

    def fade_out(self):
        animTime = self.animation.elapsed_time()

        if self.ancrage > 430:  # si on a clique sur un icone d'application, la lancer tout de suite
            if animTime > 0.2:
                if self.fade_direction is not "":
                    self.ScreenStatus = "GOTO_" + ScreenRedirector(
                    ).next_screen("HOMESCREEN",
                                  self.fade_direction) + "_AND_DEAD"
                else:
                    self.ScreenStatus = "GOTO_" + self.TransitionDestination + "_AND_DEAD"
                    print "sent goto " + self.TransitionDestination

        else:  # si on est sur le panneau principal, faire une animation sortante avant de changer de Screen.
            if animTime > 0 and animTime < 1:
                self.time_color = 255 / (1 + math.exp(-(0.5 - animTime) / 0.1))
            if animTime > 0.5 and animTime < 1:
                self.date_color = 255 / (1 +
                                         math.exp(-(0.75 - animTime) / 0.05))
            '''
            Envoie un texto quand l'ecran a fini de disparaitre, avec la destination (le nouvel ecran a faire apparaitre).
            '''
            if animTime > 1.5:
                if self.fade_direction is not "":
                    self.ScreenStatus = "GOTO_" + ScreenRedirector(
                    ).next_screen("HOMESCREEN",
                                  self.fade_direction) + "_AND_DEAD"
                else:
                    self.ScreenStatus = "GOTO_" + self.TransitionDestination + "_AND_DEAD"
                    print "sent goto " + self.TransitionDestination

    def Reset(self):
        pass

    def Quit(self):
        pass

    def __str__(self):
        return "HOMESCREEN"
Exemplo n.º 12
0
class NewsItem():
    '''
    Cette classe est un des rectangles qui correspondent a chaque article dans l'interface : je l'appelle la "Card".
    La classe principale cree une liste d'objets de cette classe, chacun ayant les donnees d'un article.
    '''
    def __init__(self, titlefont, title, date, hour, link, descriptionfont,
                 description, image):
        '''
        Initialisation des elements dont la Card a besoin.
        '''
        self.CardSize = (329, 200)
        self.ActiveDraw = False

        self.Title = title
        self.Date = date
        self.Hour = hour
        self.Link = link
        self.Description = description

        self.Image = image
        print image.get_rect()
        self.Image = pygame.transform.scale(self.Image, (400, 200))
        print self.Image.get_width() * (self.Image.get_height() / 200)

        self.openonphone_img = pygame.image.load(
            "Images/NewsScreen/openInBrowser.png")
        self.more_img = pygame.image.load("Images/NewsScreen/more.png")
        self.sent_img = pygame.image.load("Images/NewsScreen/sent.png")

        self.TitleFont = titlefont
        self.DescriptionFont = descriptionfont

        self.drawpos = (2000, 2000)
        self.banner_extended = False
        self.banner_pos = 140

        self.requestpush = False
        self.sentpush = False
        self.pushchrono = AnimationManager()

        self.CardSurface = pygame.Surface((329, 200))
        self.reRender = True

    def Update(self, InputEvents, pushbullet):
        '''
        Partie qui s'occupe de gerer les etats de Pushbullet (le service qui permet d'envoyer l'article sur son portable).
        Trois etats :
            - Inactif, ou self.requestpush et self.sentpush sont a False. On attend que l'utilisateur active le service.
            - Actif, notification pas encore envoyee. On envoie la notification. self.requestpush est a True et self.sentpush est a False
            - Envoye, self.requestpush est a True et self.setnpush est a True. Cet etat resqte actif pendant quelques secondes
                pour l'animation, et tout repasse a False plus tard.
        '''
        if self.requestpush is True:
            try:
                pushbullet.send_link(self.Title, self.Link)
                self.sentpush = True
                self.pushchrono.reset()
            except:
                pass
            self.requestpush = False
        '''
        Partie qui gere les entrees tactiles
        '''
        for event in InputEvents:
            if "TOUCH" in event:
                '''
                On prend la position du clic relative a la position de la Card, puisque cette classe ne s'occupe que de la Card.
                '''
                if Helpers.is_in_rect(pygame.mouse.get_pos(), [
                        self.drawpos[0], self.drawpos[1], self.CardSize[0],
                        self.CardSize[1]
                ]):
                    mousepos = (pygame.mouse.get_pos()[0] - self.drawpos[0],
                                pygame.mouse.get_pos()[1] - self.drawpos[1])
                    '''
                    Si on clique sur l'icone d'envoi Pushbullet, activer l'envoi et les animations.
                    '''
                    if Helpers.is_in_rect(
                            mousepos,
                        [self.CardSize[0] - 40, self.CardSize[1] - 40, 40, 40
                         ]) and self.banner_pos == 0:
                        self.requestpush = True
                        self.reRender = True
                    '''
                    Si on clique sur la baniere, la faire apparaitre ou disparaitre.
                    '''
                    if Helpers.is_in_rect(mousepos, [
                            0, self.CardSize[1] - 60, self.CardSize[0], 60
                    ]) and self.banner_extended is False:
                        self.banner_extended = True
                    if Helpers.is_in_rect(mousepos,
                                          [0, 0, self.CardSize[0], 60
                                           ]) and self.banner_extended is True:
                        self.banner_extended = False
                else:
                    '''
                    Si on a capte un clic mais qu'il est en dehors de la Card, on rabaisse la banniere.
                    '''
                    self.banner_extended = False
        '''
        Animations de la banniere
        '''
        if self.banner_extended is True:
            if self.banner_pos > 1:
                self.banner_pos = Helpers.mathlerp(self.banner_pos, 0, 0.5)
                self.reRender = True
            else:
                self.banner_pos = 0
        if self.banner_extended is False:
            if self.banner_pos < 139:
                self.banner_pos = Helpers.mathlerp(self.banner_pos, 140, 0.5)
                self.reRender = True
            else:
                self.banner_pos = 140

    def Render(self, drawpos):
        '''
        Ici, on dessine l'integralite des elements qui composent la Card.
        '''
        self.ActiveDraw = True
        self.drawpos = drawpos

        if self.reRender == True:
            self.reRenderAll(drawpos)
        '''
        On renvoie a la classe principale le rendu final de la Card. La classe principale la dessinera au bon endroit.
        '''
        return self.CardSurface

    def reRenderAll(self, drawpos):
        self.reRender = False
        '''
        On cree la surface on l'on dessine la Card
        '''
        self.drawpos = drawpos
        s = pygame.Surface(self.CardSize).convert_alpha()
        '''
        On affiche le fond d'ecran, qui est l'image de l'article
        '''
        s.blit(self.Image, (0, 0))
        '''
        Baniere blanche en bas qui contient le titre de l'article. Il s'agrandit si l'on a clique dessus
        pour afficher la description de l'article.
        '''
        white_titlebanner = pygame.Surface(
            (self.CardSize[0], 200 - self.banner_pos + 1)).convert_alpha()
        white_titlebanner.fill((220, 220, 220, 240))
        s.blit(white_titlebanner, (0, self.banner_pos))
        '''
        Titre de l'article
        '''
        self.render_text_in_zone(s, self.Title, self.TitleFont, (0, 0, 0),
                                 (5, self.banner_pos + 8), 320, 22)
        '''
        Elements a l'interieur de la banniere, qui apparait quand on clique dessus.
        '''
        if self.banner_pos is not 140:
            '''
            Description courte de l'article, dessinee avec la focntion permettant d'ecrire automatiquement sur
            plusieurs lignes
            '''
            self.render_text_in_zone(s, self.Description, self.DescriptionFont,
                                     (0, 0, 0), (10, self.banner_pos + 60),
                                     320, 18)
            '''
            Partie qui s'occupe de l'icone en bas a gauche, anime pour illustrer chaque etat de la fonctionnalite Pushbullet (celle qui
            permet d'ouvrir l'article sur le telephone)
            '''
            '''
            Dessin d'un carre plus fonce derriere l'icone, question design
            '''
            blur = pygame.Surface((40, 40)).convert_alpha()
            blur.fill((0, 0, 0, 20))
            s.blit(blur, (self.CardSize[0] - 40,
                          self.CardSize[1] - 40 + self.banner_pos))
            '''
            Changement et animation des icones en fonction de l'etat du service Pushbullet
            '''
            if self.requestpush == True:
                '''
                Si requestpush est a True, cela veut dire que Pushbullet est en train d'envoyer l'article. On dessine l'icone correspondant,
                sans animation.
                '''
                s.blit(self.more_img,
                       (self.CardSize[0] - 32.5,
                        self.CardSize[1] - 32.5 + self.banner_pos))
                self.reRender = True
            elif self.sentpush == True:
                '''
                Cette zone s'active quand la notification a ete envoyee. L'icone est animee en disparaissant progressivement, et reactive
                la troisieme partie lorsque l'icone de confirmation d'envoi a disparu.
                '''
                Helpers.blit_alpha(s, self.sent_img,
                                   (self.CardSize[0] - 30,
                                    self.CardSize[1] - 30 + self.banner_pos),
                                   -128 * self.pushchrono.elapsed_time() + 255)

                self.reRender = True

                if -128 * self.pushchrono.elapsed_time() + 255 < 0:
                    self.sentpush = False

            else:
                '''
                Lorsque Pushbullet ne fait rien, on affiche l'icone standart qui invite l'uyilisateur a envoyer l'article sur son
                portable.
                '''
                s.blit(self.openonphone_img,
                       (self.CardSize[0] - 35,
                        self.CardSize[1] - 35 + self.banner_pos))

        self.CardSurface.blit(s, (0, 0))

    def render_text_in_zone(self, gameDisplay, text, font, color, startpos,
                            horizontal_size_limit, interligne):
        '''
        Fonction qui permet d'ecrire du texte sur plusieurs lignes. Voir la fonction dans CalendarScreen pour plus de details.
        '''
        s = font.render(
            text, True, color
        )  # on dessine le texte une première fois pour avoir sa longueur
        h_size = horizontal_size_limit - startpos[
            0]  # la limite en longueur que le texte ne doit pas depasser
        vertical_size = 0  # voir return en derniere ligne
        '''
        Si le texte est trop long, on le coupe jusqu'a ce qu'il reste dans l'espace delimite
        '''
        if s.get_rect().width > h_size:
            splitted_text = text.split(
            )  # On separe la phrase entre chaque mot
            final_lines = []

            cropped_size = 0
            done = False
            for i in range(
                    len(splitted_text) - 1, -1,
                    -1):  # on scanne toues les mots en partant du dernier
                if not done:
                    word_image = font.render(
                        splitted_text[i], True,
                        color)  # on dessine le mot pour avoir

                    cropped_size += word_image.get_rect(
                    ).width + 4  # on compte ce mot en plus dans la largeur du texte
                    if s.get_rect(
                    ).width - cropped_size < h_size:  # on teste si le bout coupe est suffisant pour que le titre ne depasse pas la
                        # limite
                        '''
                        On prepare le dessin en dessinant la premier ligne...
                        '''
                        first_line_text = ""
                        for word in splitted_text[0:i]:
                            first_line_text += " " + word
                        first_line = font.render(first_line_text, True, color)
                        final_lines.append(first_line)
                        '''
                        ... separement a la deuxieme (le bout de la premiere coupee)
                        '''
                        line_text = ""
                        for word in range(i, len(splitted_text)):
                            line_text += " " + splitted_text[word]

                        final_line = font.render(line_text, True, color)
                        final_lines.append(final_line)

                        done = True
            '''
            On dessine les lignes sur l'ecran, avec la bonne position
            '''
            for linenumber in range(0, len(final_lines)):
                gameDisplay.blit(
                    final_lines[linenumber],
                    (startpos[0], startpos[1] + interligne * linenumber))
            vertical_size = interligne * len(
                final_lines
            )  # on enregistre l'espace vertical qui a ete utilise pour afficher le texte
            # (voir return en derniere ligne)

        else:
            gameDisplay.blit(
                s, startpos
            )  # si le titre n'est pas trop long, on le dessine simplement.
            vertical_size = s.get_rect().height
        return vertical_size  # redonne la taille verticale qui a ete utilisee pour afficher ce texte (utile pour afficher les prochains titres en dessous).
Exemplo n.º 13
0
    def __init__(self, WindowRes):
        self.windowres = WindowRes
        self.infos_meteo = WeatherCollector()

        self.ScreenStatus = "RUNNING"

#Icones meteo de la grande fenetre

        self.sunny_icon = pygame.image.load("Images/Icones_Meteo/weather-clear-2.png").convert_alpha()
        self.sunny_cloud_icon = pygame.image.load("Images/Icones_Meteo/weather-few-clouds-2.png").convert_alpha()
        self.cloud_icon = pygame.image.load("Images/Icones_Meteo/weather-overcast-2.png").convert_alpha()
        self.light_rain_icon = pygame.image.load("Images/Icones_Meteo/weather-showers-scattered-2.png").convert_alpha()
        self.heavy_rain_icon = pygame.image.load("Images/Icones_Meteo/weather-showers-2.png").convert_alpha()
        self.storm_icon = pygame.image.load("Images/Icones_Meteo/weather-storm-2.png").convert_alpha()
        self.snow_icon = pygame.image.load("Images/Icones_Meteo/weather-snow-2.png").convert_alpha()


#Icones meteo des petites fenetres

        self.sunny_mini_icon = pygame.image.load("Images/Icones_Meteo/weather-clear-2-mini.png").convert_alpha()
        self.sunny_cloud_mini_icon = pygame.image.load("Images/Icones_Meteo/weather-few-clouds-2-mini.png").convert_alpha()
        self.cloud_mini_icon = pygame.image.load("Images/Icones_Meteo/weather-overcast-2-mini.png").convert_alpha()
        self.light_rain_mini_icon = pygame.image.load("Images/Icones_Meteo/weather-showers-scattered-2-mini.png").convert_alpha()
        self.heavy_rain_mini_icon = pygame.image.load("Images/Icones_Meteo/weather-showers-2-mini.png").convert_alpha()
        self.storm_mini_icon = pygame.image.load("Images/Icones_Meteo/weather-storm-2-mini.png").convert_alpha()
        self.snow_mini_icon = pygame.image.load("Images/Icones_Meteo/weather-snow-2-mini.png").convert_alpha()
       
#Icones des parametres du temps de la grande fenetre (vent, temperature...)

        self.thermometremax_icon = pygame.image.load("Images/Icones_Meteo/ThermometreMax.png").convert_alpha()
        self.thermometremin_icon = pygame.image.load("Images/Icones_Meteo/ThermometreMin.png").convert_alpha()
        self.humidite_icon = pygame.image.load("Images/Icones_Meteo/Goutte.png").convert_alpha()
        self.RainProb_icon = pygame.image.load("Images/Icones_Meteo/probapluie.png").convert_alpha()
        self.wind_icon = pygame.image.load("Images/Icones_Meteo/Vent.png").convert_alpha() 
        self.sunrise_icon = pygame.image.load("Images/Icones_Meteo/sunrise.png").convert_alpha() 
        self.sunset_icon = pygame.image.load("Images/Icones_Meteo/sunset.png").convert_alpha() 
        self.switch_icon = pygame.image.load("Images/Icones_Meteo/switch.png").convert_alpha()


#Fonds d'ecran en fonction du temps

        self.WallPaperSun = pygame.image.load("Images/Icones_Meteo/sun_sky.jpg").convert_alpha()
        self.WallPaperCloudandsun = pygame.image.load("Images/Icones_Meteo/cloudandsun_sky.jpg").convert_alpha()
        self.WallPaperCloud = pygame.image.load("Images/Icones_Meteo/cloud_sky.jpg").convert_alpha()
        self.WallPaperLightrain = pygame.image.load("Images/Icones_Meteo/lightrain_sky.jpg").convert_alpha()
        self.WallPaperHeavyrain = pygame.image.load("Images/Icones_Meteo/heavyrain_sky.jpg").convert_alpha()
        self.WallPaperStorm = pygame.image.load("Images/Icones_Meteo/storm_sky.jpg").convert_alpha()
        self.WallPaperSnow = pygame.image.load("Images/Icones_Meteo/snow_sky.jpg").convert_alpha()

#Styles d'ecriture

        self.FontDatum = pygame.font.Font("Fonts/HelveticaNeue-Light.ttf", 55)
        self.FontTemperatureMini = pygame.font.Font("Fonts/HelveticaNeue-UltraLight.ttf", 40)
        self.FontDate = pygame.font.Font("Fonts/HelveticaNeue-Light.ttf", 45)
        self.DayFont = pygame.font.Font("Fonts/HelveticaNeue-UltraLight.ttf",30)

#Barres transparentes

        self.barre_icon = pygame.Surface((113,100)).convert_alpha() 
        self.barre_icon.fill((255,255,255,150)) #Case des jours non choisis plus transparentes (150)
        self.barre2_icon = pygame.Surface((113,100)).convert_alpha() 
        self.barre2_icon.fill((255,255,255,225)) #Case du jour choisi qui est plus claire (225)
        self.barre_switch = pygame.Surface((59,37)).convert_alpha()
        self.barre_switch.fill((255,255,255,210))
        self.barre2_switch = pygame.Surface((59,37)).convert_alpha()
        self.barre2_switch.fill((255,255,255,150))

#!!!!!!VARIABLES!!!!!!:
            
#Variable qui correspond à l'ecran qui EST affiche / EST apparu

        self.currentday = 0

#Variable qui correspond à l'ecran que l'on VEUT faire apparaitre

        self.NewDay = 0

#Variables qui appellent des chronos

        self.chrono = AnimationManager() #Chrono de la majeur partie  des animations
        self.chrono2 = AnimationManager() #Chrono de l'icone meteo de l'ecran principal
        self.chrono1screen = AnimationManager() #Chrono du 1er ecran (quand on lance l'application)

#Variables qui donnent la transparence (Permet un ordre d'apparition)

        self.Transparence = 0  #Transparence de la date, de l'icone meteo et du fond d'ecran
        self.Transparence2 = 0 #Transparence de la temperature, de son icone associe et du bouton "switch"
        self.Transparence3 = 0 #Transparence du vent et de son icone associe
        self.Transparence4 = 0 #Transparence du la proba de pluie et de son icone associe
        self.Transparence5 = 0 #Transparence de l'humidite et de son icone associe
        self.Transparence6 = 0 #Transparence du lever de soleil et de son icone associe
        self.Transparence7 = 0 #Transparence du coucher de soleil et de son icone associe

#Variable qui donne la position Y (Utilisee dans des formules pour faire "planer" textes/images...)

        self.PosY_Icone = 100

#Variable qui sert a donner la temperature max ou min (Pair = Max / Impair = Min)

        self.tempswitch = 0
Exemplo n.º 14
0
class LockScreen():
    def __init__(self, windowres):
        self.WindowRes = windowres
        self.ScreenStatus = "OUT"
        self.chrono = AnimationManager()

        self.Locked = True
        self.InputCode = ""
        self.SecretCode = "1234"

        self.PannelsStatus = "SLEEP"  # SLEEP pour afficher l'ecran noir, LOCK pour le deverrouillage

        self.TitleFont = pygame.font.Font("Fonts/HelveticaNeue-UltraLight.ttf",
                                          88)
        self.TimeFont = pygame.font.Font("Fonts/HelveticaNeue-UltraLight.ttf",
                                         180)
        self.SecondsFont = pygame.font.Font(
            "Fonts/HelveticaNeue-UltraLight.ttf", 80)
        self.DateFont = pygame.font.Font("Fonts/HelveticaNeue-Light.ttf", 25)
        self.SwipeFont = pygame.font.Font("Fonts/HelveticaNeue-Light.ttf", 20)
        self.WarningFont = pygame.font.Font("Fonts/HelveticaNeue-Medium.ttf",
                                            12)

        self.bg = pygame.image.load("Images/lock_bg1.png")
        self.digitcounter_whiteimg = pygame.image.load(
            "Images/Numbers/round_square_white.png")
        self.digitcounter_darkimg = pygame.image.load(
            "Images/Numbers/round_square_dark.png")
        self.numbers_imgs = [
            pygame.image.load("Images/Numbers/zero.png"),
            pygame.image.load("Images/Numbers/one.png"),
            pygame.image.load("Images/Numbers/two.png"),
            pygame.image.load("Images/Numbers/three.png"),
            pygame.image.load("Images/Numbers/four.png"),
            pygame.image.load("Images/Numbers/five.png"),
            pygame.image.load("Images/Numbers/six.png"),
            pygame.image.load("Images/Numbers/seven.png"),
            pygame.image.load("Images/Numbers/eight.png"),
            pygame.image.load("Images/Numbers/nine.png"),
            pygame.image.load("Images/Numbers/back.png")
        ]

        self.chrono_warningbanner = AnimationManager()
        self.show_warningbanner = False

        self.general_transp = 0.0
        self.time_color = 0.0
        self.date_color = 0.0
        self.swipe_color = 0.0
        self.bg_transp = 0.0
        self.keypad_transp = 0.0
        self.warning_transp = 0.0

    def Update(self, InputEvents):
        print self.ScreenStatus + "   " + self.PannelsStatus
        for event in InputEvents:
            if "TOUCH" in event:
                mousepos = pygame.mouse.get_pos()
                if self.PannelsStatus is "SLEEP":
                    self.PannelsStatus = "SLEEPTOLOCK"
                    self.chrono.reset()
                if self.PannelsStatus is "LOCK" or self.PannelsStatus is "LOCK_FADING_IN":
                    '''
                    On regarde si on a clique sur une des touches. Si oui on verifie si le nouveau code est bon, etc.
                    '''
                    for line in range(3):
                        for column in range(3):
                            if Helpers.is_in_rect(mousepos, [
                                    self.WindowRes[0] / 2 - 200 / 2 +
                                    column * 80, self.WindowRes[1] / 2 -
                                    280 / 2 + line * 80 + 50, 40, 40
                            ]):  # touche 0
                                i = column + line * 3 + 1
                                print "TOUCHE : " + str(i)  # DEBUG

                                self.InputCode += str(i)
                                if self.InputCode == self.SecretCode:
                                    self.Locked = False
                                elif self.InputCode != self.SecretCode and len(
                                        self.InputCode) == 4:
                                    self.InputCode = ""
                                    self.show_warningbanner = True
                                    self.chrono_warningbanner.reset()
                    '''
                    Meme chose si on clique sur la touche 0
                    '''
                    if Helpers.is_in_rect(mousepos, [
                            self.WindowRes[0] / 2 - 200 / 2 + 1 * 80,
                            self.WindowRes[1] / 2 - 280 / 2 + 3 * 80 + 50, 40,
                            40
                    ]):  # touche 1
                        self.InputCode += '0'

                        if self.InputCode == self.SecretCode:
                            self.Locked = False
                        elif self.InputCode != self.SecretCode and len(
                                self.InputCode) == 4:
                            self.InputCode = ""
                            self.show_warningbanner = True
                            self.chrono_warningbanner.reset()
                    '''
                    Si on clique sur le bouton pour supprimer le dernier chiffre qu'on vient d'entrer,
                    on enleve le dernier chiffre du code qui est en train d'etre entre.
                    '''
                    if Helpers.is_in_rect(mousepos, [500, 73, 20, 20]):
                        try:
                            self.InputCode = self.InputCode[0:len(self.
                                                                  InputCode) -
                                                            1]
                        except:
                            self.InputCode = ""  # si l'utilisateur demande d'effacer alors que rien n'est entre encore, on gere l'erreur.

        if self.ScreenStatus == "RUNNING":
            self.swipe_color = 120 + 40 * math.sin(
                1 * self.chrono.elapsed_time())

        if self.ScreenStatus == "FADING_IN":
            if self.chrono.elapsed_time() > 0 and self.chrono.elapsed_time(
            ) < 2:
                self.general_transp = 255 / (
                    1 + math.exp(-(self.chrono.elapsed_time() - 1) / 0.2))
            if self.chrono.elapsed_time() > 2 and self.chrono.elapsed_time(
            ) < 10:
                self.time_color = 160 / (
                    1 + math.exp(-(self.chrono.elapsed_time() - 4.5) / 0.5))
                self.date_color = 160 / (
                    1 + math.exp(-(self.chrono.elapsed_time() - 7) / 0.3))
            if self.chrono.elapsed_time() > 6 and self.chrono.elapsed_time(
            ) < 10:
                self.swipe_color = 130 / (
                    1 + math.exp(-(self.chrono.elapsed_time() - 8) / 0.4))

            if self.chrono.elapsed_time() > 10:
                self.ScreenStatus = "RUNNING"
                self.chrono.reset()

        if self.ScreenStatus == "FADING_OUT":
            if self.chrono.elapsed_time() > 0:
                self.ScreenStatus = "OUT"
                self.date_color = 0
                self.swipe_color = 0
                self.time_color = 0

        if self.PannelsStatus == "SLEEPTOLOCK":
            self.time_color = 160 / (
                1 + math.exp(-(0.5 - self.chrono.elapsed_time()) / 0.1))
            self.date_color = 160 / (
                1 + math.exp(-(0.5 - self.chrono.elapsed_time()) / 0.1))
            self.swipe_color = 130 / (
                1 + math.exp(-(0.5 - self.chrono.elapsed_time()) / 0.1))
            self.bg_transp = 100 / (
                1 + math.exp(-(self.chrono.elapsed_time() - 1) / 0.2))

            if self.chrono.elapsed_time() > 1:
                self.PannelsStatus = "LOCK_FADING_IN"
                self.chrono.reset()

        if self.PannelsStatus == "LOCK_FADING_IN":
            self.keypad_transp = 255 / (
                1 + math.exp(-(self.chrono.elapsed_time() - 0.5) / 0.1))
            self.warning_transp = 255 / (
                1 + math.exp(-(self.chrono.elapsed_time() - 0.5) / 0.1))
            self.bg_transp = 100 / (
                1 + math.exp(-(self.chrono.elapsed_time()) / 0.2))

            if self.chrono.elapsed_time() > 1:
                self.PannelsStatus = "LOCK"
                self.chrono.reset()

        if self.PannelsStatus == "LOCK":
            if self.Locked == False:
                self.Deactivate()

    def Activate(self):
        self.chrono.reset()
        self.ScreenStatus = "FADING_IN"

    def Deactivate(self):
        self.chrono.reset()
        self.ScreenStatus = "RESET"
        self.PannelsStatus = "INACTIVE"

    def Reset(self):
        self.ScreenStatus = "OUT"
        self.PannelsStatus = "SLEEP"

    def Draw(self, gameDisplay):
        '''
        On cree une surface d'affichage temporaire.
        Ceci permet de mettre de l'opacite sur toute la surface, pour obscurcir tout l'ecran
        progressivement.
        '''
        black = pygame.Surface(self.WindowRes).convert_alpha()
        if self.PannelsStatus == "SLEEP":
            black.fill((0, 0, 0, self.general_transp))
            gameDisplay.blit(black, (0, 0))
        else:
            black.fill((0, 0, 0))
            gameDisplay.blit(black, (0, 0))
            Helpers.blit_alpha(gameDisplay, self.bg, (0, 0), self.bg_transp)
        '''
        --------------------------------------------------- PARTIE SLEEP -------------------------------------------------------
        '''
        if self.PannelsStatus == "SLEEP" or self.PannelsStatus == "SLEEPTOLOCK":
            '''
            Renders the Date and Time (date, Hours+Minutes, Seconds)
            '''
            timeSurface = self.TimeFont.render(strftime("%H:%M"), True,
                                               (255, 255, 255))
            secondsSurface = self.SecondsFont.render(strftime(":%S"), True,
                                                     (255, 255, 255))
            dateSurface = self.DateFont.render(
                "Today is " + strftime("%A %d, %B %Y"), True, (255, 255, 255))
            '''
            Rendu du texte qui demande de cliquer.
            '''
            swipeSurface = self.SwipeFont.render(u"Tapez pour déverrouiller",
                                                 True, (255, 255, 255))
            '''
            Calculs de positions pour simplifier les blit() en bas
            '''
            secondsWidth = self.SecondsFont.render(
                strftime(":00"), True, (255, 255, 255)).get_rect().width
            timePos = self.WindowRes[0] / 2 - (timeSurface.get_rect().width +
                                               secondsWidth) / 2
            '''
            On dessine tout, avec transparence
            '''
            # on dessine l'heure
            Helpers.blit_alpha(gameDisplay, timeSurface,
                               (timePos, self.WindowRes[1] / 2 -
                                timeSurface.get_rect().height / 2 - 60),
                               self.time_color)

            # on dessine les secondes
            Helpers.blit_alpha(gameDisplay, secondsSurface,
                               (timePos + timeSurface.get_rect().width,
                                timeSurface.get_rect().bottom -
                                timeSurface.get_rect().height * 1 / 5 + 5),
                               self.time_color)

            # on dessine la date situee sous l'heure
            Helpers.blit_alpha(
                gameDisplay, dateSurface,
                (self.WindowRes[0] / 2 - dateSurface.get_rect().width / 2,
                 self.WindowRes[1] / 2 - dateSurface.get_rect().height / 2 +
                 28), self.time_color)

            # on dessine la ligne qui demande de cliquer pour deverrouiller
            Helpers.blit_alpha(
                gameDisplay, swipeSurface,
                (self.WindowRes[0] / 2 - swipeSurface.get_rect().width / 2,
                 self.WindowRes[1] - 70), self.swipe_color)
        '''
        ---------------------------------------------------- PARTIE LOCK -------------------------------------------------------
        '''
        if self.PannelsStatus == "LOCK" or self.PannelsStatus == "LOCK_FADING_IN":
            s = pygame.Surface((40, 40))
            s.fill((255, 255, 255))

            count = 1
            for line in range(3):
                for column in range(3):
                    Helpers.blit_alpha(
                        gameDisplay, self.numbers_imgs[count],
                        (self.WindowRes[0] / 2 - 200 / 2 + column * 80,
                         self.WindowRes[1] / 2 - 280 / 2 + line * 80 + 50),
                        self.keypad_transp)

                    count += 1

            Helpers.blit_alpha(
                gameDisplay,
                self.numbers_imgs[0],
                (
                    self.WindowRes[0] / 2 - 200 / 2 + 1 * 80,  # touche 0
                    self.WindowRes[1] / 2 - 280 / 2 + 3 * 80 + 50),
                self.keypad_transp)
            Helpers.blit_alpha(
                gameDisplay,
                self.numbers_imgs[10],
                (
                    self.WindowRes[0] / 2 - 200 / 2 +
                    2 * 80,  # touche backspace
                    self.WindowRes[1] / 2 - 280 / 2 + 3 * 80 + 50),
                self.keypad_transp)

            s = pygame.Surface((15, 15))
            for i in range(4):
                if len(self.InputCode) > i:
                    Helpers.blit_alpha(
                        gameDisplay, self.digitcounter_whiteimg,
                        (self.WindowRes[0] / 2 - 15 / 2 - 68 + i * 45, 94),
                        self.keypad_transp)
                else:
                    Helpers.blit_alpha(
                        gameDisplay, self.digitcounter_darkimg,
                        (self.WindowRes[0] / 2 - 15 / 2 - 68 + i * 45, 94),
                        self.keypad_transp)

            self.WarningBanner_Update(gameDisplay)

    def WarningBanner_Update(self, gameDisplay):
        if self.show_warningbanner:
            text = self.WarningFont.render(u"Code erroné. Veuillez Réessayer.",
                                           True, (255, 0, 0))
            Helpers.blit_alpha(
                gameDisplay, text,
                (self.WindowRes[0] / 2 - text.get_rect().width / 2, 45),
                self.warning_transp)

            if self.chrono_warningbanner.elapsed_time() > 2.5:
                self.show_warningbanner = False
        else:
            text = self.WarningFont.render(
                u"Entrez votre code pour déverrouiller.", True,
                (255, 255, 255))
            Helpers.blit_alpha(
                gameDisplay, text,
                (self.WindowRes[0] / 2 - text.get_rect().width / 2, 45),
                self.warning_transp)

    def Quit(self):
        pass

    def __str__(self):
        return "LOCKSCREEN"
Exemplo n.º 15
0
class TestScreen():
    '''
    Ecran qui n'est jamais affiche, il a servi a tester des trucs au besoin.
    Pas de commentaires necessaires, ce n'est qu'une 'sandbox' qu'on utilisait au avant d'implementer
    notre test dans notre vraie application.
    '''
    def __init__(self, windowres):
        # Charger une image
        self.sunny_icon = pygame.image.load("Images/weather_sunny_transparent.png").convert_alpha()
        # position image (seulement pour animation)
        self.sunny_positionX = 80  # direction : 580
        self.sunny_positionY = 100  # direction : 200
        # texto
        self.ScreenStatus = "RUNNING"
        # police du texte( la rappeler qaund on ecrit le txt) -> temperature/humidite...
        self.TitleFont     = pygame.font.Font("Fonts/HelveticaNeue-Light.ttf", 55)
        self.TitleFont2    = pygame.font.Font("Fonts/HelveticaNeue-UltraLight.ttf", 100)
        self.WaitFont      = pygame.font.Font("Fonts/HelveticaNeue-UltraLight.ttf", 22)
        self.PostTitleFont = pygame.font.Font("Fonts/HelveticaNeue-Medium.ttf", 12, bold=False)

        self.Aujourdhui_color = 0

        self.TemperatureText = self.TitleFont2.render("15 C", True, (255, 255, 255))

        self.chrono = AnimationManager()

    def Update(self, InputEvents):
        '''
        Partie qui regarde si on a clique sur l'ecran :
        '''
        for event in InputEvents:
            if "TOUCH" in event:
                mousepos = Helpers.get_message_x_y(event) # recupere la position ou la personne a clique
                if Helpers.is_in_rect(mousepos, [50, 290, 25, 130]):
                    self.a
                    pass # fait ce que tu veux :)



        if self.chrono.elapsed_time() > 0 and self.chrono.elapsed_time() < 1:
           self.Aujourdhui_color=int(255 / (1 + math.exp(-(self.chrono.elapsed_time() - 0.5) / 0.1)))


        if self.chrono.elapsed_time() > 1 and self.chrono.elapsed_time() < 3:
           self.sunny_positionX=int(80 + 500 / (1 + math.exp(-(self.chrono.elapsed_time() - 2) / 0.2)))
        if self.chrono.elapsed_time() > 1 and self.chrono.elapsed_time() < 3:
           self.sunny_positionY=int(100 + 100 / (1 + math.exp(-(self.chrono.elapsed_time() - 2) / 0.2)))




    def Draw(self, gameDisplay):

# Afficher une image (ici soleil)

        gameDisplay.blit(self.sunny_icon, (self.sunny_positionX, self.sunny_positionY))
#1er self = "nom" du texte; 2e self = police;
        self.AujourdhuiText = self.TitleFont.render("Aujourd'hui", True, (255, 255, 255))
        gameDisplay.blit(self.AujourdhuiText, (55, 30))  # pos initiale : 55, 30

        gameDisplay.blit(self.TemperatureText, (550, 100))

        # MODE DEMPLOI POUR AFFICHER UN TEXTE
        # 1 - charger la police dans le init (ci-dessus)
        # 2 - self.NOMDELIMAGE = self.NOMDELAPOLICE.render(str(self.onfos.current), True, (255, 255, 255))
        # 3 - gameDisplay.blit(self.NOMDELIMAGE, (POSITIONX, POSITIONY))
        '''
        for i in range (0, 7):
            temps = WeatherManager.icone[i]
            if temps == "cloudy"
                 # afficher icone cloudy


            self.temperature = TitleFont.render(
                WeatherManager.temperatures[i], True, (255, 255, 255))

            gameDisplay.blit(self.temperature, (ancrageX + 800 * i, 0))
        '''



    def Quit(self):
        pass

    def __str__(self):
        return "TESTSCREEN"
Exemplo n.º 16
0
    def __init__(self, WindowRes):
        self.WindowRes = WindowRes
        self.chrono = AnimationManager()
        self.lock_screen = LockScreen(WindowRes)

        self.lockscreen_activated = False
Exemplo n.º 17
0
class StartScreen():
    '''
    Ecran de demarrage, qui dit bonjour.
    Il n'est la que pour faire joli, mais c'est le tout premier ecran developpe dans l'histoire
    de notre systeme !
    '''
    def __init__(self, windowres, fade_direction=""):
        '''
        Demarrage de l'ecran : chargement des images, polices d'ecriture, et variables globales (animations,
        etat et communication avec MainSC).
        '''
        self.bg_img = pygame.image.load("Images/landscape1.png")

        self.TitleFont = pygame.font.Font("Fonts/HelveticaNeue-UltraLight.ttf",
                                          180)
        self.SwipeFont = pygame.font.Font("Fonts/HelveticaNeue-Light.ttf", 25)
        self.TimeFont = pygame.font.Font("Fonts/HelveticaNeue-UltraLight.ttf",
                                         60)

        self.WindowRes = windowres
        self.ScreenStatus = "FADING_IN"
        self.fade_direction = fade_direction
        '''
        Create the animation structure
        '''
        self.animation = AnimationManager()
        self.bonjour_offset = 0.0
        self.bonjour_color = 0

        self.swipe_color = 0
        self.swipe_offset = 0.0

        self.time_color = 0
        self.time_offset = 0.0
        self.goto_sent = False

    def Update(self, InputEvents):
        if self.ScreenStatus is not "FADING_OUT" and self.ScreenStatus is not "DEAD":
            '''
            Handle Gestures in order to go to the next screen
            '''
            if "UP" in InputEvents:
                self.ScreenStatus = "FADING_OUT"
                self.animation.reset()

        if self.ScreenStatus is "FADING_IN":
            self.fade_in()
        if self.ScreenStatus is "FADING_OUT":
            self.fade_out()
        '''
        LOGISTIC FUNCTION USER GUIDE :

        if animTime > BEGIN_TIME and animTime < END_TIME:
            self.swipe_color = AMPLITUDE / (1 + math.exp(-(INVERT animTime - MOY_TIMES) / DURATION))

            - BEGIN_TIME : when the animation begins after the AnimationMaganer has started.
            - END_TIME : when the animation ends.
            - AMPLITUDE : the movement will go from 0 to the number specified. You can put a minus sign here to go to negatives.
            - MOY_TIMES : it is equal to (BEGIN_TIME + END_TIME) / 2.
            - IVNERT : put the MOY_TIMES here instead if you want the curve to go from AMPLITUDE to 0 (the curve is upside-down).
            - DURATION : you have to adapt this number to the duration of the animation.
                - 0.1 : the animation lasts 1sec
                - 0.2 : the animation lasts 2sec
        '''

    def Draw(self, gameDisplay):
        '''
        On dessine le fond d'ecran
        '''
        Helpers.blit_alpha(gameDisplay, self.bg_img, (0, 0), 180)
        '''
        On cree les textes
        '''
        titleSurface = self.TitleFont.render("Bonjour !", True,
                                             (255, 255, 255))
        swipeSurface = self.SwipeFont.render(
            "Balayez vers le haut pour continuer", True, (255, 255, 255))
        timeSurface = self.TimeFont.render(strftime("%H:%M:%S"), True,
                                           (255, 255, 255))
        '''
        Calculs de positions pour simplifier les blit() en bas
        '''
        secondsWidth = self.TimeFont.render(strftime("00:00:00"), True,
                                            (250, 250, 250)).get_rect().width
        '''
        On dessine tout, avec transparence pour les animations
        '''
        # on dessine l'heure situee en bas
        Helpers.blit_alpha(
            gameDisplay, timeSurface,
            (self.WindowRes[0] / 2 - secondsWidth / 2,
             self.WindowRes[1] * 6.4 / 8 - timeSurface.get_rect().height / 2 +
             self.time_offset), self.time_color)

        # on dessine la ligne qui demande de glisser vers le haut
        Helpers.blit_alpha(
            gameDisplay, swipeSurface,
            (self.WindowRes[0] / 2 - swipeSurface.get_rect().width / 2,
             self.WindowRes[1] / 2 - swipeSurface.get_rect().height / 2 + 50 +
             self.swipe_offset), self.swipe_color)

        # on dessine le Bonjour au centre
        Helpers.blit_alpha(
            gameDisplay, titleSurface,
            (self.WindowRes[0] / 2 - titleSurface.get_rect().width / 2,
             self.WindowRes[1] / 2 - titleSurface.get_rect().height / 2 - 25 +
             self.bonjour_offset), self.bonjour_color)

    def fade_in(self):
        animTime = self.animation.elapsed_time()
        '''
        Bonjour Text animations
        '''
        if animTime > 0.5 and animTime < 1.5:
            self.bonjour_color = 255 / (1 + math.exp(-(animTime - 1) / 0.1))

        if animTime > 2 and animTime < 4:
            self.bonjour_offset = -70 / (1 + math.exp(-(animTime - 3) / 0.2))
        '''
        Swipe Text animations
        '''
        if animTime > 3 and animTime < 4:
            self.swipe_color = 255 / (1 + math.exp(-(animTime - 3.5) / 0.1))
        '''
        Time Text animations
        '''
        if animTime > 4.5 and animTime < 5.5:
            self.time_color = 255 / (1 + math.exp(-(animTime - 5) / 0.1))

        if animTime >= 5.5: self.ScreenStatus = "RUNNING"

    def fade_out(self):
        animTime = self.animation.elapsed_time()
        #self.ScreenStatus = "FADING_OUT_TRANSP " + str(int(255 * animTime))

        if animTime > 0.0 and animTime < 0.5:
            self.bonjour_color = 255 / (1 +
                                        math.exp(-(0.25 - animTime) / 0.05))
            self.bonjour_offset = -70 / (1 + math.exp(
                -(4 - 3) / 0.2)) + -50 / (1 +
                                          math.exp(-(animTime - 0.25) / 0.05))

        if animTime > 0.25 and animTime < 0.75:
            self.swipe_color = 255 / (1 + math.exp(-(0.5 - animTime) / 0.05))
            self.swipe_offset = -30 / (1 + math.exp(-(animTime - 0.5) / 0.05))

        if animTime > 0.5 and animTime < 1:
            self.time_color = 255 / (1 + math.exp(-(0.75 - animTime) / 0.05))
            self.time_offset = -30 / (1 + math.exp(-(animTime - 0.75) / 0.05))

        if animTime > 0.9 and self.goto_sent == False:  # when the animation of the next screen starts
            self.ScreenStatus = "GOTO_" + ScreenRedirector().next_screen(
                "STARTSCREEN", "DOWN") + "_AND_DEAD"
            self.goto_sent = True
        '''if animTime > 1.5: # when the animation is finished, the screen can be killed.
            self.ScreenStatus = "DEAD"'''

    def Reset(self):
        pass

    def Quit(self):
        pass

    def __str__(self):
        return "STARTSCREEN"
Exemplo n.º 18
0
class WeatherScreen():
    def __init__(self, WindowRes):
        self.windowres = WindowRes
        self.infos_meteo = WeatherCollector()

        self.ScreenStatus = "RUNNING"

#Icones meteo de la grande fenetre

        self.sunny_icon = pygame.image.load("Images/Icones_Meteo/weather-clear-2.png").convert_alpha()
        self.sunny_cloud_icon = pygame.image.load("Images/Icones_Meteo/weather-few-clouds-2.png").convert_alpha()
        self.cloud_icon = pygame.image.load("Images/Icones_Meteo/weather-overcast-2.png").convert_alpha()
        self.light_rain_icon = pygame.image.load("Images/Icones_Meteo/weather-showers-scattered-2.png").convert_alpha()
        self.heavy_rain_icon = pygame.image.load("Images/Icones_Meteo/weather-showers-2.png").convert_alpha()
        self.storm_icon = pygame.image.load("Images/Icones_Meteo/weather-storm-2.png").convert_alpha()
        self.snow_icon = pygame.image.load("Images/Icones_Meteo/weather-snow-2.png").convert_alpha()


#Icones meteo des petites fenetres

        self.sunny_mini_icon = pygame.image.load("Images/Icones_Meteo/weather-clear-2-mini.png").convert_alpha()
        self.sunny_cloud_mini_icon = pygame.image.load("Images/Icones_Meteo/weather-few-clouds-2-mini.png").convert_alpha()
        self.cloud_mini_icon = pygame.image.load("Images/Icones_Meteo/weather-overcast-2-mini.png").convert_alpha()
        self.light_rain_mini_icon = pygame.image.load("Images/Icones_Meteo/weather-showers-scattered-2-mini.png").convert_alpha()
        self.heavy_rain_mini_icon = pygame.image.load("Images/Icones_Meteo/weather-showers-2-mini.png").convert_alpha()
        self.storm_mini_icon = pygame.image.load("Images/Icones_Meteo/weather-storm-2-mini.png").convert_alpha()
        self.snow_mini_icon = pygame.image.load("Images/Icones_Meteo/weather-snow-2-mini.png").convert_alpha()
       
#Icones des parametres du temps de la grande fenetre (vent, temperature...)

        self.thermometremax_icon = pygame.image.load("Images/Icones_Meteo/ThermometreMax.png").convert_alpha()
        self.thermometremin_icon = pygame.image.load("Images/Icones_Meteo/ThermometreMin.png").convert_alpha()
        self.humidite_icon = pygame.image.load("Images/Icones_Meteo/Goutte.png").convert_alpha()
        self.RainProb_icon = pygame.image.load("Images/Icones_Meteo/probapluie.png").convert_alpha()
        self.wind_icon = pygame.image.load("Images/Icones_Meteo/Vent.png").convert_alpha() 
        self.sunrise_icon = pygame.image.load("Images/Icones_Meteo/sunrise.png").convert_alpha() 
        self.sunset_icon = pygame.image.load("Images/Icones_Meteo/sunset.png").convert_alpha() 
        self.switch_icon = pygame.image.load("Images/Icones_Meteo/switch.png").convert_alpha()


#Fonds d'ecran en fonction du temps

        self.WallPaperSun = pygame.image.load("Images/Icones_Meteo/sun_sky.jpg").convert_alpha()
        self.WallPaperCloudandsun = pygame.image.load("Images/Icones_Meteo/cloudandsun_sky.jpg").convert_alpha()
        self.WallPaperCloud = pygame.image.load("Images/Icones_Meteo/cloud_sky.jpg").convert_alpha()
        self.WallPaperLightrain = pygame.image.load("Images/Icones_Meteo/lightrain_sky.jpg").convert_alpha()
        self.WallPaperHeavyrain = pygame.image.load("Images/Icones_Meteo/heavyrain_sky.jpg").convert_alpha()
        self.WallPaperStorm = pygame.image.load("Images/Icones_Meteo/storm_sky.jpg").convert_alpha()
        self.WallPaperSnow = pygame.image.load("Images/Icones_Meteo/snow_sky.jpg").convert_alpha()

#Styles d'ecriture

        self.FontDatum = pygame.font.Font("Fonts/HelveticaNeue-Light.ttf", 55)
        self.FontTemperatureMini = pygame.font.Font("Fonts/HelveticaNeue-UltraLight.ttf", 40)
        self.FontDate = pygame.font.Font("Fonts/HelveticaNeue-Light.ttf", 45)
        self.DayFont = pygame.font.Font("Fonts/HelveticaNeue-UltraLight.ttf",30)

#Barres transparentes

        self.barre_icon = pygame.Surface((113,100)).convert_alpha() 
        self.barre_icon.fill((255,255,255,150)) #Case des jours non choisis plus transparentes (150)
        self.barre2_icon = pygame.Surface((113,100)).convert_alpha() 
        self.barre2_icon.fill((255,255,255,225)) #Case du jour choisi qui est plus claire (225)
        self.barre_switch = pygame.Surface((59,37)).convert_alpha()
        self.barre_switch.fill((255,255,255,210))
        self.barre2_switch = pygame.Surface((59,37)).convert_alpha()
        self.barre2_switch.fill((255,255,255,150))

#!!!!!!VARIABLES!!!!!!:
            
#Variable qui correspond à l'ecran qui EST affiche / EST apparu

        self.currentday = 0

#Variable qui correspond à l'ecran que l'on VEUT faire apparaitre

        self.NewDay = 0

#Variables qui appellent des chronos

        self.chrono = AnimationManager() #Chrono de la majeur partie  des animations
        self.chrono2 = AnimationManager() #Chrono de l'icone meteo de l'ecran principal
        self.chrono1screen = AnimationManager() #Chrono du 1er ecran (quand on lance l'application)

#Variables qui donnent la transparence (Permet un ordre d'apparition)

        self.Transparence = 0  #Transparence de la date, de l'icone meteo et du fond d'ecran
        self.Transparence2 = 0 #Transparence de la temperature, de son icone associe et du bouton "switch"
        self.Transparence3 = 0 #Transparence du vent et de son icone associe
        self.Transparence4 = 0 #Transparence du la proba de pluie et de son icone associe
        self.Transparence5 = 0 #Transparence de l'humidite et de son icone associe
        self.Transparence6 = 0 #Transparence du lever de soleil et de son icone associe
        self.Transparence7 = 0 #Transparence du coucher de soleil et de son icone associe

#Variable qui donne la position Y (Utilisee dans des formules pour faire "planer" textes/images...)

        self.PosY_Icone = 100

#Variable qui sert a donner la temperature max ou min (Pair = Max / Impair = Min)

        self.tempswitch = 0

    def Update(self, InputEvents):

#Ci-dessous: Si le clic est dans le carre delimite par les valeurs alors affiche l'ecran lie a la variable NewDay (La valeur du NewDay prendra ensuite la forme de currentday, cad )

        for event in InputEvents:
            if "TOUCH" in event:
                    mousepos = Helpers.get_message_x_y(event)
                    
                    if Helpers.is_in_rect(mousepos, [1.5, 380, 797, 100]):
                                            
                        if Helpers.is_in_rect(mousepos, [1.5, 380, 113, 100]): #x, y, longueur cote x, longueur cote y
                            self.chrono.reset()                            
                            self.NewDay = 0
                            
                        if Helpers.is_in_rect(mousepos, [115.5, 380, 113, 100]): 
                            self.chrono.reset()
                            self.NewDay = 1
                                              
                        if Helpers.is_in_rect(mousepos, [229.5, 380, 113, 100]):
                            self.chrono.reset()
                            self.NewDay = 2
                            
                        if Helpers.is_in_rect(mousepos, [343.5, 380, 113, 100]): 
                            self.NewDay = 3
                            self.chrono.reset()
                           
                        if Helpers.is_in_rect(mousepos, [457.5, 380, 113, 100]): 
                            self.NewDay = 4
                            self.chrono.reset()
                           
                        if Helpers.is_in_rect(mousepos, [571.5, 380, 113, 100]): 
                            self.NewDay = 5
                            self.chrono.reset()
                            
                        if Helpers.is_in_rect(mousepos, [685.5, 380, 113, 100]): 
                            self.NewDay = 6
                            self.chrono.reset()

#Permet de passer de la temperature max a min et inversement quand on clique sur le bouton "switch"

                    if Helpers.is_in_rect(mousepos, [205, 75, 65, 65]):
                        self.tempswitch = self.tempswitch + 1


#Aniamation -> Fondu "apparaissant" du 1er écran (currentscreen0) quand on lance l'application 
#L'ecran apparait des que l'application est lancee

        if self.chrono1screen.elapsed_time() > 0 and self.chrono1screen < 1:
            self.Transparence=int(255 / (1 + math.exp(-(self.chrono1screen.elapsed_time() - 2.5/2 ) / 0.05)))
                            
#Animation -> Fondu "apparaissant" des ecrans (Apres le 1er). La condition avec le chrono1screen est necessaire pour ne pas engendrer un conflit entre les animations 
#L'ecran apparait 1sec apres qu'on ait decide de changer d'ecran (il faut 1sec a l'ecran d'avant pour disparaitre)

        if self.chrono1screen.elapsed_time() > 1:
            if self.chrono.elapsed_time() > 1 and self.chrono.elapsed_time() < 3  :
                self.currentday = self.NewDay #Le jour que l'on a selectionne va apparaitre
                self.Transparence=int(255 / (1 + math.exp(-(self.chrono.elapsed_time() - 2 ) / 0.1)))

#Animation -> Fondu "disparaissant" des ecrans. La condition avec le chrono1screen est necessaire pour ne pas engendrer un conflit entre les animations 

            if self.chrono.elapsed_time() > 0 and self.chrono.elapsed_time() < 1 : 
                self.Transparence=int(255 / (1 + math.exp(-(0.5 - self.chrono.elapsed_time()) / 0.1)))

#Animation -> Fondu "apparaissant" des Icones et de leur valeur associee
#Voir a quel element les transparences correspondent dans le init

            if self.chrono.elapsed_time() > 3 and  self.chrono.elapsed_time() < 4 :
                self.Transparence2=int(255 / (1 + math.exp(-(self.chrono.elapsed_time() - 6.5/2) / 0.05)))

            if self.chrono.elapsed_time() > 4 and  self.chrono.elapsed_time() < 5:
                self.Transparence3=int(255 / (1 + math.exp(-(self.chrono.elapsed_time() - 8.5/2) / 0.05)))

            if self.chrono.elapsed_time() > 5 and  self.chrono.elapsed_time() < 6:
                self.Transparence4=int(255 / (1 + math.exp(-(self.chrono.elapsed_time() - 10.5/2) / 0.05)))

            if self.chrono.elapsed_time() > 6 and  self.chrono.elapsed_time() < 7:
                self.Transparence5=int(255 / (1 + math.exp(-(self.chrono.elapsed_time() - 12.5/2) / 0.05)))

            if self.chrono.elapsed_time() > 7 and  self.chrono.elapsed_time() < 8:
                self.Transparence6=int(255 / (1 + math.exp(-(self.chrono.elapsed_time() - 14.5/2) / 0.05)))

            if self.chrono.elapsed_time() > 8 and  self.chrono.elapsed_time() < 9:
                self.Transparence7=int(255 / (1 + math.exp(-(self.chrono.elapsed_time() - 16.5/2) / 0.05)))

#Animation -> Fondu "disparraissant"  des Icones et de leur valeur associee

            if self.chrono.elapsed_time() > 0 and self.chrono.elapsed_time() < 1: 
                self.Transparence2=int(255 / (1 + math.exp(-(0.5 - self.chrono.elapsed_time()) / 0.1)))

            if self.chrono.elapsed_time() > 0 and self.chrono.elapsed_time() < 1 : 
                self.Transparence3=int(255 / (1 + math.exp(-(0.5 - self.chrono.elapsed_time()) / 0.1)))

            if self.chrono.elapsed_time() > 0 and self.chrono.elapsed_time() < 1 : 
                self.Transparence4=int(255 / (1 + math.exp(-(0.5 - self.chrono.elapsed_time()) / 0.1)))

            if self.chrono.elapsed_time() > 0 and self.chrono.elapsed_time() < 1 : 
                self.Transparence5=int(255 / (1 + math.exp(-(0.5 - self.chrono.elapsed_time()) / 0.1)))

            if self.chrono.elapsed_time() > 0 and self.chrono.elapsed_time() < 1 : 
                self.Transparence6=int(255 / (1 + math.exp(-(0.5 - self.chrono.elapsed_time()) / 0.1)))

            if self.chrono.elapsed_time() > 0 and self.chrono.elapsed_time() < 1 : 
                self.Transparence7=int(255 / (1 + math.exp(-(0.5 - self.chrono.elapsed_time()) / 0.1)))


#Varaible PosY_Icone est placee dans fonction sinusoidale pour faire "planer" textes/images
#fct sinus: Amplitude*math.sin(2*math.pi/Periode*t)
      
        if self.chrono2.elapsed_time() > 0:
            self.PosY_Icone = 100 + 5*math.sin(2*math.pi/3*self.chrono2.elapsed_time())
            

    def Draw(self, gameDisplay):

#Afficher le fond d'ecran et l'icone correspondant a la case selectionnne et en lien avec les infos du WeatherCollector ("01d"... sont les informations recuperees du site internet)
#Permet aussi de gerer la transparence et la position des elements a afficher

        if str(self.infos_meteo.DailyWeather.Icons[self.currentday]) == "01d" : 
            Helpers.blit_alpha(gameDisplay, self.WallPaperSun,(0,0), self.Transparence)
            Helpers.blit_alpha(gameDisplay, self.sunny_icon, (20, self.PosY_Icone), self.Transparence)

        if str(self.infos_meteo.DailyWeather.Icons[self.currentday]) == "02d" : 
            Helpers.blit_alpha(gameDisplay, self.WallPaperCloudandsun,(0,0), self.Transparence)
            Helpers.blit_alpha(gameDisplay, self.sunny_cloud_icon, (20, self.PosY_Icone), self.Transparence)

        if str(self.infos_meteo.DailyWeather.Icons[self.currentday]) == "03d" : 
            Helpers.blit_alpha(gameDisplay, self.WallPaperCloud,(0,0), self.Transparence)
            Helpers.blit_alpha(gameDisplay, self.cloud_icon, (20, self.PosY_Icone), self.Transparence)

        if str(self.infos_meteo.DailyWeather.Icons[self.currentday]) == "04d" : 
            Helpers.blit_alpha(gameDisplay, self.WallPaperCloud,(0,0), self.Transparence)
            Helpers.blit_alpha(gameDisplay, self.cloud_icon, (20, self.PosY_Icone), self.Transparence)

        if str(self.infos_meteo.DailyWeather.Icons[self.currentday]) == "10d" : 
            Helpers.blit_alpha(gameDisplay, self.WallPaperLightrain,(0,0), self.Transparence)
            Helpers.blit_alpha(gameDisplay, self.light_rain_icon, (20, self.PosY_Icone), self.Transparence)

        if str(self.infos_meteo.DailyWeather.Icons[self.currentday]) == "09d" :
            Helpers.blit_alpha(gameDisplay, self.WallPaperHeavyrain,(0,0), self.Transparence)
            Helpers.blit_alpha(gameDisplay, self.heavy_rain_icon, (20, self.PosY_Icone), self.Transparence)

        if str(self.infos_meteo.DailyWeather.Icons[self.currentday]) == "11d" :
            Helpers.blit_alpha(gameDisplay, self.WallPaperStorm,(0,0), self.Transparence)
            Helpers.blit_alpha(gameDisplay, self.storm_icon, (20, self.PosY_Icone), self.Transparence)

        if str(self.infos_meteo.DailyWeather.Icons[self.currentday]) == "13d": 
            Helpers.blit_alpha(gameDisplay, self.WallPaperSnow,(0,0), self.Transparence)
            Helpers.blit_alpha(gameDisplay, self.snow_icon, (20, self.PosY_Icone), self.Transparence)

#Affiche les icones lies aux caracteristiques du temps

        Helpers.blit_alpha(gameDisplay, self.RainProb_icon, (250, 175), self.Transparence4)
        Helpers.blit_alpha(gameDisplay, self.humidite_icon, (510, 175), self.Transparence5)
        Helpers.blit_alpha(gameDisplay, self.wind_icon, (515, 70), self.Transparence3)
        Helpers.blit_alpha(gameDisplay, self.sunrise_icon, (250, 280), self.Transparence6)
        Helpers.blit_alpha(gameDisplay, self.sunset_icon, (510, 280), self.Transparence7)

#Affiche les donnees liees a la temperature/humidite/pluie
#Exception pour la temperature -> Affiche aussi LES icones de la temperature (Temp Max et Min)

        if self.tempswitch % 2 == 0:
                self.Temperature = self.FontDatum.render(str(self.infos_meteo.DailyWeather.TemperaturesMax[self.currentday])+chr(176)+"C", True, (0,0,0,100))
                Helpers.blit_alpha(gameDisplay, self.Temperature, (341, 71), self.Transparence2)
                self.Temperature = self.FontDatum.render(str(self.infos_meteo.DailyWeather.TemperaturesMax[self.currentday])+chr(176)+"C", True, (255,255,255))
                Helpers.blit_alpha(gameDisplay, self.Temperature, (340, 70), self.Transparence2)
                Helpers.blit_alpha(gameDisplay, self.thermometremax_icon, (250, 70), self.Transparence2)

        else:
                self.Temperature = self.FontDatum.render(str(self.infos_meteo.DailyWeather.TemperaturesMin[self.currentday])+chr(176)+"C", True, (0,0,0,100))
                Helpers.blit_alpha(gameDisplay, self.Temperature, (341, 71), self.Transparence2)
                self.Temperature = self.FontDatum.render(str(self.infos_meteo.DailyWeather.TemperaturesMin[self.currentday])+chr(176)+"C", True, (255,255,255))
                Helpers.blit_alpha(gameDisplay, self.Temperature, (340, 70), self.Transparence2)
                Helpers.blit_alpha(gameDisplay, self.thermometremin_icon, (250, 70), self.Transparence2)

        
        self.WindStrength = self.FontDatum.render(str(self.infos_meteo.DailyWeather.WindStrength[self.currentday])+"km/h", True, (0,0,0,100))
        Helpers.blit_alpha(gameDisplay, self.WindStrength, (601, 71), self.Transparence3)
        self.WindStrength = self.FontDatum.render(str(self.infos_meteo.DailyWeather.WindStrength[self.currentday])+"km/h", True, (255,255,255))
        Helpers.blit_alpha(gameDisplay, self.WindStrength, (600, 70), self.Transparence3)

        self.Sunset = self.FontDatum.render(str(self.infos_meteo.DailyWeather.Sunset[self.currentday]), True, (0,0,0,100))
        Helpers.blit_alpha(gameDisplay, self.Sunset, (601, 281), self.Transparence7)
        self.Sunset = self.FontDatum.render(str(self.infos_meteo.DailyWeather.Sunset[self.currentday]), True, (255,255,255))
        Helpers.blit_alpha(gameDisplay, self.Sunset, (600, 280), self.Transparence7)

        self.Sunrise = self.FontDatum.render(str(self.infos_meteo.DailyWeather.Sunrise[self.currentday]), True, (0,0,0,100))
        Helpers.blit_alpha(gameDisplay, self.Sunrise, (341, 281), self.Transparence6)
        self.Sunrise = self.FontDatum.render(str(self.infos_meteo.DailyWeather.Sunrise[self.currentday]), True, (255,255,255))
        Helpers.blit_alpha(gameDisplay, self.Sunrise, (340, 280), self.Transparence6)

#Le site duquel on recupere les infos meteo ne donne plus d'info concernant la proba de l'humidite a partir du 6e jour, d'ou ce "if", pour ne pas faire apparaitre "0%" pour le 5e et 6e jour

        if self.currentday == 5 or self.currentday == 6 : 
            self.Humidite = self.FontDatum.render("N/A %", True, (0,0,0,100))
            Helpers.blit_alpha(gameDisplay, self.Humidite, (601, 176), self.Transparence5)
            self.Humidite = self.FontDatum.render("N/A %", True, (255,255,255))
            Helpers.blit_alpha(gameDisplay, self.Humidite, (600, 175), self.Transparence5)

            self.RainProb = self.FontDatum.render(str(self.infos_meteo.DailyWeather.RainProbs[self.currentday])+"%", True, (0,0,0,100))
            Helpers.blit_alpha(gameDisplay, self.RainProb, (341, 176), self.Transparence4)
            self.RainProb = self.FontDatum.render(str(self.infos_meteo.DailyWeather.RainProbs[self.currentday])+"%", True, (255,255,255))
            Helpers.blit_alpha(gameDisplay, self.RainProb, (340, 175), self.Transparence4)

          
        else:
            self.Humidite = self.FontDatum.render(str(self.infos_meteo.DailyWeather.Humidities[self.currentday])+"%", True, (0,0,0,100))
            Helpers.blit_alpha(gameDisplay, self.Humidite, (601, 176), self.Transparence5)
            self.Humidite = self.FontDatum.render(str(self.infos_meteo.DailyWeather.Humidities[self.currentday])+"%", True, (255,255,255))
            Helpers.blit_alpha(gameDisplay, self.Humidite, (600, 175), self.Transparence5)

            self.RainProb = self.FontDatum.render(str(self.infos_meteo.DailyWeather.RainProbs[self.currentday])+"%", True, (0,0,0,100))
            Helpers.blit_alpha(gameDisplay, self.RainProb, (341, 176), self.Transparence4)
            self.RainProb = self.FontDatum.render(str(self.infos_meteo.DailyWeather.RainProbs[self.currentday])+"%", True, (255,255,255))
            Helpers.blit_alpha(gameDisplay, self.RainProb, (340, 175), self.Transparence4)

#Definie les cases de la barre du bas
#La case selectionnee est plus claire 

        for i in range (0,7):
            if self.NewDay == i:
                gameDisplay.blit(self.barre2_icon, (115.5+(i-1)*114,380))
            if self.NewDay != i:
                gameDisplay.blit(self.barre_icon, (115.5+(i-1)*114,380))

#Affiche le texte dans les cases de la barre du bas
        
            self.DayText = self.DayFont.render(str(self.infos_meteo.DailyWeather.Week[i]), True, (0,0,0))
            gameDisplay.blit(self.DayText, (115.5+(i-1)*114+20,380+60))
       
#Boucle (voir au-dessus) qui identifie quel icone de temps a afficher suivant le jour selectionne et les informations qui l'accompagnent

            if self.infos_meteo.DailyWeather.Icons[i] == "01d":
                gameDisplay.blit(self.sunny_mini_icon,(115.5+(i-1)*114,380))           
            if self.infos_meteo.DailyWeather.Icons[i] == "02d":
                gameDisplay.blit(self.sunny_cloud_mini_icon,(115.5+(i-1)*114,380))                    
            if self.infos_meteo.DailyWeather.Icons[i] == "03d":
                gameDisplay.blit(self.cloud_mini_icon,(115.5+(i-1)*114,380))              
            if self.infos_meteo.DailyWeather.Icons[i] == "04d":               
                gameDisplay.blit(self.cloud_mini_icon,(115.5+(i-1)*114,380))                   
            if self.infos_meteo.DailyWeather.Icons[i] == "10d":   
                gameDisplay.blit(self.light_rain_mini_icon,(115.5+(i-1)*114,380))                     
            if self.infos_meteo.DailyWeather.Icons[i] == "09d":
                gameDisplay.blit(self.heavy_rain_mini_icon,(115.5+(i-1)*114,380))                    
            if self.infos_meteo.DailyWeather.Icons[i] == "11d":
                gameDisplay.blit(self.storm_mini_icon,(115.5+(i-1)*114,380))                     
            if self.infos_meteo.DailyWeather.Icons[i] == "13d":
                gameDisplay.blit(self.snow_mini_icon,(115.5+(i-1)*114,380))
                         
#Affiche la temperature dans les cases du bas
#La position de la temperature n'est pas la meme suivant si elle est a 1 ou 2 chiffres

            if len(str(self.infos_meteo.DailyWeather.TemperaturesBas[i])) == 1:
                self.TemperatureMini = self.FontTemperatureMini.render(str(self.infos_meteo.DailyWeather.TemperaturesBas[i])+chr(176), True, (0,0,0))
                gameDisplay.blit(self.TemperatureMini, (178+(i-1)*114, 380))
            if len(str(self.infos_meteo.DailyWeather.TemperaturesBas[i])) > 1:
                self.TemperatureMini = self.FontTemperatureMini.render(str(self.infos_meteo.DailyWeather.TemperaturesBas[i])+chr(176), True, (0,0,0))
                gameDisplay.blit(self.TemperatureMini, (169+(i-1)*114, 380))
           
#Affiche date en haut de l'écran
  
        self.Date = self.FontDate.render(self.infos_meteo.DailyWeather.Time[self.currentday], True, (0,0,0,100))
        Helpers.blit_alpha(gameDisplay, self.Date, (41, 21), self.Transparence)
        self.Date = self.FontDate.render(self.infos_meteo.DailyWeather.Time[self.currentday], True, (255,255,255))
        Helpers.blit_alpha(gameDisplay, self.Date, (40, 20), self.Transparence)      

#Fond du bouton switch

        if self.tempswitch % 2 == 0:
           Helpers.blit_alpha(gameDisplay, self.barre2_switch, (213, 95), self.Transparence2)
        if self.tempswitch % 2 == 1:
           Helpers.blit_alpha(gameDisplay, self.barre_switch, (213, 95), self.Transparence2)    

#Bouton switch

        Helpers.blit_alpha(gameDisplay, self.switch_icon, (205, 75), self.Transparence2)

   
                   
    def Quit(self):
        pass
    def __str__(self):
        return "WEATHERSCREEN"