# 3rd party python modules
import os
import pygame
pygame.init()

# Own modules
from game.classes.Preferences import *

class Text( pygame.sprite.Sprite ):
	def __init__( self, text, centerxy, unique_name=None, size=20, font=os.path.join( FONT_DIR, "Ubuntu-R.ttf" ), color=BLACK, antialias=True, bold=False, italic=False, background=None, is_option=False ):
		pygame.sprite.Sprite.__init__( self )

		self._text = text
		self._centerxy = centerxy
		self._unique_name = unique_name
		self._font = os.path.join( FONT_DIR, "Ubuntu-R.ttf" )
		self._color = color
		self._antialias = antialias
		self._size = size
		self._bold = bold
		self._italic = italic
		self._background = background
		self._is_option = is_option


		self._font = pygame.font.Font( os.path.join( os.getcwd(), self._font ), self._size ) #, self._bold, self._italic )
#		self._font = pygame.font.SysFont( self._font, self._size, self._bold, self._italic )

		# Draw the text onto the surface.
		if self._background == None:
			self.image = self._font.render( self._text, self._antialias, self._color )
		else:
			self.image = self._font.render( self._text, self._antialias, self._color , self._background )
		self.rect = self.image.get_rect( center = self._centerxy )


	def set_text( self, new_text ):
		"""
		Changes the text.
		"""

		self._text = new_text

		# Draw the text onto the surface.
		if self._background == None:
			self.image = self._font.render( self._text, self._antialias, self._color )
		else:
			self.image = self._font.render( self._text, self._antialias, self._color , self._background )
		self.rect = self.image.get_rect( center = self._centerxy )		
