mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Fix CurrentChannel
GVAR -> FUNC onEachFrame exits when channel control is closed
This commit is contained in:
parent
11be8f6f8f
commit
8945f99be1
@ -26,5 +26,5 @@ class RscDisplayInventory {
|
||||
};
|
||||
|
||||
class RscDisplayChannel {
|
||||
onLoad = QUOTE(_this call GVAR(onLoadRscDisplayChannel));
|
||||
onLoad = QUOTE(_this call FUNC(onLoadRscDisplayChannel));
|
||||
};
|
||||
|
@ -14,4 +14,4 @@
|
||||
#define CHANNELS ["group", "side", "global", "command", "vehicle", "direct"]
|
||||
#define CHANNELS_LOCALIZED [localize "str_channel_group", localize "str_channel_side", localize "str_channel_global", localize "str_channel_command", localize "str_channel_vehicle", localize "str_channel_direct"]
|
||||
|
||||
CHANNELS select (CHANNELS_LOCALIZED find (uiNamespace getVariable ["ACE_currentChannel", ""])) max 0
|
||||
CHANNELS select (CHANNELS_LOCALIZED find (uiNamespace getVariable [QGVAR(currentChannel), ""])) max 0
|
||||
|
@ -1,24 +1,29 @@
|
||||
/*
|
||||
Name: FUNC(onLoadRscDisplayChannel)
|
||||
|
||||
Author: Pabst Mirror, commy2
|
||||
|
||||
Description:
|
||||
When the RscDisplayChannel is loaded, this will constantly uiNamespace variable "ACE_currentChannel"
|
||||
with the raw localized text of CA_Channel (IDC=101). Only runs while the display is open.
|
||||
|
||||
Parameters:
|
||||
0: DISPLAY - RscDisplayChannel
|
||||
|
||||
Returns:
|
||||
Nothing
|
||||
*/
|
||||
* Author: Pabst Mirror, commy2
|
||||
* When the RscDisplayChannel is loaded, this will constantly uiNamespace variable ace_common_currentChannel
|
||||
* with the raw localized text of CA_Channel (IDC=101). Only runs while the display is open.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: The RscDisplayChannel Display <DISPLAY>
|
||||
*
|
||||
* Return Value:
|
||||
* Nothing
|
||||
*
|
||||
* Example:
|
||||
* onLoad = QUOTE(_this call FUNC(onLoadRscDisplayChannel));
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
uiNamespace setVariable ["ACE_ctrlChannel", (_this select 0) displayCtrl 101];
|
||||
uiNamespace setVariable [QGVAR(currentChannelControl), ((_this select 0) displayCtrl 101)];
|
||||
|
||||
["ACE_currentChannel", "onEachFrame", {
|
||||
if (ctrlText (uiNamespace getVariable ["ACE_ctrlChannel", controlNull]) != "") then {
|
||||
uiNamespace setVariable ["ACE_currentChannel", ctrlText (uiNamespace getVariable ["ACE_ctrlChannel", controlNull])];
|
||||
};
|
||||
if (isNull (uiNamespace getVariable [QGVAR(currentChannelControl), controlNull])) then {
|
||||
["ACE_currentChannel", "onEachFrame"] call BIS_fnc_removeStackedEventHandler;
|
||||
} else {
|
||||
private "_localizedChannelText";
|
||||
_localizedChannelText = ctrlText (uiNamespace getVariable [QGVAR(currentChannelControl), controlNull]);
|
||||
uiNamespace setVariable [QGVAR(currentChannel), _localizedChannelText];
|
||||
};
|
||||
}] call BIS_fnc_addStackedEventhandler;
|
||||
|
@ -31,42 +31,49 @@
|
||||
ctrlSetFocus _text;
|
||||
|
||||
//Change ok button's text based on current channel
|
||||
//if (isNull _buttonOK) exitWith {true};
|
||||
[{
|
||||
EXPLODE_2_PVT(_this,_params,_pfhId);
|
||||
EXPLODE_1_PVT(_params,_buttonOK);
|
||||
|
||||
_channel = "";
|
||||
_textColor = [1,1,1,1];
|
||||
switch (call EFUNC(common,currentChannel)) do {
|
||||
if (isNull _buttonOK) exitWith {
|
||||
[_pfhId] call CBA_fnc_removePerFrameHandler;
|
||||
};
|
||||
|
||||
_channel = "";
|
||||
_textColor = [1,1,1,1];
|
||||
switch (call EFUNC(common,currentChannel)) do {
|
||||
case ("global"): {
|
||||
_channel = localize "str_channel_global";
|
||||
_textColor = [(216/255),(216/255),(216/255),1];
|
||||
};
|
||||
_channel = localize "str_channel_global";
|
||||
_textColor = [(216/255),(216/255),(216/255),1];
|
||||
};
|
||||
case ("side"): {
|
||||
_channel = localize "str_channel_side";
|
||||
_textColor = [(70/255),(211/255),(252/255),1];
|
||||
};
|
||||
_channel = localize "str_channel_side";
|
||||
_textColor = [(70/255),(211/255),(252/255),1];
|
||||
};
|
||||
case ("group"): {
|
||||
_channel = localize "str_channel_group";
|
||||
_textColor = [(181/255),(248/255),(98/255),1];
|
||||
};
|
||||
_channel = localize "str_channel_group";
|
||||
_textColor = [(181/255),(248/255),(98/255),1];
|
||||
};
|
||||
case ("vehicle"): {
|
||||
_channel = localize "str_channel_vehicle";
|
||||
_textColor = [(255/255),(208/255),(0/255),1];
|
||||
};
|
||||
_channel = localize "str_channel_vehicle";
|
||||
_textColor = [(255/255),(208/255),(0/255),1];
|
||||
};
|
||||
case ("direct"): {
|
||||
_channel = localize "str_channel_direct";
|
||||
_textColor = [(255/255),(255/255),(255/255),1];
|
||||
};
|
||||
_channel = localize "str_channel_direct";
|
||||
_textColor = [(255/255),(255/255),(255/255),1];
|
||||
};
|
||||
case ("command"): {
|
||||
_channel = localize "str_channel_command";
|
||||
_textColor = [(255/255),(255/255),(70/255),1];
|
||||
_channel = localize "str_channel_command";
|
||||
_textColor = [(255/255),(255/255),(70/255),1];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
//If localization not found, then don't touch anything (default is RscButtonMenuOK's localized text)
|
||||
if (_channel != "") then {
|
||||
_buttonOK ctrlSetTextColor _textColor;
|
||||
_buttonOK ctrlSetText format [localize "STR_ACE_Markers_PlaceIn", _channel];
|
||||
};
|
||||
//If localization not found, then don't touch anything (default is RscButtonMenuOK's localized text)
|
||||
if (_channel != "") then {
|
||||
_buttonOK ctrlSetTextColor _textColor;
|
||||
_buttonOK ctrlSetText format [localize "STR_ACE_Markers_PlaceIn", _channel];
|
||||
};
|
||||
}, 0, [_buttonOK]] call CBA_fnc_addPerFrameHandler;
|
||||
|
||||
//--- Background
|
||||
_pos = ctrlposition _text;
|
||||
|
Loading…
Reference in New Issue
Block a user