Exemplo n.º 1
0
        public override void DrawOn2DControlOrthographicView(MapObjectHoverData hoverData)
        {
            List <(float x, float y, float z, float angle, int tex)> data = GetData();

            for (int i = data.Count - 1; i >= 0; i--)
            {
                var dataPoint = data[i];
                (float x, float y, float z, float angle, int tex) = dataPoint;
                (float x, float z)positionOnControl = MapUtilities.ConvertCoordsForControlOrthographicView(x, y, z, UseRelativeCoordinates);
                float  angleDegrees = Rotates ? MapUtilities.ConvertAngleForControl(angle) : 0;
                SizeF  size         = MapUtilities.ScaleImageSizeForControl(Config.ObjectAssociations.BlueMarioMapImage.Size, Size, Scales);
                PointF point        = new PointF(positionOnControl.x, positionOnControl.z);
                double opacity      = Opacity;
                if (this == hoverData?.MapObject && i == hoverData?.Index)
                {
                    opacity = MapUtilities.GetHoverOpacity();
                }
                MapUtilities.DrawTexture(tex, point, size, angleDegrees, opacity);
            }
        }
Exemplo n.º 2
0
        public override MapObjectHoverData GetHoverDataTopDownView(bool isForObjectDrag, bool forceCursorPosition)
        {
            Point?relPosMaybe = MapObjectHoverData.GetPositionMaybe(isForObjectDrag, forceCursorPosition);

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

            (float inGameX, float inGameY, float inGameZ) = GetArrowHeadPosition();
            (double controlX, double controlZ)            = MapUtilities.ConvertCoordsForControlTopDownView(inGameX, inGameZ, UseRelativeCoordinates);
            double dist = MoreMath.GetDistanceBetween(controlX, controlZ, relPos.X, relPos.Y);

            if (dist <= 20 || forceCursorPosition)
            {
                return(new MapObjectHoverData(this, inGameX, inGameY, inGameZ));
            }
            return(null);
        }
Exemplo n.º 3
0
        public override MapObjectHoverData GetHoverDataOrthographicView(bool isForObjectDrag, bool forceCursorPosition)
        {
            Point?relPosMaybe = MapObjectHoverData.GetPositionMaybe(isForObjectDrag, forceCursorPosition);

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

            (double x, double y, double z, double angle) = GetPositionAngle().GetValues();
            (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 ? GetSize() * Config.CurrentMapGraphics.MapViewScaleValue : GetSize();

            if (dist <= radius || forceCursorPosition)
            {
                return(new MapObjectHoverData(this, x, y, z));
            }
            return(null);
        }
Exemplo n.º 4
0
        public override MapObjectHoverData GetHoverDataTopDownView(bool isForObjectDrag, bool forceCursorPosition)
        {
            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, double angle) = GetPositionAngle().GetValues();
            double dist   = MoreMath.GetDistanceBetween(x, z, inGameX, inGameZ);
            double radius = Scales ? GetSize() : GetSize() / Config.CurrentMapGraphics.MapViewScaleValue;

            if (dist <= radius || forceCursorPosition)
            {
                return(new MapObjectHoverData(this, x, y, z));
            }
            return(null);
        }
Exemplo n.º 5
0
        public override void DrawOn2DControlOrthographicView(MapObjectHoverData hoverData)
        {
            base.DrawOn2DControlOrthographicView(hoverData);

            if (_customImage != null)
            {
                List <(float x, float y, float z)> positions = GetGridlineIntersectionPositionsOrthographicView();
                for (int i = 0; i < positions.Count; i++)
                {
                    (float x, float y, float z)      = positions[i];
                    (float controlX, float controlZ) = MapUtilities.ConvertCoordsForControlOrthographicView(x, y, z, UseRelativeCoordinates);
                    SizeF  size    = MapUtilities.ScaleImageSizeForControl(_customImage.Size, _imageSize, Scales);
                    double opacity = Opacity;
                    if (this == hoverData?.MapObject && i == hoverData?.Index)
                    {
                        opacity = MapUtilities.GetHoverOpacity();
                    }
                    MapUtilities.DrawTexture(_customImageTex.Value, new PointF(controlX, controlZ), size, 0, opacity);
                }
            }
        }
Exemplo n.º 6
0
        public override void DrawOn2DControlOrthographicView(MapObjectHoverData hoverData)
        {
            List <(float x, float y, float z)> data = GetData();

            for (int i = 0; i < data.Count; i++)
            {
                var dataPoint = data[i];
                (float x, float y, float z)         = dataPoint;
                (float x, float z)positionOnControl = MapUtilities.ConvertCoordsForControlOrthographicView(x, y, z, UseRelativeCoordinates);
                SizeF  size    = MapUtilities.ScaleImageSizeForControl(Config.ObjectAssociations.BlueMarioMapImage.Size, Size, Scales);
                PointF point   = new PointF(positionOnControl.x, positionOnControl.z);
                double opacity = Opacity;
                if (this == hoverData?.MapObject && i == hoverData?.Index)
                {
                    opacity = MapUtilities.GetHoverOpacity();
                }
                MapUtilities.DrawTexture(_customImageTex ?? _tex, point, size, 0, opacity);
            }

            if (LineWidth != 0)
            {
                GL.BindTexture(TextureTarget.Texture2D, -1);
                GL.MatrixMode(MatrixMode.Modelview);
                GL.LoadIdentity();
                GL.Color4(LineColor.R, LineColor.G, LineColor.B, OpacityByte);
                GL.LineWidth(LineWidth);
                GL.Begin(PrimitiveType.Lines);
                for (int i = 0; i < data.Count - 1; i++)
                {
                    (float x1, float y1, float z1)      = data[i];
                    (float x2, float y2, float z2)      = data[i + 1];
                    (float x, float z)vertex1ForControl = MapUtilities.ConvertCoordsForControlOrthographicView(x1, y1, z1, UseRelativeCoordinates);
                    (float x, float z)vertex2ForControl = MapUtilities.ConvertCoordsForControlOrthographicView(x2, y2, z2, UseRelativeCoordinates);
                    GL.Vertex2(vertex1ForControl.x, vertex1ForControl.z);
                    GL.Vertex2(vertex2ForControl.x, vertex2ForControl.z);
                }
                GL.End();
                GL.Color4(1, 1, 1, 1.0f);
            }
        }
