Untitled
unknown
csharp
3 years ago
16 kB
8
Indexable
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using Client.MirControls;
using Client.MirGraphics;
using Client.MirObjects;
using Client.MirSounds;
using SlimDX;
namespace Client.MirScenes.Dialogs.MainDialog
{
public class MiniMapDialog : MirImageControl
{
public MirImageControl LightSetting, NewMail;
public MirButton ToggleButton, BigMapButton, MailButton;
public MirLabel LocationLabel, MapNameLabel;
private float _fade = 1F;
private bool _bigMode = true, _realBigMode = true;
public bool _extraBigMode;
public List<MirLabel> QuestIcons = new List<MirLabel>();
public MiniMapDialog()
{
Index = 2090;
Library = Libraries.Prguse;
Location = new Point(Settings.ScreenWidth - 126, 0);
PixelDetect = true;
BeforeDraw += MiniMap_BeforeDraw;
AfterDraw += MiniMapDialog_AfterDraw;
MapNameLabel = new MirLabel
{
DrawFormat = TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter,
Parent = this,
Size = new Size(120, 18),
Location = new Point(2, 2),
NotControl = true,
};
LocationLabel = new MirLabel
{
DrawFormat = TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter,
Parent = this,
Size = new Size(56, 18),
Location = new Point(46, 131),
NotControl = true,
};
MailButton = new MirButton
{
Index = 2099,
HoverIndex = 2100,
PressedIndex = 2101,
Parent = this,
Location = new Point(4, 131),
Library = Libraries.Prguse,
Sound = SoundList.ButtonA,
Hint = GameLanguage.Mail
};
MailButton.Click += (o, e) => GameScene.Scene.MailListDialog.Toggle();
NewMail = new MirImageControl
{
Index = 544,
Location = new Point(5, 132),
Parent = this,
Library = Libraries.Prguse,
Visible = false,
NotControl = true
};
BigMapButton = new MirButton
{
Index = 2096,
HoverIndex = 2097,
PressedIndex = 2098,
Parent = this,
Location = new Point(25, 131),
Library = Libraries.Prguse,
Sound = SoundList.ButtonA,
Hint = string.Format(GameLanguage.BigMap, CMain.InputKeys.GetKey(KeybindOptions.Bigmap))
};
BigMapButton.Click += (o, e) => GameScene.Scene.BigMapDialog.Toggle();
ToggleButton = new MirButton
{
Index = 2102,
HoverIndex = 2103,
PressedIndex = 2104,
Parent = this,
Location = new Point(109, 3),
Library = Libraries.Prguse,
Sound = SoundList.ButtonA,
Hint = "MiniMap (" + CMain.InputKeys.GetKey(KeybindOptions.Minimap) + ")"
};
ToggleButton.Click += (o, e) => Toggle();
LightSetting = new MirImageControl
{
Index = 2093,
Library = Libraries.Prguse,
Parent = this,
Location = new Point(102, 131),
};
}
private void MiniMapDialog_AfterDraw(object sender, EventArgs e)
{
}
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;
}
if (map.MiniMap <= 0 || Index != 2090 && Index != 2611 || Libraries.MiniMap == null)
{
return;
}
Rectangle viewRect;
if (_extraBigMode)
{
viewRect = new Rectangle(0, 0, 223, 220);
}
else
{
viewRect = new Rectangle(0, 0, 120, 108);
}
//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;
bool gMember = GroupDialog.GroupList.Where(a => a.PlayerName == ob.Name).FirstOrDefault() != null;
if ((gMember && 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 if (ob is MonsterObject tmp)
{
if (tmp.QuestMob)
colour = Color.Goldenrod;
// Normal Mob
else
colour = Color.FromArgb(255, 0, 0);
}
else
colour = Color.FromArgb(255, 0, 0);
DXManager.Sprite.Draw(DXManager.RadarTexture, new Rectangle(0, 0, 3, 3), Vector3.Zero,
new Vector3((float)(x - 0.5), (float)(y - 0.5), 0.0F), colour);
#region NPC Quest Icons
if (ob is NPCObject npc && 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
}
}
public override void Show()
{
Visible = true;
GameScene.CurrentMiniMapDialog = this;
}
public override void Hide()
{
Visible = false;
}
public override void Toggle()
{
if (_fade == 0F)
{
_bigMode = true;
SetBigMode();
_fade = 1F;
Redraw();
}
else
{
_bigMode = false;
SetSmallMode();
_fade = 0;
Redraw();
Hide();
GameScene.Scene.LargeMiniMapDialog.Show();
}
}
private void SetSmallMode()
{
Index = 2091;
int y = Size.Height - 23;
MailButton.Location = new Point(4, y);
NewMail.Location = new Point(5, y + 1);
BigMapButton.Location = new Point(25, y);
LocationLabel.Location = new Point(46, y);
LightSetting.Location = new Point(102, y);
_realBigMode = false;
GameScene.Scene.DuraStatusPanel.Location = new Point(GameScene.Scene.MiniMapDialog.Location.X + 86,
GameScene.Scene.MiniMapDialog.Size.Height);
GameScene.Scene.CharacterDuraPanel.Location = new Point(GameScene.Scene.MiniMapDialog.Location.X + 61,
GameScene.Scene.MiniMapDialog.Location.Y + 160);
}
private void SetBigMode()
{
Index = 2090;
int y = Size.Height - 23;
MailButton.Location = new Point(4, y);
NewMail.Location = new Point(5, y + 1);
BigMapButton.Location = new Point(25, y);
LocationLabel.Location = new Point(46, y);
LightSetting.Location = new Point(102, y);
_realBigMode = true;
GameScene.Scene.DuraStatusPanel.Location = new Point(GameScene.Scene.MiniMapDialog.Location.X + 86,
GameScene.Scene.MiniMapDialog.Size.Height);
GameScene.Scene.CharacterDuraPanel.Location = new Point(GameScene.Scene.MiniMapDialog.Location.X + 61,
GameScene.Scene.MiniMapDialog.Location.Y + 220);
}
public override void Process()
{
MapControl map = GameScene.Scene.MapControl;
if (map == null) return;
MapNameLabel.Text = map.Title;
LocationLabel.Text = Functions.PointToString(MapObject.User.CurrentLocation);
int offset = _realBigMode ? 0 : 0;
//GameScene.Scene.MainDialogRightBackground.SModeLabel.Location = new Point((GameScene.Scene.MiniMapDialog.Location.X - 3) - GameScene.Scene.MainDialogRightBackground.Location.X,
//(GameScene.Scene.MiniMapDialog.Size.Height + 150) - Settings.ScreenHeight);
GameScene.Scene.MainDialogRightBackground._userTimeLabel.Location = new Point((GameScene.Scene.MiniMapDialog.Location.X - 3) - GameScene.Scene.MainDialogRightBackground.Location.X,
(GameScene.Scene.MiniMapDialog.Size.Height + 105) - Settings.ScreenHeight);
GameScene.Scene.MainDialogRightBackground.AModeLabel.Location = new Point((GameScene.Scene.MiniMapDialog.Location.X - 3) - GameScene.Scene.MainDialogRightBackground.Location.X,
(GameScene.Scene.MiniMapDialog.Size.Height + 120) - Settings.ScreenHeight);
GameScene.Scene.MainDialogRightBackground.PModeLabel.Location = new Point((GameScene.Scene.MiniMapDialog.Location.X - 3) - GameScene.Scene.MainDialogRightBackground.Location.X,
(GameScene.Scene.MiniMapDialog.Size.Height + 135) - Settings.ScreenHeight);
GameScene.Scene.MainDialogRightBackground.PingLabel.Location = new Point((GameScene.Scene.MiniMapDialog.Location.X - 3) - GameScene.Scene.MainDialogRightBackground.Location.X,
(GameScene.Scene.MiniMapDialog.Size.Height + 165) - Settings.ScreenHeight);
GameScene.Scene.MainDialogRightBackground.FPSLabel.Location = new Point((GameScene.Scene.MiniMapDialog.Location.X - 3) - GameScene.Scene.MainDialogRightBackground.Location.X,
(GameScene.Scene.MiniMapDialog.Size.Height + 150) - Settings.ScreenHeight);
GameScene.Scene.BuffsDialog.Location = new Point(GameScene.Scene.MiniMapDialog.Location.X - GameScene.Scene.BuffsDialog.Size.Width, 0);
if (GameScene.Scene.NewMail)
{
double time = (CMain.Time) / 100D;
if (Math.Round(time) % 10 < 5 || GameScene.Scene.NewMailCounter >= 10)
{
NewMail.Visible = true;
}
else
{
if (NewMail.Visible)
{
GameScene.Scene.NewMailCounter++;
}
NewMail.Visible = false;
}
}
else
{
NewMail.Visible = false;
}
}
}
}Editor is loading...