/// <summary> /// Inserts an actor in the grid /// </summary> /// <param name="grid">The grid where the actor will be inserted</param> /// <param name="editButton">The edit button that will be enabled (if there is an actor)</param> /// <param name="removeButton">Ditto for the removeButton</param> /// <param name="type">The type of the new blueprint</param> /// <param name="list">The list that the new actor will be added to</param> /// <param name="dataName">The name of the data cell in the grid</param> private static void insertActor(DataGridView grid, EnumTypes.actorType type, ref LinkedList<Actor> list, String dataCell) { modifyForm = ModifyNew.getModifyNew(type); // If the user wants to create a new blueprint, and there is only one type, then we might as well create that modifyForm.testCreate(); Actor actor = null; if (modifyForm.ShowDialog() == DialogResult.OK) { actor = ModifyNew.lastActor; if (actor != null) { LinkedList<Actor> dummyList = new LinkedList<Actor>(); dummyList.AddLast(actor); setGrid(grid, dummyList, list, dataCell, type); } } }
/// <summary> /// The modifyNew form is created for creating new actors /// </summary> /// <param name="type">The type of actors that can be returned</param> /// <returns></returns> public static ModifyNew getModifyNew(EnumTypes.actorType type) { edit = false; saveValue = false; if (modifyNew == null) { modifyNew = new ModifyNew(); debug("Create new modify"); } modifyNew.Text = "Create new blueprint"; modifyNew.comboType.Items.Clear(); modifyNew.propGrid.SelectedObjects = null; modifyNew.propGrid.RefreshGrid(); // I set which types can created if ((type & EnumTypes.actorType.Creature) == EnumTypes.actorType.Creature) modifyNew.comboType.Items.Add("Creature"); if ((type & EnumTypes.actorType.Door) == EnumTypes.actorType.Door) modifyNew.comboType.Items.Add("Door"); if ((type & EnumTypes.actorType.Placeable) == EnumTypes.actorType.Placeable) modifyNew.comboType.Items.Add("Placeable"); if ((type & EnumTypes.actorType.Item) == EnumTypes.actorType.Item) modifyNew.comboType.Items.Add("Item"); if ((type & EnumTypes.actorType.TriggerRegion) == EnumTypes.actorType.TriggerRegion) modifyNew.comboType.Items.Add("Trigger"); if (modifyNew.comboType.Items.Count > 0) modifyNew.comboType.SelectedIndex = 0; return modifyNew; }
/// <summary> /// Edit a actor in a multiple actor grid /// </summary> /// <param name="grid"></param> /// <param name="type">The type of actor</param> /// <param name="dataName">The name of the datacell</param> /// <param name="list">The list of actors (extra, item, triggers)</param> private static void editActor(DataGridView grid, EnumTypes.actorType type, String dataName, LinkedList<Actor> list) { if (grid.SelectedRows.Count > 0) { int gridNumber = grid.SelectedRows[0].Index; Actor oldActor = gridGetActor(grid, dataName); if (oldActor != null) { modifyForm = ModifyNew.getModifyNew(oldActor, type); if (modifyForm.ShowDialog() == DialogResult.OK) { Actor actor = ModifyNew.lastActor; grid[0, gridNumber].Value = actor.ToString(); grid[1, gridNumber].Value = actor.Tag; grid[dataName, gridNumber].Value = actor; if (list != null) { list.Remove(oldActor); list.AddLast(actor); } } } } }