Esempio n. 1
0
        public async Task <ResourceInfo> CreateEmptyResource(string absFolder, string rootFolder, IResourceCreateData createData)
        {
            await EngineNS.Thread.AsyncDummyClass.DummyFunc();

            var result = new ExcelResourceInfo();

            var data   = createData as ExcelCreateData;
            var reName = EngineNS.CEngine.Instance.FileManager._GetRelativePathFromAbsPath(absFolder + "/" + (data.ExcelName.Equals("") ? data.ResourceName : data.ExcelName), EngineNS.CEngine.Instance.FileManager.ProjectContent);

            reName += EngineNS.CEngineDesc.ExcelExtension;
            result.ResourceName = EngineNS.RName.GetRName(reName, data.RNameType);

            ExcelExporter newexport   = new ExcelExporter();
            var           macrossType = EngineNS.Macross.MacrossFactory.Instance.GetMacrossType(data.MacrossName);

            newexport.Init("", macrossType);
            List <Object> lst = new List <Object>();

            //lst.Add( Activator.CreateInstance(data._Type)); //必须要有默认构造函数

            newexport.Objects2Table(lst);
            newexport.Save(result.ResourceName.Address);
            result.MacrossName = data.MacrossName;// + ", " + data._Type.Assembly.FullName;
            return(result);
        }
