Example #1
0
 def _handleinit(self):
     self._itemimages = []
     if len(self._itemlist):
         for item in self._itemlist:
             self._itemimages.append([item._draw(),None])
     self._startitem = None
     self._enditem = None
     self._currentitem = None
     if self._bgfile != None:
         self._bgfilesurface = globals.loadfile(parameters.getitempath(), self._bgfile, self._bgdatfile, self._bgencryption)
     self._leftsurface = globals.loadfile(parameters.getitempath(), 'left.png', None, 0)
     self._rightsurface = globals.loadfile(parameters.getitempath(), 'right.png', None, 0)
     self._initialized = 1
Example #2
0
 def _draw(self):
     #Load image if needed
     if self._itemsurface == None:
         self._itemsurface = globals.loadfile(parameters.getitempath(), self._file, self._datfile, self._encryption)
         #Set alpha if needed
         if self._alpha != None:
             self._itemsurface.set_colorkey(self._itemsurface.get_at(self._alpha))
     return self._itemsurface
Example #3
0
 def _handleinit(self):
     #If there are any items in the inventory load them
     if len(self._itemlist):
         for item in self._itemlist:
             self._itemimages.append([item._draw(),None])
     #Load the background file if needed
     if self._bgfile != None:
         self._bgfilesurface = globals.loadfile(parameters.getitempath(), self._bgfile, self._bgdatfile, self._bgencryption)
     #Load the srcoll images
     self._backsurface = globals.loadfile(parameters.getitempath(), 'backscroll.bmp', None, 0)
     self._backsurface.set_colorkey(self._backsurface.get_at((0,0)))
     self._fwdsurface = globals.loadfile(parameters.getitempath(), 'fwdscroll.bmp', None, 0)
     self._fwdsurface.set_colorkey(self._fwdsurface.get_at((0,0)))
     #Set the state of this object to initialized
     self._initialized = 1
     #Make the inventory visible now that it is initialized
     self._visible = 1
Example #4
0
 def _draw(self):
     self._bgsurface = pygame.Surface(self._currentrect.size).convert_alpha()
     self._bgsurface.fill((0,0,0,0))
     self._bgsurface.blit(globals.uhabuffer, (0,0), self._currentrect)
     self._leftrect = None
     self._rightrect = None
     self._enditem = None
     self._areasurface = pygame.Surface(self._currentrect.size).convert_alpha()
     self._areasurface.fill((0,0,0,0))
     if self._bgfilesurface == None:
         if self._bgfile != None:
             self._bgfilesurface = globals.loadfile(parameters.getitempath(), self._bgfile, self._bgdatfile, self._bgencryption)
             self._areasurface.blit(self._bgfilesurface, (0,0))
     else:
         self._areasurface.blit(self._bgfilesurface, (0,0))
     if len(self._itemimages):
         if self._startitem == None:
             self._startitem = 0
         currentpos = 0
         if self._currentrect.width > self._currentrect.height:
             limit = self._currentrect.width
         else:
             limit = self._currentrect.height
         if self._startitem > 0:
             if self._currentitem == 'left':
                 self._leftsurface.set_alpha(self._mouseoveralpha)
             else:
                 self._leftsurface.set_alpha(self._showalpha)
             self._leftrect = self._areasurface.blit(self._leftsurface, (0,0))
             if self._currentrect.width > self._currentrect.height:
                 currentpos += self._leftrect.width
             else:
                 currentpos += self._leftrect.height
         for item in range(self._startitem,len(self._itemimages)):
             if self._currentitem == item:
                 self._itemimages[item][0].set_alpha(self._mouseoveralpha)
             else:
                 self._itemimages[item][0].set_alpha(self._showalpha)
             if self._currentrect.width > self._currentrect.height:
                 self._itemimages[item][1] = self._areasurface.blit(self._itemimages[item][0],(currentpos, 0))
                 currentpos += self._itemimages[item][1].width
             else:
                 self._itemimages[item][1] = self._areasurface.blit(self._itemimages[item][0],(0, currentpos))
                 currentpos += self._itemimages[item][1].height
             if currentpos >= limit:
                 if self._currentitem == 'right':
                     self._rightsurface.set_alpha(self._mouseoveralpha)
                 else:
                     self._rightsurface.set_alpha(self._showalpha)
                 self._rightrect = self._rightsurface.get_rect()
                 if self._currentrect.width > self._currentrect.height:
                     self._areasurface.fill((0,0,0,0), (self._currentrect.width - self._rightrect.width, 0, self._currentrect.height, self._rightrect.width))
                     self._rightrect = self._areasurface.blit(self._rightsurface, (self._currentrect.width - self._rightrect.width, 0))
                 else:
                     self._areasurface.fill((0,0,0,0), (0, self._currentrect.height - self._rightrect.height, self._currentrect.height, self._rightrect.width,))
                     self._rightrect = self._areasurface.blit(self._rightsurface, (0, self._currentrect.height - self._rightrect.height))
                 self._enditem = item
                 break
         else:
             self._enditem = len(self._itemimages)
     globals.uhabuffer.blit(self._areasurface, self._currentrect)
