Source

Fat x Fast / FatxFast / gui / hud / attributesframe.py

# This file is part of FatxFast.                                                
#                                                                               
#    FatxFast is free software: you can redistribute it and/or modify           
#    it under the terms of the GNU General Public License as published by       
#    the Free Software Foundation, either version 3 of the License, or          
#    (at your option) any later version.                                        
#                                                                               
#    FatxFast is distributed in the hope that it will be useful,                
#    but WITHOUT ANY WARRANTY; without even the implied warranty of             
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              
#    GNU General Public License for more details.                               
#                                                                               
#    You should have received a copy of the GNU General Public License          
#    along with FatxFast.  If not, see <http://www.gnu.org/licenses/>.          
                                                                                
# Versioning based on:                                                          
# http://en.wikipedia.org/wiki/Versioning#Designating_development_stage         
__author__ = "dryatu (c) 2013"                                                  
__version__ = "1.2.5" 

from FatxFast.gui.hud.frame import Frame
import time

class AttributesFrame(Frame):
    # Part of GameFrame
    def __init__(self, game, player, **kwargs):
        super(AttributesFrame, self).__init__(game, **kwargs)  
        self._player = player
        self._cache_points = self._player.points
#        self._cache_maps = self._player.maps_left
        self.create_text(
            {"name": "points-icon",
                "x": 65,
                "y": 56,
                "size": 26,
                "container": self,
                "text": u"\ue800",
                "font": "fontello.ttf"})
        self._points_widget = self.create_text(
            {"name": "points",
                "x": 100,
                "font":"lavoir.ttf",
                "y": 60,
                "container": self,
                "text": "POINTS: {0}".format(self._player.points)})
#        self.create_text(
#            {"name": "maps-left-icon",
#                "color": "gold3",
#                "x": 65,
#                "y": 90,
#                "size": 26,
#                "container": self,
#                "text": u"\ue801",
#                "font": "fontello.ttf"})
#        self._maps_left_widget = self.create_text(
#            {"name": "maps-left"+str(id(player)),
#                "color": "gold3",
#                "font":"lavoir.ttf",
#                "x": 100,
#                "y": 90,
#                "container": self,
#                "text": "{0}".format(self._player.maps_left)})

    def update(self, dt):
        if self._cache_points != self._player.points:
            self._cache_points = self._player.points
            self._points_widget.text = "POINTS: {0}".format(self._cache_points)
#        if self._cache_maps != self._player.maps_left:
#            self._cache_maps = self._player.maps_left
#            self._maps_left_widget.text = "{0}".format(self._cache_maps)