private GeometryObj EditArea(GeometryObj obj, DataRow areaRow) { if (areaRow[DB.COL_AREA_X] == DBNull.Value || areaRow[DB.COL_AREA_Y] == DBNull.Value) { return(null); } float x = (float)Convert.ToDouble(areaRow[DB.COL_AREA_X]); float y = (float)Convert.ToDouble(areaRow[DB.COL_AREA_Y]); float width = areaRow[DB.COL_AREA_Z] == DBNull.Value ? 0 : (float)Convert.ToDouble(areaRow[DB.COL_AREA_Z]); float height = areaRow[DB.COL_AREA_R] == DBNull.Value ? 0 : (float)Convert.ToDouble(areaRow[DB.COL_AREA_R]); if (x > 0 || y > 0) { Model m_PointModel; if ((string)areaRow[DB.COL_AREA_AREATYPE] == Const.AREA_SQUARE) { DOL.Tools.Mapping.DX.Meshes.Plane plane = new DOL.Tools.Mapping.DX.Meshes.Plane(Common.Device, width, height, false); m_PointModel = new Model(plane, Textures.AreaSquare); } else { DOL.Tools.Mapping.DX.Meshes.Plane plane = new DOL.Tools.Mapping.DX.Meshes.Plane(Common.Device, height, height, true); m_PointModel = new Model(plane, Textures.AreaCircle); } obj.Model = m_PointModel; obj.X = x; obj.Y = y; } return(obj); }
private void DXControl_MouseUp(object sender, MouseEventArgs e) { int diffX = Math.Abs(MouseMoveStart.X - e.X); int diffY = Math.Abs(MouseMoveStart.Y - e.Y); if ((diffX <= 3 && diffY <= 3) || (MouseMoveStart.X == -1 && MouseMoveStart.Y == -1)) { ModulMgr.TriggerModules(ModulEvent.DXClick, e); } LastMouseVector = DXClickToVector(new Vector2(e.X, e.Y)); if (e.Button == MouseButtons.Right) { contextMenuStrip.Show(this, e.Location); } else if (e.Button == MouseButtons.Left) { MapMoving = false; ObjectMoving = false; MouseMoveStart.X = -1; MouseMoveStart.Y = -1; SelectedObject = null; this.Cursor = Cursors.Default; } }
private GeometryObj AddLocation(DataRow locationRow) { if (locationRow[DB.COL_LOCATION_X] == DBNull.Value || locationRow[DB.COL_LOCATION_Y] == DBNull.Value) { return(null); } float x = (float)Convert.ToDouble(locationRow[DB.COL_LOCATION_X]); float y = (float)Convert.ToDouble(locationRow[DB.COL_LOCATION_Y]); GeometryObj obj = null; if (x > 0 || y > 0) { Model m_PointModel; m_PointModel = new Model(Plane, Textures.LoadMapObjectTexture("Location")); obj = new GeometryObj(this, m_PointModel, DrawLevel.Forer, DetailLevel.Detailed, x, y, 0, 0, 0, 0, new Vector3(2, 2, 2), true, true); if (!IsFiltered) { DXControl.GeoObjects.Add(obj); } SetObjectForRow(locationRow, obj); } return(obj); }
private void MobTable_RowChanged(object sender, DataRowChangeEventArgs e) { DataRow mobRow = e.Row; if (RegionMgr.CurrentRegion != null && (int)mobRow[DB.COL_NPC_REGION] == RegionMgr.CurrentRegion.ID) { if (e.Action == DataRowAction.Add) { GeometryObj obj = AddMob(mobRow); } else if (e.Action == DataRowAction.Delete) { GeometryObj obj = GetGeometryObjectForDataObject(mobRow); if (obj != null) { DXControl.GeoObjects.Remove(obj); } RemoveObjectForRow(mobRow); } else if (e.Action == DataRowAction.Change) { GeometryObj obj = GetGeometryObjectForDataObject(mobRow); if (obj != null) { EditMob(obj, mobRow); } else { AddMob(mobRow); } } QuestDesignerMain.DesignerForm.DXControl.Invalidate(); } }
private void LocationTable_RowChanged(object sender, DataRowChangeEventArgs e) { DataRow locationRow = e.Row; if (RegionMgr.CurrentRegion != null && locationRow[DB.COL_LOCATION_REGIONID] is int && (int)locationRow[DB.COL_LOCATION_REGIONID] == RegionMgr.CurrentRegion.ID) { if (e.Action == DataRowAction.Add) { GeometryObj obj = AddLocation(locationRow); } else if (e.Action == DataRowAction.Delete) { GeometryObj obj = GetGeometryObjectForDataObject(locationRow); if (obj != null) { DXControl.GeoObjects.Remove(obj); } RemoveObjectForRow(locationRow); } else if (e.Action == DataRowAction.Change) { GeometryObj obj = GetGeometryObjectForDataObject(locationRow); if (obj != null) { EditLocation(obj, locationRow); } else // no object found add it { AddLocation(locationRow); } } QuestDesignerMain.DesignerForm.DXControl.Invalidate(); } }
private void DXControl_MouseDown(object sender, MouseEventArgs e) { this.ZoomSlider.Focus(); this.ZoomSlider.Select(); Vector3 v3 = DXClickToVector(new Vector2(e.X, e.Y)); SelectedObject = ModulMgr.GetObjectAt((int)v3.X, (int)v3.Y); if (e.Button == MouseButtons.Left) { if (SelectedObject != null && SelectedObject.IsMovable) { MapMoving = false; ObjectMoving = true; } else { this.Cursor = Cursors.Hand; MouseMoveStart = new Point(e.X, e.Y); MouseValueH = hScrollBar.Value; MouseValueV = vScrollBar.Value; MapMoving = true; ObjectMoving = false; } } else { MapMoving = false; ObjectMoving = false; } }
public override string GetInfoText(GeometryObj obj) { DataRow mobRow = GetDataObjectForGeometryObject(obj); StringBuilder sb = new StringBuilder(); sb.Append((string)mobRow[DB.COL_NPC_NAME]); return sb.ToString(); }
public override string GetInfoText(GeometryObj obj) { WorldObject mob = GetDataObjectForGeometryObject(obj); StringBuilder sb = new StringBuilder(); sb.Append(mob.Name); return(sb.ToString()); }
public override string GetInfoText(GeometryObj obj) { DataRow mobRow = GetDataObjectForGeometryObject(obj); StringBuilder sb = new StringBuilder(); sb.Append((string)mobRow[DB.COL_NPC_NAME]); return(sb.ToString()); }
public T GetDataObjectForGeometryObject(GeometryObj obj) { foreach (T row in m_RowObjectMapping.Keys) { if (m_RowObjectMapping[row] == obj) { return(row); } } return(default(T)); }
public override void ObjectMoved(GeometryObj obj) { DataRow row = GetDataObjectForGeometryObject(obj); if (row != null) { row.BeginEdit(); row[DB.COL_LOCATION_X] = obj.X; row[DB.COL_LOCATION_Y] = obj.Y; row.EndEdit(); } QuestDesignerMain.DesignerForm.DXControl.Invalidate(); }
public static GeometryObj GetObjectAt(int x, int y) { GeometryObj obj = null; List <GeometryObj> objects = GetObjectsAt(x, y); foreach (GeometryObj o in objects) { if (obj == null || o.DrawLevel > obj.DrawLevel) { obj = o; } } return(obj); }
public override string GetInfoText(GeometryObj obj) { Mob mob = GetDataObjectForGeometryObject(obj); StringBuilder sb = new StringBuilder(); sb.Append(mob.Name); if (!String.IsNullOrEmpty(mob.Guild)) { sb.Append(" ("); sb.Append(mob.Guild); sb.Append(")"); } return(sb.ToString()); }
public static List <GeometryObj> GetObjectsAt(int x, int y) { List <GeometryObj> items = new List <GeometryObj>(); if (RegionMgr.CurrentRegion != null) { foreach (IModul mod in m_Modules) { GeometryObj obj = mod.GetObjectAt(x, y); if (obj != null) { items.Add(obj); } } } return(items); }
private GeometryObj EditMob(GeometryObj obj, DataRow mobRow) { if (mobRow[DB.COL_NPC_X] == DBNull.Value || mobRow[DB.COL_NPC_Y] == DBNull.Value) { return(null); } float x = (float)Convert.ToDouble(mobRow[DB.COL_NPC_X]); float y = (float)Convert.ToDouble(mobRow[DB.COL_NPC_Y]); float heading = Utils.HeadingToRadians(Convert.ToInt32(mobRow[DB.COL_NPC_HEADING])); obj.X = x; obj.Y = y; obj.Roll = heading; return(obj); }
private GeometryObj EditLocation(GeometryObj obj, DataRow locationRow) { if (locationRow[DB.COL_LOCATION_X] == DBNull.Value || locationRow[DB.COL_LOCATION_Y] == DBNull.Value) { return(obj); } float x = (float)Convert.ToDouble(locationRow[DB.COL_LOCATION_X]); float y = (float)Convert.ToDouble(locationRow[DB.COL_LOCATION_Y]); float heading = Utils.HeadingToRadians(Convert.ToInt32(locationRow[DB.COL_LOCATION_HEADING])); obj.X = x; obj.Y = y; obj.Roll = heading; return(obj); }
public override void ObjectMoved(GeometryObj obj) { // new coordinates are already in the db row nothing else needs to be done. /* * DataRow row = GetRowForObject(obj); * * if (row != null) * { * row.BeginEdit(); * row[DB.COL_NPC_X] = obj.X; * row[DB.COL_NPC_Y] = obj.Y; * row.EndEdit(); * } * * // render moved objects * QuestDesignerMain.DesignerForm.DXControl.Invalidate(); * */ }
/// <summary> /// Initializes the database /// </summary> private static void backgroundWorker_doWork(object sender, DoWorkEventArgs e) { //Load zones BackgroundWorker worker = (BackgroundWorker)sender; QuestDesignerMain.DesignerForm.StatusProgress.Step = QuestDesignerMain.DesignerForm.StatusProgress.Maximum / m_OpenedRegion.Zones.Count; lock (DXControl.GeoObjects) { foreach (Zone zone in m_OpenedRegion.Zones) { //Create it! Plane mesh = new Plane(Common.Device, zone.Width, zone.Height, false); Texture tex = Textures.LoadTexture(zone.Texture); if (e.Cancel || worker.CancellationPending) { e.Cancel = true; e.Result = false; return; } //float scaleX = zone.Width / tex.GetLevelDescription(0).Width; //float scaleY = zone.Height / tex.GetLevelDescription(0).Height; Model model = new Model(mesh, tex); GeometryObj obj = new GeometryObj(null, model, DrawLevel.Background, DetailLevel.Nondetailed, zone.X, zone.Y, 0.0f, 0.0f, 0.0f, 0.0f, new Vector3(1.0f, 1.0f, 1.0f), false, false); DXControl.GeoObjects.Add(obj); if (QuestDesignerMain.DesignerForm != null && !QuestDesignerMain.DesignerForm.StatusProgress.IsDisposed) { QuestDesignerMain.DesignerForm.StatusProgress.PerformStep(); QuestDesignerMain.DesignerForm.DXControl.Invalidate(); } } } e.Result = true; }
private GeometryObj AddArea(DataRow areaRow) { if (areaRow[DB.COL_AREA_X] == DBNull.Value || areaRow[DB.COL_AREA_Y] == DBNull.Value) { return(null); } float x = (float)Convert.ToDouble(areaRow[DB.COL_AREA_X]); float y = (float)Convert.ToDouble(areaRow[DB.COL_AREA_Y]); float width = areaRow[DB.COL_AREA_Z] == DBNull.Value ? 0 : (float)Convert.ToDouble(areaRow[DB.COL_AREA_Z]); float height = areaRow[DB.COL_AREA_R] == DBNull.Value ? 0 : (float)Convert.ToDouble(areaRow[DB.COL_AREA_R]); GeometryObj obj = null; if (x > 0 || y > 0) { Model m_PointModel; if ((string)areaRow[DB.COL_AREA_AREATYPE] == Const.AREA_SQUARE) { DOL.Tools.Mapping.DX.Meshes.Plane plane = new DOL.Tools.Mapping.DX.Meshes.Plane(Common.Device, width, height, false); m_PointModel = new Model(plane, Textures.AreaSquare); } else { DOL.Tools.Mapping.DX.Meshes.Plane plane = new DOL.Tools.Mapping.DX.Meshes.Plane(Common.Device, height, height, true); m_PointModel = new Model(plane, Textures.AreaCircle); } obj = new GeometryObj(this, m_PointModel, DrawLevel.Backer, DetailLevel.Nondetailed, x, y, 0, 0, 0, 0, new Vector3(1, 1, 1), true, false); if (!IsFiltered) { DXControl.GeoObjects.Add(obj); } SetObjectForRow(areaRow, obj); } return(obj); }
private GeometryObj AddWorldObject(WorldObject mob) { float heading = Utils.HeadingToRadians(mob.Heading); GeometryObj obj = null; Model m_PointModel; Texture texture = Textures.LoadMapObjectTexture(mob.ClassType); m_PointModel = new Model(Plane, texture); obj = new GeometryObj(this, m_PointModel, DrawLevel.Middle, DetailLevel.MoreDetailed, mob.X, mob.Y, 0, 0, 0, heading, new Vector3(1, 1, 1), false, true); if (!IsFiltered) { DXControl.GeoObjects.Add(obj); } SetObjectForRow(mob, obj); return(obj); }
public override void ObjectMoved(GeometryObj obj) { DataRow row = GetDataObjectForGeometryObject(obj); if (row != null) { row.BeginEdit(); // since aresquare is not centered in mapviewer mode handle is special here if ((string)row[DB.COL_AREA_AREATYPE] == Const.AREA_SQUARE) { row[DB.COL_AREA_X] = obj.X - Convert.ToInt32(row[DB.COL_AREA_Z]) / 2; row[DB.COL_AREA_Y] = obj.Y - Convert.ToInt32(row[DB.COL_AREA_R]) / 2; } else { row[DB.COL_AREA_X] = obj.X; row[DB.COL_AREA_Y] = obj.Y; } row.EndEdit(); } QuestDesignerMain.DesignerForm.DXControl.Invalidate(); }
private GeometryObj AddMob(DataRow mobRow) { if (mobRow[DB.COL_NPC_X] == DBNull.Value || mobRow[DB.COL_NPC_Y] == DBNull.Value) { return(null); } float x = (float)Convert.ToDouble(mobRow[DB.COL_NPC_X]); float y = (float)Convert.ToDouble(mobRow[DB.COL_NPC_Y]); float heading = Utils.HeadingToRadians(Convert.ToInt32(mobRow[DB.COL_NPC_HEADING])); GeometryObj obj = null; if (x > 0 || y > 0) { Model m_PointModel; if ((byte)mobRow[DB.COL_NPC_REALM] == (byte)eRealm.None) { m_PointModel = new Model(Plane, Textures.Mob); } else { m_PointModel = new Model(Plane, Textures.NPC); } obj = new GeometryObj(this, m_PointModel, DrawLevel.Forer, DetailLevel.Detailed, x, y, 0, 0, 0, heading, new Vector3(1, 1, 1), true, true); if (!IsFiltered) { DXControl.GeoObjects.Add(obj); } SetObjectForRow(mobRow, obj); } return(obj); }
protected void SetObjectForRow(T row, GeometryObj obj) { m_RowObjectMapping[row] = obj; }
private GeometryObj AddMob(DataRow mobRow) { if (mobRow[DB.COL_NPC_X] == DBNull.Value || mobRow[DB.COL_NPC_Y] == DBNull.Value) return null; float x = (float)Convert.ToDouble(mobRow[DB.COL_NPC_X]); float y = (float)Convert.ToDouble(mobRow[DB.COL_NPC_Y]); float heading = Utils.HeadingToRadians(Convert.ToInt32(mobRow[DB.COL_NPC_HEADING])); GeometryObj obj = null; if (x > 0 || y > 0) { Model m_PointModel; if ((byte)mobRow[DB.COL_NPC_REALM] == (byte)eRealm.None) { m_PointModel = new Model(Plane, Textures.Mob); } else { m_PointModel = new Model(Plane, Textures.NPC); } obj = new GeometryObj(this,m_PointModel, DrawLevel.Forer, DetailLevel.Detailed, x, y, 0, 0, 0, heading, new Vector3(1, 1, 1),true,true); if (!IsFiltered) DXControl.GeoObjects.Add(obj); SetObjectForRow(mobRow, obj); } return obj; }
private GeometryObj EditMob(GeometryObj obj, DataRow mobRow) { if (mobRow[DB.COL_NPC_X] == DBNull.Value || mobRow[DB.COL_NPC_Y] == DBNull.Value) return null; float x = (float)Convert.ToDouble(mobRow[DB.COL_NPC_X]); float y = (float)Convert.ToDouble(mobRow[DB.COL_NPC_Y]); float heading = Utils.HeadingToRadians(Convert.ToInt32(mobRow[DB.COL_NPC_HEADING])); obj.X = x; obj.Y = y; obj.Roll = heading; return obj; }
private GeometryObj AddLocation(DataRow locationRow) { if (locationRow[DB.COL_LOCATION_X] == DBNull.Value || locationRow[DB.COL_LOCATION_Y] == DBNull.Value) return null; float x = (float)Convert.ToDouble(locationRow[DB.COL_LOCATION_X]); float y = (float)Convert.ToDouble(locationRow[DB.COL_LOCATION_Y]); GeometryObj obj = null; if (x > 0 || y > 0) { Model m_PointModel; m_PointModel = new Model(Plane, Textures.LoadMapObjectTexture("Location")); obj = new GeometryObj(this,m_PointModel, DrawLevel.Forer, DetailLevel.Detailed, x, y, 0, 0, 0, 0, new Vector3(2, 2, 2),true,true); if (!IsFiltered) DXControl.GeoObjects.Add(obj); SetObjectForRow(locationRow, obj); } return obj; }
private GeometryObj EditArea(GeometryObj obj, DataRow areaRow) { if (areaRow[DB.COL_AREA_X] == DBNull.Value || areaRow[DB.COL_AREA_Y] == DBNull.Value) return null; float x = (float)Convert.ToDouble(areaRow[DB.COL_AREA_X]); float y = (float)Convert.ToDouble(areaRow[DB.COL_AREA_Y]); float width = areaRow[DB.COL_AREA_Z] == DBNull.Value ? 0 : (float)Convert.ToDouble(areaRow[DB.COL_AREA_Z]); float height = areaRow[DB.COL_AREA_R] == DBNull.Value ? 0 : (float)Convert.ToDouble(areaRow[DB.COL_AREA_R]); if (x > 0 || y > 0) { Model m_PointModel; if ((string)areaRow[DB.COL_AREA_AREATYPE] == Const.AREA_SQUARE) { DOL.Tools.Mapping.DX.Meshes.Plane plane = new DOL.Tools.Mapping.DX.Meshes.Plane(Common.Device, width, height, false); m_PointModel = new Model(plane, Textures.AreaSquare); } else { DOL.Tools.Mapping.DX.Meshes.Plane plane = new DOL.Tools.Mapping.DX.Meshes.Plane(Common.Device, height, height, true); m_PointModel = new Model(plane, Textures.AreaCircle); } obj.Model = m_PointModel; obj.X = x; obj.Y = y; } return obj; }
/// <summary> /// Initializes the database /// </summary> private static void backgroundWorker_doWork(object sender, DoWorkEventArgs e) { //Load zones BackgroundWorker worker = (BackgroundWorker) sender; QuestDesignerMain.DesignerForm.StatusProgress.Step = QuestDesignerMain.DesignerForm.StatusProgress.Maximum / m_OpenedRegion.Zones.Count; lock (DXControl.GeoObjects) { foreach (Zone zone in m_OpenedRegion.Zones) { //Create it! Plane mesh = new Plane(Common.Device, zone.Width, zone.Height, false); Texture tex = Textures.LoadTexture(zone.Texture); if (e.Cancel || worker.CancellationPending) { e.Cancel = true; e.Result = false; return; } //float scaleX = zone.Width / tex.GetLevelDescription(0).Width; //float scaleY = zone.Height / tex.GetLevelDescription(0).Height; Model model = new Model(mesh, tex); GeometryObj obj = new GeometryObj(null,model, DrawLevel.Background, DetailLevel.Nondetailed, zone.X, zone.Y, 0.0f, 0.0f, 0.0f, 0.0f, new Vector3(1.0f, 1.0f, 1.0f),false,false); DXControl.GeoObjects.Add(obj); if (QuestDesignerMain.DesignerForm != null && !QuestDesignerMain.DesignerForm.StatusProgress.IsDisposed) { QuestDesignerMain.DesignerForm.StatusProgress.PerformStep(); QuestDesignerMain.DesignerForm.DXControl.Invalidate(); } } } e.Result = true; }
public static bool LoadRegion(Region region) { if (region == null) return false; if (m_OpenedRegion != null && region.ID == m_OpenedRegion.ID) { Log.Info(String.Format(Resources.msgRegionAlreadyLoaded, region.Name)); return true; } // we are still loading a old region, cancel that operation if (backgroundWorker!=null && backgroundWorker.IsBusy) backgroundWorker.CancelAsync(); UnloadRegion(); //Create "hitbox" Mesh hb = Mesh.Box(Common.Device, 256*256*16, 256*256*16, 0.0f); XMesh ms = new XMesh(hb); Texture tx = Textures.Generator(Color.Cyan); Model mdl = new Model(ms, tx); GeometryObj bj = new GeometryObj(null,mdl, DrawLevel.NonRender, DetailLevel.Nondetailed, 256*256*16/2, 256*256*16/2, 0.0f, 0.0f, 0.0f, 0.0f, new Vector3(1.0f, 1.0f, 1.0f),false,false); DXControl.GeoObjects.Add(bj); QuestDesignerMain.DesignerForm.DXControl.HBObject = bj; try { m_OpenedRegion = region; backgroundWorker = new BackgroundWorker(); backgroundWorker.WorkerSupportsCancellation = true; backgroundWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(backgroundWorker_doWork); backgroundWorker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(backgroundWorker_RunWorkerCompleted); backgroundWorker.RunWorkerAsync(); } catch (Exception e) { QuestDesignerMain.HandleException(e, Resources.msgRegionError+": " + e.Message, global::DOL.Tools.QuestDesigner.Properties.Resources.databaseError); } //Scrollbars.. QuestDesignerMain.DesignerForm.DXControl.hScrollBar.Minimum = 0; QuestDesignerMain.DesignerForm.DXControl.hScrollBar.Maximum = 256*256*16; QuestDesignerMain.DesignerForm.DXControl.hScrollBar.SmallChange = 256; QuestDesignerMain.DesignerForm.DXControl.hScrollBar.LargeChange = 2560; QuestDesignerMain.DesignerForm.DXControl.vScrollBar.Minimum = 0; QuestDesignerMain.DesignerForm.DXControl.vScrollBar.Maximum = 256*256*16; QuestDesignerMain.DesignerForm.DXControl.vScrollBar.SmallChange = 256; QuestDesignerMain.DesignerForm.DXControl.vScrollBar.LargeChange = 2560; QuestDesignerMain.DesignerForm.DXControl.SetZoom(0.75F); ; int maxSize = Math.Max (region.MaxHeight - region.MinHeight,region.MaxWidth- region.MinWidth); int zoomFactor = (QuestDesignerMain.DesignerForm.DXControl.ZoomSlider.Maximum - QuestDesignerMain.DesignerForm.DXControl.ZoomSlider.Minimum) / 16 * (maxSize / (256 * 256)); // restrcit zoomFactor zo Minimum-Maximum QuestDesignerMain.DesignerForm.DXControl.ZoomSlider.Value = Math.Min(QuestDesignerMain.DesignerForm.DXControl.ZoomSlider.Maximum, Math.Max(QuestDesignerMain.DesignerForm.DXControl.ZoomSlider.Minimum, zoomFactor)); QuestDesignerMain.DesignerForm.DXControl.hScrollBar.Enabled = true; QuestDesignerMain.DesignerForm.DXControl.vScrollBar.Enabled = true; QuestDesignerMain.DesignerForm.DXControl.ZoomSlider.Enabled = true; QuestDesignerMain.DesignerForm.DXControl.CenterView(); ModulMgr.TriggerModules(ModulEvent.RegionLoad, region); // render newly added objects from Modules QuestDesignerMain.DesignerForm.DXControl.Invalidate(); return true; }
private void DXControl_MouseUp(object sender, MouseEventArgs e) { int diffX = Math.Abs(MouseMoveStart.X - e.X); int diffY = Math.Abs(MouseMoveStart.Y - e.Y); if ((diffX <= 3 && diffY <= 3) || (MouseMoveStart.X == -1 && MouseMoveStart.Y == -1)) ModulMgr.TriggerModules(ModulEvent.DXClick, e); LastMouseVector = DXClickToVector(new Vector2(e.X, e.Y)); if (e.Button == MouseButtons.Right) { contextMenuStrip.Show(this, e.Location); } else if (e.Button == MouseButtons.Left) { MapMoving = false; ObjectMoving = false; MouseMoveStart.X = -1; MouseMoveStart.Y = -1; SelectedObject = null; this.Cursor = Cursors.Default; } }
public static bool LoadRegion(Region region) { if (region == null) { return(false); } if (m_OpenedRegion != null && region.ID == m_OpenedRegion.ID) { Log.Info(String.Format(Resources.msgRegionAlreadyLoaded, region.Name)); return(true); } // we are still loading a old region, cancel that operation if (backgroundWorker != null && backgroundWorker.IsBusy) { backgroundWorker.CancelAsync(); } UnloadRegion(); //Create "hitbox" Mesh hb = Mesh.Box(Common.Device, 256 * 256 * 16, 256 * 256 * 16, 0.0f); XMesh ms = new XMesh(hb); Texture tx = Textures.Generator(Color.Cyan); Model mdl = new Model(ms, tx); GeometryObj bj = new GeometryObj(null, mdl, DrawLevel.NonRender, DetailLevel.Nondetailed, 256 * 256 * 16 / 2, 256 * 256 * 16 / 2, 0.0f, 0.0f, 0.0f, 0.0f, new Vector3(1.0f, 1.0f, 1.0f), false, false); DXControl.GeoObjects.Add(bj); QuestDesignerMain.DesignerForm.DXControl.HBObject = bj; try { m_OpenedRegion = region; backgroundWorker = new BackgroundWorker(); backgroundWorker.WorkerSupportsCancellation = true; backgroundWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(backgroundWorker_doWork); backgroundWorker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(backgroundWorker_RunWorkerCompleted); backgroundWorker.RunWorkerAsync(); } catch (Exception e) { QuestDesignerMain.HandleException(e, Resources.msgRegionError + ": " + e.Message, global::DOL.Tools.QuestDesigner.Properties.Resources.databaseError); } //Scrollbars.. QuestDesignerMain.DesignerForm.DXControl.hScrollBar.Minimum = 0; QuestDesignerMain.DesignerForm.DXControl.hScrollBar.Maximum = 256 * 256 * 16; QuestDesignerMain.DesignerForm.DXControl.hScrollBar.SmallChange = 256; QuestDesignerMain.DesignerForm.DXControl.hScrollBar.LargeChange = 2560; QuestDesignerMain.DesignerForm.DXControl.vScrollBar.Minimum = 0; QuestDesignerMain.DesignerForm.DXControl.vScrollBar.Maximum = 256 * 256 * 16; QuestDesignerMain.DesignerForm.DXControl.vScrollBar.SmallChange = 256; QuestDesignerMain.DesignerForm.DXControl.vScrollBar.LargeChange = 2560; QuestDesignerMain.DesignerForm.DXControl.SetZoom(0.75F);; int maxSize = Math.Max(region.MaxHeight - region.MinHeight, region.MaxWidth - region.MinWidth); int zoomFactor = (QuestDesignerMain.DesignerForm.DXControl.ZoomSlider.Maximum - QuestDesignerMain.DesignerForm.DXControl.ZoomSlider.Minimum) / 16 * (maxSize / (256 * 256)); // restrcit zoomFactor zo Minimum-Maximum QuestDesignerMain.DesignerForm.DXControl.ZoomSlider.Value = Math.Min(QuestDesignerMain.DesignerForm.DXControl.ZoomSlider.Maximum, Math.Max(QuestDesignerMain.DesignerForm.DXControl.ZoomSlider.Minimum, zoomFactor)); QuestDesignerMain.DesignerForm.DXControl.hScrollBar.Enabled = true; QuestDesignerMain.DesignerForm.DXControl.vScrollBar.Enabled = true; QuestDesignerMain.DesignerForm.DXControl.ZoomSlider.Enabled = true; QuestDesignerMain.DesignerForm.DXControl.CenterView(); ModulMgr.TriggerModules(ModulEvent.RegionLoad, region); // render newly added objects from Modules QuestDesignerMain.DesignerForm.DXControl.Invalidate(); return(true); }
public abstract String GetInfoText(GeometryObj obj);
private GeometryObj EditLocation(GeometryObj obj, DataRow locationRow) { if (locationRow[DB.COL_LOCATION_X] == DBNull.Value || locationRow[DB.COL_LOCATION_Y] == DBNull.Value) return obj; float x = (float)Convert.ToDouble(locationRow[DB.COL_LOCATION_X]); float y = (float)Convert.ToDouble(locationRow[DB.COL_LOCATION_Y]); float heading = Utils.HeadingToRadians(Convert.ToInt32(locationRow[DB.COL_LOCATION_HEADING])); obj.X = x; obj.Y = y; obj.Roll = heading; return obj; }
public abstract void ObjectMoved(GeometryObj obj);
private GeometryObj AddArea(DataRow areaRow) { if (areaRow[DB.COL_AREA_X] == DBNull.Value || areaRow[DB.COL_AREA_Y] == DBNull.Value) return null; float x = (float)Convert.ToDouble(areaRow[DB.COL_AREA_X]); float y = (float)Convert.ToDouble(areaRow[DB.COL_AREA_Y]); float width = areaRow[DB.COL_AREA_Z] == DBNull.Value ? 0 : (float)Convert.ToDouble(areaRow[DB.COL_AREA_Z]); float height = areaRow[DB.COL_AREA_R] == DBNull.Value ? 0 : (float)Convert.ToDouble(areaRow[DB.COL_AREA_R]); GeometryObj obj = null; if (x > 0 || y > 0) { Model m_PointModel; if ((string)areaRow[DB.COL_AREA_AREATYPE] == Const.AREA_SQUARE) { DOL.Tools.Mapping.DX.Meshes.Plane plane = new DOL.Tools.Mapping.DX.Meshes.Plane(Common.Device, width, height, false); m_PointModel = new Model(plane, Textures.AreaSquare); } else { DOL.Tools.Mapping.DX.Meshes.Plane plane = new DOL.Tools.Mapping.DX.Meshes.Plane(Common.Device, height, height, true); m_PointModel = new Model(plane, Textures.AreaCircle); } obj = new GeometryObj(this, m_PointModel, DrawLevel.Backer, DetailLevel.Nondetailed, x, y, 0, 0, 0, 0, new Vector3(1, 1, 1), true,false); if (!IsFiltered) DXControl.GeoObjects.Add(obj); SetObjectForRow(areaRow, obj); } return obj; }