ModernUO/Projects/Scripts/Engines/VeteranRewards/Character Statue Maker/Gumps/CharacterStatueGump.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

196 lines
5.6 KiB
C#

using Server.Mobiles;
using Server.Network;
namespace Server.Gumps
{
public class CharacterStatueGump : Gump
{
private Item m_Maker;
private Mobile m_Owner;
private CharacterStatue m_Statue;
public CharacterStatueGump(Item maker, CharacterStatue statue, Mobile owner) : base(60, 36)
{
m_Maker = maker;
m_Statue = statue;
m_Owner = owner;
if (m_Statue == null)
return;
Closable = true;
Disposable = true;
Draggable = true;
Resizable = false;
AddPage(0);
AddBackground(0, 0, 327, 324, 0x13BE);
AddImageTiled(10, 10, 307, 20, 0xA40);
AddImageTiled(10, 40, 307, 244, 0xA40);
AddImageTiled(10, 294, 307, 20, 0xA40);
AddAlphaRegion(10, 10, 307, 304);
AddHtmlLocalized(14, 12, 327, 20, 1076156, 0x7FFF); // Character Statue Maker
// pose
AddHtmlLocalized(133, 41, 120, 20, 1076168, 0x7FFF); // Choose Pose
AddHtmlLocalized(133, 61, 120, 20, 1076208 + (int)m_Statue.Pose, 0x77E);
AddButton(163, 81, 0xFA5, 0xFA7, (int)Buttons.PoseNext);
AddButton(133, 81, 0xFAE, 0xFB0, (int)Buttons.PosePrev);
// direction
AddHtmlLocalized(133, 126, 120, 20, 1076170, 0x7FFF); // Choose Direction
AddHtmlLocalized(133, 146, 120, 20, GetDirectionNumber(m_Statue.Direction), 0x77E);
AddButton(163, 167, 0xFA5, 0xFA7, (int)Buttons.DirNext);
AddButton(133, 167, 0xFAE, 0xFB0, (int)Buttons.DirPrev);
// material
AddHtmlLocalized(133, 211, 120, 20, 1076171, 0x7FFF); // Choose Material
AddHtmlLocalized(133, 231, 120, 20, GetMaterialNumber(m_Statue.StatueType, m_Statue.Material), 0x77E);
AddButton(163, 253, 0xFA5, 0xFA7, (int)Buttons.MatNext);
AddButton(133, 253, 0xFAE, 0xFB0, (int)Buttons.MatPrev);
// cancel
AddButton(10, 294, 0xFB1, 0xFB2, (int)Buttons.Close);
AddHtmlLocalized(45, 294, 80, 20, 1006045, 0x7FFF); // Cancel
// sculpt
AddButton(234, 294, 0xFB7, 0xFB9, (int)Buttons.Sculpt);
AddHtmlLocalized(269, 294, 80, 20, 1076174, 0x7FFF); // Sculpt
// restore
if (m_Maker is CharacterStatueDeed)
{
AddButton(107, 294, 0xFAB, 0xFAD, (int)Buttons.Restore);
AddHtmlLocalized(142, 294, 80, 20, 1076193, 0x7FFF); // Restore
}
}
private int GetMaterialNumber(StatueType type, StatueMaterial material) =>
material switch
{
case StatueMaterial.Antique:
return type switch
{
StatueType.Bronze => 1076187,
StatueType.Jade => 1076186,
StatueType.Marble => 1076182,
_ => 1076187
};
case StatueMaterial.Dark:
if (type == StatueType.Marble)
return 1076183;
return 1076182;
case StatueMaterial.Medium: return 1076184;
case StatueMaterial.Light: return 1076185;
default: return 1076187;
}
}
private int GetDirectionNumber(Direction direction)
{
return direction switch
{
Direction.North => 1075389,
Direction.Right => 1075388,
Direction.East => 1075387,
Direction.Down => 1076204,
Direction.South => 1075386,
Direction.Left => 1075391,
Direction.West => 1075390,
Direction.Up => 1076205,
_ => 1075386
};
}
public override void OnResponse(NetState state, RelayInfo info)
{
if (m_Statue?.Deleted != false)
return;
bool sendGump = false;
if (info.ButtonID == (int)Buttons.Sculpt)
{
if (m_Maker is CharacterStatueDeed deed)
{
CharacterStatue backup = deed.Statue;
backup?.Delete();
}
m_Maker?.Delete();
m_Statue.Sculpt(sender.Mobile);
}
else if (info.ButtonID == (int)Buttons.PosePrev)
{
m_Statue.Pose = (StatuePose)(((int)m_Statue.Pose + 5) % 6);
sendGump = true;
}
else if (info.ButtonID == (int)Buttons.PoseNext)
{
m_Statue.Pose = (StatuePose)(((int)m_Statue.Pose + 1) % 6);
sendGump = true;
}
else if (info.ButtonID == (int)Buttons.DirPrev)
{
m_Statue.Direction = (Direction)(((int)m_Statue.Direction + 7) % 8);
m_Statue.InvalidatePose();
sendGump = true;
}
else if (info.ButtonID == (int)Buttons.DirNext)
{
m_Statue.Direction = (Direction)(((int)m_Statue.Direction + 1) % 8);
m_Statue.InvalidatePose();
sendGump = true;
}
else if (info.ButtonID == (int)Buttons.MatPrev)
{
m_Statue.Material = (StatueMaterial)(((int)m_Statue.Material + 3) % 4);
sendGump = true;
}
else if (info.ButtonID == (int)Buttons.MatNext)
{
m_Statue.Material = (StatueMaterial)(((int)m_Statue.Material + 1) % 4);
sendGump = true;
}
else if (info.ButtonID == (int)Buttons.Restore)
{
if (m_Maker is CharacterStatueDeed deed)
{
CharacterStatue backup = deed.Statue;
if (backup != null)
m_Statue.Restore(backup);
}
sendGump = true;
}
else // Close
{
sendGump = !m_Statue.Demolish(sender.Mobile);
}
if (sendGump)
sender.Mobile.SendGump(new CharacterStatueGump(m_Maker, m_Statue, m_Owner));
}
private enum Buttons
{
Close,
Sculpt,
PosePrev,
PoseNext,
DirPrev,
DirNext,
MatPrev,
MatNext,
Restore
}
}
}