RelationshipDialog.cs 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. using Client.MirControls;
  2. using Client.MirGraphics;
  3. using Client.MirNetwork;
  4. using Client.MirSounds;
  5. using C = ClientPackets;
  6. namespace Client.MirScenes.Dialogs
  7. {
  8. public sealed class RelationshipDialog : MirImageControl
  9. {
  10. public MirImageControl TitleLabel;
  11. public MirButton CloseButton, AllowButton, RequestButton, DivorceButton, MailButton, WhisperButton;
  12. public MirLabel LoverNameLabel, LoverDateLabel, LoverOnlineLabel, LoverLengthLabel;
  13. public string LoverName = "";
  14. public DateTime Date;
  15. public string MapName = "";
  16. public short MarriedDays = 0;
  17. public RelationshipDialog()
  18. {
  19. Index = 583;
  20. Library = Libraries.Prguse;
  21. Movable = true;
  22. Sort = true;
  23. Location = Center;
  24. TitleLabel = new MirImageControl
  25. {
  26. Index = 52,
  27. Library = Libraries.Title,
  28. Location = new Point(18, 8),
  29. Parent = this
  30. };
  31. CloseButton = new MirButton
  32. {
  33. HoverIndex = 361,
  34. Index = 360,
  35. Location = new Point(260, 3),
  36. Library = Libraries.Prguse2,
  37. Parent = this,
  38. PressedIndex = 362,
  39. Sound = SoundList.ButtonA,
  40. };
  41. CloseButton.Click += (o, e) => Hide();
  42. AllowButton = new MirButton
  43. {
  44. HoverIndex = 611,
  45. Index = 610,
  46. Location = new Point(50, 164),
  47. Library = Libraries.Prguse,
  48. Parent = this,
  49. PressedIndex = 612,
  50. Sound = SoundList.ButtonA,
  51. Hint = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.SwitchMarriage)
  52. };
  53. AllowButton.Click += (o, e) => Network.Enqueue(new C.ChangeMarriage());
  54. RequestButton = new MirButton
  55. {
  56. HoverIndex = 601,
  57. Index = 600,
  58. Location = new Point(85, 164),
  59. Library = Libraries.Prguse,
  60. Parent = this,
  61. PressedIndex = 602,
  62. Sound = SoundList.ButtonA,
  63. Hint = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.RequestMarriage)
  64. };
  65. RequestButton.Click += (o, e) =>
  66. {
  67. if (LoverName != "")
  68. {
  69. GameScene.Scene.ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.YouAreAlreadyMarried), ChatType.System);
  70. return;
  71. }
  72. Network.Enqueue(new C.MarriageRequest());
  73. };
  74. DivorceButton = new MirButton
  75. {
  76. HoverIndex = 617,
  77. Index = 616,
  78. Location = new Point(120, 164),
  79. Library = Libraries.Prguse,
  80. Parent = this,
  81. PressedIndex = 618,
  82. Sound = SoundList.ButtonA,
  83. Hint = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.RequestDivorce)
  84. };
  85. DivorceButton.Click += (o, e) =>
  86. {
  87. if (LoverName == "")
  88. {
  89. GameScene.Scene.ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.YouAreNotMarried), ChatType.System);
  90. return;
  91. }
  92. Network.Enqueue(new C.DivorceRequest());
  93. };
  94. MailButton = new MirButton
  95. {
  96. HoverIndex = 438,
  97. Index = 437,
  98. Location = new Point(155, 164),
  99. Library = Libraries.Prguse,
  100. Parent = this,
  101. PressedIndex = 439,
  102. Sound = SoundList.ButtonA,
  103. Hint = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.MailLover)
  104. };
  105. MailButton.Click += (o, e) =>
  106. {
  107. if (LoverName == "")
  108. {
  109. GameScene.Scene.ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.YouAreNotMarried), ChatType.System);
  110. return;
  111. }
  112. GameScene.Scene.MailComposeLetterDialog.ComposeMail(LoverName);
  113. };
  114. WhisperButton = new MirButton
  115. {
  116. HoverIndex = 567,
  117. Index = 566,
  118. Location = new Point(190, 164),
  119. Library = Libraries.Prguse,
  120. Parent = this,
  121. PressedIndex = 568,
  122. Sound = SoundList.ButtonA,
  123. Hint = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.WhisperLover)
  124. };
  125. WhisperButton.Click += (o, e) =>
  126. {
  127. if (LoverName == "")
  128. {
  129. GameScene.Scene.ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.YouAreNotMarried), ChatType.System);
  130. return;
  131. }
  132. if (MapName == "")
  133. {
  134. GameScene.Scene.ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.LoverIsNotOnline), ChatType.System);
  135. return;
  136. }
  137. GameScene.Scene.ChatDialog.ChatTextBox.SetFocus();
  138. GameScene.Scene.ChatDialog.ChatTextBox.Text = ":)";
  139. GameScene.Scene.ChatDialog.ChatTextBox.Visible = true;
  140. GameScene.Scene.ChatDialog.ChatTextBox.TextBox.SelectionLength = 0;
  141. GameScene.Scene.ChatDialog.ChatTextBox.TextBox.SelectionStart = GameScene.Scene.ChatDialog.ChatTextBox.Text.Length;
  142. };
  143. LoverNameLabel = new MirLabel
  144. {
  145. Location = new Point(30, 40),
  146. Size = new Size(200, 30),
  147. BackColour = Color.Empty,
  148. ForeColour = Color.LightGray,
  149. DrawFormat = TextFormatFlags.VerticalCenter,
  150. Parent = this,
  151. NotControl = true,
  152. Font = new Font(Settings.FontName, 10F),
  153. };
  154. LoverDateLabel = new MirLabel
  155. {
  156. Location = new Point(30, 65),
  157. Size = new Size(200, 30),
  158. BackColour = Color.Empty,
  159. ForeColour = Color.LightGray,
  160. DrawFormat = TextFormatFlags.VerticalCenter,
  161. Parent = this,
  162. NotControl = true,
  163. Font = new Font(Settings.FontName, 10F),
  164. };
  165. LoverLengthLabel = new MirLabel
  166. {
  167. Location = new Point(30, 90),
  168. Size = new Size(200, 30),
  169. BackColour = Color.Empty,
  170. ForeColour = Color.LightGray,
  171. DrawFormat = TextFormatFlags.VerticalCenter,
  172. Parent = this,
  173. NotControl = true,
  174. Font = new Font(Settings.FontName, 10F),
  175. };
  176. LoverOnlineLabel = new MirLabel
  177. {
  178. Location = new Point(30, 115),
  179. Size = new Size(200, 30),
  180. BackColour = Color.Empty,
  181. ForeColour = Color.LightGray,
  182. DrawFormat = TextFormatFlags.VerticalCenter,
  183. Parent = this,
  184. NotControl = true,
  185. Font = new Font(Settings.FontName, 10F),
  186. };
  187. }
  188. public void UpdateInterface()
  189. {
  190. LoverNameLabel.Text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.LoverName), LoverName);
  191. if (MapName != "")
  192. {
  193. LoverOnlineLabel.Text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.LoverLocation), MapName);
  194. }
  195. else
  196. LoverOnlineLabel.Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.LoverLocationOffline);
  197. if ((LoverName == "") && (Date != default))
  198. {
  199. if (Date < new DateTime(2000))
  200. {
  201. LoverDateLabel.Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.LoverDate);
  202. LoverLengthLabel.Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.LoverLength);
  203. }
  204. else
  205. {
  206. LoverDateLabel.Text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.DivorcedDate), Date.ToShortDateString());
  207. LoverLengthLabel.Text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.TimeSinceDays), MarriedDays);
  208. }
  209. LoverOnlineLabel.Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.LoverLocationTitle)
  210. ;
  211. AllowButton.Hint = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.SwitchMarriage);
  212. }
  213. else
  214. {
  215. LoverDateLabel.Text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.MarriageDate), Date == DateTime.MinValue ? string.Empty : Date.ToShortDateString());
  216. LoverLengthLabel.Text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.LengthDays), MarriedDays);
  217. AllowButton.Hint = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.AllowBlockRecall);
  218. }
  219. }
  220. }
  221. }