2016-04-08 20:21:46 +00:00
|
|
|
/*
|
|
|
|
Author: Raimonds Virtoss - EpochMod.com
|
|
|
|
|
2017-08-21 12:26:13 +00:00
|
|
|
Contributors: He-Man
|
2016-04-08 20:21:46 +00:00
|
|
|
|
|
|
|
Description:
|
|
|
|
DESC-TBA
|
|
|
|
|
|
|
|
Licence:
|
|
|
|
Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike
|
|
|
|
|
|
|
|
Github:
|
2016-06-13 16:54:19 +00:00
|
|
|
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_code/gui/scripts/dynamenu/Epoch_dynamicMenu.sqf
|
2016-04-08 20:21:46 +00:00
|
|
|
*/
|
2015-10-28 15:16:00 +00:00
|
|
|
disableSerialization;
|
2016-09-01 02:19:23 +00:00
|
|
|
//[[[cog import generate_private_arrays ]]]
|
2017-08-21 12:26:13 +00:00
|
|
|
private ["_iconcode","_action","_arr","_buttonSettings","_c","_cfg","_checkConfigs","_config","_configs","_dName","_display","_entries","_hasTarget","_icon","_in","_selfOrTarget","_subclasses","_tTip","_tooltip","_tooltipcode","_x"];
|
2016-09-01 02:19:23 +00:00
|
|
|
//[[[end]]]
|
2016-04-08 20:21:46 +00:00
|
|
|
_in = [_this, 0, "",[""]] call BIS_fnc_param;
|
2015-12-07 16:24:52 +00:00
|
|
|
|
2015-10-28 15:16:00 +00:00
|
|
|
_display = findDisplay 66600;
|
|
|
|
_cfg = "CfgActionMenu" call EPOCH_returnConfig;
|
|
|
|
_arr = [];
|
|
|
|
_buttonSettings = [];
|
|
|
|
|
|
|
|
/** Variable Defines **/
|
|
|
|
{
|
|
|
|
call compile (format ["%1 = %2;",configName _x,getText _x]);
|
|
|
|
} count (configProperties [(_cfg >> "variableDefines"),"true",false]);
|
|
|
|
|
|
|
|
_hasTarget = !(dyna_cursorTarget isEqualTo objNull);
|
|
|
|
|
2016-04-08 20:21:46 +00:00
|
|
|
if (isNull _display && dialog) exitWith {false call Epoch_dynamicMenuCleanup; false};
|
2015-10-28 15:16:00 +00:00
|
|
|
|
|
|
|
if (isNull _display) then {
|
2017-10-02 16:49:27 +00:00
|
|
|
if!(visibleMap)then{
|
|
|
|
if (_hasTarget) then {
|
|
|
|
createDialog "rmx_dynamenu";
|
|
|
|
} else {
|
|
|
|
findDisplay 46 createDisplay "rmx_dynamenu";
|
|
|
|
}
|
2015-10-28 15:16:00 +00:00
|
|
|
} else {
|
2017-10-02 16:49:27 +00:00
|
|
|
findDisplay 12 createDisplay "rmx_dynamenu";
|
2015-10-28 15:16:00 +00:00
|
|
|
};
|
|
|
|
};
|
2015-11-01 07:28:48 +00:00
|
|
|
|
2017-10-02 16:49:27 +00:00
|
|
|
_selfOrTarget = if!(visibleMap)then{ if !(_hasTarget) then {"self"} else {"target"} } else {"map"};
|
2015-10-28 15:16:00 +00:00
|
|
|
_checkConfigs = {
|
|
|
|
|
|
|
|
_config = switch (_in) do {
|
|
|
|
case "build_upgrade":
|
|
|
|
{
|
|
|
|
_cfg = "CfgBaseBuilding" call EPOCH_returnConfig;
|
|
|
|
(_cfg >> dyna_cursorTargetType)
|
|
|
|
};
|
2019-05-01 21:31:15 +00:00
|
|
|
case "PaintGarage":
|
|
|
|
{
|
2019-05-02 21:07:51 +00:00
|
|
|
private _garagevehs = nearestobjects [dyna_cursorTarget,["LandVehicle","AIR"],10];
|
|
|
|
if (_garagevehs isEqualTo []) exitwith {
|
|
|
|
["No Paintable Vehicle found in Garage",5] call Epoch_message;
|
|
|
|
(_cfg >> _selfOrTarget)
|
|
|
|
};
|
2019-05-01 21:31:15 +00:00
|
|
|
private _cfgtmp = "CfgPainting" call EPOCH_returnConfig;
|
2019-05-02 21:07:51 +00:00
|
|
|
_garageveh = _garagevehs select 0;
|
|
|
|
private _isclass = isclass (_cfgtmp >> (typeof _garageveh));
|
|
|
|
if (!_isclass && (("true" configClasses (configFile >> "CfgVehicles" >> (typeof _garageveh) >> "TextureSources")) isEqualTo [])) exitwith {
|
2019-05-01 21:31:15 +00:00
|
|
|
["No Paintable Vehicle found in Garage",5] call Epoch_message;
|
|
|
|
(_cfg >> _selfOrTarget)
|
|
|
|
};
|
|
|
|
dyna_Paintobj = _garageveh;
|
2019-05-02 21:07:51 +00:00
|
|
|
if (_isclass) exitwith {
|
|
|
|
(_cfgtmp >> (typeof _garageveh))
|
|
|
|
};
|
|
|
|
(_cfgtmp >> "DefaultVehicle")
|
2019-05-01 21:31:15 +00:00
|
|
|
};
|
2015-10-28 15:16:00 +00:00
|
|
|
case "":
|
|
|
|
{
|
|
|
|
(_cfg >> _selfOrTarget)
|
|
|
|
};
|
|
|
|
default
|
|
|
|
{
|
|
|
|
_c = format ["_cfg >> '%1'",_selfOrTarget];
|
|
|
|
_arr = _this;
|
|
|
|
{
|
|
|
|
_c = _c + (format [" >> '%1'",_x]);
|
|
|
|
} forEach _arr;
|
2015-11-01 07:28:48 +00:00
|
|
|
|
2015-10-28 15:16:00 +00:00
|
|
|
(call compile _c)
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
switch (_in) do {
|
|
|
|
case "build_upgrade":
|
|
|
|
{
|
|
|
|
if !(isClass _config) exitWith {_in = "";};
|
2015-11-01 07:28:48 +00:00
|
|
|
|
2015-10-28 15:16:00 +00:00
|
|
|
{
|
|
|
|
_dName = getText(configfile >> "CfgVehicles" >> (_x select 0) >> "DisplayName");
|
|
|
|
_tTip = "";
|
|
|
|
_icon = "";
|
|
|
|
{
|
2016-04-08 20:21:46 +00:00
|
|
|
if !(_x isEqualType []) then {_x = [_x, 1]};
|
2015-10-28 15:16:00 +00:00
|
|
|
_c = configfile >> "CfgMagazines" >> (_x select 0);
|
|
|
|
_tTip = _tTip + format ["[%1 x %2] ", _x select 1, getText(_c >> "DisplayName")];
|
|
|
|
if (_icon isEqualTo "") then {_icon = getText (_c >> "picture")};
|
|
|
|
} forEach (_x select 1);
|
2015-11-01 07:28:48 +00:00
|
|
|
|
2015-10-28 15:16:00 +00:00
|
|
|
_tooltip = format ["%1 >> %2 ",_dName,_tTip];
|
2015-12-15 18:46:09 +00:00
|
|
|
_action = format ["[dyna_cursorTarget,%1] call EPOCH_upgradeBUILD; true call Epoch_dynamicMenuCleanup;",_forEachIndex];
|
2015-11-01 07:28:48 +00:00
|
|
|
|
2015-10-28 15:16:00 +00:00
|
|
|
_buttonSettings pushBack [
|
|
|
|
_icon,
|
|
|
|
_tooltip,
|
|
|
|
_action
|
|
|
|
];
|
2015-11-01 07:28:48 +00:00
|
|
|
|
2015-10-28 15:16:00 +00:00
|
|
|
} forEach (getArray (_config >> "upgradeBuilding"));
|
2015-11-01 07:28:48 +00:00
|
|
|
|
|
|
|
|
2019-05-01 21:31:15 +00:00
|
|
|
};
|
|
|
|
case "PaintGarage":
|
|
|
|
{
|
|
|
|
if !(isClass _config) exitWith {_in = "";};
|
2019-05-02 21:07:51 +00:00
|
|
|
private _usedefaultcolors = tolower (gettext (_config >> "UseArmaDefaultColors"));
|
2019-05-01 21:31:15 +00:00
|
|
|
_icon = gettext (_config >> "icon");
|
2019-05-02 21:07:51 +00:00
|
|
|
if (_usedefaultcolors isEqualTo "true") then {
|
|
|
|
{
|
|
|
|
private _textures = getarray (_x >> "textures");
|
|
|
|
_tooltip = gettext (_x >> "displayName");
|
|
|
|
_iconcolor = [1,1,1,1];
|
|
|
|
{
|
|
|
|
if ((tolower _tooltip) find (_x select 0) > -1) exitwith {
|
|
|
|
_iconcolor = _x select 1;
|
|
|
|
};
|
|
|
|
} foreach [
|
|
|
|
["red",[1,0,0,1]],
|
|
|
|
["green",[0,1,0,1]],
|
|
|
|
["blue",[0,0,1,1]],
|
|
|
|
["yellow",[1,1,0,1]],
|
|
|
|
["white",[1,1,1,1]],
|
|
|
|
["black",[0,0,0,1]],
|
|
|
|
["grey",[0.5, 0.5, 0.5]],
|
|
|
|
["orange",[1, 0.9, 0, 1]],
|
|
|
|
["hex",[0.74, 0.72, 0.42, 1]],
|
|
|
|
["sand",[1, 0.9, 0.8, 1]],
|
|
|
|
["olive",[0.33, 0.42, 0.185, 1]]
|
|
|
|
];
|
|
|
|
_action = format ["[dyna_cursorTarget,dyna_Paintobj,%1] call EPOCH_vehicle_Paintgarage; true call Epoch_dynamicMenuCleanup;",_textures];
|
|
|
|
_buttonSettings pushBack [
|
|
|
|
_icon,
|
|
|
|
_tooltip,
|
|
|
|
_action,
|
|
|
|
_iconcolor
|
|
|
|
];
|
|
|
|
} foreach ("true" configClasses (configFile >> "CfgVehicles" >> (typeof dyna_Paintobj) >> "TextureSources"));
|
|
|
|
};
|
2019-05-01 21:31:15 +00:00
|
|
|
{
|
|
|
|
_tooltip = gettext (_x >> "ColorName");
|
|
|
|
_iconcolor = getarray (_x >> "iconcolor");
|
|
|
|
private _textures = getarray (_x >> "textures");
|
|
|
|
if (_textures isEqualTo []) exitwith {_in = "";};
|
|
|
|
_action = format ["[dyna_cursorTarget,dyna_Paintobj,%1] call EPOCH_vehicle_Paintgarage; true call Epoch_dynamicMenuCleanup;",_textures];
|
|
|
|
_buttonSettings pushBack [
|
|
|
|
_icon,
|
|
|
|
_tooltip,
|
|
|
|
_action,
|
|
|
|
_iconcolor
|
|
|
|
];
|
|
|
|
} forEach (configProperties [_config, "isClass _x",true]);
|
2015-10-28 15:16:00 +00:00
|
|
|
};
|
|
|
|
default
|
|
|
|
{
|
|
|
|
_configs = "true" configClasses _config;
|
|
|
|
{
|
|
|
|
if (call compile (getText(_x >> "condition"))) then {
|
2015-11-01 07:28:48 +00:00
|
|
|
|
2017-10-02 16:49:27 +00:00
|
|
|
if (_selfOrTarget in ["self","map"] || dyna_distance) then {
|
2015-11-01 07:28:48 +00:00
|
|
|
|
2015-10-28 15:16:00 +00:00
|
|
|
_subclasses = configProperties [_x, "isClass _x",true];
|
2015-11-01 07:28:48 +00:00
|
|
|
|
2015-10-28 15:16:00 +00:00
|
|
|
_action = if (_subclasses isEqualTo []) then {
|
|
|
|
format ["%1; true call Epoch_dynamicMenuCleanup;",getText(_x >> "action")]
|
|
|
|
} else {
|
|
|
|
format ["%2 %1 call Epoch_dynamicMenu;",_arr + [(configName _x)],getText(_x >> "action")]
|
|
|
|
};
|
|
|
|
|
2016-07-07 15:36:49 +00:00
|
|
|
_tooltip = "";
|
2016-07-07 22:29:02 +00:00
|
|
|
_tooltipcode = getText(_x >> "tooltipcode");
|
2016-07-07 15:36:49 +00:00
|
|
|
if (_tooltipcode != "") then {
|
|
|
|
_tooltip = [] call compile _tooltipcode;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
_tooltip = getText(_x >> "tooltip");
|
|
|
|
};
|
2017-08-21 12:26:13 +00:00
|
|
|
|
|
|
|
_icon = "";
|
|
|
|
_iconcode = getText(_x >> "iconcode");
|
|
|
|
if (_iconcode != "") then {
|
|
|
|
_icon = [] call compile _iconcode;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
_icon = getText(_x >> "icon");
|
|
|
|
};
|
|
|
|
if (!(_icon isequaltype "") || _icon isequalto "") then {
|
|
|
|
_icon = "x\addons\a3_epoch_code\Data\UI\buttons\player_inspect.paa";
|
|
|
|
};
|
2016-07-07 15:36:49 +00:00
|
|
|
|
2015-10-28 15:16:00 +00:00
|
|
|
_buttonSettings pushBack [
|
2017-08-21 12:26:13 +00:00
|
|
|
_icon,
|
2016-07-07 15:36:49 +00:00
|
|
|
_tooltip,
|
2015-10-28 15:16:00 +00:00
|
|
|
_action
|
|
|
|
];
|
2016-07-07 15:36:49 +00:00
|
|
|
|
2015-10-28 15:16:00 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
} forEach _configs;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
call _checkConfigs;
|
2017-10-02 16:49:27 +00:00
|
|
|
if (_buttonSettings isEqualTo []) then {_selfOrTarget = if!(visibleMap)then{"self"}else{"map"}; call _checkConfigs;};
|
2015-10-28 15:16:00 +00:00
|
|
|
|
|
|
|
_entries = count _buttonSettings;
|
|
|
|
if !(_entries <= 0) then {
|
2017-03-05 17:02:00 +00:00
|
|
|
[_entries, _buttonSettings] spawn epoch_dynamicMenuPopulate;
|
2015-10-28 15:16:00 +00:00
|
|
|
} else {
|
|
|
|
true call Epoch_dynamicMenuCleanup;
|
|
|
|
};
|
|
|
|
|
|
|
|
true
|