using System; using Server; using Server.Gumps; using Knives.Utils; namespace Knives.Chat3 { public class Profile { public static void Insert(Mobile m, GumpPlus g, int x, int y) { if ( m == null ) return; Data data = Data.GetData(g.Owner); int oldY = y; g.AddHtml(x, y += 10, 300, 21, HTML.White + "
" + Server.Misc.Titles.ComputeTitle(g.Owner, m), false, false); if (m.AccessLevel != AccessLevel.Player) g.AddHtml(x, y += 20, 300, 21, HTML.White + "
" + m.AccessLevel, false, false); else { if (m.Guild != null) g.AddHtml(x, y += 20, 300, 21, HTML.White + "
[" + m.Guild.Abbreviation + "] " + m.GuildTitle, false, false); if(General.IsInFaction(m)) g.AddHtml(x, y += 20, 300, 21, HTML.White + "
" + General.FactionName(m) + " " + General.FactionTitle(m), false, false); } g.AddButton(x + 20, (y += 30) + 3, 0x2716, 0x2716, "Friend", new TimerStateCallback(Friend), new object[] { data, m, g }); g.AddHtml(x + 40, y, 120, 21, HTML.White + (data.Friends.Contains(m) ? General.Local(1) : General.Local(0)), false, false); g.AddButton(x + 170, y + 3, 0x2716, 0x2716, "Ignore", new TimerStateCallback(Ignore), new object[] { data, m, g }); g.AddHtml(x + 190, y, 120, 21, HTML.White + (data.Ignores.Contains(m) ? General.Local(3) : General.Local(2)), false, false); if (Chat3.Message.CanMessage(data.Mobile, m)) { g.AddButton(x + 20, (y += 20) + 3, 0x2716, 0x2716, "Send Message", new TimerStateCallback(Message), new object[] { data, m, g }); g.AddHtml(x + 40, y, 120, 21, HTML.White + General.Local(13), false, false); } if (data.Mobile.AccessLevel >= AccessLevel.GameMaster && data.Mobile.AccessLevel > m.AccessLevel) { g.AddButton(x + 170, y + 3, 0x2716, 0x2716, "Read Messages", new TimerStateCallback(ReadMessages), new object[] { data, m, g }); g.AddHtml(x + 190, y, 120, 21, HTML.Red + General.Local(14), false, false, false); } y += 20; if (data.Mobile.AccessLevel == AccessLevel.Administrator && m.AccessLevel != AccessLevel.Administrator && m.AccessLevel != AccessLevel.Player) { g.AddButton(x + 20, y + 3, 0x2716, 0x2716, "Global Access", new TimerStateCallback(GlobalAccess), new object[] { m, g }); g.AddHtml(x + 40, y, 120, 21, HTML.LightPurple + (Data.GetData(m).GlobalAccess ? General.Local(5) : General.Local(4)), false, false, false); } if (data.Mobile.AccessLevel >= AccessLevel.GameMaster && m.AccessLevel == AccessLevel.Player) { g.AddButton(x + 170, y + 3, 0x2716, 0x2716, "Ban", new TimerStateCallback(Ban), new object[] { m, g }); g.AddHtml(x + 190, y, 120, 21, HTML.Red + (Data.GetData(m).Banned ? General.Local(7) : General.Local(6)), false, false, false); } if (data.GlobalAccess) { y += 20; if (data.Global) { g.AddButton(x + 20, y + 3, 0x2716, 0x2716, "Global Ignore", new TimerStateCallback(GIgnore), new object[] { data, m, g }); g.AddHtml(x + 40, y, 120, 21, HTML.Red + (data.GIgnores.Contains(m) ? General.Local(9) : General.Local(8)), false, false, false); } else { g.AddButton(x + 170, y + 3, 0x2716, 0x2716, "Global Listen", new TimerStateCallback(GListen), new object[] { data, m, g }); g.AddHtml(x + 190, y, 120, 21, HTML.Red + (data.GListens.Contains(m) ? General.Local(11) : General.Local(10)), false, false, false); } } if (data.Mobile.AccessLevel >= AccessLevel.GameMaster && m.NetState != null) { g.AddButton(x + 20, (y += 20) + 3, 0x2716, 0x2716, "Client", new TimerStateCallback(Client), new object[] { data, m, g }); g.AddHtml(x + 40, y, 120, 21, HTML.Red + General.Local(15), false, false, false); g.AddButton(x + 170, y + 3, 0x2716, 0x2716, "Goto", new TimerStateCallback(Goto), new object[] { data, m, g }); g.AddHtml(x + 190, y, 120, 21, HTML.Red + General.Local(16), false, false, false); } if (data.MsgSound) { g.AddHtml(x, y+=25, 300, 21, HTML.White + "
" + General.Local(17), false, false); g.AddImageTiled(x+125, y+=25, 50, 21, 0xBBA); g.AddTextField(x+125, y, 50, 21, 0x480, 0, data.GetSound(m).ToString()); g.AddButton(x + 185, y+3, 0x15E1, 0x15E5, "Play Sound", new TimerStateCallback(PlaySound), new object[] { data, m, g }); g.AddButton(x + 110, y, 0x983, 0x983, "Sound Up", new TimerStateCallback(SoundUp), new object[] { data, m, g }); g.AddButton(x + 110, y+10, 0x985, 0x985, "Sound Down", new TimerStateCallback(SoundDown), new object[] { data, m, g }); } g.Entries.Insert( 0, new GumpBackground(x, oldY, 300, y+40-oldY, 0x1400)); } private static void Friend(object o) { if (!(o is object[])) return; object[] obj = (object[])o; if (obj.Length != 3 || !(obj[0] is Data) || !(obj[1] is Mobile) || !(obj[2] is GumpPlus)) return; Data data = (Data)obj[0]; Mobile m = (Mobile)obj[1]; GumpPlus g = (GumpPlus)obj[2]; if (Data.GetData(m).ByRequest && !data.Friends.Contains(m)) { if (!TrackSpam.LogSpam(g.Owner, "Request " + m.Name, TimeSpan.FromHours(24))) { TimeSpan ts = TrackSpam.NextAllowedIn(g.Owner, "Request " + m.Name, TimeSpan.FromHours(Data.RequestSpam)); string txt = (ts.Days != 0 ? ts.Days + " " + General.Local(170) + " " : "") + (ts.Hours != 0 ? ts.Hours + " " + General.Local(171) + " " : "") + (ts.Minutes != 0 ? ts.Minutes + " " + General.Local(172) + " " : ""); g.Owner.SendMessage(data.SystemC, General.Local(96) + " " + txt); g.NewGump(); return; } Data.GetData(m).AddMessage(new Message(g.Owner, General.Local(84), General.Local(85), MsgType.Invite)); g.Owner.SendMessage(data.SystemC, General.Local(86) + " " + m.Name); if (m.HasGump(typeof(FriendsGump))) General.RefreshGump(m, typeof(FriendsGump)); else FriendsGump.SendTo(m, true); General.RefreshGump(m, typeof(MailGump)); g.NewGump(); return; } if (data.Friends.Contains(m)) data.RemoveFriend(m); else data.AddFriend(m); g.NewGump(); } private static void Ignore(object o) { if (!(o is object[])) return; object[] obj = (object[])o; if (obj.Length != 3 || !(obj[0] is Data) || !(obj[1] is Mobile) || !(obj[2] is GumpPlus)) return; Data data = (Data)obj[0]; Mobile m = (Mobile)obj[1]; GumpPlus g = (GumpPlus)obj[2]; if (data.Ignores.Contains(m)) data.RemoveIgnore(m); else data.AddIgnore(m); g.NewGump(); } private static void Message(object o) { if (!(o is object[])) return; object[] obj = (object[])o; if (obj.Length != 3 || !(obj[0] is Data) || !(obj[1] is Mobile) || !(obj[2] is GumpPlus)) return; Data data = (Data)obj[0]; Mobile m = (Mobile)obj[1]; GumpPlus g = (GumpPlus)obj[2]; g.NewGump(); if (Chat3.Message.CanMessage(data.Mobile, m)) SendMessageGump.SendTo(data.Mobile, m); } private static void ReadMessages(object o) { if (!(o is object[])) return; object[] obj = (object[])o; if (obj.Length != 3 || !(obj[0] is Data) || !(obj[1] is Mobile) || !(obj[2] is GumpPlus)) return; Data data = (Data)obj[0]; Mobile m = (Mobile)obj[1]; GumpPlus g = (GumpPlus)obj[2]; g.NewGump(); MailGump.SendTo(data.Mobile, m); } private static void GlobalAccess(object o) { if (!(o is object[])) return; object[] obj = (object[])o; if (obj.Length != 2 || !(obj[0] is Mobile) || !(obj[1] is GumpPlus)) return; Mobile m = (Mobile)obj[0]; GumpPlus g = (GumpPlus)obj[1]; Data.GetData(m).GlobalAccess = !Data.GetData(m).GlobalAccess; if (Data.GetData(m).GlobalAccess) g.Owner.SendMessage(Data.GetData(g.Owner).SystemC, m.Name + " " + General.Local(75)); else g.Owner.SendMessage(Data.GetData(g.Owner).SystemC, m.Name + " " + General.Local(76)); g.NewGump(); } private static void Ban(object o) { if (!(o is object[])) return; object[] obj = (object[])o; if (obj.Length != 2 || !(obj[0] is Mobile) || !(obj[1] is GumpPlus)) return; Mobile m = (Mobile)obj[0]; GumpPlus g = (GumpPlus)obj[1]; if (Data.GetData(m).Banned) { Data.GetData(m).RemoveBan(); g.Owner.SendMessage(Data.GetData(g.Owner).SystemC, General.Local(78) + " " + m.Name); g.NewGump(); } else new InternalGump(m, g); } private static void GIgnore(object o) { if (!(o is object[])) return; object[] obj = (object[])o; if (obj.Length != 3 || !(obj[0] is Data) || !(obj[1] is Mobile) || !(obj[2] is GumpPlus)) return; Data data = (Data)obj[0]; Mobile m = (Mobile)obj[1]; GumpPlus g = (GumpPlus)obj[2]; if (data.GIgnores.Contains(m)) data.RemoveGIgnore(m); else data.AddGIgnore(m); g.NewGump(); } private static void GListen(object o) { if (!(o is object[])) return; object[] obj = (object[])o; if (obj.Length != 3 || !(obj[0] is Data) || !(obj[1] is Mobile) || !(obj[2] is GumpPlus)) return; Data data = (Data)obj[0]; Mobile m = (Mobile)obj[1]; GumpPlus g = (GumpPlus)obj[2]; if (data.GListens.Contains(m)) data.RemoveGListen(m); else data.AddGListen(m); g.NewGump(); } private static void Client(object o) { if (!(o is object[])) return; object[] obj = (object[])o; if (obj.Length != 3 || !(obj[0] is Data) || !(obj[1] is Mobile) || !(obj[2] is GumpPlus)) return; Data data = (Data)obj[0]; Mobile m = (Mobile)obj[1]; GumpPlus g = (GumpPlus)obj[2]; g.NewGump(); if (m.NetState == null) data.Mobile.SendMessage(data.SystemC, m.Name + " " + General.Local(83)); else data.Mobile.SendGump(new ClientGump(data.Mobile, m.NetState)); } private static void Goto(object o) { if (!(o is object[])) return; object[] obj = (object[])o; if (obj.Length != 3 || !(obj[0] is Data) || !(obj[1] is Mobile) || !(obj[2] is GumpPlus)) return; Data data = (Data)obj[0]; Mobile m = (Mobile)obj[1]; GumpPlus g = (GumpPlus)obj[2]; if (m.NetState == null) data.Mobile.SendMessage(data.SystemC, m.Name + " " + General.Local(83)); else { data.Mobile.Location = m.Location; data.Mobile.Map = m.Map; } g.NewGump(); } private static void PlaySound(object o) { if (!(o is object[])) return; object[] obj = (object[])o; if (obj.Length != 3 || !(obj[0] is Data) || !(obj[1] is Mobile) || !(obj[2] is GumpPlus)) return; Data data = (Data)obj[0]; Mobile m = (Mobile)obj[1]; GumpPlus g = (GumpPlus)obj[2]; data.SetSound(m, Utility.ToInt32(g.GetTextField(0))); data.Mobile.SendSound(data.GetSound(m)); g.NewGump(); } private static void SoundUp(object o) { if (!(o is object[])) return; object[] obj = (object[])o; if (obj.Length != 3 || !(obj[0] is Data) || !(obj[1] is Mobile) || !(obj[2] is GumpPlus)) return; Data data = (Data)obj[0]; Mobile m = (Mobile)obj[1]; GumpPlus g = (GumpPlus)obj[2]; data.SetSound(m, data.GetSound(m) + 1); g.NewGump(); } private static void SoundDown(object o) { if (!(o is object[])) return; object[] obj = (object[])o; if (obj.Length != 3 || !(obj[0] is Data) || !(obj[1] is Mobile) || !(obj[2] is GumpPlus)) return; Data data = (Data)obj[0]; Mobile m = (Mobile)obj[1]; GumpPlus g = (GumpPlus)obj[2]; data.SetSound(m, data.GetSound(m) - 1); g.NewGump(); } private class InternalGump : GumpPlus { private GumpPlus c_Gump; private Mobile c_Target; public InternalGump(Mobile m, GumpPlus g) : base(g.Owner, 100, 100) { c_Gump = g; c_Target = m; NewGump(); } protected override void BuildGump() { int y = 10; AddHtml(0, y, 150, 21, HTML.White + "
" + General.Local(160), false, false); AddHtml(40, y += 20, 100, 21, HTML.White + General.Local(161), false, false); AddButton(25, y + 3, 0x2716, 0x2716, "30 minutes", new TimerStateCallback(BanTime), TimeSpan.FromMinutes(30)); AddHtml(40, y += 20, 100, 21, HTML.White + General.Local(162), false, false); AddButton(25, y + 3, 0x2716, 0x2716, "1 hour", new TimerStateCallback(BanTime), TimeSpan.FromHours(1)); AddHtml(40, y += 20, 100, 21, HTML.White + General.Local(163), false, false); AddButton(25, y + 3, 0x2716, 0x2716, "12 hours", new TimerStateCallback(BanTime), TimeSpan.FromHours(12)); AddHtml(40, y += 20, 100, 21, HTML.White + General.Local(164), false, false); AddButton(25, y + 3, 0x2716, 0x2716, "1 day", new TimerStateCallback(BanTime), TimeSpan.FromDays(1)); AddHtml(40, y += 20, 100, 21, HTML.White + General.Local(165), false, false); AddButton(25, y + 3, 0x2716, 0x2716, "1 week", new TimerStateCallback(BanTime), TimeSpan.FromDays(7)); AddHtml(40, y += 20, 100, 21, HTML.White + General.Local(166), false, false); AddButton(25, y + 3, 0x2716, 0x2716, "1 month", new TimerStateCallback(BanTime), TimeSpan.FromDays(30)); AddHtml(40, y += 20, 100, 21, HTML.White + General.Local(167), false, false); AddButton(25, y + 3, 0x2716, 0x2716, "1 year", new TimerStateCallback(BanTime), TimeSpan.FromDays(365)); Entries.Insert(0, new GumpBackground(0, 0, 150, y + 40, 0x1400)); } private void BanTime(object o) { if (!(o is TimeSpan)) return; Data.GetData(c_Target).Ban((TimeSpan)o); Owner.SendMessage(Data.GetData(Owner).SystemC, General.Local(77) + " " + c_Target.Name); c_Gump.NewGump(); } protected override void OnClose() { c_Gump.NewGump(); } } } }