Example #5
0
 def _draw(self):
     #Save the area behind this one
     self._bgsurface = pygame.Surface(self._rect.size).convert_alpha()
     self._bgsurface.fill((0,0,0,0))
     self._bgsurface.blit(globals.uhabuffer, (0,0), self._rect)
     #Clear the scroll item rects (they might not be needed)
     self._backrect = None
     self._fwdrect = None
     #Clear the ending item (it will be set by this function)
     self._enditem = None
     #Create the tmp surface to draw to
     self._areasurface = pygame.Surface(self._rect.size).convert_alpha()
     self._areasurface.fill((0,0,0,0))
     #Load the background file if needed, and copy it to the temp surface
     if self._bgfilesurface == None:
         if self._bgfile != None:
             self._bgfilesurface = globals.loadfile(parameters.getitempath(), self._bgfile, self._bgdatfile, self._bgencryption)
             self._areasurface.blit(self._bgfilesurface, (0,0))
     else:
         self._areasurface.blit(self._bgfilesurface, (0,0))
     #If there are any items
     if len(self._itemimages):
         #If this is the first time this was drawn, set the starting item to be the first item in the inventory
         if self._startitem == None:
             self._startitem = 0
         #This will be used to tell when the inventory is full and no more items will fit in the temp surface
         currentpos = 0
         #Get the max position we can draw to, based on the orientation of the rect
         if self._rect.width > self._rect.height:
             limit = self._rect.width
         else:
             limit = self._rect.height
         #If the starting item is not the first, add the back scroll arrow
         if self._startitem > 0:
             #Set the scroll arrows alpha depending on state and mouse position
             if self._state == 1:
                 if self._currentitem == 'back':
                     self._backsurface.set_alpha(self._mouseoveralpha)
                 else:
                     self._backsurface.set_alpha(self._showalpha)
             else:
                 self._backsurface.set_alpha(self._hidealpha)
             #Blit the scroll item to the inventory and get it's rect
             self._backrect = self._areasurface.blit(self._backsurface, (0,0))
             #Add the scroll items size to the current position
             if self._rect.width > self._rect.height:
                 currentpos += self._backrect.width
             else:
                 currentpos += self._backrect.height
         #Loop thorough the items, starting with _startitem and go until there is no more room
         for item in range(self._startitem,len(self._itemimages)):
             #Set the items alpha depending on state and mouse position
             if self._state == 1:
                 if self._currentitem == item:
                     self._itemimages[item][0].set_alpha(self._mouseoveralpha)
                 else:
                     self._itemimages[item][0].set_alpha(self._showalpha)
             else:
                 self._itemimages[item][0].set_alpha(self._hidealpha)
             #Blit the items image to the proper place in the inventory and save its rect
             #then add it's size to the current position
             if self._rect.width > self._rect.height:
                 self._itemimages[item][1] = self._areasurface.blit(self._itemimages[item][0],(currentpos, 0))
                 currentpos += self._itemimages[item][1].width
             else:
                 self._itemimages[item][1] = self._areasurface.blit(self._itemimages[item][0],(0, currentpos))
                 currentpos += self._itemimages[item][1].height
             #If the current position is greater than the limit, we will need to add the fwd scroll item
             if currentpos >= limit:
                 #Set the scroll arrows alpha depending on state and mouse position
                 if self._state == 1:
                     if self._currentitem == 'fwd':
                         self._fwdsurface.set_alpha(self._mouseoveralpha)
                     else:
                         self._fwdsurface.set_alpha(self._showalpha)
                 else:
                     self._fwdsurface.set_alpha(self._hidealpha)
                 #Get the size of the forward scroll arrow
                 self._fwdrect = self._fwdsurface.get_rect()
                 #Blist the scroll arrow to the very end of the inventory and save it's rect (it may overwrite any item already there)
                 if self._rect.width > self._rect.height:
                     self._areasurface.fill((0,0,0,0), (self._rect.width - self._fwdrect.width, 0, self._rect.height, self._fwdrect.width))
                     self._fwdrect = self._areasurface.blit(self._fwdsurface, (self._rect.width - self._fwdrect.width, 0))
                 else:
                     self._areasurface.fill((0,0,0,0), (0, self._rect.height - self._fwdrect.height, self._rect.height, self._fwdrect.width))
                     self._fwdrect = self._areasurface.blit(self._fwdsurface, (0, self._rect.height - self._fwdrect.height))
                 #Save the last item that was drawn, the break out (can't draw any more items)
                 self._enditem = item
                 break
         else:
             #If we were able to draw all the way to the last item, we don't need the fwd scroll arrow
             #So just save the last item drawn
             self._enditem = len(self._itemimages)
     #Blit our temp surface to the UHA buffer
     globals.uhabuffer.blit(self._areasurface, self._rect)