Exemplo n.º 1
0
        static void PickLanguageCode(string path, ref ExHLanguage language, IndexFile indexFile)
        {
            try
            {
                Console.Clear();
                Console.WriteLine();

                if (string.IsNullOrEmpty(path) || !File.Exists(path))
                {
                    throw new Exception("Specified index file path is incorrect. Please make sure you selected a file first!");
                }

                Dictionary <ExHLanguage, bool> availableLanguages = indexFile.Load(path);
                ExHLanguage[] availableLanguagesArray             = availableLanguages.Keys.ToArray();

                while (true)
                {
                    Console.Clear();
                    Console.WriteLine();

                    Console.ForegroundColor = ConsoleColor.Gray;

                    for (int i = 0; i < availableLanguagesArray.Length; i++)
                    {
                        Console.WriteLine(string.Format("[{0}] - {1}", i.ToString(), availableLanguagesArray[i].ToString()));
                    }

                    Console.Write("Pick the language code: ");
                    string input = Console.ReadLine();

                    if (!int.TryParse(input, out int _input))
                    {
                        continue;
                    }
                    if (_input < 0 || _input >= availableLanguagesArray.Length)
                    {
                        continue;
                    }

                    language = availableLanguagesArray[_input];

                    return;
                }
            }
            catch (Exception e)
            {
                Console.ForegroundColor = ConsoleColor.DarkRed;
                Console.WriteLine(e.Message);
                Console.WriteLine();

                Console.ForegroundColor = ConsoleColor.Gray;
                Console.WriteLine("Press ENTER to go back to the main menu...");
                Console.ReadLine();

                return;
            }
        }
Exemplo n.º 2
0
        public void LoadExH()
        {
            if (Data == null || Data.Length == 0)
            {
                return;
            }

            FixedSizeDataLength = ToUInt16(Data, 0x6, true);
            ushort columnCount = ToUInt16(Data, 0x8, true);

            Variant = ToUInt16(Data, 0x10, true);
            ushort rangeCount = ToUInt16(Data, 0xa, true);
            ushort langCount  = ToUInt16(Data, 0xc, true);

            if (Variant != 1)
            {
                return;
            }

            Columns = new ExHColumn[columnCount];
            for (int i = 0; i < columnCount; i++)
            {
                int columnOffset = 0x20 + i * 0x4;

                Columns[i]        = new ExHColumn();
                Columns[i].Type   = ToUInt16(Data, columnOffset, true);
                Columns[i].Offset = ToUInt16(Data, columnOffset + 0x2, true);
            }
            Columns = Columns.Where(c => c.Type == 0x0).ToArray();

            Ranges = new ExHRange[rangeCount];
            for (int i = 0; i < rangeCount; i++)
            {
                int rangeOffset = (0x20 + columnCount * 0x4) + i * 0x8;

                Ranges[i]        = new ExHRange();
                Ranges[i].Start  = ToUInt32(Data, rangeOffset, true);
                Ranges[i].Length = ToUInt32(Data, rangeOffset + 0x4, true);
            }

            Languages = new ExHLanguage[langCount];
            for (int i = 0; i < langCount; i++)
            {
                int langOffset = ((0x20 + columnCount * 0x4) + rangeCount * 0x8) + i * 0x2;

                Languages[i] = (ExHLanguage)Data[langOffset];
            }
        }