예제 #1
0
def PopulateShaderLibraryFromFiles():
    global _isShaderLibraryPopulated
    global _isShaderLibraryInitialized
    if _isShaderLibraryInitialized:
        return
    _isShaderLibraryInitialized = True

    def _AddToShaderLibrary(filepath):
        highLevelShader = blue.resMan.LoadObject(filepath)
        if highLevelShader is not None:
            try:
                shaderManager.shaderLibrary.append(highLevelShader)
            except Exception:
                logger.exception('Exception loading High Level Shader: %s', filepath)
                sys.exc_clear()

        else:
            logger.error('Unable to find shader library object: %s', filepath)

    filesToLoad = set()
    for path, dirs, files in walk.walk('res:/Graphics/Shaders/ShaderDescriptions'):
        for f in files:
            filename, extension = os.path.splitext(f)
            if extension in ('.red', '.black'):
                filepath = path + '/' + filename + '.red'
                filesToLoad.add(filepath)

    uthread2.map(_AddToShaderLibrary, filesToLoad)
    _isShaderLibraryPopulated = True
예제 #2
0
def PopulateShaderLibraryFromFiles():
    global _isShaderLibraryPopulated
    global _isShaderLibraryInitialized
    if _isShaderLibraryInitialized:
        return
    _isShaderLibraryInitialized = True

    def _AddToShaderLibrary(filepath):
        highLevelShader = blue.resMan.LoadObject(filepath)
        if highLevelShader is not None:
            try:
                shaderManager.shaderLibrary.append(highLevelShader)
            except Exception:
                logger.exception('Exception loading High Level Shader: %s', filepath)
                sys.exc_clear()

        else:
            logger.error('Unable to find shader library object: %s', filepath)

    filesToLoad = set()
    for path, dirs, files in walk.walk('res:/Graphics/Shaders/ShaderDescriptions'):
        for f in files:
            filename, extension = os.path.splitext(f)
            if extension in ('.red', '.black'):
                filepath = path + '/' + filename + '.red'
                filesToLoad.add(filepath)

    uthread2.map(_AddToShaderLibrary, filesToLoad)
    _isShaderLibraryPopulated = True
예제 #3
0
def prefetch_files(file_set):
    """
    Prefetches all the files in the given set, blocking the calling tasklet
    until all files have been downloaded.
    
    Yields until all downloads have finished.
    """
    uthread2.map(prefetch_single_file, file_set)
예제 #4
0
def ApplyBoosters(trinobjs, race):
    validobjs = filter(lambda o: hasattr(o, 'boosters'), trinobjs)
    if not validobjs:
        return

    def clearbooster(obj):
        obj.boosters = None

    if race is None:
        uthread2.map(clearbooster, validobjs)
        return
    booster_filepath = '%s/booster_%s.red' % (BOOSTER_RES_PATH, race)
    booster = trinity.Load(booster_filepath)
    if not booster:
        raise IOError("Could not load file '%s'" % booster_filepath)

    def loadit(obj):
        boost = trinity.Load(booster_filepath)
        obj.boosters = boost
        obj.boosters.alwaysOn = True
        obj.RebuildBoosterSet()

    uthread2.map(lambda o: uthread2.start_tasklet(loadit, o), validobjs)
예제 #5
0
def ApplyBoosters(trinobjs, race):
    validobjs = filter(lambda o: hasattr(o, 'boosters'), trinobjs)
    if not validobjs:
        return

    def clearbooster(obj):
        obj.boosters = None

    if race is None:
        uthread2.map(clearbooster, validobjs)
        return
    booster_filepath = '%s/booster_%s.red' % (BOOSTER_RES_PATH, race)
    booster = trinity.Load(booster_filepath)
    if not booster:
        raise IOError("Could not load file '%s'" % booster_filepath)

    def loadit(obj):
        boost = trinity.Load(booster_filepath)
        obj.boosters = boost
        obj.boosters.alwaysOn = True
        obj.RebuildBoosterSet()

    uthread2.map(lambda o: uthread2.start_tasklet(loadit, o), validobjs)
예제 #6
0
def prefetch_files(file_set):
    uthread2.map(prefetch_single_file, file_set)
예제 #7
0
def prefetch_files(file_set):
    uthread2.map(prefetch_single_file, file_set)