* Fixes a bug with the main loop. Removes unnecessary optimizations for RDRand. * WIP - Rewriting packets. * Cleanup and updates README * Converts more packets * Fixes header * Converts Effects packets. * Forgot the send command * Adds the start of containers packets. * Adds message packets with caching * Extends the send methods * Starts to add Acquire methods * Converted the packets * Cleanup * Cleanup * Adds more packets * Adds more packets * Fixes clearing arrays from pool. Adds Mobile Incoming * Converts more packets. * Moves more packets * Moves more packets * Test compression * Merges * Migrating to an idiomatic syntax that also supports compression, and proxying. * Optimize the stack alloc. Changes attributes * Converted container packets * Visual Studio doesn't auto save files. I am still getting used to subpar IDEs. * Adds static packet caching. Will profile later. Converts more packets * Fixes packets and changes how compression is configured * WIP - Adds basics for Gumps. Not finished though. * Fix file * Fixes formatting * Changed SpanWriter to be more idiomatic. * Fixes Span vs RawSpan and missing stackallocs * Converts over some more gumps * WIP - Deletes 32bit support. * Drops RDRand32 support. * Fixes gump compilation * Converting gump components * Removes old huffman compression function * Revert signature for backwards compatibility * WIP - Converting more gump components * Creates ArraySet for the strings. Updates AppendTo to reference that. * Converts the maining gump components * Cleans up gump components * Cleans up directives * Cleans up ArraySet and moves it. Adds null-coalescing-assignment * Cleanup, Target Packets, and C# 8 changes. * Removed OPL Packet * World packets * Fixing packet uses * Cleans up code. Fixes packet uses in various places. * More cleanup for packets * Code cleanup * Converts more packet uses and cleans up more code * More code cleanup * Finishes fixing the packets in Item * Updates secure trade packets * Updates core and gets it to compile. * Moved packets to scripts. Fixed account handler use of packets * Code cleanup * Updates chat packets * Code cleanuo * Adds party packets, but need to implement them. * Party packets WIP * Finishes party packets * Rearrange movement namespaces and classes * Finishes plant packets * Code Formatting * Fixes moving effects * Code cleanup, eliminates equipinfo * Adds more packets. Fixes bugs with various packets. * Finishes mahjon packets * Fixes mahjong packet * Code cleanup * Finishes mahjong packets * Adds Map packets * Add multifacet maps and charts * Cleans up some packets with UTF8 * Optimizes packets * Cleans up more packets. Moves the MessageHelper * Removes assistant support. Removes extended protocol. Incorporates MapUO packets as normal packets. * Updates protocol extensions packet receiver * Fixes a few bugs. Fixes a few more packets. * Code cleanup and fixing more packets * Fixes packet effects * Cleaned up more code * Buff Icon cleanup * Removed unused constructors * Code Cleanup. Adds BoatHS Packets * Moves house files. Updates house foundation packets. * Deployment cleanup * Fixes: * Code cleanup * More code cleanup * More code cleanup * Cleaned up BaseHouse * Enforces styling * Converts foreach to linq where possible. * Dont need that * Goals/Readme updates * Removes 32bit support at the highest level. Turns on HRT by default. * Code cleanup. Fixes extended features packet. * Fixes various bugs * Code cleanup * Code cleanup * Code cleanup. Fixes gump X/Y assignment. * Code cleanup using |= operator * More code cleanup * Cleanup * Fixes spacing issues. Thanks Visual Studio. You suck. * Compiler error * Fixes NPE from RunUO 2.7 * Renames ScriptCompiler to AssemblyHandler. Fixes packets. Updates README * Fixes more packets. Stupid trailing nulls. * Fixes various bugs. * Fixes for gumps * Fixes more gump stuff. Going to split it out later since it is getting insane * Recoded the gump writing * WIP * *Added output path of scripts project to dev branch *Activated debugging in code
352 lines
8.3 KiB
C#
352 lines
8.3 KiB
C#
using Server.Gumps;
|
|
using Server.Network;
|
|
|
|
namespace Server.Items
|
|
{
|
|
public sealed class VirtualCheck : Item
|
|
{
|
|
public static bool UseEditGump = false;
|
|
|
|
private int _Gold;
|
|
|
|
private int _Plat;
|
|
|
|
public VirtualCheck(int plat = 0, int gold = 0)
|
|
: base(0x14F0)
|
|
{
|
|
Plat = plat;
|
|
Gold = gold;
|
|
|
|
Movable = false;
|
|
}
|
|
|
|
public VirtualCheck(Serial serial)
|
|
: base(serial)
|
|
{
|
|
}
|
|
|
|
public override bool IsVirtualItem => true;
|
|
|
|
public override bool DisplayWeight => false;
|
|
public override bool DisplayLootType => false;
|
|
|
|
public override double DefaultWeight => 0;
|
|
|
|
public override string DefaultName => "Offer Of Currency";
|
|
|
|
public EditGump Editor { get; private set; }
|
|
|
|
[CommandProperty(AccessLevel.Administrator)]
|
|
public int Plat
|
|
{
|
|
get => _Plat;
|
|
set
|
|
{
|
|
_Plat = value;
|
|
InvalidateProperties();
|
|
}
|
|
}
|
|
|
|
[CommandProperty(AccessLevel.Administrator)]
|
|
public int Gold
|
|
{
|
|
get => _Gold;
|
|
set
|
|
{
|
|
_Gold = value;
|
|
InvalidateProperties();
|
|
}
|
|
}
|
|
|
|
public override bool IsAccessibleTo(Mobile check)
|
|
{
|
|
SecureTradeContainer c = GetSecureTradeCont();
|
|
|
|
if (check == null || c == null) return base.IsAccessibleTo(check);
|
|
|
|
return c.RootParent == check && IsChildOf(c);
|
|
}
|
|
|
|
public override void OnDoubleClickSecureTrade(Mobile from)
|
|
{
|
|
if (UseEditGump && IsAccessibleTo(from))
|
|
{
|
|
if (Editor?.Check?.Deleted != false)
|
|
{
|
|
Editor = new EditGump(from, this);
|
|
Editor.Send();
|
|
}
|
|
else
|
|
{
|
|
Editor.Refresh(true);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (Editor != null)
|
|
{
|
|
Editor.Close();
|
|
Editor = null;
|
|
}
|
|
|
|
base.OnDoubleClickSecureTrade(from);
|
|
}
|
|
}
|
|
|
|
public override void OnSingleClick(Mobile from)
|
|
{
|
|
LabelTo(from, "Offer: {0:#,0} platinum, {1:#,0} gold", Plat, Gold);
|
|
}
|
|
|
|
public override void GetProperties(ObjectPropertyList list)
|
|
{
|
|
base.GetProperties(list);
|
|
|
|
list.Add(1060738, $"{Plat:#,0} platinum, {Gold:#,0} gold"); // value: ~1_val~
|
|
}
|
|
|
|
public void UpdateTrade(Mobile user)
|
|
{
|
|
SecureTradeContainer c = GetSecureTradeCont();
|
|
|
|
if (c?.Trade == null) return;
|
|
|
|
if (user == c.Trade.From.Mobile)
|
|
c.Trade.UpdateFromCurrency();
|
|
else if (user == c.Trade.To.Mobile) c.Trade.UpdateToCurrency();
|
|
|
|
c.ClearChecks();
|
|
}
|
|
|
|
public override void OnAfterDelete()
|
|
{
|
|
base.OnAfterDelete();
|
|
|
|
if (Editor != null)
|
|
{
|
|
Editor.Close();
|
|
Editor = null;
|
|
}
|
|
}
|
|
|
|
public override void Serialize(GenericWriter writer)
|
|
{
|
|
}
|
|
|
|
public override void Deserialize(GenericReader reader)
|
|
{
|
|
Delete();
|
|
}
|
|
|
|
public class EditGump : Gump
|
|
{
|
|
public enum Buttons
|
|
{
|
|
Close,
|
|
Clear,
|
|
Accept,
|
|
AllPlat,
|
|
AllGold
|
|
}
|
|
|
|
private int _Plat, _Gold;
|
|
|
|
public EditGump(Mobile user, VirtualCheck check)
|
|
: base(50, 50)
|
|
{
|
|
User = user;
|
|
Check = check;
|
|
|
|
_Plat = Check.Plat;
|
|
_Gold = Check.Gold;
|
|
|
|
Closable = true;
|
|
Disposable = true;
|
|
Draggable = true;
|
|
Resizable = false;
|
|
|
|
User.CloseGump<EditGump>();
|
|
|
|
CompileLayout();
|
|
}
|
|
|
|
public Mobile User { get; }
|
|
public VirtualCheck Check { get; private set; }
|
|
|
|
public override void OnServerClose(NetState owner)
|
|
{
|
|
base.OnServerClose(owner);
|
|
|
|
if (Check?.Deleted == false)
|
|
Check.UpdateTrade(User);
|
|
}
|
|
|
|
public void Close()
|
|
{
|
|
User.CloseGump<EditGump>();
|
|
|
|
if (Check?.Deleted == false)
|
|
Check.UpdateTrade(User);
|
|
else
|
|
Check = null;
|
|
}
|
|
|
|
public void Send()
|
|
{
|
|
if (Check?.Deleted == false)
|
|
User.SendGump(this);
|
|
else
|
|
Close();
|
|
}
|
|
|
|
public void Refresh(bool recompile)
|
|
{
|
|
if (Check?.Deleted != false)
|
|
{
|
|
Close();
|
|
return;
|
|
}
|
|
|
|
if (recompile)
|
|
CompileLayout();
|
|
|
|
Close();
|
|
Send();
|
|
}
|
|
|
|
private void CompileLayout()
|
|
{
|
|
if (Check?.Deleted != false)
|
|
return;
|
|
|
|
Entries.ForEach(e => e.Parent = null);
|
|
Entries.Clear();
|
|
|
|
AddPage(0);
|
|
|
|
AddBackground(0, 0, 400, 160, 3500);
|
|
|
|
// Title
|
|
AddImageTiled(25, 35, 350, 3, 96);
|
|
AddImage(10, 8, 113);
|
|
AddImage(360, 8, 113);
|
|
|
|
string title =
|
|
$"<BASEFONT COLOR=#FF2F4F4F><CENTER>BANK OF {User.RawName.ToUpper()}</CENTER>";
|
|
|
|
AddHtml(40, 15, 320, 20, title);
|
|
|
|
// Platinum Row
|
|
AddBackground(15, 60, 175, 20, 9300);
|
|
AddBackground(20, 45, 165, 30, 9350);
|
|
AddItem(20, 45, 3826); // Plat
|
|
AddLabel(60, 50, 0, User.Account.TotalPlat.ToString("#,0"));
|
|
|
|
AddButton(195, 50, 95, 95, (int)Buttons.AllPlat); // ->
|
|
|
|
AddBackground(210, 60, 175, 20, 9300);
|
|
AddBackground(215, 45, 165, 30, 9350);
|
|
AddTextEntry(225, 50, 145, 20, 0, 0, _Plat.ToString(), User.Account.TotalPlat.ToString().Length);
|
|
|
|
// Gold Row
|
|
AddBackground(15, 100, 175, 20, 9300);
|
|
AddBackground(20, 85, 165, 30, 9350);
|
|
AddItem(20, 85, 3823); // Gold
|
|
AddLabel(60, 90, 0, User.Account.TotalGold.ToString("#,0"));
|
|
|
|
AddButton(195, 90, 95, 95, (int)Buttons.AllGold); // ->
|
|
|
|
AddBackground(210, 100, 175, 20, 9300);
|
|
AddBackground(215, 85, 165, 30, 9350);
|
|
AddTextEntry(225, 90, 145, 20, 0, 1, _Gold.ToString(), User.Account.TotalGold.ToString().Length);
|
|
|
|
// Buttons
|
|
AddButton(20, 128, 12006, 12007, (int)Buttons.Close);
|
|
AddButton(215, 128, 12003, 12004, (int)Buttons.Clear);
|
|
AddButton(305, 128, 12000, 12002, (int)Buttons.Accept);
|
|
}
|
|
|
|
public override void OnResponse(NetState sender, RelayInfo info)
|
|
{
|
|
if (Check?.Deleted != false || sender.Mobile != User)
|
|
{
|
|
Close();
|
|
return;
|
|
}
|
|
|
|
bool refresh = false, updated = false;
|
|
|
|
switch ((Buttons)info.ButtonID)
|
|
{
|
|
case Buttons.Close:
|
|
break;
|
|
case Buttons.Clear:
|
|
{
|
|
_Plat = _Gold = 0;
|
|
refresh = true;
|
|
}
|
|
break;
|
|
case Buttons.Accept:
|
|
{
|
|
string platText = info.GetTextEntry(0).Text;
|
|
string goldText = info.GetTextEntry(1).Text;
|
|
|
|
if (!int.TryParse(platText, out _Plat))
|
|
{
|
|
User.SendMessage("That is not a valid amount of platinum.");
|
|
refresh = true;
|
|
}
|
|
else if (!int.TryParse(goldText, out _Gold))
|
|
{
|
|
User.SendMessage("That is not a valid amount of gold.");
|
|
refresh = true;
|
|
}
|
|
else
|
|
{
|
|
int totalPlat = User.Account.TotalPlat;
|
|
int totalGold = User.Account.TotalGold;
|
|
|
|
if (totalPlat < _Plat || totalGold < _Gold)
|
|
{
|
|
_Plat = User.Account.TotalPlat;
|
|
_Gold = User.Account.TotalGold;
|
|
User.SendMessage("You do not have that much currency.");
|
|
refresh = true;
|
|
}
|
|
else
|
|
{
|
|
Check.Plat = _Plat;
|
|
Check.Gold = _Gold;
|
|
updated = true;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
case Buttons.AllPlat:
|
|
{
|
|
_Plat = User.Account.TotalPlat;
|
|
refresh = true;
|
|
}
|
|
break;
|
|
case Buttons.AllGold:
|
|
{
|
|
_Gold = User.Account.TotalGold;
|
|
refresh = true;
|
|
}
|
|
break;
|
|
}
|
|
|
|
if (updated)
|
|
User.SendMessage("Your offer has been updated.");
|
|
|
|
if (refresh && Check?.Deleted == false)
|
|
{
|
|
Refresh(true);
|
|
return;
|
|
}
|
|
|
|
Close();
|
|
}
|
|
}
|
|
}
|
|
}
|