Esempio n. 1
0
        /// <summary>
        /// Repopulates the plan list with the plan files that are listed in the world REQ and mode MRQs.
        /// </summary>
        private void PopulatePlanList()
        {
            try
            {
                worldPlans.Clear();

                // Get the existing pln files that are listed in the world req and merge the returned dictionary with the worldPlans dictionary
                ReqChunk basePlnChunk = ReqParser.ParseChunk(worldReqFilePath, "congraph");

                var resolvedBasePlanFiles = basePlnChunk.ResolveContentsAsFiles(worldDirectory, ".pln", true);
                resolvedBasePlanFiles.ToList().ForEach(x => worldPlans[x.Key] = x.Value);

                // Get a list of all the existing pln files in each game mode mrq
                foreach (string modeFilePath in worldModes.Values)
                {
                    if (modeFilePath != DROPDOWN_MODES_BASE)
                    {
                        ReqChunk modePlnChunk = ReqParser.ParseChunk(modeFilePath, "congraph");

                        // Get the mrq's existing pln files and merge the returned dictionary with the worldPlans dictionary
                        var resolvedModePlanFiles = modePlnChunk.ResolveContentsAsFiles(worldDirectory, ".pln", true);
                        resolvedModePlanFiles.ToList().ForEach(x => worldPlans[x.Key] = x.Value);
                    }
                }

                // Add the pln files to the dropdown
                dd_PlanFile.Items.Clear();
                dd_PlanFile.Items.AddRange(worldPlans.Keys.ToArray());
            }
            catch (ArgumentNullException ex)
            {
                Trace.WriteLine(ex.Message);
                throw;
            }
            catch (FileNotFoundException ex)
            {
                Trace.WriteLine(ex.Message);
                throw;
            }
            catch (IOException ex)
            {
                Trace.WriteLine(ex.Message);
                throw;
            }
            catch (OutOfMemoryException ex)
            {
                Trace.WriteLine(ex.Message);
                throw;
            }

            ResetSelectedPlan();
        }
Esempio n. 2
0
        /// <summary>
        /// Returns a list of file paths for files of the specified extensions from the specified world REQ file and mode MRQ.
        /// </summary>
        /// <param name="reqFile">Path of REQ file to parse.</param>
        /// <param name="mrqFile">Path of MRQ file to parse.</param>
        /// <param name="extensions">Array of file extensions to check for. (ex: ".rgn")</param>
        /// <returns></returns>
        private List <string> GetWorldChunkFilePaths(string reqFile, string mrqFile, string[] extensions)
        {
            List <string> filePaths = new List <string>();
            bool          mrq       = (mrqFile != "" && mrqFile != DROPDOWN_MODES_BASE);

            try
            {
                // Retrieve the "world" REQN chunks
                ReqChunk baseWorldChunk = ReqParser.ParseChunk(reqFile, "world");
                ReqChunk modeWorldChunk = new ReqChunk();
                if (mrq)
                {
                    modeWorldChunk = ReqParser.ParseChunk(mrqFile, "world");
                }

                // Resolve the file paths for each extension
                foreach (string extension in extensions)
                {
                    filePaths.AddRange(baseWorldChunk.ResolveContentsAsFiles(worldDirectory, extension).Values);
                    if (mrq)
                    {
                        filePaths.AddRange(modeWorldChunk.ResolveContentsAsFiles(worldDirectory, extension).Values);
                    }
                }
            }
            catch (FileNotFoundException ex)
            {
                Trace.WriteLine(ex.Message);
                throw;
            }
            catch (IOException ex)
            {
                Trace.WriteLine(ex.Message);
                throw;
            }
            catch (OutOfMemoryException ex)
            {
                Trace.WriteLine(ex.Message);
                throw;
            }

            return(filePaths);
        }
Esempio n. 3
0
        /// <summary>
        /// Repopulates the mode list with the modes that are listed in world REQ.
        /// </summary>
        private void PopulateModeList()
        {
            try
            {
                try
                {
                    ReqChunk reqChunk = ReqParser.ParseChunk(worldReqFilePath, "lvl");
                    // Add the "[Base]" mode to the list
                    worldModes.Clear();
                    worldModes.Add(DROPDOWN_MODES_BASE, DROPDOWN_MODES_BASE);

                    // Get the existing mrq files and merge the returned dictionary with the worldModes dictionary
                    var resolvedFiles = reqChunk.ResolveContentsAsFiles(worldDirectory, ".mrq", true);
                    resolvedFiles.ToList().ForEach(x => worldModes[x.Key] = x.Value);

                    // Add the modes to the dropdown
                    dd_ModeMrq.Items.Clear();
                    dd_ModeMrq.Items.AddRange(worldModes.Keys.ToArray());
                }
                catch (FileNotFoundException ex)
                {
                    Trace.WriteLine(ex.Message);
                    throw;
                }
                catch (IOException ex)
                {
                    Trace.WriteLine(ex.Message);
                    throw;
                }
                catch (OutOfMemoryException ex)
                {
                    Trace.WriteLine(ex.Message);
                    throw;
                }
            }
            catch (ArgumentNullException ex)
            {
                Trace.WriteLine(ex.Message);
                throw;
            }

            ResetSelectedMode();
        }