Пример #1
0
 public RoomEditor(Room roomToEdit)
 {
     InitializeComponent();
     Room = roomToEdit.ShallowCopy();  // copy the room to edit so we can back out without corrupting original
     name = roomNameTextBox.Text = Room.Name;
     description = descriptionTextBox.Text = Room.Description;
     shortTextBox.Text = Room.shortDescription;
      //   PopulateExitListBox();
 }
Пример #2
0
 public void LoadXml(XmlNode node)
 {
     Name = node.FirstChild["Name"].InnerText;
     Description = node.FirstChild["Description"].InnerText;
     XmlNodeList rooms = node.FirstChild["Rooms"].SelectNodes("Room");
     foreach(XmlNode room in rooms) {
         Room newRoom = new Room();
         newRoom.LoadXml(room, this);
         Rooms.Add(newRoom);
     }
 }
Пример #3
0
 private void areaComboBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     string name = areaComboBox.SelectedItem.ToString();
     SelectedArea = world.Areas.Find(area => area.Name == (string)areaComboBox.SelectedItem);
     areaTextBox.Text = SelectedArea.Name;
     roomsListBox.Items.Clear();
     roomsListBox.Items.AddRange(SelectedArea.Rooms.Select(room => room.Name).ToArray());
     SelectedRoom = SelectedArea.Rooms.List[0];
     if (roomsListBox.Items.Count > 0) {
         roomsListBox.SelectedIndex = 0;
         roomTextBox.Text = SelectedRoom.Name;
     }
 }
Пример #4
0
        public RoomForm(Room room, ApplicationSettings settings)
        {
            InitializeComponent();

            roomEdits = Functions.CloneRoomToEdit(room, settings);
            roomCheckBoxList = new List<CheckBox>();
            roomCheckBoxList.Add(roomTypeCheckBox);
            roomCheckBoxList.Add(roomLimitCheckBox);
            roomCheckBoxList.Add(roomTraitsCheckBox);

            roomTypeCheckBox.Tag = roomItem.roomType;
            roomLimitCheckBox.Tag = roomItem.roomLimits;
            roomTraitsCheckBox.Tag = roomItem.roomTraits;

            this.settings = settings;
            roomTypeTextBox.Text = GetRoomTypeFlaggedList(roomItem.roomType);

            name = nameTextBox.Text = room.Name;
            area = room.Linkage.Area;
            areaLabel.Text = room.Linkage.Area.Name;
            description = descriptionTextBox.Text = room.Description;
            tagTextBox.Text = room.Tag;

            PopulateExitRestrictedCheckedComboBox(Enum.GetNames(typeof(exitRestrictionType)));
            PopulateExitListBox(room.Exits);
            PopulateAreaComboBox(settings.world.Areas.ToArray());
            PopulateRoomComboBox();

            PopulateRoomLimitsCheckedComboBox();
            PopulateRoomTraitsCheckedComboBox();

            exitLinkTypeComboBox.DataSource = Enum.GetValues(typeof(exitType));
            exitDoorLockTypeComboBox.DataSource = Enum.GetValues(typeof(lockType));
            exitDoorDirectionalComboBox.DataSource = Enum.GetValues(typeof(direction));
            exitLinkTypeComboBox.DataSource = Enum.GetValues(typeof(exitType));

            CheckAttributes();
        }
Пример #5
0
 private void roomsListBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     SelectedRoom = SelectedArea.Rooms.FindByName((string)roomsListBox.SelectedItem);
     RefreshEditor();
 }
Пример #6
0
 private void roomsListBox_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button != MouseButtons.Right) return;
     var index = roomsListBox.IndexFromPoint(e.Location);
     if (index != ListBox.NoMatches) {
         roomsListBox.SelectedIndex = index;
         SelectedRoom = SelectedArea.Rooms.FindByName((string)roomsListBox.SelectedItem);
         for (int i = 0; i <= RoomContextMenu.Items.Count - 1; i++) {
             RoomContextMenu.Items[i].Enabled = true;
         }
         RoomContextMenu.Show(Cursor.Position);
     } else {
         roomsListBox.SelectedIndex = -1;
         for (int i = 0; i <= RoomContextMenu.Items.Count - 1; i++) {
             if (i == 0) continue;
             RoomContextMenu.Items[i].Enabled = false;
         }
     }
 }
Пример #7
0
 private void roomsListBox_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     var index = roomsListBox.IndexFromPoint(e.Location);
     if (index != ListBox.NoMatches) {
         roomsListBox.SelectedIndex = index;
         SelectedRoom = SelectedArea.Rooms.FindByName((string)roomsListBox.SelectedItem);
         EditRoomContextMenuItem_Click(sender, e);
     } else {
         roomsListBox.SelectedIndex = -1;
         // NewRoomContextMenuItem_Click(...
     }
 }
