GuildTerritoryDialog .cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. using Client.MirControls;
  2. using Client.MirGraphics;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Drawing;
  6. using Client.MirSounds;
  7. using Client.MirNetwork;
  8. using C = ClientPackets;
  9. namespace Client.MirScenes.Dialogs
  10. {
  11. public class GTRow : MirImageControl
  12. {
  13. public MirLabel Idx;
  14. public MirLabel GuildOwner;
  15. public string Owner1, Owner2;
  16. public MirLabel OwnerName;
  17. public MirLabel Status;
  18. public MirLabel Price;
  19. public GTRow()
  20. {
  21. Size = new Size(550, 17);
  22. Idx = new MirLabel
  23. {
  24. Location = new Point(15, 0),
  25. AutoSize = true,
  26. Parent = this,
  27. ForeColour = Color.White,
  28. NotControl = true,
  29. BackColour = Color.Transparent,
  30. };
  31. GuildOwner = new MirLabel
  32. {
  33. Location = new Point(45, 0),
  34. AutoSize = true,
  35. Parent = this,
  36. ForeColour = Color.White,
  37. NotControl = true,
  38. BackColour = Color.Transparent,
  39. };
  40. OwnerName = new MirLabel
  41. {
  42. Location = new Point(150, 0),
  43. AutoSize = true,
  44. Parent = this,
  45. ForeColour = Color.White,
  46. NotControl = true,
  47. BackColour = Color.Transparent,
  48. };
  49. Status = new MirLabel
  50. {
  51. Location = new Point(365, 0),
  52. AutoSize = true,
  53. Parent = this,
  54. ForeColour = Color.White,
  55. NotControl = true,
  56. BackColour = Color.Transparent,
  57. };
  58. Price = new MirLabel
  59. {
  60. Location = new Point(460, 0),
  61. AutoSize = true,
  62. Parent = this,
  63. ForeColour = Color.White,
  64. NotControl = true,
  65. BackColour = Color.Transparent,
  66. };
  67. }
  68. }
  69. public sealed class GuildTerritoryDialog : MirImageControl
  70. {
  71. public List<ClientGTMap> GTMapList = new List<ClientGTMap>();
  72. public List<GTRow> GTRowList = new List<GTRow>();
  73. public int Page = 0, Lenght = 0;
  74. public MirButton BuyButton;
  75. public int selectedIndex = -1;
  76. public GuildTerritoryDialog()
  77. {
  78. Index = 680;
  79. Library = Libraries.Prguse;
  80. Movable = true;
  81. Sort = true;
  82. #region Buttons.
  83. var closeButton = new MirButton
  84. {
  85. Parent = this,
  86. Index = 361,
  87. PressedIndex = 363,
  88. HoverIndex = 362,
  89. Library = Libraries.Prguse,
  90. Location = new Point(544, 8),
  91. Hint = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ExitButton)
  92. };
  93. closeButton.Click += (o, e) => Hide();
  94. var prevButton = new MirButton
  95. {
  96. HoverIndex = 241,
  97. Index = 240,
  98. Location = new Point(214, 213),
  99. Library = Libraries.Prguse2,
  100. Parent = this,
  101. PressedIndex = 242,
  102. Sound = SoundList.ButtonA,
  103. Hint = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.PageBack)
  104. };
  105. prevButton.Click += (o, e) =>
  106. {
  107. if ((Page - 1) >= 0)
  108. {
  109. Page--;
  110. Network.Enqueue(new C.GuildTerritoryPage { Page = Page });
  111. Reset();
  112. }
  113. };
  114. var nextButton = new MirButton
  115. {
  116. HoverIndex = 244,
  117. Index = 243,
  118. Location = new Point(317, 213),
  119. Library = Libraries.Prguse2,
  120. Parent = this,
  121. PressedIndex = 245,
  122. Sound = SoundList.ButtonA,
  123. Hint = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.PageForward)
  124. };
  125. nextButton.Click += (o, e) =>
  126. {
  127. if (((Page + 1) * 7) < Lenght)
  128. {
  129. Page++;
  130. Network.Enqueue(new C.GuildTerritoryPage { Page = Page });
  131. Reset();
  132. }
  133. };
  134. var mailButton = new MirButton
  135. {
  136. Index = 437,
  137. HoverIndex = 438,
  138. PressedIndex = 439,
  139. Library = Libraries.Prguse,
  140. Location = new Point(262, 208),
  141. Sound = SoundList.ButtonA,
  142. Parent = this,
  143. Hint = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.MailGuildLeader)
  144. };
  145. mailButton.Click += (o, e) =>
  146. {
  147. var GT = GTRowList.FirstOrDefault(x => x.Idx.Text == selectedIndex.ToString());
  148. if (GT == null || GT.OwnerName.Text == GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.None)) return;
  149. GameScene.Scene.MailComposeLetterDialog.ComposeMail(GT.Owner1);
  150. };
  151. BuyButton = new MirButton
  152. {
  153. Index = 437,
  154. HoverIndex = 438,
  155. PressedIndex = 439,
  156. Library = Libraries.Prguse,
  157. Location = new Point(292, 208),
  158. Sound = SoundList.ButtonA,
  159. Parent = this,
  160. Hint = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Purchase),
  161. Visible = false
  162. };
  163. BuyButton.Click += (o, e) =>
  164. {
  165. var GT = GTRowList.FirstOrDefault(x => x.Idx.Text == selectedIndex.ToString());
  166. if (GT == null || GT.OwnerName.Text == GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.None)) return;
  167. if (GT.Status.Text != GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ForSale)) return;
  168. Network.Enqueue(new C.PurchaseGuildTerritory { Owner = GT.GuildOwner.Text });
  169. };
  170. #endregion
  171. #region Labels.
  172. var _titleLabel = new MirImageControl
  173. {
  174. Index = 54,
  175. Library = Libraries.Title,
  176. Location = new Point(217, 11),
  177. Parent = this
  178. };
  179. var __gtnumberLabel = new MirLabel
  180. {
  181. Location = new Point(15, 38),
  182. AutoSize = true,
  183. Parent = this,
  184. ForeColour = Color.Goldenrod,
  185. Font = new Font(Settings.FontName, 8F),
  186. NotControl = true,
  187. BackColour = Color.Transparent,
  188. Text = "GT #"
  189. };
  190. var __gtguildLabel = new MirLabel
  191. {
  192. Location = new Point(60, 38),
  193. AutoSize = true,
  194. Parent = this,
  195. ForeColour = Color.Goldenrod,
  196. Font = new Font(Settings.FontName, 8F),
  197. NotControl = true,
  198. BackColour = Color.Transparent,
  199. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.OwningGuild)
  200. };
  201. var __gtguildownersLabel = new MirLabel
  202. {
  203. Location = new Point(230, 38),
  204. AutoSize = true,
  205. Parent = this,
  206. ForeColour = Color.Goldenrod,
  207. Font = new Font(Settings.FontName, 8F),
  208. NotControl = true,
  209. BackColour = Color.Transparent,
  210. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.GuildLeaders)
  211. };
  212. var __gtstatusLabel = new MirLabel
  213. {
  214. Location = new Point(380, 38),
  215. AutoSize = true,
  216. Parent = this,
  217. ForeColour = Color.Goldenrod,
  218. Font = new Font(Settings.FontName, 8F),
  219. NotControl = true,
  220. BackColour = Color.Transparent,
  221. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.GTStatus)
  222. };
  223. var __gtpriceLabel = new MirLabel
  224. {
  225. Location = new Point(480, 38),
  226. AutoSize = true,
  227. Parent = this,
  228. ForeColour = Color.Goldenrod,
  229. Font = new Font(Settings.FontName, 8F),
  230. NotControl = true,
  231. BackColour = Color.Transparent,
  232. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.GTPrice)
  233. };
  234. for (int i = 0; i < 7; i++)
  235. {
  236. GTRow gt = new GTRow
  237. {
  238. Parent = this,
  239. Location = new Point(5, 60 + 20 * i),
  240. Border = false,
  241. BorderColour = Color.Lime,
  242. };
  243. gt.Idx.Text = (i + 1).ToString();
  244. gt.GuildOwner.Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.None);
  245. gt.OwnerName.Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.None);
  246. gt.Status.Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Available);
  247. gt.Price.Text = "10,000,000";
  248. gt.Click += (e, o) =>
  249. {
  250. var obj = ((GTRow)e);
  251. Reset();
  252. if (obj.GuildOwner.Text != string.Empty)
  253. {
  254. int.TryParse(obj.Idx.Text, out selectedIndex);
  255. obj.Border = true;
  256. BuyButton.Visible = obj.Status.Text == GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ForSale);
  257. }
  258. };
  259. GTRowList.Add(gt);
  260. }
  261. #endregion
  262. }
  263. public void Reset()
  264. {
  265. foreach (var r in GameScene.Scene.GuildTerritoryDialog.GTRowList)
  266. {
  267. r.Border = false;
  268. }
  269. selectedIndex = -1;
  270. }
  271. public override void Show()
  272. {
  273. Visible = true;
  274. }
  275. public override void Hide()
  276. {
  277. Visible = false;
  278. }
  279. public void UpdateInterface()
  280. {
  281. for (int i = 0; i < GTRowList.Count; i++)
  282. {
  283. if (GTMapList.Count > i)
  284. {
  285. var gtMap = GTMapList[i];
  286. var gtRow = GTRowList[i];
  287. gtRow.Idx.Text = ((i + 1) + Page * 7).ToString();
  288. gtRow.GuildOwner.Text = gtMap.Owner;
  289. gtRow.Owner1 = gtMap.Leader;
  290. gtRow.Owner2 = gtMap.Leader2;
  291. gtRow.OwnerName.Text = gtMap.Leader;
  292. if (gtMap.Leader2 != string.Empty)
  293. gtRow.OwnerName.Text += GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.AndPlaceholder), gtMap.Leader2);
  294. if (gtMap.Owner != GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.None))
  295. if (gtMap.begin > 0)
  296. gtRow.Status.Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.SalePending);
  297. else
  298. gtRow.Status.Text = gtMap.price > 0 ? GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ForSale) : GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Unavailable);
  299. else
  300. gtRow.Status.Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Available);
  301. gtRow.Price.Text = gtMap.price.ToString("###,###,##0");
  302. }
  303. else
  304. {
  305. var gtRow = GTRowList[i];
  306. gtRow.Idx.Text = string.Empty;
  307. gtRow.GuildOwner.Text = string.Empty;
  308. gtRow.OwnerName.Text = string.Empty;
  309. gtRow.Status.Text = string.Empty;
  310. gtRow.Price.Text = string.Empty;
  311. }
  312. }
  313. }
  314. }
  315. }