serverbrowserentry.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829
  1. class ServerBrowserEntry extends ScriptedWidgetEventHandler
  2. {
  3. protected Widget m_Root;
  4. protected Widget m_Favorite;
  5. //Basic info
  6. protected TextWidget m_ServerName;
  7. protected TextWidget m_ServerPopulation;
  8. protected TextWidget m_ServerSlots;
  9. protected TextWidget m_ServerPing;
  10. protected ImageWidget m_ServerTime; // not currently displayed
  11. protected ImageWidget m_ServerLock;
  12. protected ImageWidget m_ServerModIcon;
  13. protected ImageWidget m_ServerMaKIcon;
  14. //Detailed info
  15. protected TextWidget m_ServerShard;
  16. protected TextWidget m_ServerCharacterAlive;
  17. protected TextWidget m_ServerFriends;
  18. protected TextWidget m_ServerMode;
  19. protected TextWidget m_ServerBattleye;
  20. protected TextWidget m_ServerIP;
  21. protected TextWidget m_ServerAcceleration;
  22. protected TextWidget m_ServerMap;
  23. protected TextWidget m_ServerMods;
  24. protected ButtonWidget m_ServerModsExpand;
  25. protected ref array<string> m_Mods;
  26. protected Widget m_DetailedInfo;
  27. protected bool m_IsExpanded;
  28. protected bool m_IsFavorited;
  29. protected bool m_IsOnline;
  30. protected ref GetServersResultRow m_ServerData;
  31. protected int m_Index;
  32. protected ServerBrowserTab m_Tab;
  33. protected bool m_Selected;
  34. protected bool m_FirstExpand = true;
  35. void ServerBrowserEntry(Widget parent, int index, ServerBrowserTab tab)
  36. {
  37. #ifdef PLATFORM_CONSOLE
  38. m_Root = GetGame().GetWorkspace().CreateWidgets("gui/layouts/new_ui/server_browser/xbox/server_browser_list_entry.layout", parent);
  39. #else
  40. m_Root = GetGame().GetWorkspace().CreateWidgets("gui/layouts/new_ui/server_browser/pc/server_browser_list_entry_pages.layout", parent);
  41. #endif
  42. m_Root.Enable(true);
  43. m_Favorite = m_Root.FindAnyWidget("favorite_button");
  44. m_ServerName = TextWidget.Cast(m_Root.FindAnyWidget("server_name"));
  45. m_ServerPopulation = TextWidget.Cast( m_Root.FindAnyWidget("server_population"));
  46. m_ServerSlots = TextWidget.Cast(m_Root.FindAnyWidget("server_slots"));
  47. m_ServerPing = TextWidget.Cast(m_Root.FindAnyWidget("server_ping"));
  48. m_ServerTime = ImageWidget.Cast(m_Root.FindAnyWidget("server_time"));
  49. m_ServerLock = ImageWidget.Cast(m_Root.FindAnyWidget("lock_icon"));
  50. m_ServerModIcon = ImageWidget.Cast(m_Root.FindAnyWidget("modded_icon"));
  51. m_ServerMaKIcon = ImageWidget.Cast(m_Root.FindAnyWidget("mandk_icon"));
  52. m_ServerShard = TextWidget.Cast(m_Root.FindAnyWidget("shard_text"));
  53. m_ServerCharacterAlive = TextWidget.Cast(m_Root.FindAnyWidget("character_alive_text"));
  54. m_ServerFriends = TextWidget.Cast(m_Root.FindAnyWidget("steam_friends_text"));
  55. m_ServerMode = TextWidget.Cast(m_Root.FindAnyWidget("mode_text"));
  56. m_ServerBattleye = TextWidget.Cast(m_Root.FindAnyWidget("battlleye_text"));
  57. m_ServerIP = TextWidget.Cast(m_Root.FindAnyWidget("ip_text"));
  58. m_ServerAcceleration = TextWidget.Cast(m_Root.FindAnyWidget("server_acceleration_text"));
  59. m_ServerMap = TextWidget.Cast(m_Root.FindAnyWidget("server_map"));
  60. m_ServerMods = TextWidget.Cast(m_Root.FindAnyWidget("mods_text"));
  61. m_ServerModsExpand = ButtonWidget.Cast(m_Root.FindAnyWidget("mods_expand"));
  62. m_DetailedInfo = m_Root.FindAnyWidget("detailed_info");
  63. m_Root.FindAnyWidget("basic_info").Show(true);
  64. m_Root.FindAnyWidget("favorite_image").Update();
  65. m_Root.FindAnyWidget("unfavorite_image").Update();
  66. m_Index = index;
  67. m_Tab = tab;
  68. m_IsOnline = true;
  69. m_ServerTime.LoadImageFile(0, "set:dayz_gui image:icon_sun");
  70. m_ServerTime.LoadImageFile(1, "set:dayz_gui image:icon_sun_accel");
  71. m_ServerTime.LoadImageFile(2, "set:dayz_gui image:icon_moon");
  72. m_ServerTime.LoadImageFile(3, "set:dayz_gui image:icon_moon_accel");
  73. m_Root.SetHandler(this);
  74. }
  75. void ~ServerBrowserEntry()
  76. {
  77. delete m_Root;
  78. }
  79. Widget GetRoot()
  80. {
  81. return m_Root;
  82. }
  83. void Show(bool show)
  84. {
  85. m_Root.Show(show);
  86. }
  87. // Method never gets called on console!
  88. override bool OnClick(Widget w, int x, int y, int button)
  89. {
  90. if (!IsOnline() || w == null)
  91. {
  92. return false;
  93. }
  94. switch (w)
  95. {
  96. #ifdef PLATFORM_CONSOLE
  97. case m_Root:
  98. {
  99. m_Tab.Connect(this);
  100. return true;
  101. }
  102. #endif
  103. case m_ServerModsExpand:
  104. {
  105. string mods_text;
  106. if (m_Mods && m_Mods.Count() > 0)
  107. {
  108. mods_text = m_Mods[0];
  109. for (int i = 1; i < m_Mods.Count(); i++)
  110. {
  111. mods_text += "\n" + m_Mods[i];
  112. }
  113. }
  114. GetGame().GetUIManager().ShowDialog("#main_menu_mods", mods_text, 0, 0, 0, 0, GetGame().GetUIManager().GetMenu());
  115. return true;
  116. }
  117. }
  118. return false;
  119. }
  120. override bool OnDoubleClick(Widget w, int x, int y, int button)
  121. {
  122. if (!IsOnline())
  123. {
  124. return false;
  125. }
  126. if (button == MouseState.LEFT && w == m_Root)
  127. {
  128. m_Tab.Connect(this);
  129. return true;
  130. }
  131. return false;
  132. }
  133. override bool OnMouseButtonUp(Widget w, int x, int y, int button)
  134. {
  135. if (button == MouseState.LEFT)
  136. {
  137. switch (w)
  138. {
  139. case m_Favorite:
  140. {
  141. ToggleFavorite();
  142. return true;
  143. }
  144. case m_Root:
  145. {
  146. OnSelect();
  147. return true;
  148. }
  149. }
  150. }
  151. return false;
  152. }
  153. void OnSelect()
  154. {
  155. Darken(m_Root, 0, 0);
  156. Select();
  157. SetFocus(m_Root);
  158. m_Tab.SetServerDetails(m_ServerData, m_IsOnline);
  159. }
  160. override bool OnMouseEnter(Widget w, int x, int y)
  161. {
  162. if (IsFocusable(w))
  163. {
  164. Preview(w, x, y);
  165. return true;
  166. }
  167. return false;
  168. }
  169. override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
  170. {
  171. if (IsFocusable(w) && !IsFocusable(enterW))
  172. {
  173. Lighten(w, enterW, x, y);
  174. return true;
  175. }
  176. return false;
  177. }
  178. void Focus()
  179. {
  180. SetFocus(m_Root);
  181. }
  182. void ServerListFocus(bool focus)
  183. {
  184. m_Tab.ServerListFocus(focus, m_IsFavorited);
  185. }
  186. override bool OnFocus(Widget w, int x, int y)
  187. {
  188. if (!m_Selected)
  189. {
  190. if (IsFocusable(w))
  191. Darken(w, x, y);
  192. #ifdef PLATFORM_CONSOLE
  193. if (w == m_Root)
  194. {
  195. Select();
  196. ServerListFocus(true);
  197. m_Tab.SetServerDetails(m_ServerData, m_IsOnline);
  198. }
  199. #endif
  200. return true;
  201. }
  202. return false;
  203. }
  204. override bool OnFocusLost(Widget w, int x, int y)
  205. {
  206. #ifdef PLATFORM_CONSOLE
  207. if (w == m_Root)
  208. {
  209. Deselect();
  210. ServerListFocus(false);
  211. }
  212. #endif
  213. if (IsFocusable(w))
  214. {
  215. Lighten(w, null, x, y);
  216. }
  217. return true;
  218. return false;
  219. }
  220. bool IsOnline()
  221. {
  222. return m_IsOnline;
  223. }
  224. bool IsFocusable(Widget w)
  225. {
  226. if (w)
  227. return (w == m_Root || w == m_Favorite || w == m_ServerModsExpand);
  228. return false;
  229. }
  230. void FillInfo(GetServersResultRow server_info)
  231. {
  232. m_ServerData = server_info;
  233. m_FirstExpand = true;
  234. #ifndef PLATFORM_CONSOLE
  235. m_DetailedInfo.Show(server_info.m_IsExpanded);
  236. #endif
  237. SetName(server_info.m_Name);
  238. SetPasswordLocked(server_info.m_IsPasswordProtected);
  239. SetPopulationEx(server_info);
  240. SetSlots(server_info.m_MaxPlayers);
  241. SetPing(server_info.m_Ping);
  242. SetFavorite(server_info.m_Favorite);
  243. SetModded(server_info.m_Modded);
  244. SetServerMapName();
  245. RefreshDLCIcon();
  246. #ifdef PLATFORM_CONSOLE
  247. SetMouseAndKeyboard(server_info.m_MouseAndKeyboardEnabled);
  248. #endif
  249. #ifdef PLATFORM_WINDOWS
  250. #ifndef PLATFORM_CONSOLE
  251. SetExpand(server_info.m_IsExpanded);
  252. int pp = 0; // private
  253. if (server_info.m_ShardId.Length() == 3 && server_info.m_ShardId.ToInt() < 200)
  254. {
  255. pp = 1; // official
  256. }
  257. SetShard(pp);
  258. SetCharacterAlive(server_info.m_CharactersAlive);
  259. SetFriends(server_info.m_SteamFriends);
  260. SetMode(server_info.m_Disable3rdPerson);
  261. SetBattleye(server_info.m_AntiCheat);
  262. SetIP(server_info.m_Id);
  263. SetAcceleration(server_info.m_EnvironmentTimeMul);
  264. #endif
  265. #endif
  266. }
  267. void UpdateEntry()
  268. {
  269. if (m_ServerData.m_IsSelected)
  270. {
  271. Darken(m_Root, 0, 0);
  272. Select();
  273. SetFocus(m_Root);
  274. }
  275. else
  276. {
  277. Lighten(m_Root, null, 0, 0);
  278. Deselect();
  279. }
  280. }
  281. void SetName(string name)
  282. {
  283. m_ServerName.SetText(name);
  284. }
  285. void SetPasswordLocked(bool locked)
  286. {
  287. m_ServerLock.Show(locked);
  288. }
  289. private void SetPopulationEx(GetServersResultRow serverInfo)
  290. {
  291. string popText = "";
  292. int population = serverInfo.m_CurrentNumberPlayers;
  293. int maxPlayers = serverInfo.m_MaxPlayers;
  294. int playersInQueue = serverInfo.m_PlayersInQueue;
  295. if (IsOnline())
  296. {
  297. // sometimes servers report a queue size even though server isn't full,
  298. // in which case we ignore queue size
  299. if (playersInQueue > 0 && population == maxPlayers)
  300. {
  301. popText = population.ToString() + "+" + playersInQueue.ToString() + "/" + maxPlayers.ToString();
  302. }
  303. else
  304. {
  305. popText = population.ToString() + "/" + maxPlayers.ToString();
  306. }
  307. }
  308. else
  309. {
  310. popText = "-";
  311. }
  312. m_ServerPopulation.SetText(popText);
  313. }
  314. void SetSlots(int slots)
  315. {
  316. if (IsOnline())
  317. {
  318. m_ServerSlots.SetText(slots.ToString());
  319. }
  320. else
  321. {
  322. m_ServerSlots.SetText("-");
  323. }
  324. }
  325. void SetPing(int ping)
  326. {
  327. int color;
  328. string displayValue;
  329. if (ping < 50)
  330. color = ARGBF(1, 0, 1, 0);
  331. else if(ping < 100)
  332. color = ARGBF(1, 0.8, 0.8, 0);
  333. else if( ping < 200 )
  334. color = ARGBF(1, 1, 0.5, 0);
  335. else
  336. color = ARGBF(1, 1, 0, 0);
  337. if (IsOnline())
  338. {
  339. displayValue = ping.ToString();
  340. }
  341. else
  342. {
  343. displayValue = "-";
  344. }
  345. m_ServerPing.SetColor(color);
  346. m_ServerPing.SetText(displayValue);
  347. }
  348. void SetTime(string time, float multiplier)
  349. {
  350. if (time != "")
  351. {
  352. TStringArray arr = new TStringArray;
  353. time.Split(":", arr);
  354. if (arr.Count() == 2)
  355. {
  356. int hour = arr.Get(0).ToInt();
  357. int minute = arr.Get(1).ToInt();
  358. if (hour >= 19 || hour <= 5) //Night
  359. {
  360. if (multiplier > 1)
  361. m_ServerTime.SetImage(3);
  362. else
  363. m_ServerTime.SetImage(2);
  364. }
  365. else //Day
  366. {
  367. if (multiplier > 1)
  368. m_ServerTime.SetImage(1);
  369. else
  370. m_ServerTime.SetImage(0);
  371. }
  372. }
  373. }
  374. }
  375. void SetShard(int shard)
  376. {
  377. string text;
  378. switch (shard)
  379. {
  380. case 0:
  381. {
  382. text = "#server_browser_entry_private";
  383. break;
  384. }
  385. case 1:
  386. {
  387. text = "#server_browser_entry_official";
  388. break;
  389. }
  390. }
  391. m_ServerShard.SetText(text);
  392. }
  393. void RefreshDLCIcon()
  394. {
  395. if (m_ServerData.m_IsDLC)
  396. {
  397. bool own = GetGame().VerifyWorldOwnership(GetMapToRun());
  398. m_ServerModIcon.Show(true);
  399. m_ServerModIcon.FindWidget("Owned").Show(own);
  400. m_ServerModIcon.FindWidget("Unowned").Show(!own);
  401. }
  402. else
  403. {
  404. m_ServerModIcon.FindWidget("Owned").Show(false);
  405. m_ServerModIcon.FindWidget("Unowned").Show(false);
  406. }
  407. }
  408. void SetCharacterAlive(string char_alive)
  409. {
  410. if (char_alive == "")
  411. m_ServerCharacterAlive.SetText("#STR_server_browser_char_not_alive");
  412. else
  413. m_ServerCharacterAlive.SetText(char_alive);
  414. }
  415. void SetFriends(string friends_text)
  416. {
  417. m_ServerFriends.SetText(friends_text);
  418. }
  419. void SetMode(int mode)
  420. {
  421. string text;
  422. switch (mode)
  423. {
  424. case 0:
  425. {
  426. text = "#server_browser_entry_person_both";
  427. break;
  428. }
  429. case 1:
  430. {
  431. text = "#server_browser_entry_person_first";
  432. break;
  433. }
  434. }
  435. m_ServerMode.SetText(text);
  436. }
  437. void SetBattleye(bool battleye)
  438. {
  439. if (battleye)
  440. {
  441. m_ServerBattleye.SetText("#server_browser_entry_enabled");
  442. m_ServerBattleye.SetColor(ARGBF(1, 0, 1, 0));
  443. }
  444. else
  445. {
  446. m_ServerBattleye.SetText("#server_browser_entry_disabled");
  447. m_ServerBattleye.SetColor(ARGBF(1, 1, 0, 0));
  448. }
  449. }
  450. void SetIP(string ip)
  451. {
  452. m_ServerIP.SetText(ip);
  453. }
  454. string GetIP()
  455. {
  456. return m_ServerData.GetIP();
  457. }
  458. int GetPort()
  459. {
  460. return m_ServerData.m_HostPort;
  461. }
  462. int GetSteamQueryPort()
  463. {
  464. return m_ServerData.m_SteamQueryPort;
  465. }
  466. string GetServerID()
  467. {
  468. return m_ServerData.m_Id;
  469. }
  470. string GetMapToRun()
  471. {
  472. return m_ServerData.m_MapNameToRun;
  473. }
  474. void SetFavorite(bool favorite)
  475. {
  476. m_IsFavorited = favorite;
  477. m_Root.FindAnyWidget("favorite_image").Show(favorite);
  478. m_Root.FindAnyWidget("unfavorite_image").Show(!favorite);
  479. }
  480. void SetAcceleration(float mult)
  481. {
  482. if (mult > 1)
  483. {
  484. m_ServerAcceleration.Show(true);
  485. m_ServerAcceleration.SetText(mult.ToString() + "x");
  486. }
  487. else
  488. {
  489. m_ServerAcceleration.Show(false);
  490. }
  491. }
  492. void SetModded(bool is_modded)
  493. {
  494. m_ServerModIcon.Show(is_modded);
  495. }
  496. void SetServerMapName()
  497. {
  498. string displayValue = "-";
  499. if (IsOnline())
  500. {
  501. displayValue = ServerBrowserHelperFunctions.GetMapDisplayName(m_ServerData.m_MapNameToRun);
  502. }
  503. m_ServerMap.SetText(displayValue);
  504. }
  505. void SetMods(array<string> mods)
  506. {
  507. m_Mods = mods;
  508. if (mods && mods.Count() > 0)
  509. {
  510. string mods_text = mods[0];
  511. for (int i = 1; i < mods.Count(); i++)
  512. mods_text += ", " + mods[i];
  513. m_ServerMods.SetText(mods_text);
  514. }
  515. #ifdef PLATFORM_WINDOWS
  516. m_ServerModsExpand.Show((mods && mods.Count() > 0));
  517. #endif
  518. }
  519. void SetMouseAndKeyboard(bool is_mkenabled)
  520. {
  521. m_ServerMaKIcon.Show(is_mkenabled);
  522. }
  523. void SetIsOnline(bool isOnline)
  524. {
  525. m_IsOnline = isOnline;
  526. }
  527. bool ToggleFavorite()
  528. {
  529. m_IsFavorited = !m_IsFavorited;
  530. string ip = m_ServerData.GetIP();
  531. #ifdef PLATFORM_WINDOWS
  532. //Save Data PC
  533. m_Tab.GetRootMenu().AddFavorite(ip, m_ServerData.m_SteamQueryPort, m_IsFavorited);
  534. #ifdef PLATFORM_CONSOLE
  535. OnlineServices.SetServerFavorited(ip, 0, m_ServerData.m_SteamQueryPort, m_IsFavorited);
  536. #else
  537. OnlineServices.SetServerFavorited(ip, m_ServerData.m_HostPort, m_ServerData.m_SteamQueryPort, m_IsFavorited);
  538. #endif
  539. #else
  540. //Save Data Console
  541. m_IsFavorited = m_Tab.GetRootMenu().SetFavoriteConsoles(ip, m_ServerData.m_HostPort, m_IsFavorited);
  542. //Refresh favorites server list when entry is unfavorited
  543. ServerBrowserFavoritesTabConsolePages sbf = ServerBrowserFavoritesTabConsolePages.Cast(m_Tab);
  544. if (!m_IsFavorited && sbf)
  545. {
  546. sbf.SetFavoriteChanged(true);
  547. sbf.RefreshServerList();
  548. }
  549. #endif
  550. m_Root.FindAnyWidget("unfavorite_image").Show(!m_IsFavorited);
  551. m_Root.FindAnyWidget("favorite_image").Show(m_IsFavorited);
  552. return m_IsFavorited;
  553. }
  554. bool ToggleExpand()
  555. {
  556. return SetExpand(!m_IsExpanded);
  557. }
  558. bool SetExpand(bool expand)
  559. {
  560. m_IsExpanded = expand;
  561. m_Root.FindAnyWidget("collapse_image").Show(m_IsExpanded);
  562. m_Root.FindAnyWidget("expand_image").Show(!m_IsExpanded);
  563. m_DetailedInfo.Show(m_IsExpanded);
  564. if (m_ServerData)
  565. {
  566. m_ServerData.m_IsExpanded = m_IsExpanded;
  567. }
  568. if (expand && m_FirstExpand)
  569. {
  570. if (m_ServerData.m_Modded)
  571. {
  572. OnlineServices.GetServerModList(m_ServerData.m_Id);
  573. }
  574. m_FirstExpand = false;
  575. }
  576. return m_IsExpanded;
  577. }
  578. void Select(bool notify = true)
  579. {
  580. if (!m_Selected)
  581. {
  582. if (notify)
  583. {
  584. m_Tab.SelectServer(this);
  585. }
  586. m_ServerData.m_IsSelected = true;
  587. m_Selected = true;
  588. }
  589. }
  590. void Deselect()
  591. {
  592. if (m_Selected)
  593. {
  594. m_ServerData.m_IsSelected = false;
  595. m_Selected = false;
  596. Lighten(m_Root, null, 0, 0);
  597. }
  598. }
  599. void UpdateColors()
  600. {
  601. float alpha = 1;
  602. int maxPlayers = m_ServerData.m_MaxPlayers;
  603. int whiteColor = ARGBF(1, 1, 1, 1);
  604. int populationColor = whiteColor;
  605. int populationOutline = 1;
  606. if (IsOnline())
  607. {
  608. if (maxPlayers > 0)
  609. {
  610. int population = m_ServerData.m_CurrentNumberPlayers;
  611. float pop_percentage = population / maxPlayers;
  612. if (pop_percentage >= 1)
  613. {
  614. populationColor = ARGBF(1, 1, 0, 0);
  615. }
  616. else if (pop_percentage >= 0.8)
  617. {
  618. populationColor = ARGBF(1, 1, 0.5, 0);
  619. }
  620. }
  621. }
  622. else
  623. {
  624. alpha = 0.5;
  625. populationOutline = 0;
  626. m_ServerPing.SetColor(whiteColor);
  627. }
  628. m_ServerTime.Show(IsOnline());
  629. m_ServerName.SetColor(whiteColor);
  630. m_ServerName.SetAlpha(alpha);
  631. m_ServerPopulation.SetBold(IsOnline());
  632. m_ServerPopulation.SetColor(populationColor);
  633. m_ServerPopulation.SetOutline(populationOutline);
  634. m_ServerPopulation.SetAlpha(alpha);
  635. m_ServerSlots.SetAlpha(alpha);
  636. m_ServerPing.SetAlpha(alpha);
  637. m_Root.SetAlpha(alpha);
  638. }
  639. //Coloring functions (Until WidgetStyles are useful)
  640. void Preview(Widget w, int x, int y)
  641. {
  642. if (m_Selected)
  643. return;
  644. switch (w)
  645. {
  646. case m_Root:
  647. case m_Favorite:
  648. {
  649. m_Root.SetColor(ARGB(255, 0, 0, 0));
  650. m_Root.SetAlpha(1);
  651. UpdateColors();
  652. m_ServerName.SetColor(ARGB(255, 255, 0, 0));
  653. if (!IsOnline())
  654. {
  655. m_ServerName.SetAlpha(0.5);
  656. }
  657. break;
  658. }
  659. }
  660. }
  661. //Coloring functions (Until WidgetStyles are useful)
  662. void Darken(Widget w, int x, int y)
  663. {
  664. if (m_Selected)
  665. return;
  666. switch (w)
  667. {
  668. case m_Root:
  669. case m_Favorite:
  670. {
  671. m_Root.SetColor(ARGB(255, 200, 0, 0));
  672. SetPopulationEx(m_ServerData);
  673. UpdateColors();
  674. break;
  675. }
  676. }
  677. }
  678. void Lighten(Widget w, Widget enterW, int x, int y)
  679. {
  680. float alpha = 0.3;
  681. if (GetFocus() == w || m_Selected)
  682. {
  683. return;
  684. }
  685. if (w == m_Root && (m_Favorite && enterW == m_Favorite))
  686. {
  687. return;
  688. }
  689. m_Root.SetColor(ARGB(255, 0, 0, 0));
  690. SetPopulationEx(m_ServerData);
  691. UpdateColors();
  692. if (m_Index % 2)
  693. {
  694. alpha = 0;
  695. }
  696. m_Root.SetAlpha(alpha);
  697. }
  698. GetServersResultRow GetServerData()
  699. {
  700. return m_ServerData;
  701. }
  702. // DEPRECATED
  703. string GetMapName();
  704. // DEPRECATED
  705. void SetMapName(string mapName);
  706. // DEPRECATED
  707. void SetPopulation(int population, int slots);
  708. }