dapperstache

BIS_fnc_garage

Nov 3rd, 2024
9
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 56.96 KB | None | 0 0
  1. if (is3DEN && {_fnc_scriptName == "bis_fnc_garage"}) exitwith {_this call bis_fnc_garage3DEN;};
  2.  
  3. #include "\A3\ui_f\hpp\defineDIKCodes.inc"
  4. #include "\A3\Ui_f\hpp\defineResinclDesign.inc"
  5.  
  6. #define FADE_DELAY 0.15
  7.  
  8. disableserialization;
  9.  
  10. _mode = [_this,0,"Open",[displaynull,""]] call bis_fnc_param;
  11. _this = [_this,1,[]] call bis_fnc_param;
  12. _fullVersion = missionnamespace getvariable ["BIS_fnc_arsenal_fullGarage",false];
  13.  
  14. #ifdef FNC_IS3DEN
  15. //--- Rewrite left side IDCs to 3DEN specific ones
  16. #define IDC_RSCDISPLAYGARAGE_TAB_CAR -1
  17. #define IDC_RSCDISPLAYGARAGE_TAB_ARMOR -1
  18. #define IDC_RSCDISPLAYGARAGE_TAB_HELI -1
  19. #define IDC_RSCDISPLAYGARAGE_TAB_PLANE -1
  20. #define IDC_RSCDISPLAYGARAGE_TAB_NAVAL -1
  21. #define IDC_RSCDISPLAYGARAGE_TAB_STATIC -1
  22.  
  23. #define IDC_RSCDISPLAYGARAGE_TAB_SUBCREW -1
  24. #define IDC_RSCDISPLAYGARAGE_TAB_SUBANIMATION IDC_RSCDISPLAYGARAGE3DEN_TAB_SUBANIMATION
  25. #define IDC_RSCDISPLAYGARAGE_TAB_SUBTEXTURE IDC_RSCDISPLAYGARAGE3DEN_TAB_SUBTEXTURE
  26.  
  27. #define IDCS_LEFT\
  28. IDC_RSCDISPLAYGARAGE_TAB_SUBANIMATION,\
  29. IDC_RSCDISPLAYGARAGE_TAB_SUBTEXTURE
  30.  
  31. #define IDCS_RIGHT
  32. #define INITTYPES
  33.  
  34. #define IDCS [IDCS_LEFT]
  35. #else
  36. #define IDCS_LEFT\
  37. IDC_RSCDISPLAYGARAGE_TAB_CAR,\
  38. IDC_RSCDISPLAYGARAGE_TAB_ARMOR,\
  39. IDC_RSCDISPLAYGARAGE_TAB_HELI,\
  40. IDC_RSCDISPLAYGARAGE_TAB_PLANE,\
  41. IDC_RSCDISPLAYGARAGE_TAB_NAVAL,\
  42. IDC_RSCDISPLAYGARAGE_TAB_STATIC
  43.  
  44. #define IDCS_RIGHT\
  45. IDC_RSCDISPLAYGARAGE_TAB_SUBCREW,\
  46. IDC_RSCDISPLAYGARAGE_TAB_SUBANIMATION,\
  47. IDC_RSCDISPLAYGARAGE_TAB_SUBTEXTURE
  48.  
  49. #define INITTYPES\
  50. _types = [];\
  51. _types set [IDC_RSCDISPLAYGARAGE_TAB_CAR,["carx"]];\
  52. _types set [IDC_RSCDISPLAYGARAGE_TAB_ARMOR,["tankx"]];\
  53. _types set [IDC_RSCDISPLAYGARAGE_TAB_HELI,["helicopterx"]];\
  54. _types set [IDC_RSCDISPLAYGARAGE_TAB_PLANE,["airplanex"]];\
  55. _types set [IDC_RSCDISPLAYGARAGE_TAB_NAVAL,["shipx","sumbarinex"]];\
  56. _types set [IDC_RSCDISPLAYGARAGE_TAB_STATIC,[""]];
  57.  
  58. #define IDCS [IDCS_LEFT,IDCS_RIGHT]
  59. #endif
  60.  
  61.  
  62. #define STATS\
  63. ["maxspeed","armor","fuelcapacity","threat"],\
  64. [false,true,false,false]
  65.  
  66.  
  67. #define CONDITION(LIST) (_fullVersion || {"%ALL" in LIST} || {{_item == _x} count LIST > 0})
  68. #define ERROR if !(_item in _disabledItems) then {_disabledItems set [count _disabledItems,_item];};
  69.  
  70. private _fnc_compareTextures =
  71. {
  72. params ["_vehtex", "_cfgtex"];
  73. if (_cfgtex isEqualTo "") exitWith { true }; // empty/absent config texture == any texture
  74. if (_vehtex find "\" != 0) then {_vehtex = "\" + _vehtex};
  75. if (_cfgtex find "\" != 0) then {_cfgtex = "\" + _cfgtex};
  76. _vehtex == _cfgtex
  77. };
  78.  
  79. private _checkboxTextures =
  80. [
  81. tolower gettext (configfile >> "RscCheckBox" >> "textureUnchecked"),
  82. tolower gettext (configfile >> "RscCheckBox" >> "textureChecked")
  83. ];
  84.  
  85. switch _mode do {
  86.  
  87. ///////////////////////////////////////////////////////////////////////////////////////////
  88. case "Open": {
  89. if !(isnull (uinamespace getvariable ["BIS_fnc_arsenal_cam",objnull])) exitwith {"Garage Viewer is already running" call bis_fnc_logFormat;};
  90. missionnamespace setvariable ["BIS_fnc_arsenal_fullGarage",[_this,0,false,[false]] call bis_fnc_param];
  91.  
  92. with missionnamespace do {
  93. BIS_fnc_garage_center = [_this,1,missionnamespace getvariable ["BIS_fnc_garage_center",player],[objnull]] call bis_fnc_param;
  94. };
  95. with uinamespace do {
  96. _displayMission = [] call (uinamespace getvariable "bis_fnc_displayMission");
  97. _displayClass = "RscDisplayGarage";
  98. if !(isnull finddisplay 312) then {_displayMission = finddisplay 312;};
  99. if (is3DEN) then {_displayMission = finddisplay 313; _displayClass = "RscDisplayGarage3DEN";};
  100. _displayMission createdisplay _displayClass;
  101. };
  102. };
  103.  
  104. ///////////////////////////////////////////////////////////////////////////////////////////
  105. case "Init": {
  106. ["BIS_fnc_arsenal"] call bis_fnc_startloadingscreen;
  107. _display = _this select 0;
  108. _toggleSpace = uinamespace getvariable ["BIS_fnc_arsenal_toggleSpace",false];
  109. BIS_fnc_arsenal_type = 1; //--- 0 - Arsenal, 1 - Garage
  110. BIS_fnc_arsenal_toggleSpace = nil;
  111. BIS_fnc_garage_turretPaths = [];
  112. if (isnil "BIS_fnc_garage_centerType") then {BIS_fnc_garage_centerType = "";};
  113. setstatvalue ["MarkVirtualVehicleInspection",1];
  114.  
  115. with missionnamespace do {
  116. BIS_fnc_arsenal_group = creategroup side group player;
  117. BIS_fnc_arsenal_center = missionnamespace getvariable ["BIS_fnc_garage_center",player];
  118. };
  119.  
  120. //--- Show specific class
  121. _classDefault = uinamespace getvariable ["bis_fnc_garage_defaultClass",""];
  122. if (isclass (configfile >> "cfgvehicles" >> _classDefault)) then {
  123. _vehModel = gettext (configfile >> "cfgvehicles" >> _classDefault >> "model");
  124. if (getnumber (configfile >> "cfgvehicles" >> _classDefault >> "forceInGarage") > 0) then {_vehModel = _vehModel + ":" + _classDefault;};
  125. bis_fnc_garage_centerType = _vehModel;
  126. };
  127. uinamespace setvariable ["bis_fnc_garage_defaultClass",nil];
  128.  
  129. //--- Load stats
  130. if (isnil {uinamespace getvariable "BIS_fnc_garage_stats"}) then {
  131. _defaultCrew = gettext (configfile >> "cfgvehicles" >> "all" >> "crew");
  132. uinamespace setvariable [
  133. "BIS_fnc_garage_stats",
  134. [
  135. //("isclass _x && getnumber (_x >> 'scope') == 2") configclasses (configfile >> "cfgvehicles"),
  136. ("isclass _x && {getnumber (_x >> 'scope') == 2} && {gettext (_x >> 'crew') != _defaultCrew}" configclasses (configfile >> "cfgvehicles")),
  137. STATS
  138. ] call bis_fnc_configExtremes
  139. ];
  140. };
  141.  
  142. INITTYPES
  143. ["InitGUI",[_display,"bis_fnc_garage"]] call bis_fnc_arsenal;
  144. ["Preload"] call BIS_fnc_garage;
  145. ["ListAdd",[_display]] call BIS_fnc_garage;
  146. //["ListSelectCurrent",[_display]] call BIS_fnc_garage;
  147. if (BIS_fnc_garage_centerType == "") then {["buttonRandom",[_display]] call BIS_fnc_garage;};
  148. ["MouseZChanged",[controlnull,0]] call BIS_fnc_arsenal; //--- Reset zoom
  149. {
  150. _ctrl = _display displayctrl _x;
  151. _ctrl ctrlsetfade 0;
  152. } foreach [IDC_RSCDISPLAYARSENAL_LINETABLEFT];
  153.  
  154. _ctrl = _display displayctrl IDC_RSCDISPLAYARSENAL_LINEICON;
  155. _ctrl ctrlshow false;
  156.  
  157. with missionnamespace do {
  158. [missionnamespace,"garageOpened",[_display,_toggleSpace]] call bis_fnc_callscriptedeventhandler;
  159. };
  160. ["BIS_fnc_arsenal"] call bis_fnc_endloadingscreen;
  161. };
  162.  
  163. ///////////////////////////////////////////////////////////////////////////////////////////
  164. case "Exit": {
  165. with missionnamespace do {
  166. BIS_fnc_garage_center = BIS_fnc_arsenal_center;
  167. /*
  168. {
  169. BIS_fnc_arsenal_center deletevehiclecrew _x;
  170. } foreach crew BIS_fnc_arsenal_center;
  171. deletevehicle BIS_fnc_arsenal_center;
  172. BIS_fnc_arsenal_group = nil;
  173. */
  174. };
  175. BIS_fnc_garage_turretPaths = nil;
  176.  
  177. with missionnamespace do {
  178. [missionnamespace,"garageClosed",[displaynull,uinamespace getvariable ["BIS_fnc_arsenal_toggleSpace",false]]] call bis_fnc_callscriptedeventhandler;
  179. };
  180. "Exit" call bis_fnc_arsenal;
  181. };
  182.  
  183. ///////////////////////////////////////////////////////////////////////////////////////////
  184. case "Preload": {
  185. if (is3DEN) then {
  186.  
  187. //--- 3DEN specific, load only animations and textures
  188. ["bis_fnc_garage_preload"] call bis_fnc_startloadingscreen;
  189. private ["_data"];
  190. _data = [];
  191. _center = (missionnamespace getvariable ["BIS_fnc_arsenal_center",player]);
  192. _centerFaction = faction _center;
  193. {
  194. _items = [];
  195. {
  196. _configName = configname _x;
  197. _displayName = gettext (_x >> "displayName");
  198. _factions = getarray (_x >> "factions");
  199. if (count _factions == 0) then {_factions = [_centerFaction];};
  200. if (
  201. _displayName != ""
  202. &&
  203. {getnumber (_x >> "scope") > 1 || !isnumber (_x >> "scope")}
  204. &&
  205. {{_x == _centerFaction} count _factions > 0}
  206. ) then {
  207. _items pushback [_x,_displayName];
  208. };
  209. } foreach (configproperties [_x,"isclass _x",true]);
  210. _data pushback _items;
  211. } foreach [
  212. configfile >> "cfgvehicles" >> typeof _center >> "animationSources",
  213. configfile >> "cfgvehicles" >> typeof _center >> "textureSources"
  214. ];
  215.  
  216. missionnamespace setvariable ["bis_fnc_garage_data",_data];
  217. ["bis_fnc_garage_preload"] call bis_fnc_endloadingscreen;
  218. BIS_fnc_garage_centerType = typeof _center;
  219. true
  220. } else {
  221.  
  222. //--- Non-3DEN, laod vehicle types sorted by category
  223. if (isnil "_data" || cheatsenabled) then {
  224. ["bis_fnc_garage_preload"] call bis_fnc_startloadingscreen;
  225.  
  226. _data = [];
  227. {
  228. _data set [_x,[]];
  229. } foreach [IDCS_LEFT];
  230. _defaultCrew = gettext (configfile >> "cfgvehicles" >> "all" >> "crew");
  231.  
  232. {
  233. _simulation = gettext (_x >> "simulation");
  234. _items = switch tolower _simulation do {
  235. case "car";
  236. case "carx": {
  237. _data select IDC_RSCDISPLAYGARAGE_TAB_CAR;
  238. };
  239. case "tank";
  240. case "tankx": {
  241. if (getnumber (_x >> "maxspeed") > 0) then {
  242. _data select IDC_RSCDISPLAYGARAGE_TAB_ARMOR;
  243. } else {
  244. _data select IDC_RSCDISPLAYGARAGE_TAB_STATIC;
  245. };
  246. };
  247. case "helicopter";
  248. case "helicopterx";
  249. case "helicopterrtd": {
  250. _data select IDC_RSCDISPLAYGARAGE_TAB_HELI;
  251. };
  252. case "airplane";
  253. case "airplanex": {
  254. _data select IDC_RSCDISPLAYGARAGE_TAB_PLANE;
  255. };
  256. case "ship";
  257. case "shipx";
  258. case "submarinex": {
  259. _data select IDC_RSCDISPLAYGARAGE_TAB_NAVAL;
  260. };
  261. default {[]};
  262. };
  263.  
  264. //--- Sort vehicles by model (vehicles with the same model are displayed as one, with variable textures / animations)
  265. _model = tolower gettext (_x >> "model");
  266. if (getnumber (_x >> "forceInGarage") > 0) then {_model = _model + ":" + configname _x;}; //--- Force specific class
  267. _modelID = _items find _model;
  268. if (_modelID < 0) then {
  269. _modelID = count _items;
  270. _items pushback _model;
  271. _items pushback [];
  272. };
  273. _modelData = _items select (_modelID + 1);
  274. _modelData pushback _x;
  275.  
  276. } foreach ("isclass _x && {getnumber (_x >> 'scope') == 2} && {gettext (_x >> 'crew') != _defaultCrew}" configclasses (configfile >> "cfgvehicles"));
  277.  
  278. missionnamespace setvariable ["bis_fnc_garage_data",_data];
  279. ["bis_fnc_garage_preload"] call bis_fnc_endloadingscreen;
  280. true
  281. } else {
  282. false
  283. };
  284. };
  285. };
  286.  
  287. ///////////////////////////////////////////////////////////////////////////////////////////
  288. case "ListAdd": {
  289. _display = _this select 0;
  290. _data = missionnamespace getvariable "bis_fnc_garage_data";
  291. _center = (missionnamespace getvariable ["BIS_fnc_arsenal_center",player]);
  292. if (is3DEN) then {
  293. _centerTextures = getobjecttextures _center;
  294. _ctrlList = controlnull; //--- Used by ShowItemInfo
  295. _cursel = -1; //--- Used by ShowItemInfo
  296. {
  297. _items = _x;
  298. _idc = _foreachindex;
  299. _ctrlList = _display displayctrl (IDC_RSCDISPLAYARSENAL_LIST + _foreachindex);
  300. {
  301. _configName = configname (_x select 0);
  302. _displayName = _x select 1;
  303. _lbAdd = _ctrlList lbadd _displayName;
  304. _ctrlList lbsetdata [_lbAdd,_configName];
  305. _ctrlList lbsettooltip [_lbAdd,_displayName];
  306. if (_idc == 0) then
  307. {
  308. _ctrlList lbsetpicture [_lbAdd,_checkboxTextures select ((_center animationphase _configName) max 0)];
  309. }
  310. else
  311. {
  312. private _cfg = configfile >> "cfgvehicles" >> typeof _center >> "texturesources" >> _configName;
  313.  
  314. private _configTextures = getarray (_cfg >> "textures");
  315. private _decals = getarray (_cfg >> "decals");
  316. private _selected =
  317. ({
  318. if !(_forEachIndex in _decals || { [_x, _configTextures param [_forEachIndex, ""]] call _fnc_compareTextures }) exitWith { false };
  319. true
  320. }
  321. forEach _centerTextures);
  322.  
  323. _ctrlList lbsetpicture [_lbAdd,_checkboxTextures select _selected];
  324. };
  325. }
  326. foreach _items;
  327. lbsort _ctrlList;
  328.  
  329. _ctrlListDisabled = _display displayctrl (IDC_RSCDISPLAYARSENAL_LISTDISABLED + _foreachindex);
  330. _ctrlListDisabled ctrlshow (lbsize _ctrlList == 0);
  331. } foreach _data;
  332.  
  333. _cfg = configfile >> "cfgvehicles" >> typeof _center;
  334. ["ShowItemInfo",[_cfg,gettext (_cfg >> "displayName")]] call bis_fnc_arsenal;
  335. ["ShowItemStats",[_cfg]] call bis_fnc_garage;
  336. } else {
  337. {
  338. _items = _x;
  339. _ctrlList = _display displayctrl (IDC_RSCDISPLAYARSENAL_LIST + _foreachindex);
  340. for "_i" from 0 to (count _items - 1) step 2 do {
  341. _model = _items select _i;
  342. _modelData = _items select (_i + 1);
  343. _modelExample = _modelData select 0;
  344. _displayName = gettext (_modelExample >> "displayName");
  345. _lbAdd = _ctrlList lbadd _displayName;
  346. _ctrlList lbsetpicture [_lbAdd,gettext (_modelExample >> "picture")];
  347. _ctrlList lbsetdata [_lbAdd,_model];
  348. _ctrlList lbsetvalue [_lbAdd,_i];
  349. _ctrlList lbsettooltip [_lbAdd,_displayName];
  350. if (_fullVersion) then {
  351. _addons = configsourceaddonlist _modelExample;
  352. if (count _addons > 0) then {
  353. _dlcs = configsourcemodlist (configfile >> "CfgPatches" >> _addons select 0);
  354. if (count _dlcs > 0) then {
  355. private _dlcName = _dlcs select 0;
  356. if (_dlcName != "") then {
  357. _ctrlList lbsetpictureright [_lbAdd,(modParams [_dlcName,["logo"]]) param [0,""]];
  358. }else{
  359. _ctrlList lbsetpictureright [_lbAdd,gettext ((configfile >> "cfgMods" >> gettext (_modelExample >> "dlc")) >> "logo")];
  360. };
  361. };
  362. };
  363. };
  364. };
  365. lbsort _ctrlList;
  366.  
  367. //--- Select previously selected item (must be done after sorting)
  368. for "_i" from 0 to (lbsize _ctrlList - 1) do {
  369. if ((_ctrlList lbdata _i) == bis_fnc_garage_centerType) then {
  370. _ctrlList lbsetcursel _i;
  371. };
  372. } foreach _data;
  373. } foreach _data;
  374. };
  375. };
  376.  
  377. ///////////////////////////////////////////////////////////////////////////////////////////
  378. case "TabSelectLeft": {
  379. _display = _this select 0;
  380. _index = _this select 1;
  381. _center = (missionnamespace getvariable ["BIS_fnc_arsenal_center",player]);
  382. /*
  383. {
  384. _ctrlList = _display displayctrl (IDC_RSCDISPLAYARSENAL_LIST + _x);
  385. _ctrlList lbsetcursel -1;
  386. lbclear _ctrlList;
  387. } foreach [IDCS_RIGHT];
  388. */
  389. {
  390. _idc = _x;
  391. _active = _idc == _index;
  392.  
  393. {
  394. _ctrlList = _display displayctrl (_x + _idc);
  395. _ctrlList ctrlenable _active;
  396. _ctrlList ctrlsetfade ([1,0] select _active);
  397. _ctrlList ctrlcommit FADE_DELAY;
  398. } foreach [IDC_RSCDISPLAYARSENAL_LIST,IDC_RSCDISPLAYARSENAL_LISTDISABLED];
  399.  
  400. _ctrlTab = _display displayctrl (IDC_RSCDISPLAYARSENAL_TAB + _idc);
  401. _ctrlTab ctrlenable !_active;
  402.  
  403. _ctrlList = _display displayctrl (IDC_RSCDISPLAYARSENAL_LIST + _idc);
  404. if (_active) then {
  405. _ctrlLineTabLeft = _display displayctrl IDC_RSCDISPLAYARSENAL_LINETABLEFT;
  406. _ctrlLineTabLeft ctrlsetfade 0;
  407. _ctrlTabPos = ctrlposition _ctrlTab;
  408. _ctrlLineTabPosX = (_ctrlTabPos select 0) + (_ctrlTabPos select 2) - 0.01;
  409. _ctrlLineTabPosY = (_ctrlTabPos select 1);
  410. _ctrlLineTabLeft ctrlsetposition [
  411. safezoneX,//_ctrlLineTabPosX,
  412. _ctrlLineTabPosY,
  413. (ctrlposition _ctrlList select 0) - safezoneX,//_ctrlLineTabPosX,
  414. ctrlposition _ctrlTab select 3
  415. ];
  416. _ctrlLineTabLeft ctrlcommit 0;
  417. ctrlsetfocus _ctrlList;
  418. if (_idc != IDC_RSCDISPLAYGARAGE_TAB_SUBANIMATION) then { //--- Don't select animation, it would inverse the state
  419. ['SelectItem',[_display,_display displayctrl (IDC_RSCDISPLAYARSENAL_LIST + _idc),_idc]] call bis_fnc_garage;
  420. };
  421. } else {
  422. if ((_center getvariable "bis_fnc_arsenal_idc") != _idc) then {_ctrlList lbsetcursel -1;};
  423. };
  424.  
  425. _ctrlIcon = _display displayctrl (IDC_RSCDISPLAYARSENAL_ICON + _idc);
  426. //_ctrlIcon ctrlsetfade ([1,0] select _active);
  427. _ctrlIcon ctrlshow _active;
  428. _ctrlIcon ctrlenable !_active;
  429. } foreach [IDCS_LEFT];
  430.  
  431. {
  432. _ctrl = _display displayctrl _x;
  433. _ctrl ctrlsetfade 0;
  434. _ctrl ctrlcommit FADE_DELAY;
  435. } foreach [
  436. //IDC_RSCDISPLAYARSENAL_LINETABLEFT,
  437. IDC_RSCDISPLAYARSENAL_FRAMELEFT,
  438. IDC_RSCDISPLAYARSENAL_BACKGROUNDLEFT
  439. ];
  440.  
  441. //--- Right lists
  442. {
  443. _idc = _x;
  444. _ctrl = _display displayctrl (IDC_RSCDISPLAYARSENAL_TAB + _x);
  445. _ctrl ctrlenable true;
  446. _ctrl ctrlsetfade 0;
  447. _ctrl ctrlcommit 0;//FADE_DELAY;
  448. {
  449. _ctrlList = _display displayctrl (_idc + _x);
  450. _ctrlList ctrlenable true;
  451. _ctrlList ctrlsetfade 0;
  452. _ctrlList ctrlcommit FADE_DELAY;
  453. } foreach [IDC_RSCDISPLAYARSENAL_LIST,IDC_RSCDISPLAYARSENAL_LISTDISABLED];
  454. } foreach [IDCS_RIGHT];
  455.  
  456. //--- Right sidebar
  457. if !(is3DEN) then {
  458. {
  459. _ctrl = _display displayctrl _x;
  460. _ctrl ctrlsetfade 0;
  461. _ctrl ctrlcommit FADE_DELAY;
  462. } foreach [
  463. IDC_RSCDISPLAYARSENAL_LINETABRIGHT,
  464. IDC_RSCDISPLAYARSENAL_FRAMERIGHT,
  465. IDC_RSCDISPLAYARSENAL_BACKGROUNDRIGHT
  466. ];
  467. };
  468.  
  469. ['TabSelectRight',[_display,IDC_RSCDISPLAYGARAGE_TAB_SUBCREW]] call bis_fnc_garage;
  470. };
  471.  
  472. ///////////////////////////////////////////////////////////////////////////////////////////
  473. case "TabSelectRight": {
  474. _display = _this select 0;
  475. _index = _this select 1;
  476. _ctrFrameRight = _display displayctrl IDC_RSCDISPLAYARSENAL_FRAMERIGHT;
  477. _ctrBackgroundRight = _display displayctrl IDC_RSCDISPLAYARSENAL_BACKGROUNDRIGHT;
  478.  
  479. {
  480. _idc = _x;
  481. _active = _idc == _index;
  482.  
  483. {
  484. _ctrlList = _display displayctrl (_x + _idc);
  485. _ctrlList ctrlenable _active;
  486. _ctrlList ctrlsetfade ([1,0] select _active);
  487. _ctrlList ctrlcommit FADE_DELAY;
  488. } foreach [IDC_RSCDISPLAYARSENAL_LIST,IDC_RSCDISPLAYARSENAL_LISTDISABLED];
  489.  
  490. _ctrlTab = _display displayctrl (IDC_RSCDISPLAYARSENAL_TAB + _idc);
  491. _ctrlTab ctrlenable (!_active && ctrlfade _ctrlTab == 0);
  492.  
  493. if (_active) then {
  494. _ctrlList = _display displayctrl (IDC_RSCDISPLAYARSENAL_LIST + _idc);
  495. _ctrlLineTabRight = _display displayctrl IDC_RSCDISPLAYARSENAL_LINETABRIGHT;
  496. _ctrlLineTabRight ctrlsetfade 0;
  497. _ctrlTabPos = ctrlposition _ctrlTab;
  498. _ctrlLineTabPosX = (ctrlposition _ctrlList select 0) + (ctrlposition _ctrlList select 2);
  499. _ctrlLineTabPosY = (_ctrlTabPos select 1);
  500. _ctrlLineTabRight ctrlsetposition [
  501. _ctrlLineTabPosX,
  502. _ctrlLineTabPosY,
  503. safezoneX + safezoneW - _ctrlLineTabPosX,//(_ctrlTabPos select 0) - _ctrlLineTabPosX + 0.01,
  504. ctrlposition _ctrlTab select 3
  505. ];
  506. _ctrlLineTabRight ctrlcommit 0;
  507. ctrlsetfocus _ctrlList;
  508.  
  509. _ctrlLoadCargo = _display displayctrl IDC_RSCDISPLAYARSENAL_LOADCARGO;
  510. _ctrlListPos = ctrlposition _ctrlList;
  511. _ctrlListPos set [3,(_ctrlListPos select 3) + (ctrlposition _ctrlLoadCargo select 3)];
  512. {
  513. _x ctrlsetposition _ctrlListPos;
  514. _x ctrlcommit 0;
  515. } foreach [_ctrFrameRight,_ctrBackgroundRight];
  516.  
  517. if (_idc in [IDC_RSCDISPLAYARSENAL_TAB_CARGOMAG,IDC_RSCDISPLAYARSENAL_TAB_CARGOTHROW,IDC_RSCDISPLAYARSENAL_TAB_CARGOPUT,IDC_RSCDISPLAYARSENAL_TAB_CARGOMISC]) then {
  518. ["SelectItemRight",[_display,_ctrlList,_index]] call bis_fnc_arsenal;
  519. };
  520. };
  521.  
  522. _ctrlIcon = _display displayctrl (IDC_RSCDISPLAYARSENAL_ICON + _idc);
  523. //_ctrlIcon ctrlenable false;
  524. _ctrlIcon ctrlshow _active;
  525. _ctrlIcon ctrlenable (!_active && ctrlfade _ctrlTab == 0);
  526. } foreach [IDCS_RIGHT];
  527. };
  528.  
  529. ///////////////////////////////////////////////////////////////////////////////////////////
  530. case "SelectItem": {
  531. private ["_ctrlList","_index","_cursel"];
  532. _display = _this select 0;
  533. _ctrlList = _this select 1;
  534. _idc = _this select 2;
  535. _cursel = lbcursel _ctrlList;
  536. if (_cursel < 0) exitwith {};
  537. _index = _ctrlList lbvalue _cursel;
  538.  
  539. _center = (missionnamespace getvariable ["BIS_fnc_arsenal_center",player]);
  540. _group = (missionnamespace getvariable ["BIS_fnc_arsenal_group",group player]);
  541. _cfg = configfile >> "dummy";
  542. //_cfg = configfile >> "cfgvehicles" >> typeof _center;
  543. _cfgStats = _cfg;
  544. _colors = [[1,1,1,1],[1,1,1,0.25]];
  545. _initVehicle = false;
  546.  
  547. switch _idc do {
  548. case IDC_RSCDISPLAYGARAGE_TAB_CAR;
  549. case IDC_RSCDISPLAYGARAGE_TAB_ARMOR;
  550. case IDC_RSCDISPLAYGARAGE_TAB_HELI;
  551. case IDC_RSCDISPLAYGARAGE_TAB_PLANE;
  552. case IDC_RSCDISPLAYGARAGE_TAB_NAVAL;
  553. case IDC_RSCDISPLAYGARAGE_TAB_STATIC: {
  554. _item = if (ctrltype _ctrlList == 102) then {_ctrlList lnbdata [_cursel,0]} else {_ctrlList lbdata _cursel};
  555. _target = (missionnamespace getvariable ["BIS_fnc_arsenal_target",player]);
  556. _centerType = if !(simulationenabled _center) then {""} else {typeof _center}; //--- Accept only previous vehicle, not player during init
  557. _centerSizeOld = ((boundingboxreal _center select 0) vectordistance (boundingboxreal _center select 1));//sizeof _centerType;
  558. _data = missionnamespace getvariable "bis_fnc_garage_data";
  559. _modelData = (_data select _idc) select (_index + 1);
  560. _cfg = _modelData select 0;
  561. _cfgStats = _cfg;
  562. _class = configname _cfg;
  563.  
  564. if (_class != _centerType || !alive _center) then {
  565. _centerPos = position _center;
  566. _centerPos set [2,0];
  567. _players = [];
  568. _crew = [];
  569. {
  570. _member = _x select 0;
  571. _role = _x select 1;
  572. _index = if (_role == "turret") then {_x select 3} else {_x select 2};
  573. _crew pushback [typeof _member,_role,_index];
  574. } foreach fullcrew _center;
  575. {
  576. if (isplayer _x) then {
  577. _players pushback [_x,assignedvehiclerole _x];
  578. moveout _x;
  579. } else {
  580. _center deletevehiclecrew _x;
  581. };
  582. } foreach crew _center;
  583. if (getnumber (configfile >> "cfgvehicles" >> typeof _center >> "isUAV") > 0) then {_crew = [];}; //--- Don't restore UAV crew
  584.  
  585. if (_center != player) then {_center setpos [10,10,00];};
  586. deletevehicle _center;
  587. _center = _class createvehiclelocal _centerPos;
  588. _center setVariable ["bis_fnc_arsenal_isGarageCenter", true];
  589. [_center, "", []] call bis_fnc_initVehicle;
  590. if (_center isKindOf "C_Kart_01_F") then { [_center] call bis_fnc_initVehicleKart };
  591. _center setpos _centerPos;
  592. if ((_center getvariable ["bis_fnc_arsenal_idc",-1]) >= 0) then {_center setpos _centerPos;}; //--- Move vehicle only when previous vehicle was created by Garage
  593. _center allowdamage false;
  594. _center setvelocity [0,0,0];
  595. _center setvariable ["bis_fnc_arsenal_idc",_idc];
  596. if (_fullVersion) then {_center setvehicletipars [0.5,0.5,0.5];}; //--- Heat vehicle parts so user can preview them
  597. bis_fnc_garage_centerType = _item;
  598. missionnamespace setvariable ["BIS_fnc_arsenal_center",_center];
  599. _target attachto [_center,BIS_fnc_arsenal_campos select 3,""];
  600.  
  601. //--- Restore player seats
  602. {
  603. _player = _x select 0;
  604. _roleArray = _x select 1;
  605. _role = _roleArray select 0;
  606. switch (tolower _role) do {
  607. case "driver": {
  608. if (_center emptypositions _role > 0) then {_player moveindriver _center;} else {_player moveinany _center;};
  609. };
  610. case "gunner";
  611. case "commander";
  612. case "turret": {
  613. if (count (allturrets _center) > 0) then {_player moveinturret [_center,(allturrets _center) select 0];} else {_player moveinany _center;};
  614. };
  615. case "cargo": {
  616. if (_center emptypositions _role > 0) then {_player moveincargo _center;} else {_player moveinany _center;};
  617. };
  618. };
  619. } foreach _players;
  620. if (getnumber (_cfg >> "isUAV") < 1) then {
  621. _crewUnits = [_center,_crew,true,nil,true] call bis_fnc_initVehicleCrew;
  622. {
  623. //_x disableai "move";
  624. _x setbehaviour "careless";
  625. _x call bis_fnc_vrHitpart;
  626. } foreach _crewUnits;
  627. };
  628.  
  629. //--- Set the same relative distance and position
  630. _centerSize = ((boundingboxreal _center select 0) vectordistance (boundingboxreal _center select 1));//sizeof typeof _center;
  631. if (_centerSizeOld != 0) then {
  632. _dis = BIS_fnc_arsenal_campos select 0;
  633. _disCoef = _dis / _centerSizeOld;
  634. BIS_fnc_arsenal_campos set [0,_centerSize * _disCoef];
  635.  
  636. _targetPos = BIS_fnc_arsenal_campos select 3;
  637. _coefX = (_targetPos select 0) / _centerSizeOld;
  638. _coefY = (_targetPos select 1) / _centerSizeOld;
  639. _coefZ = (_targetPos select 2) / _centerSizeOld;
  640. BIS_fnc_arsenal_campos set [3,[_centerSize * _coefX,_centerSize * _coefY,_centerSize * _coefZ]];
  641. };
  642. };
  643.  
  644. //--- Reset the vehicle state
  645. _center setdir direction _center;
  646. _center setvelocity [0,0,0];
  647.  
  648. //--- Crew positions
  649. _ctrlButtonTry = _display displayctrl IDC_RSCDISPLAYARSENAL_CONTROLSBAR_BUTTONTRY;
  650. _ctrlListCrew = _display displayctrl (IDC_RSCDISPLAYARSENAL_LIST + IDC_RSCDISPLAYGARAGE_TAB_SUBCREW);
  651. lbclear _ctrlListCrew;
  652.  
  653. if (getnumber (_cfg >> "isUAV") < 1) then {
  654. //_lbAdd = _ctrlListCrew lbadd "All crew"; //--- ToDo: Localize
  655. //_ctrlListCrew lbsetdata [_lbAdd,"Driver"];
  656. //_lbAdd = _ctrlListCrew lbadd "All passengers"; //--- ToDo: Localize
  657. //_ctrlListCrew lbsetdata [_lbAdd,"Driver"];
  658. _colorMe = getarray (configfile >> "CfgInGameUI" >> "IslandMap" >> "colorMe");
  659.  
  660. //--- Driver
  661. if (getnumber (_cfg >> "hasdriver") > 0) then {
  662. _text = if (_center iskindof "air") then {localize "str_pilot"} else {localize "str_driver"};
  663. _isPlayer = isplayer driver _center;
  664. if (_isPlayer) then {_text = format ["%1 (%2)",_text,name player];};
  665. _lbAdd = _ctrlListCrew lbadd _text;
  666. _ctrlListCrew lbsetdata [_lbAdd,"Driver"];
  667. _ctrlListCrew lbsetpicture [_lbAdd,_checkboxTextures select !(isnull driver _center)];
  668. if (_isPlayer) then {_ctrlListCrew lbsetcolor [_lbAdd,_colorMe];};
  669. };
  670.  
  671. //--- Turrets
  672. BIS_fnc_garage_turretPaths = [];
  673. _proxyIndexes = [];
  674. {
  675. _value = _foreachindex;
  676. _value = _value + 1; //--- Index must not be 0 to allow negative values
  677. _cfgTurret = _cfg;
  678. {_cfgTurret = (_cfgTurret >> "turrets") select _x;} foreach _x;
  679. _lbAdd = _ctrlListCrew lbadd gettext (_cfgTurret >> "gunnerName");
  680. _locked = _center lockedturret _x;
  681. _ctrlListCrew lbsetdata [_lbAdd,"Turret"];
  682. _ctrlListCrew lbsetvalue [_lbAdd,if (_locked) then {-_value} else {_value}];
  683. _ctrlListCrew lbsetpicture [_lbAdd,_checkboxTextures select !(isnull (_center turretunit _x))];
  684. BIS_fnc_garage_turretPaths pushback _x;
  685.  
  686. //--- Count number of cargo turrets
  687. //if (gettext (_cfgTurret >> "proxyType") == "CPCargo") then {
  688. if (getnumber (_cfgTurret >> "isPersonTurret") > 0 && getnumber (_cfg >> "hideProxyInCombat") == 0) then { // ToDo: onlyPersonTurret
  689. //_proxyIndexes pushback (count _proxyIndexes + 1);
  690. _proxyIndexes pushback getnumber (_cfgTurret >> "proxyIndex");
  691. };
  692. } foreach (allturrets [_center,true]);
  693.  
  694. //--- Cargo
  695. _occupiedSeats = [];
  696. {
  697. if ((_x select 1) == "cargo") then {_occupiedSeats pushback (_x select 2);};
  698. } foreach fullcrew _center;
  699. _getInProxyOrder = getarray (_cfg >> "getInProxyOrder");
  700. _transportSoldier = getnumber (_cfg >> "transportSoldier");
  701.  
  702. _cargoProxyIndexes = [];
  703. if (count _getInProxyOrder == 0) then {
  704. for "_i" from 1 to _transportSoldier do {_getInProxyOrder pushback _i;};
  705. _turretCount = count _proxyIndexes;
  706. for "_i" from (1 + _turretCount) to (_transportSoldier + _turretCount) do {_cargoProxyIndexes pushback _i;};
  707. } else {
  708. {
  709. if !(_x in _proxyIndexes) then {_cargoProxyIndexes pushback (_foreachindex + 1);};
  710. } foreach _getInProxyOrder;
  711. };
  712. _cargoProxyIndexes resize (_transportSoldier min (count _cargoProxyIndexes)); //--- Do not let cargoProxyIndexes be larger than transportSoldier. Added because of misconfigured HEMTTs
  713. {
  714. _locked = _center lockedcargo (_x - 1);
  715. _lbAdd = _ctrlListCrew lbadd format ["%1 %2",localize "STR_GETIN_POS_PASSENGER",_foreachindex + 1];
  716. _ctrlListCrew lbsetdata [_lbAdd,"Cargo"];
  717. _ctrlListCrew lbsetvalue [_lbAdd,if (_locked) then {-_x} else {_x}];
  718. _ctrlListCrew lbsetpicture [_lbAdd,_checkboxTextures select ((_x - 1) in _occupiedSeats)];
  719. _ctrlListCrew lbsetcolor [_lbAdd,_colors select _locked];
  720. _ctrlListCrew lbsetpicturecolor [_lbAdd,_colors select _locked];
  721. } foreach _cargoProxyIndexes;
  722.  
  723. _ctrlButtonTry ctrlenable _fullVersion;
  724. } else {
  725. createvehiclecrew _center;
  726. if (_fullVersion) then {{_x setbehaviour "careless";} foreach crew _center;};
  727. _ctrlButtonTry ctrlenable false;
  728. };
  729. _ctrlListCrewDisabled = _display displayctrl (IDC_RSCDISPLAYARSENAL_LISTDISABLED + IDC_RSCDISPLAYGARAGE_TAB_SUBCREW);
  730. _ctrlListCrewDisabled ctrlshow (lbsize _ctrlListCrew == 0);
  731.  
  732. //--- Animations
  733. _ctrlListAnimations = _display displayctrl (IDC_RSCDISPLAYARSENAL_LIST + IDC_RSCDISPLAYGARAGE_TAB_SUBANIMATION);
  734. lbclear _ctrlListAnimations;
  735. {
  736. _configName = configname _x;
  737. _displayName = gettext (_x >> "displayName");
  738. if (_displayName != "" && {getnumber (_x >> "scope") > 1 || !isnumber (_x >> "scope")}) then {
  739. _lbAdd = _ctrlListAnimations lbadd _displayName;
  740. _ctrlListAnimations lbsetdata [_lbAdd,_configName];
  741. _ctrlListAnimations lbsetpicture [_lbAdd,_checkboxTextures select ((_center animationphase _configName) max 0)];
  742. };
  743. } foreach (configproperties [_cfg >> "animationSources","isclass _x",true]);
  744. lbsort _ctrlListAnimations;
  745. _ctrlListAnimationsDisabled = _display displayctrl (IDC_RSCDISPLAYARSENAL_LISTDISABLED + IDC_RSCDISPLAYGARAGE_TAB_SUBANIMATION);
  746. _ctrlListAnimationsDisabled ctrlshow (lbsize _ctrlListAnimations == 0);
  747.  
  748. //--- Textures
  749. _currentTextures = getobjecttextures _center;
  750. _current = "";
  751. _ctrlListTextures = _display displayctrl (IDC_RSCDISPLAYARSENAL_LIST + IDC_RSCDISPLAYGARAGE_TAB_SUBTEXTURE);
  752. lbclear _ctrlListTextures;
  753. {
  754. _displayName = gettext (_x >> "displayName");
  755. if (_displayName != "") then
  756. {
  757. private _textures = getarray (_x >> "textures");
  758. private _decals = getarray (_x >> "decals");
  759. private _selected =
  760. ({
  761. if !(_forEachIndex in _decals || { [_x, _textures param [_forEachIndex, ""]] call _fnc_compareTextures }) exitWith { false };
  762. true
  763. }
  764. forEach _currentTextures);
  765.  
  766. _lbAdd = _ctrlListTextures lbadd _displayName;
  767. _ctrlListTextures lbsetdata [_lbAdd,configname _x];
  768. _ctrlListTextures lbsetpicture [_lbAdd,_checkboxTextures select 0];
  769. if (_selected) then {_current = configname _x;};
  770. };
  771. } foreach (configproperties [_cfg >> "textureSources","isclass _x",true]);
  772. lbsort _ctrlListTextures;
  773. for "_i" from 0 to (lbsize _ctrlListTextures - 1) do {
  774. if ((_ctrlListTextures lbdata _i) == _current) then {
  775. _ctrlListTextures lbsetcursel _i;
  776. };
  777. };
  778. _ctrlListTexturesDisabled = _display displayctrl (IDC_RSCDISPLAYARSENAL_LISTDISABLED + IDC_RSCDISPLAYGARAGE_TAB_SUBTEXTURE);
  779. _ctrlListTexturesDisabled ctrlshow (lbsize _ctrlListTextures == 0);
  780.  
  781. //--- Mark the tab as selected
  782. _ctrlTab = _display displayctrl (IDC_RSCDISPLAYARSENAL_TAB + _idc);
  783. _ctrlLineTab = _display displayctrl IDC_RSCDISPLAYARSENAL_LINETABLEFTSELECTED;
  784. _ctrlLineTabPos = ctrlposition _ctrlLineTab;
  785. _ctrlLineTabPos set [1,ctrlposition _ctrlTab select 1];
  786. _ctrlLineTab ctrlsetposition _ctrlLineTabPos;
  787. _ctrlLineTab ctrlcommit 0;
  788. };
  789. case IDC_RSCDISPLAYGARAGE_TAB_SUBCREW: {
  790. _role = _ctrlList lbdata _cursel;
  791. _roleIndex = _ctrlList lbvalue _cursel;
  792. if (_roleIndex < 0) exitwith {};
  793. _roleIndex = _roleIndex - 1; //--- Value was increased by 1 to allow negative values, revert back
  794.  
  795. _checked = false;
  796. _fnc_createUnit = {
  797. //_unit = (creategroup (side group player)) createunit ["B_soldier_vr_f",position _center,[],0,"none"];
  798. _unit = createagent ["B_soldier_vr_f",position _center,[],0,"none"];
  799. _unit call bis_fnc_vrHitpart;
  800. if (_fullVersion) then {_unit setbehaviour "careless";}; //--- Turn out
  801. _unit
  802. };
  803. _fnc_deleteUnit = {
  804. _group = group _unit;
  805. _center deletevehiclecrew _unit;
  806. deletegroup _group;
  807. };
  808. switch _role do {
  809. case "Driver": {
  810. _unit = driver _center;
  811. if !(isplayer _unit) then {
  812. if (isnull _unit) then {
  813. _unit = call _fnc_createUnit;
  814. _unit moveindriver _center;
  815. _checked = true;
  816. } else {
  817. call _fnc_deleteUnit;
  818. };
  819. } else {
  820. _checked = true;
  821. };
  822. };
  823. case "Turret": {
  824. _roleIndexArray = BIS_fnc_garage_turretPaths select _roleIndex;
  825. _unit = _center turretunit _roleIndexArray;
  826. if !(isplayer _unit) then {
  827. if (isnull _unit) then {
  828. _unit = call _fnc_createUnit;
  829. _unit moveinturret [_center,_roleIndexArray];
  830. _checked = true;
  831. } else {
  832. call _fnc_deleteUnit;
  833. };
  834. } else {
  835. _checked = true;
  836. };
  837. };
  838. case "Cargo": {
  839. _unit = objnull;
  840. {
  841. if ((_x select 1) == "cargo" && (_x select 2) == _roleIndex) exitwith {_unit = _x select 0;};
  842. } foreach fullcrew _center;
  843. if !(isplayer _unit) then {
  844. if (isnull _unit) then {
  845. _unit = call _fnc_createUnit;
  846. _unit moveincargo [_center,_roleIndex];
  847. _checked = true;
  848. } else {
  849. call _fnc_deleteUnit;
  850. };
  851. } else {
  852. _checked = true;
  853. };
  854. };
  855. };
  856. //_ctrlListCrew = _display displayctrl (IDC_RSCDISPLAYARSENAL_LIST + IDC_RSCDISPLAYGARAGE_TAB_SUBCREW);
  857. _ctrlList lbsetpicture [_cursel,_checkboxTextures select _checked];
  858. };
  859.  
  860. case IDC_RSCDISPLAYGARAGE_TAB_SUBANIMATION: {
  861. _selected = _checkboxTextures find (_ctrlList lbpicture _cursel);
  862. _ctrlList lbsetpicture [_cursel,_checkboxTextures select ((_selected + 1) % 2)];
  863. _initVehicle = true;
  864. };
  865. case IDC_RSCDISPLAYGARAGE_TAB_SUBTEXTURE: {
  866. _selected = _checkboxTextures find (_ctrlList lbpicture _cursel);
  867. for "_i" from 0 to (lbsize _ctrlList - 1) do {
  868. _ctrlList lbsetpicture [_i,_checkboxTextures select 0];
  869. };
  870. _ctrlList lbsetpicture [_cursel,_checkboxTextures select 1];
  871. _initVehicle = true;
  872. };
  873. /*
  874. case IDC_RSCDISPLAYGARAGE_TAB_SUBANIMATION: {
  875. _animationClass = _ctrlList lbdata _cursel;
  876. _cfg = configfile >> "cfgvehicles" >> typeof _center >> "animationsources" >> _animationClass;
  877. _animationPhase = round ((_center animationphase _animationClass) + 1) % 2;
  878. _center animate [_animationClass,_animationPhase];
  879. _ctrlList lbsetpicture [_cursel,_checkboxTextures select _animationPhase];
  880. };
  881. case IDC_RSCDISPLAYGARAGE_TAB_SUBTEXTURE: {
  882. _textureClass = _ctrlList lbdata _cursel;
  883. _cfg = configfile >> "cfgvehicles" >> typeof _center >> "texturesources" >> _textureClass;
  884. {
  885. _center setobjecttexture [_foreachindex,_x];
  886. } foreach getarray (_cfg >> "textures");
  887. };
  888. */
  889. };
  890. if (_initVehicle) then {
  891. _ctrlListTextures = _display displayctrl (IDC_RSCDISPLAYARSENAL_LIST + IDC_RSCDISPLAYGARAGE_TAB_SUBTEXTURE);
  892. _ctrlListAnimations = _display displayctrl (IDC_RSCDISPLAYARSENAL_LIST + IDC_RSCDISPLAYGARAGE_TAB_SUBANIMATION);
  893. _textures = "";
  894. _animations = [];
  895. for "_i" from 0 to (lbsize _ctrlListTextures - 1) do {
  896. if ((_ctrlListTextures lbpicture _i) == (_checkboxTextures select 1)) exitwith {_textures = [_ctrlListTextures lbdata _i,1];};
  897. };
  898. for "_i" from 0 to (lbsize _ctrlListAnimations - 1) do {
  899. _animations pushback (_ctrlListAnimations lbdata _i);
  900. _animations pushback (_checkboxTextures find (_ctrlListAnimations lbpicture _i));
  901. };
  902. //_animations call bis_fnc_log;
  903. [_center,_textures,_animations,true] call bis_fnc_initVehicle;
  904. };
  905.  
  906. ["SetCrewStatus",[_display]] call bis_fnc_garage;
  907. ["SetAnimationStatus",[_display]] call bis_fnc_garage;
  908. ["SetTextureStatus",[_display]] call bis_fnc_garage;
  909. if (isclass _cfg) then {
  910. ["ShowItemInfo",[_cfg]] call bis_fnc_arsenal;
  911. ["ShowItemStats",[_cfgStats]] call bis_fnc_garage;
  912. };
  913. };
  914.  
  915. ///////////////////////////////////////////////////////////////////////////////////////////
  916. case "SetAnimationStatus":
  917. {
  918. _display = _this select 0;
  919. _center = (missionnamespace getvariable ["BIS_fnc_arsenal_center",player]);
  920. _ctrlListAnimations = _display displayctrl (IDC_RSCDISPLAYARSENAL_LIST + IDC_RSCDISPLAYGARAGE_TAB_SUBANIMATION);
  921. for "_i" from 0 to (lbsize _ctrlListAnimations - 1) do {
  922. _selected = _center animationphase (_ctrlListAnimations lbdata _i);
  923. _ctrlListAnimations lbsetpicture [_i,_checkboxTextures select _selected];
  924. };
  925. };
  926.  
  927. ///////////////////////////////////////////////////////////////////////////////////////////
  928. case "SetTextureStatus":
  929. {
  930. private _display = _this select 0;
  931. private _center = (missionnamespace getvariable ["BIS_fnc_arsenal_center",player]);
  932. private _ctrlListTextures = _display displayctrl (IDC_RSCDISPLAYARSENAL_LIST + IDC_RSCDISPLAYGARAGE_TAB_SUBTEXTURE);
  933. private _centerTextures = getObjectTextures _center;
  934.  
  935. for "_i" from 0 to (lbsize _ctrlListTextures - 1) do
  936. {
  937. private _cfg = configfile >> "cfgvehicles" >> typeof _center >> "texturesources" >> (_ctrlListTextures lbdata _i);
  938.  
  939. private _configTextures = getarray (_cfg >> "textures");
  940. private _decals = getarray (_cfg >> "decals");
  941. private _selected =
  942. ({
  943. if !(_forEachIndex in _decals || { [_x, _configTextures param [_forEachIndex, ""]] call _fnc_compareTextures }) exitWith { false };
  944. true
  945. }
  946. forEach _centerTextures);
  947.  
  948. _ctrlListTextures lbsetpicture [_i,_checkboxTextures select _selected];
  949. };
  950. };
  951.  
  952. ///////////////////////////////////////////////////////////////////////////////////////////
  953. case "SetCrewStatus": {
  954. _display = _this select 0;
  955. _center = (missionnamespace getvariable ["BIS_fnc_arsenal_center",player]);
  956. _colors = [[1,1,1,1],[1,1,1,0.25]];
  957.  
  958. _ctrlListCrew = _display displayctrl (IDC_RSCDISPLAYARSENAL_LIST + IDC_RSCDISPLAYGARAGE_TAB_SUBCREW);
  959. _lockedIndexes = [];
  960. _colorMe = getarray (configfile >> "CfgInGameUI" >> "IslandMap" >> "colorMe");
  961. _iconPlayer = gettext (configfile >> "CfgInGameUI" >> "IslandMap" >> "iconPlayer");
  962. _emptyPositions = 0;
  963. for "_i" from 0 to (lbsize _ctrlListCrew - 1) do {
  964. _role = _ctrlListCrew lbdata _i;
  965. _roleIndex = abs (_ctrlListCrew lbvalue _i) - 1;
  966. _value = abs (_ctrlListCrew lbvalue _i);
  967. _locked = false;
  968. _unit = objnull;
  969.  
  970. //--- ToDo: lockCargoAnimationPhase
  971. switch (tolower _role) do {
  972. case "cargo": {
  973. _unit = objnull;
  974. {if ((_x select 2) == _roleIndex) exitwith {_unit = _x select 0;};} foreach fullcrew _center;
  975. _locked = _center lockedcargo _roleIndex;
  976. if (_locked) then {_lockedIndexes pushback _roleIndex;};
  977. };
  978. case "gunner";
  979. case "commander";
  980. case "turret": {
  981. _turretPath = BIS_fnc_garage_turretPaths select _roleIndex;
  982. _unit = _center turretunit _turretPath;
  983. _locked = _center lockedturret _turretPath;
  984. if (_locked) then {_lockedIndexes pushback _turretPath;};
  985. };
  986. case "driver": {
  987. _unit = driver _center;
  988. _locked = lockeddriver _center;
  989. };
  990. };
  991. _isPlayer = isplayer _unit;
  992. if (_locked && !isnull _unit) then {
  993. moveout _unit;
  994. _isPlayer = false;
  995. if (_fullVersion) then {
  996. if (_unit == player) then {_unit hideobject true;} else {deletevehicle _unit;};
  997. };
  998. };
  999. _ctrlListCrew lbsetcolor [_i,_colors select _locked];
  1000. _ctrlListCrew lbsetvalue [_i,[_value,-_value] select _locked];
  1001. if (_isPlayer) then {
  1002. _ctrlListCrew lbsetpicture [_i,_iconPlayer];
  1003. _ctrlListCrew lbsetpicturecolor [_i,_colorMe];
  1004. _emptyPositions = _emptyPositions + 1;
  1005. } else {
  1006. _isOccupied = !isnull _unit && !_locked;
  1007. _ctrlListCrew lbsetpicturecolor [_i,_colors select _locked];
  1008. _ctrlListCrew lbsetpicture [_i,_checkboxTextures select _isOccupied];
  1009. if !(_isOccupied) then {_emptyPositions = _emptyPositions + 1;};
  1010. };
  1011. };
  1012.  
  1013. //--- Delete crew on locked seats
  1014. {
  1015. _delete = switch (tolower (_x select 1)) do {
  1016. case "cargo": {(_x select 2) in _lockedIndexes};
  1017. case "gunner";
  1018. case "commander";
  1019. case "turret": {(_x select 3) in _lockedIndexes};
  1020. default {false}
  1021. };
  1022. if (_delete) then {
  1023. _center deletevehiclecrew (_x select 0);
  1024. };
  1025. } foreach (fullcrew _center);
  1026.  
  1027. //--- Disable TRY button when there's no space
  1028. _ctrlButtonTry = _display displayctrl IDC_RSCDISPLAYARSENAL_CONTROLSBAR_BUTTONTRY;
  1029. _ctrlButtonTry ctrlenable (_emptyPositions > 0);
  1030. };
  1031.  
  1032. ///////////////////////////////////////////////////////////////////////////////////////////
  1033. case "ShowItemStats": {
  1034. _itemCfg = _this select 0;
  1035. if (isclass _itemCfg) then {
  1036. _ctrlStats = _display displayctrl IDC_RSCDISPLAYARSENAL_STATS_STATS;
  1037. _ctrlStatsPos = ctrlposition _ctrlStats;
  1038. _ctrlStatsPos set [0,0];
  1039. _ctrlStatsPos set [1,0];
  1040. _ctrlBackground = _display displayctrl IDC_RSCDISPLAYARSENAL_STATS_STATSBACKGROUND;
  1041. _barMin = 0.01;
  1042. _barMax = 1;
  1043.  
  1044. _statControls = [
  1045. [IDC_RSCDISPLAYARSENAL_STATS_STAT1,IDC_RSCDISPLAYARSENAL_STATS_STATTEXT1],
  1046. [IDC_RSCDISPLAYARSENAL_STATS_STAT2,IDC_RSCDISPLAYARSENAL_STATS_STATTEXT2],
  1047. [IDC_RSCDISPLAYARSENAL_STATS_STAT3,IDC_RSCDISPLAYARSENAL_STATS_STATTEXT3],
  1048. [IDC_RSCDISPLAYARSENAL_STATS_STAT4,IDC_RSCDISPLAYARSENAL_STATS_STATTEXT4],
  1049. [IDC_RSCDISPLAYARSENAL_STATS_STAT5,IDC_RSCDISPLAYARSENAL_STATS_STATTEXT5]
  1050. ];
  1051. _rowH = 1 / (count _statControls + 1);
  1052. _fnc_showStats = {
  1053. _h = _rowH;
  1054. {
  1055. _ctrlStat = _display displayctrl ((_statControls select _foreachindex) select 0);
  1056. _ctrlText = _display displayctrl ((_statControls select _foreachindex) select 1);
  1057. if (count _x > 0) then {
  1058. _ctrlStat progresssetposition (_x select 0);
  1059. _ctrlText ctrlsettext toupper (_x select 1);
  1060. _ctrlText ctrlsetfade 0;
  1061. _ctrlText ctrlcommit 0;
  1062. //_ctrlText ctrlshow true;
  1063. _h = _h + _rowH;
  1064. } else {
  1065. _ctrlStat progresssetposition 0;
  1066. _ctrlText ctrlsetfade 1;
  1067. _ctrlText ctrlcommit 0;
  1068. //_ctrlText ctrlshow false;
  1069. };
  1070. } foreach _this;
  1071. _ctrlStatsPos set [1,(_ctrlStatsPos select 3) * (1 - _h)];
  1072. _ctrlStatsPos set [3,(_ctrlStatsPos select 3) * _h];
  1073. _ctrlBackground ctrlsetposition _ctrlStatsPos;
  1074. _ctrlBackground ctrlcommit 0;
  1075. };
  1076.  
  1077. _ctrlStats ctrlsetfade 0;
  1078. _statsExtremes = uinamespace getvariable "BIS_fnc_garage_stats";
  1079. if !(isnil "_statsExtremes") then {
  1080. _statsMin = _statsExtremes select 0;
  1081. _statsMax = _statsExtremes select 1;
  1082.  
  1083. _stats = [
  1084. [_itemCfg],
  1085. STATS,
  1086. _statsMin
  1087. ] call bis_fnc_configExtremes;
  1088. _stats = _stats select 1;
  1089.  
  1090. _statMaxSpeed = linearConversion [_statsMin select 0,_statsMax select 0,_stats select 0,_barMin,_barMax];
  1091. _statArmor = linearConversion [_statsMin select 1,_statsMax select 1,_stats select 1,_barMin,_barMax];
  1092. _statFuelCapacity = linearConversion [_statsMin select 2,_statsMax select 2,_stats select 2,_barMin,_barMax];
  1093. _statThreat = linearConversion [_statsMin select 3,_statsMax select 3,_stats select 3,_barMin,_barMax];
  1094. [
  1095. [],[],[],
  1096. [_statMaxSpeed,localize "STR_A3_RSCDISPLAYGARAGE_STAT_MAX_SPEED"],
  1097. [_statArmor,localize "STR_UI_ABAR"]/*
  1098. [_statFuelCapacity,"Fuel capacity"],
  1099. [_statThreat,"Threat"]*/
  1100. ] call _fnc_showStats;
  1101. };
  1102.  
  1103. _ctrlStats ctrlcommit FADE_DELAY;
  1104. } else {
  1105. _ctrlStats = _display displayctrl IDC_RSCDISPLAYARSENAL_STATS_STATS;
  1106. _ctrlStats ctrlsetfade 1;
  1107. _ctrlStats ctrlcommit FADE_DELAY;
  1108. };
  1109. };
  1110.  
  1111. ///////////////////////////////////////////////////////////////////////////////////////////
  1112. case "buttonImport": {
  1113. startloadingscreen [""];
  1114. _display = _this select 0;
  1115. _center = (missionnamespace getvariable ["BIS_fnc_arsenal_center",player]);
  1116. _centerCfg = configfile >> "cfgvehicles" >> typeof _center;
  1117.  
  1118. _import = copyfromclipboard;
  1119. _importArray = [_import," ;='"",[]" + tostring [13,10]] call bis_fnc_splitString;
  1120.  
  1121. _textures = [];
  1122. _animations = [];
  1123. _crew = [];
  1124.  
  1125. if (count _importArray == 1) then {
  1126. //--- Import vehicle class
  1127. _class = _importArray select 0;
  1128. } else {
  1129. //--- Import specific items
  1130. _importArray = _importArray + [""];
  1131. _isVehicle = false;
  1132. {
  1133. if (_x == "createvehicle" && !_isVehicle) then {
  1134. _vehClass = _importArray select _foreachindex + 1; //--- ToDo: Detect old createVehicle syntax
  1135. _vehModel = tolower gettext (configfile >> "cfgvehicles" >> _vehClass >> "model");
  1136. if (is3DEN) then {
  1137.  
  1138. if (_vehModel == gettext (_centerCfg >> "model")) then {
  1139. _isVehicle = true;
  1140. } else {
  1141.  
  1142. //--- Only settings of the same object can be imported in 3DEN
  1143. [
  1144. "showMessage",
  1145. [
  1146. _display,
  1147. format [
  1148. "Cannot import settings of %1 to %2!", // ToDo: Localize
  1149. gettext (configfile >> "cfgvehicles" >> _vehClass >> "displayName"),
  1150. gettext (_centerCfg >> "displayName")
  1151. ]
  1152. ]
  1153. ] call bis_fnc_arsenal;
  1154. };
  1155. } else {
  1156. _vehModelForced = _vehModel + ":" + _vehClass;
  1157. _isVehicle = false;
  1158. {
  1159. _ctrlList = _display displayctrl (IDC_RSCDISPLAYARSENAL_LIST + _x);
  1160. for "_l" from 0 to (lbsize _ctrlList - 1) do {
  1161. if ((_ctrlList lbdata _l) == _vehModel) then {
  1162. _ctrlList lbsetcursel _l;
  1163. _center = (missionnamespace getvariable ["BIS_fnc_arsenal_center",player]);
  1164. _centerCfg = configfile >> "cfgvehicles" >> typeof _center;
  1165. _isVehicle = true;
  1166. };
  1167. if ((_ctrlList lbdata _l) == _vehModelForced) exitwith {
  1168. _ctrlList lbsetcursel _l;
  1169. _center = (missionnamespace getvariable ["BIS_fnc_arsenal_center",player]);
  1170. _centerCfg = configfile >> "cfgvehicles" >> typeof _center;
  1171. _isVehicle = true;
  1172. };
  1173. };
  1174. if (_isVehicle) exitwith {};
  1175. } foreach [IDCS_LEFT];
  1176. };
  1177. };
  1178. if (_isVehicle) then {
  1179. switch true do {
  1180. case (isclass (_centerCfg >> "animationsources" >> _x)): {
  1181. _probability = parsenumber (_importArray select _foreachindex + 1);
  1182. _animations pushback _x;
  1183. _animations pushback _probability;
  1184. };
  1185. case (isclass (_centerCfg >> "texturesources" >> _x)): {
  1186. _probability = parsenumber (_importArray select _foreachindex + 1);
  1187. _textures pushback _x;
  1188. _textures pushback _probability;
  1189. };
  1190. case (_x == "driver"): {
  1191. _crew pushback ["B_Soldier_VR_F",_x];
  1192. };
  1193. case ((tolower _x) in ["turret","commander","gunner"]): {
  1194. _turretPath = [];
  1195. _maxTurretSize = 0;
  1196. {_maxTurretSize = _maxTurretSize max (count _x)} foreach (allturrets _center);
  1197. for "_t" from (_foreachindex + 1) to (_foreachindex + _maxTurretSize) do {
  1198. if (_t < count _importArray) then {
  1199. _turretPathValue = _importArray select _t;
  1200. if (_turretPathValue in ["0","1","2","3","4","5","6","7","8","9"]) then {
  1201. _turretPath pushback parsenumber _turretPathValue;
  1202. };
  1203. };
  1204. };
  1205. _crew pushback ["B_Soldier_VR_F",_x,_turretPath];
  1206. };
  1207. case (_x == "cargo"): {
  1208. _crew pushback ["B_Soldier_VR_F",_x,parsenumber (_importArray select _foreachindex + 1)];
  1209. };
  1210. };
  1211. };
  1212. } foreach _importArray;
  1213.  
  1214. [_center,_textures,_animations] call bis_fnc_initVehicle;
  1215. if !(is3DEN) then {
  1216. {_center deletevehiclecrew _x;} foreach (crew _center);
  1217. [_center,_crew] call bis_fnc_initVehicleCrew;
  1218. {_x setbehaviour "careless";} foreach (crew _center);
  1219. ["SetCrewStatus",[_display]] call bis_fnc_garage;
  1220. ["SetAnimationStatus",[_display]] call bis_fnc_garage;
  1221. ["SetTextureStatus",[_display]] call bis_fnc_garage;
  1222. };
  1223. };
  1224. endloadingscreen;
  1225. };
  1226.  
  1227. ///////////////////////////////////////////////////////////////////////////////////////////
  1228. case "buttonExport": {
  1229. _display = _this select 0;
  1230. _exportMode = _this select 1;
  1231. _center = (missionnamespace getvariable ["BIS_fnc_arsenal_center",player]);
  1232. _centerType = "";
  1233.  
  1234. _br = tostring [13,10];
  1235. _export = "";
  1236. if (_exportMode == "init" && !is3den) then {
  1237.  
  1238. //--- Get all classes using the model
  1239. _export = "comment ""Related vehicle classes:"";" + _br;
  1240. _data = missionnamespace getvariable "bis_fnc_garage_data";
  1241. _modelData = [];
  1242.  
  1243. _currentTextures = getobjecttextures _center;//_center getvariable ["bis_fnc_initVehicle_textures",[]];
  1244. {_currentTextures set [_foreachindex,tolower _x];} foreach _currentTextures;
  1245.  
  1246. {
  1247. _items = _x;
  1248. _ctrlList = _display displayctrl (IDC_RSCDISPLAYARSENAL_LIST + _foreachindex);
  1249. if (lbcursel _ctrlList >= 0) then {
  1250. _i = _ctrlList lbvalue lbcursel _ctrlList;
  1251. _modelData = _items select (_i + 1);
  1252. {
  1253. _export = _export + format ["comment ""%1"";" + _br,configname _x];
  1254. if (_centerType == "") then {
  1255. _textureList = getarray (_x >> "textureList");
  1256. for "_i" from 0 to (count _textureList - 1) step 2 do
  1257. {
  1258. private _textures = getarray (_x >> "textureSources" >> (_textureList select _i) >> "textures");
  1259. private _decals = getarray (_cfg >> "decals");
  1260. private _selected =
  1261. ({
  1262. if !(_forEachIndex in _decals || { [_x, _textures param [_forEachIndex, ""]] call _fnc_compareTextures }) exitWith { false };
  1263. true
  1264. }
  1265. forEach _currentTextures);
  1266.  
  1267. if (_selected) then {_centerType = configname _x;};
  1268. };
  1269. };
  1270. } foreach _modelData;
  1271. };
  1272. } foreach _data;
  1273. _export = _export + _br;
  1274. if (count _modelData == 1) then {
  1275. _export = "";
  1276. };
  1277. };
  1278. if (_centerType == "") then {_centerType = typeof _center;};
  1279. _export = _export + ([_center,_centerType] call bis_fnc_exportVehicle);
  1280. _export spawn {copytoclipboard _this;};
  1281. ['showMessage',[_display,localize "STR_a3_RscDisplayArsenal_message_clipboard"]] call bis_fnc_arsenal;
  1282. };
  1283.  
  1284. ///////////////////////////////////////////////////////////////////////////////////////////
  1285. case "buttonRandom": {
  1286. _display = _this select 0;
  1287.  
  1288. if (is3DEN) then {
  1289.  
  1290. //--- Select random animations
  1291. _ctrlList = _display displayctrl (IDC_RSCDISPLAYARSENAL_LIST + IDC_RSCDISPLAYGARAGE_TAB_SUBANIMATION);
  1292. for "_i" from 0 to (lbsize _ctrlList - 1) do {
  1293. if (random 1 > 0.5) then {_ctrlList lbsetcursel _i;};
  1294. };
  1295.  
  1296. //--- Select random texture
  1297. _ctrlList = _display displayctrl (IDC_RSCDISPLAYARSENAL_LIST + IDC_RSCDISPLAYGARAGE_TAB_SUBTEXTURE);
  1298. _ctrlList lbsetcursel floor random (lbsize _ctrlList);
  1299.  
  1300. } else {
  1301. //--- Select random vehicle type
  1302. {
  1303. _ctrlList = _display displayctrl (IDC_RSCDISPLAYARSENAL_LIST + _x);
  1304. _ctrlList lbsetcursel -1;
  1305. } foreach [IDCS_LEFT];
  1306.  
  1307. //--- Select random item
  1308. _ctrlList = _display displayctrl (IDC_RSCDISPLAYARSENAL_LIST + (floor random (count [IDCS_LEFT] - 1)));
  1309. _ctrlList lbsetcursel (floor random (lbsize _ctrlList - 1));
  1310. };
  1311. };
  1312.  
  1313. ///////////////////////////////////////////////////////////////////////////////////////////
  1314. case "showTemplates": {
  1315. _display = _this select 0;
  1316. _ctrlList = _display displayctrl IDC_RSCDISPLAYARSENAL_TEMPLATE_VALUENAME;
  1317. lnbclear _ctrlList;
  1318. _data = missionnamespace getvariable ["bis_fnc_garage_data",[]];
  1319. _savedData = profilenamespace getvariable ["bis_fnc_saveVehicle_data",[]];
  1320. _center = (missionnamespace getvariable ["BIS_fnc_arsenal_center",player]);
  1321. _centerType = typeof _center;
  1322.  
  1323. for "_i" from 0 to (count _savedData - 1) step 2 do {
  1324. _name = _savedData select _i;
  1325. _vehData = _savedData select (_i + 1);
  1326. _vehType = _vehData select 0;
  1327. if (!is3DEN || {is3DEN && _vehType == _centerType}) then {
  1328. _vehModel = tolower gettext (configfile >> "cfgvehicles" >> _vehType >> "model");
  1329. if (getnumber (configfile >> "cfgvehicles" >> _vehType >> "forceInGarage") > 0) then {_vehModel = _vehModel + ":" + _vehType;};
  1330. _lbAdd = _ctrlList lnbaddrow [_name];
  1331. _categoryIndex = -1;
  1332. if (is3DEN) then {_categoryIndex = 0;} else {{if (_vehModel in _x) exitwith {_categoryIndex = _foreachindex;}} foreach _data;};
  1333. _ctrlList lbsetvalue [_lbAdd,_categoryIndex];
  1334.  
  1335. if (_categoryIndex < 0) then {_ctrlList lnbsetcolor [[_lbAdd,0],[1,1,1,0.25]];};
  1336. };
  1337. };
  1338. ["templateSelChanged",[_display]] call bis_fnc_arsenal;
  1339. };
  1340.  
  1341. ///////////////////////////////////////////////////////////////////////////////////////////
  1342. case "buttonTemplateOK": {
  1343. _display = _this select 0;
  1344. _center = (missionnamespace getvariable ["BIS_fnc_arsenal_center",player]);
  1345. _hideTemplate = true;
  1346.  
  1347. _ctrlTemplateName = _display displayctrl IDC_RSCDISPLAYARSENAL_TEMPLATE_EDITNAME;
  1348. if (ctrlenabled _ctrlTemplateName) then {
  1349. //--- Save
  1350. [
  1351. _center,
  1352. [profilenamespace,ctrltext _ctrlTemplateName]
  1353. ] call bis_fnc_saveVehicle;
  1354. } else {
  1355. //--- Load
  1356. _ctrlTemplateValue = _display displayctrl IDC_RSCDISPLAYARSENAL_TEMPLATE_VALUENAME;
  1357. _categoryIndex = _ctrlTemplateValue lbvalue lnbcurselrow _ctrlTemplateValue;
  1358.  
  1359. if (_categoryIndex >= 0) then {
  1360. _savedData = profilenamespace getvariable ["bis_fnc_saveVehicle_data",[]];
  1361. _name = _ctrlTemplateValue lnbtext [lnbcurselrow _ctrlTemplateValue,0];
  1362. _nameID = _savedData find _name;
  1363. if (_nameID >= 0) then {
  1364. _vehData = _savedData select (_nameID + 1);
  1365. _vehType = _vehData select 0;
  1366. _vehModel = tolower gettext (configfile >> "cfgvehicles" >> _vehType >> "model");
  1367. if (getnumber (configfile >> "cfgvehicles" >> _vehType >> "forceInGarage") > 0) then {_vehModel = _vehModel + ":" + _vehType;};
  1368. _ctrlList = _display displayctrl (IDC_RSCDISPLAYARSENAL_LIST + _categoryIndex);
  1369. for "_i" from 0 to (lbsize _ctrlList - 1) do {
  1370. if (_ctrlList lbdata _i == _vehModel) exitwith {_ctrlList lbsetcursel _i;};
  1371. };
  1372.  
  1373. _center = (missionnamespace getvariable ["BIS_fnc_arsenal_center",player]);
  1374. [_center,_name,_categoryIndex,_display] spawn { //--- Must be spawned, animations cannot be applied immediately
  1375. disableserialization;
  1376. _center = _this select 0;
  1377. _name = _this select 1;
  1378. _categoryIndex = _this select 2;
  1379. _display = _this select 3;
  1380.  
  1381. [_center,[profilenamespace,_name]] call bis_fnc_loadvehicle;
  1382. if (is3DEN) then {
  1383. ['SelectItem',[_display,_display displayctrl (IDC_RSCDISPLAYARSENAL_LIST + _categoryIndex),_categoryIndex]] call bis_fnc_garage;
  1384. } else {
  1385. ["SetCrewStatus",[_display]] call bis_fnc_garage;
  1386. ["SetAnimationStatus",[_display]] call bis_fnc_garage;
  1387. ["SetTextureStatus",[_display]] call bis_fnc_garage;
  1388. };
  1389. };
  1390. };
  1391. } else {
  1392. _hideTemplate = false;
  1393. };
  1394. };
  1395. if (_hideTemplate) then {
  1396. _ctrlTemplate = _display displayctrl IDC_RSCDISPLAYARSENAL_TEMPLATE_TEMPLATE;
  1397. _ctrlTemplate ctrlsetfade 1;
  1398. _ctrlTemplate ctrlcommit 0;
  1399. _ctrlTemplate ctrlenable false;
  1400.  
  1401. _ctrlMouseBlock = _display displayctrl IDC_RSCDISPLAYARSENAL_MOUSEBLOCK;
  1402. _ctrlMouseBlock ctrlenable false;
  1403. };
  1404. };
  1405.  
  1406. ///////////////////////////////////////////////////////////////////////////////////////////
  1407. case "buttonTry": {
  1408. _display = _this select 0;
  1409. _display closedisplay 2;
  1410.  
  1411. ["#(argb,8,8,3)color(0,0,0,1)",false,nil,0,[0,0.5]] call bis_fnc_textTiles;
  1412.  
  1413. _center = (missionnamespace getvariable ["BIS_fnc_arsenal_center",player]);
  1414. if (_fullVersion && vehicle player != _center) then {
  1415. player setpos ([_center,135,(sizeof typeof _center) / 2] call bis_fnc_relpos);
  1416. player setdir (direction _center - 45);
  1417. player moveinany _center;
  1418. };
  1419. };
  1420.  
  1421. ///////////////////////////////////////////////////////////////////////////////////////////
  1422. case "buttonOK": {
  1423. _display = _this select 0;
  1424. _display closedisplay 2;
  1425. ["#(argb,8,8,3)color(0,0,0,1)",false,nil,0,[0,0.5]] call bis_fnc_textTiles;
  1426.  
  1427.  
  1428. //--- Apply the look on all selected objects
  1429. if (is3DEN) then {
  1430. _center = (missionnamespace getvariable ["BIS_fnc_arsenal_center",player]);
  1431. _centerType = typeof _center;
  1432. _customization = _center call bis_fnc_getVehicleCustomization;
  1433. _variant = _customization select 0;
  1434. _texture = _variant select 0;
  1435. _anims = _customization select 1;
  1436. _objects = [];
  1437. {
  1438. if (_centerType == typeof _x) then {_objects pushback _x;}; //--- Change only objects of the same type
  1439. } foreach get3DENSelected "object";
  1440. set3DENAttributes [[_objects,"VehicleCustomization",[_variant,_anims]]];
  1441. set3DENAttributes [[_objects,"ObjectTexture",_texture]];
  1442. };
  1443.  
  1444. };
  1445.  
  1446. ///////////////////////////////////////////////////////////////////////////////////////////
  1447. case "loadVehicle": {
  1448. disableserialization;
  1449. _vehClass = [_this,0,"",[""]] call bis_fnc_param;
  1450. _vehCfg = configfile >> "cfgvehicles" >> _vehClass;
  1451. if (isclass _vehCfg) then {
  1452. _vehID = -1;
  1453. _vehModel = tolower gettext (_vehCfg >> "model");
  1454. _vehModelForced = _vehModel + ":" + _vehClass;
  1455. _isVehicle = false;
  1456. _display = uinamespace getvariable ["bis_fnc_arsenal_display",displaynull];
  1457. {
  1458. _ctrlList = _display displayctrl (IDC_RSCDISPLAYARSENAL_LIST + _x);
  1459. for "_l" from 0 to (lbsize _ctrlList - 1) do {
  1460. _lbData = _ctrlList lbdata _l;
  1461. if (_lbData == _vehModel && !_isVehicle) then {_vehID = _l; _isVehicle = true;};
  1462. if (_lbData == _vehModelForced) exitwith {_vehID = _l; _isVehicle = true;};
  1463. };
  1464. if (_isVehicle) exitwith {
  1465. if (_vehID >= 0) then {_ctrlList lbsetcursel _vehID;};
  1466. };
  1467. } foreach [IDCS_LEFT];
  1468. };
  1469. };
  1470. };
Add Comment
Please, Sign In to add comment