Fix CurrentChannel

GVAR -> FUNC
onEachFrame exits when channel control is closed
This commit is contained in:
PabstMirror 2015-02-21 21:19:54 -06:00
parent 11be8f6f8f
commit 8945f99be1
4 changed files with 59 additions and 47 deletions

View File

@ -26,5 +26,5 @@ class RscDisplayInventory {
}; };
class RscDisplayChannel { class RscDisplayChannel {
onLoad = QUOTE(_this call GVAR(onLoadRscDisplayChannel)); onLoad = QUOTE(_this call FUNC(onLoadRscDisplayChannel));
}; };

View File

@ -14,4 +14,4 @@
#define CHANNELS ["group", "side", "global", "command", "vehicle", "direct"] #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"] #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

View File

@ -1,24 +1,29 @@
/* /*
Name: FUNC(onLoadRscDisplayChannel) * Author: Pabst Mirror, commy2
* When the RscDisplayChannel is loaded, this will constantly uiNamespace variable ace_common_currentChannel
Author: Pabst Mirror, commy2 * with the raw localized text of CA_Channel (IDC=101). Only runs while the display is open.
*
Description: * Arguments:
When the RscDisplayChannel is loaded, this will constantly uiNamespace variable "ACE_currentChannel" * 0: The RscDisplayChannel Display <DISPLAY>
with the raw localized text of CA_Channel (IDC=101). Only runs while the display is open. *
* Return Value:
Parameters: * Nothing
0: DISPLAY - RscDisplayChannel *
* Example:
Returns: * onLoad = QUOTE(_this call FUNC(onLoadRscDisplayChannel));
Nothing *
*/ * Public: No
*/
#include "script_component.hpp" #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", { ["ACE_currentChannel", "onEachFrame", {
if (ctrlText (uiNamespace getVariable ["ACE_ctrlChannel", controlNull]) != "") then { if (isNull (uiNamespace getVariable [QGVAR(currentChannelControl), controlNull])) then {
uiNamespace setVariable ["ACE_currentChannel", ctrlText (uiNamespace getVariable ["ACE_ctrlChannel", controlNull])]; ["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; }] call BIS_fnc_addStackedEventhandler;

View File

@ -31,7 +31,13 @@
ctrlSetFocus _text; ctrlSetFocus _text;
//Change ok button's text based on current channel //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);
if (isNull _buttonOK) exitWith {
[_pfhId] call CBA_fnc_removePerFrameHandler;
};
_channel = ""; _channel = "";
_textColor = [1,1,1,1]; _textColor = [1,1,1,1];
@ -67,6 +73,7 @@
_buttonOK ctrlSetTextColor _textColor; _buttonOK ctrlSetTextColor _textColor;
_buttonOK ctrlSetText format [localize "STR_ACE_Markers_PlaceIn", _channel]; _buttonOK ctrlSetText format [localize "STR_ACE_Markers_PlaceIn", _channel];
}; };
}, 0, [_buttonOK]] call CBA_fnc_addPerFrameHandler;
//--- Background //--- Background
_pos = ctrlposition _text; _pos = ctrlposition _text;