servuo/Scripts/Services/Quests/QuestSystem.cs

702 lines
21 KiB
C#
Raw Permalink Normal View History

2016-04-04 13:03:36 -05:00
using Server.ContextMenus;
using Server.Gumps;
using Server.Items;
using Server.Mobiles;
using Server.Network;
2020-04-14 14:04:34 -04:00
using System;
using System.Collections;
using System.Collections.Generic;
2016-04-04 13:03:36 -05:00
namespace Server.Engines.Quests
{
public delegate void QuestCallback();
public abstract class QuestSystem
{
public static void Configure()
{
EventSink.OnKilledBy += OnKilledBy;
EventSink.Login += OnLogin;
}
2016-04-04 13:03:36 -05:00
private PlayerMobile m_From;
private ArrayList m_Objectives;
private ArrayList m_Conversations;
2016-04-04 13:03:36 -05:00
public QuestSystem(PlayerMobile from)
{
2020-04-16 21:29:55 -04:00
m_From = from;
m_Objectives = new ArrayList();
m_Conversations = new ArrayList();
2016-04-04 13:03:36 -05:00
}
public QuestSystem()
{
}
public abstract object Name { get; }
public abstract object OfferMessage { get; }
public abstract int Picture { get; }
public abstract bool IsTutorial { get; }
public abstract TimeSpan RestartDelay { get; }
2016-04-04 13:03:36 -05:00
public PlayerMobile From
{
get
{
2020-04-16 21:29:55 -04:00
return m_From;
2016-04-04 13:03:36 -05:00
}
set
{
2020-04-16 21:29:55 -04:00
m_From = value;
2016-04-04 13:03:36 -05:00
}
}
public ArrayList Objectives
{
get
{
2020-04-16 21:29:55 -04:00
return m_Objectives;
2016-04-04 13:03:36 -05:00
}
set
{
2020-04-16 21:29:55 -04:00
m_Objectives = value;
2016-04-04 13:03:36 -05:00
}
}
public ArrayList Conversations
{
get
{
2020-04-16 21:29:55 -04:00
return m_Conversations;
2016-04-04 13:03:36 -05:00
}
set
{
2020-04-16 21:29:55 -04:00
m_Conversations = value;
2016-04-04 13:03:36 -05:00
}
}
private static readonly string _TimerID = "QuestTimer";
2016-04-04 13:03:36 -05:00
public static bool CanOfferQuest(Mobile check, Type questType)
{
bool inRestartPeriod;
return CanOfferQuest(check, questType, out inRestartPeriod);
}
public static bool CanOfferQuest(Mobile check, Type questType, out bool inRestartPeriod)
{
inRestartPeriod = false;
PlayerMobile pm = check as PlayerMobile;
if (pm == null)
return false;
if (pm.HasGump(typeof(QuestOfferGump)))
return false;
List<QuestRestartInfo> doneQuests = pm.DoneQuests;
if (doneQuests != null)
{
for (int i = 0; i < doneQuests.Count; ++i)
{
QuestRestartInfo restartInfo = doneQuests[i];
if (restartInfo.QuestType == questType)
{
DateTime endTime = restartInfo.RestartTime;
if (DateTime.UtcNow < endTime)
{
inRestartPeriod = true;
return false;
}
doneQuests.RemoveAt(i--);
return true;
}
}
}
return true;
}
public static void FocusTo(Mobile who, Mobile to)
{
if (Utility.RandomBool())
{
who.Animate(17, 7, 1, true, false, 0);
}
else
{
2020-04-14 14:04:34 -04:00
switch (Utility.Random(3))
2016-04-04 13:03:36 -05:00
{
case 0:
who.Animate(32, 7, 1, true, false, 0);
break;
case 1:
who.Animate(33, 7, 1, true, false, 0);
break;
case 2:
who.Animate(34, 7, 1, true, false, 0);
break;
}
}
who.Direction = who.GetDirectionTo(to);
}
public static int RandomBrightHue()
{
if (0.1 > Utility.RandomDouble())
return Utility.RandomList(0x62, 0x71);
return Utility.RandomList(0x03, 0x0D, 0x13, 0x1C, 0x21, 0x30, 0x37, 0x3A, 0x44, 0x59);
}
public virtual void StartTimer()
{
TimerRegistry.Register<QuestSystem>(_TimerID, this, TimeSpan.FromSeconds(0.5), TimeSpan.FromSeconds(0.5), false, q => q.Slice());
2016-04-04 13:03:36 -05:00
}
public virtual void StopTimer()
{
TimerRegistry.RemoveFromRegistry<QuestSystem>(_TimerID, this);
2016-04-04 13:03:36 -05:00
}
public virtual void Slice()
{
2020-04-16 21:29:55 -04:00
for (int i = m_Objectives.Count - 1; i >= 0; --i)
2016-04-04 13:03:36 -05:00
{
2020-04-16 21:29:55 -04:00
QuestObjective obj = (QuestObjective)m_Objectives[i];
2016-04-04 13:03:36 -05:00
if (obj.GetTimerEvent())
obj.CheckProgress();
}
}
public static void OnKilledBy(OnKilledByEventArgs e)
{
if (e.KilledBy is PlayerMobile pm && e.Killed is BaseCreature bc)
{
QuestSystem qs = pm.Quest;
if (qs != null)
{
qs.OnKill(bc, bc.Corpse);
}
}
}
public static void OnLogin(LoginEventArgs e)
{
if (e.Mobile is PlayerMobile pm)
{
if (pm.Quest != null)
{
Timer.DelayCall(TimeSpan.FromSeconds(2), () =>
{
pm.Quest.ShowQuestLog();
});
}
}
}
2016-04-04 13:03:36 -05:00
public virtual void OnKill(BaseCreature creature, Container corpse)
{
2020-04-16 21:29:55 -04:00
for (int i = m_Objectives.Count - 1; i >= 0; --i)
2016-04-04 13:03:36 -05:00
{
2020-04-16 21:29:55 -04:00
QuestObjective obj = (QuestObjective)m_Objectives[i];
2016-04-04 13:03:36 -05:00
if (obj.GetKillEvent(creature, corpse))
obj.OnKill(creature, corpse);
}
}
public virtual bool IgnoreYoungProtection(Mobile from)
{
2020-04-16 21:29:55 -04:00
for (int i = m_Objectives.Count - 1; i >= 0; --i)
2016-04-04 13:03:36 -05:00
{
2020-04-16 21:29:55 -04:00
QuestObjective obj = (QuestObjective)m_Objectives[i];
2016-04-04 13:03:36 -05:00
if (obj.IgnoreYoungProtection(from))
return true;
}
return false;
}
public virtual void BaseDeserialize(GenericReader reader)
{
int version = reader.ReadEncodedInt();
2020-04-14 14:04:34 -04:00
switch (version)
2016-04-04 13:03:36 -05:00
{
case 0:
{
int count = reader.ReadEncodedInt();
2020-04-16 21:29:55 -04:00
m_Objectives = new ArrayList(count);
2016-04-04 13:03:36 -05:00
for (int i = 0; i < count; ++i)
{
QuestObjective obj = QuestSerializer.DeserializeObjective(this, reader);
2016-04-04 13:03:36 -05:00
if (obj != null)
{
obj.System = this;
2020-04-16 21:29:55 -04:00
m_Objectives.Add(obj);
2016-04-04 13:03:36 -05:00
}
}
count = reader.ReadEncodedInt();
2020-04-16 21:29:55 -04:00
m_Conversations = new ArrayList(count);
2016-04-04 13:03:36 -05:00
for (int i = 0; i < count; ++i)
{
QuestConversation conv = QuestSerializer.DeserializeConversation(this, reader);
2016-04-04 13:03:36 -05:00
if (conv != null)
{
conv.System = this;
2020-04-16 21:29:55 -04:00
m_Conversations.Add(conv);
2016-04-04 13:03:36 -05:00
}
}
break;
}
}
2020-04-16 21:29:55 -04:00
ChildDeserialize(reader);
2016-04-04 13:03:36 -05:00
}
public virtual void ChildDeserialize(GenericReader reader)
{
int version = reader.ReadEncodedInt();
}
public virtual void BaseSerialize(GenericWriter writer)
{
writer.WriteEncodedInt(0); // version
2016-04-04 13:03:36 -05:00
writer.WriteEncodedInt(m_Objectives.Count);
2016-04-04 13:03:36 -05:00
2020-04-16 21:29:55 -04:00
for (int i = 0; i < m_Objectives.Count; ++i)
QuestSerializer.Serialize(this, (QuestObjective)m_Objectives[i], writer);
2016-04-04 13:03:36 -05:00
writer.WriteEncodedInt(m_Conversations.Count);
2016-04-04 13:03:36 -05:00
2020-04-16 21:29:55 -04:00
for (int i = 0; i < m_Conversations.Count; ++i)
QuestSerializer.Serialize(this, (QuestConversation)m_Conversations[i], writer);
2016-04-04 13:03:36 -05:00
2020-04-16 21:29:55 -04:00
ChildSerialize(writer);
2016-04-04 13:03:36 -05:00
}
public virtual void ChildSerialize(GenericWriter writer)
{
writer.WriteEncodedInt(0); // version
2016-04-04 13:03:36 -05:00
}
public bool IsObjectiveInProgress(Type type)
{
2020-04-16 21:29:55 -04:00
QuestObjective obj = FindObjective(type);
2016-04-04 13:03:36 -05:00
return (obj != null && !obj.Completed);
}
public QuestObjective FindObjective(Type type)
{
2020-04-16 21:29:55 -04:00
for (int i = m_Objectives.Count - 1; i >= 0; --i)
2016-04-04 13:03:36 -05:00
{
2020-04-16 21:29:55 -04:00
QuestObjective obj = (QuestObjective)m_Objectives[i];
2016-04-04 13:03:36 -05:00
if (obj.GetType() == type)
return obj;
}
return null;
}
public virtual void SendOffer()
{
2020-04-16 21:29:55 -04:00
m_From.SendGump(new QuestOfferGump(this));
2016-04-04 13:03:36 -05:00
}
public virtual void GetContextMenuEntries(List<ContextMenuEntry> list)
{
2020-04-16 21:29:55 -04:00
if (m_Objectives.Count > 0)
list.Add(new QuestCallbackEntry(6154, ShowQuestLog)); // View Quest Log
2016-04-04 13:03:36 -05:00
2020-04-16 21:29:55 -04:00
if (m_Conversations.Count > 0)
list.Add(new QuestCallbackEntry(6156, ShowQuestConversation)); // Quest Conversation
2016-04-04 13:03:36 -05:00
list.Add(new QuestCallbackEntry(6155, BeginCancelQuest)); // Cancel Quest
2016-04-04 13:03:36 -05:00
}
public virtual void ShowQuestLogUpdated()
{
2020-04-16 21:29:55 -04:00
m_From.CloseGump(typeof(QuestLogUpdatedGump));
m_From.SendGump(new QuestLogUpdatedGump(this));
2016-04-04 13:03:36 -05:00
}
public virtual void ShowQuestLog()
{
2020-04-16 21:29:55 -04:00
if (m_Objectives.Count > 0)
2016-04-04 13:03:36 -05:00
{
2020-04-16 21:29:55 -04:00
m_From.CloseGump(typeof(QuestItemInfoGump));
m_From.CloseGump(typeof(QuestLogUpdatedGump));
m_From.CloseGump(typeof(QuestObjectivesGump));
m_From.CloseGump(typeof(QuestConversationsGump));
2016-04-04 13:03:36 -05:00
2020-04-16 21:29:55 -04:00
m_From.SendGump(new QuestObjectivesGump(m_Objectives));
2016-04-04 13:03:36 -05:00
2020-04-16 21:29:55 -04:00
QuestObjective last = (QuestObjective)m_Objectives[m_Objectives.Count - 1];
2016-04-04 13:03:36 -05:00
if (last.Info != null)
2020-04-16 21:29:55 -04:00
m_From.SendGump(new QuestItemInfoGump(last.Info));
2016-04-04 13:03:36 -05:00
}
}
public virtual void ShowQuestConversation()
{
2020-04-16 21:29:55 -04:00
if (m_Conversations.Count > 0)
2016-04-04 13:03:36 -05:00
{
2020-04-16 21:29:55 -04:00
m_From.CloseGump(typeof(QuestItemInfoGump));
m_From.CloseGump(typeof(QuestObjectivesGump));
m_From.CloseGump(typeof(QuestConversationsGump));
2016-04-04 13:03:36 -05:00
2020-04-16 21:29:55 -04:00
m_From.SendGump(new QuestConversationsGump(m_Conversations));
2016-04-04 13:03:36 -05:00
2020-04-16 21:29:55 -04:00
QuestConversation last = (QuestConversation)m_Conversations[m_Conversations.Count - 1];
2016-04-04 13:03:36 -05:00
if (last.Info != null)
2020-04-16 21:29:55 -04:00
m_From.SendGump(new QuestItemInfoGump(last.Info));
2016-04-04 13:03:36 -05:00
}
}
public virtual void BeginCancelQuest()
{
2020-04-16 21:29:55 -04:00
m_From.SendGump(new QuestCancelGump(this));
2016-04-04 13:03:36 -05:00
}
public virtual void EndCancelQuest(bool shouldCancel)
{
2020-04-16 21:29:55 -04:00
if (m_From.Quest != this)
2016-04-04 13:03:36 -05:00
return;
if (shouldCancel)
{
2020-04-16 21:29:55 -04:00
m_From.SendLocalizedMessage(1049015); // You have canceled your quest.
Cancel();
2016-04-04 13:03:36 -05:00
}
else
{
2020-04-16 21:29:55 -04:00
m_From.SendLocalizedMessage(1049014); // You have chosen not to cancel your quest.
2016-04-04 13:03:36 -05:00
}
}
public virtual void Cancel()
{
2020-04-16 21:29:55 -04:00
ClearQuest(false);
2016-04-04 13:03:36 -05:00
}
public virtual void Complete()
{
EventSink.InvokeQuestComplete(new QuestCompleteEventArgs(From, GetType()));
2020-04-16 21:29:55 -04:00
ClearQuest(true);
2016-04-04 13:03:36 -05:00
}
public virtual void ClearQuest(bool completed)
{
2020-04-16 21:29:55 -04:00
StopTimer();
2016-04-04 13:03:36 -05:00
2020-04-16 21:29:55 -04:00
if (m_From.Quest == this)
2016-04-04 13:03:36 -05:00
{
2020-04-16 21:29:55 -04:00
m_From.Quest = null;
2016-04-04 13:03:36 -05:00
2020-04-16 21:29:55 -04:00
TimeSpan restartDelay = RestartDelay;
2016-04-04 13:03:36 -05:00
if ((completed && restartDelay > TimeSpan.Zero) || (!completed && restartDelay == TimeSpan.MaxValue))
{
2020-04-16 21:29:55 -04:00
List<QuestRestartInfo> doneQuests = m_From.DoneQuests;
2016-04-04 13:03:36 -05:00
if (doneQuests == null)
2020-04-16 21:29:55 -04:00
m_From.DoneQuests = doneQuests = new List<QuestRestartInfo>();
2016-04-04 13:03:36 -05:00
bool found = false;
2020-04-16 21:29:55 -04:00
Type ourQuestType = GetType();
2016-04-04 13:03:36 -05:00
for (int i = 0; i < doneQuests.Count; ++i)
{
QuestRestartInfo restartInfo = doneQuests[i];
if (restartInfo.QuestType == ourQuestType)
{
restartInfo.Reset(restartDelay);
found = true;
break;
}
}
if (!found)
doneQuests.Add(new QuestRestartInfo(ourQuestType, restartDelay));
}
}
}
public virtual void AddConversation(QuestConversation conv)
{
conv.System = this;
if (conv.Logged)
2020-04-16 21:29:55 -04:00
m_Conversations.Add(conv);
2016-04-04 13:03:36 -05:00
2020-04-16 21:29:55 -04:00
m_From.CloseGump(typeof(QuestItemInfoGump));
m_From.CloseGump(typeof(QuestObjectivesGump));
m_From.CloseGump(typeof(QuestConversationsGump));
2016-04-04 13:03:36 -05:00
if (conv.Logged)
2020-04-16 21:29:55 -04:00
m_From.SendGump(new QuestConversationsGump(m_Conversations));
2016-04-04 13:03:36 -05:00
else
2020-04-16 21:29:55 -04:00
m_From.SendGump(new QuestConversationsGump(conv));
2016-04-04 13:03:36 -05:00
if (conv.Info != null)
2020-04-16 21:29:55 -04:00
m_From.SendGump(new QuestItemInfoGump(conv.Info));
2016-04-04 13:03:36 -05:00
}
public virtual void AddObjective(QuestObjective obj)
{
obj.System = this;
2020-04-16 21:29:55 -04:00
m_Objectives.Add(obj);
2016-04-04 13:03:36 -05:00
2020-04-16 21:29:55 -04:00
ShowQuestLogUpdated();
2016-04-04 13:03:36 -05:00
}
public virtual void Accept()
{
2020-04-16 21:29:55 -04:00
if (m_From.Quest != null)
2016-04-04 13:03:36 -05:00
return;
2020-04-16 21:29:55 -04:00
m_From.Quest = this;
m_From.SendLocalizedMessage(1049019); // You have accepted the Quest.
2016-04-04 13:03:36 -05:00
2020-04-16 21:29:55 -04:00
StartTimer();
2016-04-04 13:03:36 -05:00
}
public virtual void Decline()
{
2020-04-16 21:29:55 -04:00
m_From.SendLocalizedMessage(1049018); // You have declined the Quest.
2016-04-04 13:03:36 -05:00
}
}
public class QuestCancelGump : BaseQuestGump
{
private readonly QuestSystem m_System;
public QuestCancelGump(QuestSystem system)
: base(120, 50)
{
2020-04-16 21:29:55 -04:00
m_System = system;
2016-04-04 13:03:36 -05:00
2020-04-16 21:29:55 -04:00
Closable = false;
2016-04-04 13:03:36 -05:00
2020-04-16 21:29:55 -04:00
AddPage(0);
2016-04-04 13:03:36 -05:00
2020-04-16 21:29:55 -04:00
AddImageTiled(0, 0, 348, 262, 2702);
AddAlphaRegion(0, 0, 348, 262);
2016-04-04 13:03:36 -05:00
2020-04-16 21:29:55 -04:00
AddImage(0, 15, 10152);
AddImageTiled(0, 30, 17, 200, 10151);
AddImage(0, 230, 10154);
2016-04-04 13:03:36 -05:00
2020-04-16 21:29:55 -04:00
AddImage(15, 0, 10252);
AddImageTiled(30, 0, 300, 17, 10250);
AddImage(315, 0, 10254);
2016-04-04 13:03:36 -05:00
2020-04-16 21:29:55 -04:00
AddImage(15, 244, 10252);
AddImageTiled(30, 244, 300, 17, 10250);
AddImage(315, 244, 10254);
2016-04-04 13:03:36 -05:00
2020-04-16 21:29:55 -04:00
AddImage(330, 15, 10152);
AddImageTiled(330, 30, 17, 200, 10151);
AddImage(330, 230, 10154);
2016-04-04 13:03:36 -05:00
2020-04-16 21:29:55 -04:00
AddImage(333, 2, 10006);
AddImage(333, 248, 10006);
AddImage(2, 248, 10006);
AddImage(2, 2, 10006);
2016-04-04 13:03:36 -05:00
2020-04-16 21:29:55 -04:00
AddHtmlLocalized(25, 22, 200, 20, 1049000, 32000, false, false); // Confirm Quest Cancellation
AddImage(25, 40, 3007);
2016-04-04 13:03:36 -05:00
if (system.IsTutorial)
{
2020-04-16 21:29:55 -04:00
AddHtmlLocalized(25, 55, 300, 120, 1060836, White, false, false); // This quest will give you valuable information, skills and equipment that will help you advance in the game at a quicker pace.<BR><BR>Are you certain you wish to cancel at this time?
2016-04-04 13:03:36 -05:00
}
else
{
2020-04-16 21:29:55 -04:00
AddHtmlLocalized(25, 60, 300, 20, 1049001, White, false, false); // You have chosen to abort your quest:
AddImage(25, 81, 0x25E7);
AddHtmlObject(48, 80, 280, 20, system.Name, DarkGreen, false, false);
2016-04-04 13:03:36 -05:00
2020-04-16 21:29:55 -04:00
AddHtmlLocalized(25, 120, 280, 20, 1049002, White, false, false); // Can this quest be restarted after quitting?
AddImage(25, 141, 0x25E7);
AddHtmlLocalized(48, 140, 280, 20, (system.RestartDelay < TimeSpan.MaxValue) ? 1049016 : 1049017, DarkGreen, false, false); // Yes/No
2016-04-04 13:03:36 -05:00
}
2020-04-16 21:29:55 -04:00
AddRadio(25, 175, 9720, 9723, true, 1);
AddHtmlLocalized(60, 180, 280, 20, 1049005, White, false, false); // Yes, I really want to quit!
2016-04-04 13:03:36 -05:00
2020-04-16 21:29:55 -04:00
AddRadio(25, 210, 9720, 9723, false, 0);
AddHtmlLocalized(60, 215, 280, 20, 1049006, White, false, false); // No, I don't want to quit.
2016-04-04 13:03:36 -05:00
2020-04-16 21:29:55 -04:00
AddButton(265, 220, 247, 248, 1, GumpButtonType.Reply, 0);
2016-04-04 13:03:36 -05:00
}
public override void OnResponse(NetState sender, RelayInfo info)
{
if (info.ButtonID == 1)
2020-04-16 21:29:55 -04:00
m_System.EndCancelQuest(info.IsSwitched(1));
2016-04-04 13:03:36 -05:00
}
}
public class QuestOfferGump : BaseQuestGump
{
private readonly QuestSystem m_System;
public QuestOfferGump(QuestSystem system)
: base(75, 25)
{
2020-04-16 21:29:55 -04:00
m_System = system;
2016-04-04 13:03:36 -05:00
2020-04-16 21:29:55 -04:00
Closable = false;
2016-04-04 13:03:36 -05:00
2020-04-16 21:29:55 -04:00
AddPage(0);
2016-04-04 13:03:36 -05:00
2020-04-16 21:29:55 -04:00
AddImageTiled(50, 20, 400, 400, 2624);
AddAlphaRegion(50, 20, 400, 400);
2016-04-04 13:03:36 -05:00
2020-04-16 21:29:55 -04:00
AddImage(90, 33, 9005);
AddHtmlLocalized(130, 45, 270, 20, 1049010, White, false, false); // Quest Offer
AddImageTiled(130, 65, 175, 1, 9101);
2016-04-04 13:03:36 -05:00
2020-04-16 21:29:55 -04:00
AddImage(140, 110, 1209);
AddHtmlObject(160, 108, 250, 20, system.Name, DarkGreen, false, false);
2016-04-04 13:03:36 -05:00
2020-04-16 21:29:55 -04:00
AddHtmlObject(98, 140, 312, 200, system.OfferMessage, LightGreen, false, true);
2016-04-04 13:03:36 -05:00
2020-04-16 21:29:55 -04:00
AddRadio(85, 350, 9720, 9723, true, 1);
AddHtmlLocalized(120, 356, 280, 20, 1049011, White, false, false); // I accept!
2016-04-04 13:03:36 -05:00
2020-04-16 21:29:55 -04:00
AddRadio(85, 385, 9720, 9723, false, 0);
AddHtmlLocalized(120, 391, 280, 20, 1049012, White, false, false); // No thanks, I decline.
2016-04-04 13:03:36 -05:00
2020-04-16 21:29:55 -04:00
AddButton(340, 390, 247, 248, 1, GumpButtonType.Reply, 0);
2016-04-04 13:03:36 -05:00
2020-04-16 21:29:55 -04:00
AddImageTiled(50, 29, 30, 390, 10460);
AddImageTiled(34, 140, 17, 279, 9263);
2016-04-04 13:03:36 -05:00
2020-04-16 21:29:55 -04:00
AddImage(48, 135, 10411);
AddImage(-16, 285, 10402);
AddImage(0, 10, 10421);
AddImage(25, 0, 10420);
2016-04-04 13:03:36 -05:00
2020-04-16 21:29:55 -04:00
AddImageTiled(83, 15, 350, 15, 10250);
2016-04-04 13:03:36 -05:00
2020-04-16 21:29:55 -04:00
AddImage(34, 419, 10306);
AddImage(442, 419, 10304);
AddImageTiled(51, 419, 392, 17, 10101);
2016-04-04 13:03:36 -05:00
2020-04-16 21:29:55 -04:00
AddImageTiled(415, 29, 44, 390, 2605);
AddImageTiled(415, 29, 30, 390, 10460);
AddImage(425, 0, 10441);
2016-04-04 13:03:36 -05:00
2020-04-16 21:29:55 -04:00
AddImage(370, 50, 1417);
AddImage(379, 60, system.Picture);
2016-04-04 13:03:36 -05:00
}
public override void OnResponse(NetState sender, RelayInfo info)
{
if (info.ButtonID == 1)
{
if (info.IsSwitched(1))
2020-04-16 21:29:55 -04:00
m_System.Accept();
2016-04-04 13:03:36 -05:00
else
2020-04-16 21:29:55 -04:00
m_System.Decline();
2016-04-04 13:03:36 -05:00
}
}
}
public abstract class BaseQuestGump : Gump
{
public const int Black = 0x0000;
public const int White = 0x7FFF;
public const int DarkGreen = 10000;
public const int LightGreen = 90000;
public const int Blue = 19777215;
public BaseQuestGump(int x, int y)
: base(x, y)
{
}
public static int C16232(int c16)
{
c16 &= 0x7FFF;
int r = (((c16 >> 10) & 0x1F) << 3);
int g = (((c16 >> 05) & 0x1F) << 3);
int b = (((c16 >> 00) & 0x1F) << 3);
return (r << 16) | (g << 8) | (b << 0);
}
public static int C16216(int c16)
{
return c16 & 0x7FFF;
}
public static int C32216(int c32)
{
c32 &= 0xFFFFFF;
int r = (((c32 >> 16) & 0xFF) >> 3);
int g = (((c32 >> 08) & 0xFF) >> 3);
int b = (((c32 >> 00) & 0xFF) >> 3);
return (r << 10) | (g << 5) | (b << 0);
}
public static string Color(string text, int color)
{
return string.Format("<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", color, text);
2016-04-04 13:03:36 -05:00
}
public static ArrayList BuildList(object obj)
{
ArrayList list = new ArrayList();
list.Add(obj);
return list;
}
public void AddHtmlObject(int x, int y, int width, int height, object message, int color, bool back, bool scroll)
{
if (message is string)
{
string html = (string)message;
2020-04-16 21:29:55 -04:00
AddHtml(x, y, width, height, Color(html, C16232(color)), back, scroll);
2016-04-04 13:03:36 -05:00
}
else if (message is int)
{
int html = (int)message;
2020-04-16 21:29:55 -04:00
AddHtmlLocalized(x, y, width, height, html, C16216(color), back, scroll);
2016-04-04 13:03:36 -05:00
}
}
}
}