Advertisement
Guest User

Untitled

a guest
Jul 28th, 2015
376
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 253.96 KB | None | 0 0
  1. //#############################################################################
  2. //#
  3. //# Return to Blockland - Version 4
  4. //#
  5. //# -------------------------------------------------------------------------
  6. //#
  7. //# $Rev: 494 $
  8. //# $Date: 2013-04-21 12:52:43 +0100 (Sun, 21 Apr 2013) $
  9. //# $Author: Ephialtes $
  10. //# $URL: http://svn.returntoblockland.com/code/trunk/modules/client/connectClient.cs $
  11. //#
  12. //# $Id: connectClient.cs 494 2013-04-21 11:52:43Z Ephialtes $
  13. //#
  14. //# Copyright (c) 2008 - 2010 by Nick "Ephialtes" Matthews
  15. //#
  16. //# -------------------------------------------------------------------------
  17. //#
  18. //# Modules / Client / Connect Client
  19. //#
  20. //#############################################################################
  21. //Register that this module has been loaded
  22. $RTB::Modules::Client::ConnectClient = 1;
  23.  
  24. //*********************************************************
  25. //* Variable Declarations
  26. //*********************************************************
  27. $RTB::MCCC::Server = "connect.returntoblockland.com";
  28. $RTB::MCCC::Port = 14000;
  29.  
  30. //*********************************************************
  31. //* Sound Profiles
  32. //*********************************************************
  33. if(!isObject(RTBCC_TickSound))
  34. new AudioProfile(RTBCC_TickSound)
  35. {
  36. fileName = $RTB::Path@"sounds/tick.wav";
  37. description = "AudioGui";
  38. preload = "1";
  39. };
  40.  
  41. if(!isObject(RTBCC_OnlineSound))
  42. new AudioProfile(RTBCC_OnlineSound)
  43. {
  44. fileName = $RTB::Path@"sounds/boop1.wav";
  45. description = "AudioGui";
  46. preload = "1";
  47. };
  48.  
  49. if(!isObject(RTBCC_MessageSound))
  50. new AudioProfile(RTBCC_MessageSound)
  51. {
  52. fileName = $RTB::Path@"sounds/beep1.wav";
  53. description = "AudioGui";
  54. preload = "1";
  55. };
  56.  
  57. if(!isObject(RTBCC_JoinSound))
  58. new AudioProfile(RTBCC_JoinSound)
  59. {
  60. fileName = $RTB::Path@"sounds/beep2.wav";
  61. description = "AudioGui";
  62. preload = "1";
  63. };
  64.  
  65. //*********************************************************
  66. //* Connect Client GUI Interaction
  67. //********************************************************
  68. //- RTB_ConnectClient::onWake (gui on wake callback)
  69. function RTB_ConnectClient::onWake(%this)
  70. {
  71. %this.resetCursor();
  72.  
  73. %this.prepare();
  74. %this.setAvatar();
  75. }
  76.  
  77. //- RTB_ConnectClient::escape (call for people who close the client)
  78. function RTB_ConnectClient::escape(%this,%direct)
  79. {
  80. if(!%direct)
  81. {
  82. if(RTBCC_Modal.isVisible())
  83. {
  84. %this.closeModalWindow();
  85. return;
  86. }
  87. }
  88. RTB_Overlay.pop(%this);
  89. }
  90.  
  91. //- RTB_ConnectClient::init (prepares connect client for usage)
  92. function RTB_ConnectClient::init(%this)
  93. {
  94. if(!RTBCC_Avatar.hasBeenSet)
  95. {
  96. RTBCC_Avatar.setObject("","base/data/shapes/player/m.dts","",100);
  97. RTBCC_Avatar.hasBeenSet = 1;
  98. }
  99. RTB_ConnectClient.setDetails();
  100.  
  101. if(isObject(RTBCC_Socket))
  102. {
  103. RTBCC_Socket.disconnect();
  104. RTBCC_Socket.parser.delete();
  105. RTBCC_Socket.delete();
  106. }
  107. RTBCC_createInputRecycler();
  108. RTBCC_createRoomOptionsManager();
  109. RTBCC_createNotificationManager();
  110.  
  111. %socket = new TCPObject(RTBCC_Socket)
  112. {
  113. connected = 0;
  114. authenticated = 0;
  115.  
  116. trying = 0;
  117. tries = 0;
  118.  
  119. host = $RTB::MCCC::Server;
  120. port = $RTB::MCCC::Port;
  121.  
  122. token = 0;
  123.  
  124. roster = RTBCC_createRoster();
  125. tempRoster = RTBCC_createTempRoster();
  126. roomManager = RTBCC_createRoomManager();
  127. inviteRoster = RTBCC_createInviteRoster();
  128. sessionManager = RTBCC_createSessionManager();
  129. roomSessionManager = RTBCC_createRoomSessionManager();
  130.  
  131. version = 2;
  132. };
  133. RTBGroup.add(%socket);
  134.  
  135. %parser = new ScriptGroup(RTBCC_XMLParser)
  136. {
  137. class = "XMLParser";
  138. };
  139. %socket.parser = %parser;
  140. RTBGroup.add(%parser);
  141.  
  142. %parser.registerHandler("error","RTBCC_Socket::onErrorPacket",%socket);
  143. %parser.registerHandler("success","RTBCC_Socket::onErrorPacket",%socket);
  144. %parser.registerHandler("response","RTBCC_Socket::onErrorPacket",%socket);
  145.  
  146. %parser.registerHandler("notice","RTBCC_Socket::onNoticePacket",%socket);
  147. %parser.registerHandler("auth","RTBCC_Socket::onAuthPacket",%socket);
  148. %parser.registerHandler("roster","RTBCC_Socket::onRosterPacket",%socket);
  149. %parser.registerHandler("presence","RTBCC_Socket::onPresencePacket",%socket);
  150. %parser.registerHandler("message","RTBCC_Socket::onMessagePacket",%socket);
  151. %parser.registerHandler("action","RTBCC_Socket::onActionPacket",%socket);
  152.  
  153. %parser.registerHandler("ping","RTBCC_Socket::onPingPacket",%socket);
  154. %parser.registerHandler("disconnect","RTBCC_Socket::onDisconnectPacket",%socket);
  155. }
  156.  
  157. //- RTB_ConnectClient::setDetails (updates the details in the gui)
  158. function RTB_ConnectClient::setDetails(%this)
  159. {
  160. %this.client_id = getNumKeyID();
  161. %this.client_name = $pref::Player::NetName;
  162.  
  163. RTBCC_NetName.setText("<color:666666><font:Impact:18>"@%this.client_name);
  164. RTBCC_BLID.setText("<color:888888><font:Arial:12>Blockland ID "@%this.client_id);
  165. }
  166.  
  167. //- RTB_ConnectClient::changeStatus (opens status changing modal)
  168. function RTB_ConnectClient::changeStatus(%this)
  169. {
  170. if(RTBCC_Socket.connected && RTBCC_Socket.authenticated)
  171. RTB_ConnectClient.setModalWindow("ChangeStatus");
  172. }
  173.  
  174. //- RTB_ConnectClient::setStatus (sets the user's status)
  175. function RTB_ConnectClient::setStatus(%this,%status,%update)
  176. {
  177. if(%status $= "online")
  178. {
  179. RTBCC_StatusIcon.setBitmap($RTB::Path@"images/icons/status_online");
  180. RTBCC_StatusText.setText("<font:Verdana:12><color:777777>Online<bitmap:"@$RTB::Path@"images/icons/bullet_arrow_down>");
  181. }
  182. else if(%status $= "away")
  183. {
  184. RTBCC_StatusIcon.setBitmap($RTB::Path@"images/icons/status_away");
  185. RTBCC_StatusText.setText("<font:Verdana:12><color:777777>Away<bitmap:"@$RTB::Path@"images/icons/bullet_arrow_down>");
  186. }
  187. else if(%status $= "busy")
  188. {
  189. RTBCC_StatusIcon.setBitmap($RTB::Path@"images/icons/status_busy");
  190. RTBCC_StatusText.setText("<font:Verdana:12><color:777777>Busy<bitmap:"@$RTB::Path@"images/icons/bullet_arrow_down>");
  191. }
  192. else if(%status $= "hidden")
  193. {
  194. RTBCC_StatusIcon.setBitmap($RTB::Path@"images/icons/status_offline");
  195. RTBCC_StatusText.setText("<font:Verdana:12><color:777777>Hidden<bitmap:"@$RTB::Path@"images/icons/bullet_arrow_down>");
  196. }
  197. else
  198. {
  199. RTBCC_StatusIcon.setBitmap($RTB::Path@"images/icons/status_offline");
  200. RTBCC_StatusText.setText("<font:Verdana:12><color:777777>Offline");
  201. }
  202.  
  203. if(%update)
  204. {
  205. RTBCC_Socket.sendStatus(%status);
  206.  
  207. RTB_ConnectClient.closeModalWindow();
  208. }
  209. }
  210.  
  211. //- RTB_ConnectClient::setAvatar (sets the user's avatar)
  212. function RTB_ConnectClient::setAvatar(%this)
  213. {
  214. if($hat0 $= "")
  215. {
  216. AvatarGui.onWake();
  217.  
  218. //@HACK
  219. // - If the mdts tssconstructor exists as datablocks are loaded, explosions occur
  220. deleteDatablocks();
  221. }
  222.  
  223. RTBCC_Avatar.forceFOV = 18;
  224. RTBCC_Avatar.setOrbitDist(6);
  225. RTBCC_Avatar.setCameraRot(0.22,0.5,2.8);
  226. RTBCC_Avatar.lightDirection = "0 0.2 0.2";
  227.  
  228. %face = $Pref::Avatar::FaceName;
  229. %skincolor = $Pref::Avatar::HeadColor;
  230. %hat = $Pref::Avatar::Hat;
  231. %hatColor = $Pref::Avatar::HatColor;
  232. %accent = $Pref::Avatar::Accent;
  233. %accentColor = $Pref::Avatar::AccentColor;
  234. %chest = $Pref::Avatar::Chest;
  235. %chestColor = $Pref::Avatar::TorsoColor;
  236. %arm = $Pref::Avatar::LArm;
  237. %armColor = $pref::Avatar::LArmColor;
  238. %chestDecal = $Pref::Avatar::DecalName;
  239. %pack = $pref::Avatar::Pack;
  240. %packColor = $pref::Avatar::PackColor;
  241. %secondPack = $Pref::Avatar::SecondPack;
  242. %secondPackColor = $pref::Avatar::SecondPackColor;
  243.  
  244. %i=0;
  245. while($face[%i] !$= "")
  246. {
  247. if($face[%i] $= %face)
  248. {
  249. %face = %i;
  250. break;
  251. }
  252. %i++;
  253.  
  254. if(%i > 500)
  255. break;
  256. }
  257.  
  258. %i=0;
  259. while($decal[%i] !$= "")
  260. {
  261. if($decal[%i] $= %chestDecal)
  262. {
  263. %chestDecal = %i;
  264. break;
  265. }
  266. %i++;
  267.  
  268. if(%i > 500)
  269. break;
  270. }
  271.  
  272. %parts = "accent hat chest pack secondpack larm rarm lhand rhand hip lleg rleg";
  273. for(%i=0;%i<getWordCount(%parts);%i++)
  274. {
  275. %k = 0;
  276. eval("%partName = $"@getWord(%parts,%i)@%k@";");
  277. while(%partName !$= "")
  278. {
  279. if(%partName !$= "none")
  280. RTBCC_Avatar.hidenode("",%partName);
  281. eval("%partName = $"@getWord(%parts,%i)@%k++@";");
  282. %b++;
  283. }
  284. }
  285.  
  286. RTBCC_Avatar.setNodeColor("","ALL",%skinColor);
  287. RTBCC_Avatar.setIFLFrame("","face",%face);
  288. RTBCC_Avatar.setIFLFrame("","decal",%chestDecal);
  289.  
  290. if(%hat !$= "" && %hat !$= 0)
  291. {
  292. RTBCC_Avatar.unhidenode("",$hat[%hat]);
  293. RTBCC_Avatar.setnodeColor("",$hat[%hat],%hatColor);
  294.  
  295. %accent = getWord($accentsAllowed[$hat[%hat]],%accent);
  296. if(%accent !$= "" && %accent !$= "none")
  297. {
  298. RTBCC_Avatar.unhidenode("",%accent);
  299. RTBCC_Avatar.setnodeColor("",%accent,%accentColor);
  300. }
  301. }
  302.  
  303. if(%pack !$= "" && %pack !$= 0)
  304. {
  305. RTBCC_Avatar.unhidenode("",$pack[%pack]);
  306. RTBCC_Avatar.setnodeColor("",$pack[%pack],%packColor);
  307. }
  308. if(%secondpack !$= "" && %secondpack !$= 0)
  309. {
  310. RTBCC_Avatar.unhidenode("",$secondpack[%secondpack]);
  311. RTBCC_Avatar.setnodeColor("",$secondpack[%secondpack],%secondpackColor);
  312. }
  313. RTBCC_Avatar.unhidenode("",$chest[%chest]);
  314. RTBCC_Avatar.setNodeColor("",$chest[%chest],%chestColor);
  315. RTBCC_Avatar.unhidenode("",$larm[%arm]);
  316. RTBCC_Avatar.setNodeColor("",$larm[%arm],%armColor);
  317. RTBCC_Avatar.unhidenode("",$rarm[%arm]);
  318. RTBCC_Avatar.setNodeColor("",$rarm[%arm],%armColor);
  319.  
  320. RTBCC_Avatar.setMouse(0,0);
  321. }
  322.  
  323. //- RTB_ConnectClient::enableInterface (enables buttons on the roster interface)
  324. function RTB_ConnectClient::enableInterface(%this)
  325. {
  326. RTBCC_Tab_Roster.setActive(true);
  327. RTBCC_Tab_Chat.setActive(true);
  328. RTBCC_Tab_Options.setActive(true);
  329.  
  330. RTBCC_Connect.setVisible(false);
  331. RTBCC_Disconnect.setVisible(true);
  332. }
  333.  
  334. //- RTB_ConnectClient::disableInterface (disables buttons on the roster interface)
  335. function RTB_ConnectClient::disableInterface(%this)
  336. {
  337. RTBCC_Tab_Roster.setActive(false);
  338. RTBCC_Tab_Chat.setActive(false);
  339. RTBCC_Tab_Options.setActive(false);
  340.  
  341. RTBCC_Connect.setVisible(true);
  342. RTBCC_Disconnect.setVisible(false);
  343.  
  344. %this.setPane(RTBCC_Window_Splash);
  345. }
  346.  
  347. //- RTB_ConnectClient::prepare (prepares the gui for usage)
  348. function RTB_ConnectClient::prepare(%this)
  349. {
  350. if(!RTBCC_Socket.connected)
  351. {
  352. %this.disableInterface();
  353. if(RTBCC_Socket.trying)
  354. {
  355. RTBCC_Disconnect.setVisible(true);
  356. RTBCC_Connect.setVisible(false);
  357. }
  358. }
  359. else
  360. %this.enableInterface();
  361. }
  362.  
  363. //- RTB_ConnectClient::resetCursor (finds the best place to put the cursor back to)
  364. function RTB_ConnectClient::resetCursor(%this)
  365. {
  366. %lastActive = RTB_Overlay.getObject(RTB_Overlay.getCount()-1);
  367. if(%lastActive.session)
  368. %lastActive.session.focus();
  369. }
  370.  
  371. //- RTB_ConnectClient::onSleep (gui on sleep callback)
  372. function RTB_ConnectClient::onSleep(%this)
  373. {
  374. }
  375.  
  376. //- RTB_ConnectClient::setPane (sets the pane for the gui)
  377. function RTB_ConnectClient::setPane(%this,%pane)
  378. {
  379. if(%this.currPane $= %pane && %this.currPane.isVisible())
  380. return;
  381.  
  382. RTBCC_Window_Splash.setVisible(false);
  383. RTBCC_Window_Roster.setVisible(false);
  384. RTBCC_Window_Chat.setVisible(false);
  385. RTBCC_Window_Options.setVisible(false);
  386.  
  387. if(isObject(%this.currPane) && %this.currPane.getID() !$= %pane.getID())
  388. eval(%this.currPane.getName()@"::onSleep("@%this.currPane@");");
  389.  
  390. if(isObject(%pane))
  391. {
  392. %this.currPane = %pane;
  393. %pane.setVisible(true);
  394. eval(%pane@"::onWake("@%pane@");");
  395. }
  396. }
  397.  
  398. //*********************************************************
  399. //* Client Tab Callbacks and Management
  400. //********************************************************
  401. //- RTBCC_Window_Roster::onWake (on wake callback)
  402. function RTBCC_Window_Roster::onWake(%this)
  403. {
  404. }
  405.  
  406. //- RTBCC_Window_Roster::onSleep (on sleep callback)
  407. function RTBCC_Window_Roster::onSleep(%this)
  408. {
  409. }
  410.  
  411. //- RTBCC_Window_Chat::onWake (on wake callback)
  412. function RTBCC_Window_Chat::onWake(%this)
  413. {
  414. if(!%this.isVisible())
  415. return;
  416.  
  417. if(RTBCC_Socket.connected)
  418. RTBCC_RoomManager.refresh();
  419. }
  420.  
  421. //- RTBCC_Window_Chat::onSleep (on sleep callback)
  422. function RTBCC_Window_Chat::onSleep(%this)
  423. {
  424. RTBCC_RoomManager.stopRefresh();
  425. }
  426.  
  427. //- RTBCC_Window_Options::registerGroup (registers a group for the options menu)
  428. function RTBCC_Window_Options::registerGroup(%this,%name,%icon)
  429. {
  430. if(%this.group[%name])
  431. return;
  432.  
  433. %this.group[%this.groups] = %name TAB %icon;
  434. %this.group[%name] = 1;
  435. %this.groups++;
  436. }
  437.  
  438. //- RTBCC_Window_Options::registerPref (registers a pref for the options menu)
  439. function RTBCC_Window_Options::registerPref(%this,%name,%group,%pref,%type)
  440. {
  441. if(%this.pref[%pref])
  442. return;
  443.  
  444. %this.pref[%this.prefs] = %name TAB %type;
  445. %this.pref[%pref] = 1;
  446. %this.prefToStore[%this.prefs] = %pref;
  447. %this.prefToGroup[%this.prefs] = %group;
  448. %this.prefs++;
  449. }
  450.  
  451. //- RTBCC_Window_Options::onWake (on wake callback, loads cc prefs)
  452. function RTBCC_Window_Options::onWake(%this)
  453. {
  454. if(!%this.isVisible())
  455. return;
  456.  
  457. %pointer = "0 0";
  458. RTBCC_Options_Swatch.clear();
  459. for(%i=0;%i<%this.groups;%i++)
  460. {
  461. %groupName = getField(%this.group[%i],0);
  462. %icon = getField(%this.group[%i],1);
  463.  
  464. %icon = new GuiBitmapCtrl()
  465. {
  466. position = vectorAdd(%pointer,"6 2");
  467. extent = "16 16";
  468. bitmap = $RTB::Path@"images/icons/"@%icon;
  469. };
  470. RTBCC_Options_Swatch.add(%icon);
  471.  
  472. %text = new GuiMLTextCtrl()
  473. {
  474. position = vectorAdd(%pointer,"26 4");
  475. extent = "150 12";
  476. text = "<font:Verdana Bold:12><color:444444>"@%groupName;
  477. selectable = false;
  478. };
  479. RTBCC_Options_Swatch.add(%text);
  480.  
  481. %divider = new GuiBitmapCtrl()
  482. {
  483. position = vectorAdd(%pointer,"4 20");
  484. extent = "175 3";
  485. bitmap = $RTB::Path@"images/ui/dottedLine";
  486. wrap = true;
  487. };
  488. RTBCC_Options_Swatch.add(%divider);
  489.  
  490. %pointer = vectorAdd(%pointer,"0 27");
  491.  
  492. for(%j=0;%j<%this.prefs;%j++)
  493. {
  494. if(%this.prefToGroup[%j] !$= %groupName)
  495. continue;
  496.  
  497. %name = getField(%this.pref[%j],0);
  498. %type = getField(%this.pref[%j],1);
  499.  
  500. if(%type $= "bool")
  501. {
  502. %text = new GuiMLTextCtrl()
  503. {
  504. position = vectorAdd(%pointer,"7 1");
  505. extent = "155 12";
  506. text = "<color:888888><font:Verdana:12>"@%name;
  507. selectable = false;
  508. };
  509. RTBCC_Options_Swatch.add(%text);
  510.  
  511. %box = new GuiCheckboxCtrl()
  512. {
  513. profile = "RTB_CheckboxProfile";
  514. position = vectorAdd(%pointer,"163 0");
  515. extent = "16 16";
  516. text = " ";
  517. pref = %j;
  518. prefName = %this.prefToStore[%j];
  519. prefValue = 1;
  520. command = %this@".done();";
  521. };
  522. RTBCC_Options_Swatch.add(%box);
  523.  
  524. if(RTBCO_getPref(%this.prefToStore[%j]) $= 1)
  525. %box.setValue(1);
  526.  
  527. %pointer = vectorAdd(%pointer,"0 17");
  528. }
  529. else
  530. {
  531. %parameters = getSubStr(%type,strPos(%type,"{")+1,strPos(%type,"}")-strPos(%type,"{")-1);
  532. %type = getSubStr(%type,0,strPos(%type,":"));
  533. if(%type $= "list")
  534. {
  535. %text = new GuiMLTextCtrl()
  536. {
  537. position = vectorAdd(%pointer,"7 1");
  538. extent = "180 12";
  539. text = "<color:888888><font:Verdana:12>"@%name;
  540. selectable = false;
  541. };
  542. RTBCC_Options_Swatch.add(%text);
  543.  
  544. %pointer = vectorAdd(%pointer,"0 14");
  545.  
  546. %parameters = strReplace(%parameters,",","\t");
  547. for(%k=0;%k<getFieldCount(%parameters);%k++)
  548. {
  549. %param = getField(%parameters,%k);
  550. %name = getSubStr(%param,0,strPos(%param,":"));
  551. %value = getSubStr(%param,strPos(%param,":")+1,strLen(%param));
  552.  
  553. %text = new GuiMLTextCtrl()
  554. {
  555. position = vectorAdd(%pointer,"11 1");
  556. extent = "145 12";
  557. text = "<just:right><color:AAAAAA><font:Verdana:12>"@%name;
  558. selectable = false;
  559. };
  560. RTBCC_Options_Swatch.add(%text);
  561.  
  562. %box = new GuiRadioCtrl()
  563. {
  564. profile = "RTB_RadioButtonProfile";
  565. position = vectorAdd(%pointer,"163 0");
  566. extent = "16 16";
  567. text = " ";
  568. pref = %j;
  569. groupNum = %j;
  570. prefName = %this.prefToStore[%j];
  571. prefValue = %value;
  572. command = %this@".schedule(1,\"done\");";
  573. };
  574. RTBCC_Options_Swatch.add(%box);
  575.  
  576. if(RTBCO_getPref(%this.prefToStore[%j]) $= %value)
  577. %box.performClick();
  578.  
  579. %pointer = vectorAdd(%pointer,"0 16");
  580. }
  581. }
  582. else if(%type $= "multibool")
  583. {
  584. %text = new GuiMLTextCtrl()
  585. {
  586. position = vectorAdd(%pointer,"7 1");
  587. extent = "180 12";
  588. text = "<color:888888><font:Verdana:12>"@%name;
  589. selectable = false;
  590. };
  591. RTBCC_Options_Swatch.add(%text);
  592.  
  593. %pointer = vectorAdd(%pointer,"0 14");
  594.  
  595. %parameters = strReplace(%parameters,",","\t");
  596. for(%k=0;%k<getFieldCount(%parameters);%k++)
  597. {
  598. %param = getField(%parameters,%k);
  599. %name = getSubStr(%param,0,strPos(%param,":"));
  600. %prefAppend = getSubStr(%param,strPos(%param,":")+1,strLen(%param));
  601.  
  602. %text = new GuiMLTextCtrl()
  603. {
  604. position = vectorAdd(%pointer,"11 1");
  605. extent = "145 12";
  606. text = "<just:right><color:AAAAAA><font:Verdana:12>"@%name;
  607. selectable = false;
  608. };
  609. RTBCC_Options_Swatch.add(%text);
  610.  
  611. %box = new GuiCheckboxCtrl()
  612. {
  613. profile = "RTB_CheckboxProfile";
  614. position = vectorAdd(%pointer,"163 0");
  615. extent = "16 16";
  616. text = " ";
  617. pref = %j;
  618. prefName = %this.prefToStore[%j]@%prefAppend;
  619. prefValue = 1;
  620. command = %this@".done();";
  621. };
  622. RTBCC_Options_Swatch.add(%box);
  623.  
  624. if(RTBCO_getPref(%this.prefToStore[%j]@%prefAppend) $= 1)
  625. %box.setValue(1);
  626.  
  627. %pointer = vectorAdd(%pointer,"0 16");
  628. }
  629. }
  630. %pointer = vectorAdd(%pointer,"0 1");
  631. }
  632. }
  633. %pointer = vectorAdd(%pointer,"0 5");
  634. }
  635. RTBCC_Options_Swatch.resize(1,1,194,getWord(%pointer,1));
  636. }
  637.  
  638. //- RTBCC_Window_Options::onSleep (on sleep callback, saves cc prefs)
  639. function RTBCC_Window_Options::onSleep(%this)
  640. {
  641. }
  642.  
  643. //- RTBCC_Window_Options::done (saves all the preferences set)
  644. function RTBCC_Window_Options::done(%this)
  645. {
  646. for(%i=0;%i<RTBCC_Options_Swatch.getCount();%i++)
  647. {
  648. %ctrl = RTBCC_Options_Swatch.getObject(%i);
  649. if(%ctrl.getClassName() $= "GuiCheckboxCtrl")
  650. {
  651. if(%ctrl.getValue() $= 1)
  652. RTBCO_setPref(%ctrl.prefName,%ctrl.prefValue);
  653. else
  654. RTBCO_setPref(%ctrl.prefName,0);
  655. }
  656. else if(%ctrl.getClassName() $= "GuiRadioCtrl")
  657. {
  658. if(%ctrl.getValue() $= 1)
  659. RTBCO_setPref(%ctrl.prefName,%ctrl.prefValue);
  660. }
  661. }
  662. RTBCO_Save();
  663.  
  664. if(RTBCC_Socket.authenticated)
  665. RTBCC_Socket.sendPrefs();
  666.  
  667. if(RTBCO_getPref("CC::SeparateOffline"))
  668. {
  669. %group = RTBCC_Roster.getGroupByName("Offline Users");
  670. if(%group.getCount() <= 0)
  671. {
  672. for(%i=0;%i<RTBCC_Roster.getCount();%i++)
  673. {
  674. %group = RTBCC_Roster.getObject(%i);
  675. if(%group.name $= "Offline Users" || %group.name $= "Your Invites")
  676. continue;
  677.  
  678. for(%j=%group.getCount()-1;%j>=0;%j--)
  679. {
  680. if(!%group.getObject(%j).online)
  681. %group.getObject(%j).moveToGroup("Offline Users");
  682. }
  683. }
  684. }
  685. }
  686. else
  687. {
  688. %group = RTBCC_Roster.getGroupByName("Offline Users");
  689. while(%group.getCount() > 0)
  690. %group.getObject(0).moveToGroup(%group.getObject(0).group.name);
  691. }
  692. }
  693.  
  694. //- RTBCC_Window_Splash::onSleep (on sleep callback)
  695. function RTBCC_Window_Splash::onWake(%this)
  696. {
  697. }
  698.  
  699. //- RTBCC_Window_Splash::onSleep (on sleep callback)
  700. function RTBCC_Window_Splash::onSleep(%this)
  701. {
  702. }
  703.  
  704. //*********************************************************
  705. //* Register Settings
  706. //*********************************************************
  707. // Groups
  708. RTBCC_Window_Options.registerGroup("General","wrench");
  709. RTBCC_Window_Options.registerGroup("Interface","monitor");
  710. RTBCC_Window_Options.registerGroup("Privacy","user_delete");
  711. RTBCC_Window_Options.registerGroup("Notifications","note");
  712. RTBCC_Window_Options.registerGroup("Special Options","pirate-captain_16");
  713.  
  714. // Settings
  715. RTBCC_Window_Options.registerPref("Automatically sign me in","General","CC::AutoSignIn","bool");
  716. RTBCC_Window_Options.registerPref("Enable interface sounds","General","CC::EnableSounds","bool");
  717. RTBCC_Window_Options.registerPref("Enable sticky notifications","General","CC::StickyNotifications","bool");
  718. RTBCC_Window_Options.registerPref("Enable chat logging","General","CC::ChatLogging","bool");
  719. RTBCC_Window_Options.registerPref("Separate offline users","Interface","CC::SeparateOffline","bool");
  720. RTBCC_Window_Options.registerPref("Show timestamps in chat","Interface","CC::ShowTimestamps","bool");
  721. RTBCC_Window_Options.registerPref("Save chatroom positions","Interface","CC::SavePositions","bool");
  722. RTBCC_Window_Options.registerPref("People who can send me an invite","Privacy","CC::InviteReq","list:{Anyone:0,People with build trust:1,People with full trust:2,Nobody at all:3}");
  723. RTBCC_Window_Options.registerPref("Allow anyone to see my server","Privacy","CC::ShowServer","bool");
  724. RTBCC_Window_Options.registerPref("Allow anyone to message me","Privacy","CC::AllowPM","bool");
  725. RTBCC_Window_Options.registerPref("Accept server invitations","Privacy","CC::AllowInvites","bool");
  726. RTBCC_Window_Options.registerPref("When someone signs in ...","Notifications","CC::SignIn::","multibool:{Play a beep sound:Beep,Give me a popup message:Note}");
  727. RTBCC_Window_Options.registerPref("When someone messages me ...","Notifications","CC::Message::","multibool:{Play a beep sound:Beep,Give me a popup message:Note}");
  728. RTBCC_Window_Options.registerPref("When someone joins a server ...","Notifications","CC::Join::","multibool:{Play a beep sound:Beep,Give me a popup message:Note}");
  729.  
  730. // Arr
  731. RTBCC_Window_Options.registerPref("Enable Pirate Scallywag Mode","Special Options","CC::PirateMode","bool",0);
  732.  
  733. //*********************************************************
  734. //* GUI Modal Utilities
  735. //*********************************************************
  736. //- RTB_ConnectClient::setModalWindow (opens and sets the modal window required)
  737. function RTB_ConnectClient::setModalWindow(%this,%modal)
  738. {
  739. if(!%this.isOpen())
  740. RTB_Overlay.push(%this);
  741.  
  742. %group = RTBCC_Modal;
  743.  
  744. for(%i=0;%i<%group.getCount();%i++)
  745. {
  746. %group.getObject(%i).setVisible(false);
  747. }
  748.  
  749. if(%modal $= "")
  750. {
  751. %group.setVisible(false);
  752. return;
  753. }
  754. %group.setVisible(true);
  755. %this.pushToBack(%group);
  756.  
  757. %name = "RTBCC_Modal_"@%modal;
  758. if(isObject(%name))
  759. %name.setVisible(true);
  760. }
  761.  
  762. //- RTB_ConnectClient::closeModalWindow (closes the modal window)
  763. function RTB_ConnectClient::closeModalWindow(%this)
  764. {
  765. RTBCC_Modal.setVisible(false);
  766. }
  767.  
  768. //- RTB_ConnectClient::messageBox (opens a non-closeable message box)
  769. function RTB_ConnectClient::messageBox(%this,%title,%message)
  770. {
  771. %this.setModalWindow("Box");
  772. RTBCC_Modal_Box_Title.setText("<color:444444><font:Verdana Bold:12>"@%title);
  773. RTBCC_Modal_Box_Text.setText("<color:444444><font:Verdana:12>"@%message);
  774.  
  775. if(RTB_ConnectClient.isOpen())
  776. RTBCC_Modal_Box_Text.forceReflow();
  777. %textHeight = getWord(RTBCC_Modal_Box_Text.extent,1);
  778. %modalHeight = %textHeight+52;
  779.  
  780. if(%modalHeight < 91)
  781. %modalHeight = 91;
  782.  
  783. RTBCC_Modal_Box.resize(11,91,174,%modalHeight);
  784. RTBCC_Modal_Box.center();
  785. }
  786.  
  787. //- RTB_ConnectClient::messageBoxOK (opens an ok message box)
  788. function RTB_ConnectClient::messageBoxOK(%this,%title,%message,%ok)
  789. {
  790. %this.setModalWindow("BoxOK");
  791. RTBCC_Modal_BoxOK_Title.setText("<color:444444><font:Verdana Bold:12>"@%title);
  792. RTBCC_Modal_BoxOK_Text.setText("<color:444444><font:Verdana:12>"@%message);
  793. RTBCC_Modal_BoxOK_Ok.command = "RTB_ConnectClient.closeModalWindow();"@%ok;
  794. RTBCC_Modal_BoxOK_Ok_Accelerator.makeFirstResponder(1);
  795.  
  796. if(RTB_ConnectClient.isOpen())
  797. RTBCC_Modal_BoxOK_Text.forceReflow();
  798. %textHeight = getWord(RTBCC_Modal_BoxOK_Text.extent,1);
  799. %modalHeight = %textHeight+52;
  800.  
  801. if(%modalHeight < 91)
  802. %modalHeight = 91;
  803.  
  804. RTBCC_Modal_BoxOK.resize(11,91,174,%modalHeight);
  805. RTBCC_Modal_BoxOK.center();
  806. }
  807.  
  808. //- RTB_ConnectClient::messageBoxYesNo (opens a yes/no message box)
  809. function RTB_ConnectClient::messageBoxYesNo(%this,%title,%message,%yes,%no)
  810. {
  811. %this.setModalWindow("BoxYesNo");
  812. RTBCC_Modal_BoxYesNo_Title.setText("<color:444444><font:Verdana Bold:12>"@%title);
  813. RTBCC_Modal_BoxYesNo_Text.setText("<color:444444><font:Verdana:12>"@%message);
  814. RTBCC_Modal_BoxYesNo_Yes.command = "RTB_ConnectClient.closeModalWindow();"@%yes;
  815. RTBCC_Modal_BoxYesNo_No.command = "RTB_ConnectClient.closeModalWindow();"@%no;
  816.  
  817. if(RTB_ConnectClient.isOpen())
  818. RTBCC_Modal_BoxYesNo_Text.forceReflow();
  819. %textHeight = getWord(RTBCC_Modal_BoxYesNo_Text.extent,1);
  820. %modalHeight = %textHeight+52;
  821.  
  822. if(%modalHeight < 91)
  823. %modalHeight = 91;
  824.  
  825. RTBCC_Modal_BoxYesNo.resize(11,91,174,%modalHeight);
  826. RTBCC_Modal_BoxYesNo.center();
  827. }
  828.  
  829. //- RTB_ConnectClient::messageBoxError (opens an error message box)
  830. function RTB_ConnectClient::messageBoxError(%this,%title,%message,%ok)
  831. {
  832. %this.setModalWindow("BoxError");
  833. RTBCC_Modal_BoxError_Title.setText("<color:444444><font:Verdana Bold:12>"@%title);
  834. RTBCC_Modal_BoxError_Text.setText("<color:444444><font:Verdana:12>"@%message);
  835. RTBCC_Modal_BoxError_Ok.command = "RTB_ConnectClient.closeModalWindow();"@%ok;
  836. RTBCC_Modal_BoxError_Ok_Accelerator.makeFirstResponder(1);
  837.  
  838. if(RTB_ConnectClient.isOpen())
  839. RTBCC_Modal_BoxError_Text.forceReflow();
  840. %textHeight = getWord(RTBCC_Modal_BoxError_Text.extent,1);
  841. %modalHeight = %textHeight+52;
  842.  
  843. if(%modalHeight < 91)
  844. %modalHeight = 91;
  845.  
  846. RTBCC_Modal_BoxError.resize(11,91,174,%modalHeight);
  847. RTBCC_Modal_BoxError.center();
  848. }
  849.  
  850. //- RTBCC_Modal_JoinPassword::send (attemps to join a password server)
  851. function RTBCC_Modal_JoinPassword::send(%this)
  852. {
  853. if(isObject(ServerConnection))
  854. disconnect();
  855.  
  856. MJ_txtIP.setValue($RTB::MCCC::Cache::Joining);
  857. MJ_txtJoinPass.setValue(RTBCC_Modal_JoinPassword_Pass.getValue());
  858. MJ_connect();
  859.  
  860. RTBCC_Modal_JoinPassword_Pass.setValue("");
  861. RTB_ConnectClient.closeModalWindow();
  862. }
  863.  
  864. //*********************************************************
  865. //* GUI Interface Implementation
  866. //*********************************************************
  867. //- RTBCC_Window_Roster::addFriend (opens a window to subscribe to a user)
  868. function RTBCC_Window_Roster::addFriend(%this)
  869. {
  870. RTB_ConnectClient.setModalWindow("AddFriend");
  871. RTBCC_Modal_AddFriend_BLID.setValue("");
  872. RTBCC_Modal_AddFriend_BLID.makeFirstResponder(1);
  873. }
  874.  
  875. //- RTBCC_Modal_AddFriend::close (closes the modal window)
  876. function RTBCC_Modal_AddFriend::close(%this)
  877. {
  878. RTB_ConnectClient.closeModalWindow();
  879. RTBCC_Modal_AddFriend_BLID.setValue("");
  880. }
  881.  
  882. //- RTBCC_Modal_AddFriend::send (attempts to add the specified bl_id as a friend)
  883. function RTBCC_Modal_AddFriend::send(%this)
  884. {
  885. %bl_id = RTBCC_Modal_AddFriend_BLID.getValue();
  886. if(%bl_id $= "")
  887. {
  888. RTB_ConnectClient.messageBoxOK("Oops ...","You need to enter a Blockland ID into the box to add a friend!","RTBCC_Window_Roster.addFriend();");
  889. return;
  890. }
  891. if(RTBCC_Roster.hasID(%bl_id))
  892. {
  893. RTB_ConnectClient.messageBoxOK("Oops ...","You already have that person on your friends list! Try and think of another.","RTBCC_Window_Roster.addFriend();");
  894. return;
  895. }
  896. if(RTBCC_InviteRoster.hasID(%bl_id))
  897. {
  898. RTB_ConnectClient.messageBoxOK("Oops ...","You already have a friend invitation from this person. Maybe you should accept that instead.","RTBCC_Window_Roster.addFriend();");
  899. return;
  900. }
  901. if(%bl_id $= RTB_ConnectClient.client_id)
  902. {
  903. RTB_ConnectClient.messageBoxOK("Oops ...","You can't add yourself as a friend, that's cheating!","RTBCC_Window_Roster.addFriend();");
  904. return;
  905. }
  906.  
  907. if(mFloatLength(%bl_id, 0) !$= %bl_id)
  908. {
  909. RTB_ConnectClient.messageBoxOK("Oops ...","You can only enter numbers for a Blockland ID! Try again ...","RTBCC_Window_Roster.addFriend();");
  910. return;
  911. }
  912. RTBCC_Socket.addToRoster(%bl_id);
  913. RTB_ConnectClient.messageBox("Hold on a sec ...","Attempting to add "@%bl_id@" to your friends list ...");
  914. }
  915.  
  916. //- RTBCC_Window_Chat::addRoom (opens a window to create a room)
  917. function RTBCC_Window_Chat::addRoom(%this)
  918. {
  919. RTB_ConnectClient.messageBox("Creating Room ...","Your new room is being created.");
  920. RTB_ConnectClient.schedule(1500,"messageBoxError","Just Kidding","Creating your own chat rooms is still not available yet.<br><br>Keep an eye on the RTB Development forum thread for more information.<br><br><just:center><bitmap:add-ons/system_Returntoblockland/images/icons/hot-dog_16>");
  921. }
  922.  
  923. //- RTBCC_Window_Chat::refreshRooms (clears & refreshes room list)
  924. function RTBCC_Window_Chat::refreshRooms(%this)
  925. {
  926. RTBCC_Chat_Swatch.clear();
  927.  
  928. RTBCC_RoomManager.getRooms();
  929. }
  930.  
  931. //*********************************************************
  932. //* Connection Handling & Instantiation
  933. //*********************************************************
  934. //- RTBCC_Socket::onConnected (connected callback)
  935. function RTBCC_Socket::onConnected(%this)
  936. {
  937. //@DEBUG
  938. if($RTB::Debug)
  939. echo("\c4>> Connected");
  940.  
  941. %this.trying = 0;
  942. %this.connected = 1;
  943.  
  944. RTBCC_Roster_Loading.setStage(1);
  945. }
  946.  
  947. //- RTBCC_Socket::onConnectFailed (connect failed callback)
  948. function RTBCC_Socket::onConnectFailed(%this)
  949. {
  950. //@DEBUG
  951. if($RTB::Debug)
  952. echo("\c2>> Connect Failed");
  953.  
  954. RTBCC_Roster_Loading.setVisible(false);
  955. RTB_ConnectClient.messageBoxError("Connection Error","Connection to the RTB Connect server failed. Retrying ...","RTBCC_Socket.softDisconnect();");
  956.  
  957. %this.retry();
  958. }
  959.  
  960. //- RTBCC_Socket::onDNSFailed (dns failed callback)
  961. function RTBCC_Socket::onDNSFailed(%this)
  962. {
  963. //@DEBUG
  964. if($RTB::Debug)
  965. echo("\c2>> DNS Failed");
  966.  
  967. RTBCC_Roster_Loading.setVisible(false);
  968. RTB_ConnectClient.messageBoxError("Connection Error","Connection to the RTB Connect server failed. Retrying ...","RTBCC_Socket.softDisconnect();");
  969.  
  970. %this.retry();
  971. }
  972.  
  973. //- RTBCC_Socket::onLine (on line)
  974. function RTBCC_Socket::onLine(%this,%xml)
  975. {
  976. %xml = getASCIIString(%xml);
  977.  
  978. //@DEBUG
  979. if($RTB::Debug)
  980. echo("\c2>> ["@getDateTime()@"] "@strReplace(%xml,"\n",""));
  981.  
  982. %this.parser.bufferData(%xml);
  983. }
  984.  
  985. //- RTBCC_Socket::onDisconnect (on disconnected)
  986. function RTBCC_Socket::onDisconnect(%this)
  987. {
  988. //@DEBUG
  989. if($RTB::Debug)
  990. echo("\c2>> Disconnected");
  991.  
  992. %this.tries = 0;
  993. %this.trying = 0;
  994. %this.connected = 0;
  995. RTB_ConnectClient.setStatus("offline");
  996. RTB_ConnectClient.prepare();
  997.  
  998. RTBCC_Roster_Loading.setVisible(false);
  999. RTBCC_Modal.setVisible(false);
  1000.  
  1001. if(%this.authenticated && %this.disconnectType $= "")
  1002. {
  1003. RTB_ConnectClient.messageBoxError("Connection Lost","The connection with the server was lost. Retrying ...","RTBCC_Socket.softDisconnect();");
  1004. RTBCC_NotificationManager.push("Connection Lost","Lost connection to server.","delete");
  1005.  
  1006. %this.retry();
  1007. }
  1008. %this.disconnectType = "";
  1009. %this.authenticated = 0;
  1010.  
  1011. RTBCC_RoomSessionManager.destroy();
  1012. }
  1013.  
  1014. //*********************************************************
  1015. //* Connection Interaction
  1016. //*********************************************************
  1017. //- RTBCC_Socket::connect (connect to server)
  1018. function RTBCC_Socket::connect(%this)
  1019. {
  1020. if(%this.connected)
  1021. return;
  1022.  
  1023. //@DEBUG
  1024. if($RTB::Debug)
  1025. echo("\c4>> Connecting");
  1026.  
  1027. %this.trying = 1;
  1028. RTB_ConnectClient.prepare();
  1029.  
  1030. RTBCC_Modal.setVisible(false);
  1031.  
  1032. RTBCC_Roster_Loading.setVisible(true);
  1033. RTBCC_Roster_Loading.setStage(0);
  1034.  
  1035. %this.roster = RTBCC_createRoster();
  1036. %this.roomManager = RTBCC_createRoomManager();
  1037. %this.inviteRoster = RTBCC_createInviteRoster();
  1038. %this.sessionManager = RTBCC_createSessionManager();
  1039. %this.roomSessionManager = RTBCC_createRoomSessionManager();
  1040.  
  1041. Parent::connect(%this,%this.host@":"@%this.port);
  1042. }
  1043.  
  1044. //- RTBCC_Socket::retry (retries connection)
  1045. function RTBCC_Socket::retry(%this)
  1046. {
  1047. %this.tries++;
  1048.  
  1049. if(!%this.trying)
  1050. {
  1051. %this.trying = 1;
  1052. RTB_ConnectClient.prepare();
  1053. }
  1054. %this.retry = %this.schedule(5000,"connect");
  1055. }
  1056.  
  1057. //- RTBCC_Socket::softDisconnect (performs a soft disconnect)
  1058. function RTBCC_Socket::softDisconnect(%this)
  1059. {
  1060. if(isEventPending(%this.retry))
  1061. cancel(%this.retry);
  1062.  
  1063. if(%this.connected)
  1064. %this.sendXML("<disconnect />");
  1065. else
  1066. %this.hardDisconnect();
  1067. }
  1068.  
  1069. //- RTBCC_Socket::hardDisconnect (performs a hard disconnect)
  1070. function RTBCC_Socket::hardDisconnect(%this)
  1071. {
  1072. %this.disconnectType = "expected";
  1073.  
  1074. %this.disconnect();
  1075. %this.onDisconnect();
  1076. }
  1077.  
  1078. //- RTBCC_Socket::getToken (increments and returns token)
  1079. function RTBCC_Socket::getToken(%this)
  1080. {
  1081. %letters = "abcdefghijklmnopqrstuvwxyz";
  1082. for(%i=0;%i<4;%i++)
  1083. {
  1084. %token = %token@getSubStr(%letters,getRandom(0,strlen(%letters)-1),1);
  1085. }
  1086. return %token @ %this.token++;
  1087. }
  1088.  
  1089. //- RTBCC_Socket::sendXML (sends xml stream)
  1090. function RTBCC_Socket::sendXML(%this,%xml,%handler,%arg)
  1091. {
  1092. if(isObject(%xml))
  1093. {
  1094. if(%xml.attrib["id"] $= "")
  1095. {
  1096. %token = %this.getToken();
  1097. %xml.setAttribute("id",%token);
  1098.  
  1099. if(%handler !$= "")
  1100. %this.setPacketHandler(%token,%handler,%arg);
  1101. }
  1102. %xmlString = %xml.toString();
  1103.  
  1104. %xml.delete();
  1105. }
  1106. else
  1107. %xmlString = %xml;
  1108.  
  1109. //@DEBUG
  1110. if($RTB::Debug)
  1111. echo("\c4<< ["@getDateTime()@"] "@%xmlString);
  1112. %this.send(getUTF8String(%xmlString)@"\r\n");
  1113.  
  1114. return %token;
  1115. }
  1116.  
  1117. //*********************************************************
  1118. //* Incoming BLXS Packet Routing
  1119. //*********************************************************
  1120. //- RTBCC_Socket::setPacketHandler (registers a packet handler for packets with an id)
  1121. function RTBCC_Socket::setPacketHandler(%this,%token,%handler,%arg)
  1122. {
  1123. %this.tokenToHandler[%token] = %handler;
  1124. %this.tokenArgument[%token] = %arg;
  1125.  
  1126. return 1;
  1127. }
  1128.  
  1129. //- RTBCC_Socket::onNoticePacket (handles notice packets)
  1130. function RTBCC_Socket::onNoticePacket(%this,%parser,%packet)
  1131. {
  1132. if(%packet.attrib["from"] $= "system")
  1133. {
  1134. RTB_ConnectClient.messageBoxOK("System Notice",%packet.cData);
  1135. RTBCC_NotificationManager.push("System Notice","Open the overlay to read.","information","",-1);
  1136. return;
  1137. }
  1138.  
  1139. if(RTBCC_RoomSessionManager.hasRoom(%packet.attrib["from"]))
  1140. RTBCC_RoomSessionManager.getRoomByName(%packet.attrib["from"]).onNotice(%parser,%packet);
  1141. }
  1142.  
  1143. //- RTBCC_Socket::onAuthPacket (handles authentication packets)
  1144. function RTBCC_Socket::onAuthPacket(%this,%parser,%packet)
  1145. {
  1146. if(%packet.attrib["type"] $= "get")
  1147. %this.authenticate();
  1148.  
  1149. if(%packet.attrib["type"] $= "result")
  1150. {
  1151. if(%packet.find("success"))
  1152. {
  1153. RTBCC_Roster_Loading.setStage(2);
  1154. %this.authenticated = 1;
  1155.  
  1156. RTB_ConnectClient.setStatus("online");
  1157. RTB_ConnectClient.enableInterface();
  1158. RTBCC_Tab_Roster.performClick();
  1159.  
  1160. RTBCC_NotificationManager.push("Connected","You are now online.","star");
  1161.  
  1162. %this.sendPrefs();
  1163. RTBCC_Roster.load();
  1164. }
  1165. else if(%packet.find("fail"))
  1166. {
  1167. %this.hardDisconnect();
  1168. RTB_ConnectClient.messageBoxError("Login Error",%packet.find("fail").cData);
  1169. }
  1170. }
  1171. }
  1172.  
  1173. //- RTBCC_Socket::onRosterPacket (handles roster packets)
  1174. function RTBCC_Socket::onRosterPacket(%this,%parser,%packet)
  1175. {
  1176. if(%packet.attrib["type"] $= "get")
  1177. {
  1178. for(%i=0;%i<%packet.children;%i++)
  1179. {
  1180. %user = %packet.child[%i];
  1181. RTBCC_Roster.addUser(%user);
  1182. }
  1183.  
  1184. if(%packet.attrib["end"] $= "1")
  1185. {
  1186. RTBCC_Roster.loading = false;
  1187. RTBCC_Roster.render();
  1188.  
  1189. %this.sendPresenceProbe();
  1190. %this.getRoomList();
  1191.  
  1192. RTBCC_Roster_Loading.setVisible(false);
  1193. }
  1194. }
  1195. else if(%packet.attrib["type"] $= "add")
  1196. {
  1197. %user = RTBCC_Roster.addUser(%packet.child[0]);
  1198.  
  1199. if(!isObject(%user))
  1200. return;
  1201.  
  1202. if(%user.getGroup() !$= RTBCC_InviteRoster.getID())
  1203. %user.render();
  1204. }
  1205. else if(%packet.attrib["type"] $= "del")
  1206. {
  1207. %id = %packet.child[0].cData;
  1208.  
  1209. if(RTBCC_Roster.hasID(%id))
  1210. RTBCC_Roster.removeByID(%id);
  1211. else if(RTBCC_InviteRoster.hasID(%id))
  1212. RTBCC_InviteRoster.removeByID(%id);
  1213.  
  1214. if(RTBCC_SessionManager.hasID(%id))
  1215. {
  1216. %session = RTBCC_SessionManager.getByID(%id);
  1217. %session.writeNotice("You and "@%session.user.name@" are no longer friends.");
  1218. }
  1219. }
  1220. else if(%packet.attrib["type"] $= "block")
  1221. {
  1222. %id = %packet.child[0].cData;
  1223.  
  1224. if(RTBCC_Roster.hasID(%id))
  1225. {
  1226. %item = RTBCC_Roster.getByID(%id);
  1227. %item.state = "blocked";
  1228. %item.render();
  1229.  
  1230. if(RTBCC_SessionManager.hasID(%id) && RTBCC_SessionManager.getByID(%id).isRendered())
  1231. {
  1232. RTBCC_SessionManager.getByID(%id).writeNotice("You have blocked "@%item.name@".");
  1233. RTBCC_SessionManager.getByID(%id).setBlockedStatus(1);
  1234. RTBCC_SessionManager.getByID(%id).updateStatus(0);
  1235. }
  1236. }
  1237.  
  1238. if(RTBCC_TempRoster.hasID(%id))
  1239. {
  1240. %item = RTBCC_TempRoster.getByID(%id);
  1241. %item.state = "blocked";
  1242.  
  1243. if(RTBCC_SessionManager.hasID(%id) && RTBCC_SessionManager.getByID(%id).isRendered())
  1244. {
  1245. RTBCC_SessionManager.getByID(%id).writeNotice("You have blocked "@%item.name@".");
  1246. RTBCC_SessionManager.getByID(%id).setBlockedStatus(1);
  1247. }
  1248. }
  1249.  
  1250. for(%i=0;%i<RTBCC_RoomSessionManager.getCount();%i++)
  1251. {
  1252. %session = RTBCC_RoomSessionManager.getObject(%i);
  1253. if(%session.manifest.hasUser(%id))
  1254. {
  1255. %user = %session.manifest.getByID(%id);
  1256. %user.blocked = 1;
  1257. }
  1258. }
  1259. }
  1260. else if(%packet.attrib["type"] $= "unblock")
  1261. {
  1262. %id = %packet.child[0].cData;
  1263.  
  1264. if(RTBCC_Roster.hasID(%id))
  1265. {
  1266. %item = RTBCC_Roster.getByID(%id);
  1267. %item.state = "";
  1268. %item.render();
  1269.  
  1270. if(RTBCC_SessionManager.hasID(%id) && RTBCC_SessionManager.getByID(%id).isRendered())
  1271. {
  1272. RTBCC_SessionManager.getByID(%id).writeNotice("You have unblocked "@%item.name@".");
  1273. RTBCC_SessionManager.getByID(%id).setBlockedStatus(0);
  1274. }
  1275. }
  1276.  
  1277. if(RTBCC_TempRoster.hasID(%id))
  1278. {
  1279. %item = RTBCC_TempRoster.getByID(%id);
  1280. %item.state = "";
  1281.  
  1282. if(RTBCC_SessionManager.hasID(%id) && RTBCC_SessionManager.getByID(%id).isRendered())
  1283. {
  1284. RTBCC_SessionManager.getByID(%id).writeNotice("You have unblocked "@%item.name@".");
  1285. RTBCC_SessionManager.getByID(%id).setBlockedStatus(0);
  1286. }
  1287. }
  1288.  
  1289. for(%i=0;%i<RTBCC_RoomSessionManager.getCount();%i++)
  1290. {
  1291. %session = RTBCC_RoomSessionManager.getObject(%i);
  1292. if(%session.manifest.hasUser(%id))
  1293. {
  1294. %user = %session.manifest.getByID(%id);
  1295. %user.blocked = 0;
  1296. }
  1297. }
  1298. }
  1299. }
  1300.  
  1301. //- RTBCC_Socket::onPresencePacket (handles presence packets)
  1302. function RTBCC_Socket::onPresencePacket(%this,%parser,%packet)
  1303. {
  1304. %id = %packet.attrib["from"];
  1305. if(RTBCC_Roster.hasID(%id))
  1306. {
  1307. %user = RTBCC_Roster.getByID(%id);
  1308.  
  1309. if(!%user.online && %packet.attrib["type"] $= "online")
  1310. {
  1311. if(!RTB_Overlay.isAwake())
  1312. {
  1313. if(%packet.attrib["event"] !$= "probe" && RTBCO_getPref("CC::SignIn::Beep"))
  1314. alxPlay(RTBCC_OnlineSound);
  1315. if(%packet.attrib["event"] !$= "probe" && RTBCO_getPref("CC::SignIn::Note"))
  1316. RTBCC_NotificationManager.push(%user.name,"has just signed in.","user",%user.id);
  1317. }
  1318.  
  1319. if(RTBCO_getPref("CC::SeparateOffline"))
  1320. %user.moveToGroup(%user.group.name);
  1321.  
  1322. if(%packet.attrib["event"] !$= "probe" && RTBCC_SessionManager.hasID(%id))
  1323. {
  1324. %session = RTBCC_SessionManager.getByID(%id);
  1325. %session.writeNotice(%user.name@" has signed in.");
  1326. }
  1327. }
  1328. else if (%user.online && %packet.attrib["type"] $= "offline")
  1329. {
  1330. if(RTBCO_getPref("CC::SeparateOffline"))
  1331. %user.moveToGroup("Offline Users");
  1332.  
  1333. if(RTBCC_SessionManager.hasID(%id))
  1334. {
  1335. %session = RTBCC_SessionManager.getByID(%id);
  1336. %session.writeNotice(%user.name@" has signed out.");
  1337. %session.updateStatus(0);
  1338.  
  1339. %session.setInviteDisplay(0);
  1340. RTBCC_NotificationManager.pop(%id@"_invite");
  1341. }
  1342. }
  1343.  
  1344. %user.online = (%packet.attrib["type"] $= "online") ? true : false;
  1345. %user.presence = %packet.find("show").cData;
  1346.  
  1347. %status = %packet.find("status").cData;
  1348. if(%user.status !$= "" && !RTB_Overlay.isAwake())
  1349. if((%user.status < 1 || %user.status > 3) && (%status >= 1 && %status <= 3))
  1350. {
  1351. if(RTBCO_getPref("CC::Join::Note"))
  1352. RTBCC_NotificationManager.push(%user.name,"has just started a server.","world",%user.id);
  1353. if(RTBCO_getPref("CC::Join::Beep"))
  1354. alxPlay(RTBCC_JoinSound);
  1355. }
  1356. else if(%user.status < 4 && %status > 3)
  1357. {
  1358. if(RTBCO_getPref("CC::Join::Note"))
  1359. RTBCC_NotificationManager.push(%user.name,"has just joined a server.","world",%user.id);
  1360. if(RTBCO_getPref("CC::Join::Beep"))
  1361. alxPlay(RTBCC_JoinSound);
  1362. }
  1363.  
  1364. %user.status = %status;
  1365.  
  1366. if(%packet.find("server").children)
  1367. {
  1368. %user.server["ip"] = %packet.find("server/ip").cData;
  1369. %user.server["port"] = %packet.find("server/port").cData;
  1370. }
  1371. else
  1372. {
  1373. %user.server["ip"] = "";
  1374. %user.server["port"] = "";
  1375.  
  1376. if(RTBCC_SessionManager.hasID(%id))
  1377. {
  1378. %session = RTBCC_SessionManager.getByID(%id);
  1379. %session.setInviteDisplay(0);
  1380.  
  1381. RTBCC_NotificationManager.pop(%id@"_invite");
  1382. }
  1383. }
  1384.  
  1385. %user.getGroup().sort();
  1386. %user.rerender();
  1387. }
  1388. }
  1389.  
  1390. //- RTBCC_Socket::onMessagePacket (handles message packet)
  1391. function RTBCC_Socket::onMessagePacket(%this,%parser,%packet)
  1392. {
  1393. %to = %packet.attrib["to"];
  1394. %from = %packet.attrib["from"];
  1395.  
  1396. if(isInt(%to))
  1397. {
  1398. if(!RTBCC_Roster.hasID(%from))
  1399. RTBCC_TempRoster.addUser(%from,%packet.attrib["name"]);
  1400.  
  1401. %session = RTBCC_SessionManager.createSession(%from);
  1402. }
  1403. else
  1404. {
  1405. if(!RTBCC_RoomSessionManager.hasRoom(%to))
  1406. return;
  1407.  
  1408. %session = RTBCC_RoomSessionManager.createSession(%to);
  1409. }
  1410. %session.receive(%packet);
  1411. }
  1412.  
  1413. //- RTBCC_Socket::onActionPacket (handles action packet)
  1414. function RTBCC_Socket::onActionPacket(%this,%parser,%packet)
  1415. {
  1416. if(%packet.child[0].tag $= "typing")
  1417. {
  1418. %from = %packet.attrib["from"];
  1419. %status = %packet.find("typing/status").cData;
  1420.  
  1421. if(RTBCC_SessionManager.hasID(%from))
  1422. %session = RTBCC_SessionManager.getByID(%from).updateStatus(%status);
  1423. }
  1424. else if(%packet.child[0].tag $= "invite")
  1425. {
  1426. %from = %packet.attrib["from"];
  1427. %user = RTBCC_Roster.getByID(%from);
  1428.  
  1429. %session = RTBCC_SessionManager.createSession(%from);
  1430. %session.handleInvite(%packet.attrib["ip"],%packet.attrib["port"]);
  1431.  
  1432. RTBCC_NotificationManager.push(%user.name,"has invited you to play.","house",%from@"_invite",-1);
  1433.  
  1434. %session.focus();
  1435. }
  1436. }
  1437.  
  1438. //- RTBCC_Socket::onPingPacket (handles ping packet)
  1439. function RTBCC_Socket::onPingPacket(%this,%parser,%packet)
  1440. {
  1441. %this.sendXML("<pong />");
  1442. }
  1443.  
  1444. //- RTBCC_Socket::onDisconnectPacket (handles disconnect packet)
  1445. function RTBCC_Socket::onDisconnectPacket(%this,%parser,%packet)
  1446. {
  1447. %this.hardDisconnect();
  1448.  
  1449. if(%packet.attrib["type"] $= "kick")
  1450. {
  1451. RTB_ConnectClient.messageBoxError("You have been kicked!","You have been kicked from the service by an Administrator.");
  1452. RTBCC_NotificationManager.push("Disconnected","You have been kicked.","delete");
  1453. }
  1454. else if(%packet.attrib["type"] $= "timeout")
  1455. {
  1456. RTB_ConnectClient.messageBoxError("Service Timeout","The connection to the service timed out. Retrying ...","RTBCC_Socket.softDisconnect();");
  1457. RTBCC_NotificationManager.push("Disconnected","You have timed out.","delete");
  1458.  
  1459. %this.retry();
  1460. }
  1461. else if(%packet.attrib["type"] $= "auth")
  1462. {
  1463. RTB_ConnectClient.messageBoxError("Authentication Failed","RTB was unable to authenticate you, please reconnect.");
  1464. RTBCC_NotificationManager.push("Disconnected","Authentication failed.","delete");
  1465. }
  1466. else if(%packet.attrib["type"] $= "shutdown")
  1467. {
  1468. RTB_ConnectClient.messageBoxError("Service Shutdown","The service has been shut down for maintenance.");
  1469. RTBCC_NotificationManager.push("Service Maintenance","Connect Server going down.","wrench");
  1470. }
  1471. else if(%packet.attrib["type"] $= "reboot")
  1472. {
  1473. RTB_ConnectClient.messageBoxError("Server Restarting","The connect server is being restarted. You'll be automatically re-connected.");
  1474. RTBCC_NotificationManager.push("Service Maintenance","Connect Server rebooting.","time");
  1475.  
  1476. %this.retry();
  1477. }
  1478. }
  1479.  
  1480. //- RTBCC_Socket::onErrorPacket (handles error packet and relays to appropriate handler)
  1481. function RTBCC_Socket::onErrorPacket(%this,%parser,%packet)
  1482. {
  1483. if(%packet.attrib["id"] !$= "")
  1484. {
  1485. %token = %packet.attrib["id"];
  1486. if(%this.tokenToHandler[%token] !$= "")
  1487. {
  1488. %arg = %this.tokenArgument[%token];
  1489. eval(%this.tokenToHandler[%token]@"("@%this@","@%parser@","@%packet@",\""@%arg@"\");");
  1490.  
  1491. %this.tokenArgument[%token] = "";
  1492. %this.tokenToHandler[%token] = "";
  1493. }
  1494. }
  1495. }
  1496.  
  1497. //*********************************************************
  1498. //* BLXS Packet Stanza Constructs & Callback Procedures
  1499. //*********************************************************
  1500. //- RTBCC_Socket::authenticate (authenticate with connect server)
  1501. function RTBCC_Socket::authenticate(%this)
  1502. {
  1503. %xml = %this.parser.newElement("auth")
  1504. .setAttribute("type","set")
  1505. .setAttribute("version",RTBCC_Socket.version)
  1506. .newElement("id",RTB_ConnectClient.client_id,1)
  1507. .newElement("username",RTB_ConnectClient.client_name)
  1508. .getTop();
  1509.  
  1510. %this.sendXML(%xml);
  1511. }
  1512.  
  1513. //- RTBCC_Socket::getRoster (retrieves roster from the server)
  1514. function RTBCC_Socket::getRoster(%this)
  1515. {
  1516. %xml = %this.parser.newElement("roster")
  1517. .setAttribute("type","get")
  1518. .getTop();
  1519.  
  1520. %this.sendXML(%xml);
  1521. }
  1522.  
  1523. //- RTBCC_Socket::sendPresenceProbe (sends presence probe)
  1524. function RTBCC_Socket::sendPresenceProbe(%this)
  1525. {
  1526. %this.sendPresence(1);
  1527. }
  1528.  
  1529. //- RTBCC_Socket::sendPresence (sends presence data to server)
  1530. function RTBCC_Socket::sendPresence(%this,%probe,%disconnect)
  1531. {
  1532. %xml = %this.parser.newElement("presence");
  1533.  
  1534. if(%probe)
  1535. %xml.setAttribute("probe",1);
  1536.  
  1537. if(isObject(ServerConnection) && !%disconnect)
  1538. {
  1539. %address = ServerConnection.getAddress();
  1540. if(%address $= "local")
  1541. {
  1542. if($Server::LAN)
  1543. {
  1544. if($Server::ServerType $= "Singleplayer")
  1545. {
  1546. %xml = %xml.newElement("status",1,1);
  1547. RTB_ConnectClient.status = 1;
  1548. }
  1549. else
  1550. {
  1551. %xml = %xml.newElement("status",2,1);
  1552. RTB_ConnectClient.status = 2;
  1553. }
  1554. %xml = %xml.newElement("server","",1);
  1555. }
  1556. else
  1557. {
  1558. RTB_ConnectClient.status = 3;
  1559. %xml = %xml.newElement("status",3,1)
  1560. .newElement("server","")
  1561. .newElement("ip","x.x.x.x",1)
  1562. .newElement("port",$Pref::Server::Port,1)
  1563. .getTop();
  1564. }
  1565. }
  1566. else
  1567. {
  1568. %address = strReplace(%address,":"," ");
  1569. %ip = getWord(%address,0);
  1570. %port = getWord(%address,1);
  1571.  
  1572. if(strPos(%ip,"192.168.") $= 0 || strPos(%ip,"10.") $= 0)
  1573. {
  1574. %xml = %xml.newElement("status",4,1);
  1575. RTB_ConnectClient.status = 4;
  1576. }
  1577. else
  1578. {
  1579. %xml = %xml.newElement("status",5,1);
  1580. RTB_ConnectClient.status = 5;
  1581. }
  1582.  
  1583. %xml = %xml.newElement("server","")
  1584. .newElement("ip",%ip,1)
  1585. .newElement("port",%port,1)
  1586. .getTop();
  1587. }
  1588. }
  1589. else
  1590. {
  1591. RTB_ConnectClient.status = 0;
  1592. %xml = %xml.getTop().newElement("status",0,1)
  1593. .newElement("server","",1);
  1594. }
  1595.  
  1596. %this.sendXML(%xml);
  1597. }
  1598.  
  1599. //- RTBCC_Socket::sendStatus (sends user status)
  1600. function RTBCC_Socket::sendStatus(%this,%status)
  1601. {
  1602. %xml = %xml = %this.parser.newElement("presence")
  1603. .newElement("show",%status)
  1604. .getTop();
  1605.  
  1606. %this.sendXML(%xml);
  1607. }
  1608.  
  1609. //- RTBCC_Socket::addToRoster (adds a user to the roster)
  1610. function RTBCC_Socket::addToRoster(%this,%id,%room)
  1611. {
  1612. %xml = %this.parser.newElement("roster")
  1613. .setAttribute("type","add")
  1614. .newElement("item",%id)
  1615. .getTop();
  1616.  
  1617. %this.sendXML(%xml,"RTBCC_Socket::onRosterAddResponse",%room);
  1618. }
  1619.  
  1620. //- RTBCC_Socket::addToRoster (removes a user from the roster)
  1621. function RTBCC_Socket::removeFromRoster(%this,%id)
  1622. {
  1623. %xml = %this.parser.newElement("roster")
  1624. .setAttribute("type","del")
  1625. .newElement("item",%id)
  1626. .getTop();
  1627.  
  1628. %this.sendXML(%xml);
  1629. }
  1630.  
  1631. //- RTBCC_Socket::unblockUser (adds a user to our block list)
  1632. function RTBCC_Socket::blockUser(%this,%id)
  1633. {
  1634. %xml = %this.parser.newElement("roster")
  1635. .setAttribute("type","block")
  1636. .newElement("item",%id)
  1637. .getTop();
  1638.  
  1639. %this.sendXML(%xml);
  1640. }
  1641.  
  1642. //- RTBCC_Socket::unblockUser (removes a user from our block list)
  1643. function RTBCC_Socket::unblockUser(%this,%id)
  1644. {
  1645. %xml = %this.parser.newElement("roster")
  1646. .setAttribute("type","unblock")
  1647. .newElement("item",%id)
  1648. .getTop();
  1649.  
  1650. %this.sendXML(%xml);
  1651. }
  1652.  
  1653. //- RTBCC_Socket::getUserInfo (returns a load of info about a player)
  1654. function RTBCC_Socket::getUserInfo(%this,%id)
  1655. {
  1656. %xml = %this.parser.newElement("request")
  1657. .newElement("playerdata",%id)
  1658. .getTop();
  1659.  
  1660. %this.sendXML(%xml, "RTBCC_Socket::onPlayerInfoResponse");
  1661. }
  1662.  
  1663. //- RTBCC_Socket::getServerStatus (checks whether server has password or not)
  1664. function RTBCC_Socket::getServerStatus(%this,%ip,%port)
  1665. {
  1666. %xml = %this.parser.newElement("request")
  1667. .newElement("gamedata")
  1668. .newElement("ip",%ip,1)
  1669. .newElement("port",%port)
  1670. .getTop();
  1671.  
  1672. %this.sendXML(%xml, "RTBCC_Socket::onServerStatusResponse");
  1673. }
  1674.  
  1675. //- RTBCC_Socket::sendServerInvite (sends player an invite to your server)
  1676. function RTBCC_Socket::sendServerInvite(%this,%to)
  1677. {
  1678. %xml = %this.parser.newElement("action")
  1679. .newElement("invite")
  1680. .setAttribute("to",%to)
  1681. .getTop();
  1682.  
  1683. %this.sendXML(%xml, "RTBCC_Socket::onServerInviteResponse");
  1684. }
  1685.  
  1686. //- RTBCC_Socket::sendMessage (sends a message to a user/room)
  1687. function RTBCC_Socket::sendMessage(%this,%to,%message,%action)
  1688. {
  1689. %xml = %this.parser.newElement("message")
  1690. .setAttribute("to",%to)
  1691. .newElement("body",%message)
  1692. .getTop();
  1693.  
  1694. if(%action)
  1695. %xml.setAttribute("type","action");
  1696.  
  1697. %this.sendXML(%xml,"RTBCC_Socket::onMessageFailed",%to);
  1698. }
  1699.  
  1700. //- RTBCC_Socket::sendPrefs (sends prefs to be saved on the server)
  1701. function RTBCC_Socket::sendPrefs(%this)
  1702. {
  1703. %xml = %this.parser.newElement("set")
  1704. .newElement("prefs")
  1705. .newElement("inviteMode",RTBCO_getPref("CC::InviteReq"),1)
  1706. .newElement("showServer",RTBCO_getPref("CC::ShowServer"),1)
  1707. .newElement("allowPM",RTBCO_getPref("CC::AllowPM"),1)
  1708. .newElement("allowInvites",RTBCO_getPref("CC::AllowInvites"),1)
  1709. .newElement("pirateMode",RTBCO_getPref("CC::PirateMode"),1)
  1710. .getTop();
  1711.  
  1712. %this.sendXML(%xml);
  1713. }
  1714.  
  1715. //- RTBCC_Socket::sendTypingStatus (sends typing status to user)
  1716. function RTBCC_Socket::sendTypingStatus(%this,%to,%status)
  1717. {
  1718. %xml = %this.parser.newElement("set")
  1719. .setAttribute("to",%to)
  1720. .newElement("typing")
  1721. .newElement("status",%status)
  1722. .getTop();
  1723.  
  1724. %this.sendXML(%xml);
  1725. }
  1726.  
  1727. //- RTBCC_Socket::getRoomList (gets a list of rooms from the server)
  1728. function RTBCC_Socket::getRoomList(%this,%update)
  1729. {
  1730. %xml = %this.parser.newElement("request")
  1731. .newElement("roomlist")
  1732. .getTop();
  1733.  
  1734. %this.sendXML(%xml,"RTBCC_Socket::onRoomListResponse",%update);
  1735. }
  1736.  
  1737. //- RTBCC_Socket::joinRoom (joins a chatroom)
  1738. function RTBCC_Socket::joinRoom(%this,%room)
  1739. {
  1740. %xml = %this.parser.newElement("action")
  1741. .newElement("join",%room)
  1742. .getTop();
  1743.  
  1744. %this.sendXML(%xml,"RTBCC_Socket::onRoomJoinResponse",%room);
  1745. }
  1746.  
  1747. //- RTBCC_Socket::leaveRoom (leaves a chatroom)
  1748. function RTBCC_Socket::leaveRoom(%this,%room)
  1749. {
  1750. %xml = %this.parser.newElement("action")
  1751. .newElement("leave",%room)
  1752. .getTop();
  1753.  
  1754. %this.sendXML(%xml);
  1755. }
  1756.  
  1757. //- RTBCC_Socket::kickUser (kicks a user from a room)
  1758. function RTBCC_Socket::kickUser(%this,%room,%user,%reason)
  1759. {
  1760. %xml = %this.parser.newElement("action")
  1761. .newElement("kick")
  1762. .setAttribute("to",%room)
  1763. .setAttribute("user",%user)
  1764. .setAttribute("reason",%reason)
  1765. .getTop();
  1766.  
  1767. %this.sendXML(%xml,"RTBCC_Socket::onRoomKickResponse",%room);
  1768. }
  1769.  
  1770. //- RTBCC_Socket::banUser (bans a user from a room)
  1771. function RTBCC_Socket::banUser(%this,%room,%user,%reason,%length)
  1772. {
  1773. %xml = %this.parser.newElement("action")
  1774. .newElement("ban")
  1775. .setAttribute("to",%room)
  1776. .setAttribute("user",%user)
  1777. .setAttribute("reason",%reason)
  1778. .setAttribute("length",%length)
  1779. .getTop();
  1780.  
  1781. %this.sendXML(%xml,"RTBCC_Socket::onRoomBanResponse",%room);
  1782. }
  1783.  
  1784. //- RTBCC_Socket::changeUserRank (changes users rank in a room)
  1785. function RTBCC_Socket::changeUserRank(%this,%room,%id,%rank)
  1786. {
  1787. %xml = %this.parser.newElement("set")
  1788. .setAttribute("to",%room)
  1789. .newElement("rank")
  1790. .setAttribute("user",%id)
  1791. .setAttribute("level",%rank)
  1792. .getTop();
  1793.  
  1794. %this.sendXML(%xml,"RTBCC_Socket::onRankChangeError",%room);
  1795. }
  1796.  
  1797. //*********************************************************
  1798. //* Error Callback Handlers
  1799. //*********************************************************
  1800. //- RTBCC_Socket::onRosterAddResponse (deals with roster add response)
  1801. function RTBCC_Socket::onRosterAddResponse(%this,%parser,%packet,%room)
  1802. {
  1803. if(isObject(%room))
  1804. %window = %room;
  1805. else
  1806. {
  1807. %window = RTB_ConnectClient;
  1808.  
  1809. RTBCC_Modal_AddFriend_BLID.setValue("");
  1810. }
  1811.  
  1812. if(%packet.tag $= "success")
  1813. %window.messageBoxOK("Woo!","Your friend request has been sent successfully.");
  1814. else
  1815. %window.messageBoxError("Oops ...",%packet.cData);
  1816. }
  1817.  
  1818. //- RTBCC_Socket::onMessageFailed (deals with message errors)
  1819. function RTBCC_Socket::onMessageFailed(%this,%parser,%packet,%arg)
  1820. {
  1821. if(%arg $= "")
  1822. return;
  1823.  
  1824. if(isInt(%arg) && RTBCC_SessionManager.hasID(%arg))
  1825. %session = RTBCC_SessionManager.getByID(%arg);
  1826. else if(RTBCC_RoomSessionManager.hasRoom(%arg))
  1827. %session = RTBCC_RoomSessionManager.getRoomByName(%arg);
  1828. else
  1829. return;
  1830.  
  1831. %session.writeError(%packet.cData);
  1832. }
  1833.  
  1834. //*********************************************************
  1835. //* Response Callback Handlers
  1836. //*********************************************************
  1837. //- RTBCC_Socket::onServerStatusResponse (deals with server response)
  1838. function RTBCC_Socket::onServerStatusResponse(%this,%parser,%packet)
  1839. {
  1840. if(%packet.tag $= "response")
  1841. {
  1842. $ServerInfo::MaxPlayers = %packet.attrib["maxPlayers"];
  1843. $ServerInfo::Name = %packet.attrib["name"];
  1844.  
  1845. RTB_ConnectClient.closeModalWindow();
  1846. if(%packet.attrib["type"] $= "password")
  1847. {
  1848. RTB_ConnectClient.setModalWindow("JoinPassword");
  1849. RTBCC_Modal_JoinPassword_Pass.setValue("");
  1850. RTBCC_Modal_JoinPassword_Pass.makeFirstResponder(1);
  1851. }
  1852. else
  1853. {
  1854. if(isObject(ServerConnection))
  1855. disconnect();
  1856.  
  1857. MJ_txtIP.setValue($RTB::MCCC::Cache::Joining);
  1858. MJ_txtJoinPass.setValue("");
  1859. MJ_connect();
  1860. }
  1861. }
  1862. else if(%packet.tag $= "error")
  1863. RTB_ConnectClient.messageBoxError("Unable to Join",%packet.cData);
  1864. }
  1865.  
  1866. //- RTBCC_Socket::onServerInviteResponse (deals with server response)
  1867. function RTBCC_Socket::onServerInviteResponse(%this,%parser,%packet)
  1868. {
  1869. if(%packet.tag $= "success")
  1870. RTB_ConnectClient.messageBoxOk("Success","Your invite has been sent.");
  1871. else if(%packet.tag $= "error")
  1872. RTB_ConnectClient.messageBoxError("Invite Failed",%packet.cData);
  1873. }
  1874.  
  1875. //- RTBCC_Socket::onRankChangeError (deals with rank change errors)
  1876. function RTBCC_Socket::onRankChangeError(%this,%parser,%packet,%room)
  1877. {
  1878. %room = RTBCC_RoomSessionManager.getRoomByName(%room);
  1879. if(%packet.tag $= "error")
  1880. %room.writeError(%packet.cData);
  1881. }
  1882.  
  1883. //- RTBCC_Socket::onRoomListResponse (list of rooms from server)
  1884. function RTBCC_Socket::onRoomListResponse(%this,%parser,%packet,%update)
  1885. {
  1886. %rooms = %packet.getObject(0);
  1887. for(%i=0;%i<%rooms.children;%i++)
  1888. {
  1889. %room = %rooms.getObject(%i);
  1890. RTBCC_RoomManager.addRoom(%room.cData,%room.attrib["icon"],%room.attrib["type"],%room.attrib["owner"],%room.attrib["users"],%update);
  1891. }
  1892.  
  1893. if(!RTBCC_RoomManager.hasList)
  1894. RTBCC_RoomManager.performAutoJoins();
  1895.  
  1896. RTBCC_RoomManager.hasList = 1;
  1897.  
  1898. if(!%update)
  1899. RTBCC_RoomManager.render();
  1900. }
  1901.  
  1902. //- RTBCC_Socket::onRoomJoinResponse (room join response)
  1903. function RTBCC_Socket::onRoomJoinResponse(%this,%parser,%packet,%room)
  1904. {
  1905. RTB_ConnectClient.closeModalWindow();
  1906.  
  1907. if(%packet.tag $= "success")
  1908. {
  1909. %roomSO = RTBCC_RoomSessionManager.createSession(%room);
  1910.  
  1911. if(RTB_ConnectClient.isOpen() && RTB_ConnectClient.currPane $= "RTBCC_Window_Chat")
  1912. RTBCC_RoomManager.refresh();
  1913.  
  1914. RTBCC_NotificationManager.push(%room,"You have joined the room.","comment_add","join_"@%room);
  1915.  
  1916. %roomSO.manifest.loading = true;
  1917. }
  1918. else if(%packet.tag $= "error")
  1919. {
  1920. if(%packet.attrib["type"] $= "banned")
  1921. {
  1922. if(%packet.attrib["length"] $= "permanent")
  1923. RTB_ConnectClient.messageBoxError(%room,"You are permanently banned from this room.<br><br><font:Verdana Bold:12>Reason: <font:Verdana:12>"@%packet.attrib["reason"]);
  1924. else
  1925. RTB_ConnectClient.messageBoxError(%room,"You are banned from this room.<br><br><font:Verdana Bold:12>Remaining: <font:Verdana:12>"@timeDiffString(%packet.attrib["left"])@" left.<br><font:Verdana Bold:12>Reason: <font:Verdana:12>"@%packet.attrib["reason"]);
  1926. }
  1927. else
  1928. RTB_ConnectClient.messageBoxError(%room,%packet.cData);
  1929. }
  1930. }
  1931.  
  1932. //- RTBCC_Socket::onRoomKickResponse (room kick response)
  1933. function RTBCC_Socket::onRoomKickResponse(%this,%parser,%packet,%room)
  1934. {
  1935. if(%packet.tag $= "error")
  1936. {
  1937. %room = RTBCC_RoomSessionManager.getRoomByName(%room);
  1938. %room.writeError(%packet.cData);
  1939. }
  1940. }
  1941.  
  1942. //- RTBCC_Socket::onRoomBanResponse (room ban response)
  1943. function RTBCC_Socket::onRoomBanResponse(%this,%parser,%packet,%room)
  1944. {
  1945. if(%packet.tag $= "error")
  1946. {
  1947. %room = RTBCC_RoomSessionManager.getRoomByName(%room);
  1948. %room.writeError(%packet.cData);
  1949. }
  1950. }
  1951.  
  1952. //- RTBCC_Socket::onPlayerInfoResponse (info about specific player)
  1953. function RTBCC_Socket::onPlayerInfoResponse(%this,%parser,%packet)
  1954. {
  1955. if(%packet.tag $= "error")
  1956. {
  1957. RTB_ConnectClient.messageBoxError("No Information",%packet.cData);
  1958. return;
  1959. }
  1960.  
  1961. %id = %packet.find("id").cData;
  1962. %name = %packet.find("name").cData;
  1963. %status = %packet.find("status").cData;
  1964. %lastOnline = (%packet.find("last_online").cData $= "-1") ? "Unknown" : timeDiffString(%packet.find("last_online").cData,0) SPC "ago";
  1965.  
  1966. switch(%status)
  1967. {
  1968. case 0:
  1969. %textStatus = "Online";
  1970. case 1:
  1971. %textStatus = "Singleplayer";
  1972. case 2:
  1973. %textStatus = "Hosting LAN";
  1974. case 3:
  1975. %textStatus = "Hosting";
  1976. case 4:
  1977. %textStatus = "Playing LAN";
  1978. case 5:
  1979. %textStatus = "Playing";
  1980. default:
  1981. %textStatus = "Offline";
  1982. }
  1983.  
  1984. RTB_ConnectClient.setModalWindow("PlayerInfo");
  1985. %swatch = RTBCC_Modal_PlayerInfo_Swatch;
  1986. %swatch.clear();
  1987.  
  1988. %bitmap = new GuiBitmapCtrl()
  1989. {
  1990. position = "5 6";
  1991. extent = "16 16";
  1992. bitmap = $RTB::Path@"images/icons/information";
  1993. };
  1994. %swatch.add(%bitmap);
  1995.  
  1996. %text = new GuiMLTextCtrl()
  1997. {
  1998. position = "25 8";
  1999. extent = "140 12";
  2000. text = "<color:444444><font:Verdana Bold:12>Details";
  2001. selectable = false;
  2002. };
  2003. %swatch.add(%text);
  2004.  
  2005. %dots = new GuiBitmapCtrl()
  2006. {
  2007. position = "5 25";
  2008. extent = "158 2";
  2009. bitmap = $RTB::Path@"images/ui/dottedLine";
  2010. wrap = true;
  2011. };
  2012. %swatch.add(%dots);
  2013.  
  2014. %bl_idText = new GuiMLTextCtrl()
  2015. {
  2016. position = "6 31";
  2017. extent = "156 12";
  2018. text = "<color:444444><font:Verdana Bold:12>BL ID<just:right><font:Verdana:12>"@%id;
  2019. selectable = false;
  2020. };
  2021. %swatch.add(%bl_idText);
  2022.  
  2023. %nameText = new GuiMLTextCtrl()
  2024. {
  2025. position = "6 47";
  2026. extent = "156 12";
  2027. text = "<color:444444><font:Verdana Bold:12>Name<just:right><font:Verdana:12>"@%name;
  2028. selectable = false;
  2029. };
  2030. %swatch.add(%nameText);
  2031.  
  2032. %statusText = new GuiMLTextCtrl()
  2033. {
  2034. position = "6 63";
  2035. extent = "156 12";
  2036. text = "<color:444444><font:Verdana Bold:12>Status<just:right><font:Verdana:12>"@%textStatus;
  2037. selectable = false;
  2038. };
  2039. %swatch.add(%statusText);
  2040.  
  2041. if(%status $= "-1")
  2042. {
  2043. %lastOnlineText = new GuiMLTextCtrl()
  2044. {
  2045. position = "6 79";
  2046. extent = "156 12";
  2047. text = "<color:444444><font:Verdana Bold:12>Last Online<just:right><font:Verdana:12>"@%lastOnline;
  2048. selectable = false;
  2049. };
  2050. %swatch.add(%lastOnlineText);
  2051.  
  2052. RTBCC_Modal_PlayerInfo_Swatch.extent = "168 100";
  2053. RTBCC_Modal_PlayerInfo.resize(12,62,174,153);
  2054. RTBCC_Modal_PlayerInfo.center();
  2055. return;
  2056. }
  2057.  
  2058. if(%status $= "0" || %status $= "1" || %status $= "2" || %status $= "4" || %packet.find("server/no_details"))
  2059. {
  2060. RTBCC_Modal_PlayerInfo_Swatch.extent = "168 80";
  2061. RTBCC_Modal_PlayerInfo.resize(12,72,174,133);
  2062. RTBCC_Modal_PlayerInfo.center();
  2063. return;
  2064. }
  2065.  
  2066. %bitmap = new GuiBitmapCtrl()
  2067. {
  2068. position = "5 87";
  2069. extent = "16 16";
  2070. bitmap = $RTB::Path@"images/icons/world";
  2071. };
  2072. %swatch.add(%bitmap);
  2073.  
  2074. %text = new GuiMLTextCtrl()
  2075. {
  2076. position = "25 89";
  2077. extent = "140 12";
  2078. text = "<color:444444><font:Verdana Bold:12>Server Details";
  2079. selectable = false;
  2080. };
  2081. %swatch.add(%text);
  2082.  
  2083. %dots = new GuiBitmapCtrl()
  2084. {
  2085. position = "5 106";
  2086. extent = "158 2";
  2087. bitmap = $RTB::Path@"images/ui/dottedLine";
  2088. wrap = true;
  2089. };
  2090. %swatch.add(%dots);
  2091.  
  2092. %name = %packet.find("server/name").cData;
  2093. %host = %packet.find("server/host").cData;
  2094. %players = %packet.find("server/players").cData;
  2095. %maxPlayers = %packet.find("server/maxPlayers").cData;
  2096. %bricks = numberFormat(%packet.find("server/bricks").cData);
  2097. %map = %packet.find("server/map").cData;
  2098. %password = %packet.find("server/password").cData;
  2099. %dedicated = %packet.find("server/dedicated").cData;
  2100.  
  2101. if(%dedicated)
  2102. {
  2103. %bitmap = new GuiBitmapCtrl()
  2104. {
  2105. position = "146 87";
  2106. extent = "16 16";
  2107. bitmap = $RTB::Path@"images/icons/server";
  2108. };
  2109. %swatch.add(%bitmap);
  2110. }
  2111.  
  2112. %nameLabel = new GuiMLTextCtrl()
  2113. {
  2114. position = "6 112";
  2115. extent = "156 12";
  2116. text = "<color:444444><font:Verdana Bold:12>Name";
  2117. selectable = false;
  2118. };
  2119. %swatch.add(%nameLabel);
  2120.  
  2121. %nameText = new GuiMLTextCtrl()
  2122. {
  2123. position = "39 112";
  2124. extent = "123 12";
  2125. text = "<color:444444><just:right><font:Verdana:12>"@%name;
  2126. selectable = false;
  2127. };
  2128. %swatch.add(%nameText);
  2129. %nameText.fitText(%nameText.text);
  2130.  
  2131. %hostText = new GuiMLTextCtrl()
  2132. {
  2133. position = "6 128";
  2134. extent = "156 12";
  2135. text = "<color:444444><font:Verdana Bold:12>Host<just:right><font:Verdana:12>"@%host;
  2136. selectable = false;
  2137. };
  2138. %swatch.add(%hostText);
  2139.  
  2140. %playersText = new GuiMLTextCtrl()
  2141. {
  2142. position = "6 144";
  2143. extent = "156 12";
  2144. text = "<color:444444><font:Verdana Bold:12>Players<just:right><font:Verdana:12>"@%players SPC "/" SPC %maxPlayers;
  2145. selectable = false;
  2146. };
  2147. %swatch.add(%playersText);
  2148.  
  2149. %bricksText = new GuiMLTextCtrl()
  2150. {
  2151. position = "6 160";
  2152. extent = "156 12";
  2153. text = "<color:444444><font:Verdana Bold:12>Bricks<just:right><font:Verdana:12>"@%bricks;
  2154. selectable = false;
  2155. };
  2156. %swatch.add(%bricksText);
  2157.  
  2158. %mapText = new GuiMLTextCtrl()
  2159. {
  2160. position = "6 176";
  2161. extent = "156 12";
  2162. text = "<color:444444><font:Verdana Bold:12>Map<just:right><font:Verdana:12>"@%map;
  2163. selectable = false;
  2164. };
  2165. %swatch.add(%mapText);
  2166.  
  2167. if(%password)
  2168. {
  2169. %bitmap = new GuiBitmapCtrl()
  2170. {
  2171. position = "143 87";
  2172. extent = "16 16";
  2173. bitmap = $RTB::Path@"images/icons/lock";
  2174. };
  2175. %swatch.add(%bitmap);
  2176. }
  2177.  
  2178. RTBCC_Modal_PlayerInfo_Swatch.extent = "168 190";
  2179. RTBCC_Modal_PlayerInfo.resize(12,72,174,245);
  2180. RTBCC_Modal_PlayerInfo.center();
  2181. }
  2182.  
  2183. //*********************************************************
  2184. //* Roster Initialisation & Implementation
  2185. //*********************************************************
  2186. //- RTBCC_createRoster (creates a friend roster object)
  2187. function RTBCC_createRoster()
  2188. {
  2189. if(isObject(RTBCC_Roster))
  2190. RTBCC_Roster.delete();
  2191.  
  2192. %roster = new ScriptGroup(RTBCC_Roster)
  2193. {
  2194. loading = true;
  2195. };
  2196. RTBGroup.add(%roster);
  2197.  
  2198. %roster.addGroup("Your Invites","folder_heart");
  2199. %roster.addGroup("Offline Users","folder");
  2200.  
  2201. return %roster;
  2202. }
  2203.  
  2204. //- RTBCC_Roster::load (loads roster from server)
  2205. function RTBCC_Roster::load(%this)
  2206. {
  2207. %this.loading = true;
  2208.  
  2209. RTBCC_Socket.getRoster();
  2210. }
  2211.  
  2212. //- RTBCC_Roster::addUser (adds a user to the roster)
  2213. function RTBCC_Roster::addUser(%this,%user)
  2214. {
  2215. %id = %user.attrib["id"];
  2216. %name = %user.attrib["name"];
  2217. %state = %user.attrib["state"];
  2218.  
  2219. if(%state $= "pending_from")
  2220. {
  2221. if(%user = RTBCC_InviteRoster.addUser(%user))
  2222. {
  2223. RTBCC_NotificationManager.push(%user.name,"wants to be your friend.","heart_add",%user.id@"_friend",-1);
  2224. return %user;
  2225. }
  2226. else
  2227. return false;
  2228. }
  2229.  
  2230. if(%this.hasID(%id))
  2231. %this.removeByID(%id);
  2232.  
  2233. if(%state $= "pending_to")
  2234. %group = %this.addGroup("Your Invites","folder_heart");
  2235. else
  2236. %group = %this.addGroup("Friends");
  2237.  
  2238. if(RTBCO_getPref("CC::SeparateOffline") && %group.name !$= "Your Invites")
  2239. {
  2240. %user = %this.addGroup("Offline Users").addUser(%id,%name);
  2241. }
  2242. else
  2243. %user = %group.addUser(%id,%name);
  2244.  
  2245. if(RTBCC_TempRoster.hasID(%id))
  2246. {
  2247. RTBCC_TempRoster.removeByID(%id);
  2248. if(RTBCC_SessionManager.hasID(%id))
  2249. {
  2250. %session = RTBCC_SessionManager.getByID(%id);
  2251. %session.user = %user;
  2252. }
  2253. }
  2254.  
  2255. %user.group = %group;
  2256. %user.state = %state;
  2257.  
  2258. return %user;
  2259. }
  2260.  
  2261. //- RTBCC_Roster::addGroup (adds a group object to the roster)
  2262. function RTBCC_Roster::addGroup(%this,%name,%icon)
  2263. {
  2264. if(%this.hasGroup(%name))
  2265. return %this.getGroupByName(%name);
  2266.  
  2267. %group = new ScriptGroup()
  2268. {
  2269. class = "RTBCC_RosterGroup";
  2270.  
  2271. name = %name;
  2272. icon = "folder_user";
  2273. };
  2274. %this.add(%group);
  2275.  
  2276. if(%icon !$= "")
  2277. %group.icon = %icon;
  2278.  
  2279. if(%this.getCount() $= 1)
  2280. %this.render();
  2281.  
  2282. return %group;
  2283. }
  2284.  
  2285. //- RTBCC_Roster::getUserCount (gets total users in the roster)
  2286. function RTBCC_Roster::getUserCount(%this)
  2287. {
  2288. %users = 0;
  2289. for(%i=0;%i<%this.getCount();%i++)
  2290. {
  2291. %group = %this.getObject(%i);
  2292. %users += %group.getCount();
  2293. }
  2294. return %users;
  2295. }
  2296.  
  2297. //- RTBCC_Roster::hasID (checks if id is present in roster)
  2298. function RTBCC_Roster::hasID(%this,%id)
  2299. {
  2300. for(%i=0;%i<%this.getCount();%i++)
  2301. {
  2302. %group = %this.getObject(%i);
  2303. if(%group.hasID(%id))
  2304. return true;
  2305. }
  2306. return false;
  2307. }
  2308.  
  2309. //- RTBCC_Roster::getByID (returns user based on id)
  2310. function RTBCC_Roster::getByID(%this,%id)
  2311. {
  2312. for(%i=0;%i<%this.getCount();%i++)
  2313. {
  2314. %group = %this.getObject(%i);
  2315. if(%group.hasID(%id))
  2316. return %group.getByID(%id);
  2317. }
  2318. return false;
  2319. }
  2320.  
  2321. //- RTBCC_Roster::removeByID (removes a user based on id)
  2322. function RTBCC_Roster::removeByID(%this,%id)
  2323. {
  2324. if(!%this.hasID(%id))
  2325. return false;
  2326.  
  2327. %user = %this.getByID(%id);
  2328. %tempUser = RTBCC_TempRoster.addUser(%id,%user.name);
  2329. if(RTBCC_SessionManager.hasID(%id))
  2330. {
  2331. %session = RTBCC_SessionManager.getByID(%id);
  2332. %session.user = %tempUser;
  2333. }
  2334. %group = %user.getGroup();
  2335. %user.unrender();
  2336. %user.delete();
  2337.  
  2338. if(%group.getCount() <= 0)
  2339. {
  2340. %this.removeGroupByName(%group.name);
  2341. }
  2342. return true;
  2343. }
  2344.  
  2345. //- RTBCC_Roster::hasGroup (checks if roster has group by name)
  2346. function RTBCC_Roster::hasGroup(%this,%name)
  2347. {
  2348. for(%i=0;%i<%this.getCount();%i++)
  2349. {
  2350. %group = %this.getObject(%i);
  2351. if(%group.name $= %name)
  2352. return true;
  2353. }
  2354. return false;
  2355. }
  2356.  
  2357. //- RTBCC_Roster::getGroupByName (returns group object by name)
  2358. function RTBCC_Roster::getGroupByName(%this,%name)
  2359. {
  2360. for(%i=0;%i<%this.getCount();%i++)
  2361. {
  2362. %group = %this.getObject(%i);
  2363. if(%group.name $= %name)
  2364. return %group;
  2365. }
  2366. return false;
  2367. }
  2368.  
  2369. //- RTBCC_Roster::removeGroupByName (removes a group object by name)
  2370. function RTBCC_Roster::removeGroupByName(%this,%name)
  2371. {
  2372. if(!%this.hasGroup(%name))
  2373. return false;
  2374.  
  2375. %group = %this.getGroupByName(%name);
  2376. %group.unrender();
  2377. %group.delete();
  2378.  
  2379. if(%this.getCount() <= 0)
  2380. %this.render();
  2381.  
  2382. return true;
  2383. }
  2384.  
  2385. //*********************************************************
  2386. //* Roster Group Initialisation & Implementation
  2387. //*********************************************************
  2388. //- RTBCC_RosterGroup::addUser (adds a user object to roster group)
  2389. function RTBCC_RosterGroup::addUser(%this,%id,%name)
  2390. {
  2391. if(%this.hasID(%id))
  2392. return %this.getByID(%id);
  2393.  
  2394. %user = new ScriptObject()
  2395. {
  2396. class = "RTBCC_RosterUser";
  2397.  
  2398. id = %id;
  2399. name = %name;
  2400. group = %this;
  2401. groupName = %this.name;
  2402. };
  2403. %this.add(%user);
  2404.  
  2405. return %user;
  2406. }
  2407.  
  2408. //- RTBCC_RosterGroup::hasID (checks if group has user by id)
  2409. function RTBCC_RosterGroup::hasID(%this,%id)
  2410. {
  2411. for(%i=0;%i<%this.getCount();%i++)
  2412. {
  2413. %user = %this.getObject(%i);
  2414. if(%user.id $= %id)
  2415. return true;
  2416. }
  2417. return false;
  2418. }
  2419.  
  2420. //- RTBCC_RosterGroup::getByID (returns user by id)
  2421. function RTBCC_RosterGroup::getByID(%this,%id)
  2422. {
  2423. for(%i=0;%i<%this.getCount();%i++)
  2424. {
  2425. %user = %this.getObject(%i);
  2426. if(%user.id $= %id)
  2427. return %user;
  2428. }
  2429. return false;
  2430. }
  2431.  
  2432. //- RTBCC_RosterGroup::removeByID (removes user by id)
  2433. function RTBCC_RosterGroup::removeByID(%this,%id)
  2434. {
  2435. if(!%this.hasID(%id))
  2436. return false;
  2437.  
  2438. %this.remove(%this.getByID(%id));
  2439.  
  2440. if(%this.isRendered())
  2441. %this.rerender();
  2442. }
  2443.  
  2444. //*********************************************************
  2445. //* Roster User Initialisation & Implementation
  2446. //*********************************************************
  2447. function RTBCC_RosterUser::moveToGroup(%this,%name)
  2448. {
  2449. if(!RTBCC_Roster.hasGroup(%name))
  2450. %group = RTBCC_Roster.addGroup(%name);
  2451. else
  2452. %group = RTBCC_Roster.getGroupByName(%name);
  2453.  
  2454. %this.getGroup().removeByID(%this.id);
  2455. %group.add(%this);
  2456. %this.rerender();
  2457. }
  2458.  
  2459. //*********************************************************
  2460. //* Temp Roster Initialisation & Implementation
  2461. //*********************************************************
  2462. //- RTBCC_createTempRoster (creates a temporary user roster object)
  2463. function RTBCC_createTempRoster()
  2464. {
  2465. if(isObject(RTBCC_TempRoster))
  2466. RTBCC_TempRoster.delete();
  2467.  
  2468. %roster = new ScriptGroup(RTBCC_TempRoster);
  2469. RTBGroup.add(%roster);
  2470.  
  2471. return %roster;
  2472. }
  2473.  
  2474. //- RTBCC_TempRoster::addUser (adds a user to the roster)
  2475. function RTBCC_TempRoster::addUser(%this,%id,%name)
  2476. {
  2477. if(%this.hasID(%id))
  2478. return %this.getByID(%id);
  2479.  
  2480. %user = new ScriptObject()
  2481. {
  2482. class = "RTBCC_TempRosterUser";
  2483.  
  2484. id = %id;
  2485. name = %name;
  2486. };
  2487. %this.add(%user);
  2488.  
  2489. return %user;
  2490. }
  2491.  
  2492. //- RTBCC_TempRoster::hasID (checks for a user by id)
  2493. function RTBCC_TempRoster::hasID(%this,%id)
  2494. {
  2495. for(%i=0;%i<%this.getCount();%i++)
  2496. {
  2497. if(%this.getObject(%i).id $= %id)
  2498. return true;
  2499. }
  2500. return false;
  2501. }
  2502.  
  2503. //- RTBCC_TempRoster::getByID (returns a user by id)
  2504. function RTBCC_TempRoster::getByID(%this,%id)
  2505. {
  2506. for(%i=0;%i<%this.getCount();%i++)
  2507. {
  2508. %user = %this.getObject(%i);
  2509. if(%user.id $= %id)
  2510. return %user;
  2511. }
  2512. return false;
  2513. }
  2514.  
  2515. //- RTBCC_TempRoster::removeByID (removes a user by id)
  2516. function RTBCC_TempRoster::removeByID(%this,%id)
  2517. {
  2518. if(!%this.hasID(%id))
  2519. return false;
  2520.  
  2521. %user = %this.getByID(%id);
  2522. %user.delete();
  2523.  
  2524. return true;
  2525. }
  2526.  
  2527. //*********************************************************
  2528. //* Invite Roster Initialisation & Implementation
  2529. //*********************************************************
  2530. //- RTBCC_createInviteRoster (creates the invitation roster)
  2531. function RTBCC_createInviteRoster()
  2532. {
  2533. if(isObject(RTBCC_InviteRoster))
  2534. RTBCC_InviteRoster.delete();
  2535.  
  2536. %roster = new ScriptGroup(RTBCC_InviteRoster);
  2537. RTBGroup.add(%roster);
  2538.  
  2539. %roster.render();
  2540.  
  2541. return %roster;
  2542. }
  2543.  
  2544. //- RTBCC_InviteRoster::addUser (adds a user to the invite roster)
  2545. function RTBCC_InviteRoster::addUser(%this,%user)
  2546. {
  2547. %id = %user.attrib["id"];
  2548. %name = %user.attrib["name"];
  2549.  
  2550. if(%this.hasID(%id))
  2551. return %this.getByID(%id);
  2552.  
  2553. if($Trust::Count $= "")
  2554. loadTrustList();
  2555.  
  2556. if(RTBCO_getPref("CC::InviteReq") $= 3)
  2557. {
  2558. RTBCC_Socket.removeFromRoster(%id);
  2559. return false;
  2560. }
  2561. else if(RTBCO_getPref("CC::InviteReq") $= 2)
  2562. {
  2563. for(%i=0;%i<$Trust::Count;%i++)
  2564. {
  2565. %trust = $Trust::Line[%i];
  2566. if(%id $= getField(%trust,0))
  2567. {
  2568. if(getField(%trust,1) $= "2")
  2569. {
  2570. %match = true;
  2571. break;
  2572. }
  2573. }
  2574. }
  2575.  
  2576. if(!%match)
  2577. {
  2578. RTBCC_Socket.removeFromRoster(%id);
  2579. return false;
  2580. }
  2581. }
  2582. else if(RTBCO_getPref("CC::InviteReq") $= 1)
  2583. {
  2584. for(%i=0;%i<$Trust::Count;%i++)
  2585. {
  2586. %trust = $Trust::Line[%i];
  2587. if(%id $= getField(%trust,0))
  2588. {
  2589. if(getField(%trust,1) $= "1" || getField(%trust,1) $= "2")
  2590. {
  2591. %match = true;
  2592. break;
  2593. }
  2594. }
  2595. }
  2596.  
  2597. if(!%match)
  2598. {
  2599. RTBCC_Socket.removeFromRoster(%id);
  2600. return false;
  2601. }
  2602. }
  2603.  
  2604. %user = new ScriptObject()
  2605. {
  2606. class = "RTBCC_InviteRosterItem";
  2607.  
  2608. id = %id;
  2609. name = %name;
  2610. };
  2611. %this.add(%user);
  2612.  
  2613. %this.render();
  2614.  
  2615. return %user;
  2616. }
  2617.  
  2618. //- RTBCC_InviteRoster::hasID (checks for an invite by id)
  2619. function RTBCC_InviteRoster::hasID(%this,%id)
  2620. {
  2621. for(%i=0;%i<%this.getCount();%i++)
  2622. {
  2623. if(%this.getObject(%i).id $= %id)
  2624. return true;
  2625. }
  2626. return false;
  2627. }
  2628.  
  2629. //- RTBCC_InviteRoster::getByID (returns an invite by id)
  2630. function RTBCC_InviteRoster::getByID(%this,%id)
  2631. {
  2632. for(%i=0;%i<%this.getCount();%i++)
  2633. {
  2634. %user = %this.getObject(%i);
  2635. if(%user.id $= %id)
  2636. return %user;
  2637. }
  2638. return false;
  2639. }
  2640.  
  2641. //- RTBCC_InviteRoster::removeByID (removes an invite by id)
  2642. function RTBCC_InviteRoster::removeByID(%this,%id)
  2643. {
  2644. if(!%this.hasID(%id))
  2645. return false;
  2646.  
  2647. %user = %this.getByID(%id);
  2648. %user.delete();
  2649.  
  2650. %this.render();
  2651.  
  2652. return true;
  2653. }
  2654.  
  2655. //*********************************************************
  2656. //* Invite Roster Runtime Manipulation
  2657. //*********************************************************
  2658. //- RTBCC_InviteRoster::accept (accepts a roster invite request)
  2659. function RTBCC_InviteRoster::accept(%this,%invite)
  2660. {
  2661. RTBCC_Socket.addToRoster(%invite.id);
  2662. %this.removeByID(%invite.id);
  2663. }
  2664.  
  2665. //- RTBCC_InviteRoster::accept (rejects a roster invite request)
  2666. function RTBCC_InviteRoster::reject(%this,%invite,%block)
  2667. {
  2668. if(%block $= "")
  2669. {
  2670. RTB_ConnectClient.messageBoxYesNo("Okay, but how about ...","Would you like to block this user from sending you future friend requests?",%this@".reject("@%invite@",1);",%this@".reject("@%invite@",0);");
  2671. return;
  2672. }
  2673.  
  2674. if(%block)
  2675. RTBCC_Socket.blockUser(%invite.id);
  2676.  
  2677. RTBCC_Socket.removeFromRoster(%invite.id);
  2678. %this.removeByID(%invite.id);
  2679. }
  2680.  
  2681. //*********************************************************
  2682. //* Roster Live Rendering & Manipulation
  2683. //*********************************************************
  2684. //- RTBCC_Roster_Swatch::clear (resizes the swatch to the correct extent)
  2685. function RTBCC_Roster_Swatch::clear(%this)
  2686. {
  2687. Parent::clear(%this);
  2688. %this.resize(1,1,194,getWord(RTBCC_Roster_Scroll.extent,1)-2);
  2689. }
  2690.  
  2691. //- RTBCC_Roster_Swatch::reshape (shapes the size of the roster swatch to be high enough)
  2692. function RTBCC_Roster_Swatch::reshape(%this)
  2693. {
  2694. if(%this.getLowestPoint() < (getWord(RTBCC_Roster_Scroll.extent,1)-2))
  2695. %this.resize(1,getWord(%this.position,1),194,getWord(RTBCC_Roster_Scroll.extent,1)-2);
  2696. else
  2697. %this.resize(1,getWord(%this.position,1),194,%this.getLowestPoint());
  2698. }
  2699.  
  2700. //- RTBCC_Roster::render (renders the entire roster)
  2701. function RTBCC_Roster::render(%this)
  2702. {
  2703. RTBCC_Roster_Swatch.clear();
  2704.  
  2705. if(%this.getUserCount() <= 0)
  2706. {
  2707. %text = new GuiMLTextCtrl()
  2708. {
  2709. horizSizing = "center";
  2710. vertSizing = "center";
  2711.  
  2712. extent = "194 40";
  2713. text = "<just:center><bitmap:" @ $RTB::Path @ "images/icons/emoticon_unhappy><br><br><color:444444><font:Verdana:12>You don't have any friends!";
  2714.  
  2715. selectable = false;
  2716. };
  2717. RTBCC_Roster_Swatch.add(%text);
  2718. RTBCC_Roster_Swatch.reshape();
  2719. if(RTB_ConnectClient.isOpen())
  2720. %text.forceReflow();
  2721. %text.center();
  2722. return;
  2723. }
  2724.  
  2725. %this.sort();
  2726. for(%i=0;%i<%this.getCount();%i++)
  2727. {
  2728. %group = %this.getObject(%i);
  2729. if(%group.getCount() <= 0)
  2730. continue;
  2731.  
  2732. %group.render();
  2733. }
  2734. }
  2735.  
  2736. //- RTBCC_Roster::sort (sorts child object indexes within group by child name value)
  2737. function RTBCC_Roster::sort(%this)
  2738. {
  2739. if(%this.getCount() <= 0)
  2740. return;
  2741.  
  2742. %sorter = new GuiTextListCtrl();
  2743. for(%i=0;%i<%this.getCount();%i++)
  2744. {
  2745. %group = %this.getObject(%i);
  2746. %sorter.addRow(%group,%group.name);
  2747. }
  2748. %sorter.sort(0,1);
  2749.  
  2750. for(%i=0;%i<%sorter.rowCount();%i++)
  2751. {
  2752. %this.pushToBack(%sorter.getRowId(%i));
  2753. }
  2754. %sorter.delete();
  2755.  
  2756. %this.pushToBack(%this.getGroupByName("Your Invites"));
  2757. %this.pushToBack(%this.getGroupByName("Offline Users"));
  2758. }
  2759.  
  2760. //- RTBCC_RosterUser::isRendered (checks to see if the roster user is rendered already)
  2761. function RTBCC_RosterUser::isRendered(%this)
  2762. {
  2763. if(!isObject(%this.gui_container))
  2764. return false;
  2765.  
  2766. if(%this.gui_container.getGroup().getID() !$= %this.getGroup().container.getID())
  2767. return false;
  2768.  
  2769. return true;
  2770. }
  2771.  
  2772. //- RTBCC_RosterUser::render (attempts to render the roster user)
  2773. function RTBCC_RosterUser::render(%this)
  2774. {
  2775. if(%this.isRendered())
  2776. {
  2777. %image = "status_offline";
  2778.  
  2779. switch(%this.status)
  2780. {
  2781. case 1:
  2782. %textStatus = "Singleplayer";
  2783. case 2:
  2784. %textStatus = "Hosting LAN";
  2785. case 3:
  2786. %textStatus = "Hosting";
  2787. case 4:
  2788. %textStatus = "Playing LAN";
  2789. case 5:
  2790. %textStatus = "Playing";
  2791. }
  2792.  
  2793. if(%this.online $= true)
  2794. if(%this.presence $= "away")
  2795. %image = "status_away";
  2796. else if(%this.presence $= "busy")
  2797. %image = "status_busy";
  2798. else
  2799. %image = "status_online";
  2800.  
  2801. if(%this.state $= "blocked")
  2802. if(%this.online)
  2803. %image = "status_online_blocked";
  2804. else
  2805. %image = "status_offline_blocked";
  2806.  
  2807. if(%this.state $= "blocked")
  2808. %textStatus = "Blocked";
  2809.  
  2810. %this.gui_rosterStatus.setBitmap($RTB::Path @ "images/icons/" @ %image);
  2811. %this.gui_rosterName.setText("<color:444444><font:Verdana:12>" @ %this.name @ "<just:right><font:Verdana Italic:12>" @ %textStatus);
  2812.  
  2813. if(isObject(%this.gui_menu))
  2814. %this.closeRosterMenu();
  2815. }
  2816. else
  2817. {
  2818. if(!%this.getGroup().isRendered())
  2819. %this.getGroup().render();
  2820. else
  2821. {
  2822. %position = 19;
  2823. %this.getGroup().sort();
  2824. for(%i=0;%i<%this.getGroup().getCount();%i++)
  2825. {
  2826. %user = %this.getGroup().getObject(%i);
  2827. if(!%user.isRendered() && %user !$= %this)
  2828. continue;
  2829.  
  2830. if(%this $= %user)
  2831. {
  2832. %this.getGroup().container.conditionalShiftY(%position,22);
  2833. %this.renderInPlace("13" SPC %position);
  2834. %this.getGroup().container.extent = vectorAdd(%this.getGroup().container.extent,"0 22");
  2835. RTBCC_Roster_Swatch.conditionalShiftY(getWord(%this.getGroup().container.position,1) + 1,22);
  2836. }
  2837. else
  2838. %position += 22;
  2839. }
  2840. RTBCC_Roster_Swatch.reshape();
  2841. }
  2842. }
  2843. }
  2844.  
  2845. //- RTBCC_RosterUser::renderInPlace (renders a roster user taking a position argument)
  2846. function RTBCC_RosterUser::renderInPlace(%this,%position)
  2847. {
  2848. if(%this.isRendered())
  2849. return;
  2850.  
  2851. %swatch = %this.getGroup().container;
  2852.  
  2853. %container = new GuiSwatchCtrl()
  2854. {
  2855. position = %position;
  2856. extent = "170 22";
  2857.  
  2858. color = "0 0 0 0";
  2859. };
  2860. %swatch.add(%container);
  2861. %this.gui_container = %container;
  2862.  
  2863. %selectBox = new GuiBitmapCtrl()
  2864. {
  2865. position = "0 0";
  2866. extent = "170 22";
  2867.  
  2868. visible = false;
  2869. bitmap = $RTB::Path @ "images/ui/buddyListSelect_n";
  2870. };
  2871. %container.add(%selectBox);
  2872. %this.gui_selectBox = %selectBox;
  2873.  
  2874. %icon = new GuiBitmapCtrl()
  2875. {
  2876. position = "1 3";
  2877. extent = "16 16";
  2878. };
  2879. %container.add(%icon);
  2880. %this.gui_rosterStatus = %icon;
  2881.  
  2882. %text = new GuiMLTextCtrl()
  2883. {
  2884. position = "19 5";
  2885. extent = "147 12";
  2886.  
  2887. selectable = false;
  2888. };
  2889. %container.add(%text);
  2890. %this.gui_rosterName = %text;
  2891.  
  2892. %mouseEvent = new GuiMouseEventCtrl()
  2893. {
  2894. position = "0 0";
  2895. extent = "170 22";
  2896.  
  2897. persistent = 1;
  2898. eventType = "BuddyListSelect";
  2899. eventCallbacks = "1111011";
  2900.  
  2901. user = %this;
  2902. select = %selectBox;
  2903. };
  2904. %container.add(%mouseEvent);
  2905. %this.gui_mouseEvent = %mouseEvent;
  2906.  
  2907. %this.render();
  2908. }
  2909.  
  2910. //- RTBCC_RosterUser::rerender (rerenders the roster user if it's already rendered)
  2911. function RTBCC_RosterUser::rerender(%this)
  2912. {
  2913. if(%this.isRendered())
  2914. %this.unrender();
  2915. %this.render();
  2916. }
  2917.  
  2918. //- RTBCC_RosterUser::unrender (unrenders the roster user and parent group if empty)
  2919. function RTBCC_RosterUser::unrender(%this)
  2920. {
  2921. if(!%this.isRendered())
  2922. return;
  2923.  
  2924. %this.closeRosterMenu();
  2925. %position = getWord(%this.gui_container.position,1);
  2926.  
  2927. %this.gui_container.delete();
  2928.  
  2929. %this.getGroup().container.conditionalShiftY(%position,-22);
  2930. %this.getGroup().container.extent = vectorSub(%this.getGroup().container.extent,"0 22");
  2931. RTBCC_Roster_Swatch.conditionalShiftY(getWord(%this.getGroup().container.position,1)+1,-22);
  2932.  
  2933. RTBCC_Roster_Swatch.reshape();
  2934. }
  2935.  
  2936. //- RTBCC_RosterGroup::isRendered (checks to see if the roster group is rendered already)
  2937. function RTBCC_RosterGroup::isRendered(%this)
  2938. {
  2939. if(!isObject(%this.container))
  2940. return false;
  2941.  
  2942. if(!isObject(%this.container.getGroup()) || %this.container.getGroup().getID() !$= RTBCC_Roster_Swatch.getID())
  2943. return false;
  2944.  
  2945. return true;
  2946. }
  2947.  
  2948. //- RTBCC_RosterGroup::sort (sorts child object indexes within group by child name value)
  2949. function RTBCC_RosterGroup::sort(%this)
  2950. {
  2951. if(%this.getCount() <= 0)
  2952. return;
  2953.  
  2954. %sorter = new GuiTextListCtrl();
  2955. for(%i=0;%i<%this.getCount();%i++)
  2956. {
  2957. %user = %this.getObject(%i);
  2958. if(%user.online && %user.status > 0)
  2959. %sorter.addRow(%user,%user.name);
  2960. }
  2961. %sorter.sort(0,1);
  2962.  
  2963. for(%i=0;%i<%sorter.rowCount();%i++)
  2964. {
  2965. %this.pushToBack(%sorter.getRowId(%i));
  2966. }
  2967. %sorter.delete();
  2968.  
  2969. %sorter = new GuiTextListCtrl();
  2970. for(%i=0;%i<%this.getCount();%i++)
  2971. {
  2972. %user = %this.getObject(%i);
  2973. if(%user.online && %user.status <= 0)
  2974. %sorter.addRow(%user,%user.name);
  2975. }
  2976. %sorter.sort(0,1);
  2977.  
  2978. for(%i=0;%i<%sorter.rowCount();%i++)
  2979. {
  2980. %this.pushToBack(%sorter.getRowId(%i));
  2981. }
  2982. %sorter.delete();
  2983.  
  2984. %sorter = new GuiTextListCtrl();
  2985. for(%i=0;%i<%this.getCount();%i++)
  2986. {
  2987. %user = %this.getObject(%i);
  2988. if(!%user.online)
  2989. %sorter.addRow(%user,%user.name);
  2990. }
  2991. %sorter.sort(0,1);
  2992.  
  2993. for(%i=0;%i<%sorter.rowCount();%i++)
  2994. {
  2995. %this.pushToBack(%sorter.getRowId(%i));
  2996. }
  2997. %sorter.delete();
  2998. }
  2999.  
  3000. //- RTBCC_RosterGroup::render (attempts to render the roster group and user items)
  3001. function RTBCC_RosterGroup::render(%this)
  3002. {
  3003. if(%this.isRendered())
  3004. return;
  3005.  
  3006. if(%this.getCount() <= 0)
  3007. return;
  3008.  
  3009. %position = 0;
  3010. RTBCC_Roster.sort();
  3011. for(%i=0;%i<RTBCC_Roster.getCount();%i++)
  3012. {
  3013. %group = RTBCC_Roster.getObject(%i);
  3014. if(!%group.isRendered() && %this !$= %group)
  3015. continue;
  3016.  
  3017. %group.sort();
  3018. if(%this $= %group)
  3019. {
  3020. %extent = ((%group.getCount() + 1) * 22) + 4;
  3021. RTBCC_Roster_Swatch.conditionalShiftY(%position,%extent);
  3022.  
  3023. %group.renderInPlace("0" SPC %position);
  3024.  
  3025. for(%j=0;%j<%group.getCount();%j++)
  3026. {
  3027. %position = "13" SPC (%j * 22) + 19;
  3028. %group.getObject(%j).renderInPlace(%position);
  3029. }
  3030. }
  3031. else
  3032. %position += getWord(%group.container.extent,1);
  3033. }
  3034. RTBCC_Roster_Swatch.reshape();
  3035.  
  3036. if(RTBCC_Roster_Swatch.getObject(0).getClassName() $= "GuiMLTextCtrl")
  3037. RTBCC_Roster.render();
  3038. }
  3039.  
  3040. //- RTBCC_RosterGroup::renderInPlace (renders a roster group taking a position argument)
  3041. function RTBCC_RosterGroup::renderInPlace(%this,%position)
  3042. {
  3043. %extent = ((%this.getCount() + 1) * 22) + 4;
  3044. %this.container = new GuiSwatchCtrl()
  3045. {
  3046. position = %position;
  3047. extent = "194" SPC %extent;
  3048. color = "0 0 0 0";
  3049.  
  3050. new GuiBitmapCtrl()
  3051. {
  3052. position = "0 0";
  3053. extent = "16 16";
  3054. bitmap = $RTB::Path @ "images/icons/" @ %this.icon;
  3055. };
  3056.  
  3057. new GuiMLTextCtrl()
  3058. {
  3059. position = "20 2";
  3060. extent = "160 12";
  3061. text = "<color:333333><font:Verdana Bold:12>" @ %this.name;
  3062.  
  3063. selectable = false;
  3064. };
  3065. };
  3066. RTBCC_Roster_Swatch.add(%this.container);
  3067. }
  3068.  
  3069. //- RTBCC_RosterGroup::rerender (rerenders the roster group if it's already rendered)
  3070. function RTBCC_RosterGroup::rerender(%this)
  3071. {
  3072. if(%this.isRendered())
  3073. %this.unrender();
  3074. %this.render();
  3075. }
  3076.  
  3077. //- RTBCC_RosterGroup::unrender (unrenders a roster group and its user items)
  3078. function RTBCC_RosterGroup::unrender(%this)
  3079. {
  3080. if(!%this.isRendered())
  3081. return;
  3082.  
  3083. %position = getWord(%this.container.position,1);
  3084. %extent = getWord(%this.container.extent,1);
  3085.  
  3086. %this.container.delete();
  3087. RTBCC_Roster_Swatch.conditionalShiftY(%position,"-"@%extent);
  3088. RTBCC_Roster_Swatch.reshape();
  3089.  
  3090. RTBCC_Roster.render();
  3091. }
  3092.  
  3093. //*********************************************************
  3094. //* Roster Interaction
  3095. //*********************************************************
  3096. //- Event_BuddyListSelect::onMouseEnter (handles entry interaction with roster user item)
  3097. function Event_BuddyListSelect::onMouseEnter(%this)
  3098. {
  3099. %this.select.setVisible(true);
  3100. }
  3101.  
  3102. //- Event_BuddyListSelect::onMouseLeave (handles leaving interaction with roster user item)
  3103. function Event_BuddyListSelect::onMouseLeave(%this)
  3104. {
  3105. %this.select.setVisible(false);
  3106.  
  3107. %this.user.closeRosterMenu();
  3108. }
  3109.  
  3110. //- Event_BuddyListSelect::onMouseDown (handles click interaction with roster user item)
  3111. function Event_BuddyListSelect::onMouseDown(%this)
  3112. {
  3113. if(isObject(RTBCC_Roster.gui_userMenu) && RTBCC_Roster.gui_userMenu.user !$= %this.user)
  3114. RTBCC_Roster.gui_userMenu.user.closeRosterMenu();
  3115.  
  3116. if(isObject(%this.user.gui_menu))
  3117. return;
  3118.  
  3119. %this.select.setBitmap($RTB::Path @ "images/ui/buddyListSelect_h");
  3120. }
  3121.  
  3122. //- Event_BuddyListSelect::onMouseUp (handles click interaction with roster user item)
  3123. function Event_BuddyListSelect::onMouseUp(%this)
  3124. {
  3125. if(isObject(RTBCC_Roster.gui_userMenu) && RTBCC_Roster.gui_userMenu.user !$= %this.user)
  3126. return;
  3127.  
  3128. if(isObject(%this.user.gui_menu))
  3129. {
  3130. %this.user.closeRosterMenu();
  3131.  
  3132. if((getSimTime() - %this.lastClickTime) <= 300 && %this.user.online)
  3133. %this.user.openChatWindow();
  3134.  
  3135. return;
  3136. }
  3137. %this.user.openRosterMenu();
  3138.  
  3139. %this.lastClickTime = getSimTime();
  3140. }
  3141.  
  3142. //- Event_BuddyListSelect::onRightMouseDown (handles click interaction with roster user item)
  3143. function Event_BuddyListSelect::onRightMouseDown(%this)
  3144. {
  3145. if(isObject(RTBCC_Roster.gui_userMenu) && RTBCC_Roster.gui_userMenu.user !$= %this.user)
  3146. RTBCC_Roster.gui_userMenu.user.closeRosterMenu();
  3147.  
  3148. if(isObject(%this.user.gui_menu))
  3149. return;
  3150.  
  3151. %this.select.setBitmap($RTB::Path @ "images/ui/buddyListSelect_h");
  3152. }
  3153.  
  3154. //- Event_BuddyListSelect::onRightMouseUp (handles click interaction with roster user item)
  3155. function Event_BuddyListSelect::onRightMouseUp(%this)
  3156. {
  3157. if(isObject(RTBCC_Roster.gui_userMenu) && RTBCC_Roster.gui_userMenu.user !$= %this.user)
  3158. return;
  3159.  
  3160. if(isObject(%this.user.gui_menu))
  3161. {
  3162. %this.user.closeRosterMenu();
  3163. return;
  3164. }
  3165. %this.user.openRosterMenu();
  3166.  
  3167. %this.lastClickTime = getSimTime();
  3168. }
  3169.  
  3170. //- Event_BuddyListMenu::onMouseEnter (handles menu item interaction of the roster interact menu)
  3171. function Event_BuddyListMenu::onMouseEnter(%this)
  3172. {
  3173. %this.item.setBitmap($RTB::Path @ "images/ui/buddyListMenu_h");
  3174. }
  3175.  
  3176. //- Event_BuddyListMenu::onMouseLeave (handles menu item interaction of the roster interact menu)
  3177. function Event_BuddyListMenu::onMouseLeave(%this)
  3178. {
  3179. %this.item.setBitmap($RTB::Path @ "images/ui/buddyListMenu_n");
  3180. }
  3181.  
  3182. //- Event_BuddyListMenu::onMouseUp (handles menu item interaction of the roster interact menu)
  3183. function Event_BuddyListMenu::onMouseUp(%this)
  3184. {
  3185. eval(%this.command);
  3186. }
  3187.  
  3188. //*********************************************************
  3189. //* Roster User Interact Menu
  3190. //*********************************************************
  3191. //- RTBCC_RosterUser::openRosterMenu (opens a menu of items for the user to select)
  3192. function RTBCC_RosterUser::openRosterMenu(%this)
  3193. {
  3194. %this.gui_selectBox.setBitmap($RTB::Path @ "images/ui/buddyListSelect_d");
  3195.  
  3196. %top = getWord(%this.gui_selectBox.getPosRelativeTo(RTBCC_Roster_Scroll),1);
  3197. %bottom = %top + getWord(%this.gui_selectBox.extent,1);
  3198. %scrollExt = getWord(RTBCC_Roster_Scroll.extent,1)-2;
  3199.  
  3200. if(%top < 0)
  3201. RTBCC_Roster_Swatch.resize(1,getWord(RTBCC_Roster_Swatch.position,1)-(%top-2),194,getWord(RTBCC_Roster_Swatch.extent,1));
  3202. if(%bottom > %scrollExt)
  3203. RTBCC_Roster_Swatch.resize(1,getWord(RTBCC_Roster_Swatch.position,1)-(%bottom-%scrollExt)-2,194,getWord(RTBCC_Roster_Swatch.extent,1));
  3204.  
  3205. %menuItems = -1;
  3206. if(%this.online)
  3207. {
  3208. if(%this.state !$= "blocked")
  3209. {
  3210. %menuIcon[%menuItems++] = "comment";
  3211. %menuText[%menuItems] = "Chat";
  3212. %menuComm[%menuItems] = %this@".openChatWindow();";
  3213. }
  3214. if(%this.status $= 3 || %this.status $= 5)
  3215. {
  3216. %menuIcon[%menuItems++] = "world";
  3217. %menuText[%menuItems] = "Play";
  3218. %menuComm[%menuItems] = %this@".joinServer();";
  3219. }
  3220. if(RTB_ConnectClient.status $= 3 || RTB_ConnectClient.status $= 5)
  3221. {
  3222. %menuIcon[%menuItems++] = "house";
  3223. %menuText[%menuItems] = "Invite";
  3224. %menuComm[%menuItems] = %this@".inviteToServer();";
  3225. }
  3226. }
  3227.  
  3228. %menuIcon[%menuItems++] = "information";
  3229. %menuText[%menuItems] = "Info";
  3230. %menuComm[%menuItems] = %this@".info();";
  3231.  
  3232. if(%this.state $= "")
  3233. {
  3234. %menuIcon[%menuItems++] = "block";
  3235. %menuText[%menuItems] = "Block";
  3236. %menuComm[%menuItems] = %this@".block();";
  3237. }
  3238. else if(%this.state $= "blocked")
  3239. {
  3240. %menuIcon[%menuItems++] = "block";
  3241. %menuText[%menuItems] = "Unblock";
  3242. %menuComm[%menuItems] = %this@".unblock();";
  3243. }
  3244. if(%this.state $= "pending_to")
  3245. {
  3246. %menuIcon[%menuItems++] = "delete";
  3247. %menuText[%menuItems] = "Cancel";
  3248. %menuComm[%menuItems] = %this@".cancelSubscribe();";
  3249. %menuItems++;
  3250. }
  3251. else
  3252. {
  3253. %menuIcon[%menuItems++] = "delete";
  3254. %menuText[%menuItems] = "Remove";
  3255. %menuComm[%menuItems] = %this@".unsubscribe();";
  3256. %menuItems++;
  3257. }
  3258. %menuSize = (%menuItems * 20) + 4;
  3259.  
  3260. %container = RTB_Overlay;
  3261. %position = %this.gui_selectBox.getAbsPosition(%container);
  3262. %menu = new GuiSwatchCtrl()
  3263. {
  3264. position = vectorAdd(%position,"104 22");
  3265. extent = "66" SPC %menuSize;
  3266. color = "0 0 0 0";
  3267.  
  3268. user = %this;
  3269.  
  3270. new GuiBitmapCtrl()
  3271. {
  3272. position = "0" SPC %menuSize - 4;
  3273. extent = "66 4";
  3274.  
  3275. bitmap = $RTB::Path @ "images/ui/buddyListMenuBottom";
  3276. };
  3277. };
  3278. %container.add(%menu);
  3279. %this.gui_menu = %menu;
  3280. RTBCC_Roster.gui_userMenu = %menu;
  3281.  
  3282. for(%i=0;%i<%menuItems;%i++)
  3283. {
  3284. %item = new GuiBitmapCtrl()
  3285. {
  3286. position = "0" SPC (%i * 20);
  3287. extent = "66 20";
  3288.  
  3289. bitmap = $RTB::Path @ "images/ui/buddyListMenu_n";
  3290.  
  3291. new GuiBitmapCtrl()
  3292. {
  3293. position = "4 2";
  3294. extent = "16 16";
  3295.  
  3296. bitmap = $RTB::Path @ "images/icons/" @ %menuIcon[%i];
  3297. };
  3298.  
  3299. new GuiMLTextCtrl()
  3300. {
  3301. position = "22 4";
  3302. extent = "54 12";
  3303.  
  3304. text = "<color:444444><font:Verdana:12>" @ %menuText[%i];
  3305.  
  3306. selectable = false;
  3307. };
  3308. };
  3309. %menu.add(%item);
  3310.  
  3311. %mouseEvent = new GuiMouseEventCtrl()
  3312. {
  3313. position = "0" SPC (%i * 20);
  3314. extent = "66 20";
  3315.  
  3316. eventType = "BuddyListMenu";
  3317. eventCallbacks = "1101000";
  3318.  
  3319. user = %this;
  3320. item = %item;
  3321. command = %menuComm[%i];
  3322. };
  3323. %menu.add(%mouseEvent);
  3324. }
  3325. %this.gui_mouseEvent.extent = "170" SPC (%menuSize + 30);
  3326.  
  3327. if(RTBCO_getPref("CC::EnableSounds"))
  3328. alxPlay(RTBCC_TickSound);
  3329. }
  3330.  
  3331. //- RTBCC_RosterUser::closeRosterMenu (closes the roster menu)
  3332. function RTBCC_RosterUser::closeRosterMenu(%this)
  3333. {
  3334. if(isObject(%this.gui_menu))
  3335. {
  3336. RTBCC_Roster.gui_userMenu = "";
  3337. %this.gui_menu.schedule(1,"delete");
  3338. if(RTBCO_getPref("CC::EnableSounds"))
  3339. alxPlay(RTBCC_TickSound);
  3340. }
  3341. %this.gui_mouseEvent.extent = "170 22";
  3342. %this.gui_selectBox.setBitmap($RTB::Path @ "images/ui/buddyListSelect_n");
  3343. }
  3344.  
  3345. //- RTBCC_RosterUser::openChatWindow (opens a chat window with the user)
  3346. function RTBCC_RosterUser::openChatWindow(%this)
  3347. {
  3348. %this.closeRosterMenu();
  3349.  
  3350. if(!RTBCC_SessionManager.hasID(%this.id))
  3351. RTBCC_SessionManager.createSession(%this.id);
  3352. else
  3353. RTBCC_SessionManager.getByID(%this.id).render();
  3354. }
  3355.  
  3356. //- RTBCC_RosterUser::joinServer (joins the user's server)
  3357. function RTBCC_RosterUser::joinServer(%this,%skip)
  3358. {
  3359. %this.closeRosterMenu();
  3360.  
  3361. %ip = %this.server["ip"];
  3362. %port = %this.server["port"];
  3363.  
  3364. if(isObject(ServerConnection) && !%skip)
  3365. {
  3366. if(ServerConnection.getAddress() $= "local")
  3367. RTB_ConnectClient.messageBoxYesNo("Are you sure?","You're currently hosting a server - are you sure you want to close it and join this game?",%this@".joinServer(1);","");
  3368. else
  3369. RTB_ConnectClient.messageBoxYesNo("Are you sure?","Are you sure you want to leave your current server and join this game?",%this@".joinServer(1);","");
  3370. return;
  3371. }
  3372.  
  3373. $RTB::MCCC::Cache::Joining = %ip@":"@%port;
  3374. RTB_ConnectClient.messageBox("Joining ...","Getting server data ...");
  3375. RTBCC_Socket.getServerStatus(%ip,%port);
  3376. }
  3377.  
  3378. //- RTBCC_RosterUser::inviteToServer (invites user to your server)
  3379. function RTBCC_RosterUser::inviteToServer(%this)
  3380. {
  3381. %this.closeRosterMenu();
  3382.  
  3383. RTB_ConnectClient.messageBox("Inviting ...","Sending an invitation to "@%this.name@" ...");
  3384. RTBCC_Socket.sendServerInvite(%this.id);
  3385. }
  3386.  
  3387. //- RTBCC_RosterUser::info (shows information on the user)
  3388. function RTBCC_RosterUser::info(%this)
  3389. {
  3390. %this.closeRosterMenu();
  3391.  
  3392. RTBCC_Socket.getUserInfo(%this.id);
  3393. RTB_ConnectClient.messageBox("Please Wait ...","Getting user details for Blockland ID "@%this.id);
  3394. }
  3395.  
  3396. //- RTBCC_RosterUser::block (blocks user from contacting us)
  3397. function RTBCC_RosterUser::block(%this,%confirm)
  3398. {
  3399. %this.closeRosterMenu();
  3400.  
  3401. if(!%confirm)
  3402. RTB_ConnectClient.messageBoxYesNo("Really?","Are you sure you want to block "@%this.name@" from messaging you?",%this@".block(1);");
  3403. else
  3404. RTBCC_Socket.blockUser(%this.id);
  3405. }
  3406.  
  3407. //- RTBCC_RosterUser::unblock (allows blocked user to contact us)
  3408. function RTBCC_RosterUser::unblock(%this)
  3409. {
  3410. %this.closeRosterMenu();
  3411.  
  3412. RTBCC_Socket.unblockUser(%this.id);
  3413. }
  3414.  
  3415. //- RTBCC_RosterUser::unsubscribe (menu action to remove user from roster)
  3416. function RTBCC_RosterUser::unsubscribe(%this,%confirm)
  3417. {
  3418. %this.closeRosterMenu();
  3419.  
  3420. if(!%confirm)
  3421. RTB_ConnectClient.messageBoxYesNo("For Serious?","Are you sure you want to remove "@%this.name@" from your friends list?",%this@".unsubscribe(1);");
  3422. else
  3423. RTBCC_Socket.removeFromRoster(%this.id);
  3424. }
  3425.  
  3426. //- RTBCC_RosterUser::cancelSubscribe (menu action to remove user from roster)
  3427. function RTBCC_RosterUser::cancelSubscribe(%this,%confirm)
  3428. {
  3429. %this.closeRosterMenu();
  3430.  
  3431. if(!%confirm)
  3432. RTB_ConnectClient.messageBoxYesNo("Are you sure?","Do you really want to cancel this friend invitation?",%this@".cancelSubscribe(1);");
  3433. else
  3434. RTBCC_Socket.removeFromRoster(%this.id);
  3435. }
  3436.  
  3437. //*********************************************************
  3438. //* Invite Roster Live Rendering & Manipulation
  3439. //*********************************************************
  3440. //- RTBCC_InviteRoster (renders an indicator of number of invites)
  3441. function RTBCC_InviteRoster::render(%this)
  3442. {
  3443. if(%this.getCount() <= 0)
  3444. {
  3445. if(isObject(RTBCC_InviteButton))
  3446. {
  3447. RTBCC_InviteButton.delete();
  3448. RTBCC_Roster_Scroll.resize(3,3,196,getWord(RTBCC_Roster_Scroll.extent,1)+28);
  3449. }
  3450. }
  3451. else
  3452. {
  3453. if(isObject(RTBCC_InviteButton))
  3454. RTBCC_InviteButton.delete();
  3455. else
  3456. RTBCC_Roster_Scroll.resize(3,3,196,getWord(RTBCC_Roster_Scroll.extent,1)-28);
  3457.  
  3458. if(%this.getCount() > 1)
  3459. %text = "You have "@%this.getCount()@" friend invitations.";
  3460. else
  3461. %text = "You have 1 friend invitation.";
  3462.  
  3463. %button = new GuiBitmapButtonCtrl(RTBCC_InviteButton)
  3464. {
  3465. profile = RTB_TextEditProfile;
  3466. vertSizing = "top";
  3467. position = "4" SPC getWord(RTBCC_Window_Roster.extent,1)-54;
  3468. extent = "194 24";
  3469. bitmap = $RTB::Path@"images/ui/buttons/connectClient/infoBar";
  3470. text = " "@%text;
  3471. command = "RTBCC_InviteRoster.open();";
  3472. };
  3473. RTBCC_Window_Roster.add(%button);
  3474. }
  3475. }
  3476.  
  3477. //- RTBCC_InviteRoster::unrender (unrenders the invite roster indicator)
  3478. function RTBCC_InviteRoster::unrender(%this)
  3479. {
  3480. if(isObject(RTBCC_InviteButton))
  3481. {
  3482. RTBCC_InviteButton.delete();
  3483. RTBCC_Roster_Scroll.resize(3,29,196,getWord(RTBCC_Roster_Scroll.extent,1)+28);
  3484. }
  3485. }
  3486.  
  3487. //*********************************************************
  3488. //* Invite Roster Interaction
  3489. //*********************************************************
  3490. //- RTBCC_InviteRoster::open (opens the invite approve/deny)
  3491. function RTBCC_InviteRoster::open(%this)
  3492. {
  3493. if(%this.getCount() $= 0)
  3494. {
  3495. %this.render();
  3496. return;
  3497. }
  3498.  
  3499. if(%this.getCount() $= 1)
  3500. {
  3501. %invite = %this.getObject(0);
  3502. RTB_ConnectClient.messageBoxYesNo("Friend Request",%invite.name@" ("@%invite.id@") has requested to be friends with you. Would you like to accept?","RTBCC_InviteRoster.accept("@%invite@");","RTBCC_InviteRoster.reject("@%invite@");");
  3503. return;
  3504. }
  3505.  
  3506. RTB_ConnectClient.setModalWindow("Invites");
  3507. RTBCC_Invites_Swatch.resize(0,0,154,144);
  3508. RTBCC_Invites_Swatch.clear();
  3509.  
  3510. %nextY = 0;
  3511. for(%i=0;%i<%this.getCount();%i++)
  3512. {
  3513. %invite = %this.getObject(%i);
  3514. %mlText = new GuiMLTextCtrl()
  3515. {
  3516. position = "2" SPC %nextY;
  3517. extent = "123 24";
  3518. text = "<color:444444><font:Verdana Bold:12>"@%invite.name@"<br><font:Arial:12>Blockland ID "@%invite.id;
  3519.  
  3520. selectable = false;
  3521. };
  3522. RTBCC_Invites_Swatch.add(%mlText);
  3523.  
  3524. %checkboxA = new GuiCheckboxCtrl()
  3525. {
  3526. profile = RTB_CheckboxProfile;
  3527. position = "108" SPC %nextY;
  3528. extent = "17 24";
  3529. text = " ";
  3530. buttonType = "ToggleButton";
  3531.  
  3532. id = %invite.id;
  3533. type = "yes";
  3534. };
  3535. RTBCC_Invites_Swatch.add(%checkboxA);
  3536.  
  3537. %checkboxB = new GuiCheckboxCtrl()
  3538. {
  3539. profile = RTB_CheckboxProfile;
  3540. position = "128" SPC %nextY;
  3541. extent = "17 24";
  3542. text = " ";
  3543. buttonType = "ToggleButton";
  3544.  
  3545. id = %invite.id;
  3546. type = "no";
  3547. };
  3548. RTBCC_Invites_Swatch.add(%checkboxB);
  3549.  
  3550. %checkboxA.command = %checkboxB@".setValue(0);";
  3551. %checkboxB.command = %checkboxA@".setValue(0);";
  3552.  
  3553. if(%i < %this.getCount() - 1)
  3554. {
  3555. %divider = new GuiSwatchCtrl()
  3556. {
  3557. position = "0" SPC %nextY+27;
  3558. extent = "145 1";
  3559. color = "200 200 200 255";
  3560. minExtent = "1 1";
  3561. };
  3562. RTBCC_Invites_Swatch.add(%divider);
  3563. }
  3564. %nextY += 30;
  3565. }
  3566. RTBCC_Invites_Swatch.resize(0,0,154,%nextY);
  3567. }
  3568.  
  3569. //- RTBCC_InviteRoster::done (accepts/denies all the invites)
  3570. function RTBCC_InviteRoster::done(%this)
  3571. {
  3572. %accepted = 0;
  3573. %rejected = 0;
  3574.  
  3575. for(%i=0;%i<RTBCC_Invites_Swatch.getCount();%i++)
  3576. {
  3577. %ctrl = RTBCC_Invites_Swatch.getObject(%i);
  3578. if(%ctrl.getClassName() $= "GuiCheckboxCtrl")
  3579. {
  3580. %invite = RTBCC_InviteRoster.getByID(%ctrl.id);
  3581. if(%ctrl.type $= "yes" && %ctrl.getValue() $= 1)
  3582. {
  3583. RTBCC_InviteRoster.accept(%invite);
  3584. %accepted++;
  3585. }
  3586. else if(%ctrl.type $= "no" && %ctrl.getValue() $= 1)
  3587. {
  3588. RTBCC_InviteRoster.reject(%invite,0);
  3589. %rejected++;
  3590. }
  3591. %total++;
  3592. }
  3593. }
  3594. %total /= 2;
  3595.  
  3596. if(%accepted $= %total)
  3597. RTB_ConnectClient.messageBoxOK("Nice One!","You accepted all "@%total@" invites.");
  3598. else if(%rejected $= %total)
  3599. RTB_ConnectClient.messageBoxOK("Nice One!","You rejected all "@%total@" invites.");
  3600. else if (%rejected $= 0 && %accepted $= 0)
  3601. RTB_ConnectClient.messageBoxOK("Nice One!","You have done ... absolutely nothing?");
  3602. else if (%rejected > %accepted)
  3603. RTB_ConnectClient.messageBoxOK("Nice One!","You have rejected "@%rejected@" of your "@%total@" invites.");
  3604. else
  3605. RTB_ConnectClient.messageBoxOK("Nice One!","You have accepted "@%accepted@" of your "@%total@" invites.");
  3606. }
  3607.  
  3608. //- RTBCC_InviteRoster::close (closes the invite modal window)
  3609. function RTBCC_InviteRoster::close(%this)
  3610. {
  3611. RTB_ConnectClient.closeModalWindow();
  3612. }
  3613.  
  3614. //*********************************************************
  3615. //* Loading Window Functionality
  3616. //*********************************************************
  3617. //- RTBCC_Roster_Loading::setStage (sets the stage of loading which decides message/fps)
  3618. function RTBCC_Roster_Loading::setStage(%this,%stage)
  3619. {
  3620. if(%stage $= 1)
  3621. {
  3622. %fps = 15;
  3623. %text = "Logging In";
  3624. }
  3625. else if(%stage $= 2)
  3626. {
  3627. %fps = 30;
  3628. %text = "Loading Roster";
  3629. }
  3630. else
  3631. {
  3632. %fps = 5;
  3633. %text = "Connecting";
  3634. }
  3635. RTBCC_Loading_Ring.setVisible(true);
  3636. RTBCC_Loading_RingFail.setVisible(false);
  3637. RTBCC_Loading_Text.setText("<color:444444><font:Verdana:12><just:center>" @ %text);
  3638. RTBCC_Loading_Ring.framesPerSecond = %fps;
  3639. }
  3640.  
  3641. //- RTBCC_Roster_Loading::error (displays an error on the loading page)
  3642. function RTBCC_Roster_Loading::error(%this,%error)
  3643. {
  3644. RTBCC_Roster_Loading.setVisible(true);
  3645. RTBCC_Loading_Ring.setVisible(false);
  3646. RTBCC_Loading_RingFail.setVisible(true);
  3647. RTBCC_Loading_Text.setText("<color:FF0000><font:Verdana Bold:12><just:center>" @ %error);
  3648. if(RTB_ConnectClient.isOpen())
  3649. RTBCC_Loading_Text.forceReflow();
  3650. }
  3651.  
  3652. //*********************************************************
  3653. //* Session Manager Implementation
  3654. //*********************************************************
  3655. //- RTBCC_createSessionManager (creates a chat session manager)
  3656. function RTBCC_createSessionManager()
  3657. {
  3658. if(isObject(RTBCC_SessionManager))
  3659. {
  3660. RTBCC_SessionManager.destroy();
  3661. RTBCC_SessionManager.delete();
  3662. }
  3663.  
  3664. %manager = new ScriptGroup(RTBCC_SessionManager);
  3665. RTBGroup.add(%manager);
  3666.  
  3667. return %manager;
  3668. }
  3669.  
  3670. //- RTBCC_SessionManager::resetCursor (resets cursor to active chat or best alternative)
  3671. function RTBCC_SessionManager::resetCursor(%this)
  3672. {
  3673. if(isObject(%this.lastFocus) && %this.isMember(%this.lastFocus))
  3674. %this.lastFocus.focus();
  3675. else if(%this.getCount() > 0)
  3676. {
  3677. for(%i=%this.getCount()-1;%i>=0;%i--)
  3678. {
  3679. %session = %this.getObject(%i);
  3680. if(%session.isRendered())
  3681. {
  3682. %session.focus();
  3683. break;
  3684. }
  3685. }
  3686. }
  3687. }
  3688.  
  3689. //- RTBCC_SessionManager::createSession (creates a chat session for a user)
  3690. function RTBCC_SessionManager::createSession(%this,%id)
  3691. {
  3692. if(%this.hasID(%id))
  3693. return %this.getByID(%id);
  3694.  
  3695. if(!RTBCC_Roster.hasID(%id))
  3696. %user = RTBCC_TempRoster.getByID(%id);
  3697. else
  3698. %user = RTBCC_Roster.getByID(%id);
  3699.  
  3700. %session = new ScriptObject()
  3701. {
  3702. class = "RTBCC_Session";
  3703.  
  3704. id = %id;
  3705. user = %user;
  3706. };
  3707. %this.add(%session);
  3708.  
  3709. %session.render();
  3710.  
  3711. return %session;
  3712. }
  3713.  
  3714. //- RTBCC_SessionManager::hasID (checks to see if we have a session for this id)
  3715. function RTBCC_SessionManager::hasID(%this,%id)
  3716. {
  3717. for(%i=0;%i<%this.getCount();%i++)
  3718. {
  3719. if(%this.getObject(%i).id $= %id)
  3720. return true;
  3721. }
  3722. return false;
  3723. }
  3724.  
  3725. //- RTBCC_SessionManager::getByID (returns session by id)
  3726. function RTBCC_SessionManager::getByID(%this,%id)
  3727. {
  3728. for(%i=0;%i<%this.getCount();%i++)
  3729. {
  3730. %session = %this.getObject(%i);
  3731. if(%session.id $= %id)
  3732. return %session;
  3733. }
  3734. return false;
  3735. }
  3736.  
  3737. //- RTBCC_SessionManager::reclaim (resets user ids within sessions)
  3738. function RTBCC_SessionManager::reclaim(%this)
  3739. {
  3740. for(%i=0;%i<%this.getCount();%i++)
  3741. {
  3742. %session = %this.getObject(%i);
  3743. if(RTBCC_Roster.hasID(%session.id))
  3744. %session.user = RTBCC_Roster.getByID(%session.id);
  3745. else
  3746. %session.user = RTBCC_TempRoster.getByID(%session.id);
  3747. }
  3748. }
  3749.  
  3750. //- RTBCC_SessionManager::destroy (destroys sessions and their renderings)
  3751. function RTBCC_SessionManager::destroy(%this)
  3752. {
  3753. while(%this.getCount() >= 1)
  3754. {
  3755. %session = %this.getObject(0);
  3756. %session.unrender();
  3757. %session.delete();
  3758. }
  3759. }
  3760.  
  3761. //*********************************************************
  3762. //* Chat Session Implementation
  3763. //*********************************************************
  3764. //- RTBCC_Session::send (sends whatever is in the text box)
  3765. function RTBCC_Session::send(%this)
  3766. {
  3767. %text = %this.window.input.getValue();
  3768. if(%text $= "")
  3769. return;
  3770.  
  3771. if(!RTBCC_Socket.authenticated)
  3772. {
  3773. %this.writeNotice("You're not currently signed in!");
  3774. return;
  3775. }
  3776.  
  3777. %this.window.input.setValue("");
  3778.  
  3779. %this.stoppedTyping();
  3780. if(getSubStr(%text,0,1) $= "/")
  3781. {
  3782. if(firstWord(%text) $= "/me" || firstWord(%text) $= "/action")
  3783. {
  3784. %this.writeAction(RTB_ConnectClient.client_name,parseLinks(stripMLControlChars(restWords(%text))));
  3785. RTBCC_Socket.sendMessage(%this.id,restWords(%text),true);
  3786. }
  3787. }
  3788. else
  3789. {
  3790. %this.writeMessage(RTB_ConnectClient.client_name,parseLinks(stripMLControlChars(%text)));
  3791. RTBCC_Socket.sendMessage(%this.id,%text);
  3792. }
  3793. %this.focus();
  3794.  
  3795. %this.window.scroll.scrollToBottom();
  3796. }
  3797.  
  3798. //- RTBCC_Session::receive (handles a message packet)
  3799. function RTBCC_Session::receive(%this,%message)
  3800. {
  3801. if(!%this.isRendered())
  3802. %this.render();
  3803.  
  3804. if(%message.attrib["type"] $= "action")
  3805. %this.writeAction(%this.user.name,%message.find("body").cData);
  3806. else
  3807. %this.writeMessage(%this.user.name,%message.find("body").cData);
  3808.  
  3809. if(!RTB_Overlay.isAwake())
  3810. {
  3811. if(RTBCO_getPref("CC::Message::Beep"))
  3812. alxPlay(RTBCC_MessageSound);
  3813. if(RTBCO_getPref("CC::Message::Note"))
  3814. RTBCC_NotificationManager.push(%this.user.name,"has just sent you a message.","comments",%this.user.id@"_msg",-1);
  3815.  
  3816. %this.focus();
  3817. }
  3818. %this.lastMessage = getDateTime();
  3819. %this.updateStatus(0);
  3820. }
  3821.  
  3822. //- RTBCC_Session::handleInvite (handles an invite)
  3823. function RTBCC_Session::handleInvite(%this,%ip,%port)
  3824. {
  3825. if(!%this.isRendered())
  3826. %this.render();
  3827.  
  3828. %this.writeInfo(%this.user.name @ " has invited you to play with them.");
  3829. %this.setInviteDisplay(1);
  3830.  
  3831. %this.lastMessage = getDateTime();
  3832. }
  3833.  
  3834. //- RTBCC_Session::writeMessage (adds a user-sent message to the bottom of the ml text)
  3835. function RTBCC_Session::writeMessage(%this,%sender,%message)
  3836. {
  3837. if(RTBCO_getPref("CC::ChatLogging"))
  3838. %this.log(%sender@": "@%message);
  3839.  
  3840. %message = "<font:Verdana Bold:12>"@%sender@"<font:Verdana:12>: "@%message;
  3841.  
  3842. if(RTBCO_getPref("CC::ShowTimestamps"))
  3843. %message = "<font:Verdana Bold:12>["@getSubStr(getWord(getDateTime(),1),0,8)@"] " @ %message;
  3844.  
  3845. %this.write(%message);
  3846. }
  3847.  
  3848. //- RTBCC_Session::writeAction (adds an action message to the bottom of the ml text)
  3849. function RTBCC_Session::writeAction(%this,%sender,%message)
  3850. {
  3851. if(RTBCO_getPref("CC::ChatLogging"))
  3852. %this.log("* "@%sender@" "@%message);
  3853.  
  3854. %message = "<font:Verdana Bold:12><color:CC00CC>* "@%sender@" <font:Verdana:12>"@%message@"<color:444444>";
  3855.  
  3856. if(RTBCO_getPref("CC::ShowTimestamps"))
  3857. %message = "<font:Verdana Bold:12>["@getSubStr(getWord(getDateTime(),1),0,8)@"] " @ %message;
  3858.  
  3859. %this.write(%message);
  3860. }
  3861.  
  3862. //- RTBCC_Session::writeNotice (adds a notice message to the bottom of the ml text)
  3863. function RTBCC_Session::writeNotice(%this,%message)
  3864. {
  3865. if(RTBCO_getPref("CC::ChatLogging"))
  3866. %this.log("* "@%message);
  3867.  
  3868. %message = "<font:Verdana:12><color:666666>* "@%message@"<color:444444>";
  3869.  
  3870. if(RTBCO_getPref("CC::ShowTimestamps"))
  3871. %message = "<font:Verdana Bold:12>["@getSubStr(getWord(getDateTime(),1),0,8)@"] " @ %message;
  3872.  
  3873. %this.write(%message);
  3874. }
  3875.  
  3876. //- RTBCC_Session::writeInfo (adds an information message to the bottom of the ml text)
  3877. function RTBCC_Session::writeInfo(%this,%message)
  3878. {
  3879. if(RTBCO_getPref("CC::ChatLogging"))
  3880. %this.log("* "@%message);
  3881.  
  3882. %message = "<font:Verdana:12><color:00AA00>* "@%message@"<color:444444>";
  3883.  
  3884. if(RTBCO_getPref("CC::ShowTimestamps"))
  3885. %message = "<font:Verdana Bold:12>["@getSubStr(getWord(getDateTime(),1),0,8)@"] " @ %message;
  3886.  
  3887. %this.write(%message);
  3888. }
  3889.  
  3890. //- RTBCC_Session::writeError (adds an error message to the bottom of the ml text)
  3891. function RTBCC_Session::writeError(%this,%message)
  3892. {
  3893. %message = "<color:FF0000>* "@%message@"<color:444444>";
  3894.  
  3895. %this.write(%message);
  3896. }
  3897.  
  3898. //- RTBCC_Session::write (adds a line to the bottom of the ml text)
  3899. function RTBCC_Session::write(%this,%line)
  3900. {
  3901. if(!%this.isRendered())
  3902. return;
  3903.  
  3904. %scroll = %this.window.scroll;
  3905. %display = %this.window.display;
  3906.  
  3907. %position = getWord(%display.position,1);
  3908. if((getWord(%display.extent,1)+getWord(%display.position,1)) <= (getWord(%scroll.extent,1)-1))
  3909. %atBottom = true;
  3910.  
  3911. if(%display.getValue() $= "")
  3912. %display.setValue(%line);
  3913. else
  3914. %display.setValue(%display.getValue()@"\n"@%line);
  3915.  
  3916. if(RTB_Overlay.isAwake())
  3917. %display.forceReflow();
  3918.  
  3919. %display.setCursorPosition(strLen(%display.getValue()));
  3920.  
  3921. if(%atBottom)
  3922. %scroll.scrollToBottom();
  3923. else
  3924. %display.resize(getWord(%display.position,0),%position,getWord(%display.extent,0),getWord(%display.extent,1));
  3925. }
  3926.  
  3927. //- RTBCC_Session::log (logs a message into the chat logging)
  3928. function RTBCC_Session::log(%this,%message)
  3929. {
  3930. if(!isObject(%this.logger))
  3931. {
  3932. %this.logger = new FileObject();
  3933. %this.logger.openForAppend("config/client/rtb/logs/users/"@%this.id@".txt");
  3934. %this.logger.writeLine("");
  3935. %this.logger.writeLine(getDateTime());
  3936. %this.logger.writeLine("--");
  3937. %this.logger.close();
  3938. }
  3939. %this.logger.openForAppend("config/client/rtb/logs/users/"@%this.id@".txt");
  3940. %this.logger.writeLine("["@lastWord(getDateTime())@"] "@stripMLControlChars(%message));
  3941. %this.logger.close();
  3942.  
  3943. RTBGroup.add(%this.logger);
  3944. }
  3945.  
  3946. //- RTBCC_Session::updateStatus (updates typing status messages)
  3947. function RTBCC_Session::updateStatus(%this,%status)
  3948. {
  3949. %this.typingStatus = %status;
  3950.  
  3951. if(!%this.isRendered())
  3952. return;
  3953.  
  3954. if(%this.typingStatus $= 1)
  3955. %this.window.status.setValue("<color:888888><font:Verdana:12>"@%this.user.name@" is typing a message ...");
  3956. else if(%this.typingStatus $= 2)
  3957. %this.window.status.setValue("<color:888888><font:Verdana:12>"@%this.user.name@" has entered a message.");
  3958. else
  3959. if(%this.lastMessage !$= "" && !RTBCO_getPref("CC::ShowTimestamps"))
  3960. %this.window.status.setValue("<color:888888><font:Verdana:12>Last message received on "@getWord(%this.lastMessage,0)@" at "@getWord(%this.lastMessage,1)@".");
  3961. else
  3962. %this.window.status.setValue("");
  3963. }
  3964.  
  3965. //- RTBCC_Session::typing (indicates to server that user is typing)
  3966. function RTBCC_Session::typing(%this)
  3967. {
  3968. if(isEventPending(%this.typingSchedule))
  3969. cancel(%this.typingSchedule);
  3970.  
  3971. if(!%this.typingTo)
  3972. RTBCC_Socket.sendTypingStatus(%this.id,1);
  3973.  
  3974. %this.focus();
  3975.  
  3976. RTBCC_SessionManager.lastFocus = %this;
  3977. RTBCC_SessionManager.lastFocusTime = getSimTime();
  3978.  
  3979. %this.typingTo = true;
  3980. %this.typingSchedule = %this.schedule(3000,"stoppedTyping");
  3981. }
  3982.  
  3983. //- RTBCC_Session::stoppedTyping (notifies server that user is not typing)
  3984. function RTBCC_Session::stoppedTyping(%this)
  3985. {
  3986. if(isEventPending(%this.typingSchedule))
  3987. cancel(%this.typingSchedule);
  3988.  
  3989. %this.typingTo = false;
  3990.  
  3991. if(isObject(%this.window) && %this.window.input.getValue() !$= "")
  3992. RTBCC_Socket.sendTypingStatus(%this.id,2);
  3993. else
  3994. RTBCC_Socket.sendTypingStatus(%this.id,0);
  3995. }
  3996.  
  3997. //- RTBCC_Session::focus (brings the window into user focus)
  3998. function RTBCC_Session::focus(%this)
  3999. {
  4000. if(%this.isRendered())
  4001. {
  4002. RTB_Overlay.pushToBack(%this.window);
  4003. %this.window.input.makeFirstResponder(1);
  4004. }
  4005. }
  4006.  
  4007. //- RTBCC_Session::render (renders a chat window for the session)
  4008. function RTBCC_Session::render(%this)
  4009. {
  4010. if(%this.isRendered())
  4011. {
  4012. %this.focus();
  4013. return;
  4014. }
  4015.  
  4016. %window = new GuiWindowCtrl()
  4017. {
  4018. profile = GuiWindowProfile;
  4019. position = "0 0";
  4020. extent = "300 202";
  4021. minExtent = "300 202";
  4022. text = %this.user.name;
  4023. resizeWidth = true;
  4024. resizeHeight = true;
  4025. canMove = true;
  4026. canClose = true;
  4027. canMinimize = false;
  4028. canMaximize = false;
  4029.  
  4030. new GuiBitmapBorderCtrl()
  4031. {
  4032. profile = RTB_ContentBorderProfile;
  4033. horizSizing = "width";
  4034. vertSizing = "height";
  4035. position = "7 30";
  4036. extent = "287 140";
  4037.  
  4038. new GuiSwatchCtrl()
  4039. {
  4040. profile = GuiDefaultProfile;
  4041. horizSizing = "width";
  4042. vertSizing = "height";
  4043. position = "3 3";
  4044. extent = "281 134";
  4045. color = "255 255 255 255";
  4046.  
  4047. new GuiScrollCtrl()
  4048. {
  4049. profile = RTB_ScrollProfile;
  4050. horizSizing = "width";
  4051. vertSizing = "height";
  4052. position = "1 1";
  4053. extent = "279 119";
  4054. hScrollBar = "alwaysOff";
  4055.  
  4056. new GuiMLTextCtrl()
  4057. {
  4058. profile = RTB_MLEditProfile;
  4059. horizSizing = "width";
  4060. vertSizing = "height";
  4061. position = "1 1";
  4062. extent = "265 84";
  4063. };
  4064. };
  4065. new GuiMLTextCtrl()
  4066. {
  4067. profile = GuiDefaultProfile;
  4068. horizSizing = "right";
  4069. vertSizing = "top";
  4070. position = "2 120";
  4071. extent = "280 14";
  4072.  
  4073. selectable = false;
  4074. };
  4075. };
  4076. };
  4077.  
  4078. new GuiBitmapBorderCtrl()
  4079. {
  4080. profile = RTB_ContentBorderProfile;
  4081. horizSizing = "width";
  4082. vertSizing = "top";
  4083. position = "7 173";
  4084. extent = "262 22";
  4085.  
  4086. new GuiSwatchCtrl()
  4087. {
  4088. profile = GuiDefaultProfile;
  4089. horizSizing = "width";
  4090. vertSizing = "height";
  4091. position = "3 3";
  4092. extent = "256 16";
  4093. color = "255 255 255 255";
  4094. };
  4095.  
  4096. new GuiBitmapCtrl()
  4097. {
  4098. profile = GuiDefaultProfile;
  4099. horizSizing = "left";
  4100. vertSizing = "bottom";
  4101. position = "243 2";
  4102. extent = "16 16";
  4103. bitmap = $RTB::Path@"images/icons/bullet_go";
  4104. };
  4105.  
  4106. new GuiBitmapButtonCtrl() {
  4107. profile = "GuiDefaultProfile";
  4108. horizSizing = "left";
  4109. vertSizing = "bottom";
  4110. position = "243 2";
  4111. extent = "16 16";
  4112. command = %this@".send();";
  4113. text = " ";
  4114. };
  4115. };
  4116.  
  4117. new GuiBitmapBorderCtrl()
  4118. {
  4119. profile = RTB_ContentBorderProfile;
  4120. horizSizing = "left";
  4121. vertSizing = "top";
  4122. position = "272 173";
  4123. extent = "22 22";
  4124.  
  4125. new GuiSwatchCtrl()
  4126. {
  4127. profile = GuiDefaultProfile;
  4128. horizSizing = "width";
  4129. vertSizing = "height";
  4130. position = "3 3";
  4131. extent = "16 16";
  4132. color = "255 255 255 255";
  4133. };
  4134.  
  4135. new GuiBitmapCtrl()
  4136. {
  4137. profile = GuiDefaultProfile;
  4138. horizSizing = "left";
  4139. vertSizing = "bottom";
  4140. position = "3 3";
  4141. extent = "16 16";
  4142. bitmap = $RTB::Path@"images/icons/delete";
  4143. };
  4144.  
  4145. new GuiBitmapButtonCtrl() {
  4146. profile = "GuiDefaultProfile";
  4147. horizSizing = "left";
  4148. vertSizing = "bottom";
  4149. position = "2 2";
  4150. extent = "18 18";
  4151. command = %this@".block();";
  4152. text = " ";
  4153. };
  4154. };
  4155.  
  4156. new GuiSwatchCtrl()
  4157. {
  4158. profile = GuiDefaultProfile;
  4159. horizSizing = "width";
  4160. vertSizing = "bottom";
  4161. position = "7 30";
  4162. extent = "287 25";
  4163. color = "0 0 0 0";
  4164. visible = 0;
  4165.  
  4166. new GuiBitmapBorderCtrl()
  4167. {
  4168. profile = RTB_ContentBorderProfile;
  4169. horizSizing = "width";
  4170. vertSizing = "top";
  4171. position = "0 0";
  4172. extent = "287 25";
  4173.  
  4174. new GuiSwatchCtrl()
  4175. {
  4176. profile = GuiDefaultProfile;
  4177. horizSizing = "width";
  4178. vertSizing = "height";
  4179. position = "3 3";
  4180. extent = "281 19";
  4181. color = "255 255 255 255";
  4182. };
  4183. };
  4184. new GuiSwatchCtrl()
  4185. {
  4186. profile = GuiDefaultProfile;
  4187. horizSizing = "width";
  4188. vertSizing = "height";
  4189. position = "1 1";
  4190. extent = "285 23";
  4191. color = "100 200 100 100";
  4192. };
  4193. new GuiBitmapCtrl()
  4194. {
  4195. profile = GuiDefaultProfile;
  4196. horizSizing = "right";
  4197. vertSizing = "bottom";
  4198. position = "6 4";
  4199. extent = "16 16";
  4200. bitmap = $RTB::Path@"images/icons/email_go";
  4201. };
  4202. new GuiMLTextCtrl()
  4203. {
  4204. profile = GuiDefaultProfile;
  4205. horizSizing = "right";
  4206. vertSizing = "top";
  4207. position = "28 6";
  4208. extent = "250 12";
  4209. text = "<font:Verdana:12><color:444444>"@%this.user.name@" has invited you to play.";
  4210. selectable = false;
  4211. };
  4212. new GuiBitmapButtonCtrl() {
  4213. profile = "GuiDefaultProfile";
  4214. horizSizing = "left";
  4215. vertSizing = "bottom";
  4216. position = "0 0";
  4217. extent = "260 25";
  4218. command = %this@".user.joinServer();"@%this@".setInviteDisplay(0);";
  4219. text = " ";
  4220. };
  4221. new GuiBitmapButtonCtrl() {
  4222. profile = "GuiDefaultProfile";
  4223. horizSizing = "left";
  4224. vertSizing = "bottom";
  4225. position = "269 8";
  4226. extent = "9 9";
  4227. command = %this@".setInviteDisplay(0);";
  4228. text = " ";
  4229. bitmap = $RTB::Path@"images/ui/buttons/connectClient/closeInvite";
  4230. };
  4231. };
  4232. };
  4233. RTB_Overlay.add(%window);
  4234.  
  4235. %input = RTBCC_InputRecycler.get();
  4236. %window.getObject(1).add(%input);
  4237. %input.horizSizing = "width";
  4238. %input.vertSizing = "bottom";
  4239. %input.position = "1 3";
  4240. %input.extent = "240 16";
  4241. %input.command = %this@".typing();";
  4242. %input.altCommand = %this@".send();";
  4243.  
  4244. %window.scrollContainer = %window.getObject(0);
  4245. %window.scroll = %window.scrollContainer.getObject(0).getObject(0);
  4246. %window.status = %window.scrollContainer.getObject(0).getObject(1);
  4247. %window.display = %window.scroll.getObject(0);
  4248. %window.input = %input;
  4249. %window.blockBtn = %window.getObject(2);
  4250. %window.inviteBanner = %window.getObject(3);
  4251. %window.closeCommand = %this@".unrender();";
  4252.  
  4253. if(%this.user.state $= "blocked")
  4254. {
  4255. %window.blockBtn.getObject(1).setBitmap($RTB::Path@"images/icons/unblock");
  4256. %window.blockBtn.getObject(2).command = %this@".unblock();";
  4257. }
  4258. else
  4259. {
  4260. %window.blockBtn.getObject(1).setBitmap($RTB::Path@"images/icons/delete");
  4261. %window.blockBtn.getObject(2).command = %this@".block();";
  4262. }
  4263.  
  4264. %window.session = %this;
  4265. %this.window = %window;
  4266.  
  4267. %this.positionWindow();
  4268.  
  4269. if(%this.user.conversationHistory !$= "")
  4270. {
  4271. %history = strReplace(strReplace(%this.user.conversationHistory,"\n","<br>"),"<color:","\t");
  4272. %this.user.conversationHistory = "";
  4273.  
  4274. %text = getField(%history,0);
  4275. for(%i=1;%i<getFieldCount(%history);%i++)
  4276. {
  4277. %part = getField(%history,%i);
  4278. %text = %text @ "<color:CCCCCC>" @ getSubStr(%part,7,strLen(%part));
  4279. }
  4280. %window.display.setText("<color:CCCCCC>"@%text@"<color:444444>");
  4281.  
  4282. %window.display.setCursorPosition(strLen(%window.display.getValue()));
  4283. %window.scroll.scrollToBottom();
  4284. }
  4285. }
  4286.  
  4287. //- RTBCC_Session::positionWindow (determines best position to render chat window)
  4288. function RTBCC_Session::positionWindow(%this)
  4289. {
  4290. %offset = 0;
  4291. %position = "0 0";
  4292. while(%free !$= true)
  4293. {
  4294. %free = true;
  4295. for(%i=0;%i<RTBCC_SessionManager.getCount();%i++)
  4296. {
  4297. %session = RTBCC_SessionManager.getObject(%i);
  4298. if(!%session.isRendered() || %session $= %this)
  4299. continue;
  4300.  
  4301. if(%session.window.position $= %position)
  4302. {
  4303. %free = false;
  4304. break;
  4305. }
  4306. }
  4307.  
  4308. if(%free !$= true)
  4309. {
  4310. %offset += 40;
  4311. %position = %offset SPC %offset;
  4312. }
  4313. }
  4314. %this.window.position = %position;
  4315. }
  4316.  
  4317. //- RTBCC_Session::isRendered (determines whether the session chat is rendered)
  4318. function RTBCC_Session::isRendered(%this)
  4319. {
  4320. if(isObject(%this.window) && %this.window.session $= %this)
  4321. return true;
  4322. return false;
  4323. }
  4324.  
  4325. //- RTBCC_Session::unrender (unrenders the session chat window)
  4326. function RTBCC_Session::unrender(%this)
  4327. {
  4328. if(!%this.isRendered())
  4329. return;
  4330.  
  4331. if(%this.window.input.getValue() !$= "")
  4332. RTBCC_Socket.sendTypingStatus(%this.id,0);
  4333.  
  4334. %this.user.conversationHistory = %this.window.display.getValue();
  4335.  
  4336. RTBCC_InputRecycler.reclaim(%this.window.input);
  4337. %this.window.delete();
  4338. %this.window = "";
  4339. }
  4340.  
  4341. //- RTBCC_Session::block (blocks the user you're talking to)
  4342. function RTBCC_Session::block(%this)
  4343. {
  4344. RTBCC_Socket.blockUser(%this.user.id);
  4345. }
  4346.  
  4347. //- RTBCC_Session::unblock (unblocks the user you're talking to)
  4348. function RTBCC_Session::unblock(%this)
  4349. {
  4350. RTBCC_Socket.unblockUser(%this.user.id);
  4351. }
  4352.  
  4353. //- RTBCC_Session::setBlockedStatus (switches block buttons)
  4354. function RTBCC_Session::setBlockedStatus(%this,%status)
  4355. {
  4356. if(%status $= 1)
  4357. {
  4358. %this.window.blockBtn.getObject(1).setBitmap($RTB::Path@"images/icons/unblock");
  4359. %this.window.blockBtn.getObject(2).command = %this@".unblock();";
  4360. }
  4361. else
  4362. {
  4363. %this.window.blockBtn.getObject(1).setBitmap($RTB::Path@"images/icons/delete");
  4364. %this.window.blockBtn.getObject(2).command = %this@".block();";
  4365. }
  4366. }
  4367.  
  4368. //- RTBCC_Session::setInviteDisplay (shows or hides the invitation banner)
  4369. function RTBCC_Session::setInviteDisplay(%this,%display)
  4370. {
  4371. if(!%this.isRendered())
  4372. return;
  4373.  
  4374. if(%display)
  4375. {
  4376. if(%this.window.inviteBanner.isVisible())
  4377. return;
  4378.  
  4379. %this.window.scrollContainer.resize(7,58,getWord(%this.window.scrollContainer.extent,0),getWord(%this.window.scrollContainer.extent,1)-28);
  4380. %this.window.inviteBanner.setVisible(true);
  4381. }
  4382. else
  4383. {
  4384. if(!%this.window.inviteBanner.isVisible())
  4385. return;
  4386.  
  4387. %this.window.scrollContainer.resize(7,30,getWord(%this.window.scrollContainer.extent,0),getWord(%this.window.scrollContainer.extent,1)+28);
  4388. %this.window.inviteBanner.setVisible(false);
  4389. }
  4390. }
  4391.  
  4392. //*********************************************************
  4393. //* Room Manager Implementation
  4394. //*********************************************************
  4395. //- RTBCC_createRoomManager (creates a room manager)
  4396. function RTBCC_createRoomManager()
  4397. {
  4398. if(isObject(RTBCC_RoomManager))
  4399. RTBCC_RoomManager.delete();
  4400.  
  4401. %manager = new ScriptGroup(RTBCC_RoomManager);
  4402. RTBGroup.add(%manager);
  4403.  
  4404. %manager.addGroup("Public Rooms",1,"world");
  4405. %manager.addGroup("Player Rooms",2,"heart");
  4406. %manager.addGroup("Other Rooms",0,"world");
  4407.  
  4408. return %manager;
  4409. }
  4410.  
  4411. //- RTBCC_RoomManager::getRooms (obtain a list of rooms from the server)
  4412. function RTBCC_RoomManager::getRooms(%this)
  4413. {
  4414. RTBCC_Socket.getRoomList();
  4415. }
  4416.  
  4417. //- RTBCC_RoomManager::updateRooms (updates room list)
  4418. function RTBCC_RoomManager::updateRooms(%this)
  4419. {
  4420. RTBCC_Socket.getRoomList(1);
  4421. }
  4422.  
  4423. //- RTBCC_RoomManager::refresh (refreshes room details every 10 seconds)
  4424. function RTBCC_RoomManager::refresh(%this)
  4425. {
  4426. if(isEventPending(%this.refreshSchedule))
  4427. cancel(%this.refreshSchedule);
  4428.  
  4429. %this.updateRooms();
  4430. %this.refreshSchedule = %this.schedule(10000,"refresh");
  4431. }
  4432.  
  4433. //- RTBCC_RoomManager::stopRefresh (stops room refresh)
  4434. function RTBCC_RoomManager::stopRefresh(%this)
  4435. {
  4436. if(isEventPending(%this.refreshSchedule))
  4437. cancel(%this.refreshSchedule);
  4438. }
  4439.  
  4440. //- RTBCC_RoomManager::performAutoJoins (auto joins rooms)
  4441. function RTBCC_RoomManager::performAutoJoins(%this)
  4442. {
  4443. for(%i=0;%i<%this.getCount();%i++)
  4444. {
  4445. %group = %this.getObject(%i);
  4446. for(%j=0;%j<%group.getCount();%j++)
  4447. {
  4448. %room = %group.getObject(%j);
  4449. if(RTBCC_RoomOptionsManager.hasRoomStore(%room.name))
  4450. {
  4451. %store = RTBCC_RoomOptionsManager.getRoomStore(%room.name);
  4452. if(%store.autojoin)
  4453. %room.join();
  4454. }
  4455. }
  4456. }
  4457. }
  4458.  
  4459. //- RTBCC_RoomManager::addRoom (creates new room object)
  4460. function RTBCC_RoomManager::addRoom(%this,%name,%icon,%type,%owner,%users,%update)
  4461. {
  4462. %group = %this.getGroupByType(%type);
  4463. if(%group.hasRoom(%name))
  4464. {
  4465. %room = %group.getRoomByName(%name);
  4466. %room.users = %users;
  4467. %room.render();
  4468. return %room;
  4469. }
  4470.  
  4471. if(%update)
  4472. return false;
  4473.  
  4474. %room = %group.addRoom(%name,%icon,%owner,%users);
  4475.  
  4476. return %room;
  4477. }
  4478.  
  4479. //- RTBCC_RoomManager::hasRoom (checks for a room)
  4480. function RTBCC_RoomManager::hasRoom(%this,%name)
  4481. {
  4482. for(%i=0;%i<%this.getCount();%i++)
  4483. {
  4484. %group = %this.getObject(%i);
  4485. if(%group.hasRoom(%name))
  4486. return true;
  4487. }
  4488. return false;
  4489. }
  4490.  
  4491. //- RTBCC_RoomManager::getRoomByName (returns a room by name)
  4492. function RTBCC_RoomManager::getRoomByName(%this,%name)
  4493. {
  4494. if(!%this.hasRoom(%name))
  4495. return false;
  4496.  
  4497. for(%i=0;%i<%this.getCount();%i++)
  4498. {
  4499. %group = %this.getObject(%i);
  4500. if(%group.hasRoom(%name))
  4501. return %group.getRoomByName(%name);
  4502. }
  4503. return false;
  4504. }
  4505.  
  4506. //- RTBCC_RoomManager::addGroup (adds a new room group)
  4507. function RTBCC_RoomManager::addGroup(%this,%name,%type,%icon)
  4508. {
  4509. if(%this.hasGroup(%name))
  4510. return %this.getGroupByName(%name);
  4511.  
  4512. %group = new ScriptGroup()
  4513. {
  4514. class = "RTBCC_RoomGroup";
  4515.  
  4516. name = %name;
  4517. type = %type;
  4518. icon = "folder_user";
  4519. };
  4520. %this.add(%group);
  4521.  
  4522. if(%icon !$= "")
  4523. %group.icon = %icon;
  4524.  
  4525. return %group;
  4526. }
  4527.  
  4528. //- RTBCC_RoomManager::hasGroup (checks if a room group exists)
  4529. function RTBCC_RoomManager::hasGroup(%this,%name)
  4530. {
  4531. for(%i=0;%i<%this.getCount();%i++)
  4532. {
  4533. if(%this.getObject(%i).name $= %name)
  4534. return true;
  4535. }
  4536. return false;
  4537. }
  4538.  
  4539. //- RTBCC_RoomManager::getGroupByName (returns a room group by name)
  4540. function RTBCC_RoomManager::getGroupByName(%this,%name)
  4541. {
  4542. if(!%this.hasGroup(%name))
  4543. return false;
  4544.  
  4545. for(%i=0;%i<%this.getCount();%i++)
  4546. {
  4547. %group = %this.getObject(%i);
  4548. if(%group.name $= %name)
  4549. return %group;
  4550. }
  4551. return false;
  4552. }
  4553.  
  4554. //- RTBCC_RoomManager::getGroupByType (returns a room group by type)
  4555. function RTBCC_RoomManager::getGroupByType(%this,%type)
  4556. {
  4557. for(%i=0;%i<%this.getCount();%i++)
  4558. {
  4559. %group = %this.getObject(%i);
  4560. if(%group.type $= %type)
  4561. return %group;
  4562. }
  4563. return false;
  4564. }
  4565.  
  4566. //*********************************************************
  4567. //* Room Group Implementation
  4568. //*********************************************************
  4569. //- RTBCC_RoomGroup::addRoom (adds a room to the group)
  4570. function RTBCC_RoomGroup::addRoom(%this,%name,%icon,%owner,%users)
  4571. {
  4572. if(%this.hasRoom(%name))
  4573. return %this.getRoomByName(%name);
  4574.  
  4575. %room = new ScriptGroup()
  4576. {
  4577. class = "RTBCC_Room";
  4578. type = %this.name;
  4579.  
  4580. name = %name;
  4581. type = %this.type;
  4582. icon = %icon;
  4583. owner = %owner;
  4584. users = %users;
  4585. };
  4586. %this.add(%room);
  4587.  
  4588. return %room;
  4589. }
  4590.  
  4591. //- RTBCC_RoomGroup::hasRoom (checks if a room exists)
  4592. function RTBCC_RoomGroup::hasRoom(%this,%name)
  4593. {
  4594. for(%i=0;%i<%this.getCount();%i++)
  4595. {
  4596. if(%this.getObject(%i).name $= %name)
  4597. return true;
  4598. }
  4599. return false;
  4600. }
  4601.  
  4602. //- RTBCC_RoomGroup::getRoomByName (returns a room by name)
  4603. function RTBCC_RoomGroup::getRoomByName(%this,%name)
  4604. {
  4605. if(!%this.hasRoom(%name))
  4606. return false;
  4607.  
  4608. for(%i=0;%i<%this.getCount();%i++)
  4609. {
  4610. %room = %this.getObject(%i);
  4611. if(%room.name $= %name)
  4612. return %room;
  4613. }
  4614. return false;
  4615. }
  4616.  
  4617. //- RTBCC_RoomGroup::removeRoomByName (removes a room by name)
  4618. function RTBCC_RoomGroup::removeRoomByName(%this,%name)
  4619. {
  4620. // to be implemented
  4621. }
  4622.  
  4623. //*********************************************************
  4624. //* Room Rendering & Manipulation
  4625. //*********************************************************
  4626. //- RTBCC_Chat_Swatch::clear (resizes the swatch to the correct extent)
  4627. function RTBCC_Chat_Swatch::clear(%this)
  4628. {
  4629. Parent::clear(%this);
  4630. %this.resize(1,1,194,getWord(RTBCC_Chat_Scroll.extent,1)-2);
  4631. }
  4632.  
  4633. //- RTBCC_Chat_Swatch::reshape (shapes the size of the chat swatch to be high enough)
  4634. function RTBCC_Chat_Swatch::reshape(%this)
  4635. {
  4636. if(%this.getLowestPoint() < (getWord(RTBCC_Chat_Scroll.extent,1)-2))
  4637. %this.resize(1,getWord(%this.position,1),194,getWord(RTBCC_Chat_Scroll.extent,1)-2);
  4638. else
  4639. %this.resize(1,getWord(%this.position,1),194,%this.getLowestPoint());
  4640. }
  4641.  
  4642. //- RTBCC_RoomManager::render (renders the room panel)
  4643. function RTBCC_RoomManager::render(%this)
  4644. {
  4645. RTBCC_Chat_Swatch.clear();
  4646.  
  4647. for(%i=0;%i<%this.getCount();%i++)
  4648. {
  4649. %group = %this.getObject(%i);
  4650. if(%group.getCount() <= 0)
  4651. continue;
  4652.  
  4653. %group.render();
  4654. }
  4655. }
  4656.  
  4657. //- RTBCC_Room::join (tries to join a room)
  4658. function RTBCC_Room::join(%this)
  4659. {
  4660. RTB_ConnectClient.messageBox(%this.name, "Attempting to join room ...");
  4661. RTBCC_Socket.joinRoom(%this.name);
  4662. }
  4663.  
  4664. //- RTBCC_Room::leave (tries to leave a room)
  4665. function RTBCC_Room::leave(%this,%direct)
  4666. {
  4667. if(!%direct)
  4668. {
  4669. %room = RTBCC_RoomSessionManager.getRoomByName(%this.name);
  4670. if(%room.window.modalSwatch.isVisible())
  4671. {
  4672. %room.closeModalWindow();
  4673. return;
  4674. }
  4675. }
  4676.  
  4677. RTBCC_RoomSessionManager.getRoomByName(%this.name).destroy();
  4678. RTBCC_Socket.leaveRoom(%this.name);
  4679.  
  4680. if(RTB_ConnectClient.isOpen() && RTB_ConnectClient.currPane $= "RTBCC_Window_Chat")
  4681. RTBCC_RoomManager.refresh();
  4682. }
  4683.  
  4684. //- RTBCC_Room::isRendered (checks to see if the room is rendered already)
  4685. function RTBCC_Room::isRendered(%this)
  4686. {
  4687. if(!isObject(%this.gui_container))
  4688. return false;
  4689.  
  4690. if(%this.gui_container.getGroup().getID() !$= %this.getGroup().container.getID())
  4691. return false;
  4692.  
  4693. return true;
  4694. }
  4695.  
  4696. //- RTBCC_Room::render (attempts to render the room)
  4697. function RTBCC_Room::render(%this)
  4698. {
  4699. if(%this.isRendered())
  4700. {
  4701. %ml = %this.gui_container.userText;
  4702. if(%this.users $= 1)
  4703. %ml.setText(%ml.prepend @ %this.users @ " User");
  4704. else
  4705. %ml.setText(%ml.prepend @ %this.users @ " Users");
  4706. }
  4707. else
  4708. {
  4709. if(!%this.getGroup().isRendered())
  4710. %this.getGroup().render();
  4711. else
  4712. {
  4713. %position = 32;
  4714. //%this.getGroup().sort();
  4715. for(%i=0;%i<%this.getGroup().getCount();%i++)
  4716. {
  4717. %room = %this.getGroup().getObject(%i);
  4718. if(!%room.isRendered() && %room !$= %this)
  4719. continue;
  4720.  
  4721. if(%this $= %room)
  4722. {
  4723. %this.getGroup().container.conditionalShiftY(%position,40);
  4724. %this.renderInPlace("16" SPC %position);
  4725. %this.getGroup().container.extent = vectorAdd(%this.getGroup().container.extent,"0 40");
  4726. RTBCC_Chat_Swatch.conditionalShiftY(getWord(%this.getGroup().container.position,1) + 1,40);
  4727. }
  4728. else
  4729. %position += 40;
  4730. }
  4731. RTBCC_Chat_Swatch.reshape();
  4732. }
  4733. }
  4734. }
  4735.  
  4736. //- RTBCC_Room::renderInPlace (renders a room taking a position argument)
  4737. function RTBCC_Room::renderInPlace(%this,%position)
  4738. {
  4739. if(%this.isRendered())
  4740. return;
  4741.  
  4742. %swatch = %this.getGroup().container;
  4743.  
  4744. if(%this.type == 1)
  4745. {
  4746. %container = new GuiBitmapCtrl()
  4747. {
  4748. position = %position;
  4749. extent = "164 36";
  4750. bitmap = $RTB::Path @ "images/ui/roomBody";
  4751.  
  4752. new GuiBitmapCtrl()
  4753. {
  4754. position = "5 5";
  4755. extent = "16 16";
  4756. bitmap = $RTB::Path @ "images/icons/" @ %this.icon;
  4757. };
  4758.  
  4759. new GuiMLTextCtrl()
  4760. {
  4761. position = "27 7";
  4762. extent = "150 12";
  4763. text = "<color:FFFFFF><font:Verdana Bold:12>" @ %this.name;
  4764. };
  4765.  
  4766. new GuiMLTextCtrl()
  4767. {
  4768. position = "29 20";
  4769. extent = "150 12";
  4770. prepend = "<color:DDDDDD><font:Arial:12>";
  4771. };
  4772.  
  4773. new GuiSwatchCtrl()
  4774. {
  4775. position = "0 0";
  4776. extent = "164 36";
  4777. color = "255 255 255 50";
  4778. visible = false;
  4779. };
  4780.  
  4781. new GuiMouseEventCtrl()
  4782. {
  4783. position = "0 0";
  4784. extent = "164 36";
  4785.  
  4786. room = %this;
  4787.  
  4788. eventType = "roomSelect";
  4789. eventCallbacks = "1111000";
  4790. };
  4791. };
  4792. %swatch.add(%container);
  4793.  
  4794. %container.userText = %container.getObject(2);
  4795. }
  4796. else if(%this.type == 2)
  4797. {
  4798. %container = new GuiSwatchCtrl()
  4799. {
  4800. position = "2" SPC getWord(%position,1);
  4801. extent = "180 36";
  4802. color = "0 0 0 0";
  4803.  
  4804. new GuiBitmapCtrl()
  4805. {
  4806. position = "0 0";
  4807. extent = "180 31";
  4808. bitmap = $RTB::Path @ "images/ui/roomBodyBack";
  4809. visible = false;
  4810. };
  4811.  
  4812. new GuiBitmapCtrl()
  4813. {
  4814. position = "5 6";
  4815. extent = "16 16";
  4816. bitmap = $RTB::Path @ "images/icons/lock";
  4817. visible = true;
  4818. };
  4819.  
  4820. new GuiMLTextCtrl()
  4821. {
  4822. position = "27 3";
  4823. extent = "150 12";
  4824. text = "<color:666666><font:Verdana Bold:12>" @ %this.name;
  4825. };
  4826.  
  4827. new GuiMLTextCtrl()
  4828. {
  4829. position = "29 15";
  4830. extent = "150 12";
  4831. prepend = "<color:888888><font:Arial:12>";
  4832. };
  4833.  
  4834. new GuiSwatchCtrl()
  4835. {
  4836. position = "26 35";
  4837. extent = "148 1";
  4838. minExtent = "1 1";
  4839. color = "200 200 200 255";
  4840. };
  4841.  
  4842. new GuiBitmapCtrl()
  4843. {
  4844. position = "161 1";
  4845. extent = "16 16";
  4846. bitmap = $RTB::Path @ "images/icons/bullet_go";
  4847. };
  4848.  
  4849. new GuiSwatchCtrl()
  4850. {
  4851. position = "0 0";
  4852. extent = "180 36";
  4853. color = "255 255 255 100";
  4854. visible = false;
  4855. };
  4856.  
  4857. new GuiMouseEventCtrl()
  4858. {
  4859. position = "0 0";
  4860. extent = "180 36";
  4861.  
  4862. room = %this;
  4863.  
  4864. eventType = "roomSelectOther";
  4865. eventCallbacks = "1111000";
  4866. };
  4867. };
  4868. %swatch.add(%container);
  4869.  
  4870. %container.userText = %container.getObject(3);
  4871. }
  4872. %this.gui_container = %container;
  4873.  
  4874. %this.render();
  4875. }
  4876.  
  4877. //- Event_roomSelect::onMouseEnter (onMouseEnter callback)
  4878. function Event_roomSelect::onMouseEnter(%this)
  4879. {
  4880. %this.getGroup().getObject(3).color = "255 255 255 50";
  4881. %this.getGroup().getObject(3).setVisible(true);
  4882. }
  4883.  
  4884. //- Event_roomSelect::onMouseLeave (onMouseLeave callback)
  4885. function Event_roomSelect::onMouseLeave(%this)
  4886. {
  4887. %this.getGroup().getObject(3).setVisible(false);
  4888. }
  4889.  
  4890. //- Event_roomSelect::onMouseDown (onMouseDown callback)
  4891. function Event_roomSelect::onMouseDown(%this)
  4892. {
  4893. %this.getGroup().getObject(3).color = "255 255 255 100";
  4894. }
  4895.  
  4896. //- Event_roomSelect::onMouseUp (onMouseUp callback)
  4897. function Event_roomSelect::onMouseUp(%this)
  4898. {
  4899. %this.getGroup().getObject(3).color = "255 255 255 50";
  4900.  
  4901. if(RTBCC_RoomSessionManager.hasRoom(%this.room.name))
  4902. RTBCC_RoomSessionManager.getRoomByName(%this.room.name).focus();
  4903. else
  4904. %this.room.join();
  4905. }
  4906.  
  4907. //- Event_roomSelectOther::onMouseEnter (onMouseEnter callback)
  4908. function Event_roomSelectOther::onMouseEnter(%this)
  4909. {
  4910. %this.getGroup().getObject(0).setVisible(true);
  4911. %this.getGroup().getObject(6).setVisible(false);
  4912. }
  4913.  
  4914. //- Event_roomSelectOther::onMouseLeave (onMouseLeave callback)
  4915. function Event_roomSelectOther::onMouseLeave(%this)
  4916. {
  4917. %this.getGroup().getObject(0).setVisible(false);
  4918. %this.getGroup().getObject(6).setVisible(false);
  4919. }
  4920.  
  4921. //- Event_roomSelectOther::onMouseDown (onMouseDown callback)
  4922. function Event_roomSelectOther::onMouseDown(%this)
  4923. {
  4924. %this.getGroup().getObject(6).setVisible(true);
  4925. }
  4926.  
  4927. //- Event_roomSelectOther::onMouseUp (onMouseUp callback)
  4928. function Event_roomSelectOther::onMouseUp(%this)
  4929. {
  4930. %this.getGroup().getObject(6).setVisible(false);
  4931. }
  4932.  
  4933. //- RTBCC_Room::rerender (rerenders the room if it's already rendered)
  4934. function RTBCC_Room::rerender(%this)
  4935. {
  4936. if(%this.isRendered())
  4937. %this.unrender();
  4938. %this.render();
  4939. }
  4940.  
  4941. //- RTBCC_Room::unrender (unrenders the room and parent group if empty)
  4942. function RTBCC_Room::unrender(%this)
  4943. {
  4944. if(!%this.isRendered())
  4945. return;
  4946.  
  4947. %position = getWord(%this.gui_container.position,1);
  4948.  
  4949. %this.gui_container.delete();
  4950.  
  4951. %this.getGroup().container.conditionalShiftY(%position,-40);
  4952. %this.getGroup().container.extent = vectorSub(%this.getGroup().container.extent,"0 40");
  4953. RTBCC_Chat_Swatch.conditionalShiftY(getWord(%this.getGroup().container.position,1)+1,-40);
  4954.  
  4955. RTBCC_Chat_Swatch.reshape();
  4956. }
  4957.  
  4958. //- RTBCC_RoomGroup::isRendered (checks to see if the room group is rendered already)
  4959. function RTBCC_RoomGroup::isRendered(%this)
  4960. {
  4961. if(!isObject(%this.container))
  4962. return false;
  4963.  
  4964. if(!isObject(%this.container.getGroup()) || %this.container.getGroup().getID() !$= RTBCC_Chat_Swatch.getID())
  4965. return false;
  4966.  
  4967. return true;
  4968. }
  4969.  
  4970. //- RTBCC_RoomGroup::render (attempts to render the rogoom group and rooms)
  4971. function RTBCC_RoomGroup::render(%this)
  4972. {
  4973. if(%this.isRendered())
  4974. return;
  4975.  
  4976. if(%this.getCount() <= 0)
  4977. return;
  4978.  
  4979. %position = 0;
  4980. for(%i=0;%i<RTBCC_RoomManager.getCount();%i++)
  4981. {
  4982. %group = RTBCC_RoomManager.getObject(%i);
  4983. if(!%group.isRendered() && %this !$= %group)
  4984. continue;
  4985.  
  4986. if(%this $= %group)
  4987. {
  4988. %extent = ((%group.getCount() + 1) * 40) + 4;
  4989. RTBCC_Chat_Swatch.conditionalShiftY(%position,%extent);
  4990.  
  4991. %group.renderInPlace("0" SPC %position);
  4992.  
  4993. for(%j=0;%j<%group.getCount();%j++)
  4994. {
  4995. %position = "18" SPC (%j * 40) + 32;
  4996. %group.getObject(%j).renderInPlace(%position);
  4997. }
  4998. }
  4999. else
  5000. %position += getWord(%group.container.extent,1);
  5001. }
  5002. RTBCC_Chat_Swatch.reshape();
  5003. }
  5004.  
  5005. //- RTBCC_RoomGroup::renderInPlace (renders a room group taking a position argument)
  5006. function RTBCC_RoomGroup::renderInPlace(%this,%position)
  5007. {
  5008. %extent = (%this.getCount() * 40) + 30;
  5009. %this.container = new GuiSwatchCtrl()
  5010. {
  5011. position = %position;
  5012. extent = "194" SPC %extent;
  5013. color = "0 0 0 0";
  5014.  
  5015. new GuiBitmapCtrl()
  5016. {
  5017. position = "2 2";
  5018. extent = "180 26";
  5019. bitmap = $RTB::Path @ "images/ui/roomGroupHeader";
  5020.  
  5021. new GuiBitmapCtrl()
  5022. {
  5023. position = "5 5";
  5024. extent = "16 16";
  5025. bitmap = $RTB::Path @ "images/icons/" @ %this.icon;
  5026. };
  5027.  
  5028. new GuiMLTextCtrl()
  5029. {
  5030. position = "27 7";
  5031. extent = "150 12";
  5032. text = "<color:EEEEEE><font:Verdana Bold:12>" @ %this.name;
  5033.  
  5034. selectable = false;
  5035. };
  5036. };
  5037. };
  5038. RTBCC_Chat_Swatch.add(%this.container);
  5039. }
  5040.  
  5041. //- RTBCC_RoomGroup::rerender (rerenders the room group if it's already rendered)
  5042. function RTBCC_RoomGroup::rerender(%this)
  5043. {
  5044. if(%this.isRendered())
  5045. %this.unrender();
  5046. %this.render();
  5047. }
  5048.  
  5049. //- RTBCC_RoomGroup::unrender (unrenders a room group and its user items)
  5050. function RTBCC_RoomGroup::unrender(%this)
  5051. {
  5052. if(!%this.isRendered())
  5053. return;
  5054.  
  5055. %position = getWord(%this.container.position,1);
  5056. %extent = getWord(%this.container.extent,1);
  5057.  
  5058. %this.container.delete();
  5059. RTBCC_Chat_Swatch.conditionalShiftY(%position,"-"@%extent);
  5060. RTBCC_Chat_Swatch.reshape();
  5061. }
  5062.  
  5063. //*********************************************************
  5064. //* Room Session Manager Implementation
  5065. //*********************************************************
  5066. //- RTBCC_createRoomSessionManager (creates a room session manager)
  5067. function RTBCC_createRoomSessionManager()
  5068. {
  5069. if(isObject(RTBCC_RoomSessionManager))
  5070. {
  5071. RTBCC_RoomSessionManager.destroy();
  5072. RTBCC_RoomSessionManager.delete();
  5073. }
  5074. %manager = new ScriptGroup(RTBCC_RoomSessionManager);
  5075. RTBGroup.add(%manager);
  5076.  
  5077. return %manager;
  5078. }
  5079.  
  5080. //- RTBCC_RoomSessionManager::createSession (creates a session and manifest)
  5081. function RTBCC_RoomSessionManager::createSession(%this,%name)
  5082. {
  5083. if(%this.hasRoom(%name))
  5084. return %this.getRoomByName(%name);
  5085.  
  5086. %session = new ScriptGroup()
  5087. {
  5088. class = "RTBCC_RoomSession";
  5089.  
  5090. name = %name;
  5091. room = RTBCC_RoomManager.getRoomByName(%name);
  5092. };
  5093. %this.add(%session);
  5094.  
  5095. %manifest = new ScriptGroup()
  5096. {
  5097. class = "RTBCC_RoomSessionManifest";
  5098.  
  5099. session = %session;
  5100. };
  5101. %session.add(%manifest);
  5102. %session.manifest = %manifest;
  5103.  
  5104. %session.render();
  5105.  
  5106. return %session;
  5107. }
  5108.  
  5109. //- RTBCC_RoomSessionManager::resetCursor (resets cursor to active room or best alternative)
  5110. function RTBCC_RoomSessionManager::resetCursor(%this)
  5111. {
  5112. if(isObject(%this.lastFocus) && %this.isMember(%this.lastFocus))
  5113. %this.lastFocus.focus();
  5114. else if(%this.getCount() > 0)
  5115. {
  5116. for(%i=%this.getCount()-1;%i>=0;%i--)
  5117. {
  5118. %session = %this.getObject(%i);
  5119. if(%session.isRendered())
  5120. {
  5121. %session.focus();
  5122. break;
  5123. }
  5124. }
  5125. }
  5126. }
  5127.  
  5128. //- RTBCC_RoomSessionManager::hasRoom (checks for a room session by name)
  5129. function RTBCC_RoomSessionManager::hasRoom(%this,%name)
  5130. {
  5131. for(%i=0;%i<%this.getCount();%i++)
  5132. {
  5133. if(%this.getObject(%i).name $= %name)
  5134. return true;
  5135. }
  5136. return false;
  5137. }
  5138.  
  5139. //- RTBCC_RoomSessionManager::getRoomByName (returns a room session by name)
  5140. function RTBCC_RoomSessionManager::getRoomByName(%this,%name)
  5141. {
  5142. if(!%this.hasRoom(%name))
  5143. return false;
  5144.  
  5145. for(%i=0;%i<%this.getCount();%i++)
  5146. {
  5147. %object = %this.getObject(%i);
  5148. if(%object.name $= %name)
  5149. return %object;
  5150. }
  5151. return false;
  5152. }
  5153.  
  5154. //- RTBCC_RoomSessionManager::reclaim (re-focuses room pointer incase things got frisky)
  5155. function RTBCC_RoomSessionManager::reclaim(%this)
  5156. {
  5157. for(%i=0;%i<%this.getCount();%i++)
  5158. {
  5159. %session = %this.getObject(%i);
  5160. %session.room = RTBCC_RoomManager.getRoomByName(%session.name);
  5161. }
  5162. }
  5163.  
  5164. //- RTBCC_RoomSessionManager::destroy (destroys all room sessions)
  5165. function RTBCC_RoomSessionManager::destroy(%this)
  5166. {
  5167. while(%this.getCount() >= 1)
  5168. {
  5169. %this.getObject(0).destroy();
  5170. }
  5171. }
  5172.  
  5173. //*********************************************************
  5174. //* Room Session Implementation
  5175. //*********************************************************
  5176. //- RTBCC_RoomSession::onNotice (handles room session notice)
  5177. function RTBCC_RoomSession::onNotice(%this,%parser,%packet)
  5178. {
  5179. if(%packet.attrib["type"] $= "users")
  5180. {
  5181. for(%i=0;%i<%packet.children;%i++)
  5182. {
  5183. %user = %packet.child[%i];
  5184. %this.manifest.addUser(%user.attrib["id"],%user.attrib["name"],%user.attrib["rank"],%user.attrib["icon"],%user.attrib["blocked"]);
  5185. }
  5186.  
  5187. if(%packet.attrib["end"] $= "1")
  5188. {
  5189. %this.manifest.loading = false;
  5190. %this.manifest.render();
  5191. }
  5192.  
  5193. %user = %this.manifest.getByID(RTB_ConnectClient.client_id);
  5194. if(%user && %user.rank >= 2)
  5195. %this.setAdminDisplay(1);
  5196. else
  5197. %this.setAdminDisplay(0);
  5198. }
  5199. else if(%packet.attrib["type"] $= "join")
  5200. {
  5201. %user = %packet.child[0];
  5202. %user = %this.manifest.addUser(%user.attrib["id"],%user.attrib["name"],%user.attrib["rank"],%user.attrib["icon"],%user.attrib["blocked"]);
  5203. if(!%this.manifest.loading)
  5204. %user.render();
  5205.  
  5206. if(%this.options.join_message)
  5207. %this.writeNotice(%user.name @ " has joined the room.");
  5208. if(%this.options.join_popup)
  5209. RTBCC_NotificationManager.push(%this.room.name,%user.name @ " joined.","comment_add","joinleave_"@%user.name);
  5210. }
  5211. else if(%packet.attrib["type"] $= "kick")
  5212. {
  5213. %id = %packet.child[0].attrib["id"];
  5214. %user = %this.manifest.getByID(%id);
  5215. %kicker = %this.manifest.getByID(%packet.attrib["user"]);
  5216.  
  5217. if(%packet.attrib["reason"] !$= "")
  5218. %this.writeColor(%kicker.name @ " has kicked " @ %user.name @" from the room. ("@%packet.attrib["reason"]@")", "FF0000");
  5219. else
  5220. %this.writeColor(%kicker.name @ " has kicked " @ %user.name @" from the room.", "FF0000");
  5221.  
  5222. if(%user.id $= RTB_ConnectClient.client_id)
  5223. {
  5224. RTBCC_NotificationManager.push(%this.room.name,"You have been kicked.","delete");
  5225. if(%packet.attrib["reason"] !$= "")
  5226. %this.messageBoxError("You were kicked!","You were kicked from the room by "@%kicker.name@".<br><br>"@%packet.attrib["reason"],%this@".destroy();");
  5227. else
  5228. %this.messageBoxError("You were kicked!","You were kicked from the room by "@%kicker.name@".",%this@".destroy();");
  5229. }
  5230. }
  5231. else if(%packet.attrib["type"] $= "ban")
  5232. {
  5233. %id = %packet.child[0].attrib["id"];
  5234. %user = %this.manifest.getByID(%id);
  5235. %banner = %this.manifest.getByID(%packet.attrib["user"]);
  5236.  
  5237. if(%packet.attrib["reason"] !$= "")
  5238. %this.writeColor(%banner.name @ " has banned " @ %user.name @" from the room. ("@%packet.attrib["reason"]@")", "FF0000");
  5239. else
  5240. %this.writeColor(%banner.name @ " has banned " @ %user.name @" from the room.", "FF0000");
  5241.  
  5242. if(%user.id $= RTB_ConnectClient.client_id)
  5243. {
  5244. RTBCC_NotificationManager.push(%this.room.name,"You have been banned.","delete");
  5245. if (%packet.attrib["length"] $= "permanent")
  5246. %message = "You were permanently banned from the room by "@%banner.name@".<br>";
  5247. else
  5248. %message = "You were banned from the room by "@%banner.name@".<br><br><font:Verdana Bold:12>Time: <font:Verdana:12>"@timeDiffString(0,%packet.attrib["time"]);
  5249.  
  5250. if(%packet.attrib["reason"] !$= "")
  5251. %message = %message @ "<br><font:Verdana Bold:12>Reason: <font:Verdana:12>"@%packet.attrib["reason"];
  5252.  
  5253. %this.messageBoxError("You were banned!",%message,%this@".destroy();");
  5254. }
  5255. }
  5256. else if(%packet.attrib["type"] $= "rank")
  5257. {
  5258. %id = %packet.child[0].attrib["id"];
  5259. %user = %this.manifest.getByID(%id);
  5260.  
  5261. %oldRank = %user.rank;
  5262. %user.rank = %packet.child[0].attrib["rank"];
  5263. %user.icon = %packet.child[0].attrib["icon"];
  5264. if(!%this.manifest.loading)
  5265. {
  5266. %user.getGroup().sort();
  5267. %user.rerender();
  5268. }
  5269.  
  5270. %changer = %this.manifest.getByID(%packet.attrib["user"]);
  5271.  
  5272. if(%user.id $= RTB_ConnectClient.client_id)
  5273. if(%user.rank >= 2)
  5274. %this.setAdminDisplay(1);
  5275. else
  5276. %this.setAdminDisplay(0);
  5277.  
  5278. %rank[0] = "a normal user";
  5279. %rank[1] = "a moderator";
  5280. %rank[2] = "an administrator";
  5281. if(%oldRank !$= %user.rank)
  5282. %this.writeColor(%changer.name @ " has made " @ %user.name SPC %rank[%user.rank] @ ".","0099FF");
  5283.  
  5284. if(%id $= RTB_ConnectClient.client_id)
  5285. if(isObject(%this.gui_userMenu))
  5286. %this.gui_userMenu.user.closeMenu();
  5287. }
  5288. else if(%packet.attrib["type"] $= "leave")
  5289. {
  5290. %id = %packet.child[0].attrib["id"];
  5291. %user = %this.manifest.getByID(%id);
  5292.  
  5293. if(%this.options.leave_message)
  5294. %this.writeNotice(%user.name @ " has left the room.");
  5295. if(%this.options.leave_popup)
  5296. RTBCC_NotificationManager.push(%this.room.name,%user.name @ " left.","comment_delete","joinleave_"@%user.name);
  5297.  
  5298. %this.manifest.removeByID(%id);
  5299. }
  5300. else if(%packet.attrib["type"] $= "motd")
  5301. {
  5302. %this.writeNotice(%packet.cData);
  5303. }
  5304. else if(%packet.attrib["type"] $= "motd_change")
  5305. {
  5306. %user = %this.manifest.getByID(%packet.attrib["user"]);
  5307. %this.writeNotice(%user.name @ " changed the welcome message to \""@ %packet.cData @"\"");
  5308. }
  5309. }
  5310.  
  5311. //- RTBCC_RoomSession::send (sends whatever is in the text box)
  5312. function RTBCC_RoomSession::send(%this)
  5313. {
  5314. %text = %this.window.input.getValue();
  5315. if(%text $= "")
  5316. return;
  5317.  
  5318. RTBCC_RoomSessionManager.lastFocus = %this;
  5319. RTBCC_RoomSessionManager.lastFocusTime = getSimTime();
  5320.  
  5321. %this.window.input.setValue("");
  5322.  
  5323. if(getSubStr(%text,0,1) $= "/")
  5324. {
  5325. if(firstWord(%text) $= "/me" || firstWord(%text) $= "/action")
  5326. {
  5327. %this.writeAction(RTB_ConnectClient.client_name,parseLinks(stripMLControlChars(restWords(%text))));
  5328. RTBCC_Socket.sendMessage(%this.name,restWords(%text),true);
  5329. }
  5330. }
  5331. else
  5332. {
  5333. if(%this.manifest.getById(RTB_ConnectClient.client_id).rank > 0)
  5334. %this.writeRank("<color:FF6600>"@RTB_ConnectClient.client_name,parseLinks(stripMLControlChars(%text)));
  5335. else
  5336. %this.writeMessage("<color:FF6600>"@RTB_ConnectClient.client_name,parseLinks(stripMLControlChars(%text)));
  5337. RTBCC_Socket.sendMessage(%this.name,%text);
  5338. }
  5339.  
  5340. %this.focus();
  5341.  
  5342. %this.window.scroll.scrollToBottom();
  5343. }
  5344.  
  5345. //- RTBCC_RoomSession::receive (handles a message packet)
  5346. function RTBCC_RoomSession::receive(%this,%message)
  5347. {
  5348. if(!%this.isRendered())
  5349. %this.render();
  5350.  
  5351. %from = %message.attrib["from"];
  5352. if(!%this.manifest.hasUser(%from))
  5353. return;
  5354.  
  5355. %user = %this.manifest.getByID(%from);
  5356. %name = %user.name;
  5357. if(RTBCC_Roster.hasID(%user.id) && RTBCC_Roster.getByID(%user.id).state !$= "pending_to")
  5358. %name = "<color:228822>"@%name;
  5359.  
  5360. if(%message.attrib["type"] $= "action")
  5361. %this.writeAction(%user.name,%message.find("body").cData);
  5362. else if(%user.rank > 0)
  5363. %this.writeRank(%name,%message.find("body").cData);
  5364. else
  5365. %this.writeMessage(%name,%message.find("body").cData);
  5366. }
  5367.  
  5368. //- RTBCC_Session::writeMessage (adds a user-sent message to the bottom of the ml text)
  5369. function RTBCC_RoomSession::writeMessage(%this,%sender,%message)
  5370. {
  5371. if(RTBCO_getPref("CC::ChatLogging"))
  5372. %this.log(%sender@": "@%message);
  5373.  
  5374. %message = "<font:Verdana Bold:12>"@%sender@"<font:Verdana:12><color:444444>: "@%message;
  5375.  
  5376. if(RTBCO_getPref("CC::ShowTimestamps"))
  5377. %message = "<font:Verdana Bold:12>["@getSubStr(getWord(getDateTime(),1),0,8)@"] " @ %message;
  5378.  
  5379. %this.write(%message);
  5380. }
  5381.  
  5382. //- RTBCC_Session::writeRank (adds an admin-sent message to the bottom of the ml text)
  5383. function RTBCC_RoomSession::writeRank(%this,%sender,%message)
  5384. {
  5385. if(RTBCO_getPref("CC::ChatLogging"))
  5386. %this.log(%sender@": "@%message);
  5387.  
  5388. %message = "<font:Verdana Bold:12><color:0099FF>"@%sender@"<font:Verdana:12>: "@%message@"<color:444444>";
  5389.  
  5390. if(RTBCO_getPref("CC::ShowTimestamps"))
  5391. %message = "<font:Verdana Bold:12>["@getSubStr(getWord(getDateTime(),1),0,8)@"] " @ %message;
  5392.  
  5393. %this.write(%message);
  5394. }
  5395.  
  5396. //- RTBCC_RoomSession::writeAction (adds an action message to the bottom of the ml text)
  5397. function RTBCC_RoomSession::writeAction(%this,%sender,%message)
  5398. {
  5399. if(RTBCO_getPref("CC::ChatLogging"))
  5400. %this.log("* "@%sender@" "@%message);
  5401.  
  5402. %message = "<font:Verdana Bold:12><color:CC00CC>* "@%sender@" <font:Verdana:12>"@%message@"<color:444444>";
  5403.  
  5404. if(RTBCO_getPref("CC::ShowTimestamps"))
  5405. %message = "<font:Verdana Bold:12>["@getSubStr(getWord(getDateTime(),1),0,8)@"] " @ %message;
  5406.  
  5407. %this.write(%message);
  5408. }
  5409.  
  5410. //- RTBCC_RoomSession::writeInfo (adds an information message to the bottom of the ml text)
  5411. function RTBCC_RoomSession::writeInfo(%this,%message)
  5412. {
  5413. if(RTBCO_getPref("CC::ChatLogging"))
  5414. %this.log("* "@%message);
  5415.  
  5416. %message = "<font:Verdana:12><color:00AA00>* "@%message@"<color:444444>";
  5417.  
  5418. if(RTBCO_getPref("CC::ShowTimestamps"))
  5419. %message = "<font:Verdana Bold:12>["@getSubStr(getWord(getDateTime(),1),0,8)@"] " @ %message;
  5420.  
  5421. %this.write(%message);
  5422. }
  5423.  
  5424. //- RTBCC_RoomSession::writeColor (adds a colored message to the bottom of the ml text)
  5425. function RTBCC_RoomSession::writeColor(%this,%message,%color)
  5426. {
  5427. if(RTBCO_getPref("CC::ChatLogging"))
  5428. %this.log("* "@%message);
  5429.  
  5430. %message = "<font:Verdana:12><color:"@%color@">* "@%message@"<color:444444>";
  5431.  
  5432. if(RTBCO_getPref("CC::ShowTimestamps"))
  5433. %message = "<font:Verdana Bold:12>["@getSubStr(getWord(getDateTime(),1),0,8)@"] " @ %message;
  5434.  
  5435. %this.write(%message);
  5436. }
  5437.  
  5438. //- RTBCC_RoomSession::writeNotice (adds a notice message to the bottom of the ml text)
  5439. function RTBCC_RoomSession::writeNotice(%this,%message)
  5440. {
  5441. if(RTBCO_getPref("CC::ChatLogging"))
  5442. %this.log("* "@%message);
  5443.  
  5444. %message = "<font:Verdana:12><color:666666>* "@%message@"<color:444444>";
  5445.  
  5446. if(RTBCO_getPref("CC::ShowTimestamps"))
  5447. %message = "<font:Verdana Bold:12>["@getSubStr(getWord(getDateTime(),1),0,8)@"] " @ %message;
  5448.  
  5449. %this.write(%message);
  5450. }
  5451.  
  5452. //- RTBCC_RoomSession::writeError (adds an error message to the bottom of the ml text)
  5453. function RTBCC_RoomSession::writeError(%this,%message)
  5454. {
  5455. %message = "<color:FF0000>* "@%message@"<color:444444>";
  5456.  
  5457. %this.write(%message);
  5458. }
  5459.  
  5460. //- RTBCC_RoomSession::write (adds a line to the bottom of the ml text)
  5461. function RTBCC_RoomSession::write(%this,%line)
  5462. {
  5463. if(!%this.isRendered())
  5464. return;
  5465.  
  5466. %scroll = %this.window.scroll;
  5467. %display = %this.window.display;
  5468.  
  5469. %position = getWord(%display.position,1);
  5470. if((getWord(%display.extent,1)+getWord(%display.position,1)) <= (getWord(%scroll.extent,1)-1))
  5471. %atBottom = true;
  5472.  
  5473. if(%display.getValue() $= "")
  5474. %display.setValue(%line);
  5475. else
  5476. %display.setValue(%display.getValue()@"\n"@%line);
  5477.  
  5478. if(RTB_Overlay.isAwake())
  5479. %display.forceReflow();
  5480.  
  5481. %display.setCursorPosition(strLen(%display.getValue()));
  5482.  
  5483. if(%atBottom)
  5484. %scroll.scrollToBottom();
  5485. else
  5486. %display.resize(getWord(%display.position,0),%position,getWord(%display.extent,0),getWord(%display.extent,1));
  5487. }
  5488.  
  5489. //- RTBCC_RoomSession::log (logs a message into the chat logging)
  5490. function RTBCC_RoomSession::log(%this,%message)
  5491. {
  5492. if(!isObject(%this.logger))
  5493. {
  5494. %this.logger = new FileObject();
  5495. %this.logger.openForAppend("config/client/rtb/logs/rooms/"@getSafeVariableName(%this.name)@".txt");
  5496. %this.logger.writeLine("");
  5497. %this.logger.writeLine(getDateTime());
  5498. %this.logger.writeLine("--");
  5499. %this.logger.close();
  5500. }
  5501. %this.logger.openForAppend("config/client/rtb/logs/rooms/"@getSafeVariableName(%this.name)@".txt");
  5502. %this.logger.writeLine("["@lastWord(getDateTime())@"] "@stripMLControlChars(%message));
  5503. %this.logger.close();
  5504.  
  5505. RTBGroup.add(%this.logger);
  5506. }
  5507.  
  5508. //- RTBCC_RoomSession::setAdminDisplay (enables/disables admin button)
  5509. function RTBCC_RoomSession::setAdminDisplay(%this,%status)
  5510. {
  5511. if(%status $= 1)
  5512. {
  5513. if(%this.adminDisplay)
  5514. return;
  5515.  
  5516. %this.adminDisplay = 1;
  5517.  
  5518. %ctrl = %this.window.inputContainer;
  5519. %ctrl.resize(getWord(%ctrl.position,0),getWord(%ctrl.position,1),getWord(%ctrl.extent,0)-25,getWord(%ctrl.extent,1));
  5520. }
  5521. else
  5522. {
  5523. if(!%this.adminDisplay)
  5524. return;
  5525.  
  5526. %this.adminDisplay = 0;
  5527. %ctrl = %this.window.inputContainer;
  5528. %ctrl.resize(getWord(%ctrl.position,0),getWord(%ctrl.position,1),getWord(%ctrl.extent,0)+25,getWord(%ctrl.extent,1));
  5529. }
  5530. }
  5531.  
  5532. //- RTBCC_RoomSession::focus (brings the window into user focus)
  5533. function RTBCC_RoomSession::focus(%this)
  5534. {
  5535. if(%this.isRendered())
  5536. {
  5537. RTB_Overlay.pushToBack(%this.window);
  5538. %this.window.input.makeFirstResponder(1);
  5539. }
  5540. }
  5541.  
  5542. //- RTBCC_RoomSession::render (renders a room window for the session)
  5543. function RTBCC_RoomSession::render(%this)
  5544. {
  5545. if(%this.isRendered())
  5546. {
  5547. %this.focus();
  5548. return;
  5549. }
  5550.  
  5551. %window = new GuiWindowCtrl()
  5552. {
  5553. profile = GuiWindowProfile;
  5554. position = "0 0";
  5555. extent = "500 342";
  5556. minExtent = "450 250";
  5557. text = %this.room.getGroup().name @ " - " @ %this.name;
  5558. resizeWidth = true;
  5559. resizeHeight = true;
  5560. canMove = true;
  5561. canClose = true;
  5562. canMinimize = false;
  5563. canMaximize = false;
  5564. title = %this.room.getGroup().name @ " - " @ %this.name;
  5565.  
  5566. new GuiBitmapBorderCtrl()
  5567. {
  5568. profile = RTB_ContentBorderProfile;
  5569. horizSizing = "width";
  5570. vertSizing = "height";
  5571. position = "7 30";
  5572. extent = "334 280";
  5573.  
  5574. new GuiSwatchCtrl()
  5575. {
  5576. profile = GuiDefaultProfile;
  5577. horizSizing = "width";
  5578. vertSizing = "height";
  5579. position = "3 3";
  5580. extent = "328 274";
  5581. color = "255 255 255 255";
  5582.  
  5583. new GuiScrollCtrl()
  5584. {
  5585. profile = RTB_ScrollProfile;
  5586. horizSizing = "width";
  5587. vertSizing = "height";
  5588. position = "1 1";
  5589. extent = "326 271";
  5590. hScrollBar = "alwaysOff";
  5591.  
  5592. dSet = "window";
  5593. dName = "scroll";
  5594.  
  5595. new GuiMLTextCtrl()
  5596. {
  5597. profile = RTB_MLEditProfile;
  5598. horizSizing = "width";
  5599. vertSizing = "height";
  5600. position = "1 1";
  5601. extent = "312 12";
  5602.  
  5603. dSet = "window";
  5604. dName = "display";
  5605. };
  5606. };
  5607. };
  5608. };
  5609.  
  5610. new GuiBitmapBorderCtrl()
  5611. {
  5612. profile = RTB_ContentBorderProfile;
  5613. horizSizing = "left";
  5614. vertSizing = "height";
  5615. position = "344 30";
  5616. extent = "150 280";
  5617.  
  5618. new GuiSwatchCtrl()
  5619. {
  5620. profile = GuiDefaultProfile;
  5621. horizSizing = "width";
  5622. vertSizing = "height";
  5623. position = "3 3";
  5624. extent = "144 274";
  5625. color = "255 255 255 255";
  5626.  
  5627. dSet = "window";
  5628. dName = "userPane";
  5629.  
  5630. new GuiScrollCtrl()
  5631. {
  5632. profile = RTB_ScrollProfile;
  5633. horizSizing = "width";
  5634. vertSizing = "height";
  5635. position = "1 1";
  5636. extent = "142 272";
  5637. hScrollBar = "alwaysOff";
  5638.  
  5639. dSet = "window";
  5640. dName = "userScroll";
  5641.  
  5642. new GuiSwatchCtrl()
  5643. {
  5644. profile = GuiDefaultProfile;
  5645. horizSizing = "right";
  5646. vertSizing = "bottom";
  5647. position = "1 1";
  5648. extent = "140 0";
  5649. minExtent = "140 0";
  5650. color = "255 255 255 255";
  5651.  
  5652. dSet = "window";
  5653. dName = "userSwatch";
  5654. };
  5655. };
  5656. };
  5657.  
  5658. new GuiSwatchCtrl()
  5659. {
  5660. profile = GuiDefaultProfile;
  5661. horizSizing = "width";
  5662. vertSizing = "height";
  5663. position = "3 3";
  5664. extent = "144 274";
  5665. color = "255 255 255 255";
  5666. visible = false;
  5667.  
  5668. dSet = "window";
  5669. dName = "optsPane";
  5670.  
  5671. new GuiScrollCtrl()
  5672. {
  5673. profile = RTB_ScrollProfile;
  5674. horizSizing = "width";
  5675. vertSizing = "height";
  5676. position = "1 1";
  5677. extent = "142 272";
  5678. hScrollBar = "alwaysOff";
  5679.  
  5680. dSet = "window";
  5681. dName = "optsScroll";
  5682.  
  5683. new GuiSwatchCtrl()
  5684. {
  5685. profile = GuiDefaultProfile;
  5686. horizSizing = "right";
  5687. vertSizing = "bottom";
  5688. position = "1 1";
  5689. extent = "140 258";
  5690. minExtent = "140 0";
  5691. color = "255 255 255 255";
  5692.  
  5693. dSet = "window";
  5694. dName = "optsSwatch";
  5695.  
  5696. new GuiBitmapCtrl()
  5697. {
  5698. profile = GuiDefaultProfile;
  5699. horizSizing = "right";
  5700. vertSizing = "bottom";
  5701. position = "6 2";
  5702. extent = "16 16";
  5703. bitmap = $RTB::Path@"images/icons/wrench";
  5704. };
  5705.  
  5706. new GuiMLTextCtrl()
  5707. {
  5708. profile = GuiDefaultProfile;
  5709. horizSizing = "right";
  5710. vertSizing = "bottom";
  5711. position = "26 4";
  5712. extent = "150 12";
  5713. text = "<font:Verdana Bold:12><color:444444>General";
  5714. selectable = false;
  5715. };
  5716.  
  5717. new GuiBitmapCtrl()
  5718. {
  5719. profile = GuiDefaultProfile;
  5720. horizSizing = "right";
  5721. vertSizing = "bottom";
  5722. position = "4 21";
  5723. extent = "121 2";
  5724. bitmap = $RTB::Path@"images/ui/dottedLine";
  5725. wrap = true;
  5726. };
  5727.  
  5728. new GuiMLTextCtrl()
  5729. {
  5730. profile = GuiDefaultProfile;
  5731. horizSizing = "right";
  5732. vertSizing = "bottom";
  5733. position = "7 28";
  5734. extent = "100 12";
  5735. text = "<font:Verdana:12><color:888888>Auto-join this room";
  5736. selectable = false;
  5737. };
  5738.  
  5739. new GuiCheckboxCtrl()
  5740. {
  5741. profile = RTB_CheckboxProfile;
  5742. horizSizing = "right";
  5743. vertSizing = "bottom";
  5744. position = "109 27";
  5745. extent = "16 16";
  5746. text = " ";
  5747. groupNum = "-1";
  5748. buttonType = "ToggleButton";
  5749. command = "RTBCC_RoomOptionsManager.storeRoomSettings("@%this@");";
  5750.  
  5751. var = "autojoin";
  5752. def = 0;
  5753. };
  5754.  
  5755. new GuiBitmapCtrl()
  5756. {
  5757. profile = GuiDefaultProfile;
  5758. horizSizing = "right";
  5759. vertSizing = "bottom";
  5760. position = "6 54";
  5761. extent = "16 16";
  5762. bitmap = $RTB::Path@"images/icons/note";
  5763. };
  5764.  
  5765. new GuiMLTextCtrl()
  5766. {
  5767. profile = GuiDefaultProfile;
  5768. horizSizing = "right";
  5769. vertSizing = "bottom";
  5770. position = "26 56";
  5771. extent = "150 12";
  5772. text = "<font:Verdana Bold:12><color:444444>Notifications";
  5773. selectable = false;
  5774. };
  5775.  
  5776. new GuiBitmapCtrl()
  5777. {
  5778. profile = GuiDefaultProfile;
  5779. horizSizing = "right";
  5780. vertSizing = "bottom";
  5781. position = "4 73";
  5782. extent = "121 2";
  5783. bitmap = $RTB::Path@"images/ui/dottedLine";
  5784. wrap = true;
  5785. };
  5786.  
  5787. new GuiMLTextCtrl()
  5788. {
  5789. profile = GuiDefaultProfile;
  5790. horizSizing = "right";
  5791. vertSizing = "bottom";
  5792. position = "7 78";
  5793. extent = "126 12";
  5794. text = "<font:Verdana:12><color:888888>When a user joins ...";
  5795. selectable = false;
  5796. };
  5797.  
  5798. new GuiMLTextCtrl()
  5799. {
  5800. profile = GuiDefaultProfile;
  5801. horizSizing = "right";
  5802. vertSizing = "bottom";
  5803. position = "8 92";
  5804. extent = "94 12";
  5805. text = "<font:Verdana:12><color:AAAAAA><just:right>Sound";
  5806. selectable = false;
  5807. };
  5808.  
  5809. new GuiCheckboxCtrl()
  5810. {
  5811. profile = RTB_CheckboxProfile;
  5812. horizSizing = "right";
  5813. vertSizing = "bottom";
  5814. position = "109 91";
  5815. extent = "16 16";
  5816. text = " ";
  5817. groupNum = "-1";
  5818. buttonType = "ToggleButton";
  5819. command = "RTBCC_RoomOptionsManager.storeRoomSettings("@%this@");";
  5820.  
  5821. var = "join_sound";
  5822. def = 0;
  5823. };
  5824.  
  5825. new GuiMLTextCtrl()
  5826. {
  5827. profile = GuiDefaultProfile;
  5828. horizSizing = "right";
  5829. vertSizing = "bottom";
  5830. position = "8 108";
  5831. extent = "94 12";
  5832. text = "<font:Verdana:12><color:AAAAAA><just:right>Popup";
  5833. selectable = false;
  5834. };
  5835.  
  5836. new GuiCheckboxCtrl()
  5837. {
  5838. profile = RTB_CheckboxProfile;
  5839. horizSizing = "right";
  5840. vertSizing = "bottom";
  5841. position = "109 107";
  5842. extent = "16 16";
  5843. text = " ";
  5844. groupNum = "-1";
  5845. buttonType = "ToggleButton";
  5846. command = "RTBCC_RoomOptionsManager.storeRoomSettings("@%this@");";
  5847.  
  5848. var = "join_popup";
  5849. def = 0;
  5850. };
  5851.  
  5852. new GuiMLTextCtrl()
  5853. {
  5854. profile = GuiDefaultProfile;
  5855. horizSizing = "right";
  5856. vertSizing = "bottom";
  5857. position = "8 123";
  5858. extent = "94 12";
  5859. text = "<font:Verdana:12><color:AAAAAA><just:right>Chat Message";
  5860. selectable = false;
  5861. };
  5862.  
  5863. new GuiCheckboxCtrl()
  5864. {
  5865. profile = RTB_CheckboxProfile;
  5866. horizSizing = "right";
  5867. vertSizing = "bottom";
  5868. position = "109 122";
  5869. extent = "16 16";
  5870. text = " ";
  5871. groupNum = "-1";
  5872. buttonType = "ToggleButton";
  5873. command = "RTBCC_RoomOptionsManager.storeRoomSettings("@%this@");";
  5874.  
  5875. var = "join_message";
  5876. def = 1;
  5877. };
  5878.  
  5879. new GuiMLTextCtrl()
  5880. {
  5881. profile = GuiDefaultProfile;
  5882. horizSizing = "right";
  5883. vertSizing = "bottom";
  5884. position = "7 140";
  5885. extent = "126 12";
  5886. text = "<font:Verdana:12><color:888888>When a user leaves ...";
  5887. selectable = false;
  5888. };
  5889.  
  5890. new GuiMLTextCtrl()
  5891. {
  5892. profile = GuiDefaultProfile;
  5893. horizSizing = "right";
  5894. vertSizing = "bottom";
  5895. position = "8 154";
  5896. extent = "94 12";
  5897. text = "<font:Verdana:12><color:AAAAAA><just:right>Sound";
  5898. selectable = false;
  5899. };
  5900.  
  5901. new GuiCheckboxCtrl()
  5902. {
  5903. profile = RTB_CheckboxProfile;
  5904. horizSizing = "right";
  5905. vertSizing = "bottom";
  5906. position = "109 153";
  5907. extent = "16 16";
  5908. text = " ";
  5909. groupNum = "-1";
  5910. buttonType = "ToggleButton";
  5911. command = "RTBCC_RoomOptionsManager.storeRoomSettings("@%this@");";
  5912.  
  5913. var = "leave_sound";
  5914. def = 0;
  5915. };
  5916.  
  5917. new GuiMLTextCtrl()
  5918. {
  5919. profile = GuiDefaultProfile;
  5920. horizSizing = "right";
  5921. vertSizing = "bottom";
  5922. position = "8 170";
  5923. extent = "94 12";
  5924. text = "<font:Verdana:12><color:AAAAAA><just:right>Popup";
  5925. selectable = false;
  5926. };
  5927.  
  5928. new GuiCheckboxCtrl()
  5929. {
  5930. profile = RTB_CheckboxProfile;
  5931. horizSizing = "right";
  5932. vertSizing = "bottom";
  5933. position = "109 169";
  5934. extent = "16 16";
  5935. text = " ";
  5936. groupNum = "-1";
  5937. buttonType = "ToggleButton";
  5938. command = "RTBCC_RoomOptionsManager.storeRoomSettings("@%this@");";
  5939.  
  5940. var = "leave_popup";
  5941. def = 0;
  5942. };
  5943.  
  5944. new GuiMLTextCtrl()
  5945. {
  5946. profile = GuiDefaultProfile;
  5947. horizSizing = "right";
  5948. vertSizing = "bottom";
  5949. position = "8 185";
  5950. extent = "94 12";
  5951. text = "<font:Verdana:12><color:AAAAAA><just:right>Chat Message";
  5952. selectable = false;
  5953. };
  5954.  
  5955. new GuiCheckboxCtrl()
  5956. {
  5957. profile = RTB_CheckboxProfile;
  5958. horizSizing = "right";
  5959. vertSizing = "bottom";
  5960. position = "109 184";
  5961. extent = "16 16";
  5962. text = " ";
  5963. groupNum = "-1";
  5964. buttonType = "ToggleButton";
  5965. command = "RTBCC_RoomOptionsManager.storeRoomSettings("@%this@");";
  5966.  
  5967. var = "leave_message";
  5968. def = 1;
  5969. };
  5970. };
  5971. };
  5972. };
  5973. };
  5974.  
  5975. new GuiBitmapButtonCtrl() {
  5976. profile = "GuiDefaultProfile";
  5977. horizSizing = "left";
  5978. vertSizing = "top";
  5979. position = "466 308";
  5980. extent = "24 27";
  5981. command = "";
  5982. text = " ";
  5983. groupNum = "2";
  5984. buttonType = "RadioButton";
  5985. bitmap = $RTB::Path@"images/ui/buttons/connectClient/tabUserList";
  5986. mKeepCached = "1";
  5987. };
  5988.  
  5989. new GuiBitmapButtonCtrl() {
  5990. profile = "GuiDefaultProfile";
  5991. horizSizing = "left";
  5992. vertSizing = "top";
  5993. position = "439 308";
  5994. extent = "24 27";
  5995. command = "";
  5996. text = " ";
  5997. groupNum = "2";
  5998. buttonType = "RadioButton";
  5999. bitmap = $RTB::Path@"images/ui/buttons/connectClient/tabSettings";
  6000. mKeepCached = "1";
  6001. };
  6002.  
  6003. new GuiBitmapBorderCtrl()
  6004. {
  6005. profile = RTB_ContentBorderProfile;
  6006. horizSizing = "left";
  6007. vertSizing = "top";
  6008. position = "414 313";
  6009. extent = "22 22";
  6010.  
  6011. new GuiSwatchCtrl()
  6012. {
  6013. profile = GuiDefaultProfile;
  6014. horizSizing = "width";
  6015. vertSizing = "height";
  6016. position = "3 3";
  6017. extent = "16 16";
  6018. color = "255 255 255 255";
  6019. };
  6020.  
  6021. new GuiBitmapCtrl()
  6022. {
  6023. profile = GuiDefaultProfile;
  6024. horizSizing = "left";
  6025. vertSizing = "bottom";
  6026. position = "3 3";
  6027. extent = "16 16";
  6028. bitmap = $RTB::Path@"images/icons/shield_gold";
  6029. };
  6030.  
  6031. new GuiBitmapButtonCtrl() {
  6032. profile = "GuiDefaultProfile";
  6033. horizSizing = "left";
  6034. vertSizing = "bottom";
  6035. position = "2 2";
  6036. extent = "18 18";
  6037. command = %this@".openAdminPanel();";
  6038. text = " ";
  6039. };
  6040. };
  6041.  
  6042. new GuiBitmapBorderCtrl()
  6043. {
  6044. profile = RTB_ContentBorderProfile;
  6045. horizSizing = "width";
  6046. vertSizing = "top";
  6047. position = "7 313";
  6048. extent = "429 22";
  6049.  
  6050. dSet = "window";
  6051. dName = "inputContainer";
  6052.  
  6053. new GuiSwatchCtrl()
  6054. {
  6055. profile = GuiDefaultProfile;
  6056. horizSizing = "width";
  6057. vertSizing = "height";
  6058. position = "3 3";
  6059. extent = "423 16";
  6060. color = "255 255 255 255";
  6061. };
  6062.  
  6063. new GuiBitmapCtrl()
  6064. {
  6065. profile = GuiDefaultProfile;
  6066. horizSizing = "left";
  6067. vertSizing = "bottom";
  6068. position = "410 2";
  6069. extent = "16 16";
  6070. bitmap = $RTB::Path@"images/icons/bullet_go";
  6071. };
  6072.  
  6073. new GuiBitmapButtonCtrl() {
  6074. profile = "GuiDefaultProfile";
  6075. horizSizing = "left";
  6076. vertSizing = "bottom";
  6077. position = "410 2";
  6078. extent = "16 16";
  6079. command = %this@".send();";
  6080. text = " ";
  6081. };
  6082. };
  6083.  
  6084. new GuiSwatchCtrl() {
  6085. profile = GuiDefaultProfile;
  6086. horizSizing = "width";
  6087. vertSizing = "height";
  6088. position = "6 27";
  6089. extent = "490 310";
  6090. color = "200 200 200 150";
  6091. visible = "0";
  6092.  
  6093. dSet = "window";
  6094. dName = "modalSwatch";
  6095.  
  6096. new GuiBitmapBorderCtrl() {
  6097. profile = "RTB_ContentBorderProfile";
  6098. horizSizing = "center";
  6099. vertSizing = "center";
  6100. position = "158 109";
  6101. extent = "174 91";
  6102. minExtent = "8 2";
  6103. visible = "0";
  6104.  
  6105. dSet = "window";
  6106. dName = "modal_BoxOK";
  6107.  
  6108. new GuiSwatchCtrl() {
  6109. profile = "GuiDefaultProfile";
  6110. horizSizing = "width";
  6111. vertSizing = "height";
  6112. position = "3 3";
  6113. extent = "168 85";
  6114. minExtent = "8 2";
  6115. visible = "1";
  6116. color = "255 255 255 255";
  6117.  
  6118. new GuiSwatchCtrl() {
  6119. profile = "GuiDefaultProfile";
  6120. horizSizing = "right";
  6121. vertSizing = "bottom";
  6122. position = "0 0";
  6123. extent = "168 20";
  6124. minExtent = "8 2";
  6125. visible = "1";
  6126. color = "0 0 0 30";
  6127. };
  6128. new GuiMLTextCtrl() {
  6129. profile = "GuiMLTextProfile";
  6130. horizSizing = "right";
  6131. vertSizing = "bottom";
  6132. position = "23 5";
  6133. extent = "140 12";
  6134. minExtent = "8 2";
  6135. visible = "1";
  6136. lineSpacing = "2";
  6137. allowColorChars = "0";
  6138. maxChars = "-1";
  6139. text = "<color:444444><font:Verdana Bold:12>Title Text";
  6140. maxBitmapHeight = "-1";
  6141. selectable = "0";
  6142.  
  6143. dSet = "parent";
  6144. dName = "m_title";
  6145. dOffset = 1;
  6146. };
  6147. new GuiBitmapCtrl() {
  6148. profile = "GuiDefaultProfile";
  6149. horizSizing = "right";
  6150. vertSizing = "bottom";
  6151. position = "3 2";
  6152. extent = "16 16";
  6153. minExtent = "8 2";
  6154. visible = "1";
  6155. bitmap = $RTB::Path@"images/icons/information";
  6156. wrap = "0";
  6157. lockAspectRatio = "0";
  6158. alignLeft = "0";
  6159. overflowImage = "0";
  6160. keepCached = "0";
  6161. };
  6162. new GuiMLTextCtrl() {
  6163. profile = "GuiMLTextProfile";
  6164. horizSizing = "right";
  6165. vertSizing = "bottom";
  6166. position = "3 23";
  6167. extent = "162 12";
  6168. minExtent = "8 2";
  6169. visible = "1";
  6170. lineSpacing = "2";
  6171. allowColorChars = "0";
  6172. maxChars = "-1";
  6173. text = "<color:444444><font:Verdana:12>Message Text";
  6174. maxBitmapHeight = "-1";
  6175. selectable = "0";
  6176.  
  6177. dSet = "parent";
  6178. dName = "m_text";
  6179. dOffset = 1;
  6180. };
  6181. new GuiBitmapButtonCtrl() {
  6182. profile = "GuiDefaultProfile";
  6183. horizSizing = "right";
  6184. vertSizing = "top";
  6185. position = "147 65";
  6186. extent = "16 16";
  6187. minExtent = "8 2";
  6188. visible = "1";
  6189. command = %this@".closeModalWindow();";
  6190. text = " ";
  6191. groupNum = "-1";
  6192. buttonType = "PushButton";
  6193. bitmap = $RTB::Path@"images/ui/buttons/generic/tick";
  6194. lockAspectRatio = "0";
  6195. alignLeft = "0";
  6196. overflowImage = "0";
  6197. mKeepCached = "0";
  6198. mColor = "255 255 255 255";
  6199.  
  6200. dSet = "parent";
  6201. dName = "m_ok";
  6202. dOffset = 1;
  6203. };
  6204. new GuiTextEditCtrl() {
  6205. profile = "RTB_TextEditProfile";
  6206. horizSizing = "right";
  6207. vertSizing = "bottom";
  6208. position = "0 -16";
  6209. extent = "65 16";
  6210. minExtent = "8 2";
  6211. visible = "1";
  6212. altCommand = "eval("@%this@".window.modal_BoxOK.m_ok.command);";
  6213. maxLength = "32";
  6214. historySize = "0";
  6215. password = "1";
  6216. tabComplete = "0";
  6217. sinkAllKeyEvents = "0";
  6218.  
  6219. dSet = "parent";
  6220. dName = "m_accel";
  6221. dOffset = 1;
  6222. };
  6223. };
  6224. };
  6225.  
  6226. new GuiBitmapBorderCtrl() {
  6227. profile = "RTB_ContentBorderProfile";
  6228. horizSizing = "center";
  6229. vertSizing = "center";
  6230. position = "158 109";
  6231. extent = "174 91";
  6232. minExtent = "8 2";
  6233. visible = "0";
  6234.  
  6235. dSet = "window";
  6236. dName = "modal_BoxError";
  6237.  
  6238. new GuiSwatchCtrl() {
  6239. profile = "GuiDefaultProfile";
  6240. horizSizing = "width";
  6241. vertSizing = "height";
  6242. position = "3 3";
  6243. extent = "168 85";
  6244. minExtent = "8 2";
  6245. visible = "1";
  6246. color = "255 255 255 255";
  6247.  
  6248. new GuiSwatchCtrl() {
  6249. profile = "GuiDefaultProfile";
  6250. horizSizing = "right";
  6251. vertSizing = "bottom";
  6252. position = "0 0";
  6253. extent = "168 20";
  6254. minExtent = "8 2";
  6255. visible = "1";
  6256. color = "0 0 0 30";
  6257. };
  6258. new GuiMLTextCtrl() {
  6259. profile = "GuiMLTextProfile";
  6260. horizSizing = "right";
  6261. vertSizing = "bottom";
  6262. position = "23 5";
  6263. extent = "140 12";
  6264. minExtent = "8 2";
  6265. visible = "1";
  6266. lineSpacing = "2";
  6267. allowColorChars = "0";
  6268. maxChars = "-1";
  6269. text = "<color:444444><font:Verdana Bold:12>Title Text";
  6270. maxBitmapHeight = "-1";
  6271. selectable = "0";
  6272.  
  6273. dSet = "parent";
  6274. dName = "m_title";
  6275. dOffset = 1;
  6276. };
  6277. new GuiBitmapCtrl() {
  6278. profile = "GuiDefaultProfile";
  6279. horizSizing = "right";
  6280. vertSizing = "bottom";
  6281. position = "3 2";
  6282. extent = "16 16";
  6283. minExtent = "8 2";
  6284. visible = "1";
  6285. bitmap = $RTB::Path@"images/icons/exclamation";
  6286. wrap = "0";
  6287. lockAspectRatio = "0";
  6288. alignLeft = "0";
  6289. overflowImage = "0";
  6290. keepCached = "0";
  6291. };
  6292. new GuiMLTextCtrl() {
  6293. profile = "GuiMLTextProfile";
  6294. horizSizing = "right";
  6295. vertSizing = "bottom";
  6296. position = "3 23";
  6297. extent = "162 12";
  6298. minExtent = "8 2";
  6299. visible = "1";
  6300. lineSpacing = "2";
  6301. allowColorChars = "0";
  6302. maxChars = "-1";
  6303. text = "<color:444444><font:Verdana:12>Message Text";
  6304. maxBitmapHeight = "-1";
  6305. selectable = "0";
  6306.  
  6307. dSet = "parent";
  6308. dName = "m_text";
  6309. dOffset = 1;
  6310. };
  6311. new GuiBitmapButtonCtrl() {
  6312. profile = "GuiDefaultProfile";
  6313. horizSizing = "right";
  6314. vertSizing = "top";
  6315. position = "147 65";
  6316. extent = "16 16";
  6317. minExtent = "8 2";
  6318. visible = "1";
  6319. command = %this@".closeModalWindow();";
  6320. text = " ";
  6321. groupNum = "-1";
  6322. buttonType = "PushButton";
  6323. bitmap = $RTB::Path@"images/ui/buttons/generic/cross";
  6324. lockAspectRatio = "0";
  6325. alignLeft = "0";
  6326. overflowImage = "0";
  6327. mKeepCached = "0";
  6328. mColor = "255 255 255 255";
  6329.  
  6330. dSet = "parent";
  6331. dName = "m_ok";
  6332. dOffset = 1;
  6333. };
  6334. new GuiTextEditCtrl() {
  6335. profile = "RTB_TextEditProfile";
  6336. horizSizing = "right";
  6337. vertSizing = "bottom";
  6338. position = "0 -16";
  6339. extent = "65 16";
  6340. minExtent = "8 2";
  6341. visible = "1";
  6342. altCommand = "eval("@%this@".window.modal_BoxError.m_ok.command);";
  6343. maxLength = "32";
  6344. historySize = "0";
  6345. password = "1";
  6346. tabComplete = "0";
  6347. sinkAllKeyEvents = "0";
  6348.  
  6349. dSet = "parent";
  6350. dName = "m_accel";
  6351. dOffset = 1;
  6352. };
  6353. };
  6354. };
  6355.  
  6356. new GuiBitmapBorderCtrl() {
  6357. profile = "RTB_ContentBorderProfile";
  6358. horizSizing = "center";
  6359. vertSizing = "center";
  6360. position = "4 92";
  6361. extent = "144 93";
  6362. minExtent = "8 2";
  6363. visible = "0";
  6364.  
  6365. dSet = "window";
  6366. dName = "modal_ChangeRank";
  6367.  
  6368. new GuiSwatchCtrl() {
  6369. profile = "GuiDefaultProfile";
  6370. horizSizing = "width";
  6371. vertSizing = "height";
  6372. position = "3 4";
  6373. extent = "138 87";
  6374. minExtent = "8 2";
  6375. visible = "1";
  6376. color = "255 255 255 255";
  6377.  
  6378. new GuiSwatchCtrl() {
  6379. profile = "GuiDefaultProfile";
  6380. horizSizing = "right";
  6381. vertSizing = "top";
  6382. position = "0 65";
  6383. extent = "190 20";
  6384. minExtent = "8 2";
  6385. visible = "1";
  6386. color = "0 0 0 30";
  6387. };
  6388. new GuiSwatchCtrl() {
  6389. profile = "GuiDefaultProfile";
  6390. horizSizing = "right";
  6391. vertSizing = "bottom";
  6392. position = "0 0";
  6393. extent = "190 20";
  6394. minExtent = "8 2";
  6395. visible = "1";
  6396. color = "0 0 0 30";
  6397. };
  6398. new GuiMLTextCtrl() {
  6399. profile = "GuiMLTextProfile";
  6400. horizSizing = "right";
  6401. vertSizing = "bottom";
  6402. position = "23 5";
  6403. extent = "110 12";
  6404. minExtent = "8 2";
  6405. visible = "1";
  6406. lineSpacing = "2";
  6407. allowColorChars = "0";
  6408. maxChars = "-1";
  6409. text = "<color:444444><font:Verdana Bold:12>Change Rank";
  6410. maxBitmapHeight = "-1";
  6411. selectable = "0";
  6412. };
  6413. new GuiBitmapButtonCtrl() {
  6414. profile = "GuiDefaultProfile";
  6415. horizSizing = "right";
  6416. vertSizing = "bottom";
  6417. position = "118 3";
  6418. extent = "16 16";
  6419. minExtent = "8 2";
  6420. visible = "1";
  6421. command = %this@".closeModalWindow();";
  6422. text = " ";
  6423. groupNum = "-1";
  6424. buttonType = "PushButton";
  6425. bitmap = "Add-Ons/system_returntoblockland/images/ui/buttons/generic/cross";
  6426. lockAspectRatio = "0";
  6427. alignLeft = "0";
  6428. overflowImage = "0";
  6429. mKeepCached = "0";
  6430. mColor = "255 255 255 255";
  6431. };
  6432. new GuiBitmapCtrl() {
  6433. profile = "GuiDefaultProfile";
  6434. horizSizing = "right";
  6435. vertSizing = "bottom";
  6436. position = "3 2";
  6437. extent = "16 16";
  6438. minExtent = "8 2";
  6439. visible = "1";
  6440. bitmap = "Add-Ons/system_returntoblockland/images/icons/medal_gold_3";
  6441. wrap = "0";
  6442. lockAspectRatio = "0";
  6443. alignLeft = "0";
  6444. overflowImage = "0";
  6445. keepCached = "0";
  6446. };
  6447. new GuiBitmapBorderCtrl() {
  6448. profile = "RTB_ContentBorderProfile";
  6449. horizSizing = "right";
  6450. vertSizing = "bottom";
  6451. position = "10 29";
  6452. extent = "30 30";
  6453. minExtent = "8 2";
  6454. visible = "1";
  6455.  
  6456. new GuiSwatchCtrl() {
  6457. profile = "GuiDefaultProfile";
  6458. horizSizing = "width";
  6459. vertSizing = "height";
  6460. position = "4 4";
  6461. extent = "22 22";
  6462. minExtent = "8 2";
  6463. visible = "1";
  6464. color = "255 255 255 255";
  6465.  
  6466. new GuiBitmapCtrl() {
  6467. profile = "GuiDefaultProfile";
  6468. horizSizing = "center";
  6469. vertSizing = "center";
  6470. position = "3 3";
  6471. extent = "16 16";
  6472. minExtent = "8 2";
  6473. visible = "1";
  6474. bitmap = "Add-Ons/System_ReturnToBlockland/images/icons/user";
  6475. wrap = "0";
  6476. lockAspectRatio = "0";
  6477. alignLeft = "0";
  6478. overflowImage = "0";
  6479. keepCached = "0";
  6480. };
  6481. };
  6482. };
  6483. new GuiBitmapBorderCtrl() {
  6484. profile = "RTB_ContentBorderProfile";
  6485. horizSizing = "right";
  6486. vertSizing = "bottom";
  6487. position = "54 29";
  6488. extent = "30 30";
  6489. minExtent = "8 2";
  6490. visible = "1";
  6491.  
  6492. new GuiSwatchCtrl() {
  6493. profile = "GuiDefaultProfile";
  6494. horizSizing = "width";
  6495. vertSizing = "height";
  6496. position = "4 4";
  6497. extent = "22 22";
  6498. minExtent = "8 2";
  6499. visible = "1";
  6500. color = "255 255 255 255";
  6501.  
  6502. new GuiBitmapCtrl() {
  6503. profile = "GuiDefaultProfile";
  6504. horizSizing = "center";
  6505. vertSizing = "center";
  6506. position = "3 3";
  6507. extent = "16 16";
  6508. minExtent = "8 2";
  6509. visible = "1";
  6510. bitmap = "Add-Ons/System_ReturnToBlockland/images/icons/shield_silver";
  6511. wrap = "0";
  6512. lockAspectRatio = "0";
  6513. alignLeft = "0";
  6514. overflowImage = "0";
  6515. keepCached = "0";
  6516. };
  6517. };
  6518. };
  6519. new GuiBitmapBorderCtrl() {
  6520. profile = "RTB_ContentBorderProfile";
  6521. horizSizing = "right";
  6522. vertSizing = "bottom";
  6523. position = "98 29";
  6524. extent = "30 30";
  6525. minExtent = "8 2";
  6526. visible = "1";
  6527.  
  6528. new GuiSwatchCtrl() {
  6529. profile = "GuiDefaultProfile";
  6530. horizSizing = "width";
  6531. vertSizing = "height";
  6532. position = "4 4";
  6533. extent = "22 22";
  6534. minExtent = "8 2";
  6535. visible = "1";
  6536. color = "255 255 255 255";
  6537.  
  6538. new GuiBitmapCtrl() {
  6539. profile = "GuiDefaultProfile";
  6540. horizSizing = "center";
  6541. vertSizing = "center";
  6542. position = "3 3";
  6543. extent = "16 16";
  6544. minExtent = "8 2";
  6545. visible = "1";
  6546. bitmap = "Add-Ons/System_ReturnToBlockland/images/icons/shield_gold";
  6547. wrap = "0";
  6548. lockAspectRatio = "0";
  6549. alignLeft = "0";
  6550. overflowImage = "0";
  6551. keepCached = "0";
  6552. };
  6553. };
  6554. };
  6555. new GuiBitmapButtonCtrl() {
  6556. profile = "GuiDefaultProfile";
  6557. horizSizing = "right";
  6558. vertSizing = "bottom";
  6559. position = "10 29";
  6560. extent = "30 30";
  6561. minExtent = "8 2";
  6562. visible = "1";
  6563. command = "";
  6564. text = " ";
  6565. groupNum = "-1";
  6566. buttonType = "PushButton";
  6567. lockAspectRatio = "0";
  6568. alignLeft = "0";
  6569. overflowImage = "0";
  6570. mKeepCached = "0";
  6571. mColor = "255 255 255 255";
  6572.  
  6573. dSet = "parent";
  6574. dName = "btn_normal";
  6575. dOffset = 1;
  6576. };
  6577. new GuiBitmapButtonCtrl() {
  6578. profile = "GuiDefaultProfile";
  6579. horizSizing = "right";
  6580. vertSizing = "bottom";
  6581. position = "54 29";
  6582. extent = "30 30";
  6583. minExtent = "8 2";
  6584. visible = "1";
  6585. command = "";
  6586. text = " ";
  6587. groupNum = "-1";
  6588. buttonType = "PushButton";
  6589. lockAspectRatio = "0";
  6590. alignLeft = "0";
  6591. overflowImage = "0";
  6592. mKeepCached = "0";
  6593. mColor = "255 255 255 255";
  6594.  
  6595. dSet = "parent";
  6596. dName = "btn_mod";
  6597. dOffset = 1;
  6598. };
  6599. new GuiBitmapButtonCtrl() {
  6600. profile = "GuiDefaultProfile";
  6601. horizSizing = "right";
  6602. vertSizing = "bottom";
  6603. position = "98 29";
  6604. extent = "30 30";
  6605. minExtent = "8 2";
  6606. visible = "1";
  6607. command = "";
  6608. text = " ";
  6609. groupNum = "-1";
  6610. buttonType = "PushButton";
  6611. lockAspectRatio = "0";
  6612. alignLeft = "0";
  6613. overflowImage = "0";
  6614. mKeepCached = "0";
  6615. mColor = "255 255 255 255";
  6616.  
  6617. dSet = "parent";
  6618. dName = "btn_admin";
  6619. dOffset = 1;
  6620. };
  6621. };
  6622. };
  6623. new GuiBitmapBorderCtrl() {
  6624. profile = "RTB_ContentBorderProfile";
  6625. horizSizing = "center";
  6626. vertSizing = "center";
  6627. position = "4 92";
  6628. extent = "267 100";
  6629. minExtent = "8 2";
  6630. visible = "0";
  6631.  
  6632. dSet = "window";
  6633. dName = "modal_BanUser";
  6634.  
  6635. new GuiSwatchCtrl() {
  6636. profile = "GuiDefaultProfile";
  6637. horizSizing = "width";
  6638. vertSizing = "height";
  6639. position = "3 4";
  6640. extent = "261 94";
  6641. minExtent = "8 2";
  6642. visible = "1";
  6643. color = "255 255 255 255";
  6644.  
  6645. new GuiSwatchCtrl() {
  6646. profile = "GuiDefaultProfile";
  6647. horizSizing = "width";
  6648. vertSizing = "top";
  6649. position = "0 72";
  6650. extent = "262 20";
  6651. minExtent = "8 2";
  6652. visible = "1";
  6653. color = "0 0 0 30";
  6654. };
  6655. new GuiSwatchCtrl() {
  6656. profile = "GuiDefaultProfile";
  6657. horizSizing = "width";
  6658. vertSizing = "bottom";
  6659. position = "0 0";
  6660. extent = "261 20";
  6661. minExtent = "8 2";
  6662. visible = "1";
  6663. color = "0 0 0 30";
  6664. };
  6665. new GuiMLTextCtrl() {
  6666. profile = "GuiMLTextProfile";
  6667. horizSizing = "right";
  6668. vertSizing = "bottom";
  6669. position = "23 5";
  6670. extent = "110 12";
  6671. minExtent = "8 2";
  6672. visible = "1";
  6673. lineSpacing = "2";
  6674. allowColorChars = "0";
  6675. maxChars = "-1";
  6676. text = "<color:444444><font:Verdana Bold:12>Ban User";
  6677. maxBitmapHeight = "-1";
  6678. selectable = "0";
  6679. };
  6680. new GuiBitmapButtonCtrl() {
  6681. profile = "GuiDefaultProfile";
  6682. horizSizing = "left";
  6683. vertSizing = "bottom";
  6684. position = "241 3";
  6685. extent = "16 16";
  6686. minExtent = "8 2";
  6687. visible = "1";
  6688. command = %this@".closeModalWindow();";
  6689. text = " ";
  6690. groupNum = "-1";
  6691. buttonType = "PushButton";
  6692. bitmap = "Add-Ons/System_ReturnToBlockland/images/ui/buttons/generic/cross";
  6693. lockAspectRatio = "0";
  6694. alignLeft = "0";
  6695. overflowImage = "0";
  6696. mKeepCached = "0";
  6697. mColor = "255 255 255 255";
  6698. };
  6699. new GuiBitmapCtrl() {
  6700. profile = "GuiDefaultProfile";
  6701. horizSizing = "right";
  6702. vertSizing = "bottom";
  6703. position = "3 2";
  6704. extent = "16 16";
  6705. minExtent = "8 2";
  6706. visible = "1";
  6707. bitmap = "Add-Ons/System_ReturnToBlockland/images/icons/delete";
  6708. wrap = "0";
  6709. lockAspectRatio = "0";
  6710. alignLeft = "0";
  6711. overflowImage = "0";
  6712. keepCached = "0";
  6713. };
  6714. new GuiTextEditCtrl() {
  6715. profile = "RTB_TextEditProfile";
  6716. horizSizing = "right";
  6717. vertSizing = "bottom";
  6718. position = "48 49";
  6719. extent = "206 16";
  6720. minExtent = "8 2";
  6721. visible = "1";
  6722. maxLength = "255";
  6723. historySize = "0";
  6724. password = "0";
  6725. tabComplete = "0";
  6726. sinkAllKeyEvents = "0";
  6727.  
  6728. dSet = "parent";
  6729. dName = "txt_reason";
  6730. dOffset = 1;
  6731. };
  6732. new GuiMLTextCtrl() {
  6733. profile = "GuiMLTextProfile";
  6734. horizSizing = "right";
  6735. vertSizing = "bottom";
  6736. position = "5 50";
  6737. extent = "42 12";
  6738. minExtent = "8 2";
  6739. visible = "1";
  6740. lineSpacing = "2";
  6741. allowColorChars = "0";
  6742. maxChars = "-1";
  6743. text = "<color:444444><font:Verdana Bold:12>Reason:";
  6744. maxBitmapHeight = "-1";
  6745. selectable = "0";
  6746. };
  6747. new GuiMLTextCtrl() {
  6748. profile = "GuiMLTextProfile";
  6749. horizSizing = "right";
  6750. vertSizing = "bottom";
  6751. position = "5 30";
  6752. extent = "42 12";
  6753. minExtent = "8 2";
  6754. visible = "1";
  6755. lineSpacing = "2";
  6756. allowColorChars = "0";
  6757. maxChars = "-1";
  6758. text = "<color:444444><font:Verdana Bold:12>Length:";
  6759. maxBitmapHeight = "-1";
  6760. selectable = "0";
  6761. };
  6762. new GuiPopUpMenuCtrl() {
  6763. profile = "RTB_PopupProfile";
  6764. horizSizing = "right";
  6765. vertSizing = "bottom";
  6766. position = "48 28";
  6767. extent = "139 16";
  6768. minExtent = "8 2";
  6769. visible = "1";
  6770. maxLength = "255";
  6771. maxPopupHeight = "200";
  6772.  
  6773. dSet = "parent";
  6774. dName = "pop_length";
  6775. dOffset = 1;
  6776. };
  6777. new GuiMLTextCtrl() {
  6778. profile = "GuiMLTextProfile";
  6779. horizSizing = "right";
  6780. vertSizing = "bottom";
  6781. position = "213 30";
  6782. extent = "38 12";
  6783. minExtent = "8 2";
  6784. visible = "1";
  6785. lineSpacing = "2";
  6786. allowColorChars = "0";
  6787. maxChars = "-1";
  6788. text = "<color:444444><font:Verdana Bold:12>Forever";
  6789. maxBitmapHeight = "-1";
  6790. selectable = "0";
  6791. };
  6792. new GuiCheckBoxCtrl() {
  6793. profile = "RTB_CheckBoxProfile";
  6794. horizSizing = "right";
  6795. vertSizing = "bottom";
  6796. position = "195 28";
  6797. extent = "61 18";
  6798. minExtent = "8 2";
  6799. visible = "1";
  6800. text = " ";
  6801. groupNum = "-1";
  6802. buttonType = "ToggleButton";
  6803.  
  6804. dSet = "parent";
  6805. dName = "chk_forever";
  6806. dOffset = 1;
  6807. };
  6808. new GuiBitmapButtonCtrl() {
  6809. profile = "GuiDefaultProfile";
  6810. horizSizing = "left";
  6811. vertSizing = "bottom";
  6812. position = "241 74";
  6813. extent = "16 16";
  6814. minExtent = "8 2";
  6815. visible = "1";
  6816. text = " ";
  6817. groupNum = "-1";
  6818. buttonType = "PushButton";
  6819. bitmap = $RTB::Path@"images/ui/buttons/generic/tick";
  6820. lockAspectRatio = "0";
  6821. alignLeft = "0";
  6822. overflowImage = "0";
  6823. mKeepCached = "0";
  6824. mColor = "255 255 255 255";
  6825.  
  6826. dSet = "parent";
  6827. dName = "btn_ban";
  6828. dOffset = 1;
  6829. };
  6830. };
  6831. };
  6832. };
  6833. };
  6834. RTB_Overlay.add(%window);
  6835.  
  6836. %this.window = %window;
  6837. %window.session = %this;
  6838. %this.registerPointers(%window);
  6839.  
  6840. %input = RTBCC_InputRecycler.get();
  6841. %window.getObject(5).add(%input);
  6842. %input.horizSizing = "width";
  6843. %input.vertSizing = "bottom";
  6844. %input.position = "1 3";
  6845. %input.extent = "407 16";
  6846. %input.command = %this@".focus();";
  6847. %input.altCommand = %this@".send();";
  6848.  
  6849. %window.input = %input;
  6850. %window.closeCommand = %this@".room.leave(1);";
  6851. %window.overlayCloseCommand = %this@".room.leave(0);";
  6852.  
  6853. %window.getObject(2).command = %window.userPane@".setVisible(true);"@%window.optsPane@".setVisible(false);";
  6854. %window.getObject(3).command = %window.userPane@".setVisible(false);"@%window.optsPane@".setVisible(true);";
  6855. %window.getObject(2).performClick();
  6856.  
  6857. RTBCC_RoomOptionsManager.loadRoomSettings(%this);
  6858. %this.options = RTBCC_RoomOptionsManager.getRoomStore(%this.room.name);
  6859.  
  6860. %this.positionWindow();
  6861.  
  6862. if(%this.room.conversationHistory !$= "")
  6863. {
  6864. %history = strReplace(strReplace(%this.room.conversationHistory,"\n","<br>"),"<color:","\t");
  6865. %this.room.conversationHistory = "";
  6866.  
  6867. %text = getField(%history,0);
  6868. for(%i=1;%i<getFieldCount(%history);%i++)
  6869. {
  6870. %part = getField(%history,%i);
  6871. %text = %text @ "<color:CCCCCC>" @ getSubStr(%part,7,strLen(%part));
  6872. }
  6873. %window.display.setText("<color:CCCCCC>"@%text@"<color:444444>");
  6874.  
  6875. %window.display.setCursorPosition(strLen(%window.display.getValue()));
  6876. %window.scroll.scrollToBottom();
  6877. }
  6878. }
  6879.  
  6880. //- RTBCC_RoomSession::registerPointers (can't even sum this one up in a line)
  6881. function RTBCC_RoomSession::registerPointers(%this, %parent)
  6882. {
  6883. for(%i=0;%i<%parent.getCount();%i++)
  6884. {
  6885. %ctrl = %parent.getObject(%i);
  6886.  
  6887. if(%ctrl.dSet $= "parent")
  6888. {
  6889. %target = %ctrl.getGroup();
  6890. if(%ctrl.dOffset > 0)
  6891. for(%j=0;%j<%ctrl.dOffset;%j++)
  6892. %target = %target.getGroup();
  6893.  
  6894. eval(%target@"."@%ctrl.dName@" = "@%ctrl@";");
  6895. }
  6896. else if(%ctrl.dSet $= "window")
  6897. eval(%this.window@"."@%ctrl.dName@" = "@%ctrl@";");
  6898.  
  6899. %ctrl.dSet = "";
  6900. %ctrl.dName = "";
  6901.  
  6902. if(%ctrl.getCount() > 0)
  6903. %this.registerPointers(%ctrl);
  6904. }
  6905. }
  6906.  
  6907. //- RTBCC_RoomSession::positionWindow (determines best position to render room window)
  6908. function RTBCC_RoomSession::positionWindow(%this)
  6909. {
  6910. if(RTBCO_getPref("CC::SavePositions"))
  6911. {
  6912. if(%this.options.window_position !$= "" && %this.options.window_extent !$= "")
  6913. {
  6914. // some fucking lame torque bug that causes crashes for whatever fucking reason
  6915. if(RTB_Overlay.isAwake())
  6916. {
  6917. %this.window.resize(getWord(%this.options.window_position,0),getWord(%this.options.window_position,1),getWord(%this.options.window_extent,0),getWord(%this.options.window_extent,1));
  6918. %this.positionOnWake = false;
  6919. }
  6920. else
  6921. %this.positionOnWake = true;
  6922. return;
  6923. }
  6924. }
  6925.  
  6926. %offset = 0;
  6927. %position = "0 0";
  6928. while(%free !$= true)
  6929. {
  6930. %free = true;
  6931. for(%i=0;%i<RTBCC_RoomSessionManager.getCount();%i++)
  6932. {
  6933. %session = RTBCC_RoomSessionManager.getObject(%i);
  6934. if(!%session.isRendered() || %session $= %this)
  6935. continue;
  6936.  
  6937. if(%session.window.position $= %position)
  6938. {
  6939. %free = false;
  6940. break;
  6941. }
  6942. }
  6943.  
  6944. if(%free !$= true)
  6945. {
  6946. %offset += 40;
  6947. %position = %offset SPC %offset;
  6948. }
  6949. }
  6950. %this.window.position = %position;
  6951. }
  6952.  
  6953. //- RTBCC_RoomSession::isRendered (determines whether the session room is rendered)
  6954. function RTBCC_RoomSession::isRendered(%this)
  6955. {
  6956. if(isObject(%this.window) && %this.window.session $= %this)
  6957. return true;
  6958. return false;
  6959. }
  6960.  
  6961. //- RTBCC_RoomSession::unrender (unrenders the session room window)
  6962. function RTBCC_RoomSession::unrender(%this)
  6963. {
  6964. if(!%this.isRendered())
  6965. return;
  6966.  
  6967. %store = RTBCC_RoomOptionsManager.getRoomStore(%this.name);
  6968. %store.window_position = %this.window.position;
  6969. %store.window_extent = %this.window.extent;
  6970. RTBCC_RoomOptionsManager.store();
  6971.  
  6972. %this.room.conversationHistory = %this.window.display.getValue();
  6973.  
  6974. RTBCC_InputRecycler.reclaim(%this.window.input);
  6975. %this.window.delete();
  6976. %this.window = "";
  6977. }
  6978.  
  6979. //- RTBCC_RoomSession::destroy (destroys a room session)
  6980. function RTBCC_RoomSession::destroy(%this)
  6981. {
  6982. if(isObject(%this.logger))
  6983. {
  6984. %this.logger.close();
  6985. %this.logger = "";
  6986. }
  6987. %this.unrender();
  6988. %this.delete();
  6989. }
  6990.  
  6991. //*********************************************************
  6992. //* Room Session Window Modal Implementation
  6993. //*********************************************************
  6994. //- RTBCC_RoomSession::setModalWindow (sets modal window for session)
  6995. function RTBCC_RoomSession::setModalWindow(%this,%modal)
  6996. {
  6997. %group = %this.window.modalSwatch;
  6998. for(%i=0;%i<%group.getCount();%i++)
  6999. {
  7000. %group.getObject(%i).setVisible(false);
  7001. }
  7002.  
  7003. if(%modal $= "")
  7004. {
  7005. %group.setVisible(false);
  7006. return;
  7007. }
  7008. %group.setVisible(true);
  7009.  
  7010. if(isObject(%this.window.modal_[%modal]))
  7011. {
  7012. %this.window.modal_[%modal].setVisible(true);
  7013. %this.window.modal_[%modal].center();
  7014. }
  7015. }
  7016.  
  7017. //- RTBCC_RoomSession::closeModalWindow (closes modal window for session)
  7018. function RTBCC_RoomSession::closeModalWindow(%this)
  7019. {
  7020. %this.window.modalSwatch.setVisible(false);
  7021.  
  7022. %this.window.input.makeFirstResponder(1);
  7023. }
  7024.  
  7025. //- RTBCC_RoomSession::messageBoxOK (opens an ok message box)
  7026. function RTBCC_RoomSession::messageBoxOK(%this,%title,%message,%ok)
  7027. {
  7028. %this.setModalWindow("BoxOK");
  7029.  
  7030. %modal = %this.window.modal_BoxOK;
  7031. %modal.m_title.setText("<color:444444><font:Verdana Bold:12>"@%title);
  7032. %modal.m_text.setText("<color:444444><font:Verdana:12>"@%message);
  7033. %modal.m_ok.command = %this@".closeModalWindow();"@%ok;
  7034. %modal.m_accel.makeFirstResponder(1);
  7035.  
  7036. if(RTB_ConnectClient.isOpen())
  7037. %modal.m_text.forceReflow();
  7038. %textHeight = getWord(%modal.m_text.extent,1);
  7039. %modalHeight = %textHeight+52;
  7040.  
  7041. if(%modalHeight < 91)
  7042. %modalHeight = 91;
  7043.  
  7044. %modal.resize(11,91,174,%modalHeight);
  7045. %modal.center();
  7046. }
  7047.  
  7048. //- RTBCC_RoomSession::messageBoxError (opens an error message box)
  7049. function RTBCC_RoomSession::messageBoxError(%this,%title,%message,%ok)
  7050. {
  7051. %this.setModalWindow("BoxError");
  7052.  
  7053. %modal = %this.window.modal_BoxError;
  7054. %modal.m_title.setText("<color:444444><font:Verdana Bold:12>"@%title);
  7055. %modal.m_text.setText("<color:444444><font:Verdana:12>"@%message);
  7056. %modal.m_ok.command = %this@".closeModalWindow();"@%ok;
  7057. %modal.m_accel.makeFirstResponder(1);
  7058.  
  7059. if(RTB_ConnectClient.isOpen())
  7060. %modal.m_text.forceReflow();
  7061. %textHeight = getWord(%modal.m_text.extent,1);
  7062. %modalHeight = %textHeight+52;
  7063.  
  7064. if(%modalHeight < 91)
  7065. %modalHeight = 91;
  7066.  
  7067. %modal.resize(11,91,174,%modalHeight);
  7068. %modal.center();
  7069. }
  7070.  
  7071. //*********************************************************
  7072. //* Room Session Manifest Implementation
  7073. //*********************************************************
  7074. //- RTBCC_RoomSessionManifest::addUser (adds a user to the room session manifest)
  7075. function RTBCC_RoomSessionManifest::addUser(%this,%id,%name,%rank,%icon,%blocked)
  7076. {
  7077. if(%this.hasUser(%id))
  7078. return %this.getByID(%id);
  7079.  
  7080. %user = new ScriptObject()
  7081. {
  7082. class = "RTBCC_RoomSessionManifestUser";
  7083.  
  7084. id = %id;
  7085. name = %name;
  7086. rank = %rank;
  7087. icon = %icon;
  7088.  
  7089. blocked = %blocked;
  7090.  
  7091. session = %this.getGroup();
  7092. manifest = %this;
  7093. };
  7094. %this.add(%user);
  7095.  
  7096. if(%this.getCount() == 1)
  7097. %this.getGroup().window.setText(%this.getGroup().window.title @ " (1 user)");
  7098. else
  7099. %this.getGroup().window.setText(%this.getGroup().window.title @ " (" @ %this.getCount() @ " users)");
  7100.  
  7101. return %user;
  7102. }
  7103.  
  7104. //- RTBCC_RoomSessionManifest::hasUser (checks if manifest contains user)
  7105. function RTBCC_RoomSessionManifest::hasUser(%this,%id)
  7106. {
  7107. for(%i=0;%i<%this.getCount();%i++)
  7108. {
  7109. if(%this.getObject(%i).id $= %id)
  7110. return true;
  7111. }
  7112. return false;
  7113. }
  7114.  
  7115. //- RTBCC_RoomSessionManifest::getByID (returns manifest item by id)
  7116. function RTBCC_RoomSessionManifest::getByID(%this,%id)
  7117. {
  7118. if(!%this.hasUser(%id))
  7119. return false;
  7120.  
  7121. for(%i=0;%i<%this.getCount();%i++)
  7122. {
  7123. %user = %this.getObject(%i);
  7124. if(%user.id $= %id)
  7125. return %user;
  7126. }
  7127. return false;
  7128. }
  7129.  
  7130. //- RTBCC_RoomSessionManifest::removeByID (remove user from session manifest by id)
  7131. function RTBCC_RoomSessionManifest::removeByID(%this,%id)
  7132. {
  7133. if(!%this.hasUser(%id))
  7134. return false;
  7135.  
  7136. %user = %this.getByID(%id);
  7137. %user.unrender();
  7138. %user.delete();
  7139.  
  7140. if(%this.getCount() == 1)
  7141. %this.getGroup().window.setText(%this.getGroup().window.title @ " (1 user)");
  7142. else
  7143. %this.getGroup().window.setText(%this.getGroup().window.title @ " (" @ %this.getCount() @ " users)");
  7144. }
  7145.  
  7146. //- RTBCC_RoomSessionManifest::sort (sorts the manifest by rank/name)
  7147. function RTBCC_RoomSessionManifest::sort(%this)
  7148. {
  7149. if(%this.getCount() <= 0)
  7150. return;
  7151.  
  7152. for(%i=3;%i>=0;%i--)
  7153. {
  7154. %sorter = new GuiTextListCtrl();
  7155. for(%j=0;%j<%this.getCount();%j++)
  7156. {
  7157. %user = %this.getObject(%j);
  7158. if(%user.rank $= %i)
  7159. %sorter.addRow(%user,%user.name);
  7160. }
  7161. %sorter.sort(0,1);
  7162.  
  7163. for(%j=0;%j<%sorter.rowCount();%j++)
  7164. {
  7165. %this.pushToBack(%sorter.getRowId(%j));
  7166. }
  7167. %sorter.delete();
  7168. }
  7169. }
  7170.  
  7171. //- RTBCC_RoomSessionManifest::render (renders the manifest)
  7172. function RTBCC_RoomSessionManifest::render(%this)
  7173. {
  7174. %this.session.window.userSwatch.clear();
  7175.  
  7176. %this.sort();
  7177. for(%i=0;%i<%this.getCount();%i++)
  7178. {
  7179. %item = %this.getObject(%i);
  7180. %item.renderInPlace("0" SPC (%i * 22));
  7181. }
  7182. %item.session.window.userSwatch.extent = "0" SPC (%i * 22);
  7183. %item.manifest.reshape();
  7184.  
  7185. if(%this.getCount() == 1)
  7186. %this.getGroup().window.setText(%this.getGroup().window.title @ " (1 user)");
  7187. else
  7188. %this.getGroup().window.setText(%this.getGroup().window.title @ " (" @ %this.getCount() @ " users)");
  7189. }
  7190.  
  7191. //- RTBCC_RoomSessionManifest::reshape (reshapes the swatch)
  7192. function RTBCC_RoomSessionManifest::reshape(%this)
  7193. {
  7194. %swatch = %this.getGroup().window.userSwatch;
  7195.  
  7196. %swatch.resize(1,getWord(%swatch.position,1),194,%swatch.getLowestPoint());
  7197. }
  7198.  
  7199. //*********************************************************
  7200. //* Room Session Manifest User Implementation
  7201. //*********************************************************
  7202. //- RTBCC_RoomSessionManifestUser::isRendered (checks to see if the manifest user is rendered already)
  7203. function RTBCC_RoomSessionManifestUser::isRendered(%this)
  7204. {
  7205. if(!isObject(%this.gui_container))
  7206. return false;
  7207.  
  7208. if(%this.gui_container.getGroup().getID() !$= %this.session.window.userSwatch.getID())
  7209. return false;
  7210.  
  7211. return true;
  7212. }
  7213.  
  7214. //- RTBCC_RoomSessionManifestUser::render (attempts to render the manifest user)
  7215. function RTBCC_RoomSessionManifestUser::render(%this)
  7216. {
  7217. if(%this.isRendered())
  7218. {
  7219. %this.gui_userIcon.setBitmap($RTB::Path @ "images/icons/" @ %this.icon);
  7220. %this.gui_userName.setText("<color:444444><font:Verdana:12>" @ %this.name);
  7221. }
  7222. else
  7223. {
  7224. %position = 0;
  7225. %this.getGroup().sort();
  7226. for(%i=0;%i<%this.getGroup().getCount();%i++)
  7227. {
  7228. %user = %this.getGroup().getObject(%i);
  7229. if(!%user.isRendered() && %user !$= %this)
  7230. continue;
  7231.  
  7232. if(%this $= %user)
  7233. {
  7234. %this.session.window.userSwatch.conditionalShiftY(%position,22);
  7235. %this.renderInPlace("0" SPC %position);
  7236. %this.session.window.userSwatch.extent = vectorAdd(%this.session.window.userSwatch.extent,"0 22");
  7237. %this.manifest.reshape();
  7238. }
  7239. else
  7240. %position += 22;
  7241. }
  7242. }
  7243. }
  7244.  
  7245. //- RTBCC_RoomSessionManifestUser::renderInPlace (renders a manifest user taking a position argument)
  7246. function RTBCC_RoomSessionManifestUser::renderInPlace(%this,%position)
  7247. {
  7248. if(%this.isRendered())
  7249. return;
  7250.  
  7251. %swatch = %this.session.window.userSwatch;
  7252.  
  7253. %container = new GuiSwatchCtrl()
  7254. {
  7255. position = %position;
  7256. extent = "129 22";
  7257.  
  7258. color = "0 0 0 0";
  7259. };
  7260. %swatch.add(%container);
  7261. %this.gui_container = %container;
  7262.  
  7263. %selectBox = new GuiBitmapCtrl()
  7264. {
  7265. position = "0 0";
  7266. extent = "129 22";
  7267.  
  7268. visible = false;
  7269. bitmap = $RTB::Path @ "images/ui/userListSelect_n";
  7270. };
  7271. %container.add(%selectBox);
  7272. %this.gui_selectBox = %selectBox;
  7273.  
  7274. %icon = new GuiBitmapCtrl()
  7275. {
  7276. position = "1 3";
  7277. extent = "16 16";
  7278. };
  7279. %container.add(%icon);
  7280. %this.gui_userIcon = %icon;
  7281.  
  7282. %text = new GuiMLTextCtrl()
  7283. {
  7284. position = "19 5";
  7285. extent = "147 12";
  7286.  
  7287. selectable = false;
  7288. };
  7289. %container.add(%text);
  7290. %this.gui_userName = %text;
  7291.  
  7292. %mouseEvent = new GuiMouseEventCtrl()
  7293. {
  7294. position = "0 0";
  7295. extent = "129 22";
  7296.  
  7297. persistent = 1;
  7298. eventType = "UserListSelect";
  7299. eventCallbacks = "1111011";
  7300.  
  7301. user = %this;
  7302. select = %selectBox;
  7303. session = %this.getGroup().session;
  7304. };
  7305. %container.add(%mouseEvent);
  7306. %this.gui_mouseEvent = %mouseEvent;
  7307.  
  7308. %this.render();
  7309. }
  7310.  
  7311. //- RTBCC_RoomSessionManifestUser::rerender (rerenders the manifest user if it's already rendered)
  7312. function RTBCC_RoomSessionManifestUser::rerender(%this)
  7313. {
  7314. if(%this.isRendered())
  7315. %this.unrender();
  7316. %this.render();
  7317. }
  7318.  
  7319. //- RTBCC_RoomSessionManifestUser::unrender (unrenders the manifest user)
  7320. function RTBCC_RoomSessionManifestUser::unrender(%this)
  7321. {
  7322. if(!%this.isRendered())
  7323. return;
  7324.  
  7325. %this.closeMenu();
  7326. %position = getWord(%this.gui_container.position,1);
  7327.  
  7328. %this.gui_container.delete();
  7329.  
  7330. %this.session.window.userSwatch.conditionalShiftY(%position,-22);
  7331. %this.session.window.userSwatch.extent = vectorSub(%this.session.window.userSwatch.extent,"0 22");
  7332.  
  7333. %this.manifest.reshape();
  7334. }
  7335.  
  7336. //- RTBCC_RoomSessionManifestUser::openMenu (opens a menu of items for the user to select)
  7337. function RTBCC_RoomSessionManifestUser::openMenu(%this)
  7338. {
  7339. %this.gui_selectBox.setBitmap($RTB::Path @ "images/ui/userListSelect_d");
  7340.  
  7341. %top = getWord(%this.gui_selectBox.getPosRelativeTo(%this.session.window.userScroll),1);
  7342. %bottom = %top + getWord(%this.gui_selectBox.extent,1);
  7343. %scrollExt = getWord(%this.session.window.userScroll.extent,1)-2;
  7344.  
  7345. if(%top < 0)
  7346. %this.session.window.userSwatch.resize(1,getWord(%this.session.window.userSwatch.position,1)-(%top-2),140,getWord(%this.session.window.userSwatch.extent,1));
  7347. if(%bottom > %scrollExt)
  7348. %this.session.window.userSwatch.resize(1,getWord(%this.session.window.userSwatch.position,1)-(%bottom-%scrollExt)-2,140,getWord(%this.session.window.userSwatch.extent,1));
  7349.  
  7350.  
  7351. %menuItems = -1;
  7352. %menuIcon[%menuItems++] = "comment";
  7353. %menuText[%menuItems] = "Chat";
  7354. %menuComm[%menuItems] = %this@".openChatWindow();";
  7355. %menuIcon[%menuItems++] = "information";
  7356. %menuText[%menuItems] = "Info";
  7357. %menuComm[%menuItems] = %this@".info();";
  7358. if(!RTBCC_Roster.hasID(%this.id) && !RTBCC_InviteRoster.hasID(%this.id))
  7359. {
  7360. %menuIcon[%menuItems++] = "heart_add";
  7361. %menuText[%menuItems] = "Friend";
  7362. %menuComm[%menuItems] = %this@".addFriend();";
  7363. }
  7364. if(%this.manifest.getById(RTB_ConnectClient.client_id).rank >= 1 && %this.rank < %this.manifest.getById(RTB_ConnectClient.client_id).rank)
  7365. {
  7366. %menuIcon[%menuItems++] = "block";
  7367. %menuText[%menuItems] = "Kick";
  7368. %menuComm[%menuItems] = %this@".kick();";
  7369. }
  7370. if(%this.manifest.getById(RTB_ConnectClient.client_id).rank >= 2 && %this.rank < %this.manifest.getById(RTB_ConnectClient.client_id).rank)
  7371. {
  7372. %menuIcon[%menuItems++] = "delete";
  7373. %menuText[%menuItems] = "Ban";
  7374. %menuComm[%menuItems] = %this@".ban();";
  7375.  
  7376. %menuIcon[%menuItems++] = "medal_gold_3";
  7377. %menuText[%menuItems] = "Rank";
  7378. %menuComm[%menuItems] = %this@".changeRank();";
  7379. }
  7380. %menuItems++;
  7381.  
  7382. %menuSize = (%menuItems * 20) + 4;
  7383.  
  7384. %container = RTB_Overlay;
  7385. %position = %this.gui_selectBox.getAbsPosition(%container);
  7386. %menu = new GuiSwatchCtrl()
  7387. {
  7388. position = vectorAdd(%position,"63 22");
  7389. extent = "66" SPC %menuSize;
  7390. color = "0 0 0 0";
  7391.  
  7392. user = %this;
  7393.  
  7394. new GuiBitmapCtrl()
  7395. {
  7396. position = "0" SPC %menuSize - 4;
  7397. extent = "66 4";
  7398.  
  7399. bitmap = $RTB::Path @ "images/ui/buddyListMenuBottom";
  7400. };
  7401. };
  7402. %container.add(%menu);
  7403. %this.gui_menu = %menu;
  7404. %this.session.gui_userMenu = %menu;
  7405.  
  7406. for(%i=0;%i<%menuItems;%i++)
  7407. {
  7408. %item = new GuiBitmapCtrl()
  7409. {
  7410. position = "0" SPC (%i * 20);
  7411. extent = "66 20";
  7412.  
  7413. bitmap = $RTB::Path @ "images/ui/buddyListMenu_n";
  7414.  
  7415. new GuiBitmapCtrl()
  7416. {
  7417. position = "4 2";
  7418. extent = "16 16";
  7419.  
  7420. bitmap = $RTB::Path @ "images/icons/" @ %menuIcon[%i];
  7421. };
  7422.  
  7423. new GuiMLTextCtrl()
  7424. {
  7425. position = "22 4";
  7426. extent = "54 12";
  7427.  
  7428. text = "<color:444444><font:Verdana:12>" @ %menuText[%i];
  7429.  
  7430. selectable = false;
  7431. };
  7432. };
  7433. %menu.add(%item);
  7434.  
  7435. %mouseEvent = new GuiMouseEventCtrl()
  7436. {
  7437. position = "0" SPC (%i * 20);
  7438. extent = "66 20";
  7439.  
  7440. eventType = "UserListMenu";
  7441. eventCallbacks = "1101000";
  7442.  
  7443. user = %this;
  7444. item = %item;
  7445. command = %menuComm[%i];
  7446. };
  7447. %menu.add(%mouseEvent);
  7448. }
  7449. %this.gui_mouseEvent.extent = "129" SPC (%menuSize + 30);
  7450.  
  7451. if(RTBCO_getPref("CC::EnableSounds"))
  7452. alxPlay(RTBCC_TickSound);
  7453. }
  7454.  
  7455. //- RTBCC_RoomSessionManifestUser::closeMenu (closes the roster menu)
  7456. function RTBCC_RoomSessionManifestUser::closeMenu(%this)
  7457. {
  7458. if(isObject(%this.gui_menu))
  7459. {
  7460. %this.session.gui_userMenu = "";
  7461. %this.gui_menu.schedule(1,"delete");
  7462. if(RTBCO_getPref("CC::EnableSounds"))
  7463. alxPlay(RTBCC_TickSound);
  7464. }
  7465.  
  7466. %this.gui_mouseEvent.extent = "129 22";
  7467. %this.gui_selectBox.setBitmap($RTB::Path @ "images/ui/userListSelect_n");
  7468. }
  7469.  
  7470. //- Event_UserListSelect::onMouseEnter (handles entry interaction with roster user item)
  7471. function Event_UserListSelect::onMouseEnter(%this)
  7472. {
  7473. %this.select.setVisible(true);
  7474. }
  7475.  
  7476. //- Event_UserListSelect::onMouseLeave (handles leaving interaction with roster user item)
  7477. function Event_UserListSelect::onMouseLeave(%this)
  7478. {
  7479. %this.select.setVisible(false);
  7480.  
  7481. %this.user.closeMenu();
  7482. }
  7483.  
  7484. //- Event_UserListSelect::onMouseDown (handles click interaction with roster user item)
  7485. function Event_UserListSelect::onMouseDown(%this)
  7486. {
  7487. if(%this.user.id $= RTB_ConnectClient.client_id)
  7488. return;
  7489.  
  7490. if(isObject(%this.session.gui_userMenu) && %this.session.gui_userMenu.user !$= %this.user)
  7491. %this.session.gui_userMenu.user.closeMenu();
  7492.  
  7493. if(isObject(%this.user.gui_menu))
  7494. return;
  7495.  
  7496. %this.select.setBitmap($RTB::Path @ "images/ui/userListSelect_h");
  7497. }
  7498.  
  7499. //- Event_UserListSelect::onMouseUp (handles click interaction with roster user item)
  7500. function Event_UserListSelect::onMouseUp(%this)
  7501. {
  7502. if(%this.user.id $= RTB_ConnectClient.client_id)
  7503. return;
  7504.  
  7505. if(isObject(%this.session.gui_userMenu) && %this.session.gui_userMenu.user !$= %this.user)
  7506. return;
  7507.  
  7508. if(isObject(%this.user.gui_menu))
  7509. {
  7510. %this.user.closeMenu();
  7511.  
  7512. if((getSimTime() - %this.lastClickTime) <= 300)
  7513. %this.user.openChatWindow();
  7514.  
  7515. return;
  7516. }
  7517.  
  7518. %this.user.openMenu();
  7519.  
  7520. %this.lastClickTime = getSimTime();
  7521. }
  7522.  
  7523. //- Event_UserListSelect::onRightMouseDown (handles click interaction with roster user item)
  7524. function Event_UserListSelect::onRightMouseDown(%this)
  7525. {
  7526. if(%this.user.id $= RTB_ConnectClient.client_id)
  7527. return;
  7528.  
  7529. if(isObject(%this.session.gui_userMenu) && %this.session.gui_userMenu.user !$= %this.user)
  7530. %this.session.gui_userMenu.user.closeMenu();
  7531.  
  7532. if(isObject(%this.user.gui_menu))
  7533. return;
  7534.  
  7535. %this.select.setBitmap($RTB::Path @ "images/ui/userListSelect_h");
  7536. }
  7537.  
  7538. //- Event_UserListSelect::onRightMouseUp (handles click interaction with roster user item)
  7539. function Event_UserListSelect::onRightMouseUp(%this)
  7540. {
  7541. if(%this.user.id $= RTB_ConnectClient.client_id)
  7542. return;
  7543.  
  7544. if(isObject(%this.session.gui_userMenu) && %this.session.gui_userMenu.user !$= %this.user)
  7545. return;
  7546.  
  7547. if(isObject(%this.user.gui_menu))
  7548. {
  7549. %this.user.closeMenu();
  7550. return;
  7551. }
  7552.  
  7553. %this.user.openMenu();
  7554.  
  7555. %this.lastClickTime = getSimTime();
  7556. }
  7557.  
  7558. //- Event_BuddyListMenu::onMouseEnter (handles menu item interaction of the roster interact menu)
  7559. function Event_UserListMenu::onMouseEnter(%this)
  7560. {
  7561. %this.item.setBitmap($RTB::Path @ "images/ui/buddyListMenu_h");
  7562. }
  7563.  
  7564. //- Event_BuddyListMenu::onMouseLeave (handles menu item interaction of the roster interact menu)
  7565. function Event_UserListMenu::onMouseLeave(%this)
  7566. {
  7567. %this.item.setBitmap($RTB::Path @ "images/ui/buddyListMenu_n");
  7568. }
  7569.  
  7570. //- Event_BuddyListMenu::onMouseUp (handles menu item interaction of the roster interact menu)
  7571. function Event_UserListMenu::onMouseUp(%this)
  7572. {
  7573. eval(%this.command);
  7574. }
  7575.  
  7576. //- RTBCC_RoomSessionManifestUser::openChatWindow (opens chat window with user)
  7577. function RTBCC_RoomSessionManifestUser::openChatWindow(%this)
  7578. {
  7579. if(!RTBCC_Roster.hasID(%this.id))
  7580. RTBCC_TempRoster.addUser(%this.id,%this.name);
  7581.  
  7582. if(RTBCC_SessionManager.hasID(%this.id))
  7583. RTBCC_SessionManager.getByID(%this.id).render();
  7584. else
  7585. RTBCC_SessionManager.createSession(%this.id);
  7586.  
  7587. RTBCC_SessionManager.getByID(%this.id).setBlockedStatus(%this.blocked);
  7588.  
  7589. %this.closeMenu();
  7590. }
  7591.  
  7592. //- RTBCC_RoomSessionManifestUser::info (gets info on a user)
  7593. function RTBCC_RoomSessionManifestUser::info(%this)
  7594. {
  7595. RTBCC_Socket.getUserInfo(%this.id);
  7596. RTB_ConnectClient.messageBox("Please Wait ...","Getting user details for Blockland ID "@%this.id);
  7597.  
  7598. %this.closeMenu();
  7599. }
  7600.  
  7601. //- RTBCC_RoomSessionManifestUser::addFriend (adds user as a friend)
  7602. function RTBCC_RoomSessionManifestUser::addFriend(%this)
  7603. {
  7604. RTBCC_Socket.addToRoster(%this.id,%this.session);
  7605.  
  7606. %this.closeMenu();
  7607. }
  7608.  
  7609. //- RTBCC_RoomSessionManifestUser::kick (tries to kick a user)
  7610. function RTBCC_RoomSessionManifestUser::kick(%this)
  7611. {
  7612. RTBCC_Socket.kickUser(%this.session.name,%this.id);
  7613.  
  7614. %this.closeMenu();
  7615. }
  7616.  
  7617. //- RTBCC_RoomSessionManifestUser::ban (tries to ban a user)
  7618. function RTBCC_RoomSessionManifestUser::ban(%this,%flag)
  7619. {
  7620. %this.closeMenu();
  7621.  
  7622. %modal = %this.session.window.modal_BanUser;
  7623.  
  7624. if(%flag $= "")
  7625. {
  7626. %this.session.setModalWindow("BanUser");
  7627.  
  7628. %modal.btn_ban.command = %this@".ban(1);";
  7629.  
  7630. %select = %modal.pop_length;
  7631. %select.clear();
  7632.  
  7633. %select.add("5 Minutes",60*5);
  7634. %select.add("15 Minutes",60*15);
  7635. %select.add("30 Minutes",60*30);
  7636. %select.add("1 Hour",60*60);
  7637. %select.add("2 Hours",60*60*2);
  7638. %select.add("6 Hours",60*60*6);
  7639. %select.add("12 Hours",60*60*12);
  7640. %select.add("1 Day",60*60*24);
  7641. %select.add("2 Days",60*60*24*2);
  7642. %select.add("5 Days",60*60*24*5);
  7643. %select.add("1 Week",60*60*24*7);
  7644.  
  7645. return;
  7646. }
  7647. %this.session.closeModalWindow();
  7648.  
  7649. %reason = %modal.txt_reason.getValue();
  7650. %length = (%modal.chk_forever.getValue() $= 1) ? -1 : %modal.pop_length.getSelected();
  7651.  
  7652. RTBCC_Socket.banUser(%this.session.name,%this.id,%reason,%length);
  7653. }
  7654.  
  7655. //- RTBCC_RoomSessionManifestUser::changeRank (opens dialog to change rank, and changes it)
  7656. function RTBCC_RoomSessionManifestUser::changeRank(%this,%rank)
  7657. {
  7658. %this.closeMenu();
  7659.  
  7660. if(%rank $= "")
  7661. {
  7662. %this.session.setModalWindow("ChangeRank");
  7663.  
  7664. %modal = %this.session.window.modal_ChangeRank;
  7665. %modal.btn_normal.command = %this@".changeRank(0);";
  7666. %modal.btn_mod.command = %this@".changeRank(1);";
  7667. %modal.btn_admin.command = %this@".changeRank(2);";
  7668.  
  7669. return;
  7670. }
  7671. %this.session.closeModalWindow();
  7672.  
  7673. RTBCC_Socket.changeUserRank(%this.session.name,%this.id,%rank);
  7674. }
  7675.  
  7676. //*********************************************************
  7677. //* Room Options Manager
  7678. //*********************************************************
  7679. //- RTBCC_createRoomOptionsManager (creates a room options manager)
  7680. function RTBCC_createRoomOptionsManager()
  7681. {
  7682. if(isObject(RTBCC_RoomOptionsManager))
  7683. RTBCC_RoomOptionsManager.delete();
  7684.  
  7685. if(isFile("config/client/rtb/rooms.cs"))
  7686. exec("config/client/rtb/rooms.cs");
  7687.  
  7688. if(isObject(RTBCC_RoomOptionsManager))
  7689. {
  7690. RTBGroup.add(RTBCC_RoomOptionsManager);
  7691. return RTBCC_RoomOptionsManager;
  7692. }
  7693.  
  7694. %manager = new ScriptGroup(RTBCC_RoomOptionsManager)
  7695. {
  7696. new ScriptObject()
  7697. {
  7698. room = "General Discussion";
  7699. autojoin = 1;
  7700. };
  7701. };
  7702. RTBGroup.add(%manager);
  7703.  
  7704. return %manager;
  7705. }
  7706.  
  7707. //- RTBCC_RoomOptionsManager::store (saves settings to file)
  7708. function RTBCC_RoomOptionsManager::store(%this)
  7709. {
  7710. %this.save("config/client/rtb/rooms.cs");
  7711. }
  7712.  
  7713. //- RTBCC_RoomOptionsManager::storeRoomSettings (stores settings for a specific room)
  7714. function RTBCC_RoomOptionsManager::storeRoomSettings(%this,%session)
  7715. {
  7716. %roomStore = %this.getRoomStore(%session.room.name);
  7717.  
  7718. %swatch = %session.window.optsSwatch;
  7719. for(%i=0;%i<%swatch.getCount();%i++)
  7720. {
  7721. %ctrl = %swatch.getObject(%i);
  7722. if(%ctrl.getClassName() $= "GuiCheckboxCtrl" && %ctrl.var !$= "")
  7723. eval(%roomStore@"."@%ctrl.var@" = "@%ctrl.getValue()@";");
  7724. }
  7725. %this.store();
  7726. }
  7727.  
  7728. //- RTBCC_RoomOptionsManager::loadRoomSettings (loads settings for a specific room)
  7729. function RTBCC_RoomOptionsManager::loadRoomSettings(%this,%session)
  7730. {
  7731. %roomStore = %this.getRoomStore(%session.room.name);
  7732.  
  7733. %swatch = %session.window.optsSwatch;
  7734. for(%i=0;%i<%swatch.getCount();%i++)
  7735. {
  7736. %ctrl = %swatch.getObject(%i);
  7737. if(%ctrl.getClassName() $= "GuiCheckboxCtrl" && %ctrl.var !$= "")
  7738. {
  7739. eval("%value = "@%roomStore@"."@%ctrl.var@";");
  7740. if(%value !$= "")
  7741. %ctrl.setValue(%value);
  7742. else
  7743. %ctrl.setValue(%ctrl.def);
  7744. }
  7745. }
  7746. %this.store();
  7747. }
  7748.  
  7749. //- RTBCC_RoomOptionsManager::hasRoomStore (checks to see if store for room exists)
  7750. function RTBCC_RoomOptionsManager::hasRoomStore(%this,%name)
  7751. {
  7752. for(%i=0;%i<%this.getCount();%i++)
  7753. {
  7754. if(%this.getObject(%i).room $= %name)
  7755. return true;
  7756. }
  7757. return false;
  7758. }
  7759.  
  7760. //- RTBCC_RoomOptionsManager::getRoomStore (gets an object to store settings for a room)
  7761. function RTBCC_RoomOptionsManager::getRoomStore(%this,%name)
  7762. {
  7763. for(%i=0;%i<%this.getCount();%i++)
  7764. {
  7765. if(%this.getObject(%i).room $= %name)
  7766. return %this.getObject(%i);
  7767. }
  7768.  
  7769. %store = new ScriptObject()
  7770. {
  7771. room = %name;
  7772. };
  7773. %this.add(%store);
  7774.  
  7775. return %store;
  7776. }
  7777.  
  7778. //*********************************************************
  7779. //* GuiInputCtrl Recycling
  7780. //* ----------------------
  7781. //* There's a torque memory corruption bug relating to the
  7782. //* dynamic creation and destruction of GuiInputCtrl
  7783. //* objects which causes crashes when they're used so we're
  7784. //* going to create a bunch and recycle them.
  7785. //*********************************************************
  7786. //- RTBCC_createInputRecycler (creates an input recycler)
  7787. function RTBCC_createInputRecycler()
  7788. {
  7789. if(isObject(RTBCC_InputRecycler))
  7790. {
  7791. echo("\c2ERROR: Cannot destroy input recycler!");
  7792. return RTBCC_InputRecycler;
  7793. }
  7794.  
  7795. %recycler = new GuiSwatchCtrl(RTBCC_InputRecycler)
  7796. {
  7797. visible = false;
  7798. };
  7799. RTB_ConnectClient.add(%recycler);
  7800.  
  7801. %recycler.populate(50);
  7802.  
  7803. return %recycler;
  7804. }
  7805.  
  7806. //- RTBCC_InputRecycler::get (returns a free input object)
  7807. function RTBCC_InputRecycler::get(%this)
  7808. {
  7809. if(%this.getCount() >= 1)
  7810. {
  7811. %input = %this.getObject(0);
  7812. %input.setValue("");
  7813. return %input;
  7814. }
  7815. else
  7816. {
  7817. echo("\c2ERROR: Unable to allocate free input object!");
  7818. return false;
  7819. }
  7820. }
  7821.  
  7822. //- RTBCC_InputRecycler::reclaim (reclaims an input object)
  7823. function RTBCC_InputRecycler::reclaim(%this,%input)
  7824. {
  7825. if(!isObject(%input))
  7826. return false;
  7827.  
  7828. %input.setValue("");
  7829. %input.command = "";
  7830. %input.altCommand = "";
  7831.  
  7832. %this.add(%input);
  7833.  
  7834. return true;
  7835. }
  7836.  
  7837. //- RTBCC_InputRecycler::populate (populates recycler)
  7838. function RTBCC_InputRecycler::populate(%this,%amount)
  7839. {
  7840. if(%this.getCount() > 0)
  7841. {
  7842. echo("\c2ERROR: Cannot re-populate input recycler!");
  7843. return false;
  7844. }
  7845.  
  7846. for(%i=0;%i<%amount;%i++)
  7847. {
  7848. %input = new GuiTextEditCtrl()
  7849. {
  7850. profile = RTB_TextEditProfile;
  7851. horizSizing = "right";
  7852. vertSizing = "bottom";
  7853. position = "0 0";
  7854. extent = "64 16";
  7855. maxLength = "255";
  7856. command = "";
  7857. altCommand = "";
  7858. accelerator = "return";
  7859. historySize = 32;
  7860. };
  7861. %this.add(%input);
  7862. }
  7863. return (%this.getCount() == %amount);
  7864. }
  7865.  
  7866. //*********************************************************
  7867. //* Notification Manager
  7868. //*********************************************************
  7869. //- RTBCC_createNotificationManager (creates a notification manager)
  7870. function RTBCC_createNotificationManager()
  7871. {
  7872. if(isObject(RTBCC_NotificationManager))
  7873. {
  7874. RTBCC_NotificationManager.destroy();
  7875. RTBCC_NotificationManager.delete();
  7876. }
  7877.  
  7878. %manager = new ScriptGroup(RTBCC_NotificationManager);
  7879. RTBGroup.add(%manager);
  7880.  
  7881. return %manager;
  7882. }
  7883.  
  7884. //- RTBCC_NotificationManager::push (pushes a notification)
  7885. function RTBCC_NotificationManager::push(%this,%title,%message,%icon,%key,%holdTime)
  7886. {
  7887. if(RTB_Overlay.isAwake())
  7888. return;
  7889.  
  7890. if(%key !$= "")
  7891. {
  7892. for(%i=0;%i<%this.getCount();%i++)
  7893. {
  7894. %notification = %this.getObject(%i);
  7895. if(%notification.key $= %key)
  7896. {
  7897. %notification.icon = %icon;
  7898. %notification.title = %title;
  7899. %notification.message = %message;
  7900. %notification.render();
  7901. return;
  7902. }
  7903. }
  7904. }
  7905.  
  7906. if(%icon $= "")
  7907. %icon = "information";
  7908.  
  7909. if(%holdTime $= "")
  7910. %holdTime = 3000;
  7911.  
  7912. if(%holdTime < 0 && !RTBCO_getPref("CC::StickyNotifications"))
  7913. %holdTime = 5000;
  7914.  
  7915. %notification = new ScriptObject()
  7916. {
  7917. class = "RTBCC_Notification";
  7918.  
  7919. key = %key;
  7920. icon = %icon;
  7921. title = %title;
  7922. message = %message;
  7923.  
  7924. holdTime = %holdTime;
  7925.  
  7926. state = "left";
  7927. };
  7928. %this.add(%notification);
  7929.  
  7930. %notification.render();
  7931. }
  7932.  
  7933. //- RTBCC_NotificationManager::pop (removes a notification by key)
  7934. function RTBCC_NotificationManager::pop(%this,%key)
  7935. {
  7936. for(%i=0;%i<%this.getCount();%i++)
  7937. {
  7938. %notification = %this.getObject(%i);
  7939. if(%notification.key $= %key)
  7940. {
  7941. %notification.state = "right";
  7942. %notification.step();
  7943. break;
  7944. }
  7945. }
  7946. }
  7947.  
  7948. //- RTBCC_NotificationManager::refocus (moves all notifications to current window)
  7949. function RTBCC_NotificationManager::refocus(%this)
  7950. {
  7951. for(%i=0;%i<%this.getCount();%i++)
  7952. {
  7953. %notification = %this.getObject(%i);
  7954. if(isObject(%notification.canvas) && %notification.canvas.script $= %notification)
  7955. Canvas.getObject(Canvas.getCount()-1).add(%notification.canvas);
  7956. }
  7957. }
  7958.  
  7959. //- RTBCC_NotificationManager::destroy (destroys all traces of the object)
  7960. function RTBCC_NotificationManager::destroy(%this)
  7961. {
  7962. for(%i=0;%i<%this.getCount();%i++)
  7963. {
  7964. %notification = %this.getObject(%i);
  7965. if(isObject(%notification.canvas) && %notification.canvas.script $= %notification)
  7966. {
  7967. cancel(%notification.moveAnim);
  7968. %notification.canvas.delete();
  7969. }
  7970. }
  7971. %this.clear();
  7972. }
  7973.  
  7974. //- RTBCC_Notification::render (handles the rendering/drawing of a notification)
  7975. function RTBCC_Notification::render(%this)
  7976. {
  7977. %width = 209;
  7978. %height = 50;
  7979.  
  7980. if(isObject(%this.canvas) && %this.canvas.script $= %this)
  7981. {
  7982. %this.setIcon(%this.icon);
  7983. %this.setTitle(%this.title);
  7984. %this.setMessage(%this.message);
  7985.  
  7986. cancel(%this.moveAnim);
  7987. %this.state = "left";
  7988.  
  7989. %this.step();
  7990. }
  7991. else
  7992. {
  7993. %xPosition = getWord(getRes(),0) - %width;
  7994. %yPosition = getWord(getRes(),1) - %height;
  7995.  
  7996. %manager = %this.getGroup();
  7997. for(%i=0;%i<%manager.getCount();%i++)
  7998. {
  7999. %notification = %manager.getObject(%i);
  8000. if(isObject(%notification.canvas) && %notification.canvas.script $= %notification)
  8001. {
  8002. if(getWord(%notification.canvas.position,1) <= %yPosition)
  8003. %yPosition = getWord(%notification.canvas.position,1)-%height;
  8004. }
  8005. }
  8006.  
  8007. if(%yPosition < 0)
  8008. return;
  8009.  
  8010. %canvas = new GuiSwatchCtrl()
  8011. {
  8012. position = %xPosition SPC %yPosition;
  8013. extent = %width SPC %height;
  8014. color = "0 0 0 0";
  8015.  
  8016. script = %this;
  8017. };
  8018. Canvas.getObject(canvas.getCount()-1).add(%canvas);
  8019.  
  8020. %this.canvas = %canvas;
  8021.  
  8022. if(canvas.getContent().getName() $= "PlayGui")
  8023. %this.drawPlay();
  8024. else
  8025. %this.drawMenu();
  8026.  
  8027. %this.step();
  8028. }
  8029. }
  8030.  
  8031. //- RTBCC_Notification::step (plays a step through the animation)
  8032. function RTBCC_Notification::step(%this)
  8033. {
  8034. if(%this.state $= "left")
  8035. {
  8036. if(getWord(%this.window.position,0) <= 0)
  8037. {
  8038. if(%this.holdTime < 0)
  8039. {
  8040. %this.window.position = "0 0";
  8041. %this.state = "done";
  8042. return;
  8043. }
  8044. %this.window.position = "0 0";
  8045. %this.state = "wait";
  8046. %this.moveAnim = %this.schedule(%this.holdTime,"step");
  8047. return;
  8048. }
  8049. %this.window.position = vectorSub(%this.window.position,"10 0");
  8050. %this.moveAnim = %this.schedule(10,"step");
  8051. }
  8052. else if(%this.state $= "wait")
  8053. {
  8054. %this.state = "right";
  8055. %this.step();
  8056. }
  8057. else if(%this.state $= "right")
  8058. {
  8059. if(getWord(%this.window.position,0) >= getWord(%this.canvas.extent,0))
  8060. {
  8061. %this.window.position = getWord(%this.canvas.extent,0) SPC "0";
  8062. %this.state = "done";
  8063. %this.step();
  8064. return;
  8065. }
  8066. %this.window.position = vectorAdd(%this.window.position,"10 0");
  8067. %this.moveAnim = %this.schedule(10,"step");
  8068. }
  8069. else if(%this.state $= "done")
  8070. {
  8071. %y = getWord(%this.canvas.position,1);
  8072. %this.canvas.delete();
  8073.  
  8074. for(%i=0;%i<RTBCC_NotificationManager.getCount();%i++)
  8075. {
  8076. %notification = RTBCC_NotificationManager.getObject(%i);
  8077. if(!isObject(%notification.canvas))
  8078. continue;
  8079. if(getWord(%notification.canvas.position,1) < %y)
  8080. %notification.canvas.shift(0,50);
  8081. }
  8082. %this.delete();
  8083. }
  8084. }
  8085.  
  8086. //- RTBCC_Notification::drawPlay (draws the PlayGui version of the notification)
  8087. function RTBCC_Notification::drawPlay(%this)
  8088. {
  8089. %draw = new GuiBitmapCtrl() {
  8090. position = getWord(%this.canvas.extent,0) SPC "0";
  8091. extent = "204 44";
  8092. bitmap = $RTB::Path@"images/ui/notificationPlay";
  8093.  
  8094. new GuiBitmapCtrl() {
  8095. position = "13 12";
  8096. extent = "16 16";
  8097. bitmap = $RTB::Path@"images/icons/"@%this.icon;
  8098. };
  8099. new GuiMLTextCtrl() {
  8100. position = "41 5";
  8101. extent = "154 14";
  8102. text = "<shadow:2:2><shadowcolor:00000066><color:EEEEEE><font:Verdana Bold:15>"@%this.title;
  8103. selectable = false;
  8104. };
  8105. new GuiMLTextCtrl() {
  8106. position = "41 21";
  8107. extent = "165 12";
  8108. text = "<shadow:2:2><shadowcolor:00000066><color:DDDDDD><font:Verdana:12>"@%this.message;
  8109. selectable = false;
  8110. };
  8111. new GuiBitmapButtonCtrl() {
  8112. position = "0 0";
  8113. extent = "204 44";
  8114. text = " ";
  8115. command = "RTB_Overlay.fadeIn();";
  8116. };
  8117. };
  8118. %this.canvas.add(%draw);
  8119.  
  8120. %this.window = %draw;
  8121. }
  8122.  
  8123. //- RTBCC_Notification::drawMenu (draws the menu version of the notification)
  8124. function RTBCC_Notification::drawMenu(%this)
  8125. {
  8126. %draw = new GuiBitmapCtrl() {
  8127. position = getWord(%this.canvas.extent,0) SPC "0";
  8128. extent = "204 44";
  8129. bitmap = $RTB::Path@"images/ui/notificationMenu";
  8130.  
  8131. new GuiBitmapCtrl() {
  8132. position = "13 12";
  8133. extent = "16 16";
  8134. bitmap = $RTB::Path@"images/icons/"@%this.icon;
  8135. };
  8136. new GuiMLTextCtrl() {
  8137. position = "41 5";
  8138. extent = "154 14";
  8139. text = "<shadow:2:2><shadowcolor:00000066><color:EEEEEE><font:Verdana Bold:15>"@%this.title;
  8140. selectable = false;
  8141. };
  8142. new GuiMLTextCtrl() {
  8143. position = "41 21";
  8144. extent = "165 12";
  8145. text = "<shadow:2:2><shadowcolor:00000066><color:DDDDDD><font:Verdana:12>"@%this.message;
  8146. selectable = false;
  8147. };
  8148. new GuiBitmapButtonCtrl() {
  8149. position = "0 0";
  8150. extent = "204 44";
  8151. text = " ";
  8152. command = "RTB_Overlay.fadeIn();";
  8153. };
  8154. };
  8155. %this.canvas.add(%draw);
  8156.  
  8157. %this.window = %draw;
  8158. }
  8159.  
  8160. //- RTBCC_Notification::setIcon (sets the notification icon)
  8161. function RTBCC_Notification::setIcon(%this,%icon)
  8162. {
  8163. %this.window.getObject(0).setBitmap($RTB::Path@"images/icons/"@%icon);
  8164. }
  8165.  
  8166. //- RTBCC_Notification::setTitle (sets the notification title)
  8167. function RTBCC_Notification::setTitle(%this,%title)
  8168. {
  8169. %this.window.getObject(1).setText("<shadow:2:2><shadowcolor:00000066><color:EEEEEE><font:Verdana Bold:15>"@%title);
  8170. }
  8171.  
  8172. //- RTBCC_Notification::setMessage (sets the notification message)
  8173. function RTBCC_Notification::setMessage(%this,%message)
  8174. {
  8175. %this.window.getObject(2).setText("<shadow:2:2><shadowcolor:00000066><color:DDDDDD><font:Verdana:12>"@%message);
  8176. }
  8177.  
  8178. //*********************************************************
  8179. //* Connect Packaging
  8180. //*********************************************************
  8181. package RTB_Modules_Client_ConnectClient
  8182. {
  8183. function GameConnection::onConnectionAccepted(%this,%a,%b,%c,%d,%e,%f,%g,%h,%i,%j,%k)
  8184. {
  8185. Parent::onConnectionAccepted(%this,%a,%b,%c,%d,%e,%f,%g,%h,%i,%j,%k);
  8186.  
  8187. if(RTBCC_Socket.authenticated)
  8188. RTBCC_Socket.sendPresence();
  8189. }
  8190.  
  8191. function connectingGui::cancel(%this)
  8192. {
  8193. Parent::cancel(%this);
  8194.  
  8195. if(RTBCC_Socket.authenticated)
  8196. RTBCC_Socket.sendPresence();
  8197. }
  8198.  
  8199. function disconnectedCleanup()
  8200. {
  8201. Parent::disconnectedCleanup();
  8202.  
  8203. if(RTBCC_Socket.authenticated)
  8204. RTBCC_Socket.sendPresence(0,1);
  8205. }
  8206.  
  8207. function Canvas::setContent(%this,%content)
  8208. {
  8209. if(Canvas.getContent() $= LoadingGui.getId() && %content.getId() $= PlayGui.getId() && RTB_Overlay.isAwake())
  8210. %reopenOverlay = true;
  8211.  
  8212. Parent::setContent(%this,%content);
  8213.  
  8214. if(isObject(RTBCC_NotificationManager) && %content !$= "noHudGui")
  8215. RTBCC_NotificationManager.refocus();
  8216.  
  8217. if(%reopenOverlay)
  8218. Canvas.pushDialog(RTB_Overlay);
  8219. }
  8220.  
  8221. function Canvas::pushDialog(%this,%dialog)
  8222. {
  8223. Parent::pushDialog(%this,%dialog);
  8224.  
  8225. if(isObject(RTBCC_NotificationManager))
  8226. if(%dialog $= RTB_Overlay)
  8227. RTBCC_NotificationManager.destroy();
  8228. else
  8229. RTBCC_NotificationManager.refocus();
  8230. }
  8231.  
  8232. function Canvas::popDialog(%this,%dialog)
  8233. {
  8234. Parent::popDialog(%this,%dialog);
  8235.  
  8236. if(isObject(RTBCC_NotificationManager))
  8237. RTBCC_NotificationManager.refocus();
  8238. }
  8239.  
  8240. function Avatar_Done()
  8241. {
  8242. Parent::Avatar_Done();
  8243.  
  8244. RTB_ConnectClient.setAvatar();
  8245. }
  8246.  
  8247. function MM_AuthBar::blinkSuccess(%this)
  8248. {
  8249. Parent::blinkSuccess(%this);
  8250.  
  8251. RTB_ConnectClient.setDetails();
  8252.  
  8253. if(RTBCO_getPref("CC::AutoSignIn") && !RTBCC_Socket.connected)
  8254. RTBCC_Socket.connect();
  8255. }
  8256.  
  8257. function regNameGui::register()
  8258. {
  8259. Parent::register();
  8260.  
  8261. if(RTBCC_Socket.connected)
  8262. RTBCC_Socket.softDisconnect();
  8263. }
  8264.  
  8265. function keyGui::done()
  8266. {
  8267. Parent::done();
  8268.  
  8269. if(RTBCC_Socket.connected)
  8270. RTBCC_Socket.softDisconnect();
  8271. }
  8272. };
  8273. RTB_ConnectClient.init();
  8274.  
  8275. RTBCC_NotificationManager.schedule(1000,"push","Press \""@ getField(RTBCO_getPref("OV::OverlayKeybind"),1) @"\"","to open the RTB Overlay.","","",5000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement