Fixes formatting (#200)

This commit is contained in:
Kamron Batman 2020-08-25 18:53:35 -07:00 committed by GitHub
parent 1f651992d7
commit 86b7b3aed1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
209 changed files with 51326 additions and 50397 deletions

View file

@ -1,136 +1,136 @@
/***************************************************************************
* BaseMulti.cs
* -------------------
* begin : May 1, 2002
* copyright : (C) The RunUO Software Team
* email : info@runuo.com
*
* $Id$
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
using System;
namespace Server.Items
{
public abstract class BaseMulti : Item
{
public BaseMulti(int itemID) : base(itemID) => Movable = false;
public BaseMulti(Serial serial) : base(serial)
{
}
[CommandProperty(AccessLevel.GameMaster)]
public override int ItemID
{
get => base.ItemID;
set
{
if (base.ItemID != value)
{
var facet = Parent == null ? Map : null;
facet?.OnLeave(this);
base.ItemID = value;
facet?.OnEnter(this);
}
}
}
public override int LabelNumber
{
get
{
var mcl = Components;
if (mcl.List.Length > 0)
{
int id = mcl.List[0].ItemId;
if (id < 0x4000)
return 1020000 + id;
return 1078872 + id;
}
return base.LabelNumber;
}
}
public virtual bool AllowsRelativeDrop => false;
public virtual MultiComponentList Components => MultiData.GetComponents(ItemID);
[Obsolete("Replace with calls to OnLeave and OnEnter surrounding component invalidation.", true)]
public virtual void RefreshComponents()
{
if (Parent == null)
{
var facet = Map;
if (facet != null)
{
facet.OnLeave(this);
facet.OnEnter(this);
}
}
}
public override int GetMaxUpdateRange() => 22;
public override int GetUpdateRange(Mobile m) => 22;
public virtual bool Contains(Point2D p) => Contains(p.m_X, p.m_Y);
public virtual bool Contains(Point3D p) => Contains(p.m_X, p.m_Y);
public virtual bool Contains(IPoint3D p) => Contains(p.X, p.Y);
public virtual bool Contains(int x, int y)
{
var mcl = Components;
x -= X + mcl.Min.m_X;
y -= Y + mcl.Min.m_Y;
return x >= 0
&& x < mcl.Width
&& y >= 0
&& y < mcl.Height
&& mcl.Tiles[x][y].Length > 0;
}
public bool Contains(Mobile m) => m.Map == Map && Contains(m.X, m.Y);
public bool Contains(Item item) => item.Map == Map && Contains(item.X, item.Y);
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
writer.Write(1); // version
}
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
if (version == 0)
if (ItemID >= 0x4000)
ItemID -= 0x4000;
}
}
}
/***************************************************************************
* BaseMulti.cs
* -------------------
* begin : May 1, 2002
* copyright : (C) The RunUO Software Team
* email : info@runuo.com
*
* $Id$
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
using System;
namespace Server.Items
{
public abstract class BaseMulti : Item
{
public BaseMulti(int itemID) : base(itemID) => Movable = false;
public BaseMulti(Serial serial) : base(serial)
{
}
[CommandProperty(AccessLevel.GameMaster)]
public override int ItemID
{
get => base.ItemID;
set
{
if (base.ItemID != value)
{
var facet = Parent == null ? Map : null;
facet?.OnLeave(this);
base.ItemID = value;
facet?.OnEnter(this);
}
}
}
public override int LabelNumber
{
get
{
var mcl = Components;
if (mcl.List.Length > 0)
{
int id = mcl.List[0].ItemId;
if (id < 0x4000)
return 1020000 + id;
return 1078872 + id;
}
return base.LabelNumber;
}
}
public virtual bool AllowsRelativeDrop => false;
public virtual MultiComponentList Components => MultiData.GetComponents(ItemID);
[Obsolete("Replace with calls to OnLeave and OnEnter surrounding component invalidation.", true)]
public virtual void RefreshComponents()
{
if (Parent == null)
{
var facet = Map;
if (facet != null)
{
facet.OnLeave(this);
facet.OnEnter(this);
}
}
}
public override int GetMaxUpdateRange() => 22;
public override int GetUpdateRange(Mobile m) => 22;
public virtual bool Contains(Point2D p) => Contains(p.m_X, p.m_Y);
public virtual bool Contains(Point3D p) => Contains(p.m_X, p.m_Y);
public virtual bool Contains(IPoint3D p) => Contains(p.X, p.Y);
public virtual bool Contains(int x, int y)
{
var mcl = Components;
x -= X + mcl.Min.m_X;
y -= Y + mcl.Min.m_Y;
return x >= 0
&& x < mcl.Width
&& y >= 0
&& y < mcl.Height
&& mcl.Tiles[x][y].Length > 0;
}
public bool Contains(Mobile m) => m.Map == Map && Contains(m.X, m.Y);
public bool Contains(Item item) => item.Map == Map && Contains(item.X, item.Y);
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
writer.Write(1); // version
}
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
if (version == 0)
if (ItemID >= 0x4000)
ItemID -= 0x4000;
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,132 +1,137 @@
/***************************************************************************
* Containers.cs
* -------------------
* begin : May 1, 2002
* copyright : (C) The RunUO Software Team
* email : info@runuo.com
*
* $Id$
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
using Server.Accounting;
using Server.Network;
namespace Server.Items
{
public class BankBox : Container
{
public BankBox(Serial serial) : base(serial)
{
}
public BankBox(Mobile owner) : base(0xE7C)
{
Layer = Layer.Bank;
Movable = false;
Owner = owner;
}
public override int DefaultMaxWeight => 0;
public override bool IsVirtualItem => true;
public Mobile Owner { get; private set; }
public bool Opened { get; private set; }
public static bool SendDeleteOnClose { get; set; }
public void Open()
{
Opened = true;
if (Owner != null)
{
Owner.PrivateOverheadMessage(MessageType.Regular, 0x3B2, true,
$"Bank container has {TotalItems} items, {TotalWeight} stones", Owner.NetState);
Owner.Send(new EquipUpdate(this));
DisplayTo(Owner);
}
}
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
writer.Write(Owner);
writer.Write(Opened);
}
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
switch (version)
{
case 0:
{
Owner = reader.ReadMobile();
Opened = reader.ReadBool();
if (Owner == null)
Delete();
break;
}
}
if (ItemID == 0xE41)
ItemID = 0xE7C;
}
public void Close()
{
Opened = false;
if (SendDeleteOnClose)
Owner?.Send(RemovePacket);
}
public override void OnSingleClick(Mobile from)
{
}
public override void OnDoubleClick(Mobile from)
{
}
public override DeathMoveResult OnParentDeath(Mobile parent) => DeathMoveResult.RemainEquipped;
public override bool IsAccessibleTo(Mobile check) =>
((check == Owner && Opened) || check.AccessLevel >= AccessLevel.GameMaster) && base.IsAccessibleTo(check);
public override bool OnDragDrop(Mobile from, Item dropped) =>
((from == Owner && Opened) || from.AccessLevel >= AccessLevel.GameMaster) && base.OnDragDrop(from, dropped);
public override bool OnDragDropInto(Mobile from, Item item, Point3D p) =>
((from == Owner && Opened) || from.AccessLevel >= AccessLevel.GameMaster) &&
base.OnDragDropInto(from, item, p);
public override int GetTotal(TotalType type)
{
if (AccountGold.Enabled && Owner?.Account != null && type == TotalType.Gold)
return Owner.Account.TotalGold;
return base.GetTotal(type);
}
}
}
/***************************************************************************
* Containers.cs
* -------------------
* begin : May 1, 2002
* copyright : (C) The RunUO Software Team
* email : info@runuo.com
*
* $Id$
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
using Server.Accounting;
using Server.Network;
namespace Server.Items
{
public class BankBox : Container
{
public BankBox(Serial serial) : base(serial)
{
}
public BankBox(Mobile owner) : base(0xE7C)
{
Layer = Layer.Bank;
Movable = false;
Owner = owner;
}
public override int DefaultMaxWeight => 0;
public override bool IsVirtualItem => true;
public Mobile Owner { get; private set; }
public bool Opened { get; private set; }
public static bool SendDeleteOnClose { get; set; }
public void Open()
{
Opened = true;
if (Owner != null)
{
Owner.PrivateOverheadMessage(
MessageType.Regular,
0x3B2,
true,
$"Bank container has {TotalItems} items, {TotalWeight} stones",
Owner.NetState
);
Owner.Send(new EquipUpdate(this));
DisplayTo(Owner);
}
}
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
writer.Write(Owner);
writer.Write(Opened);
}
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
switch (version)
{
case 0:
{
Owner = reader.ReadMobile();
Opened = reader.ReadBool();
if (Owner == null)
Delete();
break;
}
}
if (ItemID == 0xE41)
ItemID = 0xE7C;
}
public void Close()
{
Opened = false;
if (SendDeleteOnClose)
Owner?.Send(RemovePacket);
}
public override void OnSingleClick(Mobile from)
{
}
public override void OnDoubleClick(Mobile from)
{
}
public override DeathMoveResult OnParentDeath(Mobile parent) => DeathMoveResult.RemainEquipped;
public override bool IsAccessibleTo(Mobile check) =>
(check == Owner && Opened || check.AccessLevel >= AccessLevel.GameMaster) && base.IsAccessibleTo(check);
public override bool OnDragDrop(Mobile from, Item dropped) =>
(from == Owner && Opened || from.AccessLevel >= AccessLevel.GameMaster) && base.OnDragDrop(from, dropped);
public override bool OnDragDropInto(Mobile from, Item item, Point3D p) =>
(from == Owner && Opened || from.AccessLevel >= AccessLevel.GameMaster) &&
base.OnDragDropInto(from, item, p);
public override int GetTotal(TotalType type)
{
if (AccountGold.Enabled && Owner?.Account != null && type == TotalType.Gold)
return Owner.Account.TotalGold;
return base.GetTotal(type);
}
}
}

View file

@ -1,116 +1,116 @@
/***************************************************************************
* SecureTradeContainer.cs
* -------------------
* begin : May 1, 2002
* copyright : (C) The RunUO Software Team
* email : info@runuo.com
*
* $Id$
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
using Server.Accounting;
using Server.Network;
namespace Server.Items
{
public class SecureTradeContainer : Container
{
public SecureTradeContainer(SecureTrade trade) : base(0x1E5E)
{
Trade = trade;
Movable = false;
}
public SecureTradeContainer(Serial serial) : base(serial)
{
}
public SecureTrade Trade { get; }
public override bool CheckHold(Mobile m, Item item, bool message, bool checkItems, int plusItems, int plusWeight)
{
if (item == Trade.From.VirtualCheck || item == Trade.To.VirtualCheck) return true;
var to = Trade.From.Container != this ? Trade.From.Mobile : Trade.To.Mobile;
return m.CheckTrade(to, item, this, message, checkItems, plusItems, plusWeight);
}
public override bool CheckLift(Mobile from, Item item, ref LRReason reject)
{
reject = LRReason.CannotLift;
return false;
}
public override bool IsAccessibleTo(Mobile check) =>
IsChildOf(check) && Trade?.Valid == true && base.IsAccessibleTo(check);
public override void OnItemAdded(Item item)
{
if (!(item is VirtualCheck))
ClearChecks();
}
public override void OnItemRemoved(Item item)
{
if (!(item is VirtualCheck))
ClearChecks();
}
public override void OnSubItemAdded(Item item)
{
if (!(item is VirtualCheck))
ClearChecks();
}
public override void OnSubItemRemoved(Item item)
{
if (!(item is VirtualCheck))
ClearChecks();
}
public void ClearChecks()
{
if (Trade == null)
return;
if (Trade.From?.IsDisposed == false)
Trade.From.Accepted = false;
if (Trade.To?.IsDisposed == false)
Trade.To.Accepted = false;
Trade.Update();
}
public override bool IsChildVisibleTo(Mobile m, Item child) =>
child is VirtualCheck
? AccountGold.Enabled && m.NetState?.NewSecureTrading != true
: base.IsChildVisibleTo(m, child);
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
}
}
}
/***************************************************************************
* SecureTradeContainer.cs
* -------------------
* begin : May 1, 2002
* copyright : (C) The RunUO Software Team
* email : info@runuo.com
*
* $Id$
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
using Server.Accounting;
using Server.Network;
namespace Server.Items
{
public class SecureTradeContainer : Container
{
public SecureTradeContainer(SecureTrade trade) : base(0x1E5E)
{
Trade = trade;
Movable = false;
}
public SecureTradeContainer(Serial serial) : base(serial)
{
}
public SecureTrade Trade { get; }
public override bool CheckHold(Mobile m, Item item, bool message, bool checkItems, int plusItems, int plusWeight)
{
if (item == Trade.From.VirtualCheck || item == Trade.To.VirtualCheck) return true;
var to = Trade.From.Container != this ? Trade.From.Mobile : Trade.To.Mobile;
return m.CheckTrade(to, item, this, message, checkItems, plusItems, plusWeight);
}
public override bool CheckLift(Mobile from, Item item, ref LRReason reject)
{
reject = LRReason.CannotLift;
return false;
}
public override bool IsAccessibleTo(Mobile check) =>
IsChildOf(check) && Trade?.Valid == true && base.IsAccessibleTo(check);
public override void OnItemAdded(Item item)
{
if (!(item is VirtualCheck))
ClearChecks();
}
public override void OnItemRemoved(Item item)
{
if (!(item is VirtualCheck))
ClearChecks();
}
public override void OnSubItemAdded(Item item)
{
if (!(item is VirtualCheck))
ClearChecks();
}
public override void OnSubItemRemoved(Item item)
{
if (!(item is VirtualCheck))
ClearChecks();
}
public void ClearChecks()
{
if (Trade == null)
return;
if (Trade.From?.IsDisposed == false)
Trade.From.Accepted = false;
if (Trade.To?.IsDisposed == false)
Trade.To.Accepted = false;
Trade.Update();
}
public override bool IsChildVisibleTo(Mobile m, Item child) =>
child is VirtualCheck
? AccountGold.Enabled && m.NetState?.NewSecureTrading != true
: base.IsChildVisibleTo(m, child);
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
}
}
}

View file

@ -1,353 +1,353 @@
using Server.Gumps;
using Server.Network;
namespace Server.Items
{
public sealed class VirtualCheck : Item
{
// TODO: Move to configuration
public static bool UseEditGump = false;
private int m_Gold;
private int m_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 => m_Plat;
set
{
m_Plat = value;
InvalidateProperties();
}
}
[CommandProperty(AccessLevel.Administrator)]
public int Gold
{
get => m_Gold;
set
{
m_Gold = value;
InvalidateProperties();
}
}
public override bool IsAccessibleTo(Mobile check)
{
var 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)
{
var 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(IGenericWriter writer)
{
}
public override void Deserialize(IGenericReader reader)
{
Delete();
}
public class EditGump : Gump
{
public enum Buttons
{
Close,
Clear,
Accept,
AllPlat,
AllGold
}
private int m_Plat, m_Gold;
public EditGump(Mobile user, VirtualCheck check)
: base(50, 50)
{
User = user;
Check = check;
m_Plat = Check.Plat;
m_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);
var 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, m_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, m_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:
{
m_Plat = m_Gold = 0;
refresh = true;
}
break;
case Buttons.Accept:
{
var platText = info.GetTextEntry(0).Text;
var goldText = info.GetTextEntry(1).Text;
if (!int.TryParse(platText, out m_Plat))
{
User.SendMessage("That is not a valid amount of platinum.");
refresh = true;
}
else if (!int.TryParse(goldText, out m_Gold))
{
User.SendMessage("That is not a valid amount of gold.");
refresh = true;
}
else
{
var totalPlat = User.Account.TotalPlat;
var totalGold = User.Account.TotalGold;
if (totalPlat < m_Plat || totalGold < m_Gold)
{
m_Plat = User.Account.TotalPlat;
m_Gold = User.Account.TotalGold;
User.SendMessage("You do not have that much currency.");
refresh = true;
}
else
{
Check.Plat = m_Plat;
Check.Gold = m_Gold;
updated = true;
}
}
}
break;
case Buttons.AllPlat:
{
m_Plat = User.Account.TotalPlat;
refresh = true;
}
break;
case Buttons.AllGold:
{
m_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();
}
}
}
}
using Server.Gumps;
using Server.Network;
namespace Server.Items
{
public sealed class VirtualCheck : Item
{
// TODO: Move to configuration
public static bool UseEditGump = false;
private int m_Gold;
private int m_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 => m_Plat;
set
{
m_Plat = value;
InvalidateProperties();
}
}
[CommandProperty(AccessLevel.Administrator)]
public int Gold
{
get => m_Gold;
set
{
m_Gold = value;
InvalidateProperties();
}
}
public override bool IsAccessibleTo(Mobile check)
{
var 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)
{
var 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(IGenericWriter writer)
{
}
public override void Deserialize(IGenericReader reader)
{
Delete();
}
public class EditGump : Gump
{
public enum Buttons
{
Close,
Clear,
Accept,
AllPlat,
AllGold
}
private int m_Plat, m_Gold;
public EditGump(Mobile user, VirtualCheck check)
: base(50, 50)
{
User = user;
Check = check;
m_Plat = Check.Plat;
m_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);
var 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, m_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, m_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:
{
m_Plat = m_Gold = 0;
refresh = true;
}
break;
case Buttons.Accept:
{
var platText = info.GetTextEntry(0).Text;
var goldText = info.GetTextEntry(1).Text;
if (!int.TryParse(platText, out m_Plat))
{
User.SendMessage("That is not a valid amount of platinum.");
refresh = true;
}
else if (!int.TryParse(goldText, out m_Gold))
{
User.SendMessage("That is not a valid amount of gold.");
refresh = true;
}
else
{
var totalPlat = User.Account.TotalPlat;
var totalGold = User.Account.TotalGold;
if (totalPlat < m_Plat || totalGold < m_Gold)
{
m_Plat = User.Account.TotalPlat;
m_Gold = User.Account.TotalGold;
User.SendMessage("You do not have that much currency.");
refresh = true;
}
else
{
Check.Plat = m_Plat;
Check.Gold = m_Gold;
updated = true;
}
}
}
break;
case Buttons.AllPlat:
{
m_Plat = User.Account.TotalPlat;
refresh = true;
}
break;
case Buttons.AllGold:
{
m_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();
}
}
}
}

View file

@ -1,153 +1,153 @@
/***************************************************************************
* VirtualHair.cs
* -------------------
* begin : May 1, 2002
* copyright : (C) The RunUO Software Team
* email : info@runuo.com
*
* $Id$
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
using Server.Network;
namespace Server
{
public abstract class BaseHairInfo
{
protected BaseHairInfo(int itemid, int hue = 0)
{
ItemID = itemid;
Hue = hue;
}
protected BaseHairInfo(IGenericReader reader)
{
var version = reader.ReadInt();
switch (version)
{
case 0:
{
ItemID = reader.ReadInt();
Hue = reader.ReadInt();
break;
}
}
}
[CommandProperty(AccessLevel.GameMaster)]
public int ItemID { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public int Hue { get; set; }
public virtual void Serialize(IGenericWriter writer)
{
writer.Write(0); // version
writer.Write(ItemID);
writer.Write(Hue);
}
}
public class HairInfo : BaseHairInfo
{
public HairInfo(int itemid)
: base(itemid)
{
}
public HairInfo(int itemid, int hue)
: base(itemid, hue)
{
}
public HairInfo(IGenericReader reader)
: base(reader)
{
}
// TODO: Can we make this higher for newer clients?
public static uint FakeSerial(Mobile parent) => 0x7FFFFFFF - 0x400 - parent.Serial * 4;
}
public class FacialHairInfo : BaseHairInfo
{
public FacialHairInfo(int itemid)
: base(itemid)
{
}
public FacialHairInfo(int itemid, int hue)
: base(itemid, hue)
{
}
public FacialHairInfo(IGenericReader reader)
: base(reader)
{
}
// TOOD: Can we make this higher for newer clients?
public static uint FakeSerial(Mobile parent) => 0x7FFFFFFF - 0x400 - 1 - parent.Serial * 4;
}
public sealed class HairEquipUpdate : Packet
{
public HairEquipUpdate(Mobile parent)
: base(0x2E, 15)
{
var hue = parent.SolidHueOverride >= 0 ? parent.SolidHueOverride : parent.HairHue;
Stream.Write(HairInfo.FakeSerial(parent));
Stream.Write((short)parent.HairItemID);
Stream.Write((byte)0);
Stream.Write((byte)Layer.Hair);
Stream.Write(parent.Serial);
Stream.Write((short)hue);
}
}
public sealed class FacialHairEquipUpdate : Packet
{
public FacialHairEquipUpdate(Mobile parent)
: base(0x2E, 15)
{
var hue = parent.SolidHueOverride >= 0 ? parent.SolidHueOverride : parent.FacialHairHue;
Stream.Write(FacialHairInfo.FakeSerial(parent));
Stream.Write((short)parent.FacialHairItemID);
Stream.Write((byte)0);
Stream.Write((byte)Layer.FacialHair);
Stream.Write(parent.Serial);
Stream.Write((short)hue);
}
}
public sealed class RemoveHair : Packet
{
public RemoveHair(Mobile parent)
: base(0x1D, 5)
{
Stream.Write(HairInfo.FakeSerial(parent));
}
}
public sealed class RemoveFacialHair : Packet
{
public RemoveFacialHair(Mobile parent)
: base(0x1D, 5)
{
Stream.Write(FacialHairInfo.FakeSerial(parent));
}
}
}
/***************************************************************************
* VirtualHair.cs
* -------------------
* begin : May 1, 2002
* copyright : (C) The RunUO Software Team
* email : info@runuo.com
*
* $Id$
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
using Server.Network;
namespace Server
{
public abstract class BaseHairInfo
{
protected BaseHairInfo(int itemid, int hue = 0)
{
ItemID = itemid;
Hue = hue;
}
protected BaseHairInfo(IGenericReader reader)
{
var version = reader.ReadInt();
switch (version)
{
case 0:
{
ItemID = reader.ReadInt();
Hue = reader.ReadInt();
break;
}
}
}
[CommandProperty(AccessLevel.GameMaster)]
public int ItemID { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public int Hue { get; set; }
public virtual void Serialize(IGenericWriter writer)
{
writer.Write(0); // version
writer.Write(ItemID);
writer.Write(Hue);
}
}
public class HairInfo : BaseHairInfo
{
public HairInfo(int itemid)
: base(itemid)
{
}
public HairInfo(int itemid, int hue)
: base(itemid, hue)
{
}
public HairInfo(IGenericReader reader)
: base(reader)
{
}
// TODO: Can we make this higher for newer clients?
public static uint FakeSerial(Mobile parent) => 0x7FFFFFFF - 0x400 - parent.Serial * 4;
}
public class FacialHairInfo : BaseHairInfo
{
public FacialHairInfo(int itemid)
: base(itemid)
{
}
public FacialHairInfo(int itemid, int hue)
: base(itemid, hue)
{
}
public FacialHairInfo(IGenericReader reader)
: base(reader)
{
}
// TOOD: Can we make this higher for newer clients?
public static uint FakeSerial(Mobile parent) => 0x7FFFFFFF - 0x400 - 1 - parent.Serial * 4;
}
public sealed class HairEquipUpdate : Packet
{
public HairEquipUpdate(Mobile parent)
: base(0x2E, 15)
{
var hue = parent.SolidHueOverride >= 0 ? parent.SolidHueOverride : parent.HairHue;
Stream.Write(HairInfo.FakeSerial(parent));
Stream.Write((short)parent.HairItemID);
Stream.Write((byte)0);
Stream.Write((byte)Layer.Hair);
Stream.Write(parent.Serial);
Stream.Write((short)hue);
}
}
public sealed class FacialHairEquipUpdate : Packet
{
public FacialHairEquipUpdate(Mobile parent)
: base(0x2E, 15)
{
var hue = parent.SolidHueOverride >= 0 ? parent.SolidHueOverride : parent.FacialHairHue;
Stream.Write(FacialHairInfo.FakeSerial(parent));
Stream.Write((short)parent.FacialHairItemID);
Stream.Write((byte)0);
Stream.Write((byte)Layer.FacialHair);
Stream.Write(parent.Serial);
Stream.Write((short)hue);
}
}
public sealed class RemoveHair : Packet
{
public RemoveHair(Mobile parent)
: base(0x1D, 5)
{
Stream.Write(HairInfo.FakeSerial(parent));
}
}
public sealed class RemoveFacialHair : Packet
{
public RemoveFacialHair(Mobile parent)
: base(0x1D, 5)
{
Stream.Write(FacialHairInfo.FakeSerial(parent));
}
}
}