Exemplo n.º 1
0
        public static ME3LibWV.CustomProperty PropertyToGrid(Property p, UDKFile udk)
        {
            string cat = p.TypeVal.ToString();

            ME3LibWV.CustomProperty pg;
            NameProp pp;

            switch (p.TypeVal)
            {
            case Type.BoolProperty:
                pg = new ME3LibWV.CustomProperty(udk.getName(p.Name), cat, (p.Value.IntValue == 1), typeof(bool), false, true);
                break;

            case Type.FloatProperty:
                byte[] buff = BitConverter.GetBytes(p.Value.IntValue);
                float  f    = BitConverter.ToSingle(buff, 0);
                pg = new ME3LibWV.CustomProperty(udk.getName(p.Name), cat, f, typeof(float), false, true);
                break;

            case Type.ByteProperty:
                if (p.Size != 8)
                {
                    pg = new ME3LibWV.CustomProperty(udk.getName(p.Name), cat, (byte)p.Value.IntValue, typeof(byte), false, true);
                }
                else
                {
                    pp           = new NameProp();
                    pp.name      = udk.getName(p.Value.IntValue);
                    pp.nameindex = p.Value.IntValue;
                    pg           = new ME3LibWV.CustomProperty(udk.getName(p.Name), cat, pp, typeof(NameProp), false, true);
                }
                break;

            case Type.NameProperty:
                pp           = new NameProp();
                pp.name      = udk.getName(p.Value.IntValue);
                pp.nameindex = p.Value.IntValue;
                pg           = new ME3LibWV.CustomProperty(udk.getName(p.Name), cat, pp, typeof(NameProp), false, true);
                break;

            case Type.ObjectProperty:
                ObjectProp ppo = new ObjectProp();
                ppo.objectName = udk.getObjectName(p.Value.IntValue);
                ppo.index      = p.Value.IntValue;
                pg             = new ME3LibWV.CustomProperty(udk.getName(p.Name), cat, ppo, typeof(ObjectProp), false, true);
                break;

            case Type.StrProperty:
                pg = new ME3LibWV.CustomProperty(udk.getName(p.Name), cat, p.Value.StringValue, typeof(string), false, true);
                break;

            case Type.ArrayProperty:
                pg = new ME3LibWV.CustomProperty(udk.getName(p.Name), cat, BitConverter.ToInt32(p.raw, 24) + " elements", typeof(string), false, true);
                break;

            case Type.StructProperty:
                string structType = udk.getName(p.Value.IntValue);
                if (structType == "Color")
                {
                    ColorProp cp = new ColorProp();
                    cp.name      = structType;
                    cp.nameindex = p.Value.IntValue;
                    System.Drawing.Color color = System.Drawing.Color.FromArgb(BitConverter.ToInt32(p.raw, 32));
                    cp.Alpha = color.A;
                    cp.Red   = color.R;
                    cp.Green = color.G;
                    cp.Blue  = color.B;
                    pg       = new ME3LibWV.CustomProperty(udk.getName(p.Name), cat, cp, typeof(ColorProp), false, true);
                }
                else if (structType == "Vector")
                {
                    VectorProp vp = new VectorProp();
                    vp.name      = structType;
                    vp.nameindex = p.Value.IntValue;
                    vp.X         = BitConverter.ToSingle(p.raw, 32);
                    vp.Y         = BitConverter.ToSingle(p.raw, 36);
                    vp.Z         = BitConverter.ToSingle(p.raw, 40);
                    pg           = new ME3LibWV.CustomProperty(udk.getName(p.Name), cat, vp, typeof(VectorProp), false, true);
                }
                else if (structType == "Rotator")
                {
                    RotatorProp rp = new RotatorProp();
                    rp.name      = structType;
                    rp.nameindex = p.Value.IntValue;
                    rp.Pitch     = BitConverter.ToInt32(p.raw, 32) * 360f / 65536f;
                    rp.Yaw       = BitConverter.ToInt32(p.raw, 36) * 360f / 65536f;
                    rp.Roll      = BitConverter.ToInt32(p.raw, 40) * 360f / 65536f;
                    pg           = new ME3LibWV.CustomProperty(udk.getName(p.Name), cat, rp, typeof(RotatorProp), false, true);
                }
                else if (structType == "LinearColor")
                {
                    LinearColorProp lcp = new LinearColorProp();
                    lcp.name      = structType;
                    lcp.nameindex = p.Value.IntValue;
                    lcp.Red       = BitConverter.ToSingle(p.raw, 32);
                    lcp.Green     = BitConverter.ToSingle(p.raw, 36);
                    lcp.Blue      = BitConverter.ToSingle(p.raw, 40);
                    lcp.Alpha     = BitConverter.ToSingle(p.raw, 44);
                    pg            = new ME3LibWV.CustomProperty(udk.getName(p.Name), cat, lcp, typeof(VectorProp), false, true);
                }
                else
                {
                    StructProp ppp = new StructProp();
                    ppp.name      = structType;
                    ppp.nameindex = p.Value.IntValue;
                    byte[] buf = new byte[p.Value.Array.Count()];
                    for (int i = 0; i < p.Value.Array.Count(); i++)
                    {
                        buf[i] = (byte)p.Value.Array[i].IntValue;
                    }
                    List <int> buf2 = new List <int>();
                    for (int i = 0; i < p.Value.Array.Count() / 4; i++)
                    {
                        buf2.Add(BitConverter.ToInt32(buf, i * 4));
                    }
                    ppp.data = buf2.ToArray();
                    pg       = new ME3LibWV.CustomProperty(udk.getName(p.Name), cat, ppp, typeof(StructProp), false, true);
                }
                break;

            default:
                pg = new ME3LibWV.CustomProperty(udk.getName(p.Name), cat, p.Value.IntValue, typeof(int), false, true);
                break;
            }
            return(pg);
        }
