Overwrite

Complete Overwrite of the Folder with the free shard. ServUO 57.3 has been added.
This commit is contained in:
Unstable Kitsune
2023-11-28 23:20:26 -05:00
parent 3cd54811de
commit b918192e4e
11608 changed files with 2644205 additions and 47 deletions

View File

@@ -0,0 +1,296 @@
#region Header
// _,-'/-'/
// . __,-; ,'( '/
// \. `-.__`-._`:_,-._ _ , . ``
// `:-._,------' ` _,`--` -: `_ , ` ,' :
// `---..__,,--' (C) 2023 ` -'. -'
// # Vita-Nex [http://core.vita-nex.com] #
// {o)xxx|===============- # -===============|xxx(o}
// # #
#endregion
#region References
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using Server;
using Server.Accounting;
using Server.Engines.Help;
using Server.Misc;
using Server.Mobiles;
using VitaNex.IO;
using VitaNex.SuperGumps.UI;
using VitaNex.Text;
#endregion
namespace VitaNex.Modules.AntiAdverts
{
public static partial class AntiAdverts
{
public const AccessLevel Access = AccessLevel.Administrator;
public static AntiAdvertsOptions CMOptions { get; private set; }
public static FileInfo ReportsFile => IOUtility.EnsureFile(VitaNexCore.SavesDirectory + "/AntiAdverts/Reports.bin");
public static List<AntiAdvertsReport> Reports { get; private set; }
public static event Action<AntiAdvertNotifyGump> OnBeforeSendGump;
public static event Action<AntiAdvertNotifyGump> OnAfterSendGump;
private static void InvokeOnBeforeSendGump(AntiAdvertNotifyGump g)
{
if (OnBeforeSendGump != null)
{
OnBeforeSendGump(g);
}
}
private static void InvokeOnAfterSendGump(AntiAdvertNotifyGump g)
{
if (OnAfterSendGump != null)
{
OnAfterSendGump(g);
}
}
public static bool Detect(string text)
{
return Detect(text, out var keyword);
}
public static bool Detect(string text, out string keyword)
{
// Does the speech contain any forbidden key words?
foreach (var kw in CMOptions.KeyWords)
{
if (CMOptions.SearchMode.Execute(text, kw, CMOptions.SearchCapsIgnore))
{
keyword = kw;
return true;
}
if (!kw.Contains(' '))
{
continue;
}
foreach (var kwr in CMOptions.WhitespaceAliases.Select(wa => kw.Replace(' ', wa))
.Where(kwr => CMOptions.SearchMode.Execute(text, kwr, CMOptions.SearchCapsIgnore)))
{
keyword = kwr;
return true;
}
}
keyword = null;
return false;
}
private static void OnSpeech(SpeechEventArgs e)
{
if (e == null || !(e.Mobile is PlayerMobile) || e.Mobile.NetState == null || String.IsNullOrWhiteSpace(e.Speech) ||
e.Mobile.AccessLevel > CMOptions.HandleAccess)
{
return;
}
if (!Detect(e.Speech, out var detected))
{
return;
}
var banned = Ban(e.Mobile, e.Speech);
var jailed = Jail(e.Mobile, e.Speech);
ToConsole(e.Mobile, e.Speech, jailed, banned);
ToLog(e.Mobile, e.Speech, jailed, banned);
SendPage(e.Mobile, e.Speech, jailed, banned);
SendWarning(e.Mobile, e.Speech, jailed, banned);
if (CMOptions.Squelch)
{
e.Mobile.Squelched = true;
}
if (CMOptions.Kick)
{
e.Mobile.Say("I've been kicked!");
if (e.Mobile.NetState != null)
{
e.Mobile.NetState.Dispose();
}
}
Reports.Insert(
0,
new AntiAdvertsReport(
DateTime.Now,
e.Mobile,
GetDetectedString(false, e.Mobile, e.Speech, jailed, banned),
e.Speech,
jailed,
banned));
Reports.TrimEndTo(100);
}
private static string GetDetectedString(bool lines, Mobile m, string speech, bool jailed, bool banned)
{
if (m == null || m.Deleted || !m.Player || String.IsNullOrWhiteSpace(speech))
{
return String.Empty;
}
return String.Format(
lines
? "IP('{0}')\nAccount('{1}')\nChar('{2}')\nJail('{3}')\nBan('{4}')\nQuote(\"{5}\")"
: "IP('{0}') Account('{1}') Char('{2}') Jail('{3}') Ban('{4}') Quote(\"{5}\")",
m.NetState.Address,
m.Account.Username,
m.RawName,
jailed ? "yes" : "no",
banned ? "yes" : "no",
speech);
}
private static void ToConsole(Mobile m, string speech, bool jailed, bool banned)
{
if (m != null && !m.Deleted && m.Player && !String.IsNullOrWhiteSpace(speech) && CMOptions.ConsoleWrite)
{
Console.WriteLine("[Warning: Advertising Detected]: " + GetDetectedString(false, m, speech, jailed, banned));
}
}
private static void ToLog(Mobile m, string speech, bool jailed, bool banned)
{
if (m != null && !m.Deleted && !String.IsNullOrWhiteSpace(speech) && CMOptions.LogEnabled)
{
String.Format(
"[{0}]: {1}",
DateTime.Now.TimeOfDay.ToSimpleString("h:m"),
GetDetectedString(false, m, speech, jailed, banned))
.Log("DetectedAdvertisers.log");
}
}
private static void SendPage(Mobile m, string speech, bool jailed, bool banned)
{
if (m == null || m.Deleted || !m.Player || String.IsNullOrWhiteSpace(speech) || !CMOptions.PageStaff)
{
return;
}
var entry = PageQueue.GetEntry(m);
if (entry == null || !entry.Message.StartsWith("[Warning: Advertising Detected]"))
{
PageQueue.Enqueue(
new PageEntry(
m,
"[Warning: Advertising Detected]: " + GetDetectedString(true, m, speech, jailed, banned),
PageType.Account));
}
}
private static void SendWarning(Mobile m, string speech, bool jailed, bool banned)
{
if (m == null || m.Deleted || !m.Player || String.IsNullOrWhiteSpace(speech))
{
return;
}
string message;
if (CMOptions.NotifyStaff)
{
message = "[Warning: Advertising Detected]: " + GetDetectedString(true, m, speech, jailed, banned);
Notify.Notify.Broadcast<AntiAdvertNotifyGump>(
message,
false,
1.0,
3.0,
Color.OrangeRed,
InvokeOnBeforeSendGump,
InvokeOnAfterSendGump,
CMOptions.NotifyAccess);
}
if (!CMOptions.NotifyPlayer)
{
return;
}
var pm = m as PlayerMobile;
if (pm == null)
{
return;
}
message = String.Empty;
message += "A recent check shows that you may be trying to advertise on " + ServerList.ServerName + ".\n";
message += "Advertising is not allowed.\n";
if (jailed)
{
message += "You have been jailed until a member of staff can review your case.\n";
message += "If you are found to be innocent, you will be promptly released and free to adventure again.\n";
}
else
{
message += "A report has been submitted to the staff team for review.\n";
}
message += "\nOffending Speech:\n" + speech;
new NoticeDialogGump(pm)
{
Width = 420,
Height = 420,
CanMove = false,
CanDispose = false,
BlockSpeech = true,
RandomButtonID = true,
Title = jailed ? "Jailed! Why?" : "Advertising Reported",
Html = message
}.Send();
}
private static bool Jail(Mobile m, string speech)
{
return m != null && !m.Deleted && m.Player && !String.IsNullOrWhiteSpace(speech) && CMOptions.Jail &&
CMOptions.JailPoint.MoveToWorld(m);
}
private static bool Ban(Mobile m, string speech)
{
if (m == null || m.Deleted || !m.Player || String.IsNullOrWhiteSpace(speech) || !CMOptions.Ban)
{
return false;
}
var a = m.Account as Account;
if (a != null)
{
a.Banned = true;
a.SetBanTags(null, DateTime.UtcNow, TimeSpan.MaxValue);
return true;
}
return false;
}
}
}

