Exemplo n.º 1
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 { }
                }
            }
        }