ChatOptionDialog.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. using Client.MirControls;
  2. using Client.MirGraphics;
  3. using Client.MirSounds;
  4. namespace Client.MirScenes.Dialogs
  5. {
  6. public class ChatOptionDialog : MirImageControl
  7. {
  8. public MirButton FilterTabButton, ChatTabButton;
  9. public MirButton CloseButton;
  10. public MirButton AllButton, GeneralButton, WhisperButton, ShoutButton, SystemButton, LoverButton, MentorButton, GroupButton, GuildButton;
  11. public MirButton TransparencyOnButton, TransparencyOffButton;
  12. public bool AllFiltersOff = true;
  13. public ChatOptionDialog()
  14. {
  15. Index = 466;
  16. Library = Libraries.Title;
  17. Size = new Size(224, 180);
  18. Movable = true;
  19. Sort = true;
  20. Location = new Point((Settings.ScreenWidth - Size.Width) / 2, (Settings.ScreenHeight - Size.Height) / 2);
  21. BeforeDraw += ChatFilterPanel_BeforeDraw;
  22. FilterTabButton = new MirButton
  23. {
  24. Index = 463,
  25. PressedIndex = 462,
  26. Parent = this,
  27. Library = Libraries.Title,
  28. Sound = SoundList.ButtonA,
  29. Location = new Point(8, 8)
  30. };
  31. FilterTabButton.Click += (o, e) => SwitchTab(0);
  32. ChatTabButton = new MirButton
  33. {
  34. Index = 464,
  35. PressedIndex = 465,
  36. Parent = this,
  37. Library = Libraries.Title,
  38. Sound = SoundList.ButtonA,
  39. Location = new Point(78, 8)
  40. };
  41. ChatTabButton.Click += (o, e) => SwitchTab(1);
  42. CloseButton = new MirButton
  43. {
  44. HoverIndex = 361,
  45. Index = 360,
  46. Location = new Point(198, 3),
  47. Library = Libraries.Prguse2,
  48. Parent = this,
  49. PressedIndex = 362,
  50. Sound = SoundList.ButtonA,
  51. };
  52. CloseButton.Click += (o, e) => Hide();
  53. #region Filters
  54. AllButton = new MirButton
  55. {
  56. Index = 2087,
  57. Library = Libraries.Prguse,
  58. Parent = this,
  59. Location = new Point(74, 47),
  60. Sound = SoundList.ButtonA,
  61. Size = new Size(16, 12)
  62. };
  63. AllButton.Click += (o, e) => ToggleAllFilters();
  64. GeneralButton = new MirButton
  65. {
  66. Index = 2071,
  67. Library = Libraries.Prguse,
  68. Parent = this,
  69. Location = new Point(40, 69),
  70. Sound = SoundList.ButtonA
  71. };
  72. GeneralButton.Click += (o, e) =>
  73. {
  74. Settings.FilterNormalChat = !Settings.FilterNormalChat;
  75. CheckAllFilters();
  76. };
  77. WhisperButton = new MirButton
  78. {
  79. Index = 2075,
  80. Library = Libraries.Prguse,
  81. Parent = this,
  82. Location = new Point(40, 92),
  83. Sound = SoundList.ButtonA
  84. };
  85. WhisperButton.Click += (o, e) =>
  86. {
  87. Settings.FilterWhisperChat = !Settings.FilterWhisperChat;
  88. CheckAllFilters();
  89. };
  90. ShoutButton = new MirButton
  91. {
  92. Index = 2073,
  93. Library = Libraries.Prguse,
  94. Parent = this,
  95. Location = new Point(40, 115),
  96. Sound = SoundList.ButtonA
  97. };
  98. ShoutButton.Click += (o, e) =>
  99. {
  100. Settings.FilterShoutChat = !Settings.FilterShoutChat;
  101. CheckAllFilters();
  102. };
  103. SystemButton = new MirButton
  104. {
  105. Index = 2085,
  106. Library = Libraries.Prguse,
  107. Parent = this,
  108. Location = new Point(40, 138),
  109. Sound = SoundList.ButtonA
  110. };
  111. SystemButton.Click += (o, e) =>
  112. {
  113. Settings.FilterSystemChat = !Settings.FilterSystemChat;
  114. CheckAllFilters();
  115. };
  116. LoverButton = new MirButton
  117. {
  118. Index = 2077,
  119. Library = Libraries.Prguse,
  120. Parent = this,
  121. Location = new Point(135, 69),
  122. Sound = SoundList.ButtonA
  123. };
  124. LoverButton.Click += (o, e) =>
  125. {
  126. Settings.FilterLoverChat = !Settings.FilterLoverChat;
  127. CheckAllFilters();
  128. };
  129. MentorButton = new MirButton
  130. {
  131. Index = 2079,
  132. Library = Libraries.Prguse,
  133. Parent = this,
  134. Location = new Point(135, 92),
  135. Sound = SoundList.ButtonA
  136. };
  137. MentorButton.Click += (o, e) =>
  138. {
  139. Settings.FilterMentorChat = !Settings.FilterMentorChat;
  140. CheckAllFilters();
  141. };
  142. GroupButton = new MirButton
  143. {
  144. Index = 2081,
  145. Library = Libraries.Prguse,
  146. Parent = this,
  147. Location = new Point(135, 115),
  148. Sound = SoundList.ButtonA
  149. };
  150. GroupButton.Click += (o, e) =>
  151. {
  152. Settings.FilterGroupChat = !Settings.FilterGroupChat;
  153. CheckAllFilters();
  154. };
  155. GuildButton = new MirButton
  156. {
  157. Index = 2083,
  158. Library = Libraries.Prguse,
  159. Parent = this,
  160. Location = new Point(135, 138),
  161. Sound = SoundList.ButtonA
  162. };
  163. GuildButton.Click += (o, e) =>
  164. {
  165. Settings.FilterGuildChat = !Settings.FilterGuildChat;
  166. CheckAllFilters();
  167. };
  168. #endregion
  169. #region Transparency
  170. TransparencyOffButton = new MirButton
  171. {
  172. Index = 471,
  173. HoverIndex = 472,
  174. PressedIndex = 470,
  175. Location = new Point(45, 90),
  176. Parent = this,
  177. Library = Libraries.Title,
  178. Sound = SoundList.ButtonA,
  179. Visible = false
  180. };
  181. TransparencyOffButton.Click += (o, e) =>
  182. {
  183. Settings.TransparentChat = false;
  184. UpdateTransparency();
  185. };
  186. TransparencyOnButton = new MirButton
  187. {
  188. Index = 474,
  189. HoverIndex = 475,
  190. PressedIndex = 473,
  191. Location = new Point(115, 90),
  192. Parent = this,
  193. Library = Libraries.Title,
  194. Sound = SoundList.ButtonA,
  195. Visible = false
  196. };
  197. TransparencyOnButton.Click += (o, e) =>
  198. {
  199. Settings.TransparentChat = true;
  200. UpdateTransparency();
  201. };
  202. #endregion
  203. CheckAllFilters();
  204. UpdateTransparency();
  205. }
  206. private void ChatFilterPanel_BeforeDraw(object sender, EventArgs e)
  207. {
  208. AllButton.Index = AllFiltersOff ? 2087 : 2086;
  209. GeneralButton.Index = Settings.FilterNormalChat ? 2070 : 2071;
  210. WhisperButton.Index = Settings.FilterWhisperChat ? 2074 : 2075;
  211. ShoutButton.Index = Settings.FilterShoutChat ? 2072 : 2073;
  212. SystemButton.Index = Settings.FilterSystemChat ? 2084 : 2085;
  213. LoverButton.Index = Settings.FilterLoverChat ? 2076 : 2077;
  214. MentorButton.Index = Settings.FilterMentorChat ? 2078 : 2079;
  215. GroupButton.Index = Settings.FilterGroupChat ? 2080 : 2081;
  216. GuildButton.Index = Settings.FilterGuildChat ? 2082 : 2083;
  217. }
  218. private void SwitchTab(int tab = 0)
  219. {
  220. if(tab == 0)
  221. {
  222. FilterTabButton.Index = 463;
  223. FilterTabButton.PressedIndex = 462;
  224. ChatTabButton.Index = 464;
  225. ChatTabButton.PressedIndex = 465;
  226. Index = 466;
  227. //Show all buttons on filter tab
  228. AllButton.Visible = true;
  229. GeneralButton.Visible = true;
  230. WhisperButton.Visible = true;
  231. ShoutButton.Visible = true;
  232. SystemButton.Visible = true;
  233. LoverButton.Visible = true;
  234. MentorButton.Visible = true;
  235. GroupButton.Visible = true;
  236. GuildButton.Visible = true;
  237. //hide all transparency buttons
  238. TransparencyOffButton.Visible = false;
  239. TransparencyOnButton.Visible = false;
  240. }
  241. else if(tab == 1)
  242. {
  243. FilterTabButton.Index = 462;
  244. FilterTabButton.PressedIndex = 463;
  245. ChatTabButton.Index = 465;
  246. ChatTabButton.PressedIndex = 464;
  247. Index = 467;
  248. //Hide all buttons on filter tab
  249. AllButton.Visible = false;
  250. GeneralButton.Visible = false;
  251. WhisperButton.Visible = false;
  252. ShoutButton.Visible = false;
  253. SystemButton.Visible = false;
  254. LoverButton.Visible = false;
  255. MentorButton.Visible = false;
  256. GroupButton.Visible = false;
  257. GuildButton.Visible = false;
  258. //show all transparency buttons
  259. TransparencyOffButton.Visible = true;
  260. TransparencyOnButton.Visible = true;
  261. }
  262. }
  263. private void CheckAllFilters()
  264. {
  265. if (!Settings.FilterNormalChat && !Settings.FilterWhisperChat
  266. && !Settings.FilterShoutChat && !Settings.FilterSystemChat
  267. && !Settings.FilterLoverChat && !Settings.FilterMentorChat
  268. && !Settings.FilterGroupChat && !Settings.FilterGuildChat)
  269. {
  270. AllFiltersOff = true;
  271. }
  272. else
  273. {
  274. AllFiltersOff = false;
  275. }
  276. GameScene.Scene.ChatDialog.Update();
  277. }
  278. private void ToggleAllFilters()
  279. {
  280. if(AllFiltersOff)
  281. {
  282. //turn all filters on
  283. Settings.FilterNormalChat = true;
  284. Settings.FilterWhisperChat = true;
  285. Settings.FilterShoutChat = true;
  286. Settings.FilterSystemChat = true;
  287. Settings.FilterLoverChat = true;
  288. Settings.FilterMentorChat = true;
  289. Settings.FilterGroupChat = true;
  290. Settings.FilterGuildChat = true;
  291. AllButton.Index = 2086;
  292. }
  293. else
  294. {
  295. //turn all filters off
  296. Settings.FilterNormalChat = false;
  297. Settings.FilterWhisperChat = false;
  298. Settings.FilterShoutChat = false;
  299. Settings.FilterSystemChat = false;
  300. Settings.FilterLoverChat = false;
  301. Settings.FilterMentorChat = false;
  302. Settings.FilterGroupChat = false;
  303. Settings.FilterGuildChat = false;
  304. AllButton.Index = 2087;
  305. }
  306. AllFiltersOff = !AllFiltersOff;
  307. GameScene.Scene.ChatDialog.Update();
  308. }
  309. private void UpdateTransparency()
  310. {
  311. if (Settings.TransparentChat)
  312. {
  313. GameScene.Scene.ChatDialog.ForeColour = Color.FromArgb(15, 0, 0);
  314. GameScene.Scene.ChatDialog.BackColour = Color.FromArgb(15, 0, 0);
  315. GameScene.Scene.ChatDialog.Opacity = 0.8f;
  316. TransparencyOnButton.Index = 474;
  317. TransparencyOnButton.HoverIndex = 475;
  318. TransparencyOffButton.Index = 470;
  319. TransparencyOffButton.HoverIndex = 470;
  320. }
  321. else
  322. {
  323. GameScene.Scene.ChatDialog.ForeColour = Color.White;
  324. GameScene.Scene.ChatDialog.BackColour = Color.White;
  325. GameScene.Scene.ChatDialog.Opacity = 1;
  326. TransparencyOnButton.Index = 473;
  327. TransparencyOnButton.HoverIndex = 473;
  328. TransparencyOffButton.Index = 471;
  329. TransparencyOffButton.HoverIndex = 472;
  330. }
  331. }
  332. public void Toggle()
  333. {
  334. if (!Visible)
  335. Show();
  336. else
  337. Hide();
  338. }
  339. }
  340. }