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)
                {
                    (float x, float z) = GetQuadMidpoint(quad);
                    return(new MapObjectHoverData(this, x, GetHeight(), z, index: i));
                }
            }
            return(null);
        }
        protected override List <(float x, float y, float z)> GetVerticesTopDownView()
        {
            // failsafe to prevent filling the whole screen
            if (!MapUtilities.IsAbleToShowUnitPrecision())
            {
                return(new List <(float x, float y, float z)>());
            }

            float marioY = Config.Stream.GetSingle(MarioConfig.StructAddress + MarioConfig.YOffset);

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

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

            for (int x = xMin; x <= xMax; x += 1)
            {
                vertices.Add((x, marioY, zMin));
                vertices.Add((x, marioY, zMax));
            }
            for (int z = zMin; z <= zMax; z += 1)
            {
                vertices.Add((xMin, marioY, z));
                vertices.Add((xMax, marioY, z));
            }
            return(vertices);
        }
        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;

            var positions = GetGridlineIntersectionPositionsOrthographicView();

            for (int i = positions.Count - 1; i >= 0; i--)
            {
                var position = positions[i];
                (float controlX, float controlZ) = MapUtilities.ConvertCoordsForControlOrthographicView(position.x, position.y, position.z, UseRelativeCoordinates);
                double dist   = MoreMath.GetDistanceBetween(controlX, controlZ, relPos.X, relPos.Y);
                double radius = Scales ? _imageSize * Config.CurrentMapGraphics.MapViewScaleValue : _imageSize;
                if (dist <= radius || forceCursorPosition)
                {
                    return(new MapObjectHoverData(this, position.x, position.y, position.z, index: i));
                }
            }
            return(null);
        }
Beispiel #4
0
        public MapObjectAllObjectsWithName(string objName)
            : base()
        {
            _objName      = objName;
            texDictionary = new Dictionary <Image, int>();

            List <ObjectBehaviorAssociation> associations = Config.ObjectAssociations.GetObjectAssociations(objName);

            if (associations.Count > 0)
            {
                _objImage       = ImageUtilities.CreateMultiImage(associations.ConvertAll(a => a.Image.Image), 256, 256);
                _objMapImage    = ImageUtilities.CreateMultiImage(associations.ConvertAll(a => a.MapImage.Image), 256, 256);
                InternalRotates = associations[0].RotatesOnMap;

                foreach (ObjectBehaviorAssociation a in associations)
                {
                    texDictionary[a.Image.Image]    = MapUtilities.LoadTexture(a.Image.Image as Bitmap);
                    texDictionary[a.MapImage.Image] = MapUtilities.LoadTexture(a.MapImage.Image as Bitmap);
                }
            }
            else
            {
                _objImage       = Config.ObjectAssociations.EmptyImage;
                _objMapImage    = Config.ObjectAssociations.EmptyImage;
                InternalRotates = false;
            }
        }
        public override MapObjectHoverData GetHoverDataOrthographicView(bool isForObjectDrag, bool forceCursorPosition)
        {
            Point?relPosMaybe = MapObjectHoverData.GetPositionMaybe(isForObjectDrag, forceCursorPosition);

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

            List <List <(float x, float z, Color color)> > dimensionList = GetOrthographicDimensionsForControl();

            for (int i = dimensionList.Count - 1; i >= 0; i--)
            {
                List <(float x, float z, Color color)> dimensionWithColor = dimensionList[i];
                List <(float x, float z)> dimension = dimensionWithColor.ConvertAll(d => (d.x, d.z));
                if (MapUtilities.IsWithinShapeForControl(dimension, relPos.X, relPos.Y) || forceCursorPosition)
                {
                    var inGameDimensionList = GetPoints();
                    var inGameDimension     = inGameDimensionList[i];
                    return(new MapObjectHoverData(this, inGameDimension.x, inGameDimension.y, inGameDimension.z, index: i));
                }
            }
            return(null);
        }
