From 41e653136f7e5de88590db07f73e3e675c253511 Mon Sep 17 00:00:00 2001 From: ebaydayz Date: Sat, 7 May 2016 19:29:00 -0400 Subject: [PATCH] Add attachments compatibility list to trader Also reduced item info size a bit to better fit normal and large interface sizes. --- .../functions/z_at_displayItemInfo.sqf | 56 +++++++++++++++--- .../functions/z_at_displayVehicleInfo.sqf | 40 +++++-------- .../functions/z_at_displayWeaponInfo.sqf | 58 ++++++++++++++----- SQF/dayz_code/stringtable.xml | 16 +++++ 4 files changed, 123 insertions(+), 47 deletions(-) diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_displayItemInfo.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_displayItemInfo.sqf index 70fe6f684..13224f2ab 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_displayItemInfo.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_displayItemInfo.sqf @@ -1,4 +1,4 @@ -private ['_item','_picture','_class','_display','_buyPrice','_sellPrice','_formattedText','_buyCurrency','_sellCurrency']; +private ['_item','_picture','_class','_display','_buyPrice','_sellPrice','_formattedText','_buyCurrency','_sellCurrency','_compatible','_weapon','_attach','_config','_compatibleText','_type','_text']; #include "defines.sqf"; _item = _this select 0; _picture = _item select 4; @@ -18,13 +18,43 @@ if (Z_Selling) then { _sellCurrency = _item select 8; }; +_compatible = []; +if (["Attachment",_class] call fnc_inString) then { + _config = configFile >> "CfgWeapons"; + + for "_i" from 0 to (count _config)-1 do { + _weapon = _config select _i; + if (isClass _weapon && {isClass (_weapon >> "Attachments")}) then { + for "_i" from 0 to (count (_weapon >> "Attachments"))-1 do { + _attach = (_weapon >> "Attachments") select _i; + _type = configName _attach; + if (_class == _type) exitWith { + _text = getText (_weapon >> "displayName"); + if (!(_text in _compatible) && (!(isClass (_weapon >> "ItemActions")) or {count (_weapon >> "ItemActions") < 1})) then { + _compatible set [count _compatible,_text]; + }; + }; + }; + }; + }; +}; + +_compatibleText = ""; +{ + if (_forEachIndex > 0) then { + _compatibleText = _compatibleText + ", " + _x; + } else { + _compatibleText = _compatibleText + _x; + }; +} forEach _compatible; + if (Z_SingleCurrency) then { _formattedText = format [ "
" + - "%8: %2
" + - "%9: %3
" + - "%10: %5 %7
" + - "%11: %6 %7
" + "%8: %2
" + + "%9: %3
" + + "%10: %5 %7
" + + "%11: %6 %7
" , _picture, _display, _class, 'lazy', _sellPrice, _buyPrice, CurrencyName, localize "STR_EPOCH_NAME", localize "STR_EPOCH_CLASS", localize "STR_EPOCH_PLAYER_292", localize "STR_EPOCH_PLAYER_291" ]; } else { @@ -34,11 +64,19 @@ if (Z_SingleCurrency) then { _buyCurrency = getText (configFile >> 'CfgMagazines' >> _buyCurrency >> 'displayName'); _formattedText = format [ "
" + - "%11: %2
" + - "%12: %3
" + - "%13: %5 %7
" + - "%14: %6 %9
" + "%11: %2
" + + "%12: %3
" + + "%13: %5 %7
" + + "%14: %6 %9
" , _picture, _display, _class, 'lazy', _sellPrice, _buyPrice, _sellCurrency , _picSell , _buyCurrency, _picBuy, localize "STR_EPOCH_NAME", localize "STR_EPOCH_CLASS", localize "STR_EPOCH_PLAYER_292", localize "STR_EPOCH_PLAYER_291" ]; }; + +if (count _compatible > 0) then { + _formattedText = _formattedText + format [ + "%1: %2" + ,localize "STR_EPOCH_COMPATIBLE",_compatibleText + ]; +}; + (findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_ITEMINFO) ctrlSetStructuredText parseText _formattedText; diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_displayVehicleInfo.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_displayVehicleInfo.sqf index 3af56afb5..98ac4f3fd 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_displayVehicleInfo.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_displayVehicleInfo.sqf @@ -118,18 +118,14 @@ _wepText = ""; if (Z_SingleCurrency) then { _formattedText = format [ "
" + - "%10: %2
" + - "%11: %3
" + - "%12: %5 %7
" + - "%13: %6 %7
" + - "%14: %9
" + - "%15: %8
" + - "%16: %4
" + - "%17: %18
" + // Armor - //"%19: %20
" + // Fuel - "%21%22: %23
" + // MaxSpeed - "%24: %25
" + // Seats - "%26: %27" // Weapons + "%10: %2
" + + "%11: %3
" + + "%12: %5 %7
" + + "%13: %6 %7
" + + "%14/%15/%16: %9/%8/%4
" + + "%17: %18 %24: %25
" + // Armor / Seats + "%21%22: %23 %19: %20
" + // MaxSpeed / Fuel + "%26: %27" // Weapons , _picture, _display, _class, _transportmaxBackpacks, _sellPrice, _buyPrice, CurrencyName, _transportMaxWeapons,_transportMaxMagazines, localize "STR_EPOCH_NAME", localize "STR_EPOCH_CLASS", localize "STR_EPOCH_PLAYER_292", localize "STR_EPOCH_PLAYER_291", localize "STR_EPOCH_MAGS", localize "STR_EPOCH_WEPS", localize "STR_EPOCH_BAGS", localize "STR_EPOCH_ARMOR",_armor,localize "STR_EPOCH_FUEL",_fuelCapacity,localize "STR_EPOCH_MAX",localize "STR_EPOCH_SPEED",_maxSpeed,localize "STR_EPOCH_SEATS",_seats,localize "STR_EPOCH_WEAPONS",_wepText ]; @@ -143,18 +139,14 @@ if (Z_SingleCurrency) then { _formattedText = format [ "
" + - "%13: %2
" + - "%14: %3
" + - "%15: %5 %10
" + - "%16: %6 %7
" + - "%17: %8
" + - "%18: %9
" + - "%19: %4
" + - "%20: %21
" + // Armor - //"%22: %23
" + // Fuel - "%24%25: %26
" + // MaxSpeed - "%27: %28
" + // Seats - "%29: %30" // Weapons + "%13: %2
" + + "%14: %3
" + + "%15: %5 %10
" + + "%16: %6 %7
" + + "%17/%18/%19: %8/%9/%4
" + + "%20: %21 %27: %28
" + // Armor / Seats + "%24%25: %26 %22: %23
" + // MaxSpeed / Fuel + "%29: %30" // Weapons , _picture, _display, _class, _transportmaxBackpacks, _sellPrice, _buyPrice, _buyCurrency, _transportMaxWeapons,_transportMaxMagazines, _sellCurrency, _picSell,_picBuy, localize "STR_EPOCH_NAME", localize "STR_EPOCH_CLASS", localize "STR_EPOCH_PLAYER_292", localize "STR_EPOCH_PLAYER_291", localize "STR_EPOCH_WEPS", localize "STR_EPOCH_MAGS", localize "STR_EPOCH_BAGS", localize "STR_EPOCH_ARMOR",_armor,localize "STR_EPOCH_FUEL",_fuelCapacity,localize "STR_EPOCH_MAX",localize "STR_EPOCH_SPEED",_maxSpeed,localize "STR_EPOCH_SEATS",_seats,localize "STR_EPOCH_WEAPONS",_wepText ]; diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_displayWeaponInfo.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_displayWeaponInfo.sqf index 387338e1a..2fb11bcd7 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_displayWeaponInfo.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_displayWeaponInfo.sqf @@ -1,4 +1,4 @@ -private ["_item","_picture","_class","_display","_buyPrice","_sellPrice","_magazines","_magText","_formattedText","_buyCurrency","_sellCurrency"]; +private ["_item","_picture","_class","_display","_buyPrice","_sellPrice","_magazines","_magText","_formattedText","_buyCurrency","_sellCurrency","_attachments","_attachText","_config","_text","_attach","_type"]; #include "defines.sqf"; _item = _this select 0; @@ -22,9 +22,33 @@ if (Z_Selling) then { _sellCurrency = _item select 8; }; +_attachments = []; +_config = configFile >> "CfgWeapons" >> _class >> "Attachments"; +if (isClass _config) then { + for "_i" from 0 to (count _config)-1 do { + _attach = _config select _i; + _type = configName _attach; + _text = getText (configFile >> "CfgMagazines" >> _type >> "displayName"); + _attachments set [count _attachments,_text]; + }; +}; + +if (count _attachments < 1) then {_attachments = [localize "STR_EPOCH_NONE"];}; + +_attachText = ""; +{ + if (_forEachIndex > 0) then { + _attachText = _attachText + ", " + _x; + } else { + _attachText = _attachText + _x; + }; +} forEach _attachments; + _magazines = []; if( isArray (configFile >> 'CfgWeapons' >> _class >> 'magazines')) then { - _magazines = getArray (configFile >> 'CfgWeapons' >> _class >> 'magazines'); + { + _magazines set [count _magazines, getText (configFile >> "CfgMagazines" >> _x >> "displayName")]; + } forEach (getArray (configFile >> 'CfgWeapons' >> _class >> 'magazines')); }; _magText = ""; @@ -40,12 +64,11 @@ _magText = ""; if (Z_SingleCurrency) then { _formattedText = format [ "
" + - "%8: %2
" + - "%9: %3
" + - "%10: %5 %7
" + - "%11: %6 %7
" + - "%12:
%4" - , _picture, _display, _class, _magText, _sellPrice, _buyPrice, CurrencyName, localize "STR_EPOCH_NAME", localize "STR_EPOCH_CLASS", localize "STR_EPOCH_PLAYER_292", localize "STR_EPOCH_PLAYER_291", localize "STR_EPOCH_MAGS" + "%8: %2
" + + "%9: %3
" + + "%10: %5 %7
" + + "%11: %6 %7
" + , _picture, _display, _class, _magText, _sellPrice, _buyPrice, CurrencyName, localize "STR_EPOCH_NAME", localize "STR_EPOCH_CLASS", localize "STR_EPOCH_PLAYER_292", localize "STR_EPOCH_PLAYER_291" ]; }else { _picSell = getText (configFile >> 'CfgMagazines' >> _sellCurrency >> 'picture'); @@ -55,15 +78,22 @@ if (Z_SingleCurrency) then { _formattedText = format [ "
" + - "%11: %2
" + - "%12: %3
" + - "%13: %5 %7
" + - "%14: %6 %8
" + - "%15:
%4" - , _picture, _display, _class, _magText, _sellPrice, _buyPrice, _sellCurrency, _buyCurrency, _picSell, _picBuy, localize "STR_EPOCH_NAME", localize "STR_EPOCH_CLASS", localize "STR_EPOCH_PLAYER_292", localize "STR_EPOCH_PLAYER_291", localize "STR_EPOCH_MAGS" + "%11: %2
" + + "%12: %3
" + + "%13: %5 %7
" + + "%14: %6 %8
" + , _picture, _display, _class, _magText, _sellPrice, _buyPrice, _sellCurrency, _buyCurrency, _picSell, _picBuy, localize "STR_EPOCH_NAME", localize "STR_EPOCH_CLASS", localize "STR_EPOCH_PLAYER_292", localize "STR_EPOCH_PLAYER_291" ]; }; +_parentClasses = [(configFile >> "CfgWeapons" >> _class),true] call BIS_fnc_returnParents; +if !("ItemCore" in _parentClasses or "Binocular" in _parentClasses) then { + _formattedText = _formattedText + format [ + "%1: %2
" + + "%3: %4" + ,localize "STR_EPOCH_ATTACHMENTS",_attachText,localize "STR_EPOCH_MAGS",_magText + ]; +}; (findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_ITEMINFO) ctrlSetStructuredText parseText _formattedText; diff --git a/SQF/dayz_code/stringtable.xml b/SQF/dayz_code/stringtable.xml index 135e6fd69..e85286edf 100644 --- a/SQF/dayz_code/stringtable.xml +++ b/SQF/dayz_code/stringtable.xml @@ -15890,6 +15890,14 @@ Bags Рюкзаков + + Attachments + Zubehör + Вложения + Accesorios + Accessoires + Přílohy + Seats Sitze @@ -17322,5 +17330,13 @@ Brak Nincs + + Compatible + Kompatibel + совместимый + Compatible + Compatible + Kompatibilní +