GuildDialog.cs 81 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244
  1. using Client.MirControls;
  2. using Client.MirGraphics;
  3. using Client.MirNetwork;
  4. using Client.MirObjects;
  5. using Client.MirSounds;
  6. using Font = System.Drawing.Font;
  7. using C = ClientPackets;
  8. namespace Client.MirScenes.Dialogs
  9. {
  10. public sealed class GuildDialog : MirImageControl
  11. {
  12. #region NoticeBase
  13. public MirLabel GuildName;
  14. public MirButton CloseButton;
  15. #endregion
  16. #region GuildLeft
  17. public MirButton NoticeButton, MembersButton, StorageButton, RankButton;
  18. public MirImageControl NoticePage, MembersPage, StoragePage, RankPage;
  19. public MirImageControl StoragePageBase, MembersPageBase;
  20. public MirImageControl TitleLabel;
  21. #endregion
  22. #region GuildRight
  23. public MirButton BuffButton, StatusButton;
  24. public MirImageControl BuffPage, StatusPage, StatusPageBase;
  25. public GuildBuffButton[] Buffs;
  26. private bool RequestedList = false;
  27. public List<GuildBuffInfo> GuildBuffInfos = new List<GuildBuffInfo>();
  28. public List<GuildBuff> EnabledBuffs = new List<GuildBuff>();
  29. public int StartIndex = 0;
  30. private long LastRequest = 0;
  31. public string ActiveStats = "";
  32. #endregion
  33. #region DataValues
  34. public byte Level;
  35. public long Experience;
  36. public long MaxExperience;
  37. public uint Gold;
  38. public byte SparePoints;
  39. public int MemberCount;
  40. public int MaxMembers;
  41. public bool Voting;
  42. public byte ItemCount;
  43. public byte BuffCount;
  44. public static int MyRankId;
  45. public static GuildRankOptions MyOptions;
  46. public List<GuildRank> Ranks = new List<GuildRank>();
  47. public bool MembersChanged = true;
  48. public long LastMemberRequest = 0;
  49. public long LastGuildMsg = 0;
  50. public long LastRankNameChange = 0;
  51. public GuildRankOptions GetMyOptions()
  52. {
  53. return MyOptions;
  54. }
  55. #endregion
  56. #region NoticePagePub
  57. public bool NoticeChanged = true;
  58. public long LastNoticeRequest = 0;
  59. public int NoticeScrollIndex = 0;
  60. public MirButton NoticeUpButton, NoticeDownButton, NoticePositionBar, NoticeEditButton, NoticeSaveButton;
  61. public MirTextBox Notice;
  62. #endregion
  63. #region MembersPagePub
  64. public int MemberScrollIndex = 0, MembersShowCount = 1;
  65. public MirButton MembersUpButton, MembersDownButton, MembersPositionBar;
  66. public MirLabel MembersHeaderRank, MembersHeaderName, MembersHeaderStatus, MembersShowOffline;
  67. public MirButton MembersShowOfflineButton;
  68. public MirImageControl MembersShowOfflineStatus;
  69. public MirDropDownBox[] MembersRanks;
  70. public MirLabel[] MembersName, MembersStatus;
  71. public MirButton[] MembersDelete;
  72. public int MemberPageRows = 18;
  73. public bool MembersShowOfflinesetting = true;
  74. #endregion
  75. #region StatusPagePub
  76. public MirLabel StatusLevelLabel;
  77. public MirLabel StatusHeaders;
  78. public MirLabel StatusGuildName, StatusLevel, StatusMembers;
  79. public MirImageControl StatusExpBar;
  80. public MirLabel StatusExpLabel, RecruitMemberLabel;
  81. public MirTextBox MembersRecruitName;
  82. public MirButton RecruitMemberButton;
  83. #endregion
  84. #region StoragePagePub
  85. public MirLabel StorageGoldText;
  86. public MirButton StorageGoldAdd, StorageGoldRemove, StorageGoldIcon;
  87. public MirItemCell[] StorageGrid;
  88. public MirButton StorageUpButton, StorageDownButton, StoragePositionBar;
  89. public int StorageIndex = 1;
  90. #endregion
  91. #region RankPagePub
  92. public MirLabel RanksSelectTextR, RanksSelectTextL, PointsLeft;
  93. public MirTextBox RanksName;
  94. public MirImageControl[] RanksOptionsStatus;
  95. public MirButton[] RanksOptionsButtons;
  96. public MirLabel[] RanksOptionsTexts;
  97. public MirDropDownBox RanksSelectBox;
  98. public MirButton RanksSaveName, UpButton, DownButton, PositionBar;
  99. #endregion
  100. #region BuffPagePub
  101. #endregion
  102. #region GuildUI
  103. public GuildDialog()
  104. {
  105. Index = 180;
  106. Library = Libraries.Prguse;
  107. Movable = true;
  108. Sort = true;
  109. Location = Center;
  110. BeforeDraw += (o, e) => RefreshInterface();
  111. #region TabUI
  112. TitleLabel = new MirImageControl
  113. {
  114. Index = 25,
  115. Library = Libraries.Title,
  116. Location = new Point(18, 9),
  117. Parent = this
  118. };
  119. NoticeButton = new MirButton
  120. {
  121. Library = Libraries.Title,
  122. Index = 93,
  123. PressedIndex = 94,
  124. Sound = SoundList.ButtonA,
  125. Parent = this,
  126. Location = new Point(20, 38)
  127. };
  128. NoticeButton.Click += (o, e) => LeftDialog(0);
  129. MembersButton = new MirButton
  130. {
  131. Library = Libraries.Title,
  132. Index = 99,
  133. PressedIndex = 100,
  134. Sound = SoundList.ButtonA,
  135. Parent = this,
  136. Location = new Point(91, 38),
  137. };
  138. MembersButton.Click += (o, e) => LeftDialog(1);
  139. StorageButton = new MirButton
  140. {
  141. Library = Libraries.Title,
  142. Index = 105,
  143. PressedIndex = 106,
  144. Sound = SoundList.ButtonA,
  145. Parent = this,
  146. Location = new Point(162, 38),
  147. Visible = false
  148. };
  149. StorageButton.Click += (o, e) => LeftDialog(2);
  150. RankButton = new MirButton // Ranks
  151. {
  152. Library = Libraries.Title,
  153. Index = 101,
  154. Sound = SoundList.ButtonA,
  155. Parent = this,
  156. Location = new Point(233, 38),
  157. Visible = false,
  158. };
  159. RankButton.Click += (o, e) => LeftDialog(3);
  160. StatusButton = new MirButton
  161. {
  162. Library = Libraries.Title,
  163. Parent = this,
  164. Index = 103,
  165. Location = new Point(501, 38),
  166. Sound = SoundList.ButtonA,
  167. };
  168. StatusButton.Click += (o, e) => RightDialog(0);
  169. BuffButton = new MirButton
  170. {
  171. Library = Libraries.Title,
  172. Parent = this,
  173. Index = 95,
  174. Location = new Point(430, 38),
  175. Sound = SoundList.ButtonA,
  176. Visible = false,
  177. };
  178. BuffButton.Click += (o, e) => RightDialog(1);
  179. CloseButton = new MirButton
  180. {
  181. HoverIndex = 361,
  182. Index = 360,
  183. Location = new Point(565, 4),
  184. Library = Libraries.Prguse2,
  185. Parent = this,
  186. PressedIndex = 362,
  187. Sound = SoundList.ButtonA
  188. };
  189. CloseButton.Click += (o, e) => Hide();
  190. #endregion
  191. #region NoticePageUI
  192. NoticePage = new MirImageControl()
  193. {
  194. Parent = this,
  195. Size = new Size(352, 372),
  196. Location = new Point(0, 60),
  197. Visible = true
  198. };
  199. Notice = new MirTextBox()
  200. {
  201. ForeColour = Color.White,
  202. Font = new Font(Settings.FontName, 8F),
  203. Enabled = false,
  204. Visible = true,
  205. Parent = NoticePage,
  206. Size = new Size(322, 330),
  207. Location = new Point(13, 1)
  208. };
  209. Notice.MultiLine();
  210. NoticeEditButton = new MirButton
  211. {
  212. Visible = false,
  213. Index = 560,
  214. HoverIndex = 561,
  215. PressedIndex = 562,
  216. Library = Libraries.Prguse,
  217. Sound = SoundList.ButtonA,
  218. Parent = NoticePage,
  219. Location = new Point(20, 342)
  220. };
  221. NoticeEditButton.Click += (o, e) => EditNotice();
  222. NoticeSaveButton = new MirButton
  223. {
  224. Visible = false,
  225. Index = 554,
  226. HoverIndex = 555,
  227. PressedIndex = 556,
  228. Library = Libraries.Prguse,
  229. Sound = SoundList.ButtonA,
  230. Parent = NoticePage,
  231. Location = new Point(20, 342)
  232. };
  233. NoticeSaveButton.Click += (o, e) => EditNotice();
  234. NoticeUpButton = new MirButton
  235. {
  236. HoverIndex = 198,
  237. Index = 197,
  238. Visible = true,
  239. Library = Libraries.Prguse2,
  240. Location = new Point(337, 1),
  241. Size = new Size(16, 14),
  242. Parent = NoticePage,
  243. PressedIndex = 199,
  244. Sound = SoundList.ButtonA
  245. };
  246. NoticeUpButton.Click += (o, e) =>
  247. {
  248. if (NoticeScrollIndex == 0) return;
  249. NoticeScrollIndex--;
  250. UpdateNotice();
  251. UpdateNoticeScrollPosition();
  252. };
  253. NoticeDownButton = new MirButton
  254. {
  255. HoverIndex = 208,
  256. Index = 207,
  257. Visible = true,
  258. Library = Libraries.Prguse2,
  259. Location = new Point(337, 318),
  260. Size = new Size(16, 14),
  261. Parent = NoticePage,
  262. PressedIndex = 209,
  263. Sound = SoundList.ButtonA
  264. };
  265. NoticeDownButton.Click += (o, e) =>
  266. {
  267. if (NoticeScrollIndex == Notice.MultiText.Length - 1) return;
  268. if (NoticeScrollIndex >= Notice.MultiText.Length - 25) NoticeScrollIndex--;
  269. NoticeScrollIndex++;
  270. UpdateNotice(true);
  271. UpdateNoticeScrollPosition();
  272. };
  273. NoticePositionBar = new MirButton
  274. {
  275. Index = 206,
  276. Library = Libraries.Prguse2,
  277. Location = new Point(337, 16),
  278. Parent = NoticePage,
  279. Movable = true,
  280. Visible = true,
  281. Sound = SoundList.None
  282. };
  283. NoticePositionBar.OnMoving += NoticePositionBar_OnMoving;
  284. NoticePage.KeyDown += NoticePanel_KeyDown;
  285. NoticePage.MouseWheel += NoticePanel_MouseWheel;
  286. #endregion
  287. #region MembersPageUI
  288. MembersPage = new MirImageControl()
  289. {
  290. Parent = this,
  291. Size = new Size(352, 372),
  292. Location = new Point(0, 60),
  293. Visible = false
  294. };
  295. MembersPageBase = new MirImageControl()
  296. {
  297. Library = Libraries.Prguse,
  298. Index = 1852,
  299. Parent = MembersPage,
  300. Location = new Point(13, 1),
  301. Visible = true
  302. };
  303. MembersPageBase.MouseWheel += MembersPanel_MouseWheel;
  304. MembersPage.BeforeDraw += (o, e) => RequestUpdateMembers();
  305. MembersRanks = new MirDropDownBox[MemberPageRows];
  306. MembersName = new MirLabel[MemberPageRows];
  307. MembersStatus = new MirLabel[MemberPageRows];
  308. MembersDelete = new MirButton[MemberPageRows];
  309. for (int i = MembersRanks.Length - 1; i >= 0; i--)
  310. {
  311. int index = i;
  312. MembersRanks[i] = new MirDropDownBox()
  313. {
  314. BackColour = i % 2 == 0 ? Color.FromArgb(255, 10, 10, 10) : Color.FromArgb(255, 15, 15, 15),
  315. ForeColour = Color.White,
  316. Parent = MembersPage,
  317. Size = new Size(100, 14),
  318. Location = new Point(24, 30 + (i * 15)),
  319. Visible = false,
  320. Enabled = false
  321. };
  322. MembersRanks[index].ValueChanged += (o, e) => OnNewRank(index, MembersRanks[index]._WantedIndex);
  323. MembersRanks[index].MouseWheel += MembersPanel_MouseWheel;
  324. }
  325. for (int i = 0; i < MembersName.Length; i++)
  326. {
  327. MembersName[i] = new MirLabel()
  328. {
  329. BackColour = i % 2 == 0 ? Color.FromArgb(255, 05, 05, 05) : Color.FromArgb(255, 07, 07, 07),
  330. ForeColour = Color.White,
  331. Parent = MembersPage,
  332. Size = new Size(100, 14),
  333. Location = new Point(125, 30 + (i * 15)),
  334. Visible = false,
  335. Enabled = false,
  336. Font = new Font(Settings.FontName, 7F)
  337. };
  338. MembersName[i].MouseWheel += MembersPanel_MouseWheel;
  339. }
  340. for (int i = 0; i < MembersStatus.Length; i++)
  341. {
  342. MembersStatus[i] = new MirLabel()
  343. {
  344. BackColour = i % 2 == 0 ? Color.FromArgb(255, 10, 10, 10) : Color.FromArgb(255, 15, 15, 15),
  345. ForeColour = Color.White,
  346. Parent = MembersPage,
  347. Size = new Size(100, 14),
  348. Location = new Point(225, 30 + (i * 15)),
  349. Visible = false,
  350. Enabled = false,
  351. Font = new Font(Settings.FontName, 7F)
  352. };
  353. MembersStatus[i].MouseWheel += MembersPanel_MouseWheel;
  354. }
  355. for (int i = 0; i < MembersDelete.Length; i++)
  356. {
  357. int index = i;
  358. MembersDelete[i] = new MirButton()
  359. {
  360. Enabled = true,
  361. Visible = true,
  362. Location = new Point(210, 30 + (i * 15)),
  363. Library = Libraries.Prguse,
  364. Index = 917,
  365. Parent = MembersPage
  366. };
  367. MembersDelete[index].MouseWheel += MembersPanel_MouseWheel;
  368. MembersDelete[index].Click += (o, e) => DeleteMember(index);
  369. }
  370. MembersUpButton = new MirButton
  371. {
  372. HoverIndex = 198,
  373. Index = 197,
  374. Visible = true,
  375. Library = Libraries.Prguse2,
  376. Location = new Point(337, 1),
  377. Size = new Size(16, 14),
  378. Parent = MembersPage,
  379. PressedIndex = 199,
  380. Sound = SoundList.ButtonA
  381. };
  382. MembersUpButton.Click += (o, e) =>
  383. {
  384. if (MemberScrollIndex == 0) return;
  385. MemberScrollIndex--;
  386. UpdateMembers();
  387. UpdateMembersScrollPosition();
  388. };
  389. MembersDownButton = new MirButton
  390. {
  391. HoverIndex = 208,
  392. Index = 207,
  393. Visible = true,
  394. Library = Libraries.Prguse2,
  395. Location = new Point(337, 318),
  396. Size = new Size(16, 14),
  397. Parent = MembersPage,
  398. PressedIndex = 209,
  399. Sound = SoundList.ButtonA
  400. };
  401. MembersDownButton.Click += (o, e) =>
  402. {
  403. if (MemberScrollIndex == MembersShowCount - MemberPageRows) return;
  404. MemberScrollIndex++;
  405. UpdateMembers();
  406. UpdateMembersScrollPosition();
  407. };
  408. MembersPositionBar = new MirButton
  409. {
  410. Index = 206,
  411. Library = Libraries.Prguse2,
  412. Location = new Point(337, 16),
  413. Parent = MembersPage,
  414. Movable = true,
  415. Sound = SoundList.None
  416. };
  417. MembersPositionBar.OnMoving += MembersPositionBar_OnMoving;
  418. MembersShowOfflineButton = new MirButton
  419. {
  420. Visible = true,
  421. Index = 1346,
  422. Library = Libraries.Prguse,
  423. Sound = SoundList.ButtonA,
  424. Parent = MembersPage,
  425. Location = new Point(230, 310)
  426. };
  427. MembersShowOfflineButton.Click += (o, e) => MembersShowOfflineSwitch();
  428. MembersShowOfflineStatus = new MirImageControl
  429. {
  430. Visible = true,
  431. Index = 1347,
  432. Library = Libraries.Prguse,
  433. Parent = MembersPage,
  434. Location = new Point(230, 310)
  435. };
  436. MembersShowOfflineStatus.Click += (o, e) => MembersShowOfflineSwitch();
  437. MembersShowOffline = new MirLabel
  438. {
  439. Visible = true,
  440. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ShowOffline),
  441. Location = new Point(245, 309),
  442. Parent = MembersPage,
  443. Size = new Size(150, 12),
  444. Font = new Font(Settings.FontName, 7F),
  445. ForeColour = Color.White
  446. };
  447. MembersPage.KeyDown += MembersPanel_KeyDown;
  448. MembersPage.MouseWheel += MembersPanel_MouseWheel;
  449. #endregion
  450. #region StatusDialogUI
  451. StatusPage = new MirImageControl()
  452. {
  453. Parent = this,
  454. Size = new Size(230, 372),
  455. Location = new Point(355, 60),
  456. Visible = true
  457. };
  458. StatusPageBase = new MirImageControl()
  459. {
  460. Parent = StatusPage,
  461. Library = Libraries.Prguse,
  462. Index = 1850,
  463. Visible = true,
  464. Location = new Point(10, 2)
  465. };
  466. StatusPage.BeforeDraw += (o, e) =>
  467. {
  468. if (MapControl.User.GuildName == "")
  469. {
  470. StatusGuildName.Text = "";
  471. StatusLevel.Text = "";
  472. StatusMembers.Text = "";
  473. }
  474. else
  475. {
  476. StatusGuildName.Text = string.Format("{0}", MapObject.User.GuildName);
  477. StatusLevel.Text = string.Format("{0}", Level);
  478. StatusMembers.Text = string.Format("{0}{1}", MemberCount, MaxMembers == 0 ? "" : ("/" + MaxMembers.ToString()));
  479. }
  480. };
  481. StatusHeaders = new MirLabel()
  482. {
  483. Location = new Point(7, 47),
  484. DrawFormat = TextFormatFlags.Right,
  485. Size = new Size(75, 300),
  486. NotControl = true,
  487. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.GuildNameLevelMembers),
  488. Visible = true,
  489. Parent = StatusPage,
  490. ForeColour = Color.Gray,
  491. };
  492. StatusGuildName = new MirLabel()
  493. {
  494. Location = new Point(82, 47),
  495. Size = new Size(120, 200),
  496. NotControl = true,
  497. Text = "",
  498. Visible = true,
  499. Parent = StatusPage
  500. };
  501. StatusLevel = new MirLabel()
  502. {
  503. Location = new Point(82, 73),
  504. Size = new Size(120, 200),
  505. NotControl = true,
  506. Text = "",
  507. Visible = true,
  508. Parent = StatusPage
  509. };
  510. StatusMembers = new MirLabel()
  511. {
  512. Location = new Point(82, 99),
  513. Size = new Size(120, 200),
  514. NotControl = true,
  515. Text = "",
  516. Visible = true,
  517. Parent = StatusPage
  518. };
  519. StatusExpBar = new MirImageControl()
  520. {
  521. Visible = true,
  522. Index = 423,
  523. Library = Libraries.Prguse2,
  524. Location = new Point(322, 403),
  525. DrawImage = false,
  526. NotControl = true,
  527. Parent = this,
  528. Size = new Size(260, 15)
  529. };
  530. StatusExpBar.BeforeDraw += StatusExpBar_BeforeDraw;
  531. StatusExpLabel = new MirLabel()
  532. {
  533. Visible = true,
  534. DrawFormat = TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter,
  535. Location = new Point(322, 405),
  536. NotControl = true,
  537. Parent = this,
  538. Size = new Size(260, 15)
  539. };
  540. MembersRecruitName = new MirTextBox()
  541. {
  542. Location = new Point(40, 300),
  543. Size = new Size(130, 21),
  544. MaxLength = 20,
  545. Parent = StatusPage,
  546. Visible = true,
  547. Text = "",
  548. BackColour = Color.FromArgb(255, 25, 25, 25),
  549. Border = true,
  550. BorderColour = Color.FromArgb(255, 35, 35, 35),
  551. CanLoseFocus = true
  552. };
  553. RecruitMemberButton = new MirButton()
  554. {
  555. Parent = StatusPage,
  556. Enabled = true,
  557. Visible = true,
  558. Location = new Point(170, 298),
  559. Library = Libraries.Title,
  560. Index = 356,
  561. HoverIndex = 357,
  562. PressedIndex = 358
  563. };
  564. RecruitMemberButton.Click += (o, e) => AddMember();
  565. RecruitMemberLabel = new MirLabel()
  566. {
  567. Visible = true,
  568. Location = new Point(36, 283),
  569. NotControl = true,
  570. Parent = StatusPage,
  571. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.RecruitMember),
  572. Size = new Size(150, 15)
  573. };
  574. #endregion
  575. #region StorageDialogUI
  576. StoragePage = new MirImageControl()
  577. {
  578. Parent = this,
  579. Size = new Size(352, 372),
  580. Location = new Point(0, 60),
  581. Visible = false
  582. };
  583. StoragePageBase = new MirImageControl()
  584. {
  585. Visible = true,
  586. Parent = StoragePage,
  587. Library = Libraries.Prguse,
  588. Index = 1851,
  589. Location = new Point(30, 19)
  590. };
  591. StoragePage.BeforeDraw += (o, e) =>
  592. {
  593. StorageGoldText.Text = Gold > 0 ? string.Format("{0:###,###,###}", Gold) : "0";
  594. if (MyRankId == 0)
  595. StorageGoldRemove.Visible = true;
  596. else
  597. StorageGoldRemove.Visible = false;
  598. };
  599. StorageGoldText = new MirLabel()
  600. {
  601. Parent = StoragePage,
  602. Size = new Size(125, 12),
  603. Location = new Point(194, 312),
  604. Visible = true,
  605. Text = "0",
  606. NotControl = true,
  607. };
  608. StorageGoldAdd = new MirButton()
  609. {
  610. Parent = StoragePage,
  611. Library = Libraries.Prguse,
  612. Index = 918,
  613. Visible = true,
  614. Enabled = true,
  615. Location = new Point(158, 313)
  616. };
  617. StorageGoldAdd.Click += (o, e) => StorageAddGold();
  618. StorageGoldRemove = new MirButton()
  619. {
  620. Parent = StoragePage,
  621. Library = Libraries.Prguse,
  622. Index = 917,
  623. Visible = true,
  624. Enabled = true,
  625. Location = new Point(142, 313)
  626. };
  627. StorageGoldRemove.Click += (o, e) => StorageRemoveGold();
  628. StorageGrid = new MirItemCell[8 * 14];
  629. {
  630. for (int x = 0; x < 8; x++)
  631. {
  632. for (int y = 0; y < 14; y++)
  633. {
  634. int idx = 8 * y + x;
  635. StorageGrid[idx] = new MirItemCell
  636. {
  637. ItemSlot = idx,
  638. GridType = MirGridType.GuildStorage,
  639. Library = Libraries.Items,
  640. Parent = StoragePage,
  641. Size = new Size(35, 35),
  642. Location = new Point(x * 35 + 31 + x, y * 35 + 20 + y),
  643. };
  644. if (y > 7) StorageGrid[idx].Visible = false;
  645. StorageGrid[idx].MouseWheel += StoragePanel_MouseWheel;
  646. }
  647. }
  648. }
  649. StorageUpButton = new MirButton
  650. {
  651. HoverIndex = 198,
  652. Index = 197,
  653. Visible = true,
  654. Library = Libraries.Prguse2,
  655. Location = new Point(337, 1),
  656. Size = new Size(16, 14),
  657. Parent = StoragePage,
  658. PressedIndex = 199,
  659. Sound = SoundList.ButtonA
  660. };
  661. StorageUpButton.Click += (o, e) =>
  662. {
  663. if (StorageIndex == 0) return;
  664. StorageIndex--;
  665. UpdateStorage();
  666. StorageUpdatePositionBar();
  667. };
  668. StorageDownButton = new MirButton
  669. {
  670. HoverIndex = 208,
  671. Index = 207,
  672. Visible = true,
  673. Library = Libraries.Prguse2,
  674. Location = new Point(337, 318),
  675. Size = new Size(16, 14),
  676. Parent = StoragePage,
  677. PressedIndex = 209,
  678. Sound = SoundList.ButtonA
  679. };
  680. StorageDownButton.Click += (o, e) =>
  681. {
  682. if (StorageIndex >= 6) StorageIndex = 5;
  683. StorageIndex++;
  684. UpdateStorage();
  685. StorageUpdatePositionBar();
  686. };
  687. StoragePositionBar = new MirButton
  688. {
  689. Index = 206,
  690. Library = Libraries.Prguse2,
  691. Location = new Point(337, 16),
  692. Parent = StoragePage,
  693. Movable = true,
  694. Visible = true,
  695. Sound = SoundList.None
  696. };
  697. StoragePositionBar.OnMoving += StoragePositionBar_OnMoving;
  698. StoragePage.MouseWheel += StoragePanel_MouseWheel;
  699. StoragePageBase.MouseWheel += StoragePanel_MouseWheel;
  700. #endregion
  701. #region RankDialogUI
  702. RankPage = new MirImageControl()
  703. {
  704. Parent = this,
  705. Size = new Size(352, 372),
  706. Location = new Point(0, 60),
  707. Visible = false
  708. };
  709. RankPage.BeforeDraw += (o, e) => RequestUpdateMembers();
  710. RanksSelectTextL = new MirLabel()
  711. {
  712. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.EditRank),
  713. Location = new Point(42, 18),
  714. Size = new Size(150, 20),
  715. ForeColour = Color.White,
  716. Parent = RankPage,
  717. NotControl = true,
  718. };
  719. RanksSelectTextR = new MirLabel()
  720. {
  721. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.SelectRank),
  722. Location = new Point(198, 18),
  723. Size = new Size(150, 20),
  724. ForeColour = Color.White,
  725. Parent = RankPage,
  726. NotControl = true,
  727. };
  728. RanksSelectBox = new MirDropDownBox()
  729. {
  730. Parent = RankPage,
  731. Location = new Point(198, 36),
  732. Size = new Size(130, 16),
  733. ForeColour = Color.White,
  734. Visible = true,
  735. Enabled = true,
  736. BackColour = Color.FromArgb(255, 25, 25, 25),
  737. BorderColour = Color.FromArgb(255, 35, 35, 35),
  738. };
  739. RanksSelectBox.ValueChanged += (o, e) => OnRankSelect(RanksSelectBox._WantedIndex);
  740. RanksName = new MirTextBox()
  741. {
  742. Location = new Point(42, 36),
  743. Size = new Size(130, 16),
  744. MaxLength = 20,
  745. Parent = RankPage,
  746. Visible = true,
  747. Enabled = false,
  748. Text = "",
  749. Border = true,
  750. BackColour = Color.FromArgb(255, 25, 25, 25),
  751. BorderColour = Color.FromArgb(255, 35, 35, 35),
  752. };
  753. RanksName.BeforeDraw += (o, e) => RanksName_BeforeDraw();
  754. RanksName.TextBox.KeyPress += RanksName_KeyPress;
  755. RanksSaveName = new MirButton()
  756. {
  757. Location = new Point(155, 290),
  758. Enabled = false,
  759. Visible = true,
  760. Parent = RankPage,
  761. Index = 90,
  762. HoverIndex = 91,
  763. PressedIndex = 92,
  764. Library = Libraries.Title,
  765. Sound = SoundList.ButtonA
  766. };
  767. RanksSaveName.Click += (o, e) =>
  768. {
  769. RanksChangeName();
  770. };
  771. String[] Options = { "Edit ranks", "Recruit member", "Kick member", "Store item", "Retrieve item", "Alter alliance", "Change notice", "Activate Buff" };
  772. RanksOptionsButtons = new MirButton[8];
  773. RanksOptionsStatus = new MirImageControl[8];
  774. RanksOptionsTexts = new MirLabel[8];
  775. for (int i = 0; i < RanksOptionsButtons.Length; i++)
  776. {
  777. RanksOptionsButtons[i] = new MirButton()
  778. {
  779. Visible = true,
  780. Enabled = false,
  781. Index = 1346,
  782. Library = Libraries.Prguse,
  783. Sound = SoundList.ButtonA,
  784. Parent = RankPage,
  785. Location = new Point(i % 2 == 0 ? 42 : 202, i % 2 == 0 ? 120 + (i * 20) : 120 + ((i - 1) * 20))
  786. };
  787. int index = i;
  788. RanksOptionsButtons[i].Click += (o, e) => SwitchRankOption(index);
  789. }
  790. for (int i = 0; i < RanksOptionsStatus.Length; i++)
  791. {
  792. RanksOptionsStatus[i] = new MirImageControl()
  793. {
  794. Visible = false,
  795. Index = 1347,
  796. Library = Libraries.Prguse,
  797. Parent = RankPage,
  798. NotControl = true,
  799. Location = new Point(i % 2 == 0 ? 42 : 202, i % 2 == 0 ? 120 + (i * 20) : 120 + ((i - 1) * 20))
  800. };
  801. int index = i;
  802. RanksOptionsStatus[i].Click += (o, e) => SwitchRankOption(index);
  803. }
  804. for (int i = 0; i < RanksOptionsTexts.Length; i++)
  805. {
  806. RanksOptionsTexts[i] = new MirLabel()
  807. {
  808. Visible = true,
  809. NotControl = true,
  810. Parent = RankPage,
  811. Location = new Point(17 + (i % 2 == 0 ? 42 : 202), i % 2 == 0 ? 118 + (i * 20) : 118 + ((i - 1) * 20)),
  812. AutoSize = true,
  813. Text = Options[i]
  814. };
  815. }
  816. #endregion
  817. #region BuffDialogUI
  818. BuffPage = new MirImageControl()
  819. {
  820. Parent = this,
  821. Size = new Size(352, 372),
  822. Location = new Point(360, 61),
  823. Index = 1853,
  824. Library = Libraries.Prguse,
  825. Visible = false
  826. };
  827. BuffPage.MouseWheel += BuffsPanel_MouseWheel;
  828. Buffs = new GuildBuffButton[8];
  829. for (byte i = 0; i < Buffs.Length; i++)
  830. {
  831. byte Id = i;
  832. Buffs[i] = new GuildBuffButton { Parent = BuffPage, Visible = true, Location = new Point(4, 27 + (i * 38)), Id = Id };
  833. Buffs[i].Click += (o, e) => RequestBuff(Id);
  834. Buffs[i].MouseWheel += BuffsPanel_MouseWheel;
  835. }
  836. PointsLeft = new MirLabel
  837. {
  838. DrawFormat = TextFormatFlags.HorizontalCenter,
  839. Parent = BuffPage,
  840. Location = new Point(118, 3),
  841. Size = new Size(100, 20),
  842. NotControl = true
  843. };
  844. UpButton = new MirButton
  845. {
  846. Index = 197,
  847. HoverIndex = 198,
  848. PressedIndex = 199,
  849. Library = Libraries.Prguse2,
  850. Location = new Point(203, 24),
  851. Parent = BuffPage,
  852. Sound = SoundList.ButtonA
  853. };
  854. UpButton.Click += (o, e) =>
  855. {
  856. if (StartIndex == 0) return;
  857. StartIndex--;
  858. UpdatePositionBar();
  859. RefreshInterface();
  860. };
  861. DownButton = new MirButton
  862. {
  863. Index = 207,
  864. HoverIndex = 208,
  865. PressedIndex = 209,
  866. Library = Libraries.Prguse2,
  867. Location = new Point(203, 317),
  868. Parent = BuffPage,
  869. Sound = SoundList.ButtonA
  870. };
  871. DownButton.Click += (o, e) =>
  872. {
  873. if (GuildBuffInfos.Count < 8) return;
  874. if (StartIndex == GuildBuffInfos.Count - 8) return;
  875. StartIndex++;
  876. UpdatePositionBar();
  877. RefreshInterface();
  878. };
  879. PositionBar = new MirButton
  880. {
  881. Index = 205,
  882. HoverIndex = 206,
  883. PressedIndex = 206,
  884. Library = Libraries.Prguse2,
  885. Parent = BuffPage,
  886. Movable = true,
  887. Sound = SoundList.None,
  888. Location = new Point(203, 39)
  889. };
  890. PositionBar.OnMoving += PositionBar_OnMoving;
  891. PositionBar.MouseUp += (o, e) => RefreshInterface();
  892. #endregion
  893. }
  894. #endregion
  895. public void RequestBuff(byte Id)
  896. {
  897. if ((Id + StartIndex) > GuildBuffInfos.Count) return;
  898. GuildBuffInfo BuffInfo = GuildBuffInfos[Id + StartIndex];
  899. if (BuffInfo == null) return;
  900. GuildBuff Buff = FindGuildBuff(BuffInfo.Id);
  901. if (Buff == null)
  902. {
  903. string Error = "";
  904. if (GameScene.Scene.GuildDialog.SparePoints < BuffInfo.PointsRequirement)
  905. Error = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.InsufficientPointsAvailable);
  906. if (GameScene.Scene.GuildDialog.Level < BuffInfo.LevelRequirement)
  907. Error = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.GuildLevelTooLow);
  908. if (!GameScene.Scene.GuildDialog.GetMyOptions().HasFlag(GuildRankOptions.CanActivateBuff))
  909. Error = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.GuildRankNoBuffActivation);
  910. if (Error != "")
  911. {
  912. MirMessageBox messageBox = new MirMessageBox(Error);
  913. messageBox.Show();
  914. return;
  915. }
  916. if (CMain.Time < LastRequest + 100) return;
  917. LastRequest = CMain.Time;
  918. Network.Enqueue(new C.GuildBuffUpdate { Action = 1, Id = BuffInfo.Id });
  919. }
  920. else
  921. {
  922. string Error = "";
  923. if (Buff.Active)
  924. Error = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.BuffIsActive);
  925. if (GameScene.Scene.GuildDialog.Gold < BuffInfo.ActivationCost)
  926. Error = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.GuildFundsInsufficient);
  927. if (!GameScene.Scene.GuildDialog.GetMyOptions().HasFlag(GuildRankOptions.CanActivateBuff))
  928. Error = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.GuildRankNoBuffActivation);
  929. if (Error != "")
  930. {
  931. MirMessageBox messageBox = new MirMessageBox(Error);
  932. messageBox.Show();
  933. return;
  934. }
  935. if (CMain.Time < LastRequest + 100) return;
  936. LastRequest = CMain.Time;
  937. Network.Enqueue(new C.GuildBuffUpdate { Action = 2, Id = BuffInfo.Id });
  938. }
  939. }
  940. public GuildBuff FindGuildBuff(int Index)
  941. {
  942. for (int i = 0; i < EnabledBuffs.Count; i++)
  943. {
  944. if ((EnabledBuffs[i] != null) && (EnabledBuffs[i].Id == Index))
  945. return EnabledBuffs[i];
  946. }
  947. return null;
  948. }
  949. private void UpdatePositionBar()
  950. {
  951. int h = 277 - PositionBar.Size.Height;
  952. h = (int)((h / (float)(GuildBuffInfos.Count - 8)) * StartIndex);
  953. PositionBar.Location = new Point(203, 39 + h);
  954. }
  955. private void PositionBar_OnMoving(object sender, MouseEventArgs e)
  956. {
  957. const int x = 203;
  958. int y = PositionBar.Location.Y;
  959. if (y >= 296) y = 296;
  960. if (y < 39) y = 39;
  961. int h = 277 - PositionBar.Size.Height;
  962. h = (int)Math.Round(((y - 39) / (h / (float)(GuildBuffInfos.Count - 8))));
  963. PositionBar.Location = new Point(x, y);
  964. if (h == StartIndex) return;
  965. StartIndex = h;
  966. RefreshInterface();
  967. }
  968. private void BuffsPanel_MouseWheel(object sender, MouseEventArgs e)
  969. {
  970. int count = e.Delta / SystemInformation.MouseWheelScrollDelta;
  971. if (StartIndex == 0 && count >= 0) return;
  972. if (StartIndex == (GuildBuffInfos.Count - 8) && count <= 0) return;
  973. StartIndex -= count > 0 ? 1 : -1;
  974. if (GuildBuffInfos.Count <= 8) StartIndex = 0;
  975. UpdatePositionBar();
  976. RefreshInterface();
  977. }
  978. public void RefreshInterface()
  979. {
  980. if (StartIndex < 0) StartIndex = 0;
  981. if (GuildBuffInfos.Count == 0) BuffButton.Visible = false;
  982. else BuffButton.Visible = true;
  983. if (MapObject.User.GuildName == "")
  984. {
  985. Hide();
  986. return;
  987. }
  988. else
  989. {
  990. PointsLeft.Text = GameScene.Scene.GuildDialog.SparePoints.ToString();
  991. for (int i = 0; i < Buffs.Length; i++)
  992. {
  993. if ((StartIndex + i) > GuildBuffInfos.Count - 1)
  994. {
  995. Buffs[i].Visible = false;
  996. continue;
  997. }
  998. GuildBuffInfo BuffInfo = GuildBuffInfos[i + StartIndex];
  999. if (BuffInfo == null)
  1000. {
  1001. Buffs[i].Visible = false;
  1002. continue;
  1003. }
  1004. Buffs[i].Visible = true;
  1005. GuildBuff Buff = FindGuildBuff(BuffInfo.Id);
  1006. Buffs[i].Name.Text = BuffInfo.Name;
  1007. Buffs[i].Icon.Index = BuffInfo.Icon;
  1008. if (Buff == null)
  1009. {
  1010. if (BuffInfo.LevelRequirement > GameScene.Scene.GuildDialog.Level)
  1011. {
  1012. Buffs[i].Info.Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.InsufficientLevel);
  1013. Buffs[i].Info.ForeColour = Color.Red;
  1014. Buffs[i].Icon.Index += 2;
  1015. }
  1016. else
  1017. {
  1018. Buffs[i].Info.Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Available);
  1019. Buffs[i].Info.ForeColour = Buffs[i].Name.ForeColour;
  1020. Buffs[i].Icon.Index += 2;
  1021. }
  1022. Buffs[i].Obtained.Text = "";
  1023. }
  1024. else
  1025. {
  1026. if (BuffInfo.TimeLimit > 0)
  1027. {
  1028. if (Buff.Active)
  1029. Buffs[i].Info.Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.CountingDown);
  1030. else
  1031. Buffs[i].Info.Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Expired);
  1032. }
  1033. else
  1034. Buffs[i].Info.Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Obtained);
  1035. Buffs[i].Info.ForeColour = Buffs[i].Name.ForeColour;
  1036. if (Buff.Active)
  1037. {
  1038. Buffs[i].Obtained.Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Active);
  1039. Buffs[i].Icon.Index += 1;
  1040. }
  1041. else
  1042. Buffs[i].Obtained.Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Inactive);
  1043. }
  1044. }
  1045. }
  1046. }
  1047. public GuildBuffInfo FindGuildBuffInfo(int Index)
  1048. {
  1049. if (!RequestedList)
  1050. {
  1051. RequestGuildBuffList();
  1052. }
  1053. for (int i = 0; i < GuildBuffInfos.Count; i++)
  1054. {
  1055. if (GuildBuffInfos[i].Id == Index)
  1056. return GuildBuffInfos[i];
  1057. }
  1058. return null;
  1059. }
  1060. public void RequestGuildBuffList()
  1061. {
  1062. if (!RequestedList)
  1063. {
  1064. RequestedList = true;
  1065. Network.Enqueue(new C.GuildBuffUpdate { Action = 0 });
  1066. }
  1067. }
  1068. public void UpdateActiveStats()
  1069. {
  1070. string text = "";
  1071. var stats = new Stats();
  1072. foreach (GuildBuff buff in EnabledBuffs)
  1073. {
  1074. if ((buff.Info == null) || (!buff.Active)) continue;
  1075. stats.Add(buff.Info.Stats);
  1076. }
  1077. foreach (var val in stats.Values)
  1078. {
  1079. var c = val.Value < 0 ? GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Decreases) : GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Increases);
  1080. var txt = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.ValueByOwnerPercent), c, val.Key, val.Value, val.Key.ToString().Contains("Percent") ? "%" : "");
  1081. text += txt;
  1082. }
  1083. ActiveStats = text;
  1084. }
  1085. public void CreateHintLabel(byte Id)
  1086. {
  1087. GameScene.Scene.GuildBuffLabel = new MirControl
  1088. {
  1089. BackColour = Color.FromArgb(255, 50, 50, 50),
  1090. Border = true,
  1091. BorderColour = Color.Gray,
  1092. NotControl = true,
  1093. Parent = GameScene.Scene,
  1094. Opacity = 0.7F,
  1095. DrawControlTexture = true
  1096. };
  1097. if (Id + StartIndex > GuildBuffInfos.Count) return;
  1098. GuildBuffInfo Buff = GuildBuffInfos[Id + StartIndex];
  1099. if (Buff == null) return;
  1100. MirLabel HintName = new MirLabel
  1101. {
  1102. AutoSize = true,
  1103. ForeColour = Color.White,
  1104. Location = new Point(4, 4),
  1105. OutLine = true,
  1106. Parent = GameScene.Scene.GuildBuffLabel,
  1107. Text = Buff.Name
  1108. };
  1109. GameScene.Scene.GuildBuffLabel.Size = new Size(Math.Max(GameScene.Scene.GuildBuffLabel.Size.Width, HintName.DisplayRectangle.Right + 4),
  1110. Math.Max(GameScene.Scene.GuildBuffLabel.Size.Height, HintName.DisplayRectangle.Bottom));
  1111. string ReqText = "";
  1112. if (Buff.LevelRequirement > 0)
  1113. {
  1114. ReqText += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.MinimumGuildLevel) + Buff.LevelRequirement.ToString();
  1115. }
  1116. if (Buff.PointsRequirement > 0)
  1117. {
  1118. if (ReqText != "") ReqText += "\n";
  1119. ReqText += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.PointsRequired) + Buff.PointsRequirement.ToString();
  1120. }
  1121. if (Buff.ActivationCost > 0)
  1122. {
  1123. if (ReqText != "") ReqText += "\n";
  1124. ReqText += GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.ActivationCostGold), Buff.ActivationCost.ToString());
  1125. //if (ReqText != "") ReqText += "\n";
  1126. }
  1127. MirLabel RequiredLabel = new MirLabel
  1128. {
  1129. AutoSize = true,
  1130. ForeColour = Color.White,
  1131. Location = new Point(4, GameScene.Scene.GuildBuffLabel.DisplayRectangle.Bottom),
  1132. OutLine = true,
  1133. Parent = GameScene.Scene.GuildBuffLabel,
  1134. Text = ReqText
  1135. };
  1136. GameScene.Scene.GuildBuffLabel.Size = new Size(Math.Max(GameScene.Scene.GuildBuffLabel.Size.Width, RequiredLabel.DisplayRectangle.Right + 4),
  1137. Math.Max(GameScene.Scene.GuildBuffLabel.Size.Height, RequiredLabel.DisplayRectangle.Bottom));
  1138. //code to dispay the buffs duration
  1139. if (Buff.TimeLimit > 0)
  1140. {
  1141. GuildBuff activeBuff = FindGuildBuff(Buff.Id);
  1142. string text = "";
  1143. if (activeBuff != null && activeBuff.Active)
  1144. {
  1145. text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.TimeRemainingMinutes), activeBuff.ActiveTimeRemaining);
  1146. }
  1147. else
  1148. {
  1149. text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.BuffLengthMinutes), Buff.TimeLimit.ToString());
  1150. }
  1151. MirLabel TimeLabel = new MirLabel
  1152. {
  1153. AutoSize = true,
  1154. ForeColour = Color.White,
  1155. Location = new Point(4, GameScene.Scene.GuildBuffLabel.DisplayRectangle.Bottom),
  1156. OutLine = true,
  1157. Parent = GameScene.Scene.GuildBuffLabel,
  1158. Text = text
  1159. };
  1160. GameScene.Scene.GuildBuffLabel.Size = new Size(Math.Max(GameScene.Scene.GuildBuffLabel.Size.Width, TimeLabel.DisplayRectangle.Right + 4),
  1161. Math.Max(GameScene.Scene.GuildBuffLabel.Size.Height, TimeLabel.DisplayRectangle.Bottom));
  1162. }
  1163. //code to display the buff's effect
  1164. MirLabel InfoLabel = new MirLabel
  1165. {
  1166. AutoSize = true,
  1167. ForeColour = Color.White,
  1168. Location = new Point(4, GameScene.Scene.GuildBuffLabel.DisplayRectangle.Bottom),
  1169. OutLine = true,
  1170. Parent = GameScene.Scene.GuildBuffLabel,
  1171. Text = Buff.ShowStats()
  1172. };
  1173. GameScene.Scene.GuildBuffLabel.Size = new Size(Math.Max(GameScene.Scene.GuildBuffLabel.Size.Width, InfoLabel.DisplayRectangle.Right + 4),
  1174. Math.Max(GameScene.Scene.GuildBuffLabel.Size.Height, InfoLabel.DisplayRectangle.Bottom));
  1175. }
  1176. #region ButtonResets
  1177. public void ResetButtonStats()
  1178. {
  1179. if (MyOptions.HasFlag(GuildRankOptions.CanRetrieveItem) || MyOptions.HasFlag(GuildRankOptions.CanStoreItem))
  1180. StorageButton.Visible = true;
  1181. else
  1182. StorageButton.Visible = false;
  1183. if (MyOptions.HasFlag(GuildRankOptions.CanChangeRank))
  1184. RankButton.Visible = true;
  1185. else
  1186. RankButton.Visible = false;
  1187. if (MyOptions.HasFlag(GuildRankOptions.CanChangeNotice))
  1188. NoticeEditButton.Visible = true;
  1189. else
  1190. NoticeEditButton.Visible = false;
  1191. BuffButton.Visible = true;
  1192. }
  1193. #endregion
  1194. #region NoticeDialogCode
  1195. #region NoticeButtonStates
  1196. public void EditNotice()
  1197. {
  1198. if (Notice.Enabled == false)
  1199. {
  1200. Notice.Enabled = true;
  1201. Notice.SetFocus();
  1202. NoticeEditButton.Visible = false;
  1203. NoticeSaveButton.Visible = true;
  1204. }
  1205. else
  1206. {
  1207. Notice.Enabled = false;
  1208. NoticeEditButton.Index = 560;
  1209. NoticeEditButton.Visible = true;
  1210. NoticeSaveButton.Visible = false;
  1211. Network.Enqueue(new C.EditGuildNotice() { notice = Notice.MultiText.ToList() });
  1212. }
  1213. }
  1214. public void NoticeChange(List<string> newnotice)
  1215. {
  1216. NoticeEditButton.Index = 560;
  1217. Notice.Enabled = false;
  1218. NoticeScrollIndex = 0;
  1219. Notice.Text = "";
  1220. Notice.MultiText = newnotice.ToArray();
  1221. NoticeChanged = false;
  1222. UpdateNotice();
  1223. }
  1224. #endregion
  1225. #region AssholeNoticeScroller
  1226. public void UpdateNotice(bool forward = false)
  1227. {
  1228. int NoticeScrollerIndex = NoticeScrollIndex;
  1229. if (forward) NoticeScrollerIndex += 24;
  1230. if (NoticeScrollerIndex >= Notice.MultiText.Length) NoticeScrollerIndex = Notice.MultiText.Length - 24;
  1231. if (NoticeScrollerIndex < 0) NoticeScrollerIndex = 0;
  1232. if (Notice.MultiText.Length != 0)
  1233. {
  1234. Notice.TextBox.SelectionLength = 1;
  1235. Notice.TextBox.SelectionStart = Notice.TextBox.GetFirstCharIndexFromLine(NoticeScrollerIndex);
  1236. Notice.TextBox.ScrollToCaret();
  1237. }
  1238. }
  1239. private void UpdateNoticeScrollPosition()
  1240. {
  1241. int interval = 289 / (Notice.MultiText.Length - 25);
  1242. int x = 337;
  1243. int y = 16 + (NoticeScrollIndex * interval);
  1244. if (y >= NoticeDownButton.Location.Y - 20) y = NoticeDownButton.Location.Y - 20;
  1245. if (y <= 16) y = 16;
  1246. NoticePositionBar.Location = new Point(x, y);
  1247. }
  1248. void NoticePositionBar_OnMoving(object sender, MouseEventArgs e)
  1249. {
  1250. //int x = 337;
  1251. int y = NoticePositionBar.Location.Y;
  1252. int TempIndex = 0;
  1253. bool forward;
  1254. if (y < 16) y = 16;
  1255. int location = y - 16;
  1256. int interval = 289 / (Notice.MultiText.Length - 25);
  1257. double yPoint = location / interval;
  1258. TempIndex = Convert.ToInt16(Math.Floor(yPoint));
  1259. if (NoticeScrollIndex < TempIndex)
  1260. {
  1261. forward = true;
  1262. NoticeScrollIndex = Convert.ToInt16(Math.Floor(yPoint));
  1263. }
  1264. else
  1265. {
  1266. forward = false;
  1267. NoticeScrollIndex = Convert.ToInt16(Math.Floor(yPoint));
  1268. }
  1269. if (NoticeScrollIndex >= Notice.MultiText.Length - 25) NoticeScrollIndex = Notice.MultiText.Length - 25;
  1270. if (NoticeScrollIndex <= 0) NoticeScrollIndex = 0;
  1271. UpdateNotice(forward);
  1272. UpdateNoticeScrollPosition();
  1273. }
  1274. private void NoticePanel_MouseWheel(object sender, MouseEventArgs e)
  1275. {
  1276. int count = e.Delta / SystemInformation.MouseWheelScrollDelta;
  1277. if (NoticeScrollIndex == 0 && count >= 0) return;
  1278. if (NoticeScrollIndex == Notice.MultiText.Length - 25 && count <= 0) return;
  1279. if (count > 0)
  1280. {
  1281. NoticeScrollIndex--;
  1282. UpdateNotice();
  1283. }
  1284. else
  1285. {
  1286. NoticeScrollIndex++;
  1287. UpdateNotice(true);
  1288. }
  1289. UpdateNoticeScrollPosition();
  1290. }
  1291. private void NoticePanel_KeyDown(object sender, KeyEventArgs e)
  1292. {
  1293. switch (e.KeyCode)
  1294. {
  1295. case Keys.Up:
  1296. if (NoticeScrollIndex == 0) break;
  1297. if (NoticeScrollIndex >= 25) NoticeScrollIndex -= 24;
  1298. NoticeScrollIndex--;
  1299. break;
  1300. case Keys.Home:
  1301. if (NoticeScrollIndex == 0) break;
  1302. NoticeScrollIndex = 0;
  1303. break;
  1304. case Keys.Down:
  1305. if (NoticeScrollIndex == Notice.MultiText.Length - 1) break;
  1306. if (NoticeScrollIndex < 25) NoticeScrollIndex = 24;
  1307. NoticeScrollIndex++;
  1308. break;
  1309. case Keys.End:
  1310. if (NoticeScrollIndex == Notice.MultiText.Length - 1) break;
  1311. NoticeScrollIndex = Notice.MultiText.Length - 1;
  1312. break;
  1313. case Keys.PageUp:
  1314. if (NoticeScrollIndex == 0) break;
  1315. NoticeScrollIndex -= 25;
  1316. break;
  1317. case Keys.PageDown:
  1318. if (NoticeScrollIndex == Notice.MultiText.Length - 25) break;
  1319. NoticeScrollIndex += 25;
  1320. break;
  1321. default:
  1322. return;
  1323. }
  1324. UpdateNotice();
  1325. e.Handled = true;
  1326. }
  1327. #endregion
  1328. #endregion
  1329. #region MembersDialogCode
  1330. public void NewMembersList(List<GuildRank> NewRanks)
  1331. {
  1332. Ranks = NewRanks;
  1333. MemberCount = CountMembers(Ranks);
  1334. MembersChanged = false;
  1335. RefreshMemberList();
  1336. }
  1337. private int CountMembers(List<GuildRank> ranks)
  1338. {
  1339. if (ranks == null) return 0;
  1340. int total = 0;
  1341. for (int i = 0; i < ranks.Count; i++)
  1342. {
  1343. if (ranks[i] != null && ranks[i].Members != null)
  1344. total += ranks[i].Members.Count;
  1345. }
  1346. return total;
  1347. }
  1348. public void RefreshMemberList()
  1349. {
  1350. MemberScrollIndex = 0;
  1351. List<string> RankNames = new List<string>();
  1352. for (int i = 0; i < Ranks.Count; i++)
  1353. {
  1354. if (Ranks[i] != null)
  1355. {
  1356. int index = i;
  1357. Ranks[i].Index = index;
  1358. RankNames.Add(Ranks[i].Name);
  1359. }
  1360. else
  1361. RankNames.Add("Missing Rank");
  1362. }
  1363. for (int i = 0; i < MembersRanks.Length; i++)
  1364. {
  1365. MembersRanks[i].Items = RankNames;
  1366. MembersRanks[i].MinimumOption = MyRankId;
  1367. }
  1368. RanksSelectBox.Items = RankNames.ToList();
  1369. RanksSelectBox.MinimumOption = 0;
  1370. if (RankNames.Count < 255)
  1371. RanksSelectBox.Items.Add("Add New");
  1372. UpdateMembers();
  1373. UpdateRanks();
  1374. }
  1375. public void MemberStatusChange(string name, bool online)
  1376. {
  1377. for (int i = 0; i < Ranks.Count; i++)
  1378. for (int j = 0; j < Ranks[i].Members.Count; j++)
  1379. if (Ranks[i].Members[j].Name == name)
  1380. Ranks[i].Members[j].Online = online;
  1381. UpdateMembers();
  1382. }
  1383. public void OnNewRank(int Index, int SelectedIndex)
  1384. {
  1385. if (SelectedIndex >= Ranks.Count) return;
  1386. if (LastGuildMsg > CMain.Time) return;
  1387. MirMessageBox messageBox = new MirMessageBox(GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.ConfirmChangeRank), MembersName[Index].Text, Ranks[SelectedIndex].Name), MirMessageBoxButtons.YesNo);
  1388. messageBox.YesButton.Click += (o, a) =>
  1389. {
  1390. Network.Enqueue(new C.EditGuildMember { ChangeType = 2, Name = MembersName[Index].Text, RankIndex = (byte)Ranks[SelectedIndex].Index, RankName = Ranks[SelectedIndex].Name });
  1391. LastGuildMsg = CMain.Time + 5000;
  1392. };
  1393. messageBox.Show();
  1394. }
  1395. public void AddMember()
  1396. {
  1397. if (!MyOptions.HasFlag(GuildRankOptions.CanRecruit)) return;
  1398. if (LastGuildMsg > CMain.Time) return;
  1399. Network.Enqueue(new C.EditGuildMember { ChangeType = 0, Name = MembersRecruitName.Text });
  1400. LastGuildMsg = CMain.Time + 5000;
  1401. MembersRecruitName.Text = "";
  1402. }
  1403. public void DeleteMember(int Index)
  1404. {
  1405. if (MembersName[Index].Text == MapControl.User.Name) return;
  1406. if (LastGuildMsg > CMain.Time) return;
  1407. MirMessageBox messageBox = new MirMessageBox(GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.ConfirmKickPlayer), MembersName[Index].Text), MirMessageBoxButtons.YesNo);
  1408. messageBox.YesButton.Click += (o, a) =>
  1409. {
  1410. Network.Enqueue(new C.EditGuildMember { ChangeType = 1, Name = MembersName[Index].Text });
  1411. LastGuildMsg = CMain.Time + 5000;
  1412. };
  1413. messageBox.Show();
  1414. }
  1415. public void UpdateMembers()
  1416. {
  1417. MembersShowCount = 0;
  1418. for (int i = 0; i < Ranks.Count; i++)
  1419. for (int j = 0; j < Ranks[i].Members.Count; j++)
  1420. {
  1421. if (MembersShowOfflinesetting || Ranks[i].Members[j].Online) MembersShowCount++;
  1422. }
  1423. if (MembersShowCount < MemberPageRows)
  1424. MemberScrollIndex = 0;
  1425. for (int i = 0; i < MembersRanks.Length; i++)
  1426. {
  1427. if (MembersShowCount > i)
  1428. {
  1429. MembersRanks[i].Visible = true;
  1430. }
  1431. else
  1432. MembersRanks[i].Visible = false;
  1433. }
  1434. for (int i = 0; i < MembersName.Length; i++)
  1435. {
  1436. if (MembersShowCount > i)
  1437. MembersName[i].Visible = true;
  1438. else
  1439. MembersName[i].Visible = false;
  1440. }
  1441. for (int i = 0; i < MembersStatus.Length; i++)
  1442. {
  1443. if (MembersShowCount > i)
  1444. MembersStatus[i].Visible = true;
  1445. else
  1446. MembersStatus[i].Visible = false;
  1447. }
  1448. for (int i = 0; i < MembersDelete.Length; i++)
  1449. {
  1450. MembersDelete[i].Visible = false;
  1451. }
  1452. if (MyOptions.HasFlag(GuildRankOptions.CanRecruit))
  1453. {
  1454. RecruitMemberButton.Visible = true;
  1455. MembersRecruitName.Visible = true;
  1456. RecruitMemberLabel.Visible = true;
  1457. }
  1458. else
  1459. {
  1460. RecruitMemberButton.Visible = false;
  1461. MembersRecruitName.Visible = false;
  1462. RecruitMemberLabel.Visible = false;
  1463. }
  1464. int Offset = 0;
  1465. int RowCount = 0;
  1466. DateTime now = CMain.Now;
  1467. for (int i = 0; i < Ranks.Count; i++)
  1468. for (int j = 0; j < Ranks[i].Members.Count; j++)
  1469. {
  1470. if (Offset < MemberScrollIndex)
  1471. {
  1472. if ((MembersShowOfflinesetting) || (Ranks[i].Members[j].Online))
  1473. Offset++;
  1474. }
  1475. else
  1476. {
  1477. if ((!MembersShowOfflinesetting) && (Ranks[i].Members[j].Online == false)) continue;
  1478. if ((MyOptions.HasFlag(GuildRankOptions.CanChangeRank)) && (Ranks[i].Index >= MyRankId))
  1479. MembersRanks[RowCount].Enabled = true;
  1480. else
  1481. MembersRanks[RowCount].Enabled = false;
  1482. if ((MyOptions.HasFlag(GuildRankOptions.CanKick)) && (Ranks[i].Index >= MyRankId) && (Ranks[i].Members[j].Name != MapControl.User.Name)/* && (Ranks[i].Index != 0)*/)
  1483. MembersDelete[RowCount].Visible = true;
  1484. else
  1485. MembersDelete[RowCount].Visible = false;
  1486. MembersRanks[RowCount].SelectedIndex = Ranks[i].Index;
  1487. MembersName[RowCount].Text = Ranks[i].Members[j].Name;
  1488. if (Ranks[i].Members[j].Online)
  1489. MembersStatus[RowCount].ForeColour = Color.LimeGreen;
  1490. else
  1491. MembersStatus[RowCount].ForeColour = Color.White;
  1492. TimeSpan Diff = now - Ranks[i].Members[j].LastLogin.ToLocalTime();
  1493. string text;
  1494. if (Ranks[i].Members[j].Online)
  1495. text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Online);
  1496. else
  1497. {
  1498. switch (Diff.Days)
  1499. {
  1500. case 0:
  1501. text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Today);
  1502. break;
  1503. case 1:
  1504. text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Yesterday);
  1505. break;
  1506. default:
  1507. text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.DaysAgo), Diff.Days);
  1508. break;
  1509. }
  1510. }
  1511. MembersStatus[RowCount].Text = text;
  1512. RowCount++;
  1513. if (RowCount > MemberPageRows - 1) return;
  1514. }
  1515. }
  1516. }
  1517. public void MembersShowOfflineSwitch()
  1518. {
  1519. if (MembersShowOfflinesetting)
  1520. {
  1521. MembersShowOfflinesetting = false;
  1522. MembersShowOfflineStatus.Visible = false;
  1523. }
  1524. else
  1525. {
  1526. MembersShowOfflinesetting = true;
  1527. MembersShowOfflineStatus.Visible = true;
  1528. }
  1529. UpdateMembers();
  1530. }
  1531. public void MembersPositionBar_OnMoving(object sender, MouseEventArgs e)
  1532. {
  1533. int x = 337;
  1534. int y = MembersPositionBar.Location.Y;
  1535. if (y >= MembersDownButton.Location.Y - 20) y = MembersDownButton.Location.Y - 20;
  1536. if (y < 16) y = 16;
  1537. int location = y - 16;
  1538. int interval = 289 / (MembersShowCount - MemberPageRows);
  1539. double yPoint = location / interval;
  1540. MemberScrollIndex = Convert.ToInt16(Math.Floor(yPoint));
  1541. if (MemberScrollIndex > MembersShowCount - MemberPageRows) MemberScrollIndex = MembersShowCount - MemberPageRows;
  1542. if (MemberScrollIndex <= 0) MemberScrollIndex = 0;
  1543. UpdateMembers();
  1544. MembersPositionBar.Location = new Point(x, y);
  1545. }
  1546. private void UpdateMembersScrollPosition()
  1547. {
  1548. int interval = 289 / (MembersShowCount - MemberPageRows);
  1549. int x = 337;
  1550. int y = 16 + (MemberScrollIndex * interval);
  1551. if (y >= MembersDownButton.Location.Y - 20) y = MembersDownButton.Location.Y - 20;
  1552. if (y <= 16) y = 16;
  1553. MembersPositionBar.Location = new Point(x, y);
  1554. }
  1555. private void MembersPanel_MouseWheel(object sender, MouseEventArgs e)
  1556. {
  1557. int count = e.Delta / SystemInformation.MouseWheelScrollDelta;
  1558. if (MemberScrollIndex == 0 && count >= 0) return;
  1559. if (MemberScrollIndex == MembersShowCount - MemberPageRows && count <= 0) return;
  1560. MemberScrollIndex -= count > 0 ? 1 : -1;
  1561. UpdateMembers();
  1562. UpdateMembersScrollPosition();
  1563. }
  1564. private void MembersPanel_KeyDown(object sender, KeyEventArgs e)
  1565. {
  1566. switch (e.KeyCode)
  1567. {
  1568. case Keys.Up:
  1569. if (MemberScrollIndex == 0) break;
  1570. MemberScrollIndex--;
  1571. break;
  1572. case Keys.Home:
  1573. if (MemberScrollIndex == 0) break;
  1574. MemberScrollIndex = 0;
  1575. break;
  1576. case Keys.Down:
  1577. if (MembersShowCount < MemberPageRows) break;
  1578. if (MemberScrollIndex == MembersShowCount - MemberPageRows) break;
  1579. MemberScrollIndex++;
  1580. break;
  1581. case Keys.End:
  1582. if (MembersShowCount < MemberPageRows) break;
  1583. if (MemberScrollIndex == MembersShowCount - MemberPageRows) break;
  1584. MemberScrollIndex = MembersShowCount - MemberPageRows;
  1585. break;
  1586. case Keys.PageUp:
  1587. if (MemberScrollIndex == 0) break;
  1588. MemberScrollIndex -= 25;
  1589. if (MemberScrollIndex < 0) MemberScrollIndex = 0;
  1590. break;
  1591. case Keys.PageDown:
  1592. if (MembersShowCount < MemberPageRows) break;
  1593. if (MemberScrollIndex == MembersShowCount - 25) break;
  1594. MemberScrollIndex += 25;
  1595. if (MemberScrollIndex > (MembersShowCount - MemberPageRows)) MemberScrollIndex = MembersShowCount - MemberPageRows;
  1596. break;
  1597. default:
  1598. return;
  1599. }
  1600. UpdateMembers();
  1601. UpdateMembersScrollPosition();
  1602. e.Handled = true;
  1603. }
  1604. #endregion
  1605. #region StatusDialogCode
  1606. private void StatusExpBar_BeforeDraw(object sender, EventArgs e)
  1607. {
  1608. if (GameScene.Scene.GuildDialog.MaxExperience == 0)
  1609. {
  1610. StatusExpLabel.Text = "";
  1611. return;
  1612. }
  1613. if (StatusExpBar.Library == null) return;
  1614. StatusExpBar.Library.Draw(424, StatusExpBar.DisplayLocation, new Size(260, 22), Color.White);
  1615. double percent = GameScene.Scene.GuildDialog.Experience / (double)GameScene.Scene.GuildDialog.MaxExperience;
  1616. StatusExpLabel.Text = string.Format("{0:#0.##%}", percent);
  1617. if (percent > 1) percent = 1;
  1618. if (percent <= 0) return;
  1619. Rectangle section = new Rectangle
  1620. {
  1621. Size = new Size((int)((260 - 3) * percent), 22)
  1622. };
  1623. StatusExpBar.Library.Draw(StatusExpBar.Index, section, StatusExpBar.DisplayLocation, Color.White, false);
  1624. }
  1625. #endregion
  1626. #region RankDialogCode
  1627. public void NewRankRecieved(GuildRank New)
  1628. {
  1629. int NewIndex = Ranks.Count > 1 ? Ranks.Count - 1 : 1;
  1630. Ranks.Insert(NewIndex, New);
  1631. Ranks[Ranks.Count - 1].Index = Ranks.Count - 1;
  1632. RefreshMemberList();
  1633. UpdateRanks();
  1634. }
  1635. public void MyRankChanged(GuildRank New)
  1636. {
  1637. MyOptions = New.Options;
  1638. MapObject.User.GuildRankName = New.Name;
  1639. GuildMember Member = null;
  1640. int OldRank = MyRankId;
  1641. MyRankId = New.Index;
  1642. if (OldRank >= Ranks.Count) return;
  1643. for (int i = 0; i < Ranks[OldRank].Members.Count; i++)
  1644. if (Ranks[OldRank].Members[i].Name == MapObject.User.Name)
  1645. {
  1646. Member = Ranks[OldRank].Members[i];
  1647. Ranks[OldRank].Members.Remove(Member);
  1648. break;
  1649. }
  1650. if (Member == null) return;
  1651. if (Ranks.Count <= New.Index)
  1652. {
  1653. Ranks[MyRankId].Members.Add(Member);
  1654. MembersChanged = true;
  1655. return;
  1656. }
  1657. Ranks[New.Index].Members.Add(Member);
  1658. ResetButtonStats();
  1659. UpdateMembers();
  1660. }
  1661. public void RankChangeRecieved(GuildRank New)
  1662. {
  1663. for (int i = 0; i < Ranks.Count; i++)
  1664. if (Ranks[i].Index == New.Index)
  1665. {
  1666. if (Ranks[i].Name == MapObject.User.GuildRankName)
  1667. for (int j = 0; j < Ranks[i].Members.Count; j++)
  1668. if (Ranks[i].Members[j].Name == MapObject.User.Name)
  1669. {
  1670. MapObject.User.GuildRankName = New.Name;
  1671. MyOptions = New.Options;
  1672. ResetButtonStats();
  1673. UpdateMembers();
  1674. }
  1675. if (Ranks[i].Name == New.Name)
  1676. {
  1677. Ranks[i] = New;
  1678. }
  1679. else
  1680. {
  1681. Ranks[i] = New;
  1682. RefreshMemberList();
  1683. }
  1684. }
  1685. UpdateRanks();
  1686. }
  1687. public void UpdateRanks()
  1688. {
  1689. if ((RanksSelectBox.SelectedIndex == -1) || (Ranks[RanksSelectBox.SelectedIndex].Index < MyRankId))
  1690. {
  1691. for (int i = 0; i < RanksOptionsButtons.Length; i++)
  1692. RanksOptionsButtons[i].Enabled = false;
  1693. for (int i = 0; i < RanksOptionsStatus.Length; i++)
  1694. RanksOptionsStatus[i].Enabled = false;
  1695. if (RanksSelectBox.SelectedIndex == -1)
  1696. for (int i = 0; i < RanksOptionsStatus.Length; i++)
  1697. RanksOptionsStatus[i].Visible = false;
  1698. LastRankNameChange = long.MaxValue;
  1699. RanksName.Text = "";
  1700. return;
  1701. }
  1702. RanksName.Text = Ranks[RanksSelectBox.SelectedIndex].Name;
  1703. if (Ranks[RanksSelectBox.SelectedIndex].Index >= MyRankId)
  1704. LastRankNameChange = 0;
  1705. else
  1706. LastRankNameChange = long.MaxValue;
  1707. for (int i = 0; i < RanksOptionsStatus.Length; i++)
  1708. {
  1709. if (Ranks[RanksSelectBox.SelectedIndex].Options.HasFlag((GuildRankOptions)(1 << i)))
  1710. RanksOptionsStatus[i].Visible = true;
  1711. else
  1712. RanksOptionsStatus[i].Visible = false;
  1713. if (Ranks[RanksSelectBox.SelectedIndex].Index >= MyRankId)
  1714. RanksOptionsButtons[i].Enabled = true;
  1715. else
  1716. RanksOptionsButtons[i].Enabled = false;
  1717. }
  1718. }
  1719. public void OnRankSelect(int Index)
  1720. {
  1721. if (Index < Ranks.Count)
  1722. RanksSelectBox.SelectedIndex = Index;
  1723. else
  1724. {
  1725. if (Ranks.Count == 255) return;
  1726. if (LastGuildMsg > CMain.Time) return;
  1727. MirMessageBox messageBox = new MirMessageBox(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ConfirmCreateNewRank), MirMessageBoxButtons.YesNo);
  1728. messageBox.YesButton.Click += (o, a) =>
  1729. {
  1730. Network.Enqueue(new C.EditGuildMember { ChangeType = 4, RankName = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.RankTitle), Ranks.Count - 1) });
  1731. LastGuildMsg = CMain.Time + 5000;
  1732. };
  1733. messageBox.Show();
  1734. }
  1735. UpdateRanks();
  1736. }
  1737. public void SwitchRankOption(int OptionIndex)
  1738. {
  1739. if ((RanksSelectBox.SelectedIndex == -1) || (RanksSelectBox.SelectedIndex >= Ranks.Count)) return;
  1740. if (LastGuildMsg > CMain.Time) return;
  1741. Network.Enqueue(new C.EditGuildMember { ChangeType = 5, RankIndex = (byte)Ranks[RanksSelectBox.SelectedIndex].Index, RankName = OptionIndex.ToString(), Name = RanksOptionsStatus[OptionIndex].Visible ? "false" : "true" });
  1742. LastGuildMsg = CMain.Time + 300;
  1743. }
  1744. public void RanksChangeName()
  1745. {
  1746. if (!string.IsNullOrEmpty(RanksName.Text))
  1747. {
  1748. Network.Enqueue(new C.EditGuildMember { ChangeType = 3, RankIndex = (byte)Ranks[RanksSelectBox.SelectedIndex].Index, RankName = RanksName.Text });
  1749. LastRankNameChange = CMain.Time + 5000;
  1750. RanksName.Enabled = false;
  1751. }
  1752. }
  1753. public void RanksName_KeyPress(object sender, KeyPressEventArgs e)
  1754. {
  1755. switch (e.KeyChar)
  1756. {
  1757. case (char)'\\':
  1758. e.Handled = true;
  1759. break;
  1760. case (char)Keys.Enter:
  1761. e.Handled = true;
  1762. RanksChangeName();
  1763. break;
  1764. case (char)Keys.Escape:
  1765. e.Handled = true;
  1766. UpdateRanks();
  1767. break;
  1768. }
  1769. }
  1770. public void RanksName_BeforeDraw()
  1771. {
  1772. if (LastRankNameChange < CMain.Time)
  1773. {
  1774. RanksName.Enabled = true;
  1775. RanksSaveName.Enabled = true;
  1776. }
  1777. else
  1778. {
  1779. RanksName.Enabled = false;
  1780. RanksSaveName.Enabled = false;
  1781. }
  1782. }
  1783. #endregion
  1784. #region StorageCode
  1785. public void StoragePositionBar_OnMoving(object sender, MouseEventArgs e)
  1786. {
  1787. int x = 337;
  1788. int y = StoragePositionBar.Location.Y;
  1789. if (y >= StorageDownButton.Location.Y - 20) y = StorageDownButton.Location.Y - 20;
  1790. if (y < 16) y = 16;
  1791. int location = y - 16;
  1792. int interval = 289 / 8;
  1793. double yPoint = location / interval;
  1794. StorageIndex = Convert.ToInt16(Math.Floor(yPoint));
  1795. if (StorageIndex > 6) StorageIndex = 6;
  1796. if (StorageIndex <= 0) StorageIndex = 0;
  1797. UpdateStorage();
  1798. StoragePositionBar.Location = new Point(x, y);
  1799. }
  1800. private void StoragePanel_MouseWheel(object sender, MouseEventArgs e)
  1801. {
  1802. int count = e.Delta / SystemInformation.MouseWheelScrollDelta;
  1803. if (StorageIndex == 0 && count >= 0) return;
  1804. if (StorageIndex == 6 && count <= 0) return;
  1805. StorageIndex -= count;
  1806. if (StorageIndex < 0) StorageIndex = 0;
  1807. if (StorageIndex > 6) StorageIndex = 6;
  1808. UpdateStorage();
  1809. StorageUpdatePositionBar();
  1810. }
  1811. private void StorageUpdatePositionBar()
  1812. {
  1813. int interval = 289 / 6;
  1814. int x = 337;
  1815. int y = 16 + (StorageIndex * interval);
  1816. if (y >= StorageDownButton.Location.Y - 20) y = StorageDownButton.Location.Y - 20;
  1817. if (y <= 16) y = 16;
  1818. StoragePositionBar.Location = new Point(x, y);
  1819. }
  1820. public void UpdateStorage()
  1821. {
  1822. for (int x = 0; x < 8; x++)
  1823. {
  1824. for (int y = 0; y < 14; y++)
  1825. {
  1826. int idx = 8 * y + x;
  1827. if (StorageIndex <= y && (y < StorageIndex + 8))
  1828. {
  1829. StorageGrid[idx].Location = new Point(x * 35 + 31 + x, (y - StorageIndex) * 35 + 20 + (y - StorageIndex));
  1830. StorageGrid[idx].Visible = true;
  1831. }
  1832. else
  1833. StorageGrid[idx].Visible = false;
  1834. }
  1835. }
  1836. }
  1837. public void StorageAddGold()
  1838. {
  1839. if (LastGuildMsg > CMain.Time) return;
  1840. MirAmountBox amountBox = new MirAmountBox(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Deposit), 116, GameScene.Gold);
  1841. amountBox.OKButton.Click += (o, a) =>
  1842. {
  1843. if (amountBox.Amount <= 0) return;
  1844. LastGuildMsg = CMain.Time + 100;
  1845. Network.Enqueue(new C.GuildStorageGoldChange
  1846. {
  1847. Type = 0,
  1848. Amount = amountBox.Amount,
  1849. });
  1850. };
  1851. amountBox.Show();
  1852. }
  1853. public void StorageRemoveGold()
  1854. {
  1855. if (LastGuildMsg > CMain.Time) return;
  1856. MirAmountBox amountBox = new MirAmountBox(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.GoldToRetrieve), 116, Gold);
  1857. amountBox.OKButton.Click += (o, a) =>
  1858. {
  1859. if (amountBox.Amount <= 0) return;
  1860. LastGuildMsg = CMain.Time + 100;
  1861. Network.Enqueue(new C.GuildStorageGoldChange
  1862. {
  1863. Type = 1,
  1864. Amount = amountBox.Amount,
  1865. });
  1866. };
  1867. amountBox.Show();
  1868. }
  1869. #endregion
  1870. #region UpdateNotice
  1871. public void RequestUpdateNotice()
  1872. {
  1873. if ((NoticeChanged) && (LastNoticeRequest < CMain.Time))
  1874. {
  1875. LastNoticeRequest = CMain.Time + 5000;
  1876. Network.Enqueue(new C.RequestGuildInfo() { Type = 0 });
  1877. }
  1878. }
  1879. public void RequestUpdateMembers()
  1880. {
  1881. if ((MembersChanged) && (LastMemberRequest < CMain.Time))
  1882. {
  1883. LastMemberRequest = CMain.Time + 5000;
  1884. Network.Enqueue(new C.RequestGuildInfo() { Type = 1 });
  1885. }
  1886. }
  1887. #endregion
  1888. #region NoticeDialogPages
  1889. public void RightDialog(byte Rpageid)
  1890. {
  1891. StatusPage.Visible = false;
  1892. BuffPage.Visible = false;
  1893. StatusButton.Index = 103;
  1894. BuffButton.Index = 95;
  1895. switch (Rpageid)
  1896. {
  1897. case 0:
  1898. StatusPage.Visible = true;
  1899. StatusButton.Index = 104;
  1900. break;
  1901. case 1:
  1902. BuffPage.Visible = true;
  1903. BuffButton.Index = 96;
  1904. break;
  1905. }
  1906. }
  1907. public void LeftDialog(byte Lpageid)
  1908. {
  1909. NoticePage.Visible = false;
  1910. MembersPage.Visible = false;
  1911. StoragePage.Visible = false;
  1912. RankPage.Visible = false;
  1913. NoticeButton.Index = 93;
  1914. MembersButton.Index = 99;
  1915. StorageButton.Index = 105;
  1916. RankButton.Index = 101;
  1917. switch (Lpageid)
  1918. {
  1919. case 0:
  1920. NoticePage.Visible = true;
  1921. NoticeButton.Index = 94;
  1922. RequestUpdateNotice();
  1923. break;
  1924. case 1:
  1925. MembersPage.Visible = true;
  1926. MembersButton.Index = 100;
  1927. RequestUpdateMembers();
  1928. break;
  1929. case 2:
  1930. StoragePage.Visible = true;
  1931. StorageButton.Index = 106;
  1932. Network.Enqueue(new C.GuildStorageItemChange() { Type = 3 });
  1933. break;
  1934. case 3:
  1935. RankPage.Visible = true;
  1936. RankButton.Index = 102;
  1937. RequestUpdateMembers();
  1938. break;
  1939. }
  1940. }
  1941. public void StatusChanged(GuildRankOptions status)
  1942. {
  1943. Notice.Enabled = false;
  1944. NoticeEditButton.Index = 85;
  1945. MyOptions = status;
  1946. if (MyOptions.HasFlag(GuildRankOptions.CanChangeNotice))
  1947. NoticeEditButton.Visible = true;
  1948. else
  1949. NoticeEditButton.Visible = false;
  1950. if (MyOptions.HasFlag(GuildRankOptions.CanChangeRank))
  1951. RankButton.Visible = true;
  1952. else
  1953. RankButton.Visible = false;
  1954. if ((MyOptions.HasFlag(GuildRankOptions.CanStoreItem)) || (MyOptions.HasFlag(GuildRankOptions.CanRetrieveItem)))
  1955. StorageButton.Visible = true;
  1956. else
  1957. StorageButton.Visible = false;
  1958. if (GuildBuffInfos.Count == 0) BuffButton.Visible = false;
  1959. else BuffButton.Visible = true;
  1960. }
  1961. #endregion
  1962. #region GuildDialogChecks
  1963. public override void Show()
  1964. {
  1965. if (Visible) return;
  1966. if (MapControl.User.GuildName == "")
  1967. {
  1968. MirMessageBox messageBox = new MirMessageBox(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.NotInGuild), MirMessageBoxButtons.OK);
  1969. messageBox.Show();
  1970. return;
  1971. }
  1972. Visible = true;
  1973. if (NoticePage.Visible)
  1974. {
  1975. if ((NoticeChanged) && (LastNoticeRequest < CMain.Time))
  1976. {
  1977. LastNoticeRequest = CMain.Time + 5000;
  1978. Network.Enqueue(new C.RequestGuildInfo() { Type = 0 });
  1979. }
  1980. NoticeButton.Index = 94;
  1981. }
  1982. if (StatusPage.Visible)
  1983. StatusButton.Index = 104;
  1984. }
  1985. #endregion
  1986. }
  1987. public sealed class GuildBuffButton : MirControl
  1988. {
  1989. public byte Id;
  1990. //public MirButton Icon;
  1991. public MirImageControl Icon;
  1992. public MirLabel Name, Info, Obtained;
  1993. //public MirControl HintLabel;
  1994. public GuildBuffButton()
  1995. {
  1996. BorderColour = Color.Orange;
  1997. Size = new Size(188, 33);
  1998. Icon = new MirImageControl
  1999. {
  2000. Index = 0,
  2001. Library = Libraries.GuildSkill,
  2002. Parent = this,
  2003. //Location = new Point(1, 0),
  2004. Location = new Point(1, 0),
  2005. NotControl = true
  2006. };
  2007. Name = new MirLabel
  2008. {
  2009. AutoSize = true,
  2010. Parent = this,
  2011. Location = new Point(35, 1),
  2012. NotControl = true
  2013. };
  2014. Info = new MirLabel
  2015. {
  2016. AutoSize = true,
  2017. Parent = this,
  2018. Location = new Point(35, 17),
  2019. NotControl = true
  2020. };
  2021. Obtained = new MirLabel
  2022. {
  2023. DrawFormat = TextFormatFlags.Right,
  2024. AutoSize = true,
  2025. Parent = this,
  2026. Location = new Point(140, 17),
  2027. NotControl = true,
  2028. Text = ""
  2029. };
  2030. }
  2031. protected override void OnMouseEnter()
  2032. {
  2033. base.OnMouseEnter();
  2034. GameScene.Scene.GuildDialog.CreateHintLabel(Id);
  2035. Border = true;
  2036. }
  2037. protected override void OnMouseLeave()
  2038. {
  2039. base.OnMouseLeave();
  2040. GameScene.Scene.DisposeGuildBuffLabel();
  2041. Border = false;
  2042. }
  2043. }
  2044. }