ModernUO/Projects/Scripts/Gumps/ClientGump.cs
Kamron Batman 179cb50557 Updates Packets & Randomizer (#43)
* 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
2019-11-11 12:40:16 +01:00

299 lines
9.3 KiB
C#

using Server.Accounting;
using Server.Commands;
using Server.Commands.Generic;
using Server.Mobiles;
using Server.Network;
using Server.Targets;
namespace Server.Gumps
{
public class ClientGump : Gump
{
private const int LabelColor32 = 0xFFFFFF;
private NetState m_State;
public ClientGump(Mobile from, NetState state, string initialText = "") : base(30, 20)
{
if (state == null)
return;
m_State = state;
AddPage(0);
AddBackground(0, 0, 400, 274, 5054);
AddImageTiled(10, 10, 380, 19, 0xA40);
AddAlphaRegion(10, 10, 380, 19);
AddImageTiled(10, 32, 380, 232, 0xA40);
AddAlphaRegion(10, 32, 380, 232);
AddHtml(10, 10, 380, 20, Color(Center("User Information"), LabelColor32));
int line = 0;
AddHtml(14, 36 + line * 20, 200, 20, Color("Address:", LabelColor32));
AddHtml(70, 36 + line++ * 20, 200, 20, Color(state.ToString(), LabelColor32));
AddHtml(14, 36 + line * 20, 200, 20, Color("Client:", LabelColor32));
AddHtml(70, 36 + line++ * 20, 200, 20,
Color(state.Version == null ? "(null)" : state.Version.ToString(), LabelColor32));
AddHtml(14, 36 + line * 20, 200, 20, Color("Version:", LabelColor32));
ExpansionInfo info = state.ExpansionInfo;
string expansionName = info.Name;
AddHtml(70, 36 + line++ * 20, 200, 20, Color(expansionName, LabelColor32));
Account a = state.Account as Account;
Mobile m = state.Mobile;
if (from.AccessLevel >= AccessLevel.GameMaster && a != null)
{
AddHtml(14, 36 + line * 20, 200, 20, Color("Account:", LabelColor32));
AddHtml(70, 36 + line++ * 20, 200, 20, Color(a.Username, LabelColor32));
}
if (m != null)
{
AddHtml(14, 36 + line * 20, 200, 20, Color("Mobile:", LabelColor32));
AddHtml(70, 36 + line++ * 20, 200, 20, Color($"{m.Name} (0x{m.Serial.Value:X})", LabelColor32));
AddHtml(14, 36 + line * 20, 200, 20, Color("Location:", LabelColor32));
AddHtml(70, 36 + line++ * 20, 200, 20, Color($"{m.Location} [{m.Map}]", LabelColor32));
AddButton(13, 157, 0xFAB, 0xFAD, 1);
AddHtml(48, 158, 200, 20, Color("Send Message", LabelColor32));
AddImageTiled(12, 182, 376, 80, 0xA40);
AddImageTiled(13, 183, 374, 78, 0xBBC);
AddTextEntry(15, 183, 372, 78, 0x480, 0, "");
AddImageTiled(245, 35, 142, 144, 5058);
AddImageTiled(246, 36, 140, 142, 0xA40);
AddAlphaRegion(246, 36, 140, 142);
line = 0;
if (BaseCommand.IsAccessible(from, m))
{
AddButton(246, 36 + line * 20, 0xFA5, 0xFA7, 4);
AddHtml(280, 38 + line++ * 20, 100, 20, Color("Properties", LabelColor32));
}
if (from != m)
{
AddButton(246, 36 + line * 20, 0xFA5, 0xFA7, 5);
AddHtml(280, 38 + line++ * 20, 100, 20, Color("Go to them", LabelColor32));
AddButton(246, 36 + line * 20, 0xFA5, 0xFA7, 6);
AddHtml(280, 38 + line++ * 20, 100, 20, Color("Bring them here", LabelColor32));
}
AddButton(246, 36 + line * 20, 0xFA5, 0xFA7, 7);
AddHtml(280, 38 + line++ * 20, 100, 20, Color("Move to target", LabelColor32));
if (from.AccessLevel >= AccessLevel.GameMaster && from.AccessLevel > m.AccessLevel)
{
AddButton(246, 36 + line * 20, 0xFA5, 0xFA7, 8);
AddHtml(280, 38 + line++ * 20, 100, 20, Color("Disconnect", LabelColor32));
if (m.Alive)
{
AddButton(246, 36 + line * 20, 0xFA5, 0xFA7, 9);
AddHtml(280, 38 + line++ * 20, 100, 20, Color("Kill", LabelColor32));
}
else
{
AddButton(246, 36 + line * 20, 0xFA5, 0xFA7, 10);
AddHtml(280, 38 + line++ * 20, 100, 20, Color("Resurrect", LabelColor32));
}
}
if (from.AccessLevel >= AccessLevel.Counselor && from.AccessLevel > m.AccessLevel)
{
AddButton(246, 36 + line * 20, 0xFA5, 0xFA7, 11);
AddHtml(280, 38 + line++ * 20, 100, 20, Color("Skills browser", LabelColor32));
}
}
}
private void Resend(Mobile to, RelayInfo info)
{
TextRelay te = info.GetTextEntry(0);
to.SendGump(new ClientGump(to, m_State, te == null ? "" : te.Text));
}
public override void OnResponse(NetState sender, RelayInfo info)
{
if (m_State == null)
return;
Mobile focus = m_State.Mobile;
Mobile from = sender.Mobile;
if (focus == null)
{
from.SendMessage("That character is no longer online.");
return;
}
if (focus.Deleted)
{
from.SendMessage("That character no longer exists.");
return;
}
if (from != focus && focus.Hidden && from.AccessLevel < focus.AccessLevel &&
(focus as PlayerMobile)?.VisibilityList.Contains(from) != true)
{
from.SendMessage("That character is no longer visible.");
return;
}
switch (info.ButtonID)
{
case 1: // Tell
{
TextRelay text = info.GetTextEntry(0);
if (text != null)
{
focus.SendMessage(0x482, "{0} tells you:", from.Name);
focus.SendMessage(0x482, text.Text);
CommandLogging.WriteLine(from, "{0} {1} telling {2} \"{3}\" ", from.AccessLevel,
CommandLogging.Format(from), CommandLogging.Format(focus), text.Text);
}
from.SendGump(new ClientGump(from, m_State));
break;
}
case 4: // Props
{
Resend(from, info);
if (!BaseCommand.IsAccessible(from, focus))
{
from.SendLocalizedMessage(500447); // That is not accessible.
}
else
{
from.SendGump(new PropertiesGump(from, focus));
CommandLogging.WriteLine(from, "{0} {1} opening properties gump of {2} ", from.AccessLevel,
CommandLogging.Format(from), CommandLogging.Format(focus));
}
break;
}
case 5: // Go to
{
if (focus.Map == null || focus.Map == Map.Internal)
{
from.SendMessage("That character is not in the world.");
}
else
{
from.MoveToWorld(focus.Location, focus.Map);
Resend(from, info);
CommandLogging.WriteLine(from, "{0} {1} going to {2}, Location {3}, Map {4}", from.AccessLevel,
CommandLogging.Format(from), CommandLogging.Format(focus), focus.Location, focus.Map);
}
break;
}
case 6: // Get
{
if (from.Map == null || from.Map == Map.Internal)
{
from.SendMessage("You cannot bring that person here.");
}
else
{
focus.MoveToWorld(from.Location, from.Map);
Resend(from, info);
CommandLogging.WriteLine(from, "{0} {1} bringing {2} to Location {3}, Map {4}", from.AccessLevel,
CommandLogging.Format(from), CommandLogging.Format(focus), from.Location, from.Map);
}
break;
}
case 7: // Move
{
from.Target = new MoveTarget(focus);
Resend(from, info);
break;
}
case 8: // Kick
{
if (from.AccessLevel >= AccessLevel.GameMaster && from.AccessLevel > focus.AccessLevel)
{
focus.Say("I've been kicked!");
m_State.Dispose();
CommandLogging.WriteLine(from, "{0} {1} kicking {2} ", from.AccessLevel, CommandLogging.Format(from),
CommandLogging.Format(focus));
}
break;
}
case 9: // Kill
{
if (from.AccessLevel >= AccessLevel.GameMaster && from.AccessLevel > focus.AccessLevel)
{
focus.Kill();
CommandLogging.WriteLine(from, "{0} {1} killing {2} ", from.AccessLevel, CommandLogging.Format(from),
CommandLogging.Format(focus));
}
Resend(from, info);
break;
}
case 10: //Res
{
if (from.AccessLevel >= AccessLevel.GameMaster && from.AccessLevel > focus.AccessLevel)
{
focus.PlaySound(0x214);
focus.FixedEffect(0x376A, 10, 16);
focus.Resurrect();
CommandLogging.WriteLine(from, "{0} {1} resurrecting {2} ", from.AccessLevel,
CommandLogging.Format(from), CommandLogging.Format(focus));
}
Resend(from, info);
break;
}
case 11: // Skills
{
Resend(from, info);
if (from.AccessLevel > focus.AccessLevel)
{
from.SendGump(new SkillsGump(from, focus));
CommandLogging.WriteLine(from, "{0} {1} Opening Skills gump of {2} ", from.AccessLevel,
CommandLogging.Format(from), CommandLogging.Format(focus));
}
break;
}
}
}
public string Center(string text) => $"<CENTER>{text}</CENTER>";
public string Color(string text, int color) => $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
}
}