예제 #1
0
파일: BNCL.cs 프로젝트: poudink/NSMB-Editor
        public void LoadBNCL()
        {
            UpdaterCanCreateButtons = false;

            numberOfObjs_UpDown.Value = 0;
            for (int i = 1; i < objn_button.Length; i++)
            {
                panel1.Controls.Remove(objn_button[i]);
                objn_button[i]       = null;
                objn_xPos[i]         = 0;
                objn_yPos[i]         = 0;
                objn_xAlign[i]       = 0;
                objn_yAlign[i]       = 0;
                objn_graphicID[i]    = 0;
                graphicID_width[i]   = 0;
                graphicID_height[i]  = 0;
                graphicID_comment[i] = "";
            }

            GetGfxIDSizesForFilename();

            numberOfObjs_UpDown.Value = f.getByteAt(6);

            for (int i = 1; i <= numberOfObjs_UpDown.Value; i++)
            {
                objn_button[i] = new Button2()
                {
                    Opacity = 192,
                    Text    = string.Format("Object {0}", i),
                    Name    = string.Format("ObjectN_Button_{0}", i),
                    Tag     = i
                };
                objn_button[i].Click += new EventHandler(objn_Click);
                panel1.Controls.Add(objn_button[i]);

                ushort xPosUInt16 = f.getUshortAt(0x8 - 0x8 + (i * 0x8));
                objn_xAlign[i] = (byte)(xPosUInt16 >> 12 & 3);
                objn_xPos[i]   = (ushort)(xPosUInt16 & 0xFFF);
                if (objn_xPos[i] > 255)
                {
                    objn_xPos[i] = 255;
                }

                ushort yPosUInt16 = f.getUshortAt(0xA - 0x8 + (i * 0x8));
                objn_yAlign[i] = (byte)(yPosUInt16 >> 12 & 3);
                objn_yPos[i]   = (ushort)(yPosUInt16 & 0xFFF);
                if (objn_yPos[i] > 255)
                {
                    objn_yPos[i] = 255;
                }

                objn_graphicID[i] = f.getByteAt(0xC - 0x8 + (i * 0x8));
            }

            currentObj_UpDown.Value = 1;
            OnSelectedObjectChange(null, null);

            UpdaterCanCreateButtons = true;
        }
예제 #2
0
        public void LoadBNBL()
        {
            allowedToCreateButtons = false;

            numberOfTouchObjs_UpDown.Value = f.getByteAt(6);

            for (int i = 1; i <= numberOfTouchObjs_UpDown.Value; i++)
            {
                objn_button[i] = new Button2()
                {
                    Opacity = 192, //0.75
                    Text    = string.Format("Object {0}", i),
                    Name    = string.Format("ObjectN_Button_{0}", i),
                    Tag     = i
                };
                objn_button[i].Click += new EventHandler(objn_Click);
                panel1.Controls.Add(objn_button[i]);

                ushort xPosUInt16        = f.getUshortAt(0x8 - 0x6 + (i * 0x6));
                byte   xPosUInt12        = (byte)(xPosUInt16 & 0xFFF);
                byte   xPosAlignmentByte = (byte)(xPosUInt16 >> 12 & 3);
                objn_xPos[i] = xPosUInt12;

                ushort yPosUInt16        = f.getUshortAt(0xA - 0x6 + (i * 0x6));
                byte   yPosUInt12        = (byte)(yPosUInt16 & 0xFFF);
                byte   yPosAlignmentByte = (byte)(yPosUInt16 >> 12 & 3);
                objn_yPos[i] = yPosUInt12;

                byte widthByte = f.getByteAt(0xC - 0x6 + (i * 0x6));
                objn_width[i] = widthByte;

                byte heightByte = f.getByteAt(0xD - 0x6 + (i * 0x6));
                objn_height[i] = heightByte;

                //Do some calculations
                if (xPosAlignmentByte == 1) //If X is centered
                {
                    objn_xPos[i] -= (byte)((widthByte + 1) / 2);
                }
                else if (xPosAlignmentByte == 2) //If X is set to Bottom/Right
                {
                    objn_xPos[i] -= widthByte;
                }

                if (yPosAlignmentByte == 1) //If Y is centered
                {
                    objn_yPos[i] -= (byte)((heightByte + 1) / 2);
                }
                else if (yPosAlignmentByte == 2) //If Y is set to Bottom/Right
                {
                    objn_yPos[i] -= heightByte;
                }

                objn_button[i].Location = new Point(objn_xPos[i], objn_yPos[i]);
                objn_button[i].Width    = objn_width[i];
                objn_button[i].Height   = objn_height[i];

                xPos_UpDown.Value   = objn_xPos[1];
                yPos_UpDown.Value   = objn_yPos[1];
                width_UpDown.Value  = objn_width[1];
                height_UpDown.Value = objn_height[1];

                ObjectClicked(null, null);
            }
            currentTouchObj_UpDown.Value = 1;
            allowedToCreateButtons       = true;
        }