Esempio n. 1
0
        public bool RemoveFilter(string filter, bool bDelete = false)
        {
            Filter filterToRemove = FindFilterByName(this, filter);
            if (filterToRemove == null)
                return false;

            string directoryToRemove = string.Format("{0}\\{1}", ProjectUtils.GetProjectDirectory(), filterToRemove.GetFilterDirectory());
            filterToRemove.RemoveFiles(bDelete);

            try
            {
                Directory.Delete(directoryToRemove);
            }
            catch
            {
                LoggingUtils.LogEvent("Unable to delete directory!");
            }

            Filter parentFilter = filterToRemove.GetParent();
            if (parentFilter == null)
                return true;

            parentFilter.RemoveFilter(filterToRemove);
            return true;
        }
Esempio n. 2
0
        public void Compile()
        {
            string _args     = CompilerUtils._compileArgs;
            string arguments = string.Format("-game \"{0}\" \"{1}\"", ProjectUtils.GetGameInfoPath(), _path);

            if (!string.IsNullOrEmpty(_args))
            {
                arguments = string.Format("-game \"{0}\" {1} \"{2}\"", ProjectUtils.GetGameInfoPath(), _args, _path);
            }

            Process procLaunchStudioMdl = new Process();

            procLaunchStudioMdl.StartInfo.Arguments              = arguments;
            procLaunchStudioMdl.StartInfo.CreateNoWindow         = true;
            procLaunchStudioMdl.StartInfo.FileName               = CompilerUtils.GetStudioMdlPath();
            procLaunchStudioMdl.StartInfo.UseShellExecute        = false;
            procLaunchStudioMdl.StartInfo.WindowStyle            = ProcessWindowStyle.Hidden;
            procLaunchStudioMdl.StartInfo.RedirectStandardOutput = true;
            procLaunchStudioMdl.Start();

            while (!procLaunchStudioMdl.StandardOutput.EndOfStream && CompilerUtils.IsCompiling())
            {
                string line = procLaunchStudioMdl.StandardOutput.ReadLine();

                Globals.compileLog.Invoke(new Action(() => Globals.compileLog.Text += (line + Environment.NewLine)));
                _log += (line + Environment.NewLine);
            }

            LoggingUtils.CreateCompileLog(_mdlName, _log, _directoryStructure);
            CompilerUtils.ProcessQCFile();
        }
Esempio n. 3
0
        public static bool SaveOpenedFiles()
        {
            if (contextWindowMenu == null)
            {
                return(false);
            }

            if (!contextWindowMenu.Visible)
            {
                return(false);
            }

            foreach (TabPage page in contextWindowMenu.GetTabControl().TabPages)
            {
                string pathToFile = ProjectUtils.GetFilePathForTreeNodeItem(page.Name, page.Text);
                if (File.Exists(pathToFile))
                {
                    RichQCEditor textBox = contextWindowMenu.GetTextBoxFromTab(page);
                    if (textBox != null)
                    {
                        File.WriteAllText(pathToFile, textBox.Text, Encoding.ASCII);
                    }
                }
            }

            return(true);
        }
Esempio n. 4
0
        public void AddFile(string pathType, string path)
        {
            string fullPath = path;
            if (pathType != "path")
                fullPath = string.Format("{0}\\{1}", ProjectUtils.GetProjectDirectory(), path);

            _files.Add(new FilterInfo(fullPath, path, pathType));
        }
Esempio n. 5
0
        public static string GetStudioMdlPath()
        {
            if (ProjectUtils.IsProjectLoaded())
            {
                return(string.Format("{0}\\studiomdl.exe", ProjectUtils.GetStudioModelPath()));
            }

            return(null);
        }
Esempio n. 6
0
        public string GetFilterDirectory()
        {
            if (GetName() == ProjectUtils.GetProjectName())
                return "src";

            string folder = string.Format("{0}\\{1}", GetFilterDirectory(GetParent()), GetName());
            folder = folder.Replace(string.Format("{0}\\", ProjectUtils.GetProjectName()), "");

            return folder;
        }
Esempio n. 7
0
        public static string GetImportPath()
        {
            string path = Properties.Settings.Default.lastImportPath;

            if (string.IsNullOrEmpty(path))
            {
                return(ProjectUtils.GetProjectDirectory());
            }

            return(path);
        }
