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); }
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); }
private void btnAddFile_Click(object sender, EventArgs e) { string fileName = textBoxName.Text; string path = fileName; if (File.Exists(fileName)) { path = string.Format("{0}\\{1}", _filter.GetFilterDirectory(), Path.GetFileName(fileName)); QCParser importedQC = new QCParser(fileName); if (!importedQC.ImportDependenciesToPath(string.Format("{0}\\{1}", ProjectUtils.GetProjectDirectory(), Path.GetDirectoryName(path)))) { try { File.Copy(fileName, string.Format("{0}\\{1}", ProjectUtils.GetProjectDirectory(), path), true); } catch { LoggingUtils.LogEvent("Failed to import a file!"); } } } else { if (!Globals.IsStringValid(fileName)) { return; } path = string.Format("{0}\\{1}", _filter.GetFilterDirectory(), fileName); } if (!fileName.EndsWith(".qc", StringComparison.InvariantCultureIgnoreCase) && !fileName.EndsWith(".qci", StringComparison.InvariantCultureIgnoreCase)) { InfoDialog.ShowDialog(this, "Invalid file extension!", "Error!"); return; } string hasFile = ProjectUtils.GetFilePathForTreeNodeItem(_filter.GetName(), Path.GetFileName(path)); if (!string.IsNullOrEmpty(hasFile)) { InfoDialog.ShowDialog(this, "This file already exists in the choosen filter!", "Error!"); return; } string fullPath = string.Format("{0}\\{1}", ProjectUtils.GetProjectDirectory(), path); if (!File.Exists(fullPath)) { Directory.CreateDirectory(Path.GetDirectoryName(fullPath)); File.WriteAllText(fullPath, ""); } _filter.AddFile("local", path); TreeNode newNode = new TreeNode(Path.GetFileName(path)); newNode.ContextMenuStrip = _fileStrip; newNode.ImageIndex = newNode.SelectedImageIndex = newNode.StateImageIndex = 0; _node.Nodes.Add(newNode); _node.ExpandAll(); Close(); }