Esempio n. 2
0
        //public static async Task<MacrossEnumResourceInfo> GetBaseMacrossResourceInfo(Type baseType)
        //{
        //    var macrossDirs = EngineNS.CEngine.Instance.FileManager.GetFiles(EngineNS.CEngine.Instance.FileManager.Content, baseType.Name + EngineNS.CEngineDesc.MacrossEnumExtension + ".rinfo", System.IO.SearchOption.AllDirectories);
        //    if (macrossDirs.Length > 0)
        //    {
        //        var resInfo = await EditorCommon.Resources.ResourceInfoManager.Instance.CreateResourceInfoFromFile(macrossDirs[0], null) as MacrossEnumResourceInfo;
        //        return resInfo;
        //    }
        //    return null;
        //}

        protected override async Task <ResourceInfo> CreateResourceInfoFromResourceOverride(EngineNS.RName resourceName)
        {
            await EngineNS.Thread.AsyncDummyClass.DummyFunc();

            var retValue = new ExcelResourceInfo();

            return(retValue);
        }
        public async Task SetObjectToEdit(ResourceEditorContext context)
        {
            await EngineNS.Thread.AsyncDummyClass.DummyFunc();

            if (context.ResInfo == null)
            {
                return;
            }

            ResourceInfo = context.ResInfo as ExcelResourceInfo;
            if (ResourceInfo == null)
            {
                return;
            }

            //UIPanel.Children.Clear();
            var filename = ResourceInfo.AbsInfoFileName.Replace(".rinfo", "");

            FileName = filename;
            if (System.IO.File.Exists(filename))
            {
                ExcelImporter import = new ExcelImporter();
                import.Init(filename);
                var method = import.GetType().GetMethod("Table2Objects");

                //var assembly = EngineNS.Rtti.RttiHelper.GetAssemblyFromDllFileName(EngineNS.ECSType.Common, EngineNS.CEngine.Instance.FileManager.Bin + "MacrossScript.dll", "", true);
                var assembly = EngineNS.CEngine.Instance.MacrossDataManager.MacrossScripAssembly;// Assembly.LoadFile(EngineNS.CEngine.Instance.FileManager.Bin + "MacrossScript.dll");
                try
                {
                    MacrossName = ResourceInfo.MacrossName;
                    var type = EngineNS.Macross.MacrossFactory.Instance.GetMacrossType(MacrossName);
                    ObjectList = method.MakeGenericMethod(type).Invoke(import, null) as IList;
                    RefreshDatas();
                }
                catch (System.Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.ToString());
                }
            }
            else
            {
                //ClassInfo.AddNode(_ClassType.ClassName, _ClassType);
            }
        }
        public void RecordObject(Object obj, ExcelResourceInfo info)
        {
            if (obj == null)
            {
                return;
            }

            var type = obj.GetType();

            if (DontProcessObject(obj, type))
            {
                return;
            }

            if (DontProcessNameSpace(obj, type))
            {
                return;
            }



            //处理字段集
            FieldInfo[] ActorFields = type.GetFields();

            for (int i = 0; i < ActorFields.Length; i++)
            {
                object value;
                try
                {
                    value = ActorFields[i].GetValue(obj);
                }
                catch (Exception e)

                {
                    value = null;
                }

                if (value == null)
                {
                    continue;
                }

                {
                    //看是否使用宏图文件
                    EngineNS.RName rname = value as EngineNS.RName;
                    if (rname != null)
                    {
                        //Record..
                        info.ReferenceRNameList.Add(rname);
                    }
                }


                Type pp = value.GetType();
                if (IsArray(pp))
                {
                    Type[] args = pp.GetGenericArguments();
                    //Array List
                    if (args.Length == 1 || args.Length == 0)
                    {
                        var tt = (System.Collections.IEnumerable)value;
                        if (tt != null)
                        {
                            foreach (var v in tt)
                            {
                                EngineNS.RName rname = v as EngineNS.RName;
                                if (rname != null)
                                {
                                    //Record..
                                    info.ReferenceRNameList.Add(rname);
                                }
                                else
                                {
                                    RecordObject(v, info);
                                }
                            }
                        }
                    }
                    //Dictionary
                    else if (args.Length == 2)
                    {
                        var tt = (System.Collections.IDictionary)value;
                        if (tt != null)
                        {
                            foreach (var v in tt.Values)
                            {
                                EngineNS.RName rname = v as EngineNS.RName;
                                if (rname != null)
                                {
                                    //Record..
                                    info.ReferenceRNameList.Add(rname);
                                }
                                else
                                {
                                    RecordObject(v, info);
                                }
                            }
                        }
                    }
                }
                else
                {
                    RecordObject(value, info);
                }
            }

            //处理属性集
            PropertyInfo[] ActorProperties = type.GetProperties();
            for (int i = 0; i < ActorProperties.Length; i++)
            {
                object value;
                try
                {
                    value = ActorProperties[i].GetValue(obj);
                }
                catch (Exception e)

                {
                    value = null;
                }

                if (value == null)
                {
                    continue;
                }

                //看是否使用宏图文件
                {
                    EngineNS.RName rname = value as EngineNS.RName;
                    if (rname != null)
                    {
                        //Record..
                        info.ReferenceRNameList.Add(rname);
                    }
                }

                Type pp = value.GetType();
                if (IsArray(pp))
                {
                    Type[] args = pp.GetGenericArguments();
                    //Array List
                    if (args.Length == 1 || args.Length == 0)
                    {
                        var tt = (System.Collections.IEnumerable)value;
                        if (tt != null)
                        {
                            foreach (var v in tt)
                            {
                                EngineNS.RName rname = v as EngineNS.RName;
                                if (rname != null)
                                {
                                    //Record..
                                    info.ReferenceRNameList.Add(rname);
                                }
                                else
                                {
                                    RecordObject(v, info);
                                }
                            }
                        }
                    }
                    //Dictionary
                    else if (args.Length == 2)
                    {
                        var tt = (System.Collections.IDictionary)value;
                        if (tt != null)
                        {
                            foreach (var v in tt.Values)
                            {
                                EngineNS.RName rname = v as EngineNS.RName;
                                if (rname != null)
                                {
                                    //Record..
                                    info.ReferenceRNameList.Add(rname);
                                }
                                else
                                {
                                    RecordObject(v, info);
                                }
                            }
                        }
                    }
                }
                else
                {
                    RecordObject(value, info);
                }
            }
        }