Beispiel #6
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 data = GetData();

            for (int i = 0; i < data.Count; i++)
            {
                var    dataPoint = data[i];
                double dist      = MoreMath.GetDistanceBetween(dataPoint.x, dataPoint.z, inGameX, inGameZ);
                double radius    = Scales ? Size : Size / Config.CurrentMapGraphics.MapViewScaleValue;
                if (dist <= radius || forceCursorPosition)
                {
                    return(new MapObjectHoverData(this, dataPoint.x, dataPoint.y, dataPoint.z, index: i));
                }
            }
            return(null);
        }
        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)
                {
                    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);
                    string info = string.Format("{0}<x<{1} {2}<z<{3}", xMin, xMax, zMin, zMax);
                    return(new MapObjectHoverData(this, 0, 0, 0, index: i, info: info));
                }
            }
            return(null);
        }
        public override ContextMenuStrip GetContextMenuStrip()
        {
            if (_contextMenuStrip == null)
            {
                ToolStripMenuItem addMoreTrisItem = new ToolStripMenuItem("Add More Tris");
                addMoreTrisItem.Click += (sender, e) =>
                {
                    string      text           = DialogUtilities.GetStringFromDialog(labelText: "Enter triangle addresses as hex uints.");
                    List <uint> triAddressList = MapUtilities.ParseCustomTris(text, TriangleClassification.Wall);
                    if (triAddressList == null)
                    {
                        return;
                    }
                    _triList.AddRange(triAddressList.ConvertAll(address => TriangleDataModel.CreateLazy(address)));
                };

                _contextMenuStrip = new ContextMenuStrip();
                _contextMenuStrip.Items.Add(addMoreTrisItem);
                _contextMenuStrip.Items.Add(new ToolStripSeparator());
                GetWallToolStripMenuItems().ForEach(item => _contextMenuStrip.Items.Add(item));
                _contextMenuStrip.Items.Add(new ToolStripSeparator());
                GetTriangleToolStripMenuItems().ForEach(item => _contextMenuStrip.Items.Add(item));
            }

            return(_contextMenuStrip);
        }
        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);
        }
Beispiel #10
0
        protected List <TriangleDataModel> GetFilteredTriangles()
        {
            float centerY = _withinCenter ?? Config.Stream.GetSingle(MarioConfig.StructAddress + MarioConfig.YOffset);
            List <TriangleDataModel> tris = GetUnfilteredTriangles()
                                            .FindAll(tri => tri.IsTriWithinVerticalDistOfCenter(_withinDist, centerY));

            if (_excludeDeathBarriers)
            {
                tris = tris.FindAll(tri => tri.SurfaceType != 0x0A);
            }
            if (Config.MapGui.checkBoxMapOptionsEnableOrthographicView.Checked)
            {
                if (_useCrossSection)
                {
                    tris.Sort((TriangleDataModel t1, TriangleDataModel t2) =>
                    {
                        string string1 = t1.Classification.ToString();
                        string string2 = t2.Classification.ToString();
                        return(string1.CompareTo(string2));
                    });
                }
                else
                {
                    tris.Sort((TriangleDataModel t1, TriangleDataModel t2) =>
                    {
                        double dist1 = MapUtilities.GetSignedDistToCameraPlane(t1);
                        double dist2 = MapUtilities.GetSignedDistToCameraPlane(t2);
                        return(dist2.CompareTo(dist1));
                    });
                }
            }
            return(tris);
        }
        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);
        }
        protected override List <(float x, float y, float z)> GetGridlineIntersectionPositionsTopDownView()
        {
            // failsafe to prevent filling the whole screen
            if (!MapUtilities.IsAbleToShowUnitPrecision())
            {
                return(new List <(float x, float y, float z)>());
            }

            float marioY = Config.Stream.GetFloat(MarioConfig.StructAddress + MarioConfig.YOffset);

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

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

            for (int x = xMin; x <= xMax; x += _multiplier)
            {
                for (int z = zMin; z <= zMax; z += _multiplier)
                {
                    vertices.Add((x, marioY, z));
                }
            }
            return(vertices);
        }
