2015-01-11 19:32:51 +00:00
|
|
|
/*
|
|
|
|
Author:
|
|
|
|
commy2
|
|
|
|
Garth de Wet (LH)
|
|
|
|
|
|
|
|
Description:
|
|
|
|
Initialises the interaction click handlers.
|
|
|
|
|
|
|
|
Parameters:
|
|
|
|
0 : CODE - code to call when right clicking/center button
|
|
|
|
1 : BOOLEAN - Submenu
|
|
|
|
2 : BOOLEAN - Flow Menu
|
|
|
|
3 : BOOLEAN - Self interaction
|
|
|
|
4 : OBJECT - Target
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
Nothing
|
|
|
|
|
|
|
|
Example:
|
2015-01-12 04:20:02 +00:00
|
|
|
[{"Default" call FUNC(openMenu);}, true, (profileNamespace getVariable [QGVAR(FlowMenu), false]), GVAR(Target)] call FUNC(initialiseInteraction);
|
2015-01-11 19:32:51 +00:00
|
|
|
*/
|
2015-01-11 23:13:47 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-01-11 19:32:51 +00:00
|
|
|
private ["_subMenu", "_selfMenu", "_target"];
|
2015-01-11 23:13:47 +00:00
|
|
|
GVAR(MainButton) = _this select 0;
|
2015-01-11 19:32:51 +00:00
|
|
|
_subMenu = _this select 1;
|
|
|
|
_selfMenu = _this select 3;
|
|
|
|
_target = _this select 4;
|
|
|
|
|
2015-01-12 04:20:02 +00:00
|
|
|
_player = ACE_player;
|
2015-01-11 19:32:51 +00:00
|
|
|
_vehicle = vehicle _player;
|
2015-01-11 23:13:47 +00:00
|
|
|
//_object = [GVAR(Target), _player] select (GVAR(MenuType) % 2 == 1);
|
2015-01-11 19:32:51 +00:00
|
|
|
|
2015-01-11 23:13:47 +00:00
|
|
|
if !([_target, 5] call GVAR(isInRange)) exitWith {};
|
2015-01-11 19:32:51 +00:00
|
|
|
|
2015-01-11 23:13:47 +00:00
|
|
|
GVAR(Shortcuts) = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1];
|
2015-01-11 19:32:51 +00:00
|
|
|
|
|
|
|
// Flow menu
|
|
|
|
if (_this select 2) then {
|
2015-01-11 23:13:47 +00:00
|
|
|
(QGVAR(FlowMenu) call BIS_fnc_rscLayer) cutRsc [QGVAR(FlowMenu), "PLAIN",0.5, false];
|
2015-01-12 04:20:02 +00:00
|
|
|
ACE_Interaction_SelectedButton = 0;
|
2015-01-11 19:32:51 +00:00
|
|
|
(findDisplay 1713999) closeDisplay 1;
|
2015-01-12 04:20:02 +00:00
|
|
|
if (_player getVariable ["ACE_AcceptAction", -1] == -1) then {
|
2015-01-13 05:14:27 +00:00
|
|
|
[{if(isNil {GVAR(MainButton)} || {!(profileNamespace getVariable [QGVAR(FlowMenu), false])})exitWith{false};(-(_this select 0) / 1.2) call FUNC(MoveDown);true}] call EFUNC(common,addScrollWheelEventHandler);
|
2015-01-11 19:32:51 +00:00
|
|
|
|
2015-01-13 05:14:27 +00:00
|
|
|
_player setVariable ["ACE_AcceptAction", [_player, "DefaultAction", {(!isNil {GVAR(MainButton)}) && {(profileNamespace getVariable [QGVAR(FlowMenu), false])}}, {_action = GVAR(Buttons) select ACE_Interaction_SelectedButton;_target = GVAR(Target);_player = ACE_player;_vehicle = vehicle _player;if ([_target, _player] call (_action select 2)) then {call FUNC(hideMenu);if(count _action == 12) then{(_action select 11) call (_action select 1);}else{[_target, _player] call (_action select 1);};};}] call EFUNC(common,addActionEventHandler)];
|
|
|
|
_player setVariable ["ACE_AcceptAction", [_player, "menuBack", {(!isNil {GVAR(MainButton)}) && {(profileNamespace getVariable [QGVAR(FlowMenu), false])}}, {call GVAR(MainButton);}] call EFUNC(common,addActionEventHandler)];
|
2015-01-11 19:32:51 +00:00
|
|
|
};
|
2015-01-11 23:13:47 +00:00
|
|
|
0 call FUNC(moveDown);
|
2015-01-12 04:20:02 +00:00
|
|
|
[localize "STR_ACE_Interaction_MakeSelection", if (_subMenu)then{localize "STR_ACE_Interaction_Back"}else{""}, localize "STR_ACE_Interaction_ScrollHint"] call FUNC(showMouseHint);
|
2015-01-11 23:13:47 +00:00
|
|
|
((uiNamespace getVariable QGVAR(Flow_Display)) displayCtrl (1210)) ctrlShow _subMenu;
|
2015-01-11 19:32:51 +00:00
|
|
|
}else{ // Rose
|
2015-01-11 23:13:47 +00:00
|
|
|
if (!isNull(uiNamespace getVariable QGVAR(Flow_Display))) then {
|
|
|
|
(uiNameSpace getVariable QGVAR(Flow_Display)) closeDisplay 0;
|
|
|
|
call FUNC(hideMouseHint);
|
2015-01-11 19:32:51 +00:00
|
|
|
};
|
|
|
|
if (!_subMenu || {isNull (findDisplay 1713999)}) then {
|
|
|
|
(findDisplay 1713999) closeDisplay 1;
|
|
|
|
|
2015-01-11 23:13:47 +00:00
|
|
|
(findDisplay 46) createDisplay QGVAR(Dialog);
|
2015-01-11 19:32:51 +00:00
|
|
|
// Add eventhandlers
|
2015-01-13 05:14:27 +00:00
|
|
|
(findDisplay 1713999) displayAddEventHandler ["KeyDown", QUOTE( _this call EFUNC(common,onKeyDown) )];
|
|
|
|
(findDisplay 1713999) displayAddEventHandler ["KeyUp", QUOTE( _this call EFUNC(common,onKeyUp) )];
|
2015-01-11 19:32:51 +00:00
|
|
|
|
2015-01-11 23:13:47 +00:00
|
|
|
(findDisplay 1713999) displayAddEventHandler ["KeyDown", QUOTE( _this call FUNC(menuKeyInput) )];
|
2015-01-11 19:32:51 +00:00
|
|
|
};
|
|
|
|
disableSerialization;
|
2015-01-11 23:13:47 +00:00
|
|
|
_dlgInteractionDialog = uiNamespace getVariable QGVAR(Dialog);
|
2015-01-11 19:32:51 +00:00
|
|
|
_ctrlInteractionDialog = _dlgInteractionDialog displayCtrl 3;
|
2015-01-11 23:13:47 +00:00
|
|
|
if (profileNamespace getVariable [QGVAR(AutoCenterCursor), true]) then {setMousePosition [0.5, 0.5]};
|
2015-01-11 19:32:51 +00:00
|
|
|
if !(_subMenu) then {
|
2015-01-13 05:14:27 +00:00
|
|
|
_ctrlInteractionDialog ctrlSetText ([_target] call EFUNC(common,getName));
|
2015-01-11 19:32:51 +00:00
|
|
|
} else {
|
2015-01-12 04:20:02 +00:00
|
|
|
_ctrlInteractionDialog ctrlSetText localize "STR_ACE_Interaction_Back";
|
2015-01-11 19:32:51 +00:00
|
|
|
};
|
|
|
|
|
2015-01-11 23:13:47 +00:00
|
|
|
_buttons = GVAR(Buttons);
|
2015-01-11 19:32:51 +00:00
|
|
|
_count = count _buttons;
|
|
|
|
|
|
|
|
for "_i" from 0 to 9 do {
|
|
|
|
_ctrlInteractionDialog = _dlgInteractionDialog displayCtrl (10 + _i);
|
|
|
|
_ctrlInteractionDialog ctrlShow true;
|
|
|
|
|
|
|
|
_ctrlInteractionDialogIcon = _dlgInteractionDialog displayCtrl (20 + _i);
|
|
|
|
_ctrlInteractionDialogShortcut = _dlgInteractionDialog displayCtrl (30 + _i);
|
|
|
|
//_ctrlInteractionDialogBackground = _dlgInteractionDialog displayCtrl (40 + _i);
|
|
|
|
if (_i < _count) then {
|
|
|
|
_action = _buttons select _i;
|
|
|
|
_ctrlInteractionDialog ctrlSetText (_action select 0);
|
|
|
|
_ctrlInteractionDialog ctrlEnable ([_target, _player] call (_action select 2));
|
|
|
|
_ctrlInteractionDialog ctrlSetTooltip (_action select 6);
|
|
|
|
|
|
|
|
_ctrlInteractionDialogIcon ctrlSetText (_action select 5);
|
|
|
|
_ctrlInteractionDialogShortcut ctrlSetText (_action select 10);
|
|
|
|
//_ctrlInteractionDialogBackground ctrlShow true;
|
|
|
|
|
2015-01-13 05:14:27 +00:00
|
|
|
GVAR(Shortcuts) set [_i, [_action select 10] call EFUNC(common,letterToCode)];
|
2015-01-11 19:32:51 +00:00
|
|
|
} else {
|
|
|
|
_ctrlInteractionDialog ctrlSetText "";
|
|
|
|
_ctrlInteractionDialog ctrlEnable false;
|
|
|
|
_ctrlInteractionDialog ctrlSetTooltip "";
|
|
|
|
|
|
|
|
_ctrlInteractionDialogIcon ctrlSetText "";
|
|
|
|
_ctrlInteractionDialogShortcut ctrlSetText "";
|
|
|
|
//_ctrlInteractionDialogBackground ctrlShow false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
// Update Buttons
|
2015-01-11 23:13:47 +00:00
|
|
|
terminate (missionNamespace getVariable [QGVAR(updateMenuHandle), scriptNull]);
|
2015-01-11 19:32:51 +00:00
|
|
|
|
2015-01-11 23:13:47 +00:00
|
|
|
GVAR(updateMenuHandle) = 0 spawn {
|
2015-01-11 19:32:51 +00:00
|
|
|
disableSerialization;
|
2015-01-11 23:13:47 +00:00
|
|
|
_dlgMenu = uiNamespace getVariable [QGVAR(Dialog), displayNull];
|
2015-01-11 19:32:51 +00:00
|
|
|
_ctrlTooltip = _dlgMenu displayCtrl 40;
|
|
|
|
|
2015-01-12 04:20:02 +00:00
|
|
|
_player = ACE_player;
|
2015-01-11 19:32:51 +00:00
|
|
|
_vehicle = vehicle _player;
|
2015-01-11 23:13:47 +00:00
|
|
|
_target = [GVAR(Target), _player] select (GVAR(MenuType) % 2 == 1);
|
2015-01-11 19:32:51 +00:00
|
|
|
|
|
|
|
waitUntil {
|
2015-01-11 23:13:47 +00:00
|
|
|
if !([_target, 5] call GVAR(isInRange)) exitWith {
|
2015-01-11 19:32:51 +00:00
|
|
|
(findDisplay 1713999) closeDisplay 1
|
|
|
|
};
|
|
|
|
|
2015-01-11 23:13:47 +00:00
|
|
|
GVAR(Tooltips) = [[], [], [], [], [], [], [], [], [], []];
|
2015-01-11 19:32:51 +00:00
|
|
|
{
|
|
|
|
_ctrlText = _dlgMenu displayCtrl (10 + _forEachIndex);
|
|
|
|
_ctrlIcon = _dlgMenu displayCtrl (20 + _forEachIndex);
|
|
|
|
|
|
|
|
_condition = _x select 2;
|
|
|
|
_conditionShow = _x select 7;
|
|
|
|
_distance = _x select 9;
|
|
|
|
|
2015-01-11 23:13:47 +00:00
|
|
|
GVAR(CurrentTooltip) = [];
|
2015-01-11 19:32:51 +00:00
|
|
|
|
2015-01-11 23:13:47 +00:00
|
|
|
_enable = (_distance == 0 || {[_target, _distance] call GVAR(isInRange)}) && {[_target, _player] call _condition} && {[_target, _player] call _conditionShow};
|
2015-01-11 19:32:51 +00:00
|
|
|
if (isNil "_enable") then {_enable = false};
|
|
|
|
|
2015-01-11 23:13:47 +00:00
|
|
|
GVAR(Tooltips) set [_forEachIndex, GVAR(CurrentTooltip)];
|
2015-01-11 19:32:51 +00:00
|
|
|
|
|
|
|
// apply conditional tooltips
|
2015-01-12 04:20:02 +00:00
|
|
|
/*if (_forEachIndex == call ACE_Interaction_fnc_getSelectedButton) then {
|
2015-01-11 19:32:51 +00:00
|
|
|
_tooltip = _x select 6;
|
|
|
|
|
|
|
|
_showTooltip = _tooltip != "";
|
|
|
|
|
|
|
|
_tooltip = text _tooltip;
|
|
|
|
|
|
|
|
{
|
|
|
|
_showTooltip = true;
|
|
|
|
_tooltip = composeText [_tooltip, lineBreak, _x];
|
2015-01-11 23:13:47 +00:00
|
|
|
} forEach (GVAR(Tooltips) select _forEachIndex);
|
2015-01-11 19:32:51 +00:00
|
|
|
|
|
|
|
_ctrlTooltip ctrlSetStructuredText _tooltip;
|
|
|
|
_ctrlTooltip ctrlShow _showTooltip;
|
|
|
|
};*/
|
|
|
|
|
|
|
|
_ctrlText ctrlEnable _enable;
|
|
|
|
_ctrlIcon ctrlEnable _enable;
|
2015-01-11 23:13:47 +00:00
|
|
|
} forEach GVAR(Buttons);
|
2015-01-11 19:32:51 +00:00
|
|
|
|
|
|
|
sleep 0.5;
|
|
|
|
isNull (findDisplay 1713999)
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|