예제 #1
0
        public unsafe void Assemble(byte *byteptr_t)
        {
            // Since CollectionName is of type 0x{1}{2}{3}{4}, use SAT GetColors functions
            int i1 = SAT.GetAlpha(this._collection_name);
            var i2 = SAT.GetRed(this._collection_name);
            var i3 = SAT.GetGreen(this._collection_name);
            var i4 = SAT.GetBlue(this._collection_name);

            *(int *)byteptr_t            = i1;
            *(byteptr_t + 0x04)          = i2;
            *(byteptr_t + 0x05)          = i3;
            *(byteptr_t + 0x06)          = i4;
            *(float *)(byteptr_t + 0x08) = this.MinSliderValueRatio;
            *(float *)(byteptr_t + 0x0C) = this.MaxSliderValueRatio;
            *(float *)(byteptr_t + 0x10) = this.ValueSpread1;
            *(float *)(byteptr_t + 0x14) = this.ValueSpread2;
        }
예제 #2
0
파일: Core.cs 프로젝트: NFSTools/Binary
        private static string ExecuteUpdateFNG(BasicBase db, string node, string field, string value)
        {
            if (!db.TryGetCollection(node, FNGroups, out var collection))
            {
                return($"Collection {node} does not exist in root {FNGroups}.");
            }
            if (!(collection is FNGroup fng))
            {
                return($"Collection {node} is not a {FNGroups} collection.");
            }

            if (!SAT.CanBeColor(value))
            {
                return($"Value {value} is not an 8-digit hexadecimal color-type.");
            }

            var color = new FEngColor(null);

            color.Alpha = SAT.GetAlpha(value);
            color.Red   = SAT.GetRed(value);
            color.Green = SAT.GetGreen(value);
            color.Blue  = SAT.GetBlue(value);

            if (field.StartsWith("ReplaceSame"))
            {
                if (field.StartsWith("ReplaceSameNoAlpha[") && field.EndsWith("]"))
                {
                    if (FormatX.GetInt32(field, "ReplaceSameNoAlpha[{X}]", out int index))
                    {
                        fng.TrySetSame(index, color, true);
                    }
                    else
                    {
                        return($"Unable to get color index from field named {field}.");
                    }
                }
                else if (field.StartsWith("ReplaceSameWithAlpha[") && field.EndsWith("]"))
                {
                    if (FormatX.GetInt32(field, "ReplaceSameWithAlpha[{X}]", out int index))
                    {
                        fng.TrySetSame(index, color, false);
                    }
                    else
                    {
                        return($"Unable to get color index from field named {field}.");
                    }
                }
                else
                {
                    return($"Incorrect passed parameter named {field}.");
                }
            }
            else if (field == "ReplaceAllNoAlpha")
            {
                fng.TrySetAll(color, true);
            }
            else if (field == "ReplaceAllWithAlpha")
            {
                fng.TrySetAll(color, false);
            }
            else
            {
                int index = SAT.GetIndex(field);
                if (index >= fng.InfoLength || index == -1)
                {
                    return($"Field named {field} does not exist.");
                }
                fng.TrySetOne(index, color);
            }
            return(null);
        }