From ff4b401b5fe1cce5d7314b71dde9420ad18df3f4 Mon Sep 17 00:00:00 2001 From: He-Man Date: Thu, 3 Aug 2017 18:18:18 +0200 Subject: [PATCH] Some Fav-Bar Tweaks - Moved configs to cfgepochclient - Changed Keydown-Check from EPOCH_Buildmode to EPOCH_Target - Replaced "resetonLogin" to only remove "forbidden items" --- .../EPOCH_KeyDown.sqf | 13 ++++-- .../interface_event_handlers/EPOCH_KeyUp.sqf | 6 ++- .../compile/inventory/EPOCH_equip.sqf | 2 +- .../scripts/favBar/epoch_favBar_action.sqf | 44 +++++++++---------- .../gui/scripts/favBar/epoch_favBar_draw.sqf | 21 +++++---- .../scripts/favBar/epoch_favBar_inventory.sqf | 2 +- .../scripts/favBar/epoch_favBar_refresh.sqf | 2 +- Sources/epoch_code/init/client_init.sqf | 11 ----- .../epoch_config/Configs/CfgEpochClient.hpp | 11 ++++- 9 files changed, 59 insertions(+), 53 deletions(-) diff --git a/Sources/epoch_code/compile/interface_event_handlers/EPOCH_KeyDown.sqf b/Sources/epoch_code/compile/interface_event_handlers/EPOCH_KeyDown.sqf index a69a6222..156a0bef 100644 --- a/Sources/epoch_code/compile/interface_event_handlers/EPOCH_KeyDown.sqf +++ b/Sources/epoch_code/compile/interface_event_handlers/EPOCH_KeyDown.sqf @@ -38,12 +38,19 @@ if (_handled) exitWith{ true }; if !(alive player) exitWith{ false }; EPOCH_doRotate = false; -EPOCH_modKeys = [_shift,_ctrl,_alt]; -call epoch_favBar_modifier; + +if !(EPOCH_modKeys isequalto [_shift,_ctrl,_alt]) then { + EPOCH_modKeys = [_shift,_ctrl,_alt]; + call epoch_favBar_modifier; +}; //Favorites bar if (_dikCode in [EPOCH_keysfav1,EPOCH_keysfav2,EPOCH_keysfav3,EPOCH_keysfav4,EPOCH_keysfav5]) then { - _this call epoch_favBar_action; + if (isnull EPOCH_Target) then { + _this call epoch_favBar_action; + } else { + "Can't use while in building mode!" call epoch_message; + }; }; // increase vol diff --git a/Sources/epoch_code/compile/interface_event_handlers/EPOCH_KeyUp.sqf b/Sources/epoch_code/compile/interface_event_handlers/EPOCH_KeyUp.sqf index a2807ea7..51960002 100644 --- a/Sources/epoch_code/compile/interface_event_handlers/EPOCH_KeyUp.sqf +++ b/Sources/epoch_code/compile/interface_event_handlers/EPOCH_KeyUp.sqf @@ -34,8 +34,10 @@ _handled = false; _this call Epoch_custom_EH_KeyUp; if (_handled) exitWith{ true }; -EPOCH_modKeys = [_shift,_ctrl,_alt]; -call epoch_favBar_modifier; +if !(EPOCH_modKeys isequalto [_shift,_ctrl,_alt]) then { + EPOCH_modKeys = [_shift,_ctrl,_alt]; + call epoch_favBar_modifier; +}; //Main actions if (_dikCode == EPOCH_keysAction) then { diff --git a/Sources/epoch_code/compile/inventory/EPOCH_equip.sqf b/Sources/epoch_code/compile/inventory/EPOCH_equip.sqf index aba81336..875b89f7 100644 --- a/Sources/epoch_code/compile/inventory/EPOCH_equip.sqf +++ b/Sources/epoch_code/compile/inventory/EPOCH_equip.sqf @@ -369,7 +369,7 @@ _fnc_dropEquipAccessories = { }; player selectWeapon ((_loadout select _slot) select 0); - if (!EPOCH_fav_FastWeaponSwitching) then { + if !(["CfgEpochClient", "Fav_FastWeaponSwitching", false] call EPOCH_fnc_returnConfigEntryV2) then { player playAction "reloadMagazine"; }; _return diff --git a/Sources/epoch_code/gui/scripts/favBar/epoch_favBar_action.sqf b/Sources/epoch_code/gui/scripts/favBar/epoch_favBar_action.sqf index 1bc58adc..6b347513 100644 --- a/Sources/epoch_code/gui/scripts/favBar/epoch_favBar_action.sqf +++ b/Sources/epoch_code/gui/scripts/favBar/epoch_favBar_action.sqf @@ -13,7 +13,7 @@ Usage: none */ -private ["_item","_slot","_dsp","_kee","_tileIdx","_itemHasInteraction","_force","_errorCode","_curSlot"]; +private ["_item","_slot","_dsp","_kee","_tileIdx","_itemHasInteraction","_force","_errorCode","_curSlot","_Fav_DropIfOverflow","_Fav_FastWeaponSwitching"]; params ["_dsp","_kee"]; _tileIdx = switch (_kee) do { @@ -27,28 +27,26 @@ _tileIdx = switch (_kee) do { _item = rmx_var_favBar_current select _tileIdx; _itemHasInteraction = str(missionConfigFile >> "CfgItemInteractions" >> _item) != ""; -if (EPOCH_buildMode == 0) then { - if (_itemHasInteraction) then { - EPOCH_InteractedItem = ["",_item,""]; - [] call EPOCH_consumeItem; - EPOCH_favBar_itemConsumed = true; - } else { - _slot = _item call epoch_itemTypeSlot; - _force = if (_slot in [3,4,5,7,8,10,11,16]) then {true} else {false}; //see how it works with other items, definitely keep true for weapons - _errorCode = [_item,EPOCH_fav_DropIfOverflow,_force] call epoch_equip; - player selectWeapon _item; - - if (_slot in [3,4,5]) then { - _curSlot = _item call epoch_itemTypeSlot; - if (_curSlot == _slot && !EPOCH_fav_FastWeaponSwitching && _errorCode in [1,2]) then {player playAction "reloadMagazine";}; - }; - - if (_errorCode isEqualTo 2) then {"Not enough space, item dropped on the ground!" call epoch_message;}; - if (_errorCode isEqualTo 4 && _item != (currentWeapon player)) then {"Not enough space!" call epoch_message;}; - if (_errorCode isEqualTo 3) then {"Item not found!" call epoch_message;}; - if (_errorCode isEqualTo 5) then {"No compatible weapon found!" call epoch_message;}; - }; +if (_itemHasInteraction) then { + EPOCH_InteractedItem = ["",_item,""]; + [] call EPOCH_consumeItem; + EPOCH_favBar_itemConsumed = true; } else { - "Can't use while in building mode!" call epoch_message; + _Fav_DropIfOverflow = ["CfgEpochClient", "Fav_DropIfOverflow", false] call EPOCH_fnc_returnConfigEntryV2; + _slot = _item call epoch_itemTypeSlot; + _force = if (_slot in [3,4,5,7,8,10,11,16]) then {true} else {false}; //see how it works with other items, definitely keep true for weapons + _errorCode = [_item,_Fav_DropIfOverflow,_force] call epoch_equip; + player selectWeapon _item; + + if (_slot in [3,4,5]) then { + _curSlot = _item call epoch_itemTypeSlot; + _Fav_FastWeaponSwitching = ["CfgEpochClient", "Fav_FastWeaponSwitching", false] call EPOCH_fnc_returnConfigEntryV2; + if (_curSlot == _slot && !_Fav_FastWeaponSwitching && _errorCode in [1,2]) then {player playAction "reloadMagazine";}; + }; + + if (_errorCode isEqualTo 2) then {"Not enough space, item dropped on the ground!" call epoch_message;}; + if (_errorCode isEqualTo 4 && _item != (currentWeapon player)) then {"Not enough space!" call epoch_message;}; + if (_errorCode isEqualTo 3) then {"Item not found!" call epoch_message;}; + if (_errorCode isEqualTo 5) then {"No compatible weapon found!" call epoch_message;}; }; true diff --git a/Sources/epoch_code/gui/scripts/favBar/epoch_favBar_draw.sqf b/Sources/epoch_code/gui/scripts/favBar/epoch_favBar_draw.sqf index 0eaf9bdd..9fc28f74 100644 --- a/Sources/epoch_code/gui/scripts/favBar/epoch_favBar_draw.sqf +++ b/Sources/epoch_code/gui/scripts/favBar/epoch_favBar_draw.sqf @@ -14,23 +14,27 @@ Usage: none */ disableSerialization; -private ["_action","_idx","_bidx","_mod"]; +private ["_action","_idx","_bidx","_mod","_baritems","_Fav_BannedItems"]; params ["_action","_idx","_bidx","_mod"]; +_Fav_BannedItems = ["CfgEpochClient", "Fav_BannedItems", []] call EPOCH_fnc_returnConfigEntryV2; switch _action do { case "load": { private ["_tmp","_c","_p"]; - if (EPOCH_fav_resetOnLogin) then { - profileNamespace setVariable ["rmx_var_favBar_MNone",nil]; - profileNamespace setVariable ["rmx_var_favBar_MCtrl",nil]; - profileNamespace setVariable ["rmx_var_favBar_MShift",nil]; - profileNamespace setVariable ["rmx_var_favBar_MAlt",nil]; - }; rmx_var_favBar_MNone = profileNamespace getVariable ["rmx_var_favBar_MNone",["","","","",""]]; rmx_var_favBar_MCtrl = profileNamespace getVariable ["rmx_var_favBar_MCtrl",["","","","",""]]; rmx_var_favBar_MShift = profileNamespace getVariable ["rmx_var_favBar_MShift",["","","","",""]]; rmx_var_favBar_MAlt = profileNamespace getVariable ["rmx_var_favBar_MAlt",["","","","",""]]; + { + _baritems = _x; + { + if (_x in _Fav_BannedItems) then { + _baritems set [_foreachindex,""]; + }; + } foreach _x; + } foreach [rmx_var_favBar_MNone,rmx_var_favBar_MCtrl,rmx_var_favBar_MShift,rmx_var_favBar_MAlt]; + rmx_var_favBar_current = rmx_var_favBar_MNone; waitUntil {uiSleep 0.1; ctrlShown (["fav_equipped", 1] call epoch_getHUDCtrl)}; @@ -53,8 +57,7 @@ switch _action do { case "add": { private ["_type","_isBanned","_isAmmo","_isChemlight","_itemIsWeapon","_itemHasInteraction","_c"]; - - if (rmx_var_favBar_Item in EPOCH_fav_BannedItems) exitWith {"Item is not allowed in favorites!" call epoch_message; false}; + if (rmx_var_favBar_Item in _Fav_BannedItems) exitWith {"Item is not allowed in favorites!" call epoch_message; false}; if (rmx_var_favBar_Item in rmx_var_favBar_current) exitWith {"Item already exists in favorites!" call epoch_message; false}; //if duplicate _type = (rmx_var_favBar_Item call BIS_fnc_itemType) select 1; diff --git a/Sources/epoch_code/gui/scripts/favBar/epoch_favBar_inventory.sqf b/Sources/epoch_code/gui/scripts/favBar/epoch_favBar_inventory.sqf index 7eac545f..bfa115e5 100644 --- a/Sources/epoch_code/gui/scripts/favBar/epoch_favBar_inventory.sqf +++ b/Sources/epoch_code/gui/scripts/favBar/epoch_favBar_inventory.sqf @@ -26,7 +26,7 @@ */ private ["_display","_c","_gIdx","_g"]; -if !(EPOCH_fav_enableFavoriteBar) exitWith {false}; +if !(["CfgEpochClient", "Fav_enableFavoriteBar", true] call EPOCH_fnc_returnConfigEntryV2) exitWith {false}; disableSerialization; waitUntil {!isNull findDisplay 602}; diff --git a/Sources/epoch_code/gui/scripts/favBar/epoch_favBar_refresh.sqf b/Sources/epoch_code/gui/scripts/favBar/epoch_favBar_refresh.sqf index 675644a5..006e7faa 100644 --- a/Sources/epoch_code/gui/scripts/favBar/epoch_favBar_refresh.sqf +++ b/Sources/epoch_code/gui/scripts/favBar/epoch_favBar_refresh.sqf @@ -14,7 +14,7 @@ Usage: none */ -if !(EPOCH_fav_enableFavoriteBar) exitWith {false}; +if !(["CfgEpochClient", "Fav_enableFavoriteBar", true] call EPOCH_fnc_returnConfigEntryV2) exitWith {false}; private ["_playerItems","_equipped","_mod","_txt"]; _playerItems = itemsWithMagazines player; diff --git a/Sources/epoch_code/init/client_init.sqf b/Sources/epoch_code/init/client_init.sqf index d1871306..8f7fd5c0 100644 --- a/Sources/epoch_code/init/client_init.sqf +++ b/Sources/epoch_code/init/client_init.sqf @@ -66,17 +66,6 @@ EPOCH_favBar_itemConsumed = false; rmx_var_favBar_Item = ""; EPOCH_modKeys = [false,false,false]; -//If disabled, players will not be able to use favorite bar -EPOCH_fav_enableFavoriteBar = true; -//If enabled, same slot weapons from favorites bar are equipped instantly, otherwise reload action is played (recommended for immersion) -EPOCH_fav_FastWeaponSwitching = false; -//If enabled and inventory full, equipped weapon will be dropped on ground in favor for the new selected weapon, otherwise action will fail with message and weapon will not be equipped -EPOCH_fav_DropIfOverflow = false; -//Items that users are not allowed to pin -EPOCH_fav_BannedItems = ["FAK"]; //add items that can be abused here -//Reset all favorite items on every login (players will be required to re-add everything again). -EPOCH_fav_resetOnLogin = true; - ["EPOCH_onEachFrame", "onEachFrame", EPOCH_onEachFrame] call BIS_fnc_addStackedEventHandler; // Custom Keys diff --git a/Sources/epoch_config/Configs/CfgEpochClient.hpp b/Sources/epoch_config/Configs/CfgEpochClient.hpp index 438fbbc5..aca15c5b 100644 --- a/Sources/epoch_config/Configs/CfgEpochClient.hpp +++ b/Sources/epoch_config/Configs/CfgEpochClient.hpp @@ -91,9 +91,16 @@ class CfgEpochClient playerRevengeMinAliveTime = 900; bankTransferTime[] = {0.0006,1.2,0.06}; + // Favorite Bar + Fav_enableFavoriteBar = "true"; // If disabled, players will not be able to use favorite bar + Fav_DropIfOverflow = "false"; // If enabled and inventory full, equipped weapon will be dropped on ground in favor for the new selected weapon, otherwise action will fail with message and weapon will not be equipped + Fav_FastWeaponSwitching = "false"; // If enabled, same slot weapons from favorites bar are equipped instantly, otherwise reload action is played (recommended for immersion) + Fav_BannedItems[] = {"FAK"}; // Items that users are not allowed to pin + + // Advanced Vehicle Repair + UseAdvancedVehicleRepair = "true"; // Switch On / Off Advanced Vehicle Repair (Does not effect SuppressedCraftingItems !) SuppressedCraftingItems[] = {"VehicleRepair","VehicleRepairLg"}; // Suppresed for usage of "Advanced Vehicle Repair" - UseAdvancedVehicleRepair = "true"; - VehicleRepairs[] = { + VehicleRepairs[] = { // {Hitpoint, dmg to repair, dmg to replace, mat to repair, mat to replace} {"HitHull",0.33,0.66,"ItemScraps","ItemCorrugated"}, {"HitBody",0.33,1,"ItemScraps","ItemCorrugated"}, {"HitLFWheel",0.33,1,"VehicleRepair","SpareTire"},