void RoomDlg_MouseUp(object sender, MouseEventArgs e) { mDragObject = null; mDragDepth = false; if (mMode == ViewMode.Deepmap) mDragDepthBottom = false; if (mMode == ViewMode.Inventory) { mDragMode = DragMode.DragNone; this.Cursor = Cursors.Default; } if (mMode == ViewMode.Specialfx) { mDragMode = DragMode.DragNone; } }
void RoomDlg_MouseDown(object sender, MouseEventArgs e) { Point click = new Point(e.X, e.Y); Vec2i pos = new Vec2i(e.X, e.Y); mMousePos = pos; if (mMode == ViewMode.Objects) { bool dragDepthFound = false; foreach (ObjectInstance obj in mRoom.Objects) { if (obj.Layer != 1) continue; Vec2i depthcenter = new Vec2i(obj.Position.x, obj.Depth * mData.WalkGridSize/2 - mData.WalkGridSize / 4); if ((depthcenter - pos - mRoom.ScrollOffset).length() <= 5) { mDragObject = obj; mDragOffset = depthcenter - pos; mDragDepth = true; dragDepthFound = true; break; } } if (!dragDepthFound) { mDragDepth = false; bool dragSecond = e.Button == MouseButtons.Middle; mDragObject = getObjectAt(pos + mRoom.ScrollOffset, dragSecond); mControl.SelectedObject = mDragObject; if (mDragObject != null) { mDragOffset = mDragObject.getPosition() - pos; } } if (e.Button == MouseButtons.Right) { if (mDragObject != null) { if (mDragObject.GetType() == typeof(ObjectInstance)) menuObject.Items[2].Text = "Show in Object window"; else menuObject.Items[2].Text = "Show in Character window"; menuObject.Show(this, click); } else menuRemoveBackground.Show(this, click); } } else if (mMode == ViewMode.Walkmap) { if (e.Button == MouseButtons.Right) { Vec2i cp = clickToWalkmap(e.X, e.Y); ToolStripMenuItem it = menuWalkmap.Items[9] as ToolStripMenuItem; if (mRoom.Walkmap[cp.x, cp.y].hasScript) { it.Enabled = true; } else it.Enabled = false; menuWalkmap.Show(this, click); return; } modifyWalkmap(pos.x, pos.y); mDragDepth = true; } else if (mMode == ViewMode.Deepmap) { int depth = (e.Y+mData.WalkGridSize/2+mRoom.ScrollOffset.y) / mData.WalkGridSize; if (depth == mRoom.Depthmap.x) mDragDepth = true; if (depth == mRoom.Depthmap.y) mDragDepthBottom = true; } else if (mMode == ViewMode.Inventory) { if (mRoom.HasInventory) { if (e.Button == MouseButtons.Right) { menuInventory.Show(this, click); } int sizex = mRoom.InvSize.x * ((int)(50 * mRoom.InvScale.x) + mRoom.InvSpacing) + 30; int sizey = mRoom.InvSize.y * ((int)(50 * mRoom.InvScale.y) + mRoom.InvSpacing) + 5; int ydown = -mRoom.ScrollOffset.y + mRoom.InvPos.y + sizey; int xmiddle = -mRoom.ScrollOffset.x + mRoom.InvPos.x + sizex / 2; int ymiddle = -mRoom.ScrollOffset.y + mRoom.InvPos.y + sizey / 2; int xright = -mRoom.ScrollOffset.x + mRoom.InvPos.x + sizex; int xleft = -mRoom.ScrollOffset.x + mRoom.InvPos.x; int yup = -mRoom.ScrollOffset.y + mRoom.InvPos.y; //bottom if (e.X >= xmiddle - 15 && e.X <= xmiddle + 15) { if (e.Y <= ydown + 3 && e.Y >= ydown - 5 - 3) { mDragMode = DragMode.DragBottom; mDragOffset.y = e.Y - ydown; } else mDragMode = DragMode.DragNone; } //right else if (e.Y >= ymiddle - 15 && e.Y <= ymiddle + 15) { if (e.X <= xright + 3 && e.X >= xright - 5 - 3) { mDragMode = DragMode.DragRight; mDragOffset.x = e.X - xright; } else mDragMode = DragMode.DragNone; } //corner else if (e.X >= xright - 11 - 3 && e.X <= xright + 3) { if (e.Y >= ydown - 11 - 3 && e.Y <= ydown + 3) mDragMode = DragMode.DragCorner; else mDragMode = DragMode.DragNone; } else mDragMode = DragMode.DragNone; //elsewhere on inventory if (mDragMode == DragMode.DragNone && e.X >= xleft && e.X <= xright) { if (e.Y >= yup && e.Y <= ydown) { mDragMode = DragMode.DragPosition; mDragOffset = new Vec2i(e.X, e.Y) - mRoom.InvPos; } } } else { if (e.Button == MouseButtons.Right) { return; } mRoom.InvPos = new Vec2i(e.X + mRoom.ScrollOffset.x, e.Y + mRoom.ScrollOffset.y); mRoom.InvScale = new Vec2f(1.0f, 1.0f); mRoom.HasInventory = true; mDragMode = DragMode.DragCorner; this.Cursor = Cursors.SizeNWSE; } } else if (mMode == ViewMode.Specialfx) { Vec2i clickpos = pos; clickpos += mRoom.ScrollOffset; for (int shapeidx = 0; shapeidx < mRoom.FXShapes.Count; ++shapeidx) { FxShape shape = (FxShape)mRoom.FXShapes[shapeidx]; if (!shape.Active) continue; Vec2i center = new Vec2i(); for (int i = 0; i < shape.Positions.Length; ++i) { if ((shape.Positions[i] - clickpos).length() <= 4) { mDragMode = DragMode.DragCorner; mDraggingShape = shape; mShapeIndex = i; mDragOffset = clickpos - center; return; } center += shape.Positions[i]; } center /= shape.Positions.Length; if ((center - clickpos).length() <= 10) { mDragMode = DragMode.DragPosition; mDraggingShape = shape; mDragOffset = pos; break; } Vec2i depthcenter = new Vec2i(center.x, (int)((shape.Depth + 0.5f) * mData.WalkGridSize - mData.WalkGridSize / 2)); if ((depthcenter - clickpos).length() <= 5) { mDragMode = DragMode.DragBottom; mDraggingShape = shape; mDragOffset = depthcenter - pos; return; } } } }