public static void GetXMLString(ref string xmlStr, XmlHolder node) { unsafe { var str = XmlSDK.RapidXmlA_GetStringFromXML(node.CoreObject); xmlStr = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(str); XmlSDK.RapidXmlA_FreeString(str); } }
public static void SaveXML(System.String file, XmlHolder node, bool bClearStrPtr = true) { // 计算绝对路径 var fileName = CEngine.Instance.FileManager._GetAbsPathFromRelativePath(file); unsafe { XmlSDK.RapidXmlA_SaveXML(node.CoreObject, fileName); } }
public static XmlHolder NewXMLHolder(System.String name, System.String value) { unsafe { var xmlHolder = new XmlHolder(); xmlHolder.mCoreObject = XmlSDK.RapidXmlA_NewXmlHolder(); var root = XmlSDK.RapidXmlNodeA_allocate_node(xmlHolder.CoreObject, name, ""); XmlSDK.RapidXmlA_append_node(xmlHolder.CoreObject, root); return(xmlHolder); } }
public static XmlHolder ParseXML(System.String xmlString) { var pHolder = XmlSDK.RapidXmlA_ParseXML(xmlString); if (pHolder.Pointer == IntPtr.Zero) { return(null); } var xmlHolder = new XmlHolder(); xmlHolder.mCoreObject = pHolder; return(xmlHolder); }
public void AddProjectXMLNode(string value) { if (ProjectXML == null) { string projectpath = EngineNS.CEngine.Instance.FileManager.ProjectSourceRoot + "Batman.Droid/"; ProjectXML = EngineNS.IO.XmlHolder.LoadXML(projectpath + "Batman.Droid.csproj"); CorrectProjectCatalogue(ProjectXML.RootNode); } EngineNS.IO.XmlNode ItemGroupNode = ProjectXML.RootNode.AddNode("ItemGroup", "", ProjectXML); EngineNS.IO.XmlNode AndroidAssetNode = ItemGroupNode.AddNode("AndroidAsset", "", ProjectXML); //test value = value.Replace("/", "\\"); AndroidAssetNode.AddAttrib("Include", value); }
public static XmlHolder LoadXML(System.String file) { unsafe { // 计算绝对路径 file = CEngine.Instance.FileManager._GetAbsPathFromRelativePath(file); //IntPtr strPtr = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(file); //file = file.ToLower(); var pHolder = XmlSDK.RapidXml_LoadFileA(file); if (pHolder.Pointer == IntPtr.Zero) { return(null); } var holder = new XmlHolder(); holder.mCoreObject = pHolder; return(holder); } }
public XmlNode AddNode(string name, string value, XmlHolder holder) { unsafe { if (CoreObject.Pointer == IntPtr.Zero) { return(null); } var node = XmlSDK.RapidXmlNodeA_allocate_node(holder.CoreObject, name, value); XmlSDK.RapidXmlNodeA_append_node(CoreObject, node); var result = new XmlNode(node); if (holder == null) { result.mHolder = mHolder; } else { result.mHolder = holder; } return(result); } }
static async System.Threading.Tasks.Task RealMain(CMDEngine cmdEngine, string[] args) { await EngineNS.CEngine.Instance.InitSystem(IntPtr.Zero, 0, 0, EngineNS.ERHIType.RHT_VirtualDevice, true); await EngineNS.CEngine.Instance.OnEngineInited(); CIPlatform.Instance.PlayMode = CIPlatform.enPlayMode.Cook; switch (args[0].ToLower()) { case "pack": { var src = FindArgument(args, "src=").Substring("src=".Length); if (src == null) { return; } var tar = FindArgument(args, "tar=").Substring("tar=".Length); if (tar == null) { return; } AssetsPacker.PackAList(src, tar); var pak = new EngineNS.IO.CPakFile(); pak.LoadPak(tar); for (UInt32 i = 0; i < pak.AssetNum; i++) { var name = pak.GetAssetName(i); var sz = pak.GetAssetSize(i); var szip = pak.GetAssetSizeInPak(i); } cmdEngine.IsRun = false; } break; case "unpack": { } break; case "cook": { var entry = FindArgument(args, "entry=").Substring("entry=".Length); var rn = EngineNS.RName.GetRName(entry); var platformStr = FindArgument(args, "platform=").Substring("platform=".Length); var platforms = platformStr.Split('+'); var copyRInfo = FindArgument(args, "copyrinfo"); EngineNS.IO.XmlHolder AssetInfos = EngineNS.IO.XmlHolder.NewXMLHolder("AssetsPackage", ""); //For andorid string[] sm = null; var smStr = FindArgument(args, "shadermodel="); if (smStr != null) { sm = smStr.Substring("shadermodel=".Length).Split('+'); } if (FindArgument(args, "genvsproj") != null) { CMDEngine.CMDEngineInstance.IsNeedProject = true; } var texEncoder = FindArgument(args, "texencoder="); if (texEncoder != null) { ResourceCooker.TexCompressFlags = 0; var texFormats = texEncoder.Substring("texencoder=".Length).Split('+'); if (FindArgument(texFormats, "PNG") != null) { ResourceCooker.TexCompressFlags |= ResourceCooker.ETexCompressMode.PNG; } if (FindArgument(texFormats, "ETC2") != null) { ResourceCooker.TexCompressFlags |= ResourceCooker.ETexCompressMode.ETC2; } if (FindArgument(texFormats, "ASTC") != null) { ResourceCooker.TexCompressFlags |= ResourceCooker.ETexCompressMode.ASTC; } } var pakAssets = FindArgument(args, "pak="); if (pakAssets != null) { pakAssets = pakAssets.Substring("pak=".Length); } try { foreach (var i in platforms) { CEngine.Instance.FileManager.CookingPlatform = i; var cooker = new AssetCooker(); await cooker.CollectAssets(rn, i, copyRInfo != null?true : false, sm); await CookPlatformShader(args, i, sm, cooker.MaterialAssets); cooker.DirectCopyFiles(i); CMDEngine.CMDEngineInstance.SaveAssetinfos(i); if (pakAssets != null) { var listFileName = CEngine.Instance.FileManager.Cooked + CEngine.Instance.FileManager.CookingPlatform + "/tmp_pakassets.alist"; using (System.IO.StreamWriter sw = new System.IO.StreamWriter(listFileName)) { var files = CEngine.Instance.FileManager.GetFiles(CEngine.Instance.FileManager.CookingRoot, "*.*", System.IO.SearchOption.AllDirectories); foreach (var j in files) { var absName = j.ToLower(); bool error = false; absName = CEngine.Instance.FileManager.NormalizePath(absName, out error); if (absName.EndsWith(".rinfo")) { continue; } if (absName.EndsWith(".cs")) { continue; } if (absName.EndsWith(".noused")) { continue; } var NameInPak = absName.Substring(CEngine.Instance.FileManager.CookingRoot.Length); sw.WriteLine($"{absName} {NameInPak} normal"); } } AssetsPacker.PackAList(listFileName, pakAssets); } } } catch (Exception ex) { EngineNS.Profiler.Log.WriteException(ex); } finally { cmdEngine.IsRun = false; } } break; case "bake": { } break; case "localhost": { } break; case "gen_proj": { if (args.Length != 2) { return; } GenProject.Instance.Command(args); cmdEngine.IsRun = false; } break; case "fresh_rinfo": { var subdir = FindArgument(args, "dir=").Substring("dir=".Length); var types = FindArgument(args, "type=").Substring("type=".Length); var resTypes = types.Split('+'); var nouse = cmdEngine.FreshRInfo(subdir, resTypes); cmdEngine.IsRun = false; } break; case "rname_change": { Dictionary <string, string> changeList = new Dictionary <string, string>(); var name = FindArgument(args, "name="); if (name != null) { name = name.Substring("name=".Length); var seg = name.Split('+'); foreach (var i in seg) { var rnPair = i.Split('#'); if (rnPair.Length != 2) { EngineNS.Profiler.Log.WriteLine(EngineNS.Profiler.ELogTag.Warning, "RName", $"rename resource arguments error:{i}"); continue; } var rn = RName.GetRName(rnPair[0]); if (CEngine.Instance.FileManager.FileExists(rn.Address)) { var rnModifier = new RNameModifier(); rnModifier.CollectRefObjects(rn); await rnModifier.SaveRefObjects(rn, rnPair[1]); changeList[rnPair[0]] = rnPair[1]; } else { EngineNS.Profiler.Log.WriteLine(EngineNS.Profiler.ELogTag.Warning, "RName", $"rename resource doesn't exist:{i}"); } } } //移动目录 var dir = FindArgument(args, "dir="); if (dir != null) { dir = dir.Replace('&', ' '); dir = dir.Substring("dir=".Length); var seg = dir.Split('#'); if (seg.Length != 2) { EngineNS.Profiler.Log.WriteLine(EngineNS.Profiler.ELogTag.Warning, "RName", $"rename directory:{dir}"); } else { var src = seg[0].ToLower(); var tar = seg[1].ToLower(); var files = CEngine.Instance.FileManager.GetFiles(EngineNS.CEngine.Instance.FileManager.ProjectContent + src, "*.rinfo", System.IO.SearchOption.AllDirectories); foreach (var i in files) { bool error; var sf = EngineNS.CEngine.Instance.FileManager.NormalizePath(i, out error); sf = sf.Substring(EngineNS.CEngine.Instance.FileManager.ProjectContent.Length); sf = sf.Substring(0, sf.Length - ".rinfo".Length); var rn = EngineNS.RName.GetRName(sf); var sf2 = sf.Substring(src.Length); sf2 = tar + sf2; if (CEngine.Instance.FileManager.FileExists(rn.Address)) { var rnModifier = new RNameModifier(); rnModifier.CollectRefObjects(rn); await rnModifier.SaveRefObjects(rn, sf2); changeList[sf] = sf2; } } } } foreach (var i in changeList) { CEngine.Instance.FileManager.RNameRemap[i.Key] = i.Value; } var map = FindArgument(args, "savemap="); if (map != null) { map = map.Substring("savemap=".Length); var seg = map.Split('+'); foreach (var i in seg) { var rn = RName.GetRName(i); EngineNS.GamePlay.GWorld World = new EngineNS.GamePlay.GWorld(); World.Init(); var scene = await EngineNS.GamePlay.GGameInstance.LoadScene(CEngine.Instance.RenderContext, World, rn); if (scene != null) { EngineNS.Vector3 pos = new EngineNS.Vector3(0, -10, 0); EngineNS.Vector3 lookAt = new EngineNS.Vector3(0, 0, 0); EngineNS.Vector3 up = new EngineNS.Vector3(0, 1, 0); { var xnd = await EngineNS.IO.XndHolder.LoadXND(rn.Address + "/scene.map"); if (xnd != null) { var att = xnd.Node.FindAttrib("ED_info"); if (att != null) { att.BeginRead(); att.Read(out pos); att.Read(out lookAt); att.Read(out up); att.EndRead(); } xnd.Dispose(); } } await scene.SaveScene(rn, null, (InScene, InXnd) => { var att = InXnd.Node.AddAttrib("ED_info"); att.BeginWrite(); att.Write(pos); att.Write(lookAt); att.Write(up); att.EndWrite(); }); } } } cmdEngine.IsRun = false; } break; default: break; } }