Exemple #1
0
    protected virtual void disposeOver()
    {
        _disposed = true;

        if (_loadState > 0)
        {
            if (_loadVersion == LoadControl.getVersion() && _loadResource > 0)
            {
                //unload
                LoadControl.unloadOne(_loadResource);
            }

            if (_loadState == 2)
            {
                if (_smodel != null)
                {
                    _smodel.doDispose();

                    _smodel = null;

                    GameObject.Destroy(_modelObject);
                    _modelObject = null;
                }
            }
        }

        //归零
        _loadState = 0;
    }
    /// <summary>
    /// 读完所有表后处理
    /// </summary>
    public static void afterReadConfigAll()
    {
        firstLoadList      = new IntList();
        firstSceneLoadList = new IntList();

        _dic.forEachValue(v =>
        {
            int resourceID = LoadControl.getResourceIDByName(BaseGameUtils.getURLReplace(v.url));

            switch (v.type)
            {
            case MarkResourceType.FirstLoad:
                {
                    firstLoadList.add(resourceID);
                }
                break;

            case MarkResourceType.FirstSceneLoad:
                {
                    firstSceneLoadList.add(resourceID);
                }
                break;
            }
        });
    }
Exemple #3
0
 public XmlSaver(TypeFinder typeFinder)
 {
     this.typeFinder = typeFinder;
     loadControl     = new LoadControl(typeFinder);
     saveableValue   = new XmlSaveable(this);
     valueReaders.Add(saveableValue.ElementName, saveableValue);
     enumValue = new XmlEnum(this);
     valueReaders.Add(enumValue.ElementName, enumValue);
     valueWriters = new ValueWriterCollection(saveableValue, enumValue);
     addXmlValue <bool>(new XmlBool(this));
     addXmlValue <byte>(new XmlByte(this));
     addXmlValue <char>(new XmlChar(this));
     addXmlValue <decimal>(new XmlDecimal(this));
     addXmlValue <double>(new XmlDouble(this));
     addXmlValue <float>(new XmlFloat(this));
     addXmlValue <int>(new XmlInt(this));
     addXmlValue <long>(new XmlLong(this));
     addXmlValue <Quaternion>(new XmlQuaternion(this));
     addXmlValue <Ray3>(new XmlRay3(this));
     addXmlValue <sbyte>(new XmlSByte(this));
     addXmlValue <short>(new XmlShort(this));
     addXmlValue <String>(new XmlString(this));
     addXmlValue <uint>(new XmlUInt(this));
     addXmlValue <ulong>(new XmlULong(this));
     addXmlValue <ushort>(new XmlUShort(this));
     addXmlValue <Vector3>(new XmlVector3(this));
     addXmlValue <Color>(new XmlColor(this));
     addXmlValue <byte[]>(new XmlBlob(this));
     addXmlValue <Guid>(new XmlGuid(this));
     saveControl = new SaveControl(this, valueWriters, this);
 }
Exemple #4
0
            public bool releaseHead()
            {
                if (_queue.isEmpty())
                {
                    return(false);
                }

                ResourceNode node = _queue.poll();

                GameObject obj = node.obj;

                node.obj = null;

                GameObject.Destroy(obj);

                --_parent.num;

                //直接-1
                if (_refCount == 0 && _queue.isEmpty())
                {
                    LoadControl.unloadOne(id);
                }

                return(true);
            }
Exemple #5
0
    public void loadSplit(int type, string configName, int key, Action <BaseConfig> overFunc)
    {
        int configResourceID = LoadControl.getResourceIDByNameAbs(getSplitConfigPath(configName, key));

        LoadControl.loadOne(configResourceID, () =>
        {
            byte[] bytes = (byte[])LoadControl.getResource(configResourceID);

            BytesReadStream stream = _tempStream;

            stream.setBuf(bytes);

            if (CommonSetting.configNeedCompress)
            {
                stream.unCompress();
            }

            if (!stream.checkVersion(ShineGlobal.configVersion))
            {
                Ctrl.errorLog("config结构版本不对");
                return;
            }

            if (!checkSplitStream(stream))
            {
                return;
            }

            BaseConfig bConfig = _useData.readBytesOneSplit(type, stream);

            overFunc(bConfig);
        });
    }
