PageRenderTime 61ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/Scripts/Gumps/HouseGumpAOS.cs

https://bitbucket.org/Kel/crepuscule
C# | 1165 lines | 915 code | 216 blank | 34 comment | 205 complexity | e4d8f4b67851cd0622ffc09f55f91c24 MD5 | raw file
  1. using System;
  2. using System.Reflection;
  3. using System.Collections;
  4. using Server.Network;
  5. using Server.Prompts;
  6. using Server.Mobiles;
  7. using Server.Multis;
  8. using Server.Multis.Deeds;
  9. using Server.Items;
  10. namespace Server.Gumps
  11. {
  12. public enum HouseGumpPageAOS
  13. {
  14. Information,
  15. Security,
  16. Storage,
  17. Customize,
  18. Ownership,
  19. ChangeHanger,
  20. ChangeFoundation,
  21. ChangeSign,
  22. RemoveCoOwner,
  23. ListCoOwner,
  24. RemoveFriend,
  25. ListFriend,
  26. RemoveBan,
  27. ListBan,
  28. RemoveAccess,
  29. ListAccess,
  30. ChangePost
  31. }
  32. public class HouseGumpAOS : Gump
  33. {
  34. private BaseHouse m_House;
  35. private HouseGumpPageAOS m_Page;
  36. private const int LabelColor = 0x7FFF;
  37. private const int SelectedColor = 0x421F;
  38. private const int DisabledColor = 0x4210;
  39. private const int LabelHue = 0x480;
  40. private ArrayList m_List;
  41. private string GetOwnerName()
  42. {
  43. Mobile m = m_House.Owner;
  44. if ( m == null || m.Deleted )
  45. return "(unowned)";
  46. string name;
  47. if ( (name = m.Name) == null || (name = name.Trim()).Length <= 0 )
  48. name = "(no name)";
  49. return name;
  50. }
  51. private string GetDateTime( DateTime val )
  52. {
  53. if ( val == DateTime.MinValue )
  54. return "";
  55. return val.ToString( "yyyy'-'MM'-'dd HH':'mm':'ss" );
  56. }
  57. public void AddPageButton( int x, int y, int buttonID, int number, HouseGumpPageAOS page )
  58. {
  59. bool isSelection = ( m_Page == page );
  60. AddButton( x, y, isSelection ? 4006 : 4005, 4007, buttonID, GumpButtonType.Reply, 0 );
  61. AddHtmlLocalized( x + 45, y, 200, 20, number, isSelection ? SelectedColor : LabelColor, false, false );
  62. }
  63. public void AddButtonLabeled( int x, int y, int buttonID, int number )
  64. {
  65. AddButtonLabeled( x, y, buttonID, number, true );
  66. }
  67. public void AddButtonLabeled( int x, int y, int buttonID, int number, bool enabled )
  68. {
  69. if ( enabled )
  70. AddButton( x, y, 4005, 4007, buttonID, GumpButtonType.Reply, 0 );
  71. AddHtmlLocalized( x + 35, y, 240, 20, number, enabled ? LabelColor : DisabledColor, false, false );
  72. }
  73. public void AddList( ArrayList list, int button, bool accountOf )
  74. {
  75. if ( list == null )
  76. return;
  77. m_List = list;
  78. int lastPage = 0;
  79. int index = 0;
  80. for ( int i = 0; i < list.Count; ++i )
  81. {
  82. int offset = index % 10;
  83. int page = 1 + (index / 10);
  84. if ( page != lastPage )
  85. {
  86. if ( lastPage != 0 )
  87. AddButton( 40, 360, 4005, 4007, 0, GumpButtonType.Page, page );
  88. AddPage( page );
  89. if ( lastPage != 0 )
  90. AddButton( 10, 360, 4014, 4016, 0, GumpButtonType.Page, lastPage );
  91. lastPage = page;
  92. }
  93. Mobile m = (Mobile)list[i];
  94. string name;
  95. if ( m == null || (name = m.Name) == null || (name = name.Trim()).Length <= 0 )
  96. continue;
  97. if ( button != -1 )
  98. AddButton( 10, 150 + (offset * 20), 4005, 4007, GetButtonID( button, i ), GumpButtonType.Reply, 0 );
  99. AddLabel( button > 0 ? 45 : 10, 150 + (offset * 20), LabelHue, accountOf && m.Player && m.Account != null ? String.Format( "* Account of {0}", name ) : String.Format( "* {0}", name ) );
  100. ++index;
  101. }
  102. }
  103. public int GetButtonID( int type, int index )
  104. {
  105. return 1 + (index * 15) + type;
  106. }
  107. private static int[] m_HangerNumbers = new int[]
  108. {
  109. 2968, 2970, 2972,
  110. 2974, 2976, 2978
  111. };
  112. private static int[] m_FoundationNumbers = new int[]
  113. {
  114. 20, 189, 765, 65, 101
  115. };
  116. private static int[] m_PostNumbers = new int[]
  117. {
  118. 9, 29, 54, 90, 147, 169,
  119. 177, 204, 251, 257, 263,
  120. 298, 347, 424, 441, 466,
  121. 514, 600, 601, 602, 603,
  122. 660, 666, 672, 898, 970,
  123. 974, 982
  124. };
  125. public HouseGumpAOS( HouseGumpPageAOS page, Mobile from, BaseHouse house ) : base( 50, 40 )
  126. {
  127. m_House = house;
  128. m_Page = page;
  129. from.CloseGump( typeof( HouseGumpAOS ) );
  130. //from.CloseGump( typeof( HouseListGump ) );
  131. //from.CloseGump( typeof( HouseRemoveGump ) );
  132. bool isOwner = house.IsOwner( from );
  133. bool isCoOwner = isOwner || house.IsCoOwner( from );
  134. bool isFriend = isCoOwner || house.IsFriend( from );
  135. AddPage( 0 );
  136. if ( isFriend )
  137. {
  138. AddBackground( 0, 0, 420, 440, 3500 );
  139. AddImageTiled( 10, 10, 400, 100, 2624 );
  140. AddAlphaRegion( 10, 10, 400, 100 );
  141. AddImageTiled( 10, 120, 400, 260, 2624 );
  142. AddAlphaRegion( 10, 120, 400, 260 );
  143. AddImageTiled( 10, 390, 400, 40, 2624 );
  144. AddAlphaRegion( 10, 390, 400, 40 );
  145. AddButtonLabeled( 250, 410, 0, 1060675 ); // CLOSE
  146. }
  147. AddImage( 10, 10, 100 );
  148. if ( m_House.Sign != null )
  149. {
  150. ArrayList lines = Wrap( m_House.Sign.Name );
  151. if ( lines != null )
  152. {
  153. for ( int i = 0, y = (114 - (lines.Count * 14)) / 2; i < lines.Count; ++i, y += 14 )
  154. {
  155. string s = (string)lines[i];
  156. AddLabel( 10 + ((160 - (s.Length * 8)) / 2), y, 0, s );
  157. }
  158. }
  159. }
  160. if ( !isFriend )
  161. return;
  162. if ( house.Public )
  163. {
  164. AddButtonLabeled( 10, 390, GetButtonID( 0, 0 ), 1060674 ); // Banish
  165. AddButtonLabeled( 10, 410, GetButtonID( 0, 1 ), 1011261 ); // Lift a Ban
  166. }
  167. else
  168. {
  169. AddButtonLabeled( 10, 390, GetButtonID( 0, 2 ), 1060676 ); // Grant Access
  170. AddButtonLabeled( 10, 410, GetButtonID( 0, 3 ), 1060677 ); // Revoke Access
  171. }
  172. AddPageButton( 150, 10, GetButtonID( 1, 0 ), 1060668, HouseGumpPageAOS.Information );
  173. AddPageButton( 150, 30, GetButtonID( 1, 1 ), 1060669, HouseGumpPageAOS.Security );
  174. AddPageButton( 150, 50, GetButtonID( 1, 2 ), 1060670, HouseGumpPageAOS.Storage );
  175. AddPageButton( 150, 70, GetButtonID( 1, 3 ), 1060671, HouseGumpPageAOS.Customize );
  176. AddPageButton( 150, 90, GetButtonID( 1, 4 ), 1060672, HouseGumpPageAOS.Ownership );
  177. switch ( page )
  178. {
  179. case HouseGumpPageAOS.Information:
  180. {
  181. AddHtmlLocalized( 20, 130, 200, 20, 1011242, LabelColor, false, false ); // Owned By:
  182. AddLabel( 210, 130, LabelHue, GetOwnerName() );
  183. AddHtmlLocalized( 20, 170, 380, 20, 1018032, SelectedColor, false, false ); // This house is properly placed.
  184. AddHtmlLocalized( 20, 190, 380, 20, 1018035, SelectedColor, false, false ); // This house is of modern design.
  185. AddHtmlLocalized( 20, 210, 380, 20, (house is HouseFoundation) ? 1060681 : 1060680, SelectedColor, false, false ); // This is a (pre | custom)-built house.
  186. AddHtmlLocalized( 20, 230, 380, 20, house.Public ? 1060678 : 1060679, SelectedColor, false, false ); // This house is (private | open to the public).
  187. AddHtmlLocalized( 20, 250, 380, 20, 1062209, SelectedColor, false, false ); // This house is <a href = "?ForceTopic97">Automatically</a> refreshed.
  188. AddHtmlLocalized( 20, 290, 200, 20, 1060692, SelectedColor, false, false ); // Built On:
  189. AddLabel( 250, 290, LabelHue, GetDateTime( house.BuiltOn ) );
  190. AddHtmlLocalized( 20, 310, 200, 20, 1060693, SelectedColor, false, false ); // Last Traded:
  191. AddLabel( 250, 310, LabelHue, GetDateTime( house.LastTraded ) );
  192. AddHtmlLocalized( 20, 330, 200, 20, 1061793, SelectedColor, false, false ); // House Value
  193. AddLabel( 250, 330, LabelHue, house.Price.ToString() );
  194. AddHtmlLocalized( 20, 360, 300, 20, 1011241, SelectedColor, false, false ); // Number of visits this building has had:
  195. AddLabel( 350, 360, LabelHue, house.Visits.ToString() );
  196. break;
  197. }
  198. case HouseGumpPageAOS.Security:
  199. {
  200. AddButtonLabeled( 10, 130, GetButtonID( 3, 0 ), 1011266, isCoOwner ); // View Co-Owner List
  201. AddButtonLabeled( 10, 150, GetButtonID( 3, 1 ), 1011267, isOwner ); // Add a Co-Owner
  202. AddButtonLabeled( 10, 170, GetButtonID( 3, 2 ), 1018036, isOwner ); // Remove a Co-Owner
  203. AddButtonLabeled( 10, 190, GetButtonID( 3, 3 ), 1011268, isOwner ); // Clear Co-Owner List
  204. AddButtonLabeled( 10, 220, GetButtonID( 3, 4 ), 1011243 ); // View Friends List
  205. AddButtonLabeled( 10, 240, GetButtonID( 3, 5 ), 1011244, isCoOwner ); // Add a Friend
  206. AddButtonLabeled( 10, 260, GetButtonID( 3, 6 ), 1018037, isCoOwner ); // Remove a Friend
  207. AddButtonLabeled( 10, 280, GetButtonID( 3, 7 ), 1011245, isCoOwner ); // Clear Friend List
  208. if ( house.Public )
  209. {
  210. AddButtonLabeled( 10, 310, GetButtonID( 3, 8 ), 1011260 ); // View Ban List
  211. AddButtonLabeled( 10, 330, GetButtonID( 3, 9 ), 1060698 ); // Clear Ban List
  212. AddButtonLabeled( 210, 130, GetButtonID( 3, 12 ), 1060695, isOwner ); // Make This House Private
  213. }
  214. else
  215. {
  216. AddButtonLabeled( 10, 310, GetButtonID( 3, 10 ), 1060699 ); // View Access List
  217. AddButtonLabeled( 10, 330, GetButtonID( 3, 11 ), 1060700 ); // Clear Access List
  218. AddButtonLabeled( 210, 130, GetButtonID( 3, 13 ), 1060694, isOwner ); // Make This House Public
  219. }
  220. break;
  221. }
  222. case HouseGumpPageAOS.Storage:
  223. {
  224. AddHtmlLocalized( 10, 130, 400, 20, 1060682, LabelColor, false, false ); // <CENTER>HOUSE STORAGE SUMMARY</CENTER>
  225. // This is not as OSI; storage changes not yet implemented
  226. /*AddHtmlLocalized( 10, 170, 275, 20, 1011237, LabelColor, false, false ); // Number of locked down items:
  227. AddLabel( 310, 170, LabelHue, m_House.LockDownCount.ToString() );
  228. AddHtmlLocalized( 10, 190, 275, 20, 1011238, LabelColor, false, false ); // Maximum locked down items:
  229. AddLabel( 310, 190, LabelHue, m_House.MaxLockDowns.ToString() );
  230. AddHtmlLocalized( 10, 210, 275, 20, 1011239, LabelColor, false, false ); // Number of secure containers:
  231. AddLabel( 310, 210, LabelHue, m_House.SecureCount.ToString() );
  232. AddHtmlLocalized( 10, 230, 275, 20, 1011240, LabelColor, false, false ); // Maximum number of secure containers:
  233. AddLabel( 310, 230, LabelHue, m_House.MaxSecures.ToString() );*/
  234. int fromSecures, fromVendors, fromLockdowns;
  235. int maxSecures = house.GetAosMaxSecures();
  236. int curSecures = house.GetAosCurSecures( out fromSecures, out fromVendors, out fromLockdowns );
  237. int maxLockdowns = house.GetAosMaxLockdowns();
  238. int curLockdowns = house.GetAosCurLockdowns();
  239. AddHtmlLocalized( 10, 170, 300, 20, 1060683, LabelColor, false, false ); // Maximum Secure Storage
  240. AddLabel( 310, 170, LabelHue, maxSecures.ToString() );
  241. AddHtmlLocalized( 10, 190, 300, 20, 1060685, LabelColor, false, false ); // Used by Moving Crate
  242. AddLabel( 310, 190, LabelHue, "0" );
  243. AddHtmlLocalized( 10, 210, 300, 20, 1060686, LabelColor, false, false ); // Used by Lockdowns
  244. AddLabel( 310, 210, LabelHue, fromLockdowns.ToString() );
  245. AddHtmlLocalized( 10, 230, 300, 20, 1060687, LabelColor, false, false ); // Used by Vendors
  246. AddLabel( 310, 230, LabelHue, fromVendors.ToString() );
  247. AddHtmlLocalized( 10, 250, 300, 20, 1060688, LabelColor, false, false ); // Used by Secure Containers
  248. AddLabel( 310, 250, LabelHue, fromSecures.ToString() );
  249. AddHtmlLocalized( 10, 270, 300, 20, 1060689, LabelColor, false, false ); // Available Storage
  250. AddLabel( 310, 270, LabelHue, Math.Max( maxSecures - curSecures, 0 ).ToString() );
  251. AddHtmlLocalized( 10, 330, 300, 20, 1060690, LabelColor, false, false ); // Maximum Lockdowns
  252. AddLabel( 310, 330, LabelHue, maxLockdowns.ToString() );
  253. AddHtmlLocalized( 10, 350, 300, 20, 1060691, LabelColor, false, false ); // Available Lockdowns
  254. AddLabel( 310, 350, LabelHue, Math.Max( maxLockdowns - curLockdowns, 0 ).ToString() );
  255. break;
  256. }
  257. case HouseGumpPageAOS.Customize:
  258. {
  259. bool isCustomizable = isOwner && ( house is HouseFoundation );
  260. AddButtonLabeled( 10, 120, GetButtonID( 5, 0 ), 1060759, isOwner && !isCustomizable && ( house.ConvertEntry != null ) ); // Convert Into Customizable House
  261. AddButtonLabeled( 10, 160, GetButtonID( 5, 1 ), 1060765, isOwner && isCustomizable ); // Customize This House
  262. AddButtonLabeled( 10, 180, GetButtonID( 5, 2 ), 1060760, false ); // Relocate Moving Crate
  263. AddButtonLabeled( 10, 210, GetButtonID( 5, 3 ), 1060761, isOwner && house.Public ); // Change House Sign
  264. AddButtonLabeled( 10, 230, GetButtonID( 5, 4 ), 1060762, isOwner && isCustomizable ); // Change House Sign Hanger
  265. AddButtonLabeled( 10, 250, GetButtonID( 5, 5 ), 1060763, isOwner && isCustomizable && ( ((HouseFoundation)house).Signpost != null ) ); // Change Signpost
  266. AddButtonLabeled( 10, 280, GetButtonID( 5, 6 ), 1062004, isOwner && isCustomizable ); // Change Foundation Style
  267. AddButtonLabeled( 10, 310, GetButtonID( 5, 7 ), 1060764, isCoOwner ); // Rename House
  268. break;
  269. }
  270. case HouseGumpPageAOS.Ownership:
  271. {
  272. AddButtonLabeled( 10, 130, GetButtonID( 6, 0 ), 1061794, isOwner ); // Demolish House
  273. AddButtonLabeled( 10, 150, GetButtonID( 6, 1 ), 1061797, isOwner ); // Trade House
  274. AddButtonLabeled( 10, 190, GetButtonID( 6, 2 ), 1061798, false ); // Make Primary
  275. break;
  276. }
  277. case HouseGumpPageAOS.ChangeHanger:
  278. {
  279. for ( int i = 0; i < m_HangerNumbers.Length; ++i )
  280. {
  281. int x = 50 + ((i % 3) * 100);
  282. int y = 180 + ((i / 3) * 80);
  283. AddButton( x, y, 4005, 4007, GetButtonID( 7, i ), GumpButtonType.Reply, 0 );
  284. AddItem( x + 20, y, m_HangerNumbers[i] );
  285. }
  286. break;
  287. }
  288. case HouseGumpPageAOS.ChangeFoundation:
  289. {
  290. for ( int i = 0; i < m_FoundationNumbers.Length; ++i )
  291. {
  292. int x = 15 + ((i % 5) * 80);
  293. int y = 180 + ((i / 5) * 100);
  294. AddButton( x, y, 4005, 4007, GetButtonID( 8, i ), GumpButtonType.Reply, 0 );
  295. AddItem( x + 25, y, m_FoundationNumbers[i] );
  296. }
  297. break;
  298. }
  299. case HouseGumpPageAOS.ChangeSign:
  300. {
  301. int index = 0;
  302. for ( int i = 0; i < 3; ++i )
  303. {
  304. AddPage( i + 1 );
  305. AddButton( 10, 360, 4005, 4007, 0, GumpButtonType.Page, ((i + 1) % 3) + 1 );
  306. for ( int j = 0; j < 18; ++j )
  307. {
  308. int x = 30 + ((j % 6) * 60);
  309. int y = 130 + ((j / 6) * 60);
  310. AddButton( x, y, 4005, 4007, GetButtonID( 9, index ), GumpButtonType.Reply, 0 );
  311. AddItem( x + 20, y, 2980 + (index++ * 2) );
  312. }
  313. }
  314. break;
  315. }
  316. case HouseGumpPageAOS.RemoveCoOwner:
  317. {
  318. AddHtmlLocalized( 10, 120, 400, 20, 1060730, LabelColor, false, false ); // <CENTER>CO-OWNER LIST</CENTER>
  319. AddList( house.CoOwners, 10, false );
  320. break;
  321. }
  322. case HouseGumpPageAOS.ListCoOwner:
  323. {
  324. AddHtmlLocalized( 10, 120, 400, 20, 1060730, LabelColor, false, false ); // <CENTER>CO-OWNER LIST</CENTER>
  325. AddList( house.CoOwners, -1, false );
  326. break;
  327. }
  328. case HouseGumpPageAOS.RemoveFriend:
  329. {
  330. AddHtmlLocalized( 10, 120, 400, 20, 1060731, LabelColor, false, false ); // <CENTER>FRIENDS LIST</CENTER>
  331. AddList( house.Friends, 11, false );
  332. break;
  333. }
  334. case HouseGumpPageAOS.ListFriend:
  335. {
  336. AddHtmlLocalized( 10, 120, 400, 20, 1060731, LabelColor, false, false ); // <CENTER>FRIENDS LIST</CENTER>
  337. AddList( house.Friends, -1, false );
  338. break;
  339. }
  340. case HouseGumpPageAOS.RemoveBan:
  341. {
  342. AddHtmlLocalized( 10, 120, 400, 20, 1060733, LabelColor, false, false ); // <CENTER>BAN LIST</CENTER>
  343. AddList( house.Bans, 12, true );
  344. break;
  345. }
  346. case HouseGumpPageAOS.ListBan:
  347. {
  348. AddHtmlLocalized( 10, 120, 400, 20, 1060733, LabelColor, false, false ); // <CENTER>BAN LIST</CENTER>
  349. AddList( house.Bans, -1, true );
  350. break;
  351. }
  352. case HouseGumpPageAOS.RemoveAccess:
  353. {
  354. AddHtmlLocalized( 10, 120, 400, 20, 1060732, LabelColor, false, false ); // <CENTER>ACCESS LIST</CENTER>
  355. AddList( house.Access, 13, false );
  356. break;
  357. }
  358. case HouseGumpPageAOS.ListAccess:
  359. {
  360. AddHtmlLocalized( 10, 120, 400, 20, 1060732, LabelColor, false, false ); // <CENTER>ACCESS LIST</CENTER>
  361. AddList( house.Access, -1, false );
  362. break;
  363. }
  364. case HouseGumpPageAOS.ChangePost:
  365. {
  366. int index = 0;
  367. for ( int i = 0; i < 2; ++i )
  368. {
  369. AddPage( i + 1 );
  370. AddButton( 10, 360, 4005, 4007, 0, GumpButtonType.Page, ((i + 1) % 2) + 1 );
  371. for ( int j = 0; j < 16 && index < m_PostNumbers.Length; ++j )
  372. {
  373. int x = 15 + ((j % 8) * 50);
  374. int y = 130 + ((j / 8) * 110);
  375. AddButton( x, y, 4005, 4007, GetButtonID( 14, index ), GumpButtonType.Reply, 0 );
  376. AddItem( x + 10, y, m_PostNumbers[index++] );
  377. }
  378. }
  379. break;
  380. }
  381. }
  382. }
  383. public static void PublicPrivateNotice_Callback( Mobile from, object state )
  384. {
  385. from.SendGump( new HouseGumpAOS( HouseGumpPageAOS.Security, from, (BaseHouse)state ) );
  386. }
  387. public static void ClearCoOwners_Callback( Mobile from, bool okay, object state )
  388. {
  389. BaseHouse house = (BaseHouse)state;
  390. if ( okay && house.IsOwner( from ) )
  391. {
  392. if ( house.CoOwners != null )
  393. house.CoOwners.Clear();
  394. from.SendLocalizedMessage( 501333 ); // All co-owners have been removed from this house.
  395. }
  396. from.SendGump( new HouseGumpAOS( HouseGumpPageAOS.Security, from, house ) );
  397. }
  398. public static void ClearFriends_Callback( Mobile from, bool okay, object state )
  399. {
  400. BaseHouse house = (BaseHouse)state;
  401. if ( okay && house.IsCoOwner( from ) )
  402. {
  403. if ( house.Friends != null )
  404. house.Friends.Clear();
  405. from.SendLocalizedMessage( 501332 ); // All friends have been removed from this house.
  406. }
  407. from.SendGump( new HouseGumpAOS( HouseGumpPageAOS.Security, from, house ) );
  408. }
  409. public static void ClearBans_Callback( Mobile from, bool okay, object state )
  410. {
  411. BaseHouse house = (BaseHouse)state;
  412. if ( okay && house.IsFriend( from ) )
  413. {
  414. if ( house.Bans != null )
  415. house.Bans.Clear();
  416. from.SendLocalizedMessage( 1060754 ); // All bans for this house have been lifted.
  417. }
  418. from.SendGump( new HouseGumpAOS( HouseGumpPageAOS.Security, from, house ) );
  419. }
  420. public static void ClearAccess_Callback( Mobile from, bool okay, object state )
  421. {
  422. BaseHouse house = (BaseHouse)state;
  423. if ( okay && house.IsFriend( from ) )
  424. {
  425. ArrayList list = new ArrayList( house.Access );
  426. if ( house.Access != null )
  427. house.Access.Clear();
  428. for ( int i = 0; i < list.Count; ++i )
  429. {
  430. Mobile m = (Mobile)list[i];
  431. if ( !house.HasAccess( m ) && house.IsInside( m ) )
  432. {
  433. m.Location = house.BanLocation;
  434. m.SendLocalizedMessage( 1060734 ); // Your access to this house has been revoked.
  435. }
  436. }
  437. from.SendLocalizedMessage( 1061843 ); // This house's Access List has been cleared.
  438. }
  439. from.SendGump( new HouseGumpAOS( HouseGumpPageAOS.Security, from, house ) );
  440. }
  441. public static void ConvertHouse_Callback( Mobile from, bool okay, object state )
  442. {
  443. BaseHouse house = (BaseHouse)state;
  444. if ( okay && house.IsOwner( from ) )
  445. {
  446. HousePlacementEntry e = house.ConvertEntry;
  447. if ( e != null )
  448. {
  449. int cost = e.Cost - house.Price;
  450. if ( cost > 0 )
  451. {
  452. if ( Banker.Withdraw( from, cost ) )
  453. {
  454. from.SendLocalizedMessage( 1060398, cost.ToString() ); // ~1_AMOUNT~ gold has been withdrawn from your bank box.
  455. }
  456. else
  457. {
  458. from.SendLocalizedMessage( 1061624 ); // You do not have enough funds in your bank to cover the difference between your old house and your new one.
  459. return;
  460. }
  461. }
  462. else if ( cost < 0 )
  463. {
  464. if ( Banker.Deposit( from, -cost ) )
  465. from.SendLocalizedMessage( 1060397, (-cost).ToString() ); // ~1_AMOUNT~ gold has been deposited into your bank box.
  466. else
  467. return;
  468. }
  469. BaseHouse newHouse = e.ConstructHouse( from );
  470. if ( newHouse != null )
  471. {
  472. newHouse.Price = e.Cost;
  473. newHouse.Friends = new ArrayList( house.Friends );
  474. newHouse.CoOwners = new ArrayList( house.CoOwners );
  475. newHouse.Bans = new ArrayList( house.Bans );
  476. newHouse.Access = new ArrayList( house.Access );
  477. newHouse.Addons = new ArrayList( house.Addons );
  478. newHouse.BuiltOn = house.BuiltOn;
  479. newHouse.LastTraded = house.LastTraded;
  480. newHouse.MoveToWorld( new Point3D( house.X + house.ConvertOffsetX, house.Y + house.ConvertOffsetY, house.Z + house.ConvertOffsetZ ), house.Map );
  481. house.Delete();
  482. /* You have successfully replaced your original house with a new house.
  483. * The value of the replaced house has been deposited into your bank box.
  484. * All of the items in your original house have been relocated to a Moving Crate in the new house.
  485. * Any deed-based house add-ons have been converted back into deeds.
  486. * Vendors and barkeeps in the house, if any, have been stored in the Moving Crate as well.
  487. * Use the <B>Get Vendor</B> context-sensitive menu option on your character to retrieve them.
  488. * These containers can be used to re-create the vendor in a new location.
  489. * Any barkeepers have been converted into deeds.
  490. */
  491. from.SendGump( new NoticeGump( 1060637, 30720, 1060012, 32512, 420, 280, null, null ) );
  492. return;
  493. }
  494. }
  495. }
  496. from.SendGump( new HouseGumpAOS( HouseGumpPageAOS.Security, from, house ) );
  497. }
  498. public override void OnResponse( NetState sender, RelayInfo info )
  499. {
  500. if ( m_House.Deleted )
  501. return;
  502. Mobile from = sender.Mobile;
  503. bool isOwner = m_House.IsOwner( from );
  504. bool isCoOwner = isOwner || m_House.IsCoOwner( from );
  505. bool isFriend = isCoOwner || m_House.IsFriend( from );
  506. if ( !isFriend || !from.CheckAlive() )
  507. return;
  508. Item sign = m_House.Sign;
  509. if ( sign == null || from.Map != sign.Map || !from.InRange( sign.GetWorldLocation(), 18 ) )
  510. return;
  511. HouseFoundation foundation = m_House as HouseFoundation;
  512. bool isCustomizable = ( foundation != null );
  513. int val = info.ButtonID - 1;
  514. if ( val < 0 )
  515. return;
  516. int type = val % 15;
  517. int index = val / 15;
  518. switch ( type )
  519. {
  520. case 0:
  521. {
  522. switch ( index )
  523. {
  524. case 0: // Banish
  525. {
  526. if ( m_House.Public )
  527. {
  528. from.SendLocalizedMessage( 501325 ); // Target the individual to ban from this house.
  529. from.Target = new HouseBanTarget( true, m_House );
  530. }
  531. break;
  532. }
  533. case 1: // Lift Ban
  534. {
  535. if ( m_House.Public )
  536. from.SendGump( new HouseGumpAOS( HouseGumpPageAOS.RemoveBan, from, m_House ) );
  537. break;
  538. }
  539. case 2: // Grant Access
  540. {
  541. if ( !m_House.Public )
  542. {
  543. from.SendLocalizedMessage( 1060711 ); // Target the person you would like to grant access to.
  544. from.Target = new HouseAccessTarget( m_House );
  545. }
  546. break;
  547. }
  548. case 3: // Revoke Access
  549. {
  550. if ( !m_House.Public )
  551. from.SendGump( new HouseGumpAOS( HouseGumpPageAOS.RemoveAccess, from, m_House ) );
  552. break;
  553. }
  554. }
  555. break;
  556. }
  557. case 1:
  558. {
  559. HouseGumpPageAOS page;
  560. switch ( index )
  561. {
  562. case 0: page = HouseGumpPageAOS.Information; break;
  563. case 1: page = HouseGumpPageAOS.Security; break;
  564. case 2: page = HouseGumpPageAOS.Storage; break;
  565. case 3: page = HouseGumpPageAOS.Customize; break;
  566. case 4: page = HouseGumpPageAOS.Ownership; break;
  567. default: return;
  568. }
  569. from.SendGump( new HouseGumpAOS( page, from, m_House ) );
  570. break;
  571. }
  572. case 3:
  573. {
  574. switch ( index )
  575. {
  576. case 0: // View Co-Owner List
  577. {
  578. if ( isCoOwner )
  579. from.SendGump( new HouseGumpAOS( HouseGumpPageAOS.ListCoOwner, from, m_House ) );
  580. break;
  581. }
  582. case 1: // Add a Co-Owner
  583. {
  584. if ( isOwner )
  585. {
  586. from.SendLocalizedMessage( 501328 ); // Target the person you wish to name a co-owner of your household.
  587. from.Target = new CoOwnerTarget( true, m_House );
  588. }
  589. break;
  590. }
  591. case 2: // Remove a Co-Owner
  592. {
  593. if ( isOwner )
  594. from.SendGump( new HouseGumpAOS( HouseGumpPageAOS.RemoveCoOwner, from, m_House ) );
  595. break;
  596. }
  597. case 3: // Clear Co-Owner List
  598. {
  599. if ( isOwner )
  600. from.SendGump( new WarningGump( 1060635, 30720, 1060736, 32512, 420, 280, new WarningGumpCallback( ClearCoOwners_Callback ), m_House ) );
  601. break;
  602. }
  603. case 4: // View Friends List
  604. {
  605. from.SendGump( new HouseGumpAOS( HouseGumpPageAOS.ListFriend, from, m_House ) );
  606. break;
  607. }
  608. case 5: // Add a Friend
  609. {
  610. if ( isCoOwner )
  611. {
  612. from.SendLocalizedMessage( 501317 ); // Target the person you wish to name a friend of your household.
  613. from.Target = new HouseFriendTarget( true, m_House );
  614. }
  615. break;
  616. }
  617. case 6: // Remove a Friend
  618. {
  619. if ( isCoOwner )
  620. from.SendGump( new HouseGumpAOS( HouseGumpPageAOS.RemoveFriend, from, m_House ) );
  621. break;
  622. }
  623. case 7: // Clear Friend List
  624. {
  625. if ( isCoOwner )
  626. from.SendGump( new WarningGump( 1060635, 30720, 1018039, 32512, 420, 280, new WarningGumpCallback( ClearFriends_Callback ), m_House ) );
  627. break;
  628. }
  629. case 8: // View Ban List
  630. {
  631. from.SendGump( new HouseGumpAOS( HouseGumpPageAOS.ListBan, from, m_House ) );
  632. break;
  633. }
  634. case 9: // Clear Ban List
  635. {
  636. from.SendGump( new WarningGump( 1060635, 30720, 1060753, 32512, 420, 280, new WarningGumpCallback( ClearBans_Callback ), m_House ) );
  637. break;
  638. }
  639. case 10: // View Access List
  640. {
  641. from.SendGump( new HouseGumpAOS( HouseGumpPageAOS.ListAccess, from, m_House ) );
  642. break;
  643. }
  644. case 11: // Clear Access List
  645. {
  646. from.SendGump( new WarningGump( 1060635, 30720, 1061842, 32512, 420, 280, new WarningGumpCallback( ClearAccess_Callback ), m_House ) );
  647. break;
  648. }
  649. case 12: // Make Private
  650. {
  651. if ( isOwner )
  652. {
  653. if ( m_House.FindPlayerVendor() != null )
  654. {
  655. // You have vendors working out of this building. It cannot be declared private until there are no vendors in place.
  656. from.SendGump( new NoticeGump( 1060637, 30720, 501887, 32512, 320, 180, new NoticeGumpCallback( PublicPrivateNotice_Callback ), m_House ) );
  657. break;
  658. }
  659. m_House.Public = false;
  660. m_House.ChangeLocks( from );
  661. // This house is now private.
  662. from.SendGump( new NoticeGump( 1060637, 30720, 501888, 32512, 320, 180, new NoticeGumpCallback( PublicPrivateNotice_Callback ), m_House ) );
  663. Region r = m_House.Region;
  664. ArrayList list = new ArrayList( r.Mobiles );
  665. for ( int i = 0; i < list.Count; ++i )
  666. {
  667. Mobile m = (Mobile)list[i];
  668. if ( !m_House.HasAccess( m ) && m_House.IsInside( m ) )
  669. m.Location = m_House.BanLocation;
  670. }
  671. }
  672. break;
  673. }
  674. case 13: // Make Public
  675. {
  676. if ( isOwner )
  677. {
  678. m_House.Public = true;
  679. m_House.RemoveKeys( from );
  680. m_House.RemoveLocks();
  681. // This house is now public. Friends of the house may now have vendors working out of this building.
  682. from.SendGump( new NoticeGump( 1060637, 30720, 501886, 32512, 320, 180, new NoticeGumpCallback( PublicPrivateNotice_Callback ), m_House ) );
  683. Region r = m_House.Region;
  684. ArrayList list = new ArrayList( r.Mobiles );
  685. for ( int i = 0; i < list.Count; ++i )
  686. {
  687. Mobile m = (Mobile)list[i];
  688. if ( m_House.IsBanned( m ) && m_House.IsInside( m ) )
  689. m.Location = m_House.BanLocation;
  690. }
  691. }
  692. break;
  693. }
  694. }
  695. break;
  696. }
  697. case 5:
  698. {
  699. switch ( index )
  700. {
  701. case 0: // Convert Into Customizable House
  702. {
  703. if ( isOwner && !isCustomizable )
  704. {
  705. HousePlacementEntry e = m_House.ConvertEntry;
  706. if ( e != null )
  707. {
  708. /* You are about to turn your house into a customizable house.
  709. * You will be refunded the value of this house, and then be charged the cost of the equivalent customizable dirt lot.
  710. * All of your possessions in the house will be transported to a Moving Crate.
  711. * Deed-based house add-ons will be converted back into deeds.
  712. * Vendors and barkeeps will also be stored in the Moving Crate.
  713. * Your house will be leveled to its foundation, and you will be able to build new walls, windows, doors, and stairs.
  714. * Are you sure you wish to continue?
  715. */
  716. from.SendGump( new WarningGump( 1060635, 30720, 1060013, 32512, 420, 280, new WarningGumpCallback( ConvertHouse_Callback ), m_House ) );
  717. }
  718. }
  719. break;
  720. }
  721. case 1: // Customize This House
  722. {
  723. if ( isOwner && isCustomizable )
  724. foundation.BeginCustomize( from );
  725. break;
  726. }
  727. case 2: // Relocate Moving Crate
  728. break;
  729. case 3: // Change House Sign
  730. {
  731. if ( isOwner && m_House.Public )
  732. from.SendGump( new HouseGumpAOS( HouseGumpPageAOS.ChangeSign, from, m_House ) );
  733. break;
  734. }
  735. case 4: // Change House Sign Hanger
  736. {
  737. if ( isOwner && isCustomizable )
  738. from.SendGump( new HouseGumpAOS( HouseGumpPageAOS.ChangeHanger, from, m_House ) );
  739. break;
  740. }
  741. case 5: // Change Signpost
  742. {
  743. if ( isOwner && isCustomizable && foundation.Signpost != null )
  744. from.SendGump( new HouseGumpAOS( HouseGumpPageAOS.ChangePost, from, m_House ) );
  745. break;
  746. }
  747. case 6: // Change Foundation Style
  748. {
  749. if ( isOwner && isCustomizable )
  750. from.SendGump( new HouseGumpAOS( HouseGumpPageAOS.ChangeFoundation, from, m_House ) );
  751. break;
  752. }
  753. case 7: // Rename House
  754. {
  755. if ( isCoOwner )
  756. {
  757. from.Prompt = new RenamePrompt( m_House );
  758. from.SendLocalizedMessage( 501302 ); // What dost thou wish the sign to say?
  759. }
  760. break;
  761. }
  762. }
  763. break;
  764. }
  765. case 6:
  766. {
  767. switch ( index )
  768. {
  769. case 0: // Demolish
  770. {
  771. if ( isOwner )
  772. {
  773. from.SendGump( new HouseDemolishGump( from, m_House ) );
  774. }
  775. break;
  776. }
  777. case 1: // Trade House
  778. {
  779. if ( isOwner )
  780. {
  781. from.SendLocalizedMessage( 501309 ); // Target the person to whom you wish to give this house.
  782. from.Target = new HouseOwnerTarget( m_House );
  783. }
  784. break;
  785. }
  786. case 2: // Make Primary
  787. break;
  788. }
  789. break;
  790. }
  791. case 7:
  792. {
  793. if ( isOwner && isCustomizable && index >= 0 && index < m_HangerNumbers.Length )
  794. {
  795. Item hanger = foundation.SignHanger;
  796. if ( hanger != null )
  797. hanger.ItemID = m_HangerNumbers[index];
  798. from.SendGump( new HouseGumpAOS( HouseGumpPageAOS.Customize, from, m_House ) );
  799. }
  800. break;
  801. }
  802. case 8:
  803. {
  804. if ( isOwner && isCustomizable )
  805. {
  806. FoundationType newType;
  807. switch ( index )
  808. {
  809. case 0: newType = FoundationType.DarkWood; break;
  810. case 1: newType = FoundationType.LightWood; break;
  811. case 2: newType = FoundationType.Dungeon; break;
  812. case 3: newType = FoundationType.Brick; break;
  813. case 4: newType = FoundationType.Stone; break;
  814. default: return;
  815. }
  816. foundation.Type = newType;
  817. DesignState state = foundation.BackupState;
  818. HouseFoundation.ApplyFoundation( newType, state.Components );
  819. state.OnRevised();
  820. state = foundation.DesignState;
  821. HouseFoundation.ApplyFoundation( newType, state.Components );
  822. state.OnRevised();
  823. state = foundation.CurrentState;
  824. HouseFoundation.ApplyFoundation( newType, state.Components );
  825. state.OnRevised();
  826. foundation.Delta( ItemDelta.Update );
  827. from.SendGump( new HouseGumpAOS( HouseGumpPageAOS.Customize, from, m_House ) );
  828. }
  829. break;
  830. }
  831. case 9:
  832. {
  833. if ( isOwner && m_House.Public && index >= 0 && index < 54 )
  834. {
  835. m_House.ChangeSignType( 2980 + (index * 2) );
  836. from.SendGump( new HouseGumpAOS( HouseGumpPageAOS.Customize, from, m_House ) );
  837. }
  838. break;
  839. }
  840. case 10:
  841. {
  842. if ( isOwner && m_List != null && index >= 0 && index < m_List.Count )
  843. {
  844. m_House.RemoveCoOwner( from, (Mobile)m_List[index] );
  845. if ( m_List.Count > 0 )
  846. from.SendGump( new HouseGumpAOS( HouseGumpPageAOS.RemoveCoOwner, from, m_House ) );
  847. else
  848. from.SendGump( new HouseGumpAOS( HouseGumpPageAOS.Security, from, m_House ) );
  849. }
  850. break;
  851. }
  852. case 11:
  853. {
  854. if ( isCoOwner && m_List != null && index >= 0 && index < m_List.Count )
  855. {
  856. m_House.RemoveFriend( from, (Mobile)m_List[index] );
  857. if ( m_List.Count > 0 )
  858. from.SendGump( new HouseGumpAOS( HouseGumpPageAOS.RemoveFriend, from, m_House ) );
  859. else
  860. from.SendGump( new HouseGumpAOS( HouseGumpPageAOS.Security, from, m_House ) );
  861. }
  862. break;
  863. }
  864. case 12:
  865. {
  866. if ( m_List != null && index >= 0 && index < m_List.Count )
  867. {
  868. m_House.RemoveBan( from, (Mobile)m_List[index] );
  869. if ( m_List.Count > 0 )
  870. from.SendGump( new HouseGumpAOS( HouseGumpPageAOS.RemoveBan, from, m_House ) );
  871. else
  872. from.SendGump( new HouseGumpAOS( HouseGumpPageAOS.Security, from, m_House ) );
  873. }
  874. break;
  875. }
  876. case 13:
  877. {
  878. if ( m_List != null && index >= 0 && index < m_List.Count )
  879. {
  880. m_House.RemoveAccess( from, (Mobile)m_List[index] );
  881. if ( m_List.Count > 0 )
  882. from.SendGump( new HouseGumpAOS( HouseGumpPageAOS.RemoveAccess, from, m_House ) );
  883. else
  884. from.SendGump( new HouseGumpAOS( HouseGumpPageAOS.Security, from, m_House ) );
  885. }
  886. break;
  887. }
  888. case 14:
  889. {
  890. if ( isOwner && isCustomizable && index >= 0 && index < m_PostNumbers.Length )
  891. {
  892. foundation.SignpostGraphic = m_PostNumbers[index];
  893. foundation.CheckSignpost();
  894. from.SendGump( new HouseGumpAOS( HouseGumpPageAOS.Customize, from, m_House ) );
  895. }
  896. break;
  897. }
  898. }
  899. }
  900. private ArrayList Wrap( string value )
  901. {
  902. if ( value == null || (value = value.Trim()).Length <= 0 )
  903. return null;
  904. string[] values = value.Split( ' ' );
  905. ArrayList list = new ArrayList();
  906. string current = "";
  907. for ( int i = 0; i < values.Length; ++i )
  908. {
  909. string val = values[i];
  910. string v = current.Length == 0 ? val : current + ' ' + val;
  911. if ( v.Length < 10 )
  912. {
  913. current = v;
  914. }
  915. else if ( v.Length == 10 )
  916. {
  917. list.Add( v );
  918. if ( list.Count == 6 )
  919. return list;
  920. current = "";
  921. }
  922. else if ( val.Length <= 10 )
  923. {
  924. list.Add( current );
  925. if ( list.Count == 6 )
  926. return list;
  927. current = val;
  928. }
  929. else
  930. {
  931. while ( v.Length >= 10 )
  932. {
  933. list.Add( v.Substring( 0, 10 ) );
  934. if ( list.Count == 6 )
  935. return list;
  936. v = v.Substring( 10 );
  937. }
  938. current = v;
  939. }
  940. }
  941. if ( current.Length > 0 )
  942. list.Add( current );
  943. return list;
  944. }
  945. }
  946. }