Skip to content

Commit

Permalink
EEA3I v1.2
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vbawol committed Feb 8, 2017
1 parent 7181835 commit ea32cb9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 10 deletions.
8 changes: 7 additions & 1 deletion Sources/epoch_enhanced_a3_inventory/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];" },
};
};
Expand Down
33 changes: 24 additions & 9 deletions Sources/epoch_enhanced_a3_inventory/scripts/fn_subMenu.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand All @@ -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 {
Expand All @@ -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);
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit ea32cb9

Please sign in to comment.