From ea32cb9bc747b24fcb4576f54d9141ee6056bbef Mon Sep 17 00:00:00 2001 From: vbawol Date: Wed, 8 Feb 2017 10:26:53 -0600 Subject: [PATCH] EEA3I v1.2 Fixed inverted logic on condition. true allows button, false disallows. Added new config AllAmmoSettings inside CfgItemInteractions for all ammo related options. This also allows easier customization or disabling of ammo repack options. --- .../epoch_enhanced_a3_inventory/config.cpp | 8 ++++- .../scripts/fn_subMenu.sqf | 33 ++++++++++++++----- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/Sources/epoch_enhanced_a3_inventory/config.cpp b/Sources/epoch_enhanced_a3_inventory/config.cpp index 8c5035b..f38da02 100644 --- a/Sources/epoch_enhanced_a3_inventory/config.cpp +++ b/Sources/epoch_enhanced_a3_inventory/config.cpp @@ -100,11 +100,17 @@ class CfgFunctions { 4 = (optional) Code to execute when the button is pressed on a failed condition above. */ class CfgItemInteractions { + class AllAmmoSettings // this is a fake class that holds the settings for the ammo repack feature. + { + interactActions[] = { + {"REPACK", "call EPOCH_fnc_ammoRepack;" } // To disable set this to an empty array here or in description.ext. interactActions[] = {}; + }; + }; class FirstAidKit { interactActions[] = { // Test actions - requires the player to have a watch equipped for "Check Pulse" action to show on double click of the First Aid Kit. - {"Check Pulse", "_target = player; if (cursorTarget isKindof 'Man') then {_target = cursorTarget}; if ((damage _target) > 0.1) then { hintSilent format['%1 Needs Medical Attention!',name _target];} else {hintSilent format['%1, Does Not Need Medical Attention.',name _target];};", "'ItemWatch' in (assignedItems player)", 1 , "hintSilent 'Watch Needed';" } + {"Check Pulse", "_target = player; if (cursorTarget isKindof 'Man') then {_target = cursorTarget}; if ((damage _target) > 0.1) then { hintSilent format['%1 Needs Medical Attention!',name _target];} else {hintSilent format['%1, Does Not Need Medical Attention.',name _target];};", "!('ItemWatch' in (assignedItems player))", 1 , "hintSilent 'Watch Needed';" } // {"Debug 1", "hintSilent str[_thisItem,_thisItemType];" }, }; }; diff --git a/Sources/epoch_enhanced_a3_inventory/scripts/fn_subMenu.sqf b/Sources/epoch_enhanced_a3_inventory/scripts/fn_subMenu.sqf index 50b803d..89f50e5 100644 --- a/Sources/epoch_enhanced_a3_inventory/scripts/fn_subMenu.sqf +++ b/Sources/epoch_enhanced_a3_inventory/scripts/fn_subMenu.sqf @@ -20,7 +20,6 @@ NUMBER */ //[[[cog import generate_private_arrays ]]] -private ["_activeControl","_bg","_btn_arr","_buffer","_button_gen","_cfgItemInteractions","_config","_control","_thisItem","_display","_interactActions","_interactedItem","_magCount","_missionconfig","_pos","_start_idc","_thisItemType","_y2d"]; //[[[end]]] _interactActions = []; @@ -44,14 +43,28 @@ if !(_interactedItem isEqualTo []) then { _thisItem = _interactedItem select 1; // load action configs - _cfgItemInteractions = (configfile >> "CfgItemInteractions" >> _thisItem); - _missionconfig = (missionConfigFile >> "CfgItemInteractions" >> _thisItem); - if (isClass _missionconfig) then{ - _cfgItemInteractions = _missionconfig; + _mainMissionConfig = (missionConfigFile >> "CfgItemInteractions"); + _mainConfig = (configfile >> "CfgItemInteractions"); + // find item classes + _selectedItemConfig = (_mainConfig >> _thisItem); + _selectedItemMissionConfig = (_mainMissionConfig >> _thisItem); + // prefer mission config over main + if (isClass _selectedItemMissionConfig) then{ + _selectedItemConfig = _selectedItemMissionConfig; }; - _config = (configfile >> "CfgWeapons" >> _thisItem); + // load ammo repack configs + _repackConfig = (_mainConfig >> "AllAmmoSettings"); + _repackMissionConfig = (_mainMissionConfig >> "AllAmmoSettings"); + // prefer mission config over main + if (isClass _repackMissionConfig) then{ + _repackConfig = _repackMissionConfig; + }; + _repack = getArray(_repackConfig >> "interactActions"); + + // get actual item config + _config = (configfile >> "CfgWeapons" >> _thisItem); if (isClass (_config)) then { _thisItemType = getNumber(_config >> "type"); } else { @@ -60,13 +73,15 @@ if !(_interactedItem isEqualTo []) then { _magCount = getNumber(_config >> "count"); }; - _interactActions = getArray(_cfgItemInteractions >> "interactActions"); + _interactActions = getArray(_selectedItemConfig >> "interactActions"); // ammo repack if (_magCount > 1) then { - _interactActions pushBack ["REPACK","call EPOCH_fnc_ammoRepack;"]; + {_interactActions pushBack _x} forEach _repack; }; + diag_log format["DEBUG: _interactActions %1",_interactActions]; + // build menu if !(_interactActions isEqualTo []) then { _display = ctrlParent (_main_control select 0); @@ -104,7 +119,7 @@ if !(_interactedItem isEqualTo []) then { _start_idc = 12346; { _x params [["_btn_text",""],["_btn_code",""],["_btn_condition","true"],["_btn_mode",0],["_btn_fail_code",""]]; - _logicCheck = !(call compile _btn_condition); + _logicCheck = call compile _btn_condition; // mode 0 = do not show button if condition is not met. // mode 1 = show button but execute alternate code when clicked. switch (_btn_mode) do {