View File

@@ -0,0 +1,77 @@
#region Header
// _,-'/-'/
// . __,-; ,'( '/
// \. `-.__`-._`:_,-._ _ , . ``
// `:-._,------' ` _,`--` -: `_ , ` ,' :
// `---..__,,--' (C) 2023 ` -'. -'
// # Vita-Nex [http://core.vita-nex.com] #
// {o)xxx|===============- # -===============|xxx(o}
// # #
#endregion
#region References
using System.Collections.Generic;
using Server;
#endregion
namespace VitaNex.Modules.AntiAdverts
{
[CoreModule("Anti Adverts", "1.0.0.2")]
public static partial class AntiAdverts
{
static AntiAdverts()
{
CMOptions = new AntiAdvertsOptions();
Reports = new List<AntiAdvertsReport>(100);
}
private static void CMConfig()
{
EventSink.Speech += OnSpeech;
}
private static void CMInvoke()
{
CommandUtility.Register("AntiAds", Access, e => new AntiAvertsReportsGump(e.Mobile).Send());
}
private static void CMEnabled()
{
EventSink.Speech += OnSpeech;
}
private static void CMDisabled()
{
EventSink.Speech -= OnSpeech;
}
private static void CMSave()
{
VitaNexCore.TryCatch(() => ReportsFile.Serialize(SerializeReports), CMOptions.ToConsole);
}
private static void CMLoad()
{
VitaNexCore.TryCatch(() => ReportsFile.Deserialize(DeserializeReports), CMOptions.ToConsole);
}
private static void CMDisposed()
{ }
private static void SerializeReports(GenericWriter writer)
{
writer.SetVersion(0);
writer.WriteBlockList(Reports, (w, r) => r.Serialize(w));
}
private static void DeserializeReports(GenericReader reader)
{
reader.GetVersion();
reader.ReadBlockList(r => new AntiAdvertsReport(r), Reports);
}
}
}

