Favorites bar - full release

This commit is contained in:
Raymix 2017-08-01 03:00:28 +01:00
parent 2c99640040
commit 45b6bf1fb2
18 changed files with 1197 additions and 11 deletions

View File

@ -1,7 +1,7 @@
/*
Author: Aaron Clark - EpochMod.com
Contributors:
Contributors: Raimonds Virtoss
Description:
Epoch add item with overflow
@ -20,12 +20,14 @@
_this select 1: NUMBER - (Optional) Ammo count
Returns:
BOOL
BOOL True: item was dropped nearby
False: item was added to inventory
*/
//[[[cog import generate_private_arrays ]]]
private ["_nearByHolder","_wH","_wHPos"];
private ["_dropped","_nearByHolder","_wH","_wHPos"];
//[[[end]]]
params [["_item","",[""]],["_count",1]];
_dropped = false;
for "_i" from 1 to _count do
{
if (player canAdd _item) then {
@ -47,6 +49,7 @@ for "_i" from 1 to _count do
if !(isNull _wh) then {
_wh addItemCargoGlobal [_item,1];
};
_dropped = true;
};
};
true
_dropped

View File

@ -38,6 +38,13 @@ if (_handled) exitWith{ true };
if !(alive player) exitWith{ false };
EPOCH_doRotate = false;
EPOCH_modKeys = [_shift,_ctrl,_alt];
'modifier' spawn epoch_favBar_draw;
//Favorites bar
if (_dikCode in [EPOCH_keysfav1,EPOCH_keysfav2,EPOCH_keysfav3,EPOCH_keysfav4,EPOCH_keysfav5]) then {
_this call epoch_favBar_action;
};
// increase vol
if (_ctrl && _dikCode == EPOCH_keysVolumeUp) then {

View File

@ -1,7 +1,7 @@
/*
Author: Aaron Clark - EpochMod.com
Contributors:
Contributors: Raymix
Description:
Key Up EH functions
@ -34,6 +34,9 @@ _handled = false;
_this call Epoch_custom_EH_KeyUp;
if (_handled) exitWith{ true };
EPOCH_modKeys = [_shift,_ctrl,_alt];
'modifier' spawn epoch_favBar_draw;
//Main actions
if (_dikCode == EPOCH_keysAction) then {
EPOCH_keysActionPressed = false;
@ -42,4 +45,5 @@ if (_dikCode == EPOCH_keysAction) then {
if (_dikCode in(actionKeys "Gear")) then {
EPOCH_gearKeyPressed = false;
};
_handled

View File

@ -0,0 +1,478 @@
/*
Author: Raimonds Virtoss - EpochMod.com
Contributors:
Description: Equips or un-equips item (if equipped) instantly. Item has to exist in the inventory.
to switch weapons slowly use below in your code:
player playAction "reloadMagazine";
_item - className
_drop - drop on ground if inventory full, weapons will be stripped off attachments
weapons stripped because attachments can only be added while weapon is equipped.
_forceEquip - disables un-equip and forces new item to be equipped at all times
Licence:
Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike
Github:
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_code/compile/inventory/EPOCH_equip.sqf
Usage:
[_item, false] call epoch_equip; //don't drop item if inventory full. Does not equip requested item if another item already equipped, instead un-equips existing one.
[_item, true,true] call epoch_equip; //drops item if not enough space. Removes existing weapon and equips new one.
RETURNS:
0 - fail, item not provided
1 - success
2 - success, but item dropped on ground.
3 - item not found
4 - not enough space
5 - accessory not compatible
*/
private ["_item","_drop","_forceEquip"];
params [["_item","",[""]],["_drop",false,[false]],["_forceEquip",false,[false]]];
_return = 0;
if (_item == "") exitWith {_return};
_slot = _item call epoch_itemTypeSlot;
_loadout = getUnitLoadout player;
_loadout params ["_pSlot","_sSlot","_hSlot","_uniform","_vest","_bpack","_helm","_goggles","_bino","_assigned"];
_pSlot params ["_pWeapon","_pSilencer","_pLaser","_pOptic","_pMag","_pMag2","_pBipod"];
_sSlot params ["_sWeapon","_sSilencer","_sLaser","_sOptic","_sMag","_sBipod"];
_hSlot params ["_hWeapon","_hSilencer","_hLaser","_hOptic","_hMag","_hBipod"];
_uniformItems = _uniform param [1,[]];
_vestItems = _vest param [1,[]];
_bPackItems = _bPack param [1,[]];
_binoculars = _bino param [0,[]];
_itemInInventory = _item in ((magazines player) + (items player));
_fnc_dropItem = {
private ["_item","_nearByHolder","_wH","_wHPos"];
params [["_item","",[""]],["_count",1]];
for "_i" from 1 to _count do
{
_wH = objNull;
if (isNil "_nearByHolder") then {
_nearByHolder = nearestObjects [position player,["groundWeaponHolder"],3];
};
if (_nearByHolder isEqualTo []) then {
_wHPos = player modelToWorld [0,1,0];
if (surfaceIsWater _wHPos) then {
_wHPos = ASLToATL _wHPos;
};
_wH = createVehicle ["groundWeaponHolder",_wHPos, [], 0, "CAN_COLLIDE"];
} else {
_wH = _nearByHolder select 0;
};
if !(isNull _wh) then {
_wh addItemCargoGlobal [_item,1];
};
};
};
_fnc_findItemInContainers = {
private "_item";
params ["_item"];
_container = 0;
_index = 0;
_found = false;
{
_container = _forEachIndex;
if (!isnil "_x") then {
{
_index = _forEachIndex;
_currItem = _x select 0;
if (_currItem isEqualType "") then { //if item
if (_currItem isEqualTo _item) exitWith {_found = true};
} else { //if weapon
if ((_currItem select 0) isEqualTo _item) exitWith {_found = true};
};
if _found exitWith {};
} forEach _x;
};
if _found exitWith {};
} forEach [_uniformItems,_vestItems,_bPackItems];
[_container,_index,_found];
};
_fnc_moveWeaponFromContainer = {
private ["_idx","_container","_sIdx","_dIdx"]; //_dIdx can only be 0, 1 and 2
params ["_idx","_dIdx"];
_idx params ["_container","_sIdx"];
//copy old entry
_temp = ((_loadout select (_container + 3)) select 1) select _sIdx select 0;
//delete old entry
((_loadout select (_container + 3)) select 1) deleteAt _sIdx;
//add new entry
_loadout set [_dIdx,_temp];
//save changes
player setUnitLoadout _loadout;
};
_fnc_MoveWeaponToContainer = {
private ["_container","_sIdx"]; //_sIdx can only be 0, 1 and 2
params ["_container","_sIdx"];
/*
//Delete this block if no issues.
//Commented out because increasing index alone is not enough due to unique attachement placements or ammo size
_exists = _item call _fnc_findItemInContainers;
_exists params ["_container","_idx","_found"];
if _found then {
_cnt = ((_loadout select (_container + 3)) select 1) select _idx select 1;
((_loadout select (_container + 3)) select 1) select _idx set [1,_cnt + 1];
} else {
((_loadout select (_container + 3)) select 1) append [[_loadout select _sIdx,1]];
};
*/
((_loadout select (_container + 3)) select 1) append [[_loadout select _sIdx,1]]; //cut out from above comment, looks like appending alone works great
_loadout set [_sIdx,[]];
player setUnitLoadout _loadout;
};
_fnc_canMoveToContainer = {
private "_item";
params ["_item"];
if (player canAddItemToUniform _item) exitWith {0};
if (player canAddItemToVest _item) exitWith {1};
if (player canAddItemToBackpack _item) exitWith {2};
4
};
_fnc_dropEquipWeapon = {
private ["_equipped","_slot"];
params ["_equipped","_slot"];
if (!_itemInInventory && (_item != _equipped)) exitWith {_return = 3}; //Item not found
if (_equipped != "") then { //something equipped already
if (player canAdd _equipped) then { //can we move it?
_container = _equipped call _fnc_canMoveToContainer;
if (_container != 4) then {
[_container,_slot] call _fnc_MoveWeaponToContainer;
_return = 1;
} else {
_return = 4;
};
} else { //drop it and strip from attachments?
if !(_drop) exitWith {_return = 4;}; //drop not allowed
/* //Delete this block if no issues with dropping on ground
{//Drop equipped items first
_x call _fnc_dropItem;
player removePrimaryWeaponItem _x;
}forEach primaryWeaponItems player;
{
_x call _fnc_dropItem;
}forEach primaryWeaponMagazine player;
*/
_equipped call _fnc_dropItem;
player removeWeaponGlobal _equipped;
_return = 2; //success, but dropped
};
if (_forceEquip && _return != 4) then {//Equip new weapon after old one removed
_idx = _item call _fnc_findItemInContainers;
[_idx,_slot] call _fnc_moveWeaponFromContainer;
};
} else {
//Equip weapon
_idx = _item call _fnc_findItemInContainers;
[_idx,_slot] call _fnc_moveWeaponFromContainer;
_return = 1; //success
};
};
_fnc_dropAssign= {
private ["_equipped"];
params ["_equipped"];
if (!_itemInInventory && (_item != _equipped)) exitWith {_return = 3};
if (_equipped != "") then {
if (player canAdd _equipped) then {
_container = _equipped call _fnc_canMoveToContainer;
if (_container != 4) then {
player unassignItem _equipped;
_return = 1;
} else {
_return = 4;
};
} else {
if !(_drop) exitWith {_return = 4;};
_equipped call _fnc_dropItem;
player removeItem _equipped;
_return = 2;
};
if (_forceEquip && _return != 4) then {
player assignItem _item;
};
} else {
player assignItem _item;
_return = 1;
};
};
_fnc_MoveShellToContainer = {
private ["_container"];
params ["_container"];
_temp = _loadout select 0 select 5;
_temp2 = [(_temp select 0), 1, (_temp select 1)];
if ((_temp select 1) > 0) then { //only move if ammo not empty, delete otherwise
((_loadout select (_container + 3)) select 1) append [_temp2]; //cut out from above comment, looks like appending alone works great
};
(_loadout select 0) set [5,[]];
player setUnitLoadout _loadout;
};
_fnc_moveShellFromContainer = {
private ["_idx","_container","_sIdx"]; //_dIdx can only be 0, 1 and 2
params ["_idx"];
_idx params ["_container","_sIdx","_found"];
if (_found) then {
_temp = ((_loadout select (_container + 3)) select 1) select _sIdx;
if ((_temp select 1) > 1) then {
_cnt = (((_loadout select (_container + 3)) select 1) select _sIdx) select 1;
(((_loadout select (_container + 3)) select 1) select _sIdx) set [1,_cnt - 1];
} else {
((_loadout select (_container + 3)) select 1) deleteAt _sIdx;
};
(_loadout select 0) set [5,[_temp select 0,_temp select 2]];
player setUnitLoadout _loadout;
};
};
_fnc_dropEquipShells = {
private ["_equipped"];
params ["_equipped"];
if (!_itemInInventory && (_item != _equipped)) exitWith {_return = 3};
if (_equipped != "") then {
if (player canAdd _equipped) then {
_container = _equipped call _fnc_canMoveToContainer;
if (_container != 4) then {
[_container] call _fnc_MoveShellToContainer;
_return = 1;
} else {
_return = 4;
};
} else {
if !(_drop) exitWith {_return = 4;};
_equipped call _fnc_dropItem;
(_loadout select 0) set [5,[]];
player setUnitLoadout _loadout;
_return = 2;
};
if (_forceEquip && _return != 4) then {
_idx = _item call _fnc_findItemInContainers;
[_idx,_slot] call _fnc_moveShellFromContainer;
player playAction "reloadMagazine";
};
} else {
_idx = _item call _fnc_findItemInContainers;
[_idx,_slot] call _fnc_moveShellFromContainer;
player playAction "reloadMagazine";
_return = 1;
};
_muzzle = (getArray (configFile >> "CfgWeapons" >> (primaryWeapon player) >> "muzzles"));
player selectWeapon (_muzzle select 1);
};
_fnc_findAccessorySlot = {
_item = toLower _item;
private ["_found","_slot","_accessory"];
_slot = 0;
_accessory = 0;
_found = false;
{
_slot = _foreachIndex;
_compatibleMuzzles = getArray(configFile >> "CfgWeapons" >> _x >> "WeaponSlotsInfo" >> "MuzzleSlot" >> "compatibleItems");
_compatibleCows= getArray(configFile >> "CfgWeapons" >> _x >> "WeaponSlotsInfo" >> "CowsSlot" >> "compatibleItems");
_compatiblePointers = getArray(configFile >> "CfgWeapons" >> _x >> "WeaponSlotsInfo" >> "PointerSlot" >> "compatibleItems");
_compatibleBipods = getArray(configFile >> "CfgWeapons" >> _x >> "WeaponSlotsInfo" >> "UnderBarrelSlot" >> "compatibleItems");
for "_i" from 0 to (count _compatibleMuzzles) do {
_compatibleMuzzles set [_i,toLower (_compatibleMuzzles select _i)];
};
for "_i" from 0 to (count _compatibleCows) do {
_compatibleCows set [_i,toLower (_compatibleCows select _i)];
};
for "_i" from 0 to (count _compatiblePointers) do {
_compatiblePointers set [_i,toLower (_compatiblePointers select _i)];
};
for "_i" from 0 to (count _compatibleBipods) do {
_compatibleBipods set [_i,toLower (_compatibleBipods select _i)];
};
if (_item in _compatibleMuzzles) exitWith {_found = true; _accessory = 1};
if (_item in _compatibleCows) exitWith {_found = true; _accessory = 3};
if (_item in _compatiblePointers) exitWith {_found = true; _accessory = 2};
if (_item in _compatibleBipods) exitWith {_found = true; _accessory = 6};
} forEach [(primaryWeapon player),(secondaryWeapon player),(handgunWeapon player)];
[_found,_slot,_accessory];
};
_fnc_dropEquipAccessories = {
_properties = call _fnc_findAccessorySlot;
_properties params ["_found","_slot","_accessory"];
if !_found exitWith {_return = 5};
_itemsPlayer = (primaryWeaponItems player + secondaryWeaponItems player + handgunItems player);
for "_i" from 0 to (count _itemsPlayer) do {
_itemsPlayer set [_i,toLower (_itemsPlayer select _i)];
};
_itemEquipped = _item in _itemsPlayer;
_equipped = (_loadout select _slot) select _accessory;
if (!_itemInInventory && !_itemEquipped) exitWith {_return = 3};
if (_equipped != "") then {
_equipped = (_loadout select _slot) select _accessory;
if (player canAdd _equipped) then {
(_loadout select _slot) set [_accessory,""];
player setUnitLoadout _loadout;
player addItem _equipped;
_return = 1;
} else {
if !(_drop) exitWith {_return = 4;};
_equipped call _fnc_dropItem;
(_loadout select _slot) set [_accessory,""];
player setUnitLoadout _loadout;
_return = 1;
};
if (((toLower _equipped) != (toLower _item)) || _forceEquip && _return != 4) then {
(_loadout select _slot) set [_accessory,_item];
player setUnitLoadout _loadout;
};
} else {
(_loadout select _slot) set [_accessory,_item];
player setUnitLoadout _loadout;
_return = 1;
};
player selectWeapon ((_loadout select _slot) select 0);
if (!EPOCH_fav_FastWeaponSwitching) then {
player playAction "reloadMagazine";
};
_return
/*
_slot = primary 0, second 1, hand 2
_accessory = silencer 1, laser 2, optics 3
*/
};
/*
*/
//Main
switch _slot do {
case 3:
{
[(primaryWeapon player),0] call _fnc_dropEquipWeapon;
};
case 4:
{
[(secondaryWeapon player),1] call _fnc_dropEquipWeapon;
};
case 5:
{
[(handgunWeapon player),2] call _fnc_dropEquipWeapon;
};
case 6: //accesories
{
_item call _fnc_dropEquipAccessories;
};
case 7: //toolbelt
{
if (_item in (assignedItems player)) then {
switch _item do {
case "ItemGPS":
{
//can't find a way to display it in A3
"Use [Right Ctrl] + M to toggle GPS" call epoch_message;
};
case "ItemMap":
{
openMap true;
};
case "ItemCompass":
{
//can't find a way to display it in A3
"Use [K] to toggle Compass" call epoch_message;
};
case "ItemWatch":
{
//can't find a way to display it in A3
"Use [O] to toggle watch" call epoch_message;
};
case default
{
//do stuff with radios here
if (_item in ["EpochRadio0","EpochRadio1","EpochRadio2","EpochRadio3","EpochRadio4","EpochRadio5","EpochRadio6","EpochRadio7","EpochRadio8","EpochRadio9"]) then {_item call EPOCH_custom_radioActions};
};
};
} else {
_item call _fnc_dropAssign;
};
};
case 8: //headgear
{
(headgear player) call _fnc_dropAssign;
};
case 9: //hmd
{
(hmd player) call _fnc_dropAssign;
};
case 10: //bino
{
[(binocular player),8] call _fnc_dropEquipWeapon;
};
case 11: //goggles
{
(hmd player) call _fnc_dropAssign;
};
case 12: //mines
{
if (_itemInInventory) then {
_allMuzzles = getArray (configFile >> "CfgWeapons" >> "Put" >> "Muzzles");
_muzzle = "";
_found = false;
{
_mags = getArray (configFile >> "CfgWeapons" >> "Put" >> _x >> "magazines");
_muzzle = _x;
{
if (_x isEqualTo _item) exitWith {_found = true};
} forEach _mags;
if (_found) exitWith {};
} forEach _allMuzzles;
player playActionNow "PutDown";
player selectWeapon _muzzle;
player fire [_muzzle, _muzzle, _item];
player setWeaponReloadingTime [player, _muzzle, 0];
};
};
case 16: //Grenade launcher shells.
{
_equipped = (primaryWeaponMagazine player) param [1,""];
_equipped call _fnc_dropEquipShells;
};
};
_return

View File

@ -28,6 +28,8 @@ private ["_bar","_bar_compare","_color","_colorCompare","_container","_display",
//[[[end]]]
disableSerialization;
[] spawn epoch_favBar_inventory;
EPOCH_InteractedItem = [];
params ["_unit","_targetContainer","_secondaryContainer"];
EPOCH_targetContainer = _targetContainer;

View File

@ -0,0 +1,75 @@
/*
Author: Raimonds Virtoss - EpochMod.com
Contributors:
Description: Determines which gear slot item goes into
Licence:
Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike
Github:
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_code/compile/inventory/EPOCH_itemTypeSlot.sqf
Usage: _item call epoch_itemTypeSlot;
Returns: [INT]
0 - unknown
1 - Epoch items
2 - Magazines/Ammo
3 - Primary slot
4 - Secondary slot
5 - Handgun slot
6 - Weapon attachments
7 - assigned Items (use assignItem)
8 - Headgear (assignItem works)
9 - NVGoggles (assignItem works)
10 - Binocular (assignItem doesn't work)
11 - goggles (assignItem works)
12 - Mines
13 - Vests
14 - Uniforms
15 - Backpack
16 - smoke shells
17 - Grenades
17 - Unsure about these, modify script as required, but don't change existing structure
*/
private ["_item"];
params [["_item","",[""]]];
if (_item == "") exitWith {false};
(_item call BIS_fnc_itemType) params ["_cat","_type"]; //For missing types go to https://community.bistudio.com/wiki/BIS_fnc_itemType
if (_type == "UnknownMagazine") exitWith {1};
if (_type in ["Bullet","ShotgunShell","Flare"]) exitWith {2}; //Ammo
if (_type in ["MachineGun","AssaultRifle","SniperRifle","Rifle","SubmachineGun"]) exitWith {3}; //Primary Epoch
if (_type == "Throw") exitWith {4}; //secondary epoch
if (_type == "Handgun") exitWith {5}; //handgun epoch
if (_type in ["AccessoryMuzzle","AccessoryPointer","AccessorySights","AccessoryBipod"]) exitWith {6}; //accessories
if (_type in ["Compass","GPS","Map","Radio","Watch"]) exitWith {7}; //assignItem works
if (_type == "Headgear") exitWith {8}; //assignItem works
if (_type == "NVGoggles") exitWith {9}; //assignItem works
if (_type == "Binocular") exitWith {10}; //assignItem doesn't work
if (_type == "Glasses") exitWith {11}; //assignItem doesn't work
if (_cat == "Mine") exitWith {12};
if (_type == "Vest") exitWith {13};
if (_type == "Uniform") exitWith {14};
if (_type == "Backpack") exitWith {15};
if (_type in ["Shell","SmokeShell"]) exitWith {16}; //Smoke shells for GL
if (_type == "Grenade") exitWith {17};
//unsure
if (_type in ["Magazine","Shotgun","FirstAidKit","LaserDesignator","Medikit","MineDetector","Toolkit","VehicleWeapon","Unknown","UnknownEquipment","UnknownWeapon"]) exitWith {18};
0

View File

@ -35,6 +35,11 @@ _keyMap =
["Volume + (ctrl)","EPOCH_keysVolumeUp",0x0D],
["Volume - (ctrl)","EPOCH_keysVolumeDown",0x0C],
["Favorite Bar 1", "EPOCH_keysfav1", 0x02],
["Favorite Bar 2", "EPOCH_keysfav2", 0x03],
["Favorite Bar 3", "EPOCH_keysfav3", 0x04],
["Favorite Bar 4", "EPOCH_keysfav4", 0x05],
["Favorite Bar 5", "EPOCH_keysfav5", 0x06],
["Build: Mode 1", "EPOCH_keysBuildMode1", 2],
// ["Build: Mode 2", "EPOCH_keysBuildMode2", 3],
// ["Build: Direction", "EPOCH_keysBuildDir", 4],

View File

@ -162,6 +162,9 @@ if (EPOCH_debugMode) then {
// player to player trade loop
call EPOCH_TradeLoop;
//Updates favorites bar
call epoch_favBar_refresh;
// blank out unused hud elements and prepare for next loop
_hudIndex = missionNamespace getVariable [format["EPOCH_dynHUD_%1","topRight"],1];
for "_i" from _hudIndex to 9 do {

View File

@ -0,0 +1,31 @@
/*
Author: Raimonds Virtoss - EpochMod.com
Contributors:
Description: Activates code block within switch when certain radio is used from Favorites bar
Licence:
Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike
Github:
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_code/gui/scripts/Epoch_3DctrlSpin.sqf
Usage: None by default, create your own actions here if you want
*/
switch _this do {
case "EpochRadio0":{};
case "EpochRadio1":{};
case "EpochRadio2":{};
case "EpochRadio3":{};
case "EpochRadio4":{};
case "EpochRadio5":{};
case "EpochRadio6":{};
case "EpochRadio7":{};
case "EpochRadio8":{};
case "EpochRadio9":{};
default {};
};
true

View File

@ -0,0 +1,50 @@
/*
Author: Raimonds Virtoss - EpochMod.com
Contributors:
Description: manages actions when user presses favorites key
Licence:
Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike
Github:
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_code/gui/scripts/favBar/epoch_favBar_action.sqf
Usage: none
*/
private ["_item","_slot"];
params ["_dsp","_kee"];
_tileIdx = switch (_kee) do {
case EPOCH_keysfav1:{0};
case EPOCH_keysfav2:{1};
case EPOCH_keysfav3:{2};
case EPOCH_keysfav4:{3};
case EPOCH_keysfav5:{4};
};
_item = rmx_var_favBar_current select _tileIdx;
_itemHasInteraction = str(missionConfigFile >> "CfgItemInteractions" >> _item) != "";
if (_itemHasInteraction) then {
EPOCH_InteractedItem = ["",_item,""];
[] call EPOCH_consumeItem;
} 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;};
};
true

View File

@ -0,0 +1,138 @@
/*
Author: Raimonds Virtoss - EpochMod.com
Contributors:
Description: manages drawing of favbar changes
Licence:
Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike
Github:
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_code/gui/scripts/favBar/epoch_favBar_draw.sqf
Usage: none
*/
disableSerialization;
params ["_action","_idx","_bidx","_mod"];
switch _action do {
case "load":
{
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",["","","","",""]];
rmx_var_favBar_current = rmx_var_favBar_MNone;
waitUntil {uiSleep 0.1; ctrlShown (["fav_equipped", 1] call epoch_getHUDCtrl)};
_tmp = ctrlPosition (["fav_pic_bg", 1] call epoch_getHUDCtrl);
for "_i" from 1 to 5 do {
_c = (["fav_equipped", _i] call epoch_getHUDCtrl);
_c ctrlSetText "#(rgb,8,8,3)color(1,1,1,0.7)";
_p = ctrlPosition _c;
_p set [2, (_tmp select 2)/10];
_p set [3, (_tmp select 3)/10];
_c ctrlSetPosition _p;
_c ctrlCommit 0;
};
"draw_current" call epoch_favBar_draw;
call epoch_favBar_refresh;
};
case "draw_current":
{
for "_i" from 0 to 4 do {
_c = (["fav_pic", _i+1] call epoch_getHUDCtrl);
_c ctrlSetText ((rmx_var_favBar_current select _i) call EPOCH_itemPicture);
};
};
case "add":
{
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;
_isBanned = _type in ["BombLauncher", "Cannon", "GrenadeLauncher", "Launcher", "MissileLauncher", "RocketLauncher", "Magazine", "Mortar", "Shotgun","Rocket","Grenade"];
_isAmmo = _type == "Bullet" && !(rmx_var_favBar_Item in ["EnergyPack","EnergyPackLg"]);
_isChemlight = rmx_var_favBar_Item in ["Chemlight_green","Chemlight_red","Chemlight_yellow","Chemlight_blue"];
//if (_type in ["AccessoryMuzzle","AccessoryPointer","AccessorySights","AccessoryBipod"]) exitWith {"Attachments are not supported at the moment!" call epoch_message; false};
if (_isBanned || _isAmmo || _isChemlight) exitWith {"Item cannot be added to favorites!" call epoch_message; false}; //Don't allow certain types
_itemIsWeapon = [rmx_var_favBar_Item, "CfgWeapons"] call EPOCH_fnc_isAny;
_itemHasInteraction = str(missionConfigFile >> "CfgItemInteractions" >> rmx_var_favBar_Item) != "";
if (!_itemIsWeapon && !_itemHasInteraction && rmx_var_favBar_Item == "") exitWith {"Please equip item first and try again!" call epoch_message; false}; //Workaround
rmx_var_favBar_current set [_idx,rmx_var_favBar_Item];
switch EPOCH_modKeys do {
case [true,false,false]: //shift
{
rmx_var_favBar_MShift set [_idx,rmx_var_favBar_Item];
profileNamespace setVariable ["rmx_var_favBar_MShift",rmx_var_favBar_MShift];
rmx_var_favBar_current = rmx_var_favBar_MShift;
};
case [false,true,false]: //Ctrl
{
rmx_var_favBar_MCtrl set [_idx,rmx_var_favBar_Item];
profileNamespace setVariable ["rmx_var_favBar_MCtrl",rmx_var_favBar_MCtrl];
rmx_var_favBar_current = rmx_var_favBar_MCtrl;
};
case [false,false,true]: //Alt
{
rmx_var_favBar_MAlt set [_idx,rmx_var_favBar_Item];
profileNamespace setVariable ["rmx_var_favBar_MAlt",rmx_var_favBar_MAlt];
rmx_var_favBar_current = rmx_var_favBar_MAlt;
};
default { //Any other combo or no modifier
rmx_var_favBar_MNone set [_idx,rmx_var_favBar_Item];
profileNamespace setVariable ["rmx_var_favBar_MNone",rmx_var_favBar_MNone];
rmx_var_favBar_current = rmx_var_favBar_MNone;
};
};
//draw current here
if !(rmx_var_favBar_Item isEqualTo "") then {
_c = (["fav_pic", _idx+1] call epoch_getHUDCtrl);
_c ctrlSetText (rmx_var_favBar_Item call EPOCH_itemPicture);
};
};
case "remove":
{
if (_bidx == 1) then { //if right mouse click
rmx_var_favBar_current set [_idx,""];
_c = (["fav_pic", _idx+1] call epoch_getHUDCtrl);
_c ctrlSetText "";
};
};
case "modifier":
{
switch EPOCH_modKeys do {
case [true,false,false]: //shift
{
rmx_var_favBar_current = rmx_var_favBar_MShift;
};
case [false,true,false]: //Ctrl
{
rmx_var_favBar_current = rmx_var_favBar_MCtrl;
};
case [false,false,true]: //Alt
{
rmx_var_favBar_current = rmx_var_favBar_MAlt;
};
default { //Any other combo or no modifier
rmx_var_favBar_current = rmx_var_favBar_MNone;
};
};
'draw_current' call epoch_favBar_draw;
call epoch_favBar_refresh;
};
default {systemChat "fail"};
};
for "_i" from 1 to 5 do {
(["fav_pic_bg", _i] call epoch_getHUDCtrl) ctrlSetText "x\addons\a3_epoch_code\Data\UI\favbar\fav_bg.paa";
};

View File

@ -0,0 +1,32 @@
/*
Author: Raimonds Virtoss - EpochMod.com
Contributors:
Description: no use outside favbar probably. Weapons return display names only, so this hack allows getting their className
Licence:
Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike
Github:
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_code/gui/scripts/favBar/epoch_favBar_getGearItem.sqf
Usage: none
RETURNS: classname for item in inventory
*/
(_this select 1 select 0) params ["_dispName","_idx","_className"];
_return = "";
if (_className isEqualTo "") then { //do itemsWithMagazines instead
{
_txt = getText (configFile >> "CfgWeapons" >> _x >> "displayName");
if (_txt isEqualTo _dispName) exitWith {_return = _x};
} forEach (items player);
} else {
_return = _className;
};
_return

View File

@ -0,0 +1,136 @@
/*
Author: Raimonds Virtoss - EpochMod.com
Contributors:
Description: Returns className of an item or weapon from inventory IDC
This function has no practical use outside of Favorite Bar menu due to IDC used as a case
Licence:
Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike
Github:
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_code/gui/scripts/favBar/epoch_favBar_getItemByIDC.sqf
Usage: none
*/
//switch
_item = switch (_this) do {
case 610: //Primary
{
primaryWeapon player
};
case 620: //Primary silencer
{
(primaryWeaponItems player) select 0
};
case 621: //Primary Optic (TWS)
{
(primaryWeaponItems player) select 2
};
case 622: //Primary Flashlight/Laser
{
(primaryWeaponItems player) select 1
};
case 641: //Primary bipod
{
(primaryWeaponItems player) select 3
};
case 644: //Primary Grenade shell
{
_ammo = primaryWeaponMagazine player;
_cnt = count _ammo;
if (_cnt > 0) then {
if (_cnt > 1) then {
_ammo select 1
} else {
_ammo select 0
};
} else {""};
};
case 623: //Primary Magazine
{
_ammo = primaryWeaponMagazine player;
_cnt = count _ammo;
if (_cnt > 0) then {
_ammo select 0
} else {""};
};
case 611: //Secondary
{
secondaryWeapon player
};
case 624: //Secondary silencer
{
(secondaryWeaponItems player) select 0
};
case 625: //Secondary Optic (TWS)
{
(secondaryWeaponItems player) select 2
};
case 626: //Secondary Flashlight/Laser
{
(secondaryWeaponItems player) select 1
};
case 642: //Secondary bipod
{
(secondaryWeaponItems player) select 3
};
case 627: //Secondary Magazine
{
_ammo = secondaryWeaponMagazine player;
_cnt = count _ammo;
if (_cnt > 0) then {
_ammo select 0
} else {""};
};
case 612: //Handgun
{
handgunWeapon player
};
case 628: //Handgun silencer
{
(handgunItems player) select 0
};
case 629: //Handgun Optic (TWS)
{
(handgunItems player) select 2
};
case 630: //Handgun Flashlight/Laser
{
(handgunItems player) select 1
};
case 643: //Handgun bipod
{
(handgunItems player) select 3
};
case 631: //Handgun Magazine
{
_ammo = handgunMagazine player;
_cnt = count _ammo;
if (_cnt > 0) then {
_ammo select 0
} else {""};
};
case 6240: //headgear
{
headgear player;
};
case 6216: //goggles
{
goggles player;
};
case 6217: //hmd
{
hmd player;
};
case 6238: //goggles
{
binocular player;
};
default {""};
};
_item

View File

@ -0,0 +1,104 @@
/*
Author: Raimonds Virtoss - EpochMod.com
Contributors:
Description: loaded every time Gear menu is opened
Developer's FYI:
To increase amount of favorite bars you need to edit:
CfgDynamicHUD.hpp - increase array sizes for fav_*, maybe even width/height
EPOCH_clientKeyMap.sqf - add keys to keymap array
EPOCH_keyDown.sqf - add new keys to dikCode check array
epoch_favBar_action.sqf - add tile indexes for new keymaps
epoch_favBar_draw.sqf - increase FOR loop accordingly
epoch_favBar_refresh.sqf - increase FOR loop accordingly
THIS script - increase FOR loop accordingly
Licence:
Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike
Github:
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_code/gui/scripts/favBar/epoch_favBar_inventory.sqf
Usage: none
*/
//TODO: Maybe - spawn IDC cleanup thread, wait until display closes
if !(EPOCH_fav_enableFavoriteBar) exitWith {false};
disableSerialization;
waitUntil {!isNull findDisplay 602};
_display = (findDisplay 602);
_display displayAddEventHandler ["MouseButtonUp","[] spawn {rmx_var_fav_selected = false}"];
rmx_var_fav_selected = false;
{
_c = _display displayCtrl _x;
_c ctrlAddEventHandler ["LBDrag","rmx_var_favBar_Item = (_this call epoch_favBar_getGearItem); rmx_var_fav_selected = true"];
} forEach [619,638,633];
// call epoch_getGearItem;
//(_this select 1 select 0 select 2)
{
_c = _display displayCtrl _x;
_c ctrlAddEventHandler ["MouseButtonDown",(format ["'modifier' spawn epoch_favBar_draw; rmx_var_favBar_Item = %1 call epoch_favBar_getItemByIDC; rmx_var_fav_selected = true",_x])];
} forEach [610,620,641,622,621,644,623,611,624,642,626,625,627,612,628,643,630,629,631,6240,6216,6217,6238];
_gIdx = 0;
{
if ((_x select 0) isEqualTo "fav_pic") exitWith {_gIdx = _forEachIndex};
} forEach rmx_var_dynamicHUD_groupCTRL;
_g = _display ctrlCreate ["rmx_rscControlsGroup",125342];
_g ctrlSetPosition (ctrlPosition (rmx_var_dynamicHUD_groups select _gIdx));
_g ctrlCommit 0;
for "_i" from 0 to 4 do {
_c = _display ctrlCreate ["RscPictureKeepAspect",125342+_i,_g];
_c ctrlSetPosition (ctrlPosition (["fav_pic", _i + 1] call epoch_getHUDCtrl));
_c ctrlSetText "#(rgb,8,8,3)color(1,1,1,0.1)";
_c ctrlCommit 0;
_c ctrlSetEventHandler ["MouseButtonUp",format["['remove',%1,(_this select 1)] call epoch_favBar_draw;",_i]];
_c ctrlSetEventHandler ["MouseEnter",format ["if (rmx_var_fav_selected) then {['add',%1] call epoch_favBar_draw; rmx_var_fav_dragging = false}",_i]];
_c ctrlEnable true;
_c = _display ctrlCreate ["RscPictureKeepAspect",125342+_i,_g];
_c ctrlSetPosition (ctrlPosition (["fav_pic_bg", _i + 1] call epoch_getHUDCtrl));
_c ctrlSetText "x\addons\a3_epoch_code\Data\UI\favbar\fav_bg2.paa";
_c ctrlSetTextColor [0,0,0,0.5];
_c ctrlCommit 0;
};
for "_i" from 1 to 5 do {
(["fav_keymap", _i] call epoch_getHUDCtrl) ctrlShow true;
(["fav_pic_bg", _i] call epoch_getHUDCtrl) ctrlShow true;
};
/*
{
_crl = _display displayCtrl _x;
_c = _display ctrlCreate ["RscText",1253422+_forEachIndex];
_c ctrlSetPosition (ctrlPosition _crl);
_c ctrlSetText (format ["%2",ctrlClassName _crl, _x]);
_c ctrlCommit 0;
}foreach [610,620,641,622,621,644,623,611,624,642,626,625,627,612,628,643,630,629,631,6240,6216,6217,6238];
*/
//Listboxes?
//6325,1241
//619,638,633

View File

@ -0,0 +1,61 @@
/*
Author: Raimonds Virtoss - EpochMod.com
Contributors:
Description: This is called by event1.sqf every 1 second as well as every time mod key is pressed.
Licence:
Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike
Github:
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_code/gui/scripts/favBar/epoch_favBar_refresh.sqf
Usage: none
*/
if !(EPOCH_fav_enableFavoriteBar) exitWith {false};
_playerItems = itemsWithMagazines player;
_equipped = [primaryWeapon player, secondaryWeapon player, handgunWeapon player, headgear player, goggles player, hmd player, binocular player];
_equipped append (primaryWeaponItems player + primaryWeaponMagazine player + secondaryWeaponItems player + secondaryWeaponMagazine player + handgunItems player + handgunMagazine player);
_equipped append (assignedItems player);
_mod = switch EPOCH_modKeys do {
case [true,false,false]: {"Shift + "};
case [false,true,false]: {"Ctrl + "};
case [false,false,true]: {"Alt + "};
default {""};
};
for "_i" from 1 to 5 do {
_txt = missionNamespace getVariable [format["EPOCH_keysfav%1",_i],"N/A"];
(["fav_keymap", _i] call epoch_getHUDCtrl) ctrlSetText (_mod + (_txt call BIS_fnc_keyCode));
};
{
if (_x != "") then {
(["fav_pic_bg", _forEachIndex + 1] call epoch_getHUDCtrl) ctrlShow true;
(["fav_keymap", _forEachIndex + 1] call epoch_getHUDCtrl) ctrlShow true;
if (_x in _playerItems) then {
(["fav_pic", _forEachIndex + 1] call epoch_getHUDCtrl) ctrlSetTextColor [1,1,1,1];
} else {
(["fav_pic", _forEachIndex + 1] call epoch_getHUDCtrl) ctrlSetTextColor [1,0,0,1];
};
if (_x in _equipped) then {
(["fav_pic", _forEachIndex + 1] call epoch_getHUDCtrl) ctrlSetTextColor [1,1,1,1];
(["fav_equipped", _forEachIndex + 1] call epoch_getHUDCtrl) ctrlShow true;
} else {
(["fav_equipped", _forEachIndex + 1] call epoch_getHUDCtrl) ctrlShow false;
};
} else {
(["fav_equipped", _forEachIndex + 1] call epoch_getHUDCtrl) ctrlShow false;
if (isNull findDisplay 602) then {
(["fav_pic_bg", _forEachIndex + 1] call epoch_getHUDCtrl) ctrlShow false;
(["fav_keymap", _forEachIndex + 1] call epoch_getHUDCtrl) ctrlShow false;
};
};
}forEach rmx_var_favBar_current;

View File

@ -60,6 +60,17 @@ rmx_var_drag_MouseDown = false;
rmx_var_dynamicHUD_groups = [];
rmx_var_dynamicHUD_groupCTRL = [];
//Favorites bar
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;
["EPOCH_onEachFrame", "onEachFrame", EPOCH_onEachFrame] call BIS_fnc_addStackedEventHandler;
// Custom Keys
@ -76,4 +87,11 @@ call EPOCH_clientInit;
[] execFSM "epoch_code\system\SPVEH.fsm";
[] execFSM "epoch_code\system\player_login.fsm";
//Start processing right after Loading screen is done and game has started
[] spawn {
waitUntil {!isNull (findDisplay 46) && (!isNil "EPOCH_loadingScreenDone")};
'load' call epoch_favBar_draw;
};
true

View File

@ -168,6 +168,8 @@ class CfgClientFunctions
class maxArmorInit {};
class initUI {};
class refeshUI {};
class equip {};
class itemTypeSlot {};
};
class servicepoint
{
@ -192,6 +194,7 @@ class CfgClientFunctions
class custom_EH_Take {};
class custom_KeyMap {};
class custom_OnEachFrame {};
class custom_radioActions {};
};
class messaging
{
@ -316,6 +319,15 @@ class CfgClientFunctions
class gui3DModelPos {};
class gui3DModelPosEH {};
};
class favBar {
file = "epoch_code\gui\scripts\favBar";
class favBar_draw {};
class favBar_refresh {};
class favBar_action{};
class favBar_getItemByIDC {};
class favBar_inventory {};
class favBar_getGearItem {};
};
};
};

View File

@ -45,7 +45,7 @@ class rmx_dynamicHUD
{
class topRight
{
classname = "RscPicture";
classname = "RscPictureKeepAspect";
defaultPos = 2;
defaultPopulate = 1;
arraySize = 10;
@ -56,14 +56,41 @@ class rmx_dynamicHUD
angle[] = {-5,0.5,0.5,0.5};
scale[] = {1,0.05};
};
class botcenter
class fav_pic_bg
{
classname = "RscPictureKeepAspect";
defaultPos = 7;
defaultPopulate = 0;
arraySize = 5;
width = 4;
height = 4;
};
class fav_pic
{
classname = "RscPictureKeepAspect";
defaultPos = 7;
defaultPopulate = 0;
arraySize = 5;
width = 4;
height = 4;
};
class fav_equipped
{
classname = "RscPicture";
defaultPos = 7;
defaultPopulate = 4;
arraySize = 9;
width = 5;
height = 5;
defaultPopulate = 0;
arraySize = 5;
width = 4;
height = 4;
};
class fav_keymap
{
classname = "fav_keymap";
defaultPos = 7;
defaultPopulate = 0;
arraySize = 5;
width = 4;
height = 1;
};
};