예제 #1
0
        /// <summary>
        /// Disperses all settings from the rim string passed.
        /// </summary>
        /// <param name="rim">Rim string to be dispersed.</param>
        /// <param name="brand">Brand of the rim.</param>
        /// <param name="style">Style of the rim brand.</param>
        /// <param name="size">Size of the rim brand.</param>
        /// <param name="max">Max outer size of the rim brand.</param>
        private void DisperseRimSettings(string rim)
        {
            bool potentialspi = false;

            if (rim.EndsWith("_SPI"))
            {
                potentialspi = true;
                rim          = rim.Substring(0, rim.Length - 4);
            }
            this._rim_brand = FormatX.GetString(rim, "{X}_STYLE##_##_##");
            if (!FormatX.GetByte(rim, this._rim_brand + "_STYLE{X}_##_##", out byte thisstyle))
            {
                thisstyle = 1;
            }
            if (!FormatX.GetByte(rim, this._rim_brand + "_STYLE##_{X}_##", out byte thissize))
            {
                thissize = 18;
            }
            if (!FormatX.GetByte(rim, this._rim_brand + "_STYLE##_##_{X}", out byte thismax))
            {
                thismax = 24;
            }
            this._rim_style       = thisstyle;
            this._rim_size        = thissize;
            this._rim_outer_max   = thismax;
            this._is_spinning_rim = potentialspi ? eBoolean.True : eBoolean.False;
        }
예제 #2
0
 /// <summary>
 /// Gets pearl window tint string from a string passed.
 /// </summary>
 /// <param name="tint">String to get pearl window tint from.</param>
 /// <returns>Pearl tint string if was resolved, null otherwise.</returns>
 public static void GetWindowTintString(string tint)
 {
     try
     {
         if (!tint.StartsWith("WINDSHIELD_TINT"))
         {
             return;
         }
         if (!int.TryParse(tint.Substring(17, 1), out int level))
         {
             return;
         }
         if (level == 3)
         {
             string color = FormatX.GetString(tint, "WINDSHIELD_TINT_L3_{X}");
             string var1  = "WINDSHIELD_TINT_L3_PEARL_" + color;
             string var2  = "WINDSHIELD_TINT_L3_PEARL " + color;
             Map.WindowTintMap.Add(var1);
             Map.WindowTintMap.Add(var2);
             Bin.Hash(var1);
             Bin.Hash(var2);
             return;
         }
         else
         if (!Map.WindowTintMap.Contains(tint))
         {
             Map.WindowTintMap.Add(tint);
         }
     }
     catch (Exception) { }
 }
예제 #3
0
 /// <summary>
 /// Gets blue parameter of a hexadecimal color passed.
 /// </summary>
 /// <param name="color">Hexadecimal color passed.</param>
 /// <returns>Blue parameter as a byte.</returns>
 public static byte GetBlue(string color)
 {
     try
     {
         string hex = FormatX.GetString(color, "0xABCDEF{XX}");
         return(Convert.ToByte(hex, 16));
     }
     catch (Exception) { return(0); }
 }
예제 #4
0
        public static bool CareerStageCollectionName(string CName)
        {
            if (!CName.StartsWith("STAGE_"))
            {
                return(false);
            }
            string index = FormatX.GetString(CName, "STAGE_{X}");

            return(byte.TryParse(index, out byte _));
        }
예제 #5
0
        /// <summary>
        /// Disassembles frontend group array into separate properties.
        /// </summary>
        /// <param name="byteptr_t">Pointer to the frontend group array.</param>
        protected override unsafe void Disassemble(byte[] data)
        {
            this._DATA = new byte[data.Length];
            Buffer.BlockCopy(data, 0, this._DATA, 0, data.Length);

            fixed(byte *byteptr_t = &this._DATA[0])
            {
                this.Size = *(uint *)(byteptr_t + 4);

                // For some reason HUFF compression has the same ID as FEng files
                if (*(uint *)(byteptr_t + 8) == 0x46465548)
                {
                    this.Destroy = true;
                    return;
                }

                // Read CollectionName
                this.CollectionName = ScriptX.NullTerminatedString(byteptr_t + 0x30, this._DATA.Length - 0x30);
                if (this.CollectionName.EndsWith(".fng"))
                {
                    this.CollectionName = FormatX.GetString(this.CollectionName, "{X}.fng");
                }

                for (uint offset = 0x30; offset < this._DATA.Length; offset += 4)
                {
                    byte b1 = *(byteptr_t + offset);
                    byte b2 = *(byteptr_t + offset + 1);
                    byte b3 = *(byteptr_t + offset + 2);
                    byte b4 = *(byteptr_t + offset + 3);

                    // SAT, SAD, SA(0x90) or 1111
                    if ((b1 == 'S' && b2 == 'A') || (b1 == 0xFF && b2 == 0xFF && b3 == 0xFF && b4 == 0xFF))
                    {
                        uint Blue  = *(uint *)(byteptr_t + offset + 4);
                        uint Green = *(uint *)(byteptr_t + offset + 8);
                        uint Red   = *(uint *)(byteptr_t + offset + 12);
                        uint Alpha = *(uint *)(byteptr_t + offset + 16);

                        // If it is a color, add to the list
                        if (Resolve.IsColor(Alpha, Red, Green, Blue))
                        {
                            var TempColor = new FEngColor(this);
                            TempColor.Offset = offset;
                            TempColor.Alpha  = (byte)Alpha;
                            TempColor.Red    = (byte)Red;
                            TempColor.Green  = (byte)Green;
                            TempColor.Blue   = (byte)Blue;
                            this._colorinfo.Add(TempColor);
                        }
                        offset += 0x14;
                    }
                }
            }
        }