Exemple #6
0
            public void loadOne(Action overFunc)
            {
                ++_refCount;

                //自定义
                if (id < -1)
                {
                    overFunc();
                }
                else
                {
                    if (_loadState == LoadState_Complete)
                    {
                        overFunc();
                    }
                    else
                    {
                        _callFuncs.add(overFunc);

                        if (_loadState == LoadState_Free)
                        {
                            _loadState = LoadState_Loading;

                            LoadControl.loadOne(id, onLoadComplete);
                        }
                    }
                }
            }
Exemple #7
0
    private void onLoadMusic()
    {
        _music.clip = LoadControl.getUnityObjectByType <AudioClip>(_curMusic);

        //刷新状态
        pauseMusic(_pauseMusic);
    }
Exemple #8
0
        private void doBundleSaveOne(string bundleName, int type)
        {
            ResourceSaveExData data = _newVersion.getBundleEx(bundleName);

            if (data != null)
            {
                if (ShineToolSetting.bundlePackNeedPutDependAlsoIntoStreamingAssets && type == ResourceSaveType.InStreamingAsset && data.saveType != type)
                {
                    data.saveType = type;
                }
            }
            else
            {
                data = doFileSaveData(getTargetSourcePath(), bundleName, type);

                if (ShineToolSetting.bundlePackNeedPutDependAlsoIntoStreamingAssets)
                {
                    int resourceID = LoadControl.getResourceIDByName(data.name);

                    BundleInfoData bundleInfoData = LoadControl.getBundleInfo(resourceID);

                    foreach (int d in bundleInfoData.depends)
                    {
                        string pName = LoadControl.getResourceNameByID(d);

                        //父类型
                        doBundleSaveOne(pName, type);
                    }
                }
            }
        }
Exemple #9
0
 public JsonSaver(TypeFinder typeFinder)
 {
     this.typeFinder = typeFinder;
     loadControl     = new LoadControl(typeFinder);
     saveableValue   = new JsonSaveable(this);
     valueReaders.Add(saveableValue.ElementName, saveableValue);
     enumValue = new JsonEnum(this);
     valueReaders.Add(enumValue.ElementName, enumValue);
     valueWriters = new ValueWriterCollection(saveableValue, enumValue);
     addParser <bool>(new JsonBool(this));
     addParser <byte>(new JsonByte(this));
     addParser <char>(new JsonChar(this));
     addParser <decimal>(new JsonDecimal(this));
     addParser <double>(new JsonDouble(this));
     addParser <float>(new JsonFloat(this));
     addParser <int>(new JsonInt(this));
     addParser <long>(new JsonLong(this));
     addParser <Quaternion>(new JsonQuaternion(this));
     addParser <Ray3>(new JsonRay3(this));
     addParser <sbyte>(new JsonSByte(this));
     addParser <short>(new JsonShort(this));
     addParser <String>(new JsonString(this));
     addParser <uint>(new JsonUInt(this));
     addParser <ulong>(new JsonULong(this));
     addParser <ushort>(new JsonUShort(this));
     addParser <Vector3>(new JsonVector3(this));
     addParser <Color>(new JsonColor(this));
     addParser <byte[]>(new JsonBlob(this));
     addParser <Guid>(new JsonGuid(this));
     saveControl = new SaveControl(this, valueWriters, this);
 }
Exemple #10
0
        public override void readValue(LoadControl loadControl, String name, JsonReader reader)
        {
            reader.Read();
            if (reader.TokenType != JsonToken.StartObject)
            {
                throwReadFormatError();
            }

            reader.Read();
            if (reader.TokenType != JsonToken.PropertyName)
            {
                throwReadFormatError();
            }
            var clrType  = reader.Value.ToString();
            var enumType = loadControl.TypeFinder.findType(clrType);
            var valueStr = reader.ReadAsString();

            reader.Read();
            if (reader.TokenType != JsonToken.EndObject)
            {
                throwReadFormatError();
            }

            if (enumType != null)
            {
                Object value = Enum.Parse(enumType, valueStr);
                loadControl.addValue(name, value, enumType);
            }
            else
            {
                Log.Default.sendMessage("Could not find enum type {0}. Value not loaded.", LogLevel.Warning, "Saving", clrType);
            }
        }
