private void ObjectClicked(object sender, EventArgs e) { if (currentTouchObj_UpDown != null && numberOfTouchObjs_UpDown != null) { currentTouchObj_UpDown.Maximum = numberOfTouchObjs_UpDown.Value; if (currentTouchObj_UpDown.Value > currentTouchObj_UpDown.Maximum && currentTouchObj_UpDown.Value != 1) { currentTouchObj_UpDown.Value = currentTouchObj_UpDown.Maximum; } if (xPos_UpDown != null && yPos_UpDown != null && width_UpDown != null && height_UpDown != null) { xPos_UpDown.Value = objn_xPos[(byte)currentTouchObj_UpDown.Value]; yPos_UpDown.Value = objn_yPos[(byte)currentTouchObj_UpDown.Value]; width_UpDown.Value = objn_width[(byte)currentTouchObj_UpDown.Value]; height_UpDown.Value = objn_height[(byte)currentTouchObj_UpDown.Value]; } for (int i = 1; i < objn_button.Length; i++) { if (objn_button[i] != null) { if (currentTouchObj_UpDown.Value == i) { objn_button[i].BackColor = Color.FromArgb(Color.Yellow.R, Color.Yellow.G, Color.Yellow.B); } else { objn_button[i].BackColor = Color.FromArgb(221, 221, 221); } if (i > numberOfTouchObjs_UpDown.Value) { panel1.Controls.Remove(objn_button[i]); objn_button[i] = null; } } else if (objn_button[i] == null && i <= numberOfTouchObjs_UpDown.Value) { if (allowedToCreateButtons == true) { objn_button[i] = new Button2() { Width = 75, Height = 50, 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]); objn_xPos[i] = 0; objn_yPos[i] = 0; objn_width[i] = 75; objn_height[i] = 50; } } } } }
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; }
private void OnSelectedObjectChange(object sender, EventArgs e) { if (currentObj_UpDown != null && numberOfObjs_UpDown != null && xPos_UpDown != null && yPos_UpDown != null && xPosAlign_UpDown != null && yPosAlign_UpDown != null && graphicID_UpDown != null && gfxWidth_UpDown != null && gfxHeight_UpDown != null && desc_label != null) { currentObj_UpDown.Maximum = numberOfObjs_UpDown.Value; if (currentObj_UpDown.Value > currentObj_UpDown.Maximum && currentObj_UpDown.Value != 1) { currentObj_UpDown.Value = currentObj_UpDown.Maximum; } xPos_UpDown.Value = objn_xPos[(byte)currentObj_UpDown.Value]; yPos_UpDown.Value = objn_yPos[(byte)currentObj_UpDown.Value]; xPosAlign_UpDown.Value = objn_xAlign[(byte)currentObj_UpDown.Value]; yPosAlign_UpDown.Value = objn_yAlign[(byte)currentObj_UpDown.Value]; graphicID_UpDown.Value = objn_graphicID[(byte)currentObj_UpDown.Value]; gfxWidth_UpDown.Value = graphicID_width[(byte)graphicID_UpDown.Value]; gfxHeight_UpDown.Value = graphicID_height[(byte)graphicID_UpDown.Value]; desc_label.Text = graphicID_comment[(byte)graphicID_UpDown.Value]; } for (int i = 1; i < objn_button.Length; i++) { if (objn_button[i] != null) { if (currentObj_UpDown.Value == i) { objn_button[i].BackColor = Color.FromArgb(0xFFFF00); } else { objn_button[i].BackColor = Color.FromArgb(225, 225, 225); } if (i > numberOfObjs_UpDown.Value) { panel1.Controls.Remove(objn_button[i]); objn_button[i] = null; } } else if (objn_button[i] == null && numberOfObjs_UpDown.Value >= i) { if (UpdaterCanCreateButtons == true) { 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]); objn_xPos[i] = 0; objn_xAlign[i] = 0; objn_yPos[i] = 0; objn_yAlign[i] = 0; objn_graphicID[i] = 0; } } } }