Beispiel #13
0
        private List <(float?minHeight, float?maxHeight, Color color)> GetDrawData()
        {
            if (_enableQuarterFrameLandings)
            {
                float marioY      = Config.Stream.GetFloat(MarioConfig.StructAddress + MarioConfig.YOffset);
                float marioYSpeed = Config.Stream.GetFloat(MarioConfig.StructAddress + MarioConfig.YSpeedOffset);
                List <(float y, float ySpeed)> steps = new List <(float y, float ySpeed)>();
                for (int i = 0; i < 100 && steps.Count < 10; i++)
                {
                    if (marioYSpeed < 0)
                    {
                        steps.Add((marioY, marioYSpeed));
                    }
                    marioY     += marioYSpeed;
                    marioYSpeed = Math.Max(marioYSpeed - 4, -75);
                }

                List <(float yMin, float yMax)> yBounds = new List <(float yMin, float yMax)>();
                foreach ((float y, float ySpeed) in steps)
                {
                    float y0 = y + (0 / 4f) * ySpeed;
                    float y1 = y + (1 / 4f) * ySpeed;
                    float y2 = y + (2 / 4f) * ySpeed;
                    float y3 = y + (3 / 4f) * ySpeed;
                    float y4 = y + (4 / 4f) * ySpeed;
                    yBounds.Add((y1, y0));
                    yBounds.Add((y2, y1));
                    yBounds.Add((y3, y2));
                    yBounds.Add((y4, y3));
                }

                List <(float?minHeight, float?maxHeight, Color color)> drawData =
                    new List <(float?minHeight, float?maxHeight, Color color)>();
                for (int i = 0; i < yBounds.Count; i++)
                {
                    (float yMin, float yMax) = yBounds[i];
                    List <Color> colors = new List <Color>()
                    {
                        Color.Red, Color.Yellow, Color.Green, Color.Cyan
                    };
                    Color color = colors[i % 4];
                    if (_showTriUnits && MapUtilities.IsAbleToShowUnitPrecision())
                    {
                        drawData.Add((yMin, yMax, color));
                    }
                    else
                    {
                        drawData.Add((yMin, MoreMath.GetPreviousFloat(yMax), color));
                    }
                }
                return(drawData);
            }
            else
            {
                return(new List <(float?minHeight, float?maxHeight, Color color)>()
                {
                    (_minHeight, _maxHeight, Color),
                });
            }
        }
Beispiel #14
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)> data = GetData();

            for (int i = data.Count - 1; i >= 0; 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);
        }
        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);
            int inGameXTruncated = (int)inGameX;
            int inGameZTruncated = (int)inGameZ;

            (double x, double y, double z, double angle) = _posAngle.GetValues();
            int xTruncated = (int)x;
            int yTruncated = (int)y;
            int zTruncated = (int)z;

            if (xTruncated == inGameXTruncated && zTruncated == inGameZTruncated || forceCursorPosition)
            {
                return(new MapObjectHoverData(this, xTruncated, yTruncated, zTruncated));
            }
            return(null);
        }
Beispiel #16
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);

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

            foreach (var dataPoint in data)
            {
                double dist   = MoreMath.GetDistanceBetween(dataPoint.x, dataPoint.z, inGameX, inGameZ);
                double radius = Scales ? Size : Size / Config.CurrentMapGraphics.MapViewScaleValue;
                if (dist <= radius || forceCursorPosition)
                {
                    return(new MapObjectHoverData(this, dataPoint.x, dataPoint.y, dataPoint.z, objAddress: dataPoint.objAddress));
                }
            }
            return(null);
        }
        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);

            var positions = GetGridlineIntersectionPositionsTopDownView();

            for (int i = positions.Count - 1; i >= 0; i--)
            {
                var    position = positions[i];
                double dist     = MoreMath.GetDistanceBetween(position.x, position.z, inGameX, inGameZ);
                double radius   = Scales ? _imageSize : _imageSize / Config.CurrentMapGraphics.MapViewScaleValue;
                if (dist <= radius || forceCursorPosition)
                {
                    return(new MapObjectHoverData(this, position.x, 0, position.z, index: i));
                }
            }
            return(null);
        }
