Overwrite
Complete Overwrite of the Folder with the free shard. ServUO 57.3 has been added.
This commit is contained in:
466
Scripts/SubSystem/VitaNex/Core/Services/Notify/Notify.cs
Normal file
466
Scripts/SubSystem/VitaNex/Core/Services/Notify/Notify.cs
Normal file
@@ -0,0 +1,466 @@
|
||||
#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.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
using Server;
|
||||
using Server.Commands;
|
||||
using Server.Network;
|
||||
|
||||
using VitaNex.IO;
|
||||
using VitaNex.Text;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.Notify
|
||||
{
|
||||
public static partial class Notify
|
||||
{
|
||||
public const AccessLevel Access = AccessLevel.Administrator;
|
||||
|
||||
public static CoreServiceOptions CSOptions { get; private set; }
|
||||
|
||||
public static Type[] GumpTypes { get; private set; }
|
||||
|
||||
public static Dictionary<Type, Type[]> NestedTypes { get; private set; }
|
||||
|
||||
public static Dictionary<Type, Type> SettingsMap { get; private set; }
|
||||
|
||||
public static BinaryDataStore<Type, NotifySettings> Settings { get; private set; }
|
||||
|
||||
public static event Action<NotifyGump> OnGlobalMessage;
|
||||
public static event Action<NotifyGump> OnLocalMessage;
|
||||
|
||||
public static event Action<string> OnBroadcast;
|
||||
|
||||
[Usage("Notify <text | html | bbc>"), Description(
|
||||
"Send a global notification gump to all online clients, " + //
|
||||
"containing a message parsed from HTML, BBS or plain text.")]
|
||||
private static void HandleNotify(CommandEventArgs e)
|
||||
{
|
||||
if (e.Mobile.AccessLevel >= AccessLevel.Seer && !String.IsNullOrWhiteSpace(e.ArgString) && ValidateCommand(e))
|
||||
{
|
||||
Broadcast(e.Mobile, e.ArgString);
|
||||
return;
|
||||
}
|
||||
|
||||
new NotifySettingsGump(e.Mobile).Send();
|
||||
}
|
||||
|
||||
[Usage("NotifyAC <text | html | bbc>"), Description(
|
||||
"Send a global notification gump to all online clients, " + //
|
||||
"containing a message parsed from HTML, BBS or plain text, " + //
|
||||
"which auto-closes after 10 seconds.")]
|
||||
private static void HandleNotifyAC(CommandEventArgs e)
|
||||
{
|
||||
if (ValidateCommand(e))
|
||||
{
|
||||
Broadcast(e.Mobile, e.ArgString, true);
|
||||
}
|
||||
}
|
||||
|
||||
[Usage("NotifyNA <text | html | bbc>"), Description(
|
||||
"Send a global notification gump to all online clients, " + //
|
||||
"containing a message parsed from HTML, BBS or plain text, " + //
|
||||
"which has no animation delay.")]
|
||||
private static void HandleNotifyNA(CommandEventArgs e)
|
||||
{
|
||||
if (ValidateCommand(e))
|
||||
{
|
||||
Broadcast(e.Mobile, e.ArgString, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
[Usage("NotifyACNA <text | html | bbc>"), Description(
|
||||
"Send a global notification gump to all online clients, " + //
|
||||
"containing a message parsed from HTML, BBS or plain text, " + //
|
||||
"which auto-closes after 10 seconds and has no animation delay.")]
|
||||
private static void HandleNotifyACNA(CommandEventArgs e)
|
||||
{
|
||||
if (ValidateCommand(e))
|
||||
{
|
||||
Broadcast(e.Mobile, e.ArgString, true, false);
|
||||
}
|
||||
}
|
||||
|
||||
private static bool ValidateCommand(CommandEventArgs e)
|
||||
{
|
||||
if (e == null || e.Mobile == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (String.IsNullOrWhiteSpace(e.ArgString) ||
|
||||
String.IsNullOrWhiteSpace(Regex.Replace(e.ArgString, @"<[^>]*>", String.Empty)))
|
||||
{
|
||||
e.Mobile.SendMessage(0x22, "Html/BBC message must be at least 1 character and not all white-space after parsing.");
|
||||
e.Mobile.SendMessage(0x22, "Usage: {0}{1} <text | html | bbc>", CommandSystem.Prefix, e.Command);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static NotifySettings EnsureSettings<TGump>()
|
||||
where TGump : NotifyGump
|
||||
{
|
||||
return EnsureSettings(typeof(TGump));
|
||||
}
|
||||
|
||||
public static NotifySettings EnsureSettings(Type t)
|
||||
{
|
||||
if (t == null || !t.IsEqualOrChildOf<NotifyGump>())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (SettingsMap.TryGetValue(t, out var st) && st != null)
|
||||
{
|
||||
var o = Settings.GetValue(st);
|
||||
|
||||
if (o != null)
|
||||
{
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
const BindingFlags f = BindingFlags.DeclaredOnly | BindingFlags.Static | BindingFlags.NonPublic;
|
||||
|
||||
var m = t.GetMethod("InitSettings", f);
|
||||
|
||||
if (m == null)
|
||||
{
|
||||
foreach (var p in t.EnumerateHierarchy())
|
||||
{
|
||||
m = p.GetMethod("InitSettings", f);
|
||||
|
||||
if (m != null)
|
||||
{
|
||||
st = p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (st == null)
|
||||
{
|
||||
st = t;
|
||||
}
|
||||
|
||||
var init = false;
|
||||
|
||||
if (!Settings.TryGetValue(st, out var settings) || settings == null)
|
||||
{
|
||||
Settings[st] = settings = new NotifySettings(st);
|
||||
init = true;
|
||||
}
|
||||
|
||||
SettingsMap[t] = st;
|
||||
|
||||
if (init && m != null)
|
||||
{
|
||||
m.Invoke(null, new object[] { settings });
|
||||
}
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
public static bool IsAutoClose<TGump>(Mobile pm)
|
||||
where TGump : NotifyGump
|
||||
{
|
||||
return IsAutoClose(typeof(TGump), pm);
|
||||
}
|
||||
|
||||
public static bool IsAutoClose(Type t, Mobile pm)
|
||||
{
|
||||
var settings = EnsureSettings(t);
|
||||
|
||||
return settings != null && settings.IsAutoClose(pm);
|
||||
}
|
||||
|
||||
public static bool IsIgnored<TGump>(Mobile pm)
|
||||
where TGump : NotifyGump
|
||||
{
|
||||
return IsIgnored(typeof(TGump), pm);
|
||||
}
|
||||
|
||||
public static bool IsIgnored(Type t, Mobile pm)
|
||||
{
|
||||
var settings = EnsureSettings(t);
|
||||
|
||||
return settings != null && settings.IsIgnored(pm);
|
||||
}
|
||||
|
||||
public static bool IsAnimated<TGump>(Mobile pm)
|
||||
where TGump : NotifyGump
|
||||
{
|
||||
return IsAnimated(typeof(TGump), pm);
|
||||
}
|
||||
|
||||
public static bool IsAnimated(Type t, Mobile pm)
|
||||
{
|
||||
var settings = EnsureSettings(t);
|
||||
|
||||
return settings == null || settings.IsAnimated(pm);
|
||||
}
|
||||
|
||||
public static bool IsTextOnly<TGump>(Mobile pm)
|
||||
where TGump : NotifyGump
|
||||
{
|
||||
return IsTextOnly(typeof(TGump), pm);
|
||||
}
|
||||
|
||||
public static bool IsTextOnly(Type t, Mobile pm)
|
||||
{
|
||||
var settings = EnsureSettings(t);
|
||||
|
||||
return settings != null && settings.IsTextOnly(pm);
|
||||
}
|
||||
|
||||
public static void AlterTime<TGump>(Mobile pm, ref double value)
|
||||
where TGump : NotifyGump
|
||||
{
|
||||
AlterTime(typeof(TGump), pm, ref value);
|
||||
}
|
||||
|
||||
public static void AlterTime(Type t, Mobile pm, ref double value)
|
||||
{
|
||||
var settings = EnsureSettings(t);
|
||||
|
||||
if (settings != null)
|
||||
{
|
||||
settings.AlterTime(pm, ref value);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Broadcast(
|
||||
Mobile m,
|
||||
string message,
|
||||
bool autoClose = false,
|
||||
bool animate = true,
|
||||
AccessLevel level = AccessLevel.Player)
|
||||
{
|
||||
if (m != null && !m.Deleted)
|
||||
{
|
||||
message = String.Format("[{0}] {1}:\n{2}", DateTime.Now.ToSimpleString("t@h:m@"), m.RawName, message);
|
||||
}
|
||||
|
||||
Broadcast(message, autoClose, animate ? 1.0 : 0.0, 10.0, null, null, null, level);
|
||||
}
|
||||
|
||||
public static void Broadcast(
|
||||
string html,
|
||||
bool autoClose = true,
|
||||
double delay = 1.0,
|
||||
double pause = 5.0,
|
||||
Color? color = null,
|
||||
Action<WorldNotifyGump> beforeSend = null,
|
||||
Action<WorldNotifyGump> afterSend = null,
|
||||
AccessLevel level = AccessLevel.Player)
|
||||
{
|
||||
Broadcast<WorldNotifyGump>(html, autoClose, delay, pause, color, beforeSend, afterSend, level);
|
||||
}
|
||||
|
||||
public static void Broadcast<TGump>(
|
||||
string html,
|
||||
bool autoClose = true,
|
||||
double delay = 1.0,
|
||||
double pause = 5.0,
|
||||
Color? color = null,
|
||||
Action<TGump> beforeSend = null,
|
||||
Action<TGump> afterSend = null,
|
||||
AccessLevel level = AccessLevel.Player)
|
||||
where TGump : NotifyGump
|
||||
{
|
||||
var c = NetState.Instances.Count;
|
||||
|
||||
while (--c >= 0)
|
||||
{
|
||||
if (!NetState.Instances.InBounds(c))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var ns = NetState.Instances[c];
|
||||
|
||||
if (ns != null && ns.Running && ns.Mobile != null && ns.Mobile.AccessLevel >= level)
|
||||
{
|
||||
VitaNexCore.TryCatch(
|
||||
m => Send(false, m, html, autoClose, delay, pause, color, beforeSend, afterSend, level),
|
||||
ns.Mobile);
|
||||
}
|
||||
}
|
||||
|
||||
if (level < AccessLevel.Counselor && OnBroadcast != null)
|
||||
{
|
||||
OnBroadcast(html.ParseBBCode());
|
||||
}
|
||||
}
|
||||
|
||||
public static void Send(
|
||||
Mobile m,
|
||||
string html,
|
||||
bool autoClose = true,
|
||||
double delay = 1.0,
|
||||
double pause = 3.0,
|
||||
Color? color = null,
|
||||
Action<NotifyGump> beforeSend = null,
|
||||
Action<NotifyGump> afterSend = null,
|
||||
AccessLevel level = AccessLevel.Player)
|
||||
{
|
||||
Send(true, m, html, autoClose, delay, pause, color, beforeSend, afterSend, level);
|
||||
}
|
||||
|
||||
public static void Send<TGump>(
|
||||
Mobile m,
|
||||
string html,
|
||||
bool autoClose = true,
|
||||
double delay = 1.0,
|
||||
double pause = 3.0,
|
||||
Color? color = null,
|
||||
Action<TGump> beforeSend = null,
|
||||
Action<TGump> afterSend = null,
|
||||
AccessLevel level = AccessLevel.Player)
|
||||
where TGump : NotifyGump
|
||||
{
|
||||
Send(true, m, html, autoClose, delay, pause, color, beforeSend, afterSend, level);
|
||||
}
|
||||
|
||||
private static void Send<TGump>(
|
||||
bool local,
|
||||
Mobile m,
|
||||
string html,
|
||||
bool autoClose = true,
|
||||
double delay = 1.0,
|
||||
double pause = 3.0,
|
||||
Color? color = null,
|
||||
Action<TGump> beforeSend = null,
|
||||
Action<TGump> afterSend = null,
|
||||
AccessLevel level = AccessLevel.Player)
|
||||
where TGump : NotifyGump
|
||||
{
|
||||
if (!m.IsOnline() || m.AccessLevel < level)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var t = typeof(TGump);
|
||||
|
||||
if (t.IsAbstract || m.HasGump(t))
|
||||
{
|
||||
if (!NestedTypes.TryGetValue(t, out var subs) || subs == null)
|
||||
{
|
||||
NestedTypes[t] = subs = t.GetNestedTypes(BindingFlags.Public | BindingFlags.NonPublic) //
|
||||
.Where(st => st.IsChildOf<NotifyGump>())
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
var sub = subs.FirstOrDefault(st => !m.HasGump(st));
|
||||
|
||||
if (sub != null)
|
||||
{
|
||||
t = sub;
|
||||
}
|
||||
}
|
||||
|
||||
if (IsIgnored(t, m))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!t.IsAbstract && !IsTextOnly(t, m))
|
||||
{
|
||||
if (!autoClose && IsAutoClose(t, m))
|
||||
{
|
||||
autoClose = true;
|
||||
}
|
||||
|
||||
if (delay > 0.0 && !IsAnimated(t, m))
|
||||
{
|
||||
delay = 0.0;
|
||||
}
|
||||
|
||||
if (delay > 0.0)
|
||||
{
|
||||
AlterTime(t, m, ref delay);
|
||||
}
|
||||
|
||||
if (pause > 3.0)
|
||||
{
|
||||
AlterTime(t, m, ref pause);
|
||||
|
||||
pause = Math.Max(3.0, pause);
|
||||
}
|
||||
|
||||
var ng = t.CreateInstanceSafe<TGump>(m, html);
|
||||
|
||||
if (ng != null)
|
||||
{
|
||||
ng.AutoClose = autoClose;
|
||||
ng.AnimDuration = TimeSpan.FromSeconds(Math.Max(0, delay));
|
||||
ng.PauseDuration = TimeSpan.FromSeconds(Math.Max(0, pause));
|
||||
ng.HtmlColor = color ?? Color.White;
|
||||
|
||||
if (ng.IsDisposed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (local && OnLocalMessage != null)
|
||||
{
|
||||
OnLocalMessage(ng);
|
||||
}
|
||||
else if (!local && OnGlobalMessage != null)
|
||||
{
|
||||
OnGlobalMessage(ng);
|
||||
}
|
||||
|
||||
if (beforeSend != null)
|
||||
{
|
||||
beforeSend(ng);
|
||||
}
|
||||
|
||||
if (ng.IsDisposed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ng.Send();
|
||||
|
||||
if (ng.IsDisposed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (afterSend != null)
|
||||
{
|
||||
afterSend(ng);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
html = html.StripHtmlBreaks(true);
|
||||
html = html.Replace("\n", " ");
|
||||
html = html.StripHtml(false);
|
||||
html = html.StripTabs();
|
||||
html = html.StripCRLF();
|
||||
|
||||
m.SendMessage(html);
|
||||
}
|
||||
}
|
||||
}
|
||||
114
Scripts/SubSystem/VitaNex/Core/Services/Notify/Notify_Init.cs
Normal file
114
Scripts/SubSystem/VitaNex/Core/Services/Notify/Notify_Init.cs
Normal file
@@ -0,0 +1,114 @@
|
||||
#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 VitaNex.IO;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.Notify
|
||||
{
|
||||
[CoreService("Notify", "3.0.0.0", TaskPriority.Highest)]
|
||||
public static partial class Notify
|
||||
{
|
||||
static Notify()
|
||||
{
|
||||
CSOptions = new CoreServiceOptions(typeof(Notify));
|
||||
|
||||
GumpTypes = typeof(NotifyGump).GetChildren(t => !t.IsNested);
|
||||
|
||||
NestedTypes = new Dictionary<Type, Type[]>();
|
||||
|
||||
SettingsMap = new Dictionary<Type, Type>();
|
||||
|
||||
Settings = new BinaryDataStore<Type, NotifySettings>(VitaNexCore.SavesDirectory + "/Notify", "Settings")
|
||||
{
|
||||
Async = true,
|
||||
OnSerialize = Serialize,
|
||||
OnDeserialize = Deserialize
|
||||
};
|
||||
}
|
||||
|
||||
private static void CSConfig()
|
||||
{
|
||||
foreach (var t in GumpTypes)
|
||||
{
|
||||
EnsureSettings(t);
|
||||
}
|
||||
}
|
||||
|
||||
private static void CSInvoke()
|
||||
{
|
||||
CommandUtility.Register("Notify", AccessLevel.Player, HandleNotify);
|
||||
CommandUtility.Register("NotifyAC", AccessLevel.Seer, HandleNotifyAC);
|
||||
CommandUtility.Register("NotifyNA", AccessLevel.Seer, HandleNotifyNA);
|
||||
CommandUtility.Register("NotifyACNA", AccessLevel.Seer, HandleNotifyACNA);
|
||||
}
|
||||
|
||||
private static void CSLoad()
|
||||
{
|
||||
Settings.Import();
|
||||
|
||||
Settings.RemoveRange(o => !GumpTypes.Contains(o.Key) || o.Value == null);
|
||||
}
|
||||
|
||||
private static void CSSave()
|
||||
{
|
||||
Settings.Export();
|
||||
}
|
||||
|
||||
private static bool Serialize(GenericWriter writer)
|
||||
{
|
||||
writer.SetVersion(0);
|
||||
|
||||
writer.WriteBlockDictionary(
|
||||
Settings,
|
||||
(w, k, v) =>
|
||||
{
|
||||
w.WriteType(k);
|
||||
v.Serialize(w);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool Deserialize(GenericReader reader)
|
||||
{
|
||||
reader.GetVersion();
|
||||
|
||||
reader.ReadBlockDictionary(
|
||||
r =>
|
||||
{
|
||||
var k = r.ReadType();
|
||||
var v = EnsureSettings(k);
|
||||
|
||||
if (v != null)
|
||||
{
|
||||
v.Deserialize(r);
|
||||
|
||||
if (v.Type == null)
|
||||
{
|
||||
v.Type = k;
|
||||
}
|
||||
}
|
||||
|
||||
return new KeyValuePair<Type, NotifySettings>(k, v);
|
||||
},
|
||||
Settings);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#region References
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.Notify
|
||||
{
|
||||
[Flags]
|
||||
public enum NotifyFlags : ulong
|
||||
{
|
||||
None = 0x0,
|
||||
|
||||
AutoClose = 0x1,
|
||||
Ignore = 0x2,
|
||||
TextOnly = 0x4,
|
||||
Animate = 0x8
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
#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.Accounting;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.Notify
|
||||
{
|
||||
public sealed class NotifySettings : PropertyObject
|
||||
{
|
||||
public Dictionary<IAccount, NotifySettingsState> States { get; private set; }
|
||||
|
||||
[CommandProperty(Notify.Access)]
|
||||
public Dictionary<IAccount, NotifySettingsState>.KeyCollection Keys
|
||||
{
|
||||
get => States.Keys;
|
||||
private set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException("value");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(Notify.Access)]
|
||||
public Dictionary<IAccount, NotifySettingsState>.ValueCollection Values
|
||||
{
|
||||
get => States.Values;
|
||||
private set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException("value");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(Notify.Access, true)]
|
||||
public Type Type { get; set; }
|
||||
|
||||
[CommandProperty(Notify.Access)]
|
||||
public string Name { get; set; }
|
||||
|
||||
[CommandProperty(Notify.Access)]
|
||||
public string Desc { get; set; }
|
||||
|
||||
[CommandProperty(Notify.Access)]
|
||||
public AccessLevel Access { get; set; }
|
||||
|
||||
[CommandProperty(Notify.Access)]
|
||||
public bool CanIgnore { get; set; }
|
||||
|
||||
[CommandProperty(Notify.Access)]
|
||||
public bool CanAutoClose { get; set; }
|
||||
|
||||
public NotifySettings(Type t)
|
||||
{
|
||||
Type = t;
|
||||
Name = t.Name;
|
||||
|
||||
Desc = String.Empty;
|
||||
Access = AccessLevel.Player;
|
||||
|
||||
CanIgnore = true;
|
||||
CanAutoClose = true;
|
||||
|
||||
States = new Dictionary<IAccount, NotifySettingsState>();
|
||||
}
|
||||
|
||||
public NotifySettings(GenericReader reader)
|
||||
: base(reader)
|
||||
{ }
|
||||
|
||||
public override void Clear()
|
||||
{
|
||||
States.Clear();
|
||||
}
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
States.Clear();
|
||||
}
|
||||
|
||||
public bool IsAutoClose(Mobile m)
|
||||
{
|
||||
return CanAutoClose && m != null && m.Account != null && States.ContainsKey(m.Account) && States[m.Account].AutoClose;
|
||||
}
|
||||
|
||||
public bool IsIgnored(Mobile m)
|
||||
{
|
||||
return CanIgnore && m != null && m.Account != null && States.ContainsKey(m.Account) && States[m.Account].Ignore;
|
||||
}
|
||||
|
||||
public bool IsTextOnly(Mobile m)
|
||||
{
|
||||
return m != null && m.Account != null && States.ContainsKey(m.Account) && States[m.Account].TextOnly;
|
||||
}
|
||||
|
||||
public bool IsAnimated(Mobile m)
|
||||
{
|
||||
return m == null || m.Account == null || !States.ContainsKey(m.Account) || States[m.Account].Animate;
|
||||
}
|
||||
|
||||
public void AlterTime(Mobile m, ref double value)
|
||||
{
|
||||
if (m == null || m.Account == null || !States.ContainsKey(m.Account) || value <= 0.0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var speed = Math.Max(0, Math.Min(200, (int)States[m.Account].Speed));
|
||||
|
||||
if (speed > 100)
|
||||
{
|
||||
value -= value * ((speed - 100) / 100.0);
|
||||
}
|
||||
else if (speed < 100)
|
||||
{
|
||||
value += value * ((100 - speed) / 100.0);
|
||||
}
|
||||
}
|
||||
|
||||
public NotifySettingsState EnsureState(IAccount a)
|
||||
{
|
||||
var s = States.GetValue(a);
|
||||
|
||||
if (s == null || s.Settings != this)
|
||||
{
|
||||
States[a] = s = new NotifySettingsState(this, a);
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
var name = Name.Replace("Notify", String.Empty).Replace("Gump", String.Empty);
|
||||
|
||||
if (String.IsNullOrWhiteSpace(name))
|
||||
{
|
||||
name = "Notifications";
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.SetVersion(0);
|
||||
|
||||
writer.WriteType(Type);
|
||||
writer.Write(Name);
|
||||
writer.Write(Desc);
|
||||
|
||||
writer.Write(CanIgnore);
|
||||
writer.Write(CanAutoClose);
|
||||
|
||||
writer.WriteBlockDictionary(States, (w, k, v) => v.Serialize(w));
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
reader.GetVersion();
|
||||
|
||||
Type = reader.ReadType();
|
||||
Name = reader.ReadString();
|
||||
Desc = reader.ReadString();
|
||||
|
||||
CanIgnore = reader.ReadBool();
|
||||
CanAutoClose = reader.ReadBool();
|
||||
|
||||
States = reader.ReadBlockDictionary(
|
||||
r =>
|
||||
{
|
||||
var state = new NotifySettingsState(this, r);
|
||||
|
||||
return new KeyValuePair<IAccount, NotifySettingsState>(state.Owner, state);
|
||||
},
|
||||
States);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#region References
|
||||
using Server;
|
||||
using Server.Accounting;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.Notify
|
||||
{
|
||||
public sealed class NotifySettingsState : SettingsObject<NotifyFlags>
|
||||
{
|
||||
[CommandProperty(Notify.Access)]
|
||||
public NotifySettings Settings { get; private set; }
|
||||
|
||||
[CommandProperty(Notify.Access, true)]
|
||||
public IAccount Owner { get; private set; }
|
||||
|
||||
[CommandProperty(Notify.Access)]
|
||||
public override NotifyFlags Flags { get => base.Flags; set => base.Flags = value; }
|
||||
|
||||
[CommandProperty(Notify.Access)]
|
||||
public bool AutoClose
|
||||
{
|
||||
get => GetFlag(NotifyFlags.AutoClose);
|
||||
set => SetFlag(NotifyFlags.AutoClose, value);
|
||||
}
|
||||
|
||||
[CommandProperty(Notify.Access)]
|
||||
public bool Ignore { get => GetFlag(NotifyFlags.Ignore); set => SetFlag(NotifyFlags.Ignore, value); }
|
||||
|
||||
[CommandProperty(Notify.Access)]
|
||||
public bool TextOnly { get => GetFlag(NotifyFlags.TextOnly); set => SetFlag(NotifyFlags.TextOnly, value); }
|
||||
|
||||
[CommandProperty(Notify.Access)]
|
||||
public bool Animate { get => GetFlag(NotifyFlags.Animate); set => SetFlag(NotifyFlags.Animate, value); }
|
||||
|
||||
[CommandProperty(Notify.Access)]
|
||||
public byte Speed { get; set; }
|
||||
|
||||
public NotifySettingsState(NotifySettings settings, IAccount owner)
|
||||
{
|
||||
Settings = settings;
|
||||
Owner = owner;
|
||||
|
||||
SetDefaults();
|
||||
}
|
||||
|
||||
public NotifySettingsState(NotifySettings settings, GenericReader reader)
|
||||
: base(reader)
|
||||
{
|
||||
Settings = settings;
|
||||
}
|
||||
|
||||
public override void Clear()
|
||||
{
|
||||
SetDefaults();
|
||||
}
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
SetDefaults();
|
||||
}
|
||||
|
||||
public void SetDefaults()
|
||||
{
|
||||
AutoClose = false;
|
||||
Ignore = false;
|
||||
TextOnly = false;
|
||||
Animate = true;
|
||||
|
||||
Speed = 100;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
if (Owner != null)
|
||||
{
|
||||
if (Settings != null)
|
||||
{
|
||||
return Owner + ": " + Settings;
|
||||
}
|
||||
|
||||
return Owner.ToString();
|
||||
}
|
||||
|
||||
if (Settings != null)
|
||||
{
|
||||
return Settings.ToString();
|
||||
}
|
||||
|
||||
return base.ToString();
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.SetVersion(0);
|
||||
|
||||
writer.Write(Owner);
|
||||
|
||||
writer.Write(Speed);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
reader.GetVersion();
|
||||
|
||||
Owner = reader.ReadAccount();
|
||||
|
||||
Speed = reader.ReadByte();
|
||||
}
|
||||
}
|
||||
}
|
||||
551
Scripts/SubSystem/VitaNex/Core/Services/Notify/UI/NotifyGump.cs
Normal file
551
Scripts/SubSystem/VitaNex/Core/Services/Notify/UI/NotifyGump.cs
Normal file
@@ -0,0 +1,551 @@
|
||||
#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.Linq;
|
||||
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
|
||||
using VitaNex.SuperGumps;
|
||||
using VitaNex.Text;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.Notify
|
||||
{
|
||||
public abstract class NotifyGump : SuperGump
|
||||
{
|
||||
private static void InitSettings(NotifySettings o)
|
||||
{
|
||||
o.Name = "Misc Notifications";
|
||||
o.Desc = "Any notifications that do not fall into a more specific category.";
|
||||
}
|
||||
|
||||
public static event Action<NotifyGump> OnNotify;
|
||||
|
||||
public static TimeSpan DefaultAnimDuration = TimeSpan.FromMilliseconds(500.0);
|
||||
public static TimeSpan DefaultPauseDuration = TimeSpan.FromSeconds(5.0);
|
||||
|
||||
public static Size SizeMin = new Size(100, 60);
|
||||
public static Size SizeMax = new Size(400, 200);
|
||||
|
||||
public enum AnimState
|
||||
{
|
||||
Show,
|
||||
Hide,
|
||||
Pause
|
||||
}
|
||||
|
||||
public TimeSpan AnimDuration { get; set; }
|
||||
public TimeSpan PauseDuration { get; set; }
|
||||
|
||||
public string Html { get; set; }
|
||||
public Color HtmlColor { get; set; }
|
||||
public int HtmlIndent { get; set; }
|
||||
|
||||
public int BorderID { get; set; }
|
||||
public int BorderSize { get; set; }
|
||||
public bool BorderAlpha { get; set; }
|
||||
|
||||
public int BackgroundID { get; set; }
|
||||
public bool BackgroundAlpha { get; set; }
|
||||
|
||||
public int WidthMax { get; set; }
|
||||
public int HeightMax { get; set; }
|
||||
|
||||
public bool AutoClose { get; set; }
|
||||
|
||||
public int Frame { get; private set; }
|
||||
public AnimState State { get; private set; }
|
||||
|
||||
public int FrameCount => (int)Math.Ceiling(Math.Max(100.0, AnimDuration.TotalMilliseconds) / 100.0);
|
||||
public int FrameHeight { get; private set; }
|
||||
public int FrameWidth { get; private set; }
|
||||
|
||||
public Size HtmlSize { get; private set; }
|
||||
public Size OptionsSize { get; private set; }
|
||||
|
||||
public List<NotifyGumpOption> Options { get; private set; }
|
||||
|
||||
public int OptionsCols { get; private set; }
|
||||
public int OptionsRows { get; private set; }
|
||||
|
||||
public override bool InitPolling => true;
|
||||
|
||||
public NotifyGump(Mobile user, string html)
|
||||
: this(user, html, null)
|
||||
{ }
|
||||
|
||||
public NotifyGump(Mobile user, string html, IEnumerable<NotifyGumpOption> options)
|
||||
: base(user, null, 0, 140)
|
||||
{
|
||||
Options = options.Ensure().ToList();
|
||||
|
||||
AnimDuration = DefaultAnimDuration;
|
||||
PauseDuration = DefaultPauseDuration;
|
||||
|
||||
Html = html ?? String.Empty;
|
||||
HtmlColor = Color.White;
|
||||
HtmlIndent = 10;
|
||||
|
||||
BorderSize = 4;
|
||||
BorderID = 9204;
|
||||
BorderAlpha = false;
|
||||
|
||||
BackgroundID = 2624;
|
||||
BackgroundAlpha = true;
|
||||
|
||||
AutoClose = true;
|
||||
|
||||
Frame = 0;
|
||||
State = AnimState.Pause;
|
||||
|
||||
CanMove = false;
|
||||
CanResize = false;
|
||||
|
||||
CloseSound = -1;
|
||||
|
||||
ForceRecompile = true;
|
||||
AutoRefreshRate = TimeSpan.FromMilliseconds(100.0);
|
||||
AutoRefresh = true;
|
||||
|
||||
WidthMax = 250;
|
||||
HeightMax = 100;
|
||||
|
||||
InitOptions();
|
||||
}
|
||||
|
||||
protected virtual void InitOptions()
|
||||
{ }
|
||||
|
||||
public void AddOption(TextDefinition label, Action<GumpButton> callback)
|
||||
{
|
||||
AddOption(label, callback, Color.Empty);
|
||||
}
|
||||
|
||||
public void AddOption(TextDefinition label, Action<GumpButton> callback, Color color)
|
||||
{
|
||||
AddOption(label, callback, color, Color.Empty);
|
||||
}
|
||||
|
||||
public void AddOption(TextDefinition label, Action<GumpButton> callback, Color color, Color fill)
|
||||
{
|
||||
AddOption(label, callback, color, fill, Color.Empty);
|
||||
}
|
||||
|
||||
public void AddOption(TextDefinition label, Action<GumpButton> callback, Color color, Color fill, Color border)
|
||||
{
|
||||
if (color.IsEmpty)
|
||||
{
|
||||
color = HtmlColor;
|
||||
}
|
||||
|
||||
var opt = Options.Find(o => o.Label.Equals(label));
|
||||
|
||||
if (opt != null)
|
||||
{
|
||||
opt.Callback = callback;
|
||||
opt.LabelColor = color;
|
||||
opt.FillColor = fill;
|
||||
opt.BorderColor = border;
|
||||
}
|
||||
else
|
||||
{
|
||||
Options.Add(new NotifyGumpOption(label, callback, color, fill, border));
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual Size GetSizeMin()
|
||||
{
|
||||
return SizeMin;
|
||||
}
|
||||
|
||||
protected virtual Size GetSizeMax()
|
||||
{
|
||||
return SizeMax;
|
||||
}
|
||||
|
||||
protected override void Compile()
|
||||
{
|
||||
base.Compile();
|
||||
|
||||
var sMin = GetSizeMin();
|
||||
var sMax = GetSizeMax();
|
||||
|
||||
WidthMax = Math.Max(sMin.Width, Math.Min(sMax.Width, WidthMax));
|
||||
HeightMax = Math.Max(sMin.Height, Math.Min(sMax.Height, HeightMax));
|
||||
|
||||
HtmlIndent = Math.Max(0, HtmlIndent);
|
||||
BorderSize = Math.Max(0, BorderSize);
|
||||
|
||||
var wm = WidthMax - (BorderSize * 2);
|
||||
|
||||
var text = Html.ParseBBCode(HtmlColor).StripHtmlBreaks(true).StripHtml();
|
||||
|
||||
var font = UOFont.Unicode[1];
|
||||
|
||||
var s = font.GetSize(text);
|
||||
|
||||
s.Width += 4;
|
||||
s.Height += 4;
|
||||
|
||||
if (s.Width > wm)
|
||||
{
|
||||
s.Height += (int)Math.Ceiling((s.Width - wm) / (double)wm) * (font.LineHeight + font.LineSpacing);
|
||||
s.Width = wm;
|
||||
}
|
||||
|
||||
if (!Initialized)
|
||||
{
|
||||
s.Height = Math.Max(sMin.Height, Math.Min(HeightMax, Math.Min(sMax.Height, s.Height)));
|
||||
}
|
||||
else
|
||||
{
|
||||
s.Height = Math.Max(sMin.Height, Math.Min(sMax.Height, Math.Min(sMax.Height, s.Height)));
|
||||
}
|
||||
|
||||
HtmlSize = s;
|
||||
|
||||
if (Options.Count > 1)
|
||||
{
|
||||
OptionsCols = wm / Math.Max(30, Math.Min(wm, Options.Max(o => o.Width)));
|
||||
OptionsRows = (int)Math.Ceiling(Options.Count / (double)OptionsCols);
|
||||
}
|
||||
else if (Options.Count > 0)
|
||||
{
|
||||
OptionsCols = OptionsRows = 1;
|
||||
}
|
||||
|
||||
s.Width = wm;
|
||||
s.Height = (OptionsRows * 20) + 4;
|
||||
|
||||
OptionsSize = s;
|
||||
|
||||
HeightMax = (BorderSize * 2) + HtmlSize.Height + OptionsSize.Height;
|
||||
|
||||
var f = Frame / (double)FrameCount;
|
||||
|
||||
FrameWidth = (int)Math.Ceiling(WidthMax * f);
|
||||
FrameHeight = (int)Math.Ceiling(HeightMax * f);
|
||||
}
|
||||
|
||||
protected override void CompileLayout(SuperGumpLayout layout)
|
||||
{
|
||||
base.CompileLayout(layout);
|
||||
|
||||
layout.Add(
|
||||
"frame",
|
||||
() =>
|
||||
{
|
||||
if (BorderSize > 0 && BorderID >= 0)
|
||||
{
|
||||
AddImageTiled(0, 0, FrameWidth, FrameHeight, BorderID);
|
||||
|
||||
if (BorderAlpha)
|
||||
{
|
||||
AddAlphaRegion(0, 0, FrameWidth, FrameHeight);
|
||||
}
|
||||
}
|
||||
|
||||
var fw = FrameWidth - (BorderSize * 2);
|
||||
var fh = FrameHeight - (BorderSize * 2);
|
||||
|
||||
if (fw * fh > 0 && BackgroundID > 0)
|
||||
{
|
||||
AddImageTiled(BorderSize, BorderSize, fw, fh, BackgroundID);
|
||||
|
||||
if (BackgroundAlpha)
|
||||
{
|
||||
AddAlphaRegion(BorderSize, BorderSize, fw, fh);
|
||||
}
|
||||
}
|
||||
|
||||
if (Frame < FrameCount)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AddButton(FrameWidth - BorderSize, (FrameHeight / 2) - 8, 22153, 22155, OnSettings);
|
||||
|
||||
var x = BorderSize + 2 + HtmlIndent;
|
||||
var y = BorderSize + 2;
|
||||
var w = fw - (4 + HtmlIndent);
|
||||
var h = fh - (4 + OptionsSize.Height);
|
||||
|
||||
var html = Html.ParseBBCode(HtmlColor).WrapUOHtmlColor(HtmlColor, false);
|
||||
|
||||
AddHtml(x, y, w, h, html, false, (HtmlSize.Height - 4) > h);
|
||||
});
|
||||
|
||||
if (Frame >= FrameCount && Options.Count > 0)
|
||||
{
|
||||
var x = BorderSize + 2;
|
||||
var y = BorderSize + HtmlSize.Height + 2;
|
||||
var w = OptionsSize.Width - 4;
|
||||
var h = OptionsSize.Height - 4;
|
||||
|
||||
CompileOptionsLayout(layout, x, y, w, h, w / OptionsCols);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void CompileOptionsLayout(SuperGumpLayout layout, int x, int y, int w, int h, int bw)
|
||||
{
|
||||
if (Frame < FrameCount || Options.Count == 0 || OptionsCols * OptionsRows <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
layout.Add("opts", () => AddRectangle(x, y, w, h, Color.Black, true));
|
||||
|
||||
var oi = 0;
|
||||
var ox = x;
|
||||
var oy = y;
|
||||
|
||||
foreach (var ob in Options)
|
||||
{
|
||||
CompileOptionLayout(layout, oi, ox, oy, bw, 20, ob);
|
||||
|
||||
if (++oi % OptionsCols == 0)
|
||||
{
|
||||
ox = x;
|
||||
oy += 20;
|
||||
}
|
||||
else
|
||||
{
|
||||
ox += bw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void CompileOptionLayout(
|
||||
SuperGumpLayout layout,
|
||||
int index,
|
||||
int x,
|
||||
int y,
|
||||
int w,
|
||||
int h,
|
||||
NotifyGumpOption option)
|
||||
{
|
||||
layout.Add(
|
||||
"opts/" + index,
|
||||
() =>
|
||||
{
|
||||
AddHtmlButton(
|
||||
x,
|
||||
y,
|
||||
w,
|
||||
h,
|
||||
b =>
|
||||
{
|
||||
if (option.Callback != null)
|
||||
{
|
||||
option.Callback(b);
|
||||
}
|
||||
|
||||
Refresh();
|
||||
},
|
||||
option.GetString(User),
|
||||
option.LabelColor,
|
||||
option.FillColor,
|
||||
option.BorderColor,
|
||||
1);
|
||||
});
|
||||
}
|
||||
|
||||
protected virtual void OnSettings(GumpButton b)
|
||||
{
|
||||
Refresh();
|
||||
|
||||
new NotifySettingsGump(User).Send();
|
||||
}
|
||||
|
||||
protected override bool CanAutoRefresh()
|
||||
{
|
||||
return State == AnimState.Pause && Frame > 0 ? AutoClose && base.CanAutoRefresh() : base.CanAutoRefresh();
|
||||
}
|
||||
|
||||
protected override void OnAutoRefresh()
|
||||
{
|
||||
base.OnAutoRefresh();
|
||||
|
||||
AnimateList();
|
||||
|
||||
switch (State)
|
||||
{
|
||||
case AnimState.Show:
|
||||
{
|
||||
if (Frame++ >= FrameCount)
|
||||
{
|
||||
AutoRefreshRate = PauseDuration;
|
||||
State = AnimState.Pause;
|
||||
Frame = FrameCount;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case AnimState.Hide:
|
||||
{
|
||||
if (Frame-- <= 0)
|
||||
{
|
||||
AutoRefreshRate = TimeSpan.FromMilliseconds(100.0);
|
||||
State = AnimState.Pause;
|
||||
Frame = 0;
|
||||
Close(true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case AnimState.Pause:
|
||||
{
|
||||
AutoRefreshRate = TimeSpan.FromMilliseconds(100.0);
|
||||
State = Frame <= 0 ? AnimState.Show : AutoClose ? AnimState.Hide : AnimState.Pause;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool OnBeforeSend()
|
||||
{
|
||||
if (!Initialized)
|
||||
{
|
||||
if (Notify.IsIgnored(GetType(), User))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Notify.IsAnimated(GetType(), User))
|
||||
{
|
||||
AnimDuration = TimeSpan.Zero;
|
||||
}
|
||||
|
||||
if (OnNotify != null)
|
||||
{
|
||||
OnNotify(this);
|
||||
}
|
||||
}
|
||||
|
||||
return base.OnBeforeSend();
|
||||
}
|
||||
|
||||
public override void Close(bool all)
|
||||
{
|
||||
if (all)
|
||||
{
|
||||
base.Close(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
AutoRefreshRate = TimeSpan.FromMilliseconds(100.0);
|
||||
AutoClose = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void AnimateList()
|
||||
{
|
||||
VitaNexCore.TryCatch(
|
||||
() =>
|
||||
{
|
||||
var p = this;
|
||||
|
||||
foreach (var g in EnumerateInstances<NotifyGump>(User, true)
|
||||
.Where(g => g != this && g.IsOpen && !g.IsDisposed && g.Y >= p.Y)
|
||||
.OrderBy(g => g.Y))
|
||||
{
|
||||
g.Y = p.Y + p.FrameHeight;
|
||||
|
||||
p = g;
|
||||
|
||||
if (g.State != AnimState.Pause)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var lr = g.LastAutoRefresh;
|
||||
|
||||
g.Refresh(true);
|
||||
g.LastAutoRefresh = lr;
|
||||
}
|
||||
},
|
||||
e => e.ToConsole());
|
||||
}
|
||||
|
||||
private class Sub0 : NotifyGump
|
||||
{
|
||||
public Sub0(Mobile user, string html)
|
||||
: base(user, html)
|
||||
{ }
|
||||
}
|
||||
|
||||
private class Sub1 : NotifyGump
|
||||
{
|
||||
public Sub1(Mobile user, string html)
|
||||
: base(user, html)
|
||||
{ }
|
||||
}
|
||||
|
||||
private class Sub2 : NotifyGump
|
||||
{
|
||||
public Sub2(Mobile user, string html)
|
||||
: base(user, html)
|
||||
{ }
|
||||
}
|
||||
|
||||
private class Sub3 : NotifyGump
|
||||
{
|
||||
public Sub3(Mobile user, string html)
|
||||
: base(user, html)
|
||||
{ }
|
||||
}
|
||||
|
||||
private class Sub4 : NotifyGump
|
||||
{
|
||||
public Sub4(Mobile user, string html)
|
||||
: base(user, html)
|
||||
{ }
|
||||
}
|
||||
|
||||
private class Sub5 : NotifyGump
|
||||
{
|
||||
public Sub5(Mobile user, string html)
|
||||
: base(user, html)
|
||||
{ }
|
||||
}
|
||||
|
||||
private class Sub6 : NotifyGump
|
||||
{
|
||||
public Sub6(Mobile user, string html)
|
||||
: base(user, html)
|
||||
{ }
|
||||
}
|
||||
|
||||
private class Sub7 : NotifyGump
|
||||
{
|
||||
public Sub7(Mobile user, string html)
|
||||
: base(user, html)
|
||||
{ }
|
||||
}
|
||||
|
||||
private class Sub8 : NotifyGump
|
||||
{
|
||||
public Sub8(Mobile user, string html)
|
||||
: base(user, html)
|
||||
{ }
|
||||
}
|
||||
|
||||
private class Sub9 : NotifyGump
|
||||
{
|
||||
public Sub9(Mobile user, string html)
|
||||
: base(user, html)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.Drawing;
|
||||
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
|
||||
using VitaNex.Text;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.Notify
|
||||
{
|
||||
public class NotifyGumpOption
|
||||
{
|
||||
public char? Prefix { get; set; }
|
||||
|
||||
public TextDefinition Label { get; set; }
|
||||
public Action<GumpButton> Callback { get; set; }
|
||||
|
||||
public Color LabelColor { get; set; }
|
||||
public Color FillColor { get; set; }
|
||||
public Color BorderColor { get; set; }
|
||||
|
||||
public int Width => 10 + UOFont.GetUnicodeWidth(1, GetString());
|
||||
|
||||
public NotifyGumpOption(TextDefinition label, Action<GumpButton> callback)
|
||||
: this(label, callback, Color.Empty)
|
||||
{ }
|
||||
|
||||
public NotifyGumpOption(TextDefinition label, Action<GumpButton> callback, Color color)
|
||||
: this(label, callback, color, Color.Empty)
|
||||
{ }
|
||||
|
||||
public NotifyGumpOption(TextDefinition label, Action<GumpButton> callback, Color color, Color fill)
|
||||
: this(label, callback, color, fill, Color.Empty)
|
||||
{ }
|
||||
|
||||
public NotifyGumpOption(TextDefinition label, Action<GumpButton> callback, Color color, Color fill, Color border)
|
||||
{
|
||||
Prefix = UniGlyph.TriRightFill;
|
||||
|
||||
Label = label;
|
||||
Callback = callback;
|
||||
|
||||
LabelColor = color;
|
||||
FillColor = fill;
|
||||
BorderColor = border;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return GetString();
|
||||
}
|
||||
|
||||
public string GetString()
|
||||
{
|
||||
return GetString(null);
|
||||
}
|
||||
|
||||
public string GetString(Mobile viewer)
|
||||
{
|
||||
if (Prefix.HasValue)
|
||||
{
|
||||
return Prefix.Value + " " + Label.GetString(viewer);
|
||||
}
|
||||
|
||||
return Label.GetString(viewer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,600 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#region References
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
|
||||
using Server;
|
||||
using Server.Commands.Generic;
|
||||
using Server.Gumps;
|
||||
|
||||
using VitaNex.SuperGumps;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.Notify
|
||||
{
|
||||
public class NotifySettingsGump : SuperGumpList<NotifySettings>
|
||||
{
|
||||
public NotifySettingsGump(Mobile user)
|
||||
: base(user)
|
||||
{
|
||||
EntriesPerPage = 5;
|
||||
}
|
||||
|
||||
protected override void CompileList(List<NotifySettings> list)
|
||||
{
|
||||
list.Clear();
|
||||
list.AddRange(Notify.Settings.Values.Where(o => User.AccessLevel >= o.Access).OrderByNatural());
|
||||
|
||||
base.CompileList(list);
|
||||
}
|
||||
|
||||
protected override void CompileLayout(SuperGumpLayout layout)
|
||||
{
|
||||
base.CompileLayout(layout);
|
||||
|
||||
const int width = 400, height = 600;
|
||||
|
||||
var sup = SupportsUltimaStore;
|
||||
var pad = sup ? 15 : 10;
|
||||
var bgID = sup ? 40000 : 9270;
|
||||
|
||||
layout.Add("bg", () => AddBackground(0, 0, width, height, bgID));
|
||||
|
||||
layout.Add(
|
||||
"title",
|
||||
() =>
|
||||
{
|
||||
var title = "Notification Settings";
|
||||
|
||||
title = title.WrapUOHtmlBig();
|
||||
title = title.WrapUOHtmlCenter();
|
||||
title = title.WrapUOHtmlColor(Color.Gold, false);
|
||||
|
||||
AddHtml(pad, pad, width - (pad * 2), 40, title, false, false);
|
||||
});
|
||||
|
||||
layout.Add(
|
||||
"opts",
|
||||
() =>
|
||||
{
|
||||
var xx = pad;
|
||||
var yy = pad + 30;
|
||||
var ww = width - (pad * 2);
|
||||
var hh = height - ((pad * 2) + 60);
|
||||
|
||||
var r = GetListRange();
|
||||
var o = AddAccordion(xx, yy, ww, hh, r.Values, CompileEntryLayout);
|
||||
|
||||
if (o == null || o.Item1 == null)
|
||||
{
|
||||
if (o != null)
|
||||
{
|
||||
CompileEmptyLayout(xx, yy + o.Item2, ww, hh - o.Item2);
|
||||
}
|
||||
else
|
||||
{
|
||||
CompileEmptyLayout(xx, yy, ww, hh);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
layout.Add(
|
||||
"pages",
|
||||
() =>
|
||||
{
|
||||
var xx = pad;
|
||||
var yy = (height - 25) - pad;
|
||||
var ww = width - (pad * 2);
|
||||
|
||||
if (HasPrevPage)
|
||||
{
|
||||
if (sup)
|
||||
{
|
||||
AddButton(xx, yy, 40016, 40026, PreviousPage);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddButton(xx, yy, 9766, 9767, PreviousPage);
|
||||
}
|
||||
}
|
||||
|
||||
xx += 35;
|
||||
ww -= 70;
|
||||
|
||||
var page = String.Format("Page {0:#,0} / {1:#,0}", Page + 1, PageCount);
|
||||
|
||||
page = page.WrapUOHtmlCenter();
|
||||
page = page.WrapUOHtmlColor(Color.PaleGoldenrod, false);
|
||||
|
||||
AddHtml(xx, yy + 2, ww, 40, page, false, false);
|
||||
|
||||
xx += ww;
|
||||
|
||||
if (HasNextPage)
|
||||
{
|
||||
if (sup)
|
||||
{
|
||||
AddButton(xx, yy, 40017, 40027, NextPage);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddButton(xx, yy, 9762, 9763, NextPage);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected virtual void CompileEntryLayout(int x, int y, int w, int h, NotifySettings o)
|
||||
{
|
||||
var sup = SupportsUltimaStore;
|
||||
var pad = sup ? 15 : 10;
|
||||
var off = sup ? 35 : 10;
|
||||
var bgID = sup ? 40000 : 9270;
|
||||
var btnNormal = sup ? 40017 : 9762;
|
||||
var btnSelected = sup ? 40027 : 9763;
|
||||
var chkNormal = sup ? 40014 : 9722;
|
||||
var chkSelected = sup ? 40015 : 9723;
|
||||
|
||||
var s = o.EnsureState(User.Account);
|
||||
|
||||
string label;
|
||||
|
||||
if (User.AccessLevel >= Notify.Access)
|
||||
{
|
||||
AddButton(
|
||||
x,
|
||||
y,
|
||||
btnNormal,
|
||||
btnSelected,
|
||||
b =>
|
||||
{
|
||||
Refresh();
|
||||
|
||||
if (User.AccessLevel >= Notify.Access)
|
||||
{
|
||||
User.SendGump(new PropertiesGump(User, o));
|
||||
}
|
||||
});
|
||||
|
||||
label = Notify.Access.ToString().ToUpper();
|
||||
label = label.WrapUOHtmlBold();
|
||||
label = label.WrapUOHtmlColor(Color.PaleGoldenrod, false);
|
||||
|
||||
AddHtml(x + 35, y + 2, w - 35, 40, label, false, false);
|
||||
|
||||
y += 30;
|
||||
h -= 30;
|
||||
}
|
||||
|
||||
if (w * h <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (o.CanIgnore)
|
||||
{
|
||||
AddCheck(x, y, chkNormal, chkSelected, s.Ignore, (c, v) => s.Ignore = v);
|
||||
|
||||
label = "IGNORE";
|
||||
label = label.WrapUOHtmlBold();
|
||||
label = label.WrapUOHtmlColor(Color.PaleGoldenrod, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddImage(x, y, chkNormal, 900);
|
||||
|
||||
label = "IGNORE";
|
||||
label = label.WrapUOHtmlBold();
|
||||
label = label.WrapUOHtmlColor(Color.Gray, false);
|
||||
}
|
||||
|
||||
AddHtml(x + 30, y + 2, (w / 2) - 30, 40, label, false, false);
|
||||
|
||||
if (o.CanAutoClose)
|
||||
{
|
||||
AddCheck(x + (w / 2), y, chkNormal, chkSelected, s.AutoClose, (c, v) => s.AutoClose = v);
|
||||
|
||||
label = "AUTO CLOSE";
|
||||
label = label.WrapUOHtmlBold();
|
||||
label = label.WrapUOHtmlColor(Color.PaleGoldenrod, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddImage(x + (w / 2), y, chkNormal, 900);
|
||||
|
||||
label = "AUTO CLOSE";
|
||||
label = label.WrapUOHtmlBold();
|
||||
label = label.WrapUOHtmlColor(Color.Gray, false);
|
||||
}
|
||||
|
||||
AddHtml(x + (w / 2) + 30, y + 2, (w / 2) - 30, 40, label, false, false);
|
||||
|
||||
y += 30;
|
||||
h -= 30;
|
||||
|
||||
if (w * h <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AddCheck(x, y, chkNormal, chkSelected, s.Animate, (c, v) => s.Animate = v);
|
||||
|
||||
label = "ANIMATE";
|
||||
label = label.WrapUOHtmlBold();
|
||||
label = label.WrapUOHtmlColor(Color.PaleGoldenrod, false);
|
||||
|
||||
AddHtml(x + 30, y + 2, (w / 2) - 30, 40, label, false, false);
|
||||
|
||||
AddCheck(x + (w / 2), y, chkNormal, chkSelected, s.TextOnly, (c, v) => s.TextOnly = v);
|
||||
|
||||
label = "TEXT ONLY";
|
||||
label = label.WrapUOHtmlBold();
|
||||
label = label.WrapUOHtmlColor(Color.PaleGoldenrod, false);
|
||||
|
||||
AddHtml(x + (w / 2) + 30, y + 2, (w / 2) - 30, 40, label, false, false);
|
||||
|
||||
y += 30;
|
||||
h -= 30;
|
||||
|
||||
if (w * h <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var track = (w / 2) - 60;
|
||||
|
||||
AddScrollbarH(
|
||||
x,
|
||||
y + 4,
|
||||
200,
|
||||
s.Speed,
|
||||
p =>
|
||||
{
|
||||
s.Speed = (byte)Math.Max(0, s.Speed - 10);
|
||||
|
||||
Refresh(true);
|
||||
},
|
||||
n =>
|
||||
{
|
||||
s.Speed = (byte)Math.Min(200, s.Speed + 10);
|
||||
|
||||
Refresh(true);
|
||||
},
|
||||
new Rectangle(30, 0, track, 13),
|
||||
new Rectangle(0, 0, 28, 13),
|
||||
new Rectangle(track + 32, 0, 28, 13));
|
||||
|
||||
label = String.Format("{0}% SPEED", Math.Max((byte)1, s.Speed));
|
||||
label = label.WrapUOHtmlBold();
|
||||
label = label.WrapUOHtmlColor(Color.PaleGoldenrod, false);
|
||||
|
||||
AddHtml(x + track + 70, y + 2, w - (track + 60), 40, label, false, false);
|
||||
|
||||
y += 30;
|
||||
h -= 30;
|
||||
|
||||
if (w * h <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (String.IsNullOrWhiteSpace(o.Desc))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
x -= pad;
|
||||
w += pad * 2;
|
||||
|
||||
AddImage(x, y, bgID);
|
||||
AddImageTiled(x + off, y, w - (off * 2), off, bgID + 1);
|
||||
AddImage(x + off + (w - (off * 2)), y, bgID + 2);
|
||||
|
||||
x += pad;
|
||||
w -= pad * 2;
|
||||
y += pad;
|
||||
h -= pad;
|
||||
|
||||
label = "Description";
|
||||
label = label.WrapUOHtmlBig();
|
||||
label = label.WrapUOHtmlCenter();
|
||||
label = label.WrapUOHtmlColor(Color.Gold, false);
|
||||
|
||||
AddHtml(x, y, w, 40, label, false, false);
|
||||
|
||||
x += 5;
|
||||
w -= 5;
|
||||
y += 20;
|
||||
h -= 10;
|
||||
|
||||
if (w * h <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
label = o.Desc;
|
||||
label = label.WrapUOHtmlColor(Color.PaleGoldenrod, false);
|
||||
|
||||
AddHtml(x, y, w, h, label, false, true);
|
||||
}
|
||||
|
||||
protected virtual void CompileEmptyLayout(int x, int y, int w, int h)
|
||||
{
|
||||
var sup = SupportsUltimaStore;
|
||||
var pad = sup ? 15 : 10;
|
||||
var off = sup ? 35 : 10;
|
||||
var bgID = sup ? 40000 : 9270;
|
||||
var btnNormal = sup ? 40017 : 9762;
|
||||
var btnSelected = sup ? 40027 : 9763;
|
||||
var chkNormal = sup ? 40014 : 9722;
|
||||
var chkSelected = sup ? 40015 : 9723;
|
||||
|
||||
x -= pad;
|
||||
w += pad * 2;
|
||||
|
||||
AddImage(x, y, bgID);
|
||||
AddImageTiled(x + off, y, w - (off * 2), off, bgID + 1);
|
||||
AddImage(x + off + (w - (off * 2)), y, bgID + 2);
|
||||
|
||||
x += pad;
|
||||
w -= pad * 2;
|
||||
y += pad;
|
||||
h -= pad;
|
||||
|
||||
var label = "All Notifications";
|
||||
label = label.WrapUOHtmlBig();
|
||||
label = label.WrapUOHtmlCenter();
|
||||
label = label.WrapUOHtmlColor(Color.Gold, false);
|
||||
|
||||
AddHtml(x, y + 2, w, 40, label, false, false);
|
||||
|
||||
y += 30;
|
||||
h -= 30;
|
||||
|
||||
if (User.AccessLevel >= Notify.Access)
|
||||
{
|
||||
AddButton(
|
||||
x,
|
||||
y,
|
||||
btnNormal,
|
||||
btnSelected,
|
||||
b =>
|
||||
{
|
||||
Refresh();
|
||||
|
||||
if (User.AccessLevel >= Notify.Access)
|
||||
{
|
||||
var cols = new[] { "Object" };
|
||||
var list = new ArrayList(List);
|
||||
|
||||
User.SendGump(new InterfaceGump(User, cols, list, 0, null));
|
||||
}
|
||||
});
|
||||
|
||||
label = Notify.Access.ToString().ToUpper();
|
||||
label = label.WrapUOHtmlBold();
|
||||
label = label.WrapUOHtmlColor(Color.PaleGoldenrod, false);
|
||||
|
||||
AddHtml(x + 35, y + 2, w - 35, 40, label, false, false);
|
||||
|
||||
y += 30;
|
||||
h -= 30;
|
||||
}
|
||||
|
||||
if (w * h <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var states = List.Select(o => o.EnsureState(User.Account));
|
||||
|
||||
var vals = new int[5, 2];
|
||||
|
||||
foreach (var o in states)
|
||||
{
|
||||
if (o.Settings.CanIgnore)
|
||||
{
|
||||
if (o.Ignore)
|
||||
{
|
||||
++vals[0, 0];
|
||||
}
|
||||
else
|
||||
{
|
||||
++vals[0, 1];
|
||||
}
|
||||
}
|
||||
|
||||
if (o.Settings.CanAutoClose)
|
||||
{
|
||||
if (o.AutoClose)
|
||||
{
|
||||
++vals[1, 0];
|
||||
}
|
||||
else
|
||||
{
|
||||
++vals[1, 1];
|
||||
}
|
||||
}
|
||||
|
||||
if (o.Animate)
|
||||
{
|
||||
++vals[2, 0];
|
||||
}
|
||||
else
|
||||
{
|
||||
++vals[2, 1];
|
||||
}
|
||||
|
||||
if (o.TextOnly)
|
||||
{
|
||||
++vals[3, 0];
|
||||
}
|
||||
else
|
||||
{
|
||||
++vals[3, 1];
|
||||
}
|
||||
|
||||
vals[4, 0] += o.Speed;
|
||||
++vals[4, 1];
|
||||
}
|
||||
|
||||
var ignore = vals[0, 0] >= vals[0, 1];
|
||||
|
||||
AddButton(
|
||||
x,
|
||||
y,
|
||||
ignore ? chkSelected : chkNormal,
|
||||
ignore ? chkNormal : chkSelected,
|
||||
b =>
|
||||
{
|
||||
foreach (var s in List.Where(o => o.CanIgnore).Select(o => o.EnsureState(User.Account)))
|
||||
{
|
||||
s.Ignore = !ignore;
|
||||
}
|
||||
|
||||
Refresh(true);
|
||||
});
|
||||
|
||||
label = "IGNORE";
|
||||
label = label.WrapUOHtmlBold();
|
||||
label = label.WrapUOHtmlColor(Color.PaleGoldenrod, false);
|
||||
|
||||
AddHtml(x + 30, y + 2, (w / 2) - 30, 40, label, false, false);
|
||||
|
||||
var autoClose = vals[1, 0] >= vals[1, 1];
|
||||
|
||||
AddButton(
|
||||
x + (w / 2),
|
||||
y,
|
||||
autoClose ? chkSelected : chkNormal,
|
||||
autoClose ? chkNormal : chkSelected,
|
||||
b =>
|
||||
{
|
||||
foreach (var s in List.Where(o => o.CanAutoClose).Select(o => o.EnsureState(User.Account)))
|
||||
{
|
||||
s.AutoClose = !autoClose;
|
||||
}
|
||||
|
||||
Refresh(true);
|
||||
});
|
||||
|
||||
label = "AUTO CLOSE";
|
||||
label = label.WrapUOHtmlBold();
|
||||
label = label.WrapUOHtmlColor(Color.PaleGoldenrod, false);
|
||||
|
||||
AddHtml(x + (w / 2) + 30, y + 2, (w / 2) - 30, 40, label, false, false);
|
||||
|
||||
y += 30;
|
||||
h -= 30;
|
||||
|
||||
if (w * h <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var animate = vals[2, 0] >= vals[2, 1];
|
||||
|
||||
AddButton(
|
||||
x,
|
||||
y,
|
||||
animate ? chkSelected : chkNormal,
|
||||
animate ? chkNormal : chkSelected,
|
||||
b =>
|
||||
{
|
||||
foreach (var s in List.Select(o => o.EnsureState(User.Account)))
|
||||
{
|
||||
s.Animate = !animate;
|
||||
}
|
||||
|
||||
Refresh(true);
|
||||
});
|
||||
|
||||
label = "ANIMATE";
|
||||
label = label.WrapUOHtmlBold();
|
||||
label = label.WrapUOHtmlColor(Color.PaleGoldenrod, false);
|
||||
|
||||
AddHtml(x + 30, y + 2, (w / 2) - 30, 40, label, false, false);
|
||||
|
||||
var textOnly = vals[3, 0] >= vals[4, 1];
|
||||
|
||||
AddButton(
|
||||
x + (w / 2),
|
||||
y,
|
||||
textOnly ? chkSelected : chkNormal,
|
||||
textOnly ? chkNormal : chkSelected,
|
||||
b =>
|
||||
{
|
||||
foreach (var s in List.Select(o => o.EnsureState(User.Account)))
|
||||
{
|
||||
s.TextOnly = !textOnly;
|
||||
}
|
||||
|
||||
Refresh(true);
|
||||
});
|
||||
|
||||
label = "TEXT ONLY";
|
||||
label = label.WrapUOHtmlBold();
|
||||
label = label.WrapUOHtmlColor(Color.PaleGoldenrod, false);
|
||||
|
||||
AddHtml(x + (w / 2) + 30, y + 2, (w / 2) - 30, 40, label, false, false);
|
||||
|
||||
y += 30;
|
||||
h -= 30;
|
||||
|
||||
if (w * h <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var track = (w / 2) - 60;
|
||||
|
||||
var speed = vals[4, 0] / Math.Max(1, vals[4, 1]);
|
||||
|
||||
AddScrollbarH(
|
||||
x,
|
||||
y + 4,
|
||||
200,
|
||||
speed,
|
||||
p =>
|
||||
{
|
||||
foreach (var s in List.Where(o => o.CanIgnore).Select(o => o.EnsureState(User.Account)))
|
||||
{
|
||||
s.Speed = (byte)Math.Max(0, speed - 10);
|
||||
}
|
||||
|
||||
Refresh(true);
|
||||
},
|
||||
n =>
|
||||
{
|
||||
foreach (var s in List.Where(o => o.CanIgnore).Select(o => o.EnsureState(User.Account)))
|
||||
{
|
||||
s.Speed = (byte)Math.Min(200, speed + 10);
|
||||
}
|
||||
|
||||
Refresh(true);
|
||||
},
|
||||
new Rectangle(30, 0, track, 13),
|
||||
new Rectangle(0, 0, 28, 13),
|
||||
new Rectangle(track + 32, 0, 28, 13));
|
||||
|
||||
label = String.Format("{0}% SPEED", Math.Max(1, speed));
|
||||
label = label.WrapUOHtmlBold();
|
||||
label = label.WrapUOHtmlColor(Color.PaleGoldenrod, false);
|
||||
|
||||
AddHtml(x + track + 70, y + 2, w - (track + 60), 40, label, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#region References
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
using Server;
|
||||
using Server.Mobiles;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.Notify
|
||||
{
|
||||
public abstract class WorldNotifyGump : NotifyGump
|
||||
{
|
||||
private static void InitSettings(NotifySettings o)
|
||||
{
|
||||
o.CanIgnore = true;
|
||||
o.Desc = "General broadcasts from the staff and server.";
|
||||
}
|
||||
|
||||
public WorldNotifyGump(Mobile user, string html)
|
||||
: this(user, html, false)
|
||||
{ }
|
||||
|
||||
public WorldNotifyGump(Mobile user, string html, bool autoClose)
|
||||
: base(user, html)
|
||||
{
|
||||
AnimDuration = TimeSpan.FromSeconds(1.0);
|
||||
PauseDuration = TimeSpan.FromSeconds(10.0);
|
||||
HtmlColor = Color.Yellow;
|
||||
AutoClose = autoClose;
|
||||
}
|
||||
|
||||
private class Sub0 : WorldNotifyGump
|
||||
{
|
||||
public Sub0(Mobile user, string html)
|
||||
: base(user, html)
|
||||
{ }
|
||||
|
||||
public Sub0(Mobile user, string html, bool autoClose)
|
||||
: base(user, html, autoClose)
|
||||
{ }
|
||||
}
|
||||
|
||||
private class Sub1 : WorldNotifyGump
|
||||
{
|
||||
public Sub1(Mobile user, string html)
|
||||
: base(user, html)
|
||||
{ }
|
||||
|
||||
public Sub1(Mobile user, string html, bool autoClose)
|
||||
: base(user, html, autoClose)
|
||||
{ }
|
||||
}
|
||||
|
||||
private class Sub2 : WorldNotifyGump
|
||||
{
|
||||
public Sub2(Mobile user, string html)
|
||||
: base(user, html)
|
||||
{ }
|
||||
|
||||
public Sub2(Mobile user, string html, bool autoClose)
|
||||
: base(user, html, autoClose)
|
||||
{ }
|
||||
}
|
||||
|
||||
private class Sub3 : WorldNotifyGump
|
||||
{
|
||||
public Sub3(Mobile user, string html)
|
||||
: base(user, html)
|
||||
{ }
|
||||
|
||||
public Sub3(PlayerMobile user, string html, bool autoClose)
|
||||
: base(user, html, autoClose)
|
||||
{ }
|
||||
}
|
||||
|
||||
private class Sub4 : WorldNotifyGump
|
||||
{
|
||||
public Sub4(Mobile user, string html)
|
||||
: base(user, html)
|
||||
{ }
|
||||
|
||||
public Sub4(Mobile user, string html, bool autoClose)
|
||||
: base(user, html, autoClose)
|
||||
{ }
|
||||
}
|
||||
|
||||
private class Sub5 : WorldNotifyGump
|
||||
{
|
||||
public Sub5(Mobile user, string html)
|
||||
: base(user, html)
|
||||
{ }
|
||||
|
||||
public Sub5(Mobile user, string html, bool autoClose)
|
||||
: base(user, html, autoClose)
|
||||
{ }
|
||||
}
|
||||
|
||||
private class Sub6 : WorldNotifyGump
|
||||
{
|
||||
public Sub6(Mobile user, string html)
|
||||
: base(user, html)
|
||||
{ }
|
||||
|
||||
public Sub6(Mobile user, string html, bool autoClose)
|
||||
: base(user, html, autoClose)
|
||||
{ }
|
||||
}
|
||||
|
||||
private class Sub7 : WorldNotifyGump
|
||||
{
|
||||
public Sub7(Mobile user, string html)
|
||||
: base(user, html)
|
||||
{ }
|
||||
|
||||
public Sub7(Mobile user, string html, bool autoClose)
|
||||
: base(user, html, autoClose)
|
||||
{ }
|
||||
}
|
||||
|
||||
private class Sub8 : WorldNotifyGump
|
||||
{
|
||||
public Sub8(Mobile user, string html)
|
||||
: base(user, html)
|
||||
{ }
|
||||
|
||||
public Sub8(Mobile user, string html, bool autoClose)
|
||||
: base(user, html, autoClose)
|
||||
{ }
|
||||
}
|
||||
|
||||
private class Sub9 : WorldNotifyGump
|
||||
{
|
||||
public Sub9(Mobile user, string html)
|
||||
: base(user, html)
|
||||
{ }
|
||||
|
||||
public Sub9(Mobile user, string html, bool autoClose)
|
||||
: base(user, html, autoClose)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user