fn_loadoutInfo.sqf 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #include "macro.sqf"
  2. /*
  3. @version: 1.2
  4. @file_name: fn_loadoutInfo.sqf
  5. @file_author: TAW_Tonic
  6. @file_edit: 6/5/2013
  7. @file_description: Pulls up the selected saved slots loadout.
  8. */
  9. private["_control","_slot","_type","_loadout"];
  10. _type = _this select 0;
  11. disableSerialization;
  12. switch (_type) do
  13. {
  14. case 0: {_control = VAS_getControl(VAS_save_Display,VAS_save_fetch); _slot = lbCurSel VAS_save_list;};
  15. case 1: {_control = VAS_getControl(VAS_load_Display,VAS_load_fetch); _slot = lbCurSel VAS_load_list};
  16. };
  17. lbClear _control;
  18. if(_slot == -1) exitWith {hint "You didn't select a slot!";}; //No slot selected
  19. if(vas_disableLoadSave) then
  20. {
  21. _loadout = missionNamespace getVariable format["vas_gear_new_%1",_slot];
  22. }
  23. else
  24. {
  25. _loadout = profileNamespace getVariable format["vas_gear_new_%1",_slot];
  26. };
  27. if(isNil {_loadout}) exitWith {(VAS_getControl(VAS_save_Display,VAS_save_text)) ctrlSetText "Custom Loadout Name";}; //No information in this slot.
  28. if(_type == 0) then
  29. {
  30. (VAS_getControl(VAS_save_Display,VAS_save_text)) ctrlSetText (_loadout select 0);
  31. };
  32. // Original Code
  33. /*
  34. {
  35. switch(typeName _x) do
  36. {
  37. case "STRING":
  38. {
  39. _details = [_x] call VAS_fnc_fetchCfgDetails;
  40. if(count _details > 0) then
  41. {
  42. _control lbAdd format["%1", (_details select 1)];
  43. _control lbSetPicture [(lbSize _control)-1,(_details select 2)];
  44. };
  45. };
  46. case "ARRAY":
  47. {
  48. {
  49. _details = [_x] call VAS_fnc_fetchCfgDetails;
  50. if(count _details > 0) then
  51. {
  52. _control lbAdd format["%1", (_details select 1)];
  53. _control lbSetPicture [(lbSize _control)-1,(_details select 2)];
  54. };
  55. } foreach _x;
  56. };
  57. };
  58. } foreach _loadout;
  59. */
  60. // Modified Code by naong
  61. private ["_listItems","_loadout_array","_className","_name"];
  62. _loadout_array = [];
  63. {
  64. switch(typeName _x) do {
  65. case "STRING": {
  66. _loadout_array = _loadout_array + [_x];
  67. };
  68. case "ARRAY": {
  69. {
  70. _loadout_array = _loadout_array + [_x];
  71. } forEach _x;
  72. };
  73. };
  74. } forEach _loadout;
  75. _listItems = [];
  76. {
  77. _className = _x;
  78. _details = [_x] call VAS_fnc_fetchCfgDetails;
  79. if(count _details > 0) then {
  80. _name = (_details select 1);
  81. if (_listItems find _name < 1) then {
  82. _control lbAdd format["[%1] %2",({_x == _className} count _loadout_array),_name];
  83. _control lbSetPicture [(lbSize _control)-1,(_details select 2)];
  84. _listItems = _listItems + [_name];
  85. };
  86. };
  87. } forEach _loadout_array;