Exemplo n.º 7
0
        public override List <ToolStripItem> GetHoverContextMenuStripItems(MapObjectHoverData hoverData)
        {
            List <ToolStripItem> output = base.GetHoverContextMenuStripItems(hoverData);

            var quadList = GetQuadList(null);
            var quad     = quadList[hoverData.Index.Value];

            if (quad.Count == 0)
            {
                return(output);
            }

            double xMin = quad.Min(p => p.x);
            double xMax = quad.Max(p => p.x);
            double zMin = quad.Min(p => p.z);
            double zMax = quad.Max(p => p.z);
            double y    = quad.Max(p => p.y);

            ToolStripMenuItem copyXMin = new ToolStripMenuItem(string.Format("Copy X Min ({0})", xMin));
            ToolStripMenuItem copyXMax = new ToolStripMenuItem(string.Format("Copy X Max ({0})", xMax));
            ToolStripMenuItem copyZMin = new ToolStripMenuItem(string.Format("Copy Z Min ({0})", zMin));
            ToolStripMenuItem copyZMax = new ToolStripMenuItem(string.Format("Copy Z Max ({0})", zMax));
            ToolStripMenuItem copyY    = new ToolStripMenuItem(string.Format("Copy Y ({0})", y));

            copyXMin.Click += (sender, e) => Clipboard.SetText(xMin.ToString());
            copyXMax.Click += (sender, e) => Clipboard.SetText(xMax.ToString());
            copyZMin.Click += (sender, e) => Clipboard.SetText(zMin.ToString());
            copyZMax.Click += (sender, e) => Clipboard.SetText(zMax.ToString());
            copyY.Click    += (sender, e) => Clipboard.SetText(y.ToString());

            output.Insert(0, copyXMin);
            output.Insert(1, copyXMax);
            output.Insert(2, copyZMin);
            output.Insert(3, copyZMax);
            output.Insert(4, copyY);

            return(output);
        }
        public override void DrawOn2DControlTopDownView(MapObjectHoverData hoverData)
        {
            List <MapObjectPath> paths = new List <MapObjectPath>();

            foreach (MapTracker mapTracker in Config.MapGui.flowLayoutPanelMapTrackers.Controls)
            {
                paths.AddRange(mapTracker.GetMapPathObjectsOfType <MapObjectPath>());
            }
            List <List <MapObjectPathSegment> > segmentLists = paths.ConvertAll(path => path.GetSegments());

            if (segmentLists.Count == 0)
            {
                return;
            }
            int maxCount = segmentLists.Max(list => list.Count);

            GL.BindTexture(TextureTarget.Texture2D, -1);
            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();
            for (int i = 0; i < maxCount; i++)
            {
                foreach (List <MapObjectPathSegment> segmentList in segmentLists)
                {
                    if (i >= segmentList.Count)
                    {
                        continue;
                    }
                    MapObjectPathSegment segment = segmentList[i];
                    GL.LineWidth(segment.LineWidth);
                    GL.Color4(segment.Color.R, segment.Color.G, segment.Color.B, segment.Opacity);
                    GL.Begin(PrimitiveType.Lines);
                    GL.Vertex2(segment.StartX, segment.StartZ);
                    GL.Vertex2(segment.EndX, segment.EndZ);
                    GL.End();
                }
            }
            GL.Color4(1, 1, 1, 1.0f);
        }
Exemplo n.º 9
0
        public override MapObjectHoverData GetHoverDataOrthographicView(bool isForObjectDrag, bool forceCursorPosition)
        {
            Point?relPosMaybe = MapObjectHoverData.GetPositionMaybe(isForObjectDrag, forceCursorPosition);

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

            var quadList = GetQuadList(null);

            for (int i = quadList.Count - 1; i >= 0; i--)
            {
                var quad           = quadList[i];
                var quadForControl = quad.ConvertAll(p => MapUtilities.ConvertCoordsForControlOrthographicView(p.x, p.y, p.z, UseRelativeCoordinates));
                if (MapUtilities.IsWithinShapeForControl(quadForControl, relPos.X, relPos.Y) || forceCursorPosition)
                {
                    return(new MapObjectHoverData(this, 0, 0, 0, index: i));
                }
            }
            return(null);
        }
Exemplo n.º 10
0
        public override List <ToolStripItem> GetHoverContextMenuStripItems(MapObjectHoverData hoverData)
        {
            List <ToolStripItem> output = base.GetHoverContextMenuStripItems(hoverData);

            ToolStripMenuItem selectObjectItem = new ToolStripMenuItem("Select Object in Object Tab");

            selectObjectItem.Click += (sender, e) => Config.ObjectSlotsManager.SelectSlotByAddress(hoverData.ObjAddress.Value);
            output.Insert(0, selectObjectItem);

            ToolStripMenuItem copyAddressItem = new ToolStripMenuItem("Copy Address");

            copyAddressItem.Click += (sender, e) => Clipboard.SetText(HexUtilities.FormatValue(hoverData.ObjAddress.Value));
            output.Insert(1, copyAddressItem);

            float             x = Config.Stream.GetFloat(hoverData.ObjAddress.Value + ObjectConfig.XOffset);
            float             y = Config.Stream.GetFloat(hoverData.ObjAddress.Value + ObjectConfig.YOffset);
            float             z = Config.Stream.GetFloat(hoverData.ObjAddress.Value + ObjectConfig.ZOffset);
            ToolStripMenuItem copyPositionItem = MapUtilities.CreateCopyItem(x, y, z, "Position");

            output.Insert(2, copyPositionItem);

            return(output);
        }
Exemplo n.º 11
0
        public override List <ToolStripItem> GetHoverContextMenuStripItems(MapObjectHoverData hoverData)
        {
            List <ToolStripItem> output = base.GetHoverContextMenuStripItems(hoverData);

            if (hoverData.Index2.HasValue)
            {
                var points = GetPoints();
                var point  = points[hoverData.Index.Value];
                List <(float x, float z)> positions = MapUtilities.GetFloatPositions(10_000);
                var position = positions[hoverData.Index2.Value];
                ToolStripMenuItem copyPositionItem = MapUtilities.CreateCopyItem(position.x, point.y, position.z, "Position");
                output.Insert(0, copyPositionItem);
            }
            else
            {
                var points = GetPoints();
                var point  = points[hoverData.Index.Value];
                ToolStripMenuItem copyPositionItem = MapUtilities.CreateCopyItem(point.x, point.y, point.z, "Position");
                output.Insert(0, copyPositionItem);
            }

            return(output);
        }
Exemplo n.º 12
0
        public override MapObjectHoverData GetHoverDataOrthographicView(bool isForObjectDrag, bool forceCursorPosition)
        {
            Point?relPosMaybe = MapObjectHoverData.GetPositionMaybe(isForObjectDrag, forceCursorPosition);

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

            List <(float x, float y, float z, float angle, bool rotates, Image image, int tex, uint objAddress)> data = GetData();

            foreach (var dataPoint in data)
            {
                (float controlX, float controlZ) = MapUtilities.ConvertCoordsForControlOrthographicView(dataPoint.x, dataPoint.y, dataPoint.z, UseRelativeCoordinates);
                double dist   = MoreMath.GetDistanceBetween(controlX, controlZ, relPos.X, relPos.Y);
                double radius = Scales ? Size * Config.CurrentMapGraphics.MapViewScaleValue : Size;
                if (dist <= radius || forceCursorPosition)
                {
                    return(new MapObjectHoverData(this, dataPoint.x, dataPoint.y, dataPoint.z, objAddress: dataPoint.objAddress));
                }
            }
            return(null);
        }
Exemplo n.º 13
0
        public override MapObjectHoverData GetHoverDataOrthographicView(bool isForObjectDrag, bool forceCursorPosition)
        {
            Point?relPosMaybe = MapObjectHoverData.GetPositionMaybe(isForObjectDrag, forceCursorPosition);

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

            for (int i = 0; i < data.Count; i++)
            {
                var dataPoint = data[i];
                (float controlX, float controlZ) = MapUtilities.ConvertCoordsForControlOrthographicView(dataPoint.x, dataPoint.y, dataPoint.z, UseRelativeCoordinates);
                double dist   = MoreMath.GetDistanceBetween(controlX, controlZ, relPos.X, relPos.Y);
                double radius = Scales ? Size * Config.CurrentMapGraphics.MapViewScaleValue : Size;
                if (dist <= radius || forceCursorPosition)
                {
                    return(new MapObjectHoverData(this, dataPoint.x, dataPoint.y, dataPoint.z, index: i));
                }
            }
            return(null);
        }
Exemplo n.º 14
0
        public override MapObjectHoverData GetHoverDataTopDownView(bool isForObjectDrag, bool forceCursorPosition)
        {
            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);
            var quadList = GetQuadList(null);

            for (int i = quadList.Count - 1; i >= 0; i--)
            {
                var quad       = quadList[i];
                var simpleQuad = quad.ConvertAll(q => (q.x, q.y, q.z));
                if (MapUtilities.IsWithinRectangularQuad(simpleQuad, inGameX, inGameZ) || forceCursorPosition)
                {
                    return(new MapObjectHoverData(this, 0, 0, 0, index: i));
                }
            }
            return(null);
        }
Exemplo n.º 15
0
        public override MapObjectHoverData GetHoverDataOrthographicView(bool isForObjectDrag, bool forceCursorPosition)
        {
            Point?relPosMaybe = MapObjectHoverData.GetPositionMaybe(isForObjectDrag, forceCursorPosition);

            if (!relPosMaybe.HasValue)
            {
                return(null);
            }
            Point relPos = relPosMaybe.Value;
            List <(float centerX, float centerZ, float radius, Color color)> dimensionList = GetOrthographicDimensionsForControl();

            for (int i = dimensionList.Count - 1; i >= 0; i--)
            {
                var    dimension = dimensionList[i];
                double dist      = MoreMath.GetDistanceBetween(dimension.centerX, dimension.centerZ, relPos.X, relPos.Y);
                if (dist <= dimension.radius || forceCursorPosition)
                {
                    var inGameDimensionList = GetPoints();
                    var inGameDimension     = inGameDimensionList[i];
                    return(new MapObjectHoverData(this, inGameDimension.x, inGameDimension.y, inGameDimension.z, index: i));
                }
            }
            return(null);
        }
Exemplo n.º 16
0
 public override void DrawOn2DControlTopDownView(MapObjectHoverData hoverData)
 {
     // do nothing
 }
Exemplo n.º 17
0
        public void DrawOn2DControl(bool isMainGraphics)
        {
            List <MapObject> listOrderOnTop    = new List <MapObject>();
            List <MapObject> listOrderOnBottom = new List <MapObject>();
            List <MapObject> listOrderByY      = new List <MapObject>();

            MapType mapType = Config.CurrentMapGraphics.IsOrthographicViewEnabled ? MapType.Map2DOrthographic : MapType.Map2DTopDown;

            lock (_objectLock)
            {
                foreach (MapTracker mapTracker in Controls)
                {
                    List <MapObject> mapObjects = mapTracker.GetMapObjectsToDisplay(mapType);
                    switch (mapTracker.GetOrderType())
                    {
                    case MapTrackerOrderType.OrderOnTop:
                        listOrderOnTop.AddRange(mapObjects);
                        break;

                    case MapTrackerOrderType.OrderOnBottom:
                        listOrderOnBottom.AddRange(mapObjects);
                        break;

                    case MapTrackerOrderType.OrderByY:
                        listOrderByY.AddRange(mapObjects);
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }
            }

            listOrderOnTop.Reverse();
            listOrderOnBottom.Reverse();
            listOrderByY.Reverse();
            listOrderByY = listOrderByY.OrderBy(obj => obj.GetY()).ToList();
            List <MapObject> listCombined = listOrderOnBottom.Concat(listOrderByY).Concat(listOrderOnTop).ToList();

            if (!Config.MapGui.checkBoxMapOptionsDisableHitboxTris.Checked)
            {
                listCombined.Insert(0, _mapObjHitboxTris);
            }
            listCombined.Insert(0, _mapObjMap);
            listCombined.Insert(0, _mapObjBackground);

            MapObjectHoverData hoverData = null;

            if (isMainGraphics &&
                !Config.MapGui.checkBoxMapOptionsEnable3D.Checked &&
                Config.MapGui.checkBoxMapOptionsEnableObjectHover.Checked)
            {
                for (int i = listCombined.Count - 1; i >= 0; i--)
                {
                    MapObject mapObject = listCombined[i];
                    hoverData = mapObject.GetHoverData(false, false);
                    if (hoverData != null)
                    {
                        break;
                    }
                }
                if (hoverData == null || KeyboardUtilities.IsCtrlHeld())
                {
                    hoverData = MapObjectHoverData.GetMapObjectHoverDataForCursor(false);
                }
                if (Config.CurrentMapGraphics.DraggedObject != null)
                {
                    hoverData = Config.CurrentMapGraphics.DraggedObject;
                }
                if (!Equals(PreviousHoverData, hoverData))
                {
                    PreviousHoverData = hoverData;
                    MapObjectHoverData.HoverStartTime = DateTimeOffset.Now.ToUnixTimeMilliseconds();
                    if (hoverData != null && hoverData.Tri != null)
                    {
                        MapObjectHoverData.LastTriangleAddress = hoverData.Tri.Address;
                    }
                }
                if (hoverData == null)
                {
                    Config.HideDebugText();
                }
                else
                {
                    Config.SetDebugText(hoverData);
                }
            }

            if (isMainGraphics)
            {
                ObjectDragData = null;
                if (!Config.MapGui.checkBoxMapOptionsEnable3D.Checked &&
                    Config.MapGui.checkBoxMapOptionsEnableObjectDrag.Checked)
                {
                    for (int i = listCombined.Count - 1; i >= 0; i--)
                    {
                        MapObject mapObject = listCombined[i];
                        if (mapObject.GetDragPosition().HasValue)
                        {
                            ObjectDragData = mapObject.GetHoverData(true, false);
                        }
                        if (ObjectDragData != null)
                        {
                            break;
                        }
                    }
                }
            }

            foreach (MapObject obj in listCombined)
            {
                obj.DrawOn2DControl(hoverData);
            }
        }
Exemplo n.º 18
0
        public override void DrawOn2DControlTopDownView(MapObjectHoverData hoverData)
        {
            List <CompassArrow> arrows = Enumerable.Range(0, 4).ToList().ConvertAll(index => new CompassArrow(16384 * index));

            List <List <(float x, float z)> > triPoints = new List <List <(float x, float z)> >();

            foreach (CompassArrow arrow in arrows)
            {
                triPoints.Add(new List <(float x, float z)>()
                {
                    arrow.ArrowHeadPoint, arrow.ArrowHeadCornerLeft, arrow.ArrowHeadCornerRight
                });
                triPoints.Add(new List <(float x, float z)>()
                {
                    arrow.ArrowHeadInnerCornerRight, arrow.ArrowHeadInnerCornerLeft, arrow.ArrowBaseLeft
                });
                triPoints.Add(new List <(float x, float z)>()
                {
                    arrow.ArrowBaseLeft, arrow.ArrowBaseRight, arrow.ArrowHeadInnerCornerRight
                });
                triPoints.Add(new List <(float x, float z)>()
                {
                    arrow.ArrowBaseRight, arrow.ArrowBaseLeft, (MapConfig.CompassCenterX, MapConfig.CompassCenterZ)
                });
            }
            List <List <(float x, float z)> > triPointsForControl =
                triPoints.ConvertAll(tri => tri.ConvertAll(
                                         vertex => RotatePoint(vertex.x, vertex.z)));

            List <(float x, float z)> outlinePoints           = arrows.ConvertAll(arrow => arrow.GetOutlinePoints()).SelectMany(points => points).ToList();
            List <(float x, float z)> outlinePointsForControl = outlinePoints.ConvertAll(point => RotatePoint(point.x, point.z));

            GL.BindTexture(TextureTarget.Texture2D, -1);
            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();

            // Draw polygon
            GL.Color4(Color.R, Color.G, Color.B, OpacityByte);
            GL.Begin(PrimitiveType.Triangles);
            foreach (List <(float x, float z)> tri in triPointsForControl)
            {
                foreach ((float x, float z) in tri)
                {
                    GL.Vertex2(x, z);
                }
            }
            GL.End();

            // Draw outline
            if (LineWidth != 0)
            {
                GL.Color4(LineColor.R, LineColor.G, LineColor.B, (byte)255);
                GL.LineWidth(LineWidth);
                GL.Begin(PrimitiveType.LineLoop);
                foreach ((float x, float z) in outlinePointsForControl)
                {
                    GL.Vertex2(x, z);
                }
                GL.End();
            }

            // Draw direction labels
            if (MapConfig.CompassShowDirectionText != 0)
            {
                List <int> directionTexs = new List <int>()
                {
                    _texZP, _texXP, _texZM, _texXM
                };
                for (int i = 0; i < arrows.Count; i++)
                {
                    CompassArrow arrow = arrows[i];
                    int          tex   = directionTexs[i];

                    (float x, float z)textPosition = arrow.DirectionTextPosition;
                    textPosition = RotatePoint(textPosition.x, textPosition.z);
                    PointF loc  = new PointF(textPosition.x, textPosition.z);
                    SizeF  size = new SizeF((int)MapConfig.CompassDirectionTextSize, (int)MapConfig.CompassDirectionTextSize);

                    // Place and rotate texture to correct location on control
                    GL.LoadIdentity();
                    GL.Translate(new Vector3(loc.X, loc.Y, 0));
                    GL.Color4(1.0, 1.0, 1.0, 1.0);

                    // Start drawing texture
                    GL.BindTexture(TextureTarget.Texture2D, tex);
                    GL.Begin(PrimitiveType.Quads);

                    // Set drawing coordinates
                    GL.TexCoord2(0.0f, 1.0f); GL.Vertex2(-size.Width / 2, size.Height / 2);
                    GL.TexCoord2(1.0f, 1.0f); GL.Vertex2(size.Width / 2, size.Height / 2);
                    GL.TexCoord2(1.0f, 0.0f); GL.Vertex2(size.Width / 2, -size.Height / 2);
                    GL.TexCoord2(0.0f, 0.0f); GL.Vertex2(-size.Width / 2, -size.Height / 2);

                    GL.End();
                }
            }

            // Draw angle labels
            if (MapConfig.CompassShowAngleText != 0)
            {
                List <int> angleTexs =
                    MapConfig.CompassAngleTextSigned != 0 ?
                    new List <int>()
                {
                    _tex0, _tex16384, _texM32768, _texM16384
                } :
                new List <int>()
                {
                    _tex0, _tex16384, _tex32768, _tex49152
                };
                for (int i = 0; i < arrows.Count; i++)
                {
                    CompassArrow arrow = arrows[i];
                    int          tex   = angleTexs[i];

                    (float x, float z)textPosition = arrow.AngleTextPosition;
                    textPosition = RotatePoint(textPosition.x, textPosition.z);
                    PointF loc  = new PointF(textPosition.x, textPosition.z);
                    SizeF  size = new SizeF((int)MapConfig.CompassAngleTextSize, (int)MapConfig.CompassAngleTextSize);

                    // Place and rotate texture to correct location on control
                    GL.LoadIdentity();
                    GL.Translate(new Vector3(loc.X, loc.Y, 0));
                    GL.Color4(1.0, 1.0, 1.0, 1.0);

                    // Start drawing texture
                    GL.BindTexture(TextureTarget.Texture2D, tex);
                    GL.Begin(PrimitiveType.Quads);

                    // Set drawing coordinates
                    GL.TexCoord2(0.0f, 1.0f); GL.Vertex2(-size.Width / 2, size.Height / 2);
                    GL.TexCoord2(1.0f, 1.0f); GL.Vertex2(size.Width / 2, size.Height / 2);
                    GL.TexCoord2(1.0f, 0.0f); GL.Vertex2(size.Width / 2, -size.Height / 2);
                    GL.TexCoord2(0.0f, 0.0f); GL.Vertex2(-size.Width / 2, -size.Height / 2);

                    GL.End();
                }
            }

            GL.Color4(1, 1, 1, 1.0f);
        }
Exemplo n.º 19
0
        protected override List <List <(float x, float y, float z, Color color, bool isHovered)> > GetQuadList(MapObjectHoverData hoverData)
        {
            (float posAngleX, float posAngleY, float posAngleZ, float posAngleAngle) =
                ((float, float, float, float))_posAngle.GetValues();

            int xMin = (short)posAngleX;
            int xMax = xMin + (posAngleX >= 0 ? 1 : -1);
            int zMin = (short)posAngleZ;
            int zMax = zMin + (posAngleZ >= 0 ? 1 : -1);

            bool isHovered = this == hoverData?.MapObject;
            List <(float x, float y, float z, Color color, bool isHovered)> quad =
                new List <(float x, float y, float z, Color color, bool isHovered)>()
            {
                (xMin, posAngleY, zMin, Color, isHovered),
                (xMin, posAngleY, zMax, Color, isHovered),
                (xMax, posAngleY, zMax, Color, isHovered),
                (xMax, posAngleY, zMin, Color, isHovered),
            };

            return(new List <List <(float x, float y, float z, Color color, bool isHovered)> >()
            {
                quad
            });
        }
Exemplo n.º 20
0
        protected override List <List <(float x, float y, float z, Color color, bool isHovered)> > GetQuadList(MapObjectHoverData hoverData)
        {
            (float posAngleX, float posAngleY, float posAngleZ, float posAngleAngle) =
                ((float, float, float, float))_posAngle.GetValues();

            (int cellX, int cellZ) = CellUtilities.GetCell(posAngleX, posAngleZ);
            int xMin = (cellX - 8) * 1024;
            int xMax = xMin + 1024;
            int zMin = (cellZ - 8) * 1024;
            int zMax = zMin + 1024;

            bool isHovered = this == hoverData?.MapObject;

            List <(float x, float y, float z, Color color, bool isHovered)> quad =
                new List <(float x, float y, float z, Color color, bool isHovered)>()
            {
                (xMin, posAngleY, zMin, Color, isHovered),
                (xMin, posAngleY, zMax, Color, isHovered),
                (xMax, posAngleY, zMax, Color, isHovered),
                (xMax, posAngleY, zMin, Color, isHovered),
            };

            return(new List <List <(float x, float y, float z, Color color, bool isHovered)> >()
            {
                quad
            });
        }
Exemplo n.º 21
0
        public override void DrawOn2DControlTopDownView(MapObjectHoverData hoverData)
        {
            float marioHeight = Config.Stream.GetFloat(MarioConfig.StructAddress + MarioConfig.YOffset);
            float?height      = _relativeHeight.HasValue ? marioHeight - _relativeHeight.Value : _absoluteHeight;

            List <TriangleMapData> wallDataList = GetFilteredTriangles()
                                                  .ConvertAll(tri => MapUtilities.Get2DWallDataFromTri(tri, height))
                                                  .FindAll(wallDataNullable => wallDataNullable != null);

            foreach (TriangleMapData wallData in wallDataList)
            {
                float angle          = (float)MoreMath.AngleTo_Radians(wallData.X1, wallData.Z1, wallData.X2, wallData.Z2);
                float projectionDist = Size / (float)Math.Abs(wallData.Tri.XProjection ? Math.Cos(angle) : Math.Sin(angle));
                List <List <(float x, float z)> > quads = new List <List <(float x, float z)> >();
                void addQuad(float xAdd, float zAdd)
                {
                    quads.Add(new List <(float x, float z)>()
                    {
                        (wallData.X1, wallData.Z1),
                        (wallData.X1 + xAdd, wallData.Z1 + zAdd),
                        (wallData.X2 + xAdd, wallData.Z2 + zAdd),
                        (wallData.X2, wallData.Z2),
                    });
                };
                if (wallData.Tri.XProjection)
                {
                    addQuad(projectionDist, 0);
                    addQuad(-1 * projectionDist, 0);
                }
                else
                {
                    addQuad(0, projectionDist);
                    addQuad(0, -1 * projectionDist);
                }

                List <List <(float x, float z)> > quadsForControl =
                    quads.ConvertAll(quad => quad.ConvertAll(
                                         vertex => MapUtilities.ConvertCoordsForControlTopDownView(vertex.x, vertex.z, UseRelativeCoordinates)));

                GL.BindTexture(TextureTarget.Texture2D, -1);
                GL.MatrixMode(MatrixMode.Modelview);
                GL.LoadIdentity();

                // Draw quad
                byte opacityByte = OpacityByte;
                if (this == hoverData?.MapObject && hoverData?.Tri == wallData.Tri && !hoverData.Index.HasValue)
                {
                    opacityByte = MapUtilities.GetHoverOpacityByte();
                }
                GL.Color4(Color.R, Color.G, Color.B, opacityByte);
                GL.Begin(PrimitiveType.Quads);
                foreach (List <(float x, float z)> quad in quadsForControl)
                {
                    foreach ((float x, float z) in quad)
                    {
                        GL.Vertex2(x, z);
                    }
                }
                GL.End();

                if (_showArrows)
                {
                    double totalDistance = MoreMath.GetDistanceBetween(
                        wallData.X1, wallData.Z1, wallData.X2, wallData.Z2);
                    List <double> markDistances = new List <double>();
                    if (totalDistance < 100)
                    {
                        markDistances.Add(totalDistance / 2);
                    }
                    else
                    {
                        int    cardinalAngle        = wallData.Tri.XProjection ? 16384 : 0;
                        double angleDiffCoefficient = 1 / Math.Abs(Math.Cos(MoreMath.AngleUnitsToRadians(wallData.Tri.GetPushAngle() - cardinalAngle)));
                        double firstDistance        = 25 * angleDiffCoefficient;
                        double lastDistance         = totalDistance - 25 * angleDiffCoefficient;
                        double distanceDiff         = lastDistance - firstDistance;
                        int    numMarks             = (int)Math.Truncate(distanceDiff / 50 + 0.25) + 1;
                        int    numBetweens          = numMarks - 1;
                        double betweenDistance      = distanceDiff / numBetweens;
                        for (int i = 0; i < numMarks; i++)
                        {
                            markDistances.Add(firstDistance + i * betweenDistance);
                        }
                    }

                    List <(float x, float z)> markPoints = new List <(float x, float z)>();
                    foreach (double dist in markDistances)
                    {
                        double portion = dist / totalDistance;
                        (double x, double z)pointOnMidpoint =
                            (wallData.X1 + portion * (wallData.X2 - wallData.X1), wallData.Z1 + portion * (wallData.Z2 - wallData.Z1));
                        (double x, double z)pointOnSide1 = wallData.Tri.XProjection ?
                                                           (pointOnMidpoint.x - projectionDist / 2, pointOnMidpoint.z) :
                                                           (pointOnMidpoint.x, pointOnMidpoint.z - projectionDist / 2);
                        (double x, double z)pointOnSide2 = wallData.Tri.XProjection ?
                                                           (pointOnMidpoint.x + projectionDist / 2, pointOnMidpoint.z) :
                                                           (pointOnMidpoint.x, pointOnMidpoint.z + projectionDist / 2);
                        markPoints.Add(((float x, float z))pointOnSide1);
                        markPoints.Add(((float x, float z))pointOnSide2);
                    }

                    markPoints = markPoints.FindAll(p => MapUtilities.IsInVisibleSpace(p.x, p.z, 200));

                    double pushAngle      = wallData.Tri.GetPushAngle();
                    double angleUp        = pushAngle;
                    double angleDown      = pushAngle + 32768;
                    double angleLeft      = pushAngle + 16384;
                    double angleRight     = pushAngle - 16384;
                    double angleUpLeft    = pushAngle + 8192;
                    double angleUpRight   = pushAngle - 8192;
                    double angleDownLeft  = pushAngle + 24576;
                    double angleDownRight = pushAngle - 24576;

                    double arrowBaseLength = 0.4 * Math.Min(Size, 50);
                    double arrowSideLength = 0.2 * Math.Min(Size, 50);

                    List <List <(float x, float z)> > arrowPoints = markPoints.ConvertAll(midPoint =>
                    {
                        (float x, float z)frontPoint = ((float, float))MoreMath.AddVectorToPoint(
                            arrowBaseLength, angleUp, midPoint.x, midPoint.z);
                        (float x, float z)leftOuterPoint = ((float, float))MoreMath.AddVectorToPoint(
                            arrowBaseLength / 2 + arrowSideLength, angleLeft, midPoint.x, midPoint.z);
                        (float x, float z)leftInnerPoint = ((float, float))MoreMath.AddVectorToPoint(
                            arrowBaseLength / 2, angleLeft, midPoint.x, midPoint.z);
                        (float x, float z)rightOuterPoint = ((float, float))MoreMath.AddVectorToPoint(
                            arrowBaseLength / 2 + arrowSideLength, angleRight, midPoint.x, midPoint.z);
                        (float x, float z)rightInnerPoint = ((float, float))MoreMath.AddVectorToPoint(
                            arrowBaseLength / 2, angleRight, midPoint.x, midPoint.z);
                        (float x, float z)backLeftPoint = ((float, float))MoreMath.AddVectorToPoint(
                            arrowBaseLength, angleDown, leftInnerPoint.x, leftInnerPoint.z);
                        (float x, float z)backRightPoint = ((float, float))MoreMath.AddVectorToPoint(
                            arrowBaseLength, angleDown, rightInnerPoint.x, rightInnerPoint.z);

                        return(new List <(float x, float z)>()
                        {
                            frontPoint,
                            leftOuterPoint,
                            leftInnerPoint,
                            backLeftPoint,
                            backRightPoint,
                            rightInnerPoint,
                            rightOuterPoint,
                        });
                    });

                    List <List <(float x, float z)> > arrowsForControl =
                        arrowPoints.ConvertAll(arrow => arrow.ConvertAll(
                                                   vertex => MapUtilities.ConvertCoordsForControlTopDownView(vertex.x, vertex.z, UseRelativeCoordinates)));

                    // Draw arrow
                    Color arrowColor = Color.Darken(0.5);
                    GL.Color4(arrowColor.R, arrowColor.G, arrowColor.B, opacityByte);
                    foreach (List <(float x, float z)> arrow in arrowsForControl)
                    {
                        GL.Begin(PrimitiveType.Polygon);
                        foreach ((float x, float z) in arrow)
                        {
                            GL.Vertex2(x, z);
                        }
                        GL.End();
                    }
                }

                // Draw outline
                if (LineWidth != 0)
                {
                    GL.Color4(LineColor.R, LineColor.G, LineColor.B, (byte)255);
                    GL.LineWidth(LineWidth);
                    foreach (List <(float x, float z)> quad in quadsForControl)
                    {
                        GL.Begin(PrimitiveType.LineLoop);
                        foreach ((float x, float z) in quad)
                        {
                            GL.Vertex2(x, z);
                        }
                        GL.End();
                    }
                }

                if (_customImage != null)
                {
                    for (int i = 0; i < quadsForControl.Count; i++)
                    {
                        var quad = quadsForControl[i];
                        for (int j = 0; j < quad.Count; j++)
                        {
                            var    vertex  = quad[j];
                            PointF point   = new PointF(vertex.x, vertex.z);
                            SizeF  size    = MapUtilities.ScaleImageSizeForControl(_customImage.Size, _iconSize, Scales);
                            double opacity = 1;
                            if (this == hoverData?.MapObject && hoverData?.Tri == wallData.Tri && i == hoverData?.Index && j == hoverData?.Index2)
                            {
                                opacity = MapUtilities.GetHoverOpacity();
                            }
                            MapUtilities.DrawTexture(_customImageTex.Value, point, size, 0, opacity);
                        }
                    }
                }

                GL.Color4(1, 1, 1, 1.0f);
            }
        }
Exemplo n.º 22
0
 public override void DrawOn2DControlOrthographicView(MapObjectHoverData hoverData)
 {
     // do nothing
 }
Exemplo n.º 23
0
        public override void DrawOn2DControlTopDownView(MapObjectHoverData hoverData)
        {
            List <(float centerX, float centerY, float centerZ, float radius, Color color)> dimensionList = Get2DDimensions();

            for (int i = 0; i < dimensionList.Count; i++)
            {
                (float centerX, float centerY, float centerZ, float radius, Color color) = dimensionList[i];
                (float controlCenterX, float controlCenterZ) = MapUtilities.ConvertCoordsForControlTopDownView(centerX, centerZ, UseRelativeCoordinates);
                float controlRadius = radius * Config.CurrentMapGraphics.MapViewScaleValue;
                List <(float pointX, float pointZ)> controlPoints = Enumerable.Range(0, MapConfig.MapCircleNumPoints2D).ToList()
                                                                    .ConvertAll(index => (index / (float)MapConfig.MapCircleNumPoints2D) * 65536)
                                                                    .ConvertAll(angle => ((float, float))MoreMath.AddVectorToPoint(controlRadius, angle, controlCenterX, controlCenterZ));

                GL.BindTexture(TextureTarget.Texture2D, -1);
                GL.MatrixMode(MatrixMode.Modelview);
                GL.LoadIdentity();

                // Draw circle
                byte opacityByte = OpacityByte;
                if (this == hoverData?.MapObject && i == hoverData?.Index && hoverData.Index2 == null)
                {
                    opacityByte = MapUtilities.GetHoverOpacityByte();
                }
                GL.Color4(color.R, color.G, color.B, opacityByte);
                GL.Begin(PrimitiveType.TriangleFan);
                GL.Vertex2(controlCenterX, controlCenterZ);
                foreach ((float x, float z) in controlPoints)
                {
                    GL.Vertex2(x, z);
                }
                GL.Vertex2(controlPoints[0].pointX, controlPoints[0].pointZ);
                GL.End();

                // Draw outline
                if (LineWidth != 0)
                {
                    GL.Color4(LineColor.R, LineColor.G, LineColor.B, (byte)255);
                    GL.LineWidth(LineWidth);
                    GL.Begin(PrimitiveType.LineLoop);
                    foreach ((float x, float z) in controlPoints)
                    {
                        GL.Vertex2(x, z);
                    }
                    GL.End();
                }

                if (_customImage != null)
                {
                    List <(float x, float z)> positions = MapUtilities.GetFloatPositions(10_000);
                    for (int j = 0; j < positions.Count; j++)
                    {
                        (float x, float z) = positions[j];
                        float dist = (float)MoreMath.GetDistanceBetween(centerX, centerZ, x, z);
                        if (dist >= radius)
                        {
                            continue;
                        }
                        (float controlX, float controlZ) = MapUtilities.ConvertCoordsForControlTopDownView(x, z, UseRelativeCoordinates);
                        SizeF  size    = MapUtilities.ScaleImageSizeForControl(_customImage.Size, _imageSize, Scales);
                        double opacity = 1;
                        if (this == hoverData?.MapObject && i == hoverData?.Index && j == hoverData?.Index2)
                        {
                            opacity = MapUtilities.GetHoverOpacity();
                        }
                        MapUtilities.DrawTexture(_customImageTex.Value, new PointF(controlX, controlZ), size, 0, opacity);
                    }
                }
            }

            GL.Color4(1, 1, 1, 1.0f);
        }
Exemplo n.º 24
0
        protected override List <List <(float x, float y, float z, Color color, bool isHovered)> > GetQuadList(MapObjectHoverData hoverData)
        {
            (double camX, double camY, double camZ, double camAngle) = PositionAngle.Camera.GetValues();
            double camPitch = Config.Stream.GetShort(CameraConfig.StructAddress + CameraConfig.FacingPitchOffset);
            double fov      = Config.Stream.GetFloat(CameraConfig.FOVStructAddress + CameraConfig.FOVValueOffset);
            double marioY   = Config.Stream.GetFloat(MarioConfig.StructAddress + MarioConfig.YOffset);

            double nearZ        = 100 - Size;
            double farZ         = 20_000 + Size;
            double angleDegrees = fov / 2 + 1;
            double angleRadians = angleDegrees / 360 * 2 * Math.PI;
            double nearXRadius  = nearZ * Math.Tan(angleRadians) + Size;
            double farXRadius   = farZ * Math.Tan(angleRadians) + Size;

            (double x, double y, double z)pointBackCenter  = MoreMath.AddVectorToPointWithPitch(nearZ, camAngle, -camPitch, camX, camY, camZ, false);
            (double x, double y, double z)pointBackLeft    = MoreMath.AddVectorToPoint(nearXRadius, camAngle + 16384, pointBackCenter.x, pointBackCenter.y, pointBackCenter.z);
            (double x, double y, double z)pointBackRight   = MoreMath.AddVectorToPoint(nearXRadius, camAngle - 16384, pointBackCenter.x, pointBackCenter.y, pointBackCenter.z);
            (double x, double y, double z)pointFrontCenter = MoreMath.AddVectorToPointWithPitch(farZ, camAngle, camPitch, camX, camY, camZ, false);
            (double x, double y, double z)pointFrontLeft   = MoreMath.AddVectorToPoint(farXRadius, camAngle + 16384, pointFrontCenter.x, pointFrontCenter.y, pointFrontCenter.z);
            (double x, double y, double z)pointFrontRight  = MoreMath.AddVectorToPoint(farXRadius, camAngle - 16384, pointFrontCenter.x, pointFrontCenter.y, pointFrontCenter.z);

            (double x, double y, double z) getPlaneLineIntersection((double x, double y, double z) p0)
            {
                // x = x0 + at
                // y = y0 + bt
                // z = z0 + ct

                double camAngleRadians = MoreMath.AngleUnitsToRadians(camAngle);
                double camPitchRadians = MoreMath.AngleUnitsToRadians(camPitch + 16384);

                double a = Math.Cos(camPitchRadians) * Math.Sin(camAngleRadians);
                double b = Math.Sin(camPitchRadians);
                double c = Math.Cos(camPitchRadians) * Math.Cos(camAngleRadians);

                // y = M
                // M = y0 + bt
                // bt = M - y0
                // t = (M - y0) / b

                double y = marioY;
                double t = (y - p0.y) / b;
                double x = p0.x + a * t;
                double z = p0.z + c * t;

                return(x, y, z);
            }

            (double x, double y, double z)finalBackLeft   = getPlaneLineIntersection(pointBackLeft);
            (double x, double y, double z)finalBackRight  = getPlaneLineIntersection(pointBackRight);
            (double x, double y, double z)finalFrontLeft  = getPlaneLineIntersection(pointFrontLeft);
            (double x, double y, double z)finalFrontRight = getPlaneLineIntersection(pointFrontRight);

            return(new List <List <(float x, float y, float z, Color color, bool isHovered)> >()
            {
                new List <(float x, float y, float z, Color color, bool isHovered)>()
                {
                    ((float)finalBackLeft.x, (float)finalBackLeft.y, (float)finalBackLeft.z, Color, false),
                    ((float)finalBackRight.x, (float)finalBackRight.y, (float)finalBackRight.z, Color, false),
                    ((float)finalFrontRight.x, (float)finalFrontRight.y, (float)finalFrontRight.z, Color, false),
                    ((float)finalFrontLeft.x, (float)finalFrontLeft.y, (float)finalFrontLeft.z, Color, false),
                },
            });
        }
Exemplo n.º 25
0
        public override MapObjectHoverData GetHoverDataTopDownView(bool isForObjectDrag, bool forceCursorPosition)
        {
            Point?relPosMaybe = MapObjectHoverData.GetPositionMaybe(isForObjectDrag, forceCursorPosition);

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

            float marioHeight = Config.Stream.GetFloat(MarioConfig.StructAddress + MarioConfig.YOffset);
            float?height      = _relativeHeight.HasValue ? marioHeight - _relativeHeight.Value : _absoluteHeight;

            List <TriangleMapData> wallDataList = GetFilteredTriangles()
                                                  .ConvertAll(tri => MapUtilities.Get2DWallDataFromTri(tri, height))
                                                  .FindAll(wallDataNullable => wallDataNullable != null);

            for (int i = wallDataList.Count - 1; i >= 0; i--)
            {
                TriangleMapData wallData = wallDataList[i];

                float angle          = (float)MoreMath.AngleTo_Radians(wallData.X1, wallData.Z1, wallData.X2, wallData.Z2);
                float projectionDist = Size / (float)Math.Abs(wallData.Tri.XProjection ? Math.Cos(angle) : Math.Sin(angle));
                List <List <(float x, float z)> > quads = new List <List <(float x, float z)> >();
                void addQuad(float xAdd, float zAdd)
                {
                    quads.Add(new List <(float x, float z)>()
                    {
                        (wallData.X1, wallData.Z1),
                        (wallData.X1 + xAdd, wallData.Z1 + zAdd),
                        (wallData.X2 + xAdd, wallData.Z2 + zAdd),
                        (wallData.X2, wallData.Z2),
                    });
                };
                if (wallData.Tri.XProjection)
                {
                    addQuad(projectionDist, 0);
                    addQuad(-1 * projectionDist, 0);
                }
                else
                {
                    addQuad(0, projectionDist);
                    addQuad(0, -1 * projectionDist);
                }

                List <List <(float x, float z)> > quadsForControl =
                    quads.ConvertAll(quad => quad.ConvertAll(
                                         vertex => MapUtilities.ConvertCoordsForControlTopDownView(vertex.x, vertex.z, UseRelativeCoordinates)));

                for (int j = 0; j < quadsForControl.Count; j++)
                {
                    List <(float x, float z)> quadForControl = quadsForControl[j];
                    if (_customImage != null)
                    {
                        for (int k = 0; k < quadForControl.Count; k++)
                        {
                            var    vertex = quadForControl[k];
                            double dist   = MoreMath.GetDistanceBetween(vertex.x, vertex.z, relPos.X, relPos.Y);
                            double radius = Scales ? _iconSize * Config.CurrentMapGraphics.MapViewScaleValue : _iconSize;
                            if (dist <= radius || forceCursorPosition)
                            {
                                (float x, float z) = MapUtilities.ConvertCoordsForInGameTopDownView(vertex.x, vertex.z);
                                return(new MapObjectHoverData(this, x, 0, z, tri: wallData.Tri, index: j, index2: k));
                            }
                        }
                    }
                    if (MapUtilities.IsWithinShapeForControl(quadForControl, relPos.X, relPos.Y) || forceCursorPosition)
                    {
                        return(new MapObjectHoverData(
                                   this, wallData.Tri.GetMidpointX(), wallData.Tri.GetMidpointY(), wallData.Tri.GetMidpointZ(), tri: wallData.Tri));
                    }
                }
            }

            return(null);
        }
Exemplo n.º 26
0
 protected abstract List <List <(float x, float y, float z, Color color, bool isHovered)> > GetQuadList(MapObjectHoverData hoverData);
Exemplo n.º 27
0
 public override void DrawOn2DControlOrthographicView(MapObjectHoverData hoverData)
 {
     MapUtilities.DrawLinesOn2DControlOrthographicView(GetVerticesOrthographicView(), LineWidth, LineColor, OpacityByte, UseRelativeCoordinates);
 }
Exemplo n.º 28
0
        protected override List <List <(float x, float y, float z, Color color, bool isHovered)> > GetQuadList(MapObjectHoverData hoverData)
        {
            List <(int y, int xMin, int xMax, int zMin, int zMax)> waters = WaterUtilities.GetWaterLevels();
            List <List <(float x, float y, float z, Color color, bool isHovered)> > quads =
                new List <List <(float x, float y, float z, Color color, bool isHovered)> >();

            for (int i = 0; i < waters.Count; i++)
            {
                bool isHovered = this == hoverData?.MapObject && i == hoverData?.Index;
                var  water     = waters[i];
                List <(float x, float y, float z, Color color, bool isHovered)> quad =
                    new List <(float x, float y, float z, Color color, bool isHovered)>();
                quad.Add((water.xMin, water.y, water.zMin, Color, isHovered));
                quad.Add((water.xMin, water.y, water.zMax, Color, isHovered));
                quad.Add((water.xMax, water.y, water.zMax, Color, isHovered));
                quad.Add((water.xMax, water.y, water.zMin, Color, isHovered));
                quads.Add(quad);
            }
            return(quads);
        }
Exemplo n.º 29
0
        public override List <ToolStripItem> GetHoverContextMenuStripItems(MapObjectHoverData hoverData)
        {
            List <ToolStripItem> output = base.GetHoverContextMenuStripItems(hoverData);

            return(output);
        }
        protected override List <List <(float x, float y, float z, Color color, bool isHovered)> > GetQuadList(MapObjectHoverData hoverData)
        {
            if (!MapUtilities.IsAbleToShowUnitPrecision())
            {
                return(new List <List <(float x, float y, float z, Color color, bool isHovered)> >());
            }

            int xMin = (int)Config.CurrentMapGraphics.MapViewXMin - 1;
            int xMax = (int)Config.CurrentMapGraphics.MapViewXMax + 1;
            int zMin = (int)Config.CurrentMapGraphics.MapViewZMin - 1;
            int zMax = (int)Config.CurrentMapGraphics.MapViewZMax + 1;

            float y = GetHeight();

            List <List <(float x, float y, float z, Color color, bool isHovered)> > quads =
                new List <List <(float x, float y, float z, Color color, bool isHovered)> >();

            for (int x = xMin; x <= xMax; x++)
            {
                for (int z = zMin; z <= zMax; z++)
                {
                    (TriangleDataModel floorTri, float floorY)     = _cellSnapshot.FindFloorAndY(x, y, z);
                    (TriangleDataModel ceilingTri, float ceilingY) = _cellSnapshot.FindCeilingAndY(x, floorY + 80, z);

                    if (floorTri == null || ceilingTri == null)
                    {
                        continue;
                    }
                    if (!floorTri.BelongsToObject && !ceilingTri.BelongsToObject)
                    {
                        continue;
                    }
                    if (floorTri.NormY >= 0.5f && ceilingTri.NormY <= -0.5f)
                    {
                        continue;
                    }

                    float ceilToFloorDist = ceilingY - floorY;
                    if (0 <= ceilToFloorDist && ceilToFloorDist <= 150.0f)
                    {
                        bool  painful = ceilToFloorDist < 10.1f;
                        Color color   = painful ? Color.Red : Color.Green;
                        List <List <(float x, float y, float z)> > currentQuads = MapUtilities.ConvertUnitPointsToQuads(new List <(int x, int z)>()
                        {
                            (x, z)
                        });
                        quads.AddRange(currentQuads.ConvertAll(quad => quad.ConvertAll(point => (point.x, point.y, point.z, color, false))));
                    }
                }
            }
            if (hoverData != null)
            {
                for (int i = 0; i < quads.Count; i++)
                {
                    bool isHovered = this == hoverData?.MapObject && i == hoverData?.Index;
                    if (isHovered)
                    {
                        quads[i] = quads[i].ConvertAll(point => (point.x, point.y, point.z, point.color, isHovered));
                    }
                }
            }
            return(quads);
        }