Esempio n. 8
0
        public static string GetVMTPath()
        {
            string path = Properties.Settings.Default.lastVMTPath;

            if (string.IsNullOrEmpty(path) && ProjectUtils.IsProjectLoaded())
            {
                return(ProjectUtils.GetGameInfoPath());
            }

            return(path);
        }
Esempio n. 9
0
        public static bool CreateCompileLog(string mdlName, string log, string directoryStructure)
        {
            if (!ProjectUtils.IsProjectLoaded())
            {
                return(false);
            }

            string logFile = string.Format("{0}\\logs{1}\\{2}.txt", ProjectUtils.GetProjectDirectory(), directoryStructure, Path.GetFileNameWithoutExtension(mdlName));

            Directory.CreateDirectory(Path.GetDirectoryName(logFile));
            File.WriteAllText(logFile, log);
            return(true);
        }
Esempio n. 10
0
        public void SaveFilters(Filter sub, StreamWriter writer, string extraSpace = "")
        {
            extraSpace += "    ";
            string fileSpace = extraSpace + "    ";
            string filterName = sub.GetName();
            if (filterName == ProjectUtils.GetProjectName())
                filterName = "Files";

            writer.WriteLine(string.Format("{0}\"{1}\"", extraSpace, filterName));
            writer.WriteLine(string.Format("{0}", extraSpace) + "{");

            for (int i = 0; i < sub.GetFiles().Count(); i++)
                writer.WriteLine(string.Format("{0}\"{1}\" \"{2}\"", fileSpace, sub.GetFiles()[i].GetPathType(), sub.GetFiles()[i].GetLocalPath()));

            for (int i = 0; i < sub.GetSubFilters().Count(); i++)
                SaveFilters(sub.GetSubFilters()[i], writer, extraSpace);

             writer.WriteLine(string.Format("{0}", extraSpace) + "}");
        }
Esempio n. 11
0
        public static bool OpenModelInHLMV(string path)
        {
            if (string.IsNullOrEmpty(path) || !ProjectUtils.IsProjectLoaded())
            {
                return(false);
            }

            if (!File.Exists(path))
            {
                return(false);
            }

            QCParser qcInfo = new QCParser(path);

            if (qcInfo.ParseQCFile())
            {
                string modelPath = string.Format("{0}\\models\\{1}", ProjectUtils.GetGameInfoPath(), qcInfo.GetQCParamValue("$modelname"));
                if (File.Exists(modelPath))
                {
                    string hlmv = string.Format("{0}\\hlmv.exe", ProjectUtils.GetStudioModelPath());
                    if (File.Exists(hlmv))
                    {
                        using (Process procLaunchHLMV = new Process())
                        {
                            procLaunchHLMV.StartInfo.Arguments              = string.Format("-game \"{0}\" \"{1}\"", ProjectUtils.GetGameInfoPath(), modelPath);
                            procLaunchHLMV.StartInfo.CreateNoWindow         = true;
                            procLaunchHLMV.StartInfo.FileName               = hlmv;
                            procLaunchHLMV.StartInfo.UseShellExecute        = false;
                            procLaunchHLMV.StartInfo.WindowStyle            = ProcessWindowStyle.Hidden;
                            procLaunchHLMV.StartInfo.RedirectStandardOutput = true;
                            procLaunchHLMV.Start();
                        }
                        return(true);
                    }
                }
            }

            return(false);
        }
Esempio n. 12
0
        public CompileThread(string path)
        {
            _path               = path;
            _log                = null;
            _mdlName            = "";
            _directoryStructure = (Path.GetDirectoryName(path).Replace(ProjectUtils.GetProjectDirectory(), ""));

            string   content = "";
            QCParser qcFile  = new QCParser(_path);

            if (qcFile.ParseQCFile())
            {
                content  = qcFile.GetQCContent();
                _mdlName = qcFile.GetQCParamValue("$modelname");
                if (string.IsNullOrEmpty(_mdlName))
                {
                    _mdlName = Path.GetFileName(path);
                }
            }

            _path = string.Format("{0}\\temp\\compile.qc", ProjectUtils.GetProjectDirectory());
            File.WriteAllText(_path, content);
        }