Merge pull request #383 from acemod/altSelfInteract

Alt self interact
This commit is contained in:
PabstMirror 2015-04-28 14:23:17 -05:00
commit d12ba0c610
5 changed files with 44 additions and 10 deletions

View File

@ -24,6 +24,13 @@ class ACE_Settings {
typeName = "BOOL";
isClientSettable = 1;
displayName = "$STR_ACE_Interact_Menu_AlwaysUseCursorSelfInteraction";
};
class GVAR(cursorKeepCentered) {
value = 0;
typeName = "BOOL";
isClientSettable = 1;
displayName = "$STR_ACE_Interact_cursorKeepCentered";
description = "$STR_ACE_Interact_cursorKeepCenteredDescription";
};
class GVAR(AlwaysUseCursorInteraction) {
value = 0;

View File

@ -43,8 +43,14 @@ if (GVAR(useCursorMenu)) then {
// uiNamespace getVariable QGVAR(dlgCursorMenu);
// uiNamespace getVariable QGVAR(cursorMenuOpened);
ctrlEnable [91921, true];
GVAR(cursorPos) = [0.5,0.5,0];
((finddisplay 91919) displayctrl 91921) ctrlAddEventHandler ["MouseMoving", {
GVAR(cursorPos) = [_this select 1, _this select 2, 0];
if (GVAR(cursorKeepCentered)) then {
GVAR(cursorPos) = GVAR(cursorPos) vectorAdd [_this select 1, _this select 2, 0] vectorDiff [0.5, 0.5, 0];
setMousePosition [0.5, 0.5];
} else {
GVAR(cursorPos) = [_this select 1, _this select 2, 0];
};
}];
setMousePosition [0.5, 0.5];
};

View File

@ -17,7 +17,7 @@
*/
#include "script_component.hpp"
#define DEFAULT_ICON QUOTE(\z\ace\addons\interaction\ui\dot_ca.paa)
private ["_ctrl"];
private ["_ctrl", "_pos"];
PARAMS_6(_text,_icon,_sPos,_textColor,_shadowColor,_iconColor);
//systemChat format ["Icon %1 - %2,%3", _text, _sPos select 0, _sPos select 1];
@ -27,6 +27,7 @@ if(GVAR(iconCount) > (count GVAR(iconCtrls))-1) then {
GVAR(iconCtrls) pushBack ((findDisplay _displayNum) ctrlCreate ["RscStructuredText", 54021+GVAR(iconCount)]);
};
_ctrl = GVAR(iconCtrls) select GVAR(iconCount);
GVAR(iconCount) = GVAR(iconCount) + 1;
if(_icon == "") then {
_icon = DEFAULT_ICON;
};
@ -39,11 +40,18 @@ _text = if (GVAR(UseListMenu)) then {
//_ctrl ctrlSetStructuredText parseText _text;
[_ctrl, GVAR(iconCount), _text] call FUNC(ctrlSetParsedTextCached);
GVAR(iconCount) = GVAR(iconCount) + 1;
_pos = [];
if (GVAR(UseListMenu)) then {
_ctrl ctrlSetPosition [(_sPos select 0)-(0.0095*SafeZoneW), (_sPos select 1)-(0.0095*SafeZoneW), 0.20*SafeZoneW, 0.035*SafeZoneW];
_pos = [(_sPos select 0)-(0.0095*SafeZoneW), (_sPos select 1)-(0.0095*SafeZoneW), 0.20*SafeZoneW, 0.035*SafeZoneW];
} else {
_ctrl ctrlSetPosition [(_sPos select 0)-(0.0750*SafeZoneW), (_sPos select 1)-(0.0095*SafeZoneW), 0.15*SafeZoneW, 0.100*SafeZoneW];
_pos = [(_sPos select 0)-(0.0750*SafeZoneW), (_sPos select 1)-(0.0095*SafeZoneW), 0.15*SafeZoneW, 0.100*SafeZoneW];
};
if (GVAR(cursorKeepCentered) && {uiNamespace getVariable [QGVAR(cursorMenuOpened),false]}) then {
_pos set [0, ((_pos select 0) - (GVAR(cursorPos) select 0) + 0.5)];
_pos set [1, ((_pos select 1) - (GVAR(cursorPos) select 1) + 0.5)];
};
_ctrl ctrlSetPosition _pos;
_ctrl ctrlCommit 0;

View File

@ -20,16 +20,23 @@ if(GVAR(iconCount) > (count GVAR(iconCtrls))-1) then {
GVAR(iconCtrls) pushBack ((findDisplay _displayNum) ctrlCreate ["RscStructuredText", 54021+GVAR(iconCount)]);
};
private "_ctrl";
private ["_ctrl", "_pos"];
_ctrl = GVAR(iconCtrls) select GVAR(iconCount);
GVAR(iconCount) = GVAR(iconCount) + 1;
_pos = [];
if (GVAR(UseListMenu)) then {
[_ctrl, GVAR(iconCount), format ["<img image='%1' color='#FF0000' size='1.6'/>", _icon]] call FUNC(ctrlSetParsedTextCached);
_ctrl ctrlSetPosition [(_sPos select 0)-(0.014*SafeZoneW), (_sPos select 1)-(0.014*SafeZoneW), 0.05*SafeZoneW, 0.035*SafeZoneW];
_pos = [(_sPos select 0)-(0.014*SafeZoneW), (_sPos select 1)-(0.014*SafeZoneW), 0.05*SafeZoneW, 0.035*SafeZoneW];
} else {
[_ctrl, GVAR(iconCount), format ["<img image='%1' color='#FF0000' size='1.6' align='center'/>", _icon]] call FUNC(ctrlSetParsedTextCached);
_ctrl ctrlSetPosition [(_sPos select 0)-(0.050*SafeZoneW), (_sPos select 1)-(0.014*SafeZoneW), 0.1*SafeZoneW, 0.035*SafeZoneW];
_pos = [(_sPos select 0)-(0.050*SafeZoneW), (_sPos select 1)-(0.014*SafeZoneW), 0.1*SafeZoneW, 0.035*SafeZoneW];
};
//_ctrl ctrlSetBackgroundColor [1, 0, 0, 0.1];
GVAR(iconCount) = GVAR(iconCount) + 1;
if (GVAR(cursorKeepCentered) && {uiNamespace getVariable [QGVAR(cursorMenuOpened),false]}) then {
_pos set [0, ((_pos select 0) - (GVAR(cursorPos) select 0) + 0.5)];
_pos set [1, ((_pos select 1) - (GVAR(cursorPos) select 1) + 0.5)];
};
_ctrl ctrlSetPosition _pos;
_ctrl ctrlCommit 0;

View File

@ -101,5 +101,11 @@
<German>Interaktionstextschatten Min</German>
<Italian>Interazioni - Ombra Minima</Italian>
</Key>
<Key ID="STR_ACE_Interact_cursorKeepCentered">
<English>Keep cursor centered</English>
</Key>
<Key ID="STR_ACE_Interact_cursorKeepCenteredDescription">
<English>Keeps cursor centered and pans the option menu around. Useful if screen size is limited.</English>
</Key>
</Package>
</Project>