View File

@@ -0,0 +1,125 @@
#region Header
// _,-'/-'/
// . __,-; ,'( '/
// \. `-.__`-._`:_,-._ _ , . ``
// `:-._,------' ` _,`--` -: `_ , ` ,' :
// `---..__,,--' (C) 2023 ` -'. -'
// # Vita-Nex [http://core.vita-nex.com] #
// {o)xxx|===============- # -===============|xxx(o}
// # #
#endregion
#region References
using System;
using Server;
using Server.Mobiles;
#endregion
namespace VitaNex.Modules.AntiAdverts
{
public sealed class AntiAdvertsReport : IEquatable<AntiAdvertsReport>
{
public DateTime Date { get; private set; }
public Mobile Mobile { get; private set; }
public string Report { get; set; }
public string Speech { get; set; }
public bool Jailed { get; set; }
public bool Banned { get; set; }
public bool Viewed { get; set; }
public AntiAdvertsReport(
DateTime date,
Mobile m,
string report,
string speech,
bool jailed,
bool banned,
bool viewed = false)
{
Date = date;
Mobile = m;
Speech = speech;
Report = report;
Viewed = viewed;
Jailed = jailed;
Banned = banned;
}
public AntiAdvertsReport(GenericReader reader)
{
Deserialize(reader);
}
public override string ToString()
{
return String.Format(
"[{0}] {1}: {2}",
Date.ToSimpleString("t@h:m@ m-d"),
Mobile == null ? "-null-" : Mobile.RawName,
Report);
}
public override int GetHashCode()
{
unchecked
{
var hashCode = (Mobile != null ? Mobile.Serial.Value : 0);
hashCode = (hashCode * 397) ^ Date.GetHashCode();
hashCode = (hashCode * 397) ^ (Speech != null ? Speech.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (Report != null ? Report.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ Jailed.GetHashCode();
hashCode = (hashCode * 397) ^ Banned.GetHashCode();
return hashCode;
}
}
public override bool Equals(object obj)
{
return obj is AntiAdvertsReport && Equals((AntiAdvertsReport)obj);
}
public bool Equals(AntiAdvertsReport other)
{
return !ReferenceEquals(other, null) && Mobile == other.Mobile && Date == other.Date && Jailed == other.Jailed &&
Banned == other.Banned && Speech == other.Speech && Report == other.Report;
}
public void Serialize(GenericWriter writer)
{
writer.SetVersion(0);
writer.Write(Date);
writer.Write(Mobile);
writer.Write(Speech);
writer.Write(Report);
writer.Write(Viewed);
writer.Write(Jailed);
writer.Write(Banned);
}
public void Deserialize(GenericReader reader)
{
reader.GetVersion();
Date = reader.ReadDateTime();
Mobile = reader.ReadMobile<PlayerMobile>();
Speech = reader.ReadString();
Report = reader.ReadString();
Viewed = reader.ReadBool();
Jailed = reader.ReadBool();
Banned = reader.ReadBool();
}
public static bool operator ==(AntiAdvertsReport l, AntiAdvertsReport r)
{
return ReferenceEquals(l, null) ? ReferenceEquals(r, null) : l.Equals(r);
}
public static bool operator !=(AntiAdvertsReport l, AntiAdvertsReport r)
{
return ReferenceEquals(l, null) ? !ReferenceEquals(r, null) : !l.Equals(r);
}
}
}

View File

@@ -0,0 +1,271 @@
#region Header
// _,-'/-'/
// . __,-; ,'( '/
// \. `-.__`-._`:_,-._ _ , . ``
// `:-._,------' ` _,`--` -: `_ , ` ,' :
// `---..__,,--' (C) 2023 ` -'. -'
// # Vita-Nex [http://core.vita-nex.com] #
// {o)xxx|===============- # -===============|xxx(o}
// # #
#endregion
#region References
using System.Collections.Generic;
using Server;
using VitaNex.Text;
#endregion
namespace VitaNex.Modules.AntiAdverts
{
public sealed class AntiAdvertsOptions : CoreModuleOptions
{
/// <summary>
/// Log the info in a log file?
/// </summary>
[CommandProperty(AntiAdverts.Access)]
public bool LogEnabled { get; set; }
/// <summary>
/// Write info to the console?
/// </summary>
[CommandProperty(AntiAdverts.Access)]
public bool ConsoleWrite { get; set; }
/// <summary>
/// Page staff with offense?
/// </summary>
[CommandProperty(AntiAdverts.Access)]
public bool PageStaff { get; set; }
/// <summary>
/// Send a warning broadcast to staff?
/// </summary>
[CommandProperty(AntiAdverts.Access)]
public bool NotifyStaff { get; set; }
/// <summary>
/// Send a warning to offending player
/// </summary>
[CommandProperty(AntiAdverts.Access)]
public bool NotifyPlayer { get; set; }
/// <summary>
/// Send a warning broadcast to staff of this access and above.
/// </summary>
[CommandProperty(AntiAdverts.Access)]
public AccessLevel NotifyAccess { get; set; }
/// <summary>
/// AccessLevels higher than this value will not have their speech handled.
/// </summary>
[CommandProperty(AntiAdverts.Access)]
public AccessLevel HandleAccess { get; set; }
/// <summary>
/// Jail the offender?
/// </summary>
[CommandProperty(AntiAdverts.Access)]
public bool Jail { get; set; }
/// <summary>
/// The location and map of the jail area.
/// </summary>
[CommandProperty(AntiAdverts.Access)]
public MapPoint JailPoint { get; set; }
/// <summary>
/// Squelch the offender?
/// </summary>
[CommandProperty(AntiAdverts.Access)]
public bool Squelch { get; set; }
/// <summary>
/// Kick the offender?
/// </summary>
[CommandProperty(AntiAdverts.Access)]
public bool Kick { get; set; }
/// <summary>
/// Ban the offender?
/// </summary>
[CommandProperty(AntiAdverts.Access)]
public bool Ban { get; set; }
/// <summary>
/// The mode used to find matching key words in text.
/// </summary>
[CommandProperty(AntiAdverts.Access)]
public StringSearchFlags SearchMode { get; set; }
/// <summary>
/// Should the search be case-insensitive?
/// </summary>
[CommandProperty(AntiAdverts.Access)]
public bool SearchCapsIgnore { get; set; }
/// <summary>
/// A list of common symbols used to replace whitespaces to avoid detection.
/// </summary>
public List<char> WhitespaceAliases { get; private set; }
/// <summary>
/// A case-insensitive list of all disallowed keywords and phrases.
/// Any whitespaces in keywords will also be tested with their aliases.
/// </summary>
public List<string> KeyWords { get; private set; }
public AntiAdvertsOptions()
: base(typeof(AntiAdverts))
{
WhitespaceAliases = new List<char>();
KeyWords = new List<string>();
EnsureDefaults();
}
public AntiAdvertsOptions(GenericReader reader)
: base(reader)
{ }
public void EnsureDefaults()
{
LogEnabled = true;
ConsoleWrite = true;
PageStaff = true;
NotifyStaff = true;
NotifyAccess = AccessLevel.Counselor;
HandleAccess = AccessLevel.Player;
Jail = false;
JailPoint = new MapPoint(Map.Felucca, new Point3D(5275, 1174, 0));
Squelch = false;
Kick = false;
Ban = false;
SearchMode = StringSearchFlags.Contains;
SearchCapsIgnore = true;
WhitespaceAliases.AddRange(
new[]
{
'_', ':', ';', '@', '#', '=', '-', '+', '*', '/', //
'\\', '!', '"', '<27>', '$', '%', '^', '&', '"' //
});
KeyWords.AddRange(
new[]
{
"port: 2593", "port 2593", "port: 2595", "port 2595", "paypal", "no-ip", "joinuo", "uoisnotdead", "shard.li",
"easyuo"
});
}
public override void Clear()
{
base.Clear();
EnsureDefaults();
}
public override void Reset()
{
base.Reset();
EnsureDefaults();
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
var version = writer.SetVersion(2);
switch (version)
{
case 2:
writer.Write(NotifyPlayer);
goto case 1;
case 1:
{
writer.WriteFlag(SearchMode);
writer.Write(SearchCapsIgnore);
}
goto case 0;
case 0:
{
writer.WriteBlockList(WhitespaceAliases, (w, a) => w.Write(a));
writer.WriteBlockList(KeyWords, (w, k) => w.Write(k));
writer.Write(LogEnabled);
writer.Write(ConsoleWrite);
writer.Write(PageStaff);
writer.Write(NotifyStaff);
writer.WriteFlag(NotifyAccess);
writer.Write(Jail);
JailPoint.Serialize(writer);
writer.Write(Squelch);
writer.Write(Kick);
writer.Write(Ban);
}
break;
}
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
var version = reader.GetVersion();
switch (version)
{
case 2:
NotifyPlayer = reader.ReadBool();
goto case 1;
case 1:
{
SearchMode = reader.ReadFlag<StringSearchFlags>();
SearchCapsIgnore = reader.ReadBool();
}
goto case 0;
case 0:
{
if (version < 1)
{
SearchMode = StringSearchFlags.Contains;
SearchCapsIgnore = true;
}
WhitespaceAliases = reader.ReadBlockList(r => r.ReadChar());
KeyWords = reader.ReadBlockList(r => r.ReadString());
LogEnabled = reader.ReadBool();
ConsoleWrite = reader.ReadBool();
PageStaff = reader.ReadBool();
NotifyStaff = reader.ReadBool();
NotifyAccess = reader.ReadFlag<AccessLevel>();
Jail = reader.ReadBool();
JailPoint = new MapPoint(reader);
Squelch = reader.ReadBool();
Kick = reader.ReadBool();
Ban = reader.ReadBool();
}
break;
}
}
}
}

View File

@@ -0,0 +1,81 @@
#region Header
// _,-'/-'/
// . __,-; ,'( '/
// \. `-.__`-._`:_,-._ _ , . ``
// `:-._,------' ` _,`--` -: `_ , ` ,' :
// `---..__,,--' (C) 2023 ` -'. -'
// # Vita-Nex [http://core.vita-nex.com] #
// {o)xxx|===============- # -===============|xxx(o}
// # #
#endregion
#region References
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Server;
using Server.Gumps;
using VitaNex.SuperGumps.UI;
#endregion
namespace VitaNex.Modules.AntiAdverts
{
public sealed class AntiAdvertsEditAliasesGump : GenericListGump<char>
{
public string Input { get; set; }
public AntiAdvertsEditAliasesGump(Mobile user, Gump parent = null)
: base(
user,
parent,
list: AntiAdverts.CMOptions.WhitespaceAliases,
title: "Anti-Adverts: Whitespace Aliases",
emptyText: "No whitespace aliases to display.",
canAdd: true,
canClear: true,
canRemove: true)
{ }
public override string GetSearchKeyFor(char key)
{
return key.ToString(CultureInfo.InvariantCulture);
}
protected override bool OnBeforeListAdd()
{
if (Input != null)
{
return true;
}
Send(
new InputDialogGump(
User,
Refresh(),
title: "Add Whitespace Alias",
html: "Write a single character to add it to this list.",
limit: 1,
callback: (b1, text) =>
{
Input = !String.IsNullOrWhiteSpace(text) ? text : String.Empty;
HandleAdd();
Input = null;
}));
return false;
}
public override List<char> GetExternalList()
{
return AntiAdverts.CMOptions.WhitespaceAliases;
}
public override char GetListAddObject()
{
return Input.FirstOrDefault();
}
}
}

View File

@@ -0,0 +1,78 @@
#region Header
// _,-'/-'/
// . __,-; ,'( '/
// \. `-.__`-._`:_,-._ _ , . ``
// `:-._,------' ` _,`--` -: `_ , ` ,' :
// `---..__,,--' (C) 2023 ` -'. -'
// # Vita-Nex [http://core.vita-nex.com] #
// {o)xxx|===============- # -===============|xxx(o}
// # #
#endregion
#region References
using System;
using System.Collections.Generic;
using Server;
using Server.Gumps;
using VitaNex.SuperGumps.UI;
#endregion
namespace VitaNex.Modules.AntiAdverts
{
public sealed class AntiAdvertsEditKeyWordsGump : GenericListGump<string>
{
public string Input { get; set; }
public AntiAdvertsEditKeyWordsGump(Mobile user, Gump parent = null)
: base(
user,
parent,
list: AntiAdverts.CMOptions.KeyWords,
title: "Anti-Adverts: Key Words",
emptyText: "No key words to display.",
canAdd: true,
canClear: true,
canRemove: true)
{ }
public override string GetSearchKeyFor(string key)
{
return key ?? String.Empty;
}
protected override bool OnBeforeListAdd()
{
if (Input != null)
{
return true;
}
Send(
new InputDialogGump(
User,
Refresh(),
title: "Add Key Word",
html: "Write a phrase to add it to this list.",
callback: (b1, text) =>
{
Input = !String.IsNullOrWhiteSpace(text) ? text : null;
HandleAdd();
Input = null;
}));
return false;
}
public override List<string> GetExternalList()
{
return AntiAdverts.CMOptions.KeyWords;
}
public override string GetListAddObject()
{
return Input;
}
}
}

View File

@@ -0,0 +1,33 @@
#region Header
// _,-'/-'/
// . __,-; ,'( '/
// \. `-.__`-._`:_,-._ _ , . ``
// `:-._,------' ` _,`--` -: `_ , ` ,' :
// `---..__,,--' (C) 2023 ` -'. -'
// # Vita-Nex [http://core.vita-nex.com] #
// {o)xxx|===============- # -===============|xxx(o}
// # #
#endregion
#region References
using Server;
using VitaNex.Notify;
#endregion
namespace VitaNex.Modules.AntiAdverts
{
public sealed class AntiAdvertNotifyGump : NotifyGump
{
private static void InitSettings(NotifySettings settings)
{
settings.CanIgnore = true;
settings.Access = AntiAdverts.Access;
settings.Desc = "Advertising Reports";
}
public AntiAdvertNotifyGump(Mobile user, string html)
: base(user, html)
{ }
}
}

View File

@@ -0,0 +1,165 @@
#region Header
// _,-'/-'/
// . __,-; ,'( '/
// \. `-.__`-._`:_,-._ _ , . ``
// `:-._,------' ` _,`--` -: `_ , ` ,' :
// `---..__,,--' (C) 2023 ` -'. -'
// # Vita-Nex [http://core.vita-nex.com] #
// {o)xxx|===============- # -===============|xxx(o}
// # #
#endregion
#region References
using System;
using System.Collections.Generic;
using Server;
using Server.Gumps;
using VitaNex.SuperGumps.UI;
#endregion
namespace VitaNex.Modules.AntiAdverts
{
public sealed class AntiAvertsReportsGump : ListGump<AntiAdvertsReport>
{
public AntiAvertsReportsGump(Mobile user)
: base(user)
{
Title = "Anti-Advert Reports";
EmptyText = "No reports to display.";
Sorted = true;
CanSearch = true;
CanMove = false;
}
protected override void CompileList(List<AntiAdvertsReport> list)
{
list.Clear();
list.AddRange(AntiAdverts.Reports);
base.CompileList(list);
}
protected override void CompileMenuOptions(MenuGumpOptions list)
{
list.AppendEntry(
new ListGumpEntry(
"Options",
() =>
{
Refresh();
User.SendGump(new PropertiesGump(User, AntiAdverts.CMOptions));
},
HighlightHue));
list.AppendEntry(
new ListGumpEntry("Key Words", () => new AntiAdvertsEditKeyWordsGump(User, this).Send(), HighlightHue));
list.AppendEntry(
new ListGumpEntry("Whitespace Aliases", () => new AntiAdvertsEditAliasesGump(User, this).Send(), HighlightHue));
list.AppendEntry(
new ListGumpEntry(
"Mark All: Viewed",
() =>
{
AntiAdverts.Reports.ForEach(t => t.Viewed = true);
User.SendMessage("All reports have been marked as viewed.");
Refresh(true);
},
TextHue));
list.AppendEntry(
new ListGumpEntry(
"Mark All: Not Viewed",
() =>
{
AntiAdverts.Reports.ForEach(t => t.Viewed = false);
User.SendMessage("All reports have been marked as not viewed.");
Refresh(true);
},
TextHue));
list.AppendEntry(
new ListGumpEntry(
"Delete All",
() =>
{
AntiAdverts.Reports.Free(true);
User.SendMessage("All reports have been deleted.");
Refresh(true);
},
ErrorHue));
list.AppendEntry(
new ListGumpEntry(
"Delete Old",
() =>
{
var expire = DateTime.Now - TimeSpan.FromDays(7);
AntiAdverts.Reports.RemoveAll(t => t.Date <= expire);
AntiAdverts.Reports.Free(false);
User.SendMessage("All old reports have been deleted.");
Refresh(true);
},
ErrorHue));
base.CompileMenuOptions(list);
}
protected override void SelectEntry(GumpButton button, AntiAdvertsReport entry)
{
base.SelectEntry(button, entry);
var opts = new MenuGumpOptions();
opts.AppendEntry(
new ListGumpEntry(
"View",
() =>
{
entry.Viewed = true;
new NoticeDialogGump(User, Refresh(true))
{
Title = "Anti-Advert Report",
Html = entry.ToString(),
Modal = false,
CanMove = false
}.Send();
},
HighlightHue));
opts.AppendEntry(
!entry.Viewed
? new ListGumpEntry("Mark Viewed", () => entry.Viewed = true)
: new ListGumpEntry("Mark Not Viewed", () => entry.Viewed = false));
opts.AppendEntry(new ListGumpEntry("Delete", () => AntiAdverts.Reports.Remove(entry), ErrorHue));
new MenuGump(User, Refresh(), opts, button).Send();
}
protected override int GetLabelHue(int index, int pageIndex, AntiAdvertsReport entry)
{
return entry != null ? entry == Selected ? HighlightHue : !entry.Viewed ? TextHue : ErrorHue : ErrorHue;
}
protected override string GetLabelText(int index, int pageIndex, AntiAdvertsReport entry)
{
return entry != null ? entry.ToString() : String.Empty;
}
public override string GetSearchKeyFor(AntiAdvertsReport key)
{
return key != null ? key.ToString() : String.Empty;
}
}
}