예제 #6
0
        public static bool BankTriggerCollectionName(string CName)
        {
            if (CName.Length != 15)
            {
                return(false);
            }
            if (!CName.StartsWith("BANK_TRIGGER_"))
            {
                return(false);
            }
            string index = FormatX.GetString(CName, "BANK_TRIGGER_{X}");

            return(byte.TryParse(index, out byte _));
        }
예제 #7
0
        public static bool PartUnlockableCollectionName(string CName)
        {
            if (CName.Length != 10)
            {
                return(false);
            }
            if (!CName.StartsWith("CARPART_"))
            {
                return(false);
            }
            string index = FormatX.GetString(CName, "CARPART_{X}");

            if (ConvertX.ToInt32(index) == 0)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
예제 #8
0
        /// <summary>
        /// Gets index from "Color[#]" string.
        /// </summary>
        /// <param name="field">String from which get the index.</param>
        /// <returns>Integer value of the index of the color.</returns>
        public static int GetIndex(string field)
        {
            int result = -1;

            if (!field.StartsWith("Color["))
            {
                return(-1);
            }
            if (!field.EndsWith("]"))
            {
                return(-1);
            }
            try
            {
                string str = FormatX.GetString(field, "Color[{X}]");
                if (!int.TryParse(str, out result))
                {
                    return(-1);
                }
            }
            catch { }
            return(result);
        }
예제 #9
0
 public string EndTagToStartTag(string tag)
 {
     return(FormatX.GetString(tag, "/{X}"));
 }
예제 #10
0
        /// <summary>
        /// Loads Wheels files and reads its rim brand strings
        /// </summary>
        /// <param name="Wheels_dir">Directory of the game.</param>
        /// <param name="db">Database of classes.</param>
        /// <returns>True if success.</returns>
        public static unsafe bool LoadWheels(string Wheels_dir)
        {
            Wheels_dir += @"\CARS\WHEELS";
            if (!Directory.Exists(Wheels_dir))
            {
                if (Process.MessageShow)
                {
                    MessageBox.Show(@"Directory CARS\WHEELS does not exist.", "Failure");
                }
                else
                {
                    Console.WriteLine(@"Directory CARS\WHEELS does not exist.");
                }
                return(false);
            }

            var files = Directory.GetFiles(Wheels_dir);

            if (files == null || files.Length == 0)
            {
                if (Process.MessageShow)
                {
                    MessageBox.Show(@"Directory CARS\WHEELS is empty.", "Failure");
                }
                else
                {
                    Console.WriteLine(@"Directory CARS\WHEELS is empty.");
                }
                return(false);
            }

            foreach (var file in files)
            {
                string ext = Path.GetExtension(file).ToUpper();
                if (!Path.GetFileName(file).StartsWith("GEOMETRY_") || (Path.GetExtension(file).ToUpper() != ".BIN"))
                {
                    continue;
                }
                try
                {
                    using (var br = new BinaryReader(File.Open(file, FileMode.Open, FileAccess.Read)))
                    {
                        if (br.ReadUInt32() != 0x80134000)
                        {
                            continue;                                        // if not a wheels file
                        }
                        br.BaseStream.Position += 4;                         // skip size
                        while (br.BaseStream.Position < br.BaseStream.Length)
                        {
                            uint ID   = br.ReadUInt32();
                            int  size = br.ReadInt32();
                            int  off  = (int)br.BaseStream.Position;
                            if (ID != 0x80134010)
                            {
                                br.ReadBytes(size);
                                continue;
                            }
                            while ((int)br.BaseStream.Position < off + size)
                            {
                                ID   = br.ReadUInt32();
                                size = br.ReadInt32();
                                if (ID == 0x00134011)
                                {
                                    break;
                                }
                            }
                            if (ID != 0x00134011)
                            {
                                continue;
                            }
                            br.BaseStream.Position += 0xA4;
                            string rim = ScriptX.NullTerminatedString(br);
                            br.BaseStream.Position -= 0xB0 + rim.Length + 1;
                            rim = FormatX.GetString(rim, "{X}_X");
                            if (!Map.RimBrands.Contains(rim))
                            {
                                Map.RimBrands.Add(rim);
                            }
                            br.ReadBytes(br.ReadInt32());
                        }
                    }
                }
                catch (Exception e)
                {
                    while (e.InnerException != null)
                    {
                        e = e.InnerException;
                    }
                    if (Process.MessageShow)
                    {
                        MessageBox.Show(e.Message, "Failure");
                    }
                    else
                    {
                        Console.WriteLine(e.Message);
                    }
                    return(false);
                }
            }
            foreach (var rim in Map.RimBrands)
            {
                Bin.Hash(rim);
            }
            return(true);
        }