Overwrite
Complete Overwrite of the Folder with the free shard. ServUO 57.3 has been added.
This commit is contained in:
@@ -0,0 +1,220 @@
|
||||
#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.Gumps;
|
||||
using Server.Network;
|
||||
|
||||
using VitaNex.Crypto;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public sealed class GumpAnimationBreak : SuperGumpEntry
|
||||
{
|
||||
private const string _Format = "{ animbreak }";
|
||||
|
||||
private static readonly byte[] _Layout = Gump.StringToBuffer("animbreak");
|
||||
|
||||
public override bool IgnoreModalOffset => true;
|
||||
|
||||
public override string Compile()
|
||||
{
|
||||
return _Format;
|
||||
}
|
||||
|
||||
public override void AppendTo(IGumpWriter disp)
|
||||
{
|
||||
disp.AppendLayout(_Layout);
|
||||
}
|
||||
}
|
||||
|
||||
public class GumpAnimation : SuperGumpEntry, IEquatable<GumpAnimation>
|
||||
{
|
||||
private static readonly Action<GumpAnimation> _EmptyHandler = anim => { };
|
||||
private static readonly GumpEntry[] _EmptyEntries = new GumpEntry[0];
|
||||
|
||||
private static readonly byte[] _BeginLayout = Server.Gumps.Gump.StringToBuffer("{ ");
|
||||
private static readonly byte[] _EndLayout = Server.Gumps.Gump.StringToBuffer(" }");
|
||||
|
||||
private const string _Format = "{{ anim {0} }}";
|
||||
|
||||
private static readonly byte[] _Layout = Server.Gumps.Gump.StringToBuffer("anim");
|
||||
|
||||
public override bool IgnoreModalOffset => true;
|
||||
|
||||
private bool _Animated;
|
||||
|
||||
public SuperGump Gump { get; private set; }
|
||||
public string UID { get; private set; }
|
||||
public string Name { get; private set; }
|
||||
public GumpAnimationState State { get; private set; }
|
||||
|
||||
public Stack<GumpEntry> Entries { get; protected set; }
|
||||
public Action<GumpAnimation> Handler { get; protected set; }
|
||||
|
||||
public object[] Args { get; set; }
|
||||
|
||||
public GumpAnimation(
|
||||
SuperGump gump,
|
||||
string name,
|
||||
int take,
|
||||
long delay,
|
||||
long duration,
|
||||
bool repeat,
|
||||
bool wait,
|
||||
object[] args,
|
||||
Action<GumpAnimation> handler)
|
||||
{
|
||||
Gump = gump;
|
||||
Name = name ?? String.Empty;
|
||||
|
||||
UID = String.Format("{{{0} {1} {2}}}", Name, Gump.Serial, Gump.User.Serial.Value);
|
||||
|
||||
take = Math.Max(-1, Math.Min(Gump.Entries.Count, take));
|
||||
|
||||
Entries = new Stack<GumpEntry>(take == -1 ? Gump.Entries.Count : take);
|
||||
|
||||
if (take == -1 || take > 0)
|
||||
{
|
||||
var count = Gump.Entries.Count;
|
||||
|
||||
while (--count >= 0)
|
||||
{
|
||||
if (count >= Gump.Entries.Count)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var e = Gump.Entries[count];
|
||||
|
||||
if (e == null || e == this || e is GumpAnimation)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (e is GumpAnimationBreak)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
Entries.Push(e);
|
||||
|
||||
if (take != -1 && --take <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Handler = handler ?? _EmptyHandler;
|
||||
|
||||
UID = CryptoGenerator.GenString(CryptoHashType.MD5, UID);
|
||||
State = GumpAnimationState.Acquire(UID, delay, duration, repeat, wait);
|
||||
|
||||
Args = args ?? new object[0];
|
||||
}
|
||||
|
||||
public T GetArg<T>(int index, T def = default(T))
|
||||
{
|
||||
try
|
||||
{
|
||||
return (T)Args[index];
|
||||
}
|
||||
catch
|
||||
{
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
_Animated = false;
|
||||
|
||||
if (State != null)
|
||||
{
|
||||
State.Reset();
|
||||
}
|
||||
}
|
||||
|
||||
public void Animate()
|
||||
{
|
||||
if (!_Animated && State != null && State.Animating)
|
||||
{
|
||||
_Animated = true;
|
||||
|
||||
OnAnimate();
|
||||
|
||||
if (Gump != null)
|
||||
{
|
||||
Gump.OnAnimate(this);
|
||||
}
|
||||
|
||||
State.Animated();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnAnimate()
|
||||
{
|
||||
if (Handler != null)
|
||||
{
|
||||
Handler(this);
|
||||
}
|
||||
}
|
||||
|
||||
public override sealed string Compile()
|
||||
{
|
||||
return String.Format(_Format, GetHashCode());
|
||||
}
|
||||
|
||||
public override sealed void AppendTo(IGumpWriter disp)
|
||||
{
|
||||
disp.AppendLayout(_Layout);
|
||||
disp.AppendLayout(GetHashCode());
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return UID.GetContentsHashCode();
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is GumpAnimation && Equals((GumpAnimation)obj);
|
||||
}
|
||||
|
||||
public virtual bool Equals(GumpAnimation anim)
|
||||
{
|
||||
return !ReferenceEquals(anim, null) && String.Equals(UID, anim.UID);
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
State = null;
|
||||
Handler = null;
|
||||
|
||||
Entries.Free(true);
|
||||
Entries = null;
|
||||
|
||||
if (Gump == null || Gump.IsDisposed)
|
||||
{
|
||||
GumpAnimationState.Free(UID);
|
||||
}
|
||||
|
||||
Gump = null;
|
||||
|
||||
base.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,234 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#region References
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public sealed class GumpAnimationState
|
||||
{
|
||||
private static readonly Dictionary<string, GumpAnimationState> _States =
|
||||
new Dictionary<string, GumpAnimationState>(0x400);
|
||||
|
||||
private static readonly Queue<GumpAnimationState> _Pool = new Queue<GumpAnimationState>(0x200);
|
||||
|
||||
private const double _Frequency = 1000.0;
|
||||
|
||||
public static GumpAnimationState Acquire(string uid, long delay, long duration, bool repeat, bool wait)
|
||||
{
|
||||
GumpAnimationState state;
|
||||
|
||||
lock (_States)
|
||||
{
|
||||
if (!_States.TryGetValue(uid, out state) || state == null)
|
||||
{
|
||||
lock (_Pool)
|
||||
{
|
||||
state = _Pool.Count > 0 ? _Pool.Dequeue() : new GumpAnimationState();
|
||||
}
|
||||
}
|
||||
|
||||
_States[uid] = state;
|
||||
}
|
||||
|
||||
state.Update(delay, duration, repeat, wait);
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
public static void Free(string uid)
|
||||
{
|
||||
GumpAnimationState state;
|
||||
|
||||
lock (_States)
|
||||
{
|
||||
if (_States.TryGetValue(uid, out state))
|
||||
{
|
||||
_States.Remove(uid);
|
||||
}
|
||||
}
|
||||
|
||||
if (state != null)
|
||||
{
|
||||
state.Free();
|
||||
}
|
||||
}
|
||||
|
||||
private long _Ticks;
|
||||
private double _Sample;
|
||||
private int _Count = -1;
|
||||
|
||||
private long _Delay, _Duration;
|
||||
private bool _Repeat, _Wait;
|
||||
|
||||
public long Start { get; private set; }
|
||||
public long Duration { get; private set; }
|
||||
public long End => Start + Duration;
|
||||
|
||||
public bool Repeat { get; private set; }
|
||||
public bool Wait { get; private set; }
|
||||
|
||||
public bool FirstUpdate { get; private set; }
|
||||
public bool FirstFrame { get; private set; }
|
||||
|
||||
public int FrameRate { get; private set; }
|
||||
|
||||
public double Slice
|
||||
{
|
||||
get
|
||||
{
|
||||
var ticks = VitaNexCore.Ticks;
|
||||
|
||||
if (ticks < Start)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
if (Duration <= 0)
|
||||
{
|
||||
return (ticks / _Frequency) % 1.0;
|
||||
}
|
||||
|
||||
if (ticks > End)
|
||||
{
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
return ((ticks - Start) / _Frequency) / (Duration / _Frequency);
|
||||
}
|
||||
}
|
||||
|
||||
public int FrameCount
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Duration <= 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return (int)Math.Ceiling(FrameRate * (Duration / _Frequency));
|
||||
}
|
||||
}
|
||||
|
||||
public int Frame => (int)Math.Ceiling(Slice * FrameCount);
|
||||
|
||||
public bool Sequencing => VitaNexCore.Ticks < Start;
|
||||
public bool Animating => VitaNexCore.Ticks < End || Duration <= 0;
|
||||
public bool Waiting => Wait && !Sequencing && Animating;
|
||||
|
||||
private GumpAnimationState()
|
||||
{ }
|
||||
|
||||
private void Update(long delay, long duration, bool repeat, bool wait)
|
||||
{
|
||||
var ticks = VitaNexCore.Ticks;
|
||||
|
||||
if (_Count++ > -1)
|
||||
{
|
||||
_Sample += ticks - _Ticks;
|
||||
|
||||
if (_Sample >= _Frequency)
|
||||
{
|
||||
FrameRate = _Count;
|
||||
|
||||
_Count = 0;
|
||||
_Sample -= _Frequency;
|
||||
}
|
||||
|
||||
FirstUpdate = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
FirstUpdate = true;
|
||||
FirstFrame = true;
|
||||
FrameRate = 10;
|
||||
}
|
||||
|
||||
_Ticks = ticks;
|
||||
|
||||
if (!FirstUpdate && _Ticks >= End && (Repeat || Duration <= 0))
|
||||
{
|
||||
FirstUpdate = true;
|
||||
}
|
||||
|
||||
if (FirstUpdate)
|
||||
{
|
||||
Start = _Ticks + (_Delay = delay);
|
||||
Duration = _Duration = duration;
|
||||
Repeat = _Repeat = repeat;
|
||||
Wait = _Wait = wait;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_Delay != delay)
|
||||
{
|
||||
Start -= _Delay;
|
||||
_Delay = delay;
|
||||
Start += _Delay;
|
||||
}
|
||||
|
||||
if (_Duration != duration)
|
||||
{
|
||||
Duration = _Duration = duration;
|
||||
}
|
||||
|
||||
if (_Repeat != repeat)
|
||||
{
|
||||
Repeat = _Repeat = repeat;
|
||||
}
|
||||
|
||||
if (_Wait != wait)
|
||||
{
|
||||
Wait = _Wait = wait;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Animated()
|
||||
{
|
||||
FirstFrame = false;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
_Count = -1;
|
||||
}
|
||||
|
||||
private void Free()
|
||||
{
|
||||
_Ticks = 0;
|
||||
_Sample = 0;
|
||||
_Count = -1;
|
||||
|
||||
_Delay = _Duration = 0;
|
||||
_Repeat = _Wait = false;
|
||||
|
||||
Start = Duration = 0;
|
||||
Repeat = Wait = false;
|
||||
|
||||
FirstUpdate = true;
|
||||
FirstFrame = true;
|
||||
FrameRate = 10;
|
||||
|
||||
lock (_Pool)
|
||||
{
|
||||
if (_Pool.Count < 0x200)
|
||||
{
|
||||
_Pool.Enqueue(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#region References
|
||||
using System;
|
||||
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public static class GumpAnimations
|
||||
{
|
||||
public static void Shake(GumpAnimation anim)
|
||||
{
|
||||
var p = anim.State.Slice;
|
||||
|
||||
p = Math.Max(0.0, Math.Min(1.0, p <= 0.5 ? p / 0.5 : (p - 0.5) / 0.5));
|
||||
|
||||
var range = anim.GetArg(0, 5);
|
||||
|
||||
var r = 1 + (int)(p * range);
|
||||
|
||||
foreach (var e in anim.Entries)
|
||||
{
|
||||
if (e.TryGetPosition(out var x, out var y))
|
||||
{
|
||||
x = Math.Max(0, Utility.RandomMinMax(x - r, x + r));
|
||||
y = Math.Max(0, Utility.RandomMinMax(y - r, y + r));
|
||||
|
||||
e.TrySetPosition(x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void GrowWidth(GumpAnimation anim)
|
||||
{
|
||||
var p = anim.State.Slice;
|
||||
|
||||
foreach (var e in anim.Entries)
|
||||
{
|
||||
if (e.TryGetWidth(out var w))
|
||||
{
|
||||
e.TrySetWidth((int)Math.Ceiling(w * p));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void GrowHeight(GumpAnimation anim)
|
||||
{
|
||||
var p = anim.State.Slice;
|
||||
|
||||
foreach (var e in anim.Entries)
|
||||
{
|
||||
if (e.TryGetHeight(out var h))
|
||||
{
|
||||
e.TrySetHeight((int)Math.Ceiling(h * p));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Grow(GumpAnimation anim)
|
||||
{
|
||||
var p = anim.State.Slice;
|
||||
|
||||
foreach (var e in anim.Entries)
|
||||
{
|
||||
if (e.TryGetSize(out var w, out var h))
|
||||
{
|
||||
e.TrySetSize((int)Math.Ceiling(w * p), (int)Math.Ceiling(h * p));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void ShrinkWidth(GumpAnimation anim)
|
||||
{
|
||||
var p = 1.0 - anim.State.Slice;
|
||||
|
||||
foreach (var e in anim.Entries)
|
||||
{
|
||||
if (e.TryGetWidth(out var w))
|
||||
{
|
||||
e.TrySetWidth((int)Math.Ceiling(w * p));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void ShrinkHeight(GumpAnimation anim)
|
||||
{
|
||||
var p = 1.0 - anim.State.Slice;
|
||||
|
||||
foreach (var e in anim.Entries)
|
||||
{
|
||||
if (e.TryGetHeight(out var h))
|
||||
{
|
||||
e.TrySetHeight((int)Math.Ceiling(h * p));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Shrink(GumpAnimation anim)
|
||||
{
|
||||
var p = 1.0 - anim.State.Slice;
|
||||
|
||||
foreach (var e in anim.Entries)
|
||||
{
|
||||
if (e.TryGetSize(out var w, out var h))
|
||||
{
|
||||
e.TrySetSize((int)Math.Ceiling(w * p), (int)Math.Ceiling(h * p));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#region References
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
|
||||
using VitaNex.IO;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public class GumpAsset : SuperGumpEntry, IGumpEntryVector
|
||||
{
|
||||
private const string _Format1 = "{{ htmlgump {0} {1} {2} {3} {4} 0 0 }}";
|
||||
|
||||
private static readonly byte[] _Layout1A = Gump.StringToBuffer("htmlgump");
|
||||
private static readonly byte[] _Layout1B = Gump.StringToBuffer(" }{ htmlgump");
|
||||
|
||||
private int _X, _Y;
|
||||
private VirtualAsset _Asset;
|
||||
|
||||
public int X { get => _X; set => Delta(ref _X, value); }
|
||||
public int Y { get => _Y; set => Delta(ref _Y, value); }
|
||||
|
||||
public VirtualAsset Asset { get => _Asset; set => Delta(ref _Asset, value); }
|
||||
|
||||
public virtual int Width
|
||||
{
|
||||
get => _Asset != null ? _Asset.Width : 0;
|
||||
set
|
||||
{
|
||||
if (_Asset != null)
|
||||
{
|
||||
_Asset.Width = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual int Height
|
||||
{
|
||||
get => _Asset != null ? _Asset.Height : 0;
|
||||
set
|
||||
{
|
||||
if (_Asset != null)
|
||||
{
|
||||
_Asset.Height = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public GumpAsset(int x, int y, string path)
|
||||
: this(x, y, VirtualAsset.LoadAsset(path))
|
||||
{ }
|
||||
|
||||
public GumpAsset(int x, int y, Uri url)
|
||||
: this(x, y, VirtualAsset.LoadAsset(url))
|
||||
{ }
|
||||
|
||||
public GumpAsset(int x, int y, FileInfo file)
|
||||
: this(x, y, VirtualAsset.LoadAsset(file))
|
||||
{ }
|
||||
|
||||
public GumpAsset(int x, int y, VirtualAsset asset)
|
||||
{
|
||||
_X = x;
|
||||
_Y = y;
|
||||
_Asset = asset;
|
||||
}
|
||||
|
||||
public override string Compile()
|
||||
{
|
||||
if (IsEnhancedClient)
|
||||
{
|
||||
return String.Empty;
|
||||
}
|
||||
|
||||
var compiled = String.Empty;
|
||||
|
||||
if (!VirtualAsset.IsNullOrEmpty(_Asset))
|
||||
{
|
||||
_Asset.ForEach(
|
||||
(x, y, c) =>
|
||||
{
|
||||
if (!c.IsEmpty && c != Color.Transparent)
|
||||
{
|
||||
compiled += Compile(x, y, 1, 1, c);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (String.IsNullOrWhiteSpace(compiled))
|
||||
{
|
||||
compiled = Compile(_X, _Y, Width, Height, Color.Transparent);
|
||||
}
|
||||
|
||||
return compiled;
|
||||
}
|
||||
|
||||
public virtual string Compile(int x, int y, int w, int h, Color c)
|
||||
{
|
||||
return String.Format(_Format1, _X + x, _Y + y, w, h, Parent.Intern(" ".WrapUOHtmlBG(c)));
|
||||
}
|
||||
|
||||
public override void AppendTo(IGumpWriter disp)
|
||||
{
|
||||
if (IsEnhancedClient)
|
||||
{
|
||||
AppendEmptyLayout(disp);
|
||||
return;
|
||||
}
|
||||
|
||||
var first = true;
|
||||
|
||||
if (!VirtualAsset.IsNullOrEmpty(_Asset))
|
||||
{
|
||||
_Asset.ForEach(
|
||||
(x, y, c) =>
|
||||
{
|
||||
if (!c.IsEmpty && c != Color.Transparent)
|
||||
{
|
||||
AppendTo(disp, ref first, x, y, 1, 1, c);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (first)
|
||||
{
|
||||
AppendTo(disp, ref first, _X, _Y, Width, Height, Color.Transparent);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void AppendTo(IGumpWriter disp, ref bool first, int x, int y, int w, int h, Color c)
|
||||
{
|
||||
disp.AppendLayout(first ? _Layout1A : _Layout1B);
|
||||
disp.AppendLayout(_X + x);
|
||||
disp.AppendLayout(_Y + y);
|
||||
disp.AppendLayout(1);
|
||||
disp.AppendLayout(1);
|
||||
disp.AppendLayout(Parent.Intern(" ".WrapUOHtmlBG(c)));
|
||||
disp.AppendLayout(false);
|
||||
disp.AppendLayout(false);
|
||||
|
||||
first = false;
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
_Asset = null;
|
||||
|
||||
base.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,357 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#region References
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public class GumpClock : SuperGumpEntry, IGumpEntryVector
|
||||
{
|
||||
private const string _Format1A = "{{ gumppic {0} {1} {2} }}";
|
||||
private const string _Format1B = "{{ gumppic {0} {1} {2} hue={3} }}";
|
||||
private const string _Format2 = "{{ htmlgump {0} {1} {2} {3} {4} 0 0 }}";
|
||||
|
||||
private static readonly byte[] _Layout1A = Gump.StringToBuffer("gumppic");
|
||||
private static readonly byte[] _Layout1B = Gump.StringToBuffer(" }{ gumppic");
|
||||
private static readonly byte[] _Layout1Hue = Gump.StringToBuffer(" hue=");
|
||||
private static readonly byte[] _Layout2A = Gump.StringToBuffer("htmlgump");
|
||||
private static readonly byte[] _Layout2B = Gump.StringToBuffer(" }{ htmlgump");
|
||||
|
||||
private int _X;
|
||||
private int _Y;
|
||||
|
||||
private DateTime _Time;
|
||||
|
||||
private bool _Background;
|
||||
private int _BackgroundHue;
|
||||
|
||||
private bool _Face;
|
||||
private int _FaceHue;
|
||||
|
||||
private bool _Numerals;
|
||||
|
||||
private bool _Numbers;
|
||||
private Color _NumbersColor;
|
||||
|
||||
private bool _Hours;
|
||||
private Color _HoursColor;
|
||||
|
||||
private bool _Minutes;
|
||||
private Color _MinutesColor;
|
||||
|
||||
private bool _Seconds;
|
||||
private Color _SecondsColor;
|
||||
|
||||
public int X { get => _X; set => Delta(ref _X, value); }
|
||||
public int Y { get => _Y; set => Delta(ref _Y, value); }
|
||||
|
||||
public DateTime Time { get => _Time; set => Delta(ref _Time, value); }
|
||||
|
||||
public bool Background { get => _Background; set => Delta(ref _Background, value); }
|
||||
public int BackgroundHue { get => _BackgroundHue; set => Delta(ref _BackgroundHue, value); }
|
||||
|
||||
public bool Face { get => _Face; set => Delta(ref _Face, value); }
|
||||
public int FaceHue { get => _FaceHue; set => Delta(ref _FaceHue, value); }
|
||||
|
||||
public bool Numerals { get => _Numerals; set => Delta(ref _Numerals, value); }
|
||||
|
||||
public bool Numbers { get => _Numbers; set => Delta(ref _Numbers, value); }
|
||||
public Color NumbersColor { get => _NumbersColor; set => Delta(ref _NumbersColor, value); }
|
||||
|
||||
public bool Hours { get => _Hours; set => Delta(ref _Hours, value); }
|
||||
public Color HoursColor { get => _HoursColor; set => Delta(ref _HoursColor, value); }
|
||||
|
||||
public bool Minutes { get => _Minutes; set => Delta(ref _Minutes, value); }
|
||||
public Color MinutesColor { get => _MinutesColor; set => Delta(ref _MinutesColor, value); }
|
||||
|
||||
public bool Seconds { get => _Seconds; set => Delta(ref _Seconds, value); }
|
||||
public Color SecondsColor { get => _SecondsColor; set => Delta(ref _SecondsColor, value); }
|
||||
|
||||
public virtual int Width { get => 80; set { } }
|
||||
public virtual int Height { get => 80; set { } }
|
||||
|
||||
public GumpClock(
|
||||
int x,
|
||||
int y,
|
||||
DateTime time,
|
||||
bool background = true,
|
||||
int backgroundHue = 900,
|
||||
bool face = true,
|
||||
int faceHue = 900,
|
||||
bool numerals = false,
|
||||
bool numbers = true,
|
||||
Color? numbersColor = null,
|
||||
bool hours = true,
|
||||
Color? hoursColor = null,
|
||||
bool minutes = true,
|
||||
Color? minutesColor = null,
|
||||
bool seconds = true,
|
||||
Color? secondsColor = null)
|
||||
{
|
||||
_X = x;
|
||||
_Y = y;
|
||||
_Time = time;
|
||||
_Background = background;
|
||||
_BackgroundHue = backgroundHue;
|
||||
_Face = face;
|
||||
_FaceHue = faceHue;
|
||||
_Numerals = numerals;
|
||||
_Numbers = numbers;
|
||||
_NumbersColor = numbersColor ?? Color.Gold;
|
||||
_Hours = hours;
|
||||
_HoursColor = hoursColor ?? Color.Gainsboro;
|
||||
_Minutes = minutes;
|
||||
_MinutesColor = minutesColor ?? Color.Gainsboro;
|
||||
_Seconds = seconds;
|
||||
_SecondsColor = secondsColor ?? Color.Red;
|
||||
}
|
||||
|
||||
public override string Compile()
|
||||
{
|
||||
var compiled = String.Empty;
|
||||
|
||||
if (_Background)
|
||||
{
|
||||
if (_BackgroundHue <= 0)
|
||||
{
|
||||
compiled += String.Format(_Format1A, _X, _Y, 1417);
|
||||
}
|
||||
else
|
||||
{
|
||||
compiled += String.Format(_Format1B, _X, _Y, 1417, FixHue(_BackgroundHue));
|
||||
}
|
||||
}
|
||||
|
||||
if (_Face)
|
||||
{
|
||||
if (_FaceHue <= 0)
|
||||
{
|
||||
compiled += String.Format(_Format1A, _X + 33, _Y + 33, 1210);
|
||||
}
|
||||
else
|
||||
{
|
||||
compiled += String.Format(_Format1B, _X + 33, _Y + 33, 1210, FixHue(_FaceHue));
|
||||
}
|
||||
}
|
||||
|
||||
if (_Numbers)
|
||||
{
|
||||
for (var number = 1; number <= 12; number++)
|
||||
{
|
||||
compiled += Compile(number, _NumbersColor);
|
||||
}
|
||||
}
|
||||
|
||||
var center = new Point2D(_X + 40, _Y + 40);
|
||||
|
||||
if (_Hours)
|
||||
{
|
||||
var ha = 2.0f * Math.PI * (_Time.Hour + _Time.Minute / 60.0f) / 12.0f;
|
||||
var hl = center.GetLine2D(center.Clone2D((int)(40 * Math.Sin(ha) / 1.5f), (int)(-40 * Math.Cos(ha) / 1.5f)));
|
||||
|
||||
compiled += Compile(hl, _Minutes && _Seconds ? 2 : 1, _HoursColor);
|
||||
}
|
||||
|
||||
if (_Minutes)
|
||||
{
|
||||
var ma = 2.0f * Math.PI * (_Time.Minute + _Time.Second / 60.0f) / 60.0f;
|
||||
var ml = center.GetLine2D(center.Clone2D((int)(40 * Math.Sin(ma)), (int)(-40 * Math.Cos(ma))));
|
||||
|
||||
compiled += Compile(ml, _Seconds ? 2 : 1, _MinutesColor);
|
||||
}
|
||||
|
||||
if (_Seconds)
|
||||
{
|
||||
var sa = 2.0f * Math.PI * _Time.Second / 60.0f;
|
||||
var sl = center.GetLine2D(center.Clone2D((int)(40 * Math.Sin(sa)), (int)(-40 * Math.Cos(sa))));
|
||||
|
||||
compiled += Compile(sl, 1, _SecondsColor);
|
||||
}
|
||||
|
||||
if (String.IsNullOrWhiteSpace(compiled))
|
||||
{
|
||||
compiled = String.Format(_Format2, _X, _Y, Width, Height, Parent.Intern(" ".WrapUOHtmlBG(Color.Transparent)));
|
||||
}
|
||||
|
||||
return compiled;
|
||||
}
|
||||
|
||||
public virtual string Compile(int number, Color color)
|
||||
{
|
||||
string n;
|
||||
|
||||
if (_Numerals)
|
||||
{
|
||||
n = (Numeral)number;
|
||||
}
|
||||
else
|
||||
{
|
||||
n = number.ToString();
|
||||
}
|
||||
|
||||
var x = (_X + 30) + (int)(-1 * (40 * Math.Cos((Math.PI / 180.0f) * (number * 30 + 90))));
|
||||
var y = (_Y + 30) + (int)(-1 * (40 * Math.Sin((Math.PI / 180.0f) * (number * 30 + 90))));
|
||||
var text = Parent.Intern(n.WrapUOHtmlBig().WrapUOHtmlCenter().WrapUOHtmlColor(color, false));
|
||||
|
||||
return String.Format(_Format2, x, y, 20, 40, text);
|
||||
}
|
||||
|
||||
public virtual string Compile(Point2D[] line, int size, Color color)
|
||||
{
|
||||
var offset = size / 3;
|
||||
var bgColor = Parent.Intern(" ".WrapUOHtmlBG(color));
|
||||
|
||||
return String.Join(
|
||||
String.Empty,
|
||||
line.Select(p => String.Format(_Format2, p.X - offset, p.Y - offset, size, size, bgColor)));
|
||||
}
|
||||
|
||||
public override void AppendTo(IGumpWriter disp)
|
||||
{
|
||||
var first = true;
|
||||
|
||||
if (_Background)
|
||||
{
|
||||
disp.AppendLayout(_Layout1A);
|
||||
disp.AppendLayout(_X);
|
||||
disp.AppendLayout(_Y);
|
||||
disp.AppendLayout(1417);
|
||||
|
||||
if (_BackgroundHue > 0)
|
||||
{
|
||||
disp.AppendLayout(_Layout1Hue);
|
||||
disp.AppendLayoutNS(FixHue(_BackgroundHue));
|
||||
}
|
||||
|
||||
first = false;
|
||||
}
|
||||
|
||||
if (_Face)
|
||||
{
|
||||
disp.AppendLayout(first ? _Layout1A : _Layout1B);
|
||||
disp.AppendLayout(_X + 33);
|
||||
disp.AppendLayout(_Y + 33);
|
||||
disp.AppendLayout(1210);
|
||||
|
||||
if (_FaceHue > 0)
|
||||
{
|
||||
disp.AppendLayout(_Layout1Hue);
|
||||
disp.AppendLayoutNS(FixHue(_FaceHue));
|
||||
}
|
||||
|
||||
first = false;
|
||||
}
|
||||
|
||||
if (_Numbers)
|
||||
{
|
||||
for (var number = 1; number <= 12; number++)
|
||||
{
|
||||
AppendTo(disp, ref first, number, _NumbersColor);
|
||||
}
|
||||
}
|
||||
|
||||
var center = new Point2D(_X + 40, _Y + 40);
|
||||
|
||||
if (_Hours)
|
||||
{
|
||||
var ha = 2.0f * Math.PI * (_Time.Hour + _Time.Minute / 60.0f) / 12.0f;
|
||||
var hl = center.GetLine2D(center.Clone2D((int)(40 * Math.Sin(ha) / 1.5f), (int)(-40 * Math.Cos(ha) / 1.5f)));
|
||||
|
||||
AppendTo(disp, ref first, hl, _Minutes && _Seconds ? 2 : 1, _HoursColor);
|
||||
}
|
||||
|
||||
if (_Minutes)
|
||||
{
|
||||
var ma = 2.0f * Math.PI * (_Time.Minute + _Time.Second / 60.0f) / 60.0f;
|
||||
var ml = center.GetLine2D(center.Clone2D((int)(40 * Math.Sin(ma)), (int)(-40 * Math.Cos(ma))));
|
||||
|
||||
AppendTo(disp, ref first, ml, _Seconds ? 2 : 1, _MinutesColor);
|
||||
}
|
||||
|
||||
if (_Seconds)
|
||||
{
|
||||
var sa = 2.0f * Math.PI * _Time.Second / 60.0f;
|
||||
var sl = center.GetLine2D(center.Clone2D((int)(40 * Math.Sin(sa)), (int)(-40 * Math.Cos(sa))));
|
||||
|
||||
AppendTo(disp, ref first, sl, 1, _SecondsColor);
|
||||
}
|
||||
|
||||
if (first)
|
||||
{
|
||||
disp.AppendLayout(_Layout2A);
|
||||
disp.AppendLayout(_X);
|
||||
disp.AppendLayout(_Y);
|
||||
disp.AppendLayout(Width);
|
||||
disp.AppendLayout(Height);
|
||||
disp.AppendLayout(Parent.Intern(" ".WrapUOHtmlBG(Color.Transparent)));
|
||||
disp.AppendLayout(false);
|
||||
disp.AppendLayout(false);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void AppendTo(IGumpWriter disp, ref bool first, int number, Color color)
|
||||
{
|
||||
string n;
|
||||
|
||||
if (_Numerals)
|
||||
{
|
||||
n = (Numeral)number;
|
||||
}
|
||||
else
|
||||
{
|
||||
n = number.ToString();
|
||||
}
|
||||
|
||||
var x = (_X + 30) + (int)(-1 * (40 * Math.Cos((Math.PI / 180.0f) * (number * 30 + 90))));
|
||||
var y = (_Y + 30) + (int)(-1 * (40 * Math.Sin((Math.PI / 180.0f) * (number * 30 + 90))));
|
||||
var text = Parent.Intern(n.WrapUOHtmlBig().WrapUOHtmlCenter().WrapUOHtmlColor(color, false));
|
||||
|
||||
disp.AppendLayout(first ? _Layout2A : _Layout2B);
|
||||
disp.AppendLayout(x);
|
||||
disp.AppendLayout(y);
|
||||
disp.AppendLayout(20);
|
||||
disp.AppendLayout(40);
|
||||
disp.AppendLayout(text);
|
||||
disp.AppendLayout(false);
|
||||
disp.AppendLayout(false);
|
||||
|
||||
first = false;
|
||||
}
|
||||
|
||||
public virtual void AppendTo(IGumpWriter disp, ref bool first, Point2D[] line, int size, Color color)
|
||||
{
|
||||
var offset = size / 3;
|
||||
var bgColor = Parent.Intern(" ".WrapUOHtmlBG(color));
|
||||
|
||||
foreach (var p in line)
|
||||
{
|
||||
disp.AppendLayout(first ? _Layout2A : _Layout2B);
|
||||
disp.AppendLayout(p.X - offset);
|
||||
disp.AppendLayout(p.Y - offset);
|
||||
disp.AppendLayout(size);
|
||||
disp.AppendLayout(size);
|
||||
disp.AppendLayout(bgColor);
|
||||
disp.AppendLayout(false);
|
||||
disp.AppendLayout(false);
|
||||
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
#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 Server.Network;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public class GumpCross : SuperGumpEntry, IGumpEntryVector
|
||||
{
|
||||
private const string _Format1 = @"{{ htmlgump {0} {1} {2} {3} {4} 0 0 }}";
|
||||
|
||||
private static readonly byte[] _Layout1A = Gump.StringToBuffer("htmlgump");
|
||||
private static readonly byte[] _Layout1B = Gump.StringToBuffer(" }{ htmlgump");
|
||||
|
||||
private int _X, _Y;
|
||||
private int _Width, _Height;
|
||||
private int _Size, _BorderSize;
|
||||
private Color _FillColor, _BorderColor;
|
||||
|
||||
public int X { get => _X; set => Delta(ref _X, value); }
|
||||
public int Y { get => _Y; set => Delta(ref _Y, value); }
|
||||
|
||||
public int Width { get => _Width; set => Delta(ref _Width, value); }
|
||||
public int Height { get => _Height; set => Delta(ref _Height, value); }
|
||||
|
||||
public int Size { get => _Size; set => Delta(ref _Size, value); }
|
||||
public int BorderSize { get => _BorderSize; set => Delta(ref _BorderSize, value); }
|
||||
|
||||
public Color FillColor { get => _FillColor; set => Delta(ref _FillColor, value); }
|
||||
public Color BorderColor { get => _BorderColor; set => Delta(ref _BorderColor, value); }
|
||||
|
||||
public GumpCross(Rectangle bounds, int size, Color color)
|
||||
: this(bounds.X, bounds.Y, bounds.Width, bounds.Height, size, color)
|
||||
{ }
|
||||
|
||||
public GumpCross(Rectangle bounds, int size, Color color, bool filled)
|
||||
: this(bounds.X, bounds.Y, bounds.Width, bounds.Height, size, color, filled)
|
||||
{ }
|
||||
|
||||
public GumpCross(Rectangle bounds, int size, Color color, int borderSize)
|
||||
: this(bounds.X, bounds.Y, bounds.Width, bounds.Height, size, color, borderSize)
|
||||
{ }
|
||||
|
||||
public GumpCross(Rectangle bounds, int size, Color color, Color border, int borderSize)
|
||||
: this(bounds.X, bounds.Y, bounds.Width, bounds.Height, size, color, border, borderSize)
|
||||
{ }
|
||||
|
||||
public GumpCross(Rectangle2D bounds, int size, Color color)
|
||||
: this(bounds.X, bounds.Y, bounds.Width, bounds.Height, size, color)
|
||||
{ }
|
||||
|
||||
public GumpCross(Rectangle2D bounds, int size, Color color, bool filled)
|
||||
: this(bounds.X, bounds.Y, bounds.Width, bounds.Height, size, color, filled)
|
||||
{ }
|
||||
|
||||
public GumpCross(Rectangle2D bounds, int size, Color color, int borderSize)
|
||||
: this(bounds.X, bounds.Y, bounds.Width, bounds.Height, size, color, borderSize)
|
||||
{ }
|
||||
|
||||
public GumpCross(Rectangle2D bounds, int size, Color color, Color border, int borderSize)
|
||||
: this(bounds.X, bounds.Y, bounds.Width, bounds.Height, size, color, border, borderSize)
|
||||
{ }
|
||||
|
||||
public GumpCross(int x, int y, int w, int h, int size, Color color)
|
||||
: this(x, y, w, h, size, color, false)
|
||||
{ }
|
||||
|
||||
public GumpCross(int x, int y, int w, int h, int size, Color color, bool filled)
|
||||
: this(x, y, w, h, size, color, filled ? 0 : 1)
|
||||
{ }
|
||||
|
||||
public GumpCross(int x, int y, int w, int h, int size, Color color, int borderSize)
|
||||
: this(x, y, w, h, size, borderSize <= 0 ? color : Color.Empty, borderSize <= 0 ? Color.Empty : color, borderSize)
|
||||
{ }
|
||||
|
||||
public GumpCross(int x, int y, int w, int h, int size, Color color, Color border, int borderSize)
|
||||
{
|
||||
_X = x;
|
||||
_Y = y;
|
||||
|
||||
_Width = w;
|
||||
_Height = h;
|
||||
|
||||
_Size = size;
|
||||
|
||||
_FillColor = color;
|
||||
_BorderColor = border;
|
||||
|
||||
_BorderSize = borderSize;
|
||||
}
|
||||
|
||||
public override string Compile()
|
||||
{
|
||||
if (IsEnhancedClient)
|
||||
{
|
||||
return String.Empty;
|
||||
}
|
||||
|
||||
var compiled = String.Empty;
|
||||
|
||||
var x1 = _X;
|
||||
var y1 = _Y + ((_Height - _Size) / 2);
|
||||
var w1 = _Width;
|
||||
var h1 = _Size;
|
||||
|
||||
var x2 = _X + ((_Width - _Size) / 2);
|
||||
var y2 = _Y;
|
||||
var w2 = _Size;
|
||||
var h2 = _Height;
|
||||
|
||||
if (!_BorderColor.IsEmpty && _BorderColor != Color.Transparent && _BorderColor != _FillColor && _BorderSize > 0)
|
||||
{
|
||||
compiled += Compile(x1, y1, w1, h1, _BorderColor);
|
||||
compiled += Compile(x2, y2, w2, h2, _BorderColor);
|
||||
|
||||
x1 += _BorderSize;
|
||||
y1 += _BorderSize;
|
||||
w1 -= _BorderSize * 2;
|
||||
h1 -= _BorderSize * 2;
|
||||
|
||||
x2 += _BorderSize;
|
||||
y2 += _BorderSize;
|
||||
w2 -= _BorderSize * 2;
|
||||
h2 -= _BorderSize * 2;
|
||||
}
|
||||
|
||||
compiled += Compile(x1, y1, w1, h1, _FillColor);
|
||||
compiled += Compile(x2, y2, w2, h2, _FillColor);
|
||||
|
||||
return compiled;
|
||||
}
|
||||
|
||||
public virtual string Compile(int x, int y, int w, int h, Color color)
|
||||
{
|
||||
var text = " ";
|
||||
|
||||
if (!color.IsEmpty && color != Color.Transparent)
|
||||
{
|
||||
text = text.WrapUOHtmlBG(color);
|
||||
}
|
||||
|
||||
return String.Format(_Format1, x, y, w, h, Parent.Intern(text));
|
||||
}
|
||||
|
||||
public override void AppendTo(IGumpWriter disp)
|
||||
{
|
||||
if (IsEnhancedClient)
|
||||
{
|
||||
AppendEmptyLayout(disp);
|
||||
return;
|
||||
}
|
||||
|
||||
var x1 = _X;
|
||||
var y1 = _Y + ((_Height - _Size) / 2);
|
||||
var w1 = _Width;
|
||||
var h1 = _Size;
|
||||
|
||||
var x2 = _X + ((_Width - _Size) / 2);
|
||||
var y2 = _Y;
|
||||
var w2 = _Size;
|
||||
var h2 = _Height;
|
||||
|
||||
var first = true;
|
||||
|
||||
if (!_BorderColor.IsEmpty && _BorderColor != Color.Transparent && _BorderColor != _FillColor && _BorderSize > 0)
|
||||
{
|
||||
AppendTo(disp, ref first, x1, y1, w1, h1, _BorderColor);
|
||||
AppendTo(disp, ref first, x2, y2, w2, h2, _BorderColor);
|
||||
|
||||
x1 += _BorderSize;
|
||||
y1 += _BorderSize;
|
||||
w1 -= _BorderSize * 2;
|
||||
h1 -= _BorderSize * 2;
|
||||
|
||||
x2 += _BorderSize;
|
||||
y2 += _BorderSize;
|
||||
w2 -= _BorderSize * 2;
|
||||
h2 -= _BorderSize * 2;
|
||||
}
|
||||
|
||||
AppendTo(disp, ref first, x1, y1, w1, h1, _FillColor);
|
||||
AppendTo(disp, ref first, x2, y2, w2, h2, _FillColor);
|
||||
}
|
||||
|
||||
public virtual void AppendTo(IGumpWriter disp, ref bool first, int x, int y, int w, int h, Color color)
|
||||
{
|
||||
var text = " ";
|
||||
|
||||
if (!color.IsEmpty && color != Color.Transparent)
|
||||
{
|
||||
text = text.WrapUOHtmlBG(color);
|
||||
}
|
||||
|
||||
disp.AppendLayout(first ? _Layout1A : _Layout1B);
|
||||
disp.AppendLayout(x);
|
||||
disp.AppendLayout(y);
|
||||
disp.AppendLayout(w);
|
||||
disp.AppendLayout(h);
|
||||
disp.AppendLayout(Parent.Intern(text));
|
||||
disp.AppendLayout(false);
|
||||
disp.AppendLayout(false);
|
||||
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,273 @@
|
||||
#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.Gumps;
|
||||
using Server.Network;
|
||||
|
||||
using Ultima;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public class GumpCursor : SuperGumpEntry, IGumpEntryVector
|
||||
{
|
||||
private static readonly Dictionary<UOCursor, Size> _SizeCache;
|
||||
|
||||
static GumpCursor()
|
||||
{
|
||||
var cursors = default(UOCursor).EnumerateValues<UOCursor>(false);
|
||||
|
||||
_SizeCache = cursors.ToDictionary(c => c, c => ArtExtUtility.GetImageSize((int)c));
|
||||
|
||||
_SizeCache[UOCursor.None] = Size.Empty;
|
||||
}
|
||||
|
||||
private const string _Format0 = "{{ tooltip {0} }}";
|
||||
private const string _Format1 = "{{ tilepic {0} {1} {2} }}";
|
||||
private const string _Format2 = "{{ tilepichue {0} {1} {2} {3} }}";
|
||||
private const string _Format3 = "{{ gumppictiled {0} {1} {2} {3} {4} }}";
|
||||
private const string _Format4 = "{{ checkertrans {0} {1} {2} {3} }}";
|
||||
|
||||
private static readonly byte[] _Layout0 = Gump.StringToBuffer("tooltip");
|
||||
private static readonly byte[] _Layout1 = Gump.StringToBuffer(" }{ tilepic");
|
||||
private static readonly byte[] _Layout2 = Gump.StringToBuffer(" }{ tilepichue");
|
||||
private static readonly byte[] _Layout3A = Gump.StringToBuffer("gumppictiled");
|
||||
private static readonly byte[] _Layout3B = Gump.StringToBuffer(" }{ gumppictiled");
|
||||
private static readonly byte[] _Layout4A = Gump.StringToBuffer("checkertrans");
|
||||
private static readonly byte[] _Layout4B = Gump.StringToBuffer(" }{ checkertrans");
|
||||
|
||||
private int _X, _Y;
|
||||
private UOCursor _Cursor;
|
||||
private int _Hue;
|
||||
private int _Tile;
|
||||
private int _Width;
|
||||
private int _Height;
|
||||
|
||||
public int X { get => _X; set => Delta(ref _X, value); }
|
||||
public int Y { get => _Y; set => Delta(ref _Y, value); }
|
||||
|
||||
public UOCursor Cursor { get => _Cursor; set => Delta(ref _Cursor, value); }
|
||||
|
||||
public int Hue { get => _Hue; set => Delta(ref _Hue, value); }
|
||||
|
||||
public int Tile { get => _Tile; set => Delta(ref _Tile, value); }
|
||||
|
||||
public int Width
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_Width <= 0)
|
||||
{
|
||||
return _SizeCache[_Cursor].Width;
|
||||
}
|
||||
|
||||
return _Width;
|
||||
}
|
||||
set => Delta(ref _Width, value);
|
||||
}
|
||||
|
||||
public int Height
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_Height <= 0)
|
||||
{
|
||||
return _SizeCache[_Cursor].Height;
|
||||
}
|
||||
|
||||
return _Height;
|
||||
}
|
||||
set => Delta(ref _Height, value);
|
||||
}
|
||||
|
||||
public GumpCursor(int x, int y, UOCursor cursor)
|
||||
: this(x, y, cursor, 0)
|
||||
{ }
|
||||
|
||||
public GumpCursor(int x, int y, UOCursor cursor, int hue)
|
||||
: this(x, y, cursor, hue, 0)
|
||||
{ }
|
||||
|
||||
public GumpCursor(int x, int y, UOCursor cursor, int hue, int bgID)
|
||||
{
|
||||
_X = x;
|
||||
_Y = y;
|
||||
_Cursor = cursor;
|
||||
_Hue = hue;
|
||||
_Tile = bgID;
|
||||
}
|
||||
|
||||
public override string Compile()
|
||||
{
|
||||
var x = X;
|
||||
var y = Y;
|
||||
var w = Width;
|
||||
var h = Height;
|
||||
var t = Tile;
|
||||
var c = (int)Cursor;
|
||||
|
||||
if (c == 0 || w * h <= 0)
|
||||
{
|
||||
return String.Format(_Format0, 0);
|
||||
}
|
||||
|
||||
var compiled = String.Empty;
|
||||
|
||||
if (t > 0)
|
||||
{
|
||||
compiled += String.Format(_Format3, x, y, w, h, t);
|
||||
}
|
||||
else
|
||||
{
|
||||
compiled += String.Format(_Format4, x, y, w, h);
|
||||
}
|
||||
|
||||
if (Hue <= 0)
|
||||
{
|
||||
compiled += String.Format(_Format1, x, y, c);
|
||||
}
|
||||
else
|
||||
{
|
||||
compiled += String.Format(_Format2, x, y, c, FixHue(Hue, true));
|
||||
}
|
||||
|
||||
const int bw = 2;
|
||||
|
||||
if (t > 0)
|
||||
{
|
||||
compiled += String.Format(_Format3, x, y, w, bw, t); // T
|
||||
compiled += String.Format(_Format3, x, y, bw, h, t); // L
|
||||
compiled += String.Format(_Format3, x, y + (h - bw), w, bw, t); // B
|
||||
compiled += String.Format(_Format3, x + (w - bw), y, bw, h, t); // R
|
||||
}
|
||||
else
|
||||
{
|
||||
compiled += String.Format(_Format4, x, y, w, bw); // T
|
||||
compiled += String.Format(_Format4, x, y, bw, h); // L
|
||||
compiled += String.Format(_Format4, x, y + (h - bw), w, bw); // B
|
||||
compiled += String.Format(_Format4, x + (w - bw), y, bw, h); // R
|
||||
}
|
||||
|
||||
return compiled;
|
||||
}
|
||||
|
||||
public override void AppendTo(IGumpWriter disp)
|
||||
{
|
||||
var x = X;
|
||||
var y = Y;
|
||||
var w = Width;
|
||||
var h = Height;
|
||||
var t = Tile;
|
||||
var c = (int)Cursor;
|
||||
|
||||
if (c == 0 || w * h <= 0)
|
||||
{
|
||||
disp.AppendLayout(_Layout0);
|
||||
disp.AppendLayout(0);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (t > 0)
|
||||
{
|
||||
disp.AppendLayout(_Layout3A);
|
||||
disp.AppendLayout(x);
|
||||
disp.AppendLayout(y);
|
||||
disp.AppendLayout(w);
|
||||
disp.AppendLayout(h);
|
||||
disp.AppendLayout(t);
|
||||
}
|
||||
else
|
||||
{
|
||||
disp.AppendLayout(_Layout4A);
|
||||
disp.AppendLayout(x);
|
||||
disp.AppendLayout(y);
|
||||
disp.AppendLayout(w);
|
||||
disp.AppendLayout(h);
|
||||
}
|
||||
|
||||
disp.AppendLayout(Hue <= 0 ? _Layout1 : _Layout2);
|
||||
disp.AppendLayout(x);
|
||||
disp.AppendLayout(y);
|
||||
disp.AppendLayout(c);
|
||||
|
||||
if (Hue > 0)
|
||||
{
|
||||
disp.AppendLayout(FixHue(Hue, true));
|
||||
}
|
||||
|
||||
const int bw = 2;
|
||||
|
||||
if (t > 0)
|
||||
{
|
||||
disp.AppendLayout(_Layout3B);
|
||||
disp.AppendLayout(x);
|
||||
disp.AppendLayout(y);
|
||||
disp.AppendLayout(w);
|
||||
disp.AppendLayout(bw);
|
||||
disp.AppendLayout(t);
|
||||
|
||||
disp.AppendLayout(_Layout3B);
|
||||
disp.AppendLayout(x);
|
||||
disp.AppendLayout(y);
|
||||
disp.AppendLayout(bw);
|
||||
disp.AppendLayout(h);
|
||||
disp.AppendLayout(t);
|
||||
|
||||
disp.AppendLayout(_Layout3B);
|
||||
disp.AppendLayout(x);
|
||||
disp.AppendLayout(y + (h - bw));
|
||||
disp.AppendLayout(w);
|
||||
disp.AppendLayout(bw);
|
||||
disp.AppendLayout(t);
|
||||
|
||||
disp.AppendLayout(_Layout3B);
|
||||
disp.AppendLayout(x + (w - bw));
|
||||
disp.AppendLayout(y);
|
||||
disp.AppendLayout(bw);
|
||||
disp.AppendLayout(h);
|
||||
disp.AppendLayout(t);
|
||||
}
|
||||
else
|
||||
{
|
||||
disp.AppendLayout(_Layout4B);
|
||||
disp.AppendLayout(x);
|
||||
disp.AppendLayout(y);
|
||||
disp.AppendLayout(w);
|
||||
disp.AppendLayout(bw);
|
||||
|
||||
disp.AppendLayout(_Layout4B);
|
||||
disp.AppendLayout(x);
|
||||
disp.AppendLayout(y);
|
||||
disp.AppendLayout(bw);
|
||||
disp.AppendLayout(h);
|
||||
|
||||
disp.AppendLayout(_Layout4B);
|
||||
disp.AppendLayout(x);
|
||||
disp.AppendLayout(y + (h - bw));
|
||||
disp.AppendLayout(w);
|
||||
disp.AppendLayout(bw);
|
||||
|
||||
disp.AppendLayout(_Layout4B);
|
||||
disp.AppendLayout(x + (w - bw));
|
||||
disp.AppendLayout(y);
|
||||
disp.AppendLayout(bw);
|
||||
disp.AppendLayout(h);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,220 @@
|
||||
#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 Server.Network;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public class GumpGradient : SuperGumpEntry, IGumpEntryVector
|
||||
{
|
||||
private static readonly Color[] _EmptyColors = new Color[0];
|
||||
private static readonly int[] _EmptySizes = new int[0];
|
||||
|
||||
private const string _Format1 = @"{{ htmlgump {0} {1} {2} {3} {4} 0 0 }}";
|
||||
|
||||
private static readonly byte[] _Layout1A = Gump.StringToBuffer("htmlgump");
|
||||
private static readonly byte[] _Layout1B = Gump.StringToBuffer(" }{ htmlgump");
|
||||
|
||||
private int _X, _Y;
|
||||
private int _Width, _Height;
|
||||
private Direction45 _Direction;
|
||||
private ColorGradient _Gradient;
|
||||
|
||||
public int X { get => _X; set => Delta(ref _X, value); }
|
||||
public int Y { get => _Y; set => Delta(ref _Y, value); }
|
||||
|
||||
public int Width { get => _Width; set => Delta(ref _Width, value); }
|
||||
public int Height { get => _Height; set => Delta(ref _Height, value); }
|
||||
|
||||
public Direction45 Direction { get => _Direction; set => Delta(ref _Direction, value); }
|
||||
public ColorGradient Gradient { get => _Gradient; set => Delta(ref _Gradient, value); }
|
||||
|
||||
public GumpGradient(int x, int y, int width, int height, Direction45 dirTo, ColorGradient gradient)
|
||||
{
|
||||
_X = x;
|
||||
_Y = y;
|
||||
|
||||
_Width = width;
|
||||
_Height = height;
|
||||
|
||||
_Direction = dirTo;
|
||||
_Gradient = gradient;
|
||||
}
|
||||
|
||||
public virtual bool GetSegments(out Color[] colors, out int[] sizes, out int count)
|
||||
{
|
||||
switch (_Direction)
|
||||
{
|
||||
case Direction45.Down:
|
||||
case Direction45.Up:
|
||||
_Gradient.GetSegments(_Height, out colors, out sizes, out count);
|
||||
return true;
|
||||
case Direction45.Right:
|
||||
case Direction45.Left:
|
||||
_Gradient.GetSegments(_Width, out colors, out sizes, out count);
|
||||
return true;
|
||||
default:
|
||||
{
|
||||
colors = _EmptyColors;
|
||||
sizes = _EmptySizes;
|
||||
count = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override string Compile()
|
||||
{
|
||||
if (IsEnhancedClient)
|
||||
{
|
||||
return String.Empty;
|
||||
}
|
||||
|
||||
var compiled = String.Empty;
|
||||
|
||||
if (GetSegments(out var colors, out var sizes, out var count) && count > 0)
|
||||
{
|
||||
Color c;
|
||||
int s;
|
||||
|
||||
for (int i = 0, o = 0; i < count; i++)
|
||||
{
|
||||
c = colors[i];
|
||||
s = sizes[i];
|
||||
|
||||
if (!c.IsEmpty && c != Color.Transparent && s > 0)
|
||||
{
|
||||
switch (_Direction)
|
||||
{
|
||||
case Direction45.Down:
|
||||
compiled += Compile(_X, _Y + o, _Width, s, c);
|
||||
break;
|
||||
case Direction45.Up:
|
||||
compiled += Compile(_X, _Y + (_Height - (o + s)), _Width, s, c);
|
||||
break;
|
||||
case Direction45.Right:
|
||||
compiled += Compile(_X + o, _Y, s, _Height, c);
|
||||
break;
|
||||
case Direction45.Left:
|
||||
compiled += Compile(_X + (_Width - (o + s)), _Y, s, _Height, c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
o += s;
|
||||
}
|
||||
}
|
||||
|
||||
if (String.IsNullOrWhiteSpace(compiled))
|
||||
{
|
||||
compiled = Compile(_X, _Y, _Width, _Height, Color.Transparent);
|
||||
}
|
||||
|
||||
return compiled;
|
||||
}
|
||||
|
||||
public virtual string Compile(int x, int y, int w, int h, Color c)
|
||||
{
|
||||
var text = " ";
|
||||
|
||||
if (!c.IsEmpty && c != Color.Transparent)
|
||||
{
|
||||
text = text.WrapUOHtmlBG(c);
|
||||
}
|
||||
|
||||
return String.Format(_Format1, _X, _Y, _Width, _Height, Parent.Intern(text));
|
||||
}
|
||||
|
||||
public override void AppendTo(IGumpWriter disp)
|
||||
{
|
||||
if (IsEnhancedClient)
|
||||
{
|
||||
AppendEmptyLayout(disp);
|
||||
return;
|
||||
}
|
||||
|
||||
var first = true;
|
||||
|
||||
if (GetSegments(out var colors, out var sizes, out var count))
|
||||
{
|
||||
Color c;
|
||||
int s;
|
||||
|
||||
for (int i = 0, o = 0; i < count; i++)
|
||||
{
|
||||
c = colors[i];
|
||||
s = sizes[i];
|
||||
|
||||
if (!c.IsEmpty && c != Color.Transparent && s > 0)
|
||||
{
|
||||
switch (_Direction)
|
||||
{
|
||||
case Direction45.Down:
|
||||
AppendTo(disp, ref first, _X, _Y + o, _Width, s, c);
|
||||
break;
|
||||
case Direction45.Up:
|
||||
AppendTo(disp, ref first, _X, _Y + (_Height - (o + s)), _Width, s, c);
|
||||
break;
|
||||
case Direction45.Right:
|
||||
AppendTo(disp, ref first, _X + o, _Y, s, _Height, c);
|
||||
break;
|
||||
case Direction45.Left:
|
||||
AppendTo(disp, ref first, _X + (_Width - (o + s)), _Y, s, _Height, c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
o += s;
|
||||
}
|
||||
}
|
||||
|
||||
if (first)
|
||||
{
|
||||
AppendTo(disp, ref first, _X, _Y, _Width, _Height, Color.Transparent);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void AppendTo(IGumpWriter disp, ref bool first, int x, int y, int w, int h, Color c)
|
||||
{
|
||||
var text = " ";
|
||||
|
||||
if (!c.IsEmpty && c != Color.Transparent)
|
||||
{
|
||||
text = text.WrapUOHtmlBG(c);
|
||||
}
|
||||
|
||||
disp.AppendLayout(first ? _Layout1A : _Layout1B);
|
||||
disp.AppendLayout(x);
|
||||
disp.AppendLayout(y);
|
||||
disp.AppendLayout(w);
|
||||
disp.AppendLayout(h);
|
||||
disp.AppendLayout(Parent.Intern(text));
|
||||
disp.AppendLayout(false);
|
||||
disp.AppendLayout(false);
|
||||
|
||||
first = false;
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
_Gradient = null;
|
||||
|
||||
base.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#region References
|
||||
using System;
|
||||
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public class GumpImageNumber : SuperGumpEntry, IGumpEntryVector
|
||||
{
|
||||
private const string _Format1A = "{{ gumppic {0} {1} {2} }}";
|
||||
private const string _Format1B = "{{ gumppic {0} {1} {2} hue={3} }}";
|
||||
|
||||
private static readonly byte[] _Layout1A = Gump.StringToBuffer("gumppic");
|
||||
private static readonly byte[] _Layout1B = Gump.StringToBuffer(" }{ gumppic");
|
||||
private static readonly byte[] _Layout1Hue = Gump.StringToBuffer(" hue=");
|
||||
|
||||
private int _X, _Y;
|
||||
private int _Value;
|
||||
private int _Hue;
|
||||
private Axis _Centering;
|
||||
|
||||
public int X { get => _X; set => Delta(ref _X, value); }
|
||||
public int Y { get => _Y; set => Delta(ref _Y, value); }
|
||||
|
||||
public int Value { get => _Value; set => Delta(ref _Value, value); }
|
||||
|
||||
public int Hue { get => _Hue; set => Delta(ref _Hue, value); }
|
||||
|
||||
public Axis Centering { get => _Centering; set => Delta(ref _Centering, value); }
|
||||
|
||||
public int Width
|
||||
{
|
||||
get => (_Value < 0 ? 20 : 0) + (int)((Math.Floor(Math.Log10(Math.Abs(_Value))) + 1) * 20);
|
||||
set { }
|
||||
}
|
||||
|
||||
public int Height { get => 28; set { } }
|
||||
|
||||
public GumpImageNumber(int x, int y, int value, int hue = 0, Axis centering = Axis.None)
|
||||
{
|
||||
_X = x;
|
||||
_Y = y;
|
||||
_Value = value;
|
||||
_Hue = hue;
|
||||
_Centering = centering;
|
||||
}
|
||||
|
||||
public override string Compile()
|
||||
{
|
||||
var x = _X;
|
||||
var y = _Y;
|
||||
|
||||
if (_Centering.HasFlag(Axis.Horizontal))
|
||||
{
|
||||
x -= Width / 2;
|
||||
}
|
||||
|
||||
if (_Centering.HasFlag(Axis.Vertical))
|
||||
{
|
||||
y -= Height / 2;
|
||||
}
|
||||
|
||||
var compiled = String.Empty;
|
||||
var value = _Value.ToString();
|
||||
|
||||
for (int i = 0, s = 0; i < value.Length; i++, s += 20)
|
||||
{
|
||||
switch (value[i])
|
||||
{
|
||||
case '-':
|
||||
{
|
||||
if (_Hue <= 0)
|
||||
{
|
||||
compiled += String.Format(_Format1A, x + s, y + 12, 1433);
|
||||
}
|
||||
else
|
||||
{
|
||||
compiled += String.Format(_Format1B, x + s, y + 12, 1433, FixHue(_Hue));
|
||||
}
|
||||
}
|
||||
continue;
|
||||
default:
|
||||
{
|
||||
if (_Hue <= 0)
|
||||
{
|
||||
compiled += String.Format(_Format1A, x + s, y, 1423 + Byte.Parse(value.Substring(i, 1)));
|
||||
}
|
||||
else
|
||||
{
|
||||
compiled += String.Format(_Format1B, x + s, y, 1423 + Byte.Parse(value.Substring(i, 1)), FixHue(_Hue));
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return compiled;
|
||||
}
|
||||
|
||||
public override void AppendTo(IGumpWriter disp)
|
||||
{
|
||||
var x = _X;
|
||||
var y = _Y;
|
||||
|
||||
if (_Centering.HasFlag(Axis.Horizontal))
|
||||
{
|
||||
x -= Width / 2;
|
||||
}
|
||||
|
||||
if (_Centering.HasFlag(Axis.Vertical))
|
||||
{
|
||||
y -= Height / 2;
|
||||
}
|
||||
|
||||
var value = _Value.ToString();
|
||||
|
||||
for (int i = 0, s = 0; i < value.Length; i++, s += 20)
|
||||
{
|
||||
switch (value[i])
|
||||
{
|
||||
case '-':
|
||||
{
|
||||
disp.AppendLayout(_Layout1A);
|
||||
disp.AppendLayout(x + s);
|
||||
disp.AppendLayout(y + 12);
|
||||
disp.AppendLayout(1433);
|
||||
|
||||
if (_Hue > 0)
|
||||
{
|
||||
disp.AppendLayout(_Layout1Hue);
|
||||
disp.AppendLayoutNS(FixHue(_Hue));
|
||||
}
|
||||
}
|
||||
continue;
|
||||
default:
|
||||
{
|
||||
disp.AppendLayout(i == 0 ? _Layout1A : _Layout1B);
|
||||
disp.AppendLayout(x + s);
|
||||
disp.AppendLayout(y);
|
||||
disp.AppendLayout(1423 + Byte.Parse(value.Substring(i, 1)));
|
||||
|
||||
if (_Hue > 0)
|
||||
{
|
||||
disp.AppendLayout(_Layout1Hue);
|
||||
disp.AppendLayoutNS(FixHue(_Hue));
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#region References
|
||||
using System;
|
||||
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public class GumpImageShadow : SuperGumpEntry, IGumpEntryPoint
|
||||
{
|
||||
private const string _Format1A = "{{ gumppic {0} {1} {2} }}";
|
||||
private const string _Format1B = "{{ gumppic {0} {1} {2} hue={3} }}";
|
||||
|
||||
private static readonly byte[] _Layout1A = Gump.StringToBuffer("gumppic");
|
||||
private static readonly byte[] _Layout1B = Gump.StringToBuffer(" }{ gumppic");
|
||||
private static readonly byte[] _Layout1Hue = Gump.StringToBuffer(" hue=");
|
||||
|
||||
private int _X, _Y;
|
||||
private int _ImageID, _ImageHue;
|
||||
private Angle _ShadowAngle;
|
||||
private int _ShadowOffset, _ShadowHue;
|
||||
|
||||
public int X { get => _X; set => Delta(ref _X, value); }
|
||||
public int Y { get => _Y; set => Delta(ref _Y, value); }
|
||||
|
||||
public int ImageID { get => _ImageID; set => Delta(ref _ImageID, value); }
|
||||
public int ImageHue { get => _ImageHue; set => Delta(ref _ImageHue, value); }
|
||||
|
||||
public Angle ShadowAngle { get => _ShadowAngle; set => Delta(ref _ShadowAngle, value); }
|
||||
public int ShadowOffset { get => _ShadowOffset; set => Delta(ref _ShadowOffset, value); }
|
||||
public int ShadowHue { get => _ShadowHue; set => Delta(ref _ShadowHue, value); }
|
||||
|
||||
public GumpImageShadow(int x, int y, int imageID)
|
||||
: this(x, y, imageID, 0)
|
||||
{ }
|
||||
|
||||
public GumpImageShadow(int x, int y, int imageID, int imageHue)
|
||||
: this(x, y, imageID, imageHue, 45)
|
||||
{ }
|
||||
|
||||
public GumpImageShadow(int x, int y, int imageID, int imageHue, Angle shadowAngle)
|
||||
: this(x, y, imageID, imageHue, shadowAngle, 5)
|
||||
{ }
|
||||
|
||||
public GumpImageShadow(int x, int y, int imageID, int imageHue, Angle shadowAngle, int shadowOffset)
|
||||
: this(x, y, imageID, imageHue, shadowAngle, shadowOffset, 2999)
|
||||
{ }
|
||||
|
||||
public GumpImageShadow(int x, int y, int imageID, int imageHue, Angle shadowAngle, int shadowOffset, int shadowHue)
|
||||
{
|
||||
_X = x;
|
||||
_Y = y;
|
||||
_ImageID = imageID;
|
||||
_ImageHue = imageHue;
|
||||
_ShadowAngle = shadowAngle;
|
||||
_ShadowOffset = shadowOffset;
|
||||
_ShadowHue = shadowHue;
|
||||
}
|
||||
|
||||
public override string Compile()
|
||||
{
|
||||
var compiled = String.Empty;
|
||||
|
||||
var s = _ShadowAngle.GetPoint2D(_X, _Y, _ShadowOffset);
|
||||
|
||||
if (_ShadowHue <= 0)
|
||||
{
|
||||
compiled += String.Format(_Format1A, s.X, s.Y, _ImageID);
|
||||
}
|
||||
else
|
||||
{
|
||||
compiled += String.Format(_Format1B, s.X, s.Y, _ImageID, FixHue(_ShadowHue));
|
||||
}
|
||||
|
||||
if (_ImageHue <= 0)
|
||||
{
|
||||
compiled += String.Format(_Format1A, _X, _Y, _ImageID);
|
||||
}
|
||||
else
|
||||
{
|
||||
compiled += String.Format(_Format1B, _X, _Y, _ImageID, FixHue(_ImageHue));
|
||||
}
|
||||
|
||||
return compiled;
|
||||
}
|
||||
|
||||
public override void AppendTo(IGumpWriter disp)
|
||||
{
|
||||
var s = _ShadowAngle.GetPoint2D(_X, _Y, _ShadowOffset);
|
||||
|
||||
disp.AppendLayout(_Layout1A);
|
||||
disp.AppendLayout(s.X);
|
||||
disp.AppendLayout(s.Y);
|
||||
disp.AppendLayout(_ImageID);
|
||||
|
||||
if (_ShadowHue > 0)
|
||||
{
|
||||
disp.AppendLayout(_Layout1Hue);
|
||||
disp.AppendLayoutNS(FixHue(_ShadowHue));
|
||||
}
|
||||
|
||||
disp.AppendLayout(_Layout1B);
|
||||
disp.AppendLayout(_X);
|
||||
disp.AppendLayout(_Y);
|
||||
disp.AppendLayout(_ImageID);
|
||||
|
||||
if (_ImageHue > 0)
|
||||
{
|
||||
disp.AppendLayout(_Layout1Hue);
|
||||
disp.AppendLayoutNS(FixHue(_ImageHue));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,223 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#region References
|
||||
using System;
|
||||
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public class GumpImageTime : SuperGumpEntry, IGumpEntryVector
|
||||
{
|
||||
private const string _Format1A = "{{ gumppic {0} {1} {2} }}";
|
||||
private const string _Format1B = "{{ gumppic {0} {1} {2} hue={3} }}";
|
||||
|
||||
private static readonly byte[] _Layout1A = Gump.StringToBuffer("gumppic");
|
||||
private static readonly byte[] _Layout1B = Gump.StringToBuffer(" }{ gumppic");
|
||||
private static readonly byte[] _Layout1Hue = Gump.StringToBuffer(" hue=");
|
||||
|
||||
private int _X, _Y;
|
||||
private TimeSpan _Value;
|
||||
private int _Hue;
|
||||
private Axis _Centering;
|
||||
|
||||
public int X { get => _X; set => Delta(ref _X, value); }
|
||||
public int Y { get => _Y; set => Delta(ref _Y, value); }
|
||||
|
||||
public TimeSpan Value { get => _Value; set => Delta(ref _Value, value); }
|
||||
|
||||
public int Hue { get => _Hue; set => Delta(ref _Hue, value); }
|
||||
|
||||
public Axis Centering { get => _Centering; set => Delta(ref _Centering, value); }
|
||||
|
||||
public virtual int Width { get => _Value < TimeSpan.Zero ? 195 : 175; set { } }
|
||||
public virtual int Height { get => 28; set { } }
|
||||
|
||||
public GumpImageTime(int x, int y, TimeSpan value, int hue = 0, Axis centering = Axis.None)
|
||||
{
|
||||
_X = x;
|
||||
_Y = y;
|
||||
_Value = value;
|
||||
_Hue = hue;
|
||||
_Centering = centering;
|
||||
}
|
||||
|
||||
public virtual string GetString()
|
||||
{
|
||||
return String.Format(
|
||||
"{0}{1:D2}:{2:D2}:{3:D2}:{4:D2}",
|
||||
_Value < TimeSpan.Zero ? "-" : String.Empty,
|
||||
Math.Abs(_Value.Days),
|
||||
Math.Abs(_Value.Hours),
|
||||
Math.Abs(_Value.Minutes),
|
||||
Math.Abs(_Value.Seconds));
|
||||
}
|
||||
|
||||
public override string Compile()
|
||||
{
|
||||
var x = _X;
|
||||
var y = _Y;
|
||||
|
||||
if (_Centering.HasFlag(Axis.Horizontal))
|
||||
{
|
||||
x -= Width / 2;
|
||||
}
|
||||
|
||||
if (_Centering.HasFlag(Axis.Vertical))
|
||||
{
|
||||
y -= Height / 2;
|
||||
}
|
||||
|
||||
var compiled = String.Empty;
|
||||
var val = GetString();
|
||||
|
||||
for (int i = 0, s = 0; i < val.Length; i++)
|
||||
{
|
||||
switch (val[i])
|
||||
{
|
||||
case '-':
|
||||
{
|
||||
if (_Hue <= 0)
|
||||
{
|
||||
compiled += String.Format(_Format1A, x + s, y + 12, 1433);
|
||||
}
|
||||
else
|
||||
{
|
||||
compiled += String.Format(_Format1B, x + s, y + 12, 1433, FixHue(_Hue));
|
||||
}
|
||||
|
||||
s += 20;
|
||||
}
|
||||
continue;
|
||||
case ':':
|
||||
{
|
||||
if (_Hue <= 0)
|
||||
{
|
||||
compiled += String.Format(_Format1A, x + s, y + 7, 1433);
|
||||
compiled += String.Format(_Format1A, x + s, y + 17, 1433);
|
||||
}
|
||||
else
|
||||
{
|
||||
compiled += String.Format(_Format1B, x + s, y + 7, 1433, FixHue(_Hue));
|
||||
compiled += String.Format(_Format1B, x + s, y + 17, 1433, FixHue(_Hue));
|
||||
}
|
||||
|
||||
s += 5;
|
||||
}
|
||||
continue;
|
||||
default:
|
||||
{
|
||||
if (_Hue <= 0)
|
||||
{
|
||||
compiled += String.Format(_Format1A, x + s, y, 1423 + Byte.Parse(val.Substring(i, 1)));
|
||||
}
|
||||
else
|
||||
{
|
||||
compiled += String.Format(_Format1B, x + s, y, 1423 + Byte.Parse(val.Substring(i, 1)), FixHue(_Hue));
|
||||
}
|
||||
|
||||
s += 20;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return compiled;
|
||||
}
|
||||
|
||||
public override void AppendTo(IGumpWriter disp)
|
||||
{
|
||||
var x = _X;
|
||||
var y = _Y;
|
||||
|
||||
if (_Centering.HasFlag(Axis.Horizontal))
|
||||
{
|
||||
x -= Width / 2;
|
||||
}
|
||||
|
||||
if (_Centering.HasFlag(Axis.Vertical))
|
||||
{
|
||||
y -= Height / 2;
|
||||
}
|
||||
|
||||
var val = GetString();
|
||||
|
||||
for (int i = 0, s = 0; i < val.Length; i++)
|
||||
{
|
||||
switch (val[i])
|
||||
{
|
||||
case '-':
|
||||
{
|
||||
disp.AppendLayout(_Layout1A);
|
||||
disp.AppendLayout(x + s);
|
||||
disp.AppendLayout(y + 12);
|
||||
disp.AppendLayout(1433);
|
||||
|
||||
if (_Hue > 0)
|
||||
{
|
||||
disp.AppendLayout(_Layout1Hue);
|
||||
disp.AppendLayoutNS(FixHue(_Hue));
|
||||
}
|
||||
|
||||
s += 20;
|
||||
}
|
||||
continue;
|
||||
case ':':
|
||||
{
|
||||
disp.AppendLayout(_Layout1B);
|
||||
disp.AppendLayout(x + s);
|
||||
disp.AppendLayout(y + 7);
|
||||
disp.AppendLayout(1433);
|
||||
|
||||
if (_Hue > 0)
|
||||
{
|
||||
disp.AppendLayout(_Layout1Hue);
|
||||
disp.AppendLayoutNS(FixHue(_Hue));
|
||||
}
|
||||
|
||||
disp.AppendLayout(_Layout1B);
|
||||
disp.AppendLayout(x + s);
|
||||
disp.AppendLayout(y + 17);
|
||||
disp.AppendLayout(1433);
|
||||
|
||||
if (_Hue > 0)
|
||||
{
|
||||
disp.AppendLayout(_Layout1Hue);
|
||||
disp.AppendLayoutNS(FixHue(_Hue));
|
||||
}
|
||||
|
||||
s += 5;
|
||||
}
|
||||
continue;
|
||||
default:
|
||||
{
|
||||
disp.AppendLayout(i == 0 ? _Layout1A : _Layout1B);
|
||||
disp.AppendLayout(x + s);
|
||||
disp.AppendLayout(y);
|
||||
disp.AppendLayout(1423 + Byte.Parse(val.Substring(i, 1)));
|
||||
|
||||
if (_Hue > 0)
|
||||
{
|
||||
disp.AppendLayout(_Layout1Hue);
|
||||
disp.AppendLayoutNS(FixHue(_Hue));
|
||||
}
|
||||
|
||||
s += 20;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#region References
|
||||
using System;
|
||||
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public class GumpInputEC : SuperGumpEntry
|
||||
{
|
||||
private static readonly byte[] _LayoutName = Gump.StringToBuffer("echandleinput");
|
||||
|
||||
public override string Compile()
|
||||
{
|
||||
if (!IsEnhancedClient)
|
||||
{
|
||||
return String.Empty;
|
||||
}
|
||||
|
||||
return "{{ echandleinput }}";
|
||||
}
|
||||
|
||||
public override void AppendTo(IGumpWriter disp)
|
||||
{
|
||||
if (!IsEnhancedClient)
|
||||
{
|
||||
AppendEmptyLayout(disp);
|
||||
return;
|
||||
}
|
||||
|
||||
disp.AppendLayout(_LayoutName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#region References
|
||||
using System;
|
||||
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public class GumpItemShadow : SuperGumpEntry, IGumpEntryPoint
|
||||
{
|
||||
private const string _Format1 = "{{ tilepic {0} {1} {2} }}";
|
||||
private const string _Format2 = "{{ tilepichue {0} {1} {2} {3} }}";
|
||||
|
||||
private static readonly byte[] _Layout1A = Gump.StringToBuffer("tilepic");
|
||||
private static readonly byte[] _Layout1B = Gump.StringToBuffer(" }{ tilepic");
|
||||
private static readonly byte[] _Layout2A = Gump.StringToBuffer("tilepichue");
|
||||
private static readonly byte[] _Layout2B = Gump.StringToBuffer(" }{ tilepichue");
|
||||
|
||||
private int _X, _Y;
|
||||
private int _ItemID, _ItemHue;
|
||||
private Angle _ShadowAngle;
|
||||
private int _ShadowOffset, _ShadowHue;
|
||||
|
||||
public int X { get => _X; set => Delta(ref _X, value); }
|
||||
public int Y { get => _Y; set => Delta(ref _Y, value); }
|
||||
|
||||
public int ItemID { get => _ItemID; set => Delta(ref _ItemID, value); }
|
||||
public int ItemHue { get => _ItemHue; set => Delta(ref _ItemHue, value); }
|
||||
|
||||
public Angle ShadowAngle { get => _ShadowAngle; set => Delta(ref _ShadowAngle, value); }
|
||||
public int ShadowOffset { get => _ShadowOffset; set => Delta(ref _ShadowOffset, value); }
|
||||
public int ShadowHue { get => _ShadowHue; set => Delta(ref _ShadowHue, value); }
|
||||
|
||||
public GumpItemShadow(int x, int y, int itemID)
|
||||
: this(x, y, itemID, 0)
|
||||
{ }
|
||||
|
||||
public GumpItemShadow(int x, int y, int itemID, int itemHue)
|
||||
: this(x, y, itemID, itemHue, 45)
|
||||
{ }
|
||||
|
||||
public GumpItemShadow(int x, int y, int itemID, int itemHue, Angle shadowAngle)
|
||||
: this(x, y, itemID, itemHue, shadowAngle, 5)
|
||||
{ }
|
||||
|
||||
public GumpItemShadow(int x, int y, int itemID, int itemHue, Angle shadowAngle, int shadowOffset)
|
||||
: this(x, y, itemID, itemHue, shadowAngle, shadowOffset, 2999)
|
||||
{ }
|
||||
|
||||
public GumpItemShadow(int x, int y, int itemID, int itemHue, Angle shadowAngle, int shadowOffset, int shadowHue)
|
||||
{
|
||||
_X = x;
|
||||
_Y = y;
|
||||
_ItemID = itemID;
|
||||
_ItemHue = itemHue;
|
||||
_ShadowAngle = shadowAngle;
|
||||
_ShadowOffset = shadowOffset;
|
||||
_ShadowHue = shadowHue;
|
||||
}
|
||||
|
||||
public override string Compile()
|
||||
{
|
||||
var compiled = String.Empty;
|
||||
|
||||
var s = _ShadowAngle.GetPoint2D(_X, _Y, _ShadowOffset);
|
||||
|
||||
if (_ShadowHue <= 0)
|
||||
{
|
||||
compiled += String.Format(_Format1, s.X, s.Y, _ItemID);
|
||||
}
|
||||
else
|
||||
{
|
||||
compiled += String.Format(_Format2, s.X, s.Y, _ItemID, FixHue(_ShadowHue, true));
|
||||
}
|
||||
|
||||
if (_ItemHue <= 0)
|
||||
{
|
||||
compiled += String.Format(_Format1, _X, _Y, _ItemID);
|
||||
}
|
||||
else
|
||||
{
|
||||
compiled += String.Format(_Format2, _X, _Y, _ItemID, FixHue(_ItemHue, true));
|
||||
}
|
||||
|
||||
return compiled;
|
||||
}
|
||||
|
||||
public override void AppendTo(IGumpWriter disp)
|
||||
{
|
||||
var s = _ShadowAngle.GetPoint2D(_X, _Y, _ShadowOffset);
|
||||
|
||||
disp.AppendLayout(_ShadowHue > 0 ? _Layout2A : _Layout1A);
|
||||
disp.AppendLayout(s.X);
|
||||
disp.AppendLayout(s.Y);
|
||||
disp.AppendLayout(_ItemID);
|
||||
|
||||
if (_ShadowHue > 0)
|
||||
{
|
||||
disp.AppendLayout(FixHue(_ShadowHue, true));
|
||||
}
|
||||
|
||||
disp.AppendLayout(_ItemHue > 0 ? _Layout2B : _Layout1B);
|
||||
disp.AppendLayout(_X);
|
||||
disp.AppendLayout(_Y);
|
||||
disp.AppendLayout(_ItemID);
|
||||
|
||||
if (_ItemHue > 0)
|
||||
{
|
||||
disp.AppendLayout(FixHue(_ItemHue, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,333 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#region References
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public class GumpLine : SuperGumpEntry, IGumpEntryVector
|
||||
{
|
||||
private const string _Format1 = @"{{ htmlgump {0} {1} {2} {3} {4} 0 0 }}";
|
||||
|
||||
private static readonly byte[] _Layout1A = Gump.StringToBuffer("htmlgump");
|
||||
private static readonly byte[] _Layout1B = Gump.StringToBuffer(" }{ htmlgump");
|
||||
|
||||
private static int GetLength(int x1, int y1, int x2, int y2)
|
||||
{
|
||||
return (int)Line2D.GetLength(new Point2D(x1, y1), new Point2D(x2, y2));
|
||||
}
|
||||
|
||||
private int _X1, _Y1;
|
||||
private int _X2, _Y2;
|
||||
|
||||
private int _Size;
|
||||
private Color _Color;
|
||||
|
||||
int IGumpEntryPoint.X { get => StartX; set => StartX = value; }
|
||||
int IGumpEntryPoint.Y { get => StartY; set => StartY = value; }
|
||||
|
||||
public int StartX { get => _X1; set => Delta(ref _X1, value); }
|
||||
public int StartY { get => _Y1; set => Delta(ref _Y1, value); }
|
||||
|
||||
public int EndX { get => _X2; set => Delta(ref _X2, value); }
|
||||
public int EndY { get => _Y2; set => Delta(ref _Y2, value); }
|
||||
|
||||
public int Width
|
||||
{
|
||||
get => Math.Abs(_X2 - _X1);
|
||||
set
|
||||
{
|
||||
if (_X2 >= _X1)
|
||||
{
|
||||
Delta(ref _X2, _X2 + (value - Width));
|
||||
}
|
||||
else
|
||||
{
|
||||
Delta(ref _X1, _X1 + (value - Width));
|
||||
}
|
||||
|
||||
Delta(ref _Rotation, Angle.FromPoints(_X1, _Y1, _X2, _Y2));
|
||||
Delta(ref _Length, GetLength(_X1, _Y1, _X2, _Y2));
|
||||
}
|
||||
}
|
||||
|
||||
public int Height
|
||||
{
|
||||
get => Math.Abs(_Y2 - _Y1);
|
||||
set
|
||||
{
|
||||
if (_Y2 >= _Y1)
|
||||
{
|
||||
Delta(ref _Y2, _Y2 + (value - Height));
|
||||
}
|
||||
else
|
||||
{
|
||||
Delta(ref _Y1, _Y1 + (value - Height));
|
||||
}
|
||||
|
||||
Delta(ref _Rotation, Angle.FromPoints(_X1, _Y1, _X2, _Y2));
|
||||
Delta(ref _Length, GetLength(_X1, _Y1, _X2, _Y2));
|
||||
}
|
||||
}
|
||||
|
||||
private Angle _Rotation;
|
||||
|
||||
public Angle Rotation
|
||||
{
|
||||
get => _Rotation;
|
||||
set
|
||||
{
|
||||
if (value == _Rotation)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Delta(ref _Rotation, value);
|
||||
|
||||
int x = _X1, y = _Y1;
|
||||
|
||||
_Rotation.Transform(ref x, ref y, _Length);
|
||||
|
||||
Delta(ref _X2, x);
|
||||
Delta(ref _Y2, y);
|
||||
}
|
||||
}
|
||||
|
||||
private int _Length;
|
||||
|
||||
public int Length
|
||||
{
|
||||
get => _Length;
|
||||
set
|
||||
{
|
||||
if (_Length == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Delta(ref _Length, value);
|
||||
|
||||
int x = _X1, y = _Y1;
|
||||
|
||||
_Rotation.Transform(ref x, ref y, _Length);
|
||||
|
||||
Delta(ref _X2, x);
|
||||
Delta(ref _Y2, y);
|
||||
}
|
||||
}
|
||||
|
||||
public Color Color { get => _Color; set => Delta(ref _Color, value); }
|
||||
public int Size { get => _Size; set => Delta(ref _Size, value); }
|
||||
|
||||
public GumpLine(IPoint2D start, IPoint2D end, Color color)
|
||||
: this(start, end, color, 1)
|
||||
{ }
|
||||
|
||||
public GumpLine(IPoint2D start, IPoint2D end, Color color, int size)
|
||||
{
|
||||
_X1 = start.X;
|
||||
_Y1 = start.Y;
|
||||
_X2 = end.X;
|
||||
_Y2 = end.Y;
|
||||
|
||||
_Rotation = Angle.FromPoints(_X1, _Y1, _X2, _Y2);
|
||||
_Length = GetLength(_X1, _Y1, _X2, _Y2);
|
||||
|
||||
_Color = color;
|
||||
_Size = size;
|
||||
}
|
||||
|
||||
public GumpLine(IPoint2D start, Angle angle, int length, Color color)
|
||||
: this(start, angle, length, color, 1)
|
||||
{ }
|
||||
|
||||
public GumpLine(IPoint2D start, Angle angle, int length, Color color, int size)
|
||||
: this(start.X, start.Y, angle, length, color, size)
|
||||
{ }
|
||||
|
||||
public GumpLine(int x, int y, Angle angle, int length, Color color)
|
||||
: this(x, y, angle, length, color, 1)
|
||||
{ }
|
||||
|
||||
public GumpLine(int x, int y, Angle angle, int length, Color color, int size)
|
||||
{
|
||||
_Rotation = angle;
|
||||
_Length = length;
|
||||
|
||||
_X1 = x;
|
||||
_Y1 = y;
|
||||
|
||||
_Rotation.Transform(ref x, ref y, _Length);
|
||||
|
||||
_X2 = x;
|
||||
_Y2 = y;
|
||||
|
||||
_Color = color;
|
||||
_Size = size;
|
||||
}
|
||||
|
||||
public override string Compile()
|
||||
{
|
||||
if (IsEnhancedClient)
|
||||
{
|
||||
return String.Empty;
|
||||
}
|
||||
|
||||
if (_Size <= 0 || _Color.IsEmpty || _Color == Color.Transparent)
|
||||
{
|
||||
return Compile(_X1, _Y1, 1, Color.Transparent);
|
||||
}
|
||||
|
||||
string compiled;
|
||||
|
||||
if (_X1 == _X2 && _Y1 == _Y2)
|
||||
{
|
||||
compiled = Compile(_X1, _Y1, _Size, _Color);
|
||||
}
|
||||
else
|
||||
{
|
||||
var line = new Point2D(_X1, _Y1).PlotLine2D(new Point2D(_X2, _Y2));
|
||||
|
||||
compiled = String.Concat(line.Select(p => Compile(p.X, p.Y, _Size, _Color)));
|
||||
}
|
||||
|
||||
if (String.IsNullOrWhiteSpace(compiled))
|
||||
{
|
||||
compiled = Compile(_X1, _Y1, 1, Color.Transparent);
|
||||
}
|
||||
|
||||
return compiled;
|
||||
}
|
||||
|
||||
public virtual string Compile(int x, int y, int s, Color color)
|
||||
{
|
||||
x -= s / 2;
|
||||
y -= s / 2;
|
||||
|
||||
var w = s;
|
||||
var h = s;
|
||||
|
||||
while (x < 0)
|
||||
{
|
||||
++x;
|
||||
--w;
|
||||
}
|
||||
|
||||
while (y < 0)
|
||||
{
|
||||
++y;
|
||||
--h;
|
||||
}
|
||||
|
||||
if (w <= 0 || h <= 0)
|
||||
{
|
||||
return String.Empty;
|
||||
}
|
||||
|
||||
var text = " ";
|
||||
|
||||
if (!color.IsEmpty && color != Color.Transparent)
|
||||
{
|
||||
text = text.WrapUOHtmlBG(color);
|
||||
}
|
||||
|
||||
return String.Format(_Format1, x, y, w, h, Parent.Intern(text));
|
||||
}
|
||||
|
||||
public override void AppendTo(IGumpWriter disp)
|
||||
{
|
||||
if (IsEnhancedClient)
|
||||
{
|
||||
AppendEmptyLayout(disp);
|
||||
return;
|
||||
}
|
||||
|
||||
var first = true;
|
||||
|
||||
if (_Size <= 0 || _Color.IsEmpty || _Color == Color.Transparent)
|
||||
{
|
||||
AppendTo(disp, ref first, _X1, _Y1, 1, Color.Transparent);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_X1 == _X2 && _Y1 == _Y2)
|
||||
{
|
||||
AppendTo(disp, ref first, _X1, _Y1, _Size, _Color);
|
||||
}
|
||||
else
|
||||
{
|
||||
var line = new Point2D(_X1, _Y1).PlotLine2D(new Point2D(_X2, _Y2));
|
||||
|
||||
foreach (var p in line)
|
||||
{
|
||||
AppendTo(disp, ref first, p.X, p.Y, _Size, _Color);
|
||||
}
|
||||
}
|
||||
|
||||
if (first)
|
||||
{
|
||||
AppendTo(disp, ref first, _X1, _Y1, 1, Color.Transparent);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void AppendTo(IGumpWriter disp, ref bool first, int x, int y, int s, Color color)
|
||||
{
|
||||
x -= s / 2;
|
||||
y -= s / 2;
|
||||
|
||||
var w = s;
|
||||
var h = s;
|
||||
|
||||
while (x < 0)
|
||||
{
|
||||
++x;
|
||||
--w;
|
||||
}
|
||||
|
||||
while (y < 0)
|
||||
{
|
||||
++y;
|
||||
--h;
|
||||
}
|
||||
|
||||
if (w <= 0 || h <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var text = " ";
|
||||
|
||||
if (!color.IsEmpty && color != Color.Transparent)
|
||||
{
|
||||
text = text.WrapUOHtmlBG(color);
|
||||
}
|
||||
|
||||
disp.AppendLayout(first ? _Layout1A : _Layout1B);
|
||||
disp.AppendLayout(x);
|
||||
disp.AppendLayout(y);
|
||||
disp.AppendLayout(w);
|
||||
disp.AppendLayout(h);
|
||||
disp.AppendLayout(Parent.Intern(text));
|
||||
disp.AppendLayout(false);
|
||||
disp.AppendLayout(false);
|
||||
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#region References
|
||||
using System;
|
||||
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public class GumpModal : SuperGumpEntry, IGumpEntryVector
|
||||
{
|
||||
private const string _Format1 = "{{ gumppictiled {0} {1} {2} {3} {4} }}";
|
||||
private const string _Format2 = "{{ checkertrans {0} {1} {2} {3} }}";
|
||||
|
||||
private static readonly byte[] _Layout1A = Gump.StringToBuffer("gumppictiled");
|
||||
private static readonly byte[] _Layout1B = Gump.StringToBuffer(" }{ gumppictiled");
|
||||
private static readonly byte[] _Layout2A = Gump.StringToBuffer("checkertrans");
|
||||
private static readonly byte[] _Layout2B = Gump.StringToBuffer(" }{ checkertrans");
|
||||
|
||||
private int _X, _Y;
|
||||
private int _Width, _Height;
|
||||
private int _GumpID;
|
||||
|
||||
public int X { get => _X; set => Delta(ref _X, value); }
|
||||
public int Y { get => _Y; set => Delta(ref _Y, value); }
|
||||
|
||||
public int Width { get => _Width; set => Delta(ref _Width, value); }
|
||||
public int Height { get => _Height; set => Delta(ref _Height, value); }
|
||||
|
||||
public int GumpID { get => _GumpID; set => Delta(ref _GumpID, value); }
|
||||
|
||||
public override bool IgnoreModalOffset => true;
|
||||
|
||||
public GumpModal(int x, int y, int width, int height, int gumpID)
|
||||
{
|
||||
_X = x;
|
||||
_Y = y;
|
||||
|
||||
_Width = width;
|
||||
_Height = height;
|
||||
|
||||
_GumpID = gumpID;
|
||||
}
|
||||
|
||||
public override string Compile()
|
||||
{
|
||||
if (_Width <= 1024 && _Height <= 786)
|
||||
{
|
||||
return Compile(_X, _Y, _Width, _Height);
|
||||
}
|
||||
|
||||
var compiled = String.Empty;
|
||||
|
||||
var xx = _X;
|
||||
var ww = _Width;
|
||||
|
||||
while (ww > 0)
|
||||
{
|
||||
var yy = _Y;
|
||||
var hh = _Height;
|
||||
|
||||
var mw = Math.Min(1024, ww);
|
||||
|
||||
while (hh > 0)
|
||||
{
|
||||
var mh = Math.Min(786, hh);
|
||||
|
||||
compiled += Compile(xx, yy, mw, mh);
|
||||
|
||||
yy += mh;
|
||||
hh -= mh;
|
||||
}
|
||||
|
||||
xx += mw;
|
||||
ww -= mw;
|
||||
}
|
||||
|
||||
return compiled;
|
||||
}
|
||||
|
||||
public virtual string Compile(int x, int y, int w, int h)
|
||||
{
|
||||
var compiled = String.Empty;
|
||||
|
||||
if (_GumpID >= 0)
|
||||
{
|
||||
compiled += String.Format(_Format1, x, y, w, h, _GumpID);
|
||||
}
|
||||
|
||||
compiled += String.Format(_Format2, x, y, w, h);
|
||||
|
||||
return compiled;
|
||||
}
|
||||
|
||||
public override void AppendTo(IGumpWriter disp)
|
||||
{
|
||||
if (_Width <= 1024 && _Height <= 786)
|
||||
{
|
||||
AppendTo(disp, _X, _Y, _Width, _Height);
|
||||
return;
|
||||
}
|
||||
|
||||
var xx = _X;
|
||||
var ww = _Width;
|
||||
|
||||
while (ww > 0)
|
||||
{
|
||||
var yy = _Y;
|
||||
var hh = _Height;
|
||||
|
||||
var mw = Math.Min(1024, ww);
|
||||
|
||||
while (hh > 0)
|
||||
{
|
||||
var mh = Math.Min(786, hh);
|
||||
|
||||
AppendTo(disp, xx, yy, mw, mh);
|
||||
|
||||
yy += mh;
|
||||
hh -= mh;
|
||||
}
|
||||
|
||||
xx += mw;
|
||||
ww -= mw;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void AppendTo(IGumpWriter disp, int x, int y, int w, int h)
|
||||
{
|
||||
var first = _X == x && _Y == y;
|
||||
|
||||
if (_GumpID >= 0)
|
||||
{
|
||||
disp.AppendLayout(first ? _Layout1A : _Layout1B);
|
||||
disp.AppendLayout(x);
|
||||
disp.AppendLayout(y);
|
||||
disp.AppendLayout(w);
|
||||
disp.AppendLayout(h);
|
||||
disp.AppendLayout(_GumpID);
|
||||
|
||||
disp.AppendLayout(_Layout2B);
|
||||
disp.AppendLayout(x);
|
||||
disp.AppendLayout(y);
|
||||
disp.AppendLayout(w);
|
||||
disp.AppendLayout(h);
|
||||
}
|
||||
else
|
||||
{
|
||||
disp.AppendLayout(first ? _Layout2A : _Layout2B);
|
||||
disp.AppendLayout(x);
|
||||
disp.AppendLayout(y);
|
||||
disp.AppendLayout(w);
|
||||
disp.AppendLayout(h);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
#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 Server.Items;
|
||||
using Server.Network;
|
||||
|
||||
using Ultima;
|
||||
|
||||
using MultiComponentList = Server.MultiComponentList;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public class GumpMulti : SuperGumpEntry, IGumpEntryPoint
|
||||
{
|
||||
private const string _Format1 = "{{ tilepic {0} {1} {2} }}";
|
||||
private const string _Format2 = "{{ tilepichue {0} {1} {2} {3} }}";
|
||||
|
||||
private static readonly byte[] _Layout1A = Gump.StringToBuffer("tilepic");
|
||||
private static readonly byte[] _Layout1B = Gump.StringToBuffer(" }{ tilepic");
|
||||
private static readonly byte[] _Layout2A = Gump.StringToBuffer("tilepichue");
|
||||
private static readonly byte[] _Layout2B = Gump.StringToBuffer(" }{ tilepichue");
|
||||
|
||||
private int _X, _Y;
|
||||
private int _Hue;
|
||||
private MultiComponentList _Components;
|
||||
|
||||
public int X { get => _X; set => Delta(ref _X, value); }
|
||||
public int Y { get => _Y; set => Delta(ref _Y, value); }
|
||||
|
||||
public int Hue { get => _Hue; set => Delta(ref _Hue, value); }
|
||||
|
||||
public MultiComponentList Components { get => _Components; set => Delta(ref _Components, value); }
|
||||
|
||||
public Point Offset
|
||||
{
|
||||
get
|
||||
{
|
||||
var o = Components.GetImageOffset();
|
||||
|
||||
o.X = _X + (o.X < 0 ? Math.Abs(o.X) : o.X);
|
||||
o.Y = _Y + (o.Y < 0 ? Math.Abs(o.Y) : o.Y);
|
||||
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
private Size? _Size;
|
||||
|
||||
public Size Size => _Size ?? (_Size = Components.GetImageSize()).Value;
|
||||
|
||||
public int Width => Size.Width;
|
||||
public int Height => Size.Height;
|
||||
|
||||
public GumpMulti(int x, int y, BaseMulti multi)
|
||||
: this(x, y, multi.Hue, multi.GetComponents())
|
||||
{ }
|
||||
|
||||
public GumpMulti(int x, int y, int multiID)
|
||||
: this(x, y, 0, multiID)
|
||||
{ }
|
||||
|
||||
public GumpMulti(int x, int y, int hue, int multiID)
|
||||
: this(x, y, hue, MultiExtUtility.GetComponents(multiID))
|
||||
{ }
|
||||
|
||||
public GumpMulti(int x, int y, MultiComponentList components)
|
||||
: this(x, y, 0, components)
|
||||
{ }
|
||||
|
||||
public GumpMulti(int x, int y, int hue, MultiComponentList components)
|
||||
{
|
||||
_X = x;
|
||||
_Y = y;
|
||||
_Hue = hue;
|
||||
_Components = components ?? MultiComponentList.Empty;
|
||||
}
|
||||
|
||||
protected override void OnInvalidate<T>(T old, T val)
|
||||
{
|
||||
base.OnInvalidate(old, val);
|
||||
|
||||
if (val is MultiComponentList)
|
||||
{
|
||||
_Size = null;
|
||||
}
|
||||
}
|
||||
|
||||
public override string Compile()
|
||||
{
|
||||
var compiled = String.Empty;
|
||||
|
||||
if (_Components.List.IsNullOrEmpty())
|
||||
{
|
||||
if (_Hue > 0)
|
||||
{
|
||||
compiled += String.Format(_Format2, _X, _Y, 1, FixHue(_Hue, true));
|
||||
}
|
||||
else
|
||||
{
|
||||
compiled += String.Format(_Format1, _X, _Y, 1);
|
||||
}
|
||||
|
||||
return compiled;
|
||||
}
|
||||
|
||||
var o = Offset;
|
||||
|
||||
Components.EnumerateByRender(
|
||||
(p, t) =>
|
||||
{
|
||||
if (_Hue > 0)
|
||||
{
|
||||
compiled += String.Format(_Format2, o.X + p.X, o.Y + p.Y, t.m_ItemID, FixHue(_Hue, true));
|
||||
}
|
||||
else
|
||||
{
|
||||
compiled += String.Format(_Format1, o.X + p.X, o.Y + p.Y, t.m_ItemID);
|
||||
}
|
||||
});
|
||||
|
||||
return compiled;
|
||||
}
|
||||
|
||||
public override void AppendTo(IGumpWriter disp)
|
||||
{
|
||||
if (_Components.List.IsNullOrEmpty())
|
||||
{
|
||||
disp.AppendLayout(_Hue > 0 ? _Layout2A : _Layout1A);
|
||||
disp.AppendLayout(_X);
|
||||
disp.AppendLayout(_Y);
|
||||
disp.AppendLayout(1);
|
||||
|
||||
if (_Hue > 0)
|
||||
{
|
||||
disp.AppendLayout(FixHue(_Hue, true));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var o = Offset;
|
||||
|
||||
var first = true;
|
||||
|
||||
Components.EnumerateByRender(
|
||||
(p, t) =>
|
||||
{
|
||||
if (first)
|
||||
{
|
||||
disp.AppendLayout(_Hue > 0 ? _Layout2A : _Layout1A);
|
||||
}
|
||||
else
|
||||
{
|
||||
disp.AppendLayout(_Hue > 0 ? _Layout2B : _Layout1B);
|
||||
}
|
||||
|
||||
disp.AppendLayout(o.X + p.X);
|
||||
disp.AppendLayout(o.Y + p.Y);
|
||||
disp.AppendLayout(t.m_ItemID);
|
||||
|
||||
if (_Hue > 0)
|
||||
{
|
||||
disp.AppendLayout(FixHue(_Hue, true));
|
||||
}
|
||||
|
||||
first = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#region References
|
||||
using System;
|
||||
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public class GumpOPL : SuperGumpEntry
|
||||
{
|
||||
private const string _Format1 = "{{ itemproperty {0} }}";
|
||||
|
||||
private static readonly byte[] _Layout1 = Gump.StringToBuffer("itemproperty");
|
||||
|
||||
private int _Serial;
|
||||
|
||||
public int Serial { get => _Serial; set => Delta(ref _Serial, value); }
|
||||
|
||||
public GumpOPL(Serial serial)
|
||||
{
|
||||
_Serial = serial;
|
||||
}
|
||||
|
||||
public override string Compile()
|
||||
{
|
||||
return String.Format(_Format1, _Serial);
|
||||
}
|
||||
|
||||
public override void AppendTo(IGumpWriter disp)
|
||||
{
|
||||
disp.AppendLayout(_Layout1);
|
||||
disp.AppendLayout(_Serial);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,461 @@
|
||||
#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 Server.Network;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public class GumpPaperdoll : SuperGumpEntry, IGumpEntryVector
|
||||
{
|
||||
private const string _Format0 = "{{ gumphtml {0} {1} {2} {3} {4} 0 0 }}";
|
||||
private const string _Format1A = "{{ gumppic {0} {1} {2} }}";
|
||||
private const string _Format1B = "{{ gumppic {0} {1} {2} hue={3} }}";
|
||||
private const string _Format2 = "{{ tilepic {0} {1} {2} }}";
|
||||
private const string _Format3 = "{{ tilepichue {0} {1} {2} {3} }}";
|
||||
private const string _Format4 = "{{ croppedtext {0} {1} {2} {3} {4} {5} }}";
|
||||
private const string _Format5 = "{{ itemproperty {0} }}";
|
||||
|
||||
private static readonly byte[] _Separator = Gump.StringToBuffer(" }{ ");
|
||||
private static readonly byte[] _Layout0 = Gump.StringToBuffer("itemproperty");
|
||||
private static readonly byte[] _Layout1 = Gump.StringToBuffer("resizepic");
|
||||
private static readonly byte[] _Layout2 = Gump.StringToBuffer(" }{ gumppic");
|
||||
private static readonly byte[] _Layout2Hue = Gump.StringToBuffer(" hue=");
|
||||
private static readonly byte[] _Layout3 = Gump.StringToBuffer(" }{ tilepic");
|
||||
private static readonly byte[] _Layout4 = Gump.StringToBuffer(" }{ tilepichue");
|
||||
private static readonly byte[] _Layout5 = Gump.StringToBuffer(" }{ croppedtext");
|
||||
private static readonly byte[] _Layout6 = Gump.StringToBuffer(" }{ itemproperty");
|
||||
|
||||
private int _X, _Y;
|
||||
private bool _Properties;
|
||||
private List<Item> _Items;
|
||||
private Body _Body;
|
||||
private int _BodyHue;
|
||||
private int _SolidHue;
|
||||
private int _HairID, _HairHue;
|
||||
private int _FacialHairID, _FacialHairHue;
|
||||
|
||||
public int X { get => _X; set => Delta(ref _X, value); }
|
||||
public int Y { get => _Y; set => Delta(ref _Y, value); }
|
||||
|
||||
public bool Properties { get => _Properties; set => Delta(ref _Properties, value); }
|
||||
|
||||
public List<Item> Items { get => _Items; set => Delta(ref _Items, value); }
|
||||
|
||||
public Body Body { get => _Body; set => Delta(ref _Body, value); }
|
||||
public int BodyHue { get => _BodyHue; set => Delta(ref _BodyHue, value); }
|
||||
|
||||
public int SolidHue { get => _SolidHue; set => Delta(ref _SolidHue, value); }
|
||||
|
||||
public int HairID { get => _HairID; set => Delta(ref _HairID, value); }
|
||||
public int HairHue { get => _HairHue; set => Delta(ref _HairHue, value); }
|
||||
|
||||
public int FacialHairID { get => _FacialHairID; set => Delta(ref _FacialHairID, value); }
|
||||
public int FacialHairHue { get => _FacialHairHue; set => Delta(ref _FacialHairHue, value); }
|
||||
|
||||
public virtual int Width { get => 260; set { } }
|
||||
public virtual int Height { get => 237; set { } }
|
||||
|
||||
public GumpPaperdoll(int x, int y, bool props, Mobile m)
|
||||
: this(
|
||||
x,
|
||||
y,
|
||||
props,
|
||||
m.Items,
|
||||
m.Body,
|
||||
m.Hue,
|
||||
m.SolidHueOverride,
|
||||
m.HairItemID,
|
||||
m.HairHue,
|
||||
m.FacialHairItemID,
|
||||
m.FacialHairHue)
|
||||
{ }
|
||||
|
||||
public GumpPaperdoll(
|
||||
int x,
|
||||
int y,
|
||||
bool props,
|
||||
IEnumerable<Item> items,
|
||||
Body body,
|
||||
int bodyHue,
|
||||
int solidHue,
|
||||
int hairID,
|
||||
int hairHue,
|
||||
int facialHairID,
|
||||
int facialHairHue)
|
||||
{
|
||||
_X = x;
|
||||
_Y = y;
|
||||
_Properties = props;
|
||||
_Items = items.Ensure().ToList();
|
||||
_Body = body;
|
||||
_BodyHue = bodyHue;
|
||||
_SolidHue = solidHue;
|
||||
_HairID = hairID;
|
||||
_HairHue = hairHue;
|
||||
_FacialHairID = facialHairID;
|
||||
_FacialHairHue = facialHairHue;
|
||||
}
|
||||
|
||||
public override string Compile()
|
||||
{
|
||||
var compiled = String.Format(_Format0, _X, _Y, Width, Height, " ".WrapUOHtmlBG(Color.Transparent));
|
||||
|
||||
var hue = _BodyHue & 0x7FFF;
|
||||
|
||||
if (_SolidHue >= 0)
|
||||
{
|
||||
hue = _SolidHue;
|
||||
}
|
||||
|
||||
var gump = ArtworkSupport.LookupGump(_Body);
|
||||
|
||||
if (gump <= 0)
|
||||
{
|
||||
gump = ShrinkTable.Lookup(_Body, 0);
|
||||
|
||||
if (gump > 0)
|
||||
{
|
||||
if (hue > 0 || (_SolidHue >= 0 && hue == _SolidHue))
|
||||
{
|
||||
compiled += String.Format(_Format3, _X, _Y, gump, FixHue(hue));
|
||||
}
|
||||
else
|
||||
{
|
||||
compiled += String.Format(_Format2, _X, _Y, gump);
|
||||
}
|
||||
}
|
||||
|
||||
return compiled;
|
||||
}
|
||||
|
||||
if (hue > 0 || (_SolidHue >= 0 && hue == _SolidHue))
|
||||
{
|
||||
compiled += String.Format(_Format1B, _X, _Y, gump, FixHue(hue));
|
||||
}
|
||||
else
|
||||
{
|
||||
compiled += String.Format(_Format1A, _X, _Y, gump);
|
||||
}
|
||||
|
||||
var hideHair = _Body.IsGhost;
|
||||
var hidePants = false;
|
||||
var props = String.Empty;
|
||||
|
||||
compiled += Compile(ref props, ref hidePants, ref hideHair);
|
||||
|
||||
if (!_Body.IsGhost && _FacialHairID > 0)
|
||||
{
|
||||
gump = ArtworkSupport.LookupGump(_FacialHairID, _Body.IsFemale);
|
||||
|
||||
if (gump > 0)
|
||||
{
|
||||
hue = _SolidHue >= 0 ? _SolidHue : _FacialHairHue;
|
||||
|
||||
if (hue > 0 || (_SolidHue >= 0 && hue == _SolidHue))
|
||||
{
|
||||
compiled += String.Format(_Format1B, _X, _Y, gump, FixHue(hue));
|
||||
}
|
||||
else
|
||||
{
|
||||
compiled += String.Format(_Format1A, _X, _Y, gump);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!hideHair && _HairID > 0)
|
||||
{
|
||||
gump = ArtworkSupport.LookupGump(_HairID, _Body.IsFemale);
|
||||
|
||||
if (gump > 0)
|
||||
{
|
||||
hue = _SolidHue >= 0 ? _SolidHue : _HairHue;
|
||||
|
||||
if (hue > 0 || (_SolidHue >= 0 && hue == _SolidHue))
|
||||
{
|
||||
compiled += String.Format(_Format1B, _X, _Y, gump, FixHue(hue));
|
||||
}
|
||||
else
|
||||
{
|
||||
compiled += String.Format(_Format1A, _X, _Y, gump);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return compiled + props;
|
||||
}
|
||||
|
||||
public virtual string Compile(ref string props, ref bool hidePants, ref bool hideHair)
|
||||
{
|
||||
var compiled = String.Empty;
|
||||
|
||||
if (_Items == null || _Items.Count == 0)
|
||||
{
|
||||
return compiled;
|
||||
}
|
||||
|
||||
_Items.SortLayers();
|
||||
|
||||
var noHue = FixHue(0);
|
||||
var noText = Parent.Intern(" ");
|
||||
|
||||
foreach (var item in _Items.TakeWhile(i => i.Layer.IsOrdered())
|
||||
.Where(i => !_Body.IsGhost || i.ItemID == 8270 || i.ItemID == 8271))
|
||||
{
|
||||
if (item.ItemID == 0x1411 || item.ItemID == 0x141A) // plate legs
|
||||
{
|
||||
hidePants = true;
|
||||
}
|
||||
else if (hidePants && item.Layer == Layer.Pants)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!hideHair && (item.ItemID == 8270 || item.ItemID == 8271 || item.Layer == Layer.Helm))
|
||||
{
|
||||
hideHair = true;
|
||||
}
|
||||
|
||||
var gump = item.GetGumpID(_Body.IsFemale);
|
||||
|
||||
if (gump <= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var hue = _SolidHue >= 0 ? _SolidHue : item.Hue;
|
||||
|
||||
if (hue > 0 || (_SolidHue >= 0 && hue == _SolidHue))
|
||||
{
|
||||
compiled += String.Format(_Format1B, _X, _Y, gump, FixHue(hue));
|
||||
}
|
||||
else
|
||||
{
|
||||
compiled += String.Format(_Format1A, _X, _Y, gump);
|
||||
}
|
||||
|
||||
if (_Properties)
|
||||
{
|
||||
var tooltip = String.Format(_Format5, item.Serial.Value);
|
||||
|
||||
foreach (var b in item.GetGumpBounds())
|
||||
{
|
||||
props += String.Format(_Format4, _X + b.X, _Y + b.Y, b.Width, b.Height, noHue, noText);
|
||||
props += tooltip;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return compiled;
|
||||
}
|
||||
|
||||
public override void AppendTo(IGumpWriter disp)
|
||||
{
|
||||
disp.AppendLayout(_Layout0);
|
||||
disp.AppendLayout(-1);
|
||||
|
||||
var hue = _BodyHue & 0x7FFF;
|
||||
|
||||
if (_SolidHue >= 0)
|
||||
{
|
||||
hue = _SolidHue;
|
||||
}
|
||||
|
||||
var gump = ArtworkSupport.LookupGump(_Body);
|
||||
|
||||
if (gump <= 0)
|
||||
{
|
||||
gump = ShrinkTable.Lookup(_Body, 0);
|
||||
|
||||
if (gump > 0)
|
||||
{
|
||||
if (hue > 0 || (_SolidHue >= 0 && hue == _SolidHue))
|
||||
{
|
||||
disp.AppendLayout(_Layout4);
|
||||
}
|
||||
else
|
||||
{
|
||||
disp.AppendLayout(_Layout3);
|
||||
}
|
||||
|
||||
disp.AppendLayout(_X);
|
||||
disp.AppendLayout(_Y);
|
||||
disp.AppendLayout(gump);
|
||||
|
||||
if (hue > 0 || (_SolidHue >= 0 && hue == _SolidHue))
|
||||
{
|
||||
disp.AppendLayout(FixHue(hue));
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
disp.AppendLayout(_Layout2);
|
||||
disp.AppendLayout(_X);
|
||||
disp.AppendLayout(_Y);
|
||||
disp.AppendLayout(gump);
|
||||
|
||||
if (hue > 0 || (_SolidHue >= 0 && hue == _SolidHue))
|
||||
{
|
||||
disp.AppendLayout(_Layout2Hue);
|
||||
disp.AppendLayoutNS(FixHue(hue));
|
||||
}
|
||||
|
||||
var hideHair = _Body.IsGhost;
|
||||
var hidePants = false;
|
||||
var props = String.Empty;
|
||||
|
||||
AppendTo(disp, ref props, ref hidePants, ref hideHair);
|
||||
|
||||
if (!_Body.IsGhost && _FacialHairID > 0)
|
||||
{
|
||||
gump = ArtworkSupport.LookupGump(_FacialHairID, _Body.IsFemale);
|
||||
|
||||
if (gump > 0)
|
||||
{
|
||||
disp.AppendLayout(_Layout2);
|
||||
disp.AppendLayout(_X);
|
||||
disp.AppendLayout(_Y);
|
||||
disp.AppendLayout(gump);
|
||||
|
||||
hue = _SolidHue >= 0 ? _SolidHue : _FacialHairHue;
|
||||
|
||||
if (hue > 0 || (_SolidHue >= 0 && hue == _SolidHue))
|
||||
{
|
||||
disp.AppendLayout(_Layout2Hue);
|
||||
disp.AppendLayoutNS(FixHue(hue));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!hideHair && _HairID > 0)
|
||||
{
|
||||
gump = ArtworkSupport.LookupGump(_HairID, _Body.IsFemale);
|
||||
|
||||
if (gump > 0)
|
||||
{
|
||||
disp.AppendLayout(_Layout2);
|
||||
disp.AppendLayout(_X);
|
||||
disp.AppendLayout(_Y);
|
||||
disp.AppendLayout(gump);
|
||||
|
||||
hue = _SolidHue >= 0 ? _SolidHue : _HairHue;
|
||||
|
||||
if (hue > 0 || (_SolidHue >= 0 && hue == _SolidHue))
|
||||
{
|
||||
disp.AppendLayout(_Layout2Hue);
|
||||
disp.AppendLayoutNS(FixHue(hue));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!_Properties || String.IsNullOrWhiteSpace(props))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var noHue = FixHue(0);
|
||||
var noText = Parent.Intern(" ");
|
||||
|
||||
props = props.Trim(',');
|
||||
|
||||
foreach (var item in props.Split(',').Select(Int32.Parse).Select(s => _Items.Find(i => i.Serial.Value == s)))
|
||||
{
|
||||
foreach (var b in item.GetGumpBounds())
|
||||
{
|
||||
disp.AppendLayout(_Layout5);
|
||||
disp.AppendLayout(_X + b.X);
|
||||
disp.AppendLayout(_Y + b.Y);
|
||||
disp.AppendLayout(b.Width);
|
||||
disp.AppendLayout(b.Height);
|
||||
disp.AppendLayout(noHue);
|
||||
disp.AppendLayout(noText);
|
||||
|
||||
disp.AppendLayout(_Layout6);
|
||||
disp.AppendLayout(item.Serial.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void AppendTo(IGumpWriter disp, ref string props, ref bool hidePants, ref bool hideHair)
|
||||
{
|
||||
if (_Items == null || _Items.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_Items.SortLayers();
|
||||
|
||||
foreach (var item in _Items.TakeWhile(i => i.Layer.IsOrdered())
|
||||
.Where(i => !_Body.IsGhost || i.ItemID == 8270 || i.ItemID == 8271))
|
||||
{
|
||||
if (item.ItemID == 0x1411 || item.ItemID == 0x141A) // plate legs
|
||||
{
|
||||
hidePants = true;
|
||||
}
|
||||
else if (hidePants && item.Layer == Layer.Pants)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!hideHair && (item.ItemID == 8270 || item.ItemID == 8271 || item.Layer == Layer.Helm))
|
||||
{
|
||||
hideHair = true;
|
||||
}
|
||||
|
||||
var gump = ArtworkSupport.LookupGump(item.ItemID, _Body.IsFemale);
|
||||
|
||||
if (gump <= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
disp.AppendLayout(_Layout2);
|
||||
disp.AppendLayout(_X);
|
||||
disp.AppendLayout(_Y);
|
||||
disp.AppendLayout(gump);
|
||||
|
||||
var hue = _SolidHue >= 0 ? _SolidHue : item.Hue;
|
||||
|
||||
if (hue > 0 || (_SolidHue >= 0 && hue == _SolidHue))
|
||||
{
|
||||
disp.AppendLayout(_Layout2Hue);
|
||||
disp.AppendLayoutNS(FixHue(hue));
|
||||
}
|
||||
|
||||
if (_Properties)
|
||||
{
|
||||
props += item.Serial.Value + ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
if (_Items != null)
|
||||
{
|
||||
_Items.Free(true);
|
||||
_Items = null;
|
||||
}
|
||||
|
||||
base.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
#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.Gumps;
|
||||
using Server.Network;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public class GumpPixel : SuperGumpEntry, IGumpEntryVector
|
||||
{
|
||||
private const string _Format1 = "{{ htmlgump {0} {1} {2} {3} {4} 0 0 }}";
|
||||
|
||||
private static readonly byte[] _Layout1 = Gump.StringToBuffer("htmlgump");
|
||||
|
||||
private int _X, _Y;
|
||||
private Color _Color;
|
||||
|
||||
public int X { get => _X; set => Delta(ref _X, value); }
|
||||
public int Y { get => _Y; set => Delta(ref _Y, value); }
|
||||
|
||||
int IGumpEntrySize.Width { get => 1; set { } }
|
||||
int IGumpEntrySize.Height { get => 1; set { } }
|
||||
|
||||
public Color Color { get => _Color; set => Delta(ref _Color, value); }
|
||||
|
||||
public GumpPixel(int x, int y, Color color)
|
||||
{
|
||||
_X = x;
|
||||
_Y = y;
|
||||
|
||||
_Color = color;
|
||||
}
|
||||
|
||||
public override string Compile()
|
||||
{
|
||||
if (IsEnhancedClient)
|
||||
{
|
||||
return String.Empty;
|
||||
}
|
||||
|
||||
var text = " ";
|
||||
|
||||
if (!Color.IsEmpty && Color != Color.Transparent)
|
||||
{
|
||||
text = text.WrapUOHtmlBG(Color);
|
||||
}
|
||||
|
||||
return String.Format(_Format1, X, Y, 1, 1, Parent.Intern(text));
|
||||
}
|
||||
|
||||
public override void AppendTo(IGumpWriter disp)
|
||||
{
|
||||
if (IsEnhancedClient)
|
||||
{
|
||||
AppendEmptyLayout(disp);
|
||||
return;
|
||||
}
|
||||
|
||||
var text = " ";
|
||||
|
||||
if (!Color.IsEmpty && Color != Color.Transparent)
|
||||
{
|
||||
text = text.WrapUOHtmlBG(Color);
|
||||
}
|
||||
|
||||
disp.AppendLayout(_Layout1);
|
||||
disp.AppendLayout(X);
|
||||
disp.AppendLayout(Y);
|
||||
disp.AppendLayout(1);
|
||||
disp.AppendLayout(1);
|
||||
disp.AppendLayout(Parent.Intern(text));
|
||||
disp.AppendLayout(false);
|
||||
disp.AppendLayout(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
#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 Server.Network;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public class GumpProgress : SuperGumpEntry, IGumpEntryVector
|
||||
{
|
||||
private const string _Format1 = @"{{ htmlgump {0} {1} {2} {3} {4} 0 0 }}";
|
||||
|
||||
private static readonly byte[] _Layout1A = Gump.StringToBuffer("htmlgump");
|
||||
private static readonly byte[] _Layout1B = Gump.StringToBuffer(" }{ htmlgump");
|
||||
|
||||
private int _X, _Y;
|
||||
private int _Width, _Height;
|
||||
private double _Progress;
|
||||
private Direction _Direction;
|
||||
private Color _BackgroundColor, _ForegroundColor, _BorderColor;
|
||||
private int _BorderSize;
|
||||
|
||||
public int X { get => _X; set => Delta(ref _X, value); }
|
||||
public int Y { get => _Y; set => Delta(ref _Y, value); }
|
||||
|
||||
public int Width { get => _Width; set => Delta(ref _Width, value); }
|
||||
public int Height { get => _Height; set => Delta(ref _Height, value); }
|
||||
|
||||
public double Progress { get => _Progress; set => Delta(ref _Progress, value); }
|
||||
|
||||
public Direction Direction { get => _Direction; set => Delta(ref _Direction, value); }
|
||||
|
||||
public Color BackgroundColor { get => _BackgroundColor; set => Delta(ref _BackgroundColor, value); }
|
||||
public Color ForegroundColor { get => _ForegroundColor; set => Delta(ref _ForegroundColor, value); }
|
||||
public Color BorderColor { get => _BorderColor; set => Delta(ref _BorderColor, value); }
|
||||
|
||||
public int BorderSize { get => _BorderSize; set => Delta(ref _BorderSize, value); }
|
||||
|
||||
public GumpProgress(
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
double progress,
|
||||
Direction dir = Direction.Right,
|
||||
Color? background = null,
|
||||
Color? foreground = null,
|
||||
Color? border = null,
|
||||
int borderSize = 0)
|
||||
{
|
||||
_X = x;
|
||||
_Y = y;
|
||||
_Width = width;
|
||||
_Height = height;
|
||||
_Progress = progress;
|
||||
_Direction = dir;
|
||||
_BackgroundColor = background ?? Color.OrangeRed;
|
||||
_ForegroundColor = foreground ?? Color.LawnGreen;
|
||||
_BorderColor = border ?? Color.Black;
|
||||
_BorderSize = borderSize;
|
||||
}
|
||||
|
||||
public bool FlowOffset(ref int x, ref int y, ref int w, ref int h)
|
||||
{
|
||||
double xo = x, yo = y, wo = w, ho = h;
|
||||
|
||||
switch (_Direction & Direction.Mask)
|
||||
{
|
||||
case Direction.Up:
|
||||
{
|
||||
ho *= _Progress;
|
||||
yo = (y + h) - ho;
|
||||
}
|
||||
break;
|
||||
case Direction.North:
|
||||
{
|
||||
wo *= _Progress;
|
||||
ho *= _Progress;
|
||||
yo = (y + h) - ho;
|
||||
}
|
||||
break;
|
||||
case Direction.Right:
|
||||
{
|
||||
wo *= _Progress;
|
||||
}
|
||||
break;
|
||||
case Direction.East:
|
||||
{
|
||||
wo *= _Progress;
|
||||
ho *= _Progress;
|
||||
}
|
||||
break;
|
||||
case Direction.Down:
|
||||
{
|
||||
ho *= _Progress;
|
||||
}
|
||||
break;
|
||||
case Direction.South:
|
||||
{
|
||||
wo *= _Progress;
|
||||
ho *= _Progress;
|
||||
xo = (x + w) - wo;
|
||||
}
|
||||
break;
|
||||
case Direction.Left:
|
||||
{
|
||||
wo *= _Progress;
|
||||
xo = (x + w) - wo;
|
||||
}
|
||||
break;
|
||||
case Direction.West:
|
||||
{
|
||||
wo *= _Progress;
|
||||
ho *= _Progress;
|
||||
xo = (x + w) - wo;
|
||||
yo = (y + h) - ho;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var contained = xo >= x && yo >= y && xo + wo <= x + w && yo + ho <= y + h;
|
||||
|
||||
x = (int)xo;
|
||||
y = (int)yo;
|
||||
w = (int)wo;
|
||||
h = (int)ho;
|
||||
|
||||
return contained;
|
||||
}
|
||||
|
||||
public override string Compile()
|
||||
{
|
||||
if (IsEnhancedClient)
|
||||
{
|
||||
return String.Empty;
|
||||
}
|
||||
|
||||
var compiled = Compile(_X, _Y, _Width, _Height, _BackgroundColor);
|
||||
|
||||
int x = _X, y = _Y, w = _Width, h = _Height;
|
||||
|
||||
if (FlowOffset(ref x, ref y, ref w, ref h))
|
||||
{
|
||||
compiled += Compile(x, y, w, h, _ForegroundColor);
|
||||
}
|
||||
|
||||
compiled += Compile(_X, _Y, _Width, _BorderSize, _BorderColor);
|
||||
compiled += Compile(_X + (_Width - _BorderSize), _Y, _BorderSize, _Height, _BorderColor);
|
||||
compiled += Compile(_X, _Y + (_Height - _BorderSize), _Width, _BorderSize, _BorderColor);
|
||||
compiled += Compile(_X, _Y, _BorderSize, _Height, _BorderColor);
|
||||
|
||||
return compiled;
|
||||
}
|
||||
|
||||
public virtual string Compile(int x, int y, int w, int h, Color color)
|
||||
{
|
||||
var text = " ";
|
||||
|
||||
if (!color.IsEmpty && color != Color.Transparent)
|
||||
{
|
||||
text = text.WrapUOHtmlBG(color);
|
||||
}
|
||||
|
||||
return String.Format(_Format1, x, y, w, h, Parent.Intern(text));
|
||||
}
|
||||
|
||||
public override void AppendTo(IGumpWriter disp)
|
||||
{
|
||||
if (IsEnhancedClient)
|
||||
{
|
||||
AppendEmptyLayout(disp);
|
||||
return;
|
||||
}
|
||||
|
||||
var first = true;
|
||||
|
||||
AppendTo(disp, ref first, _X, _Y, _Width, _Height, _BackgroundColor);
|
||||
|
||||
int x = _X, y = _Y, w = _Width, h = _Height;
|
||||
|
||||
if (FlowOffset(ref x, ref y, ref w, ref h))
|
||||
{
|
||||
AppendTo(disp, ref first, x, y, w, h, _ForegroundColor);
|
||||
}
|
||||
|
||||
AppendTo(disp, ref first, _X, _Y, _Width, _BorderSize, _BorderColor);
|
||||
AppendTo(disp, ref first, _X + (_Width - _BorderSize), _Y, _BorderSize, _Height, _BorderColor);
|
||||
AppendTo(disp, ref first, _X, _Y + (_Height - _BorderSize), _Width, _BorderSize, _BorderColor);
|
||||
AppendTo(disp, ref first, _X, _Y, _BorderSize, _Height, _BorderColor);
|
||||
}
|
||||
|
||||
public virtual void AppendTo(IGumpWriter disp, ref bool first, int x, int y, int w, int h, Color color)
|
||||
{
|
||||
var text = " ";
|
||||
|
||||
if (!color.IsEmpty && color != Color.Transparent)
|
||||
{
|
||||
text = text.WrapUOHtmlBG(color);
|
||||
}
|
||||
|
||||
disp.AppendLayout(first ? _Layout1A : _Layout1B);
|
||||
disp.AppendLayout(x);
|
||||
disp.AppendLayout(y);
|
||||
disp.AppendLayout(w);
|
||||
disp.AppendLayout(h);
|
||||
disp.AppendLayout(Parent.Intern(text));
|
||||
disp.AppendLayout(false);
|
||||
disp.AppendLayout(false);
|
||||
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
#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 Server.Network;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public class GumpRectangle : SuperGumpEntry, IGumpEntryVector
|
||||
{
|
||||
private const string _Format1 = @"{{ htmlgump {0} {1} {2} {3} {4} 0 0 }}";
|
||||
|
||||
private static readonly byte[] _Layout1A = Gump.StringToBuffer("htmlgump");
|
||||
private static readonly byte[] _Layout1B = Gump.StringToBuffer(" }{ htmlgump");
|
||||
|
||||
private int _X, _Y;
|
||||
private int _Width, _Height;
|
||||
private int _BorderSize;
|
||||
private Color _FillColor, _BorderColor;
|
||||
|
||||
public int X { get => _X; set => Delta(ref _X, value); }
|
||||
public int Y { get => _Y; set => Delta(ref _Y, value); }
|
||||
|
||||
public int Width { get => _Width; set => Delta(ref _Width, value); }
|
||||
public int Height { get => _Height; set => Delta(ref _Height, value); }
|
||||
|
||||
public Color FillColor { get => _FillColor; set => Delta(ref _FillColor, value); }
|
||||
public Color BorderColor { get => _BorderColor; set => Delta(ref _BorderColor, value); }
|
||||
|
||||
public int BorderSize { get => _BorderSize; set => Delta(ref _BorderSize, value); }
|
||||
|
||||
public GumpRectangle(Rectangle bounds, Color color)
|
||||
: this(bounds.X, bounds.Y, bounds.Width, bounds.Height, color)
|
||||
{ }
|
||||
|
||||
public GumpRectangle(Rectangle bounds, Color color, bool filled)
|
||||
: this(bounds.X, bounds.Y, bounds.Width, bounds.Height, color, filled)
|
||||
{ }
|
||||
|
||||
public GumpRectangle(Rectangle bounds, Color color, int borderSize)
|
||||
: this(bounds.X, bounds.Y, bounds.Width, bounds.Height, color, borderSize)
|
||||
{ }
|
||||
|
||||
public GumpRectangle(Rectangle bounds, Color color, Color border, int borderSize)
|
||||
: this(bounds.X, bounds.Y, bounds.Width, bounds.Height, color, border, borderSize)
|
||||
{ }
|
||||
|
||||
public GumpRectangle(Rectangle2D bounds, Color color)
|
||||
: this(bounds.X, bounds.Y, bounds.Width, bounds.Height, color)
|
||||
{ }
|
||||
|
||||
public GumpRectangle(Rectangle2D bounds, Color color, bool filled)
|
||||
: this(bounds.X, bounds.Y, bounds.Width, bounds.Height, color, filled)
|
||||
{ }
|
||||
|
||||
public GumpRectangle(Rectangle2D bounds, Color color, int borderSize)
|
||||
: this(bounds.X, bounds.Y, bounds.Width, bounds.Height, color, borderSize)
|
||||
{ }
|
||||
|
||||
public GumpRectangle(Rectangle2D bounds, Color color, Color border, int borderSize)
|
||||
: this(bounds.X, bounds.Y, bounds.Width, bounds.Height, color, border, borderSize)
|
||||
{ }
|
||||
|
||||
public GumpRectangle(int x, int y, int w, int h, Color color)
|
||||
: this(x, y, w, h, color, false)
|
||||
{ }
|
||||
|
||||
public GumpRectangle(int x, int y, int w, int h, Color color, bool filled)
|
||||
: this(x, y, w, h, color, filled ? 0 : 1)
|
||||
{ }
|
||||
|
||||
public GumpRectangle(int x, int y, int w, int h, Color color, int borderSize)
|
||||
: this(x, y, w, h, borderSize <= 0 ? color : Color.Empty, borderSize <= 0 ? Color.Empty : color, borderSize)
|
||||
{ }
|
||||
|
||||
public GumpRectangle(int x, int y, int w, int h, Color color, Color border, int borderSize)
|
||||
{
|
||||
_X = x;
|
||||
_Y = y;
|
||||
|
||||
_Width = w;
|
||||
_Height = h;
|
||||
|
||||
_FillColor = color;
|
||||
_BorderColor = border;
|
||||
|
||||
_BorderSize = borderSize;
|
||||
}
|
||||
|
||||
public override string Compile()
|
||||
{
|
||||
if (IsEnhancedClient)
|
||||
{
|
||||
return String.Empty;
|
||||
}
|
||||
|
||||
var compiled = String.Empty;
|
||||
|
||||
var b = Math.Max(0, _BorderSize);
|
||||
|
||||
if (_BorderColor.IsEmpty || _BorderColor == Color.Transparent || _BorderColor == _FillColor || b <= 0)
|
||||
{
|
||||
b = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
compiled += Compile(_X, _Y, _Width, b, _BorderColor);
|
||||
compiled += Compile(_X + (_Width - b), _Y, b, _Height, _BorderColor);
|
||||
compiled += Compile(_X, _Y + (_Height - b), _Width, b, _BorderColor);
|
||||
compiled += Compile(_X, _Y, b, _Height, _BorderColor);
|
||||
}
|
||||
|
||||
compiled += Compile(_X + b, _Y + b, _Width - (b * 2), _Height - (b * 2), _FillColor);
|
||||
|
||||
return compiled;
|
||||
}
|
||||
|
||||
public virtual string Compile(int x, int y, int w, int h, Color color)
|
||||
{
|
||||
var text = " ";
|
||||
|
||||
if (!color.IsEmpty && color != Color.Transparent)
|
||||
{
|
||||
text = text.WrapUOHtmlBG(color);
|
||||
}
|
||||
|
||||
return String.Format(_Format1, x, y, w, h, Parent.Intern(text));
|
||||
}
|
||||
|
||||
public override void AppendTo(IGumpWriter disp)
|
||||
{
|
||||
if (IsEnhancedClient)
|
||||
{
|
||||
AppendEmptyLayout(disp);
|
||||
return;
|
||||
}
|
||||
|
||||
var first = true;
|
||||
|
||||
var b = Math.Max(0, _BorderSize);
|
||||
|
||||
if (_BorderColor.IsEmpty || _BorderColor == Color.Transparent || _BorderColor == _FillColor || b <= 0)
|
||||
{
|
||||
b = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
AppendTo(disp, ref first, _X, _Y, _Width, b, _BorderColor);
|
||||
AppendTo(disp, ref first, _X + (_Width - b), _Y, b, _Height, _BorderColor);
|
||||
AppendTo(disp, ref first, _X, _Y + (_Height - b), _Width, b, _BorderColor);
|
||||
AppendTo(disp, ref first, _X, _Y, b, _Height, _BorderColor);
|
||||
}
|
||||
|
||||
AppendTo(disp, ref first, _X + b, _Y + b, _Width - (b * 2), _Height - (b * 2), _FillColor);
|
||||
}
|
||||
|
||||
public virtual void AppendTo(IGumpWriter disp, ref bool first, int x, int y, int w, int h, Color color)
|
||||
{
|
||||
var text = " ";
|
||||
|
||||
if (!color.IsEmpty && color != Color.Transparent)
|
||||
{
|
||||
text = text.WrapUOHtmlBG(color);
|
||||
}
|
||||
|
||||
disp.AppendLayout(first ? _Layout1A : _Layout1B);
|
||||
disp.AppendLayout(x);
|
||||
disp.AppendLayout(y);
|
||||
disp.AppendLayout(w);
|
||||
disp.AppendLayout(h);
|
||||
disp.AppendLayout(Parent.Intern(text));
|
||||
disp.AppendLayout(false);
|
||||
disp.AppendLayout(false);
|
||||
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#region References
|
||||
using System;
|
||||
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public interface IGumpEntryPoint
|
||||
{
|
||||
int X { get; set; }
|
||||
int Y { get; set; }
|
||||
}
|
||||
|
||||
public interface IGumpEntrySize
|
||||
{
|
||||
int Width { get; set; }
|
||||
int Height { get; set; }
|
||||
}
|
||||
|
||||
public interface IGumpEntryVector : IGumpEntryPoint, IGumpEntrySize
|
||||
{ }
|
||||
|
||||
public abstract class SuperGumpEntry : GumpEntry, IDisposable
|
||||
{
|
||||
protected static readonly byte[] _EmptyLayout = Gump.StringToBuffer("null");
|
||||
|
||||
protected void AppendEmptyLayout(IGumpWriter disp)
|
||||
{
|
||||
disp.AppendLayout(_EmptyLayout);
|
||||
}
|
||||
|
||||
public virtual bool IgnoreModalOffset => false;
|
||||
|
||||
public virtual Mobile User
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Parent is SuperGump)
|
||||
{
|
||||
return ((SuperGump)Parent).User;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual NetState UserState
|
||||
{
|
||||
get
|
||||
{
|
||||
var user = User;
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
return user.NetState;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsEnhancedClient => UserState != null && UserState.IsEnhanced();
|
||||
|
||||
protected int FixHue(int hue)
|
||||
{
|
||||
return FixHue(hue, false);
|
||||
}
|
||||
|
||||
protected int FixHue(int hue, bool item)
|
||||
{
|
||||
hue = Math.Max(-1, hue & 0x7FFF);
|
||||
|
||||
if (hue <= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
hue = Math.Min(3000, hue) - 1;
|
||||
|
||||
if (item || IsEnhancedClient)
|
||||
{
|
||||
++hue;
|
||||
}
|
||||
|
||||
return hue;
|
||||
}
|
||||
|
||||
protected void Delta<T>(ref T var, T val)
|
||||
{
|
||||
if (ReferenceEquals(var, val) || Equals(var, val))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var old = var;
|
||||
|
||||
var = val;
|
||||
|
||||
OnInvalidate(old, val);
|
||||
OnInvalidate();
|
||||
}
|
||||
|
||||
protected virtual void OnInvalidate<T>(T old, T val)
|
||||
{ }
|
||||
|
||||
protected virtual void OnInvalidate()
|
||||
{
|
||||
if (Parent != null)
|
||||
{
|
||||
Parent.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Dispose()
|
||||
{
|
||||
if (Parent != null)
|
||||
{
|
||||
Parent.Entries.Remove(this);
|
||||
Parent = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,121 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#region References
|
||||
using System;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public abstract partial class SuperGump
|
||||
{
|
||||
public static TimeSpan DefaultAnimationRate = TimeSpan.FromMilliseconds(100.0);
|
||||
|
||||
private bool? _OldForceRecompile;
|
||||
private bool? _OldAutoRefresh;
|
||||
private TimeSpan _OldRefreshRate;
|
||||
|
||||
public bool IsAnimated => GetEntries<GumpAnimation>().Any(e => !e.Entries.IsNullOrEmpty() && e.State != null);
|
||||
|
||||
public bool IsAnimating => GetEntries<GumpAnimation>()
|
||||
.Where(e => !e.Entries.IsNullOrEmpty() && e.State != null)
|
||||
.Any(e => e.State.Sequencing || e.State.Animating || e.State.Waiting);
|
||||
|
||||
public TimeSpan AnimationRate { get; set; }
|
||||
|
||||
public void SetAnimationBreak()
|
||||
{
|
||||
Add(new GumpAnimationBreak());
|
||||
}
|
||||
|
||||
public void QueueAnimation(
|
||||
Action<GumpAnimation> handler,
|
||||
string name,
|
||||
int take = -1,
|
||||
long delay = 0,
|
||||
long duration = 0,
|
||||
bool repeat = false,
|
||||
bool wait = false,
|
||||
params object[] args)
|
||||
{
|
||||
Add(new GumpAnimation(this, name, take, delay, duration, repeat, wait, args, handler));
|
||||
}
|
||||
|
||||
private void InvalidateAnimations()
|
||||
{
|
||||
if (_OldForceRecompile == null)
|
||||
{
|
||||
_OldForceRecompile = ForceRecompile;
|
||||
}
|
||||
|
||||
if (_OldAutoRefresh == null)
|
||||
{
|
||||
_OldForceRecompile = ForceRecompile;
|
||||
_OldAutoRefresh = AutoRefresh;
|
||||
_OldRefreshRate = AutoRefreshRate;
|
||||
}
|
||||
|
||||
if (IsAnimating)
|
||||
{
|
||||
ForceRecompile = true;
|
||||
|
||||
AutoRefresh = true;
|
||||
AutoRefreshRate = AnimationRate;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_OldForceRecompile != null)
|
||||
{
|
||||
ForceRecompile = _OldForceRecompile.Value;
|
||||
|
||||
_OldForceRecompile = null;
|
||||
}
|
||||
|
||||
if (_OldAutoRefresh != null)
|
||||
{
|
||||
AutoRefresh = _OldAutoRefresh.Value;
|
||||
AutoRefreshRate = _OldRefreshRate;
|
||||
|
||||
_OldAutoRefresh = null;
|
||||
}
|
||||
}
|
||||
|
||||
var idx = Entries.Count;
|
||||
|
||||
while (--idx >= 0)
|
||||
{
|
||||
if (!Entries.InBounds(idx))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var e = Entries[idx];
|
||||
|
||||
if (e is GumpAnimation)
|
||||
{
|
||||
var a = (GumpAnimation)e;
|
||||
|
||||
if (a.State.Waiting)
|
||||
{
|
||||
Entries.TrimEndTo(idx + 1);
|
||||
break;
|
||||
}
|
||||
|
||||
a.Animate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void OnAnimate(GumpAnimation a)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#region References
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using VitaNex.IO;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public abstract partial class SuperGump
|
||||
{
|
||||
private static readonly bool[] _EmptyBools = new bool[0];
|
||||
private static readonly string[] _EmptyStrings = new string[0];
|
||||
|
||||
protected virtual string[] PreloadAssets => _EmptyStrings;
|
||||
|
||||
protected bool[] LoadAssets(string[] paths)
|
||||
{
|
||||
if (paths == null || paths.Length == 0)
|
||||
{
|
||||
return _EmptyBools;
|
||||
}
|
||||
|
||||
var results = new bool[paths.Length];
|
||||
|
||||
Parallel.For(0, paths.Length, i => results[i] = LoadAsset(paths[i]));
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
protected bool LoadAsset(string path)
|
||||
{
|
||||
return !VirtualAsset.IsNullOrEmpty(VirtualAsset.LoadAsset(path));
|
||||
}
|
||||
|
||||
protected virtual void InitAssets()
|
||||
{
|
||||
var assets = PreloadAssets;
|
||||
|
||||
if (assets == null || assets.Length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var results = LoadAssets(assets);
|
||||
|
||||
if (results == null || results.Length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < assets.Length && i < results.Length; i++)
|
||||
{
|
||||
if (!results[i])
|
||||
{
|
||||
VitaNexCore.ToConsole("Warning: {0} failed to pre-load asset '{1}'", GetType(), assets[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void AddAsset(int x, int y, string path)
|
||||
{
|
||||
Add(new GumpAsset(x, y, path));
|
||||
}
|
||||
|
||||
public virtual void AddAsset(int x, int y, Uri url)
|
||||
{
|
||||
Add(new GumpAsset(x, y, url));
|
||||
}
|
||||
|
||||
public virtual void AddAsset(int x, int y, FileInfo file)
|
||||
{
|
||||
Add(new GumpAsset(x, y, file));
|
||||
}
|
||||
|
||||
public virtual void AddAsset(int x, int y, VirtualAsset asset)
|
||||
{
|
||||
Add(new GumpAsset(x, y, asset));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
#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.Gumps;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public abstract partial class SuperGump
|
||||
{
|
||||
private SuperGumpLayout _Layout;
|
||||
|
||||
public SuperGumpLayout Layout { get => _Layout; protected set => _Layout = value; }
|
||||
|
||||
public virtual bool CanMove { get => Dragable; set => Dragable = value; }
|
||||
public virtual bool CanClose { get => Closable; set => Closable = value; }
|
||||
public virtual bool CanDispose { get => Disposable; set => Disposable = value; }
|
||||
public virtual bool CanResize { get => Resizable; set => Resizable = value; }
|
||||
|
||||
public virtual int ModalXOffset { get; set; }
|
||||
public virtual int ModalYOffset { get; set; }
|
||||
public virtual int XOffset { get; set; }
|
||||
public virtual int YOffset { get; set; }
|
||||
|
||||
private long _SizeTick = -1;
|
||||
private Size _Size = Size.Empty;
|
||||
|
||||
public Size OuterSize
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_InstanceLock)
|
||||
{
|
||||
// Prevent computing size if called successive times on the same tick
|
||||
var tick = VitaNexCore.Tick;
|
||||
|
||||
if (tick == _SizeTick)
|
||||
{
|
||||
return _Size;
|
||||
}
|
||||
|
||||
_SizeTick = tick;
|
||||
|
||||
int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
|
||||
|
||||
foreach (var e in Entries.Not(e => e is GumpModal))
|
||||
{
|
||||
|
||||
if (!e.TryGetBounds(out var ex, out var ey, out var ew, out var eh))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
x1 = Math.Min(x1, ex);
|
||||
y1 = Math.Min(y1, ey);
|
||||
|
||||
x2 = Math.Max(x2, ex + ew);
|
||||
y2 = Math.Max(y2, ey + eh);
|
||||
}
|
||||
|
||||
_Size.Width = Math.Max(0, x2 - x1);
|
||||
_Size.Height = Math.Max(0, y2 - y1);
|
||||
|
||||
return _Size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int OuterWidth => OuterSize.Width;
|
||||
public int OuterHeight => OuterSize.Height;
|
||||
|
||||
public void InvalidateSize()
|
||||
{
|
||||
_SizeTick = -1;
|
||||
}
|
||||
|
||||
private void InvalidateOffsets()
|
||||
{
|
||||
Entries.ForEachReverse(
|
||||
e =>
|
||||
{
|
||||
var x = XOffset;
|
||||
var y = YOffset;
|
||||
|
||||
if (Modal && (!(e is SuperGumpEntry) || !((SuperGumpEntry)e).IgnoreModalOffset))
|
||||
{
|
||||
x += ModalXOffset;
|
||||
y += ModalYOffset;
|
||||
}
|
||||
|
||||
if (x != 0 || y != 0)
|
||||
{
|
||||
e.TryOffsetPosition(x, y);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
#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.Linq;
|
||||
|
||||
using Server.Gumps;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public abstract partial class SuperGump
|
||||
{
|
||||
private Dictionary<GumpButton, Action<GumpButton>> _Buttons;
|
||||
|
||||
public Dictionary<GumpButton, Action<GumpButton>> Buttons
|
||||
{
|
||||
get => _Buttons;
|
||||
protected set => _Buttons = value;
|
||||
}
|
||||
|
||||
public virtual Action<GumpButton> ButtonHandler { get; set; }
|
||||
|
||||
public GumpButton LastButtonClicked { get; protected set; }
|
||||
|
||||
public new void AddButton(int x, int y, int normalID, int pressedID, int buttonID, GumpButtonType type, int param)
|
||||
{
|
||||
if (type == GumpButtonType.Page)
|
||||
{
|
||||
AddButton(new GumpButton(x, y, normalID, pressedID, 0, GumpButtonType.Page, param), null);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddButton(x, y, normalID, pressedID, buttonID, null);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddButton(int x, int y, int normalID, int pressedID)
|
||||
{
|
||||
AddButton(x, y, normalID, pressedID, NewButtonID(), null);
|
||||
}
|
||||
|
||||
public void AddButton(int x, int y, int normalID, int pressedID, Action<GumpButton> handler)
|
||||
{
|
||||
AddButton(x, y, normalID, pressedID, NewButtonID(), handler);
|
||||
}
|
||||
|
||||
public void AddButton(int x, int y, int normalID, int pressedID, int buttonID)
|
||||
{
|
||||
AddButton(x, y, normalID, pressedID, buttonID, null);
|
||||
}
|
||||
|
||||
public void AddButton(int x, int y, int normalID, int pressedID, int buttonID, Action<GumpButton> handler)
|
||||
{
|
||||
AddButton(new GumpButton(x, y, normalID, pressedID, buttonID, GumpButtonType.Reply, 0), handler);
|
||||
}
|
||||
|
||||
protected void AddButton(GumpButton entry, Action<GumpButton> handler)
|
||||
{
|
||||
if (entry == null || !CanDisplay(entry))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Buttons[entry] = handler;
|
||||
|
||||
Add(entry);
|
||||
}
|
||||
|
||||
public virtual void HandleButtonClick(GumpButton button)
|
||||
{
|
||||
var now = DateTime.UtcNow;
|
||||
var lbc = LastButtonClicked;
|
||||
var lbt = LastButtonClick + DClickInterval;
|
||||
|
||||
DoubleClicked = lbc != null && now <= lbt && (lbc == button || lbc.ButtonID == button.ButtonID ||
|
||||
(lbc.Parent == button.Parent && lbc.X == button.X && lbc.Y == button.Y && lbc.Type == button.Type &&
|
||||
lbc.Param == button.Param));
|
||||
|
||||
LastButtonClicked = button;
|
||||
LastButtonClick = now;
|
||||
|
||||
OnClick();
|
||||
OnClick(button);
|
||||
|
||||
if (DoubleClicked)
|
||||
{
|
||||
OnDoubleClick(button);
|
||||
}
|
||||
|
||||
if (ButtonHandler != null)
|
||||
{
|
||||
ButtonHandler(button);
|
||||
}
|
||||
else if (Buttons[button] != null)
|
||||
{
|
||||
Buttons[button](button);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnClick(GumpButton entry)
|
||||
{ }
|
||||
|
||||
protected virtual void OnDoubleClick(GumpButton entry)
|
||||
{ }
|
||||
|
||||
protected virtual bool CanDisplay(GumpButton entry)
|
||||
{
|
||||
return entry != null;
|
||||
}
|
||||
|
||||
public GumpButton GetButtonEntry(int buttonID)
|
||||
{
|
||||
return Buttons.Keys.FirstOrDefault(button => button.ButtonID == buttonID);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,601 @@
|
||||
#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.IO;
|
||||
using System.Linq;
|
||||
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
|
||||
using VitaNex.Network;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public abstract partial class SuperGump
|
||||
{
|
||||
private static readonly object _GlobalLock = new object();
|
||||
private static readonly object _InstanceLock = new object();
|
||||
|
||||
public static Dictionary<int, SuperGump> GlobalInstances { get; private set; }
|
||||
public static Dictionary<Mobile, List<SuperGump>> Instances { get; private set; }
|
||||
|
||||
public static event Action<Mobile, Gump> CoreGumpSend;
|
||||
|
||||
static SuperGump()
|
||||
{
|
||||
GlobalInstances = new Dictionary<int, SuperGump>(0x400);
|
||||
Instances = new Dictionary<Mobile, List<SuperGump>>(0x100);
|
||||
}
|
||||
|
||||
[CallPriority(Int32.MaxValue)]
|
||||
public static void Configure()
|
||||
{
|
||||
EventSink.Logout += OnLogoutImpl;
|
||||
EventSink.Disconnected += OnDisconnectedImpl;
|
||||
EventSink.Speech += OnSpeechImpl;
|
||||
EventSink.Movement += OnMovementImpl;
|
||||
|
||||
NetState.GumpCap = 1024;
|
||||
|
||||
VitaNexCore.OnInitialized += () =>
|
||||
{
|
||||
OutgoingPacketOverrides.Register(0xB0, OnEncode0xB0_0xDD);
|
||||
OutgoingPacketOverrides.Register(0xDD, OnEncode0xB0_0xDD);
|
||||
};
|
||||
}
|
||||
|
||||
public static void OnLogoutImpl(LogoutEventArgs e)
|
||||
{
|
||||
var user = e.Mobile;
|
||||
|
||||
if (user == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
lock (_InstanceLock)
|
||||
{
|
||||
if (!Instances.ContainsKey(user))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
VitaNexCore.TryCatch(
|
||||
() =>
|
||||
{
|
||||
foreach (var g in EnumerateInstances<SuperGump>(user, true))
|
||||
{
|
||||
g.Close(true);
|
||||
}
|
||||
},
|
||||
x => x.ToConsole(true));
|
||||
}
|
||||
|
||||
public static void OnDisconnectedImpl(DisconnectedEventArgs e)
|
||||
{
|
||||
var user = e.Mobile;
|
||||
|
||||
if (user == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
lock (_InstanceLock)
|
||||
{
|
||||
if (!Instances.ContainsKey(user))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
VitaNexCore.TryCatch(
|
||||
() =>
|
||||
{
|
||||
foreach (var g in EnumerateInstances<SuperGump>(user, true))
|
||||
{
|
||||
g.Close(true);
|
||||
}
|
||||
},
|
||||
x => x.ToConsole(true));
|
||||
}
|
||||
|
||||
public static void OnSpeechImpl(SpeechEventArgs e)
|
||||
{
|
||||
var user = e.Mobile;
|
||||
|
||||
if (user == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
lock (_InstanceLock)
|
||||
{
|
||||
if (!Instances.ContainsKey(user))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
VitaNexCore.TryCatch(
|
||||
() =>
|
||||
{
|
||||
foreach (var g in EnumerateInstances<SuperGump>(user, true))
|
||||
{
|
||||
g.OnSpeech(e);
|
||||
}
|
||||
},
|
||||
x => x.ToConsole(true));
|
||||
}
|
||||
|
||||
public static void OnMovementImpl(MovementEventArgs e)
|
||||
{
|
||||
var user = e.Mobile;
|
||||
|
||||
if (user == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
lock (_InstanceLock)
|
||||
{
|
||||
if (!Instances.ContainsKey(user))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
VitaNexCore.TryCatch(
|
||||
() =>
|
||||
{
|
||||
foreach (var g in EnumerateInstances<SuperGump>(user, true))
|
||||
{
|
||||
g.OnMovement(e);
|
||||
}
|
||||
},
|
||||
x => x.ToConsole(true));
|
||||
}
|
||||
|
||||
public static int RefreshInstances<TGump>(Mobile user)
|
||||
where TGump : SuperGump
|
||||
{
|
||||
return RefreshInstances<TGump>(user, false);
|
||||
}
|
||||
|
||||
public static int RefreshInstances<TGump>(Mobile user, bool inherited)
|
||||
where TGump : SuperGump
|
||||
{
|
||||
return EnumerateInstances<TGump>(user, inherited)
|
||||
.Count(
|
||||
g =>
|
||||
{
|
||||
if ((g.IsOpen || g.Hidden) && !g.IsDisposed)
|
||||
{
|
||||
g.Refresh(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
public static int RefreshInstances(Mobile user, Type type)
|
||||
{
|
||||
return RefreshInstances(user, type, false);
|
||||
}
|
||||
|
||||
public static int RefreshInstances(Mobile user, Type type, bool inherited)
|
||||
{
|
||||
return EnumerateInstances(user, type, inherited)
|
||||
.Count(
|
||||
g =>
|
||||
{
|
||||
if ((g.IsOpen || g.Hidden) && !g.IsDisposed)
|
||||
{
|
||||
g.Refresh(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
public static int CloseInstances<TGump>(Mobile user)
|
||||
where TGump : SuperGump
|
||||
{
|
||||
return CloseInstances<TGump>(user, false);
|
||||
}
|
||||
|
||||
public static int CloseInstances<TGump>(Mobile user, bool inherited)
|
||||
where TGump : SuperGump
|
||||
{
|
||||
return EnumerateInstances<TGump>(user, inherited)
|
||||
.Count(
|
||||
g =>
|
||||
{
|
||||
if ((g.IsOpen || g.Hidden) && !g.IsDisposed)
|
||||
{
|
||||
g.Close(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
public static int CloseInstances(Mobile user, Type type)
|
||||
{
|
||||
return CloseInstances(user, type, false);
|
||||
}
|
||||
|
||||
public static int CloseInstances(Mobile user, Type type, bool inherited)
|
||||
{
|
||||
return EnumerateInstances(user, type, inherited)
|
||||
.Count(
|
||||
g =>
|
||||
{
|
||||
if ((g.IsOpen || g.Hidden) && !g.IsDisposed)
|
||||
{
|
||||
g.Close(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
public static int CountInstances<TGump>(Mobile user)
|
||||
where TGump : SuperGump
|
||||
{
|
||||
return CountInstances<TGump>(user, false);
|
||||
}
|
||||
|
||||
public static int CountInstances<TGump>(Mobile user, bool inherited)
|
||||
where TGump : SuperGump
|
||||
{
|
||||
return EnumerateInstances<TGump>(user, inherited).Count();
|
||||
}
|
||||
|
||||
public static int CountInstances(Mobile user, Type type)
|
||||
{
|
||||
return CountInstances(user, type, false);
|
||||
}
|
||||
|
||||
public static int CountInstances(Mobile user, Type type, bool inherited)
|
||||
{
|
||||
return EnumerateInstances(user, type, inherited).Count();
|
||||
}
|
||||
|
||||
public static bool HasInstance<TGump>(Mobile user)
|
||||
where TGump : SuperGump
|
||||
{
|
||||
return HasInstance<TGump>(user, false);
|
||||
}
|
||||
|
||||
public static bool HasInstance<TGump>(Mobile user, bool inherited)
|
||||
where TGump : SuperGump
|
||||
{
|
||||
return EnumerateInstances<TGump>(user, inherited).Any();
|
||||
}
|
||||
|
||||
public static bool HasInstance(Mobile user, Type type)
|
||||
{
|
||||
return HasInstance(user, type, false);
|
||||
}
|
||||
|
||||
public static bool HasInstance(Mobile user, Type type, bool inherited)
|
||||
{
|
||||
return EnumerateInstances(user, type, inherited).Any();
|
||||
}
|
||||
|
||||
public static TGump GetInstance<TGump>(Mobile user)
|
||||
where TGump : SuperGump
|
||||
{
|
||||
return GetInstance<TGump>(user, false);
|
||||
}
|
||||
|
||||
public static TGump GetInstance<TGump>(Mobile user, bool inherited)
|
||||
where TGump : SuperGump
|
||||
{
|
||||
return EnumerateInstances<TGump>(user, inherited).FirstOrDefault();
|
||||
}
|
||||
|
||||
public static SuperGump GetInstance(Mobile user, Type type)
|
||||
{
|
||||
return GetInstance(user, type, false);
|
||||
}
|
||||
|
||||
public static SuperGump GetInstance(Mobile user, Type type, bool inherited)
|
||||
{
|
||||
return EnumerateInstances(user, type, inherited).FirstOrDefault();
|
||||
}
|
||||
|
||||
public static TGump[] GetInstances<TGump>(Mobile user)
|
||||
where TGump : SuperGump
|
||||
{
|
||||
return GetInstances<TGump>(user, false);
|
||||
}
|
||||
|
||||
public static TGump[] GetInstances<TGump>(Mobile user, bool inherited)
|
||||
where TGump : SuperGump
|
||||
{
|
||||
return EnumerateInstances<TGump>(user, inherited).ToArray();
|
||||
}
|
||||
|
||||
public static SuperGump[] GetInstances(Mobile user, Type type)
|
||||
{
|
||||
return GetInstances(user, type, false);
|
||||
}
|
||||
|
||||
public static SuperGump[] GetInstances(Mobile user, Type type, bool inherited)
|
||||
{
|
||||
return EnumerateInstances(user, type, inherited).ToArray();
|
||||
}
|
||||
|
||||
public static IEnumerable<TGump> EnumerateInstances<TGump>(Mobile user)
|
||||
where TGump : SuperGump
|
||||
{
|
||||
return EnumerateInstances<TGump>(user, false);
|
||||
}
|
||||
|
||||
public static IEnumerable<TGump> EnumerateInstances<TGump>(Mobile user, bool inherited)
|
||||
where TGump : SuperGump
|
||||
{
|
||||
if (user == null)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
List<SuperGump> list;
|
||||
|
||||
lock (_InstanceLock)
|
||||
{
|
||||
list = Instances.GetValue(user);
|
||||
|
||||
if (list == null || list.Count == 0)
|
||||
{
|
||||
Instances.Remove(user);
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
|
||||
lock (((ICollection)list).SyncRoot)
|
||||
{
|
||||
var index = list.Count;
|
||||
|
||||
while (--index >= 0)
|
||||
{
|
||||
if (!list.InBounds(index))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var gump = list[index];
|
||||
|
||||
if (gump != null && gump.TypeEquals<TGump>(inherited))
|
||||
{
|
||||
yield return (TGump)gump;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<SuperGump> EnumerateInstances(Mobile user, Type type)
|
||||
{
|
||||
return EnumerateInstances(user, type, false);
|
||||
}
|
||||
|
||||
public static IEnumerable<SuperGump> EnumerateInstances(Mobile user, Type type, bool inherited)
|
||||
{
|
||||
if (user == null)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
List<SuperGump> list;
|
||||
|
||||
lock (_InstanceLock)
|
||||
{
|
||||
list = Instances.GetValue(user);
|
||||
|
||||
if (list == null || list.Count == 0)
|
||||
{
|
||||
Instances.Remove(user);
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
|
||||
lock (((ICollection)list).SyncRoot)
|
||||
{
|
||||
var index = list.Count;
|
||||
|
||||
while (--index >= 0)
|
||||
{
|
||||
if (!list.InBounds(index))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var gump = list[index];
|
||||
|
||||
if (gump != null && gump.TypeEquals(type, inherited))
|
||||
{
|
||||
yield return gump;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnEncode0xB0_0xDD(NetState state, PacketReader reader, ref byte[] buffer, ref int length)
|
||||
{
|
||||
if (state == null || reader == null || buffer == null || length < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var pos = reader.Seek(0, SeekOrigin.Current);
|
||||
reader.Seek(3, SeekOrigin.Begin);
|
||||
var serial = reader.ReadInt32();
|
||||
reader.Seek(pos, SeekOrigin.Begin);
|
||||
|
||||
if (serial <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var cg = state.Gumps.FirstOrDefault(o => o != null && o.Serial == serial);
|
||||
|
||||
if (cg == null || cg is SuperGump)
|
||||
{
|
||||
var g = cg as SuperGump;
|
||||
|
||||
if (g == null)
|
||||
{
|
||||
lock (_GlobalLock)
|
||||
{
|
||||
g = GlobalInstances.GetValue(serial);
|
||||
}
|
||||
}
|
||||
|
||||
if (g != null && !g.Compiled)
|
||||
{
|
||||
g.Refresh(true);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (CoreGumpSend != null && state.Mobile != null)
|
||||
{
|
||||
Timer.DelayCall(m => CoreGumpSend(m, cg), state.Mobile);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void RegisterInstance()
|
||||
{
|
||||
if (User == null || User.Deleted || IsDisposed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
lock (_GlobalLock)
|
||||
{
|
||||
GlobalInstances[Serial] = this;
|
||||
}
|
||||
|
||||
List<SuperGump> list;
|
||||
|
||||
lock (_InstanceLock)
|
||||
{
|
||||
list = Instances.GetValue(User);
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
Instances[User] = list = new List<SuperGump>(0x10);
|
||||
}
|
||||
}
|
||||
|
||||
var added = false;
|
||||
|
||||
lock (((ICollection)list).SyncRoot)
|
||||
{
|
||||
if (!list.Contains(this))
|
||||
{
|
||||
list.Add(this);
|
||||
|
||||
added = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (added)
|
||||
{
|
||||
OnInstanceRegistered();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void UnregisterInstance()
|
||||
{
|
||||
lock (_GlobalLock)
|
||||
{
|
||||
GlobalInstances.Remove(Serial);
|
||||
}
|
||||
|
||||
var user = User;
|
||||
|
||||
if (user == null)
|
||||
{
|
||||
lock (_InstanceLock)
|
||||
{
|
||||
user = Instances.FirstOrDefault(kv => kv.Value.Contains(this)).Key;
|
||||
}
|
||||
}
|
||||
|
||||
if (user == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
List<SuperGump> list;
|
||||
|
||||
lock (_InstanceLock)
|
||||
{
|
||||
list = Instances.GetValue(User);
|
||||
|
||||
if (list == null || list.Count == 0)
|
||||
{
|
||||
Instances.Remove(user);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var removed = false;
|
||||
|
||||
lock (((ICollection)list).SyncRoot)
|
||||
{
|
||||
if (list.Remove(this))
|
||||
{
|
||||
list.TrimExcess();
|
||||
|
||||
removed = true;
|
||||
}
|
||||
|
||||
if (list.Count == 0)
|
||||
{
|
||||
lock (_InstanceLock)
|
||||
{
|
||||
Instances.Remove(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (removed)
|
||||
{
|
||||
OnInstanceUnregistered();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnInstanceRegistered()
|
||||
{
|
||||
//Console.WriteLine("{0} Registered to {1}", this, User);
|
||||
}
|
||||
|
||||
protected virtual void OnInstanceUnregistered()
|
||||
{
|
||||
//Console.WriteLine("{0} Unregistered from {1}", this, User);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
#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.Linq;
|
||||
|
||||
using Server.Gumps;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public abstract partial class SuperGump
|
||||
{
|
||||
private Dictionary<GumpTextEntryLimited, Action<GumpTextEntryLimited, string>> _LimitedTextInputs;
|
||||
|
||||
public Dictionary<GumpTextEntryLimited, Action<GumpTextEntryLimited, string>> LimitedTextInputs
|
||||
{
|
||||
get => _LimitedTextInputs;
|
||||
protected set => _LimitedTextInputs = value;
|
||||
}
|
||||
|
||||
public Action<GumpTextEntryLimited, string> LimitedTextInputHandler { get; set; }
|
||||
|
||||
public new void AddTextEntry(int x, int y, int width, int height, int hue, int inputID, string text, int length)
|
||||
{
|
||||
AddTextEntryLimited(x, y, width, height, hue, inputID, text, length, null);
|
||||
}
|
||||
|
||||
public void AddTextEntryLimited(int x, int y, int width, int height, int hue, string text, int length)
|
||||
{
|
||||
AddTextEntryLimited(x, y, width, height, hue, NewTextEntryID(), text, length, null);
|
||||
}
|
||||
|
||||
public void AddTextEntryLimited(
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
int hue,
|
||||
string text,
|
||||
int length,
|
||||
Action<GumpTextEntryLimited, string> handler)
|
||||
{
|
||||
AddTextEntryLimited(x, y, width, height, hue, NewTextEntryID(), text, length, handler);
|
||||
}
|
||||
|
||||
public void AddTextEntryLimited(int x, int y, int width, int height, int hue, int inputID, string text, int length)
|
||||
{
|
||||
AddTextEntryLimited(x, y, width, height, hue, inputID, text, length, null);
|
||||
}
|
||||
|
||||
public void AddTextEntryLimited(
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
int hue,
|
||||
int inputID,
|
||||
string text,
|
||||
int length,
|
||||
Action<GumpTextEntryLimited, string> handler)
|
||||
{
|
||||
AddTextEntryLimited(new GumpTextEntryLimited(x, y, width, height, hue, inputID, text, length), handler);
|
||||
}
|
||||
|
||||
protected void AddTextEntryLimited(GumpTextEntryLimited input, Action<GumpTextEntryLimited, string> handler)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
LimitedTextInputs[input] = handler;
|
||||
|
||||
Add(input);
|
||||
}
|
||||
|
||||
public virtual void HandleLimitedTextInput(GumpTextEntryLimited input, string text)
|
||||
{
|
||||
if (LimitedTextInputHandler != null)
|
||||
{
|
||||
LimitedTextInputHandler(input, text);
|
||||
}
|
||||
else if (LimitedTextInputs[input] != null)
|
||||
{
|
||||
LimitedTextInputs[input](input, text);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool CanDisplay(GumpTextEntryLimited input)
|
||||
{
|
||||
return input != null;
|
||||
}
|
||||
|
||||
public GumpTextEntryLimited GetTextEntryLimited(int inputID)
|
||||
{
|
||||
return LimitedTextInputs.Keys.FirstOrDefault(input => input.EntryID == inputID);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#region References
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public abstract partial class SuperGump
|
||||
{
|
||||
private List<SuperGump> _Linked;
|
||||
|
||||
public List<SuperGump> Linked { get => _Linked; protected set => _Linked = value; }
|
||||
|
||||
public bool IsLinked => Linked.Count > 0;
|
||||
|
||||
public virtual void Link(SuperGump gump)
|
||||
{
|
||||
if (gump == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Linked.Update(gump);
|
||||
|
||||
if (!gump.Linked.Contains(this))
|
||||
{
|
||||
gump.Link(this);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Unlink(SuperGump gump)
|
||||
{
|
||||
if (gump == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Linked.Remove(gump);
|
||||
|
||||
if (gump.Linked.Contains(this))
|
||||
{
|
||||
gump.Unlink(this);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool IsLinkedWith(SuperGump gump)
|
||||
{
|
||||
return gump != null && Linked.Contains(gump);
|
||||
}
|
||||
|
||||
protected virtual void OnLinkRefreshed(SuperGump link)
|
||||
{ }
|
||||
|
||||
protected virtual void OnLinkHidden(SuperGump link)
|
||||
{ }
|
||||
|
||||
protected virtual void OnLinkClosed(SuperGump link)
|
||||
{ }
|
||||
|
||||
protected virtual void OnLinkSend(SuperGump link)
|
||||
{ }
|
||||
|
||||
protected virtual void OnLinkSendFail(SuperGump link)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#region References
|
||||
using System.Linq;
|
||||
|
||||
using Server;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public abstract partial class SuperGump
|
||||
{
|
||||
public void AddProperties(IEntity entity)
|
||||
{
|
||||
if (entity is Item)
|
||||
{
|
||||
AddProperties((Item)entity);
|
||||
}
|
||||
else if (entity is Mobile)
|
||||
{
|
||||
AddProperties((Mobile)entity);
|
||||
}
|
||||
else if (entity is Spoof)
|
||||
{
|
||||
AddProperties((Spoof)entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddProperties(entity.Serial);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void AddProperties(Item item)
|
||||
{
|
||||
if (item == null || item.Deleted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.Parent != User && User.IsOnline() && GetEntries<GumpOPL>().All(o => o.Serial != item.Serial.Value))
|
||||
{
|
||||
var opl = item.GetOPL(User);
|
||||
var inf = new OPLInfo(opl);
|
||||
|
||||
User.Send(opl);
|
||||
User.Send(inf);
|
||||
}
|
||||
|
||||
AddProperties(item.Serial);
|
||||
}
|
||||
|
||||
public virtual void AddProperties(Mobile mob)
|
||||
{
|
||||
if (mob == null || mob.Deleted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (mob != User && User.IsOnline() && GetEntries<GumpOPL>().All(o => o.Serial != mob.Serial.Value))
|
||||
{
|
||||
var opl = mob.GetOPL(User);
|
||||
var inf = new OPLInfo(opl);
|
||||
|
||||
User.Send(opl);
|
||||
User.Send(inf);
|
||||
}
|
||||
|
||||
AddProperties(mob.Serial);
|
||||
}
|
||||
|
||||
private void AddProperties(Spoof spoof)
|
||||
{
|
||||
if (spoof == null || spoof.Deleted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (User.IsOnline() && GetEntries<GumpOPL>().All(o => o.Serial != spoof.Serial.Value))
|
||||
{
|
||||
User.Send(spoof.PropertyList);
|
||||
User.Send(spoof.OPLPacket);
|
||||
}
|
||||
|
||||
AddProperties(spoof.Serial);
|
||||
}
|
||||
|
||||
public virtual void AddProperties(Serial serial)
|
||||
{
|
||||
Add(new GumpOPL(serial));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
#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.Linq;
|
||||
|
||||
using Server.Gumps;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public abstract partial class SuperGump
|
||||
{
|
||||
private Dictionary<GumpRadio, Action<GumpRadio, bool>> _Radios;
|
||||
|
||||
public Dictionary<GumpRadio, Action<GumpRadio, bool>> Radios
|
||||
{
|
||||
get => _Radios;
|
||||
protected set => _Radios = value;
|
||||
}
|
||||
|
||||
public Action<GumpRadio, bool> RadioHandler { get; set; }
|
||||
|
||||
public new void AddRadio(int x, int y, int offID, int onID, bool state, int radioID)
|
||||
{
|
||||
AddRadio(x, y, offID, onID, radioID, state, null);
|
||||
}
|
||||
|
||||
public void AddRadio(int x, int y, int offID, int onID, bool state)
|
||||
{
|
||||
AddRadio(x, y, offID, onID, NewSwitchID(), state, null);
|
||||
}
|
||||
|
||||
public void AddRadio(int x, int y, int offID, int onID, bool state, Action<GumpRadio, bool> handler)
|
||||
{
|
||||
AddRadio(x, y, offID, onID, NewSwitchID(), state, handler);
|
||||
}
|
||||
|
||||
public void AddRadio(int x, int y, int offID, int onID, int radioID, bool state)
|
||||
{
|
||||
AddRadio(x, y, offID, onID, radioID, state, null);
|
||||
}
|
||||
|
||||
public void AddRadio(int x, int y, int offID, int onID, int radioID, bool state, Action<GumpRadio, bool> handler)
|
||||
{
|
||||
AddRadio(new GumpRadio(x, y, offID, onID, state, radioID), handler);
|
||||
}
|
||||
|
||||
protected void AddRadio(GumpRadio entry, Action<GumpRadio, bool> handler)
|
||||
{
|
||||
if (entry == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Radios[entry] = handler;
|
||||
|
||||
Add(entry);
|
||||
}
|
||||
|
||||
public virtual void HandleRadio(GumpRadio entry, bool state)
|
||||
{
|
||||
if (RadioHandler != null)
|
||||
{
|
||||
RadioHandler(entry, state);
|
||||
}
|
||||
else if (Radios[entry] != null)
|
||||
{
|
||||
Radios[entry](entry, state);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool CanDisplay(GumpRadio entry)
|
||||
{
|
||||
return entry != null;
|
||||
}
|
||||
|
||||
public GumpRadio GetRadioEntry(int radioID)
|
||||
{
|
||||
return Radios.Keys.FirstOrDefault(radio => radio.SwitchID == radioID);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public abstract partial class SuperGump
|
||||
{
|
||||
public static int DefaultSendSound = -1;
|
||||
public static int DefaultHideSound = -1;
|
||||
public static int DefaultRefreshSound = -1;
|
||||
public static int DefaultCloseSound = 999;
|
||||
public static int DefaultClickSound = 1235;
|
||||
public static int DefaultDoubleClickSound = 74;
|
||||
|
||||
public virtual int SendSound { get; set; }
|
||||
public virtual int HideSound { get; set; }
|
||||
public virtual int RefreshSound { get; set; }
|
||||
public virtual int CloseSound { get; set; }
|
||||
public virtual int ClickSound { get; set; }
|
||||
public virtual int DoubleClickSound { get; set; }
|
||||
|
||||
public virtual bool UseSounds { get; set; }
|
||||
|
||||
protected virtual void InitSounds()
|
||||
{
|
||||
SendSound = DefaultSendSound;
|
||||
HideSound = DefaultHideSound;
|
||||
RefreshSound = DefaultRefreshSound;
|
||||
CloseSound = DefaultCloseSound;
|
||||
ClickSound = DefaultClickSound;
|
||||
DoubleClickSound = DefaultDoubleClickSound;
|
||||
}
|
||||
|
||||
protected virtual void PlaySendSound()
|
||||
{
|
||||
PlaySound(SendSound);
|
||||
}
|
||||
|
||||
protected virtual void PlayHideSound()
|
||||
{
|
||||
PlaySound(HideSound);
|
||||
}
|
||||
|
||||
protected virtual void PlayRefreshSound()
|
||||
{
|
||||
PlaySound(RefreshSound);
|
||||
}
|
||||
|
||||
protected virtual void PlayCloseSound()
|
||||
{
|
||||
PlaySound(CloseSound);
|
||||
}
|
||||
|
||||
protected virtual void PlayClickSound()
|
||||
{
|
||||
PlaySound(ClickSound);
|
||||
}
|
||||
|
||||
protected virtual void PlayDoubleClickSound()
|
||||
{
|
||||
PlaySound(DoubleClickSound);
|
||||
}
|
||||
|
||||
public void PlaySound(int soundID)
|
||||
{
|
||||
PlaySound(soundID, false);
|
||||
}
|
||||
|
||||
public virtual void PlaySound(int soundID, bool loud)
|
||||
{
|
||||
if (!UseSounds)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (loud)
|
||||
{
|
||||
User.PlaySound(soundID);
|
||||
}
|
||||
else
|
||||
{
|
||||
User.SendSound(soundID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
#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.Linq;
|
||||
|
||||
using Server.Gumps;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public abstract partial class SuperGump
|
||||
{
|
||||
private Dictionary<GumpCheck, Action<GumpCheck, bool>> _Switches;
|
||||
|
||||
public Dictionary<GumpCheck, Action<GumpCheck, bool>> Switches
|
||||
{
|
||||
get => _Switches;
|
||||
protected set => _Switches = value;
|
||||
}
|
||||
|
||||
public Action<GumpCheck, bool> SwitchHandler { get; set; }
|
||||
|
||||
public new void AddCheck(int x, int y, int offID, int onID, bool state, int switchID)
|
||||
{
|
||||
AddCheck(x, y, offID, onID, switchID, state, null);
|
||||
}
|
||||
|
||||
public void AddCheck(int x, int y, int offID, int onID, bool state)
|
||||
{
|
||||
AddCheck(x, y, offID, onID, NewSwitchID(), state, null);
|
||||
}
|
||||
|
||||
public void AddCheck(int x, int y, int offID, int onID, bool state, Action<GumpCheck, bool> handler)
|
||||
{
|
||||
AddCheck(x, y, offID, onID, NewSwitchID(), state, handler);
|
||||
}
|
||||
|
||||
public void AddCheck(int x, int y, int offID, int onID, int switchID, bool state)
|
||||
{
|
||||
AddCheck(x, y, offID, onID, switchID, state, null);
|
||||
}
|
||||
|
||||
public void AddCheck(int x, int y, int offID, int onID, int switchID, bool state, Action<GumpCheck, bool> handler)
|
||||
{
|
||||
AddCheck(new GumpCheck(x, y, offID, onID, state, switchID), handler);
|
||||
}
|
||||
|
||||
protected void AddCheck(GumpCheck entry, Action<GumpCheck, bool> handler)
|
||||
{
|
||||
if (entry == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Switches[entry] = handler;
|
||||
|
||||
Add(entry);
|
||||
}
|
||||
|
||||
public virtual void HandleSwitch(GumpCheck entry, bool state)
|
||||
{
|
||||
if (SwitchHandler != null)
|
||||
{
|
||||
SwitchHandler(entry, state);
|
||||
}
|
||||
else if (Switches[entry] != null)
|
||||
{
|
||||
Switches[entry](entry, state);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool CanDisplay(GumpCheck entry)
|
||||
{
|
||||
return entry != null;
|
||||
}
|
||||
|
||||
public GumpCheck GetSwitchEntry(int switchID)
|
||||
{
|
||||
return Switches.Keys.FirstOrDefault(check => check.SwitchID == switchID);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
#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.Linq;
|
||||
|
||||
using Server.Gumps;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public abstract partial class SuperGump
|
||||
{
|
||||
private Dictionary<GumpTextEntry, Action<GumpTextEntry, string>> _TextInputs;
|
||||
|
||||
public Dictionary<GumpTextEntry, Action<GumpTextEntry, string>> TextInputs
|
||||
{
|
||||
get => _TextInputs;
|
||||
protected set => _TextInputs = value;
|
||||
}
|
||||
|
||||
public Action<GumpTextEntry, string> TextInputHandler { get; set; }
|
||||
|
||||
public new void AddTextEntry(int x, int y, int width, int height, int hue, int inputID, string text)
|
||||
{
|
||||
AddTextEntry(x, y, width, height, hue, inputID, text, null);
|
||||
}
|
||||
|
||||
public void AddTextEntry(int x, int y, int width, int height, int hue, string text)
|
||||
{
|
||||
AddTextEntry(x, y, width, height, hue, NewTextEntryID(), text, null);
|
||||
}
|
||||
|
||||
public void AddTextEntry(
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
int hue,
|
||||
string text,
|
||||
Action<GumpTextEntry, string> handler)
|
||||
{
|
||||
AddTextEntry(x, y, width, height, hue, NewTextEntryID(), text, handler);
|
||||
}
|
||||
|
||||
public void AddTextEntry(
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
int hue,
|
||||
int entryID,
|
||||
string text,
|
||||
Action<GumpTextEntry, string> handler)
|
||||
{
|
||||
AddTextEntry(new GumpTextEntry(x, y, width, height, hue, entryID, text), handler);
|
||||
}
|
||||
|
||||
protected void AddTextEntry(GumpTextEntry input, Action<GumpTextEntry, string> handler)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TextInputs[input] = handler;
|
||||
|
||||
Add(input);
|
||||
}
|
||||
|
||||
public virtual void HandleTextInput(GumpTextEntry input, string text)
|
||||
{
|
||||
if (TextInputHandler != null)
|
||||
{
|
||||
TextInputHandler(input, text);
|
||||
}
|
||||
else if (TextInputs[input] != null)
|
||||
{
|
||||
TextInputs[input](input, text);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool CanDisplay(GumpTextEntry input)
|
||||
{
|
||||
return input != null;
|
||||
}
|
||||
|
||||
public GumpTextEntry GetTextEntry(int inputID)
|
||||
{
|
||||
return TextInputs.Keys.FirstOrDefault(input => input.EntryID == inputID);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
#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.Linq;
|
||||
|
||||
using Server.Gumps;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public abstract partial class SuperGump
|
||||
{
|
||||
private Dictionary<GumpImageTileButton, Action<GumpImageTileButton>> _TileButtons;
|
||||
|
||||
public Dictionary<GumpImageTileButton, Action<GumpImageTileButton>> TileButtons
|
||||
{
|
||||
get => _TileButtons;
|
||||
protected set => _TileButtons = value;
|
||||
}
|
||||
|
||||
public virtual Action<GumpImageTileButton> TileButtonHandler { get; set; }
|
||||
|
||||
public GumpImageTileButton LastTileButtonClicked { get; protected set; }
|
||||
|
||||
public new void AddImageTiledButton(
|
||||
int x,
|
||||
int y,
|
||||
int normalID,
|
||||
int pressedID,
|
||||
int buttonID,
|
||||
GumpButtonType type,
|
||||
int param,
|
||||
int itemID,
|
||||
int hue,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
if (type == GumpButtonType.Page)
|
||||
{
|
||||
AddImageTiledButton(
|
||||
new GumpImageTileButton(x, y, normalID, pressedID, 0, GumpButtonType.Page, param, itemID, hue, width, height),
|
||||
null);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddImageTiledButton(x, y, normalID, pressedID, buttonID, itemID, hue, width, height, null);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddImageTiledButton(int x, int y, int normalID, int pressedID, int itemID, int hue, int width, int height)
|
||||
{
|
||||
AddImageTiledButton(x, y, normalID, pressedID, NewButtonID(), itemID, hue, width, height, null);
|
||||
}
|
||||
|
||||
public void AddImageTiledButton(
|
||||
int x,
|
||||
int y,
|
||||
int normalID,
|
||||
int pressedID,
|
||||
int itemID,
|
||||
int hue,
|
||||
int width,
|
||||
int height,
|
||||
Action<GumpImageTileButton> handler)
|
||||
{
|
||||
AddImageTiledButton(x, y, normalID, pressedID, NewButtonID(), itemID, hue, width, height, handler);
|
||||
}
|
||||
|
||||
public void AddImageTiledButton(
|
||||
int x,
|
||||
int y,
|
||||
int normalID,
|
||||
int pressedID,
|
||||
int buttonID,
|
||||
int itemID,
|
||||
int hue,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
AddImageTiledButton(x, y, normalID, pressedID, buttonID, itemID, hue, width, height, null);
|
||||
}
|
||||
|
||||
public void AddImageTiledButton(
|
||||
int x,
|
||||
int y,
|
||||
int normalID,
|
||||
int pressedID,
|
||||
int buttonID,
|
||||
int itemID,
|
||||
int hue,
|
||||
int width,
|
||||
int height,
|
||||
Action<GumpImageTileButton> handler)
|
||||
{
|
||||
AddImageTiledButton(
|
||||
new GumpImageTileButton(x, y, normalID, pressedID, buttonID, GumpButtonType.Reply, 0, itemID, hue, width, height),
|
||||
handler);
|
||||
}
|
||||
|
||||
protected void AddImageTiledButton(GumpImageTileButton entry, Action<GumpImageTileButton> handler)
|
||||
{
|
||||
if (entry == null || !CanDisplay(entry))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TileButtons[entry] = handler;
|
||||
|
||||
Add(entry);
|
||||
}
|
||||
|
||||
public virtual void HandleTileButtonClick(GumpImageTileButton button)
|
||||
{
|
||||
var now = DateTime.UtcNow;
|
||||
var lbc = LastTileButtonClicked;
|
||||
var lbt = LastButtonClick + DClickInterval;
|
||||
|
||||
DoubleClicked = lbc != null && now <= lbt && (lbc == button || lbc.ButtonID == button.ButtonID ||
|
||||
(lbc.Parent == button.Parent && lbc.X == button.X && lbc.Y == button.Y && lbc.Type == button.Type &&
|
||||
lbc.Param == button.Param));
|
||||
|
||||
LastTileButtonClicked = button;
|
||||
LastButtonClick = now;
|
||||
|
||||
OnClick();
|
||||
OnClick(button);
|
||||
|
||||
if (DoubleClicked)
|
||||
{
|
||||
OnDoubleClick(button);
|
||||
}
|
||||
|
||||
if (TileButtonHandler != null)
|
||||
{
|
||||
TileButtonHandler(button);
|
||||
}
|
||||
else if (TileButtons[button] != null)
|
||||
{
|
||||
TileButtons[button](button);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnClick(GumpImageTileButton entry)
|
||||
{ }
|
||||
|
||||
protected virtual void OnDoubleClick(GumpImageTileButton entry)
|
||||
{ }
|
||||
|
||||
protected virtual bool CanDisplay(GumpImageTileButton entry)
|
||||
{
|
||||
return entry != null;
|
||||
}
|
||||
|
||||
public GumpImageTileButton GetTileButtonEntry(int buttonID)
|
||||
{
|
||||
return TileButtons.Keys.FirstOrDefault(button => button.ButtonID == buttonID);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#if ServUO58
|
||||
#define ServUOX
|
||||
#endif
|
||||
|
||||
#region References
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
|
||||
using Server;
|
||||
using Server.Network;
|
||||
|
||||
using VitaNex.Collections;
|
||||
using VitaNex.Network;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public abstract partial class SuperGump
|
||||
{
|
||||
private Dictionary<string, Spoof> _TextTooltips;
|
||||
|
||||
#if ServUO
|
||||
public new void AddTooltip(string text)
|
||||
#else
|
||||
public void AddTooltip(string text)
|
||||
#endif
|
||||
{
|
||||
AddTooltip(text, Color.Empty);
|
||||
}
|
||||
|
||||
public void AddTooltip(string text, Color color)
|
||||
{
|
||||
AddTooltip(String.Empty, text, Color.Empty, color);
|
||||
}
|
||||
|
||||
public void AddTooltip(string title, string text)
|
||||
{
|
||||
AddTooltip(title, text, Color.Empty, Color.Empty);
|
||||
}
|
||||
|
||||
public void AddTooltip(string title, string text, Color titleColor, Color textColor)
|
||||
{
|
||||
title = title ?? String.Empty;
|
||||
text = text ?? String.Empty;
|
||||
|
||||
if (titleColor.IsEmpty || titleColor == Color.Transparent)
|
||||
{
|
||||
titleColor = Color.Yellow;
|
||||
}
|
||||
|
||||
if (textColor.IsEmpty || textColor == Color.Transparent)
|
||||
{
|
||||
textColor = Color.White;
|
||||
}
|
||||
|
||||
if (!String.IsNullOrWhiteSpace(title))
|
||||
{
|
||||
text = String.Concat(title.WrapUOHtmlColor(titleColor, false), '\n', text.WrapUOHtmlColor(textColor, false));
|
||||
}
|
||||
else
|
||||
{
|
||||
text = text.WrapUOHtmlColor(textColor, false);
|
||||
}
|
||||
|
||||
if (!_TextTooltips.TryGetValue(text, out var spoof) || spoof == null || spoof.Deleted)
|
||||
{
|
||||
_TextTooltips[text] = spoof = Spoof.Acquire();
|
||||
}
|
||||
|
||||
spoof.Text = text;
|
||||
|
||||
AddProperties(spoof);
|
||||
}
|
||||
|
||||
private sealed class Spoof : Entity
|
||||
{
|
||||
private static readonly char[] _Split = { '\n' };
|
||||
|
||||
private static int _UID = Int32.MinValue;
|
||||
|
||||
private static Serial NewUID
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_UID >= -1)
|
||||
{
|
||||
_UID = Int32.MinValue;
|
||||
}
|
||||
|
||||
#if ServUOX
|
||||
return new Serial(++_UID);
|
||||
#else
|
||||
return ++_UID;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly ObjectPool<Spoof> _Pool = new ObjectPool<Spoof>();
|
||||
|
||||
public static Spoof Acquire()
|
||||
{
|
||||
return _Pool.Acquire();
|
||||
}
|
||||
|
||||
public static void Free(Spoof spoof)
|
||||
{
|
||||
_Pool.Free(spoof);
|
||||
}
|
||||
|
||||
public static void Free(ref Spoof spoof)
|
||||
{
|
||||
_Pool.Free(ref spoof);
|
||||
}
|
||||
|
||||
public int UID { get => Serial.Value; private set => this.SetPropertyValue("Serial", value); }
|
||||
|
||||
private OPLInfo _OPLInfo;
|
||||
|
||||
public Packet OPLPacket
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_OPLInfo == null)
|
||||
{
|
||||
_OPLInfo = new OPLInfo(PropertyList);
|
||||
_OPLInfo.SetStatic();
|
||||
}
|
||||
|
||||
return _OPLInfo;
|
||||
}
|
||||
}
|
||||
|
||||
private ObjectPropertyList _PropertyList;
|
||||
|
||||
public ObjectPropertyList PropertyList
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_PropertyList == null)
|
||||
{
|
||||
_PropertyList = new ObjectPropertyList(this);
|
||||
|
||||
if (Text != null)
|
||||
{
|
||||
var text = Text.StripHtmlBreaks(true);
|
||||
|
||||
if (text.IndexOf('\n') >= 0)
|
||||
{
|
||||
var lines = text.Split(_Split, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
_PropertyList.Add(lines[0]);
|
||||
|
||||
ExtendedOPL.AddTo(_PropertyList, lines.Skip(1));
|
||||
}
|
||||
else
|
||||
{
|
||||
_PropertyList.Add(text);
|
||||
}
|
||||
}
|
||||
|
||||
_PropertyList.Terminate();
|
||||
_PropertyList.SetStatic();
|
||||
}
|
||||
|
||||
return _PropertyList;
|
||||
}
|
||||
}
|
||||
|
||||
private string _Text = String.Empty;
|
||||
|
||||
public string Text
|
||||
{
|
||||
get => _Text ?? String.Empty;
|
||||
set
|
||||
{
|
||||
if (_Text != value)
|
||||
{
|
||||
_Text = value;
|
||||
|
||||
Packet.Release(ref _OPLInfo);
|
||||
Packet.Release(ref _PropertyList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Spoof()
|
||||
: base(NewUID, Point3D.Zero, Map.Internal)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#region References
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public abstract partial class SuperGump
|
||||
{
|
||||
private List<SuperGump> _Children;
|
||||
|
||||
public List<SuperGump> Children { get => _Children; protected set => _Children = value; }
|
||||
|
||||
public bool HasChildren => Children.Count > 0;
|
||||
public bool HasOpenChildren => Children.Any(o => o.IsOpen);
|
||||
|
||||
protected void AddChild(SuperGump child)
|
||||
{
|
||||
if (child != null && !Children.Contains(child))
|
||||
{
|
||||
Children.Add(child);
|
||||
OnChildAdded(child);
|
||||
}
|
||||
}
|
||||
|
||||
protected void RemoveChild(SuperGump child)
|
||||
{
|
||||
if (child != null && Children.Remove(child))
|
||||
{
|
||||
OnChildRemoved(child);
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasChild(SuperGump child)
|
||||
{
|
||||
return HasChild(child, false);
|
||||
}
|
||||
|
||||
public bool HasChild(SuperGump child, bool tree)
|
||||
{
|
||||
return child != null && Children.Any(c => c == child || (tree && c.HasChild(child, true)));
|
||||
}
|
||||
|
||||
public bool IsChildOf(SuperGump parent)
|
||||
{
|
||||
return IsChildOf(parent, false);
|
||||
}
|
||||
|
||||
public bool IsChildOf(SuperGump parent, bool tree)
|
||||
{
|
||||
if (parent == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var p = Parent;
|
||||
|
||||
while (p != null)
|
||||
{
|
||||
if (p == parent)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
p = !tree || !(p is SuperGump) ? null : ((SuperGump)p).Parent;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected virtual void OnChildAdded(SuperGump child)
|
||||
{ }
|
||||
|
||||
protected virtual void OnChildRemoved(SuperGump child)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,492 @@
|
||||
#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 Server.Network;
|
||||
|
||||
using VitaNex.Notify;
|
||||
using VitaNex.Targets;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public sealed class DesktopGumpEntry : SuperGumpEntry
|
||||
{
|
||||
private string _Compiled;
|
||||
private byte[] _Buffer;
|
||||
|
||||
private int _TypeID;
|
||||
private Action<NetState, RelayInfo> _Handler;
|
||||
|
||||
public DesktopGump Desktop { get; private set; }
|
||||
|
||||
public Dictionary<int, int> ButtonMap { get; private set; }
|
||||
public Dictionary<int, int> SwitchMap { get; private set; }
|
||||
public Dictionary<int, int> TextMap { get; private set; }
|
||||
|
||||
public DesktopGumpEntry(DesktopGump dt, Gump gump, bool focus)
|
||||
{
|
||||
Desktop = dt;
|
||||
|
||||
_TypeID = gump.TypeID;
|
||||
_Handler = gump.OnResponse;
|
||||
|
||||
if (focus)
|
||||
{
|
||||
ButtonMap = new Dictionary<int, int>();
|
||||
SwitchMap = new Dictionary<int, int>();
|
||||
TextMap = new Dictionary<int, int>();
|
||||
}
|
||||
|
||||
var entries = gump.Entries.Not(e => e is GumpModal).ToList();
|
||||
|
||||
var esc = false;
|
||||
|
||||
foreach (var e in entries)
|
||||
{
|
||||
bool pos;
|
||||
|
||||
if (e.TryGetPosition(out var x, out var y))
|
||||
{
|
||||
pos = true;
|
||||
e.TrySetPosition(gump.X + x, gump.Y + y);
|
||||
}
|
||||
else
|
||||
{
|
||||
pos = false;
|
||||
}
|
||||
|
||||
e.Parent = Desktop;
|
||||
|
||||
try
|
||||
{
|
||||
if (e is GumpButton)
|
||||
{
|
||||
var b = (GumpButton)e;
|
||||
|
||||
if (focus && b.Type == GumpButtonType.Reply)
|
||||
{
|
||||
ButtonMap[Desktop.NewButtonID()] = b.ButtonID;
|
||||
|
||||
b.ButtonID = ButtonMap.GetKey(b.ButtonID);
|
||||
_Compiled += b.Compile();
|
||||
b.ButtonID = ButtonMap[b.ButtonID];
|
||||
}
|
||||
else
|
||||
{
|
||||
_Compiled += new GumpImage(b.X, b.Y, b.NormalID)
|
||||
{
|
||||
Parent = Desktop
|
||||
}.Compile();
|
||||
}
|
||||
}
|
||||
else if (e is GumpImageTileButton)
|
||||
{
|
||||
var b = (GumpImageTileButton)e;
|
||||
|
||||
if (focus && b.Type == GumpButtonType.Reply)
|
||||
{
|
||||
ButtonMap[Desktop.NewButtonID()] = b.ButtonID;
|
||||
|
||||
b.ButtonID = ButtonMap.GetKey(b.ButtonID);
|
||||
_Compiled += b.Compile();
|
||||
b.ButtonID = ButtonMap[b.ButtonID];
|
||||
}
|
||||
else
|
||||
{
|
||||
_Compiled += new GumpImage(b.X, b.Y, b.NormalID)
|
||||
{
|
||||
Parent = Desktop
|
||||
}.Compile();
|
||||
}
|
||||
}
|
||||
else if (e is GumpCheck)
|
||||
{
|
||||
var c = (GumpCheck)e;
|
||||
|
||||
if (focus)
|
||||
{
|
||||
SwitchMap[Desktop.NewSwitchID()] = c.SwitchID;
|
||||
|
||||
c.SwitchID = SwitchMap.GetKey(c.SwitchID);
|
||||
_Compiled += c.Compile();
|
||||
c.SwitchID = SwitchMap[c.SwitchID];
|
||||
}
|
||||
else
|
||||
{
|
||||
_Compiled += new GumpImage(c.X, c.Y, c.InitialState ? c.ActiveID : c.InactiveID)
|
||||
{
|
||||
Parent = Desktop
|
||||
}.Compile();
|
||||
}
|
||||
}
|
||||
else if (e is GumpRadio)
|
||||
{
|
||||
var r = (GumpRadio)e;
|
||||
|
||||
if (focus)
|
||||
{
|
||||
SwitchMap[Desktop.NewSwitchID()] = r.SwitchID;
|
||||
|
||||
r.SwitchID = SwitchMap.GetKey(r.SwitchID);
|
||||
_Compiled += r.Compile();
|
||||
r.SwitchID = SwitchMap[r.SwitchID];
|
||||
}
|
||||
else
|
||||
{
|
||||
_Compiled += new GumpImage(r.X, r.Y, r.InitialState ? r.ActiveID : r.InactiveID)
|
||||
{
|
||||
Parent = Desktop
|
||||
}.Compile();
|
||||
}
|
||||
}
|
||||
else if (e is GumpTextEntry)
|
||||
{
|
||||
var t = (GumpTextEntry)e;
|
||||
|
||||
if (focus)
|
||||
{
|
||||
TextMap[Desktop.NewTextEntryID()] = t.EntryID;
|
||||
|
||||
t.EntryID = TextMap.GetKey(t.EntryID);
|
||||
_Compiled += t.Compile();
|
||||
t.EntryID = TextMap[t.EntryID];
|
||||
}
|
||||
else
|
||||
{
|
||||
_Compiled += new GumpLabelCropped(t.X, t.Y, t.Width, t.Height, t.Hue, t.InitialText)
|
||||
{
|
||||
Parent = Desktop
|
||||
}.Compile();
|
||||
}
|
||||
}
|
||||
else if (e is GumpTextEntryLimited)
|
||||
{
|
||||
var t = (GumpTextEntryLimited)e;
|
||||
|
||||
if (focus)
|
||||
{
|
||||
TextMap[Desktop.NewTextEntryID()] = t.EntryID;
|
||||
|
||||
t.EntryID = TextMap.GetKey(t.EntryID);
|
||||
t.Parent = Desktop;
|
||||
_Compiled += t.Compile();
|
||||
t.EntryID = TextMap[t.EntryID];
|
||||
}
|
||||
else
|
||||
{
|
||||
_Compiled += new GumpLabelCropped(t.X, t.Y, t.Width, t.Height, t.Hue, t.InitialText)
|
||||
{
|
||||
Parent = Desktop
|
||||
}.Compile();
|
||||
}
|
||||
}
|
||||
else if (e is GumpPage)
|
||||
{
|
||||
var p = (GumpPage)e;
|
||||
|
||||
if (p.Page > 0)
|
||||
{
|
||||
esc = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_Compiled += e.Compile();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
|
||||
e.Parent = gump;
|
||||
|
||||
if (pos)
|
||||
{
|
||||
e.TrySetPosition(x, y);
|
||||
}
|
||||
|
||||
if (esc)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
entries.Free(true);
|
||||
|
||||
if (String.IsNullOrWhiteSpace(_Compiled))
|
||||
{
|
||||
_Compiled = "{{ gumptooltip -1 }}";
|
||||
}
|
||||
|
||||
_Buffer = Gump.StringToBuffer(_Compiled);
|
||||
}
|
||||
|
||||
public override string Compile()
|
||||
{
|
||||
return _Compiled;
|
||||
}
|
||||
|
||||
public override void AppendTo(IGumpWriter disp)
|
||||
{
|
||||
disp.AppendLayout(_Buffer);
|
||||
}
|
||||
|
||||
public bool OnResponse(NetState ns, RelayInfo info)
|
||||
{
|
||||
if (_Handler == null || Desktop == null || Desktop.Viewed == null || Desktop.Viewed.NetState == null ||
|
||||
Desktop.Viewed.NetState.Gumps == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var buttonID = info.ButtonID;
|
||||
|
||||
if (!ButtonMap.ContainsKey(buttonID))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
buttonID = ButtonMap[buttonID];
|
||||
|
||||
var switches = info.Switches.Where(SwitchMap.ContainsKey).Select(SwitchMap.GetValue).ToArray();
|
||||
var texts = info.TextEntries.Where(tr => TextMap.ContainsKey(tr.EntryID))
|
||||
.Select(tr => new TextRelay(TextMap[tr.EntryID], tr.Text))
|
||||
.ToArray();
|
||||
|
||||
Desktop.Viewed.NetState.Gumps.RemoveAll(g => g.TypeID == _TypeID);
|
||||
Desktop.Viewed.NetState.Send(new CloseGump(_TypeID, 0));
|
||||
|
||||
_Handler(Desktop.Viewed.NetState, new RelayInfo(buttonID, switches, texts));
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
ButtonMap.Clear();
|
||||
ButtonMap = null;
|
||||
|
||||
SwitchMap.Clear();
|
||||
SwitchMap = null;
|
||||
|
||||
TextMap.Clear();
|
||||
TextMap = null;
|
||||
|
||||
Desktop = null;
|
||||
|
||||
_Compiled = null;
|
||||
_Buffer = null;
|
||||
|
||||
_TypeID = -1;
|
||||
_Handler = null;
|
||||
|
||||
base.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public class DesktopGump : SuperGumpList<Gump>
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
CommandUtility.Register("ViewDesktop", AccessLevel.GameMaster, e => BeginDesktopTarget(e.Mobile));
|
||||
}
|
||||
|
||||
public static void BeginDesktopTarget(Mobile m)
|
||||
{
|
||||
if (m != null && !m.Deleted && m.IsOnline())
|
||||
{
|
||||
MobileSelectTarget.Begin(m, DisplayDesktop, null);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DisplayDesktop(Mobile viewer, Mobile viewed)
|
||||
{
|
||||
if (viewer == null || viewed == null || viewer == viewed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!viewed.IsOnline())
|
||||
{
|
||||
viewer.SendMessage(0x22, "You can't view the desktop of an offline player!");
|
||||
return;
|
||||
}
|
||||
|
||||
Send(new DesktopGump(viewer, viewed));
|
||||
}
|
||||
|
||||
private static IEnumerable<Gump> FilterGumps(IEnumerable<Gump> list)
|
||||
{
|
||||
return list.Where(g => g != null && !(g is DesktopGump) && !(g is NotifyGump))
|
||||
.Where(
|
||||
g =>
|
||||
{
|
||||
if (g is SuperGump)
|
||||
{
|
||||
var sg = (SuperGump)g;
|
||||
|
||||
if (sg.IsDisposed || !sg.Compiled || !sg.IsOpen)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
})
|
||||
.Reverse()
|
||||
.TakeUntil(g => g is SuperGump && ((SuperGump)g).Modal)
|
||||
.Reverse();
|
||||
}
|
||||
|
||||
private long _NextUpdate;
|
||||
|
||||
public Mobile Viewed { get; set; }
|
||||
|
||||
public DesktopGump(Mobile viewer, Mobile viewed)
|
||||
: base(viewer, null, 0, 0)
|
||||
{
|
||||
Viewed = viewed;
|
||||
|
||||
CanMove = false;
|
||||
CanResize = false;
|
||||
CanDispose = false;
|
||||
CanClose = true;
|
||||
|
||||
Modal = true;
|
||||
|
||||
BlockMovement = true;
|
||||
BlockSpeech = true;
|
||||
|
||||
AutoRefreshRate = TimeSpan.FromSeconds(30.0);
|
||||
AutoRefresh = true;
|
||||
}
|
||||
|
||||
protected override bool CanAutoRefresh()
|
||||
{
|
||||
if (IsDisposed || !IsOpen || !AutoRefresh || HasChildren || Viewed == null || Viewed.NetState == null)
|
||||
{
|
||||
return base.CanAutoRefresh();
|
||||
}
|
||||
|
||||
if (VitaNexCore.Ticks > _NextUpdate)
|
||||
{
|
||||
_NextUpdate = VitaNexCore.Ticks + 1000;
|
||||
|
||||
if (!List.ContentsEqual(FilterGumps(Viewed.NetState.Gumps), false))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return base.CanAutoRefresh();
|
||||
}
|
||||
|
||||
protected override void CompileList(List<Gump> list)
|
||||
{
|
||||
list.Clear();
|
||||
|
||||
if (Viewed != null && Viewed.NetState != null && Viewed.NetState.Gumps != null)
|
||||
{
|
||||
list.AddRange(FilterGumps(Viewed.NetState.Gumps));
|
||||
}
|
||||
|
||||
base.CompileList(list);
|
||||
}
|
||||
|
||||
protected override void CompileLayout(SuperGumpLayout layout)
|
||||
{
|
||||
base.CompileLayout(layout);
|
||||
|
||||
var i = 0;
|
||||
var l = List.LastOrDefault();
|
||||
|
||||
foreach (var g in List)
|
||||
{
|
||||
CompileEntryLayout(layout, i++, g, g == l);
|
||||
}
|
||||
|
||||
layout.Add(
|
||||
"cpanel",
|
||||
() =>
|
||||
{
|
||||
const int x = 620, y = 0, w = 200, h = 60;
|
||||
|
||||
AddImageTiled(x, y, w, h, 2624);
|
||||
AddAlphaRegion(x, y, w, h);
|
||||
|
||||
var title = "DESKTOP: ".WrapUOHtmlBold();
|
||||
title = title.WrapUOHtmlColor(Color.Gold, false);
|
||||
title = title + Viewed.RawName.WrapUOHtmlColor(User.GetNotorietyColor(Viewed), false);
|
||||
title = title.WrapUOHtmlCenter();
|
||||
|
||||
AddHtml(x + 5, y + 5, w - 10, h - 30, title, false, false);
|
||||
|
||||
AddButton(x + 5, h - 30, 4017, 4019, Close);
|
||||
AddTooltip(3000363); // Close
|
||||
|
||||
AddButton(x + 45, h - 30, 4014, 4016, Refresh);
|
||||
AddTooltip(1015002); // Refresh
|
||||
|
||||
AddRectangle(x, y, w, h, Color.Empty, Color.Gold, 2);
|
||||
});
|
||||
}
|
||||
|
||||
protected void CompileEntryLayout(SuperGumpLayout layout, int index, Gump gump, bool focus)
|
||||
{
|
||||
layout.Add(
|
||||
"gumps/" + index,
|
||||
() =>
|
||||
{
|
||||
//Console.WriteLine("Layout Entry {0}: {1}", index, gump);
|
||||
|
||||
Add(new DesktopGumpEntry(this, gump, focus));
|
||||
AddRectangle(gump.GetBounds(), Color.Empty, Color.LawnGreen, 2);
|
||||
});
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
if (IsDisposed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (info.ButtonID > 0 && GetButtonEntry(info.ButtonID) == null && GetTileButtonEntry(info.ButtonID) == null)
|
||||
{
|
||||
var handled = VitaNexCore.TryCatchGet(
|
||||
() =>
|
||||
{
|
||||
if (GetEntries<DesktopGumpEntry>().Any(e => e.OnResponse(sender, info)))
|
||||
{
|
||||
User.SendMessage("Response injection successful!");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
if (handled)
|
||||
{
|
||||
Refresh(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
base.OnResponse(sender, info);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,229 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#region References
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
|
||||
using Server.Gumps;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps.Gml
|
||||
{
|
||||
public interface IGmlReader : IDisposable
|
||||
{
|
||||
Stream Stream { get; }
|
||||
|
||||
GumpPage ReadPage();
|
||||
GumpGroup ReadGroup();
|
||||
GumpTooltip ReadTooltip();
|
||||
GumpAlphaRegion ReadAlphaRegion();
|
||||
GumpBackground ReadBackground();
|
||||
GumpImage ReadImage();
|
||||
GumpImageTiled ReadImageTiled();
|
||||
GumpImageTileButton ReadImageTiledButton();
|
||||
GumpItem ReadItem();
|
||||
GumpLabel ReadLabel();
|
||||
GumpLabelCropped ReadLabelCropped();
|
||||
GumpHtml ReadHtml();
|
||||
GumpHtmlLocalized ReadHtmlLocalized();
|
||||
GumpButton ReadButton();
|
||||
GumpCheck ReadCheck();
|
||||
GumpRadio ReadRadio();
|
||||
GumpTextEntry ReadTextEntry();
|
||||
GumpTextEntryLimited ReadTextEntryLimited();
|
||||
}
|
||||
|
||||
public class GmlReader : IGmlReader
|
||||
{
|
||||
private readonly XmlDocument _Document;
|
||||
private readonly XmlElement _RootNode;
|
||||
|
||||
private XmlElement _LastNode;
|
||||
private XmlElement _CurrentNode;
|
||||
|
||||
public Stream Stream { get; private set; }
|
||||
|
||||
public GmlReader(Stream stream)
|
||||
{
|
||||
_Document = new XmlDocument();
|
||||
|
||||
Stream = stream;
|
||||
|
||||
_Document.Load(Stream);
|
||||
|
||||
_RootNode = _Document["gump"];
|
||||
}
|
||||
|
||||
private void MoveNext()
|
||||
{
|
||||
_LastNode = _CurrentNode ?? _RootNode;
|
||||
|
||||
_CurrentNode = null;
|
||||
|
||||
while (_CurrentNode == null)
|
||||
{
|
||||
if (_LastNode.HasChildNodes)
|
||||
{
|
||||
foreach (var e in _LastNode.ChildNodes.OfType<XmlElement>())
|
||||
{
|
||||
_CurrentNode = e;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (_LastNode.NextSibling is XmlElement)
|
||||
{
|
||||
_CurrentNode = (XmlElement)_LastNode.NextSibling;
|
||||
}
|
||||
else if (_LastNode.ParentNode is XmlElement)
|
||||
{
|
||||
var parent = (XmlElement)_LastNode.ParentNode;
|
||||
|
||||
if (parent.NextSibling is XmlElement)
|
||||
{
|
||||
_CurrentNode = (XmlElement)parent.NextSibling;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual GumpPage ReadPage()
|
||||
{
|
||||
MoveNext();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual GumpGroup ReadGroup()
|
||||
{
|
||||
MoveNext();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual GumpTooltip ReadTooltip()
|
||||
{
|
||||
MoveNext();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual GumpAlphaRegion ReadAlphaRegion()
|
||||
{
|
||||
MoveNext();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual GumpBackground ReadBackground()
|
||||
{
|
||||
MoveNext();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual GumpImage ReadImage()
|
||||
{
|
||||
MoveNext();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual GumpImageTiled ReadImageTiled()
|
||||
{
|
||||
MoveNext();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual GumpImageTileButton ReadImageTiledButton()
|
||||
{
|
||||
MoveNext();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual GumpItem ReadItem()
|
||||
{
|
||||
MoveNext();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual GumpLabel ReadLabel()
|
||||
{
|
||||
MoveNext();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual GumpLabelCropped ReadLabelCropped()
|
||||
{
|
||||
MoveNext();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual GumpHtml ReadHtml()
|
||||
{
|
||||
MoveNext();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual GumpHtmlLocalized ReadHtmlLocalized()
|
||||
{
|
||||
MoveNext();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual GumpButton ReadButton()
|
||||
{
|
||||
MoveNext();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual GumpCheck ReadCheck()
|
||||
{
|
||||
MoveNext();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual GumpRadio ReadRadio()
|
||||
{
|
||||
MoveNext();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual GumpTextEntry ReadTextEntry()
|
||||
{
|
||||
MoveNext();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual GumpTextEntryLimited ReadTextEntryLimited()
|
||||
{
|
||||
MoveNext();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual void Dispose()
|
||||
{ }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,384 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#region References
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
|
||||
using Server.Gumps;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps.Gml
|
||||
{
|
||||
public interface IGmlWriter : IDisposable
|
||||
{
|
||||
void Write(string name, GumpPage e);
|
||||
void Write(string name, GumpGroup e);
|
||||
void Write(string name, GumpTooltip e);
|
||||
void Write(string name, GumpAlphaRegion e);
|
||||
void Write(string name, GumpBackground e);
|
||||
void Write(string name, GumpImage e);
|
||||
void Write(string name, GumpImageTiled e);
|
||||
void Write(string name, GumpImageTileButton e);
|
||||
void Write(string name, GumpItem e);
|
||||
void Write(string name, GumpLabel e);
|
||||
void Write(string name, GumpLabelCropped e);
|
||||
void Write(string name, GumpHtml e);
|
||||
void Write(string name, GumpHtmlLocalized e);
|
||||
void Write(string name, GumpButton e);
|
||||
void Write(string name, GumpCheck e);
|
||||
void Write(string name, GumpRadio e);
|
||||
void Write(string name, GumpTextEntry e);
|
||||
void Write(string name, GumpTextEntryLimited e);
|
||||
|
||||
void Save(Stream stream);
|
||||
}
|
||||
|
||||
public class GmlWriter : IGmlWriter
|
||||
{
|
||||
private readonly XmlDocument _Document;
|
||||
private readonly XmlElement _RootNode;
|
||||
|
||||
private XmlElement _LastNode;
|
||||
private XmlElement _CurrentNode;
|
||||
private XmlElement _CurrentPageNode;
|
||||
private XmlElement _CurrentGroupNode;
|
||||
|
||||
public GmlWriter()
|
||||
{
|
||||
_Document = new XmlDocument();
|
||||
_RootNode = _Document.CreateElement("gump");
|
||||
}
|
||||
|
||||
~GmlWriter()
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
|
||||
private void CreateElement(GumpEntry e)
|
||||
{
|
||||
_CurrentNode = _Document.CreateElement(e.GetType().Name);
|
||||
}
|
||||
|
||||
private void CreatePageElement(GumpPage e)
|
||||
{
|
||||
_CurrentPageNode = _Document.CreateElement(e.GetType().Name);
|
||||
}
|
||||
|
||||
private void CreateGroupElement(GumpGroup e)
|
||||
{
|
||||
_CurrentGroupNode = _Document.CreateElement(e.GetType().Name);
|
||||
}
|
||||
|
||||
private void SetValue(object value)
|
||||
{
|
||||
_CurrentNode.Value = value != null ? value.ToString() : String.Empty;
|
||||
}
|
||||
|
||||
private void SetAttribute(string name, object value)
|
||||
{
|
||||
_CurrentNode.SetAttribute(name, value != null ? value.ToString() : String.Empty);
|
||||
}
|
||||
|
||||
private void SetPageAttribute(string name, object value)
|
||||
{
|
||||
_CurrentPageNode.SetAttribute(name, value != null ? value.ToString() : String.Empty);
|
||||
}
|
||||
|
||||
private void SetGroupAttribute(string name, object value)
|
||||
{
|
||||
_CurrentPageNode.SetAttribute(name, value != null ? value.ToString() : String.Empty);
|
||||
}
|
||||
|
||||
private void Append()
|
||||
{
|
||||
if (_CurrentNode == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
(_CurrentGroupNode ?? _CurrentPageNode ?? _RootNode).AppendChild(_CurrentNode);
|
||||
|
||||
_LastNode = _CurrentNode;
|
||||
_CurrentNode = null;
|
||||
}
|
||||
|
||||
private void AppendPage()
|
||||
{
|
||||
if (_CurrentPageNode == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_RootNode.AppendChild(_CurrentPageNode);
|
||||
|
||||
_CurrentPageNode = null;
|
||||
}
|
||||
|
||||
private void AppendGroup()
|
||||
{
|
||||
if (_CurrentGroupNode == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
(_CurrentPageNode ?? _RootNode).AppendChild(_CurrentGroupNode);
|
||||
|
||||
_CurrentGroupNode = null;
|
||||
}
|
||||
|
||||
public virtual void Dispose()
|
||||
{ }
|
||||
|
||||
public virtual void Write(string name, GumpPage e)
|
||||
{
|
||||
AppendPage();
|
||||
CreatePageElement(e);
|
||||
SetPageAttribute("name", name);
|
||||
SetPageAttribute("value", e.Page);
|
||||
}
|
||||
|
||||
public virtual void Write(string name, GumpGroup e)
|
||||
{
|
||||
if (_LastNode != null && _LastNode.Name != e.GetType().Name)
|
||||
{
|
||||
SetAttribute("group", e.Group);
|
||||
return;
|
||||
}
|
||||
|
||||
AppendGroup();
|
||||
CreateGroupElement(e);
|
||||
SetGroupAttribute("name", name);
|
||||
SetGroupAttribute("value", e.Group);
|
||||
}
|
||||
|
||||
public virtual void Write(string name, GumpTooltip e)
|
||||
{
|
||||
if (_LastNode != null && _LastNode.Name != e.GetType().Name)
|
||||
{
|
||||
SetAttribute("tooltip", e.Number);
|
||||
return;
|
||||
}
|
||||
|
||||
CreateElement(e);
|
||||
SetAttribute("name", name);
|
||||
SetAttribute("value", e.Number);
|
||||
Append();
|
||||
}
|
||||
|
||||
public virtual void Write(string name, GumpAlphaRegion e)
|
||||
{
|
||||
CreateElement(e);
|
||||
SetAttribute("name", name);
|
||||
SetAttribute("x", e.X);
|
||||
SetAttribute("y", e.Y);
|
||||
SetAttribute("width", e.Width);
|
||||
SetAttribute("height", e.Height);
|
||||
Append();
|
||||
}
|
||||
|
||||
public virtual void Write(string name, GumpBackground e)
|
||||
{
|
||||
CreateElement(e);
|
||||
SetAttribute("name", name);
|
||||
SetAttribute("x", e.X);
|
||||
SetAttribute("y", e.Y);
|
||||
SetAttribute("width", e.Width);
|
||||
SetAttribute("height", e.Height);
|
||||
SetAttribute("gumpid", e.GumpID);
|
||||
Append();
|
||||
}
|
||||
|
||||
public virtual void Write(string name, GumpImage e)
|
||||
{
|
||||
CreateElement(e);
|
||||
SetAttribute("name", name);
|
||||
SetAttribute("x", e.X);
|
||||
SetAttribute("y", e.Y);
|
||||
SetAttribute("hue", e.Hue);
|
||||
SetAttribute("gumpid", e.GumpID);
|
||||
Append();
|
||||
}
|
||||
|
||||
public virtual void Write(string name, GumpImageTiled e)
|
||||
{
|
||||
CreateElement(e);
|
||||
SetAttribute("name", name);
|
||||
SetAttribute("x", e.X);
|
||||
SetAttribute("y", e.Y);
|
||||
SetAttribute("width", e.Width);
|
||||
SetAttribute("height", e.Height);
|
||||
SetAttribute("gumpid", e.GumpID);
|
||||
Append();
|
||||
}
|
||||
|
||||
public virtual void Write(string name, GumpImageTileButton e)
|
||||
{
|
||||
CreateElement(e);
|
||||
SetAttribute("name", name);
|
||||
SetAttribute("x", e.X);
|
||||
SetAttribute("y", e.Y);
|
||||
SetAttribute("width", e.Width);
|
||||
SetAttribute("height", e.Height);
|
||||
SetAttribute("itemid", e.ItemID);
|
||||
SetAttribute("buttonid", e.ButtonID);
|
||||
SetAttribute("normalid", e.NormalID);
|
||||
SetAttribute("pressedid", e.PressedID);
|
||||
SetAttribute("hue", e.Hue);
|
||||
SetAttribute("tooltip", e.LocalizedTooltip);
|
||||
Append();
|
||||
}
|
||||
|
||||
public virtual void Write(string name, GumpItem e)
|
||||
{
|
||||
CreateElement(e);
|
||||
SetAttribute("name", name);
|
||||
SetAttribute("x", e.X);
|
||||
SetAttribute("y", e.Y);
|
||||
SetAttribute("itemid", e.ItemID);
|
||||
SetAttribute("hue", e.Hue);
|
||||
Append();
|
||||
}
|
||||
|
||||
public virtual void Write(string name, GumpLabel e)
|
||||
{
|
||||
CreateElement(e);
|
||||
SetAttribute("name", name);
|
||||
SetAttribute("x", e.X);
|
||||
SetAttribute("y", e.Y);
|
||||
SetAttribute("hue", e.Hue);
|
||||
SetValue(e.Text);
|
||||
Append();
|
||||
}
|
||||
|
||||
public virtual void Write(string name, GumpLabelCropped e)
|
||||
{
|
||||
CreateElement(e);
|
||||
SetAttribute("name", name);
|
||||
SetAttribute("x", e.X);
|
||||
SetAttribute("y", e.Y);
|
||||
SetAttribute("width", e.Width);
|
||||
SetAttribute("height", e.Height);
|
||||
SetAttribute("hue", e.Hue);
|
||||
SetValue(e.Text);
|
||||
Append();
|
||||
}
|
||||
|
||||
public virtual void Write(string name, GumpHtml e)
|
||||
{
|
||||
CreateElement(e);
|
||||
SetAttribute("name", name);
|
||||
SetAttribute("x", e.X);
|
||||
SetAttribute("y", e.Y);
|
||||
SetAttribute("width", e.Width);
|
||||
SetAttribute("height", e.Height);
|
||||
SetAttribute("scrollbar", e.Scrollbar);
|
||||
SetAttribute("background", e.Background);
|
||||
SetValue(e.Text);
|
||||
Append();
|
||||
}
|
||||
|
||||
public virtual void Write(string name, GumpHtmlLocalized e)
|
||||
{
|
||||
CreateElement(e);
|
||||
SetAttribute("name", name);
|
||||
SetAttribute("x", e.X);
|
||||
SetAttribute("y", e.Y);
|
||||
SetAttribute("width", e.Width);
|
||||
SetAttribute("height", e.Height);
|
||||
SetAttribute("scrollbar", e.Scrollbar);
|
||||
SetAttribute("background", e.Background);
|
||||
SetAttribute("value", e.Number);
|
||||
SetAttribute("args", e.Args);
|
||||
Append();
|
||||
}
|
||||
|
||||
public virtual void Write(string name, GumpButton e)
|
||||
{
|
||||
CreateElement(e);
|
||||
SetAttribute("name", name);
|
||||
SetAttribute("x", e.X);
|
||||
SetAttribute("y", e.Y);
|
||||
SetAttribute("buttonid", e.ButtonID);
|
||||
SetAttribute("normalid", e.NormalID);
|
||||
SetAttribute("pressedid", e.PressedID);
|
||||
SetAttribute("type", e.Type);
|
||||
SetAttribute("param", e.Param);
|
||||
Append();
|
||||
}
|
||||
|
||||
public virtual void Write(string name, GumpCheck e)
|
||||
{
|
||||
CreateElement(e);
|
||||
SetAttribute("name", name);
|
||||
SetAttribute("x", e.X);
|
||||
SetAttribute("y", e.Y);
|
||||
SetAttribute("switchid", e.SwitchID);
|
||||
SetAttribute("onid", e.ActiveID);
|
||||
SetAttribute("offid", e.InactiveID);
|
||||
SetAttribute("state", e.InitialState);
|
||||
Append();
|
||||
}
|
||||
|
||||
public virtual void Write(string name, GumpRadio e)
|
||||
{
|
||||
CreateElement(e);
|
||||
SetAttribute("name", name);
|
||||
SetAttribute("x", e.X);
|
||||
SetAttribute("y", e.Y);
|
||||
SetAttribute("switchid", e.SwitchID);
|
||||
SetAttribute("onid", e.ActiveID);
|
||||
SetAttribute("offid", e.InactiveID);
|
||||
SetAttribute("state", e.InitialState);
|
||||
Append();
|
||||
}
|
||||
|
||||
public virtual void Write(string name, GumpTextEntry e)
|
||||
{
|
||||
CreateElement(e);
|
||||
SetAttribute("name", name);
|
||||
SetAttribute("x", e.X);
|
||||
SetAttribute("y", e.Y);
|
||||
SetAttribute("width", e.Width);
|
||||
SetAttribute("height", e.Height);
|
||||
SetAttribute("entryid", e.EntryID);
|
||||
SetAttribute("hue", e.Hue);
|
||||
SetValue(e.InitialText);
|
||||
Append();
|
||||
}
|
||||
|
||||
public virtual void Write(string name, GumpTextEntryLimited e)
|
||||
{
|
||||
CreateElement(e);
|
||||
SetAttribute("name", name);
|
||||
SetAttribute("x", e.X);
|
||||
SetAttribute("y", e.Y);
|
||||
SetAttribute("width", e.Width);
|
||||
SetAttribute("height", e.Height);
|
||||
SetAttribute("entryid", e.EntryID);
|
||||
SetAttribute("limit", e.Size);
|
||||
SetAttribute("hue", e.Hue);
|
||||
SetValue(e.InitialText);
|
||||
Append();
|
||||
}
|
||||
|
||||
public void Save(Stream stream)
|
||||
{
|
||||
Append();
|
||||
AppendGroup();
|
||||
AppendPage();
|
||||
|
||||
_Document.AppendChild(_RootNode);
|
||||
_Document.Save(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public interface ISuperGumpPages
|
||||
{
|
||||
int EntriesPerPage { get; set; }
|
||||
int PageCount { get; }
|
||||
int Page { get; set; }
|
||||
|
||||
void PreviousPage();
|
||||
void PreviousPage(int delta);
|
||||
|
||||
void NextPage();
|
||||
void NextPage(int delta);
|
||||
|
||||
void FirstPage();
|
||||
void LastPage();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
#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.Linq;
|
||||
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public abstract class SuperGumpDictionary<T1, T2> : SuperGumpPages
|
||||
{
|
||||
private static Dictionary<T1, T2> Acquire(IDictionary<T1, T2> dictionary = null)
|
||||
{
|
||||
return dictionary != null ? new Dictionary<T1, T2>(dictionary) : new Dictionary<T1, T2>(0x100);
|
||||
}
|
||||
|
||||
public Dictionary<T1, T2> List { get; set; }
|
||||
|
||||
public override int EntryCount => List.Count;
|
||||
|
||||
public SuperGumpDictionary(
|
||||
Mobile user,
|
||||
Gump parent = null,
|
||||
int? x = null,
|
||||
int? y = null,
|
||||
IDictionary<T1, T2> dictionary = null)
|
||||
: base(user, parent, x, y)
|
||||
{
|
||||
List = Acquire(dictionary);
|
||||
}
|
||||
|
||||
protected override void Compile()
|
||||
{
|
||||
if (List == null)
|
||||
{
|
||||
List = Acquire();
|
||||
}
|
||||
|
||||
CompileList(List);
|
||||
|
||||
base.Compile();
|
||||
}
|
||||
|
||||
public Dictionary<int, KeyValuePair<T1, T2>> GetListRange()
|
||||
{
|
||||
return GetListRange(Page * EntriesPerPage, EntriesPerPage);
|
||||
}
|
||||
|
||||
public Dictionary<int, KeyValuePair<T1, T2>> GetListRange(int index, int length)
|
||||
{
|
||||
index = Math.Max(0, Math.Min(EntryCount, index));
|
||||
length = Math.Max(0, Math.Min(EntryCount - index, length));
|
||||
|
||||
var d = new Dictionary<int, KeyValuePair<T1, T2>>(length);
|
||||
|
||||
while (--length >= 0 && List.InBounds(index))
|
||||
{
|
||||
d[index] = List.ElementAtOrDefault(index);
|
||||
|
||||
++index;
|
||||
}
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
protected virtual void CompileList(Dictionary<T1, T2> list)
|
||||
{ }
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
base.OnDispose();
|
||||
|
||||
if (List != null)
|
||||
{
|
||||
List.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDisposed()
|
||||
{
|
||||
base.OnDisposed();
|
||||
|
||||
List = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,455 @@
|
||||
#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.Linq;
|
||||
|
||||
using VitaNex.Collections;
|
||||
|
||||
using CollectionI =
|
||||
System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<string, System.Action>>;
|
||||
using Dictionary = System.Collections.Generic.Dictionary<string, System.Action>;
|
||||
using DictionaryI = System.Collections.Generic.IDictionary<string, System.Action>;
|
||||
using KeyValuePair = System.Collections.Generic.KeyValuePair<string, System.Action>;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public class SuperGumpLayout : DictionaryI, IDisposable
|
||||
{
|
||||
private Dictionary _Entries;
|
||||
|
||||
public bool IsDisposed => _Entries == null;
|
||||
|
||||
public int Count => _Entries.Count;
|
||||
|
||||
public Dictionary.KeyCollection Keys => _Entries.Keys;
|
||||
public Dictionary.ValueCollection Values => _Entries.Values;
|
||||
|
||||
ICollection<string> DictionaryI.Keys => Keys;
|
||||
ICollection<Action> DictionaryI.Values => Values;
|
||||
|
||||
bool CollectionI.IsReadOnly => ((CollectionI)_Entries).IsReadOnly;
|
||||
|
||||
public Action this[string xpath] { get => _Entries.GetValue(xpath); set => _Entries[xpath] = value; }
|
||||
|
||||
public SuperGumpLayout()
|
||||
{
|
||||
_Entries = DictionaryPool<string, Action>.AcquireObject();
|
||||
}
|
||||
|
||||
public SuperGumpLayout(DictionaryI entries)
|
||||
: this()
|
||||
{
|
||||
foreach (var kv in entries)
|
||||
{
|
||||
Add(kv.Key, kv.Value);
|
||||
}
|
||||
}
|
||||
|
||||
public SuperGumpLayout(IEnumerable<KeyValuePair> entries)
|
||||
: this()
|
||||
{
|
||||
foreach (var kv in entries)
|
||||
{
|
||||
Add(kv.Key, kv.Value);
|
||||
}
|
||||
}
|
||||
|
||||
void CollectionI.Add(KeyValuePair item)
|
||||
{
|
||||
((CollectionI)_Entries).Add(item);
|
||||
}
|
||||
|
||||
bool CollectionI.Remove(KeyValuePair item)
|
||||
{
|
||||
return ((CollectionI)_Entries).Remove(item);
|
||||
}
|
||||
|
||||
bool CollectionI.Contains(KeyValuePair item)
|
||||
{
|
||||
return ((CollectionI)_Entries).Contains(item);
|
||||
}
|
||||
|
||||
void CollectionI.CopyTo(KeyValuePair[] array, int arrayIndex)
|
||||
{
|
||||
((CollectionI)_Entries).CopyTo(array, arrayIndex);
|
||||
}
|
||||
|
||||
bool DictionaryI.TryGetValue(string xpath, out Action value)
|
||||
{
|
||||
return Find(xpath, out value);
|
||||
}
|
||||
|
||||
bool DictionaryI.ContainsKey(string xpath)
|
||||
{
|
||||
return Contains(xpath);
|
||||
}
|
||||
|
||||
public bool Find(string key, out Action value)
|
||||
{
|
||||
return _Entries.TryGetValue(key, out value);
|
||||
}
|
||||
|
||||
public bool Contains(string xpath)
|
||||
{
|
||||
return _Entries.ContainsKey(xpath);
|
||||
}
|
||||
|
||||
public bool Contains(Action value)
|
||||
{
|
||||
return _Entries.ContainsValue(value);
|
||||
}
|
||||
|
||||
public bool Remove(string xpath)
|
||||
{
|
||||
return _Entries.Remove(xpath);
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
_Entries.Clear();
|
||||
}
|
||||
|
||||
public void Combine(string xpath, Action value)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(xpath) || value == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Contains(xpath))
|
||||
{
|
||||
_Entries[xpath] += value;
|
||||
}
|
||||
else
|
||||
{
|
||||
_Entries[xpath] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public void Combine<T>(string xpath, Action<T> value, T state)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(xpath) || value == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Contains(xpath))
|
||||
{
|
||||
_Entries[xpath] += () => value(state);
|
||||
}
|
||||
else
|
||||
{
|
||||
_Entries[xpath] = () => value(state);
|
||||
}
|
||||
}
|
||||
|
||||
public void Combine(string xpath, Action<string> value)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(xpath) || value == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Contains(xpath))
|
||||
{
|
||||
_Entries[xpath] += () => value(xpath);
|
||||
}
|
||||
else
|
||||
{
|
||||
_Entries[xpath] = () => value(xpath);
|
||||
}
|
||||
}
|
||||
|
||||
public void Combine<T>(string xpath, Action<string, T> value, T state)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(xpath) || value == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Contains(xpath))
|
||||
{
|
||||
_Entries[xpath] += () => value(xpath, state);
|
||||
}
|
||||
else
|
||||
{
|
||||
_Entries[xpath] = () => value(xpath, state);
|
||||
}
|
||||
}
|
||||
|
||||
public void Replace(string xpath, Action value)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(xpath))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (value == null)
|
||||
{
|
||||
Remove(xpath);
|
||||
}
|
||||
else
|
||||
{
|
||||
_Entries[xpath] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public void Replace<T>(string xpath, Action<T> value, T state)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(xpath))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (value == null)
|
||||
{
|
||||
Remove(xpath);
|
||||
}
|
||||
else
|
||||
{
|
||||
_Entries[xpath] = () => value(state);
|
||||
}
|
||||
}
|
||||
|
||||
public void Replace(string xpath, Action<string> value)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(xpath))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (value == null)
|
||||
{
|
||||
Remove(xpath);
|
||||
}
|
||||
else
|
||||
{
|
||||
_Entries[xpath] = () => value(xpath);
|
||||
}
|
||||
}
|
||||
|
||||
public void Replace<T>(string xpath, Action<string, T> value, T state)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(xpath))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (value == null)
|
||||
{
|
||||
Remove(xpath);
|
||||
}
|
||||
else
|
||||
{
|
||||
_Entries[xpath] = () => value(xpath, state);
|
||||
}
|
||||
}
|
||||
|
||||
public void Add(string xpath, Action value)
|
||||
{
|
||||
if (!String.IsNullOrWhiteSpace(xpath) && value != null)
|
||||
{
|
||||
_Entries.Add(xpath, value);
|
||||
}
|
||||
}
|
||||
|
||||
public void Add<T>(string xpath, Action<T> value, T state)
|
||||
{
|
||||
if (!String.IsNullOrWhiteSpace(xpath) && value != null)
|
||||
{
|
||||
_Entries.Add(xpath, () => value(state));
|
||||
}
|
||||
}
|
||||
|
||||
public void Add(string xpath, Action<string> value)
|
||||
{
|
||||
if (!String.IsNullOrWhiteSpace(xpath) && value != null)
|
||||
{
|
||||
_Entries.Add(xpath, () => value(xpath));
|
||||
}
|
||||
}
|
||||
|
||||
public void Add<T>(string xpath, Action<string, T> value, T state)
|
||||
{
|
||||
if (!String.IsNullOrWhiteSpace(xpath) && value != null)
|
||||
{
|
||||
_Entries.Add(xpath, () => value(xpath, state));
|
||||
}
|
||||
}
|
||||
|
||||
public void AddBefore(string search, string xpath, Action value)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(xpath) || value == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var index = Keys.IndexOf(search);
|
||||
|
||||
if (index < 0)
|
||||
{
|
||||
index = 0;
|
||||
}
|
||||
|
||||
_Entries.Insert(index, xpath, value);
|
||||
}
|
||||
|
||||
public void AddBefore<T>(string search, string xpath, Action<T> value, T state)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(xpath) || value == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var index = Keys.IndexOf(search);
|
||||
|
||||
if (index < 0)
|
||||
{
|
||||
index = 0;
|
||||
}
|
||||
|
||||
_Entries.Insert(index, xpath, () => value(state));
|
||||
}
|
||||
|
||||
public void AddBefore(string search, string xpath, Action<string> value)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(xpath) || value == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var index = Keys.IndexOf(search);
|
||||
|
||||
if (index < 0)
|
||||
{
|
||||
index = 0;
|
||||
}
|
||||
|
||||
_Entries.Insert(index, xpath, () => value(xpath));
|
||||
}
|
||||
|
||||
public void AddBefore<T>(string search, string xpath, Action<string, T> value, T state)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(xpath) || value == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var index = Keys.IndexOf(search);
|
||||
|
||||
if (index < 0)
|
||||
{
|
||||
index = 0;
|
||||
}
|
||||
|
||||
_Entries.Insert(index, xpath, () => value(xpath, state));
|
||||
}
|
||||
|
||||
public void AddAfter(string search, string xpath, Action value)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(xpath) || value == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var index = Keys.IndexOf(search);
|
||||
|
||||
if (index < 0)
|
||||
{
|
||||
index = _Entries.Count - 1;
|
||||
}
|
||||
|
||||
_Entries.Insert(index + 1, xpath, value);
|
||||
}
|
||||
|
||||
public void AddAfter<T>(string search, string xpath, Action<T> value, T state)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(xpath) || value == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var index = Keys.IndexOf(search);
|
||||
|
||||
if (index < 0)
|
||||
{
|
||||
index = _Entries.Count - 1;
|
||||
}
|
||||
|
||||
_Entries.Insert(index + 1, xpath, () => value(state));
|
||||
}
|
||||
|
||||
public void AddAfter(string search, string xpath, Action<string> value)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(xpath) || value == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var index = Keys.IndexOf(search);
|
||||
|
||||
if (index < 0)
|
||||
{
|
||||
index = _Entries.Count - 1;
|
||||
}
|
||||
|
||||
_Entries.Insert(index + 1, xpath, () => value(xpath));
|
||||
}
|
||||
|
||||
public void AddAfter<T>(string search, string xpath, Action<string, T> value, T state)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(xpath) || value == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var index = Keys.IndexOf(search);
|
||||
|
||||
if (index < 0)
|
||||
{
|
||||
index = _Entries.Count - 1;
|
||||
}
|
||||
|
||||
_Entries.Insert(index + 1, xpath, () => value(xpath, state));
|
||||
}
|
||||
|
||||
public void ApplyTo(SuperGump gump)
|
||||
{
|
||||
foreach (var renderer in Values.Where(o => o != null))
|
||||
{
|
||||
renderer();
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_Entries != null)
|
||||
{
|
||||
ObjectPool.Free(ref _Entries);
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerator<KeyValuePair> GetEnumerator()
|
||||
{
|
||||
return _Entries.GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
#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.Collections;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public abstract class SuperGumpList<T> : SuperGumpPages
|
||||
{
|
||||
public static List<T> Acquire(IEnumerable<T> e = null)
|
||||
{
|
||||
var o = ListPool<T>.AcquireObject();
|
||||
|
||||
if (e != null)
|
||||
{
|
||||
o.AddRange(e);
|
||||
}
|
||||
else if (o.Capacity < 0x40)
|
||||
{
|
||||
o.Capacity = 0x40;
|
||||
}
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
public static void Free(List<T> o)
|
||||
{
|
||||
ListPool<T>.FreeObject(o);
|
||||
}
|
||||
|
||||
public virtual List<T> List { get; set; }
|
||||
|
||||
public override int EntryCount => List.Count;
|
||||
|
||||
public virtual bool Sorted { get; set; }
|
||||
|
||||
public SuperGumpList(Mobile user, Gump parent = null, int? x = null, int? y = null, IEnumerable<T> list = null)
|
||||
: base(user, parent, x, y)
|
||||
{
|
||||
List = Acquire(list);
|
||||
}
|
||||
|
||||
protected override void Compile()
|
||||
{
|
||||
if (List == null)
|
||||
{
|
||||
List = Acquire();
|
||||
}
|
||||
|
||||
CompileList(List);
|
||||
|
||||
if (Sorted)
|
||||
{
|
||||
Sort();
|
||||
}
|
||||
|
||||
base.Compile();
|
||||
}
|
||||
|
||||
public virtual IEnumerable<T> EnumerateListRange()
|
||||
{
|
||||
return EnumerateListRange(Page * EntriesPerPage, EntriesPerPage);
|
||||
}
|
||||
|
||||
public virtual IEnumerable<T> EnumerateListRange(int index, int length)
|
||||
{
|
||||
index = Math.Max(0, Math.Min(EntryCount, index));
|
||||
length = Math.Max(0, Math.Min(EntryCount - index, length));
|
||||
|
||||
while (--length >= 0 && List.InBounds(index))
|
||||
{
|
||||
yield return List[index++];
|
||||
}
|
||||
}
|
||||
|
||||
public virtual Dictionary<int, T> GetListRange()
|
||||
{
|
||||
return GetListRange(Page * EntriesPerPage, EntriesPerPage);
|
||||
}
|
||||
|
||||
public virtual Dictionary<int, T> GetListRange(int index, int length)
|
||||
{
|
||||
index = Math.Max(0, Math.Min(EntryCount, index));
|
||||
length = Math.Max(0, Math.Min(EntryCount - index, length));
|
||||
|
||||
var d = new Dictionary<int, T>(length);
|
||||
|
||||
while (--length >= 0 && List.InBounds(index))
|
||||
{
|
||||
d[index] = List[index++];
|
||||
}
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
protected virtual void CompileList(List<T> list)
|
||||
{ }
|
||||
|
||||
public virtual int SortCompare(T a, T b)
|
||||
{
|
||||
if (a is IComparable<T> ac)
|
||||
{
|
||||
return ac.CompareTo(b);
|
||||
}
|
||||
|
||||
if (b is IComparable<T> bc)
|
||||
{
|
||||
return bc.CompareTo(a);
|
||||
}
|
||||
|
||||
return a.CompareNull(b);
|
||||
}
|
||||
|
||||
public virtual void Sort()
|
||||
{
|
||||
List.Sort(SortCompare);
|
||||
}
|
||||
|
||||
public virtual void Sort(Comparison<T> comparison)
|
||||
{
|
||||
if (comparison != null)
|
||||
{
|
||||
List.Sort(comparison);
|
||||
return;
|
||||
}
|
||||
|
||||
Sort();
|
||||
}
|
||||
|
||||
public virtual void Sort(IComparer<T> comparer)
|
||||
{
|
||||
if (comparer != null)
|
||||
{
|
||||
List.Sort(comparer);
|
||||
return;
|
||||
}
|
||||
|
||||
Sort();
|
||||
}
|
||||
|
||||
protected override void OnClosed(bool all)
|
||||
{
|
||||
base.OnClosed(all);
|
||||
|
||||
if (!IsOpen)
|
||||
{
|
||||
List.Free(false);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
base.OnDispose();
|
||||
|
||||
if (List != null)
|
||||
{
|
||||
List.Free(true);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDisposed()
|
||||
{
|
||||
base.OnDisposed();
|
||||
|
||||
if (List == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var o = List;
|
||||
|
||||
List = null;
|
||||
|
||||
Free(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#region References
|
||||
using System;
|
||||
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps
|
||||
{
|
||||
public abstract class SuperGumpPages : SuperGump, ISuperGumpPages
|
||||
{
|
||||
public static int DefaultEntriesPerPage = 10;
|
||||
|
||||
private int _Page;
|
||||
|
||||
public int PageCount { get; protected set; }
|
||||
|
||||
public abstract int EntryCount { get; }
|
||||
|
||||
public virtual int EntriesPerPage { get; set; }
|
||||
public virtual int Page { get => _Page; set => _Page = Math.Max(0, Math.Min(PageCount, value)); }
|
||||
|
||||
public virtual bool HasPrevPage => Page > 0;
|
||||
public virtual bool HasNextPage => Page < PageCount - 1;
|
||||
|
||||
public SuperGumpPages(Mobile user, Gump parent = null, int? x = null, int? y = null)
|
||||
: base(user, parent, x, y)
|
||||
{
|
||||
EntriesPerPage = DefaultEntriesPerPage;
|
||||
}
|
||||
|
||||
protected override void Compile()
|
||||
{
|
||||
InvalidatePageCount();
|
||||
|
||||
base.Compile();
|
||||
}
|
||||
|
||||
public virtual void InvalidatePageCount()
|
||||
{
|
||||
if (EntryCount > EntriesPerPage)
|
||||
{
|
||||
if (EntriesPerPage > 0)
|
||||
{
|
||||
PageCount = (int)Math.Ceiling(EntryCount / (double)EntriesPerPage);
|
||||
PageCount = Math.Max(1, PageCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
PageCount = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PageCount = 1;
|
||||
}
|
||||
|
||||
Page = Math.Max(0, Math.Min(PageCount - 1, Page));
|
||||
}
|
||||
|
||||
protected virtual void FirstPage(GumpButton entry)
|
||||
{
|
||||
FirstPage(true);
|
||||
}
|
||||
|
||||
public virtual void FirstPage()
|
||||
{
|
||||
FirstPage(true);
|
||||
}
|
||||
|
||||
public virtual void FirstPage(bool recompile)
|
||||
{
|
||||
PreviousPage(recompile, Page);
|
||||
}
|
||||
|
||||
protected virtual void LastPage(GumpButton entry)
|
||||
{
|
||||
LastPage(true);
|
||||
}
|
||||
|
||||
public virtual void LastPage()
|
||||
{
|
||||
LastPage(true);
|
||||
}
|
||||
|
||||
public virtual void LastPage(bool recompile)
|
||||
{
|
||||
NextPage(recompile, PageCount - Page);
|
||||
}
|
||||
|
||||
protected virtual void PreviousPage(GumpButton entry)
|
||||
{
|
||||
PreviousPage(entry, 1);
|
||||
}
|
||||
|
||||
protected virtual void PreviousPage(GumpButton entry, int delta)
|
||||
{
|
||||
PreviousPage(true, delta);
|
||||
}
|
||||
|
||||
public virtual void PreviousPage()
|
||||
{
|
||||
PreviousPage(true, 1);
|
||||
}
|
||||
|
||||
public virtual void PreviousPage(bool recompile)
|
||||
{
|
||||
PreviousPage(recompile, 1);
|
||||
}
|
||||
|
||||
public virtual void PreviousPage(int delta)
|
||||
{
|
||||
PreviousPage(true, delta);
|
||||
}
|
||||
|
||||
public virtual void PreviousPage(bool recompile, int delta)
|
||||
{
|
||||
Page -= delta;
|
||||
Refresh(recompile);
|
||||
}
|
||||
|
||||
protected virtual void NextPage(GumpButton entry)
|
||||
{
|
||||
NextPage(entry, 1);
|
||||
}
|
||||
|
||||
protected virtual void NextPage(GumpButton entry, int delta)
|
||||
{
|
||||
NextPage(true, delta);
|
||||
}
|
||||
|
||||
public virtual void NextPage()
|
||||
{
|
||||
NextPage(true, 1);
|
||||
}
|
||||
|
||||
public virtual void NextPage(bool recompile)
|
||||
{
|
||||
NextPage(recompile, 1);
|
||||
}
|
||||
|
||||
public virtual void NextPage(int delta)
|
||||
{
|
||||
NextPage(true, delta);
|
||||
}
|
||||
|
||||
public virtual void NextPage(bool recompile, int delta)
|
||||
{
|
||||
Page += delta;
|
||||
Refresh(recompile);
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
base.OnDispose();
|
||||
|
||||
EntriesPerPage = 0;
|
||||
PageCount = 0;
|
||||
Page = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#region References
|
||||
using System;
|
||||
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps.UI
|
||||
{
|
||||
public class ConfirmDialogGump : DialogGump
|
||||
{
|
||||
public virtual bool Confirmed { get; set; }
|
||||
|
||||
public ConfirmDialogGump(
|
||||
Mobile user,
|
||||
Gump parent = null,
|
||||
int? x = null,
|
||||
int? y = null,
|
||||
string title = null,
|
||||
string html = null,
|
||||
int icon = 7022,
|
||||
Action<GumpButton> onAccept = null,
|
||||
Action<GumpButton> onCancel = null)
|
||||
: base(user, parent, x, y, title, html, icon, onAccept, onCancel)
|
||||
{ }
|
||||
|
||||
protected override void OnAccept(GumpButton button)
|
||||
{
|
||||
Confirmed = true;
|
||||
base.OnAccept(button);
|
||||
}
|
||||
|
||||
protected override void OnCancel(GumpButton button)
|
||||
{
|
||||
Confirmed = false;
|
||||
base.OnCancel(button);
|
||||
}
|
||||
}
|
||||
}
|
||||
267
Scripts/SubSystem/VitaNex/Core/SuperGumps/UI/Dialogs/Dialog.cs
Normal file
267
Scripts/SubSystem/VitaNex/Core/SuperGumps/UI/Dialogs/Dialog.cs
Normal file
@@ -0,0 +1,267 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#if ServUO58
|
||||
#define ServUOX
|
||||
#endif
|
||||
|
||||
#region References
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps.UI
|
||||
{
|
||||
public class DialogGump : SuperGump
|
||||
{
|
||||
public static int Defaultwidth = 400;
|
||||
public static int DefaultHeight = 300;
|
||||
|
||||
public static int DefaultIcon = 7000;
|
||||
public static string DefaultTitle = "Dialog";
|
||||
|
||||
protected IconDefinition _Icon;
|
||||
|
||||
public virtual Action<GumpButton> AcceptHandler { get; set; }
|
||||
public virtual Action<GumpButton> CancelHandler { get; set; }
|
||||
|
||||
public virtual string Title { get; set; }
|
||||
|
||||
public virtual bool HtmlBackground { get; set; }
|
||||
public virtual bool HtmlScrollbar { get; set; }
|
||||
|
||||
public virtual Color HtmlColor { get; set; }
|
||||
public virtual string Html { get; set; }
|
||||
|
||||
public virtual int Icon { get => _Icon.AssetID; set => _Icon.AssetID = Math.Max(0, value); }
|
||||
public virtual int IconHue { get => _Icon.Hue; set => _Icon.Hue = Math.Max(0, value); }
|
||||
|
||||
public virtual bool IconItem
|
||||
{
|
||||
get => _Icon.IsItemArt;
|
||||
set => _Icon.AssetType = value ? IconType.ItemArt : IconType.GumpArt;
|
||||
}
|
||||
|
||||
public virtual int IconTooltip { get; set; }
|
||||
|
||||
public virtual int Width { get; set; }
|
||||
public virtual int Height { get; set; }
|
||||
|
||||
public DialogGump(
|
||||
Mobile user,
|
||||
Gump parent = null,
|
||||
int? x = null,
|
||||
int? y = null,
|
||||
string title = null,
|
||||
string html = null,
|
||||
int icon = -1,
|
||||
Action<GumpButton> onAccept = null,
|
||||
Action<GumpButton> onCancel = null)
|
||||
: base(user, parent, x, y)
|
||||
{
|
||||
_Icon = IconDefinition.FromGump(icon >= 0 ? icon : DefaultIcon);
|
||||
_Icon.ComputeOffset = false;
|
||||
|
||||
Modal = true;
|
||||
CanDispose = false;
|
||||
|
||||
HtmlBackground = false;
|
||||
HtmlScrollbar = true;
|
||||
|
||||
HtmlColor = DefaultHtmlColor;
|
||||
|
||||
Width = Defaultwidth;
|
||||
Height = DefaultHeight;
|
||||
|
||||
Title = title ?? DefaultTitle;
|
||||
Html = html;
|
||||
|
||||
AcceptHandler = onAccept;
|
||||
CancelHandler = onCancel;
|
||||
}
|
||||
|
||||
protected virtual void OnAccept(GumpButton button)
|
||||
{
|
||||
if (AcceptHandler != null)
|
||||
{
|
||||
AcceptHandler(button);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnCancel(GumpButton button)
|
||||
{
|
||||
if (CancelHandler != null)
|
||||
{
|
||||
CancelHandler(button);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Compile()
|
||||
{
|
||||
Width = Math.Max(300, Math.Min(1024, Width));
|
||||
Height = Math.Max(200, Math.Min(768, Height));
|
||||
|
||||
base.Compile();
|
||||
}
|
||||
|
||||
protected override void CompileLayout(SuperGumpLayout layout)
|
||||
{
|
||||
base.CompileLayout(layout);
|
||||
|
||||
var sup = SupportsUltimaStore;
|
||||
var ec = IsEnhancedClient;
|
||||
var bgID = ec ? 83 : sup ? 40000 : 9270;
|
||||
|
||||
layout.Add(
|
||||
"background/body/base",
|
||||
() =>
|
||||
{
|
||||
AddBackground(0, 0, Width, Height, bgID);
|
||||
|
||||
if (!ec)
|
||||
{
|
||||
AddImageTiled(10, 10, Width - 20, Height - 20, 2624);
|
||||
//AddAlphaRegion(10, 10, Width - 20, Height - 20);
|
||||
}
|
||||
});
|
||||
|
||||
layout.Add(
|
||||
"background/header/base",
|
||||
() =>
|
||||
{
|
||||
AddBackground(0, 0, Width, 50, bgID);
|
||||
|
||||
if (!ec)
|
||||
{
|
||||
AddImageTiled(10, 10, Width - 20, 30, 2624);
|
||||
//AddAlphaRegion(10, 10, Width - 20, 30);
|
||||
}
|
||||
});
|
||||
|
||||
layout.Add(
|
||||
"label/header/title",
|
||||
() =>
|
||||
{
|
||||
var title = Title.WrapUOHtmlBig().WrapUOHtmlColor(HtmlColor, false);
|
||||
|
||||
AddHtml(15, 15, Width - 30, 40, title, false, false);
|
||||
});
|
||||
|
||||
layout.Add(
|
||||
"image/body/icon",
|
||||
() =>
|
||||
{
|
||||
if (_Icon == null || _Icon.IsEmpty)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var iw = Math.Max(32, _Icon.Size.Width);
|
||||
var ih = Math.Max(32, _Icon.Size.Height);
|
||||
|
||||
if (sup)
|
||||
{
|
||||
if (_Icon.IsSpellIcon)
|
||||
{
|
||||
AddBackground(10, 50, iw + 30, ih + 30, 30536);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddBackground(15, 55, iw + 20, ih + 20, 40000);
|
||||
AddImageTiled(25, 65, iw, ih, 2624);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AddBackground(15, 55, iw + 20, ih + 20, 9270);
|
||||
AddImageTiled(25, 65, iw, ih, 2624);
|
||||
}
|
||||
|
||||
_Icon.AddToGump(this, 25, 65);
|
||||
|
||||
if (IconTooltip > 0)
|
||||
{
|
||||
if (IconTooltip >= 0x40000000)
|
||||
{
|
||||
#if ServUOX
|
||||
AddProperties(new Serial(IconTooltip));
|
||||
#else
|
||||
AddProperties(IconTooltip);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
AddTooltip(IconTooltip);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
layout.Add(
|
||||
"html/body/info",
|
||||
() =>
|
||||
{
|
||||
var x = 15;
|
||||
var y = 55;
|
||||
var w = Width - 30;
|
||||
var h = Height - 110;
|
||||
|
||||
if (_Icon != null && !_Icon.IsEmpty)
|
||||
{
|
||||
var iw = Math.Max(32, _Icon.Size.Width);
|
||||
|
||||
x += iw + 25;
|
||||
w -= iw + 25;
|
||||
}
|
||||
|
||||
if (SupportsUltimaStore)
|
||||
{
|
||||
AddBackground(x, y, w, h, 39925);
|
||||
|
||||
x += 20;
|
||||
y += 22;
|
||||
w -= 25;
|
||||
h -= 38;
|
||||
}
|
||||
|
||||
AddHtml(x, y, w, h, Html.WrapUOHtmlColor(HtmlColor, false), HtmlBackground, HtmlScrollbar);
|
||||
});
|
||||
|
||||
layout.Add(
|
||||
"button/body/cancel",
|
||||
() =>
|
||||
{
|
||||
AddButton(Width - 90, Height - 45, 4018, 4019, OnCancel);
|
||||
AddTooltip(1006045);
|
||||
});
|
||||
|
||||
layout.Add(
|
||||
"button/body/accept",
|
||||
() =>
|
||||
{
|
||||
AddButton(Width - 50, Height - 45, 4015, 4016, OnAccept);
|
||||
AddTooltip(1006044);
|
||||
});
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
base.OnDispose();
|
||||
|
||||
_Icon = null;
|
||||
|
||||
AcceptHandler = null;
|
||||
CancelHandler = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#region References
|
||||
using System;
|
||||
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps.UI
|
||||
{
|
||||
public class ErrorDialogGump : DialogGump
|
||||
{
|
||||
public virtual Exception Error { get; set; }
|
||||
|
||||
public ErrorDialogGump(
|
||||
Mobile user,
|
||||
Gump parent = null,
|
||||
int? x = null,
|
||||
int? y = null,
|
||||
string title = null,
|
||||
Exception error = null,
|
||||
int icon = 7019,
|
||||
Action<GumpButton> onAccept = null,
|
||||
Action<GumpButton> onCancel = null)
|
||||
: base(user, parent, x, y, title, String.Empty, icon, onAccept, onCancel)
|
||||
{
|
||||
Error = error;
|
||||
}
|
||||
|
||||
protected override void Compile()
|
||||
{
|
||||
Html = Error != null ? Error.ToString() : String.Empty;
|
||||
|
||||
base.Compile();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#region References
|
||||
using System;
|
||||
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps.UI
|
||||
{
|
||||
public class InputDateDialogGump : InputDialogGump
|
||||
{
|
||||
protected int Day;
|
||||
protected int Month;
|
||||
protected int Year;
|
||||
|
||||
public virtual Action<GumpButton, DateTime?> CallbackDate { get; set; }
|
||||
|
||||
public virtual DateTime MinDate { get; set; }
|
||||
public virtual DateTime MaxDate { get; set; }
|
||||
public virtual DateTime? InputDate { get; set; }
|
||||
|
||||
public InputDateDialogGump(
|
||||
Mobile user,
|
||||
Gump parent = null,
|
||||
int? x = null,
|
||||
int? y = null,
|
||||
string title = "Date Input",
|
||||
string html = "Enter a date below.",
|
||||
DateTime? input = null,
|
||||
DateTime? minDate = null,
|
||||
DateTime? maxDate = null,
|
||||
int icon = 7020,
|
||||
Action<GumpButton> onAccept = null,
|
||||
Action<GumpButton> onCancel = null,
|
||||
Action<GumpButton, DateTime?> callback = null)
|
||||
: base(user, parent, x, y, title, html, String.Empty, 10, icon, onAccept, onCancel)
|
||||
{
|
||||
if (input != null)
|
||||
{
|
||||
InputDate = input;
|
||||
InputText = InputDate.Value.ToSimpleString("m-d-y");
|
||||
}
|
||||
|
||||
MinDate = minDate ?? DateTime.MinValue;
|
||||
MaxDate = maxDate ?? DateTime.MaxValue;
|
||||
|
||||
Limit = 10;
|
||||
|
||||
CallbackDate = callback;
|
||||
|
||||
Callback = (b, text) =>
|
||||
{
|
||||
if (CallbackDate != null)
|
||||
{
|
||||
CallbackDate(b, InputDate);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void Compile()
|
||||
{
|
||||
base.Compile();
|
||||
|
||||
Limit = 10;
|
||||
InputText = InputDate.HasValue ? InputDate.Value.ToSimpleString("m-d-y") : String.Empty;
|
||||
}
|
||||
|
||||
protected override void CompileLayout(SuperGumpLayout layout)
|
||||
{
|
||||
base.CompileLayout(layout);
|
||||
|
||||
layout.Remove("background/body/input");
|
||||
layout.Remove("textentry/body/input");
|
||||
|
||||
layout.Add(
|
||||
"background/body/input/month",
|
||||
() =>
|
||||
{
|
||||
AddHtml(20, Height - 45, 20, 20, "MM".WrapUOHtmlColor(HtmlColor), false, false);
|
||||
AddBackground(50, 250, 40, 30, 9350);
|
||||
AddTextEntryLimited(
|
||||
55,
|
||||
Height - 45,
|
||||
30,
|
||||
20,
|
||||
TextHue,
|
||||
0,
|
||||
InputDate.HasValue ? InputDate.Value.Month.ToString("D2") : String.Empty,
|
||||
2,
|
||||
ParseInput);
|
||||
});
|
||||
|
||||
layout.Add(
|
||||
"background/body/input/day",
|
||||
() =>
|
||||
{
|
||||
AddHtml(100, Height - 45, 20, 20, "DD".WrapUOHtmlColor(HtmlColor), false, false);
|
||||
AddBackground(130, 250, 40, 30, 9350);
|
||||
AddTextEntryLimited(
|
||||
135,
|
||||
Height - 45,
|
||||
30,
|
||||
20,
|
||||
TextHue,
|
||||
1,
|
||||
InputDate.HasValue ? InputDate.Value.Day.ToString("D2") : String.Empty,
|
||||
2,
|
||||
ParseInput);
|
||||
});
|
||||
|
||||
layout.Add(
|
||||
"background/body/input/year",
|
||||
() =>
|
||||
{
|
||||
AddHtml(180, Height - 45, 40, 20, "YYYY".WrapUOHtmlColor(HtmlColor), false, false);
|
||||
AddBackground(220, 250, 70, 30, 9350);
|
||||
AddTextEntryLimited(
|
||||
225,
|
||||
Height - 45,
|
||||
60,
|
||||
20,
|
||||
TextHue,
|
||||
2,
|
||||
InputDate.HasValue ? InputDate.Value.Year.ToString("D4") : String.Empty,
|
||||
4,
|
||||
ParseInput);
|
||||
});
|
||||
}
|
||||
|
||||
protected override void ParseInput(GumpTextEntryLimited entry, string text)
|
||||
{
|
||||
switch (entry.EntryID)
|
||||
{
|
||||
case 0:
|
||||
Month = Int32.TryParse(text, out Month) ? Math.Max(1, Math.Min(12, Month)) : 0;
|
||||
break;
|
||||
case 1:
|
||||
Day = Int32.TryParse(text, out Day) ? Math.Max(1, Math.Min(31, Day)) : 0;
|
||||
break;
|
||||
case 2:
|
||||
Year = Int32.TryParse(text, out Year) ? Math.Max(1, Math.Min(9999, Year)) : 0;
|
||||
break;
|
||||
}
|
||||
|
||||
base.ParseInput(entry, text);
|
||||
}
|
||||
|
||||
protected override void ParseInput(string text)
|
||||
{
|
||||
if (Year > 0 && Month > 0 && Day > 0)
|
||||
{
|
||||
Day = Math.Min(DateTime.DaysInMonth(Year, Month), Day);
|
||||
InputDate = new DateTime(Year, Month, Day);
|
||||
}
|
||||
else
|
||||
{
|
||||
InputDate = null;
|
||||
}
|
||||
|
||||
if (InputDate.HasValue)
|
||||
{
|
||||
if (InputDate < MinDate)
|
||||
{
|
||||
InputDate = MinDate;
|
||||
}
|
||||
else if (InputDate > MaxDate)
|
||||
{
|
||||
InputDate = MaxDate;
|
||||
}
|
||||
}
|
||||
|
||||
base.ParseInput(InputDate.HasValue ? InputDate.Value.ToSimpleString("m-d-y") : String.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#region References
|
||||
using System;
|
||||
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps.UI
|
||||
{
|
||||
public class InputDialogGump : DialogGump
|
||||
{
|
||||
public virtual Action<GumpButton, string> Callback { get; set; }
|
||||
|
||||
public virtual string InputText { get; set; }
|
||||
public virtual int Limit { get; set; }
|
||||
|
||||
public bool Limited => Limit > 0;
|
||||
|
||||
public InputDialogGump(
|
||||
Mobile user,
|
||||
Gump parent = null,
|
||||
int? x = null,
|
||||
int? y = null,
|
||||
string title = null,
|
||||
string html = null,
|
||||
string input = null,
|
||||
int limit = 0,
|
||||
int icon = 7020,
|
||||
Action<GumpButton> onAccept = null,
|
||||
Action<GumpButton> onCancel = null,
|
||||
Action<GumpButton, string> callback = null)
|
||||
: base(user, parent, x, y, title, html, icon, onAccept, onCancel)
|
||||
{
|
||||
InputText = input ?? String.Empty;
|
||||
Limit = limit;
|
||||
Callback = callback;
|
||||
}
|
||||
|
||||
protected override void CompileLayout(SuperGumpLayout layout)
|
||||
{
|
||||
base.CompileLayout(layout);
|
||||
|
||||
layout.Add("background/body/input", () => AddBackground(20, Height - 50, Width - 120, 30, 9350));
|
||||
|
||||
layout.Add(
|
||||
"textentry/body/input",
|
||||
() =>
|
||||
{
|
||||
if (Limited)
|
||||
{
|
||||
AddTextEntryLimited(25, Height - 45, Width - 130, 20, TextHue, InputText, Limit, ParseInput);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddTextEntry(25, Height - 45, Width - 130, 20, TextHue, InputText, ParseInput);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected virtual void ParseInput(GumpTextEntry entry, string text)
|
||||
{
|
||||
ParseInput(text);
|
||||
}
|
||||
|
||||
protected virtual void ParseInput(GumpTextEntryLimited entry, string text)
|
||||
{
|
||||
ParseInput(text);
|
||||
}
|
||||
|
||||
protected virtual void ParseInput(string text)
|
||||
{
|
||||
InputText = text;
|
||||
}
|
||||
|
||||
protected override void OnAccept(GumpButton button)
|
||||
{
|
||||
if (Callback != null)
|
||||
{
|
||||
Callback(button, InputText);
|
||||
}
|
||||
|
||||
base.OnAccept(button);
|
||||
}
|
||||
|
||||
protected override void OnCancel(GumpButton button)
|
||||
{
|
||||
InputText = String.Empty;
|
||||
|
||||
base.OnCancel(button);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#region References
|
||||
using System;
|
||||
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps.UI
|
||||
{
|
||||
public class NoticeDialogGump : DialogGump
|
||||
{
|
||||
public NoticeDialogGump(
|
||||
Mobile user,
|
||||
Gump parent = null,
|
||||
int? x = null,
|
||||
int? y = null,
|
||||
string title = null,
|
||||
string html = null,
|
||||
int icon = 7004,
|
||||
Action<GumpButton> onAccept = null,
|
||||
Action<GumpButton> onCancel = null)
|
||||
: base(user, parent, x, y, title, html, icon, onAccept, onCancel)
|
||||
{ }
|
||||
|
||||
protected override void CompileLayout(SuperGumpLayout layout)
|
||||
{
|
||||
base.CompileLayout(layout);
|
||||
|
||||
layout.Remove("button/body/cancel");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#region References
|
||||
using System;
|
||||
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps.UI
|
||||
{
|
||||
public class DigitalNumericDisplayGump : SuperGump
|
||||
{
|
||||
public int NumericWidth { get; set; }
|
||||
public int NumericHeight { get; set; }
|
||||
public int[] Numerics { get; set; }
|
||||
public int DisplayID { get; set; }
|
||||
public int NumericDisplayID { get; set; }
|
||||
|
||||
public DigitalNumericDisplayGump(
|
||||
Mobile user,
|
||||
Gump parent = null,
|
||||
int? x = null,
|
||||
int? y = null,
|
||||
int numericWidth = 30,
|
||||
int numericHeight = 60,
|
||||
int displayID = 10004,
|
||||
int numericDisplayID = 30073,
|
||||
params int[] numbers)
|
||||
: base(user, parent, x, y)
|
||||
{
|
||||
NumericWidth = numericWidth;
|
||||
NumericHeight = numericHeight;
|
||||
Numerics = numbers ?? new int[0];
|
||||
DisplayID = displayID;
|
||||
NumericDisplayID = numericDisplayID;
|
||||
|
||||
ForceRecompile = true;
|
||||
}
|
||||
|
||||
public static bool HasLines(ref int numeric, LCDLines lines)
|
||||
{
|
||||
return LCD.HasLines(Math.Max(0, Math.Min(9, numeric)), lines);
|
||||
}
|
||||
|
||||
protected override void Compile()
|
||||
{
|
||||
for (var i = 0; i < Numerics.Length; i++)
|
||||
{
|
||||
Numerics[i] = Math.Max(0, Math.Min(9, Numerics[i]));
|
||||
}
|
||||
|
||||
base.Compile();
|
||||
}
|
||||
|
||||
protected override void CompileLayout(SuperGumpLayout layout)
|
||||
{
|
||||
base.CompileLayout(layout);
|
||||
|
||||
int lineHeight = (NumericHeight / 16),
|
||||
lineWidth = (NumericWidth / 9),
|
||||
halfHeight = (NumericHeight / 2),
|
||||
halfWidth = (NumericWidth / 2),
|
||||
eachWidth = (NumericWidth + halfWidth),
|
||||
width = 20 + (eachWidth * Numerics.Length),
|
||||
height = 20 + NumericHeight;
|
||||
|
||||
layout.Add("background/body/base", () => AddBackground(0, 0, width, height, 9270));
|
||||
|
||||
CompileNumericEntries(layout, width, height, lineHeight, lineWidth, halfHeight, halfWidth, eachWidth);
|
||||
}
|
||||
|
||||
protected virtual void CompileNumericEntries(
|
||||
SuperGumpLayout layout,
|
||||
int width,
|
||||
int height,
|
||||
int lineHeight,
|
||||
int lineWidth,
|
||||
int halfHeight,
|
||||
int halfWidth,
|
||||
int eachWidth)
|
||||
{
|
||||
for (var idx = 0; idx < Numerics.Length; idx++)
|
||||
{
|
||||
CompileNumericEntry(
|
||||
layout,
|
||||
lineHeight,
|
||||
lineWidth,
|
||||
halfHeight,
|
||||
halfWidth,
|
||||
idx,
|
||||
Numerics[idx],
|
||||
10 + (eachWidth * idx),
|
||||
10);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void CompileNumericEntry(
|
||||
SuperGumpLayout layout,
|
||||
int lineHeight,
|
||||
int lineWidth,
|
||||
int halfHeight,
|
||||
int halfWidth,
|
||||
int index,
|
||||
int numeric,
|
||||
int xOffset,
|
||||
int yOffset)
|
||||
{
|
||||
layout.Add(
|
||||
"imagetiled/bg" + index,
|
||||
() => AddImageTiled(xOffset, 10, NumericWidth + halfWidth, NumericHeight, DisplayID));
|
||||
|
||||
if (HasLines(ref numeric, LCDLines.Top))
|
||||
{
|
||||
layout.Add(
|
||||
"imagetiled/lines/t" + index,
|
||||
() => AddImageTiled(xOffset, yOffset, NumericWidth, lineHeight, NumericDisplayID));
|
||||
}
|
||||
|
||||
if (HasLines(ref numeric, LCDLines.TopLeft))
|
||||
{
|
||||
layout.Add(
|
||||
"imagetiled/lines/tl" + index,
|
||||
() => AddImageTiled(xOffset, yOffset, lineWidth, halfHeight, NumericDisplayID));
|
||||
}
|
||||
|
||||
if (HasLines(ref numeric, LCDLines.TopRight))
|
||||
{
|
||||
layout.Add(
|
||||
"imagetiled/lines/tr" + index,
|
||||
() => AddImageTiled(xOffset + (NumericWidth - lineWidth), yOffset, lineWidth, halfHeight, NumericDisplayID));
|
||||
}
|
||||
|
||||
if (HasLines(ref numeric, LCDLines.Middle))
|
||||
{
|
||||
layout.Add(
|
||||
"imagetiled/lines/m" + index,
|
||||
() => AddImageTiled(
|
||||
xOffset,
|
||||
yOffset + (halfHeight - (lineHeight / 2)),
|
||||
NumericWidth,
|
||||
lineHeight,
|
||||
NumericDisplayID));
|
||||
}
|
||||
|
||||
if (HasLines(ref numeric, LCDLines.BottomLeft))
|
||||
{
|
||||
layout.Add(
|
||||
"imagetiled/lines/bl" + index,
|
||||
() => AddImageTiled(xOffset, yOffset + halfHeight, lineWidth, halfHeight, 30073));
|
||||
}
|
||||
|
||||
if (HasLines(ref numeric, LCDLines.BottomRight))
|
||||
{
|
||||
layout.Add(
|
||||
"imagetiled/lines/br" + index,
|
||||
() => AddImageTiled(
|
||||
xOffset + (NumericWidth - lineWidth),
|
||||
yOffset + halfHeight,
|
||||
lineWidth,
|
||||
halfHeight,
|
||||
NumericDisplayID));
|
||||
}
|
||||
|
||||
if (HasLines(ref numeric, LCDLines.Bottom))
|
||||
{
|
||||
layout.Add(
|
||||
"imagetiled/lines/b" + index,
|
||||
() => AddImageTiled(xOffset, yOffset + (NumericHeight - lineHeight), NumericWidth, lineHeight, NumericDisplayID));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
168
Scripts/SubSystem/VitaNex/Core/SuperGumps/UI/Info/OPLGump.cs
Normal file
168
Scripts/SubSystem/VitaNex/Core/SuperGumps/UI/Info/OPLGump.cs
Normal file
@@ -0,0 +1,168 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#region References
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
|
||||
using VitaNex.Text;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps.UI
|
||||
{
|
||||
public class OPLGump : SuperGump
|
||||
{
|
||||
private readonly IconDefinition _DefIcon = IconDefinition.FromItem(1, 0);
|
||||
private readonly string[] _DefProperties = { "Unknown Object" };
|
||||
|
||||
public IEntity Entity { get; set; }
|
||||
|
||||
public IconDefinition Icon { get; set; }
|
||||
public string[] Properties { get; set; }
|
||||
|
||||
public OPLGump(Mobile user, Gump parent = null)
|
||||
: base(user, parent)
|
||||
{
|
||||
CanClose = true;
|
||||
CanDispose = true;
|
||||
CanMove = true;
|
||||
CanResize = false;
|
||||
}
|
||||
|
||||
public OPLGump(Mobile user, IEntity entity, Gump parent = null)
|
||||
: this(user, parent)
|
||||
{
|
||||
Entity = entity;
|
||||
}
|
||||
|
||||
public OPLGump(Mobile user, int itemID, string name, Gump parent = null)
|
||||
: this(user, itemID, 0, name, parent)
|
||||
{ }
|
||||
|
||||
public OPLGump(Mobile user, int itemID, int hue, string name, Gump parent = null)
|
||||
: this(user, itemID, hue, new[] { name }, parent)
|
||||
{ }
|
||||
|
||||
public OPLGump(Mobile user, int itemID, string[] props, Gump parent = null)
|
||||
: this(user, itemID, 0, props, parent)
|
||||
{ }
|
||||
|
||||
public OPLGump(Mobile user, int itemID, int hue, string[] props, Gump parent = null)
|
||||
: this(user, parent)
|
||||
{
|
||||
Icon = IconDefinition.FromItem(itemID, hue);
|
||||
|
||||
Properties = props;
|
||||
}
|
||||
|
||||
protected override void Compile()
|
||||
{
|
||||
if (Entity != null)
|
||||
{
|
||||
var id = 0;
|
||||
|
||||
if (Entity is Mobile)
|
||||
{
|
||||
id = ShrinkTable.Lookup((Mobile)Entity);
|
||||
}
|
||||
else if (Entity is Item)
|
||||
{
|
||||
id = ((Item)Entity).ItemID;
|
||||
}
|
||||
|
||||
|
||||
if (Entity.GetPropertyValue("Hue", out
|
||||
int hue))
|
||||
{
|
||||
Icon = IconDefinition.FromItem(id, hue);
|
||||
}
|
||||
else
|
||||
{
|
||||
Icon = IconDefinition.FromItem(id);
|
||||
}
|
||||
|
||||
Properties = Entity.GetOPLStrings(User).ToArray();
|
||||
}
|
||||
|
||||
if (Icon == null || Icon.IsEmpty)
|
||||
{
|
||||
Icon = _DefIcon;
|
||||
}
|
||||
|
||||
if (Properties.IsNullOrEmpty())
|
||||
{
|
||||
Properties = _DefProperties;
|
||||
}
|
||||
|
||||
base.Compile();
|
||||
}
|
||||
|
||||
protected override void CompileLayout(SuperGumpLayout layout)
|
||||
{
|
||||
base.CompileLayout(layout);
|
||||
|
||||
var sup = SupportsUltimaStore;
|
||||
var ec = IsEnhancedClient;
|
||||
var pad = sup ? 15 : 10;
|
||||
var pad2 = pad * 2;
|
||||
var bgID = ec ? 83 : sup ? 40000 : 5054;
|
||||
|
||||
var size = Icon.Size;
|
||||
|
||||
var innerHeight = UOFont.GetUnicodeHeight(1, Properties);
|
||||
|
||||
var outerHeight = innerHeight + pad2;
|
||||
|
||||
if (outerHeight < size.Height + pad2)
|
||||
{
|
||||
outerHeight = size.Height + pad2;
|
||||
innerHeight = outerHeight - pad2;
|
||||
}
|
||||
|
||||
layout.Add(
|
||||
"bg",
|
||||
() =>
|
||||
{
|
||||
AddBackground(0, 0, size.Width + pad2, size.Height + pad2, bgID);
|
||||
AddBackground(size.Width + pad2, 0, 400, outerHeight, bgID);
|
||||
|
||||
if (!ec)
|
||||
{
|
||||
AddImageTiled(pad, pad, size.Width, size.Height, 2624);
|
||||
AddAlphaRegion(pad, pad, size.Width, size.Height);
|
||||
|
||||
AddImageTiled(size.Width + pad2 + pad, pad, 400 - pad2, innerHeight, 2624);
|
||||
AddAlphaRegion(size.Width + pad2 + pad, pad, 400 - pad2, innerHeight);
|
||||
}
|
||||
});
|
||||
|
||||
layout.Add(
|
||||
"info",
|
||||
() =>
|
||||
{
|
||||
Icon.AddToGump(this, pad, pad);
|
||||
|
||||
var lines = Properties.Select((s, i) => i == 0 ? s.ToUpperWords().WrapUOHtmlColor(Color.Yellow) : s);
|
||||
var value = String.Join("\n", lines);
|
||||
|
||||
value = value.ToUpperWords();
|
||||
value = value.WrapUOHtmlCenter();
|
||||
value = value.WrapUOHtmlColor(Color.White, false);
|
||||
|
||||
AddHtml(size.Width + pad2 + pad, pad, 400 - pad2, innerHeight, value, false, false);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
353
Scripts/SubSystem/VitaNex/Core/SuperGumps/UI/Info/ProgressBar.cs
Normal file
353
Scripts/SubSystem/VitaNex/Core/SuperGumps/UI/Info/ProgressBar.cs
Normal file
@@ -0,0 +1,353 @@
|
||||
#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;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps.UI
|
||||
{
|
||||
public enum ProgressBarFlow
|
||||
{
|
||||
Up = Direction.Up,
|
||||
UpRight = Direction.North,
|
||||
Right = Direction.Right,
|
||||
DownRight = Direction.East,
|
||||
Down = Direction.Down,
|
||||
DownLeft = Direction.South,
|
||||
Left = Direction.Left,
|
||||
UpLeft = Direction.West
|
||||
}
|
||||
|
||||
public class ProgressBarGump : SuperGump
|
||||
{
|
||||
public static int DefaultWidth = 210;
|
||||
public static int DefaultHeight = 25;
|
||||
|
||||
public static int DefaultPadding = 5;
|
||||
|
||||
public static int DefaultBackgroundID = 9400;
|
||||
public static int DefaultForegroundID = 1464;
|
||||
|
||||
public static string DefaultText = "Progress";
|
||||
|
||||
public static ProgressBarFlow DefaultFlow = ProgressBarFlow.Right;
|
||||
|
||||
private double? _InitValue, _InitMaxValue;
|
||||
|
||||
private double _Value;
|
||||
private double _MaxValue;
|
||||
|
||||
public int Width { get; set; }
|
||||
public int Height { get; set; }
|
||||
public int Padding { get; set; }
|
||||
|
||||
public int BackgroundID { get; set; }
|
||||
public int ForegroundID { get; set; }
|
||||
|
||||
public Color TextColor { get; set; }
|
||||
public string Text { get; set; }
|
||||
|
||||
public bool DisplayPercent { get; set; }
|
||||
public ProgressBarFlow Flow { get; set; }
|
||||
|
||||
public Action<ProgressBarGump, double> ValueChanged { get; set; }
|
||||
|
||||
public double MaxValue
|
||||
{
|
||||
get => _MaxValue;
|
||||
set
|
||||
{
|
||||
_MaxValue = value;
|
||||
|
||||
if (_InitMaxValue == null)
|
||||
{
|
||||
_InitMaxValue = _MaxValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public double Value
|
||||
{
|
||||
get => _Value;
|
||||
set
|
||||
{
|
||||
if (_Value == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var oldValue = _Value;
|
||||
|
||||
InternalValue = Math.Min(_MaxValue, value);
|
||||
|
||||
OnValueChanged(oldValue);
|
||||
}
|
||||
}
|
||||
|
||||
public double InternalValue
|
||||
{
|
||||
get => Value;
|
||||
set
|
||||
{
|
||||
if (_Value == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_Value = Math.Min(_MaxValue, value);
|
||||
|
||||
if (_InitValue == null)
|
||||
{
|
||||
_InitValue = _Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public double PercentComplete
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_Value == _MaxValue)
|
||||
{
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
if (_MaxValue != 0)
|
||||
{
|
||||
return _Value / _MaxValue;
|
||||
}
|
||||
|
||||
return 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Completed => PercentComplete >= 1.0;
|
||||
|
||||
public ProgressBarGump(
|
||||
Mobile user,
|
||||
string text,
|
||||
double max,
|
||||
double value = 0,
|
||||
bool displayPercent = true,
|
||||
ProgressBarFlow? flow = null,
|
||||
Action<ProgressBarGump, double> valueChanged = null)
|
||||
: this(user, null, null, null, null, null, text, max, value, displayPercent, flow, valueChanged)
|
||||
{ }
|
||||
|
||||
public ProgressBarGump(
|
||||
Mobile user,
|
||||
Gump parent = null,
|
||||
int? x = null,
|
||||
int? y = null,
|
||||
int? w = null,
|
||||
int? h = null,
|
||||
string text = null,
|
||||
double max = 100,
|
||||
double value = 0,
|
||||
bool displayPercent = true,
|
||||
ProgressBarFlow? flow = null,
|
||||
Action<ProgressBarGump, double> valueChanged = null)
|
||||
: base(user, parent, x, y)
|
||||
{
|
||||
Width = w ?? DefaultWidth;
|
||||
Height = h ?? DefaultHeight;
|
||||
|
||||
BackgroundID = DefaultBackgroundID;
|
||||
ForegroundID = DefaultForegroundID;
|
||||
|
||||
Padding = DefaultPadding;
|
||||
|
||||
TextColor = DefaultHtmlColor;
|
||||
Text = text ?? DefaultText;
|
||||
|
||||
DisplayPercent = displayPercent;
|
||||
Flow = flow ?? DefaultFlow;
|
||||
ValueChanged = valueChanged;
|
||||
|
||||
_MaxValue = max;
|
||||
_Value = value;
|
||||
|
||||
ForceRecompile = true;
|
||||
}
|
||||
|
||||
public virtual void Reset()
|
||||
{
|
||||
_Value = _InitValue ?? 0;
|
||||
_MaxValue = _InitMaxValue ?? 100;
|
||||
|
||||
_InitValue = _InitMaxValue = null;
|
||||
}
|
||||
|
||||
public virtual string FormatText(bool html = false)
|
||||
{
|
||||
var text = String.Format("{0} {1}", Text, DisplayPercent ? PercentComplete.ToString("0.##%") : String.Empty);
|
||||
|
||||
if (html && !String.IsNullOrWhiteSpace(text))
|
||||
{
|
||||
text = text.WrapUOHtmlColor(TextColor, false).WrapUOHtmlTag("center");
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
protected override void Compile()
|
||||
{
|
||||
Width = Math.Max(10 + Padding, Math.Min(1024, Width));
|
||||
Height = Math.Max(10 + Padding, Math.Min(768, Height));
|
||||
|
||||
if (Padding < 0)
|
||||
{
|
||||
Padding = DefaultPadding;
|
||||
}
|
||||
|
||||
base.Compile();
|
||||
}
|
||||
|
||||
protected virtual void OnValueChanged(double oldValue)
|
||||
{
|
||||
if (ValueChanged != null)
|
||||
{
|
||||
ValueChanged(this, oldValue);
|
||||
}
|
||||
|
||||
Refresh(true);
|
||||
}
|
||||
|
||||
protected bool FlowOffset(ref int x, ref int y, ref int w, ref int h)
|
||||
{
|
||||
double xo = x, yo = y, wo = w, ho = h;
|
||||
|
||||
switch (Flow)
|
||||
{
|
||||
case ProgressBarFlow.Up:
|
||||
{
|
||||
ho *= PercentComplete;
|
||||
yo = (y + h) - ho;
|
||||
}
|
||||
break;
|
||||
case ProgressBarFlow.UpRight:
|
||||
{
|
||||
wo *= PercentComplete;
|
||||
ho *= PercentComplete;
|
||||
yo = (y + h) - ho;
|
||||
}
|
||||
break;
|
||||
case ProgressBarFlow.Right:
|
||||
{
|
||||
wo *= PercentComplete;
|
||||
}
|
||||
break;
|
||||
case ProgressBarFlow.DownRight:
|
||||
{
|
||||
wo *= PercentComplete;
|
||||
ho *= PercentComplete;
|
||||
}
|
||||
break;
|
||||
case ProgressBarFlow.Down:
|
||||
{
|
||||
ho *= PercentComplete;
|
||||
}
|
||||
break;
|
||||
case ProgressBarFlow.DownLeft:
|
||||
{
|
||||
wo *= PercentComplete;
|
||||
ho *= PercentComplete;
|
||||
xo = (x + w) - wo;
|
||||
}
|
||||
break;
|
||||
case ProgressBarFlow.Left:
|
||||
{
|
||||
wo *= PercentComplete;
|
||||
xo = (x + w) - wo;
|
||||
}
|
||||
break;
|
||||
case ProgressBarFlow.UpLeft:
|
||||
{
|
||||
wo *= PercentComplete;
|
||||
ho *= PercentComplete;
|
||||
xo = (x + w) - wo;
|
||||
yo = (y + h) - ho;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var contained = xo >= x && yo >= y && xo + wo <= x + w && yo + ho <= y + h;
|
||||
|
||||
x = (int)xo;
|
||||
y = (int)yo;
|
||||
w = (int)wo;
|
||||
h = (int)ho;
|
||||
|
||||
return contained;
|
||||
}
|
||||
|
||||
protected override void CompileLayout(SuperGumpLayout layout)
|
||||
{
|
||||
base.CompileLayout(layout);
|
||||
|
||||
var xyPadding = Padding;
|
||||
var whPadding = xyPadding * 2;
|
||||
|
||||
layout.Add(
|
||||
"background/body/base",
|
||||
() =>
|
||||
{
|
||||
AddBackground(0, 0, Width, Height, BackgroundID);
|
||||
|
||||
if (Width > whPadding && Height > whPadding)
|
||||
{
|
||||
AddAlphaRegion(xyPadding, xyPadding, Width - whPadding, Height - whPadding);
|
||||
}
|
||||
|
||||
//AddTooltip(Completed ? 1049071 : 1049070);
|
||||
});
|
||||
|
||||
layout.Add(
|
||||
"imagetiled/body/visual",
|
||||
() =>
|
||||
{
|
||||
if (Width <= whPadding || Height <= whPadding)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int x = xyPadding, y = xyPadding, w = Width - whPadding, h = Height - whPadding;
|
||||
|
||||
if (FlowOffset(ref x, ref y, ref w, ref h))
|
||||
{
|
||||
AddImageTiled(x, y, w, h, ForegroundID);
|
||||
}
|
||||
});
|
||||
|
||||
layout.Add(
|
||||
"html/body/text",
|
||||
() =>
|
||||
{
|
||||
if (Width <= whPadding || Height <= whPadding)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var text = FormatText(true);
|
||||
|
||||
if (!String.IsNullOrWhiteSpace(text))
|
||||
{
|
||||
AddHtml(xyPadding, xyPadding, Width - whPadding, Math.Max(40, Height - whPadding), text, false, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
#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;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps.UI
|
||||
{
|
||||
public class EntryListGump : ListGump<ListGumpEntry>
|
||||
{
|
||||
public EntryListGump(
|
||||
Mobile user,
|
||||
Gump parent,
|
||||
int? x = null,
|
||||
int? y = null,
|
||||
IEnumerable<ListGumpEntry> list = null,
|
||||
string emptyText = null,
|
||||
string title = null,
|
||||
IEnumerable<ListGumpEntry> opts = null)
|
||||
: base(user, parent, x, y, list, emptyText, title, opts)
|
||||
{ }
|
||||
|
||||
protected override void SelectEntry(GumpButton button, ListGumpEntry entry)
|
||||
{
|
||||
base.SelectEntry(button, entry);
|
||||
|
||||
if (entry.Handler != null)
|
||||
{
|
||||
entry.Handler(button);
|
||||
}
|
||||
}
|
||||
|
||||
protected override int GetLabelHue(int index, int pageIndex, ListGumpEntry entry)
|
||||
{
|
||||
return entry != null ? entry.Hue : base.GetLabelHue(index, pageIndex, ListGumpEntry.Empty);
|
||||
}
|
||||
|
||||
protected override string GetLabelText(int index, int pageIndex, ListGumpEntry entry)
|
||||
{
|
||||
return entry != null && !String.IsNullOrWhiteSpace(entry.Label)
|
||||
? entry.Label
|
||||
: base.GetLabelText(index, pageIndex, ListGumpEntry.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,334 @@
|
||||
#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;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps.UI
|
||||
{
|
||||
public abstract class GenericListGump<T> : ListGump<T>
|
||||
{
|
||||
public bool ChangesPending { get; protected set; }
|
||||
|
||||
public virtual bool CanAdd { get; set; }
|
||||
public virtual bool CanRemove { get; set; }
|
||||
public virtual bool CanClear { get; set; }
|
||||
|
||||
public virtual Action<T> AddCallback { get; set; }
|
||||
public virtual Action<T> RemoveCallback { get; set; }
|
||||
public virtual Action<List<T>> ApplyCallback { get; set; }
|
||||
public virtual Action ClearCallback { get; set; }
|
||||
|
||||
public GenericListGump(
|
||||
Mobile user,
|
||||
Gump parent = null,
|
||||
int? x = null,
|
||||
int? y = null,
|
||||
IEnumerable<T> list = null,
|
||||
string emptyText = null,
|
||||
string title = null,
|
||||
IEnumerable<ListGumpEntry> opts = null,
|
||||
bool canAdd = true,
|
||||
bool canRemove = true,
|
||||
bool canClear = true,
|
||||
Action<T> addCallback = null,
|
||||
Action<T> removeCallback = null,
|
||||
Action<List<T>> applyCallback = null,
|
||||
Action clearCallback = null)
|
||||
: base(user, parent, x, y, list, emptyText, title, opts)
|
||||
{
|
||||
CanAdd = canAdd;
|
||||
CanRemove = canRemove;
|
||||
CanClear = canClear;
|
||||
|
||||
AddCallback = addCallback;
|
||||
RemoveCallback = removeCallback;
|
||||
ApplyCallback = applyCallback;
|
||||
ClearCallback = clearCallback;
|
||||
|
||||
ForceRecompile = true;
|
||||
}
|
||||
|
||||
public override string GetSearchKeyFor(T key)
|
||||
{
|
||||
return key != null ? key.ToString() : base.GetSearchKeyFor(default(T));
|
||||
}
|
||||
|
||||
protected override string GetLabelText(int index, int pageIndex, T entry)
|
||||
{
|
||||
return entry != null ? entry.ToString() : base.GetLabelText(index, pageIndex, default(T));
|
||||
}
|
||||
|
||||
protected override void Compile()
|
||||
{
|
||||
if (ChangesPending)
|
||||
{
|
||||
if (!Title.EndsWith(" *"))
|
||||
{
|
||||
Title += " *";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Title.EndsWith(" *"))
|
||||
{
|
||||
Title = Title.Substring(0, Title.Length - 2);
|
||||
}
|
||||
}
|
||||
|
||||
base.Compile();
|
||||
}
|
||||
|
||||
protected override void CompileMenuOptions(MenuGumpOptions list)
|
||||
{
|
||||
if (ChangesPending)
|
||||
{
|
||||
list.Insert(0, new ListGumpEntry("Apply Changes", HandleApplyChanges, HighlightHue));
|
||||
list.Insert(1, new ListGumpEntry("Clear Changes", HandleClearChanges, HighlightHue));
|
||||
}
|
||||
else
|
||||
{
|
||||
list.RemoveEntry("Apply Changes");
|
||||
list.RemoveEntry("Clear Changes");
|
||||
}
|
||||
|
||||
if (CanAdd)
|
||||
{
|
||||
list.Insert(2, new ListGumpEntry("Add", HandleAdd, HighlightHue));
|
||||
}
|
||||
else
|
||||
{
|
||||
list.RemoveEntry("Add");
|
||||
}
|
||||
|
||||
if (CanClear)
|
||||
{
|
||||
list.Insert(3, new ListGumpEntry("Clear", HandleClear, ErrorHue));
|
||||
}
|
||||
else
|
||||
{
|
||||
list.RemoveEntry("Clear");
|
||||
}
|
||||
|
||||
base.CompileMenuOptions(list);
|
||||
}
|
||||
|
||||
protected override void SelectEntry(GumpButton button, T entry)
|
||||
{
|
||||
base.SelectEntry(button, entry);
|
||||
|
||||
var opts = new MenuGumpOptions();
|
||||
|
||||
CompileEntryOptions(opts, entry);
|
||||
|
||||
new MenuGump(User, Refresh(), opts, button).Send();
|
||||
}
|
||||
|
||||
protected virtual void CompileEntryOptions(MenuGumpOptions opts, T entry)
|
||||
{
|
||||
if (CanRemove)
|
||||
{
|
||||
opts.AppendEntry("Remove", b => HandleRemove(entry), ErrorHue);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void HandleAdd()
|
||||
{
|
||||
if (!OnBeforeListAdd())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var obj = GetListAddObject();
|
||||
|
||||
AddToList(obj);
|
||||
}
|
||||
|
||||
protected virtual void HandleRemove(T entry)
|
||||
{
|
||||
if (OnBeforeListRemove())
|
||||
{
|
||||
RemoveFromList(entry);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void HandleClear()
|
||||
{
|
||||
if (OnBeforeListClear())
|
||||
{
|
||||
ClearList();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void HandleApplyChanges()
|
||||
{
|
||||
if (!OnBeforeApplyChanges())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var destList = GetExternalList();
|
||||
|
||||
ApplyChangesToList(destList);
|
||||
}
|
||||
|
||||
protected virtual void HandleClearChanges()
|
||||
{
|
||||
if (!OnBeforeClearChanges())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var restoList = GetExternalList();
|
||||
|
||||
ClearChanges(restoList);
|
||||
}
|
||||
|
||||
public abstract List<T> GetExternalList();
|
||||
public abstract T GetListAddObject();
|
||||
|
||||
public virtual bool Validate(T obj)
|
||||
{
|
||||
return obj != null;
|
||||
}
|
||||
|
||||
public virtual void AddToList(T obj)
|
||||
{
|
||||
if (!Validate(obj))
|
||||
{
|
||||
Refresh();
|
||||
return;
|
||||
}
|
||||
|
||||
List.Add(obj);
|
||||
|
||||
if (AddCallback != null)
|
||||
{
|
||||
AddCallback(obj);
|
||||
}
|
||||
|
||||
ChangesPending = true;
|
||||
Refresh(true);
|
||||
}
|
||||
|
||||
public virtual void RemoveFromList(T obj)
|
||||
{
|
||||
if (obj != null && List.Contains(obj))
|
||||
{
|
||||
List.Remove(obj);
|
||||
}
|
||||
|
||||
if (RemoveCallback != null)
|
||||
{
|
||||
RemoveCallback(obj);
|
||||
}
|
||||
|
||||
ChangesPending = true;
|
||||
Refresh(true);
|
||||
}
|
||||
|
||||
public virtual void ClearList()
|
||||
{
|
||||
if (List != null)
|
||||
{
|
||||
List.Clear();
|
||||
}
|
||||
|
||||
if (ClearCallback != null)
|
||||
{
|
||||
ClearCallback();
|
||||
}
|
||||
|
||||
ChangesPending = true;
|
||||
Refresh(true);
|
||||
}
|
||||
|
||||
public virtual void ClearChanges(List<T> resto)
|
||||
{
|
||||
if (resto != null && resto != List)
|
||||
{
|
||||
List.Clear();
|
||||
List.AddRange(resto);
|
||||
}
|
||||
|
||||
ChangesPending = false;
|
||||
Refresh(true);
|
||||
}
|
||||
|
||||
public virtual void ApplyChangesToList(List<T> list)
|
||||
{
|
||||
if (list != null && list != List)
|
||||
{
|
||||
list.Clear();
|
||||
list.AddRange(List);
|
||||
}
|
||||
|
||||
if (ApplyCallback != null)
|
||||
{
|
||||
ApplyCallback(list);
|
||||
}
|
||||
|
||||
ChangesPending = false;
|
||||
Refresh(true);
|
||||
}
|
||||
|
||||
protected virtual bool OnBeforeClearChanges()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected virtual bool OnBeforeApplyChanges()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected virtual bool OnBeforeListAdd()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected virtual bool OnBeforeListRemove()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected virtual bool OnBeforeListClear()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnClosed(bool all)
|
||||
{
|
||||
base.OnClosed(all);
|
||||
|
||||
if (!ChangesPending)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
new ConfirmDialogGump(User)
|
||||
{
|
||||
Title = "Apply Changes?",
|
||||
Html = "There are changes waiting that have not been applied.\nDo you want to apply them now?",
|
||||
AcceptHandler = b =>
|
||||
{
|
||||
HandleApplyChanges();
|
||||
Close(all);
|
||||
}
|
||||
}.Send();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,237 @@
|
||||
#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.Network;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps.UI
|
||||
{
|
||||
public abstract class Rect2DListGump : GenericListGump<Rectangle2D>
|
||||
{
|
||||
public bool Preview { get; set; }
|
||||
public int PreviewHue { get; set; }
|
||||
public int PreviewEffect { get; set; }
|
||||
public EffectRender PreviewRender { get; set; }
|
||||
public string PreviewName { get; set; }
|
||||
|
||||
public Rectangle2D? InputRect { get; set; }
|
||||
public Map InputMap { get; set; }
|
||||
|
||||
private RegionExtUtility.PreviewRegion _Preview;
|
||||
|
||||
public Rect2DListGump(
|
||||
Mobile user,
|
||||
Gump parent = null,
|
||||
int? x = null,
|
||||
int? y = null,
|
||||
IEnumerable<Rectangle2D> list = null,
|
||||
string emptyText = null,
|
||||
string title = null,
|
||||
IEnumerable<ListGumpEntry> opts = null,
|
||||
bool canAdd = true,
|
||||
bool canRemove = true,
|
||||
bool canClear = true,
|
||||
Action<Rectangle2D> addCallback = null,
|
||||
Action<Rectangle2D> removeCallback = null,
|
||||
Action<List<Rectangle2D>> applyCallback = null,
|
||||
Action clearCallback = null)
|
||||
: base(
|
||||
user,
|
||||
parent,
|
||||
x,
|
||||
y,
|
||||
list,
|
||||
emptyText,
|
||||
title,
|
||||
opts,
|
||||
canAdd,
|
||||
canRemove,
|
||||
canClear,
|
||||
addCallback,
|
||||
removeCallback,
|
||||
applyCallback,
|
||||
clearCallback)
|
||||
{
|
||||
InputMap = User.Map;
|
||||
|
||||
Preview = false;
|
||||
PreviewHue = TextHue;
|
||||
PreviewEffect = 1801;
|
||||
PreviewRender = EffectRender.SemiTransparent;
|
||||
PreviewName = "Preview Region";
|
||||
|
||||
ForceRecompile = true;
|
||||
}
|
||||
|
||||
protected override int GetLabelHue(int index, int pageIndex, Rectangle2D entry)
|
||||
{
|
||||
return PreviewHue;
|
||||
}
|
||||
|
||||
protected override string GetLabelText(int index, int pageIndex, Rectangle2D entry)
|
||||
{
|
||||
return entry.Start + " -> " + entry.End;
|
||||
}
|
||||
|
||||
public override string GetSearchKeyFor(Rectangle2D key)
|
||||
{
|
||||
return key.Start + " -> " + key.End;
|
||||
}
|
||||
|
||||
protected override bool OnBeforeListAdd()
|
||||
{
|
||||
if (InputRect != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Minimize();
|
||||
|
||||
BoundingBoxPicker.Begin(
|
||||
User,
|
||||
(from, map, start, end, state) =>
|
||||
{
|
||||
InputMap = map;
|
||||
InputRect = new Rectangle2D(start, end.Clone2D(1, 1));
|
||||
HandleAdd();
|
||||
InputRect = null;
|
||||
|
||||
Maximize();
|
||||
},
|
||||
null);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override Rectangle2D GetListAddObject()
|
||||
{
|
||||
return InputRect ?? default(Rectangle2D);
|
||||
}
|
||||
|
||||
protected override void OnSend()
|
||||
{
|
||||
base.OnSend();
|
||||
|
||||
DisplayPreview();
|
||||
}
|
||||
|
||||
protected override void OnRefreshed()
|
||||
{
|
||||
base.OnRefreshed();
|
||||
|
||||
DisplayPreview();
|
||||
}
|
||||
|
||||
protected override void OnClosed(bool all)
|
||||
{
|
||||
base.OnClosed(all);
|
||||
|
||||
ClearPreview();
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
base.OnDispose();
|
||||
|
||||
ClearPreview();
|
||||
}
|
||||
|
||||
protected override void CompileEntryOptions(MenuGumpOptions opts, Rectangle2D entry)
|
||||
{
|
||||
opts.AppendEntry("Go To", () => User.MoveToWorld(entry.Start.GetWorldTop(InputMap), InputMap), HighlightHue);
|
||||
|
||||
base.CompileEntryOptions(opts, entry);
|
||||
}
|
||||
|
||||
public virtual void ClearPreview()
|
||||
{
|
||||
if (_Preview == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_Preview.Unregister();
|
||||
_Preview = null;
|
||||
}
|
||||
|
||||
public virtual void DisplayPreview()
|
||||
{
|
||||
if (!Preview || InputMap == null || InputMap == Map.Internal || List.Count == 0)
|
||||
{
|
||||
if (_Preview != null)
|
||||
{
|
||||
_Preview.Unregister();
|
||||
_Preview = null;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (_Preview != null)
|
||||
{
|
||||
if (_Preview.Map == InputMap && _Preview.Area.GetBoundsHashCode() == List.GetBoundsHashCode())
|
||||
{
|
||||
_Preview.Refresh();
|
||||
return;
|
||||
}
|
||||
|
||||
_Preview.Unregister();
|
||||
}
|
||||
|
||||
_Preview = RegionExtUtility.DisplayPreview(
|
||||
PreviewName,
|
||||
InputMap,
|
||||
PreviewHue,
|
||||
PreviewEffect,
|
||||
PreviewRender,
|
||||
List.ToArray());
|
||||
}
|
||||
|
||||
protected override void CompileMenuOptions(MenuGumpOptions list)
|
||||
{
|
||||
if (!Preview)
|
||||
{
|
||||
list.Replace(
|
||||
"Disable Preview",
|
||||
"Enable Preview",
|
||||
() =>
|
||||
{
|
||||
Preview = true;
|
||||
DisplayPreview();
|
||||
Refresh();
|
||||
},
|
||||
HighlightHue);
|
||||
}
|
||||
else
|
||||
{
|
||||
list.Replace(
|
||||
"Enable Preview",
|
||||
"Disable Preview",
|
||||
() =>
|
||||
{
|
||||
Preview = false;
|
||||
ClearPreview();
|
||||
Refresh();
|
||||
},
|
||||
ErrorHue);
|
||||
}
|
||||
|
||||
base.CompileMenuOptions(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,237 @@
|
||||
#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.Network;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps.UI
|
||||
{
|
||||
public abstract class Rect3DListGump : GenericListGump<Rectangle3D>
|
||||
{
|
||||
public bool Preview { get; set; }
|
||||
public int PreviewHue { get; set; }
|
||||
public int PreviewEffect { get; set; }
|
||||
public EffectRender PreviewRender { get; set; }
|
||||
public string PreviewName { get; set; }
|
||||
|
||||
public Rectangle3D? InputRect { get; set; }
|
||||
public Map InputMap { get; set; }
|
||||
|
||||
private RegionExtUtility.PreviewRegion _Preview;
|
||||
|
||||
public Rect3DListGump(
|
||||
Mobile user,
|
||||
Gump parent = null,
|
||||
int? x = null,
|
||||
int? y = null,
|
||||
IEnumerable<Rectangle3D> list = null,
|
||||
string emptyText = null,
|
||||
string title = null,
|
||||
IEnumerable<ListGumpEntry> opts = null,
|
||||
bool canAdd = true,
|
||||
bool canRemove = true,
|
||||
bool canClear = true,
|
||||
Action<Rectangle3D> addCallback = null,
|
||||
Action<Rectangle3D> removeCallback = null,
|
||||
Action<List<Rectangle3D>> applyCallback = null,
|
||||
Action clearCallback = null)
|
||||
: base(
|
||||
user,
|
||||
parent,
|
||||
x,
|
||||
y,
|
||||
list,
|
||||
emptyText,
|
||||
title,
|
||||
opts,
|
||||
canAdd,
|
||||
canRemove,
|
||||
canClear,
|
||||
addCallback,
|
||||
removeCallback,
|
||||
applyCallback,
|
||||
clearCallback)
|
||||
{
|
||||
InputMap = User.Map;
|
||||
|
||||
Preview = false;
|
||||
PreviewHue = TextHue;
|
||||
PreviewEffect = 1801;
|
||||
PreviewRender = EffectRender.SemiTransparent;
|
||||
PreviewName = "Preview Region";
|
||||
|
||||
ForceRecompile = true;
|
||||
}
|
||||
|
||||
protected override int GetLabelHue(int index, int pageIndex, Rectangle3D entry)
|
||||
{
|
||||
return PreviewHue;
|
||||
}
|
||||
|
||||
protected override string GetLabelText(int index, int pageIndex, Rectangle3D entry)
|
||||
{
|
||||
return entry.Start + " -> " + entry.End;
|
||||
}
|
||||
|
||||
public override string GetSearchKeyFor(Rectangle3D key)
|
||||
{
|
||||
return key.Start + " -> " + key.End;
|
||||
}
|
||||
|
||||
protected override bool OnBeforeListAdd()
|
||||
{
|
||||
if (InputRect != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Minimize();
|
||||
|
||||
BoundingBoxPicker.Begin(
|
||||
User,
|
||||
(from, map, start, end, state) =>
|
||||
{
|
||||
InputMap = map;
|
||||
InputRect = new Rectangle3D(start, end.Clone3D(1, 1));
|
||||
HandleAdd();
|
||||
InputRect = null;
|
||||
|
||||
Maximize();
|
||||
},
|
||||
null);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override Rectangle3D GetListAddObject()
|
||||
{
|
||||
return InputRect ?? default(Rectangle3D);
|
||||
}
|
||||
|
||||
protected override void OnSend()
|
||||
{
|
||||
base.OnSend();
|
||||
|
||||
DisplayPreview();
|
||||
}
|
||||
|
||||
protected override void OnRefreshed()
|
||||
{
|
||||
base.OnRefreshed();
|
||||
|
||||
DisplayPreview();
|
||||
}
|
||||
|
||||
protected override void OnClosed(bool all)
|
||||
{
|
||||
base.OnClosed(all);
|
||||
|
||||
ClearPreview();
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
base.OnDispose();
|
||||
|
||||
ClearPreview();
|
||||
}
|
||||
|
||||
protected override void CompileEntryOptions(MenuGumpOptions opts, Rectangle3D entry)
|
||||
{
|
||||
base.CompileEntryOptions(opts, entry);
|
||||
|
||||
opts.AppendEntry("Go To", () => User.MoveToWorld(entry.Start, InputMap), HighlightHue);
|
||||
}
|
||||
|
||||
public virtual void ClearPreview()
|
||||
{
|
||||
if (_Preview == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_Preview.Unregister();
|
||||
_Preview = null;
|
||||
}
|
||||
|
||||
public virtual void DisplayPreview()
|
||||
{
|
||||
if (!Preview || InputMap == null || InputMap == Map.Internal || List.Count == 0)
|
||||
{
|
||||
if (_Preview != null)
|
||||
{
|
||||
_Preview.Unregister();
|
||||
_Preview = null;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (_Preview != null)
|
||||
{
|
||||
if (_Preview.Map == InputMap && _Preview.Area.GetBoundsHashCode() == List.GetBoundsHashCode())
|
||||
{
|
||||
_Preview.Refresh();
|
||||
return;
|
||||
}
|
||||
|
||||
_Preview.Unregister();
|
||||
}
|
||||
|
||||
_Preview = RegionExtUtility.DisplayPreview(
|
||||
PreviewName,
|
||||
InputMap,
|
||||
PreviewHue,
|
||||
PreviewEffect,
|
||||
PreviewRender,
|
||||
List.ToArray());
|
||||
}
|
||||
|
||||
protected override void CompileMenuOptions(MenuGumpOptions list)
|
||||
{
|
||||
if (!Preview)
|
||||
{
|
||||
list.Replace(
|
||||
"Disable Preview",
|
||||
"Enable Preview",
|
||||
() =>
|
||||
{
|
||||
Preview = true;
|
||||
DisplayPreview();
|
||||
Refresh();
|
||||
},
|
||||
HighlightHue);
|
||||
}
|
||||
else
|
||||
{
|
||||
list.Replace(
|
||||
"Enable Preview",
|
||||
"Disable Preview",
|
||||
() =>
|
||||
{
|
||||
Preview = false;
|
||||
ClearPreview();
|
||||
Refresh();
|
||||
},
|
||||
ErrorHue);
|
||||
}
|
||||
|
||||
base.CompileMenuOptions(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
#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;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps.UI
|
||||
{
|
||||
public abstract class TypeListGump : TypeListGump<object>
|
||||
{
|
||||
public TypeListGump(
|
||||
Mobile user,
|
||||
Gump parent = null,
|
||||
int? x = null,
|
||||
int? y = null,
|
||||
IEnumerable<Type> list = null,
|
||||
string emptyText = null,
|
||||
string title = null,
|
||||
IEnumerable<ListGumpEntry> opts = null,
|
||||
bool canAdd = true,
|
||||
bool canRemove = true,
|
||||
bool canClear = true,
|
||||
Action<Type> addCallback = null,
|
||||
Action<Type> removeCallback = null,
|
||||
Action<List<Type>> applyCallback = null,
|
||||
Action clearCallback = null)
|
||||
: base(
|
||||
user,
|
||||
parent,
|
||||
x,
|
||||
y,
|
||||
list,
|
||||
emptyText,
|
||||
title,
|
||||
opts,
|
||||
canAdd,
|
||||
canRemove,
|
||||
canClear,
|
||||
addCallback,
|
||||
removeCallback,
|
||||
applyCallback,
|
||||
clearCallback)
|
||||
{ }
|
||||
}
|
||||
|
||||
public abstract class TypeListGump<TBase> : GenericListGump<Type>
|
||||
{
|
||||
public Type InputType { get; set; }
|
||||
|
||||
public TypeListGump(
|
||||
Mobile user,
|
||||
Gump parent = null,
|
||||
int? x = null,
|
||||
int? y = null,
|
||||
IEnumerable<Type> list = null,
|
||||
string emptyText = null,
|
||||
string title = null,
|
||||
IEnumerable<ListGumpEntry> opts = null,
|
||||
bool canAdd = true,
|
||||
bool canRemove = true,
|
||||
bool canClear = true,
|
||||
Action<Type> addCallback = null,
|
||||
Action<Type> removeCallback = null,
|
||||
Action<List<Type>> applyCallback = null,
|
||||
Action clearCallback = null)
|
||||
: base(
|
||||
user,
|
||||
parent,
|
||||
x,
|
||||
y,
|
||||
list,
|
||||
emptyText,
|
||||
title,
|
||||
opts,
|
||||
canAdd,
|
||||
canRemove,
|
||||
canClear,
|
||||
addCallback,
|
||||
removeCallback,
|
||||
applyCallback,
|
||||
clearCallback)
|
||||
{ }
|
||||
|
||||
public override string GetSearchKeyFor(Type key)
|
||||
{
|
||||
return key != null ? key.Name : base.GetSearchKeyFor(null);
|
||||
}
|
||||
|
||||
public override bool Validate(Type obj)
|
||||
{
|
||||
return base.Validate(obj) && obj.IsEqualOrChildOf<TBase>();
|
||||
}
|
||||
|
||||
protected override bool OnBeforeListAdd()
|
||||
{
|
||||
if (InputType != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
new InputDialogGump(User, Refresh())
|
||||
{
|
||||
Title = "Add Type by Name",
|
||||
Html = "Write the name of a Type to add it to this list.\nExample: System.String",
|
||||
Callback = (b1, text) =>
|
||||
{
|
||||
InputType = VitaNexCore.TryCatchGet(
|
||||
() => Type.GetType(text, false, true) ?? //
|
||||
ScriptCompiler.FindTypeByFullName(text, true) ?? //
|
||||
ScriptCompiler.FindTypeByName(text, true));
|
||||
|
||||
HandleAdd();
|
||||
|
||||
InputType = null;
|
||||
}
|
||||
}.Send();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override Type GetListAddObject()
|
||||
{
|
||||
return InputType;
|
||||
}
|
||||
}
|
||||
}
|
||||
446
Scripts/SubSystem/VitaNex/Core/SuperGumps/UI/Lists/List.cs
Normal file
446
Scripts/SubSystem/VitaNex/Core/SuperGumps/UI/Lists/List.cs
Normal file
@@ -0,0 +1,446 @@
|
||||
#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.Text.RegularExpressions;
|
||||
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps.UI
|
||||
{
|
||||
public class ListGump<T> : SuperGumpList<T>
|
||||
{
|
||||
public const string DefaultTitle = "List View";
|
||||
public const string DefaultEmptyText = "No entries to display.";
|
||||
|
||||
protected bool WasModal { get; set; }
|
||||
|
||||
public virtual string Title { get; set; }
|
||||
|
||||
public virtual string EmptyText { get; set; }
|
||||
|
||||
public virtual bool Minimized { get; set; }
|
||||
|
||||
public virtual T Selected { get; set; }
|
||||
|
||||
public virtual bool CanSearch { get; set; }
|
||||
public virtual string SearchText { get; set; }
|
||||
public virtual List<T> SearchResults { get; set; }
|
||||
|
||||
public virtual MenuGumpOptions Options { get; set; }
|
||||
|
||||
public MenuGump Menu { get; private set; }
|
||||
|
||||
public override int EntryCount => IsSearching() ? SearchResults.Count : base.EntryCount;
|
||||
|
||||
public int EntryHeight { get; set; }
|
||||
|
||||
public int Columns { get; set; }
|
||||
public int Width { get; set; }
|
||||
|
||||
public ListGump(
|
||||
Mobile user,
|
||||
Gump parent = null,
|
||||
int? x = null,
|
||||
int? y = null,
|
||||
IEnumerable<T> list = null,
|
||||
string emptyText = null,
|
||||
string title = null,
|
||||
IEnumerable<ListGumpEntry> opts = null)
|
||||
: base(user, parent, x, y, list)
|
||||
{
|
||||
EmptyText = emptyText ?? DefaultEmptyText;
|
||||
Title = title ?? DefaultTitle;
|
||||
|
||||
Minimized = false;
|
||||
|
||||
CanMove = false;
|
||||
CanSearch = true;
|
||||
|
||||
EntryHeight = 30;
|
||||
|
||||
Width = 400;
|
||||
Columns = 1;
|
||||
|
||||
Options = new MenuGumpOptions(opts);
|
||||
}
|
||||
|
||||
public override void AssignCollections()
|
||||
{
|
||||
if (SearchResults == null)
|
||||
{
|
||||
SearchResults = new List<T>(0x20);
|
||||
}
|
||||
|
||||
base.AssignCollections();
|
||||
}
|
||||
|
||||
public virtual bool IsSearching()
|
||||
{
|
||||
return CanSearch && !String.IsNullOrWhiteSpace(SearchText);
|
||||
}
|
||||
|
||||
protected override void Compile()
|
||||
{
|
||||
base.Compile();
|
||||
|
||||
if (Options == null)
|
||||
{
|
||||
Options = new MenuGumpOptions();
|
||||
}
|
||||
else
|
||||
{
|
||||
Options.Clear();
|
||||
}
|
||||
|
||||
CompileMenuOptions(Options);
|
||||
}
|
||||
|
||||
protected override void CompileList(List<T> list)
|
||||
{
|
||||
SearchResults.Clear();
|
||||
|
||||
if (IsSearching())
|
||||
{
|
||||
SearchResults.AddRange(
|
||||
list.Where(
|
||||
o => o != null && Regex.IsMatch(GetSearchKeyFor(o), Regex.Escape(SearchText), RegexOptions.IgnoreCase)));
|
||||
|
||||
if (Sorted)
|
||||
{
|
||||
SearchResults.Sort(SortCompare);
|
||||
}
|
||||
}
|
||||
|
||||
base.CompileList(list);
|
||||
}
|
||||
|
||||
public virtual string GetSearchKeyFor(T key)
|
||||
{
|
||||
return key != null ? key.ToString() : "NULL";
|
||||
}
|
||||
|
||||
protected virtual void OnClearSearch(GumpButton button)
|
||||
{
|
||||
SearchText = null;
|
||||
Refresh(true);
|
||||
}
|
||||
|
||||
protected virtual void OnNewSearch(GumpButton button)
|
||||
{
|
||||
new InputDialogGump(User, this)
|
||||
{
|
||||
Title = "Search",
|
||||
Html = "Search " + Title + ".\nRegular Expressions are supported.",
|
||||
Limit = 100,
|
||||
Callback = (subBtn, input) =>
|
||||
{
|
||||
SearchText = input;
|
||||
Page = 0;
|
||||
Refresh(true);
|
||||
}
|
||||
}.Send();
|
||||
}
|
||||
|
||||
protected virtual void CompileMenuOptions(MenuGumpOptions list)
|
||||
{
|
||||
if (Minimized)
|
||||
{
|
||||
list.Replace("Minimize", "Maximize", Maximize);
|
||||
}
|
||||
else
|
||||
{
|
||||
list.Replace("Maximize", "Minimize", Minimize);
|
||||
}
|
||||
|
||||
if (CanSearch)
|
||||
{
|
||||
if (IsSearching())
|
||||
{
|
||||
list.Replace("New Search", "Clear Search", OnClearSearch);
|
||||
}
|
||||
else
|
||||
{
|
||||
list.Replace("Clear Search", "New Search", OnNewSearch);
|
||||
}
|
||||
}
|
||||
|
||||
list.AppendEntry("Refresh", b => Refresh(b));
|
||||
|
||||
if (CanClose)
|
||||
{
|
||||
list.AppendEntry("Exit", b => Close(b));
|
||||
}
|
||||
}
|
||||
|
||||
protected override void CompileLayout(SuperGumpLayout layout)
|
||||
{
|
||||
base.CompileLayout(layout);
|
||||
|
||||
var sup = SupportsUltimaStore;
|
||||
var ec = IsEnhancedClient;
|
||||
var bgID = ec ? 83 : sup ? 40000 : 9270;
|
||||
var fillID = ec ? 87 : sup ? 40004 : 2624;
|
||||
|
||||
layout.Add(
|
||||
"background/header/base",
|
||||
() =>
|
||||
{
|
||||
AddBackground(0, 0, Width + 20, 50, bgID);
|
||||
AddImageTiled(10, 10, Width, 30, fillID);
|
||||
//AddAlphaRegion(10, 10, Width, 30);
|
||||
});
|
||||
|
||||
layout.Add(
|
||||
"button/header/options",
|
||||
() =>
|
||||
{
|
||||
AddButton(15, 15, 2008, 2007, ShowOptionMenu);
|
||||
AddTooltip(1015326);
|
||||
});
|
||||
|
||||
layout.Add(
|
||||
"button/header/minimize",
|
||||
() =>
|
||||
{
|
||||
if (Minimized)
|
||||
{
|
||||
AddButton(Width - 10, 20, 10740, 10742, Maximize);
|
||||
AddTooltip(3002086);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddButton(Width - 10, 20, 10741, 10742, Minimize);
|
||||
AddTooltip(3002085);
|
||||
}
|
||||
});
|
||||
|
||||
layout.Add(
|
||||
"label/header/title",
|
||||
() =>
|
||||
{
|
||||
var title = String.IsNullOrWhiteSpace(Title) ? DefaultTitle : Title;
|
||||
|
||||
AddLabelCropped(90, 15, Width - 90, 20, GetTitleHue(), title);
|
||||
});
|
||||
|
||||
if (Minimized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
layout.Add("imagetiled/body/spacer", () => AddImageTiled(0, 50, Width + 20, 10, fillID));
|
||||
|
||||
var range = GetListRange();
|
||||
|
||||
if (range.Count > 0)
|
||||
{
|
||||
var height = (int)Math.Ceiling(range.Count / Math.Max(1.0, Columns)) * EntryHeight;
|
||||
|
||||
layout.Add(
|
||||
"background/body/base",
|
||||
() =>
|
||||
{
|
||||
AddBackground(0, 55, Width + 20, height + 20, bgID);
|
||||
AddImageTiled(10, 65, Width, height, fillID);
|
||||
//AddAlphaRegion(10, 65, Width, height);
|
||||
});
|
||||
|
||||
CompileEntryLayout(layout, range);
|
||||
|
||||
range.Clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
layout.Add(
|
||||
"background/body/base",
|
||||
() =>
|
||||
{
|
||||
AddBackground(0, 55, Width + 20, 50, bgID);
|
||||
AddImageTiled(10, 65, Width, 30, fillID);
|
||||
//AddAlphaRegion(10, 65, Width, 30);
|
||||
});
|
||||
|
||||
layout.Add(
|
||||
"label/list/empty",
|
||||
() =>
|
||||
{
|
||||
var label = String.IsNullOrEmpty(EmptyText) ? DefaultEmptyText : EmptyText;
|
||||
|
||||
label = label.WrapUOHtmlCenter();
|
||||
|
||||
AddHtml(15, 72, Width - 10, 20, label, Color.IndianRed, Color.Empty);
|
||||
});
|
||||
}
|
||||
|
||||
layout.Add(
|
||||
"widget/body/scrollbar",
|
||||
() => AddScrollbarHM(10, 46, Width, PageCount, Page, PreviousPage, NextPage));
|
||||
}
|
||||
|
||||
protected virtual void CompileEntryLayout(SuperGumpLayout layout, Dictionary<int, T> range)
|
||||
{
|
||||
var i = 0;
|
||||
var h = EntryHeight;
|
||||
|
||||
foreach (var kv in range)
|
||||
{
|
||||
CompileEntryLayout(layout, range.Count, kv.Key, i, 70 + ((i++ / Columns) * h), kv.Value);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void CompileEntryLayout(
|
||||
SuperGumpLayout layout,
|
||||
int length,
|
||||
int index,
|
||||
int pIndex,
|
||||
int yOffset,
|
||||
T entry)
|
||||
{
|
||||
var wOffset = (Width - 10) / Columns;
|
||||
var xOffset = (pIndex % Columns) * wOffset;
|
||||
|
||||
layout.Add(
|
||||
"button/list/select/" + index,
|
||||
() => AddButton(xOffset + 15, yOffset, 4006, 4007, b => SelectEntry(b, entry)));
|
||||
|
||||
layout.Add(
|
||||
"label/list/entry/" + index,
|
||||
() =>
|
||||
{
|
||||
var offset = 15 + GetImageSize(4006).Width + 5;
|
||||
|
||||
var hue = GetLabelHue(index, pIndex, entry);
|
||||
var text = GetLabelText(index, pIndex, entry);
|
||||
|
||||
AddLabelCropped(xOffset + offset, yOffset + 2, wOffset - offset, EntryHeight - 2, hue, text);
|
||||
});
|
||||
}
|
||||
|
||||
public override IEnumerable<T> EnumerateListRange(int index, int length)
|
||||
{
|
||||
if (!IsSearching())
|
||||
{
|
||||
foreach (var o in base.EnumerateListRange(index, length))
|
||||
{
|
||||
yield return o;
|
||||
}
|
||||
|
||||
yield break;
|
||||
}
|
||||
|
||||
index = Math.Max(0, Math.Min(EntryCount, index));
|
||||
length = Math.Max(0, Math.Min(EntryCount - index, length));
|
||||
|
||||
while (--length >= 0 && SearchResults.InBounds(index))
|
||||
{
|
||||
yield return SearchResults[index++];
|
||||
}
|
||||
}
|
||||
|
||||
public override Dictionary<int, T> GetListRange(int index, int length)
|
||||
{
|
||||
if (!IsSearching())
|
||||
{
|
||||
return base.GetListRange(index, length);
|
||||
}
|
||||
|
||||
index = Math.Max(0, Math.Min(EntryCount, index));
|
||||
length = Math.Max(0, Math.Min(EntryCount - index, length));
|
||||
|
||||
var d = new Dictionary<int, T>(length);
|
||||
|
||||
while (--length >= 0 && SearchResults.InBounds(index))
|
||||
{
|
||||
d[index] = SearchResults[index++];
|
||||
}
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
protected virtual void Minimize(GumpButton entry = null)
|
||||
{
|
||||
Minimized = true;
|
||||
|
||||
if (Modal)
|
||||
{
|
||||
WasModal = true;
|
||||
}
|
||||
|
||||
Modal = false;
|
||||
|
||||
Refresh(true);
|
||||
}
|
||||
|
||||
protected virtual void Maximize(GumpButton entry = null)
|
||||
{
|
||||
Minimized = false;
|
||||
|
||||
if (WasModal)
|
||||
{
|
||||
Modal = true;
|
||||
}
|
||||
|
||||
WasModal = false;
|
||||
|
||||
Refresh(true);
|
||||
}
|
||||
|
||||
protected virtual int GetTitleHue()
|
||||
{
|
||||
return HighlightHue;
|
||||
}
|
||||
|
||||
protected virtual string GetLabelText(int index, int pageIndex, T entry)
|
||||
{
|
||||
return entry != null ? entry.ToString() : "NULL";
|
||||
}
|
||||
|
||||
protected virtual int GetLabelHue(int index, int pageIndex, T entry)
|
||||
{
|
||||
return entry != null ? TextHue : ErrorHue;
|
||||
}
|
||||
|
||||
protected virtual void SelectEntry(GumpButton button, T entry)
|
||||
{
|
||||
Selected = entry;
|
||||
}
|
||||
|
||||
protected virtual void ShowOptionMenu(GumpButton button)
|
||||
{
|
||||
if (User != null && !User.Deleted && Options != null && Options.Count > 0)
|
||||
{
|
||||
Send(new MenuGump(User, Refresh(), Options, button));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ListGump<T, U> : ListGump<KeyValuePair<T, U>>
|
||||
{
|
||||
public ListGump(
|
||||
Mobile user,
|
||||
Gump parent = null,
|
||||
int? x = null,
|
||||
int? y = null,
|
||||
IEnumerable<KeyValuePair<T, U>> list = null,
|
||||
string emptyText = null,
|
||||
string title = null,
|
||||
IEnumerable<ListGumpEntry> opts = null)
|
||||
: base(user, parent, x, y, list, emptyText, title, opts)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
119
Scripts/SubSystem/VitaNex/Core/SuperGumps/UI/Lists/ListEntry.cs
Normal file
119
Scripts/SubSystem/VitaNex/Core/SuperGumps/UI/Lists/ListEntry.cs
Normal file
@@ -0,0 +1,119 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#region References
|
||||
using System;
|
||||
|
||||
using Server.Gumps;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps.UI
|
||||
{
|
||||
public struct ListGumpEntry : IEquatable<ListGumpEntry>, IEquatable<string>
|
||||
{
|
||||
public static ListGumpEntry Empty = new ListGumpEntry(String.Empty, () => { });
|
||||
|
||||
private static Action<GumpButton> Resolve(Action handler)
|
||||
{
|
||||
return b =>
|
||||
{
|
||||
if (handler != null)
|
||||
{
|
||||
handler();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static bool IsNullOrEmpty(ListGumpEntry entry)
|
||||
{
|
||||
return entry == null || entry == Empty;
|
||||
}
|
||||
|
||||
public string Label { get; set; }
|
||||
public int Hue { get; set; }
|
||||
public Action<GumpButton> Handler { get; set; }
|
||||
|
||||
public ListGumpEntry(string label, Action handler)
|
||||
: this(label, Resolve(handler), SuperGump.DefaultTextHue)
|
||||
{ }
|
||||
|
||||
public ListGumpEntry(string label, Action handler, int hue)
|
||||
: this(label, Resolve(handler), hue)
|
||||
{ }
|
||||
|
||||
public ListGumpEntry(string label, Action<GumpButton> handler)
|
||||
: this(label, handler, SuperGump.DefaultTextHue)
|
||||
{ }
|
||||
|
||||
public ListGumpEntry(string label, Action<GumpButton> handler, int hue)
|
||||
: this()
|
||||
{
|
||||
Label = label;
|
||||
Handler = handler;
|
||||
Hue = hue;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Label;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Label != null ? Label.GetHashCode() : 0;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return (obj is string && Equals((string)obj)) || (obj is ListGumpEntry && Equals((ListGumpEntry)obj));
|
||||
}
|
||||
|
||||
public bool Equals(ListGumpEntry other)
|
||||
{
|
||||
return Label == other.Label;
|
||||
}
|
||||
|
||||
public bool Equals(string other)
|
||||
{
|
||||
return Label == other;
|
||||
}
|
||||
|
||||
public static bool operator ==(ListGumpEntry l, ListGumpEntry r)
|
||||
{
|
||||
return l.Equals(r);
|
||||
}
|
||||
|
||||
public static bool operator !=(ListGumpEntry l, ListGumpEntry r)
|
||||
{
|
||||
return !l.Equals(r);
|
||||
}
|
||||
|
||||
public static bool operator ==(ListGumpEntry l, string r)
|
||||
{
|
||||
return l.Equals(r);
|
||||
}
|
||||
|
||||
public static bool operator !=(ListGumpEntry l, string r)
|
||||
{
|
||||
return !l.Equals(r);
|
||||
}
|
||||
|
||||
public static bool operator ==(string l, ListGumpEntry r)
|
||||
{
|
||||
return r.Equals(l);
|
||||
}
|
||||
|
||||
public static bool operator !=(string l, ListGumpEntry r)
|
||||
{
|
||||
return !r.Equals(l);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
#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;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps.UI
|
||||
{
|
||||
public class EnumMenuGump<TEnum> : MenuGump
|
||||
where TEnum : struct, IComparable, IFormattable, IConvertible
|
||||
{
|
||||
public Action<TEnum> Callback { get; set; }
|
||||
|
||||
public TEnum DefaultValue { get; set; }
|
||||
|
||||
public EnumMenuGump(
|
||||
Mobile user,
|
||||
Gump parent = null,
|
||||
GumpButton clicked = null,
|
||||
TEnum def = default(TEnum),
|
||||
Action<TEnum> callback = null)
|
||||
: base(user, parent, null, clicked)
|
||||
{
|
||||
DefaultValue = def;
|
||||
Callback = callback;
|
||||
}
|
||||
|
||||
protected virtual void OnSelected(TEnum val)
|
||||
{
|
||||
if (Callback != null)
|
||||
{
|
||||
Callback(val);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void CompileOptions(MenuGumpOptions list)
|
||||
{
|
||||
if (typeof(TEnum).IsEnum)
|
||||
{
|
||||
foreach (var val in EnumerateValues())
|
||||
{
|
||||
var e = new ListGumpEntry(GetOptionLabel(val), b => OnSelected(val));
|
||||
|
||||
if (Equals(val, DefaultValue))
|
||||
{
|
||||
e.Hue = HighlightHue;
|
||||
}
|
||||
|
||||
list.AppendEntry(e);
|
||||
}
|
||||
}
|
||||
|
||||
base.CompileOptions(list);
|
||||
}
|
||||
|
||||
public virtual IEnumerable<TEnum> EnumerateValues()
|
||||
{
|
||||
return (default(TEnum) as Enum).EnumerateValues<TEnum>(false);
|
||||
}
|
||||
|
||||
public virtual string GetOptionLabel(TEnum val)
|
||||
{
|
||||
return val.ToString().SpaceWords();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
#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.Linq;
|
||||
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
|
||||
using VitaNex.Text;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps.UI
|
||||
{
|
||||
public class MenuGump : SuperGumpList<ListGumpEntry>
|
||||
{
|
||||
public int GuessWidth { get; protected set; }
|
||||
|
||||
public int EntryHeight { get; set; }
|
||||
|
||||
public GumpButton Clicked { get; set; }
|
||||
|
||||
public ListGumpEntry Selected { get; set; }
|
||||
|
||||
public MenuGump(Mobile user, Gump parent = null, IEnumerable<ListGumpEntry> list = null, GumpButton clicked = null)
|
||||
: base(user, parent, DefaultX, DefaultY, list)
|
||||
{
|
||||
EntryHeight = 30;
|
||||
|
||||
Clicked = clicked;
|
||||
|
||||
if (Clicked != null)
|
||||
{
|
||||
if (Clicked.Parent != null)
|
||||
{
|
||||
X = Clicked.Parent.X + Clicked.X;
|
||||
Y = Clicked.Parent.Y + Clicked.Y;
|
||||
|
||||
if (Parent == null)
|
||||
{
|
||||
Parent = Clicked.Parent;
|
||||
}
|
||||
}
|
||||
else if (Parent != null)
|
||||
{
|
||||
X = Parent.X;
|
||||
Y = Parent.Y;
|
||||
}
|
||||
else
|
||||
{
|
||||
X = DefaultX;
|
||||
Y = DefaultY;
|
||||
}
|
||||
}
|
||||
else if (Parent != null)
|
||||
{
|
||||
X = Parent.X;
|
||||
Y = Parent.Y;
|
||||
}
|
||||
else
|
||||
{
|
||||
X = DefaultX;
|
||||
Y = DefaultY;
|
||||
}
|
||||
|
||||
ForceRecompile = true;
|
||||
CanMove = false;
|
||||
CanResize = false;
|
||||
Modal = true;
|
||||
}
|
||||
|
||||
protected virtual void InvalidateWidth()
|
||||
{
|
||||
double epp = EntriesPerPage;
|
||||
|
||||
GuessWidth = 100;
|
||||
|
||||
if (epp > 0)
|
||||
{
|
||||
var font = UOFont.Unicode[1];
|
||||
|
||||
GuessWidth += List.Select((e, i) => font.GetWidth(GetLabelText(i, (int)Math.Ceiling(i + 1 / epp), e))).Highest();
|
||||
}
|
||||
}
|
||||
|
||||
public void AddOption(string label, Action handler)
|
||||
{
|
||||
List.Add(new ListGumpEntry(label, handler));
|
||||
}
|
||||
|
||||
public void AddOption(string label, Action handler, int hue)
|
||||
{
|
||||
List.Add(new ListGumpEntry(label, handler, hue));
|
||||
}
|
||||
|
||||
public void AddOption(string label, Action<GumpButton> handler)
|
||||
{
|
||||
List.Add(new ListGumpEntry(label, handler));
|
||||
}
|
||||
|
||||
public void AddOption(string label, Action<GumpButton> handler, int hue)
|
||||
{
|
||||
List.Add(new ListGumpEntry(label, handler, hue));
|
||||
}
|
||||
|
||||
protected override void CompileLayout(SuperGumpLayout layout)
|
||||
{
|
||||
base.CompileLayout(layout);
|
||||
|
||||
var range = GetListRange();
|
||||
|
||||
var eh = range.Count * EntryHeight;
|
||||
|
||||
var sup = SupportsUltimaStore;
|
||||
var ec = IsEnhancedClient;
|
||||
var bgID = ec ? 83 : sup ? 40000 : 9270;
|
||||
|
||||
layout.Add(
|
||||
"background/body/base",
|
||||
() =>
|
||||
{
|
||||
AddBackground(0, 0, GuessWidth, 30 + eh, bgID);
|
||||
|
||||
if (!sup)
|
||||
{
|
||||
AddImageTiled(10, 10, GuessWidth - 20, 10 + eh, 2624);
|
||||
//AddAlphaRegion(10, 10, GuessWidth - 20, 10 + eh);
|
||||
}
|
||||
});
|
||||
|
||||
layout.Add(
|
||||
"imagetiled/body/vsep/0",
|
||||
() =>
|
||||
{
|
||||
if (!sup || ec)
|
||||
{
|
||||
AddImageTiled(50, 20, 5, eh, bgID + 5);
|
||||
}
|
||||
});
|
||||
|
||||
CompileEntryLayout(layout, range);
|
||||
|
||||
layout.Add(
|
||||
"widget/body/scrollbar",
|
||||
() => AddScrollbarHM(10, 10, GuessWidth - 20, PageCount, Page, PreviousPage, NextPage));
|
||||
}
|
||||
|
||||
public virtual void CompileEntryLayout(SuperGumpLayout layout, Dictionary<int, ListGumpEntry> range)
|
||||
{
|
||||
range.For((i, kv) => CompileEntryLayout(layout, range.Count, kv.Key, i, 25 + (i * EntryHeight), kv.Value));
|
||||
}
|
||||
|
||||
public virtual void CompileEntryLayout(
|
||||
SuperGumpLayout layout,
|
||||
int length,
|
||||
int index,
|
||||
int pIndex,
|
||||
int yOffset,
|
||||
ListGumpEntry entry)
|
||||
{
|
||||
var sup = SupportsUltimaStore;
|
||||
var ec = IsEnhancedClient;
|
||||
var bgID = ec ? 83 : sup ? 40000 : 9270;
|
||||
|
||||
layout.Add("button/list/select/" + index, () => AddButton(15, yOffset, 4006, 4007, b => SelectEntry(b, entry)));
|
||||
|
||||
layout.Add(
|
||||
"label/list/entry/" + index,
|
||||
() => AddLabelCropped(
|
||||
65,
|
||||
2 + yOffset,
|
||||
GuessWidth - 75,
|
||||
20,
|
||||
GetLabelHue(index, pIndex, entry),
|
||||
GetLabelText(index, pIndex, entry)));
|
||||
|
||||
if (pIndex < (length - 1))
|
||||
{
|
||||
layout.Add(
|
||||
"imagetiled/body/hsep/" + index,
|
||||
() =>
|
||||
{
|
||||
if (!ec)
|
||||
{
|
||||
AddImageTiled(10, 25 + yOffset, GuessWidth - 20, 5, bgID + 7);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected override sealed void CompileList(List<ListGumpEntry> list)
|
||||
{
|
||||
var opts = new MenuGumpOptions(list);
|
||||
|
||||
CompileOptions(opts);
|
||||
|
||||
list.Clear();
|
||||
list.AddRange(opts);
|
||||
|
||||
InvalidateWidth();
|
||||
}
|
||||
|
||||
protected virtual void CompileOptions(MenuGumpOptions list)
|
||||
{
|
||||
list.Insert(list.Count, new ListGumpEntry("Cancel", Cancel, ErrorHue));
|
||||
}
|
||||
|
||||
protected virtual string GetLabelText(int index, int pageIndex, ListGumpEntry entry)
|
||||
{
|
||||
return entry != null ? entry.Label : "NULL";
|
||||
}
|
||||
|
||||
protected virtual int GetLabelHue(int index, int pageIndex, ListGumpEntry entry)
|
||||
{
|
||||
return entry != null ? entry.Hue : ErrorHue;
|
||||
}
|
||||
|
||||
protected virtual void SelectEntry(GumpButton button, ListGumpEntry entry)
|
||||
{
|
||||
Selected = entry;
|
||||
|
||||
if (entry == null || entry.Handler == null)
|
||||
{
|
||||
Close();
|
||||
return;
|
||||
}
|
||||
|
||||
entry.Handler(button);
|
||||
}
|
||||
|
||||
protected virtual void Cancel(GumpButton button)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,270 @@
|
||||
#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.Linq;
|
||||
|
||||
using Server.Gumps;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps.UI
|
||||
{
|
||||
public class MenuGumpOptions : IEnumerable<ListGumpEntry>, IEquatable<MenuGumpOptions>
|
||||
{
|
||||
private readonly List<ListGumpEntry> _Options;
|
||||
|
||||
public int Count => _Options.Count;
|
||||
|
||||
public ListGumpEntry this[int index] { get => GetEntryAt(index); set => Replace(value); }
|
||||
public ListGumpEntry this[string label] { get => GetEntry(label); set => Replace(label, value); }
|
||||
|
||||
public MenuGumpOptions()
|
||||
{
|
||||
_Options = new List<ListGumpEntry>(0x10);
|
||||
}
|
||||
|
||||
public MenuGumpOptions(IEnumerable<ListGumpEntry> options)
|
||||
: this()
|
||||
{
|
||||
AppendRange(options);
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
public IEnumerator<ListGumpEntry> GetEnumerator()
|
||||
{
|
||||
return _Options.GetEnumerator();
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
_Options.Clear();
|
||||
}
|
||||
|
||||
public void AppendRange(IEnumerable<ListGumpEntry> options)
|
||||
{
|
||||
if (options != null)
|
||||
{
|
||||
options.ForEach(AppendEntry);
|
||||
}
|
||||
}
|
||||
|
||||
public void AppendEntry(string label, Action handler)
|
||||
{
|
||||
AppendEntry(new ListGumpEntry(label, handler));
|
||||
}
|
||||
|
||||
public void AppendEntry(string label, Action handler, int hue)
|
||||
{
|
||||
AppendEntry(new ListGumpEntry(label, handler, hue));
|
||||
}
|
||||
|
||||
public void AppendEntry(string label, Action<GumpButton> handler)
|
||||
{
|
||||
AppendEntry(new ListGumpEntry(label, handler));
|
||||
}
|
||||
|
||||
public void AppendEntry(string label, Action<GumpButton> handler, int hue)
|
||||
{
|
||||
AppendEntry(new ListGumpEntry(label, handler, hue));
|
||||
}
|
||||
|
||||
public void AppendEntry(ListGumpEntry entry)
|
||||
{
|
||||
Insert(Count, entry);
|
||||
}
|
||||
|
||||
public void PrependRange(IEnumerable<ListGumpEntry> options)
|
||||
{
|
||||
if (options != null)
|
||||
{
|
||||
options.ForEach(PrependEntry);
|
||||
}
|
||||
}
|
||||
|
||||
public void PrependEntry(string label, Action handler)
|
||||
{
|
||||
PrependEntry(new ListGumpEntry(label, handler));
|
||||
}
|
||||
|
||||
public void PrependEntry(string label, Action handler, int hue)
|
||||
{
|
||||
PrependEntry(new ListGumpEntry(label, handler, hue));
|
||||
}
|
||||
|
||||
public void PrependEntry(string label, Action<GumpButton> handler)
|
||||
{
|
||||
PrependEntry(new ListGumpEntry(label, handler));
|
||||
}
|
||||
|
||||
public void PrependEntry(string label, Action<GumpButton> handler, int hue)
|
||||
{
|
||||
PrependEntry(new ListGumpEntry(label, handler, hue));
|
||||
}
|
||||
|
||||
public void PrependEntry(ListGumpEntry entry)
|
||||
{
|
||||
Insert(0, entry);
|
||||
}
|
||||
|
||||
public bool RemoveEntry(ListGumpEntry entry)
|
||||
{
|
||||
return _Options.RemoveAll(o => o == entry) > 0;
|
||||
}
|
||||
|
||||
public bool RemoveEntry(string label)
|
||||
{
|
||||
return _Options.RemoveAll(o => o == label) > 0;
|
||||
}
|
||||
|
||||
public ListGumpEntry GetEntryAt(int index)
|
||||
{
|
||||
return _Options.ElementAtOrDefault(index);
|
||||
}
|
||||
|
||||
public ListGumpEntry GetEntry(string label)
|
||||
{
|
||||
return _Options.Find(o => o == label);
|
||||
}
|
||||
|
||||
public int IndexOfEntry(ListGumpEntry entry)
|
||||
{
|
||||
return _Options.IndexOf(o => o == entry);
|
||||
}
|
||||
|
||||
public int IndexOfLabel(string label)
|
||||
{
|
||||
return _Options.IndexOf(o => o == label);
|
||||
}
|
||||
|
||||
public void Insert(int index, ListGumpEntry entry)
|
||||
{
|
||||
if (ListGumpEntry.IsNullOrEmpty(entry))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
index = Math.Max(0, Math.Min(Count, index));
|
||||
|
||||
var i = IndexOfEntry(entry);
|
||||
|
||||
if (i != -1)
|
||||
{
|
||||
_Options.RemoveAt(i);
|
||||
|
||||
if (index > i)
|
||||
{
|
||||
--index;
|
||||
}
|
||||
}
|
||||
|
||||
_Options.Insert(index, entry);
|
||||
}
|
||||
|
||||
public void Replace(ListGumpEntry entry)
|
||||
{
|
||||
Replace(entry.Label, entry);
|
||||
}
|
||||
|
||||
public void Replace(string label, ListGumpEntry entry)
|
||||
{
|
||||
var i = IndexOfLabel(label);
|
||||
|
||||
if (i == -1 || (RemoveEntry(label) && i > Count))
|
||||
{
|
||||
i = Count;
|
||||
}
|
||||
|
||||
Insert(i, entry);
|
||||
}
|
||||
|
||||
public void Replace(string label, Action handler)
|
||||
{
|
||||
Replace(label, new ListGumpEntry(label, handler));
|
||||
}
|
||||
|
||||
public void Replace(string label, Action handler, int hue)
|
||||
{
|
||||
Replace(label, new ListGumpEntry(label, handler, hue));
|
||||
}
|
||||
|
||||
public void Replace(string search, string label, Action handler)
|
||||
{
|
||||
Replace(search, new ListGumpEntry(label, handler));
|
||||
}
|
||||
|
||||
public void Replace(string search, string label, Action handler, int hue)
|
||||
{
|
||||
Replace(search, new ListGumpEntry(label, handler, hue));
|
||||
}
|
||||
|
||||
public void Replace(string label, Action<GumpButton> handler)
|
||||
{
|
||||
Replace(label, new ListGumpEntry(label, handler));
|
||||
}
|
||||
|
||||
public void Replace(string label, Action<GumpButton> handler, int hue)
|
||||
{
|
||||
Replace(label, new ListGumpEntry(label, handler, hue));
|
||||
}
|
||||
|
||||
public void Replace(string search, string label, Action<GumpButton> handler)
|
||||
{
|
||||
Replace(search, new ListGumpEntry(label, handler));
|
||||
}
|
||||
|
||||
public void Replace(string search, string label, Action<GumpButton> handler, int hue)
|
||||
{
|
||||
Replace(search, new ListGumpEntry(label, handler, hue));
|
||||
}
|
||||
|
||||
public bool Contains(string label)
|
||||
{
|
||||
return IndexOfLabel(label) != -1;
|
||||
}
|
||||
|
||||
public bool Contains(ListGumpEntry entry)
|
||||
{
|
||||
return IndexOfEntry(entry) != -1;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return _Options.Aggregate(Count, (hash, e) => unchecked((hash * 397) ^ e.GetHashCode()));
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is MenuGumpOptions && Equals((MenuGumpOptions)obj);
|
||||
}
|
||||
|
||||
public virtual bool Equals(MenuGumpOptions other)
|
||||
{
|
||||
return !ReferenceEquals(other, null) && GetHashCode() == other.GetHashCode();
|
||||
}
|
||||
|
||||
public static bool operator ==(MenuGumpOptions l, MenuGumpOptions r)
|
||||
{
|
||||
return ReferenceEquals(l, null) ? ReferenceEquals(r, null) : l.Equals(r);
|
||||
}
|
||||
|
||||
public static bool operator !=(MenuGumpOptions l, MenuGumpOptions r)
|
||||
{
|
||||
return ReferenceEquals(l, null) ? !ReferenceEquals(r, null) : !l.Equals(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,294 @@
|
||||
#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.Gumps;
|
||||
|
||||
using VitaNex.IO;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps.UI
|
||||
{
|
||||
public class FileExplorerGump : TreeGump
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
CommandUtility.Register("explorer", AccessLevel.Owner, e => new FileExplorerGump(e.Mobile, null, null).Send());
|
||||
}
|
||||
|
||||
public DirectoryInfo RootDirectory { get; set; }
|
||||
|
||||
public DirectoryInfo SelectedDirectory { get; set; }
|
||||
public FileInfo SelectedFile { get; set; }
|
||||
|
||||
public FileExplorerGump(Mobile user, Gump parent, DirectoryInfo rootDirectory)
|
||||
: base(user, parent)
|
||||
{
|
||||
RootDirectory = SelectedDirectory = rootDirectory;
|
||||
|
||||
Width = 800;
|
||||
Height = 600;
|
||||
}
|
||||
|
||||
protected override void Compile()
|
||||
{
|
||||
if (RootDirectory == null)
|
||||
{
|
||||
RootDirectory = new DirectoryInfo(Core.BaseDirectory);
|
||||
}
|
||||
|
||||
while (!RootDirectory.Exists && RootDirectory.Parent != null)
|
||||
{
|
||||
RootDirectory = RootDirectory.Parent;
|
||||
}
|
||||
|
||||
if (!RootDirectory.Exists)
|
||||
{
|
||||
RootDirectory = new DirectoryInfo(Core.BaseDirectory);
|
||||
}
|
||||
|
||||
if (SelectedFile != null)
|
||||
{
|
||||
if (SelectedFile.Exists)
|
||||
{
|
||||
SelectedDirectory = SelectedFile.Directory;
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectedFile = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (SelectedDirectory == null)
|
||||
{
|
||||
SelectedDirectory = RootDirectory;
|
||||
}
|
||||
|
||||
while (!SelectedDirectory.Exists && SelectedDirectory.Parent != null)
|
||||
{
|
||||
SelectedDirectory = SelectedDirectory.Parent;
|
||||
}
|
||||
|
||||
if (!SelectedDirectory.Exists)
|
||||
{
|
||||
SelectedDirectory = RootDirectory;
|
||||
}
|
||||
|
||||
if (!Insensitive.StartsWith(SelectedDirectory.FullName, RootDirectory.FullName))
|
||||
{
|
||||
SelectedDirectory = RootDirectory;
|
||||
}
|
||||
|
||||
base.Compile();
|
||||
}
|
||||
|
||||
private string GetPath(FileSystemInfo info)
|
||||
{
|
||||
if (RootDirectory.Parent != null)
|
||||
{
|
||||
return info.FullName.Replace(RootDirectory.Parent.FullName, String.Empty)
|
||||
.Replace(IOUtility.PathSeparator, TreeGumpNode.Separator)
|
||||
.Trim(TreeGumpNode.Separator);
|
||||
}
|
||||
|
||||
return info.FullName.Replace(RootDirectory.FullName, String.Empty)
|
||||
.Replace(IOUtility.PathSeparator, TreeGumpNode.Separator)
|
||||
.Trim(TreeGumpNode.Separator);
|
||||
}
|
||||
|
||||
private string GetPath(TreeGumpNode node)
|
||||
{
|
||||
if (RootDirectory.Parent != null)
|
||||
{
|
||||
return Path.Combine(
|
||||
RootDirectory.Parent.FullName,
|
||||
node.FullName.Replace(TreeGumpNode.Separator, IOUtility.PathSeparator))
|
||||
.Trim(IOUtility.PathSeparator);
|
||||
}
|
||||
|
||||
return Path.Combine(RootDirectory.FullName, node.FullName.Replace(TreeGumpNode.Separator, IOUtility.PathSeparator))
|
||||
.Trim(IOUtility.PathSeparator);
|
||||
}
|
||||
|
||||
protected override void CompileNodes(Dictionary<TreeGumpNode, Action<Rectangle, int, TreeGumpNode>> list)
|
||||
{
|
||||
base.CompileNodes(list);
|
||||
|
||||
list.Clear();
|
||||
|
||||
MapTree(list, RootDirectory);
|
||||
}
|
||||
|
||||
private void MapTree(Dictionary<TreeGumpNode, Action<Rectangle, int, TreeGumpNode>> list, DirectoryInfo dir)
|
||||
{
|
||||
TreeGumpNode node = GetPath(dir);
|
||||
|
||||
list[node] = RenderPanel;
|
||||
|
||||
var dirs = dir.EnumerateDirectories();
|
||||
|
||||
foreach (var d in dirs.OrderByNatural(d => d.Name))
|
||||
{
|
||||
node = GetPath(dir);
|
||||
|
||||
if (node >= SelectedNode)
|
||||
{
|
||||
MapTree(list, d);
|
||||
}
|
||||
else
|
||||
{
|
||||
list[node] = RenderPanel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void RenderPanel(Rectangle panel, int index, TreeGumpNode node)
|
||||
{
|
||||
if (SelectedFile != null)
|
||||
{
|
||||
RenderFilePanel(panel, index, node);
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderDirectoryPanel(panel, index, node);
|
||||
}
|
||||
}
|
||||
|
||||
// 310 x 350
|
||||
protected virtual void RenderDirectoryPanel(Rectangle panel, int index, TreeGumpNode node)
|
||||
{
|
||||
var x = panel.X + 20;
|
||||
var y = panel.Y + 20;
|
||||
|
||||
var w = panel.Width - 40;
|
||||
var h = panel.Height - 20;
|
||||
|
||||
var xx = x;
|
||||
var yy = y;
|
||||
|
||||
var subIndex = 0;
|
||||
|
||||
var xMax = w / 65;
|
||||
var yMax = h / 110;
|
||||
|
||||
var max = xMax * yMax;
|
||||
|
||||
var range = Enumerable.Empty<FileSystemInfo>()
|
||||
.Union(SelectedDirectory.EnumerateDirectories().OrderByNatural(d => d.Name))
|
||||
.Union(SelectedDirectory.EnumerateFiles().OrderByNatural(f => f.Name));
|
||||
|
||||
foreach (var info in range.Take(max))
|
||||
{
|
||||
// 65 x 110
|
||||
if (info is DirectoryInfo)
|
||||
{
|
||||
var dir = (DirectoryInfo)info;
|
||||
|
||||
// 56 x 80
|
||||
AddButton(xx, yy, 9810, 9810, b => SelectDirectory(dir)); // 56 x 50
|
||||
AddHtml(xx, yy + 50, 56, 40, info.Name.WrapUOHtmlCenter(), false, false); // 56 x 40
|
||||
}
|
||||
else if (info is FileInfo)
|
||||
{
|
||||
var file = (FileInfo)info;
|
||||
|
||||
// 56 x 80
|
||||
AddButton(xx + 5, yy, 2234, 2234, b => SelectFile(file)); // 46 x 50
|
||||
AddHtml(xx, yy + 50, 56, 40, info.Name.WrapUOHtmlCenter(), false, false); // 56 x 40
|
||||
}
|
||||
|
||||
if (++subIndex % xMax == 0)
|
||||
{
|
||||
xx = x;
|
||||
yy += 110;
|
||||
}
|
||||
else
|
||||
{
|
||||
xx += 65;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 310 x 350
|
||||
protected virtual void RenderFilePanel(Rectangle panel, int index, TreeGumpNode node)
|
||||
{
|
||||
if (FileMime.IsCommonText(SelectedFile))
|
||||
{
|
||||
var content = File.ReadAllText(SelectedFile.FullName);
|
||||
|
||||
AddHtml(panel.X, panel.Y, panel.Width, panel.Height, content, HtmlColor, Color.Black);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnSelected(TreeGumpNode oldNode, TreeGumpNode newNode)
|
||||
{
|
||||
var path = GetPath(newNode);
|
||||
|
||||
if (Directory.Exists(path))
|
||||
{
|
||||
SelectedDirectory = new DirectoryInfo(path);
|
||||
}
|
||||
|
||||
SelectedFile = null;
|
||||
|
||||
base.OnSelected(oldNode, newNode);
|
||||
}
|
||||
|
||||
public void SelectDirectory(DirectoryInfo dir)
|
||||
{
|
||||
var path = GetPath(dir);
|
||||
|
||||
var node = List.FirstOrDefault(n => n == path);
|
||||
|
||||
if (node != null)
|
||||
{
|
||||
SelectedNode = node;
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectedNode = path;
|
||||
}
|
||||
|
||||
SelectedDirectory = dir;
|
||||
SelectedFile = null;
|
||||
|
||||
Refresh(true);
|
||||
}
|
||||
|
||||
public void SelectFile(FileInfo file)
|
||||
{
|
||||
var path = GetPath(file.Directory);
|
||||
|
||||
var node = List.FirstOrDefault(n => n == path);
|
||||
|
||||
if (node != null)
|
||||
{
|
||||
SelectedNode = node;
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectedNode = path;
|
||||
}
|
||||
|
||||
SelectedDirectory = file.Directory;
|
||||
SelectedFile = file;
|
||||
|
||||
Refresh(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
376
Scripts/SubSystem/VitaNex/Core/SuperGumps/UI/Lists/Tree/Tree.cs
Normal file
376
Scripts/SubSystem/VitaNex/Core/SuperGumps/UI/Lists/Tree/Tree.cs
Normal file
@@ -0,0 +1,376 @@
|
||||
#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.Collections;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps.UI
|
||||
{
|
||||
public abstract class TreeGump : SuperGumpList<TreeGumpNode>
|
||||
{
|
||||
public static string DefaultTitle = "Tree View";
|
||||
|
||||
public string Title { get; set; }
|
||||
public Color TitleColor { get; set; }
|
||||
|
||||
public Color HtmlColor { get; set; }
|
||||
|
||||
public TreeGumpNode SelectedNode { get; set; }
|
||||
|
||||
public int Width { get; set; }
|
||||
public int Height { get; set; }
|
||||
|
||||
public virtual Dictionary<TreeGumpNode, Action<Rectangle, int, TreeGumpNode>> Nodes { get; private set; }
|
||||
|
||||
public TreeGump(
|
||||
Mobile user,
|
||||
Gump parent = null,
|
||||
int? x = null,
|
||||
int? y = null,
|
||||
IEnumerable<TreeGumpNode> nodes = null,
|
||||
TreeGumpNode selected = null,
|
||||
string title = null)
|
||||
: base(user, parent, x, y, nodes)
|
||||
{
|
||||
Nodes = new Dictionary<TreeGumpNode, Action<Rectangle, int, TreeGumpNode>>();
|
||||
|
||||
Title = title ?? DefaultTitle;
|
||||
TitleColor = DefaultHtmlColor;
|
||||
|
||||
HtmlColor = DefaultHtmlColor;
|
||||
|
||||
HighlightHue = 1258;
|
||||
TextHue = 1153;
|
||||
|
||||
Width = 600;
|
||||
Height = 400;
|
||||
|
||||
SelectedNode = selected ?? String.Empty;
|
||||
|
||||
ForceRecompile = true;
|
||||
CanMove = true;
|
||||
Sorted = true;
|
||||
}
|
||||
|
||||
protected override void Compile()
|
||||
{
|
||||
Width = Math.Max(600, Width);
|
||||
Height = Math.Max(400, Height);
|
||||
|
||||
EntriesPerPage = (int)Math.Floor((Height - 88) / 22.0);
|
||||
|
||||
if (Nodes == null)
|
||||
{
|
||||
Nodes = new Dictionary<TreeGumpNode, Action<Rectangle, int, TreeGumpNode>>();
|
||||
}
|
||||
|
||||
CompileNodes(Nodes);
|
||||
|
||||
base.Compile();
|
||||
}
|
||||
|
||||
protected virtual void CompileNodes(Dictionary<TreeGumpNode, Action<Rectangle, int, TreeGumpNode>> list)
|
||||
{ }
|
||||
|
||||
protected override void CompileList(List<TreeGumpNode> list)
|
||||
{
|
||||
foreach (var n in Nodes.Keys)
|
||||
{
|
||||
list.Update(n);
|
||||
}
|
||||
|
||||
var nodes = ListPool<TreeGumpNode>.AcquireObject();
|
||||
var selected = ListPool<TreeGumpNode>.AcquireObject();
|
||||
var parents = ListPool<TreeGumpNode>.AcquireObject();
|
||||
|
||||
nodes.Capacity = list.Count;
|
||||
|
||||
foreach (var n in list)
|
||||
{
|
||||
foreach (var p in n.GetParents())
|
||||
{
|
||||
nodes.Update(p);
|
||||
}
|
||||
|
||||
nodes.Update(n);
|
||||
}
|
||||
|
||||
if (SelectedNode.HasParent)
|
||||
{
|
||||
nodes.Update(SelectedNode.Parent);
|
||||
}
|
||||
|
||||
selected.AddRange(SelectedNode.GetParents());
|
||||
|
||||
nodes.RemoveAll(
|
||||
c =>
|
||||
{
|
||||
parents.AddRange(c.GetParents());
|
||||
|
||||
var remove = false;
|
||||
|
||||
if (parents.Count > 0)
|
||||
{
|
||||
if (parents.Count <= selected.Count && c != SelectedNode && !parents.Contains(SelectedNode) &&
|
||||
!selected.Any(p => p == c || c.Parent == p))
|
||||
{
|
||||
remove = true;
|
||||
}
|
||||
else if (parents.Count > selected.Count && c.Parent != SelectedNode)
|
||||
{
|
||||
remove = true;
|
||||
}
|
||||
}
|
||||
|
||||
parents.Clear();
|
||||
|
||||
return remove;
|
||||
});
|
||||
|
||||
list.Clear();
|
||||
list.AddRange(nodes);
|
||||
|
||||
ObjectPool.Free(ref nodes);
|
||||
ObjectPool.Free(ref selected);
|
||||
ObjectPool.Free(ref parents);
|
||||
|
||||
base.CompileList(list);
|
||||
}
|
||||
|
||||
public override int SortCompare(TreeGumpNode l, TreeGumpNode r)
|
||||
{
|
||||
var res = 0;
|
||||
|
||||
if (l.CompareNull(r, ref res))
|
||||
{
|
||||
return res;
|
||||
}
|
||||
|
||||
return Insensitive.Compare(l.FullName, r.FullName);
|
||||
}
|
||||
|
||||
protected override void CompileLayout(SuperGumpLayout layout)
|
||||
{
|
||||
base.CompileLayout(layout);
|
||||
|
||||
var sup = SupportsUltimaStore;
|
||||
var ec = IsEnhancedClient;
|
||||
var bgID = ec ? 83 : sup ? 40000 : 9270;
|
||||
|
||||
layout.Add(
|
||||
"body/bg",
|
||||
() =>
|
||||
{
|
||||
AddBackground(0, 43, Width, Height, 9260);
|
||||
AddImage(15, 18, 1419);
|
||||
AddBackground(15, 58, 235, 50, bgID);
|
||||
|
||||
if (!ec)
|
||||
{
|
||||
AddImageTiled(25, 68, 215, 30, 2624);
|
||||
}
|
||||
|
||||
AddImage(92, 0, 1417);
|
||||
});
|
||||
|
||||
layout.Add("body/mainbutton", () => AddButton(101, 9, 5545, 5546, MainButtonHandler));
|
||||
|
||||
layout.Add("panel/left", () => AddBackground(15, 115, 235, Height - 87, bgID));
|
||||
|
||||
layout.Add(
|
||||
"panel/left/overlay",
|
||||
() =>
|
||||
{
|
||||
if (!ec)
|
||||
{
|
||||
AddImageTiled(25, 125, 215, Height - 107, 2624);
|
||||
}
|
||||
});
|
||||
|
||||
CompileTreeLayout(layout);
|
||||
|
||||
layout.Add("panel/right", () => AddBackground(255, 58, Width - 270, Height - 30, bgID));
|
||||
|
||||
layout.Add(
|
||||
"panel/right/overlay",
|
||||
() =>
|
||||
{
|
||||
if (!ec)
|
||||
{
|
||||
AddImageTiled(265, 68, Width - 290, Height - 50, 2624);
|
||||
}
|
||||
});
|
||||
|
||||
layout.Add(
|
||||
"title",
|
||||
() => AddHtml(25, 78, 215, 40, Title.WrapUOHtmlCenter().WrapUOHtmlColor(TitleColor, false), false, false));
|
||||
|
||||
layout.Add("dragon", () => AddImage(Width - 33, 0, 10441, 0));
|
||||
|
||||
if (SelectedNode.IsEmpty)
|
||||
{
|
||||
CompileEmptyNodeLayout(layout, 265, 70, Width - 290, Height - 55, List.IndexOf(SelectedNode), SelectedNode);
|
||||
}
|
||||
else
|
||||
{
|
||||
CompileNodeLayout(layout, 265, 70, Width - 290, Height - 55, List.IndexOf(SelectedNode), SelectedNode);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void CompileTreeLayout(SuperGumpLayout layout)
|
||||
{
|
||||
var sup = SupportsUltimaStore;
|
||||
var ec = IsEnhancedClient;
|
||||
var bgID = ec ? 83 : sup ? 40000 : 9270;
|
||||
|
||||
layout.Add(
|
||||
"tree/scrollbar",
|
||||
() => AddScrollbarVM(25, 125, Height - 107, PageCount, Page, PreviousPage, NextPage));
|
||||
|
||||
var i = 0;
|
||||
|
||||
foreach (var c in EnumerateListRange())
|
||||
{
|
||||
var offset = Math.Min(150, c.Depth * 10);
|
||||
|
||||
CompileTreeEntryLayout(layout, 55 + offset, 125 + (21 * i), 175 - offset, 20, i++, c);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void CompileTreeEntryLayout(
|
||||
SuperGumpLayout layout,
|
||||
int x,
|
||||
int y,
|
||||
int w,
|
||||
int h,
|
||||
int index,
|
||||
TreeGumpNode node)
|
||||
{
|
||||
layout.Add(
|
||||
"tree/button/" + index,
|
||||
() => AddHtmlButton(x, y, w, h, btn => SelectNode(node), GetNodeName(node), GetNodeColor(node), Color.Black));
|
||||
}
|
||||
|
||||
protected virtual void CompileEmptyNodeLayout(
|
||||
SuperGumpLayout layout,
|
||||
int x,
|
||||
int y,
|
||||
int w,
|
||||
int h,
|
||||
int index,
|
||||
TreeGumpNode node)
|
||||
{ }
|
||||
|
||||
protected virtual void CompileNodeLayout(
|
||||
SuperGumpLayout layout,
|
||||
int x,
|
||||
int y,
|
||||
int w,
|
||||
int h,
|
||||
int index,
|
||||
TreeGumpNode node)
|
||||
{
|
||||
if (Nodes == null || Nodes.Count <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (Nodes.TryGetValue(node, out var nodeLayout) && nodeLayout != null)
|
||||
{
|
||||
var o = new Rectangle(x, y, w, h);
|
||||
|
||||
layout.Add("node/page/" + index, () => nodeLayout(o, index, node));
|
||||
}
|
||||
}
|
||||
|
||||
public override void InvalidatePageCount()
|
||||
{
|
||||
PageCount = 1 + Math.Max(0, List.Count - EntriesPerPage);
|
||||
Page = Math.Max(0, Math.Min(PageCount - 1, Page));
|
||||
}
|
||||
|
||||
public override Dictionary<int, TreeGumpNode> GetListRange()
|
||||
{
|
||||
return GetListRange(Page, EntriesPerPage);
|
||||
}
|
||||
|
||||
public virtual int GetNodeHue(TreeGumpNode node)
|
||||
{
|
||||
return node != null && SelectedNode != node && !SelectedNode.IsChildOf(node) ? TextHue : HighlightHue;
|
||||
}
|
||||
|
||||
public virtual Color GetNodeColor(TreeGumpNode node)
|
||||
{
|
||||
return node != null && SelectedNode != node && !SelectedNode.IsChildOf(node) ? Color.White : Color.Gold;
|
||||
}
|
||||
|
||||
public virtual string GetNodeName(TreeGumpNode node)
|
||||
{
|
||||
return node == null || String.IsNullOrWhiteSpace(node.Name) ? "..." : node.Name;
|
||||
}
|
||||
|
||||
public void SelectNode(TreeGumpNode node)
|
||||
{
|
||||
var old = SelectedNode;
|
||||
|
||||
if (SelectedNode != node)
|
||||
{
|
||||
SelectedNode = node;
|
||||
}
|
||||
else if (SelectedNode.HasParent)
|
||||
{
|
||||
SelectedNode = SelectedNode.Parent;
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectedNode = TreeGumpNode.Empty;
|
||||
}
|
||||
|
||||
OnSelected(old, SelectedNode);
|
||||
}
|
||||
|
||||
protected virtual void OnSelected(TreeGumpNode oldNode, TreeGumpNode newNode)
|
||||
{
|
||||
Refresh(true);
|
||||
}
|
||||
|
||||
protected virtual void MainButtonHandler(GumpButton b)
|
||||
{
|
||||
Refresh(true);
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
base.OnDispose();
|
||||
|
||||
VitaNexCore.TryCatch(Nodes.Clear);
|
||||
}
|
||||
|
||||
protected override void OnDisposed()
|
||||
{
|
||||
base.OnDisposed();
|
||||
|
||||
SelectedNode = null;
|
||||
|
||||
Nodes = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
#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.Linq;
|
||||
|
||||
using Server;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps.UI
|
||||
{
|
||||
public class TreeGumpNode : IEquatable<TreeGumpNode>, IEquatable<string>
|
||||
{
|
||||
public static char Separator = '|';
|
||||
|
||||
public static readonly TreeGumpNode Empty = new TreeGumpNode(String.Empty);
|
||||
|
||||
public TreeGumpNode Parent { get; private set; }
|
||||
|
||||
public TreeGumpNode RootParent
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!HasParent)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var p = Parent;
|
||||
|
||||
while (p.HasParent)
|
||||
{
|
||||
p = p.Parent;
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
public string Name { get; private set; }
|
||||
public string FullName { get; private set; }
|
||||
|
||||
public bool HasParent => Parent != null;
|
||||
|
||||
public bool IsRoot => !HasParent;
|
||||
public bool IsEmpty => String.IsNullOrWhiteSpace(FullName);
|
||||
|
||||
public int Depth => IsEmpty ? 0 : GetParents().Count();
|
||||
|
||||
public TreeGumpNode(string path)
|
||||
{
|
||||
FullName = path ?? String.Empty;
|
||||
|
||||
var parents = FullName.Split(new[] { Separator }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
if (parents.Length == 0)
|
||||
{
|
||||
Name = FullName;
|
||||
return;
|
||||
}
|
||||
|
||||
Name = parents.LastOrDefault() ?? FullName;
|
||||
|
||||
if (parents.Length > 1)
|
||||
{
|
||||
Parent = new TreeGumpNode(String.Join(Separator.ToString(), parents.Take(parents.Length - 1)));
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsChildOf(string d)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(d) || IsEmpty)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var p = Parent;
|
||||
|
||||
while (p != null)
|
||||
{
|
||||
if (p.FullName == d)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
p = p.Parent;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool IsChildOf(TreeGumpNode d)
|
||||
{
|
||||
if (d == null || d.IsEmpty || IsEmpty)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var p = Parent;
|
||||
|
||||
while (p != null)
|
||||
{
|
||||
if (p == d)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
p = p.Parent;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool IsParentOf(TreeGumpNode d)
|
||||
{
|
||||
return d != null && d.IsChildOf(this);
|
||||
}
|
||||
|
||||
public IEnumerable<TreeGumpNode> GetParents()
|
||||
{
|
||||
if (IsEmpty)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
var c = this;
|
||||
|
||||
while (c.HasParent)
|
||||
{
|
||||
c = c.Parent;
|
||||
|
||||
yield return c;
|
||||
}
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
if (IsEmpty)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
var hash = FullName.Length;
|
||||
hash = (hash * 397) ^ FullName.ToLower().GetHashCode();
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return (obj is string && Equals((string)obj)) || (obj is TreeGumpNode && Equals((TreeGumpNode)obj));
|
||||
}
|
||||
|
||||
public virtual bool Equals(TreeGumpNode other)
|
||||
{
|
||||
return !ReferenceEquals(other, null) && Equals(other.FullName);
|
||||
}
|
||||
|
||||
public virtual bool Equals(string other)
|
||||
{
|
||||
return Insensitive.Equals(FullName, other);
|
||||
}
|
||||
|
||||
public static bool operator ==(TreeGumpNode l, TreeGumpNode r)
|
||||
{
|
||||
return ReferenceEquals(l, null) ? ReferenceEquals(r, null) : l.Equals(r);
|
||||
}
|
||||
|
||||
public static bool operator !=(TreeGumpNode l, TreeGumpNode r)
|
||||
{
|
||||
return ReferenceEquals(l, null) ? !ReferenceEquals(r, null) : !l.Equals(r);
|
||||
}
|
||||
|
||||
public static bool operator >(TreeGumpNode l, TreeGumpNode r)
|
||||
{
|
||||
return !ReferenceEquals(l, null) && !ReferenceEquals(r, null) && r.IsChildOf(l);
|
||||
}
|
||||
|
||||
public static bool operator <(TreeGumpNode l, TreeGumpNode r)
|
||||
{
|
||||
return !ReferenceEquals(l, null) && !ReferenceEquals(r, null) && l.IsChildOf(r);
|
||||
}
|
||||
|
||||
public static bool operator >=(TreeGumpNode l, TreeGumpNode r)
|
||||
{
|
||||
return l == r || l > r;
|
||||
}
|
||||
|
||||
public static bool operator <=(TreeGumpNode l, TreeGumpNode r)
|
||||
{
|
||||
return l == r || l < r;
|
||||
}
|
||||
|
||||
public static implicit operator TreeGumpNode(string path)
|
||||
{
|
||||
return String.IsNullOrWhiteSpace(path) ? Empty : new TreeGumpNode(path);
|
||||
}
|
||||
|
||||
public static implicit operator string(TreeGumpNode node)
|
||||
{
|
||||
return ReferenceEquals(node, null) ? String.Empty : node.FullName;
|
||||
}
|
||||
}
|
||||
}
|
||||
275
Scripts/SubSystem/VitaNex/Core/SuperGumps/UI/Misc/AnalogClock.cs
Normal file
275
Scripts/SubSystem/VitaNex/Core/SuperGumps/UI/Misc/AnalogClock.cs
Normal file
@@ -0,0 +1,275 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#region References
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps.UI
|
||||
{
|
||||
public class AnalogClock : SuperGump
|
||||
{
|
||||
private static readonly Numeral[] _RomanNumerals = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
CommandUtility.Register("Clock", AccessLevel.Player, e => DisplayTo(e.Mobile));
|
||||
}
|
||||
|
||||
public static void DisplayTo(Mobile user)
|
||||
{
|
||||
var roman = EnumerateInstances<AnalogClock>(user).Any(g => g != null && !g.IsDisposed && g.RomanNumerals);
|
||||
|
||||
DisplayTo(user, !roman);
|
||||
}
|
||||
|
||||
public static void DisplayTo(Mobile user, bool roman)
|
||||
{
|
||||
if (user != null)
|
||||
{
|
||||
new AnalogClock(user)
|
||||
{
|
||||
RomanNumerals = roman
|
||||
}.Send();
|
||||
}
|
||||
}
|
||||
|
||||
public static int DefaultRadius = 40;
|
||||
|
||||
public static Color DefaultNumeralsColor = Color.Gold;
|
||||
public static Color DefaultHourHandColor = Color.Gainsboro;
|
||||
public static Color DefaultMinuteHandColor = Color.Gainsboro;
|
||||
public static Color DefaultSecondHandColor = Color.OrangeRed;
|
||||
|
||||
private TimeSpan? _LastTime;
|
||||
|
||||
public TimeSpan Time { get; set; }
|
||||
|
||||
public int Radius { get; set; }
|
||||
|
||||
public bool RomanNumerals { get; set; }
|
||||
|
||||
public bool DisplayNumerals { get; set; }
|
||||
public bool DisplayHourHand { get; set; }
|
||||
public bool DisplayMinuteHand { get; set; }
|
||||
public bool DisplaySecondHand { get; set; }
|
||||
|
||||
public Color ColorNumerals { get; set; }
|
||||
public Color ColorHourHand { get; set; }
|
||||
public Color ColorMinuteHand { get; set; }
|
||||
public Color ColorSecondHand { get; set; }
|
||||
|
||||
public bool RealTime { get; set; }
|
||||
|
||||
public AnalogClock(
|
||||
Mobile user,
|
||||
Gump parent = null,
|
||||
int? x = null,
|
||||
int? y = null,
|
||||
int radius = -1,
|
||||
TimeSpan? time = null)
|
||||
: base(user, parent, x, y)
|
||||
{
|
||||
Radius = radius <= 0 ? DefaultRadius : radius;
|
||||
|
||||
RomanNumerals = false;
|
||||
|
||||
DisplayNumerals = true;
|
||||
DisplayHourHand = true;
|
||||
DisplayMinuteHand = true;
|
||||
DisplaySecondHand = true;
|
||||
|
||||
ColorNumerals = DefaultNumeralsColor;
|
||||
ColorHourHand = DefaultHourHandColor;
|
||||
ColorMinuteHand = DefaultMinuteHandColor;
|
||||
ColorSecondHand = DefaultSecondHandColor;
|
||||
|
||||
if (time != null)
|
||||
{
|
||||
Time = time.Value;
|
||||
RealTime = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Time = DateTime.Now.TimeOfDay;
|
||||
RealTime = true;
|
||||
}
|
||||
|
||||
ForceRecompile = true;
|
||||
|
||||
AutoRefresh = RealTime;
|
||||
}
|
||||
|
||||
protected virtual void ComputeRefreshRate()
|
||||
{
|
||||
if (DisplaySecondHand)
|
||||
{
|
||||
AutoRefreshRate = TimeSpan.FromSeconds(1.0);
|
||||
}
|
||||
else if (DisplayMinuteHand)
|
||||
{
|
||||
AutoRefreshRate = TimeSpan.FromMinutes(1.0);
|
||||
}
|
||||
else if (DisplayHourHand)
|
||||
{
|
||||
AutoRefreshRate = TimeSpan.FromHours(1.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
AutoRefresh = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool OnBeforeSend()
|
||||
{
|
||||
ComputeRefreshRate();
|
||||
|
||||
return base.OnBeforeSend();
|
||||
}
|
||||
|
||||
protected override void OnAutoRefresh()
|
||||
{
|
||||
if (RealTime)
|
||||
{
|
||||
Time = DateTime.Now.TimeOfDay;
|
||||
}
|
||||
else if (_LastTime == Time)
|
||||
{
|
||||
_LastTime = (Time += DateTime.UtcNow - LastAutoRefresh);
|
||||
}
|
||||
|
||||
ComputeRefreshRate();
|
||||
|
||||
base.OnAutoRefresh();
|
||||
}
|
||||
|
||||
protected virtual void GetBounds(out int x, out int y, out int w, out int h)
|
||||
{
|
||||
x = y = 15;
|
||||
w = h = Radius * 2;
|
||||
}
|
||||
|
||||
protected override void CompileLayout(SuperGumpLayout layout)
|
||||
{
|
||||
base.CompileLayout(layout);
|
||||
|
||||
var sup = SupportsUltimaStore;
|
||||
var ec = IsEnhancedClient;
|
||||
var bgID = ec ? 83 : sup ? 40000 : 2620;
|
||||
|
||||
GetBounds(out var x, out var y, out var w, out var h);
|
||||
|
||||
var c = new Point2D(x + (w / 2), y + (h / 2));
|
||||
|
||||
layout.Add("clock/bg", () => AddBackground(x - 15, y - 15, w + 30, h + 30, bgID));
|
||||
|
||||
if (DisplayNumerals)
|
||||
{
|
||||
CompileNumerals(layout, c);
|
||||
}
|
||||
|
||||
if (DisplayHourHand)
|
||||
{
|
||||
CompileHourHand(layout, c);
|
||||
}
|
||||
|
||||
if (DisplayMinuteHand)
|
||||
{
|
||||
CompileMinuteHand(layout, c);
|
||||
}
|
||||
|
||||
if (DisplaySecondHand)
|
||||
{
|
||||
CompileSecondHand(layout, c);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void CompileHourHand(SuperGumpLayout layout, Point2D center)
|
||||
{
|
||||
layout.Add(
|
||||
"clock/hand/hour",
|
||||
() =>
|
||||
{
|
||||
var ha = 2.0f * Math.PI * (Time.Hours + Time.Minutes / 60.0f) / 12.0f;
|
||||
var hhp = center.Clone2D((int)(Radius * Math.Sin(ha) / 1.5f), (int)(-Radius * Math.Cos(ha) / 1.5f));
|
||||
|
||||
AddLine(center, hhp, ColorHourHand, 3);
|
||||
});
|
||||
}
|
||||
|
||||
protected virtual void CompileMinuteHand(SuperGumpLayout layout, Point2D center)
|
||||
{
|
||||
layout.Add(
|
||||
"clock/hand/minute",
|
||||
() =>
|
||||
{
|
||||
var ma = 2.0f * Math.PI * (Time.Minutes + Time.Seconds / 60.0f) / 60.0f;
|
||||
var mhp = center.Clone2D((int)(Radius * Math.Sin(ma)), (int)(-Radius * Math.Cos(ma)));
|
||||
|
||||
AddLine(center, mhp, ColorMinuteHand, 3);
|
||||
});
|
||||
}
|
||||
|
||||
protected virtual void CompileSecondHand(SuperGumpLayout layout, Point2D center)
|
||||
{
|
||||
layout.Add(
|
||||
"clock/hand/second",
|
||||
() =>
|
||||
{
|
||||
var sa = 2.0f * Math.PI * Time.Seconds / 60.0f;
|
||||
var shp = center.Clone2D((int)(Radius * Math.Sin(sa)), (int)(-Radius * Math.Cos(sa)));
|
||||
|
||||
AddLine(center, shp, ColorSecondHand, 1);
|
||||
});
|
||||
}
|
||||
|
||||
protected virtual void CompileNumerals(SuperGumpLayout layout, Point2D center)
|
||||
{
|
||||
for (var i = 1; i <= 12; i++)
|
||||
{
|
||||
CompileNumeral(layout, center, i);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void CompileNumeral(SuperGumpLayout layout, Point2D center, int num)
|
||||
{
|
||||
layout.Add(
|
||||
"clock/numeral/" + num,
|
||||
() =>
|
||||
{
|
||||
var x = center.X - (RomanNumerals ? 20 : 10);
|
||||
x += (int)(-1 * (Radius * Math.Cos((Math.PI / 180.0f) * (num * 30 + 90))));
|
||||
|
||||
var y = center.Y - 10;
|
||||
y += (int)(-1 * (Radius * Math.Sin((Math.PI / 180.0f) * (num * 30 + 90))));
|
||||
|
||||
var n = GetNumeralString(num).WrapUOHtmlCenter().WrapUOHtmlColor(ColorNumerals);
|
||||
|
||||
AddHtml(x, y, RomanNumerals ? 40 : 20, 40, n, false, false);
|
||||
});
|
||||
}
|
||||
|
||||
protected virtual string GetNumeralString(int num)
|
||||
{
|
||||
return (RomanNumerals ? GetRomanNumeral(num) : num.ToString()).WrapUOHtmlBold();
|
||||
}
|
||||
|
||||
protected virtual string GetRomanNumeral(int num)
|
||||
{
|
||||
return _RomanNumerals[num - 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
414
Scripts/SubSystem/VitaNex/Core/SuperGumps/UI/Misc/HueSelector.cs
Normal file
414
Scripts/SubSystem/VitaNex/Core/SuperGumps/UI/Misc/HueSelector.cs
Normal file
@@ -0,0 +1,414 @@
|
||||
#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 Server;
|
||||
using Server.Gumps;
|
||||
|
||||
using Ultima;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps.UI
|
||||
{
|
||||
public class HueSelector : SuperGump, IEnumerable<int>
|
||||
{
|
||||
public static int DefaultIcon = 4650;
|
||||
|
||||
private readonly Grid<int> _HueGrid = new Grid<int>
|
||||
{
|
||||
DefaultValue = -1
|
||||
};
|
||||
|
||||
private int[] _Hues = new int[0];
|
||||
|
||||
public virtual int ScrollX { get; set; }
|
||||
public virtual int ScrollY { get; set; }
|
||||
|
||||
public virtual int ScrollWidth { get; set; }
|
||||
public virtual int ScrollHeight { get; set; }
|
||||
|
||||
public virtual Action<int> AcceptCallback { get; set; }
|
||||
public virtual Action<int> CancelCallback { get; set; }
|
||||
|
||||
public virtual int this[int idx] => idx >= 0 && idx < _Hues.Length ? _Hues[idx] : -1;
|
||||
|
||||
public virtual int this[int x, int y] => x >= 0 && x < _HueGrid.Width && y >= 0 && y < _HueGrid.Height ? _HueGrid[x, y] : -1;
|
||||
|
||||
public virtual int[] Hues { get => _Hues; set => SetHues(value); }
|
||||
|
||||
public virtual int Selected { get; set; }
|
||||
|
||||
public virtual string Title { get; set; }
|
||||
|
||||
public virtual int PreviewIcon { get; set; }
|
||||
|
||||
public HueSelector(
|
||||
Mobile user,
|
||||
Gump parent = null,
|
||||
int? x = null,
|
||||
int? y = null,
|
||||
string title = "Color Chart",
|
||||
int[] hues = null,
|
||||
int selected = -1,
|
||||
Action<int> accept = null,
|
||||
Action<int> cancel = null)
|
||||
: base(user, parent, x, y)
|
||||
{
|
||||
CanDispose = false;
|
||||
|
||||
ScrollX = ScrollY = 0;
|
||||
ScrollWidth = ScrollHeight = 5;
|
||||
|
||||
Selected = selected;
|
||||
AcceptCallback = accept;
|
||||
CancelCallback = cancel;
|
||||
|
||||
Title = title ?? "Color Chart";
|
||||
|
||||
PreviewIcon = DefaultIcon;
|
||||
|
||||
SetHues(hues);
|
||||
}
|
||||
|
||||
public void SetHues(params int[] hues)
|
||||
{
|
||||
hues = hues ?? new int[0];
|
||||
|
||||
if (hues.Length == 0)
|
||||
{
|
||||
_Hues = hues;
|
||||
}
|
||||
else
|
||||
{
|
||||
var list = new List<int>(hues);
|
||||
|
||||
list.Prune();
|
||||
|
||||
_Hues = list.FreeToArray(true);
|
||||
}
|
||||
|
||||
_Hues.Sort();
|
||||
|
||||
var size = (int)Math.Ceiling(Math.Sqrt(_Hues.Length));
|
||||
|
||||
_HueGrid.DefaultValue = -1;
|
||||
_HueGrid.Resize(size, size);
|
||||
|
||||
int i = 0, gx, gy;
|
||||
|
||||
for (gy = 0; gy < size; gy++)
|
||||
{
|
||||
for (gx = 0; gx < size; gx++)
|
||||
{
|
||||
_HueGrid.SetContent(gx, gy, i < _Hues.Length ? _Hues[i] : -1);
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
if (IsOpen)
|
||||
{
|
||||
Refresh(true);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Compile()
|
||||
{
|
||||
if (_Hues.Length <= 0)
|
||||
{
|
||||
Selected = -1;
|
||||
}
|
||||
else if (!_Hues.Contains(Selected))
|
||||
{
|
||||
Selected = _Hues[0];
|
||||
}
|
||||
|
||||
base.Compile();
|
||||
}
|
||||
|
||||
protected override void CompileLayout(SuperGumpLayout layout)
|
||||
{
|
||||
base.CompileLayout(layout);
|
||||
|
||||
var sup = SupportsUltimaStore;
|
||||
var ec = IsEnhancedClient;
|
||||
var pad = ec || sup ? 15 : 10;
|
||||
var bgID = ec ? 83 : sup ? 40000 : 2620;
|
||||
|
||||
var w = 44 + (44 * ScrollWidth);
|
||||
var h = 44 + (44 * ScrollHeight);
|
||||
|
||||
w = Math.Max(176, w);
|
||||
h = Math.Max(176, h);
|
||||
|
||||
w += pad * 2;
|
||||
h += pad * 2;
|
||||
|
||||
/* Layout:
|
||||
* ___________
|
||||
* [___________|<]
|
||||
* | |O O O O |^|
|
||||
* | |O O O O | |
|
||||
* | |O O O O | |
|
||||
* | |________|v|
|
||||
* |__|<______>|>]
|
||||
*/
|
||||
|
||||
var width = 135 + w;
|
||||
var height = 70 + h;
|
||||
|
||||
layout.Add(
|
||||
"bg",
|
||||
() =>
|
||||
{
|
||||
AddBackground(0, 0, width, height, bgID);
|
||||
AddBackground(0, 35, 100, height - 35, bgID);
|
||||
AddBackground(100, 35, width - 135, height - 70, bgID);
|
||||
AddImageTiled(100 + pad, 35 + pad, width - (135 + (pad * 2)), height - (70 + (pad * 2)), bgID + 4);
|
||||
});
|
||||
|
||||
layout.Add(
|
||||
"title",
|
||||
() =>
|
||||
{
|
||||
var title = Title;
|
||||
|
||||
title = title.WrapUOHtmlBig();
|
||||
title = title.WrapUOHtmlColor(Color.Gold, false);
|
||||
|
||||
AddHtml(pad, pad, width - (pad * 2), 40, title, false, false);
|
||||
});
|
||||
|
||||
layout.Add(
|
||||
"preview",
|
||||
() =>
|
||||
{
|
||||
var label = GetHueLabel(Selected);
|
||||
|
||||
label = label.WrapUOHtmlBig();
|
||||
label = label.WrapUOHtmlCenter();
|
||||
label = label.WrapUOHtmlColor(Color.Gold, false);
|
||||
|
||||
AddHtml(pad, 35 + pad, 100 - (pad * 2), 40, label, false, false);
|
||||
|
||||
if (PreviewIcon >= 0)
|
||||
{
|
||||
var s = ArtExtUtility.GetImageSize(PreviewIcon);
|
||||
|
||||
if (Selected > 0)
|
||||
{
|
||||
AddItem((100 - s.Width) / 2, 35 + pad + 40, PreviewIcon, Selected);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddItem((100 - s.Width) / 2, 35 + pad + 40, PreviewIcon);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
CompileEntries(layout, 100 + pad, 35 + pad);
|
||||
|
||||
layout.Add(
|
||||
"scrollY",
|
||||
() =>
|
||||
{
|
||||
var value = Math.Max(0, (_HueGrid.Height + 1) - ScrollHeight);
|
||||
|
||||
AddScrollbarV(
|
||||
width - (16 + pad),
|
||||
35 + pad,
|
||||
value,
|
||||
ScrollY,
|
||||
b => ScrollUp(),
|
||||
b => ScrollDown(),
|
||||
new Rectangle(0, 20, 16, height - (110 + (pad * 2))),
|
||||
new Rectangle(0, 0, 16, 16),
|
||||
new Rectangle(0, 20 + (height - (110 + (pad * 2))) + 4, 16, 16),
|
||||
Tuple.Create(9354, 9304),
|
||||
Tuple.Create(5604, 5600, 5604),
|
||||
Tuple.Create(5606, 5602, 5606));
|
||||
});
|
||||
|
||||
layout.Add(
|
||||
"scrollX",
|
||||
() =>
|
||||
{
|
||||
var value = Math.Max(0, (_HueGrid.Width + 1) - ScrollWidth);
|
||||
|
||||
AddScrollbarH(
|
||||
100 + pad,
|
||||
height - (16 + pad),
|
||||
value,
|
||||
ScrollX,
|
||||
b => ScrollLeft(),
|
||||
b => ScrollRight(),
|
||||
new Rectangle(20, 0, width - (175 + (pad * 2)), 16),
|
||||
new Rectangle(0, 0, 16, 16),
|
||||
new Rectangle(20 + (width - (175 + (pad * 2))) + 4, 0, 16, 16),
|
||||
Tuple.Create(9354, 9304),
|
||||
Tuple.Create(5607, 5603, 5607),
|
||||
Tuple.Create(5605, 5601, 5605));
|
||||
});
|
||||
|
||||
layout.Add(
|
||||
"cancel",
|
||||
() =>
|
||||
{
|
||||
AddButton(width - (15 + pad), pad, 11410, 11411, OnCancel);
|
||||
AddTooltip(1006045);
|
||||
});
|
||||
|
||||
layout.Add(
|
||||
"accept",
|
||||
() =>
|
||||
{
|
||||
AddButton(width - (15 + pad), height - (15 + pad), 11400, 11401, OnAccept);
|
||||
AddTooltip(1006044);
|
||||
});
|
||||
}
|
||||
|
||||
protected virtual void CompileEntries(SuperGumpLayout layout, int x, int y)
|
||||
{
|
||||
var cells = _HueGrid.SelectCells(ScrollX, ScrollY, ScrollWidth, ScrollHeight);
|
||||
|
||||
int i = 0, gx, gy, xx, yy;
|
||||
|
||||
for (gy = 0, yy = y; gy < ScrollHeight; gy++, yy += 44)
|
||||
{
|
||||
for (gx = 0, xx = x; gx < ScrollWidth; gx++, xx += 44)
|
||||
{
|
||||
CompileEntry(layout, xx, yy, gx, gy, i++, cells.InBounds(gx, gy) ? cells[gx][gy] : -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void CompileEntry(SuperGumpLayout layout, int x, int y, int gx, int gy, int idx, int hue)
|
||||
{
|
||||
if (hue <= -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var sup = SupportsUltimaStore;
|
||||
var ec = IsEnhancedClient;
|
||||
var fillID = ec ? 87 : sup ? 40004 : 2624;
|
||||
|
||||
layout.Add(
|
||||
"entry/" + idx,
|
||||
() =>
|
||||
{
|
||||
const int itemID = 4011;
|
||||
|
||||
var s = Selected == hue;
|
||||
|
||||
AddButton(x, y, 2240, 2240, b => SelectEntry(gx, gy, idx, hue));
|
||||
AddImageTiled(x, y, 44, 44, fillID);
|
||||
|
||||
var o = ArtExtUtility.GetImageOffset(itemID);
|
||||
|
||||
if (s)
|
||||
{
|
||||
AddItem(x + o.X, y + o.Y + 5, itemID, 2050);
|
||||
AddItem(x + o.X, y + o.Y + 2, itemID, 2999);
|
||||
}
|
||||
else if (sup)
|
||||
{
|
||||
AddItem(x + o.X, y + o.Y + 5, itemID, 2999);
|
||||
}
|
||||
|
||||
if (hue > 0)
|
||||
{
|
||||
AddItem(x + o.X, y + o.Y, itemID, hue);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddItem(x + o.X, y + o.Y, itemID);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected virtual void SelectEntry(int gx, int gy, int idx, int hue)
|
||||
{
|
||||
Selected = hue;
|
||||
|
||||
OnSelected(gx, gy, idx, hue);
|
||||
}
|
||||
|
||||
protected virtual void OnSelected(int gx, int gy, int idx, int hue)
|
||||
{
|
||||
Refresh(true);
|
||||
}
|
||||
|
||||
public virtual void OnCancel(GumpButton b)
|
||||
{
|
||||
if (CancelCallback != null)
|
||||
{
|
||||
CancelCallback(Selected);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void OnAccept(GumpButton b)
|
||||
{
|
||||
if (AcceptCallback != null)
|
||||
{
|
||||
AcceptCallback(Selected);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void ScrollLeft()
|
||||
{
|
||||
ScrollX--;
|
||||
|
||||
Refresh(true);
|
||||
}
|
||||
|
||||
public virtual void ScrollRight()
|
||||
{
|
||||
ScrollX++;
|
||||
|
||||
Refresh(true);
|
||||
}
|
||||
|
||||
public virtual void ScrollUp()
|
||||
{
|
||||
ScrollY--;
|
||||
|
||||
Refresh(true);
|
||||
}
|
||||
|
||||
public virtual void ScrollDown()
|
||||
{
|
||||
ScrollY++;
|
||||
|
||||
Refresh(true);
|
||||
}
|
||||
|
||||
public virtual string GetHueLabel(int hue)
|
||||
{
|
||||
return hue <= 0 ? (Utility.RandomBool() ? "Cillit Bang" : "Industrial Bleach") : "N°. " + hue;
|
||||
}
|
||||
|
||||
public virtual IEnumerator<int> GetEnumerator()
|
||||
{
|
||||
return _Hues.GetEnumerator<int>();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
#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 Server;
|
||||
using Server.Accounting;
|
||||
using Server.Gumps;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps.UI
|
||||
{
|
||||
public class OffsetSelectorGump : SuperGump
|
||||
{
|
||||
public static Point DefaultOffset = Point.Empty;
|
||||
|
||||
private Point _Value;
|
||||
|
||||
public Point Value
|
||||
{
|
||||
get => _Value;
|
||||
set
|
||||
{
|
||||
if (_Value == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var oldValue = _Value;
|
||||
|
||||
_Value = value;
|
||||
|
||||
OnValueChanged(oldValue);
|
||||
}
|
||||
}
|
||||
|
||||
public int Cols { get; private set; }
|
||||
public int Rows { get; private set; }
|
||||
|
||||
public virtual Action<OffsetSelectorGump, Point> ValueChanged { get; set; }
|
||||
|
||||
public OffsetSelectorGump(
|
||||
Mobile user,
|
||||
Gump parent = null,
|
||||
Point? value = null,
|
||||
Action<OffsetSelectorGump, Point> valueChanged = null)
|
||||
: base(user, parent, 0, 0)
|
||||
{
|
||||
ForceRecompile = true;
|
||||
|
||||
CanMove = false;
|
||||
CanClose = true;
|
||||
CanDispose = true;
|
||||
|
||||
_Value = value ?? DefaultOffset;
|
||||
ValueChanged = valueChanged;
|
||||
|
||||
var hi = User.Account is Account ? ((Account)User.Account).HardwareInfo : null;
|
||||
|
||||
Cols = (hi != null ? hi.ScreenWidth : 1920) / 20;
|
||||
Rows = (hi != null ? hi.ScreenHeight : 1080) / 20;
|
||||
}
|
||||
|
||||
public override void AssignCollections()
|
||||
{
|
||||
var capacity = Cols * Rows;
|
||||
|
||||
if (Entries != null && Entries.Capacity < 0x20 + capacity)
|
||||
{
|
||||
Entries.Capacity = 0x20 + capacity;
|
||||
}
|
||||
|
||||
if (Buttons == null)
|
||||
{
|
||||
Buttons = new Dictionary<GumpButton, Action<GumpButton>>(capacity);
|
||||
}
|
||||
|
||||
base.AssignCollections();
|
||||
}
|
||||
|
||||
protected override bool OnBeforeSend()
|
||||
{
|
||||
User.SendMessage(0x55, "Generating Offset Selection Interface, please wait...");
|
||||
|
||||
return base.OnBeforeSend();
|
||||
}
|
||||
|
||||
protected virtual void OnValueChanged(Point oldValue)
|
||||
{
|
||||
if (ValueChanged != null)
|
||||
{
|
||||
ValueChanged(this, oldValue);
|
||||
}
|
||||
|
||||
Refresh();
|
||||
}
|
||||
|
||||
protected override void CompileLayout(SuperGumpLayout layout)
|
||||
{
|
||||
base.CompileLayout(layout);
|
||||
|
||||
layout.Add(
|
||||
"buttongrid/base",
|
||||
() =>
|
||||
{
|
||||
int x, y;
|
||||
|
||||
for (y = 0; y < Rows; y++)
|
||||
{
|
||||
for (x = 0; x < Cols; x++)
|
||||
{
|
||||
AddButton(x * 20, y * 20, 9028, 9021, OnSelectPoint);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
layout.Add("image/marker", () => AddImage(Value.X + 5, Value.Y, 9009));
|
||||
}
|
||||
|
||||
protected virtual void OnSelectPoint(GumpButton b)
|
||||
{
|
||||
Value = new Point(b.X, b.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,231 @@
|
||||
#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;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps.UI
|
||||
{
|
||||
public class SkillSelectionGump : ListGump<SkillName>
|
||||
{
|
||||
private static readonly SkillName[] _Skills = ((SkillName)0).GetValues<SkillName>();
|
||||
|
||||
public int Limit { get; set; }
|
||||
|
||||
public virtual Action<GumpButton> AcceptHandler { get; set; }
|
||||
public virtual Action<GumpButton> CancelHandler { get; set; }
|
||||
|
||||
public virtual Action<SkillName[]> Callback { get; set; }
|
||||
|
||||
public List<SkillName> SelectedSkills { get; set; }
|
||||
public List<SkillName> IgnoredSkills { get; set; }
|
||||
|
||||
public SkillSelectionGump(
|
||||
Mobile user,
|
||||
Gump parent = null,
|
||||
int limit = 1,
|
||||
Action<GumpButton> onAccept = null,
|
||||
Action<GumpButton> onCancel = null,
|
||||
Action<SkillName[]> callback = null,
|
||||
params SkillName[] ignoredSkills)
|
||||
: base(user, parent, emptyText: "No skills to display.", title: "Skill Selection")
|
||||
{
|
||||
EntriesPerPage = 30;
|
||||
|
||||
Limit = limit;
|
||||
Callback = callback;
|
||||
SelectedSkills = new List<SkillName>();
|
||||
IgnoredSkills = new List<SkillName>(ignoredSkills);
|
||||
|
||||
if (Limit > 0)
|
||||
{
|
||||
Title += ": (" + Limit + " Max)";
|
||||
}
|
||||
|
||||
AcceptHandler = onAccept;
|
||||
CancelHandler = onCancel;
|
||||
}
|
||||
|
||||
protected override void CompileList(List<SkillName> list)
|
||||
{
|
||||
List.Clear();
|
||||
|
||||
foreach (var skill in _Skills.Where(skill => !IgnoredSkills.Contains(skill)))
|
||||
{
|
||||
List.Add(skill);
|
||||
}
|
||||
|
||||
base.CompileList(list);
|
||||
|
||||
List.Sort((a, b) => Insensitive.Compare(a.GetName(), b.GetName()));
|
||||
}
|
||||
|
||||
protected override sealed void CompileMenuOptions(MenuGumpOptions list)
|
||||
{ }
|
||||
|
||||
protected override sealed void ShowOptionMenu(GumpButton button)
|
||||
{
|
||||
OnAccept(button);
|
||||
}
|
||||
|
||||
protected virtual void OnAccept(GumpButton button)
|
||||
{
|
||||
if (AcceptHandler != null)
|
||||
{
|
||||
AcceptHandler(button);
|
||||
}
|
||||
|
||||
if (Callback != null)
|
||||
{
|
||||
Callback(SelectedSkills.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnCancel(GumpButton button)
|
||||
{
|
||||
if (CancelHandler != null)
|
||||
{
|
||||
CancelHandler(button);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void CompileLayout(SuperGumpLayout layout)
|
||||
{
|
||||
base.CompileLayout(layout);
|
||||
|
||||
layout.Remove("button/header/options");
|
||||
|
||||
layout.Add("button/header/done", () => AddButton(15, 15, 248, 249, ShowOptionMenu));
|
||||
|
||||
if (Minimized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var sup = SupportsUltimaStore;
|
||||
var ec = IsEnhancedClient;
|
||||
var bgID = ec ? 83 : sup ? 40000 : 9270;
|
||||
|
||||
layout.Replace("background/body/base", () => AddBackground(0, 55, 420, 330, bgID));
|
||||
layout.Remove("imagetiled/body/vsep/0");
|
||||
}
|
||||
|
||||
protected override void CompileEntryLayout(
|
||||
SuperGumpLayout layout,
|
||||
int length,
|
||||
int index,
|
||||
int pIndex,
|
||||
int yOffset,
|
||||
SkillName entry)
|
||||
{
|
||||
var sup = SupportsUltimaStore;
|
||||
var bgID = sup ? 40000 : 9270;
|
||||
|
||||
var xOffset = 0;
|
||||
|
||||
if (pIndex < EntriesPerPage - 20)
|
||||
{
|
||||
xOffset = 10;
|
||||
}
|
||||
else if (pIndex < EntriesPerPage - 10)
|
||||
{
|
||||
xOffset = 145;
|
||||
yOffset = 70 + (pIndex - 10) * 30;
|
||||
}
|
||||
else if (pIndex < EntriesPerPage)
|
||||
{
|
||||
xOffset = 280;
|
||||
yOffset = 70 + (pIndex - 20) * 30;
|
||||
}
|
||||
|
||||
layout.Replace(
|
||||
"check/list/select/" + index,
|
||||
() => AddButton(
|
||||
xOffset,
|
||||
yOffset,
|
||||
5033,
|
||||
5033,
|
||||
b =>
|
||||
{
|
||||
if (SelectedSkills.Contains(entry))
|
||||
{
|
||||
SelectedSkills.Remove(entry);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SelectedSkills.Count < Limit)
|
||||
{
|
||||
SelectedSkills.Add(entry);
|
||||
}
|
||||
else
|
||||
{
|
||||
new NoticeDialogGump(User, Refresh(true))
|
||||
{
|
||||
Title = "Limit Reached",
|
||||
Html = "You have selected the maximum of " + Limit +
|
||||
" skills.\nIf you are happy with your selection, click the 'Okay' button."
|
||||
}.Send();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Refresh(true);
|
||||
}));
|
||||
|
||||
if (SelectedSkills.Contains(entry))
|
||||
{
|
||||
layout.Add(
|
||||
"imagetiled/list/entry/" + index,
|
||||
() =>
|
||||
{
|
||||
AddImageTiled(xOffset, yOffset, 128, 28, 3004);
|
||||
AddImageTiled(4 + xOffset, 4 + yOffset, 120, 20, bgID + 4);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
layout.Add("imagetiled/list/entry/" + index, () => AddImageTiled(xOffset, yOffset, 128, 28, bgID + 4));
|
||||
}
|
||||
|
||||
layout.Add(
|
||||
"html/list/entry/" + index,
|
||||
() => AddHtml(
|
||||
4 + xOffset,
|
||||
4 + yOffset,
|
||||
120,
|
||||
20,
|
||||
String.Format(
|
||||
"<center><big><basefont color=#{0:X6}>{1}</big></center>",
|
||||
(ushort)GetLabelHue(index, pIndex, entry),
|
||||
GetLabelText(index, pIndex, entry)),
|
||||
false,
|
||||
false));
|
||||
}
|
||||
|
||||
protected override string GetLabelText(int index, int pageIndex, SkillName entry)
|
||||
{
|
||||
return entry.GetName();
|
||||
}
|
||||
|
||||
protected override int GetLabelHue(int index, int pageIndex, SkillName entry)
|
||||
{
|
||||
return SelectedSkills.Contains(entry) ? Color.Cyan.ToRgb() : Color.White.ToRgb();
|
||||
}
|
||||
}
|
||||
}
|
||||
70
Scripts/SubSystem/VitaNex/Core/SuperGumps/UI/Panels/Html.cs
Normal file
70
Scripts/SubSystem/VitaNex/Core/SuperGumps/UI/Panels/Html.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
#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 Server;
|
||||
using Server.Gumps;
|
||||
|
||||
using VitaNex.Text;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps.UI
|
||||
{
|
||||
public class HtmlPanelGump<T> : PanelGump<T>
|
||||
{
|
||||
public virtual string Html { get; set; }
|
||||
public virtual Color HtmlColor { get; set; }
|
||||
public virtual bool HtmlBackground { get; set; }
|
||||
|
||||
public HtmlPanelGump(
|
||||
Mobile user,
|
||||
Gump parent = null,
|
||||
int? x = null,
|
||||
int? y = null,
|
||||
int width = 420,
|
||||
int height = 420,
|
||||
string html = null,
|
||||
string emptyText = null,
|
||||
string title = null,
|
||||
IEnumerable<ListGumpEntry> opts = null,
|
||||
T selected = default(T))
|
||||
: base(user, parent, x, y, width, height, emptyText, title, opts, selected)
|
||||
{
|
||||
HtmlColor = DefaultHtmlColor;
|
||||
HtmlBackground = false;
|
||||
|
||||
Html = html ?? String.Empty;
|
||||
}
|
||||
|
||||
protected override void CompileLayout(SuperGumpLayout layout)
|
||||
{
|
||||
base.CompileLayout(layout);
|
||||
|
||||
if (Minimized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
layout.Add(
|
||||
"html/body/base",
|
||||
() =>
|
||||
{
|
||||
var html = Html.ParseBBCode(HtmlColor);
|
||||
|
||||
AddHtml(15, 65, Width - 30, Height - 30, html, HtmlBackground, true);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
217
Scripts/SubSystem/VitaNex/Core/SuperGumps/UI/Panels/Panel.cs
Normal file
217
Scripts/SubSystem/VitaNex/Core/SuperGumps/UI/Panels/Panel.cs
Normal file
@@ -0,0 +1,217 @@
|
||||
#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;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps.UI
|
||||
{
|
||||
public class PanelGump<T> : SuperGump
|
||||
{
|
||||
private int _Width;
|
||||
private int _Height;
|
||||
|
||||
protected bool WasModal { get; set; }
|
||||
|
||||
public virtual string Title { get; set; }
|
||||
public virtual string EmptyText { get; set; }
|
||||
|
||||
public virtual bool Minimized { get; set; }
|
||||
|
||||
public virtual T Selected { get; set; }
|
||||
|
||||
public virtual MenuGumpOptions Options { get; set; }
|
||||
|
||||
public virtual int Width { get => _Width; set => _Width = Math.Max(250, Math.Min(1024, value)); }
|
||||
public virtual int Height { get => _Height; set => _Height = Math.Max(250, Math.Min(786, value)); }
|
||||
|
||||
public PanelGump(
|
||||
Mobile user,
|
||||
Gump parent = null,
|
||||
int? x = null,
|
||||
int? y = null,
|
||||
int width = 420,
|
||||
int height = 420,
|
||||
string emptyText = null,
|
||||
string title = null,
|
||||
IEnumerable<ListGumpEntry> opts = null,
|
||||
T selected = default(T))
|
||||
: base(user, parent, x, y)
|
||||
{
|
||||
Width = width;
|
||||
Height = height;
|
||||
Selected = selected;
|
||||
EmptyText = emptyText ?? "No entry to display.";
|
||||
Title = title ?? "Panel View";
|
||||
Minimized = false;
|
||||
CanMove = false;
|
||||
|
||||
if (opts != null)
|
||||
{
|
||||
Options = new MenuGumpOptions(opts);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Compile()
|
||||
{
|
||||
base.Compile();
|
||||
|
||||
if (Options == null)
|
||||
{
|
||||
Options = new MenuGumpOptions();
|
||||
}
|
||||
|
||||
CompileMenuOptions(Options);
|
||||
}
|
||||
|
||||
protected override void CompileLayout(SuperGumpLayout layout)
|
||||
{
|
||||
base.CompileLayout(layout);
|
||||
|
||||
var sup = SupportsUltimaStore;
|
||||
var ec = IsEnhancedClient;
|
||||
var bgID = ec ? 83 : sup ? 40000 : 9270;
|
||||
|
||||
layout.Add(
|
||||
"background/header/base",
|
||||
() =>
|
||||
{
|
||||
AddBackground(0, 0, Width, 50, bgID);
|
||||
|
||||
if (!ec)
|
||||
{
|
||||
AddImageTiled(10, 10, Width - 20, 30, 2624);
|
||||
//AddAlphaRegion(10, 10, Width - 20, 30);
|
||||
}
|
||||
});
|
||||
|
||||
layout.Add(
|
||||
"button/header/options",
|
||||
() =>
|
||||
{
|
||||
AddButton(15, 15, 2008, 2007, ShowOptionMenu);
|
||||
AddTooltip(1015326);
|
||||
});
|
||||
|
||||
layout.Add(
|
||||
"button/header/minimize",
|
||||
() =>
|
||||
{
|
||||
if (Minimized)
|
||||
{
|
||||
AddButton(Width - 30, 20, 10740, 10742, Maximize);
|
||||
AddTooltip(3002086);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddButton(Width - 30, 20, 10741, 10742, Minimize);
|
||||
AddTooltip(3002085);
|
||||
}
|
||||
});
|
||||
|
||||
layout.Add(
|
||||
"label/header/title",
|
||||
() => AddLabelCropped(90, 15, Width - 135, 20, GetTitleHue(), String.IsNullOrEmpty(Title) ? "Panel View" : Title));
|
||||
|
||||
if (Minimized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
layout.Add(
|
||||
"background/body/base",
|
||||
() =>
|
||||
{
|
||||
AddBackground(0, 50, Width, Height, bgID);
|
||||
|
||||
if (!ec)
|
||||
{
|
||||
AddImageTiled(10, 60, Width - 20, Height - 20, 2624);
|
||||
//AddAlphaRegion(10, 60, Width - 20, Height - 20);
|
||||
}
|
||||
});
|
||||
|
||||
if (Selected == null)
|
||||
{
|
||||
var text = String.IsNullOrEmpty(EmptyText) ? "No entry to display." : EmptyText;
|
||||
|
||||
layout.Add("label/list/empty", () => AddLabelCropped(15, 67, Width - 30, 20, ErrorHue, text));
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void Minimize(GumpButton entry = null)
|
||||
{
|
||||
Minimized = true;
|
||||
|
||||
if (Modal)
|
||||
{
|
||||
WasModal = true;
|
||||
}
|
||||
|
||||
Modal = false;
|
||||
|
||||
Refresh(true);
|
||||
}
|
||||
|
||||
protected virtual void Maximize(GumpButton entry = null)
|
||||
{
|
||||
Minimized = false;
|
||||
|
||||
if (WasModal)
|
||||
{
|
||||
Modal = true;
|
||||
}
|
||||
|
||||
WasModal = false;
|
||||
|
||||
Refresh(true);
|
||||
}
|
||||
|
||||
protected virtual int GetTitleHue()
|
||||
{
|
||||
return TextHue;
|
||||
}
|
||||
|
||||
protected virtual void ShowOptionMenu(GumpButton button)
|
||||
{
|
||||
if (User != null && !User.Deleted && Options != null && Options.Count >= 0)
|
||||
{
|
||||
Send(new MenuGump(User, Refresh(), Options, button));
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void CompileMenuOptions(MenuGumpOptions list)
|
||||
{
|
||||
if (Minimized)
|
||||
{
|
||||
list.Replace("Minimize", new ListGumpEntry("Maximize", Maximize));
|
||||
}
|
||||
else
|
||||
{
|
||||
list.Replace("Maximize", new ListGumpEntry("Minimize", Minimize));
|
||||
}
|
||||
|
||||
list.AppendEntry(new ListGumpEntry("Refresh", button => Refresh(true)));
|
||||
|
||||
if (CanClose)
|
||||
{
|
||||
list.AppendEntry(new ListGumpEntry("Exit", button => Close()));
|
||||
}
|
||||
|
||||
list.AppendEntry(new ListGumpEntry("Cancel", button => { }));
|
||||
}
|
||||
}
|
||||
}
|
||||
124
Scripts/SubSystem/VitaNex/Core/SuperGumps/UI/Panels/TextInput.cs
Normal file
124
Scripts/SubSystem/VitaNex/Core/SuperGumps/UI/Panels/TextInput.cs
Normal file
@@ -0,0 +1,124 @@
|
||||
#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;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.SuperGumps.UI
|
||||
{
|
||||
public class TextInputPanelGump<T> : PanelGump<T>
|
||||
{
|
||||
private int _Limit;
|
||||
|
||||
public virtual int Limit
|
||||
{
|
||||
get => _Limit;
|
||||
set
|
||||
{
|
||||
value = Math.Max(0, value);
|
||||
|
||||
if (_Limit == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_Limit = value;
|
||||
Refresh(true);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual string Input { get; set; }
|
||||
public virtual bool InputBackground { get; set; }
|
||||
|
||||
public bool Limited => (Limit > 0);
|
||||
|
||||
public Action<string> Callback { get; set; }
|
||||
|
||||
public TextInputPanelGump(
|
||||
Mobile user,
|
||||
Gump parent = null,
|
||||
int? x = null,
|
||||
int? y = null,
|
||||
int width = 420,
|
||||
int height = 420,
|
||||
string emptyText = null,
|
||||
string title = null,
|
||||
IEnumerable<ListGumpEntry> opts = null,
|
||||
T selected = default(T),
|
||||
string input = null,
|
||||
int limit = 0,
|
||||
Action<string> callback = null)
|
||||
: base(user, parent, x, y, width, height, emptyText, title, opts, selected)
|
||||
{
|
||||
InputBackground = true;
|
||||
|
||||
Input = input ?? String.Empty;
|
||||
_Limit = limit;
|
||||
Callback = callback;
|
||||
}
|
||||
|
||||
protected override void CompileLayout(SuperGumpLayout layout)
|
||||
{
|
||||
base.CompileLayout(layout);
|
||||
|
||||
if (Minimized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (InputBackground)
|
||||
{
|
||||
layout.Add("background/input/base", () => AddBackground(15, 65, Width - 30, Height - 30, 9350));
|
||||
}
|
||||
|
||||
if (Limited)
|
||||
{
|
||||
layout.Add(
|
||||
"textentry/body/base",
|
||||
() => AddTextEntryLimited(25, 75, Width - 40, Height - 40, TextHue, Input, Limit, ParseInput));
|
||||
}
|
||||
else
|
||||
{
|
||||
layout.Add("textentry/body/base", () => AddTextEntry(25, 75, Width - 40, Height - 40, TextHue, Input, ParseInput));
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void ParseInput(GumpTextEntry entry, string text)
|
||||
{
|
||||
ParseInput(text);
|
||||
}
|
||||
|
||||
protected virtual void ParseInput(GumpTextEntryLimited entry, string text)
|
||||
{
|
||||
ParseInput(text);
|
||||
}
|
||||
|
||||
protected virtual void ParseInput(string text)
|
||||
{
|
||||
Input = text ?? String.Empty;
|
||||
}
|
||||
|
||||
protected override void OnClick()
|
||||
{
|
||||
base.OnClick();
|
||||
|
||||
if (Callback != null)
|
||||
{
|
||||
Callback(Input);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user