Exemple #11
0
        /** 读取bundle信息 */
        public static void readBundleInfo(BytesReadStream stream)
        {
            LoadControl.clearResourceInfo();

            int len = stream.readInt();

            for (int i = 0; i < len; i++)
            {
                BundleInfoData data = new BundleInfoData();
                data.readBytes(stream);

                LoadControl.registBundleInfo(data);
            }

            len = stream.readInt();
            for (int i = 0; i < len; i++)
            {
                ResourceInfoData data = new ResourceInfoData();
                data.readBytes(stream);

                LoadControl.registResource(data.name, data.id, data.type);
            }

            LoadControl.registBundleOver();
        }
Exemple #12
0
        private void onLoadOver()
        {
            setLoading(false);

            if (_loadTool.getResourceID() == -1)
            {
                //TODO:将这里补充正确
//				_image.=null;
            }
            else
            {
                object asset = LoadControl.getResource(_loadTool.getResourceID());
                if (asset is Texture2D)
                {
                    Texture2D tex = (Texture2D)asset;
                    _image.texture = tex;
                }
                else
                {
                    Ctrl.errorLog(new Exception("不支持的图片格式:" + asset));
                }

                if (_autoNativeSize)
                {
                    _image.SetNativeSize();
                }
            }

            if (_overFunc != null)
            {
                _overFunc();
            }
        }
Exemple #13
0
        private void toClear(bool needCache)
        {
            _isLoading = false;

            if (_resourceID != -1)
            {
                ++_index;

                _resourceID = -1;

                //版本还对
                if (LoadControl.getVersion() == _loadVersion)
                {
                    if (needCache)
                    {
                        releaseCache();
                    }
                }
                else
                {
                    _cacheResourceID = -1;
                    _cacheObject     = null;
                }
            }
        }
Exemple #14
0
    /** 卸载 */
    public void unloadSplit(string configName, int key)
    {
        string path             = ShineGlobal.configDirPath + "/" + configName + "/" + key + ".bin";
        int    configResourceID = LoadControl.getResourceIDByNameAbs(path);

        LoadControl.unloadOne(configResourceID);
    }
Exemple #15
0
    public BaseConfig getSplitConfigSync(int type, string configName, int key)
    {
        int configResourceID = LoadControl.getResourceIDByNameAbs(getSplitConfigPath(configName, key));

        byte[] bytes = (byte[])LoadControl.getResource(configResourceID);

        if (bytes == null)
        {
            return(null);
        }

        BytesReadStream stream = _tempStream;

        stream.setBuf(bytes);

        if (CommonSetting.configNeedCompress)
        {
            stream.unCompress();
        }

        if (!stream.checkVersion(ShineGlobal.configVersion))
        {
            Ctrl.errorLog("config结构版本不对");
            return(null);
        }

        if (!checkSplitStream(stream))
        {
            return(null);
        }

        BaseConfig bConfig = _useData.readBytesOneSplit(type, stream);

        return(bConfig);
    }
Exemple #16
0
        /** 加载一个 */
        public void loadOne(int id)
        {
            //-1不加载
            if (id == -1)
            {
                clear();
                //直接返回
                onComplete();
                return;
            }

            //相同资源,加载中跳过
            if (_isLoading && _resourceID == id)
            {
                return;
            }

            clear();

            _loadVersion = LoadControl.getVersion();
            int index = ++_index;

            _isLoading = true;

            LoadControl.loadOne(_resourceID = id, () =>
            {
                if (_index == index && LoadControl.getVersion() == _loadVersion)
                {
                    onComplete();
                }
            }, _priority);
        }
Exemple #17
0
        private void LoadTasks()
        {
            TaskManager.ClearGroups();
            LoadControl lc = new LoadControl(
                () =>
                {
                    TaskManager.ClearGroups();
                    var rj = FileHelper.ReadJosn<List<CustomTasks>>();
                    if (rj != null)
                    {
                        TaskManager.LoadGroup(rj.ToList<ITaskGroup>());
                    }
                },
                () =>
                {
                    foreach (var taskgroup in TaskManager.GetTaskGroups())
                    {
                        MetroFramework.Controls.MetroTabPage tabPage = new MetroFramework.Controls.MetroTabPage();
                        tabPage.Name = taskgroup.GroupId;
                        tabPage.Tag = taskgroup;
                        tabPage.Text = taskgroup.GroupName;
                        tabPage.VerticalScrollbarSize = 4;
                        tabPage.HorizontalScrollbar = false;
                        tabPage.HorizontalScroll.Enabled = false;
                        tabPage.HorizontalScrollbarHighlightOnWheel = false;
                        tabPage.VerticalScrollbar = true;
                        tabPage.AutoScroll = true;
                        tabPage.Theme = this.metroStyleManager1.Theme;

                        tabPage.PagePanelDock<TaskForm>(list =>
                        {
                            List<DailyTask> dtl = new List<DailyTask>();
                            foreach (var ctl in list)
                            {
                                dtl.Add(ctl.DailyTask);
                            }
                            TaskManager.GetTaskGroup(tabPage.Name).DailyTasks = dtl;
                        });

                        metroTabControl1.TabPages.Add(tabPage);

                        foreach (var task in taskgroup.DailyTasks)
                        {
                            TaskForm form = new TaskForm(this, task);
                            form.Theme = this.metroStyleManager1.Theme;
                            form.Show();
                            tabPage.Controls.Add(form);
                            form.FormClosed += form_FormClosed;
                        }
                    }
                });
            lc.Parent = this;
            lc.Dock = DockStyle.Fill;
            this.Controls.Add(lc);
            this.Controls.SetChildIndex(lc, 0);
        }
