@Override
	public void mousePressed(MouseEvent e) {
		Point point = mView.pos2Point(e.getX(), e.getY());
		if (point == null)
			return;
		
		Sprite sprite = createSprite(point);
		// Test if we were allowed to create the sprite. Hopefully we always are. 
		if (sprite == null)
			return;
		Room room = mModel.getRoom(point);
		
		// Check if the target already has an editable type of the same level
		// as the sprite we are inserting.
		if (sprite instanceof Room && MazeController.isEditableType(room)
				|| !(sprite instanceof Room) && MazeController.isEditableType(room.inner())) {
			JOptionPane.showMessageDialog(mView, "You can't insert on top of other things.");
			return;
		}
		
		Room newRoom;
		// If inserting an "inner" type
		if (!(sprite instanceof Room)) {
			assert !MazeController.isEditableType(room.inner());
			newRoom = room.withInner(sprite);
		}
		// If inserting a room type
		else {
			assert sprite instanceof Room;
			assert !MazeController.isEditableType(room);
			newRoom = ((Room)sprite).withInner(room.inner());
		}
		
		// Check validation (without repainting)
		mModel.getMaze().putRoom(newRoom);
		ValidationResult result = mModel.validateMaze();
		if (!result.isLegal()) {
			// Restore maze
			mModel.getMaze().putRoom(room);
			JOptionPane.showMessageDialog(mView, result.getMessage() + ".");
			return;
		}
		
		// Invalidate the board for a repaint.
		mModel.putRoom(newRoom);
	}