public SpecialCollisionDialog(SpecialBoxes copyFrom)
 {
     if (copyFrom != null)
     {
         foreach (SpecialCollisionBox box in copyFrom.boxes)
         {
             SpecialCollisionBox newBox = new SpecialCollisionBox();
             newBox.type = box.type;
             newBox.x1   = box.x1;
             newBox.x2   = box.x2;
             newBox.z1   = box.z1;
             newBox.z2   = box.z2;
             newBox.y    = box.y;
             cmd.boxes.Add(newBox);
         }
     }
     InitializeComponent();
     lstBoxes.KeyDown += (_, __) =>
     {
         if (__.KeyCode == Keys.Delete && lstBoxes.SelectedIndex > -1)
         {
             cmd.boxes.RemoveAt(lstBoxes.SelectedIndex);
             lstBoxes.DataSource = null;
             lstBoxes.DataSource = cmd.boxes;
         }
     };
     lstBoxes.DataSource = cmd.boxes;
 }
 private void lstBoxes_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (lstBoxes.SelectedIndex != -1)
     {
         selected = cmd.boxes[lstBoxes.SelectedIndex];
         int i = 0;
         foreach (string a in cmbType.Items)
         {
             if (Enum.GetName(typeof(KnownBoxTypes), selected.type) == a)
             {
                 cmbType.SelectedIndex = i;
                 break;
             }
             i++;
         }
         if (i >= cmbType.Items.Count)
         {
             cmbType.SelectedText = selected.type.ToString();
         }
         numX1.Value     = selected.x1;
         numZ1.Value     = selected.z1;
         numX2.Value     = selected.x2;
         numZ2.Value     = selected.z2;
         numHeight.Value = selected.y;
     }
 }
Esempio n. 3
0
        public void LoadSettings(FileParser.Block block)
        {
            sourceFileName = block.GetString("Obj File");
            if (sourceFileName != "")
            {
                LoadFile();
            }
            if (block.GetBool("Use Custom Address"))
            {
                //Set a checkbox here
                segmentOffset = block.GetInt("Custom Address");
            }
            pointerControl1.SetROMPointers(block.GetIntArray("ROM Pointers"));
            pointerControl1.SetRAMPointers(block.GetIntArray("RAM Pointers"));

            string specialPointerString = block.GetString("Special Pointers", false);

            if (specialPointerString != null)
            {
                string[] split = specialPointerString.Split(';');
                List <SpecialPointer> validPointers = new List <SpecialPointer>();
                foreach (string s in split)
                {
                    SpecialPointer newPointer = specialPointerControl1.PointerByString(s.Trim());
                    if (newPointer != null)
                    {
                        validPointers.Add(newPointer);
                    }
                }
                specialPointerControl1.SetPointers(validPointers.ToArray());
            }

            cmbTypeStyle.SelectedIndex = block.GetInt("Type Style", false);

            foreach (Control control in panelCollisionTypes.Controls)
            {
                CollisionTypeControl c = control as CollisionTypeControl;
                if (c != null)
                {
                    c.SetType(block.GetInt(c.patch.name, false));
                    c.enableImport = block.GetBool(c.patch.name + " enabled", false);
                }
            }

            int[] specialBoxTypes = block.GetIntArray("Special Boxes", false);
            int[] specialBoxX1    = block.GetIntArray("Special Boxes X1", false);
            int[] specialBoxX2    = block.GetIntArray("Special Boxes X2", false);
            int[] specialBoxZ1    = block.GetIntArray("Special Boxes Z1", false);
            int[] specialBoxZ2    = block.GetIntArray("Special Boxes Z2", false);
            int[] specialBoxY     = block.GetIntArray("Special Boxes Height", false);
            if (specialBoxTypes.Length > 0)
            {
                collision.specialBoxes = new SpecialBoxes();
            }
            for (int i = 0; i < specialBoxTypes.Length; i++)
            {
                SpecialCollisionBox box = new SpecialCollisionBox();
                box.type = (short)specialBoxTypes[i];
                if (i < specialBoxX1.Length)
                {
                    box.x1 = (short)specialBoxX1[i];
                }
                if (i < specialBoxX2.Length)
                {
                    box.x2 = (short)specialBoxX2[i];
                }
                if (i < specialBoxZ1.Length)
                {
                    box.z1 = (short)specialBoxZ1[i];
                }
                if (i < specialBoxZ2.Length)
                {
                    box.z2 = (short)specialBoxZ2[i];
                }
                if (i < specialBoxY.Length)
                {
                    box.y = (short)specialBoxY[i];
                }
                collision.specialBoxes.boxes.Add(box);
            }
        }