Пример #1
0
        private void ObjectList_DoubleClick(object sender, EventArgs e)
        {
            NewObjectForm frm = new NewObjectForm(1); //We are modifying an object so the "formtype" should be 1

            switch (loadedRSDKver)                    //Set the form's values to the selected Object's values
            {
            case 3:
                frm.TypeNUD.Value    = objectsV1[ObjectList.SelectedIndex].type;
                frm.SubtypeNUD.Value = objectsV1[ObjectList.SelectedIndex].subtype;
                frm.XposNUD.Value    = objectsV1[ObjectList.SelectedIndex].xPos;
                frm.YposNUD.Value    = objectsV1[ObjectList.SelectedIndex].yPos;
                break;

            case 2:
                frm.TypeNUD.Value    = objectsV2[ObjectList.SelectedIndex].type;
                frm.SubtypeNUD.Value = objectsV2[ObjectList.SelectedIndex].subtype;
                frm.XposNUD.Value    = objectsV2[ObjectList.SelectedIndex].xPos;
                frm.YposNUD.Value    = objectsV2[ObjectList.SelectedIndex].yPos;
                break;

            case 1:
                frm.TypeNUD.Value    = objectsV3[ObjectList.SelectedIndex].type;
                frm.SubtypeNUD.Value = objectsV3[ObjectList.SelectedIndex].subtype;
                frm.XposNUD.Value    = objectsV3[ObjectList.SelectedIndex].xPos;
                frm.YposNUD.Value    = objectsV3[ObjectList.SelectedIndex].yPos;
                break;

            case 0:
                frm.TypeNUD.Value    = objectsV4[ObjectList.SelectedIndex].type;
                frm.SubtypeNUD.Value = objectsV4[ObjectList.SelectedIndex].subtype;
                frm.XposNUD.Value    = objectsV4[ObjectList.SelectedIndex].xPos;
                frm.YposNUD.Value    = objectsV4[ObjectList.SelectedIndex].yPos;
                break;
            }

            if (frm.ShowDialog(this) == DialogResult.OK)
            {
                if (frm.RemoveObject == 0) //Make sure we didn't decide to remove the object
                {
                    switch (loadedRSDKver) //Set the new values
                    {
                    case 3:
                        RSDKv1.Object Obj1 = new RSDKv1.Object(frm.Type, frm.Subtype, frm.Xpos, frm.Ypos); //Create a temp object to store our data
                        MapView._RSDK1Level.objects[ObjectList.SelectedIndex] = Obj1;                      //Modify the selected object's data
                        objectsV1[ObjectList.SelectedIndex] = Obj1;                                        //Modify the selected object's data
                        break;

                    case 2:
                        RSDKv2.Object Obj2 = new RSDKv2.Object(frm.Type, frm.Subtype, frm.Xpos, frm.Ypos);
                        MapView._RSDK2Level.objects[ObjectList.SelectedIndex] = Obj2;
                        objectsV2[ObjectList.SelectedIndex] = Obj2;
                        break;

                    case 1:
                        RSDKv3.Object Obj3 = new RSDKv3.Object(frm.Type, frm.Subtype, frm.Xpos, frm.Ypos);
                        MapView._RSDK3Level.objects[ObjectList.SelectedIndex] = Obj3;
                        objectsV3[ObjectList.SelectedIndex] = Obj3;
                        break;

                    case 0:
                        RSDKv4.Object Obj4 = new RSDKv4.Object(frm.Type, frm.Subtype, frm.Xpos, frm.Ypos);
                        MapView._RSDK4Level.objects[ObjectList.SelectedIndex] = Obj4;
                        objectsV4[ObjectList.SelectedIndex] = Obj4;
                        break;
                    }
                }
                else if (frm.RemoveObject == 1)
                {
                    switch (loadedRSDKver)
                    {
                    case 3:
                        MapView._RSDK1Level.objects.RemoveAt(ObjectList.SelectedIndex);     //Delete Selected Object
                        break;

                    case 2:
                        MapView._RSDK2Level.objects.RemoveAt(ObjectList.SelectedIndex);     //Delete Selected Object
                        break;

                    case 1:
                        MapView._RSDK3Level.objects.RemoveAt(ObjectList.SelectedIndex);     //Delete Selected Object
                        break;

                    case 0:
                        MapView._RSDK4Level.objects.RemoveAt(ObjectList.SelectedIndex);     //Delete Selected Object
                        break;
                    }
                }
                RefreshObjList(); //Reload the list of objects
            }
        }
