Наследование: System.Windows.Forms.Form
Пример #1
0
        //Creates a new empty room and allows editing
        private void mi_New_Room_Click(object sender, EventArgs e)
        {
            //Get the new room from the user.
            StringPromptDialog dialog = new StringPromptDialog("Enter the name of the room: ");

            //Create the world.
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                currentlySelectedRoom = new Room(dialog.UserInput);

                enableEditing(false);

                switchRooms(currentlySelectedRoom);
            }
        }
Пример #2
0
        //Creates a new game world and allows editing
        private void mi_New_World_Click(object sender, EventArgs e)
        {
            //Get the new room from the user.
            StringPromptDialog dialog = new StringPromptDialog("Enter the name of the first room: ");

            //Create the world.
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                world = new GameWorld(dialog.UserInput);

                enableEditing(true);

                switchRooms(world.CurrentRoom);
            }
        }
Пример #3
0
        private void mi_merge_room_Click(object sender, EventArgs e)
        {
            //Get the room we want to load
            OpenFileDialog dialog = new OpenFileDialog();
            dialog.Filter = "Room Files | *.room";
            dialog.InitialDirectory = ".";
            dialog.Title = "Choose the room you want to merge";

            DialogResult result = dialog.ShowDialog();

            //If the result was ok, load the resultant file, otherwise, just return.
            if (result == DialogResult.OK)
            {
                Room toMerge = Serializer.DeserializeRoom(dialog.FileName);

                //Check if it's name is unique
                while (!isRoomNameUnique(toMerge.name))
                {
                    StringPromptDialog name_dialog =
                        new StringPromptDialog(
                            "Room named "
                            + toMerge.name
                            + " name already exists, enter new name!");

                    if (name_dialog.ShowDialog() == DialogResult.OK)
                    {
                        toMerge.name = name_dialog.UserInput;
                    }
                    else
                    {
                        return;
                    }
                }

                //Add the room to the list.
                world.Rooms.Add(toMerge);

                switchRooms(toMerge);
            }
        }
Пример #4
0
        //Creates a door at the location of the user click.
        private void makeDoor(DrawPoint pt)
        {
            //First, get name for door
            StringPromptDialog dialog = new StringPromptDialog("Please enter the name of the door");

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                if (isDoorNameUnique(dialog.UserInput))
                {
                    //Create the door
                    Vector2 postition = new Vector2(
                        pt.X - (EditorConstants.DEFAULT_DOOR_SIZE / 2),
                        pt.Y - (EditorConstants.DEFAULT_DOOR_SIZE / 2));

                    string boundsFile = currdir + "\\Art\\Doors\\Door.tri";

                    Door door = new Door(postition, boundsFile, dialog.UserInput, currentlySelectedRoom);

                    //Add it to the current room
                    currentlySelectedRoom.AddObject(door);

                }
                else
                {
                    showMessage("Name Entry Error",
                        "A door already exists in the current room with the name " + dialog.UserInput);
                }
            }
        }
Пример #5
0
        //Trys and creates a new room. Pops up a RoomCreateDialog.
        private void createNewRoomToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (currentState == State.EDITING_WORLD)
            {
                StringPromptDialog dialog =
                    new StringPromptDialog("Please enter the name of the room");

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    if (isRoomNameUnique(dialog.UserInput))
                    {

                        Room room = new Room(dialog.UserInput);
                        world.Rooms.Add(room);
                        switchRooms(room);
                    }
                    else
                    {
                        MessageBox.Show(
                            "A room already exists with the name " + dialog.UserInput,
                            "Name Entry Error",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Exclamation);
                    }
                }
            }
        }
Пример #6
0
        //------------End of saving/loading functions-------------------------------------------------------
        //------------Functions for working with doors------------------------------------------------------
        //If the currently selected object is a door, then pops up a prompt asking for the new name for the
        //   door, verifies that it is unique, and renames the door.
        private void renameDoorToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (currentlySelectedObject != null &&
                currentlySelectedObject is Door)
            {
                StringPromptDialog dialog = new StringPromptDialog("Enter the new name: ");

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    if (isDoorNameUnique(dialog.UserInput))
                    {
                        ((Door)currentlySelectedObject).name = dialog.UserInput;
                    }
                    else
                    {
                        showMessage("Uniqueness Error", "A door with that name already exists in the room");
                    }
                }
            }
        }
Пример #7
0
        //Renames the current room. The callback for the "Rename current room..." option under
        //the room menu
        private void renameCurrentRoomToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (currentState != State.NO_EDITS)
            {
                StringPromptDialog dialog = new StringPromptDialog("Please enter the new name:");

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    if (currentState == State.EDITING_ROOM || isRoomNameUnique(dialog.UserInput))
                    {
                        currentlySelectedRoom.name = dialog.UserInput;
                        updateTitle();
                    }
                    else
                    {
                        showMessage("Name Entry Error", "A room already exists with the name " + dialog.UserInput);
                    }
                }
            }
        }