示例#1
0
        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);
        }