Пример #2
0
        void pnlMap_MouseDown(object sender, MouseEventArgs e)
        {
            Point tilePointNew = new Point(e.X / 128, e.Y / 128); //Get the point on the map to place the chunk! It's divided by 128 so it sticks to the grid!

            switch (e.Button)
            {
            case MouseButtons.Left:
                if (PlacementMode == 0)
                {
                    tilePoint = tilePointNew;
                    DrawLevel();
                }
                if (PlacementMode == 1)
                {
                    tilePoint = tilePointNew;
                    SetChunk(tilePoint, (ushort)_ChunkView.selectedChunk);     //Place Selected Chunk
                    DrawLevel();
                }
                if (PlacementMode == 2)
                {
                    NewObjectForm frm = new NewObjectForm(0);
                    //Where is the mouse?
                    frm.XposNUD.Value = e.X;
                    frm.YposNUD.Value = e.Y;

                    if (frm.ShowDialog(this) == DialogResult.OK)
                    {
                        switch (loadedRSDKver)
                        {
                        case 3:
                            RSDKv1.Object Obj1 = new RSDKv1.Object(frm.Type, frm.Subtype, frm.Xpos, frm.Ypos); //make an object from the data we got!
                            _RSDK1Level.objects.Add(Obj1);                                                     //Add it to the map!
                            _ChunkView.RefreshObjList();                                                       //Update the list!
                            DrawLevel();
                            break;

                        case 2:
                            RSDKv2.Object Obj2 = new RSDKv2.Object(frm.Type, frm.Subtype, frm.Xpos, frm.Ypos); //make an object from the data we got!
                            _RSDK2Level.objects.Add(Obj2);                                                     //Add it to the map!
                            _ChunkView.RefreshObjList();                                                       //Update the list!
                            DrawLevel();
                            break;

                        case 1:
                            RSDKv3.Object Obj3 = new RSDKv3.Object(frm.Type, frm.Subtype, frm.Xpos, frm.Ypos); //make an object from the data we got!
                            _RSDK3Level.objects.Add(Obj3);                                                     //Add it to the map!
                            _ChunkView.RefreshObjList();                                                       //Update the list!
                            DrawLevel();
                            break;

                        case 0:
                            RSDKv4.Object Obj4 = new RSDKv4.Object(frm.Type, frm.Subtype, frm.Xpos, frm.Ypos); //make an object from the data we got!
                            _RSDK4Level.objects.Add(Obj4);                                                     //Add it to the map!
                            _ChunkView.RefreshObjList();                                                       //Update the list!
                            DrawLevel();
                            break;
                        }
                    }
                }
                break;

            case MouseButtons.Right:
                if (PlacementMode == 0)
                {
                    tilePoint = tilePointNew;
                    DrawLevel();
                    int selChunk;
                    switch (loadedRSDKver)     //Copy chunk
                    {
                    case 0:
                        selChunk = _RSDK4Level.MapLayout[tilePoint.Y][tilePoint.X];
                        _ChunkView.BlocksList.SelectedIndex = selChunk;
                        _ChunkView.BlocksList.Refresh();
                        break;

                    case 1:
                        selChunk = _RSDK3Level.MapLayout[tilePoint.Y][tilePoint.X];
                        _ChunkView.BlocksList.SelectedIndex = selChunk;
                        _ChunkView.BlocksList.Refresh();
                        break;

                    case 2:
                        selChunk = _RSDK2Level.MapLayout[tilePoint.Y][tilePoint.X];
                        _ChunkView.BlocksList.SelectedIndex = selChunk;
                        _ChunkView.BlocksList.Refresh();
                        break;

                    case 3:
                        selChunk = _RSDK1Level.MapLayout[tilePoint.Y][tilePoint.X];
                        _ChunkView.BlocksList.SelectedIndex = selChunk;
                        _ChunkView.BlocksList.Refresh();
                        break;

                    default:
                        break;
                    }
                }
                if (PlacementMode == 1)
                {
                    tilePoint = tilePointNew;
                    SetChunk(tilePoint, 0);     //Delete the chunk
                    DrawLevel();
                }
                break;

            case MouseButtons.Middle:
                tilePoint = tilePointNew;
                DrawLevel();
                int chunk;
                switch (loadedRSDKver)     //Check the RSDK version then Copy the chunk
                {
                case 0:
                    chunk = _RSDK4Level.MapLayout[tilePoint.Y][tilePoint.X];
                    _ChunkView.BlocksList.SelectedIndex = chunk;         //Change the selected index of the chunklist!
                    _ChunkView.BlocksList.Refresh();
                    break;

                case 1:
                    chunk = _RSDK3Level.MapLayout[tilePoint.Y][tilePoint.X];
                    _ChunkView.BlocksList.SelectedIndex = chunk;
                    _ChunkView.BlocksList.Refresh();
                    break;

                case 2:
                    chunk = _RSDK2Level.MapLayout[tilePoint.Y][tilePoint.X];
                    _ChunkView.BlocksList.SelectedIndex = chunk;
                    _ChunkView.BlocksList.Refresh();
                    break;

                case 3:
                    chunk = _RSDK1Level.MapLayout[tilePoint.Y][tilePoint.X];
                    _ChunkView.BlocksList.SelectedIndex = chunk;
                    _ChunkView.BlocksList.Refresh();
                    break;

                default:
                    break;
                }
                break;
            }
        }