Formats UO Content (#201)
This commit is contained in:
parent
86b7b3aed1
commit
ad3775c4d7
3249 changed files with 431083 additions and 440981 deletions
|
|
@ -1,42 +1,42 @@
|
|||
namespace Server.Gumps
|
||||
{
|
||||
public class PropsConfig
|
||||
{
|
||||
public static readonly bool OldStyle = false;
|
||||
|
||||
public static readonly int GumpOffsetX = 30;
|
||||
public static readonly int GumpOffsetY = 30;
|
||||
|
||||
public static readonly int TextHue = 0;
|
||||
public static readonly int TextOffsetX = 2;
|
||||
|
||||
public static readonly int OffsetGumpID = 0x0A40; // Pure black
|
||||
|
||||
public static readonly int
|
||||
HeaderGumpID = OldStyle ? 0x0BBC : 0x0E14; // Light offwhite, textured : Dark navy blue, textured
|
||||
|
||||
public static readonly int EntryGumpID = 0x0BBC; // Light offwhite, textured
|
||||
public static readonly int BackGumpID = 0x13BE; // Gray slate/stoney
|
||||
public static readonly int SetGumpID = OldStyle ? 0x0000 : 0x0E14; // Empty : Dark navy blue, textured
|
||||
|
||||
public static readonly int SetWidth = 20;
|
||||
public static readonly int SetOffsetX = OldStyle ? 4 : 2, SetOffsetY = 2;
|
||||
public static readonly int SetButtonID1 = 0x15E1; // Arrow pointing right
|
||||
public static readonly int SetButtonID2 = 0x15E5; // " pressed
|
||||
|
||||
public static readonly int PrevWidth = 20;
|
||||
public static readonly int PrevOffsetX = 2, PrevOffsetY = 2;
|
||||
public static readonly int PrevButtonID1 = 0x15E3; // Arrow pointing left
|
||||
public static readonly int PrevButtonID2 = 0x15E7; // " pressed
|
||||
|
||||
public static readonly int NextWidth = 20;
|
||||
public static readonly int NextOffsetX = 2, NextOffsetY = 2;
|
||||
public static readonly int NextButtonID1 = 0x15E1; // Arrow pointing right
|
||||
public static readonly int NextButtonID2 = 0x15E5; // " pressed
|
||||
|
||||
public static readonly int OffsetSize = 1;
|
||||
|
||||
public static readonly int EntryHeight = 20;
|
||||
public static readonly int BorderSize = 10;
|
||||
}
|
||||
}
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class PropsConfig
|
||||
{
|
||||
public static readonly bool OldStyle = false;
|
||||
|
||||
public static readonly int GumpOffsetX = 30;
|
||||
public static readonly int GumpOffsetY = 30;
|
||||
|
||||
public static readonly int TextHue = 0;
|
||||
public static readonly int TextOffsetX = 2;
|
||||
|
||||
public static readonly int OffsetGumpID = 0x0A40; // Pure black
|
||||
|
||||
public static readonly int
|
||||
HeaderGumpID = OldStyle ? 0x0BBC : 0x0E14; // Light offwhite, textured : Dark navy blue, textured
|
||||
|
||||
public static readonly int EntryGumpID = 0x0BBC; // Light offwhite, textured
|
||||
public static readonly int BackGumpID = 0x13BE; // Gray slate/stoney
|
||||
public static readonly int SetGumpID = OldStyle ? 0x0000 : 0x0E14; // Empty : Dark navy blue, textured
|
||||
|
||||
public static readonly int SetWidth = 20;
|
||||
public static readonly int SetOffsetX = OldStyle ? 4 : 2, SetOffsetY = 2;
|
||||
public static readonly int SetButtonID1 = 0x15E1; // Arrow pointing right
|
||||
public static readonly int SetButtonID2 = 0x15E5; // " pressed
|
||||
|
||||
public static readonly int PrevWidth = 20;
|
||||
public static readonly int PrevOffsetX = 2, PrevOffsetY = 2;
|
||||
public static readonly int PrevButtonID1 = 0x15E3; // Arrow pointing left
|
||||
public static readonly int PrevButtonID2 = 0x15E7; // " pressed
|
||||
|
||||
public static readonly int NextWidth = 20;
|
||||
public static readonly int NextOffsetX = 2, NextOffsetY = 2;
|
||||
public static readonly int NextButtonID1 = 0x15E1; // Arrow pointing right
|
||||
public static readonly int NextButtonID2 = 0x15E5; // " pressed
|
||||
|
||||
public static readonly int OffsetSize = 1;
|
||||
|
||||
public static readonly int EntryHeight = 20;
|
||||
public static readonly int BorderSize = 10;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,295 +1,330 @@
|
|||
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 readonly List<object> m_List;
|
||||
private readonly Mobile m_Mobile;
|
||||
private readonly object m_Object;
|
||||
private readonly List<InternalEntry> m_OurList;
|
||||
private readonly int m_OurPage;
|
||||
private readonly ModelBodyType m_OurType;
|
||||
private readonly int m_Page;
|
||||
private readonly PropertyInfo m_Property;
|
||||
private readonly 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;
|
||||
|
||||
switch (oldEntry.BodyType)
|
||||
{
|
||||
default: continue;
|
||||
case ModelBodyType.Monsters:
|
||||
list = m_Monster;
|
||||
break;
|
||||
case ModelBodyType.Animals:
|
||||
list = m_Animal;
|
||||
break;
|
||||
case ModelBodyType.Sea:
|
||||
list = m_Sea;
|
||||
break;
|
||||
case ModelBodyType.Human:
|
||||
list = m_Human;
|
||||
break;
|
||||
}
|
||||
|
||||
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 readonly 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)
|
||||
{
|
||||
if (Name == null && comp.Name == null)
|
||||
return 0;
|
||||
|
||||
int v = Name?.CompareTo(comp.Name) ?? 1;
|
||||
|
||||
return v == 0 ? Body.CompareTo(comp.Body) : v;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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 readonly List<object> m_List;
|
||||
private readonly Mobile m_Mobile;
|
||||
private readonly object m_Object;
|
||||
private readonly List<InternalEntry> m_OurList;
|
||||
private readonly int m_OurPage;
|
||||
private readonly ModelBodyType m_OurType;
|
||||
private readonly int m_Page;
|
||||
private readonly PropertyInfo m_Property;
|
||||
private readonly 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)
|
||||
{
|
||||
var entry = ourList[index];
|
||||
var itemID = entry.ItemID;
|
||||
|
||||
var bounds = ItemBounds.Table[itemID & 0x3FFF];
|
||||
|
||||
var x = 15 + i % 4 * 125;
|
||||
var 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)
|
||||
{
|
||||
var 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)
|
||||
{
|
||||
var 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
|
||||
{
|
||||
var 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>();
|
||||
|
||||
var entries = Docs.LoadBodies();
|
||||
|
||||
for (var i = 0; i < entries.Count; ++i)
|
||||
{
|
||||
var oldEntry = entries[i];
|
||||
var bodyID = oldEntry.Body.BodyID;
|
||||
|
||||
if (((Body)bodyID).IsEmpty)
|
||||
continue;
|
||||
|
||||
List<InternalEntry> list;
|
||||
|
||||
switch (oldEntry.BodyType)
|
||||
{
|
||||
default: continue;
|
||||
case ModelBodyType.Monsters:
|
||||
list = m_Monster;
|
||||
break;
|
||||
case ModelBodyType.Animals:
|
||||
list = m_Animal;
|
||||
break;
|
||||
case ModelBodyType.Sea:
|
||||
list = m_Sea;
|
||||
break;
|
||||
case ModelBodyType.Human:
|
||||
list = m_Human;
|
||||
break;
|
||||
}
|
||||
|
||||
var 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 readonly 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 (var 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)
|
||||
{
|
||||
if (Name == null && comp.Name == null)
|
||||
return 0;
|
||||
|
||||
var v = Name?.CompareTo(comp.Name) ?? 1;
|
||||
|
||||
return v == 0 ? Body.CompareTo(comp.Body) : v;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,50 +1,66 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Server.Commands;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class SetCustomEnumGump : SetListOptionGump
|
||||
{
|
||||
private readonly string[] m_Names;
|
||||
|
||||
public SetCustomEnumGump(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int propspage,
|
||||
List<object> list, string[] names) : base(prop, mobile, o, stack, propspage, list, names, null) =>
|
||||
m_Names = names;
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo relayInfo)
|
||||
{
|
||||
int index = relayInfo.ButtonID - 1;
|
||||
|
||||
if (index >= 0 && index < m_Names.Length)
|
||||
try
|
||||
{
|
||||
MethodInfo info = m_Property.PropertyType.GetMethod("Parse", new[] { typeof(string) });
|
||||
|
||||
string result;
|
||||
|
||||
if (info != null)
|
||||
result = Properties.SetDirect(m_Mobile, m_Object, m_Object, m_Property, m_Property.Name,
|
||||
info.Invoke(null, new object[] { m_Names[index] }), true);
|
||||
else if (m_Property.PropertyType == typeof(Enum) || m_Property.PropertyType.IsSubclassOf(typeof(Enum)))
|
||||
result = Properties.SetDirect(m_Mobile, m_Object, m_Object, m_Property, m_Property.Name,
|
||||
Enum.Parse(m_Property.PropertyType, m_Names[index], false), true);
|
||||
else
|
||||
result = "";
|
||||
|
||||
m_Mobile.SendMessage(result);
|
||||
|
||||
if (result == "Property has been set.")
|
||||
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 PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Server.Commands;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class SetCustomEnumGump : SetListOptionGump
|
||||
{
|
||||
private readonly string[] m_Names;
|
||||
|
||||
public SetCustomEnumGump(
|
||||
PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int propspage,
|
||||
List<object> list, string[] names
|
||||
) : base(prop, mobile, o, stack, propspage, list, names, null) =>
|
||||
m_Names = names;
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo relayInfo)
|
||||
{
|
||||
var index = relayInfo.ButtonID - 1;
|
||||
|
||||
if (index >= 0 && index < m_Names.Length)
|
||||
try
|
||||
{
|
||||
var info = m_Property.PropertyType.GetMethod("Parse", new[] { typeof(string) });
|
||||
|
||||
string result;
|
||||
|
||||
if (info != null)
|
||||
result = Properties.SetDirect(
|
||||
m_Mobile,
|
||||
m_Object,
|
||||
m_Object,
|
||||
m_Property,
|
||||
m_Property.Name,
|
||||
info.Invoke(null, new object[] { m_Names[index] }),
|
||||
true
|
||||
);
|
||||
else if (m_Property.PropertyType == typeof(Enum) || m_Property.PropertyType.IsSubclassOf(typeof(Enum)))
|
||||
result = Properties.SetDirect(
|
||||
m_Mobile,
|
||||
m_Object,
|
||||
m_Object,
|
||||
m_Property,
|
||||
m_Property.Name,
|
||||
Enum.Parse(m_Property.PropertyType, m_Names[index], false),
|
||||
true
|
||||
);
|
||||
else
|
||||
result = "";
|
||||
|
||||
m_Mobile.SendMessage(result);
|
||||
|
||||
if (result == "Property has been set.")
|
||||
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 PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,281 +1,301 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Server.Commands;
|
||||
using Server.HuePickers;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class SetGump : Gump
|
||||
{
|
||||
public static readonly bool OldStyle = PropsConfig.OldStyle;
|
||||
|
||||
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
|
||||
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
|
||||
|
||||
public static readonly int TextHue = PropsConfig.TextHue;
|
||||
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
|
||||
|
||||
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
|
||||
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
|
||||
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
|
||||
public static readonly int BackGumpID = PropsConfig.BackGumpID;
|
||||
public static readonly int SetGumpID = PropsConfig.SetGumpID;
|
||||
|
||||
public static readonly int SetWidth = PropsConfig.SetWidth;
|
||||
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
|
||||
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
|
||||
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
|
||||
|
||||
public static readonly int PrevWidth = PropsConfig.PrevWidth;
|
||||
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
|
||||
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
|
||||
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
|
||||
|
||||
public static readonly int NextWidth = PropsConfig.NextWidth;
|
||||
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
|
||||
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
|
||||
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
|
||||
|
||||
public static readonly int OffsetSize = PropsConfig.OffsetSize;
|
||||
|
||||
public static readonly int EntryHeight = PropsConfig.EntryHeight;
|
||||
public static readonly int BorderSize = PropsConfig.BorderSize;
|
||||
|
||||
private static readonly int EntryWidth = 212;
|
||||
|
||||
private static readonly int TotalWidth = OffsetSize + EntryWidth + OffsetSize + SetWidth + OffsetSize;
|
||||
private static readonly int TotalHeight = OffsetSize + 2 * (EntryHeight + OffsetSize);
|
||||
|
||||
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
|
||||
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
|
||||
private readonly List<object> m_List;
|
||||
private readonly Mobile m_Mobile;
|
||||
private readonly object m_Object;
|
||||
private readonly int m_Page;
|
||||
private readonly PropertyInfo m_Property;
|
||||
private readonly Stack<StackEntry> m_Stack;
|
||||
|
||||
public SetGump(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page, List<object> list) : base(
|
||||
GumpOffsetX, GumpOffsetY)
|
||||
{
|
||||
m_Property = prop;
|
||||
m_Mobile = mobile;
|
||||
m_Object = o;
|
||||
m_Stack = stack;
|
||||
m_Page = page;
|
||||
m_List = list;
|
||||
|
||||
bool canNull = !prop.PropertyType.IsValueType;
|
||||
bool canDye = prop.IsDefined(typeof(HueAttribute), false);
|
||||
bool isBody = prop.IsDefined(typeof(BodyAttribute), false);
|
||||
|
||||
object val = prop.GetValue(m_Object, null);
|
||||
string initialText = val switch
|
||||
{
|
||||
null => "",
|
||||
TextDefinition definition => definition.GetValue(),
|
||||
_ => val.ToString()
|
||||
};
|
||||
|
||||
AddPage(0);
|
||||
|
||||
AddBackground(0, 0, BackWidth,
|
||||
BackHeight + (canNull ? EntryHeight + OffsetSize : 0) + (canDye ? EntryHeight + OffsetSize : 0) +
|
||||
(isBody ? EntryHeight + OffsetSize : 0), BackGumpID);
|
||||
AddImageTiled(BorderSize, BorderSize, TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0),
|
||||
TotalHeight + (canNull ? EntryHeight + OffsetSize : 0) + (canDye ? EntryHeight + OffsetSize : 0) +
|
||||
(isBody ? EntryHeight + OffsetSize : 0), OffsetGumpID);
|
||||
|
||||
int x = BorderSize + OffsetSize;
|
||||
int y = BorderSize + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, prop.Name);
|
||||
x += EntryWidth + OffsetSize;
|
||||
|
||||
if (SetGumpID != 0)
|
||||
AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
|
||||
|
||||
x = BorderSize + OffsetSize;
|
||||
y += EntryHeight + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
|
||||
AddTextEntry(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, 0, initialText);
|
||||
x += EntryWidth + OffsetSize;
|
||||
|
||||
if (SetGumpID != 0)
|
||||
AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
|
||||
|
||||
AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 1);
|
||||
|
||||
if (canNull)
|
||||
{
|
||||
x = BorderSize + OffsetSize;
|
||||
y += EntryHeight + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Null");
|
||||
x += EntryWidth + OffsetSize;
|
||||
|
||||
if (SetGumpID != 0)
|
||||
AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
|
||||
|
||||
AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 2);
|
||||
}
|
||||
|
||||
if (canDye)
|
||||
{
|
||||
x = BorderSize + OffsetSize;
|
||||
y += EntryHeight + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Hue Picker");
|
||||
x += EntryWidth + OffsetSize;
|
||||
|
||||
if (SetGumpID != 0)
|
||||
AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
|
||||
|
||||
AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 3);
|
||||
}
|
||||
|
||||
if (isBody)
|
||||
{
|
||||
x = BorderSize + OffsetSize;
|
||||
y += EntryHeight + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Body Picker");
|
||||
x += EntryWidth + OffsetSize;
|
||||
|
||||
if (SetGumpID != 0)
|
||||
AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
|
||||
|
||||
AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 4);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
object toSet;
|
||||
bool shouldSet, shouldSend = true;
|
||||
|
||||
switch (info.ButtonID)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
TextRelay text = info.GetTextEntry(0);
|
||||
|
||||
if (text != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
toSet = PropertiesGump.GetObjectFromString(m_Property.PropertyType, text.Text);
|
||||
shouldSet = true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
toSet = null;
|
||||
shouldSet = false;
|
||||
m_Mobile.SendMessage("Bad format");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
toSet = null;
|
||||
shouldSet = false;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 2: // Null
|
||||
{
|
||||
toSet = null;
|
||||
shouldSet = true;
|
||||
|
||||
break;
|
||||
}
|
||||
case 3: // Hue Picker
|
||||
{
|
||||
toSet = null;
|
||||
shouldSet = false;
|
||||
shouldSend = false;
|
||||
|
||||
m_Mobile.SendHuePicker(new InternalPicker(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List));
|
||||
|
||||
break;
|
||||
}
|
||||
case 4: // Body Picker
|
||||
{
|
||||
toSet = null;
|
||||
shouldSet = false;
|
||||
shouldSend = false;
|
||||
|
||||
m_Mobile.SendGump(new SetBodyGump(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List));
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
toSet = null;
|
||||
shouldSet = false;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldSet)
|
||||
try
|
||||
{
|
||||
CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name,
|
||||
toSet?.ToString() ?? "(null)");
|
||||
m_Property.SetValue(m_Object, toSet, null);
|
||||
PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);
|
||||
}
|
||||
catch
|
||||
{
|
||||
m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
|
||||
}
|
||||
|
||||
if (shouldSend)
|
||||
m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
|
||||
}
|
||||
|
||||
private class InternalPicker : HuePicker
|
||||
{
|
||||
private readonly List<object> m_List;
|
||||
private readonly Mobile m_Mobile;
|
||||
private readonly object m_Object;
|
||||
private readonly int m_Page;
|
||||
private readonly PropertyInfo m_Property;
|
||||
private readonly Stack<StackEntry> m_Stack;
|
||||
|
||||
public InternalPicker(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page,
|
||||
List<object> list) : base(((IHued)o).HuedItemID)
|
||||
{
|
||||
m_Property = prop;
|
||||
m_Mobile = mobile;
|
||||
m_Object = o;
|
||||
m_Stack = stack;
|
||||
m_Page = page;
|
||||
m_List = list;
|
||||
}
|
||||
|
||||
public override void OnResponse(int hue)
|
||||
{
|
||||
try
|
||||
{
|
||||
CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, hue.ToString());
|
||||
m_Property.SetValue(m_Object, hue, 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 PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Server.Commands;
|
||||
using Server.HuePickers;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class SetGump : Gump
|
||||
{
|
||||
public static readonly bool OldStyle = PropsConfig.OldStyle;
|
||||
|
||||
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
|
||||
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
|
||||
|
||||
public static readonly int TextHue = PropsConfig.TextHue;
|
||||
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
|
||||
|
||||
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
|
||||
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
|
||||
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
|
||||
public static readonly int BackGumpID = PropsConfig.BackGumpID;
|
||||
public static readonly int SetGumpID = PropsConfig.SetGumpID;
|
||||
|
||||
public static readonly int SetWidth = PropsConfig.SetWidth;
|
||||
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
|
||||
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
|
||||
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
|
||||
|
||||
public static readonly int PrevWidth = PropsConfig.PrevWidth;
|
||||
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
|
||||
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
|
||||
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
|
||||
|
||||
public static readonly int NextWidth = PropsConfig.NextWidth;
|
||||
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
|
||||
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
|
||||
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
|
||||
|
||||
public static readonly int OffsetSize = PropsConfig.OffsetSize;
|
||||
|
||||
public static readonly int EntryHeight = PropsConfig.EntryHeight;
|
||||
public static readonly int BorderSize = PropsConfig.BorderSize;
|
||||
|
||||
private static readonly int EntryWidth = 212;
|
||||
|
||||
private static readonly int TotalWidth = OffsetSize + EntryWidth + OffsetSize + SetWidth + OffsetSize;
|
||||
private static readonly int TotalHeight = OffsetSize + 2 * (EntryHeight + OffsetSize);
|
||||
|
||||
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
|
||||
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
|
||||
private readonly List<object> m_List;
|
||||
private readonly Mobile m_Mobile;
|
||||
private readonly object m_Object;
|
||||
private readonly int m_Page;
|
||||
private readonly PropertyInfo m_Property;
|
||||
private readonly Stack<StackEntry> m_Stack;
|
||||
|
||||
public SetGump(
|
||||
PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page, List<object> list
|
||||
) : base(
|
||||
GumpOffsetX,
|
||||
GumpOffsetY
|
||||
)
|
||||
{
|
||||
m_Property = prop;
|
||||
m_Mobile = mobile;
|
||||
m_Object = o;
|
||||
m_Stack = stack;
|
||||
m_Page = page;
|
||||
m_List = list;
|
||||
|
||||
var canNull = !prop.PropertyType.IsValueType;
|
||||
var canDye = prop.IsDefined(typeof(HueAttribute), false);
|
||||
var isBody = prop.IsDefined(typeof(BodyAttribute), false);
|
||||
|
||||
var val = prop.GetValue(m_Object, null);
|
||||
var initialText = val switch
|
||||
{
|
||||
null => "",
|
||||
TextDefinition definition => definition.GetValue(),
|
||||
_ => val.ToString()
|
||||
};
|
||||
|
||||
AddPage(0);
|
||||
|
||||
AddBackground(
|
||||
0,
|
||||
0,
|
||||
BackWidth,
|
||||
BackHeight + (canNull ? EntryHeight + OffsetSize : 0) + (canDye ? EntryHeight + OffsetSize : 0) +
|
||||
(isBody ? EntryHeight + OffsetSize : 0),
|
||||
BackGumpID
|
||||
);
|
||||
AddImageTiled(
|
||||
BorderSize,
|
||||
BorderSize,
|
||||
TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0),
|
||||
TotalHeight + (canNull ? EntryHeight + OffsetSize : 0) + (canDye ? EntryHeight + OffsetSize : 0) +
|
||||
(isBody ? EntryHeight + OffsetSize : 0),
|
||||
OffsetGumpID
|
||||
);
|
||||
|
||||
var x = BorderSize + OffsetSize;
|
||||
var y = BorderSize + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, prop.Name);
|
||||
x += EntryWidth + OffsetSize;
|
||||
|
||||
if (SetGumpID != 0)
|
||||
AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
|
||||
|
||||
x = BorderSize + OffsetSize;
|
||||
y += EntryHeight + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
|
||||
AddTextEntry(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, 0, initialText);
|
||||
x += EntryWidth + OffsetSize;
|
||||
|
||||
if (SetGumpID != 0)
|
||||
AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
|
||||
|
||||
AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 1);
|
||||
|
||||
if (canNull)
|
||||
{
|
||||
x = BorderSize + OffsetSize;
|
||||
y += EntryHeight + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Null");
|
||||
x += EntryWidth + OffsetSize;
|
||||
|
||||
if (SetGumpID != 0)
|
||||
AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
|
||||
|
||||
AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 2);
|
||||
}
|
||||
|
||||
if (canDye)
|
||||
{
|
||||
x = BorderSize + OffsetSize;
|
||||
y += EntryHeight + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Hue Picker");
|
||||
x += EntryWidth + OffsetSize;
|
||||
|
||||
if (SetGumpID != 0)
|
||||
AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
|
||||
|
||||
AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 3);
|
||||
}
|
||||
|
||||
if (isBody)
|
||||
{
|
||||
x = BorderSize + OffsetSize;
|
||||
y += EntryHeight + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Body Picker");
|
||||
x += EntryWidth + OffsetSize;
|
||||
|
||||
if (SetGumpID != 0)
|
||||
AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
|
||||
|
||||
AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 4);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
object toSet;
|
||||
bool shouldSet, shouldSend = true;
|
||||
|
||||
switch (info.ButtonID)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
var text = info.GetTextEntry(0);
|
||||
|
||||
if (text != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
toSet = PropertiesGump.GetObjectFromString(m_Property.PropertyType, text.Text);
|
||||
shouldSet = true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
toSet = null;
|
||||
shouldSet = false;
|
||||
m_Mobile.SendMessage("Bad format");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
toSet = null;
|
||||
shouldSet = false;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 2: // Null
|
||||
{
|
||||
toSet = null;
|
||||
shouldSet = true;
|
||||
|
||||
break;
|
||||
}
|
||||
case 3: // Hue Picker
|
||||
{
|
||||
toSet = null;
|
||||
shouldSet = false;
|
||||
shouldSend = false;
|
||||
|
||||
m_Mobile.SendHuePicker(new InternalPicker(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List));
|
||||
|
||||
break;
|
||||
}
|
||||
case 4: // Body Picker
|
||||
{
|
||||
toSet = null;
|
||||
shouldSet = false;
|
||||
shouldSend = false;
|
||||
|
||||
m_Mobile.SendGump(new SetBodyGump(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List));
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
toSet = null;
|
||||
shouldSet = false;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldSet)
|
||||
try
|
||||
{
|
||||
CommandLogging.LogChangeProperty(
|
||||
m_Mobile,
|
||||
m_Object,
|
||||
m_Property.Name,
|
||||
toSet?.ToString() ?? "(null)"
|
||||
);
|
||||
m_Property.SetValue(m_Object, toSet, null);
|
||||
PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);
|
||||
}
|
||||
catch
|
||||
{
|
||||
m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
|
||||
}
|
||||
|
||||
if (shouldSend)
|
||||
m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
|
||||
}
|
||||
|
||||
private class InternalPicker : HuePicker
|
||||
{
|
||||
private readonly List<object> m_List;
|
||||
private readonly Mobile m_Mobile;
|
||||
private readonly object m_Object;
|
||||
private readonly int m_Page;
|
||||
private readonly PropertyInfo m_Property;
|
||||
private readonly Stack<StackEntry> m_Stack;
|
||||
|
||||
public InternalPicker(
|
||||
PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page,
|
||||
List<object> list
|
||||
) : base(((IHued)o).HuedItemID)
|
||||
{
|
||||
m_Property = prop;
|
||||
m_Mobile = mobile;
|
||||
m_Object = o;
|
||||
m_Stack = stack;
|
||||
m_Page = page;
|
||||
m_List = list;
|
||||
}
|
||||
|
||||
public override void OnResponse(int hue)
|
||||
{
|
||||
try
|
||||
{
|
||||
CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, hue.ToString());
|
||||
m_Property.SetValue(m_Object, hue, 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 PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,186 +1,219 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Server.Commands;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class SetListOptionGump : Gump
|
||||
{
|
||||
public static readonly bool OldStyle = PropsConfig.OldStyle;
|
||||
|
||||
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
|
||||
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
|
||||
|
||||
public static readonly int TextHue = PropsConfig.TextHue;
|
||||
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
|
||||
|
||||
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
|
||||
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
|
||||
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
|
||||
public static readonly int BackGumpID = PropsConfig.BackGumpID;
|
||||
public static readonly int SetGumpID = PropsConfig.SetGumpID;
|
||||
|
||||
public static readonly int SetWidth = PropsConfig.SetWidth;
|
||||
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
|
||||
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
|
||||
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
|
||||
|
||||
public static readonly int PrevWidth = PropsConfig.PrevWidth;
|
||||
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
|
||||
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
|
||||
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
|
||||
|
||||
public static readonly int NextWidth = PropsConfig.NextWidth;
|
||||
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
|
||||
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
|
||||
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
|
||||
|
||||
public static readonly int OffsetSize = PropsConfig.OffsetSize;
|
||||
|
||||
public static readonly int EntryHeight = PropsConfig.EntryHeight;
|
||||
public static readonly int BorderSize = PropsConfig.BorderSize;
|
||||
|
||||
private static readonly int EntryWidth = 212;
|
||||
private static readonly int EntryCount = 13;
|
||||
|
||||
private static readonly int TotalWidth = OffsetSize + EntryWidth + OffsetSize + SetWidth + OffsetSize;
|
||||
|
||||
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
|
||||
|
||||
private static readonly bool PrevLabel = OldStyle;
|
||||
private static readonly bool NextLabel = OldStyle;
|
||||
|
||||
private static readonly int PrevLabelOffsetX = PrevWidth + 1;
|
||||
private static readonly int PrevLabelOffsetY = 0;
|
||||
|
||||
private static readonly int NextLabelOffsetX = -29;
|
||||
private static readonly int NextLabelOffsetY = 0;
|
||||
protected List<object> m_List;
|
||||
protected Mobile m_Mobile;
|
||||
protected object m_Object;
|
||||
protected int m_Page;
|
||||
protected PropertyInfo m_Property;
|
||||
protected Stack<StackEntry> m_Stack;
|
||||
|
||||
private readonly object[] m_Values;
|
||||
|
||||
public SetListOptionGump(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int propspage,
|
||||
List<object> list, string[] names, object[] values) : base(GumpOffsetX, GumpOffsetY)
|
||||
{
|
||||
m_Property = prop;
|
||||
m_Mobile = mobile;
|
||||
m_Object = o;
|
||||
m_Stack = stack;
|
||||
m_Page = propspage;
|
||||
m_List = list;
|
||||
|
||||
m_Values = values;
|
||||
|
||||
int pages = (names.Length + EntryCount - 1) / EntryCount;
|
||||
int index = 0;
|
||||
|
||||
for (int page = 1; page <= pages; ++page)
|
||||
{
|
||||
AddPage(page);
|
||||
|
||||
int start = (page - 1) * EntryCount;
|
||||
int count = names.Length - start;
|
||||
|
||||
if (count > EntryCount)
|
||||
count = EntryCount;
|
||||
|
||||
int totalHeight = OffsetSize + (count + 2) * (EntryHeight + OffsetSize);
|
||||
int backHeight = BorderSize + totalHeight + BorderSize;
|
||||
|
||||
AddBackground(0, 0, BackWidth, backHeight, BackGumpID);
|
||||
AddImageTiled(BorderSize, BorderSize, TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0), totalHeight,
|
||||
OffsetGumpID);
|
||||
|
||||
int x = BorderSize + OffsetSize;
|
||||
int y = BorderSize + OffsetSize;
|
||||
|
||||
int emptyWidth = TotalWidth - PrevWidth - NextWidth - OffsetSize * 4 -
|
||||
(OldStyle ? SetWidth + OffsetSize : 0);
|
||||
|
||||
AddImageTiled(x, y, PrevWidth, EntryHeight, HeaderGumpID);
|
||||
|
||||
if (page > 1)
|
||||
{
|
||||
AddButton(x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 0, GumpButtonType.Page,
|
||||
page - 1);
|
||||
|
||||
if (PrevLabel)
|
||||
AddLabel(x + PrevLabelOffsetX, y + PrevLabelOffsetY, TextHue, "Previous");
|
||||
}
|
||||
|
||||
x += PrevWidth + OffsetSize;
|
||||
|
||||
if (!OldStyle)
|
||||
AddImageTiled(x - (OldStyle ? OffsetSize : 0), y, emptyWidth + (OldStyle ? OffsetSize * 2 : 0),
|
||||
EntryHeight, HeaderGumpID);
|
||||
|
||||
x += emptyWidth + OffsetSize;
|
||||
|
||||
if (!OldStyle)
|
||||
AddImageTiled(x, y, NextWidth, EntryHeight, HeaderGumpID);
|
||||
|
||||
if (page < pages)
|
||||
{
|
||||
AddButton(x + NextOffsetX, y + NextOffsetY, NextButtonID1, NextButtonID2, 0, GumpButtonType.Page,
|
||||
page + 1);
|
||||
|
||||
if (NextLabel)
|
||||
AddLabel(x + NextLabelOffsetX, y + NextLabelOffsetY, TextHue, "Next");
|
||||
}
|
||||
|
||||
AddRect(0, prop.Name, 0);
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
AddRect(i + 1, names[index], ++index);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddRect(int index, string str, int button)
|
||||
{
|
||||
int x = BorderSize + OffsetSize;
|
||||
int y = BorderSize + OffsetSize + (index + 1) * (EntryHeight + OffsetSize);
|
||||
|
||||
AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, str);
|
||||
|
||||
x += EntryWidth + OffsetSize;
|
||||
|
||||
if (SetGumpID != 0)
|
||||
AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
|
||||
|
||||
if (button != 0)
|
||||
AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, button);
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
int index = info.ButtonID - 1;
|
||||
|
||||
if (index >= 0 && index < m_Values.Length)
|
||||
try
|
||||
{
|
||||
object toSet = m_Values[index];
|
||||
|
||||
string result = Properties.SetDirect(m_Mobile, m_Object, m_Object, m_Property, m_Property.Name, toSet,
|
||||
true);
|
||||
|
||||
m_Mobile.SendMessage(result);
|
||||
|
||||
if (result == "Property has been set.")
|
||||
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 PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Server.Commands;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class SetListOptionGump : Gump
|
||||
{
|
||||
public static readonly bool OldStyle = PropsConfig.OldStyle;
|
||||
|
||||
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
|
||||
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
|
||||
|
||||
public static readonly int TextHue = PropsConfig.TextHue;
|
||||
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
|
||||
|
||||
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
|
||||
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
|
||||
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
|
||||
public static readonly int BackGumpID = PropsConfig.BackGumpID;
|
||||
public static readonly int SetGumpID = PropsConfig.SetGumpID;
|
||||
|
||||
public static readonly int SetWidth = PropsConfig.SetWidth;
|
||||
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
|
||||
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
|
||||
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
|
||||
|
||||
public static readonly int PrevWidth = PropsConfig.PrevWidth;
|
||||
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
|
||||
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
|
||||
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
|
||||
|
||||
public static readonly int NextWidth = PropsConfig.NextWidth;
|
||||
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
|
||||
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
|
||||
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
|
||||
|
||||
public static readonly int OffsetSize = PropsConfig.OffsetSize;
|
||||
|
||||
public static readonly int EntryHeight = PropsConfig.EntryHeight;
|
||||
public static readonly int BorderSize = PropsConfig.BorderSize;
|
||||
|
||||
private static readonly int EntryWidth = 212;
|
||||
private static readonly int EntryCount = 13;
|
||||
|
||||
private static readonly int TotalWidth = OffsetSize + EntryWidth + OffsetSize + SetWidth + OffsetSize;
|
||||
|
||||
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
|
||||
|
||||
private static readonly bool PrevLabel = OldStyle;
|
||||
private static readonly bool NextLabel = OldStyle;
|
||||
|
||||
private static readonly int PrevLabelOffsetX = PrevWidth + 1;
|
||||
private static readonly int PrevLabelOffsetY = 0;
|
||||
|
||||
private static readonly int NextLabelOffsetX = -29;
|
||||
private static readonly int NextLabelOffsetY = 0;
|
||||
|
||||
private readonly object[] m_Values;
|
||||
protected List<object> m_List;
|
||||
protected Mobile m_Mobile;
|
||||
protected object m_Object;
|
||||
protected int m_Page;
|
||||
protected PropertyInfo m_Property;
|
||||
protected Stack<StackEntry> m_Stack;
|
||||
|
||||
public SetListOptionGump(
|
||||
PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int propspage,
|
||||
List<object> list, string[] names, object[] values
|
||||
) : base(GumpOffsetX, GumpOffsetY)
|
||||
{
|
||||
m_Property = prop;
|
||||
m_Mobile = mobile;
|
||||
m_Object = o;
|
||||
m_Stack = stack;
|
||||
m_Page = propspage;
|
||||
m_List = list;
|
||||
|
||||
m_Values = values;
|
||||
|
||||
var pages = (names.Length + EntryCount - 1) / EntryCount;
|
||||
var index = 0;
|
||||
|
||||
for (var page = 1; page <= pages; ++page)
|
||||
{
|
||||
AddPage(page);
|
||||
|
||||
var start = (page - 1) * EntryCount;
|
||||
var count = names.Length - start;
|
||||
|
||||
if (count > EntryCount)
|
||||
count = EntryCount;
|
||||
|
||||
var totalHeight = OffsetSize + (count + 2) * (EntryHeight + OffsetSize);
|
||||
var backHeight = BorderSize + totalHeight + BorderSize;
|
||||
|
||||
AddBackground(0, 0, BackWidth, backHeight, BackGumpID);
|
||||
AddImageTiled(
|
||||
BorderSize,
|
||||
BorderSize,
|
||||
TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0),
|
||||
totalHeight,
|
||||
OffsetGumpID
|
||||
);
|
||||
|
||||
var x = BorderSize + OffsetSize;
|
||||
var y = BorderSize + OffsetSize;
|
||||
|
||||
var emptyWidth = TotalWidth - PrevWidth - NextWidth - OffsetSize * 4 -
|
||||
(OldStyle ? SetWidth + OffsetSize : 0);
|
||||
|
||||
AddImageTiled(x, y, PrevWidth, EntryHeight, HeaderGumpID);
|
||||
|
||||
if (page > 1)
|
||||
{
|
||||
AddButton(
|
||||
x + PrevOffsetX,
|
||||
y + PrevOffsetY,
|
||||
PrevButtonID1,
|
||||
PrevButtonID2,
|
||||
0,
|
||||
GumpButtonType.Page,
|
||||
page - 1
|
||||
);
|
||||
|
||||
if (PrevLabel)
|
||||
AddLabel(x + PrevLabelOffsetX, y + PrevLabelOffsetY, TextHue, "Previous");
|
||||
}
|
||||
|
||||
x += PrevWidth + OffsetSize;
|
||||
|
||||
if (!OldStyle)
|
||||
AddImageTiled(
|
||||
x - (OldStyle ? OffsetSize : 0),
|
||||
y,
|
||||
emptyWidth + (OldStyle ? OffsetSize * 2 : 0),
|
||||
EntryHeight,
|
||||
HeaderGumpID
|
||||
);
|
||||
|
||||
x += emptyWidth + OffsetSize;
|
||||
|
||||
if (!OldStyle)
|
||||
AddImageTiled(x, y, NextWidth, EntryHeight, HeaderGumpID);
|
||||
|
||||
if (page < pages)
|
||||
{
|
||||
AddButton(
|
||||
x + NextOffsetX,
|
||||
y + NextOffsetY,
|
||||
NextButtonID1,
|
||||
NextButtonID2,
|
||||
0,
|
||||
GumpButtonType.Page,
|
||||
page + 1
|
||||
);
|
||||
|
||||
if (NextLabel)
|
||||
AddLabel(x + NextLabelOffsetX, y + NextLabelOffsetY, TextHue, "Next");
|
||||
}
|
||||
|
||||
AddRect(0, prop.Name, 0);
|
||||
|
||||
for (var i = 0; i < count; ++i)
|
||||
AddRect(i + 1, names[index], ++index);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddRect(int index, string str, int button)
|
||||
{
|
||||
var x = BorderSize + OffsetSize;
|
||||
var y = BorderSize + OffsetSize + (index + 1) * (EntryHeight + OffsetSize);
|
||||
|
||||
AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, str);
|
||||
|
||||
x += EntryWidth + OffsetSize;
|
||||
|
||||
if (SetGumpID != 0)
|
||||
AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
|
||||
|
||||
if (button != 0)
|
||||
AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, button);
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
var index = info.ButtonID - 1;
|
||||
|
||||
if (index >= 0 && index < m_Values.Length)
|
||||
try
|
||||
{
|
||||
var toSet = m_Values[index];
|
||||
|
||||
var result = Properties.SetDirect(
|
||||
m_Mobile,
|
||||
m_Object,
|
||||
m_Object,
|
||||
m_Property,
|
||||
m_Property.Name,
|
||||
toSet,
|
||||
true
|
||||
);
|
||||
|
||||
m_Mobile.SendMessage(result);
|
||||
|
||||
if (result == "Property has been set.")
|
||||
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 PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,266 +1,298 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Server.Commands;
|
||||
using Server.Commands.Generic;
|
||||
using Server.Network;
|
||||
using Server.Prompts;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class SetObjectGump : Gump
|
||||
{
|
||||
public static readonly bool OldStyle = PropsConfig.OldStyle;
|
||||
|
||||
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
|
||||
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
|
||||
|
||||
public static readonly int TextHue = PropsConfig.TextHue;
|
||||
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
|
||||
|
||||
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
|
||||
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
|
||||
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
|
||||
public static readonly int BackGumpID = PropsConfig.BackGumpID;
|
||||
public static readonly int SetGumpID = PropsConfig.SetGumpID;
|
||||
|
||||
public static readonly int SetWidth = PropsConfig.SetWidth;
|
||||
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
|
||||
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
|
||||
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
|
||||
|
||||
public static readonly int PrevWidth = PropsConfig.PrevWidth;
|
||||
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
|
||||
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
|
||||
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
|
||||
|
||||
public static readonly int NextWidth = PropsConfig.NextWidth;
|
||||
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
|
||||
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
|
||||
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
|
||||
|
||||
public static readonly int OffsetSize = PropsConfig.OffsetSize;
|
||||
|
||||
public static readonly int EntryHeight = PropsConfig.EntryHeight;
|
||||
public static readonly int BorderSize = PropsConfig.BorderSize;
|
||||
|
||||
private static readonly int EntryWidth = 212;
|
||||
|
||||
private static readonly int TotalWidth = OffsetSize + EntryWidth + OffsetSize + SetWidth + OffsetSize;
|
||||
private static readonly int TotalHeight = OffsetSize + 5 * (EntryHeight + OffsetSize);
|
||||
|
||||
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
|
||||
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
|
||||
private readonly List<object> m_List;
|
||||
private readonly Mobile m_Mobile;
|
||||
private readonly object m_Object;
|
||||
private readonly int m_Page;
|
||||
private readonly PropertyInfo m_Property;
|
||||
private readonly Stack<StackEntry> m_Stack;
|
||||
private readonly Type m_Type;
|
||||
|
||||
public SetObjectGump(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, Type type, int page,
|
||||
List<object> list) : base(GumpOffsetX, GumpOffsetY)
|
||||
{
|
||||
m_Property = prop;
|
||||
m_Mobile = mobile;
|
||||
m_Object = o;
|
||||
m_Stack = stack;
|
||||
m_Type = type;
|
||||
m_Page = page;
|
||||
m_List = list;
|
||||
|
||||
string initialText = PropertiesGump.ValueToString(o, prop);
|
||||
|
||||
AddPage(0);
|
||||
|
||||
AddBackground(0, 0, BackWidth, BackHeight, BackGumpID);
|
||||
AddImageTiled(BorderSize, BorderSize, TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0), TotalHeight,
|
||||
OffsetGumpID);
|
||||
|
||||
int x = BorderSize + OffsetSize;
|
||||
int y = BorderSize + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, prop.Name);
|
||||
x += EntryWidth + OffsetSize;
|
||||
|
||||
if (SetGumpID != 0)
|
||||
AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
|
||||
|
||||
x = BorderSize + OffsetSize;
|
||||
y += EntryHeight + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, initialText);
|
||||
x += EntryWidth + OffsetSize;
|
||||
|
||||
if (SetGumpID != 0)
|
||||
AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
|
||||
|
||||
AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 1);
|
||||
|
||||
x = BorderSize + OffsetSize;
|
||||
y += EntryHeight + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Change by Serial");
|
||||
x += EntryWidth + OffsetSize;
|
||||
|
||||
if (SetGumpID != 0)
|
||||
AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
|
||||
|
||||
AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 2);
|
||||
|
||||
x = BorderSize + OffsetSize;
|
||||
y += EntryHeight + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Nullify");
|
||||
x += EntryWidth + OffsetSize;
|
||||
|
||||
if (SetGumpID != 0)
|
||||
AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
|
||||
|
||||
AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 3);
|
||||
|
||||
x = BorderSize + OffsetSize;
|
||||
y += EntryHeight + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "View Properties");
|
||||
x += EntryWidth + OffsetSize;
|
||||
|
||||
if (SetGumpID != 0)
|
||||
AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
|
||||
|
||||
AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 4);
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
bool shouldSend = true;
|
||||
object viewProps = null;
|
||||
|
||||
switch (info.ButtonID)
|
||||
{
|
||||
case 0: // closed
|
||||
{
|
||||
m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
|
||||
shouldSend = false;
|
||||
break;
|
||||
}
|
||||
case 1: // Change by Target
|
||||
{
|
||||
m_Mobile.Target = new SetObjectTarget(m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List);
|
||||
shouldSend = false;
|
||||
break;
|
||||
}
|
||||
case 2: // Change by Serial
|
||||
{
|
||||
shouldSend = false;
|
||||
|
||||
m_Mobile.SendMessage("Enter the serial you wish to find:");
|
||||
m_Mobile.Prompt = new InternalPrompt(m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List);
|
||||
|
||||
break;
|
||||
}
|
||||
case 3: // Nullify
|
||||
{
|
||||
try
|
||||
{
|
||||
CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, "(null)");
|
||||
m_Property.SetValue(m_Object, null, null);
|
||||
PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);
|
||||
}
|
||||
catch
|
||||
{
|
||||
m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 4: // View Properties
|
||||
{
|
||||
object obj = m_Property.GetValue(m_Object, null);
|
||||
|
||||
if (obj == null)
|
||||
m_Mobile.SendMessage("The property is null and so you cannot view its properties.");
|
||||
else if (!BaseCommand.IsAccessible(m_Mobile, obj))
|
||||
m_Mobile.SendMessage("You may not view their properties.");
|
||||
else
|
||||
viewProps = obj;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldSend)
|
||||
m_Mobile.SendGump(new SetObjectGump(m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List));
|
||||
|
||||
if (viewProps != null)
|
||||
m_Mobile.SendGump(new PropertiesGump(m_Mobile, viewProps));
|
||||
}
|
||||
|
||||
private class InternalPrompt : Prompt
|
||||
{
|
||||
private readonly List<object> m_List;
|
||||
private readonly Mobile m_Mobile;
|
||||
private readonly object m_Object;
|
||||
private readonly int m_Page;
|
||||
private readonly PropertyInfo m_Property;
|
||||
private readonly Stack<StackEntry> m_Stack;
|
||||
private readonly Type m_Type;
|
||||
|
||||
public InternalPrompt(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, Type type, int page,
|
||||
List<object> list)
|
||||
{
|
||||
m_Property = prop;
|
||||
m_Mobile = mobile;
|
||||
m_Object = o;
|
||||
m_Stack = stack;
|
||||
m_Type = type;
|
||||
m_Page = page;
|
||||
m_List = list;
|
||||
}
|
||||
|
||||
public override void OnCancel(Mobile from)
|
||||
{
|
||||
m_Mobile.SendGump(new SetObjectGump(m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List));
|
||||
}
|
||||
|
||||
public override void OnResponse(Mobile from, string text)
|
||||
{
|
||||
try
|
||||
{
|
||||
uint serial = Utility.ToUInt32(text);
|
||||
|
||||
IEntity toSet = World.FindEntity(serial);
|
||||
|
||||
if (toSet == null)
|
||||
m_Mobile.SendMessage("No object with that serial was found.");
|
||||
else if (!m_Type.IsInstanceOfType(toSet))
|
||||
m_Mobile.SendMessage("The object with that serial could not be assigned to a property of type : {0}",
|
||||
m_Type.Name);
|
||||
else
|
||||
try
|
||||
{
|
||||
CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name,
|
||||
toSet.ToString());
|
||||
m_Property.SetValue(m_Object, toSet, null);
|
||||
PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);
|
||||
}
|
||||
catch
|
||||
{
|
||||
m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
m_Mobile.SendMessage("Bad format");
|
||||
}
|
||||
|
||||
m_Mobile.SendGump(new SetObjectGump(m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Server.Commands;
|
||||
using Server.Commands.Generic;
|
||||
using Server.Network;
|
||||
using Server.Prompts;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class SetObjectGump : Gump
|
||||
{
|
||||
public static readonly bool OldStyle = PropsConfig.OldStyle;
|
||||
|
||||
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
|
||||
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
|
||||
|
||||
public static readonly int TextHue = PropsConfig.TextHue;
|
||||
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
|
||||
|
||||
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
|
||||
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
|
||||
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
|
||||
public static readonly int BackGumpID = PropsConfig.BackGumpID;
|
||||
public static readonly int SetGumpID = PropsConfig.SetGumpID;
|
||||
|
||||
public static readonly int SetWidth = PropsConfig.SetWidth;
|
||||
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
|
||||
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
|
||||
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
|
||||
|
||||
public static readonly int PrevWidth = PropsConfig.PrevWidth;
|
||||
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
|
||||
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
|
||||
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
|
||||
|
||||
public static readonly int NextWidth = PropsConfig.NextWidth;
|
||||
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
|
||||
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
|
||||
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
|
||||
|
||||
public static readonly int OffsetSize = PropsConfig.OffsetSize;
|
||||
|
||||
public static readonly int EntryHeight = PropsConfig.EntryHeight;
|
||||
public static readonly int BorderSize = PropsConfig.BorderSize;
|
||||
|
||||
private static readonly int EntryWidth = 212;
|
||||
|
||||
private static readonly int TotalWidth = OffsetSize + EntryWidth + OffsetSize + SetWidth + OffsetSize;
|
||||
private static readonly int TotalHeight = OffsetSize + 5 * (EntryHeight + OffsetSize);
|
||||
|
||||
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
|
||||
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
|
||||
private readonly List<object> m_List;
|
||||
private readonly Mobile m_Mobile;
|
||||
private readonly object m_Object;
|
||||
private readonly int m_Page;
|
||||
private readonly PropertyInfo m_Property;
|
||||
private readonly Stack<StackEntry> m_Stack;
|
||||
private readonly Type m_Type;
|
||||
|
||||
public SetObjectGump(
|
||||
PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, Type type, int page,
|
||||
List<object> list
|
||||
) : base(GumpOffsetX, GumpOffsetY)
|
||||
{
|
||||
m_Property = prop;
|
||||
m_Mobile = mobile;
|
||||
m_Object = o;
|
||||
m_Stack = stack;
|
||||
m_Type = type;
|
||||
m_Page = page;
|
||||
m_List = list;
|
||||
|
||||
var initialText = PropertiesGump.ValueToString(o, prop);
|
||||
|
||||
AddPage(0);
|
||||
|
||||
AddBackground(0, 0, BackWidth, BackHeight, BackGumpID);
|
||||
AddImageTiled(
|
||||
BorderSize,
|
||||
BorderSize,
|
||||
TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0),
|
||||
TotalHeight,
|
||||
OffsetGumpID
|
||||
);
|
||||
|
||||
var x = BorderSize + OffsetSize;
|
||||
var y = BorderSize + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, prop.Name);
|
||||
x += EntryWidth + OffsetSize;
|
||||
|
||||
if (SetGumpID != 0)
|
||||
AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
|
||||
|
||||
x = BorderSize + OffsetSize;
|
||||
y += EntryHeight + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, initialText);
|
||||
x += EntryWidth + OffsetSize;
|
||||
|
||||
if (SetGumpID != 0)
|
||||
AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
|
||||
|
||||
AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 1);
|
||||
|
||||
x = BorderSize + OffsetSize;
|
||||
y += EntryHeight + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Change by Serial");
|
||||
x += EntryWidth + OffsetSize;
|
||||
|
||||
if (SetGumpID != 0)
|
||||
AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
|
||||
|
||||
AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 2);
|
||||
|
||||
x = BorderSize + OffsetSize;
|
||||
y += EntryHeight + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Nullify");
|
||||
x += EntryWidth + OffsetSize;
|
||||
|
||||
if (SetGumpID != 0)
|
||||
AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
|
||||
|
||||
AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 3);
|
||||
|
||||
x = BorderSize + OffsetSize;
|
||||
y += EntryHeight + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "View Properties");
|
||||
x += EntryWidth + OffsetSize;
|
||||
|
||||
if (SetGumpID != 0)
|
||||
AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
|
||||
|
||||
AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 4);
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
var shouldSend = true;
|
||||
object viewProps = null;
|
||||
|
||||
switch (info.ButtonID)
|
||||
{
|
||||
case 0: // closed
|
||||
{
|
||||
m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
|
||||
shouldSend = false;
|
||||
break;
|
||||
}
|
||||
case 1: // Change by Target
|
||||
{
|
||||
m_Mobile.Target = new SetObjectTarget(
|
||||
m_Property,
|
||||
m_Mobile,
|
||||
m_Object,
|
||||
m_Stack,
|
||||
m_Type,
|
||||
m_Page,
|
||||
m_List
|
||||
);
|
||||
shouldSend = false;
|
||||
break;
|
||||
}
|
||||
case 2: // Change by Serial
|
||||
{
|
||||
shouldSend = false;
|
||||
|
||||
m_Mobile.SendMessage("Enter the serial you wish to find:");
|
||||
m_Mobile.Prompt = new InternalPrompt(
|
||||
m_Property,
|
||||
m_Mobile,
|
||||
m_Object,
|
||||
m_Stack,
|
||||
m_Type,
|
||||
m_Page,
|
||||
m_List
|
||||
);
|
||||
|
||||
break;
|
||||
}
|
||||
case 3: // Nullify
|
||||
{
|
||||
try
|
||||
{
|
||||
CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, "(null)");
|
||||
m_Property.SetValue(m_Object, null, null);
|
||||
PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);
|
||||
}
|
||||
catch
|
||||
{
|
||||
m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 4: // View Properties
|
||||
{
|
||||
var obj = m_Property.GetValue(m_Object, null);
|
||||
|
||||
if (obj == null)
|
||||
m_Mobile.SendMessage("The property is null and so you cannot view its properties.");
|
||||
else if (!BaseCommand.IsAccessible(m_Mobile, obj))
|
||||
m_Mobile.SendMessage("You may not view their properties.");
|
||||
else
|
||||
viewProps = obj;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldSend)
|
||||
m_Mobile.SendGump(new SetObjectGump(m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List));
|
||||
|
||||
if (viewProps != null)
|
||||
m_Mobile.SendGump(new PropertiesGump(m_Mobile, viewProps));
|
||||
}
|
||||
|
||||
private class InternalPrompt : Prompt
|
||||
{
|
||||
private readonly List<object> m_List;
|
||||
private readonly Mobile m_Mobile;
|
||||
private readonly object m_Object;
|
||||
private readonly int m_Page;
|
||||
private readonly PropertyInfo m_Property;
|
||||
private readonly Stack<StackEntry> m_Stack;
|
||||
private readonly Type m_Type;
|
||||
|
||||
public InternalPrompt(
|
||||
PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, Type type, int page,
|
||||
List<object> list
|
||||
)
|
||||
{
|
||||
m_Property = prop;
|
||||
m_Mobile = mobile;
|
||||
m_Object = o;
|
||||
m_Stack = stack;
|
||||
m_Type = type;
|
||||
m_Page = page;
|
||||
m_List = list;
|
||||
}
|
||||
|
||||
public override void OnCancel(Mobile from)
|
||||
{
|
||||
m_Mobile.SendGump(new SetObjectGump(m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List));
|
||||
}
|
||||
|
||||
public override void OnResponse(Mobile from, string text)
|
||||
{
|
||||
try
|
||||
{
|
||||
var serial = Utility.ToUInt32(text);
|
||||
|
||||
var toSet = World.FindEntity(serial);
|
||||
|
||||
if (toSet == null)
|
||||
m_Mobile.SendMessage("No object with that serial was found.");
|
||||
else if (!m_Type.IsInstanceOfType(toSet))
|
||||
m_Mobile.SendMessage(
|
||||
"The object with that serial could not be assigned to a property of type : {0}",
|
||||
m_Type.Name
|
||||
);
|
||||
else
|
||||
try
|
||||
{
|
||||
CommandLogging.LogChangeProperty(
|
||||
m_Mobile,
|
||||
m_Object,
|
||||
m_Property.Name,
|
||||
toSet.ToString()
|
||||
);
|
||||
m_Property.SetValue(m_Object, toSet, null);
|
||||
PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);
|
||||
}
|
||||
catch
|
||||
{
|
||||
m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
m_Mobile.SendMessage("Bad format");
|
||||
}
|
||||
|
||||
m_Mobile.SendGump(new SetObjectGump(m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,67 +1,69 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Server.Commands;
|
||||
using Server.Items;
|
||||
using Server.Targeting;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class SetObjectTarget : Target
|
||||
{
|
||||
private readonly List<object> m_List;
|
||||
private readonly Mobile m_Mobile;
|
||||
private readonly object m_Object;
|
||||
private readonly int m_Page;
|
||||
private readonly PropertyInfo m_Property;
|
||||
private readonly Stack<StackEntry> m_Stack;
|
||||
private readonly Type m_Type;
|
||||
|
||||
public SetObjectTarget(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, Type type, int page,
|
||||
List<object> list) : base(-1, false, TargetFlags.None)
|
||||
{
|
||||
m_Property = prop;
|
||||
m_Mobile = mobile;
|
||||
m_Object = o;
|
||||
m_Stack = stack;
|
||||
m_Type = type;
|
||||
m_Page = page;
|
||||
m_List = list;
|
||||
}
|
||||
|
||||
protected override void OnTarget(Mobile from, object targeted)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (m_Type == typeof(Type))
|
||||
targeted = targeted.GetType();
|
||||
else if ((m_Type == typeof(BaseAddon) || m_Type.IsAssignableFrom(typeof(BaseAddon))) &&
|
||||
targeted is AddonComponent addonComponent)
|
||||
targeted = addonComponent.Addon;
|
||||
|
||||
if (m_Type.IsInstanceOfType(targeted))
|
||||
{
|
||||
CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, targeted.ToString());
|
||||
m_Property.SetValue(m_Object, targeted, null);
|
||||
PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Mobile.SendMessage("That cannot be assigned to a property of type : {0}", m_Type.Name);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnTargetFinish(Mobile from)
|
||||
{
|
||||
if (m_Type == typeof(Type))
|
||||
from.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
|
||||
else
|
||||
from.SendGump(new SetObjectGump(m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List));
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Server.Commands;
|
||||
using Server.Items;
|
||||
using Server.Targeting;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class SetObjectTarget : Target
|
||||
{
|
||||
private readonly List<object> m_List;
|
||||
private readonly Mobile m_Mobile;
|
||||
private readonly object m_Object;
|
||||
private readonly int m_Page;
|
||||
private readonly PropertyInfo m_Property;
|
||||
private readonly Stack<StackEntry> m_Stack;
|
||||
private readonly Type m_Type;
|
||||
|
||||
public SetObjectTarget(
|
||||
PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, Type type, int page,
|
||||
List<object> list
|
||||
) : base(-1, false, TargetFlags.None)
|
||||
{
|
||||
m_Property = prop;
|
||||
m_Mobile = mobile;
|
||||
m_Object = o;
|
||||
m_Stack = stack;
|
||||
m_Type = type;
|
||||
m_Page = page;
|
||||
m_List = list;
|
||||
}
|
||||
|
||||
protected override void OnTarget(Mobile from, object targeted)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (m_Type == typeof(Type))
|
||||
targeted = targeted.GetType();
|
||||
else if ((m_Type == typeof(BaseAddon) || m_Type.IsAssignableFrom(typeof(BaseAddon))) &&
|
||||
targeted is AddonComponent addonComponent)
|
||||
targeted = addonComponent.Addon;
|
||||
|
||||
if (m_Type.IsInstanceOfType(targeted))
|
||||
{
|
||||
CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, targeted.ToString());
|
||||
m_Property.SetValue(m_Object, targeted, null);
|
||||
PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Mobile.SendMessage("That cannot be assigned to a property of type : {0}", m_Type.Name);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnTargetFinish(Mobile from)
|
||||
{
|
||||
if (m_Type == typeof(Type))
|
||||
from.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
|
||||
else
|
||||
from.SendGump(new SetObjectGump(m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,231 +1,243 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Server.Commands;
|
||||
using Server.Network;
|
||||
using Server.Targeting;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class SetPoint2DGump : Gump
|
||||
{
|
||||
public static readonly bool OldStyle = PropsConfig.OldStyle;
|
||||
|
||||
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
|
||||
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
|
||||
|
||||
public static readonly int TextHue = PropsConfig.TextHue;
|
||||
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
|
||||
|
||||
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
|
||||
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
|
||||
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
|
||||
public static readonly int BackGumpID = PropsConfig.BackGumpID;
|
||||
public static readonly int SetGumpID = PropsConfig.SetGumpID;
|
||||
|
||||
public static readonly int SetWidth = PropsConfig.SetWidth;
|
||||
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
|
||||
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
|
||||
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
|
||||
|
||||
public static readonly int PrevWidth = PropsConfig.PrevWidth;
|
||||
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
|
||||
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
|
||||
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
|
||||
|
||||
public static readonly int NextWidth = PropsConfig.NextWidth;
|
||||
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
|
||||
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
|
||||
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
|
||||
|
||||
public static readonly int OffsetSize = PropsConfig.OffsetSize;
|
||||
|
||||
public static readonly int EntryHeight = PropsConfig.EntryHeight;
|
||||
public static readonly int BorderSize = PropsConfig.BorderSize;
|
||||
|
||||
private static readonly int CoordWidth = 105;
|
||||
private static readonly int EntryWidth = CoordWidth + OffsetSize + CoordWidth;
|
||||
|
||||
private static readonly int TotalWidth = OffsetSize + EntryWidth + OffsetSize + SetWidth + OffsetSize;
|
||||
private static readonly int TotalHeight = OffsetSize + 4 * (EntryHeight + OffsetSize);
|
||||
|
||||
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
|
||||
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
|
||||
private readonly List<object> m_List;
|
||||
private readonly Mobile m_Mobile;
|
||||
private readonly object m_Object;
|
||||
private readonly int m_Page;
|
||||
private readonly PropertyInfo m_Property;
|
||||
private readonly Stack<StackEntry> m_Stack;
|
||||
|
||||
public SetPoint2DGump(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page, List<object> list)
|
||||
: base(GumpOffsetX, GumpOffsetY)
|
||||
{
|
||||
m_Property = prop;
|
||||
m_Mobile = mobile;
|
||||
m_Object = o;
|
||||
m_Stack = stack;
|
||||
m_Page = page;
|
||||
m_List = list;
|
||||
|
||||
Point2D p = (Point2D)prop.GetValue(o, null);
|
||||
|
||||
AddPage(0);
|
||||
|
||||
AddBackground(0, 0, BackWidth, BackHeight, BackGumpID);
|
||||
AddImageTiled(BorderSize, BorderSize, TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0), TotalHeight,
|
||||
OffsetGumpID);
|
||||
|
||||
int x = BorderSize + OffsetSize;
|
||||
int y = BorderSize + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, prop.Name);
|
||||
x += EntryWidth + OffsetSize;
|
||||
|
||||
if (SetGumpID != 0)
|
||||
AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
|
||||
|
||||
x = BorderSize + OffsetSize;
|
||||
y += EntryHeight + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Use your location");
|
||||
x += EntryWidth + OffsetSize;
|
||||
|
||||
if (SetGumpID != 0)
|
||||
AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
|
||||
AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 1);
|
||||
|
||||
x = BorderSize + OffsetSize;
|
||||
y += EntryHeight + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Target a location");
|
||||
x += EntryWidth + OffsetSize;
|
||||
|
||||
if (SetGumpID != 0)
|
||||
AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
|
||||
AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 2);
|
||||
|
||||
x = BorderSize + OffsetSize;
|
||||
y += EntryHeight + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, CoordWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, CoordWidth - TextOffsetX, EntryHeight, TextHue, "X:");
|
||||
AddTextEntry(x + 16, y, CoordWidth - 16, EntryHeight, TextHue, 0, p.X.ToString());
|
||||
x += CoordWidth + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, CoordWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, CoordWidth - TextOffsetX, EntryHeight, TextHue, "Y:");
|
||||
AddTextEntry(x + 16, y, CoordWidth - 16, EntryHeight, TextHue, 1, p.Y.ToString());
|
||||
x += CoordWidth + OffsetSize;
|
||||
|
||||
if (SetGumpID != 0)
|
||||
AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
|
||||
AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 3);
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
Point2D toSet;
|
||||
bool shouldSet, shouldSend;
|
||||
|
||||
switch (info.ButtonID)
|
||||
{
|
||||
case 1: // Current location
|
||||
{
|
||||
toSet = new Point2D(m_Mobile.Location);
|
||||
shouldSet = true;
|
||||
shouldSend = true;
|
||||
|
||||
break;
|
||||
}
|
||||
case 2: // Pick location
|
||||
{
|
||||
m_Mobile.Target = new InternalTarget(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List);
|
||||
|
||||
toSet = Point2D.Zero;
|
||||
shouldSet = false;
|
||||
shouldSend = false;
|
||||
|
||||
break;
|
||||
}
|
||||
case 3: // Use values
|
||||
{
|
||||
TextRelay x = info.GetTextEntry(0);
|
||||
TextRelay y = info.GetTextEntry(1);
|
||||
|
||||
toSet = new Point2D(x == null ? 0 : Utility.ToInt32(x.Text), y == null ? 0 : Utility.ToInt32(y.Text));
|
||||
shouldSet = true;
|
||||
shouldSend = true;
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
toSet = Point2D.Zero;
|
||||
shouldSet = false;
|
||||
shouldSend = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldSet)
|
||||
try
|
||||
{
|
||||
CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, toSet.ToString());
|
||||
m_Property.SetValue(m_Object, toSet, null);
|
||||
PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);
|
||||
}
|
||||
catch
|
||||
{
|
||||
m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
|
||||
}
|
||||
|
||||
if (shouldSend)
|
||||
m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
|
||||
}
|
||||
|
||||
private class InternalTarget : Target
|
||||
{
|
||||
private readonly List<object> m_List;
|
||||
private readonly Mobile m_Mobile;
|
||||
private readonly object m_Object;
|
||||
private readonly int m_Page;
|
||||
private readonly PropertyInfo m_Property;
|
||||
private readonly Stack<StackEntry> m_Stack;
|
||||
|
||||
public InternalTarget(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page,
|
||||
List<object> list) : base(-1, true, TargetFlags.None)
|
||||
{
|
||||
m_Property = prop;
|
||||
m_Mobile = mobile;
|
||||
m_Object = o;
|
||||
m_Stack = stack;
|
||||
m_Page = page;
|
||||
m_List = list;
|
||||
}
|
||||
|
||||
protected override void OnTarget(Mobile from, object targeted)
|
||||
{
|
||||
if (targeted is IPoint3D p)
|
||||
try
|
||||
{
|
||||
CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, new Point2D(p).ToString());
|
||||
m_Property.SetValue(m_Object, new Point2D(p), null);
|
||||
PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);
|
||||
}
|
||||
catch
|
||||
{
|
||||
m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnTargetFinish(Mobile from)
|
||||
{
|
||||
m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Server.Commands;
|
||||
using Server.Network;
|
||||
using Server.Targeting;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class SetPoint2DGump : Gump
|
||||
{
|
||||
public static readonly bool OldStyle = PropsConfig.OldStyle;
|
||||
|
||||
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
|
||||
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
|
||||
|
||||
public static readonly int TextHue = PropsConfig.TextHue;
|
||||
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
|
||||
|
||||
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
|
||||
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
|
||||
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
|
||||
public static readonly int BackGumpID = PropsConfig.BackGumpID;
|
||||
public static readonly int SetGumpID = PropsConfig.SetGumpID;
|
||||
|
||||
public static readonly int SetWidth = PropsConfig.SetWidth;
|
||||
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
|
||||
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
|
||||
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
|
||||
|
||||
public static readonly int PrevWidth = PropsConfig.PrevWidth;
|
||||
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
|
||||
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
|
||||
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
|
||||
|
||||
public static readonly int NextWidth = PropsConfig.NextWidth;
|
||||
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
|
||||
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
|
||||
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
|
||||
|
||||
public static readonly int OffsetSize = PropsConfig.OffsetSize;
|
||||
|
||||
public static readonly int EntryHeight = PropsConfig.EntryHeight;
|
||||
public static readonly int BorderSize = PropsConfig.BorderSize;
|
||||
|
||||
private static readonly int CoordWidth = 105;
|
||||
private static readonly int EntryWidth = CoordWidth + OffsetSize + CoordWidth;
|
||||
|
||||
private static readonly int TotalWidth = OffsetSize + EntryWidth + OffsetSize + SetWidth + OffsetSize;
|
||||
private static readonly int TotalHeight = OffsetSize + 4 * (EntryHeight + OffsetSize);
|
||||
|
||||
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
|
||||
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
|
||||
private readonly List<object> m_List;
|
||||
private readonly Mobile m_Mobile;
|
||||
private readonly object m_Object;
|
||||
private readonly int m_Page;
|
||||
private readonly PropertyInfo m_Property;
|
||||
private readonly Stack<StackEntry> m_Stack;
|
||||
|
||||
public SetPoint2DGump(
|
||||
PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page, List<object> list
|
||||
)
|
||||
: base(GumpOffsetX, GumpOffsetY)
|
||||
{
|
||||
m_Property = prop;
|
||||
m_Mobile = mobile;
|
||||
m_Object = o;
|
||||
m_Stack = stack;
|
||||
m_Page = page;
|
||||
m_List = list;
|
||||
|
||||
var p = (Point2D)prop.GetValue(o, null);
|
||||
|
||||
AddPage(0);
|
||||
|
||||
AddBackground(0, 0, BackWidth, BackHeight, BackGumpID);
|
||||
AddImageTiled(
|
||||
BorderSize,
|
||||
BorderSize,
|
||||
TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0),
|
||||
TotalHeight,
|
||||
OffsetGumpID
|
||||
);
|
||||
|
||||
var x = BorderSize + OffsetSize;
|
||||
var y = BorderSize + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, prop.Name);
|
||||
x += EntryWidth + OffsetSize;
|
||||
|
||||
if (SetGumpID != 0)
|
||||
AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
|
||||
|
||||
x = BorderSize + OffsetSize;
|
||||
y += EntryHeight + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Use your location");
|
||||
x += EntryWidth + OffsetSize;
|
||||
|
||||
if (SetGumpID != 0)
|
||||
AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
|
||||
AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 1);
|
||||
|
||||
x = BorderSize + OffsetSize;
|
||||
y += EntryHeight + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Target a location");
|
||||
x += EntryWidth + OffsetSize;
|
||||
|
||||
if (SetGumpID != 0)
|
||||
AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
|
||||
AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 2);
|
||||
|
||||
x = BorderSize + OffsetSize;
|
||||
y += EntryHeight + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, CoordWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, CoordWidth - TextOffsetX, EntryHeight, TextHue, "X:");
|
||||
AddTextEntry(x + 16, y, CoordWidth - 16, EntryHeight, TextHue, 0, p.X.ToString());
|
||||
x += CoordWidth + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, CoordWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, CoordWidth - TextOffsetX, EntryHeight, TextHue, "Y:");
|
||||
AddTextEntry(x + 16, y, CoordWidth - 16, EntryHeight, TextHue, 1, p.Y.ToString());
|
||||
x += CoordWidth + OffsetSize;
|
||||
|
||||
if (SetGumpID != 0)
|
||||
AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
|
||||
AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 3);
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
Point2D toSet;
|
||||
bool shouldSet, shouldSend;
|
||||
|
||||
switch (info.ButtonID)
|
||||
{
|
||||
case 1: // Current location
|
||||
{
|
||||
toSet = new Point2D(m_Mobile.Location);
|
||||
shouldSet = true;
|
||||
shouldSend = true;
|
||||
|
||||
break;
|
||||
}
|
||||
case 2: // Pick location
|
||||
{
|
||||
m_Mobile.Target = new InternalTarget(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List);
|
||||
|
||||
toSet = Point2D.Zero;
|
||||
shouldSet = false;
|
||||
shouldSend = false;
|
||||
|
||||
break;
|
||||
}
|
||||
case 3: // Use values
|
||||
{
|
||||
var x = info.GetTextEntry(0);
|
||||
var y = info.GetTextEntry(1);
|
||||
|
||||
toSet = new Point2D(
|
||||
x == null ? 0 : Utility.ToInt32(x.Text),
|
||||
y == null ? 0 : Utility.ToInt32(y.Text)
|
||||
);
|
||||
shouldSet = true;
|
||||
shouldSend = true;
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
toSet = Point2D.Zero;
|
||||
shouldSet = false;
|
||||
shouldSend = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldSet)
|
||||
try
|
||||
{
|
||||
CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, toSet.ToString());
|
||||
m_Property.SetValue(m_Object, toSet, null);
|
||||
PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);
|
||||
}
|
||||
catch
|
||||
{
|
||||
m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
|
||||
}
|
||||
|
||||
if (shouldSend)
|
||||
m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
|
||||
}
|
||||
|
||||
private class InternalTarget : Target
|
||||
{
|
||||
private readonly List<object> m_List;
|
||||
private readonly Mobile m_Mobile;
|
||||
private readonly object m_Object;
|
||||
private readonly int m_Page;
|
||||
private readonly PropertyInfo m_Property;
|
||||
private readonly Stack<StackEntry> m_Stack;
|
||||
|
||||
public InternalTarget(
|
||||
PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page,
|
||||
List<object> list
|
||||
) : base(-1, true, TargetFlags.None)
|
||||
{
|
||||
m_Property = prop;
|
||||
m_Mobile = mobile;
|
||||
m_Object = o;
|
||||
m_Stack = stack;
|
||||
m_Page = page;
|
||||
m_List = list;
|
||||
}
|
||||
|
||||
protected override void OnTarget(Mobile from, object targeted)
|
||||
{
|
||||
if (targeted is IPoint3D p)
|
||||
try
|
||||
{
|
||||
CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, new Point2D(p).ToString());
|
||||
m_Property.SetValue(m_Object, new Point2D(p), null);
|
||||
PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);
|
||||
}
|
||||
catch
|
||||
{
|
||||
m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnTargetFinish(Mobile from)
|
||||
{
|
||||
m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,238 +1,250 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Server.Commands;
|
||||
using Server.Network;
|
||||
using Server.Targeting;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class SetPoint3DGump : Gump
|
||||
{
|
||||
public static readonly bool OldStyle = PropsConfig.OldStyle;
|
||||
|
||||
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
|
||||
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
|
||||
|
||||
public static readonly int TextHue = PropsConfig.TextHue;
|
||||
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
|
||||
|
||||
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
|
||||
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
|
||||
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
|
||||
public static readonly int BackGumpID = PropsConfig.BackGumpID;
|
||||
public static readonly int SetGumpID = PropsConfig.SetGumpID;
|
||||
|
||||
public static readonly int SetWidth = PropsConfig.SetWidth;
|
||||
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
|
||||
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
|
||||
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
|
||||
|
||||
public static readonly int PrevWidth = PropsConfig.PrevWidth;
|
||||
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
|
||||
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
|
||||
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
|
||||
|
||||
public static readonly int NextWidth = PropsConfig.NextWidth;
|
||||
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
|
||||
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
|
||||
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
|
||||
|
||||
public static readonly int OffsetSize = PropsConfig.OffsetSize;
|
||||
|
||||
public static readonly int EntryHeight = PropsConfig.EntryHeight;
|
||||
public static readonly int BorderSize = PropsConfig.BorderSize;
|
||||
|
||||
private static readonly int CoordWidth = 70;
|
||||
private static readonly int EntryWidth = CoordWidth + OffsetSize + CoordWidth + OffsetSize + CoordWidth;
|
||||
|
||||
private static readonly int TotalWidth = OffsetSize + EntryWidth + OffsetSize + SetWidth + OffsetSize;
|
||||
private static readonly int TotalHeight = OffsetSize + 4 * (EntryHeight + OffsetSize);
|
||||
|
||||
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
|
||||
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
|
||||
private readonly List<object> m_List;
|
||||
private readonly Mobile m_Mobile;
|
||||
private readonly object m_Object;
|
||||
private readonly int m_Page;
|
||||
private readonly PropertyInfo m_Property;
|
||||
private readonly Stack<StackEntry> m_Stack;
|
||||
|
||||
public SetPoint3DGump(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page, List<object> list)
|
||||
: base(GumpOffsetX, GumpOffsetY)
|
||||
{
|
||||
m_Property = prop;
|
||||
m_Mobile = mobile;
|
||||
m_Object = o;
|
||||
m_Stack = stack;
|
||||
m_Page = page;
|
||||
m_List = list;
|
||||
|
||||
Point3D p = (Point3D)prop.GetValue(o, null);
|
||||
|
||||
AddPage(0);
|
||||
|
||||
AddBackground(0, 0, BackWidth, BackHeight, BackGumpID);
|
||||
AddImageTiled(BorderSize, BorderSize, TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0), TotalHeight,
|
||||
OffsetGumpID);
|
||||
|
||||
int x = BorderSize + OffsetSize;
|
||||
int y = BorderSize + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, prop.Name);
|
||||
x += EntryWidth + OffsetSize;
|
||||
|
||||
if (SetGumpID != 0)
|
||||
AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
|
||||
|
||||
x = BorderSize + OffsetSize;
|
||||
y += EntryHeight + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Use your location");
|
||||
x += EntryWidth + OffsetSize;
|
||||
|
||||
if (SetGumpID != 0)
|
||||
AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
|
||||
AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 1);
|
||||
|
||||
x = BorderSize + OffsetSize;
|
||||
y += EntryHeight + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Target a location");
|
||||
x += EntryWidth + OffsetSize;
|
||||
|
||||
if (SetGumpID != 0)
|
||||
AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
|
||||
AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 2);
|
||||
|
||||
x = BorderSize + OffsetSize;
|
||||
y += EntryHeight + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, CoordWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, CoordWidth - TextOffsetX, EntryHeight, TextHue, "X:");
|
||||
AddTextEntry(x + 16, y, CoordWidth - 16, EntryHeight, TextHue, 0, p.X.ToString());
|
||||
x += CoordWidth + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, CoordWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, CoordWidth - TextOffsetX, EntryHeight, TextHue, "Y:");
|
||||
AddTextEntry(x + 16, y, CoordWidth - 16, EntryHeight, TextHue, 1, p.Y.ToString());
|
||||
x += CoordWidth + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, CoordWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, CoordWidth - TextOffsetX, EntryHeight, TextHue, "Z:");
|
||||
AddTextEntry(x + 16, y, CoordWidth - 16, EntryHeight, TextHue, 2, p.Z.ToString());
|
||||
x += CoordWidth + OffsetSize;
|
||||
|
||||
if (SetGumpID != 0)
|
||||
AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
|
||||
AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 3);
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
Point3D toSet;
|
||||
bool shouldSet, shouldSend;
|
||||
|
||||
switch (info.ButtonID)
|
||||
{
|
||||
case 1: // Current location
|
||||
{
|
||||
toSet = m_Mobile.Location;
|
||||
shouldSet = true;
|
||||
shouldSend = true;
|
||||
|
||||
break;
|
||||
}
|
||||
case 2: // Pick location
|
||||
{
|
||||
m_Mobile.Target = new InternalTarget(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List);
|
||||
|
||||
toSet = Point3D.Zero;
|
||||
shouldSet = false;
|
||||
shouldSend = false;
|
||||
|
||||
break;
|
||||
}
|
||||
case 3: // Use values
|
||||
{
|
||||
TextRelay x = info.GetTextEntry(0);
|
||||
TextRelay y = info.GetTextEntry(1);
|
||||
TextRelay z = info.GetTextEntry(2);
|
||||
|
||||
toSet = new Point3D(x == null ? 0 : Utility.ToInt32(x.Text), y == null ? 0 : Utility.ToInt32(y.Text),
|
||||
z == null ? 0 : Utility.ToInt32(z.Text));
|
||||
shouldSet = true;
|
||||
shouldSend = true;
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
toSet = Point3D.Zero;
|
||||
shouldSet = false;
|
||||
shouldSend = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldSet)
|
||||
try
|
||||
{
|
||||
CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, toSet.ToString());
|
||||
m_Property.SetValue(m_Object, toSet, null);
|
||||
PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);
|
||||
}
|
||||
catch
|
||||
{
|
||||
m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
|
||||
}
|
||||
|
||||
if (shouldSend)
|
||||
m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
|
||||
}
|
||||
|
||||
private class InternalTarget : Target
|
||||
{
|
||||
private readonly List<object> m_List;
|
||||
private readonly Mobile m_Mobile;
|
||||
private readonly object m_Object;
|
||||
private readonly int m_Page;
|
||||
private readonly PropertyInfo m_Property;
|
||||
private readonly Stack<StackEntry> m_Stack;
|
||||
|
||||
public InternalTarget(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page,
|
||||
List<object> list) : base(-1, true, TargetFlags.None)
|
||||
{
|
||||
m_Property = prop;
|
||||
m_Mobile = mobile;
|
||||
m_Object = o;
|
||||
m_Stack = stack;
|
||||
m_Page = page;
|
||||
m_List = list;
|
||||
}
|
||||
|
||||
protected override void OnTarget(Mobile from, object targeted)
|
||||
{
|
||||
if (targeted is IPoint3D p)
|
||||
try
|
||||
{
|
||||
CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, new Point3D(p).ToString());
|
||||
m_Property.SetValue(m_Object, new Point3D(p), null);
|
||||
PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);
|
||||
}
|
||||
catch
|
||||
{
|
||||
m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnTargetFinish(Mobile from)
|
||||
{
|
||||
m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Server.Commands;
|
||||
using Server.Network;
|
||||
using Server.Targeting;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class SetPoint3DGump : Gump
|
||||
{
|
||||
public static readonly bool OldStyle = PropsConfig.OldStyle;
|
||||
|
||||
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
|
||||
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
|
||||
|
||||
public static readonly int TextHue = PropsConfig.TextHue;
|
||||
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
|
||||
|
||||
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
|
||||
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
|
||||
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
|
||||
public static readonly int BackGumpID = PropsConfig.BackGumpID;
|
||||
public static readonly int SetGumpID = PropsConfig.SetGumpID;
|
||||
|
||||
public static readonly int SetWidth = PropsConfig.SetWidth;
|
||||
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
|
||||
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
|
||||
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
|
||||
|
||||
public static readonly int PrevWidth = PropsConfig.PrevWidth;
|
||||
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
|
||||
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
|
||||
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
|
||||
|
||||
public static readonly int NextWidth = PropsConfig.NextWidth;
|
||||
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
|
||||
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
|
||||
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
|
||||
|
||||
public static readonly int OffsetSize = PropsConfig.OffsetSize;
|
||||
|
||||
public static readonly int EntryHeight = PropsConfig.EntryHeight;
|
||||
public static readonly int BorderSize = PropsConfig.BorderSize;
|
||||
|
||||
private static readonly int CoordWidth = 70;
|
||||
private static readonly int EntryWidth = CoordWidth + OffsetSize + CoordWidth + OffsetSize + CoordWidth;
|
||||
|
||||
private static readonly int TotalWidth = OffsetSize + EntryWidth + OffsetSize + SetWidth + OffsetSize;
|
||||
private static readonly int TotalHeight = OffsetSize + 4 * (EntryHeight + OffsetSize);
|
||||
|
||||
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
|
||||
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
|
||||
private readonly List<object> m_List;
|
||||
private readonly Mobile m_Mobile;
|
||||
private readonly object m_Object;
|
||||
private readonly int m_Page;
|
||||
private readonly PropertyInfo m_Property;
|
||||
private readonly Stack<StackEntry> m_Stack;
|
||||
|
||||
public SetPoint3DGump(
|
||||
PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page, List<object> list
|
||||
)
|
||||
: base(GumpOffsetX, GumpOffsetY)
|
||||
{
|
||||
m_Property = prop;
|
||||
m_Mobile = mobile;
|
||||
m_Object = o;
|
||||
m_Stack = stack;
|
||||
m_Page = page;
|
||||
m_List = list;
|
||||
|
||||
var p = (Point3D)prop.GetValue(o, null);
|
||||
|
||||
AddPage(0);
|
||||
|
||||
AddBackground(0, 0, BackWidth, BackHeight, BackGumpID);
|
||||
AddImageTiled(
|
||||
BorderSize,
|
||||
BorderSize,
|
||||
TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0),
|
||||
TotalHeight,
|
||||
OffsetGumpID
|
||||
);
|
||||
|
||||
var x = BorderSize + OffsetSize;
|
||||
var y = BorderSize + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, prop.Name);
|
||||
x += EntryWidth + OffsetSize;
|
||||
|
||||
if (SetGumpID != 0)
|
||||
AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
|
||||
|
||||
x = BorderSize + OffsetSize;
|
||||
y += EntryHeight + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Use your location");
|
||||
x += EntryWidth + OffsetSize;
|
||||
|
||||
if (SetGumpID != 0)
|
||||
AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
|
||||
AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 1);
|
||||
|
||||
x = BorderSize + OffsetSize;
|
||||
y += EntryHeight + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Target a location");
|
||||
x += EntryWidth + OffsetSize;
|
||||
|
||||
if (SetGumpID != 0)
|
||||
AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
|
||||
AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 2);
|
||||
|
||||
x = BorderSize + OffsetSize;
|
||||
y += EntryHeight + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, CoordWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, CoordWidth - TextOffsetX, EntryHeight, TextHue, "X:");
|
||||
AddTextEntry(x + 16, y, CoordWidth - 16, EntryHeight, TextHue, 0, p.X.ToString());
|
||||
x += CoordWidth + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, CoordWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, CoordWidth - TextOffsetX, EntryHeight, TextHue, "Y:");
|
||||
AddTextEntry(x + 16, y, CoordWidth - 16, EntryHeight, TextHue, 1, p.Y.ToString());
|
||||
x += CoordWidth + OffsetSize;
|
||||
|
||||
AddImageTiled(x, y, CoordWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, CoordWidth - TextOffsetX, EntryHeight, TextHue, "Z:");
|
||||
AddTextEntry(x + 16, y, CoordWidth - 16, EntryHeight, TextHue, 2, p.Z.ToString());
|
||||
x += CoordWidth + OffsetSize;
|
||||
|
||||
if (SetGumpID != 0)
|
||||
AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
|
||||
AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 3);
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
Point3D toSet;
|
||||
bool shouldSet, shouldSend;
|
||||
|
||||
switch (info.ButtonID)
|
||||
{
|
||||
case 1: // Current location
|
||||
{
|
||||
toSet = m_Mobile.Location;
|
||||
shouldSet = true;
|
||||
shouldSend = true;
|
||||
|
||||
break;
|
||||
}
|
||||
case 2: // Pick location
|
||||
{
|
||||
m_Mobile.Target = new InternalTarget(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List);
|
||||
|
||||
toSet = Point3D.Zero;
|
||||
shouldSet = false;
|
||||
shouldSend = false;
|
||||
|
||||
break;
|
||||
}
|
||||
case 3: // Use values
|
||||
{
|
||||
var x = info.GetTextEntry(0);
|
||||
var y = info.GetTextEntry(1);
|
||||
var z = info.GetTextEntry(2);
|
||||
|
||||
toSet = new Point3D(
|
||||
x == null ? 0 : Utility.ToInt32(x.Text),
|
||||
y == null ? 0 : Utility.ToInt32(y.Text),
|
||||
z == null ? 0 : Utility.ToInt32(z.Text)
|
||||
);
|
||||
shouldSet = true;
|
||||
shouldSend = true;
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
toSet = Point3D.Zero;
|
||||
shouldSet = false;
|
||||
shouldSend = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldSet)
|
||||
try
|
||||
{
|
||||
CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, toSet.ToString());
|
||||
m_Property.SetValue(m_Object, toSet, null);
|
||||
PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);
|
||||
}
|
||||
catch
|
||||
{
|
||||
m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
|
||||
}
|
||||
|
||||
if (shouldSend)
|
||||
m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
|
||||
}
|
||||
|
||||
private class InternalTarget : Target
|
||||
{
|
||||
private readonly List<object> m_List;
|
||||
private readonly Mobile m_Mobile;
|
||||
private readonly object m_Object;
|
||||
private readonly int m_Page;
|
||||
private readonly PropertyInfo m_Property;
|
||||
private readonly Stack<StackEntry> m_Stack;
|
||||
|
||||
public InternalTarget(
|
||||
PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page,
|
||||
List<object> list
|
||||
) : base(-1, true, TargetFlags.None)
|
||||
{
|
||||
m_Property = prop;
|
||||
m_Mobile = mobile;
|
||||
m_Object = o;
|
||||
m_Stack = stack;
|
||||
m_Page = page;
|
||||
m_List = list;
|
||||
}
|
||||
|
||||
protected override void OnTarget(Mobile from, object targeted)
|
||||
{
|
||||
if (targeted is IPoint3D p)
|
||||
try
|
||||
{
|
||||
CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, new Point3D(p).ToString());
|
||||
m_Property.SetValue(m_Object, new Point3D(p), null);
|
||||
PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);
|
||||
}
|
||||
catch
|
||||
{
|
||||
m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnTargetFinish(Mobile from)
|
||||
{
|
||||
m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,229 +1,236 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Server.Commands;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class SetTimeSpanGump : Gump
|
||||
{
|
||||
public static readonly bool OldStyle = PropsConfig.OldStyle;
|
||||
|
||||
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
|
||||
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
|
||||
|
||||
public static readonly int TextHue = PropsConfig.TextHue;
|
||||
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
|
||||
|
||||
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
|
||||
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
|
||||
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
|
||||
public static readonly int BackGumpID = PropsConfig.BackGumpID;
|
||||
public static readonly int SetGumpID = PropsConfig.SetGumpID;
|
||||
|
||||
public static readonly int SetWidth = PropsConfig.SetWidth;
|
||||
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
|
||||
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
|
||||
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
|
||||
|
||||
public static readonly int PrevWidth = PropsConfig.PrevWidth;
|
||||
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
|
||||
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
|
||||
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
|
||||
|
||||
public static readonly int NextWidth = PropsConfig.NextWidth;
|
||||
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
|
||||
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
|
||||
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
|
||||
|
||||
public static readonly int OffsetSize = PropsConfig.OffsetSize;
|
||||
|
||||
public static readonly int EntryHeight = PropsConfig.EntryHeight;
|
||||
public static readonly int BorderSize = PropsConfig.BorderSize;
|
||||
|
||||
private static readonly int EntryWidth = 212;
|
||||
|
||||
private static readonly int TotalWidth = OffsetSize + EntryWidth + OffsetSize + SetWidth + OffsetSize;
|
||||
private static readonly int TotalHeight = OffsetSize + 7 * (EntryHeight + OffsetSize);
|
||||
|
||||
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
|
||||
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
|
||||
private readonly List<object> m_List;
|
||||
private readonly Mobile m_Mobile;
|
||||
private readonly object m_Object;
|
||||
private readonly int m_Page;
|
||||
private readonly PropertyInfo m_Property;
|
||||
private readonly Stack<StackEntry> m_Stack;
|
||||
|
||||
public SetTimeSpanGump(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page, List<object> list)
|
||||
: base(GumpOffsetX, GumpOffsetY)
|
||||
{
|
||||
m_Property = prop;
|
||||
m_Mobile = mobile;
|
||||
m_Object = o;
|
||||
m_Stack = stack;
|
||||
m_Page = page;
|
||||
m_List = list;
|
||||
|
||||
TimeSpan ts = (TimeSpan)prop.GetValue(o, null);
|
||||
|
||||
AddPage(0);
|
||||
|
||||
AddBackground(0, 0, BackWidth, BackHeight, BackGumpID);
|
||||
AddImageTiled(BorderSize, BorderSize, TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0), TotalHeight,
|
||||
OffsetGumpID);
|
||||
|
||||
AddRect(0, prop.Name, 0, -1);
|
||||
AddRect(1, ts.ToString(), 0, -1);
|
||||
AddRect(2, "Zero", 1, -1);
|
||||
AddRect(3, "From H:M:S", 2, -1);
|
||||
AddRect(4, "H:", 3, 0);
|
||||
AddRect(5, "M:", 4, 1);
|
||||
AddRect(6, "S:", 5, 2);
|
||||
}
|
||||
|
||||
private void AddRect(int index, string str, int button, int text)
|
||||
{
|
||||
int x = BorderSize + OffsetSize;
|
||||
int y = BorderSize + OffsetSize + index * (EntryHeight + OffsetSize);
|
||||
|
||||
AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, str);
|
||||
|
||||
if (text != -1)
|
||||
AddTextEntry(x + 16 + TextOffsetX, y, EntryWidth - TextOffsetX - 16, EntryHeight, TextHue, text, "");
|
||||
|
||||
x += EntryWidth + OffsetSize;
|
||||
|
||||
if (SetGumpID != 0)
|
||||
AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
|
||||
|
||||
if (button != 0)
|
||||
AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, button);
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
TimeSpan toSet;
|
||||
bool shouldSet, shouldSend;
|
||||
|
||||
TextRelay h = info.GetTextEntry(0);
|
||||
TextRelay m = info.GetTextEntry(1);
|
||||
TextRelay s = info.GetTextEntry(2);
|
||||
|
||||
switch (info.ButtonID)
|
||||
{
|
||||
case 1: // Zero
|
||||
{
|
||||
toSet = TimeSpan.Zero;
|
||||
shouldSet = true;
|
||||
shouldSend = true;
|
||||
|
||||
break;
|
||||
}
|
||||
case 2: // From H:M:S
|
||||
{
|
||||
bool successfulParse = false;
|
||||
if (h != null && m != null && s != null)
|
||||
successfulParse = TimeSpan.TryParse($"{h.Text}:{m.Text}:{s.Text}", out toSet);
|
||||
else
|
||||
toSet = TimeSpan.Zero;
|
||||
|
||||
shouldSet = shouldSend = successfulParse;
|
||||
|
||||
break;
|
||||
}
|
||||
case 3: // From H
|
||||
{
|
||||
if (h != null)
|
||||
try
|
||||
{
|
||||
toSet = TimeSpan.FromHours(Utility.ToDouble(h.Text));
|
||||
shouldSet = true;
|
||||
shouldSend = true;
|
||||
|
||||
break;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
toSet = TimeSpan.Zero;
|
||||
shouldSet = false;
|
||||
shouldSend = false;
|
||||
|
||||
break;
|
||||
}
|
||||
case 4: // From M
|
||||
{
|
||||
if (m != null)
|
||||
try
|
||||
{
|
||||
toSet = TimeSpan.FromMinutes(Utility.ToDouble(m.Text));
|
||||
shouldSet = true;
|
||||
shouldSend = true;
|
||||
|
||||
break;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
toSet = TimeSpan.Zero;
|
||||
shouldSet = false;
|
||||
shouldSend = false;
|
||||
|
||||
break;
|
||||
}
|
||||
case 5: // From S
|
||||
{
|
||||
if (s != null)
|
||||
try
|
||||
{
|
||||
toSet = TimeSpan.FromSeconds(Utility.ToDouble(s.Text));
|
||||
shouldSet = true;
|
||||
shouldSend = true;
|
||||
|
||||
break;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
toSet = TimeSpan.Zero;
|
||||
shouldSet = false;
|
||||
shouldSend = false;
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
toSet = TimeSpan.Zero;
|
||||
shouldSet = false;
|
||||
shouldSend = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldSet)
|
||||
try
|
||||
{
|
||||
CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, toSet.ToString());
|
||||
m_Property.SetValue(m_Object, toSet, null);
|
||||
PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);
|
||||
}
|
||||
catch
|
||||
{
|
||||
m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
|
||||
}
|
||||
|
||||
if (shouldSend)
|
||||
m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Server.Commands;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class SetTimeSpanGump : Gump
|
||||
{
|
||||
public static readonly bool OldStyle = PropsConfig.OldStyle;
|
||||
|
||||
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
|
||||
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
|
||||
|
||||
public static readonly int TextHue = PropsConfig.TextHue;
|
||||
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
|
||||
|
||||
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
|
||||
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
|
||||
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
|
||||
public static readonly int BackGumpID = PropsConfig.BackGumpID;
|
||||
public static readonly int SetGumpID = PropsConfig.SetGumpID;
|
||||
|
||||
public static readonly int SetWidth = PropsConfig.SetWidth;
|
||||
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
|
||||
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
|
||||
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
|
||||
|
||||
public static readonly int PrevWidth = PropsConfig.PrevWidth;
|
||||
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
|
||||
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
|
||||
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
|
||||
|
||||
public static readonly int NextWidth = PropsConfig.NextWidth;
|
||||
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
|
||||
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
|
||||
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
|
||||
|
||||
public static readonly int OffsetSize = PropsConfig.OffsetSize;
|
||||
|
||||
public static readonly int EntryHeight = PropsConfig.EntryHeight;
|
||||
public static readonly int BorderSize = PropsConfig.BorderSize;
|
||||
|
||||
private static readonly int EntryWidth = 212;
|
||||
|
||||
private static readonly int TotalWidth = OffsetSize + EntryWidth + OffsetSize + SetWidth + OffsetSize;
|
||||
private static readonly int TotalHeight = OffsetSize + 7 * (EntryHeight + OffsetSize);
|
||||
|
||||
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
|
||||
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
|
||||
private readonly List<object> m_List;
|
||||
private readonly Mobile m_Mobile;
|
||||
private readonly object m_Object;
|
||||
private readonly int m_Page;
|
||||
private readonly PropertyInfo m_Property;
|
||||
private readonly Stack<StackEntry> m_Stack;
|
||||
|
||||
public SetTimeSpanGump(
|
||||
PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page, List<object> list
|
||||
)
|
||||
: base(GumpOffsetX, GumpOffsetY)
|
||||
{
|
||||
m_Property = prop;
|
||||
m_Mobile = mobile;
|
||||
m_Object = o;
|
||||
m_Stack = stack;
|
||||
m_Page = page;
|
||||
m_List = list;
|
||||
|
||||
var ts = (TimeSpan)prop.GetValue(o, null);
|
||||
|
||||
AddPage(0);
|
||||
|
||||
AddBackground(0, 0, BackWidth, BackHeight, BackGumpID);
|
||||
AddImageTiled(
|
||||
BorderSize,
|
||||
BorderSize,
|
||||
TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0),
|
||||
TotalHeight,
|
||||
OffsetGumpID
|
||||
);
|
||||
|
||||
AddRect(0, prop.Name, 0, -1);
|
||||
AddRect(1, ts.ToString(), 0, -1);
|
||||
AddRect(2, "Zero", 1, -1);
|
||||
AddRect(3, "From H:M:S", 2, -1);
|
||||
AddRect(4, "H:", 3, 0);
|
||||
AddRect(5, "M:", 4, 1);
|
||||
AddRect(6, "S:", 5, 2);
|
||||
}
|
||||
|
||||
private void AddRect(int index, string str, int button, int text)
|
||||
{
|
||||
var x = BorderSize + OffsetSize;
|
||||
var y = BorderSize + OffsetSize + index * (EntryHeight + OffsetSize);
|
||||
|
||||
AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
|
||||
AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, str);
|
||||
|
||||
if (text != -1)
|
||||
AddTextEntry(x + 16 + TextOffsetX, y, EntryWidth - TextOffsetX - 16, EntryHeight, TextHue, text, "");
|
||||
|
||||
x += EntryWidth + OffsetSize;
|
||||
|
||||
if (SetGumpID != 0)
|
||||
AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
|
||||
|
||||
if (button != 0)
|
||||
AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, button);
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
TimeSpan toSet;
|
||||
bool shouldSet, shouldSend;
|
||||
|
||||
var h = info.GetTextEntry(0);
|
||||
var m = info.GetTextEntry(1);
|
||||
var s = info.GetTextEntry(2);
|
||||
|
||||
switch (info.ButtonID)
|
||||
{
|
||||
case 1: // Zero
|
||||
{
|
||||
toSet = TimeSpan.Zero;
|
||||
shouldSet = true;
|
||||
shouldSend = true;
|
||||
|
||||
break;
|
||||
}
|
||||
case 2: // From H:M:S
|
||||
{
|
||||
var successfulParse = false;
|
||||
if (h != null && m != null && s != null)
|
||||
successfulParse = TimeSpan.TryParse($"{h.Text}:{m.Text}:{s.Text}", out toSet);
|
||||
else
|
||||
toSet = TimeSpan.Zero;
|
||||
|
||||
shouldSet = shouldSend = successfulParse;
|
||||
|
||||
break;
|
||||
}
|
||||
case 3: // From H
|
||||
{
|
||||
if (h != null)
|
||||
try
|
||||
{
|
||||
toSet = TimeSpan.FromHours(Utility.ToDouble(h.Text));
|
||||
shouldSet = true;
|
||||
shouldSend = true;
|
||||
|
||||
break;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
toSet = TimeSpan.Zero;
|
||||
shouldSet = false;
|
||||
shouldSend = false;
|
||||
|
||||
break;
|
||||
}
|
||||
case 4: // From M
|
||||
{
|
||||
if (m != null)
|
||||
try
|
||||
{
|
||||
toSet = TimeSpan.FromMinutes(Utility.ToDouble(m.Text));
|
||||
shouldSet = true;
|
||||
shouldSend = true;
|
||||
|
||||
break;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
toSet = TimeSpan.Zero;
|
||||
shouldSet = false;
|
||||
shouldSend = false;
|
||||
|
||||
break;
|
||||
}
|
||||
case 5: // From S
|
||||
{
|
||||
if (s != null)
|
||||
try
|
||||
{
|
||||
toSet = TimeSpan.FromSeconds(Utility.ToDouble(s.Text));
|
||||
shouldSet = true;
|
||||
shouldSend = true;
|
||||
|
||||
break;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
toSet = TimeSpan.Zero;
|
||||
shouldSet = false;
|
||||
shouldSend = false;
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
toSet = TimeSpan.Zero;
|
||||
shouldSet = false;
|
||||
shouldSend = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldSet)
|
||||
try
|
||||
{
|
||||
CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, toSet.ToString());
|
||||
m_Property.SetValue(m_Object, toSet, null);
|
||||
PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);
|
||||
}
|
||||
catch
|
||||
{
|
||||
m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
|
||||
}
|
||||
|
||||
if (shouldSend)
|
||||
m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue