Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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;
            }
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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();
            }
        }
Ejemplo n.º 5
0
        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();
            }
        }
Ejemplo n.º 6
0
        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;
            }
        }
Ejemplo n.º 7
0
        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());
        }
Ejemplo n.º 9
0
        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());
        }
Ejemplo n.º 10
0
 public T GetDataObjectForGeometryObject(GeometryObj obj)
 {
     foreach (T row in m_RowObjectMapping.Keys)
     {
         if (m_RowObjectMapping[row] == obj)
         {
             return(row);
         }
     }
     return(default(T));
 }
Ejemplo n.º 11
0
        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();
        }
Ejemplo n.º 12
0
        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();
        }
Ejemplo n.º 13
0
        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);
        }
Ejemplo n.º 14
0
        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());
        }
Ejemplo n.º 15
0
        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);
        }
Ejemplo n.º 16
0
        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);
        }
Ejemplo n.º 17
0
        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();
             * */
        }
Ejemplo n.º 19
0
        /// <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;
        }
Ejemplo n.º 20
0
        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);
        }
Ejemplo n.º 22
0
        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();
        }
Ejemplo n.º 23
0
        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();
        }
Ejemplo n.º 24
0
        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);
        }
Ejemplo n.º 25
0
 protected void SetObjectForRow(T row, GeometryObj obj)
 {
     m_RowObjectMapping[row] = obj;
 }
Ejemplo n.º 26
0
        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;
        }
Ejemplo n.º 27
0
        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;
        }
Ejemplo n.º 28
0
        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;
        }
Ejemplo n.º 29
0
        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;
        }
Ejemplo n.º 30
0
        /// <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;
        }
Ejemplo n.º 31
0
        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;
        }
Ejemplo n.º 32
0
        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;
            }
        }
Ejemplo n.º 33
0
        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;
            }
        }
Ejemplo n.º 34
0
        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);
        }
Ejemplo n.º 35
0
 public abstract String GetInfoText(GeometryObj obj);
Ejemplo n.º 36
0
        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;
        }
Ejemplo n.º 37
0
 public abstract void ObjectMoved(GeometryObj obj);
Ejemplo n.º 38
0
        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;
        }