public static void AddToQueue(string path) { if (!CanCompile() || !File.Exists(path)) { return; } FileInfo fileInfo = new FileInfo(path); if (fileInfo.Extension != ".qc") { return; } int count = _compileList.Count(); _compileList.Add(path); if (count <= 0) { _compileArgs = Globals.compileArguments.Text; Globals.compileLog.Text = null; _currentItemInList = 0; _m_bIsCompiling = true; WindowHandler.SaveOpenedFiles(); SharedEvents.StartCompile(); ProcessQCFile(); } }
public static bool StopCompile() { if (!_m_bIsCompiling) { return(false); } _compileList.Clear(); bool bFound = false; for (int i = 0; i < Process.GetProcesses().Length; i++) { Process proc = Process.GetProcesses()[i]; if (proc.ProcessName == "studiomdl") { proc.Kill(); bFound = true; } } if (bFound) { LoggingUtils.LogEvent("Canceled a model compilation."); _m_bIsCompiling = false; SharedEvents.StopCompile(); Globals.compileLog.Text = null; } return(bFound); }
public static bool CreateProject(string name, string path, string gameinfoPath, string studiomodelPath) { if (!Globals.IsStringValid(name) || !Globals.IsPathValid(path)) { LoggingUtils.LogEvent("Failed to create a new project due to a faulty project name or path!"); return(false); } // Is there a project up already? if (!string.IsNullOrEmpty(_pszActiveProjectPath)) { CloseProject(); } // Set the new active project properties. _pszActiveProjectPath = string.Format("{0}\\{1}\\{1}.qcs", path, name); _pszGameInfoPath = gameinfoPath; _pszStudioModelPath = studiomodelPath; _projectName = name; _projectFilters = new Filter(_projectName); CreateEnvironment(); SharedEvents.CreatedNewProject(); // Create the default .qcs file, then write to it. return(SaveProject()); }
public static bool SaveProject() { if (string.IsNullOrEmpty(_pszActiveProjectPath)) { return(false); } if (!IsProjectLoaded()) { return(false); } // We re-create the file here - we need to store the structure of the project such as the .QC's you have and under which folders and stuff. using (StreamWriter writer = new StreamWriter(_pszActiveProjectPath)) { writer.WriteLine(string.Format("\"{0}\"", _projectName)); writer.WriteLine("{"); writer.WriteLine(" \"GameInfoPath\" \"{0}\"", _pszGameInfoPath); writer.WriteLine(" \"StudioModelPath\" \"{0}\"", _pszStudioModelPath); writer.WriteLine(""); _projectFilters.SaveFilters(writer); writer.WriteLine("}"); } SharedEvents.SavedProject(); return(true); }
public static void CloseProject() { if (!IsProjectLoaded()) { return; } // We want to close our project, what do we do?: // Close all windows associated to the project, // Auto Save the current stuff, // Cancel any in-action process such as compiling. if (CompilerUtils.IsCompiling()) { CompilerUtils.StopCompile(); } SaveProject(); WindowHandler.CloseAllWindows(); _projectFilters.Dispose(); _projectFilters = null; SharedEvents.ClosedProject(); _pszActiveProjectPath = null; Globals.compileLog.Text = null; }
public static void ProcessQCFile() { if (_currentItemInList >= _compileList.Count()) { _compileList.Clear(); _m_bIsCompiling = false; SharedEvents.CompileFinished(); return; } string path = _compileList[_currentItemInList]; _currentItemInList++; CompileThread compileQC = new CompileThread(path); Thread compThread = new Thread(new ThreadStart(compileQC.Compile)); compThread.Start(); }
public static bool OpenProject(string path) { // Is there a project up already? if (!string.IsNullOrEmpty(_pszActiveProjectPath)) { CloseProject(); } Properties.Settings.Default.lastProjectPath = Path.GetDirectoryName(path); Properties.Settings.Default.Save(); _pszActiveProjectPath = path; CreateEnvironment(); bool bLoaded = false; KeyValues pkvProjectFile = new KeyValues(); if (pkvProjectFile.LoadFromFile(_pszActiveProjectPath)) { bLoaded = true; _projectName = pkvProjectFile.GetName(); _pszGameInfoPath = pkvProjectFile.GetString("GameInfoPath"); _pszStudioModelPath = pkvProjectFile.GetString("StudioModelPath"); KeyValues pkvFileData = pkvProjectFile.FindSubKey("Files"); if (pkvFileData != null) { _projectFilters = new Filter(_projectName); IterateFileData(_projectFilters, pkvFileData); } } pkvProjectFile.Dispose(); pkvProjectFile = null; SharedEvents.OpenedProject(); return(bLoaded); }