Advertisement
Guest User

Untitled

a guest
May 17th, 2016
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.11 KB | None | 0 0
  1. $Sel = 0;
  2. $InvHud::MaxLoadouts = 20;
  3. $InvHud::Lists = new SimGroup();
  4. if(isFile("legions/preferences/MyLoadouts.cs"))
  5. exec("legions/preferences/MyLoadouts.cs");
  6.  
  7.  
  8. addMessageCallback("InvHudListClear", handleInvHudListClear);
  9. function handleInvHudListClear()
  10. {
  11. $InvHud::Lists.delete();
  12. $InvHud::Lists = new SimGroup();
  13. }
  14.  
  15. addMessageCallback("InvHudListAdd", handleInvHudListAdd);
  16. function handleInvHudListAdd(%msgType, %listType, %dataBlock, %name, %maxInvCount,%description)
  17. {
  18. if(!isObject(%listType))
  19. {
  20. %newList = new SimSet(%listType);
  21. $InvHud::Lists.add(%newList);
  22. }
  23. %newItem = new ScriptObject()
  24. {
  25. name = %name;
  26. dataBlock = %dataBlock;
  27. maxInvCount = %maxInvCount;
  28. //description = %description;
  29. };
  30. $itemDescription[%name] = %description;
  31. $InvHud::ListNTID[%name] = %newItem;
  32. %listType.add(%newItem);
  33. }
  34.  
  35. addMessageCallback("InvHudListDone", updateInvHudLoadout);
  36.  
  37. addMessageCallback("InvHudListInvalid", handleInvHudListInvalid);
  38. function handleInvHudListInvalid(%msgType, %listType, %dataBlock)
  39. {
  40. switch$ (%listType)
  41. {
  42. case "InvHudListWeapon":
  43. %dataBlock++;
  44. $Pref::InvHud::CurWep[%dataBlock] = "";
  45. %obj = "InvHudWeapon" @ %dataBlock;
  46. %obj.setText("N/A");
  47.  
  48. case "InvHudListClass":
  49. $Pref::InvHud::CurClass = "";
  50. InvHudClass.setText("N/A");
  51.  
  52. case "InvHudListOffhand":
  53. $Pref::InvHud::CurOffhand = "";
  54. InvHudOffhand.setText("N/A");
  55.  
  56. case "InvHudListCore":
  57. $Pref::InvHud::CurCore = "";
  58. InvHudCore.setText("N/A");
  59. }
  60. }
  61.  
  62. function toggleInvHud(%val)
  63. {
  64. if(%val)
  65. {
  66. if(InvHud.isAwake())
  67. {
  68. InvHud.close();
  69. }
  70. else
  71. {
  72. if(GamePanel.isAwake()) GamePanel.close();
  73. if(SpawnSelect.isAwake()) SpawnSelect.close();
  74. InvHud.open();
  75. }
  76. }
  77. }
  78.  
  79. function InvHud::open(%this)
  80. {
  81. Canvas.pushDialog(InvHud);
  82. slideElement(LoadoutBG, -603, 0, 0, 0, 250);
  83. }
  84.  
  85. function InvHud::close(%this)
  86. {
  87. if(InvHudLargeModelPreview.isVisible())
  88. InvHudLargeModelPreview.setVisible(false);
  89.  
  90. slideElement(LoadoutBG, 0, 0, -603, 0, 250);
  91. schedule(250, 0, DelayInvHudClose);
  92. }
  93.  
  94. function DelayInvHudClose(%this)
  95. {
  96. Canvas.popDialog(InvHud);
  97.  
  98. if(Switch2.isVisible())
  99. Switch2.onClick();
  100. }
  101.  
  102. function Switch1::onClick(%this)
  103. {
  104. slideElement(InvHudInnerContainer1, 22, 50, -556, 50, 250);
  105. slideElement(InvHudInnerContainer2, 603, 50, 22, 50, 250);
  106. Switch1.setVisible("0");
  107. Switch2.setVisible("1");
  108. wipeSkinHud();
  109. InvHudTitleText.setText("Change Your Skin");
  110. }
  111.  
  112. function InvHudRespawn::onClick(%this)
  113. {
  114. commandToServer('RespawnPlayer');
  115. InvHud.close();
  116. }
  117.  
  118. function Switch2::onClick(%this)
  119. {
  120. slideElement(InvHudInnerContainer2, 22, 50, 603, 50, 250);
  121. slideElement(InvHudInnerContainer1, -556, 50, 22, 50, 250);
  122. Switch1.setVisible("1");
  123. Switch2.setVisible("0");
  124. InvHudTitleText.setText("Create A Custom Class");
  125. }
  126.  
  127. function InvHudLargeModelViewButton::onClick(%this)
  128. {
  129. InvHudLargeModelPreview.setVisible(true);
  130. slideElement(LoadoutBG, 0, 0, -603, 0, 250);
  131. }
  132.  
  133. function InvHudLargeModelViewCloseButton::onClick(%this)
  134. {
  135. InvHudLargeModelPreview.setVisible(false);
  136. slideElement(LoadoutBG, -603, 0, 0, 0, 250);
  137. }
  138.  
  139. function InvHud::OnWake(%this)
  140. {
  141. InvHudLoadoutList.clear();
  142. for(%i=0;%i < $InvHud::MaxLoadouts;%i++)
  143. {
  144. if($InvHud::MyLoadouts::Name[%i] !$= "")
  145. InvHudLoadoutList.addRow(%i, $InvHud::MyLoadouts::Name[%i]);
  146. }
  147. updateInvHudLoadout();
  148. }
  149.  
  150. function InvHudClass::onSelect(%this)
  151. {
  152. if(!$InvHud::Init)
  153. {
  154. $Pref::InvHud::CurClass = %this.getText();
  155. commandToServer('RespawnPlayer');
  156. updateInvHudLoadout();
  157.  
  158. }
  159. }
  160. function InvHudWeapon1::onSelect(%this)
  161. {
  162. if(!$InvHud::Init)
  163. {
  164. $Pref::InvHud::CurWep1 = %this.getText();
  165. updateInvHudLoadout();
  166. }
  167. }
  168. function InvHudWeapon2::onSelect(%this)
  169. {
  170. if(!$InvHud::Init)
  171. {
  172. $Pref::InvHud::CurWep2 = %this.getText();
  173. updateInvHudLoadout();
  174. }
  175. }
  176. function InvHudWeapon3::onSelect(%this)
  177. {
  178. if(!$InvHud::Init)
  179. {
  180. $Pref::InvHud::CurWep3 = %this.getText();
  181. updateInvHudLoadout();
  182. }
  183. }
  184. function InvHudOffhand::onSelect(%this)
  185. {
  186. if(!$InvHud::Init)
  187. {
  188. $Pref::InvHud::CurOH = %this.getText();
  189. updateInvHudLoadout();
  190. }
  191. }
  192. function InvHudCore::onSelect(%this)
  193. {
  194. if(!$InvHud::Init)
  195. {
  196. $Pref::InvHud::CurCore = %this.getText();
  197. updateInvHudLoadout();
  198. }
  199. }
  200.  
  201. function InvHudSaveButton::onClick(%this)
  202. {
  203. if(InvHudLoadoutName.getValue() !$= "")
  204. {
  205. for(%i=0;%i < $InvHud::MaxLoadouts;%i++)
  206. {
  207. if($InvHud::MyLoadouts::Name[%i] $= "")
  208. {
  209. $InvHud::MyLoadouts::Name[%i] = InvHudLoadoutName.getValue();
  210. $InvHud::MyLoadouts::Class[%i] = $Pref::InvHud::CurClass;
  211. $InvHud::MyLoadouts::Wep1[%i] = $Pref::InvHud::CurWep1;
  212. $InvHud::MyLoadouts::Wep2[%i] = $Pref::InvHud::CurWep2;
  213. $InvHud::MyLoadouts::Wep3[%i] = $Pref::InvHud::CurWep3;
  214. $InvHud::MyLoadouts::OH[%i] = $Pref::InvHud::CurOH;
  215. $InvHud::MyLoadouts::Core[%i] = $Pref::InvHud::CurCore;
  216. $InvHud::MyLoadouts::Head[%i] = 0;
  217. $InvHud::MyLoadouts::Body[%i] = 0;
  218. export("$InvHud::MyLoadouts::*", "legions/preferences/MyLoadouts.cs", false);
  219. InvHudLoadoutList.addRow(%i, InvHudLoadoutName.getValue());
  220. %i = $InvHud::MaxLoadouts;
  221. InvHudLoadoutName.setValue("");
  222. }
  223. }
  224. }
  225. }
  226.  
  227. function InvHudDelete::OnClick(%this)
  228. {
  229. %sel = InvHudLoadoutList.getSelectedId();
  230. if(%sel >= 0)
  231. {
  232. $InvHud::MyLoadouts::Name[%sel] = "";
  233. $InvHud::MyLoadouts::Class[%sel] = "";
  234. $InvHud::MyLoadouts::Wep1[%sel] = "";
  235. $InvHud::MyLoadouts::Wep2[%sel] = "";
  236. $InvHud::MyLoadouts::Wep3[%sel] = "";
  237. $InvHud::MyLoadouts::OH[%sel] = "";
  238. $InvHud::MyLoadouts::Core[%sel] = "";
  239. InvHudLoadoutList.removeRowById(%sel);
  240. export("$InvHud::MyLoadouts::*", "legions/preferences/MyLoadouts.cs", false);
  241. }
  242. }
  243.  
  244. // Give them a default loadout the first time they start the game
  245. function InvHudLoadoutList::onAdd(%this)
  246. {
  247. if($Pref::Game::FirstStart != false || $Pref::Game::FirstStart $= "")
  248. {
  249. %hasLoadouts = false;
  250.  
  251. for(%i = 0; %i < $InvHud::MaxLoadouts; %i++)
  252. {
  253. if($InvHud::MyLoadouts::Name[%i] !$= "")
  254. {
  255. %hasLoadouts = true;
  256. break;
  257. }
  258. }
  259.  
  260. if(%hasLoadouts == false)
  261. {
  262. $InvHud::MyLoadouts::Name[0] = "Default";
  263. $InvHud::MyLoadouts::Class[0] = "Raider";
  264. $InvHud::MyLoadouts::Wep1[0] = "Chaingun";
  265. $InvHud::MyLoadouts::Wep2[0] = "Rocket Launcher";
  266. $InvHud::MyLoadouts::Wep3[0] = "Grenade Launcher";
  267. $InvHud::MyLoadouts::OH[0] = "Boost Grenade";
  268. $InvHud::MyLoadouts::Core[0] = "Overdrive";
  269. export("$InvHud::MyLoadouts::*", "legions/preferences/MyLoadouts.cs", false);
  270. InvHudLoadoutList.addRow(%i, InvHudLoadoutName.getValue());
  271. InvHudLoadoutName.setValue("");
  272. }
  273.  
  274. $Pref::Game::FirstStart = false;
  275. }
  276. }
  277.  
  278. function InvHudSelect::OnClick(%this)
  279. {
  280. %sel = InvHudLoadoutList.getSelectedId();
  281. if(%sel != -1)
  282. {
  283. $Sel = %sel;
  284. $Pref::InvHud::CurClass = $InvHud::MyLoadouts::Class[%sel];
  285. $Pref::InvHud::CurWep1 = $InvHud::MyLoadouts::Wep1[%sel];
  286. $Pref::InvHud::CurWep2 = $InvHud::MyLoadouts::Wep2[%sel];
  287. $Pref::InvHud::CurWep3 = $InvHud::MyLoadouts::Wep3[%sel];
  288. $Pref::InvHud::CurOH = $InvHud::MyLoadouts::OH[%sel];
  289. $Pref::InvHud::CurCore = $InvHud::MyLoadouts::Core[%sel];
  290. $Pref::SSel::Head = $InvHud::MyLoadouts::Head[%sel];
  291. $Pref::SSel::Body = $InvHud::MyLoadouts::Body[%sel];
  292. UploadSkinsRuntime();
  293. updateInvHudLoadout();
  294. commandToServer('RespawnPlayer');
  295. }
  296.  
  297. // If the user clicked on the select command without
  298. // a selected loadout, give them defaults.
  299.  
  300. // RR: Why? This fucks up the currently selected list...
  301. // So if you misclicked select instead of save button
  302. // you now have to select the loadout all over again...
  303. // Commenting it out.
  304.  
  305. /*
  306. else
  307. {
  308. if($Pref::InvHud::CurClass $= "")
  309. $Pref::InvHud::CurClass = "Raider";
  310.  
  311. if($Pref::InvHud::CurWep1 $= "")
  312. $Pref::InvHud::CurWep1 = "Chaingun";
  313.  
  314. if($Pref::InvHud::CurWep2 $= "")
  315. $Pref::InvHud::CurWep2 = "Rocket Launcher";
  316.  
  317. if($Pref::InvHud::CurWep3 $= "" && $Pref::InvHud::CurClass !$= "Outrider")
  318. $Pref::InvHud::CurWep3 = "Grenade Launcher";
  319.  
  320. if($Pref::InvHud::CurOH $= "")
  321. $Pref::InvHud::CurOH = "Boost Grenade";
  322.  
  323. if($Pref::InvHud::CurCore $= "")
  324. $Pref::InvHud::CurCore = "Overdrive";
  325. updateInvHudLoadout();
  326. }
  327. */
  328. }
  329.  
  330. function KeyPadSelection(%sel)
  331. {
  332. if(%sel > -1 && %sel < 10)
  333. {
  334. $Pref::InvHud::CurClass = $InvHud::MyLoadouts::Class[%sel];
  335. $Pref::InvHud::CurWep1 = $InvHud::MyLoadouts::Wep1[%sel];
  336. $Pref::InvHud::CurWep2 = $InvHud::MyLoadouts::Wep2[%sel];
  337. $Pref::InvHud::CurWep3 = $InvHud::MyLoadouts::Wep3[%sel];
  338. $Pref::InvHud::CurOH = $InvHud::MyLoadouts::OH[%sel];
  339. $Pref::InvHud::CurCore = $InvHud::MyLoadouts::Core[%sel];
  340. $Pref::SSel::Head = $InvHud::MyLoadouts::Head[%sel];
  341. $Pref::SSel::Body = $InvHud::MyLoadouts::Body[%sel];
  342. $Sel = %sel;
  343. UploadSkinsRuntime();
  344. updateInvHudLoadout();
  345. commandToServer('RespawnPlayer');
  346. }
  347.  
  348. // If the user clicked on the select command without
  349. // a selected loadout, give them defaults.
  350.  
  351. // RR: Again... Why?
  352.  
  353. /*
  354. else
  355. {
  356. if($Pref::InvHud::CurClass $= "")
  357. $Pref::InvHud::CurClass = "Raider";
  358.  
  359. if($Pref::InvHud::CurWep1 $= "")
  360. $Pref::InvHud::CurWep1 = "Chaingun";
  361.  
  362. if($Pref::InvHud::CurWep2 $= "")
  363. $Pref::InvHud::CurWep2 = "Rocket Launcher";
  364.  
  365. if($Pref::InvHud::CurWep3 $= "" && $Pref::InvHud::CurClass !$= "Outrider")
  366. $Pref::InvHud::CurWep3 = "Grenade Launcher";
  367.  
  368. if($Pref::InvHud::CurOH $= "")
  369. $Pref::InvHud::CurOH = "Boost Grenade";
  370.  
  371. if($Pref::InvHud::CurCore $= "")
  372. $Pref::InvHud::CurCore = "Overdrive";
  373. updateInvHudLoadout();
  374. }
  375. */
  376. }
  377.  
  378. function updateInvHudLoadout()
  379. {
  380. $InvHud::Init = true;
  381.  
  382. InvHudClass.clear();
  383. %count = InvHudListClass.getCount();
  384. for(%i=0;%i<%count;%i++)
  385. {
  386. InvHudClass.add(InvHudListClass.getObject(%i).name, %i);
  387. }
  388. InvHudClass.setSelected(InvHudClass.findText($Pref::InvHud::CurClass));
  389. InvHudClass.toolTip = $itemDescription[$Pref::InvHud::CurClass];
  390. if($InvHud::ListNTID[InvHudClass.getText()].maxInvCount < 3)
  391. {
  392. InvHudWeapon3.visible = false;
  393. if($InvHud::ListNTID[InvHudClass.getText()].maxInvCount < 2)
  394. {
  395. InvHudWeapon2.visible = false;
  396. $Pref::InvHud::CurWep2 = "";
  397. $Pref::InvHud::CurWep3 = "";
  398. }
  399. else
  400. {
  401. InvHudWeapon2.visible = true;
  402. $Pref::InvHud::CurWep3 = "";
  403. }
  404. }
  405. else
  406. {
  407. InvHudWeapon2.visible = true;
  408. InvHudWeapon3.visible = true;
  409. }
  410.  
  411. InvHudWeapon1.clear();
  412. %count = InvHudListWeapon.getCount();
  413. for(%i=0;%i<%count;%i++)
  414. {
  415. %obj = InvHudListWeapon.getObject(%i).name;
  416. if ((%obj !$= $Pref::InvHud::CurWep2) && (%obj !$= $Pref::InvHud::CurWep3))
  417. InvHudWeapon1.add(InvHudListWeapon.getObject(%i).name, %i);
  418. }
  419. InvHudWeapon1.setSelected(InvHudWeapon1.findText($Pref::InvHud::CurWep1));
  420. InvHudWeapon1.toolTip = $itemDescription[$Pref::InvHud::CurWep1];
  421.  
  422. InvHudWeapon2.clear();
  423. for(%i=0;%i<%count;%i++)
  424. {
  425. %obj = InvHudListWeapon.getObject(%i).name;
  426. if ((%obj !$= $Pref::InvHud::CurWep1) && (%obj !$= $Pref::InvHud::CurWep3))
  427. InvHudWeapon2.add(%obj, %i);
  428. }
  429. InvHudWeapon2.setSelected(InvHudWeapon2.findText($Pref::InvHud::CurWep2));
  430. InvHudWeapon2.toolTip = $itemDescription[$Pref::InvHud::CurWep2];
  431.  
  432. InvHudWeapon3.clear();
  433. for(%i=0;%i<%count;%i++)
  434. {
  435. %obj = InvHudListWeapon.getObject(%i).name;
  436. if ((%obj !$= $Pref::InvHud::CurWep1) && (%obj !$= $Pref::InvHud::CurWep2))
  437. InvHudWeapon3.add(InvHudListWeapon.getObject(%i).name, %i);
  438. }
  439. InvHudWeapon3.setSelected(InvHudWeapon3.findText($Pref::InvHud::CurWep3));
  440. InvHudWeapon3.toolTip = $itemDescription[$Pref::InvHud::CurWep3];
  441.  
  442. InvHudOffhand.clear();
  443. %count = InvHudListOffhand.getCount();
  444. for(%i=0;%i<%count;%i++)
  445. {
  446. InvHudOffhand.add(InvHudListOffhand.getObject(%i).name, %i);
  447. }
  448. InvHudOffhand.setSelected(InvHudOffhand.findText($Pref::InvHud::CurOH));
  449. InvHudOffhand.toolTip = $itemDescription[$Pref::InvHud::CurOH];
  450.  
  451. InvHudCore.clear();
  452. %count = InvHudListCore.getCount();
  453. for(%i=0;%i<%count;%i++)
  454. {
  455. InvHudCore.add(InvHudListCore.getObject(%i).name, %i);
  456. }
  457. InvHudCore.setSelected(InvHudCore.findText($Pref::InvHud::CurCore));
  458. InvHudCore.toolTip = $itemDescription[$Pref::InvHud::CurCore];
  459.  
  460. $InvHud::Init = false;
  461.  
  462. commandToServer('SetupLoadout',
  463. $InvHud::ListNTID[$Pref::InvHud::CurClass].dataBlock,
  464. $InvHud::ListNTID[$Pref::InvHud::CurWep1].dataBlock TAB
  465. $InvHud::ListNTID[$Pref::InvHud::CurWep2].dataBlock TAB
  466. $InvHud::ListNTID[$Pref::InvHud::CurWep3].dataBlock,
  467. $InvHud::ListNTID[$Pref::InvHud::CurOH].dataBlock,
  468. $InvHud::ListNTID[$Pref::InvHud::CurCore].dataBlock );
  469. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement