using System; using System.Collections; using Server; using Server.Gumps; using Knives.Utils; namespace Knives.Chat3 { public enum SetupPage { Publics, Misc, FilterSpam, IRC } public class SetupGump : GumpPlus { public static void SendTo(Mobile m) { General.ClearGump(m, typeof(SetupGump)); new SetupGump(m); } #region Class Definitions private SetupPage c_Page; private int c_Width, c_Height; private Channel c_Channel; public Data GetData { get { return Data.GetData(Owner); } } protected Channel Channel { get { return c_Channel; } set { c_Channel = value; } } #endregion #region Constructors public SetupGump(Mobile m) : base(m, 200, 200) { c_Width = c_Height = 300; NewGump(); } #endregion #region Methods protected override void BuildGump() { Owner.CloseGump(typeof(SetupGump)); AddBackground(0, 0, c_Width, c_Height, 0x1400); AddButton(c_Width / 5 - 5, c_Height - 40, c_Page == SetupPage.Publics ? 0x767 : 0x768, c_Page == SetupPage.Publics ? 0x767 : 0x768, "Messages", new TimerStateCallback(Page), SetupPage.Publics); AddButton(c_Width / 5 * 2 - 5, c_Height - 40, c_Page == SetupPage.Misc ? 0x767 : 0x768, c_Page == SetupPage.Misc ? 0x767 : 0x768, "Messages", new TimerStateCallback(Page), SetupPage.Misc); AddButton(c_Width / 5 * 3 - 5, c_Height - 40, c_Page == SetupPage.FilterSpam ? 0x767 : 0x768, c_Page == SetupPage.FilterSpam ? 0x767 : 0x768, "Filter and Spam", new TimerStateCallback(Page), SetupPage.FilterSpam); AddButton(c_Width/5*4-5, c_Height - 40, c_Page == SetupPage.IRC ? 0x767 : 0x768, c_Page == SetupPage.IRC ? 0x767 : 0x768, "IRC", new TimerStateCallback(Page), SetupPage.IRC); AddImage(13, 6, 0x476); switch (c_Page) { case SetupPage.Publics: PublicsTab(); break; case SetupPage.Misc: MiscTab(); break; case SetupPage.FilterSpam: FilterSpamTab(); break; case SetupPage.IRC: IRCTab(); break; } AddButton(c_Width - 20, c_Height - 20, 0xFC1, 0xFC1, "About", new TimerCallback(About)); } private void PublicsTab() { int y = 10; AddHtml(0, y, c_Width, 21, HTML.White + "
" + General.Local(177), false, false); AddImage(77, (y += 25) - 1, 0x9C5); AddHtml(100, y, 100, 21, "
" + HTML.White + (c_Channel == null ? "" : c_Channel.Name), false, false); AddButton(85, y+3, 0x2716, 0x2716, "Channel Select", new TimerCallback(ChannelSelect)); if( c_Channel != null ) AddButton(200, y+1, 0x5686, 0x5687, "Delete Channel", new TimerCallback(DeleteChannel)); if (c_Channel == null) { AddHtml(0, y+=25, c_Width, 21, HTML.White + "
" + General.Local(179), false, false); return; } AddHtml(77, y+=25, 100, 21, HTML.White + General.Local(180), false, false); AddImageTiled(162, y, 70, 21, 0xBBA); AddTextField(162, y, 70, 21, 0x480, 10, "" + c_Channel.Name); AddButton(142, y + 3, 0x2716, 0x2716, "Submit Channel", new TimerCallback(SubmitChannel)); AddHtml(40, y += 25, 80, 21, HTML.White + General.Local(181) + ":", false, false); AddHtml(120, y, 80, 21, HTML.White + General.Local(182), false, false); AddHtml(200, y, 80, 21, HTML.White + General.Local(183), false, false); AddButton(100, y + 3, c_Channel.Style == ChatStyle.Global ? 0x939 : 0x2716, c_Channel.Style == ChatStyle.Global ? 0x939 : 0x2716, "Global", new TimerCallback(Global)); AddButton(180, y + 3, c_Channel.Style == ChatStyle.Regional ? 0x939 : 0x2716, c_Channel.Style == ChatStyle.Regional ? 0x939 : 0x2716, "Regional", new TimerCallback(Regional)); AddHtml(110, y += 25, 120, 21, HTML.White + General.Local(184), false, false); AddButton(80, y, c_Channel.ToIrc ? 0x2343 : 0x2342, c_Channel.ToIrc ? 0x2343 : 0x2342, "Send to IRC", new TimerCallback(SendToIrc)); AddHtml(110, y += 25, 120, 21, HTML.White + General.Local(188), false, false); AddButton(80, y, c_Channel.NewChars ? 0x2343 : 0x2342, c_Channel.NewChars ? 0x2343 : 0x2342, "Auto join new characters", new TimerCallback(AutoNewChars)); AddHtml(27, y += 25, 150, 21, HTML.White + General.Local(185), false, false); AddImageTiled(182, y, 70, 21, 0xBBA); AddTextField(182, y, 70, 21, 0x480, 11, ""); AddButton(162, y + 4, 0x2716, 0x2716, "Add/Remove Command", new TimerCallback(AddCommand)); string txt = General.Local(42) + ": "; foreach (string str in c_Channel.Commands) txt += str + " "; AddHtml(20, y += 25, 260, 60, HTML.White + txt, false, false); } private void MiscTab() { int y = 10; AddHtml(0, y, c_Width, 21, HTML.White + "
" + General.Local(101), false, false); AddHtml(70, y += 25, 250, 21, HTML.White + General.Local(152), false, false); AddButton(40, y, Data.ShowStaff ? 0x2343 : 0x2342, Data.ShowStaff ? 0x2343 : 0x2342, "Show Staff", new TimerCallback(ShowStaff)); AddHtml(37, y += 25, 150, 21, HTML.White + General.Local(153), false, false); AddImageTiled(172, y, 70, 21, 0xBBA); AddTextField(172, y, 70, 21, 0x480, 9, "" + Data.MaxMsgs); AddButton(152, y + 4, 0x2716, 0x2716, "MaxMsgs", new TimerCallback(MaxMsgs)); AddHtml(70, y += 25, 250, 21, HTML.White + General.Local(169), false, false); AddButton(45, y+3, 0x2716, 0x2716, "Reload Local", new TimerCallback(ReloadLocal)); } private void FilterSpamTab() { int y = 10; AddHtml(0, y, c_Width, 21, HTML.White + "
" + General.Local(99), false, false); AddHtml(70, y += 25, 250, 21, HTML.White + General.Local(142), false, false); AddButton(40, y, Data.FilterSpeech ? 0x2343 : 0x2342, Data.FilterSpeech ? 0x2343 : 0x2342, "Filter Speech", new TimerCallback(FilterSpeech)); AddHtml(70, y += 25, 250, 21, HTML.White + General.Local(143), false, false); AddButton(40, y, Data.FilterMsg ? 0x2343 : 0x2342, Data.FilterMsg ? 0x2343 : 0x2342, "Filter Messages", new TimerCallback(FilterMsg)); AddHtml(17, y += 25, 100, 21, HTML.White + General.Local(144), false, false); AddHtml(142, y, 100, 21, HTML.White + "s", false, false); AddImageTiled(107, y, 30, 21, 0xBBA); AddTextField(107, y, 30, 21, 0x480, 4, "" + Data.ChatSpam); AddHtml(162, y, 100, 21, HTML.White + General.Local(145), false, false); AddHtml(277, y, 100, 21, HTML.White + "s", false, false); AddImageTiled(242, y, 30, 21, 0xBBA); AddTextField(242, y, 30, 21, 0x480, 5, "" + Data.MsgSpam); AddHtml(17, y += 25, 100, 21, HTML.White + General.Local(146), false, false); AddHtml(142, y, 100, 21, HTML.White + "h", false, false); AddImageTiled(107, y, 30, 21, 0xBBA); AddTextField(107, y, 30, 21, 0x480, 6, "" + Data.RequestSpam); AddHtml(162, y, 100, 21, HTML.White + General.Local(147), false, false); AddHtml(277, y, 100, 21, HTML.White + "m", false, false); AddImageTiled(242, y, 30, 21, 0xBBA); AddTextField(242, y, 30, 21, 0x480, 7, "" + Data.FilterBanLength); AddButton(148, y - 9, 0x2716, 0x2716, "SubmitFilterSpam", new TimerCallback(SubmitFilterSpam)); AddHtml(90, y += 25, 150, 21, HTML.White + General.Local(154) + ": " + General.Local(155 + (int)Data.FilterPenalty), false, false); AddButton(70, y + 4, 0x2716, 0x2716, "Filter Penalty", new TimerCallback(FilterPenalty)); AddHtml(37, y+=25, 150, 21, HTML.White + General.Local(148), false, false); AddImageTiled(172, y, 70, 21, 0xBBA); AddTextField(172, y, 70, 21, 0x480, 8, ""); AddButton(152, y + 4, 0x2716, 0x2716, "Add/Remove Filter", new TimerCallback(AddFilter)); string txt = General.Local(151) + " "; foreach (string filter in Data.Filters) txt += filter + " "; AddHtml(20, y += 25, 260, 60, HTML.White + txt, false, false); } private void IRCTab() { int y = 10; AddHtml(0, y, c_Width, 21, HTML.White + "
" + General.Local(100), false, false); AddHtml(120, y += 25, 100, 21, HTML.White + General.Local(98), false, false); AddButton(90, y, Data.IrcEnabled ? 0x2343 : 0x2342, Data.IrcEnabled ? 0x2343 : 0x2342, "IRC Enabled", new TimerCallback(IrcEnabled)); if (!Data.IrcEnabled) return; AddHtml(60, y += 25, 100, 21, HTML.White + General.Local(115), false, false); AddButton(30, y, Data.IrcAutoConnect ? 0x2343 : 0x2342, Data.IrcAutoConnect ? 0x2343 : 0x2342, "IRC Auto Connect", new TimerCallback(IrcAutoConnect)); AddHtml(180, y, 100, 21, HTML.White + General.Local(116), false, false); AddButton(150, y, Data.IrcAutoReconnect ? 0x2343 : 0x2342, Data.IrcAutoReconnect ? 0x2343 : 0x2342, "IRC Auto Reconnect", new TimerCallback(IrcAutoReconnect)); AddHtml(60, y += 25, 100, 21, HTML.White + General.Local(117), false, false); AddImageTiled(130, y, 100, 21, 0xBBA); AddTextField(130, y, 100, 21, 0x480, 0, Data.IrcNick); AddButton(235, y + 4, 0x2716, 0x2716, "Submit", new TimerCallback(Submit)); AddHtml(60, y += 25, 100, 21, HTML.White + General.Local(118), false, false); AddImageTiled(130, y, 100, 21, 0xBBA); AddTextField(130, y, 100, 21, 0x480, 1, Data.IrcServer); AddButton(235, y + 4, 0x2716, 0x2716, "Submit", new TimerCallback(Submit)); AddHtml(60, y += 25, 100, 21, HTML.White + General.Local(119), false, false); AddImageTiled(130, y, 100, 21, 0xBBA); AddTextField(130, y, 100, 21, 0x480, 2, Data.IrcRoom); AddButton(235, y + 4, 0x2716, 0x2716, "Submit", new TimerCallback(Submit)); AddHtml(60, y += 25, 100, 21, HTML.White + General.Local(120), false, false); AddImageTiled(130, y, 70, 21, 0xBBA); AddTextField(130, y, 70, 21, 0x480, 3, "" + Data.IrcPort); AddButton(235, y + 4, 0x2716, 0x2716, "Submit", new TimerCallback(Submit)); AddHtml(60, y += 25, 150, 21, HTML.White + General.Local(138) + ": " + General.Local(121 + (int)Data.IrcStaffColor), false, false); AddButton(40, y + 4, 0x2716, 0x2716, "Irc Staff Color", new TimerCallback(IrcStaffColor)); int num = 139; if (IrcConnection.Connection.Connected) num = 141; if (IrcConnection.Connection.Connecting) num = 140; AddHtml(110, y += 40, 150, 21, HTML.White + General.Local(num), false, false); AddButton(90, y + 4, 0x2716, 0x2716, "Connect or Cancel or Close", new TimerCallback(ConnectCancelClose)); } #endregion #region Responses private void Page(object o) { if (!(o is SetupPage)) return; c_Page = (SetupPage)o; NewGump(); } private void ChannelSelect() { new ChannelSelectGump(this); } private void DeleteChannel() { if (c_Channel != null) { foreach (string str in c_Channel.Commands) Channel.RemoveCommand(str); Channel.Channels.Remove(c_Channel); } c_Channel = null; NewGump(); return; } private void AutoNewChars() { if (c_Channel != null) { c_Channel.NewChars = !c_Channel.NewChars; if (c_Channel.NewChars) foreach (Data data in Data.Datas.Values) data.Channels.Add(c_Channel.Name); return; } NewGump(); } private void SubmitChannel() { if( GetTextField(10) != "" ) c_Channel.Name = GetTextField(10); NewGump(); } private void AddCommand() { if (GetTextField(11) == "") { NewGump(); return; } if (c_Channel.Commands.Contains(GetTextField(11).ToLower())) { c_Channel.Commands.Remove(GetTextField(11).ToLower()); Channel.RemoveCommand(GetTextField(11).ToLower()); } else { c_Channel.Commands.Add(GetTextField(11).ToLower()); Channel.AddCommand(GetTextField(11).ToLower()); } NewGump(); } private void Global() { c_Channel.Style = ChatStyle.Global; NewGump(); } private void Regional() { c_Channel.Style = ChatStyle.Regional; NewGump(); } private void SendToIrc() { SubmitChannel(); c_Channel.ToIrc = !c_Channel.ToIrc; NewGump(); } private void ShowStaff() { Data.ShowStaff = !Data.ShowStaff; NewGump(); } private void MaxMsgs() { Data.MaxMsgs = Utility.ToInt32(GetTextField(9)); NewGump(); } private void ReloadLocal() { General.LoadLocalFile(); Owner.SendMessage(GetData.SystemC, General.Local(168)); NewGump(); } private void FilterSpeech() { Data.FilterSpeech = !Data.FilterSpeech; NewGump(); } private void FilterMsg() { Data.FilterMsg = !Data.FilterMsg; NewGump(); } private void SubmitFilterSpam() { Data.ChatSpam = Utility.ToInt32(GetTextField(4)); Data.MsgSpam = Utility.ToInt32(GetTextField(5)); Data.RequestSpam = Utility.ToInt32(GetTextField(6)); Data.FilterBanLength = Utility.ToInt32(GetTextField(7)); NewGump(); } private void AddFilter() { if (GetTextField(8).Trim() == "") { NewGump(); return; } if (Data.Filters.Contains(GetTextField(8).ToLower())) { Data.Filters.Remove(GetTextField(8).ToLower()); Owner.SendMessage(GetData.SystemC, General.Local(149) + " " + GetTextField(8).ToLower()); } else { Data.Filters.Add(GetTextField(8).ToLower()); Owner.SendMessage(GetData.SystemC, General.Local(150) + " " + GetTextField(8).ToLower()); } NewGump(); } private void FilterPenalty() { new FilterPenaltyGump(Owner, this); } private void IrcEnabled() { Data.IrcEnabled = !Data.IrcEnabled; NewGump(); } private void IrcAutoConnect() { Data.IrcAutoConnect = !Data.IrcAutoConnect; NewGump(); } private void IrcAutoReconnect() { Data.IrcAutoReconnect = !Data.IrcAutoReconnect; NewGump(); } private void Submit() { Data.IrcNick = GetTextField(0); Data.IrcServer = GetTextField(1); Data.IrcRoom = GetTextField(2); Data.IrcPort = Utility.ToInt32(GetTextField(3)); NewGump(); } private void IrcStaffColor() { new IrcStaffColorGump(Owner, this); } private void ConnectCancelClose() { Data.IrcNick = GetTextField(0); Data.IrcServer = GetTextField(1); Data.IrcRoom = GetTextField(2); Data.IrcPort = Utility.ToInt32(GetTextField(3)); if (IrcConnection.Connection.Connected) IrcConnection.Connection.Disconnect(false); else if (IrcConnection.Connection.Connecting) IrcConnection.Connection.CancelConnect(); else if (!IrcConnection.Connection.Connected) IrcConnection.Connection.Connect(Owner); NewGump(); } private void About() { NewGump(); new AboutGump(Owner); } #endregion #region Internal Classes private class ChannelSelectGump : GumpPlus { private SetupGump c_Gump; public ChannelSelectGump(SetupGump g) : base(g.Owner, 100, 100) { c_Gump = g; NewGump(); } protected override void BuildGump() { int y = 10; AddHtml(0, y, 150, 21, HTML.White + "
" + General.Local(38), false, false); foreach (Channel c in Channel.Channels) { if (c.Mod) { AddHtml(50, y += 20, 100, 21, HTML.White + c.NameFor(Owner), false, false); AddButton(30, y + 3, 0x2716, 0x2716, "Select Channel", new TimerStateCallback(SelectChannel), c); } } AddHtml(50, y += 30, 100, 21, HTML.White + General.Local(178), false, false); AddButton(30, y + 3, 0x2716, 0x2716, "New Channel", new TimerCallback(NewChannel)); Entries.Insert(0, new GumpBackground(0, 0, 150, y + 40, 0x1400)); } private void NewChannel() { Channel c = new Channel("New"); c.Mod = true; c_Gump.Channel = c; c_Gump.NewGump(); } private void SelectChannel(object o) { if (!(o is Channel)) return; c_Gump.Channel = (Channel)o; c_Gump.NewGump(); } protected override void OnClose() { c_Gump.NewGump(); } } private class IrcStaffColorGump : GumpPlus { private GumpPlus c_Gump; public IrcStaffColorGump(Mobile m, GumpPlus g) : base(m, 100, 100) { c_Gump = g; NewGump(); } protected override void BuildGump() { int y = 10; AddHtml(0, y, 150, 21, HTML.White + "
" + General.Local(137), false, false); y += 5; for (int i = 0; i < 16; ++i) { AddHtml(60, y += 20, 90, 21, HTML.White + General.Local(121 + i), false, false); AddButton(40, y + 4, 0x2716, 0x2716, "Select", new TimerStateCallback(Select), i); } Entries.Insert(0, new GumpBackground(0, 0, 150, y + 40, 0x1400)); } protected override void OnClose() { c_Gump.NewGump(); } private void Select(object o) { if (!(o is int)) return; Data.IrcStaffColor = (IrcColor)(int)o; c_Gump.NewGump(); } } private class FilterPenaltyGump : GumpPlus { private GumpPlus c_Gump; public FilterPenaltyGump(Mobile m, GumpPlus g) : base(m, 100, 100) { c_Gump = g; NewGump(); } protected override void BuildGump() { int y = 10; AddHtml(0, y, 150, 21, HTML.White + "
" + General.Local(154), false, false); y += 5; for (int i = 0; i < 3; ++i) { AddHtml(60, y += 20, 90, 21, HTML.White + General.Local(155 + i), false, false); AddButton(40, y + 4, 0x2716, 0x2716, "Select", new TimerStateCallback(Select), i); } Entries.Insert(0, new GumpBackground(0, 0, 150, y + 40, 0x1400)); } protected override void OnClose() { c_Gump.NewGump(); } private void Select(object o) { if (!(o is int)) return; Data.FilterPenalty = (FilterPenalty)(int)o; c_Gump.NewGump(); } } private class AboutGump : GumpPlus { public AboutGump(Mobile m) : base(m, 100, 100) { NewGump(); } protected override void BuildGump() { AddBackground(0, 0, 200, 100, 0x1400); string txt = HTML.White + "
Knives' Chat
" + General.Version + "
Release Date: " + General.ReleaseDate.Month + "/" + General.ReleaseDate.Day + "/" + General.ReleaseDate.Year + "
Contact: kmwill23@hotmail.com"; AddHtml(0, 10, 200, 81, txt , false, false); } } #endregion } }