Epoch/Sources/epoch_code/compile/inventory/EPOCH_itemInteractClick.sqf

137 lines
5.3 KiB
Plaintext
Raw Normal View History

2015-12-16 17:38:25 +00:00
/*
Dynamic inventory sub menu
By Aaron Clark - Epoch Mod
2015-12-16 17:38:25 +00:00
*/
2016-09-01 00:29:08 +00:00
//[[[cog import generate_private_arrays ]]]
2017-07-31 16:28:18 +00:00
private ["_CfgEpochClient","_Suppressed","_activeControl","_bg","_btn_arr","_buffer","_buttonTXT","_button_gen","_button_texts","_cfgItemInteractions","_config","_control","_data","_display","_interactActions","_interactOption","_magCount","_pos","_start_idc","_type","_y2d"];
2016-09-01 00:29:08 +00:00
//[[[end]]]
_button_texts = [];
_activeControl = uiNamespace getVariable ["EPOCH_active_button_control", controlNull];
if (!isNull _activeControl) then {
_activeControl ctrlShow false;
ctrlDelete _activeControl;
};
Release 0.3.8 (#502) * first build for 0.3.8 * 0.3.8.0190 * 0.3.8.0202 * 0.3.8.0213 * 0.3.7.0214 * 0.3.8.0222 * 0.3.8.0246 * 0.3.8.0247 fixed typo * 0.3.8.0249 more fixes for server compiler * 0.3.8.0256 * add build number and simple batch file for packing * match build number with internal * add build numbers to server pbo's and mission files also reworked build script for more options * 0.3.8.0261 * 0.3.8.0261 * 0.3.8.0283 * 0.3.8.0284 * changelog * 0.3.8.0307 * 0.3.8.0311 * remove old BEC plugin * update redis-server.exe to latest build and full config * 0.3.8.0314 * 0.3.8.0315 * inverse logic This should correctly prevent spawning these units nearby jammer or protection zones * use pushbackUnique here * optimized loot function by using selectRandom instead of slower sqf logic * 0.3.8.0316 * make use of new getDir functionality instead of BIS fnc * add lower disconnect value to server.cfg * use new getpos functionality * 0.3.8.0317 * 0.3.8.0319 * 0.3.8.0327 * 0.3.8.0338 changelog update tba * changelog * 0.3.8.0341 * BE update * 0.3.8.0353 * changelog * removed duplicates * 0.3.8.0355 fixed error in getIDC * 0.3.8.0356 revert to BIS_fnc_param as params threw errors * 0.3.8.0357 fixes for #496 #497 * 0.3.8.0359 fixed #497 fixed #496 * 0.3.8.0365 * 0.3.8.0371 * 0.3.8.0373 * 0.3.8.0379 * 0.3.8.0381 * 0.3.8.0386 * 0.3.8.0393 * 0.3.8.0395 * 0.3.8.0396 * 0.3.8.0397 * 0.3.8.0406 * 0.3.8.0409 * 0.3.8.0410 loot balance suppress error in spawnloot make near object check based on building size * 0.3.8.0412 * 0.3.8.0414 removed classes with scope 0 test remove loot trash on gear for #498 fixed #501 * 0.3.8.0415 * same
2016-04-08 20:21:46 +00:00
_this call EPOCH_selectInventoryItem;
_data = EPOCH_InteractedItem select 1;
2015-09-14 20:55:36 +00:00
_interactOption = 0;
_buttonTXT = "";
2015-12-29 18:22:24 +00:00
_magCount = 1;
_interactActions = [];
Release 0.3.8 (#502) * first build for 0.3.8 * 0.3.8.0190 * 0.3.8.0202 * 0.3.8.0213 * 0.3.7.0214 * 0.3.8.0222 * 0.3.8.0246 * 0.3.8.0247 fixed typo * 0.3.8.0249 more fixes for server compiler * 0.3.8.0256 * add build number and simple batch file for packing * match build number with internal * add build numbers to server pbo's and mission files also reworked build script for more options * 0.3.8.0261 * 0.3.8.0261 * 0.3.8.0283 * 0.3.8.0284 * changelog * 0.3.8.0307 * 0.3.8.0311 * remove old BEC plugin * update redis-server.exe to latest build and full config * 0.3.8.0314 * 0.3.8.0315 * inverse logic This should correctly prevent spawning these units nearby jammer or protection zones * use pushbackUnique here * optimized loot function by using selectRandom instead of slower sqf logic * 0.3.8.0316 * make use of new getDir functionality instead of BIS fnc * add lower disconnect value to server.cfg * use new getpos functionality * 0.3.8.0317 * 0.3.8.0319 * 0.3.8.0327 * 0.3.8.0338 changelog update tba * changelog * 0.3.8.0341 * BE update * 0.3.8.0353 * changelog * removed duplicates * 0.3.8.0355 fixed error in getIDC * 0.3.8.0356 revert to BIS_fnc_param as params threw errors * 0.3.8.0357 fixes for #496 #497 * 0.3.8.0359 fixed #497 fixed #496 * 0.3.8.0365 * 0.3.8.0371 * 0.3.8.0373 * 0.3.8.0379 * 0.3.8.0381 * 0.3.8.0386 * 0.3.8.0393 * 0.3.8.0395 * 0.3.8.0396 * 0.3.8.0397 * 0.3.8.0406 * 0.3.8.0409 * 0.3.8.0410 loot balance suppress error in spawnloot make near object check based on building size * 0.3.8.0412 * 0.3.8.0414 removed classes with scope 0 test remove loot trash on gear for #498 fixed #501 * 0.3.8.0415 * same
2016-04-08 20:21:46 +00:00
_config = (configfile >> "CfgWeapons" >> _data);
2017-07-31 16:28:18 +00:00
_CfgEpochClient = 'CfgEpochClient' call EPOCH_returnConfig;
_Suppressed = getarray (_CfgEpochClient >> "SuppressedCraftingItems");
// _cfgItemInteractions = (('CfgItemInteractions' call EPOCH_returnConfig) >> _data);
_cfgItemInteractions = ["CfgItemInteractions", _data] call EPOCH_returnConfigV2;
Release 0.3.8 (#502) * first build for 0.3.8 * 0.3.8.0190 * 0.3.8.0202 * 0.3.8.0213 * 0.3.7.0214 * 0.3.8.0222 * 0.3.8.0246 * 0.3.8.0247 fixed typo * 0.3.8.0249 more fixes for server compiler * 0.3.8.0256 * add build number and simple batch file for packing * match build number with internal * add build numbers to server pbo's and mission files also reworked build script for more options * 0.3.8.0261 * 0.3.8.0261 * 0.3.8.0283 * 0.3.8.0284 * changelog * 0.3.8.0307 * 0.3.8.0311 * remove old BEC plugin * update redis-server.exe to latest build and full config * 0.3.8.0314 * 0.3.8.0315 * inverse logic This should correctly prevent spawning these units nearby jammer or protection zones * use pushbackUnique here * optimized loot function by using selectRandom instead of slower sqf logic * 0.3.8.0316 * make use of new getDir functionality instead of BIS fnc * add lower disconnect value to server.cfg * use new getpos functionality * 0.3.8.0317 * 0.3.8.0319 * 0.3.8.0327 * 0.3.8.0338 changelog update tba * changelog * 0.3.8.0341 * BE update * 0.3.8.0353 * changelog * removed duplicates * 0.3.8.0355 fixed error in getIDC * 0.3.8.0356 revert to BIS_fnc_param as params threw errors * 0.3.8.0357 fixes for #496 #497 * 0.3.8.0359 fixed #497 fixed #496 * 0.3.8.0365 * 0.3.8.0371 * 0.3.8.0373 * 0.3.8.0379 * 0.3.8.0381 * 0.3.8.0386 * 0.3.8.0393 * 0.3.8.0395 * 0.3.8.0396 * 0.3.8.0397 * 0.3.8.0406 * 0.3.8.0409 * 0.3.8.0410 loot balance suppress error in spawnloot make near object check based on building size * 0.3.8.0412 * 0.3.8.0414 removed classes with scope 0 test remove loot trash on gear for #498 fixed #501 * 0.3.8.0415 * same
2016-04-08 20:21:46 +00:00
if (isClass (_config)) then {
_type = getNumber (_config >> "type");
2016-05-06 20:30:10 +00:00
_interactOption = getNumber (_cfgItemInteractions >> "interactAction");
_buttonTXT = getText(_cfgItemInteractions >> "interactText");
_interactActions = getArray(_cfgItemInteractions >> "interactActions");
2015-09-14 20:55:36 +00:00
} else {
2017-07-31 16:28:18 +00:00
if (EPOCH_AdvancedVehicleRepair_Enabled && _data in ["VehicleRepair","VehicleRepairLg"]) exitwith {};
Release 0.3.8 (#502) * first build for 0.3.8 * 0.3.8.0190 * 0.3.8.0202 * 0.3.8.0213 * 0.3.7.0214 * 0.3.8.0222 * 0.3.8.0246 * 0.3.8.0247 fixed typo * 0.3.8.0249 more fixes for server compiler * 0.3.8.0256 * add build number and simple batch file for packing * match build number with internal * add build numbers to server pbo's and mission files also reworked build script for more options * 0.3.8.0261 * 0.3.8.0261 * 0.3.8.0283 * 0.3.8.0284 * changelog * 0.3.8.0307 * 0.3.8.0311 * remove old BEC plugin * update redis-server.exe to latest build and full config * 0.3.8.0314 * 0.3.8.0315 * inverse logic This should correctly prevent spawning these units nearby jammer or protection zones * use pushbackUnique here * optimized loot function by using selectRandom instead of slower sqf logic * 0.3.8.0316 * make use of new getDir functionality instead of BIS fnc * add lower disconnect value to server.cfg * use new getpos functionality * 0.3.8.0317 * 0.3.8.0319 * 0.3.8.0327 * 0.3.8.0338 changelog update tba * changelog * 0.3.8.0341 * BE update * 0.3.8.0353 * changelog * removed duplicates * 0.3.8.0355 fixed error in getIDC * 0.3.8.0356 revert to BIS_fnc_param as params threw errors * 0.3.8.0357 fixes for #496 #497 * 0.3.8.0359 fixed #497 fixed #496 * 0.3.8.0365 * 0.3.8.0371 * 0.3.8.0373 * 0.3.8.0379 * 0.3.8.0381 * 0.3.8.0386 * 0.3.8.0393 * 0.3.8.0395 * 0.3.8.0396 * 0.3.8.0397 * 0.3.8.0406 * 0.3.8.0409 * 0.3.8.0410 loot balance suppress error in spawnloot make near object check based on building size * 0.3.8.0412 * 0.3.8.0414 removed classes with scope 0 test remove loot trash on gear for #498 fixed #501 * 0.3.8.0415 * same
2016-04-08 20:21:46 +00:00
_config = (configfile >> "CfgMagazines" >> _data);
_type = getNumber (_config >> "type");
2016-05-06 20:30:10 +00:00
_interactOption = getNumber (_cfgItemInteractions >> "interactAction");
_buttonTXT = getText(_cfgItemInteractions >> "interactText");
Release 0.3.8 (#502) * first build for 0.3.8 * 0.3.8.0190 * 0.3.8.0202 * 0.3.8.0213 * 0.3.7.0214 * 0.3.8.0222 * 0.3.8.0246 * 0.3.8.0247 fixed typo * 0.3.8.0249 more fixes for server compiler * 0.3.8.0256 * add build number and simple batch file for packing * match build number with internal * add build numbers to server pbo's and mission files also reworked build script for more options * 0.3.8.0261 * 0.3.8.0261 * 0.3.8.0283 * 0.3.8.0284 * changelog * 0.3.8.0307 * 0.3.8.0311 * remove old BEC plugin * update redis-server.exe to latest build and full config * 0.3.8.0314 * 0.3.8.0315 * inverse logic This should correctly prevent spawning these units nearby jammer or protection zones * use pushbackUnique here * optimized loot function by using selectRandom instead of slower sqf logic * 0.3.8.0316 * make use of new getDir functionality instead of BIS fnc * add lower disconnect value to server.cfg * use new getpos functionality * 0.3.8.0317 * 0.3.8.0319 * 0.3.8.0327 * 0.3.8.0338 changelog update tba * changelog * 0.3.8.0341 * BE update * 0.3.8.0353 * changelog * removed duplicates * 0.3.8.0355 fixed error in getIDC * 0.3.8.0356 revert to BIS_fnc_param as params threw errors * 0.3.8.0357 fixes for #496 #497 * 0.3.8.0359 fixed #497 fixed #496 * 0.3.8.0365 * 0.3.8.0371 * 0.3.8.0373 * 0.3.8.0379 * 0.3.8.0381 * 0.3.8.0386 * 0.3.8.0393 * 0.3.8.0395 * 0.3.8.0396 * 0.3.8.0397 * 0.3.8.0406 * 0.3.8.0409 * 0.3.8.0410 loot balance suppress error in spawnloot make near object check based on building size * 0.3.8.0412 * 0.3.8.0414 removed classes with scope 0 test remove loot trash on gear for #498 fixed #501 * 0.3.8.0415 * same
2016-04-08 20:21:46 +00:00
_magCount = getNumber (_config >> "count");
_interactActions = getArray(_cfgItemInteractions >> "interactActions");
2015-09-14 20:55:36 +00:00
};
// legacy
2015-09-14 20:55:36 +00:00
if (_buttonTXT != "") then {
_button_texts pushBack [_buttonTXT];
};
// additional interactActions
if !(_interactActions isEqualTo []) then {
{
_button_texts pushBack _x;
} forEach _interactActions;
};
// ammo repack
if (_magCount > 1) then {
_button_texts pushBack ["REPACK","[0] call EPOCH_consumeItem;"];
2015-09-14 20:55:36 +00:00
};
2015-09-28 22:04:43 +00:00
_config = 'CfgCrafting' call EPOCH_returnConfig;
2017-07-31 16:28:18 +00:00
if (isClass (_config >> _data) && !(_data in _Suppressed)) then {
EPOCH_CraftingItem = EPOCH_InteractedItem select 0;
_button_texts pushBack ["CRAFT","EPOCH_CraftingItem call EPOCH_crafting_load;"];
}
else {
EPOCH_CraftingItem = "";
2015-09-14 20:55:36 +00:00
};
2015-10-12 19:15:10 +00:00
/* Moved to DynaMenu
2017-07-03 20:59:40 +00:00
_config = 'CfgVehicleUpgrades' call EPOCH_returnConfig;
if (isClass (_config >> _data)) then {
{
if (isclass (_config >> _data >> (typeof _x))) exitwith {
EPOCH_UpgradeVehicle = [_data,_x];
_reqMaterials = getArray (_config >> _data >> (typeof _x) >> "ReqMaterials");
_itemtxt = "required: ";
{
_itemtxt = _itemtxt + str (_x select 0) + ((_x select 1) call EPOCH_itemDisplayName) + ", ";
} foreach _reqMaterials;
_txt1 = format ["Upgrade %1", (typeof _x) call EPOCH_itemDisplayName];
_txt2 = "EPOCH_UpgradeVehicle call EPOCH_Client_UpgradeVehicle;";
_button_texts pushBack [_txt1,_txt2];
};
} foreach (nearestobjects [player,["Landvehicle","SHIP","AIR","TANK"],10]);
};
*/
2017-07-03 20:59:40 +00:00
if !(_button_texts isEqualTo []) then {
_display = ctrlParent (_this select 0);
_pos = getMousePosition;
_control = _display ctrlCreate ["RscControlsGroupNoScrollbars", 5678910];
uiNamespace setVariable ["EPOCH_active_button_control", _control];
_control ctrlSetPosition [(_pos select 0)-0.03,(_pos select 1)-0.03,1,1];
_control ctrlCommit 0;
_bg = _display ctrlCreate ["RscButtonTextOnly", 12349,_control];
_bg ctrlSetPosition [0,0,1,1];
_bg ctrlCommit 0;
_bg ctrlAddEventHandler ["MouseEnter",{
_activeControl = uiNamespace getVariable ["EPOCH_active_button_control", controlNull];
if !(isNull _activeControl) then {
_activeControl ctrlShow false;
};
}];
_buffer = _display ctrlCreate ["RscButtonTextOnly", 12345,_control];
_buffer ctrlSetPosition [0.02,0.02,0.25,0.0625 + (0.0625 * (count _button_texts))];
_buffer ctrlAddEventHandler ["ButtonClick",{
_activeControl = uiNamespace getVariable ["EPOCH_active_button_control", controlNull];
if !(isNull _activeControl) then {
_activeControl ctrlShow false;
};
}];
_buffer ctrlCommit 0;
_y2d = 0.06;
_btn_arr = [];
_start_idc = 12346;
{
_x params [["_btn_text","EXAMINE"],["_btn_code","[] call EPOCH_consumeItem;"]];
_button_gen = _display ctrlCreate ["RscButtonMenu", _start_idc,_control];
_start_idc = _start_idc + 1;
_button_gen ctrlSetPosition [0.06,_y2d,0.20,0.06];
_button_gen ctrlSetText _btn_text;
_button_gen ctrlCommit 0;
_button_gen ctrlSetEventHandler ["ButtonClick",_btn_code + "(uiNamespace getVariable [""EPOCH_active_button_control"", controlNull]) ctrlShow false;"];
_y2d = _y2d + 0.0625;
_btn_arr pushBack _button_gen;
} forEach _button_texts;
reverse _btn_arr;
uiNamespace setVariable ["EPOCH_active_controls", ([_control,_bg,_buffer] + _btn_arr) ];
// uiNamespace setVariable ["EPOCH_active_buttons", _btn_arr ];
{ctrlSetFocus _x} forEach (uiNamespace getVariable ["EPOCH_active_controls", []]);
};