Esempio n. 1
0
 public void Copy(FFXIATPhrase from)
 {
     this.StringResource = from.StringResource;
     this.Language = from.Language;
     this.GroupID = from.GroupID;
     this.MessageID = from.MessageID;
     this.value = from.value;
     this.shortvalue = from.shortvalue;
     this.BaseType = from.BaseType;
     this.Type = from.Type;
     this.ActualType = from.ActualType;
     this.Flags = from.Flags;
 }
Esempio n. 2
0
        public FFXIATPhrase[] GetPhraseViaRegEx(string pattern, bool shownum)
        {
            List<FFXIATPhrase> ret = new List<FFXIATPhrase>();

            if ((pattern == null) || (pattern.Trim() == String.Empty))
                return null;

            if (System.Text.RegularExpressions.Regex.IsMatch(String.Empty, pattern))
                return null;

            if (shownum == true)
            {
                FFXIATPhrase header = new FFXIATPhrase();
                header.StringResource = 0;
                header.Language = 0;
                header.GroupID = 0;
                header.MessageID = 0;
                header.Flags = 0;
                header.value = String.Empty;
                header.shortvalue = null;
                ret.Add(header);
            }
            foreach (FFXIATPhrase x in this._ATKeys_Items)
            {
                if ((x.value != null) && (x.value.Trim() != String.Empty))
                    if (System.Text.RegularExpressions.Regex.IsMatch(x.value, pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
                    {
                        ret.Add(x);
                    }
            }
            foreach (FFXIATPhrase x in this._ATPhrases)
            {
                if ((x.value != null) && (x.value.Trim() != String.Empty))
                    if (System.Text.RegularExpressions.Regex.IsMatch(x.value, pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
                    {
                        ret.Add(x);
                    }
            }
            if (shownum == true)
            {
                ret[0].value = String.Format("Found {0} similar phrase{1} matching '{2}'.",
                    ret.Count - 1, ((ret.Count - 1) == 1) ? "" : "s", pattern);
            }
            if (ret.Count == 0)
                return null;

            return ret.ToArray();
        }
Esempio n. 3
0
        /// <summary>
        /// Gets an array of phrases based on a search string.
        /// </summary>
        /// <param name="s">Search string.</param>
        /// <param name="shownum">True to show number of found objects as first object in list.</param>
        /// <returns>Array of FFXIATPhrases objects.</returns>
        public FFXIATPhrase[] GetPhrases(string s, int language, bool shownum)
        {
            int count = 0;
            FFXIATPhrase[] ret = null;

            if (shownum == true)
            {
                if (ret == null)
                    ret = new FFXIATPhrase[1];
                else Array.Resize(ref ret, ret.Length + 1);
                if (ret[count] == null)
                    ret[count] = new FFXIATPhrase();
                ret[count].StringResource = 0;
                ret[count].Language = 0;
                ret[count].GroupID = 0;
                ret[count].MessageID = 0;
                ret[count].Flags = 0;
                ret[count].value = String.Empty;
                ret[count].shortvalue = null;
                count++;
            }

            if (s.Trim() != String.Empty)
            {
                String checkNumbers = s.Trim(FFXIEncoding.StartMarker).Trim(FFXIEncoding.EndMarker);
                if (checkNumbers.Length == 8)
                {
                    UInt32 number = 0xFFFFFFFF;
                    if (UInt32.TryParse(checkNumbers, System.Globalization.NumberStyles.HexNumber, System.Globalization.NumberFormatInfo.CurrentInfo, out number))
                    {
                        return GetPhrases((int)((number & 0xFF000000) >> 24),
                                          FFXIATPhraseLoader.ffxiLanguages.LANG_ALL, // if it was only numbers, find all related ones regardless of language
                                          (int)((number & 0x0000FF00) >> 8),
                                          (int)(number & 0x000000FF), shownum);
                    }

                }

                if ((_ATKeys_Items != null) && (_ATKeys_Items.Length >= 1))
                {
                    for (int i = 0; i < _ATKeys_Items.Length; i++)
                    {
                        if (_ATKeys_Items[i] == null) continue;
                        else if (_ATKeys_Items[i].value == String.Empty) continue;
                        else if ((_ATKeys_Items[i].Language != language) && (language != ffxiLanguages.LANG_ALL)) continue;
                        else if ((String.Compare(s, 0, _ATKeys_Items[i].value, 0, s.Length, true) == 0) ||
                                 ((_ATKeys_Items[i].value[0] == '/') &&
                                  (String.Compare(s, 0, _ATKeys_Items[i].value, 1, s.Length, true) == 0)))
                        {
                            if (ret == null)
                                ret = new FFXIATPhrase[1];
                            else Array.Resize(ref ret, ret.Length + 1);
                            if (ret[count] == null)
                                ret[count] = new FFXIATPhrase();
                            ret[count].Copy(_ATKeys_Items[i]);
                            /*
                            ret[count].StringResource = _ATKeys_Items[i].StringResource;
                            ret[count].Language = _ATKeys_Items[i].Language;
                            ret[count].Flags = _ATKeys_Items[i].Flags;
                            ret[count].GroupID = _ATKeys_Items[i].GroupID;
                            ret[count].MessageID = _ATKeys_Items[i].MessageID;
                            ret[count].value = _ATKeys_Items[i].value;
                            ret[count].shortvalue = _ATKeys_Items[i].shortvalue;
                            ret[count].Type = _ATKeys_Items[i].Type;
                             */
                            count++;
                        }
                    }
                }
                if ((_ATPhrases != null) && (_ATPhrases.Length >= 1))
                {
                    for (int i = 0; i < _ATPhrases.Length; i++)
                    {
                        if (_ATPhrases[i] == null) continue;
                        else if (_ATPhrases[i].MessageID == 0x00) continue; // disable groups?
                        else if (_ATPhrases[i].value == String.Empty) continue;
                        else if ((_ATPhrases[i].Language != language) && (language != ffxiLanguages.LANG_ALL)) continue;
                        else if ((String.Compare(s, 0, _ATPhrases[i].value, 0, s.Length, true) == 0) ||
                                 ((_ATPhrases[i].value[0] == '/') &&
                                  (String.Compare(s, 0, _ATPhrases[i].value, 1, s.Length, true) == 0)))
                        {
                            if (ret == null)
                                ret = new FFXIATPhrase[1];
                            else Array.Resize(ref ret, ret.Length + 1);
                            if (ret[count] == null)
                                ret[count] = new FFXIATPhrase();
                            ret[count].Copy(_ATPhrases[i]);
                            /*
                            ret[count].StringResource = _ATPhrases[i].StringResource;
                            ret[count].Language = _ATPhrases[i].Language;
                            ret[count].GroupID = _ATPhrases[i].GroupID;
                            ret[count].MessageID = _ATPhrases[i].MessageID;
                            ret[count].value = _ATPhrases[i].value;
                            ret[count].Flags = _ATPhrases[i].Flags;*/
                            ret[count].shortvalue = null;
                            count++;
                        }
                        else if ((_ATPhrases[i].shortvalue != null) && (_ATPhrases[i].shortvalue != String.Empty) &&
                           ((String.Compare(s, 0, _ATPhrases[i].shortvalue, 0, s.Length, true) == 0) ||
                           ((_ATPhrases[i].shortvalue[0] == '/') && (String.Compare(s, 0, _ATPhrases[i].shortvalue, 1, s.Length, true) == 0)))) // equal or it's a shorthand
                        {
                            if (ret == null)
                                ret = new FFXIATPhrase[1];
                            else Array.Resize(ref ret, ret.Length + 1);
                            if (ret[count] == null)
                                ret[count] = new FFXIATPhrase();
                            ret[count].Copy(_ATPhrases[i]);
                            /*
                            ret[count].StringResource = _ATPhrases[i].StringResource;
                            ret[count].Language = _ATPhrases[i].Language;
                            ret[count].GroupID = _ATPhrases[i].GroupID;
                            ret[count].MessageID = _ATPhrases[i].MessageID;
                            ret[count].value = _ATPhrases[i].shortvalue;
                            ret[count].Flags = _ATPhrases[i].Flags;
                             */
                            ret[count].shortvalue = null;
                            count++;
                        }
                    }
                }
            }
            if (shownum == true)
            {
                count--; // acct for this extra one phrase sent
                if ((s == String.Empty) || (s == null))
                {
                    ret[0].value = "What is this, a wild goose chase? Type something in.";
                }
                else
                {
                    ret[0].value = String.Format("Found {0} similar phrase{1} matching '{2}'.",
                        count, (count == 1) ? "" : "s", s);
                }
            }
            return ret;
        }
Esempio n. 4
0
        /// <summary>
        /// Gets an array of phrases based on set of codes.
        /// </summary>
        /// <param name="s">Search string.</param>
        /// <returns></returns>
        public FFXIATPhrase[] GetPhrases(int sr, int language, int group, int messageid, bool shownum)
        {
            int count = 0;
            FFXIATPhrase[] ret = null;

            if (shownum == true)
            {
                if (ret == null)
                    ret = new FFXIATPhrase[1];
                else Array.Resize(ref ret, ret.Length + 1);
                if (ret[count] == null)
                    ret[count] = new FFXIATPhrase();
                ret[count].StringResource = 0;
                ret[count].Language = 0;
                ret[count].GroupID = 0;
                ret[count].MessageID = 0;
                ret[count].Flags = 0;
                ret[count].value = String.Empty;
                ret[count].shortvalue = null;
                count++;
            }

            if (((sr == 0x00) || (sr == 0x07) || (sr == 0x13)) && (_ATKeys_Items != null) && (_ATKeys_Items.Length >= 1))
            {
                for (int i = 0; i < _ATKeys_Items.Length; i++)
                {
                    if (_ATKeys_Items[i] == null) continue;
                    else if (_ATKeys_Items[i].value == String.Empty) continue;
                    else if (((sr == 0) || (sr == _ATKeys_Items[i].StringResource)) &&
                            ((language == ffxiLanguages.LANG_ALL) || (language == 0) || (language == _ATKeys_Items[i].Language)) &&
                            ((group == 0) || (group == _ATKeys_Items[i].GroupID)) &&
                            ((messageid == 0) || (messageid == _ATKeys_Items[i].MessageID)))
                    {
                        if (ret == null)
                            ret = new FFXIATPhrase[1];
                        else Array.Resize(ref ret, ret.Length + 1);
                        if (ret[count] == null)
                            ret[count] = new FFXIATPhrase();
                        ret[count].Copy(_ATKeys_Items[i]);
                        /*
                        ret[count].StringResource = _ATKeys_Items[i].StringResource;
                        ret[count].Language = _ATKeys_Items[i].Language;
                        ret[count].GroupID = _ATKeys_Items[i].GroupID;
                        ret[count].MessageID = _ATKeys_Items[i].MessageID;
                        ret[count].Flags = _ATKeys_Items[i].Flags;
                        ret[count].value = _ATKeys_Items[i].value;
                        ret[count].shortvalue = _ATKeys_Items[i].shortvalue;
                        ret[count].BaseType = _ATKeys_Items[i].BaseType;
                        ret[count].ActualType = _ATKeys_Items[i].ActualType;
                        ret[count].Type = _ATKeys_Items[i].Type;
                         */
                        count++;
                    }
                }
            }
            if (((sr == 0) || ((sr != 0x07) && (sr != 0x13))) && (_ATPhrases != null) && (_ATPhrases.Length >= 1))
            {
                for (int i = 0; i < _ATPhrases.Length; i++)
                {
                    if (_ATPhrases[i] == null) continue;
                    else if (_ATPhrases[i].value == String.Empty) continue;
                    else if (((sr == 0) || (sr == _ATPhrases[i].StringResource)) &&
                            ((language == ffxiLanguages.LANG_ALL) || (language == 0) || (language == _ATPhrases[i].Language)) &&
                            ((group == 0) || (group == _ATPhrases[i].GroupID)) &&
                            ((messageid == 0) || (messageid == _ATPhrases[i].MessageID)))
                    {
                        if (ret == null)
                            ret = new FFXIATPhrase[1];
                        else Array.Resize(ref ret, ret.Length + 1);
                        if (ret[count] == null)
                            ret[count] = new FFXIATPhrase();
                        ret[count].Copy(_ATPhrases[i]);
                        ret[count].shortvalue = null;
                        /*ret[count].StringResource = _ATPhrases[i].StringResource;
                        ret[count].Language = _ATPhrases[i].Language;
                        ret[count].GroupID = _ATPhrases[i].GroupID;
                        ret[count].MessageID = _ATPhrases[i].MessageID;
                        ret[count].Flags = _ATPhrases[i].Flags;
                        ret[count].value = _ATPhrases[i].value;
                        ret[count].shortvalue = null;*/
                        count++;
                    }
                }
            }
            if (shownum == true)
            {
                count--; // acct for this extra one phrase sent
                if (count == 0)
                {
                    ret[0].value = "What is this, a wild goose chase? Type something in.";
                }
                else
                {
                    ret[0].value = String.Format("Found {0} similar phrase{1} matching '{2:X2}{3:X2}{4:X2}{5:X2}'.",
                        count, (count == 1) ? "" : "s", sr, language, group, messageid);
                }
            }
            return ret;
        }
Esempio n. 5
0
        /// <summary>
        /// Loads the Spell names into a temporary array for reference by LoadAutoTranslateFile().
        /// </summary>
        private void LoadSpellInfo(int language)
        {
            d_msgFile en_d_msg = new d_msgFile(this._fileNumberArrayList[GetFileNumber(ffxiFileTypes.SPEL, language)], this.FFXIConvert);

            if ((en_d_msg == null) || (en_d_msg.EntryList == null) || (en_d_msg.Header == null))
                return;

            // Setup Spell Info structure for program
            if (SpellInfo == null)
            {
                SpellInfo = new FFXIATPhrase[en_d_msg.Header.EntryCount];
            }
            else if (SpellInfo.Length != en_d_msg.Header.EntryCount)
            {
                Array.Resize(ref SpellInfo, (int)en_d_msg.Header.EntryCount);
            }

            int step = SplashScreen.ComputeStep(SpellInfo.Length > 0 ? SpellInfo.Length : 1);
            //StreamWriter fi = File.CreateText("Spells.txt");

            for (int i = 0; i < SpellInfo.Length; i++)
            {
                // to save memory, only create a structure for a valid Spell Info block
                SpellInfo[i] = new FFXIATPhrase();
                SplashScreen.SetStatus(String.Empty, step); // 49 * 10 = 490/10000 = 5%

                if ((en_d_msg.EntryList[i] == null) ||
                    (en_d_msg.EntryList[i].data == null) ||
                    (en_d_msg.EntryList[i].data[0] == null) ||
                    (en_d_msg.EntryList[i].data[0].Length <= 0))
                    continue;

                if (en_d_msg.EntryList[i].data[0].Length > 0)
                    SpellInfo[i].value = new String(en_d_msg.EntryList[i].data[0].ToCharArray());
                else SpellInfo[i].value = "<<UNKNOWN>>";
                SpellInfo[i].Language = (byte)language;
                //fi.WriteLine("{0} {1}", i, SpellInfo[i].value);
            }
            //fi.Close();
        }
Esempio n. 6
0
        /// <summary>
        /// Loads the Key Item names into a permanent array for use by GetPhrases().
        /// </summary>
        private void LoadKeyItemInfo(int language)
        {
            // Initialize Streams
            d_msgFile en_d_msg = new d_msgFile(this._fileNumberArrayList[GetFileNumber(ffxiFileTypes.KEY, language)], this.FFXIConvert);

            if ((en_d_msg == null) || (en_d_msg.EntryList == null) || (en_d_msg.Header == null))
                return;

            int ATKeys_Items_Array_Pos = -1;
            if (_ATKeys_Items == null)
                _ATKeys_Items = new FFXIATPhrase[en_d_msg.Header.EntryCount];
            else
            {
                // Append to it
                ATKeys_Items_Array_Pos = _ATKeys_Items.Length - 1;
                Array.Resize(ref _ATKeys_Items, (int)(_ATKeys_Items.Length + en_d_msg.Header.EntryCount));
            }

            int step = SplashScreen.ComputeStep((int)en_d_msg.Header.EntryCount);
            // for each entry
            for (int i = 0; i < en_d_msg.Header.EntryCount; i++)
            {
                SplashScreen.SetStatus(String.Empty, step); // 49 * 10 = 490/10000 = 5%

                if ((en_d_msg.EntryList[i] == null) ||
                    (en_d_msg.EntryList[i].data == null) ||
                    (en_d_msg.EntryList[i].data.Length == 0))
                    continue;

                int data_cnt = 0;
                // Length - 1 b/c I do NOT want to include DESCRIPTIONS... ugh, stupid German and French
                for (; data_cnt < (en_d_msg.EntryList[i].data.Length - 1); data_cnt++)
                {
                    if ((en_d_msg.EntryList[i].data[data_cnt] == null) ||
                        (en_d_msg.EntryList[i].data[data_cnt].Trim().Trim("\0\u0001.".ToCharArray()) == String.Empty) ||
                        (en_d_msg.EntryList[i].data[data_cnt].Length <= 0))
                        continue;
                    else break;
                }
                // Length - 1 b/c I do NOT want to include DESCRIPTIONS... ugh, stupid German and French
                if (data_cnt >= (en_d_msg.EntryList[i].data.Length - 1))
                    continue;

                ATKeys_Items_Array_Pos++;

                // to save memory, only create a structure for a valid Spell Info block
                _ATKeys_Items[ATKeys_Items_Array_Pos] = new FFXIATPhrase();
                _ATKeys_Items[ATKeys_Items_Array_Pos].StringResource = 0x13;
                _ATKeys_Items[ATKeys_Items_Array_Pos].Language = (byte)language;
                _ATKeys_Items[ATKeys_Items_Array_Pos].MessageID = en_d_msg.EntryList[i].MessageID;
                _ATKeys_Items[ATKeys_Items_Array_Pos].GroupID = en_d_msg.EntryList[i].GroupID;

                if (en_d_msg.EntryList[i].data.Length >= 3)
                {
                    if ((language >= ffxiLanguages.NUM_LANG_MIN) && (language <= ffxiLanguages.NUM_LANG_MAX))
                        _ATKeys_Items[ATKeys_Items_Array_Pos].value = new String(en_d_msg.EntryList[i].data[data_cnt].ToCharArray());
                }
                else _ATKeys_Items[ATKeys_Items_Array_Pos].value = "<<UNKNOWN>>";
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Loads the Job names into a temporary array for reference by LoadAutoTranslateFile().
        /// </summary>
        private void LoadJobList(int language)
        {
            d_msgFile en_d_msg = new d_msgFile(this._fileNumberArrayList[GetFileNumber(ffxiFileTypes.JOBS, language)], this.FFXIConvert);

            if ((en_d_msg == null) || (en_d_msg.EntryList == null) || (en_d_msg.Header == null))
                return;

            if (JobList == null)
                JobList = new FFXIATPhrase[en_d_msg.Header.EntryCount];
            else if (JobList.Length != en_d_msg.Header.EntryCount)
            {
                Array.Resize(ref JobList, (int)en_d_msg.Header.EntryCount);
            }

            int step = SplashScreen.ComputeStep((int)en_d_msg.Header.EntryCount);

            // for each entry
            for (int i = 0; i < JobList.Length; i++)
            {
                SplashScreen.SetStatus(String.Empty, step); // 21 * 10 = 210/10000 = 2.5%
                JobList[i] = new FFXIATPhrase();
                if ((en_d_msg.EntryList[i] == null) ||
                    (en_d_msg.EntryList[i].data == null) ||
                    (en_d_msg.EntryList[i].data[0] == null) ||
                    (en_d_msg.EntryList[i].data[0].Length <= 0))
                    continue;

                // to save memory, only create a structure for a valid Spell Info block
                if (en_d_msg.EntryList[i].data[0].Length > 0)
                    JobList[i].value = new String(en_d_msg.EntryList[i].data[0].ToCharArray());
                else JobList[i].value = "<<UNKNOWN>>";
                JobList[i].Language = (byte)language;
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Generic loader for loading Item names into a permanent array for use by GetPhrases().
        /// </summary>
        /// <param name="file_num">File number to load (OBJ, ITEMS, PUPP, ARMR, WEPN, GIL)</param>
        private void LoadItemFile(int file_num, int language)
        {
            if (_fileNumberArrayList == null)
                return;
            else if ((file_num < 0) || (file_num >= _fileNumberArrayList.Length))
                return;

            FileInfo fi = new FileInfo(_fileNumberArrayList[file_num]);
            Boolean file_error = false;

            if (!fi.Exists) return;
            if ((fi.Length % 0xC00) != 0) return;

            int items_in_file = (int)(fi.Length / 0xC00);
            BinaryReader iteminfo = null;
            try
            {
                iteminfo = new BinaryReader(File.Open(_fileNumberArrayList[file_num], FileMode.Open, FileAccess.Read));
            }
            catch (IOException e)
            {
                System.Windows.Forms.MessageBox.Show(e.Message + "\r\nSome Auto-Translate phrases may not be available.");
                file_error = true;
            }
            if (file_error == true) return;  // Attempt a Sanity Check
            for (int item_counter = 0; item_counter < items_in_file; item_counter++)
            {
                SplashScreen.SetStatus(String.Empty, 7); // 49 * 10 = 490/10000 = 5%
                iteminfo.BaseStream.Position = 0xC00 * item_counter;
                byte[] readbytes = DecodeBlock(iteminfo.ReadBytes(0x200), 5);
                BinaryReader data = new BinaryReader(new MemoryStream(readbytes, false));
                itemFormat itemObjects = new itemFormat(data, FFXIConvert);
                // INSERT ITEM CHECK DATA HERE
                data.Close();
                //if ((itemObjects.itemHeader.ID < 0xFFFF) && (itemObjects.itemHeader.ID > 0x6FFF))
                //    continue;
                //else if (itemObjects.text == String.Empty)
                //    continue;
                //else
                if ((itemObjects.itemHeader.Flags & (ushort)ItemFlags.Nothing) == (ushort)ItemFlags.Nothing)
                    continue;
                else if (itemObjects.itemHeader.ID == 0x00)
                    continue;

                // 0x0100 0x0040 0x1000
                /* UINT32 ID
                 * UINT16 Flags
                 * UINT16 Stack Size
                 * UINT16 Type
                 * UINT16 ResourceID
                 * UINT16 ValidTargets
                 * 14 Bytes - Common Header Size
                 */
                int atp = 0;

                if (_ATKeys_Items == null)
                    _ATKeys_Items = new FFXIATPhrase[1];
                else Array.Resize(ref _ATKeys_Items, (int)(_ATKeys_Items.Length + 1));

                atp = _ATKeys_Items.Length - 1;

                _ATKeys_Items[atp] = new FFXIATPhrase();
                _ATKeys_Items[atp].StringResource = 0x07;
                _ATKeys_Items[atp].Language = (byte)language;
                _ATKeys_Items[atp].GroupID = (byte)((itemObjects.itemHeader.ID & 0xFF00) >> 8);
                _ATKeys_Items[atp].MessageID = (byte)(itemObjects.itemHeader.ID & 0x00FF);
                _ATKeys_Items[atp].Flags = itemObjects.itemHeader.Flags;
                _ATKeys_Items[atp].ActualType = itemObjects.itemHeader.Type;
                if ((itemObjects.itemHeader.ID >= 0x0000) && (itemObjects.itemHeader.ID <= 0x0FFF))
                    _ATKeys_Items[atp].BaseType = (ushort)FFXIATPhraseLoader.ffxiFileTypes.ITEMS;
                else if ((itemObjects.itemHeader.ID >= 0x1000) && (itemObjects.itemHeader.ID <= 0x1FFF))
                    _ATKeys_Items[atp].BaseType = (ushort)FFXIATPhraseLoader.ffxiFileTypes.OBJS;
                else if ((itemObjects.itemHeader.ID >= 0x2000) && (itemObjects.itemHeader.ID <= 0x2FFF))
                    _ATKeys_Items[atp].BaseType = (ushort)FFXIATPhraseLoader.ffxiFileTypes.PUPP;
                else if ((itemObjects.itemHeader.ID >= 0x2C00) && (itemObjects.itemHeader.ID <= 0x3FFF))
                    _ATKeys_Items[atp].BaseType = (ushort)FFXIATPhraseLoader.ffxiFileTypes.ARMR;
                else if ((itemObjects.itemHeader.ID >= 0x4000) && (itemObjects.itemHeader.ID <= 0x6FFF))
                    _ATKeys_Items[atp].BaseType = (ushort)FFXIATPhraseLoader.ffxiFileTypes.WPNS;
                else if (itemObjects.itemHeader.ID == 0xFFFF) // Gil
                    _ATKeys_Items[atp].BaseType = (ushort)FFXIATPhraseLoader.ffxiFileTypes.GIL;

                if (itemObjects.itemHeader.Type != 0)  // if it's nothing, categorize at as something else
                {
                    _ATKeys_Items[atp].Type = itemObjects.itemHeader.Type;
                }
                else
                {
                    if ((itemObjects.itemHeader.ID <= 0x2FFF) && (itemObjects.itemHeader.ID >= 0x2000))
                        _ATKeys_Items[atp].Type = 13; // Puppet Items
                    else if ((itemObjects.itemHeader.ID <= 0x3FFF) && (itemObjects.itemHeader.ID >= 0x3000))
                        _ATKeys_Items[atp].Type = 5; // Armor Items
                    else if ((itemObjects.itemHeader.ID <= 0x6FFF) && (itemObjects.itemHeader.ID >= 0x4000))
                        _ATKeys_Items[atp].Type = 4; // Weapon Items
                }
                _ATKeys_Items[atp].value = itemObjects.text;
                _ATKeys_Items[atp].shortvalue = itemObjects.logtext; // misleading i know
            }
            iteminfo.Close();
        }
Esempio n. 9
0
        /// <summary>
        /// Loads the Auto-Translate phrases into a permanent array for use by GetPhrases().
        /// </summary>
        private void LoadAutoTranslateFile(int language)
        {
            if (language == 4)
            {
                int xivi = 0;
                xivi++;
            }
            atphraseFileFormat at_phrase_file = new atphraseFileFormat(this._fileNumberArrayList[GetFileNumber(ffxiFileTypes.AT_P, language)]);

            if ((at_phrase_file == null) || (at_phrase_file.AtEntry == null) || (at_phrase_file.AtGroup == null))
                return;

            int step = SplashScreen.ComputeStep(at_phrase_file.AtGroup.Length + at_phrase_file.AtEntry.Length);

            int value = 0;
            string valuetoconvert;
            int cnt = -1;
            if (_ATPhrases != null)
                cnt = _ATPhrases.Length - 1;
            if (_ATPhrases == null)
                _ATPhrases = new FFXIATPhrase[at_phrase_file.AtGroup.Length + at_phrase_file.AtEntry.Length];
            else Array.Resize(ref _ATPhrases, _ATPhrases.Length + (at_phrase_file.AtGroup.Length + at_phrase_file.AtEntry.Length));
            // Read Groups first.
            int g_cnt = 0, e_cnt = 0;
            for (g_cnt = 0; g_cnt < at_phrase_file.AtGroup.Length; g_cnt++)
            {
                SplashScreen.SetStatus(String.Empty, step);
                cnt++;
                if (_ATPhrases[cnt] == null)
                    _ATPhrases[cnt] = new FFXIATPhrase();
                _ATPhrases[cnt].StringResource = at_phrase_file.AtGroup[g_cnt].StringResourceType;
                _ATPhrases[cnt].Language = at_phrase_file.AtGroup[g_cnt].LanguageCode;
                _ATPhrases[cnt].GroupID = at_phrase_file.AtGroup[g_cnt].GroupID;
                _ATPhrases[cnt].MessageID = at_phrase_file.AtGroup[g_cnt].MessageID;
                _ATPhrases[cnt].value = this.FFXIConvert.GetString(at_phrase_file.AtGroup[g_cnt].Text).Trim().Trim("\0\u0001.".ToCharArray());
                _ATPhrases[cnt].shortvalue = this.FFXIConvert.GetString(at_phrase_file.AtGroup[g_cnt].CompletionText).Trim().Trim("\0\u0001.".ToCharArray());
            }
            for (e_cnt = 0; e_cnt < at_phrase_file.AtEntry.Length; e_cnt++)
            {
                SplashScreen.SetStatus(String.Empty, step);
                cnt++;
                if (_ATPhrases[cnt] == null)
                    _ATPhrases[cnt] = new FFXIATPhrase();
                _ATPhrases[cnt].StringResource = at_phrase_file.AtEntry[e_cnt].StringResourceType;
                _ATPhrases[cnt].Language = at_phrase_file.AtEntry[e_cnt].LanguageCode;
                _ATPhrases[cnt].GroupID = at_phrase_file.AtEntry[e_cnt].GroupID;
                _ATPhrases[cnt].MessageID = at_phrase_file.AtEntry[e_cnt].MessageID;
                _ATPhrases[cnt].value = this.FFXIConvert.GetString(at_phrase_file.AtEntry[e_cnt].Text).Trim().Trim("\0\u0001.".ToCharArray());
                _ATPhrases[cnt].shortvalue = this.FFXIConvert.GetString(at_phrase_file.AtEntry[e_cnt].CompletionText).Trim().Trim("\0\u0001.".ToCharArray());
                if ((_ATPhrases[cnt].value != String.Empty) && (_ATPhrases[cnt].value[0] == '@'))
                {
                    switch (_ATPhrases[cnt].value[1])
                    {
                        case 'J':
                            if (JobList != null)
                            {
                                valuetoconvert = "0x" + _ATPhrases[cnt].value.Substring(2);
                                value = System.Convert.ToInt32(valuetoconvert, 16);
                                if (value < JobList.Length)
                                {
                                    _ATPhrases[cnt].value = JobList[value].value.Trim().Trim("\0\u0001.".ToCharArray());
                                    _ATPhrases[cnt].shortvalue = JobList[value].value.Trim().Trim("\0\u0001.".ToCharArray());
                                    _ATPhrases[cnt].Language = JobList[value].Language;
                                }
                                else
                                {
                                    _ATPhrases[cnt].value = "EN Job #" + value;
                                    _ATPhrases[cnt].shortvalue = "EN Job #" + value;
                                }
                            }
                            break;
                        case 'A':
                            if (AreaList != null)
                            {
                                valuetoconvert = "0x" + _ATPhrases[cnt].value.Substring(2);
                                value = System.Convert.ToInt32(valuetoconvert, 16);
                                if (value < AreaList.Length)
                                {
                                    _ATPhrases[cnt].value = AreaList[value].value.Trim().Trim("\0\u0001.".ToCharArray());
                                    _ATPhrases[cnt].shortvalue = AreaList[value].value.Trim().Trim("\0\u0001.".ToCharArray());
                                    _ATPhrases[cnt].Language = AreaList[value].Language;
                                }
                                else
                                {
                                    _ATPhrases[cnt].value = "EN Area #" + value;
                                    _ATPhrases[cnt].shortvalue = "EN Area #" + value;
                                }
                            }
                            break;
                        case 'Y':
                            if (AbilityInfo != null)
                            {
                                valuetoconvert = "0x" + _ATPhrases[cnt].value.Substring(2);
                                value = System.Convert.ToInt32(valuetoconvert, 16);
                                if (value < AbilityInfo.Length)
                                {
                                    _ATPhrases[cnt].value = AbilityInfo[value].value.Trim().Trim("\0\u0001.".ToCharArray());
                                    _ATPhrases[cnt].shortvalue = AbilityInfo[value].value.Trim().Trim("\0\u0001.".ToCharArray());
                                    _ATPhrases[cnt].Language = AbilityInfo[value].Language;
                                }
                                else
                                {
                                    _ATPhrases[cnt].value = "EN Ability #" + value;
                                    _ATPhrases[cnt].shortvalue = "EN Ability #" + value;
                                }
                            }
                            break;
                        case 'C':
                            if (SpellInfo != null)
                            {
                                valuetoconvert = "0x" + _ATPhrases[cnt].value.Substring(2);
                                value = System.Convert.ToInt32(valuetoconvert, 16);
                                if (value < SpellInfo.Length)
                                {
                                    _ATPhrases[cnt].value = SpellInfo[value].value.Trim().Trim("\0\u0001.".ToCharArray());
                                    _ATPhrases[cnt].shortvalue = SpellInfo[value].value.Trim().Trim("\0\u0001.".ToCharArray());
                                    _ATPhrases[cnt].Language = SpellInfo[value].Language;
                                }
                                else
                                {
                                    _ATPhrases[cnt].value = "EN Spell #" + value;
                                    _ATPhrases[cnt].shortvalue = "EN Spell #" + value;
                                }
                            }
                            break;
                        default:
                            break;
                    }
                }
            }
            Array.Sort(_ATPhrases, new FFXIATPhraseLoader.ATPhraseCompareByID());
            int x_abcdefg = 0;
            x_abcdefg++;
        }