Пример #1
0
 public override void OnOpening()
 {
     foreach (MetaInfo mi in OriginalMeta.ProjFileData)
     {
         string s        = null;
         bool?  undcPath = RelativePathConverter.IsRelativePath(mi.FullName);
         if (undcPath == true)
         {
             s = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(DocPath), mi.FullName));
         }
         else if (undcPath == false)
         {
             s = Path.GetFullPath(mi.FullName);
         }
         if (undcPath != null)
         {
             bool find = false;
             foreach (DocumentData doc in parent)
             {
                 if (s == doc.DocPath && doc is PlainDocumentData plainDocument)
                 {
                     find = true;
                     referencedDoc.Add(plainDocument);
                     plainDocument.parentProj = this;
                     plainDocument.OriginalMeta.RaisePropertyChanged("n");
                     break;
                 }
             }
             if (!find)
             {
                 try
                 {
                     VirtualDoc pdd = new VirtualDoc {
                         DocPath = s
                     };
                     if (!pdd.LoadMeta())
                     {
                         MessageBox.Show(s);
                         DocumentData newDoc = GetNewByExtension(Path.GetExtension(s), -1
                                                                 , Path.GetFileNameWithoutExtension(s), s);
                         TreeNode t = newDoc.CreateNodeFromFile(s);
                         newDoc.TreeNodes.Add(t);
                         t.RaiseCreate(new OnCreateEventArgs()
                         {
                             parent = null
                         });
                         pdd = (newDoc as PlainDocumentData)?.GetVirtualDoc();
                     }
                     referencedDoc.Add(pdd);
                 }
                 catch { }
             }
         }
     }
     foreach (MetaInfo mi in OriginalMeta.ProjFileData)
     {
     }
 }
Пример #2
0
        internal override void GatherCompileInfo(App mainAppWithInfo)
        {
            ProjectProcess c;

            c = new ProjectProcess();
            if (!CompileProcess.CanOperate(mainAppWithInfo.TempPath))
            {
                string tempPath = Path.GetFullPath(Path.Combine(Path.GetTempPath(), "LuaSTG Editor/"));
                if (!Directory.Exists(tempPath))
                {
                    Directory.CreateDirectory(tempPath);
                }
                c.currentTempPath = tempPath;
            }
            else
            {
                c.currentTempPath = mainAppWithInfo.TempPath;
            }
            CompileProcess = c;

            c.projLuaPath = c.currentTempPath + "_editor_output.lua";

            c.source          = this;
            c.rootLuaPath     = c.currentTempPath + "root.lua";
            c.rootZipPackPath = c.currentTempPath + "pack.bat";

            c.projPath = "";
            if (!string.IsNullOrEmpty(DocPath))
            {
                c.projPath = Path.GetDirectoryName(DocPath);
            }

            c.projMetaPath = DocPath + ".meta";

            c.rootCode = "Include\'THlib.lua\'\nInclude\'_editor_output.lua\'";

            c.zipExePath    = mainAppWithInfo.ZipExecutablePath;
            c.luaSTGExePath = mainAppWithInfo.LuaSTGExecutablePath;

            if (!mainAppWithInfo.IsEXEPathSet)
            {
                throw new EXEPathNotSetException();
            }

            c.projName = Path.GetFileNameWithoutExtension(RawDocName);

            //Find mod name
            foreach (TreeNode t in TreeNodes[0].Children)
            {
                if (t is ProjSettings)
                {
                    if (!string.IsNullOrEmpty(t.attributes[0].AttrInput))
                    {
                        c.projName = t.attributes[0].AttrInput;
                    }
                    break;
                }
            }

            c.luaSTGFolder  = Path.GetDirectoryName(c.luaSTGExePath);
            c.targetZipPath = c.luaSTGFolder + "\\mod\\" + c.projName + ".zip";

            foreach (IDocumentWithMeta idwm in referencedDoc)
            {
                if (idwm is PlainDocumentData pdd)
                {
                    pdd.GatherCompileInfo(mainAppWithInfo);
                    c.fileProcess.Add(pdd.CompileProcess as PartialProjectProcess);
                    //MessageBox.Show(pdd.CompileProcess.GetType().ToString());
                }
                else if (idwm is VirtualDoc vd)
                {
                    string s = vd.DocPath;
                    //try
                    {
                        DocumentData newDoc = GetNewByExtension(Path.GetExtension(s), -1
                                                                , Path.GetFileNameWithoutExtension(s), s, true);
                        TreeNode t = newDoc.CreateNodeFromFile(s);
                        newDoc.TreeNodes.Add(t);
                        (newDoc as PlainDocumentData).parentProj = this;
                        newDoc.GatherCompileInfo(mainAppWithInfo);
                        c.fileProcess.Add(newDoc.CompileProcess as PartialProjectProcess);
                        //MessageBox.Show(newDoc.CompileProcess.GetType().ToString());
                    }
                    //catch { }
                }
            }
        }