Beispiel #18
0
        public List <ToolStripItem> GetContextMenuStripItems()
        {
            List <ToolStripItem> items;

            if (MapObject != null)
            {
                items = MapObject.GetHoverContextMenuStripItems(this);
            }
            else
            {
                items = new List <ToolStripItem>();
            }
            (float x, float y, float z)? cursorPosition = GetCursorPosition(false);
            if (cursorPosition.HasValue)
            {
                if (items.Count > 0)
                {
                    items.Add(new ToolStripSeparator());
                }

                ToolStripMenuItem copyPositionItem = MapUtilities.CreateCopyItem(
                    cursorPosition.Value.x, cursorPosition.Value.y, cursorPosition.Value.z, "Clicked Position");
                items.Add(copyPositionItem);
            }
            return(items);
        }
Beispiel #19
0
 public override void Update()
 {
     if (_redMarioTex == -1)
     {
         _redMarioTex = MapUtilities.LoadTexture(
             Config.ObjectAssociations.MarioMapImage as Bitmap);
     }
     if (_greenMarioTex == -1)
     {
         _greenMarioTex = MapUtilities.LoadTexture(
             Config.ObjectAssociations.GreenMarioMapImage as Bitmap);
     }
     if (_orangeMarioTex == -1)
     {
         _orangeMarioTex = MapUtilities.LoadTexture(
             Config.ObjectAssociations.OrangeMarioMapImage as Bitmap);
     }
     if (_purpleMarioTex == -1)
     {
         _purpleMarioTex = MapUtilities.LoadTexture(
             Config.ObjectAssociations.PurpleMarioMapImage as Bitmap);
     }
     if (_blueMarioTex == -1)
     {
         _blueMarioTex = MapUtilities.LoadTexture(
             Config.ObjectAssociations.BlueMarioMapImage as Bitmap);
     }
 }
        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)
                {
                    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);
                    string info = string.Format("{0}<x<{1} {2}<z<{3}", xMin, xMax, zMin, zMax);
                    return(new MapObjectHoverData(this, 0, 0, 0, index: i, info: info));
                }
            }
            return(null);
        }
 public override void DrawOn2DControlTopDownView()
 {
     if (_enableQuarterFrameLandings)
     {
         float marioY      = Config.Stream.GetSingle(MarioConfig.StructAddress + MarioConfig.YOffset);
         float marioYSpeed = Config.Stream.GetSingle(MarioConfig.StructAddress + MarioConfig.YSpeedOffset);
         List <(float y, float ySpeed)> steps = new List <(float y, float ySpeed)>();
         for (int i = 0; i < 100 && steps.Count < 10; i++)
         {
             if (marioYSpeed < 0)
             {
                 steps.Add((marioY, marioYSpeed));
             }
             marioY     += marioYSpeed;
             marioYSpeed = Math.Max(marioYSpeed - 4, -75);
         }
         List <(float yMin, float yMax)> yBounds = new List <(float yMin, float yMax)>();
         foreach ((float y, float ySpeed) in steps)
         {
             float y0 = y + (0 / 4f) * ySpeed;
             float y1 = y + (1 / 4f) * ySpeed;
             float y2 = y + (2 / 4f) * ySpeed;
             float y3 = y + (3 / 4f) * ySpeed;
             float y4 = y + (4 / 4f) * ySpeed;
             yBounds.Add((y1, y0));
             yBounds.Add((y2, y1));
             yBounds.Add((y3, y2));
             yBounds.Add((y4, y3));
         }
         for (int i = 0; i < yBounds.Count; i++)
         {
             (float yMin, float yMax) = yBounds[i];
             List <Color> colors = new List <Color>()
             {
                 Color.Red, Color.Yellow, Color.Green, Color.Cyan
             };
             Color color = colors[i % 4];
             if (ShowTriUnits && MapUtilities.IsAbleToShowUnitPrecision())
             {
                 DrawOn2DControlTopDownViewWithUnits(yMin, yMax, color);
             }
             else
             {
                 DrawOn2DControlTopDownViewWithoutUnits(yMin, MoreMath.GetPreviousFloat(yMax), color);
             }
         }
     }
     else
     {
         if (ShowTriUnits && MapUtilities.IsAbleToShowUnitPrecision())
         {
             DrawOn2DControlTopDownViewWithUnits(_minHeight, _maxHeight, Color);
         }
         else
         {
             DrawOn2DControlTopDownViewWithoutUnits(_minHeight, _maxHeight, Color);
         }
     }
 }
