Merge pull request #2748 from acemod/simpleMapLightActions

Simplify Map Light Interactions
This commit is contained in:
Joko 2015-10-17 23:19:27 +02:00
commit 1365aebe2a
3 changed files with 37 additions and 31 deletions

View File

@ -5,7 +5,7 @@ class CfgVehicles {
class ACE_MapFlashlight { class ACE_MapFlashlight {
displayName = CSTRING(Action_Flashlights); displayName = CSTRING(Action_Flashlights);
icon = QUOTE(\a3\ui_f\data\IGUI\Cfg\VehicleToggles\lightsiconon_ca.paa); icon = QUOTE(\a3\ui_f\data\IGUI\Cfg\VehicleToggles\lightsiconon_ca.paa);
condition = QUOTE(GVAR(mapIllumination) && visibleMap && (count ([ACE_player] call FUNC(getUnitFlashlights)) > 0)); condition = QUOTE(GVAR(mapIllumination) && visibleMap && {count ([ACE_player] call FUNC(getUnitFlashlights)) > 0});
statement = "true"; statement = "true";
exceptions[] = {"isNotDragging", "notOnMap", "isNotInside", "isNotSitting"}; exceptions[] = {"isNotDragging", "notOnMap", "isNotInside", "isNotSitting"};
insertChildren = QUOTE(_this call DFUNC(compileFlashlightMenu)); insertChildren = QUOTE(_this call DFUNC(compileFlashlightMenu));

View File

@ -18,47 +18,29 @@
#include "script_component.hpp" #include "script_component.hpp"
params ["_vehicle", "_player", "_parameters"]; params ["", "_player"];
private["_action", "_actions", "_cfg", "_displayName", "_flashlights", "_icon", "_statement"];
_actions = []; _actions = [];
_flashlights = [_player] call FUNC(getUnitFlashlights); _flashlights = [_player] call FUNC(getUnitFlashlights);
//add all carried flashlight menus and on/off submenu actions //add all carried flashlight menus and on/off submenu actions
{ {
private ["_cfg", "_displayName"," _icon", "_children", "_parentAction"];
_cfg = (configFile >> "CfgWeapons" >> _x); _cfg = (configFile >> "CfgWeapons" >> _x);
_displayName = getText (_cfg >> "displayName"); _displayName = getText (_cfg >> "displayName");
_icon = getText (_cfg >> "picture"); _icon = getText (_cfg >> "picture");
_children = { _statement = if (GVAR(flashlightInUse) == _x) then {
private ["_onAction", "_offAction"]; _displayName = format [localize LSTRING(turnLightOff), _displayName];
params ["_vehicle", "_player", "_flashlight"]; {[""] call FUNC(switchFlashlight)}
} else {
_onAction = [ _displayName = format [localize LSTRING(turnLightOn), _displayName];
(_flashlight + "_On"), {[_this select 2] call FUNC(switchFlashlight)}
"On",
"",
{[_this select 2] call FUNC(switchFlashlight)},
{GVAR(flashlightInUse) != (_this select 2)},
{},
_flashlight
] call EFUNC(interact_menu,createAction);
_offAction = [
(_flashlight + "_Off"),
"Off",
"",
{[""] call FUNC(switchFlashlight)},
{GVAR(flashlightInUse) == (_this select 2)},
{},
_flashlight
] call EFUNC(interact_menu,createAction);
[[_onAction, [], _player], [_offAction, [], _player]]
}; };
_parentAction = [_x, _displayName, _icon, {true}, {true}, _children, _x] call EFUNC(interact_menu,createAction); _action = [_x, _displayName, _icon, _statement, {true}, {}, _x] call EFUNC(interact_menu,createAction);
_actions pushBack [_parentAction, [], _player]; _actions pushBack [_action, [], _player];
} forEach _flashlights; } forEach _flashlights;
_actions _actions

View File

@ -256,5 +256,29 @@
<Czech>Snížit jas</Czech> <Czech>Snížit jas</Czech>
<Spanish>Reducir brillo</Spanish> <Spanish>Reducir brillo</Spanish>
</Key> </Key>
<Key ID="STR_ACE_Map_turnLightOn">
<English>Turn On %1</English>
<German>%1 Aktivieren</German>
<Spanish>Encender %1</Spanish>
<Polish>Włącz %1</Polish>
<French>Allumer %1</French>
<Czech>Zapnout %1</Czech>
<Italian>Accendi %1</Italian>
<Hungarian>%1 Bekapcsolása</Hungarian>
<Portuguese>Ativar %1</Portuguese>
<Russian>Активировать %1</Russian>
</Key>
<Key ID="STR_ACE_Map_turnLightOff">
<English>Turn Off %1</English>
<German>%1 Deaktivieren</German>
<Spanish>Apagar %1</Spanish>
<Polish>Wyłącz %1</Polish>
<French>Éteindre %1</French>
<Czech>Vypnout %1</Czech>
<Italian>Spegni %1</Italian>
<Hungarian>%1 Kikapcsolása</Hungarian>
<Portuguese>Desativar %1</Portuguese>
<Russian>Деактивировать %1</Russian>
</Key>
</Package> </Package>
</Project> </Project>