Exemple #18
0
    /// <summary>
    /// 生成刷新配置
    /// </summary>
    protected override void generateRefresh()
    {
        if (_explain == null)
        {
            _explain = explain;
        }
        explain = LanguageConfig.getText(_explain);

        iconT = LoadControl.getResourceIDByName(icon);
    }
    public void LoadCetegory()
    {
        LoadControl LC = new LoadControl();
        DataTable   dt = LC.LoadCetegory();

        ddlCategory.DataSource     = dt;
        ddlCategory.DataTextField  = "CategoryName";
        ddlCategory.DataValueField = "CategoryID";

        ddlCategory.DataBind();
    }
Exemple #20
0
    public void LoadCetegory()
    {
        LoadControl LC = new LoadControl();
        DataTable   dt = LC.LoadCetegory();

        ddlCategory.DataSource     = dt;
        ddlCategory.DataTextField  = "CategoryName";
        ddlCategory.DataValueField = "CategoryID";

        ddlCategory.DataBind();
        ddlCategory.Items.Insert(0, new ListItem("All Category", "-1"));
    }
 private LoadControl GetLoadControl(List <IWizardControl> controls)
 {
     foreach (var item in controls)
     {
         LoadControl ctrl = item as LoadControl;
         if (null != ctrl)
         {
             return(ctrl);
         }
     }
     throw new IndexOutOfRangeException("controls");
 }
Exemple #22
0
        private void onLoadOver()
        {
            setLoading(false);

            if (_loadTool.getResourceID() == -1)
            {
                //TODO:将这里补充正确
                _image.sprite = null;
                return;
            }
            else
            {
                Sprite sprite = null;
                object asset  = LoadControl.getResource(_loadTool.getResourceID());
                if (asset is Texture2D)
                {
                    Texture2D tex = (Texture2D)asset;
                    sprite = Sprite.Create(tex, new Rect(0f, 0f, tex.width, tex.height), new Vector2((float)tex.width / 2, (float)tex.height / 2));
                }
                else if (asset is Sprite)
                {
                    sprite = (Sprite)asset;
                }
                else
                {
                    Ctrl.errorLog(new Exception("不支持的图片格式:" + asset));
                }

                _image.sprite = sprite;

                if (_autoNativeSize)
                {
                    _image.SetNativeSize();
                }

                if (_isAutoNativeSpriteSize)
                {
                    float imageWidth = _image.sprite.rect.width;
                    float imageHeigh = _image.sprite.rect.height;

                    float scale = Mathf.Min(_spriteWidth / imageWidth, _spriteHeigh / imageHeigh);

                    RectTransform rectTransform = transform.GetComponent <RectTransform>();
                    rectTransform.sizeDelta = imageWidth * scale * Vector2.right + imageHeigh * scale * Vector2.up;
                }
            }

            if (_overFunc != null)
            {
                _overFunc();
            }
        }
Exemple #23
0
    //steps

    protected virtual void stepLoadBundleInfo()
    {
        if (ShineSetting.localLoadWithOutBundle)
        {
            //直接标记完成
            LoadControl.registBundleOver();
            _stepTool.completeStep(LoadBundleInfo);
        }
        else
        {
            ResourceInfoControl.loadBundleInfo(() => { _stepTool.completeStep(LoadBundleInfo); });
        }
    }
