MentorDialog.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  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 MentorDialog : MirImageControl
  9. {
  10. public MirImageControl TitleLabel;
  11. public MirButton CloseButton, AllowButton, AddButton, RemoveButton;
  12. public MirLabel MentorNameLabel, MentorLevelLabel, MentorOnlineLabel, StudentNameLabel, StudentLevelLabel, StudentOnlineLabel, MentorLabel, StudentLabel, MenteeEXPLabel;
  13. public string MentorName;
  14. public ushort MentorLevel;
  15. public bool MentorOnline;
  16. public long MenteeEXP;
  17. public MentorDialog()
  18. {
  19. Index = 170;
  20. Library = Libraries.Prguse;
  21. Movable = true;
  22. Sort = true;
  23. Location = Center;
  24. TitleLabel = new MirImageControl
  25. {
  26. Index = 51,
  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(219, 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 = 115,
  45. Index = 114,
  46. Location = new Point(30, 178),
  47. Library = Libraries.Prguse,
  48. Parent = this,
  49. PressedIndex = 116,
  50. Sound = SoundList.ButtonA,
  51. Hint = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.MentorRequests)
  52. };
  53. AllowButton.Click += (o, e) =>
  54. {
  55. if (AllowButton.Index == 116)
  56. {
  57. AllowButton.Index = 117;
  58. AllowButton.HoverIndex = 118;
  59. AllowButton.PressedIndex = 119;
  60. }
  61. else
  62. {
  63. AllowButton.Index = 114;
  64. AllowButton.HoverIndex = 115;
  65. AllowButton.PressedIndex = 116;
  66. }
  67. Network.Enqueue(new C.AllowMentor());
  68. };
  69. AddButton = new MirButton
  70. {
  71. HoverIndex = 214,
  72. Index = 213,
  73. Location = new Point(60, 178),
  74. Library = Libraries.Title,
  75. Parent = this,
  76. PressedIndex = 215,
  77. Sound = SoundList.ButtonA,
  78. Hint = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.AddMentor)
  79. };
  80. AddButton.Click += (o, e) =>
  81. {
  82. if (MentorLevel != 0)
  83. {
  84. GameScene.Scene.ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.YouAlreadyHaveMentor), ChatType.System);
  85. return;
  86. }
  87. string message = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.MentorEnterName);
  88. MirInputBox inputBox = new MirInputBox(message);
  89. inputBox.OKButton.Click += (o1, e1) =>
  90. {
  91. Network.Enqueue(new C.AddMentor { Name = inputBox.InputTextBox.Text });
  92. inputBox.Dispose();
  93. };
  94. inputBox.Show();
  95. };
  96. RemoveButton = new MirButton
  97. {
  98. HoverIndex = 217,
  99. Index = 216,
  100. Location = new Point(135, 178),
  101. Library = Libraries.Title,
  102. Parent = this,
  103. PressedIndex = 218,
  104. Sound = SoundList.ButtonA,
  105. Hint = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.RemoveMentorMentee)
  106. };
  107. RemoveButton.Click += (o, e) =>
  108. {
  109. if (MentorName == "")
  110. {
  111. GameScene.Scene.ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.NoMentorship), ChatType.System);
  112. return;
  113. }
  114. MirMessageBox messageBox = new MirMessageBox(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.CancellingMentorshipCausesCooldown), MirMessageBoxButtons.YesNo);
  115. messageBox.YesButton.Click += (oo, ee) => Network.Enqueue(new C.CancelMentor { });
  116. messageBox.NoButton.Click += (oo, ee) => { messageBox.Dispose(); };
  117. messageBox.Show();
  118. };
  119. MentorNameLabel = new MirLabel
  120. {
  121. Location = new Point(20, 58),
  122. Size = new Size(200, 30),
  123. BackColour = Color.Empty,
  124. ForeColour = Color.LightGray,
  125. DrawFormat = TextFormatFlags.VerticalCenter,
  126. Parent = this,
  127. NotControl = true,
  128. Font = new Font(Settings.FontName, 10F),
  129. };
  130. MentorLevelLabel = new MirLabel
  131. {
  132. Location = new Point(170, 58),
  133. Size = new Size(200, 30),
  134. BackColour = Color.Empty,
  135. ForeColour = Color.LightGray,
  136. DrawFormat = TextFormatFlags.VerticalCenter,
  137. Parent = this,
  138. NotControl = true,
  139. Font = new Font(Settings.FontName, 10F),
  140. };
  141. MentorOnlineLabel = new MirLabel
  142. {
  143. Location = new Point(125, 58),
  144. Size = new Size(200, 30),
  145. BackColour = Color.Empty,
  146. ForeColour = Color.Green,
  147. DrawFormat = TextFormatFlags.VerticalCenter,
  148. Parent = this,
  149. NotControl = true,
  150. Font = new Font(Settings.FontName, 7F),
  151. Visible = false,
  152. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ONLINE),
  153. };
  154. StudentNameLabel = new MirLabel
  155. {
  156. Location = new Point(20, 112),
  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. StudentLevelLabel = new MirLabel
  166. {
  167. Location = new Point(170, 111),
  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. StudentOnlineLabel = new MirLabel
  177. {
  178. Location = new Point(125, 112),
  179. Size = new Size(200, 30),
  180. BackColour = Color.Empty,
  181. ForeColour = Color.Green,
  182. DrawFormat = TextFormatFlags.VerticalCenter,
  183. Parent = this,
  184. NotControl = true,
  185. Font = new Font(Settings.FontName, 7F),
  186. Visible = false,
  187. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ONLINE),
  188. };
  189. MentorLabel = new MirLabel
  190. {
  191. Location = new Point(15, 41),
  192. Size = new Size(200, 30),
  193. BackColour = Color.Empty,
  194. ForeColour = Color.DimGray,
  195. DrawFormat = TextFormatFlags.VerticalCenter,
  196. Parent = this,
  197. NotControl = true,
  198. Font = new Font(Settings.FontName, 7F),
  199. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.MENTOR),
  200. };
  201. StudentLabel = new MirLabel
  202. {
  203. Location = new Point(15, 94),
  204. Size = new Size(200, 30),
  205. BackColour = Color.Empty,
  206. ForeColour = Color.DimGray,
  207. DrawFormat = TextFormatFlags.VerticalCenter,
  208. Parent = this,
  209. NotControl = true,
  210. Font = new Font(Settings.FontName, 7F),
  211. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.MENTEE),
  212. };
  213. MenteeEXPLabel = new MirLabel
  214. {
  215. Location = new Point(15, 147),
  216. Size = new Size(200, 30),
  217. BackColour = Color.Empty,
  218. ForeColour = Color.DimGray,
  219. DrawFormat = TextFormatFlags.VerticalCenter,
  220. Parent = this,
  221. NotControl = true,
  222. Font = new Font(Settings.FontName, 7F),
  223. };
  224. }
  225. public void UpdateInterface()
  226. {
  227. if (MentorLevel == 0)
  228. {
  229. MentorNameLabel.Visible = false;
  230. MentorLevelLabel.Visible = false;
  231. MentorOnlineLabel.Visible = false;
  232. StudentNameLabel.Visible = false;
  233. StudentLevelLabel.Visible = false;
  234. StudentOnlineLabel.Visible = false;
  235. MenteeEXPLabel.Visible = false;
  236. return;
  237. }
  238. MentorNameLabel.Visible = true;
  239. MentorLevelLabel.Visible = true;
  240. MentorOnlineLabel.Visible = true;
  241. StudentNameLabel.Visible = true;
  242. StudentLevelLabel.Visible = true;
  243. StudentOnlineLabel.Visible = true;
  244. if (GameScene.User.Level > MentorLevel)
  245. {
  246. MentorNameLabel.Text = GameScene.User.Name;
  247. MentorLevelLabel.Text = "Lv " + GameScene.User.Level.ToString();
  248. MentorOnlineLabel.Visible = false;
  249. StudentNameLabel.Text = MentorName;
  250. StudentLevelLabel.Text = "Lv " + MentorLevel.ToString();
  251. if (MentorOnline)
  252. StudentOnlineLabel.Visible = true;
  253. else
  254. StudentOnlineLabel.Visible = false;
  255. MenteeEXPLabel.Visible = true;
  256. MenteeEXPLabel.Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.MenteeExp) + MenteeEXP;
  257. }
  258. else
  259. {
  260. MentorNameLabel.Text = MentorName;
  261. MentorLevelLabel.Text = "Lv " + MentorLevel.ToString();
  262. if (MentorOnline)
  263. MentorOnlineLabel.Visible = true;
  264. else
  265. MentorOnlineLabel.Visible = false;
  266. StudentNameLabel.Text = GameScene.User.Name;
  267. StudentLevelLabel.Text = "Lv " + GameScene.User.Level.ToString();
  268. StudentOnlineLabel.Visible = false;
  269. }
  270. }
  271. }
  272. }