public BoardItemContextMenu(MultiBoard multiboard, Board board, BoardItem target) { this.multiboard = multiboard; this.board = board; this.target = target; this.cms = null; }
public UndoRedoAction(BoardItem item, UndoRedoType type, object ParamA, object ParamB) { this.item = item; this.type = type; this.ParamA = ParamA; this.ParamB = ParamB; }
public void PlaceObject() { if (state == MouseState.StaticObjectAdding || state == MouseState.RandomTiles) { Board.UndoRedoMan.AddUndoBatch(new List<UndoRedoAction>() { UndoRedoManager.ItemAdded(currAddedObj) }); //Board.BoardItems.Add(currAddedObj.CreateInstance(Board.Layers[Board.SelectedLayerIndex], Board, x, y, 50, false, false)); currAddedObj.BeforeAdding = false; ReleaseItem(currAddedObj); if (currAddedObj is LayeredItem) { int highestZ = 0; foreach (LayeredItem item in Board.BoardItems.TileObjs) if (item.Z > highestZ) highestZ = item.Z; currAddedObj.Z = highestZ; Board.BoardItems.Sort(); } if (state == MouseState.StaticObjectAdding) currAddedObj = currAddedInfo.CreateInstance(Board.SelectedLayer, Board, X + currAddedInfo.Origin.X - currAddedInfo.Image.Width / 2, Y + currAddedInfo.Origin.Y - currAddedInfo.Image.Height / 2, 50, false, true); else currAddedObj = tileRandomList[NextInt32(tileRandomList.Length)].CreateInstance(Board.SelectedLayer, Board, X + currAddedInfo.Origin.X - currAddedInfo.Image.Width / 2, Y + currAddedInfo.Origin.Y - currAddedInfo.Image.Height / 2, 50, false, true); Board.BoardItems.Add(currAddedObj, false); BindItem(currAddedObj, new Microsoft.Xna.Framework.Point(currAddedInfo.Origin.X - currAddedInfo.Image.Width / 2, currAddedInfo.Origin.Y - currAddedInfo.Image.Height / 2)); } else if (state == MouseState.Chairs) { Board.UndoRedoMan.AddUndoBatch(new List<UndoRedoAction> { UndoRedoManager.ItemAdded(currAddedObj) }); ReleaseItem(currAddedObj); currAddedObj = new Chair(Board, X, Y, true); Board.BoardItems.Add(currAddedObj, false); BindItem(currAddedObj, new Microsoft.Xna.Framework.Point()); } else if (state == MouseState.Ropes) { int count = BoundItems.Count; object[] keys = new object[count]; BoundItems.Keys.CopyTo(keys, 0); RopeAnchor anchor = (RopeAnchor)keys[0]; ReleaseItem(anchor); if (count == 1) { Board.UndoRedoMan.AddUndoBatch(new List<UndoRedoAction> { UndoRedoManager.RopeAdded(anchor.ParentRope) }); CreateRope(); } } else if (state == MouseState.Tooltip) { int count = BoundItems.Count; object[] keys = new object[count]; BoundItems.Keys.CopyTo(keys, 0); ToolTipDot dot = (ToolTipDot)keys[0]; ReleaseItem(dot); if (count == 1) { Board.UndoRedoMan.AddUndoBatch(new List<UndoRedoAction> { UndoRedoManager.ItemAdded(dot.ParentTooltip) }); CreateTooltip(); } } }
public GeneralInstanceEditor(BoardItem item) { InitializeComponent(); this.item = item; xInput.Value = item.X; yInput.Value = item.Y; if (item.Z == -1) zInput.Enabled = false; else zInput.Value = item.Z; pathLabel.Text = HaCreatorStateManager.CreateItemDescription(item, "\r\n"); }
public GeneralInstanceEditor(BoardItem item) { InitializeComponent(); this.item = item; styleManager.ManagerStyle = UserSettings.applicationStyle; xInput.Value = item.X; yInput.Value = item.Y; if (item.Z == -1) zInput.Enabled = false; else zInput.Value = item.Z; pathLabel.Text = Editor.CreateItemDescription(item, "\r\n"); }
public void SendToBackClicked(BoardItem item) { if (OnSendToBackClicked != null) OnSendToBackClicked.Invoke(item); }
public void BringToFrontClicked(BoardItem item) { if (OnBringToFrontClicked != null) OnBringToFrontClicked.Invoke(item); }
public override void ReleaseItem(BoardItem item) { if (BoundItems.Contains(item)) { BoundItems.Remove(item); item.Parent = item.tempParent; item.tempParent = null; } }
public virtual void BindItem(BoardItem item, XNA.Point distance) { lock (Board.ParentControl) { if (boundItems.ContainsKey(item)) return; boundItems[item] = distance; boundItemsList.Add(item); item.parent = this; } }
public void Clear() { List<UndoRedoAction> foo = new List<UndoRedoAction>(); //the undoPipe here has no meaning, we don't need any undo info anyway if (currAddedObj != null) { currAddedObj.RemoveItem(ref foo); currAddedObj = null; } if (state == MouseState.Ropes || state == MouseState.Tooltip) { object[] keys = new object[BoundItems.Keys.Count]; BoundItems.Keys.CopyTo(keys, 0); if (state == MouseState.Ropes) ((RopeAnchor)keys[0]).RemoveItem(ref foo); else ((ToolTipDot)keys[0]).ParentTooltip.RemoveItem(ref foo); } else if (state == MouseState.Footholds && connectedLines.Count > 0) { FootholdLine fh = (FootholdLine)connectedLines[0]; fh.Remove(false, ref foo); Board.BoardItems.FootholdLines.Remove(fh); } InputHandler.ClearBoundItems(Board); InputHandler.ClearSelectedItems(Board); IsDown = false; }
public void SetChairMode() { Clear(); currAddedObj = new Chair(Board, X, Y, true); Board.BoardItems.Add(currAddedObj, false); BindItem(currAddedObj, new Microsoft.Xna.Framework.Point()); state = MouseState.Chairs; }
private void multiBoard_OnBringToFrontClicked(BoardItem boardRefItem) { foreach (BoardItem item in boardRefItem.Board.SelectedItems) { int oldZ = item.Z; if (item is BackgroundInstance) { IList list = ((BackgroundInstance)item).front ? multiBoard.SelectedBoard.BoardItems.FrontBackgrounds : multiBoard.SelectedBoard.BoardItems.BackBackgrounds; int highestZ = 0; foreach (BackgroundInstance bg in list) if (bg.Z > highestZ) highestZ = bg.Z; item.Z = highestZ + 1; } else { int highestZ = 0; foreach (LayeredItem layeredItem in multiBoard.SelectedBoard.BoardItems.TileObjs) if (layeredItem.Z > highestZ) highestZ = layeredItem.Z; item.Z = highestZ + 1; } if (item.Z != oldZ) item.Board.UndoRedoMan.AddUndoBatch(new List<UndoRedoAction> { UndoRedoManager.ItemZChanged(item, oldZ, item.Z) }); } boardRefItem.Board.BoardItems.Sort(); multiBoard.RenderFrame(); }
public virtual void BindItem(BoardItem item, Point distance) { if (boundItems.Contains(item)) return; boundItems[item] = distance; item.parent = this; }
private void multiBoard_OnEditBaseClicked(BoardItem item) { }
private void multiBoard_OnSendToBackClicked(BoardItem boardRefItem) { foreach (BoardItem item in boardRefItem.Board.SelectedItems) { if (item.Z > 0) { item.Board.UndoRedoMan.AddUndoBatch(new List<UndoRedoAction> { UndoRedoManager.ItemZChanged(item, item.Z, 0) }); item.Z = 0; } } boardRefItem.Board.BoardItems.Sort(); multiBoard.RenderFrame(); }
private void multiBoard_OnEditInstanceClicked(BoardItem item) { InputHandler.ClearBoundItems(multiBoard.SelectedBoard); switch (item.GetType().Name) { case "ObjectInstance": new InstanceEditor.ObjectInstanceEditor((ObjectInstance)item).ShowDialog(); multiBoard.RenderFrame(); break; case "TileInstance": case "Chair": new InstanceEditor.GeneralInstanceEditor(item).ShowDialog(); multiBoard.RenderFrame(); break; case "FootholdAnchor": FootholdLine[] selectedFootholds = FootholdLine.GetSelectedFootholds(item.Board); if (selectedFootholds.Length > 0) { new InstanceEditor.FootholdEditor(selectedFootholds).ShowDialog(); } else new InstanceEditor.GeneralInstanceEditor(item).ShowDialog(); multiBoard.RenderFrame(); break; case "RopeAnchor": new InstanceEditor.RopeInstanceEditor((RopeAnchor)item).ShowDialog(); multiBoard.RenderFrame(); break; case "LifeInstance": new InstanceEditor.LifeInstanceEditor((LifeInstance)item).ShowDialog(); multiBoard.RenderFrame(); break; case "ReactorInstance": new InstanceEditor.ReactorInstanceEditor((ReactorInstance)item).ShowDialog(); multiBoard.RenderFrame(); break; case "BackgroundInstance": multiBoard.RenderFrame(); break; case "PortalInstance": new InstanceEditor.PortalInstanceEditor((PortalInstance)item).ShowDialog(); multiBoard.RenderFrame(); break; case "ToolTip": break; default: break; } }
public static string CreateItemDescription(BoardItem item, string lineBreak) { switch (item.GetType().Name) { case "TileInstance": return "Tile:" + lineBreak + ((TileInfo)item.BaseInfo).tS + @"\" + ((TileInfo)item.BaseInfo).u + @"\" + ((TileInfo)item.BaseInfo).no; case "ObjectInstance": return "Object:" + lineBreak + ((ObjectInfo)item.BaseInfo).oS + @"\" + ((ObjectInfo)item.BaseInfo).l0 + @"\" + ((ObjectInfo)item.BaseInfo).l1 + @"\" + ((ObjectInfo)item.BaseInfo).l2; case "BackgroundInstance": return "Background:" + lineBreak + ((BackgroundInfo)item.BaseInfo).bS + @"\" + (((BackgroundInfo)item.BaseInfo).ani ? "ani" : "back") + @"\" + ((BackgroundInfo)item.BaseInfo).no; case "PortalInstance": return "Portal:" + lineBreak + "Name: " + ((PortalInstance)item).pn + lineBreak + "Type: " + Tables.PortalTypeNames[(int)((PortalInstance)item).pt]; case "LifeInstance": if (((LifeInstance)item).Type == ItemTypes.Mobs) return "Mob:" + lineBreak + "Name: " + ((MobInfo)item.BaseInfo).Name + lineBreak + "ID: " + ((MobInfo)item.BaseInfo).ID; else return "Npc:" + lineBreak + "Name: " + ((NpcInfo)item.BaseInfo).Name + lineBreak + "ID: " + ((NpcInfo)item.BaseInfo).ID; case "ReactorInstance": return "Reactor:" + lineBreak + "ID: " + ((ReactorInfo)item.BaseInfo).ID; case "FootholdAnchor": return "Foothold"; case "RopeAnchor": return ((RopeAnchor)item).ParentRope.ladder ? "Ladder" : "Rope"; case "Chair": return "Chair"; case "ToolTipDot": case "ToolTip": case "ToolTipChar": return "Tooltip"; default: return ""; } }
public virtual void ReleaseItem(BoardItem item) { lock (Board.ParentControl) { if (boundItems.ContainsKey(item)) { boundItems.Remove(item); boundItemsList.Remove(item); item.parent = null; } } }
public void EditBaseClicked(BoardItem item) { if (OnEditBaseClicked != null) OnEditBaseClicked.Invoke(item); }
private void multiBoard_SelectedItemChanged(BoardItem selectedItem) { if (selectedItem == null) itemDescLabel.Text = ""; else itemDescLabel.Text = CreateItemDescription(selectedItem, " "); }
public BoardItemPair(BoardItem nonselected, BoardItem selected) { this.NonSelectedItem = nonselected; this.SelectedItem = selected; }
public static bool IsItemUnderRectangle(BoardItem item, Rectangle rect) { return (item.Right > rect.Left && item.Left < rect.Right && item.Bottom > rect.Top && item.Top < rect.Bottom); }
public virtual void ReleaseItem(BoardItem item) { if (boundItems.Contains(item)) { boundItems.Remove(item); item.parent = null; } }
public static UndoRedoAction ItemZChanged(BoardItem item, int oldZ, int newZ) { return new UndoRedoAction(item, UndoRedoType.ItemZChanged, oldZ, newZ); }
public void SetHeldInfo(MapleDrawableInfo newInfo) { Clear(); if (newInfo.Image == null) ((MapleExtractableInfo)newInfo).ParseImage(); currAddedInfo = newInfo; currAddedObj = newInfo.CreateInstance(Board.SelectedLayer, Board, X + currAddedInfo.Origin.X - newInfo.Image.Width / 2, Y + currAddedInfo.Origin.Y - newInfo.Image.Height / 2, 50, false, true); Board.BoardItems.Add(currAddedObj, false); BindItem(currAddedObj, new Microsoft.Xna.Framework.Point(newInfo.Origin.X - newInfo.Image.Width / 2, newInfo.Origin.Y - newInfo.Image.Height / 2)); state = MouseState.StaticObjectAdding; }
private void GetObjsUnderPointFromList(IMapleList list, Point locationVirtualPos, ref BoardItem itemUnderPoint, ref BoardItem selectedUnderPoint, ref bool selectedItemHigher) { if (!list.Selectable) return; if (list.ListType == ItemTypes.None) { for (int i = 0; i < list.Count; i++) { BoardItem item = (BoardItem)list[i]; if ((ApplicationSettings.editedTypes & item.Type) != item.Type) continue; if (IsPointInsideRectangle(locationVirtualPos, item.Left, item.Top, item.Right, item.Bottom) && !(item is Mouse) && (selectedBoard.SelectedLayerIndex == -1 || item.CheckIfLayerSelected(selectedBoard.SelectedLayerIndex)) && !item.IsPixelTransparent(locationVirtualPos.X - item.Left, locationVirtualPos.Y - item.Top)) { if (item.Selected) { selectedUnderPoint = item; selectedItemHigher = true; } else { itemUnderPoint = item; selectedItemHigher = false; } } } } else if ((ApplicationSettings.editedTypes & list.ListType) == list.ListType) { for (int i = 0; i < list.Count; i++) { BoardItem item = (BoardItem)list[i]; if (IsPointInsideRectangle(locationVirtualPos, item.Left, item.Top, item.Right, item.Bottom) && !(item is Mouse) && !(item is Mouse) && (selectedBoard.SelectedLayerIndex == -1 || item.CheckIfLayerSelected(selectedBoard.SelectedLayerIndex)) && !item.IsPixelTransparent(locationVirtualPos.X - item.Left, locationVirtualPos.Y - item.Top)) { if (item.Selected) { selectedUnderPoint = item; selectedItemHigher = true; } else { itemUnderPoint = item; selectedItemHigher = false; } } } } }
public override void BindItem(BoardItem item, Microsoft.Xna.Framework.Point distance) { if (BoundItems.Contains(item)) return; BoundItems[item] = distance; item.tempParent = item.Parent; item.Parent = this; }
public void OnSelectedItemChanged(BoardItem selectedItem) { if (SelectedItemChanged != null) SelectedItemChanged.Invoke(selectedItem); }
public static bool IsItemInsideRectangle(BoardItem item, Rectangle rect) { return (item.Left > rect.Left && item.Right < rect.Right && item.Top > rect.Top && item.Bottom < rect.Bottom); }
public UndoRedoAction(BoardItem item, UndoRedoType type, object ParamA, object ParamB, object ParamC) : this(item, type, ParamA, ParamB) { this.ParamC = ParamC; }