Beispiel #22
0
 public override void Update()
 {
     if (_tex == -1)
     {
         _tex = MapUtilities.LoadTexture(
             Config.ObjectAssociations.GreenHolpImage as Bitmap);
     }
 }
Beispiel #23
0
        private void DrawOn2DControl(int numQSteps)
        {
            if (!_lockPositions)
            {
                _marioState = MarioState.CreateMarioState();
            }
            MarioState marioStateCenter   = AirMovementCalculator.ApplyInputRepeatedly(_marioState, RelativeDirection.Center, numQSteps);
            MarioState marioStateForward  = AirMovementCalculator.ApplyInputRepeatedly(_marioState, RelativeDirection.Forward, numQSteps);
            MarioState marioStateBackward = AirMovementCalculator.ApplyInputRepeatedly(_marioState, RelativeDirection.Backward, numQSteps);
            MarioState marioStateLeft     = AirMovementCalculator.ApplyInputRepeatedly(_marioState, RelativeDirection.Left, numQSteps);

            ushort marioAngle = _marioState.MarioAngle;

            (float cx, float cz) = (marioStateCenter.X, marioStateCenter.Z);
            (float fx, float fz) = (marioStateForward.X, marioStateForward.Z);
            (float bx, float bz) = (marioStateBackward.X, marioStateBackward.Z);
            (float lx, float lz) = (marioStateLeft.X, marioStateLeft.Z);

            double sideDist     = MoreMath.GetDistanceBetween(cx, cz, lx, lz);
            double forwardDist  = MoreMath.GetDistanceBetween(cx, cz, fx, fz);
            double backwardDist = MoreMath.GetDistanceBetween(cx, cz, bx, bz);

            (float controlCenterX, float controlCenterZ) = MapUtilities.ConvertCoordsForControlTopDownView(cx, cz, UseRelativeCoordinates);
            List <(float pointX, float pointZ)> controlPoints = Enumerable.Range(0, MapConfig.MapCircleNumPoints2D).ToList()
                                                                .ConvertAll(index => (index / (float)MapConfig.MapCircleNumPoints2D) * 65536)
                                                                .ConvertAll(angle => GetEllipsePoint(cx, cz, sideDist, forwardDist, backwardDist, marioAngle, angle))
                                                                .ConvertAll(point => MapUtilities.ConvertCoordsForControlTopDownView((float)point.x, (float)point.z, UseRelativeCoordinates));

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

            // Draw circle
            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();
            }

            GL.Color4(1, 1, 1, 1.0f);
        }
 protected override List <TriangleDataModel> GetUnfilteredTriangles()
 {
     if (_useCurrentCellTris)
     {
         return(MapUtilities.GetTriangles(
                    CellUtilities.GetTriangleAddressesInMarioCell(false, TriangleClassification.Ceiling)));
     }
     return(_tris);
 }