Exemple #24
0
        /// <summary>
        /// 启动
        /// </summary>
        public static void setup(GameObject root, Action exitRun = null)
        {
            if (_inited)
            {
                return;
            }

            _inited = true;

            _root = root;

            GameObject.DontDestroyOnLoad(_root);

            _exitRun = exitRun;

            _rootBehavious = _root.AddComponent <ShineBehavious>();

            SystemControl.init();
            ThreadControl.init();
            DateControl.init();
            NetControl.init();
            BytesControl.init();

            //显示部分
            if (ShineSetting.isWholeClient)
            {
                SKeyboardControl.init();
                STouchControl.init();
                UIControl.init();

                CameraControl.init();
                Tween.init();

                LoadControl.init();
                ResourceInfoControl.init();
                AssetPoolControl.init();
            }
            else
            {
                //gm指令所需
                if (ShineSetting.needGMCommandUI)
                {
                    SKeyboardControl.init();
                    STouchControl.init();
                    UIControl.init();
                }

                ShineSetting.debugJumpResourceVersion = true;
                ResourceInfoControl.initBase();
            }
        }
Exemple #25
0
        /** 加载一个 */
        public void loadOne(int id)
        {
            //-1不加载
            if (id == -1)
            {
                clear();

                _isLoading = false;
                //不返回
                return;
            }

            //相同资源,加载中跳过
            if (_isLoading && _resourceID == id)
            {
                return;
            }

            toClear(false);

            _loadVersion = LoadControl.getVersion();
            int index = ++_index;

            _isLoading = true;

            AssetPoolControl.loadOne(_type, _resourceID = id, () =>
            {
                if (_index == index && LoadControl.getVersion() == _loadVersion)
                {
                    _isLoading = false;

                    releaseCache();

                    _cacheResourceID = id;
                    _cacheObject     = AssetPoolControl.getAsset(_type, id);

                    if (_cacheObject == null)
                    {
                        Ctrl.throwError("获取Asset为空,可能是业务层调用了Destroy", _type, id);
                    }
                    else
                    {
                        if (_completeCall != null)
                        {
                            _completeCall(_cacheObject);
                        }
                    }
                }
            });
        }
Exemple #26
0
    protected virtual void stepLoadFirstResource()
    {
        if (ShineSetting.localLoadWithOutBundle)
        {
            _stepTool.completeStep(LoadFirstResource);
            return;
        }

        //此加载内容暂时不删除
        LoadControl.loadList(MarkResourceConfig.firstLoadList, () =>
        {
            _stepTool.completeStep(LoadFirstResource);
        }, -1, false);
    }
Exemple #27
0
        public override void readValue(LoadControl loadControl, XmlReader xmlReader)
        {
            Type enumType = loadControl.TypeFinder.findType(xmlReader.GetAttribute(TYPE));

            if (enumType != null)
            {
                String name  = xmlReader.GetAttribute(NAME_ENTRY);
                Object value = Enum.Parse(enumType, xmlReader.ReadElementContentAsString());
                loadControl.addValue(name, value, enumType);
            }
            else
            {
                Log.Default.sendMessage("Could not find enum type {0}. Value not loaded.", LogLevel.Warning, "Saving", xmlReader.GetAttribute(TYPE));
            }
        }
Exemple #28
0
    public override void init()
    {
        base.init();

        _wallRoot = GameObject.Find("wall");

        _wall1Rid = LoadControl.getResourceIDByName(GGlobal.source_wall1);
        _wall2Rid = LoadControl.getResourceIDByName(GGlobal.source_wall2);

        //场景显示构造

        _gridConfig = _scene.getMapInfoConfig().grid;

        makeWall();
    }
Exemple #29
0
        /** 清除占用 */
        public void clear()
        {
            if (_resourceID != -1)
            {
                ++_index;

                //版本还对
                if (LoadControl.getVersion() == _loadVersion)
                {
                    LoadControl.unloadOne(_resourceID);
                }

                _resourceID = -1;
            }

            _isLoading = false;
        }
Exemple #30
0
    /// <summary>
    /// 生成刷新配置
    /// </summary>
    protected override void generateRefresh()
    {
        if (_name == null)
        {
            _name = name;
        }
        name = LanguageConfig.getText(_name);

        if (_explain == null)
        {
            _explain = explain;
        }
        explain = LanguageConfig.getText(_explain);

        enableTimeT = new TimeExpression(enableTime);

        iconT = LoadControl.getResourceIDByName(icon);
    }