Пример #8
0
        private void RefreshEditor()
        {
            if (SelectedRoom == null) SelectedRoom = Common.Settings.TheVoid;
            roomNameLabel.Text = SelectedRoom.Name;
            roomDescriptionRichTextBox.Clear();
            roomDescriptionRichTextBox.AppendText(SelectedRoom.Description);

            ToolStripSplitButton exitsLabel = new ToolStripSplitButton("Exits:") {
                AutoToolTip = false,
                Height = 16,
                Margin = new Padding(6, 0, 0, 0)
            };
            exitsLabel.DropDownItems.Add("Add");
            exitsLabel.DropDownItemClicked += Button_DropDownItemClicked;
            exitsLabel.DropDownItems.Add("Remove All");

            ToolStrip strip = new ToolStrip() {
                Renderer = new ToolStripOverride(),
                GripStyle = ToolStripGripStyle.Hidden,
                BackColor = Color.Black,
                Height = 20,
                Margin = new Padding(0),
                LayoutStyle = ToolStripLayoutStyle.HorizontalStackWithOverflow,
                CanOverflow = false
            };

            exitLayoutPanel.Controls.Clear();
            strip.Items.Add(exitsLabel);
            foreach (Exit exit in SelectedRoom.Exits) {
                ToolStripSplitButton button = new ToolStripSplitButton(exit.ToString());
                button.Tag = exit;
                button.AutoToolTip = false;
                button.Height = 16;
                button.Margin = new Padding(0);
                button.DropDownItems.Add("Edit");
                button.DropDownItems.Add("Remove");
                button.DropDownItemClicked += Button_DropDownItemClicked;
                button.ButtonClick += Button_Click;
                strip.Items.Add(button);
            }
            exitLayoutPanel.Controls.Add(strip);
        }
Пример #9
0
 private void NewContextMenuItem_Click(object sender, EventArgs e)
 {
     Room newRoom = new Room("New Room", "This is the new room description", SelectedArea);
     SelectedArea.Rooms.Add(newRoom);
     SelectedRoom = newRoom;
     roomsListBox.Items.Clear();
     roomsListBox.Items.AddRange(SelectedArea.Rooms.Select(room => room.Name).ToArray());
     RefreshEditor();
 }
Пример #10
0
 private void Button_Click(object sender, EventArgs e)
 {
     if (((ToolStripSplitButton)sender).Text == "Exits:") return;
     SelectedRoom = ((Exit)((ToolStripSplitButton)sender).Tag).Room;
     SelectedArea = SelectedRoom.Area;
     RefreshEditor();
     SyncControls();
 }
Пример #11
0
        public void LoadXml(XmlNode node, Room room)
        {
            Owner = room;
            Area = room.Area;

            Name = node["Name"].InnerText;
            Description = node["Description"].InnerText;
            DoorLabel = node["DoorDescription"].InnerText;
            roomName = node["Room"].InnerText;
            areaName = node["Area"].InnerText;
            Visible = Convert.ToBoolean(node["Visible"].InnerText);
            Breakable = Convert.ToBoolean(node["Breakable"].InnerText);
            ExitType = (exitType)Enum.Parse(typeof(exitType), node["ExitType"].InnerText);

            var lockNode = node.SelectSingleNode("Lock");
            if (lockNode != null) {
                LockType = new lockType();
                XmlNodeList locks = node["Lock"].SelectNodes("LockType");
                foreach (XmlNode locktype in locks) {
                    LockType |= (lockType)Enum.Parse(typeof(lockType), locktype.InnerText);
                }
            }

            var doorNode = node.SelectSingleNode("Door");
            if (doorNode != null) {
                DoorType = new doorType();
                XmlNodeList doors = node["Door"].SelectNodes("DoorType");
                foreach (XmlNode doortype in doors) {
                    DoorType |= (doorType)Enum.Parse(typeof(doorType), doortype.InnerText);
                }
            }

            var restrictionNode = node.SelectSingleNode("Restrictions");
            if (restrictionNode != null) {
                Restrictions = new exitRestrictions();
                XmlNodeList restrictions = node["Restrictions"].SelectNodes("Restriction");
                foreach (XmlNode restriction in restrictions) {
                    Restrictions |= (exitRestrictions)Enum.Parse(typeof(exitRestrictions), restriction.InnerText);
                }
            }
        }
Пример #12
0
 public void AddRoom(Room room)
 {
     room.Area = this;
     Rooms.Add(room);
 }