110 lines
3.4 KiB
C#
110 lines
3.4 KiB
C#
using System;
|
|
using System.Collections;
|
|
using Server;
|
|
using Server.Gumps;
|
|
using Knives.Utils;
|
|
|
|
namespace Knives.Chat3
|
|
{
|
|
public class IRC : Channel
|
|
{
|
|
public static void Initialize()
|
|
{
|
|
new IRC();
|
|
}
|
|
|
|
public IRC() : base("IRC")
|
|
{
|
|
Commands.Add("irc");
|
|
Commands.Add("i");
|
|
DefaultC = 0x1FC;
|
|
|
|
Register(this);
|
|
}
|
|
|
|
public override string NameFor(Mobile m)
|
|
{
|
|
return Data.IrcRoom;
|
|
}
|
|
|
|
public override bool CanChat(Mobile m, bool say)
|
|
{
|
|
if (IrcConnection.Connection == null || !IrcConnection.Connection.Connected)
|
|
{
|
|
if (say) m.SendMessage(Data.GetData(m).SystemC, General.Local(158));
|
|
return false;
|
|
}
|
|
|
|
return base.CanChat(m, say);
|
|
}
|
|
|
|
public void Broadcast(string name, string msg)
|
|
{
|
|
foreach (Data data in Data.Datas.Values)
|
|
if (data.Channels.Contains(Name) && !data.IrcIgnores.Contains(name))
|
|
data.Mobile.SendMessage(data.ColorFor(this), msg);
|
|
}
|
|
|
|
protected override void Broadcast(Mobile m, string msg)
|
|
{
|
|
foreach (Data data in Data.Datas.Values)
|
|
if (data.Channels.Contains(Name) && !data.Ignores.Contains(m))
|
|
data.Mobile.SendMessage(m.AccessLevel == AccessLevel.Player ? data.ColorFor(this) : Data.GetData(m).StaffC, String.Format("<{0}> {1}: {2}", NameFor(m), m.Name, msg));
|
|
|
|
IrcConnection.Connection.SendUserMessage(m, msg);
|
|
}
|
|
|
|
public override void GumpOptions(GumpPlus g, int x, int y)
|
|
{
|
|
int oldY = y;
|
|
|
|
g.AddHtml(x, y + 10, 300, 21, HTML.White + "<CENTER>" + Name + " " + General.Local(40), false, false);
|
|
|
|
string txt = HTML.White + General.Local(42) + ":";
|
|
|
|
foreach (string str in Data.GetData(g.Owner).CurrentChannel.Commands)
|
|
txt += " " + str;
|
|
|
|
g.AddHtml(x + 30, y += 30, 170, 21, txt, false, false);
|
|
|
|
g.AddHtml(x + 130, y += 25, 120, 21, HTML.White + Name + " " + General.Local(49), false, false);
|
|
g.AddImage(x + 100, y, 0x2342, Data.GetData(g.Owner).ColorFor(this));
|
|
g.AddButton(x + 104, y + 4, 0x2716, 0x2716, "Channel Color", new TimerStateCallback(ChannelColor), g);
|
|
|
|
g.AddHtml(x + 130, y += 25, 120, 21, HTML.White + General.Local(159), false, false);
|
|
g.AddButton(x + 100, y, Data.GetData(g.Owner).IrcRaw ? 0x2343 : 0x2342, Data.GetData(g.Owner).IrcRaw ? 0x2343 : 0x2342, "IRC Raw", new TimerStateCallback(IrcRaw), g);
|
|
|
|
g.Entries.Insert(0, new GumpBackground(x, oldY, 300, y - oldY + 40, 0x1400));
|
|
}
|
|
|
|
public override ArrayList BuildList(Mobile m)
|
|
{
|
|
ArrayList list = base.BuildList(m);
|
|
|
|
foreach (string str in Data.IrcList)
|
|
list.Add(str);
|
|
|
|
return list;
|
|
}
|
|
|
|
private void ChannelColor(object o)
|
|
{
|
|
if (!(o is GumpPlus))
|
|
return;
|
|
|
|
((GumpPlus)o).Owner.SendHuePicker(new InternalPicker((GumpPlus)o, this));
|
|
}
|
|
|
|
private void IrcRaw(object o)
|
|
{
|
|
if (!(o is GumpPlus))
|
|
return;
|
|
|
|
GumpPlus g = (GumpPlus)o;
|
|
|
|
Data.GetData(g.Owner).IrcRaw = !Data.GetData(g.Owner).IrcRaw;
|
|
|
|
g.NewGump();
|
|
}
|
|
}
|
|
} |