Facebook
From Kasztura, 3 Years ago, written in C++.
Embed
Download Paste or View Raw
Hits: 201
  1. #include "..\..\script_macros.hpp"
  2. /*
  3.     File: fn_weaponShopSelection.sqf
  4.     Author: Bryan "Tonic" Boardwine
  5.  
  6.     Description:
  7.     Checks the weapon & adds the price tag.
  8. */
  9. private ["_control","_index","_shop","_priceTag","_price","_item","_itemArray","_bool"];
  10. _control = [_this,0,controlNull,[controlNull]] call BIS_fnc_param;
  11. _index = [_this,1,-1,[0]] call BIS_fnc_param;
  12. _shop = uiNamespace getVariable ["Weapon_Shop",""];
  13. if (isNull _control) exitWith {closeDialog 0;}; //Bad data
  14. if (_index isEqualTo -1) exitWith {}; //Nothing selected
  15.  
  16. _priceTag = CONTROL(38400,38404);
  17.  
  18. if ((uiNamespace getVariable ["Weapon_Shop_Filter",0]) isEqualTo 1) then {
  19.     _item = CONTROL_DATAI(_control,_index);
  20.     _itemArray = M_CONFIG(getArray,"WeaponShops",_shop,"items");
  21.     _itemArray append M_CONFIG(getArray,"WeaponShops",_shop,"mags");
  22.     _itemArray append M_CONFIG(getArray,"WeaponShops",_shop,"accs");
  23.     _item = [_item,_itemArray] call TON_fnc_index;
  24.     _price = ((_itemArray select _item) select 3);
  25.     _priceTag ctrlSetStructuredText parseText format ["<t size='0.8'>Price: <t color='#8cff9b'>$%1</t></t>",[(_price)] call life_fnc_numberText];
  26.     _control lbSetValue[_index,_price];
  27. } else {
  28.     _price = _control lbValue _index;
  29.     _item = CONTROL_DATAI(_control,_index);
  30.     if (_price > CASH) then {
  31.         _priceTag ctrlSetStructuredText parseText format ["<t size='0.8'>Price: <t color='#ff0000'>$%1</t><br/>You lack: <t color='#8cff9b'>$%2</t></t>",[(_price)] call life_fnc_numberText,[(_price - CASH)] call life_fnc_numberText];
  32.     } else {
  33.         _priceTag ctrlSetStructuredText parseText format ["<t size='0.8'>Price: <t color='#8cff9b'>$%1</t></t>",[(_price)] call life_fnc_numberText];
  34.     };
  35.     if ((uiNamespace getVariable ["Weapon_Magazine",0]) isEqualTo 0 && (uiNamespace getVariable ["Weapon_Accessories",0]) isEqualTo 0) then {
  36.             if (isClass (configFile >> "CfgWeapons" >> _item)) then {
  37.                 //Magazines menu
  38.                 if (isArray (configFile >> "CfgWeapons" >> _item >> "magazines")) then {
  39.                     _itemArray = FETCH_CONFIG2(getArray,"CfgWeapons",_item,"magazines");
  40.                     _bool = false;
  41.                     {
  42.                         _var = _x select 0;
  43.                         _count = {_x == _var} count _itemArray;
  44.                         if (_count > 0) exitWith {_bool = true};
  45.                     } forEach M_CONFIG(getArray,"WeaponShops",_shop,"mags");
  46.                     if (_bool) then {
  47.                         ((findDisplay 38400) displayCtrl 38406) ctrlEnable true;
  48.                     } else {
  49.                         ((findDisplay 38400) displayCtrl 38406) ctrlEnable false;
  50.                     };
  51.                 } else {
  52.                     ((findDisplay 38400) displayCtrl 38406) ctrlEnable false;
  53.                 };
  54.  
  55.                 if (isClass (configFile >> "CfgWeapons" >> _item >> "WeaponSlotsInfo")) then {
  56.                         ((findDisplay 38400) displayCtrl 38407) ctrlEnable true; //<== Te huje z bugemii coś zjebały i pobierało puste tablice z configów
  57.                 } else {
  58.                     ((findDisplay 38400) displayCtrl 38407) ctrlEnable false;
  59.                 };
  60.             } else {
  61.             ((findDisplay 38400) displayCtrl 38406) ctrlEnable false;
  62.             ((findDisplay 38400) displayCtrl 38407) ctrlEnable false;
  63.         };
  64.     };
  65. };