Esempio n. 1
0
 public void Add(object item, LoadPriority priority)
 {
     if (priority == LoadPriority.FirstStart)
     {
         lock (FirstStartQueue)
         {
             FirstStartQueueCount++;
             FirstStartQueue.Enqueue(item);
         }
     }
     if (priority == LoadPriority.Restart)
     {
         lock (SuspendedQueue)
         {
             SuspendedQueueCount++;
             SuspendedQueue.Enqueue(item);
         }
     }
     if (priority == LoadPriority.Stop)
     {
         lock (ContinuedQueue)
         {
             ContinuedQueueCount++;
             ContinuedQueue.Enqueue(item);
         }
     }
 }
        public void EnqueuePendingAssetBunlde(AssetBundleAssetLoadingInfo info)
        {
            LinkedListNode <AssetBundleAssetLoadingInfo> cur   = pendingBundle.First;
            LinkedListNode <AssetBundleAssetLoadingInfo> found = null;
            LoadPriority priority = info.Priority;

            while (cur != null)
            {
                if (cur.Value.BundleName == info.BundleName)
                {
                    return;
                }
                if (found == null)
                {
                    if (cur.Value.Priority < priority)
                    {
                        found = cur;
                    }
                }
                cur = cur.Next;
            }
            if (cur != null)
            {
                pendingBundle.AddAfter(cur, info);
            }
            else
            {
                pendingBundle.AddLast(info);
            }
        }
        /// <summary>
        /// 动态加载纹理数据
        /// </summary>
        /// <param name="url"></param>
        /// <param name="priority"></param>
        /// <param name="loadCallback"></param>
        public virtual void LoadTexture(string url, LoadPriority priority = LoadPriority.LV_2, Action loadCallback = null)
        {
            if (_textureExtSpriteAsset != null && _textureExtSpriteAsset.id == url || _isLoading == true && _url == url)
            {
                return;
            }

            // 停止当前加载项
            StopLoadTexture();

            if (App.assetManager.HasAsset(url))
            {
                // 内存中已存在资源
                SetTextureExtSpriteAsset(App.assetManager.GetAsset(url) as TextureExtSpriteAsset);
                if (loadCallback != null)
                {
                    loadCallback.Invoke();
                }
            }
            else
            {
                // 内存中不存在资源
                _url          = url;
                _loadCallback = loadCallback;
                _isLoading    = true;

                SetTextureExtSpriteAsset(null);

                App.resourceManager.Load(_url, LoadType.TEXTURE_EXT_SPRITE, LoadPriority.LV_2, LoadComplete);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 添加加载任务
        /// </summary>
        /// <param name="group">加载组</param>
        /// <param name="type">类型</param>
        /// <param name="path">路径</param>
        /// <param name="param">附加参数</param>
        /// <param name="completeCallback">回调</param>
        /// <param name="async">异步</param>
        /// <param name="priority">优先级</param>
        /// <param name="insert">插入</param>
        /// <returns></returns>
        public void AddLoadTask(LoaderGroup group, LoaderType type, string path, object param,
                                LoaderGroupCompleteCallback completeCallback, bool async,
                                LoadPriority priority = LoadPriority.Normal, bool insert = false)
        {
            if (!async)
            {
                Loader loader = GetLoader(type, path, param, false);
                PushCallback(loader, (data) =>
                {
                    completeCallback?.Invoke(group, data);
                });
                loader.Start();

                ReleaseLoader(loader);

                return;
            }

            if (group == null)
            {
                group = PopGroup(priority);
            }

            group.Add(type, path, param, completeCallback, true, insert);
        }
        /// <summary>
        /// 在AssetBundle已加载的条件下加载资源
        /// </summary>
        /// <param name="bundleName"></param>
        /// <param name="priority"></param>
        /// <param name="bundle"></param>
        public void DoEnqueuePending(string bundleName, LoadPriority priority, AssetBundle bundle = null)
        {
            BundleInfoResource  BundleInfoResource = cache[bundleName];
            BundleIndexItemInfo bundleInfo         = ResourceMgr.Instance.GetBundleInfo(bundleName);

            if (BundleInfoResource != null && BundleInfoResource.AssetBundle)
            {
                AssetBundleAssetLoadingInfo info = new AssetBundleAssetLoadingInfo(bundleInfo);
                info.AssetBundle = BundleInfoResource.AssetBundle;
                info.IsAsync     = true;
                info.Priority    = priority;
                EnqueuePendingAssetBunlde(info);
            }
            else
            {
                if (bundle == null)
                {
                    throw new NullReferenceException("Cannot find Bundle for " + bundleName);
                }

                AssetBundleAssetLoadingInfo info = new AssetBundleAssetLoadingInfo(bundleInfo);
                info.AssetBundle = bundle;
                info.IsAsync     = true;
                info.Priority    = priority;
                EnqueuePendingAssetBunlde(info);
            }
        }
Esempio n. 6
0
        // 全平台加载
        // 加载流文件(remote==false时先从persistentData读,没有找到则从streamingAssets读,带后缀)
        public void LoadStream(string path, LoadedHandler onLoaded,
                               bool async            = true, bool remote = false, bool isFullPath = false,
                               LoadPriority priority = LoadPriority.Normal)
        {
            string fullpath = path;

            if (!remote)
            {
                if (!isFullPath)
                {
                    fullpath = SearchPath(path, false, false, false);
                }
            }
            else
            {
                // 从服务器加载,一定是异步的
                async = true;
            }

            m_task.AddLoadTask(null, Loader.LoaderType.Stream, fullpath, remote, (group, data) => {
                if (onLoaded != null)
                {
                    onLoaded(data);
                }
            }, async, priority);
        }
Esempio n. 7
0
        public IObservable <TdApi.File> LoadFile(TdApi.File file, LoadPriority priority)
        {
            if (IsDownloadingNeeded(file))
            {
                return(_agent.Execute(new TdApi.DownloadFile
                {
                    FileId = file.Id,
                    Priority = (int)priority
                })
                       .SelectSeq(downloading =>
                {
                    return _agent.Updates
                    .OfType <TdApi.Update.UpdateFile>()
                    .Select(u => u.File)
                    .Where(f => f.Id == downloading.Id)
                    .TakeWhile(f => IsDownloadingNeeded(f));
                })
                       .Concat(Observable.Defer(() => _agent.Execute(new TdApi.GetFile
                {
                    FileId = file.Id
                }))));
            }

            return(Observable.Return(file));
        }
        /// <summary>
        /// ロードの準備開始
        /// </summary>
        /// <param name="loadPriority">ロードの優先順</param>
        /// <param name="referenceObj">ファイルを参照するオブジェクト</param>
        /// <returns></returns>
        public bool ReadyToLoad(LoadPriority loadPriority, System.Object referenceObj)
        {
            //ロードプライオリティの反映
            if (loadPriority < this.priority)
            {
                this.priority = loadPriority;
            }

            Use(referenceObj);
            unusedSortID = Int32.MaxValue;

            //通常ロード
            switch (status)
            {
            case STAUS.LOAD_WAIT:
                status = STAUS.LOADING;
                return(false);

            case STAUS.LOADING:
            case STAUS.LOAD_END:
                return(true);

            case STAUS.USING:
            case STAUS.UNUSED:
            default:
                status = STAUS.USING;
                return(true);
            }
        }
Esempio n. 9
0
        public IObservable <TdApi.File> LoadFile(TdApi.File file, LoadPriority priority)
        {
            bool downloadingNeeded = file.Local == null ||
                                     !file.Local.IsDownloadingCompleted ||
                                     file.Local.Path == null ||
                                     !File.Exists(file.Local.Path);

            if (downloadingNeeded)
            {
                bool isNew   = false;
                var  subject = _files.GetOrAdd(file.Id, id =>
                {
                    isNew = true;
                    return(new Subject <TdApi.File>());
                });

                return(isNew
                    ? _agent.Execute(new TdApi.DownloadFile {
                    FileId = file.Id, Priority = (int)priority
                })
                       .SelectMany(o => subject)
                    : subject);
            }

            return(Observable.Return(file));
        }
Esempio n. 10
0
        internal static void QueueAssetLoad <T>(AssetReference <T> asset, LoadPriority priority) where T : class, IAsset
        {
            AssetManager.SetState(asset.assetIndex, AssetState.Loading);

            if (!isSetup)
            {
                Setup();
            }
            LoadJob job = new LoadJob()
            {
                asset     = asset.Get(),
                assetId   = asset.assetIndex,
                assetName = asset.GetAssetName(),
                priority  = priority
            };

            switch (priority)
            {
            case LoadPriority.Medium:
                mediumPriorityQueue.Add(job);
                break;

            case LoadPriority.Low:
                lowPriorityQueue.Add(job);
                break;

            case LoadPriority.High:
                highPriorityQueue.Add(job);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(priority), priority, null);
            }
        }
Esempio n. 11
0
 // 加载资源
 public void LoadAsset(string path, Type type, LoadedHandler onLoaded,
                       bool async            = true, bool persistent = false, bool inData = true,
                       LoadPriority priority = LoadPriority.Normal)
 {
     //Logger.Log(string.Format("LoadAsset: {0} - {1}", path, async));
     if (ConstantData.EnableAssetBundle)
     {
         string abName = m_mapping.GetAssetBundleNameFromAssetPath(path);
         if (string.IsNullOrEmpty(abName))
         {
             Logger.LogError(string.Format("找不到资源所对应的ab文件:{0}", path));
             if (onLoaded != null)
             {
                 onLoaded(null);
             }
         }
         else
         {
             string assetName = Path.GetFileName(path);
             LoadAssetFromBundle(null, abName, assetName, type, (group, data) => {
                 if (onLoaded != null)
                 {
                     onLoaded(data);
                 }
             }, async, persistent, priority);
         }
     }
     else
     {
         LoadAssetFile(path, onLoaded, type, async, inData, priority);
     }
 }
 public bool CheckAssetLoading(string bundleName, string name, LoadPriority priority)
 {
     for (int i = 0; i < assetLoading.Count; i++)
     {
         var loading = assetLoading[i];
         if (loading.BundleName == bundleName)
         {
             if (!loading.AllDone)
             {
                 var requests = loading.Requests;
                 for (int j = 0; j < requests.Count; j++)
                 {
                     var req = requests[j];
                     if (req.AssetName == name)
                     {
                         if (req.Request == null)
                         {
                             //补充加载
                             req.Request = loading.AssetBundle.LoadAssetAsync(name);
                         }
                         return(true);
                     }
                 }
             }
             DoEnqueuePending(bundleName, priority, loading.AssetBundle);
             return(true);
         }
     }
     return(false);
 }
Esempio n. 13
0
    //异步资源加载-----------------------------------------------------------------------------------

    /// <summary>
    /// 异步加载资源
    /// </summary>
    /// <param name="path">资源路径</param>
    /// <param name="finishCallBack">完成后回调</param>
    /// <param name="loadPriority">加载优先级</param>
    /// <param name="param1">回调参数1</param>
    /// <param name="param2">回调参数2</param>
    /// <param name="param3">回调参数3</param>
    public void AsyncLoadResource(string path, OnAsyncFinishCallBack finishCallBack, LoadPriority loadPriority, bool isSprite = false,
                                  object param1 = null, object param2 = null, object param3 = null)
    {
        uint         crc  = CRC32.GetCRC32(path);
        ResourceItem item = GetCacheResourceItem(crc);

        if (item != null)
        {
            finishCallBack?.Invoke(path, item.m_Obj, param1, param2, param3);
            return;
        }

        //判断当前要加载的资源是否已存在加载列表中,不存在,则加入加载列表
        AsyncLoadResParam param = null;

        if (!m_LoadingAssetDict.TryGetValue(crc, out param) || param == null)
        {
            param            = m_AsyncLoadResPool.Spawn();
            param.m_Crc      = crc;
            param.m_Path     = path;
            param.m_Priority = loadPriority;
            param.m_IsSprite = isSprite;
            m_LoadAsyncResList[(int)loadPriority].Add(param);
            m_LoadingAssetDict.Add(crc, param);
        }
        //回调列表里添加回调
        AsyncCallBack asyncCallBack = m_AsyncCallBackPool.Spawn();

        asyncCallBack.finishCallBack = finishCallBack;
        asyncCallBack.param1         = param1;
        asyncCallBack.param2         = param2;
        asyncCallBack.param3         = param3;
        param.callBackList.Add(asyncCallBack);
    }
Esempio n. 14
0
        public void Load(string url, Action <IEventArgs> onDone, LoadPriority priority = LoadPriority.General)
        {
            Asset oAsset = null;

            if (!assetPool.TryGetValue(url, out oAsset))
            {
                oAsset = new Asset(url);
                assetPool.Add(url, oAsset);
            }
            oAsset.AddListener(onDone);
            if (oAsset.IsDone && oAsset.IsSucess)
            {
                oAsset.Callback();
            }
            switch (priority)
            {
            case LoadPriority.General:
                generalAssets.Enqueue(oAsset);
                break;

            case LoadPriority.Middle:
                middleAssets.Enqueue(oAsset);
                break;

            case LoadPriority.High:
                highAssets.Enqueue(oAsset);
                break;
            }
        }
Esempio n. 15
0
 public void Init(string path, ResourcePrioritizedCache owner, LoadPriority priority)
 {
     m_AssetPath     = path;
     m_Priority      = priority;
     m_Owner         = owner;
     m_LoadedProcess = LoadEnd;
 }
Esempio n. 16
0
        /// <summary>
        /// 加载Additive场景
        /// </summary>
        /// <param name="name"></param>
        /// <param name="OnSceneLoaded"></param>
        /// <param name="priority"></param>
        public void LoadAdditiveScene(string name, Action OnSceneLoaded = null, LoadPriority priority = LoadPriority.MostPrior)
        {
            //卸载非GameClient的场景
            OnLeaveScene();

            resourceMgr.SceneBundleGroup.GetScene(name, null, priority, true);

            UnityAction <Scene, LoadSceneMode> internelOnSceneLoadedHandler = null;

            internelOnSceneLoadedHandler = (loadedScene, LoadedSceneMode) =>
            {
                if (loadedScene.name == name)
                {
                    SceneManager.sceneLoaded -= internelOnSceneLoadedHandler;
                    SceneManager.SetActiveScene(loadedScene);

                    EngineCoreEvents.ResourceEvent.OnLoadAdditiveScene.SafeInvoke(loadedScene, loadedScene.GetRootGameObjects());

                    if (OnSceneLoaded != null)
                    {
                        OnSceneLoaded();
                    }
                }
            };
            SceneManager.sceneLoaded += internelOnSceneLoadedHandler;
        }
Esempio n. 17
0
        internal void GetScene(string name, Action callBack, LoadPriority priority = LoadPriority.Default, bool isAdditive = false)
        {
            mIsAdditive = isAdditive;

            string bundleName = this.ResourceMgr.GetBundleName(name);

            if (string.IsNullOrEmpty(bundleName))
            {
                bundleName = this.ResourceMgr.GetBundleName(name + ".unity");
            }
            if (bundleName == string.Empty)
            {
                Debug.LogError("can not find scene: " + name);
                return;
            }
            bool isCached = ResourceMgr.IsBundleCached(bundleName);

            if (/*GOERootCore.IsEditor ||*/ HasLoaded(name) || isCached)
            {
                if (mCurScene.ToLower() != name.ToLower())
                {
                    if (isCached)
                    {
                        var bundle = ResourceMgr.AssetBundleGroup.CacheManager.Cache[bundleName];
                        bundle.IsSceneBundle = true;//Set to active scene bundle
                        bundle.Touch();
                    }
                    LoadScene(name);
                    if (callBack != null)
                    {
                        callBack();
                    }
                    return;
                }
                else
                {
                    removeBundle(name);
                }
            }

            mCurScene        = name;
            getSceneCallback = callBack;

            ResourceMgr.AssetBundleGroup.PreloadBundle(bundleName, OnLoadAssetBundle, LoadPriority.MostPrior, true);

            /*Resource res = this.GetDownloadResource(bundleName);
             * if (res == null)
             * {
             *  res = this.CreateResource(bundleName, priority);
             *  res.LoadRes();
             * }
             *
             * //逻辑加载时,提高优先级//
             * if (res.Loader.Priority < priority)
             * {
             *  this.ResourceMgr.GOELoaderMgr.SetLoaderPriority(res.Loader, priority);
             * }
             * res.AddGotSceneCallback(callBack);*/
        }
Esempio n. 18
0
        /// <summary>
        /// 获得加载组
        /// </summary>
        /// <returns></returns>
        public LoaderGroup PopGroup(LoadPriority priority = LoadPriority.Normal)
        {
            LoaderGroup group = LoaderGroupPool.Get(this);

            group.priority = priority;
            m_DicLoaderGroupWaits[priority].Enqueue(group);
            return(group);
        }
Esempio n. 19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProjectInfo"/> class. 
 /// </summary>
 /// <param name="name">Name of the project.</param>
 /// <param name="projectId">Project ID.</param>
 /// <param name="priority">Project load priority.</param>
 /// <param name="parent">Parent project, if any.</param>
 public ProjectInfo(string name, Guid projectId, LoadPriority priority, ProjectInfo parent)
 {
     Name = name;
     ProjectId = projectId;
     Priority = priority;
     Parent = parent;
     Children = new List<ProjectInfo>();
 }
 private void UpdateProjectLoadPriority(Guid projectId, LoadPriority priority)
 {
     if (null != _loadManagerSupport)
     {
         var projectGuid = projectId;
         int hr          = _loadManagerSupport.SetProjectLoadPriority(ref projectGuid, (uint)priority);
     }
 }
Esempio n. 21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProjectInfo"/> class.
 /// </summary>
 /// <param name="name">Name of the project.</param>
 /// <param name="projectId">Project ID.</param>
 /// <param name="priority">Project load priority.</param>
 /// <param name="parent">Parent project, if any.</param>
 public ProjectInfo(string name, Guid projectId, LoadPriority priority, ProjectInfo parent)
 {
     Name      = name;
     ProjectId = projectId;
     Priority  = priority;
     Parent    = parent;
     Children  = new List <ProjectInfo>();
 }
 public override void GetScene(string name, Action callback, LoadPriority priority = LoadPriority.Default)
 {
     if (ResourceMgr.Instance().GetBundleName(name) == string.Empty)
     {
         ResourceMgr.Instance().RegisterBundleIdx(name, name + EngineFileUtil.m_sceneExt);
     }
     base.GetScene(name, callback);
 }
Esempio n. 23
0
        protected override Resource CreateResource(string name, LoadPriority priority)
        {
            Resource res = base.CreateResource(name, priority);

            res.AddGotAudioCallback(this.OnLoadAudio);

            return(res);
        }
Esempio n. 24
0
    public LoadPriority m_Priority = LoadPriority.RES_LOWER;            //当前资源的加载优先级

    public void Reset()
    {
        callBackList.Clear();
        m_Crc      = 0;
        m_Path     = "";
        m_IsSprite = false;
        m_Priority = LoadPriority.RES_LOWER;
    }
 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <param name="info">ファイル情報</param>
 /// <param name="fileIO">ファイルのIO管理クラス</param>
 public AssetFileWork(AssetFileInfo info, FileIOManagerBase fileIO)
 {
     this.InitKey(info.Key);
     this.fileInfo = info;
     this.fileIO   = fileIO;
     this.status   = STAUS.LOAD_WAIT;
     this.priority = LoadPriority.DownloadOnly;
     this.SubFiles = new Dictionary <string, AssetFile>();
 }
Esempio n. 26
0
 public void Reset()
 {
     m_AssetPath = "";
     m_Priority  = LoadPriority.Hight;
     m_Owner     = null;
     m_CallbackSet.Clear();
     m_CallbackReference.Clear();
     m_LoadedProcess = null;
 }
        private void LoadCell(string newcell, Action <string> callback, LoadPriority lp)
        {
            string lumdaName = newcell;

            if (!mAllLoadObjs.Keys.Contains(lumdaName))
            {
                // @xl lumdaName,也就是lod地块prefab的名字是这个格式"场景名_Chunk_数字_LOD_数字"
                //Debug.LogError("really load ::" + newcell);
                string pName      = lumdaName + ".prefab";
                string bundleName = GOERoot.ResMgr.GetBundleName(pName);
                if (string.IsNullOrEmpty(bundleName))
                {
                    return;
                }
                GOERoot.ResMgr.GetAsset(pName, (string prefabName, UnityEngine.Object obj) =>
                {
                    callback(lumdaName);
                    string[] arr = lumdaName.Split('_');
                    if (arr.Length != 5)
                    {
                        Debug.Log("包名不符合规则 " + lumdaName);
                        return;
                    }
                    //string chunkname = arr[2] + " " + arr[3];
                    string chunkname = arr[1] + " " + arr[2];
                    // @xl 查找Chunk 3的节点
                    GameObject chunkObj = FindGameObjectInChild(mTerrainBeh.gameObject, chunkname);
                    GameObject go       = obj as GameObject;
                    if (go != null)
                    {
                        // @xl 查找LOD_3 //
                        //GameObject lodObj = FindGameObjectInChild(chunkObj, arr[4] + "_" + arr[5]);
                        GameObject lodObj             = FindGameObjectInChild(chunkObj, arr[3] + "_" + arr[4]);
                        go.transform.parent           = lodObj.transform;
                        go.transform.localEulerAngles = Vector3.zero;
                        go.transform.localPosition    = Vector3.zero;
                        MeshRenderer[] mrs            = go.GetComponentsInChildren <MeshRenderer>();
                        foreach (MeshRenderer mr in mrs)
                        {
                            MeshLightmapSetting mls = mr.gameObject.GetComponent <MeshLightmapSetting>();
                            if (mls != null)
                            {
                                mls.LoadSettings();
                            }
                        }
                        BigTerrainXSetting sett = go.GetComponent <BigTerrainXSetting>();
                        if (sett != null)
                        {
                            sett.load = true;
                        }
                        mAllLoadObjs.Add(lumdaName, go);
                        mTerrainBeh.ChunkVisableUpdate(true);
                    }
                }, lp);
            }
        }
Esempio n. 28
0
 // 加载资源(Resource目录下,不带后缀)
 public void LoadResource(string path, LoadedHandler onLoaded,
                          bool async = true, LoadPriority priority = LoadPriority.Normal)
 {
     m_task.AddLoadTask(null, Loader.LoaderType.Resource, path, null, (group, data) => {
         if (onLoaded != null)
         {
             onLoaded(data);
         }
     }, async, priority);
 }
Esempio n. 29
0
        internal void SetLoaderPriority(ResourceLoader loader, LoadPriority priority)
        {
            if (loader.Priority == priority)
            {
                return;
            }

            loader.Priority = priority;
            mSortDirty      = true;
        }
        public void StartLoad(LoadPriority priority)
        {
            var state = State;

            if (state == AssetState.Loading || state == AssetState.Loaded)
            {
                return;
            }
            AssetLoader.QueueAssetLoad(this, priority);
        }
Esempio n. 31
0
 // 从AssetBundle中加载资源
 public void LoadAssetFromBundle(LoaderGroup group, string path, string name, Type type,
                                 GroupLoadedCallback onLoaded,
                                 bool async            = true, bool persistent = false,
                                 LoadPriority priority = LoadPriority.Normal)
 {
     path = path.ToLower();
     LoadAssetBundle(group, path, (group1, data) => {
         AssetBundleInfo cache = data as AssetBundleInfo;
         LoadBundleAsset(group1, cache, name, type, onLoaded, async);
     }, async, persistent, true, priority);
 }
Esempio n. 32
0
 public void Add(object item, LoadPriority priority)
 {
     if (priority == LoadPriority.FirstStart)
         lock (FirstStartQueue)
             FirstStartQueue.Enqueue(item);
     if (priority == LoadPriority.Restart)
         lock (SuspendedQueue)
             SuspendedQueue.Enqueue(item);
     if (priority == LoadPriority.Stop)
         lock (ContinuedQueue)
             ContinuedQueue.Enqueue(item);
 }
Esempio n. 33
0
 //=====================================================================
 /// <summary>
 /// 加载资源,如果资源已经加载过,则直接从缓存中获取
 /// </summary>
 /// <param name="fullName">全名</param>
 /// <param name="priority">优先级</param>
 /// <param name="loadType">加载类型</param>
 /// <param name="loadStart">加载开始前执行的方法</param>
 /// <param name="loadProgress">加载开始后且在结束前每帧执行的方法</param>
 /// <param name="loadEnd">加载结束后执行的方法</param>
 /// <param name="loadFail">加载失败后执行的方法</param>
 /// <param name="unZipStart">解压开始前执行的方法</param>
 /// <param name="unZipProgress">解压开始后且在结束前每帧执行的方法</param>
 /// <param name="unZipEnd">解压完毕后执行的方法</param>
 /// <param name="unZipFail">解压失败后执行的方法</param>
 public void addLoad(string fullName, LoadPriority priority = LoadPriority.two, LoadType loadType = LoadType.local,
     LoadFunctionDele loadStart = null, LoadFunctionDele loadProgress = null, 
     LoadFunctionDele loadEnd = null, LoadFunctionDele loadFail = null,
     LoadFunctionDele unZipStart = null, LoadFunctionDele unZipProgress = null,
     LoadFunctionDele unZipEnd = null, LoadFunctionDele unZipFail = null)
 {
     LoadInfo loadInfo = new LoadInfo();
     loadInfo.fullName = fullName;
     loadInfo.priority = priority;
     loadInfo.loadType = loadType;
     loadInfo.loadStart = loadStart;
     loadInfo.loadProgress = loadProgress;
     loadInfo.loadEnd = loadEnd;
     loadInfo.loadFail = loadFail;
     loadInfo.unZipStart = unZipStart;
     loadInfo.unZipProgress = unZipProgress;
     loadInfo.unZipEnd = unZipEnd;
     loadInfo.unZipFail = unZipFail;
     addLoad(loadInfo);
 }
Esempio n. 34
0
 public void Add(object item, LoadPriority priority)
 {
     if (priority == LoadPriority.FirstStart)
         lock (FirstStartQueue)
         {
             FirstStartQueueCount++;
             FirstStartQueue.Enqueue(item);
         }
     if (priority == LoadPriority.Restart)
         lock (SuspendedQueue)
         {
             SuspendedQueueCount++;
             SuspendedQueue.Enqueue(item);
         }
     if (priority == LoadPriority.Stop)
         lock (ContinuedQueue)
         {
             ContinuedQueueCount++;
             ContinuedQueue.Enqueue(item);
         }
 }
Esempio n. 35
0
 public void AddScriptChange(LUStruct[] items, LoadPriority priority)
 {
     if (RunInMainProcessingThread)
         StartScripts(items);
     else
     {
         LUQueue.Add(items, priority);
         if (!ScriptChangeIsRunning)
             StartThread("Change");
     }
 }
        /// <inheritdoc/>
        public void SetProjectLoadPriority(string profile, Guid projectGuid, LoadPriority priority)
        {
            var profileInfo = GetExistingProfile(profile);
            var project = profileInfo.GetProject(projectGuid);

            if (project == null)
            {
                project = new ProjectLoadInfo { ProjectGuid = projectGuid };
                profileInfo.Projects.Add(project);
            }

            project.LoadPriority = priority;
            WriteSettings();
        }
 private void UpdateProjectLoadPriority(Guid projectId, LoadPriority priority)
 {
     if (null != _loadManagerSupport)
     {
         var projectGuid = projectId;
         int hr = _loadManagerSupport.SetProjectLoadPriority(ref projectGuid, (uint)priority);
     }
 }
 public void AddScriptChange(LUStruct[] items, LoadPriority priority)
 {
     if (RunInMainProcessingThread)
     {
         List<LUStruct> NeedsFired = new List<LUStruct>();
         foreach (LUStruct item in items)
         {
             if (item.Action == LUType.Unload)
             {
                 item.ID.CloseAndDispose (true);
             }
             else if (item.Action == LUType.Load)
             {
                 try
                 {
                     if(item.ID.Start(false))
                         NeedsFired.Add(item);
                 }
                 catch (Exception ex) { m_log.Error("[" + m_ScriptEngine.ScriptEngineName + "]: LEAKED COMPILE ERROR: " + ex); }
             }
             else if (item.Action == LUType.Reupload)
             {
                 try
                 {
                     if(item.ID.Start(true))
                         NeedsFired.Add(item);
                 }
                 catch (Exception ex) { m_log.Error("[" + m_ScriptEngine.ScriptEngineName + "]: LEAKED COMPILE ERROR: " + ex); }
             }
         }
         foreach (LUStruct item in NeedsFired)
         {
             item.ID.FireEvents();
         }
     }
     else
     {
         LUQueue.Add(items, priority);
         if (!ScriptChangeIsRunning)
             StartThread("Change");
     }
 }
        private void UpdateCheckedProjectsPriority(LoadPriority priority)
        {
            String activeProfile = _settingsManager.ActiveProfile;

            UpdateNodes(projectsTreeView.Nodes[0], n =>
            {
                if (n.Checked)
                {
                    var info = (ProjectInfo)n.Tag;
                    info.Priority = priority;
                    OnPriorityChanged(new PriorityChangedEventArgs(info));

                    // Save new project load priority
                    _settingsManager.SetProjectLoadPriority(activeProfile, info.ProjectId, priority);

                    // Show load priory only for projects
                    if (0 == n.GetNodeCount(false))
                        n.BackColor = GetPriorityColor(info);
                }
            });
        }