def load_font(self, file_path, font_size, resource_id): """ Loads a font from a file and stores it into resource manager by its identifier. """ font = pygame.font.Font(file_path, font_size) if font != None: self.__fonts[resource_id] = font self.__logger.log_info("Loading a font file {0} was succesful.".format(file_path)) else: raise exceptions.ResourceNotFoundException("A font file doesn't exist!", foundation.get_signature())
def load_texture(self, file_path, resource_id): """ Loads a texture from a file and stores it into resource manager by its identifier. """ texture = pygame.image.load(file_path) if texture != None: self.__textures[resource_id] = texture self.__logger.log_info("Loading a texture file {0} was succesful.".format(file_path)) else: raise exceptions.ResourceNotFoundException("A texture file doesn't exist", foundation.get_signature())
def get_sounds(self, resource_id): """ Gets a sound by its identifier. """ sound = None if resource_id in self.__sounds: sound = self.__sounds[resource_id] else: raise exceptions.KeyNotFoundException("The resource with such identifier doesn't exists!", foundation.get_signature()) return sound
def get_font(self, resource_id): """ Gets a font by its resource identifier. """ font = None if resource_id in self.__fonts: font = self.__fonts[resource_id] else: raise exceptions.KeyNotFoundException("The resource with such identifier doesn't exists!", foundation.get_signature()) return font
def get_texture(self, resource_id): """ Gets a texture by its resource identifier. """ texture = None if resource_id in self.__textures: texture = self.__textures[resource_id] else: raise exceptions.KeyNotFoundException("The resource with such identifier doesn't exists!", foundation.get_signature()) return texture
def load_system_font(self, font_name, font_size, resource_id): """ Loads a font from operating system and stores it into resource manager by its identifier. """ font = pygame.font.SysFont(font_name, font_size) if font != None: self.__fonts[resource_id] = font self.__logger.log_info("Loading a system font {0} was succesful.".format(font_name)) else: raise exceptions.ResourceNotFoundException("A system font doesn't exist!", foundation.get_signature())