def _show(self): if globals.curcursor == self and cursor._enabled: self._visible = 1 #Check if we need to load the file if self._cursorsurface == None: self._cursorsurface = globals.loadimage( FilePath(os.path.join(parameters.getcursorpath(), self._file), None, self._encrypted, isAbsolute=True) )
def _getTexture(self, texid): if self._slide_texture[texid] == None: self._slide_texture[texid] = globals.loadimage(FilePath(self._file[texid], self._datfile[texid], self._encrypted[texid])) return self._slide_texture[texid]
def render(self): if globals.isslidevisible(self._slide): #Load image if needed if self._objectsurface == None: self._objectsurface = globals.loadimage(self._file, isSlide = False) #Build destination rect self._rect.size = [self._objectsurface.getWidth(), self._objectsurface.getHeight()] #If alpha, set color key # TODO: OpenGL vs alpha #if self._alpha != None: # self._objectsurface.set_colorkey(self._objectsurface.get_at(self._alpha)) if self._visible: #Draw image if self._ratio != None: self._objectsurface.scaleDraw(self._rect.left, self._rect.top,self._ratio[0],self._ratio[1]) else: self._objectsurface.draw(self._rect.left, self._rect.top) return self._rect
def update(self, fileref = None, rect = None, visible = None, alpha = None, angle = None, ratio = None): dirtyrect = None # I know usually in Python you don't verify types but this will help detect problems during the current refactor. if fileref is not None and not isinstance(fileref, FilePath): raise Exception("fileref must be a FilePath object") #Update attributes if fileref != None: self._file = fileref if rect != None: if len(rect) == 4: self._rect = pygame.Rect(rect) else: self._rect = pygame.Rect(rect,(0,0)) if visible != None: self._visible = visible if alpha != None: self._alpha = alpha if angle != None: self._angle = angle if ratio != None: self._ratio = ratio if self._file == None or self._rect == None: self._visible = 0 #If Updated image is visible, clear everything above it's new area and redraw if globals.isslidevisible(self._slide): if self._visible: #load with new options if needed if fileref: self._texture = globals.loadimage(self._file, isSlide = False) self._rect.size = [self._objectsurface.getWidth(), self._objectsurface.getHeight()] return else: #Image is not visible, so clear it's buffers to save mem self._clearbuffers() else: #Image is not visible, so clear it's buffers to save mem self._clearbuffers()
def __init__(self, name, file = None, datfile = None, encrypted = 0, alpha = (0,0), hotspot = (0,0), trans = 'none'): #File info self._file = file self._datfile = datfile self._encrypted = encrypted #Alpha pos self._alpha = alpha #Hotspot pos self._hotspot = hotspot #Default Transition self._transition = trans #Cursor name self._name = name #Cursor Surface self._cursorsurface = None #Visible state self._visible = 0 self._cursorsurface = globals.loadimage( FilePath(os.path.join(parameters.getcursorpath(), self._file), None, self._encrypted, isAbsolute=True) ) #Add cursor to the dictionary of cursors for later lookup globals.cursors[name] = self