Exemplo n.º 2
0
        public static ME3LibWV.CustomProperty PropertyToGrid(Property p, UDKFile udk)
        {
            string cat = p.TypeVal.ToString();
            ME3LibWV.CustomProperty pg;
            NameProp pp;
            switch (p.TypeVal)
            {
                case Type.BoolProperty :
                    pg = new ME3LibWV.CustomProperty(udk.getName(p.Name), cat, (p.Value.IntValue == 1), typeof(bool), false, true);
                    break;
                case Type.FloatProperty:
                    byte[] buff = BitConverter.GetBytes(p.Value.IntValue);
                    float f = BitConverter.ToSingle(buff, 0);
                    pg = new ME3LibWV.CustomProperty(udk.getName(p.Name), cat, f, typeof(float), false, true);
                    break;
                case Type.ByteProperty:
                    if (p.Size != 8)
                    {
                        pg = new ME3LibWV.CustomProperty(udk.getName(p.Name), cat, (byte)p.Value.IntValue, typeof(byte), false, true);
                    }
                    else
                    {

                        pp = new NameProp();
                        pp.name = udk.getName(p.Value.IntValue);
                        pp.nameindex = p.Value.IntValue;
                        pg = new ME3LibWV.CustomProperty(udk.getName(p.Name), cat, pp, typeof(NameProp), false, true);
                    }
                    break;
                case Type.NameProperty:
                    pp = new NameProp();
                    pp.name = udk.getName(p.Value.IntValue);
                    pp.nameindex = p.Value.IntValue;
                    pg = new ME3LibWV.CustomProperty(udk.getName(p.Name), cat, pp, typeof(NameProp), false, true);
                    break;
                case Type.ObjectProperty:
                    ObjectProp ppo = new ObjectProp();
                    ppo.objectName = udk.getObjectName(p.Value.IntValue);
                    ppo.index = p.Value.IntValue;
                    pg = new ME3LibWV.CustomProperty(udk.getName(p.Name), cat, ppo, typeof(ObjectProp), false, true);
                    break;
                case Type.StrProperty:
                    pg = new ME3LibWV.CustomProperty(udk.getName(p.Name), cat, p.Value.StringValue, typeof(string), false, true);
                    break;
                case Type.ArrayProperty:
                    pg = new ME3LibWV.CustomProperty(udk.getName(p.Name), cat, BitConverter.ToInt32(p.raw,24) + " elements", typeof(string), false, true);
                    break;
                case Type.StructProperty:
                    string structType = udk.getName(p.Value.IntValue);
                    if(structType == "Color") {
                        ColorProp  cp = new ColorProp();
                        cp.name = structType;
                        cp.nameindex = p.Value.IntValue;
                        System.Drawing.Color color = System.Drawing.Color.FromArgb(BitConverter.ToInt32(p.raw, 32));
                        cp.Alpha = color.A;
                        cp.Red = color.R;
                        cp.Green = color.G;
                        cp.Blue = color.B;
                        pg = new ME3LibWV.CustomProperty(udk.getName(p.Name), cat, cp, typeof(ColorProp), false, true);
                    }
                    else if (structType == "Vector")
                    {
                        VectorProp vp = new VectorProp();
                        vp.name = structType;
                        vp.nameindex = p.Value.IntValue;
                        vp.X = BitConverter.ToSingle(p.raw, 32);
                        vp.Y = BitConverter.ToSingle(p.raw, 36);
                        vp.Z = BitConverter.ToSingle(p.raw, 40);
                        pg = new ME3LibWV.CustomProperty(udk.getName(p.Name), cat, vp, typeof(VectorProp), false, true);
                    }
                    else if (structType == "Rotator")
                    {
                        RotatorProp rp = new RotatorProp();
                        rp.name = structType;
                        rp.nameindex = p.Value.IntValue;
                        rp.Pitch = BitConverter.ToInt32(p.raw, 32) * 360f / 65536f;
                        rp.Yaw = BitConverter.ToInt32(p.raw, 36) * 360f / 65536f;
                        rp.Roll = BitConverter.ToInt32(p.raw, 40) * 360f / 65536f;
                        pg = new ME3LibWV.CustomProperty(udk.getName(p.Name), cat, rp, typeof(RotatorProp), false, true);
                    }
                    else if (structType == "LinearColor")
                    {
                        LinearColorProp lcp = new LinearColorProp();
                        lcp.name = structType;
                        lcp.nameindex = p.Value.IntValue;
                        lcp.Red = BitConverter.ToSingle(p.raw, 32);
                        lcp.Green = BitConverter.ToSingle(p.raw, 36);
                        lcp.Blue = BitConverter.ToSingle(p.raw, 40);
                        lcp.Alpha = BitConverter.ToSingle(p.raw, 44);
                        pg = new ME3LibWV.CustomProperty(udk.getName(p.Name), cat, lcp, typeof(VectorProp), false, true);
                    }
                    else {
                        StructProp ppp = new StructProp();
                        ppp.name = structType;
                        ppp.nameindex = p.Value.IntValue;
                        byte[] buf = new byte[p.Value.Array.Count()];
                        for (int i = 0; i < p.Value.Array.Count(); i++)
                            buf[i] = (byte)p.Value.Array[i].IntValue;
                        List<int> buf2 = new List<int>();
                        for (int i = 0; i < p.Value.Array.Count() / 4; i++)
                            buf2.Add(BitConverter.ToInt32(buf ,i * 4));
                        ppp.data = buf2.ToArray();
                        pg = new ME3LibWV.CustomProperty(udk.getName(p.Name), cat, ppp, typeof(StructProp), false, true);
                    }
                    break;                    
                default:
                    pg = new ME3LibWV.CustomProperty(udk.getName(p.Name),cat,p.Value.IntValue,typeof(int),false,true);
                    break;
            }
            return pg;
        }