* 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
288 lines
8.8 KiB
C#
288 lines
8.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Reflection;
|
|
using Server.Commands;
|
|
using Server.Network;
|
|
|
|
namespace Server.Gumps
|
|
{
|
|
public class SetBodyGump : Gump
|
|
{
|
|
private const int LabelColor32 = 0xFFFFFF;
|
|
private const int SelectedColor32 = 0x8080FF;
|
|
private const int TextColor32 = 0xFFFFFF;
|
|
|
|
private static List<InternalEntry> m_Monster, m_Animal, m_Sea, m_Human;
|
|
private List<object> m_List;
|
|
private Mobile m_Mobile;
|
|
private object m_Object;
|
|
private List<InternalEntry> m_OurList;
|
|
private int m_OurPage;
|
|
private ModelBodyType m_OurType;
|
|
private int m_Page;
|
|
private PropertyInfo m_Property;
|
|
private Stack<StackEntry> m_Stack;
|
|
|
|
public SetBodyGump(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page, List<object> list,
|
|
int ourPage = 0, List<InternalEntry> ourList = null, ModelBodyType ourType = ModelBodyType.Invalid)
|
|
: base(20, 30)
|
|
{
|
|
m_Property = prop;
|
|
m_Mobile = mobile;
|
|
m_Object = o;
|
|
m_Stack = stack;
|
|
m_Page = page;
|
|
m_List = list;
|
|
m_OurPage = ourPage;
|
|
m_OurList = ourList;
|
|
m_OurType = ourType;
|
|
|
|
AddPage(0);
|
|
|
|
AddBackground(0, 0, 525, 328, 5054);
|
|
|
|
AddImageTiled(10, 10, 505, 20, 0xA40);
|
|
AddAlphaRegion(10, 10, 505, 20);
|
|
|
|
AddImageTiled(10, 35, 505, 283, 0xA40);
|
|
AddAlphaRegion(10, 35, 505, 283);
|
|
|
|
AddTypeButton(10, 10, 1, "Monster", ModelBodyType.Monsters);
|
|
AddTypeButton(130, 10, 2, "Animal", ModelBodyType.Animals);
|
|
AddTypeButton(250, 10, 3, "Marine", ModelBodyType.Sea);
|
|
AddTypeButton(370, 10, 4, "Human", ModelBodyType.Human);
|
|
|
|
AddImage(480, 12, 0x25EA);
|
|
AddImage(497, 12, 0x25E6);
|
|
|
|
if (ourList == null)
|
|
{
|
|
AddLabel(15, 40, 0x480, "Choose a body type above.");
|
|
}
|
|
else if (ourList.Count == 0)
|
|
{
|
|
AddLabel(15, 40, 0x480, "The server must have UO:3D installed to use this feature.");
|
|
}
|
|
else
|
|
{
|
|
for (int i = 0, index = ourPage * 12; i < 12 && index >= 0 && index < ourList.Count; ++i, ++index)
|
|
{
|
|
InternalEntry entry = ourList[index];
|
|
int itemID = entry.ItemID;
|
|
|
|
Rectangle2D bounds = ItemBounds.Table[itemID & 0x3FFF];
|
|
|
|
int x = 15 + i % 4 * 125;
|
|
int y = 40 + i / 4 * 93;
|
|
|
|
AddItem(x + (120 - bounds.Width) / 2 - bounds.X, y + (69 - bounds.Height) / 2 - bounds.Y, itemID);
|
|
AddButton(x + 6, y + 66, 0x98D, 0x98D, 7 + index);
|
|
|
|
x += 6;
|
|
y += 67;
|
|
|
|
AddHtml(x + 0, y - 1, 108, 21, Center(entry.DisplayName));
|
|
AddHtml(x + 0, y + 1, 108, 21, Center(entry.DisplayName));
|
|
AddHtml(x - 1, y + 0, 108, 21, Center(entry.DisplayName));
|
|
AddHtml(x + 1, y + 0, 108, 21, Center(entry.DisplayName));
|
|
AddHtml(x + 0, y + 0, 108, 21, Color(Center(entry.DisplayName), TextColor32));
|
|
}
|
|
|
|
if (ourPage > 0)
|
|
AddButton(480, 12, 0x15E3, 0x15E7, 5);
|
|
|
|
if ((ourPage + 1) * 12 < ourList.Count)
|
|
AddButton(497, 12, 0x15E1, 0x15E5, 6);
|
|
}
|
|
}
|
|
|
|
public string Center(string text) => $"<CENTER>{text}</CENTER>";
|
|
|
|
public string Color(string text, int color) => $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
|
|
|
|
public void AddTypeButton(int x, int y, int buttonID, string text, ModelBodyType type)
|
|
{
|
|
bool isSelection = m_OurType == type;
|
|
|
|
AddButton(x, y - 1, isSelection ? 4006 : 4005, 4007, buttonID);
|
|
AddHtml(x + 35, y, 200, 20, Color(text, isSelection ? SelectedColor32 : LabelColor32));
|
|
}
|
|
|
|
public override void OnResponse(NetState sender, RelayInfo info)
|
|
{
|
|
int index = info.ButtonID - 1;
|
|
|
|
if (index == -1)
|
|
{
|
|
m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
|
|
}
|
|
else if (index >= 0 && index < 4)
|
|
{
|
|
if (m_Monster == null)
|
|
LoadLists();
|
|
|
|
ModelBodyType type;
|
|
List<InternalEntry> list;
|
|
|
|
switch (index)
|
|
{
|
|
default:
|
|
type = ModelBodyType.Monsters;
|
|
list = m_Monster;
|
|
break;
|
|
case 1:
|
|
type = ModelBodyType.Animals;
|
|
list = m_Animal;
|
|
break;
|
|
case 2:
|
|
type = ModelBodyType.Sea;
|
|
list = m_Sea;
|
|
break;
|
|
case 3:
|
|
type = ModelBodyType.Human;
|
|
list = m_Human;
|
|
break;
|
|
}
|
|
|
|
m_Mobile.SendGump(new SetBodyGump(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List, 0, list, type));
|
|
}
|
|
else if (m_OurList != null)
|
|
{
|
|
index -= 4;
|
|
|
|
if (index == 0 && m_OurPage > 0)
|
|
{
|
|
m_Mobile.SendGump(new SetBodyGump(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List, m_OurPage - 1,
|
|
m_OurList, m_OurType));
|
|
}
|
|
else if (index == 1 && (m_OurPage + 1) * 12 < m_OurList.Count)
|
|
{
|
|
m_Mobile.SendGump(new SetBodyGump(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List, m_OurPage + 1,
|
|
m_OurList, m_OurType));
|
|
}
|
|
else
|
|
{
|
|
index -= 2;
|
|
|
|
if (index >= 0 && index < m_OurList.Count)
|
|
{
|
|
try
|
|
{
|
|
InternalEntry entry = m_OurList[index];
|
|
|
|
CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, entry.Body.ToString());
|
|
m_Property.SetValue(m_Object, entry.Body, null);
|
|
PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);
|
|
}
|
|
catch
|
|
{
|
|
m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
|
|
}
|
|
|
|
m_Mobile.SendGump(new SetBodyGump(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List, m_OurPage,
|
|
m_OurList, m_OurType));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private static void LoadLists()
|
|
{
|
|
m_Monster = new List<InternalEntry>();
|
|
m_Animal = new List<InternalEntry>();
|
|
m_Sea = new List<InternalEntry>();
|
|
m_Human = new List<InternalEntry>();
|
|
|
|
List<BodyEntry> entries = Docs.LoadBodies();
|
|
|
|
for (int i = 0; i < entries.Count; ++i)
|
|
{
|
|
BodyEntry oldEntry = entries[i];
|
|
int bodyID = oldEntry.Body.BodyID;
|
|
|
|
if (((Body)bodyID).IsEmpty)
|
|
continue;
|
|
|
|
List<InternalEntry> list = oldEntry.BodyType switch
|
|
{
|
|
ModelBodyType.Monsters => m_Monster,
|
|
ModelBodyType.Animals => m_Animal,
|
|
ModelBodyType.Sea => m_Sea,
|
|
ModelBodyType.Human => m_Human,
|
|
_ => null
|
|
};
|
|
|
|
if (list == null)
|
|
return;
|
|
|
|
int itemID = ShrinkTable.Lookup(bodyID, -1);
|
|
|
|
if (itemID != -1)
|
|
list.Add(new InternalEntry(bodyID, itemID, oldEntry.Name));
|
|
}
|
|
|
|
m_Monster.Sort();
|
|
m_Animal.Sort();
|
|
m_Sea.Sort();
|
|
m_Human.Sort();
|
|
}
|
|
|
|
public class InternalEntry : IComparable<InternalEntry>
|
|
{
|
|
private static string[] m_GroupNames =
|
|
{
|
|
"ogres_", "ettins_", "walking_dead_", "gargoyles_",
|
|
"orcs_", "flails_", "daemons_", "arachnids_",
|
|
"dragons_", "elementals_", "serpents_", "gazers_",
|
|
"liche_", "spirits_", "harpies_", "headless_",
|
|
"lizard_race_", "mongbat_", "rat_race_", "scorpions_",
|
|
"trolls_", "slimes_", "skeletons_", "ethereals_",
|
|
"terathan_", "imps_", "cyclops_", "krakens_",
|
|
"frogs_", "ophidians_", "centaurs_", "mages_",
|
|
"fey_race_", "genies_", "paladins_", "shadowlords_",
|
|
"succubi_", "lizards_", "rodents_", "birds_",
|
|
"bovines_", "bruins_", "canines_", "deer_",
|
|
"equines_", "felines_", "fowl_", "gorillas_",
|
|
"kirin_", "llamas_", "ostards_", "porcines_",
|
|
"ruminants_", "walrus_", "dolphins_", "sea_horse_",
|
|
"sea_serpents_", "character_", "h_", "titans_"
|
|
};
|
|
|
|
public InternalEntry(int body, int itemID, string name)
|
|
{
|
|
Body = body;
|
|
ItemID = itemID;
|
|
Name = name;
|
|
|
|
DisplayName = name.ToLower();
|
|
|
|
for (int i = 0; i < m_GroupNames.Length; ++i)
|
|
if (DisplayName.StartsWith(m_GroupNames[i]))
|
|
{
|
|
DisplayName = DisplayName.Substring(m_GroupNames[i].Length);
|
|
break;
|
|
}
|
|
|
|
DisplayName = DisplayName.Replace('_', ' ');
|
|
}
|
|
|
|
public int Body{ get; }
|
|
|
|
public int ItemID{ get; }
|
|
|
|
public string Name{ get; }
|
|
|
|
public string DisplayName{ get; }
|
|
|
|
public int CompareTo(InternalEntry comp)
|
|
{
|
|
int v = Name.CompareTo(comp.Name);
|
|
|
|
if (v == 0)
|
|
v = Body.CompareTo(comp.Body);
|
|
|
|
return v;
|
|
}
|
|
}
|
|
}
|
|
}
|