Exemplo n.º 1
0
 def clear(self,fadeout = 0,bgfile = None):
     self.clearQuickItems()
     
     if not fadeout:
         self.itemEntries.clear()
         self.reload()
     else:
         dr = self.camera.node().getDisplayRegion(0)
         texture = dr.getScreenshot()
        
         w = dr.getPixelWidth()
         h = dr.getPixelHeight()
                     
         self.itemEntries.clear()
         self.reload()
         
         if bgfile:
             bgentry = StoryViewItemEntry(fileName = bgfile,key = '__bg__',category = SVIC.BG)
             self.newItem(bgentry)
         
         tempbg = OnscreenImage(texture)
         if w > h:
             tempbg.setScale(1*w/float(h),1,1)
         else: tempbg.setScale(1,1,1*h/float(w))
         tempbg.setColor(1,1,1,1)
         tempbg.reparentTo(self.bgNodePath)
         tempbg.setName('__tempbg__')
         
         li = LerpColorInterval(tempbg, fadeout, (1,1,1,0), (1,1,1,1),blendType = 'easeInOut' ) 
         self._intervals.append(li)
         li.start()
Exemplo n.º 2
0
    def _createItem(self, entry, ignore_fadein = False):
        '''Create an item(not including adding this to itemEntries)'''
        imagepathes = runtime_data.game_settings['imagepathes']
        imagetypes = runtime_data.game_settings['imagetypes']
        modelpathes = runtime_data.game_settings['modelpathes']
        modeltypes = runtime_data.game_settings['modeltypes']
        
        if self._sceneItems.has_key(entry.key):
            self._sceneItems[entry.key].removeNode()
            self._sceneItems.pop(entry.key)
        item = None
        if entry.category == SVIC.FG or entry.category == SVIC.BG or entry.category == SVIC.O2D:

            
            texture = None
            for ft in ((folder,type) for folder in imagepathes for type in imagetypes):
                if exists(ft[0] + entry.fileName + ft[1]):
                    texture = loader.loadTexture(ft[0] + entry.fileName + ft[1])
                    break
            
                
            '''Alternative
            item = loader.loadModel(r"models/plain.egg")
            item.setTexture(texture, 1)
            '''
            item = OnscreenImage(texture)
            
            item.setPos(entry.pos[0],entry.pos[1],entry.pos[2])
            item.setScale(entry.scale[0]*texture.getOrigFileXSize()/float(texture.getOrigFileYSize()),entry.scale[1],entry.scale[2])  #Always make its height fill the screen normally
            color = (entry.color[0],entry.color[1],entry.color[2],entry.color[3])
            if entry.fadein:
                lv = LerpColorInterval(item, entry.fadein, color, (color[0],color[1],color[2],0) ) 
                self._intervals.append(lv)
                lv.start()
            else: item.setColor(color)
            item.setName(entry.key)
            
            if entry.category == SVIC.FG:
                item.reparentTo(self.fgNodePath)
            elif entry.category == SVIC.BG:
                item.reparentTo(self.bgNodePath)
            elif entry.category == SVIC.O2D:
                item.reparentTo(self.vNodePath)
            
        elif entry.category == SVIC.AFG:
            item = None
            for ft in ((folder,type) for folder in imagepathes for type in modeltypes):
                if exists(ft[0] + entry.fileName + ft[1]):
                    item = loader.loadModel(ft[0] + entry.fileName + ft[1])
                    break
            if not item:  item = loader.loadModel(entry.fileName)
            item.setPos(entry.pos[0],entry.pos[1],entry.pos[2])
            item.setScale(entry.scale)  #For generated egg animation with "egg-texture-cards" is a 1x1 rectangle by default
            color = (entry.color[0],entry.color[1],entry.color[2],entry.color[3])
            if entry.fadein:
                lv = LerpColorInterval(item, entry.fadein, color, (color[0],color[1],color[2],0) ) 
                self._intervals.append(lv)
                lv.start()
            else: item.setColor(color)
            item.setTransparency(1)
            item.setName(entry.key)
            item.reparentTo(self.fgNodePath)
            #item.setBin("unsorted", 0)

            
        elif entry.category == SVIC.O3D:
            item = None
            for ft in ((folder,type) for folder in modelpathes for type in modeltypes):
                if exists(ft[0] + entry.fileName + ft[1]):
                    item = loader.loadModel(ft[0] + entry.fileName + ft[1])
                    break
            if not item:  item = loader.loadModel(entry.fileName)
            item.setPos(entry.pos[0],entry.pos[1],entry.pos[2])
            item.setScale(entry.scale)  #For generated egg animation with "egg-texture-cards" is a 1x1 rectangle by default
            color = (entry.color[0],entry.color[1],entry.color[2],entry.color[3])
            if entry.fadein:
                lv = LerpColorInterval(item, entry.fadein, color, (color[0],color[1],color[2],0) ) 
                self._intervals.append(lv)
                lv.start()
            else: item.setColor(color)
            item.setTransparency(1)
            item.setName(entry.key)
            item.reparentTo(self.vNodePath)
  
        if item:
            self._sceneItems[entry.key] = item
            if entry.quickitem:
                self._quickitems.append(entry.key)