/// <summary>
        ///
        /// </summary>
        /// <param name="stockNode"></param>
        public void LoadStockNode(MEX_Stock stockNode)
        {
            StockNode = stockNode;

            var keys  = stockNode.MatAnimJoint.MaterialAnimation.TextureAnimation.AnimationObject.FObjDesc.GetDecodedKeys();
            var tobjs = stockNode.MatAnimJoint.MaterialAnimation.TextureAnimation.ToTOBJs();

            ReservedItems = new StockIconNode[stockNode.Reserved];
            Items         = new StockIconNode[stockNode.Stride];

            //
            for (int i = 0; i < stockNode.Reserved; i++)
            {
                ReservedItems[i] = new StockIconNode();
                var frame = keys.Find(e => e.Frame == i);
                if (frame != null)
                {
                    ReservedItems[i].TOBJS = new TOBJProxy[] { new TOBJProxy(tobjs[(int)frame.Value]) }
                }
                ;
            }

            //
            for (int i = 0; i < stockNode.Stride; i++)
            {
                Items[i] = new StockIconNode();
                var colorCount = 0;

                while (keys.Find(e => e.Frame == stockNode.Reserved + stockNode.Stride * colorCount + i) != null)
                {
                    colorCount++;
                }

                Items[i].TOBJS = new TOBJProxy[colorCount];

                for (int color = 0; color < colorCount; color++)
                {
                    var frame = keys.Find(e => e.Frame == stockNode.Reserved + stockNode.Stride * color + i);

                    if (frame != null)
                    {
                        Items[i].TOBJS[color] = new TOBJProxy(tobjs[(int)frame.Value]);
                    }
                }
            }

            arrayMemberEditor1.SetArrayFromProperty(this, "Items");
            arrayMemberEditor2.SetArrayFromProperty(this, "ReservedItems");
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        public static MEX_Stock GenerateStockIconNodeFromVanilla(HSD_TexAnim texanim)
        {
            // extract tex anim assets
            var         tobjs  = texanim.ToTOBJs();
            var         keys   = texanim.AnimationObject.FObjDesc.GetDecodedKeys();
            FOBJ_Player player = new FOBJ_Player();

            player.Keys = keys;


            // generate stock node
            var stockNode = new MEX_Stock();

            stockNode.Reserved = 10;
            stockNode.Stride   = 26;

            var newTobjs = new List <HSD_TOBJ>();
            var newKeys  = new List <FOBJKey>();

            // get hardcoded images

            /*
             *  0 - blank
             * 1 - smash ball
             * 2 - master hand
             * 3 - crazy hand
             * 4 - target
             * 5 - giga bowser
             * 6 - sandbag
             * 7 - red dot
             * 8 - furby
             */

            int[] hardcoded = new[] { 250, 26, 27, 28, 57, 58, 59, 185, 185 };

            for (int i = 0; i < hardcoded.Length; i++)
            {
                newKeys.Add(new FOBJKey()
                {
                    Frame = i, InterpolationType = GXInterpolationType.HSD_A_OP_CON, Value = newTobjs.Count
                });
                newTobjs.Add(tobjs[(int)player.GetValue(hardcoded[i])]);
            }

            // get fighter stock icons
            for (int i = 0; i < 27; i++)
            {
                int color = 0;
                while (true)
                {
                    var key = keys.Find(e => e.Frame == color * 30 + (i == 26 ? 29 : i));

                    if (key != null)
                    {
                        newKeys.Add(new FOBJKey()
                        {
                            Frame = 10 + color * 26 + i, InterpolationType = GXInterpolationType.HSD_A_OP_CON, Value = newTobjs.Count
                        });
                        newTobjs.Add(tobjs[(int)key.Value]);
                        color++;
                    }
                    else
                    {
                        break;
                    }
                }
            }

            // order keys
            newKeys = newKeys.OrderBy(e => e.Frame).ToList();
            foreach (var k in newKeys)
            {
                Console.WriteLine(k.Frame + " " + k.Value);
            }

            // generate new tex anim
            var newTexAnim = new HSD_TexAnim();

            newTexAnim.AnimationObject          = new HSD_AOBJ();
            newTexAnim.AnimationObject.FObjDesc = new HSD_FOBJDesc();
            newTexAnim.AnimationObject.FObjDesc.SetKeys(newKeys, (byte)TexTrackType.HSD_A_T_TIMG);
            newTexAnim.AnimationObject.FObjDesc.Next = new HSD_FOBJDesc();
            newTexAnim.AnimationObject.FObjDesc.Next.SetKeys(newKeys, (byte)TexTrackType.HSD_A_T_TCLT);

            newTexAnim.FromTOBJs(newTobjs, false);

            stockNode.MatAnimJoint = new HSD_MatAnimJoint();
            stockNode.MatAnimJoint.MaterialAnimation = new HSD_MatAnim();
            stockNode.MatAnimJoint.MaterialAnimation.TextureAnimation = newTexAnim;

            return(stockNode);
        }