Skip to content

Commit

Permalink
Split interaction menu settings between interaction and self interact…
Browse files Browse the repository at this point in the history
…ion (#6609)

* Split interaction menu settings between interaction and self interaction

* consistent spacing
not sure which way is wanted here, but I might as well be consistent in 
my own PR

* remove useless code, fix use of backgroundMenu

* clean up from Dystopian

* use existing stringtable

* remove redundent localize

* Use LLSTRING, split UseListMenu

* style fixes

* style fixes

* add movedToSQF to old settings

* condense ifs

* Don't use cursorKeepCentered as default
  • Loading branch information
Brett authored and PabstMirror committed Dec 8, 2019
1 parent 79e3de6 commit 8b4e8a6
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 45 deletions.
36 changes: 7 additions & 29 deletions addons/interact_menu/ACE_Settings.hpp
Original file line number Diff line number Diff line change
@@ -1,32 +1,18 @@
class ACE_Settings {
class GVAR(alwaysUseCursorSelfInteraction) {
value = 0;
typeName = "BOOL";
isClientSettable = 1;
category = CSTRING(Category_InteractionMenu);
displayName = CSTRING(AlwaysUseCursorSelfInteraction);
movedToSQF = 1;
};
class GVAR(cursorKeepCentered) {
value = 0;
typeName = "BOOL";
isClientSettable = 1;
category = CSTRING(Category_InteractionMenu);
displayName = CSTRING(cursorKeepCentered);
description = CSTRING(cursorKeepCenteredDescription);
movedToSQF = 1;
};
class GVAR(alwaysUseCursorInteraction) {
value = 0;
typeName = "BOOL";
isClientSettable = 1;
category = CSTRING(Category_InteractionMenu);
displayName = CSTRING(AlwaysUseCursorInteraction);
movedToSQF = 1;
};
class GVAR(useListMenu) {
value = 0;
typeName = "BOOL";
isClientSettable = 1;
category = CSTRING(Category_InteractionMenu);
displayName = CSTRING(UseListMenu);
movedToSQF = 1;
};
class GVAR(menuBackground) {
movedToSQF = 1;
};
class GVAR(colorTextMax) {
value[] = {1, 1, 1, 1};
Expand Down Expand Up @@ -80,14 +66,6 @@ class ACE_Settings {
category = CSTRING(Category_InteractionMenu);
displayName = CSTRING(ActionOnKeyRelease);
};
class GVAR(menuBackground) {
value = 0;
typeName = "SCALAR";
isClientSettable = 1;
category = CSTRING(Category_InteractionMenu);
displayName = CSTRING(background);
values[] = {"$STR_A3_OPTIONS_DISABLED", CSTRING(backgroundBlur), CSTRING(backgroundBlack)};
};
class GVAR(addBuildingActions) {
value = 0;
typeName = "BOOL";
Expand Down
12 changes: 8 additions & 4 deletions addons/interact_menu/XEH_clientInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,14 @@ format ["%1 (%2)", (localize LSTRING(SelfInteractKey)), localize ELSTRING(common

// background options
["ace_interactMenuOpened", {
if (GVAR(menuBackground)==1) then {[QGVAR(menuBackground), true] call EFUNC(common,blurScreen);};
if (GVAR(menuBackground)==2) then {0 cutRsc[QGVAR(menuBackground), "PLAIN", 1, false];};
params ["_menuType"];
private _menuBackgroundSetting = [GVAR(menuBackground), GVAR(menuBackgroundSelf)] select _menuType;
if (_menuBackgroundSetting == 1) exitWith {[QGVAR(menuBackground), true] call EFUNC(common,blurScreen);};
if (_menuBackgroundSetting == 2) exitWith {0 cutRsc [QGVAR(menuBackground), "PLAIN", 1, false];};
}] call CBA_fnc_addEventHandler;
["ace_interactMenuClosed", {
if (GVAR(menuBackground)==1) then {[QGVAR(menuBackground), false] call EFUNC(common,blurScreen);};
if (GVAR(menuBackground)==2) then {(uiNamespace getVariable [QGVAR(menuBackground), displayNull]) closeDisplay 0;};
params ["_menuType"];
private _menuBackgroundSetting = [GVAR(menuBackground), GVAR(menuBackgroundSelf)] select _menuType;
if (_menuBackgroundSetting == 1) exitWith {[QGVAR(menuBackground), false] call EFUNC(common,blurScreen);};
if (_menuBackgroundSetting == 2) exitWith {(uiNamespace getVariable [QGVAR(menuBackground), displayNull]) closeDisplay 0;};
}] call CBA_fnc_addEventHandler;
2 changes: 1 addition & 1 deletion addons/interact_menu/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ GVAR(cacheManActions) = +(GVAR(ActNamespace) getVariable ["CAManBase", []]); //

// Event handlers for all interact menu controls
DFUNC(handleMouseMovement) = {
if (GVAR(cursorKeepCentered)) then {
if ([GVAR(cursorKeepCentered), GVAR(cursorKeepCenteredSelfInteraction)] select GVAR(keyDownSelfAction)) 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 {
Expand Down
4 changes: 2 additions & 2 deletions addons/interact_menu/functions/fnc_keyDown.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ GVAR(useCursorMenu) = (vehicle ACE_player != ACE_player) ||
(!(isNull (ACE_controlledUAV select 0))) ||
visibleMap ||
(!isNull curatorCamera) ||
{(_menuType == 1) && {(isWeaponDeployed ACE_player) || GVAR(AlwaysUseCursorSelfInteraction) || {cameraView == "GUNNER"}}} ||
{(_menuType == 0) && GVAR(AlwaysUseCursorInteraction)};
{(_menuType == 1) && {(isWeaponDeployed ACE_player) || GVAR(alwaysUseCursorSelfInteraction) || {cameraView == "GUNNER"}}} ||
{(_menuType == 0) && GVAR(alwaysUseCursorInteraction)};

// Delete existing controls in case there's any left
GVAR(iconCount) = 0;
Expand Down
7 changes: 4 additions & 3 deletions addons/interact_menu/functions/fnc_renderIcon.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ if (_iconFile isEqualTo "") then {
_iconFile = DEFAULT_ICON;
};

_text = if (GVAR(UseListMenu)) then {
_text = if ([GVAR(useListMenu), GVAR(useListMenuSelf)] select GVAR(keyDownSelfAction)) then {
format ["<img image='%1' align='left' color='%2'/><t %3>%4</t>", _iconFile, _iconColor, _textSettings, _text]
} else {
format ["<img image='%1' align='center' color='%2'/><br/><t %3 align='center'>%4</t>", _iconFile, _iconColor, _textSettings, "ace_break_line" callExtension _text];
Expand All @@ -47,13 +47,14 @@ _text = if (GVAR(UseListMenu)) then {
[_ctrl, GVAR(iconCount), _text] call FUNC(ctrlSetParsedTextCached);
GVAR(iconCount) = GVAR(iconCount) + 1;

private _pos = if (GVAR(UseListMenu)) then {
private _pos = if ([GVAR(useListMenu), GVAR(useListMenuSelf)] select GVAR(keyDownSelfAction)) then {
[(_sPos select 0) - (0.0095 * SafeZoneW), (_sPos select 1) - (0.0095 * SafeZoneW), 0.20 * SafeZoneW, 0.035 * SafeZoneW]
} else {
[(_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 {

if (([GVAR(cursorKeepCentered), GVAR(cursorKeepCenteredSelfInteraction)] select GVAR(keyDownSelfAction)) && {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)];
};
Expand Down
6 changes: 3 additions & 3 deletions addons/interact_menu/functions/fnc_renderMenu.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ if (_numChildren == 1) then {
// Scale menu based on the amount of children
private _scaleX = 1;
private _scaleY = 1;

if (GVAR(UseListMenu)) then {
private _useListMenu = [GVAR(useListMenu), GVAR(useListMenuSelf)] select GVAR(keyDownSelfAction);
if (_useListMenu) then {
private _textSize = [0.75, 0.875, 1, 1.2, 1.4] select GVAR(textSize);
_scaleX = _textSize * 0.17 * 1.1;
_scaleY = 0.17 * 0.30 * 4/3;
Expand All @@ -112,7 +112,7 @@ private _player = ACE_player;
//END_COUNTER(children);
private _angle = _centerAngle - _angleSpan / 2;
{
private _newPos = if (GVAR(UseListMenu)) then {
private _newPos = if (_useListMenu) then {
[(_sPos select 0) + _scaleX,
(_sPos select 1) + _scaleY * (_forEachIndex - _numChildren/2 + 0.5)];
} else {
Expand Down
2 changes: 1 addition & 1 deletion addons/interact_menu/functions/fnc_renderSelector.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private _pos = if (GVAR(UseListMenu)) then {

GVAR(iconCount) = GVAR(iconCount) + 1;

if (GVAR(cursorKeepCentered) && {uiNamespace getVariable [QGVAR(cursorMenuOpened),false]}) then {
if (([GVAR(cursorKeepCentered), GVAR(cursorKeepCenteredSelfInteraction)] select GVAR(keyDownSelfAction)) && {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)];
};
Expand Down
76 changes: 74 additions & 2 deletions addons/interact_menu/initSettings.sqf
Original file line number Diff line number Diff line change
@@ -1,9 +1,81 @@
[
QGVAR(selectorColor),
"COLOR",
localize LSTRING(SelectorColor),
format ["ACE %1", localize LSTRING(Category_InteractionMenu)],
LSTRING(SelectorColor),
format ["ACE %1", LLSTRING(Category_InteractionMenu)],
[1, 0, 0],
false,
{GVAR(selectorColorHex) = _this call BIS_fnc_colorRGBtoHTML} // Stored in Hex to avoid constant conversion
] call CBA_settings_fnc_init;

[
QGVAR(alwaysUseCursorInteraction),
"CHECKBOX",
LSTRING(AlwaysUseCursorInteraction),
[format ["ACE %1", LLSTRING(Category_InteractionMenu)], LLSTRING(Category_InteractionMenu)],
false,
false
] call CBA_settings_fnc_init;

[
QGVAR(cursorKeepCentered),
"CHECKBOX",
[LSTRING(cursorKeepCentered), LSTRING(cursorKeepCenteredDescription)],
[format ["ACE %1", LLSTRING(Category_InteractionMenu)], LLSTRING(Category_InteractionMenu)],
false,
false
] call CBA_settings_fnc_init;

[
QGVAR(useListMenu),
"CHECKBOX",
LSTRING(UseListMenu),
[format ["ACE %1", LLSTRING(Category_InteractionMenu)], LLSTRING(Category_InteractionMenu)],
false,
false
] call CBA_settings_fnc_init;

[
QGVAR(menuBackground),
"LIST",
LSTRING(background),
[format ["ACE %1", LLSTRING(Category_InteractionMenu)], LLSTRING(Category_InteractionMenu)],
[[0, 1, 2], ["STR_A3_OPTIONS_DISABLED", LLSTRING(backgroundBlur), LLSTRING(backgroundBlack)], 0],
false
] call CBA_settings_fnc_init;

[
QGVAR(alwaysUseCursorSelfInteraction),
"CHECKBOX",
LSTRING(AlwaysUseCursorInteraction),
[format ["ACE %1", LLSTRING(Category_InteractionMenu)], LELSTRING(Interaction,InteractionMenuSelf)],
true,
false
] call CBA_settings_fnc_init;

[
QGVAR(cursorKeepCenteredSelfInteraction),
"CHECKBOX",
[LSTRING(cursorKeepCentered), LSTRING(cursorKeepCenteredDescription)],
[format ["ACE %1", LLSTRING(Category_InteractionMenu)], LELSTRING(Interaction,InteractionMenuSelf)],
false,
false
] call CBA_settings_fnc_init;

[
QGVAR(useListMenuSelf),
"CHECKBOX",
LSTRING(UseListMenu),
[format ["ACE %1", LLSTRING(Category_InteractionMenu)], LELSTRING(Interaction,InteractionMenuSelf)],
false,
false
] call CBA_settings_fnc_init;

[
QGVAR(menuBackgroundSelf),
"LIST",
LSTRING(background),
[format ["ACE %1", LLSTRING(Category_InteractionMenu)], LELSTRING(Interaction,InteractionMenuSelf)],
[[0, 1, 2], ["STR_A3_OPTIONS_DISABLED", LLSTRING(backgroundBlur), LLSTRING(backgroundBlack)], 0],
false
] call CBA_settings_fnc_init;

0 comments on commit 8b4e8a6

Please sign in to comment.