Example #1
0
        private void MiniMap_BeforeDraw(object sender, EventArgs e)
        {
            foreach (var icon in QuestIcons)
            {
                icon.Dispose();
            }

            QuestIcons.Clear();

            MapControl map = GameScene.Scene.MapControl;

            if (map == null)
            {
                return;
            }

            if (map.MiniMap == 0 && Index != 2091)
            {
                SetSmallMode();
            }
            else if (map.MiniMap > 0 && _bigMode && Index == 2091)
            {
                SetBigMode();
            }

            if (map.MiniMap <= 0 || Index != 2090 || Libraries.MiniMap == null)
            {
                return;
            }

            Rectangle viewRect     = new Rectangle(0, 0, 120, 108);
            Point     drawLocation = Location;

            drawLocation.Offset(3, 22);

            Size  miniMapSize = Libraries.MiniMap.GetSize(map.MiniMap);
            float scaleX      = miniMapSize.Width / (float)map.Width;
            float scaleY      = miniMapSize.Height / (float)map.Height;

            viewRect.Location = new Point(
                (int)(scaleX * MapObject.User.CurrentLocation.X) - viewRect.Width / 2,
                (int)(scaleY * MapObject.User.CurrentLocation.Y) - viewRect.Height / 2);

            //   viewRect.Location = viewRect.Location.Subtract(1, 1);
            if (viewRect.Right >= miniMapSize.Width)
            {
                viewRect.X = miniMapSize.Width - viewRect.Width;
            }
            if (viewRect.Bottom >= miniMapSize.Height)
            {
                viewRect.Y = miniMapSize.Height - viewRect.Height;
            }

            if (viewRect.X < 0)
            {
                viewRect.X = 0;
            }
            if (viewRect.Y < 0)
            {
                viewRect.Y = 0;
            }

            Libraries.MiniMap.Draw(map.MiniMap, viewRect, drawLocation, Color.FromArgb(255, 255, 255), _fade);


            int startPointX = (int)(viewRect.X / scaleX);
            int startPointY = (int)(viewRect.Y / scaleY);

            for (int i = MapControl.Objects.Count - 1; i >= 0; i--)
            {
                MapObject ob = MapControl.Objects[i];

                if (ob.Race == ObjectType.Item || ob.Dead || ob.Race == ObjectType.Spell || ob.Sneaking)
                {
                    continue;
                }
                float x = ((ob.CurrentLocation.X - startPointX) * scaleX) + drawLocation.X;
                float y = ((ob.CurrentLocation.Y - startPointY) * scaleY) + drawLocation.Y;

                Color colour;

                if ((GroupDialog.GroupList.Contains(ob.Name) && MapObject.User != ob) || ob.Name.EndsWith(string.Format("({0})", MapObject.User.Name)))
                {
                    colour = Color.FromArgb(0, 0, 255);
                }
                else
                if (ob is PlayerObject)
                {
                    colour = Color.FromArgb(255, 255, 255);
                }
                else if (ob is NPCObject || ob.AI == 6)
                {
                    colour = Color.FromArgb(0, 255, 50);
                }
                else
                {
                    colour = Color.FromArgb(255, 0, 0);
                }

                DXManager.Sprite.Draw2D(DXManager.RadarTexture, Point.Empty, 0, new PointF((int)(x - 0.5F), (int)(y - 0.5F)), colour);

                #region NPC Quest Icons

                NPCObject npc = ob as NPCObject;
                if (npc != null && npc.GetAvailableQuests(true).Any())
                {
                    string text  = "";
                    Color  color = Color.Empty;

                    switch (npc.QuestIcon)
                    {
                    case QuestIcon.ExclamationBlue:
                        color = Color.DodgerBlue;
                        text  = "!";
                        break;

                    case QuestIcon.ExclamationYellow:
                        color = Color.Yellow;
                        text  = "!";
                        break;

                    case QuestIcon.ExclamationGreen:
                        color = Color.Green;
                        text  = "!";
                        break;

                    case QuestIcon.QuestionBlue:
                        color = Color.DodgerBlue;
                        text  = "?";
                        break;

                    case QuestIcon.QuestionWhite:
                        color = Color.White;
                        text  = "?";
                        break;

                    case QuestIcon.QuestionYellow:
                        color = Color.Yellow;
                        text  = "?";
                        break;

                    case QuestIcon.QuestionGreen:
                        color = Color.Green;
                        text  = "?";
                        break;
                    }

                    QuestIcons.Add(new MirLabel
                    {
                        AutoSize   = true,
                        Parent     = GameScene.Scene.MiniMapDialog,
                        Font       = new Font(Settings.FontName, 9f, FontStyle.Bold),
                        DrawFormat = TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter,
                        Text       = text,
                        ForeColour = color,
                        Location   = new Point((int)(x - Settings.ScreenWidth + GameScene.Scene.MiniMapDialog.Size.Width) - 6, (int)(y) - 10),
                        NotControl = true,
                        Visible    = true,
                        Modal      = true
                    });
                }

                #endregion
            }
        }