Beispiel #25
0
        public override void DrawOn2DControlOrthographicView()
        {
            (double x, double y, double z, double angle) = GetPositionAngle().GetValues();
            (float xPosPixels, float yPosPixels)         = MapUtilities.ConvertCoordsForControlOrthographicView((float)x, (float)y, (float)z);
            float angleDegrees = Rotates ? MapUtilities.ConvertAngleForControl(angle) : 0;
            SizeF size         = MapUtilities.ScaleImageSizeForControl(Image.Size, Size);

            MapUtilities.DrawTexture(TextureId, new PointF(xPosPixels, yPosPixels), size, angleDegrees, Opacity);
        }
        protected override List <(float x, float y, float z)> GetVerticesOrthographicView()
        {
            // failsafe to prevent filling the whole screen
            if (!MapUtilities.IsAbleToShowUnitPrecision())
            {
                return(new List <(float x, float y, float z)>());
            }

            float xCenter = Config.MapGraphics.MapViewCenterXValue;
            float zCenter = Config.MapGraphics.MapViewCenterZValue;
            int   xMin    = (int)Config.MapGraphics.MapViewXMin - 1;
            int   xMax    = (int)Config.MapGraphics.MapViewXMax + 1;
            int   yMin    = (int)Config.MapGraphics.MapViewYMin - 1;
            int   yMax    = (int)Config.MapGraphics.MapViewYMax + 1;
            int   zMin    = (int)Config.MapGraphics.MapViewZMin - 1;
            int   zMax    = (int)Config.MapGraphics.MapViewZMax + 1;

            if (Config.MapGraphics.MapViewPitchValue == 0 &&
                (Config.MapGraphics.MapViewYawValue == 0 ||
                 Config.MapGraphics.MapViewYawValue == 32768))
            {
                List <(float x, float y, float z)> vertices = new List <(float x, float y, float z)>();
                for (int x = xMin; x <= xMax; x += 1)
                {
                    vertices.Add((x, yMin, zCenter));
                    vertices.Add((x, yMax, zCenter));
                }
                for (int y = yMin; y <= yMax; y += 1)
                {
                    vertices.Add((xMin, y, zCenter));
                    vertices.Add((xMax, y, zCenter));
                }
                return(vertices);
            }
            else if (Config.MapGraphics.MapViewPitchValue == 0 &&
                     (Config.MapGraphics.MapViewYawValue == 16384 ||
                      Config.MapGraphics.MapViewYawValue == 49152))
            {
                List <(float x, float y, float z)> vertices = new List <(float x, float y, float z)>();
                for (int z = zMin; z <= zMax; z += 1)
                {
                    vertices.Add((xCenter, yMin, z));
                    vertices.Add((xCenter, yMax, z));
                }
                for (int y = yMin; y <= yMax; y += 1)
                {
                    vertices.Add((zCenter, y, zMin));
                    vertices.Add((xCenter, y, zMax));
                }
                return(vertices);
            }
            else
            {
                return(new List <(float x, float y, float z)>());
            }
        }
        public override List <ToolStripItem> GetHoverContextMenuStripItems(MapObjectHoverData hoverData)
        {
            List <ToolStripItem> output = base.GetHoverContextMenuStripItems(hoverData);

            ToolStripMenuItem copyPositionItem = MapUtilities.CreateCopyItem((int)_posAngle.X, (int)_posAngle.Y, (int)_posAngle.Z, "Position");

            output.Insert(0, copyPositionItem);

            return(output);
        }
        public static MapObjectCustomWall Create(string text)
        {
            List <uint> triAddressList = MapUtilities.ParseCustomTris(text, TriangleClassification.Wall);

            if (triAddressList == null)
            {
                return(null);
            }
            return(new MapObjectCustomWall(triAddressList));
        }
Beispiel #29
0
        public override void DrawOn2DControlTopDownView(MapObjectHoverData hoverData)
        {
            byte opacityByte = OpacityByte;

            if (this == hoverData?.MapObject)
            {
                opacityByte = MapUtilities.GetHoverOpacityByte();
            }
            MapUtilities.DrawLinesOn2DControlTopDownView(GetVerticesTopDownView(), LineWidth, LineColor, opacityByte, UseRelativeCoordinates);
        }
        public override void DrawOn2DControlTopDownView()
        {
            List <(PointF loc, SizeF size)> dimensions = GetDimensions();
            float angle = InternalRotates ? MapUtilities.ConvertAngleForControl(0) : 0;

            foreach ((PointF loc, SizeF size) in dimensions)
            {
                MapUtilities.DrawTexture(TextureId, loc, size, angle, Opacity);
            }
        }