예제 #1
0
        /// <summary>
        /// Load all the hue names
        /// </summary>
        /// <param name="huesCSV">file CSV containing the hues data</param>
        /// <param name="fullName">UOP file name</param>
        private void LoadHueNames(MythicPackageFile huesCSV, string fullName)
        {
            // load the file memory stream data (we read it like a text file)
            using (StreamReader reader = new StreamReader(new MemoryStream(huesCSV.Unpack(fullName)), Encoding.ASCII))
            {
                // initialize the text lines
                string line;

                // keep reading until the end of the file
                while ((line = reader.ReadLine()) != null)
                {
                    // line that starts with # are comments
                    if (!line.StartsWith("#"))
                    {
                        // get the ID, name from the line
                        string[] data = line.Split(',');

                        // get the hue ID
                        int hueID = int.Parse(data[0]);

                        // store the value into the dictionary
                        HueNames.Add(hueID, data.Length < 2 ? hueID == 1 ? "Default" : "" : hueID == 1 ? "Default" : data[1]);
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Load all the hues
        /// </summary>
        private void FillHuesTable()
        {
            // load the hues.uop file
            MythicPackage UOP = new MythicPackage(Path.Combine(GamePath, "Hues.uop"));

            // load the hue names
            LoadHueNames(UOP.Blocks[UOP.Blocks.Count - 1].Files[UOP.Blocks[UOP.Blocks.Count - 1].Files.Count - 1], UOP.FileInfo.FullName);

            // hue index
            int fileID = 0;

            // scan all the blocks
            for (int block = 0; block < UOP.Blocks.Count; block++)
            {
                // current block
                MythicPackageBlock blk = UOP.Blocks[block];

                // scan all the files
                for (int file = 0; file < blk.Files.Count; file++)
                {
                    // the first 2 files of the first block are NOT hues, the last file of the last block is the csv with the hue names.
                    if ((block == 0 && file <= 1) || (block == UOP.Blocks.Count - 1 && file == blk.Files.Count - 1))
                    {
                        continue;
                    }

                    // current file
                    MythicPackageFile fil = blk.Files[file];

                    // load the file memory stream data
                    MemoryStream stream = new MemoryStream(fil.Unpack(UOP.FileInfo.FullName));

                    // load the colors diagram for the hue
                    Bitmap cd = new Bitmap(stream);

                    // add the hue to the list (if we have the colors diagram)
                    if (cd != null)
                    {
                        m_Hues.Add(new Hue(fileID, HueNames[fileID + 1], new Bitmap(stream)));
                    }

                    // increase the hue ID
                    fileID++;
                }
            }
        }