PageRenderTime 50ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/Scripts/Gumps/AProperties/ASetListGump.cs

https://bitbucket.org/Kel/crepuscule
C# | 595 lines | 520 code | 66 blank | 9 comment | 120 complexity | 93231840ef89eec252371ded54da6815 MD5 | raw file
  1. /* --------------------------->
  2. * Advanced properties script by Kaon
  3. * Version 1.0
  4. * Creation : 28.03.2007
  5. * Revision : N/A
  6. * --------------------------->
  7. */
  8. using System;
  9. using System.Reflection;
  10. using System.Collections;
  11. using Server;
  12. using Server.Network;
  13. using System.Globalization;
  14. using System.Collections.Generic;
  15. using Server.Targeting;
  16. using CPA = Server.CommandPropertyAttribute;
  17. using Server.Prompts;
  18. using Server.Scripts.Commands;
  19. using Server.Mobiles;
  20. using Server.Guilds;
  21. using Server.Engines.Craft;
  22. using Server.Engines;
  23. namespace Server.Gumps
  24. {
  25. public class ASetListGump<T> : Gump
  26. {
  27. private PropertyInfo m_Property;
  28. private Mobile m_Mobile;
  29. private object m_Object;
  30. private Stack m_Stack;
  31. private int m_Page;
  32. private ArrayList m_List;
  33. public static readonly bool OldStyle = PropsConfig.OldStyle;
  34. private static bool PrevLabel = OldStyle, NextLabel = OldStyle;
  35. public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
  36. public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
  37. public static readonly int TextHue = PropsConfig.TextHue;
  38. public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
  39. public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
  40. public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
  41. public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
  42. public static readonly int BackGumpID = PropsConfig.BackGumpID;
  43. public static readonly int SetGumpID = PropsConfig.SetGumpID;
  44. public static readonly int SetWidth = PropsConfig.SetWidth;
  45. public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
  46. public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
  47. public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
  48. public static readonly int PrevWidth = PropsConfig.PrevWidth;
  49. public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
  50. public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
  51. public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
  52. private static readonly int PrevLabelOffsetX = PrevWidth + 1;
  53. private static readonly int PrevLabelOffsetY = 0;
  54. private static readonly int NextLabelOffsetX = -29;
  55. private static readonly int NextLabelOffsetY = 0;
  56. public static readonly int NextWidth = PropsConfig.NextWidth;
  57. public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
  58. public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
  59. public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
  60. public static readonly int OffsetSize = PropsConfig.OffsetSize;
  61. public static readonly int EntryHeight = PropsConfig.EntryHeight;
  62. public static readonly int BorderSize = PropsConfig.BorderSize;
  63. private static readonly int EntryWidth = 300; //212;
  64. private static readonly int TotalWidth = OffsetSize + EntryWidth + OffsetSize + SetWidth + OffsetSize;
  65. private static readonly int TotalHeight = OffsetSize + (4 * (EntryHeight + OffsetSize));
  66. private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
  67. private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
  68. private List<T> CurrentList;
  69. public ASetListGump(PropertyInfo prop, Mobile mobile, object o, Stack stack, int page, ArrayList list)
  70. : base(GumpOffsetX, GumpOffsetY)
  71. {
  72. m_Property = prop;
  73. m_Mobile = mobile;
  74. m_Object = o;
  75. m_Stack = stack;
  76. m_Page = page;
  77. m_List = list;
  78. List<T> l = (List<T>)prop.GetValue( o, null );
  79. CurrentList = l;
  80. CPA attr = Properties.GetCPA(prop);
  81. bool canWrite = (attr != null && m_Mobile.AccessLevel >= attr.WriteLevel);
  82. AddPage( 0 );
  83. AddBackground(0, 0, BackWidth, BackHeight + (canWrite ? ((3 + Math.Min(20, l.Count)) * (EntryHeight + OffsetSize)) : (Math.Min(20, l.Count) * (EntryHeight + OffsetSize))), BackGumpID);
  84. int x = BorderSize + OffsetSize;
  85. int y = BorderSize + OffsetSize;
  86. int emptyWidth = TotalWidth - PrevWidth - NextWidth - (OffsetSize * 4) - (OldStyle ? SetWidth + OffsetSize : 0);
  87. AddImageTiled(BorderSize, BorderSize, TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0), TotalHeight + (canWrite ? ((3 + Math.Min(20, l.Count)) * (EntryHeight + OffsetSize)) : (Math.Min(20, l.Count)) * (EntryHeight + OffsetSize)), OffsetGumpID);
  88. if (OldStyle)
  89. AddImageTiled(x, y, TotalWidth - (OffsetSize * 3) - SetWidth, EntryHeight, HeaderGumpID);
  90. else
  91. {
  92. AddImageTiled(x, y, PrevWidth, EntryHeight, HeaderGumpID);
  93. AddImageTiled(x + PrevWidth + OffsetSize - (OldStyle ? OffsetSize : 0), y, emptyWidth + (OldStyle ? OffsetSize * 2 : 0), EntryHeight, HeaderGumpID);
  94. AddImageTiled(x + PrevWidth + OffsetSize*2 + emptyWidth, y, NextWidth, EntryHeight, HeaderGumpID);
  95. }
  96. if (!OldStyle)
  97. AddRect(1, prop.Name, 0, -1);
  98. AddRect(2, "Liste de " + typeof(T).GetShortName() , 0, -1);
  99. AddRect(3, "Total : "+l.Count, 0, -1);
  100. if (canWrite)
  101. {
  102. AddRect(4, "Ajouter", 1, -1, true);
  103. AddRect(5, "Supprimer", 2, -1, true);
  104. AddRect(6, "" , 0, -1);
  105. //AddRect(5, "Supprimer", 2, -1, true);
  106. //AddRect(6, "Vider", 3, -1, true);
  107. }
  108. int nbpages = (int)Math.Ceiling(l.Count / 20.0);
  109. for (int i = 0, k=1; i < l.Count; ++i)
  110. {
  111. if (i % 20 == 0)
  112. {
  113. AddPage(k);
  114. if (k > 1)
  115. {
  116. AddButton(x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 1, GumpButtonType.Page, k - 1);
  117. if (PrevLabel)
  118. AddLabel(x + PrevLabelOffsetX, y + PrevLabelOffsetY, TextHue, "Previous");
  119. }
  120. if (k < nbpages)
  121. {
  122. AddButton(x + PrevWidth + OffsetSize*2 + emptyWidth + NextOffsetX, y + NextOffsetY, NextButtonID1, NextButtonID2, 2, GumpButtonType.Page, k + 1);
  123. if (NextLabel)
  124. AddLabel(x + NextLabelOffsetX, y + NextLabelOffsetY, TextHue, "Next");
  125. }
  126. k++;
  127. }
  128. AddRect(7 - (canWrite ? 0 : 3) + (i%20), l[i].ToString(), (canWrite ? (5 + i) : 0), -1);
  129. }
  130. }
  131. private void AddRect(int index, string str, int button, int text)
  132. {
  133. AddRect(index,str,button,text,false);
  134. }
  135. private void AddRect(int index, string str, int button, int text, bool action)
  136. {
  137. int x = BorderSize + OffsetSize;
  138. int y = BorderSize + OffsetSize + (index * (EntryHeight + OffsetSize));
  139. AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
  140. AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, action ? 47 : TextHue, str );
  141. if ( text != -1 )
  142. AddTextEntry( x + 16 + TextOffsetX, y, EntryWidth - TextOffsetX - 16, EntryHeight, TextHue, text, "" );
  143. x += EntryWidth + OffsetSize;
  144. if ( SetGumpID != 0 )
  145. AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
  146. if (button != 0)
  147. {
  148. if (action)
  149. {
  150. AddButton(x + SetOffsetX - 3, y + SetOffsetY - 2, 5538, 5539, button, GumpButtonType.Reply, 0);
  151. }
  152. else
  153. {
  154. bool canDelete = true;
  155. if (CurrentList[button - 5] is ISelfDeletion)
  156. canDelete = (CurrentList[button - 5] as ISelfDeletion).CanBeDeleted();
  157. if(canDelete)
  158. AddButton(x + SetOffsetX - 57, y + SetOffsetY + 2, 2181, 2181, button + 1000, GumpButtonType.Reply, 0);
  159. AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, button, GumpButtonType.Reply, 0);
  160. }
  161. }
  162. }
  163. private class InternalTarget : Target
  164. {
  165. private PropertyInfo m_Property;
  166. private Mobile m_Mobile;
  167. private object m_Object;
  168. private Stack m_Stack;
  169. private int m_Page;
  170. private ArrayList m_List;
  171. private bool bAdd;
  172. public InternalTarget(PropertyInfo prop, Mobile mobile, object o, Stack stack, int page, ArrayList list, bool add)
  173. : base(-1, true, TargetFlags.None)
  174. {
  175. m_Property = prop;
  176. m_Mobile = mobile;
  177. m_Object = o;
  178. m_Stack = stack;
  179. m_Page = page;
  180. m_List = list;
  181. bAdd = add;
  182. }
  183. protected override void OnTarget(Mobile from, object targeted)
  184. {
  185. T target = default(T);
  186. try
  187. {
  188. if (typeof(T).Equals(typeof(Point3D)))
  189. target = (T)((object)new Point3D(targeted as IPoint3D));
  190. else if (typeof(T).Equals(typeof(Point2D)))
  191. target = (T)((object)new Point2D(targeted as IPoint2D));
  192. else target = (T)((object)targeted);
  193. }
  194. catch
  195. {
  196. target = default(T);
  197. from.SendMessage(targeted.ToString() + " can't be converted to type " + typeof(T) );
  198. }
  199. List<T> l = (List<T>)m_Property.GetValue(m_Object, null);
  200. if (target != null)
  201. {
  202. try
  203. {
  204. if (bAdd)
  205. {
  206. if (m_Property.GetCustomAttributes(typeof(UniqueInListProperty), false).Length > 0 && l.Contains(target))
  207. {
  208. from.SendMessage(target.ToString() + " already in the list.");
  209. }
  210. else
  211. {
  212. CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, "add " + target.ToString());
  213. l.Add(target);
  214. from.SendMessage(target.ToString() + " added to the list.");
  215. }
  216. }
  217. else
  218. {
  219. CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, "remove " + target.ToString());
  220. if( l.Remove(target) )
  221. from.SendMessage(target.ToString() + " removed from the list.");
  222. else from.SendMessage(target.ToString() + " wasn't in the list.");
  223. }
  224. }
  225. catch
  226. {
  227. m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
  228. }
  229. }
  230. }
  231. protected override void OnTargetFinish(Mobile from)
  232. {
  233. m_Mobile.SendGump(new ASetListGump<T>(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List));
  234. }
  235. }
  236. private class InternalPrompt : Prompt
  237. {
  238. private PropertyInfo m_Property;
  239. private Mobile m_Mobile;
  240. private object m_Object;
  241. private Stack m_Stack;
  242. private int m_Page;
  243. private ArrayList m_List;
  244. private bool bAdd;
  245. public InternalPrompt(PropertyInfo prop, Mobile mobile, object o, Stack stack, int page, ArrayList list, bool add) : base()
  246. {
  247. m_Property = prop;
  248. m_Mobile = mobile;
  249. m_Object = o;
  250. m_Stack = stack;
  251. m_Page = page;
  252. m_List = list;
  253. bAdd = add;
  254. }
  255. public override void OnResponse(Mobile from, string text)
  256. {
  257. T value = default(T);
  258. try
  259. {
  260. if (IsType(typeof(T), typeofBool)) value = (T)((object)bool.Parse(text));
  261. else if (IsType(typeof(T), typeofDateTime)) value = (T)((object)DateTime.Parse(text));
  262. else if (IsType(typeof(T), typeofMap)) value = (T)((object)Map.Parse(text));
  263. else if (IsType(typeof(T), typeofPoison)) value = (T)((object)Poison.Parse(text));
  264. else if (IsType(typeof(T), typeofGuild)) value = (T)((object)Enum.Parse(typeof(T), text));
  265. else if (IsType(typeof(T), typeofEnum)) value = (T)((object)Enum.Parse(typeof(T), text));
  266. else if (IsType(typeof(T), typeofNumeric)) value = (T)((object)Int64.Parse(text));
  267. else if (IsType(typeof(T), typeofReal)) value = (T)((object)Double.Parse(text));
  268. else if (IsType(typeof(T), typeofString)) value = (T)((object)text);
  269. else if (IsType(typeof(T), typeofTimeSpan)) value = (T)((object)TimeSpan.Parse(text));
  270. else value = (T)((object)Type.GetType(text));
  271. List<T> l = (List<T>)m_Property.GetValue(m_Object, null);
  272. if (bAdd)
  273. {
  274. if (m_Property.GetCustomAttributes(typeof(UniqueInListProperty), false).Length > 0 && l.Contains(value))
  275. {
  276. from.SendMessage(value.ToString() + " already in the list.");
  277. }
  278. else
  279. {
  280. CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, "add " + value.ToString());
  281. l.Add(value);
  282. from.SendMessage(value.ToString() + " added to the list.");
  283. }
  284. }
  285. else
  286. {
  287. CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, "remove " + value.ToString());
  288. if( l.Remove(value) )
  289. from.SendMessage(value.ToString() + " removed from the list.");
  290. else
  291. from.SendMessage(value.ToString() + " wasn't in the list.");
  292. }
  293. }
  294. catch
  295. {
  296. from.SendMessage("Error trying to parse '" + text + "' as a(n) " + typeof(T).ToString());
  297. }
  298. m_Mobile.SendGump(new ASetListGump<T>(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List));
  299. }
  300. }
  301. public override void OnResponse( NetState sender, RelayInfo info )
  302. {
  303. bool shouldSend = false;
  304. Mobile from = sender.Mobile;
  305. List<T> l = (List<T>)m_Property.GetValue(m_Object, null);
  306. Type type = typeof(T);
  307. switch ( info.ButtonID )
  308. {
  309. case 0: // Exit
  310. shouldSend = !(m_Stack == null && m_List == null);
  311. break;
  312. case 1: // Add
  313. if (IsType(type, typeof(GameCraftCategory)))
  314. {
  315. var list = l as List<GameCraftCategory>;
  316. list.Add(new GameCraftCategory());
  317. m_Mobile.SendGump(new ASetListGump<T>(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List));
  318. }
  319. else if (IsType(type, typeof(GameLootPack)))
  320. {
  321. var list = l as List<GameLootPack>;
  322. list.Add(new GameLootPack());
  323. m_Mobile.SendGump(new ASetListGump<T>(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List));
  324. }
  325. else if (IsType(type, typeof(GameLootItem)))
  326. {
  327. var list = l as List<GameLootItem>;
  328. list.Add(new GameLootItem());
  329. m_Mobile.SendGump(new ASetListGump<T>(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List));
  330. }
  331. else if (IsType(type, typeof(GameCraftSystem)))
  332. {
  333. var list = l as List<GameCraftSystem>;
  334. list.Add(new GameCraftSystem());
  335. m_Mobile.SendGump(new ASetListGump<T>(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List));
  336. }
  337. else if (IsType(type, typeof(TradeInfo)))
  338. {
  339. var list = l as List<TradeInfo>;
  340. list.Add(new TradeInfo());
  341. m_Mobile.SendGump(new ASetListGump<T>(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List));
  342. }
  343. else if (IsType(type, typeofMobile) || IsType(type, typeofItem) || IsType(type, typeofPoint3D) || IsType(type, typeofPoint2D))
  344. {
  345. if (from.Target != null) from.Target.Cancel(m_Mobile, TargetCancelType.Overriden);
  346. from.SendMessage("Target the " + typeof(T).ToString() + " you want to add :");
  347. from.Target = new InternalTarget(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List, true);
  348. }
  349. else
  350. {
  351. if (from.Prompt != null) from.Prompt.OnCancel(from);
  352. from.SendMessage("Enter the " + typeof(T).ToString() + " you want to add :");
  353. from.Prompt = new InternalPrompt(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List, true);
  354. }
  355. shouldSend = false;
  356. break;
  357. case 2: // Remove
  358. if (IsType(type, typeofMobile) || IsType(type, typeofItem) || IsType(type, typeofPoint3D) || IsType(type, typeofPoint2D))
  359. {
  360. if (from.Target != null) from.Target.Cancel(m_Mobile, TargetCancelType.Overriden);
  361. from.SendMessage("Target the " + typeof(T).ToString() + " you want to remove :");
  362. from.Target = new InternalTarget(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List, false);
  363. }
  364. else
  365. {
  366. if (from.Prompt != null) from.Prompt.OnCancel(from);
  367. from.SendMessage("Enter the " + typeof(T).ToString() + " you want to remove :");
  368. from.Prompt = new InternalPrompt(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List, false);
  369. }
  370. shouldSend = false;
  371. break;
  372. case 3: // Clear
  373. m_Mobile.SendGump(new AListClearConfirmationGump<T>(l, m_Property, m_Mobile as RacePlayerMobile, m_Object, m_Stack, m_Page, m_List, -1));
  374. break;
  375. default:
  376. {
  377. if (info.ButtonID > 1000) // Remove
  378. {
  379. int i = info.ButtonID - 5 - 1000;
  380. m_Mobile.SendGump(new AListRemoveConfirmationGump<T>(l, m_Property, m_Mobile as RacePlayerMobile, m_Object, m_Stack, m_Page, m_List, i));
  381. }
  382. else
  383. {
  384. int i = info.ButtonID - 5;
  385. if (IsType(type, typeofMobile) || IsType(type, typeofItem))
  386. from.SendGump(new ASetObjectGump(m_Property, from, m_Object, m_Stack, type, m_Page, m_List, i));
  387. else if (IsType(type, typeofType))
  388. from.Target = new ASetObjectTarget(m_Property, from, m_Object, m_Stack, type, m_Page, m_List, i);
  389. else if (IsType(type, typeofPoint3D))
  390. from.SendGump(new ASetPoint3DGump(m_Property, from, m_Object, m_Stack, m_Page, m_List, i));
  391. else if (IsType(type, typeofPoint2D))
  392. from.SendGump(new ASetPoint2DGump(m_Property, from, m_Object, m_Stack, m_Page, m_List, i));
  393. else if (IsType(type, typeofTimeSpan))
  394. from.SendGump(new ASetTimeSpanGump(m_Property, from, m_Object, m_Stack, m_Page, m_List, i));
  395. else if (IsType(type, typeofDateTime))
  396. from.SendGump(new ASetDateTimeGump(m_Property, from, m_Object, m_Stack, m_Page, m_List, i));
  397. else if (IsType(type, typeofGuild))
  398. from.SendGump(new ASetListOptionGump(m_Property, from, m_Object, m_Stack, m_Page, m_List, Enum.GetNames(type), APropertiesGump.GetObjects(Enum.GetValues(type)), i));
  399. else if (IsType(type, typeofEnum))
  400. from.SendGump(new ASetListOptionGump(m_Property, from, m_Object, m_Stack, m_Page, m_List, Enum.GetNames(type), APropertiesGump.GetObjects(Enum.GetValues(type)), i));
  401. else if (IsType(type, typeofBool))
  402. from.SendGump(new ASetListOptionGump(m_Property, from, m_Object, m_Stack, m_Page, m_List, APropertiesGump.m_BoolNames, APropertiesGump.m_BoolValues, i));
  403. else if (IsType(type, typeofString) || IsType(type, typeofReal) || IsType(type, typeofNumeric))
  404. from.SendGump(new ASetGump(m_Property, from, m_Object, m_Stack, m_Page, m_List, i));
  405. else if (IsType(type, typeofPoison))
  406. from.SendGump(new ASetListOptionGump(m_Property, from, m_Object, m_Stack, m_Page, m_List, APropertiesGump.m_PoisonNames, APropertiesGump.m_PoisonValues, i));
  407. else if (IsType(type, typeofMap))
  408. from.SendGump(new ASetListOptionGump(m_Property, from, m_Object, m_Stack, m_Page, m_List, Map.GetMapNames(), Map.GetMapValues(), i));
  409. else if (APropertiesGump.HasAttribute(type, typeofPropertyObject, true))
  410. {
  411. from.SendGump(new ASetListGump<T>(m_Property, from, m_Object, m_Stack, m_Page, m_List));
  412. from.SendGump(new APropertiesGump(from, l[i], m_Stack, new APropertiesGump.StackEntry(m_Object, m_Property)));
  413. }
  414. shouldSend = false;
  415. }
  416. break;
  417. }
  418. }
  419. if ( shouldSend )
  420. m_Mobile.SendGump( new APropertiesGump( m_Mobile, m_Object, m_Stack, m_List, m_Page ) );
  421. }
  422. private static bool IsType(Type type, Type check)
  423. {
  424. return type == check || type.IsSubclassOf(check);
  425. }
  426. private static bool IsType(Type type, Type[] check)
  427. {
  428. for (int i = 0; i < check.Length; ++i)
  429. if (IsType(type, check[i]))
  430. return true;
  431. return false;
  432. }
  433. private static Type typeofMobile = typeof(Mobile);
  434. private static Type typeofItem = typeof(Item);
  435. private static Type typeofType = typeof(Type);
  436. private static Type typeofPoint3D = typeof(Point3D);
  437. private static Type typeofPoint2D = typeof(Point2D);
  438. private static Type typeofTimeSpan = typeof(TimeSpan);
  439. private static Type typeofDateTime = typeof(DateTime);
  440. private static Type typeofCustomEnum = typeof(CustomEnumAttribute);
  441. private static Type typeofEnum = typeof(Enum);
  442. private static Type typeofGuild = typeof(GuildType);
  443. private static Type typeofBool = typeof(Boolean);
  444. private static Type typeofString = typeof(String);
  445. private static Type typeofPoison = typeof(Poison);
  446. private static Type typeofMap = typeof(Map);
  447. private static Type typeofSkills = typeof(Skills);
  448. private static Type typeofPropertyObject = typeof(PropertyObjectAttribute);
  449. private static Type typeofNoSort = typeof(NoSortAttribute);
  450. private static Type[] typeofReal = new Type[]
  451. {
  452. typeof( Single ),
  453. typeof( Double )
  454. };
  455. private static Type[] typeofNumeric = new Type[]
  456. {
  457. typeof( Byte ),
  458. typeof( Int16 ),
  459. typeof( Int32 ),
  460. typeof( Int64 ),
  461. typeof( SByte ),
  462. typeof( UInt16 ),
  463. typeof( UInt32 ),
  464. typeof( UInt64 )
  465. };
  466. }
  467. public class AListRemoveConfirmationGump<T> : MessageBoxGump
  468. {
  469. private const string Description = "Etes-vous sūr de vouloir effacer cet objet de la liste?";
  470. private PropertyInfo prop;
  471. private object o;
  472. private Stack stack;
  473. private int page;
  474. private ArrayList list ;
  475. private int index;
  476. private List<T> mainList;
  477. public AListRemoveConfirmationGump(List<T> mainList, PropertyInfo prop, RacePlayerMobile mobile, object o, Stack stack, int page, ArrayList list, int index)
  478. : base(mobile, "Confirmation", Description)
  479. {
  480. this.prop = prop;
  481. this.o = o;
  482. this.stack = stack;
  483. this.page = page;
  484. this.list = list;
  485. this.index = index;
  486. this.mainList = mainList;
  487. }
  488. public override void OnYesClicked(RacePlayerMobile owner, string title, string text)
  489. {
  490. mainList.RemoveAt(index);
  491. m_Owner.SendGump(new ASetListGump<T>(prop, owner, o, stack, page, list));
  492. }
  493. public override void OnNoClicked(RacePlayerMobile owner, string title, string text)
  494. {
  495. m_Owner.SendGump(new ASetListGump<T>(prop, owner, o, stack, page, list));
  496. }
  497. }
  498. public class AListClearConfirmationGump<T> : MessageBoxGump
  499. {
  500. private const string Description = "Etes-vous sūr de vouloir vider la liste complétement?";
  501. private PropertyInfo prop;
  502. private object o;
  503. private Stack stack;
  504. private int page;
  505. private ArrayList list ;
  506. private int index;
  507. private List<T> mainList;
  508. public AListClearConfirmationGump(List<T> mainList, PropertyInfo prop, RacePlayerMobile mobile, object o, Stack stack, int page, ArrayList list, int index)
  509. : base(mobile, "Confirmation", Description)
  510. {
  511. this.prop = prop;
  512. this.o = o;
  513. this.stack = stack;
  514. this.page = page;
  515. this.list = list;
  516. this.index = index;
  517. this.mainList = mainList;
  518. }
  519. public override void OnYesClicked(RacePlayerMobile owner, string title, string text)
  520. {
  521. mainList.Clear();
  522. m_Owner.SendGump(new ASetListGump<T>(prop, owner, o, stack, page, list));
  523. }
  524. public override void OnNoClicked(RacePlayerMobile owner, string title, string text)
  525. {
  526. m_Owner.SendGump(new ASetListGump<T>(prop, owner, o, stack, page, list));
  527. }
  528. }
  529. }