mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Fix basic UI being overwritten on RscDiary unload (#3920)
* Display disabled message when basic config set by mission showHud * Set showHud on RscDiary unload - fix #3907, Remove redundant force parameter from basic setElements * Log forced source to RPT * Add source to scripted element setter
This commit is contained in:
parent
5d9def3874
commit
ed15d99915
@ -15,3 +15,10 @@ class Extended_PostInit_EventHandlers {
|
|||||||
clientInit = QUOTE(call COMPILE_FILE(XEH_clientInit));
|
clientInit = QUOTE(call COMPILE_FILE(XEH_clientInit));
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Closing diary resets showHUD
|
||||||
|
class Extended_DisplayUnload_EventHandlers {
|
||||||
|
class RscDiary {
|
||||||
|
ADDON = QUOTE([{[false] call FUNC(setElements)}] call CBA_fnc_execNextFrame);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
PREP(findSetElement);
|
||||||
PREP(moduleInit);
|
PREP(moduleInit);
|
||||||
PREP(setAdvancedElement);
|
PREP(setAdvancedElement);
|
||||||
PREP(setElements);
|
PREP(setElements);
|
||||||
|
@ -5,7 +5,7 @@ if (!hasInterface) exitWith {};
|
|||||||
|
|
||||||
["ace_settingsInitialized", {
|
["ace_settingsInitialized", {
|
||||||
// Initial settings
|
// Initial settings
|
||||||
[true] call FUNC(setElements);
|
[false] call FUNC(setElements);
|
||||||
|
|
||||||
// On load and entering/exiting a vehicle
|
// On load and entering/exiting a vehicle
|
||||||
["ace_infoDisplayChanged", {
|
["ace_infoDisplayChanged", {
|
||||||
@ -30,7 +30,7 @@ if (!hasInterface) exitWith {};
|
|||||||
params ["_name"];
|
params ["_name"];
|
||||||
|
|
||||||
if (_name in ELEMENTS_BASIC) then {
|
if (_name in ELEMENTS_BASIC) then {
|
||||||
[false] call FUNC(setElements);
|
[true] call FUNC(setElements);
|
||||||
} else {
|
} else {
|
||||||
if (isClass (configFile >> "ACE_UI" >> _name select [7])) then {
|
if (isClass (configFile >> "ACE_UI" >> _name select [7])) then {
|
||||||
[_name select [7], missionNamespace getVariable _name, true] call FUNC(setAdvancedElement);
|
[_name select [7], missionNamespace getVariable _name, true] call FUNC(setAdvancedElement);
|
||||||
|
25
addons/ui/functions/fnc_findSetElement.sqf
Normal file
25
addons/ui/functions/fnc_findSetElement.sqf
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Author: Jonpas
|
||||||
|
* Finds set element by element name and returns index, source of the set element and state.
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: Element Name <STRING>
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* ["ace_ui_ammoCount"] call ace_ui_fnc_findSetElement
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
|
*/
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
params ["_element"];
|
||||||
|
|
||||||
|
{
|
||||||
|
if (_element in _x) exitWith {
|
||||||
|
[_forEachIndex, _x select 0, _x select 2]
|
||||||
|
};
|
||||||
|
[-1, "", false]
|
||||||
|
} forEach GVAR(elementsSet);
|
@ -39,10 +39,10 @@ private _elements = getArray (_config >> "elements");
|
|||||||
{
|
{
|
||||||
private _condition = call compile (getText _x);
|
private _condition = call compile (getText _x);
|
||||||
if !(_condition) exitWith {
|
if !(_condition) exitWith {
|
||||||
TRACE_2("Condition False",_element,_x);
|
|
||||||
// Display and print info which component forced the element except for default vehicle check
|
// Display and print info which component forced the element except for default vehicle check
|
||||||
if (_showHint) then {
|
if (_showHint) then {
|
||||||
[LSTRING(Disabled), 2] call EFUNC(common,displayTextStructured);
|
[LSTRING(Disabled), 2] call EFUNC(common,displayTextStructured);
|
||||||
|
ACE_LOGINFO_2("Attempted modification of a forced User Interface element '%1' by '%2'",_element,configName _x);
|
||||||
};
|
};
|
||||||
_show = false;
|
_show = false;
|
||||||
};
|
};
|
||||||
@ -50,15 +50,15 @@ private _elements = getArray (_config >> "elements");
|
|||||||
|
|
||||||
// Get setting from scripted API
|
// Get setting from scripted API
|
||||||
if (!_force) then {
|
if (!_force) then {
|
||||||
private _index = GVAR(elementsSet) find [_element, _show];
|
private _setElement = [_element] call FUNC(findSetElement);
|
||||||
if (_index == -1) then {
|
_setElement params ["_indexSet", "_sourceSet", "_showSet"];
|
||||||
_index = GVAR(elementsSet) find [_element, !_show];
|
|
||||||
if (_index != -1) then {
|
if (_indexSet != -1) then {
|
||||||
if (_showHint) then {
|
if (_showHint) then {
|
||||||
[LSTRING(Disabled), 2] call EFUNC(common,displayTextStructured);
|
[LSTRING(Disabled), 2] call EFUNC(common,displayTextStructured);
|
||||||
};
|
ACE_LOGINFO_2("Attempted modification of a forced User Interface element '%1' by '%2'",_element,_sourceSet);
|
||||||
_show = ((GVAR(elementsSet)) select _index) select 1;
|
|
||||||
};
|
};
|
||||||
|
_show = _showSet;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3,21 +3,23 @@
|
|||||||
* Setter for toggling advanced element visibility.
|
* Setter for toggling advanced element visibility.
|
||||||
*
|
*
|
||||||
* Arguments:
|
* Arguments:
|
||||||
* 0: Set/Unset <BOOL>
|
* 0: Source <STRING>
|
||||||
* 1: Element Name <ARRAY/STRING>
|
* 1: Set/Unset <BOOL>
|
||||||
* 2: Show/Hide Element <BOOL> (default: false)
|
* 2: Element Name <STRING>
|
||||||
|
* 3: Show/Hide Element <BOOL> (default: false)
|
||||||
*
|
*
|
||||||
* Return Value:
|
* Return Value:
|
||||||
* None
|
* None
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* [true, "ace_ui_ammoCount", false] call ace_ui_fnc_setElementVisibility
|
* ["ace_reload", true, "ace_ui_ammoCount", false] call ace_ui_fnc_setElementVisibility
|
||||||
*
|
*
|
||||||
* Public: Yes
|
* Public: Yes
|
||||||
*/
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
params [
|
params [
|
||||||
|
["_source", "", [""]],
|
||||||
["_set", true, [true]],
|
["_set", true, [true]],
|
||||||
["_element", "", [""]],
|
["_element", "", [""]],
|
||||||
["_show", false, [true]]
|
["_show", false, [true]]
|
||||||
@ -28,32 +30,35 @@ if (!isClass (configFile >> "ACE_UI" >> _element)) exitWith {
|
|||||||
ACE_LOGWARNING_1("Element '%1' does not exist",_element);
|
ACE_LOGWARNING_1("Element '%1' does not exist",_element);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (_source == "" || {_element == ""}) exitWith {
|
||||||
|
ACE_LOGWARNING("Source or Element may not be empty strings!");
|
||||||
|
};
|
||||||
|
|
||||||
private _return = false;
|
private _return = false;
|
||||||
|
|
||||||
|
private _setElement = [_element] call FUNC(findSetElement);
|
||||||
|
_setElement params ["_indexSet", "_sourceSet"];
|
||||||
|
|
||||||
if (_set) then {
|
if (_set) then {
|
||||||
// Exit if element has been set from another component, print warning if after interface initialization
|
// Exit if element has been set from another component, print warning if after interface initialization
|
||||||
if ([_element, _show] in GVAR(elementsSet) || {[_element, !_show] in GVAR(elementsSet)}) exitWith {
|
if (_indexSet != -1) exitWith {
|
||||||
if (GVAR(interfaceInitialized)) then {
|
if (GVAR(interfaceInitialized)) then {
|
||||||
ACE_LOGWARNING_2("Element '%1' already set in %2",_element,GVAR(elementsSet));
|
ACE_LOGWARNING_2("Element '%1' already set by %2",_element,_sourceSet);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
TRACE_3("Setting element",_element,_show,GVAR(elementsSet));
|
TRACE_4("Setting element",_source,_element,_show,GVAR(elementsSet));
|
||||||
private _success = [_element, _show, false, true] call FUNC(setAdvancedElement);
|
private _success = [_element, _show, false, true] call FUNC(setAdvancedElement);
|
||||||
|
|
||||||
if (_success) then {
|
if (_success) then {
|
||||||
GVAR(elementsSet) pushBack [_element, _show];
|
GVAR(elementsSet) pushBack [_source, _element, _show];
|
||||||
_return = true;
|
_return = true;
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
if ([_element, _show] in GVAR(elementsSet) || {[_element, !_show] in GVAR(elementsSet)}) then {
|
if (_indexSet != -1) then {
|
||||||
TRACE_3("Unsetting element",_element,_show,GVAR(elementsSet));
|
TRACE_4("Unsetting element",_sourceSet,_element,_show,GVAR(elementsSet));
|
||||||
|
|
||||||
private _index = GVAR(elementsSet) find [_element, _show];
|
GVAR(elementsSet) deleteAt _indexSet;
|
||||||
if (_index == -1) then {
|
|
||||||
_index = GVAR(elementsSet) find [_element, !_show];
|
|
||||||
};
|
|
||||||
GVAR(elementsSet) deleteAt _index;
|
|
||||||
|
|
||||||
[_element, _show, false, true] call FUNC(setAdvancedElement);
|
[_element, _show, false, true] call FUNC(setAdvancedElement);
|
||||||
_return = true;
|
_return = true;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* Sets basic visible elements of the UI using showHUD setter.
|
* Sets basic visible elements of the UI using showHUD setter.
|
||||||
*
|
*
|
||||||
* Arguments:
|
* Arguments:
|
||||||
* 0: Force change even when disallowed <BOOL> (default: false)
|
* 0: Show Hint <BOOL> (default: false)
|
||||||
*
|
*
|
||||||
* Return Value:
|
* Return Value:
|
||||||
* None
|
* None
|
||||||
@ -15,9 +15,13 @@
|
|||||||
*/
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
if (isArray (missionConfigFile >> "showHUD")) exitWith {};
|
params [["_showHint", false]];
|
||||||
|
|
||||||
params [ ["_force", false, [true]] ];
|
if (isArray (missionConfigFile >> "showHUD")) exitWith {
|
||||||
|
if (_showHint) then {
|
||||||
|
[LSTRING(Disabled)] call EFUNC(common,displayTextStructured);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
["ui", [
|
["ui", [
|
||||||
true,
|
true,
|
||||||
|
Loading…
Reference in New Issue
Block a user