Ejemplo n.º 1
0
        public override MapObjectHoverData GetHoverDataTopDownView(bool isForObjectDrag, bool forceCursorPosition)
        {
            if (_customImage == null)
            {
                return(null);
            }

            Point?relPosMaybe = MapObjectHoverData.GetPositionMaybe(isForObjectDrag, forceCursorPosition);

            if (!relPosMaybe.HasValue)
            {
                return(null);
            }
            Point relPos = relPosMaybe.Value;

            (float inGameX, float inGameZ) = MapUtilities.ConvertCoordsForInGameTopDownView(relPos.X, relPos.Y);

            (double x, double y, double z) = PositionAngle.GetMidPoint(_posAngle1, _posAngle2);
            double dist   = MoreMath.GetDistanceBetween(x, z, inGameX, inGameZ);
            double radius = Scales ? _iconSize : _iconSize / Config.CurrentMapGraphics.MapViewScaleValue;

            if (dist <= radius || forceCursorPosition)
            {
                return(new MapObjectHoverData(this, x, y, z));
            }
            return(null);
        }
Ejemplo n.º 2
0
        public override MapObjectHoverData GetHoverDataOrthographicView(bool isForObjectDrag, bool forceCursorPosition)
        {
            if (_customImage == null)
            {
                return(null);
            }

            Point?relPosMaybe = MapObjectHoverData.GetPositionMaybe(isForObjectDrag, forceCursorPosition);

            if (!relPosMaybe.HasValue)
            {
                return(null);
            }
            Point relPos = relPosMaybe.Value;

            (double x, double y, double z)   = PositionAngle.GetMidPoint(_posAngle1, _posAngle2);
            (float controlX, float controlZ) = MapUtilities.ConvertCoordsForControlOrthographicView((float)x, (float)y, (float)z, UseRelativeCoordinates);
            double dist   = MoreMath.GetDistanceBetween(controlX, controlZ, relPos.X, relPos.Y);
            double radius = Scales ? _iconSize * Config.CurrentMapGraphics.MapViewScaleValue : _iconSize;

            if (dist <= radius || forceCursorPosition)
            {
                return(new MapObjectHoverData(this, x, y, z));
            }
            return(null);
        }
Ejemplo n.º 3
0
        public override List <ToolStripItem> GetHoverContextMenuStripItems(MapObjectHoverData hoverData)
        {
            List <ToolStripItem> output = base.GetHoverContextMenuStripItems(hoverData);

            (double x, double y, double z) = PositionAngle.GetMidPoint(_posAngle1, _posAngle2);
            ToolStripMenuItem copyPositionItem = MapUtilities.CreateCopyItem(x, y, z, "Position");

            output.Insert(0, copyPositionItem);

            return(output);
        }
Ejemplo n.º 4
0
        public override void DrawOn2DControlTopDownView(MapObjectHoverData hoverData)
        {
            base.DrawOn2DControlTopDownView(hoverData);

            if (_customImage != null)
            {
                (float x, float y, float z)      = ((float, float, float))PositionAngle.GetMidPoint(_posAngle1, _posAngle2);
                (float controlX, float controlZ) = MapUtilities.ConvertCoordsForControlTopDownView(x, z, UseRelativeCoordinates);
                PointF point   = new PointF(controlX, controlZ);
                SizeF  size    = MapUtilities.ScaleImageSizeForControl(_customImage.Size, _iconSize, Scales);
                double opacity = Opacity;
                if (this == hoverData?.MapObject)
                {
                    opacity = MapUtilities.GetHoverOpacity();
                }
                MapUtilities.DrawTexture(_customImageTex.Value, point, size, 0, opacity);
            }
        }
Ejemplo n.º 5
0
        public override void DrawOn3DControl()
        {
            base.DrawOn3DControl();

            if (_customImage != null)
            {
                (float x, float y, float z) = ((float, float, float))PositionAngle.GetMidPoint(_posAngle1, _posAngle2);
                Matrix4 viewMatrix = GetModelMatrix(x, y, z, 0);
                GL.UniformMatrix4(Config.Map3DGraphics.GLUniformView, false, ref viewMatrix);

                Map3DVertex[] vertices2    = GetVertices();
                int           vertexBuffer = GL.GenBuffer();
                GL.BindBuffer(BufferTarget.ArrayBuffer, vertexBuffer);
                GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(vertices2.Length * Map3DVertex.Size),
                              vertices2, BufferUsageHint.StaticDraw);
                GL.BindTexture(TextureTarget.Texture2D, _customImageTex.Value);
                GL.BindBuffer(BufferTarget.ArrayBuffer, vertexBuffer);
                Config.Map3DGraphics.BindVertices();
                GL.DrawArrays(PrimitiveType.Triangles, 0, vertices2.Length);
                GL.DeleteBuffer(vertexBuffer);
            }
        }