diff --git a/addons/armaos/XEH_PREP.hpp b/addons/armaos/XEH_PREP.hpp index 73b4a17e..f45d5493 100644 --- a/addons/armaos/XEH_PREP.hpp +++ b/addons/armaos/XEH_PREP.hpp @@ -114,4 +114,12 @@ PREP(terminal_switchKeyboardLayout); PREP(terminal_switchTerminalDesign); PREP(terminal_setCommandLineByHistory); PREP(terminal_setInputMode); -PREP(terminal_updateBatteryStatus); \ No newline at end of file +PREP(terminal_updateBatteryStatus); + +PREP(terminal_uiOnTex_init); +PREP(terminal_uiOnTex_updateAll); +PREP(terminal_uiOnTex_updateOutput); +PREP(terminal_uiOnTex_updateBatteryStatus); +PREP(terminal_uiOnTex_setTerminalDesign); +PREP(terminal_uiOnTex_setKeyboardLayout); +PREP(terminal_uiOnTex_addUpdateAllEventHandler); \ No newline at end of file diff --git a/addons/armaos/XEH_preInit.sqf b/addons/armaos/XEH_preInit.sqf index 48cf85b3..7ba7569e 100644 --- a/addons/armaos/XEH_preInit.sqf +++ b/addons/armaos/XEH_preInit.sqf @@ -65,4 +65,19 @@ false // Setting will be marked as needing mission restart after being changed. (optional, default false) ] call CBA_fnc_addSetting; +/* ================================================================================ */ + +[ + "AE3_UiOnTexture", + "CHECKBOX", + ["STR_AE3_Main_CbaSettings_UiOnTextureName", "STR_AE3_Main_CbaSettings_UiOnTextureTooltip"], + "STR_AE3_ArmaOS_CbaSettings_ArmaOSCategoryName", + false, + nil, // "_isGlobal" flag. Set this to true to always have this setting synchronized between all clients in multiplayer + { + params ["_value"]; + }, // function that will be executed once on mission start and every time the setting is changed. + false // Setting will be marked as needing mission restart after being changed. (optional, default false) +] call CBA_fnc_addSetting; + /* ================================================================================ */ \ No newline at end of file diff --git a/addons/armaos/functions/fnc_os_shutdown.sqf b/addons/armaos/functions/fnc_os_shutdown.sqf index 41d543a7..7cc4b380 100644 --- a/addons/armaos/functions/fnc_os_shutdown.sqf +++ b/addons/armaos/functions/fnc_os_shutdown.sqf @@ -28,4 +28,10 @@ if (!_ae3OptsSuccess) exitWith {}; _computer setVariable ["AE3_computer_mutex", objNull, true]; closeDialog 1; -private _handle = [_computer, [false]] call (_computer getVariable "AE3_power_fnc_turnOffWrapper"); \ No newline at end of file +private _handle = [_computer, [false]] call (_computer getVariable "AE3_power_fnc_turnOffWrapper"); + +/* ------------- UI on Texture ------------ */ + +_computer setVariable ["AE3_UiOnTexActive", false, true]; // reset var for all clients + +/* ---------------------------------------- */ \ No newline at end of file diff --git a/addons/armaos/functions/fnc_os_standby.sqf b/addons/armaos/functions/fnc_os_standby.sqf index 1aad5e79..1af37e5b 100644 --- a/addons/armaos/functions/fnc_os_standby.sqf +++ b/addons/armaos/functions/fnc_os_standby.sqf @@ -28,4 +28,10 @@ if (!_ae3OptsSuccess) exitWith {}; _computer setVariable ["AE3_computer_mutex", objNull, true]; closeDialog 1; -private _handle = [_computer] spawn (_computer getVariable "AE3_power_fnc_standbyWrapper"); \ No newline at end of file +private _handle = [_computer] spawn (_computer getVariable "AE3_power_fnc_standbyWrapper"); + +/* ------------- UI on Texture ------------ */ + +_computer setVariable ["AE3_UiOnTexActive", false, true]; // reset var for all clients + +/* ---------------------------------------- */ \ No newline at end of file diff --git a/addons/armaos/functions/fnc_terminal_addEventHandler.sqf b/addons/armaos/functions/fnc_terminal_addEventHandler.sqf index 2eaca8b4..1555b070 100644 --- a/addons/armaos/functions/fnc_terminal_addEventHandler.sqf +++ b/addons/armaos/functions/fnc_terminal_addEventHandler.sqf @@ -214,6 +214,14 @@ private _result = _consoleDialog displayAddEventHandler _handleUpdateBatteryStatus = _display getVariable "AE3_handleUpdateBatteryStatus"; [_handleUpdateBatteryStatus] call CBA_fnc_removePerFrameHandler; + + /* ------------- UI on Texture ------------ */ + + _handleUpdateUiOnTexture = _display getVariable "AE3_handleUpdateUiOnTexture"; + [_handleUpdateUiOnTexture] call CBA_fnc_removePerFrameHandler; + + /* ---------------------------------------- */ + // Updates terminal variable for all _terminal = _computer getVariable "AE3_terminal"; _computer setVariable ["AE3_terminal", _terminal, 2]; diff --git a/addons/armaos/functions/fnc_terminal_init.sqf b/addons/armaos/functions/fnc_terminal_init.sqf index cbad0653..832d2d32 100644 --- a/addons/armaos/functions/fnc_terminal_init.sqf +++ b/addons/armaos/functions/fnc_terminal_init.sqf @@ -23,14 +23,6 @@ private _consoleOutput = _consoleDialog displayCtrl 1100; private _languageButton = _consoleDialog displayCtrl 1310; private _designButton = _consoleDialog displayCtrl 1320; -/* -private _handle = [_computer] spawn AE3_power_fnc_showBatteryLevel; - -private _ip = _computer getVariable ["AE3_ipAddress", "127.0.0.1"]; - -_consoleInput setVariable ["ip", _ip]; -*/ - [_computer, "AE3_filesystem"] call AE3_main_fnc_getRemoteVar; [_computer, "AE3_filepointer"] call AE3_main_fnc_getRemoteVar; @@ -133,6 +125,13 @@ private _currentDesign = _designs select _currentDesignIndex; private _handleUpdateBatteryStatus = [_computer, _consoleDialog] call AE3_armaos_fnc_terminal_updateBatteryStatus; _consoleDialog setVariable ["AE3_handleUpdateBatteryStatus", _handleUpdateBatteryStatus]; +/* ------------- UI on Texture ------------ */ + +private _handleUpdateUiOnTexture = [_computer, _consoleDialog] call AE3_armaos_fnc_terminal_uiOnTex_addUpdateAllEventHandler; +_consoleDialog setVariable ["AE3_handleUpdateUiOnTexture", _handleUpdateUiOnTexture]; + +/* ---------------------------------------- */ + [_consoleDialog, _consoleOutput, _languageButton, _designButton] call AE3_armaos_fnc_terminal_addEventHandler; _terminalBuffer = _terminal get "AE3_terminalBuffer"; diff --git a/addons/armaos/functions/fnc_terminal_setKeyboardLayout.sqf b/addons/armaos/functions/fnc_terminal_setKeyboardLayout.sqf index 52a9a9cf..911d9cc9 100644 --- a/addons/armaos/functions/fnc_terminal_setKeyboardLayout.sqf +++ b/addons/armaos/functions/fnc_terminal_setKeyboardLayout.sqf @@ -26,4 +26,15 @@ else ["AE3_KeyboardLayout", _terminalKeyboardLayout, 0, "client", true] call CBA_settings_fnc_set; }; -_computer setVariable ["AE3_terminal", _terminal]; \ No newline at end of file +_computer setVariable ["AE3_terminal", _terminal]; + +/* ------------- UI on Texture ------------ */ + +if (AE3_UiOnTexture) then +{ + private _playersInRange = [3, _computer] call AE3_main_fnc_getPlayersInRange; + + [_computer, _terminalKeyboardLayout] remoteExec ["AE3_armaos_fnc_terminal_uiOnTex_setKeyboardLayout", _playersInRange]; +}; + +/* ---------------------------------------- */ \ No newline at end of file diff --git a/addons/armaos/functions/fnc_terminal_setTerminalDesign.sqf b/addons/armaos/functions/fnc_terminal_setTerminalDesign.sqf index f2d2c51f..b2f3c93a 100644 --- a/addons/armaos/functions/fnc_terminal_setTerminalDesign.sqf +++ b/addons/armaos/functions/fnc_terminal_setTerminalDesign.sqf @@ -41,4 +41,17 @@ _consoleCtrl ctrlSetTextColor _fontColorConsole; private _consoleOutput = _consoleDialog displayCtrl 1100; // set focus to text field, otherwise focus stays on button and prohibits additional text input -ctrlSetFocus _consoleOutput; \ No newline at end of file +ctrlSetFocus _consoleOutput; + +/* ------------- UI on Texture ------------ */ + +if (AE3_UiOnTexture) then +{ + private _playersInRange = [3, _computer] call AE3_main_fnc_getPlayersInRange; + + private _computer = _consoleOutput getVariable "AE3_computer"; + + [_computer, _bgColorHeader, _bgColorConsole, _fontColorHeader, _fontColorConsole] remoteExec ["AE3_armaos_fnc_terminal_uiOnTex_setTerminalDesign", _playersInRange]; +}; + +/* ---------------------------------------- */ \ No newline at end of file diff --git a/addons/armaos/functions/fnc_terminal_uiOnTex_addUpdateAllEventHandler.sqf b/addons/armaos/functions/fnc_terminal_uiOnTex_addUpdateAllEventHandler.sqf new file mode 100644 index 00000000..212b6388 --- /dev/null +++ b/addons/armaos/functions/fnc_terminal_uiOnTex_addUpdateAllEventHandler.sqf @@ -0,0 +1,52 @@ +/** + * Adds an 5 Sec Per-Frame-Event-Handler for the "UI on texture" feature. This will update all contents regularly. + * + * Arguments: + * 1: Computer + * 2: Console + * + * Results: + * None + */ + +params ["_computer", "_consoleDialog"]; + +private _updateInterval = 5; + +_handle = + [ + { + (_this select 0) params ["_computer", "_consoleDialog"]; + + if (AE3_UiOnTexture) then + { + private _playersInRange = [3, _computer] call AE3_main_fnc_getPlayersInRange; + + private _languageButtonCtrl = _consoleDialog displayCtrl 1310; + private _batteryButtonCtrl = _consoleDialog displayCtrl 1050; + private _headerBackgroundCtrl = _consoleDialog displayCtrl 900; + private _consoleBackgroundCtrl = _consoleDialog displayCtrl 910; + private _headerCtrl = _consoleDialog displayCtrl 1000; + private _consoleCtrl = _consoleDialog displayCtrl 1100; + + private _output = ctrlText _consoleCtrl; + private _terminalKeyboardLayout = ctrlText _languageButtonCtrl; + private _value = ctrlText _batteryButtonCtrl; + private _bgColorHeader = ctrlBackgroundColor _headerBackgroundCtrl; + private _bgColorConsole = ctrlBackgroundColor _consoleBackgroundCtrl; + private _fontColorHeader = ctrlTextColor _headerCtrl; + private _fontColorConsole = ctrlTextColor _consoleCtrl; + + private _terminal = _computer getVariable "AE3_terminal"; + + private _terminalBufferVisable = _terminal get "AE3_terminalBufferVisable"; + private _size = _terminal get "AE3_terminalSize"; + + [_computer, _terminalBufferVisable, _size, _terminalKeyboardLayout, _bgColorHeader, _bgColorConsole, _fontColorHeader, _fontColorConsole, _value] remoteExec ["AE3_armaos_fnc_terminal_uiOnTex_updateAll", _playersInRange]; + }; + }, + _updateInterval, + [_computer, _consoleDialog] + ] call CBA_fnc_addPerFrameHandler; + +_handle; \ No newline at end of file diff --git a/addons/armaos/functions/fnc_terminal_uiOnTex_init.sqf b/addons/armaos/functions/fnc_terminal_uiOnTex_init.sqf new file mode 100644 index 00000000..7805c2be --- /dev/null +++ b/addons/armaos/functions/fnc_terminal_uiOnTex_init.sqf @@ -0,0 +1,29 @@ +/** + * Initializes the texture on the given object for the "UI on texture" feature. + * + * Arguments: + * 1: Computer + * + * Results: + * None + */ + +params ["_computer"]; + +/* -------------- WORKAROUND -------------- */ + +// Workaround: We need to preload the UI, so the used images are also preloaded; otherwise the +// images creates a "Cannot load mipmap" error on first usage with the UI2Texture feature +// See these tickets: +// https://feedback.bistudio.com/T171035 +// https://feedback.bistudio.com/T170766 + +private _tmpDisplay = findDisplay 46 createDisplay "AE3_ArmaOS_Main_Dialog"; +_tmpDisplay closeDisplay 1; + +/* ---------------------------------------- */ + +_computer setObjectTexture [1, "#(rgb,1024,1024,1)ui('AE3_ArmaOS_Main_Dialog','AE3_UiOnTexture')"]; + +_computer setVariable ["AE3_UiOnTexActive", true]; // local variable on computer object is sufficient + diff --git a/addons/armaos/functions/fnc_terminal_uiOnTex_setKeyboardLayout.sqf b/addons/armaos/functions/fnc_terminal_uiOnTex_setKeyboardLayout.sqf new file mode 100644 index 00000000..1a739cb7 --- /dev/null +++ b/addons/armaos/functions/fnc_terminal_uiOnTex_setKeyboardLayout.sqf @@ -0,0 +1,26 @@ +/** + * Updates the keyboard layout of the terminal for the "UI on texture" feature. + * + * Arguments: + * 1: Computer + * 2: Keyboard Layout + * + * Results: + * None + */ + +params ["_computer", "_terminalKeyboardLayout"]; + +private _uiOnTexActive = _computer getVariable ["AE3_UiOnTexActive", false]; // local variable on computer object is sufficient + +if (!_uiOnTexActive) then { [_computer] spawn AE3_armaos_fnc_terminal_uiOnTex_init; }; + +waitUntil { !isNull findDisplay "AE3_UiOnTexture" }; + +private _uiOnTextureDisplay = findDisplay "AE3_UiOnTexture"; + +private _uiOnTextureLanguageCtrl = _uiOnTextureDisplay displayCtrl 1310; // Language Control + +_uiOnTextureLanguageCtrl ctrlSetText _terminalKeyboardLayout; + +displayUpdate _uiOnTextureDisplay; \ No newline at end of file diff --git a/addons/armaos/functions/fnc_terminal_uiOnTex_setTerminalDesign.sqf b/addons/armaos/functions/fnc_terminal_uiOnTex_setTerminalDesign.sqf new file mode 100644 index 00000000..d2e8cee2 --- /dev/null +++ b/addons/armaos/functions/fnc_terminal_uiOnTex_setTerminalDesign.sqf @@ -0,0 +1,47 @@ +/** + * Updates the design of the terminal for the "UI on texture" feature. + * + * Arguments: + * 1: Computer + * 2: Background Color Header + * 3: Background Color Console + * 4: Font Color Header + * 5: Font Color Console + * + * Results: + * None + */ + +params ["_computer", "_bgColorHeader", "_bgColorConsole", "_fontColorHeader", "_fontColorConsole"]; + +private _uiOnTexActive = _computer getVariable ["AE3_UiOnTexActive", false]; // local variable on computer object is sufficient + +if (!_uiOnTexActive) then { [_computer] spawn AE3_armaos_fnc_terminal_uiOnTex_init; }; + +waitUntil { !isNull findDisplay "AE3_UiOnTexture" }; + +private _uiOnTextureDisplay = findDisplay "AE3_UiOnTexture"; + +private _uiOnTextureHeaderBackgroundCtrl = _uiOnTextureDisplay displayCtrl 900; +private _uiOnTextureConsoleBackgroundCtrl = _uiOnTextureDisplay displayCtrl 910; + +private _uiOnTextureHeaderCtrl = _uiOnTextureDisplay displayCtrl 1000; +private _uiOnTextureConsoleCtrl = _uiOnTextureDisplay displayCtrl 1100; + +private _uiOnTextureLanguageButtonCtrl = _uiOnTextureDisplay displayCtrl 1310; +private _uiOnTextureDesignButtonCtrl = _uiOnTextureDisplay displayCtrl 1320; +private _uiOnTextureBatteryButtonCtrl = _uiOnTextureDisplay displayCtrl 1050; +private _uiOnTextureCloseButtonCtrl = _uiOnTextureDisplay displayCtrl 1300; + +_uiOnTextureHeaderBackgroundCtrl ctrlSetBackgroundColor _bgColorHeader; +_uiOnTextureConsoleBackgroundCtrl ctrlSetBackgroundColor _bgColorConsole; + +_uiOnTextureHeaderCtrl ctrlSetTextColor _fontColorHeader; +_uiOnTextureLanguageButtonCtrl ctrlSetTextColor _fontColorHeader; +_uiOnTextureDesignButtonCtrl ctrlSetTextColor _fontColorHeader; +_uiOnTextureBatteryButtonCtrl ctrlSetTextColor _fontColorHeader; +_uiOnTextureCloseButtonCtrl ctrlSetTextColor _fontColorHeader; + +_uiOnTextureConsoleCtrl ctrlSetTextColor _fontColorConsole; + +displayUpdate _uiOnTextureDisplay; \ No newline at end of file diff --git a/addons/armaos/functions/fnc_terminal_uiOnTex_updateAll.sqf b/addons/armaos/functions/fnc_terminal_uiOnTex_updateAll.sqf new file mode 100644 index 00000000..d59e7b46 --- /dev/null +++ b/addons/armaos/functions/fnc_terminal_uiOnTex_updateAll.sqf @@ -0,0 +1,85 @@ +/** + * Updates all content of the terminal for the "UI on texture" feature. + * + * Arguments: + * 1: Computer + * 2: Terminal Buffer Visable + * 3: Size + * 4: Keyboard Layout + * 5: Background Color Header + * 6: Background Color Console + * 7: Font Color Header + * 8: Font Color Console + * 9: Battery Symbol Path + * + * Results: + * None + */ + + +params ["_computer", "_terminalBufferVisable", "_size", "_terminalKeyboardLayout", "_bgColorHeader", "_bgColorConsole", "_fontColorHeader", "_fontColorConsole", "_value"]; + +private _uiOnTexActive = _computer getVariable ["AE3_UiOnTexActive", false]; // local variable on computer object is sufficient + +if (!_uiOnTexActive) then { [_computer] spawn AE3_armaos_fnc_terminal_uiOnTex_init; }; + +waitUntil { !isNull findDisplay "AE3_UiOnTexture" }; + +private _uiOnTextureDisplay = findDisplay "AE3_UiOnTexture"; + +/* ---------------------------------------- */ + +private _uiOnTextureHeaderBackgroundCtrl = _uiOnTextureDisplay displayCtrl 900; +private _uiOnTextureConsoleBackgroundCtrl = _uiOnTextureDisplay displayCtrl 910; + +private _uiOnTextureHeaderCtrl = _uiOnTextureDisplay displayCtrl 1000; +private _uiOnTextureConsoleCtrl = _uiOnTextureDisplay displayCtrl 1100; + +private _uiOnTextureLanguageButtonCtrl = _uiOnTextureDisplay displayCtrl 1310; +private _uiOnTextureDesignButtonCtrl = _uiOnTextureDisplay displayCtrl 1320; +private _uiOnTextureBatteryButtonCtrl = _uiOnTextureDisplay displayCtrl 1050; +private _uiOnTextureCloseButtonCtrl = _uiOnTextureDisplay displayCtrl 1300; + +_uiOnTextureHeaderBackgroundCtrl ctrlSetBackgroundColor _bgColorHeader; +_uiOnTextureConsoleBackgroundCtrl ctrlSetBackgroundColor _bgColorConsole; + +_uiOnTextureHeaderCtrl ctrlSetTextColor _fontColorHeader; +_uiOnTextureLanguageButtonCtrl ctrlSetTextColor _fontColorHeader; +_uiOnTextureDesignButtonCtrl ctrlSetTextColor _fontColorHeader; +_uiOnTextureBatteryButtonCtrl ctrlSetTextColor _fontColorHeader; +_uiOnTextureCloseButtonCtrl ctrlSetTextColor _fontColorHeader; + +_uiOnTextureConsoleCtrl ctrlSetTextColor _fontColorConsole; + +/* ---------------------------------------- */ + +private _uiOnTextureBatteryCtrl = _uiOnTextureDisplay displayCtrl 1050; // Battery Control + +_uiOnTextureBatteryCtrl ctrlSetText _value; + +/* ---------------------------------------- */ + +private _uiOnTextureOutputCtrl = _uiOnTextureDisplay displayCtrl 1100; // Console Output Control + +// We need to compose the text again because we can't read the structuredText from the existing control, +// like we do on the other controls. StructuredText is set-only. + +private _output = []; +{ + private _buffer = composeText [_x, lineBreak]; + _buffer setAttributes ["size", str _size, "font", "EtelkaMonospacePro"]; + _output pushBack _buffer; +} forEach _terminalBufferVisable; + +_uiOnTextureOutputCtrl ctrlSetStructuredText (composeText _output); + + +/* ---------------------------------------- */ + +private _uiOnTextureLanguageCtrl = _uiOnTextureDisplay displayCtrl 1310; // Language Control + +_uiOnTextureLanguageCtrl ctrlSetText _terminalKeyboardLayout; + +/* ---------------------------------------- */ + +displayUpdate _uiOnTextureDisplay; \ No newline at end of file diff --git a/addons/armaos/functions/fnc_terminal_uiOnTex_updateBatteryStatus.sqf b/addons/armaos/functions/fnc_terminal_uiOnTex_updateBatteryStatus.sqf new file mode 100644 index 00000000..141f7bae --- /dev/null +++ b/addons/armaos/functions/fnc_terminal_uiOnTex_updateBatteryStatus.sqf @@ -0,0 +1,26 @@ +/** + * Updates the battery symbol of the terminal for the "UI on texture" feature. + * + * Arguments: + * 1: Computer + * 2: Battery Symbol Path + * + * Results: + * None + */ + +params ["_computer", "_value"]; + +private _uiOnTexActive = _computer getVariable ["AE3_UiOnTexActive", false]; // local variable on computer object is sufficient + +if (!_uiOnTexActive) then { [_computer] spawn AE3_armaos_fnc_terminal_uiOnTex_init; }; + +waitUntil { !isNull findDisplay "AE3_UiOnTexture" }; + +private _uiOnTextureDisplay = findDisplay "AE3_UiOnTexture"; + +private _uiOnTextureBatteryCtrl = _uiOnTextureDisplay displayCtrl 1050; // Battery Control + +_uiOnTextureBatteryCtrl ctrlSetText format ["\z\ae3\addons\armaos\images\AE3_battery_%1_percent.paa", _value]; + +displayUpdate _uiOnTextureDisplay; \ No newline at end of file diff --git a/addons/armaos/functions/fnc_terminal_uiOnTex_updateOutput.sqf b/addons/armaos/functions/fnc_terminal_uiOnTex_updateOutput.sqf new file mode 100644 index 00000000..1ac06a9c --- /dev/null +++ b/addons/armaos/functions/fnc_terminal_uiOnTex_updateOutput.sqf @@ -0,0 +1,26 @@ +/** + * Updates terminal output for the "UI on texture" feature. + * + * Arguments: + * 1: Computer + * 2: Output + * + * Results: + * None + */ + +params ["_computer", "_output"]; + +private _uiOnTexActive = _computer getVariable ["AE3_UiOnTexActive", false]; // local variable on computer object is sufficient + +if (!_uiOnTexActive) then { [_computer] spawn AE3_armaos_fnc_terminal_uiOnTex_init; }; + +waitUntil { !isNull findDisplay "AE3_UiOnTexture" }; + +private _uiOnTextureDisplay = findDisplay "AE3_UiOnTexture"; + +private _uiOnTextureOutputCtrl = _uiOnTextureDisplay displayCtrl 1100; // Console Output Control + +_uiOnTextureOutputCtrl ctrlSetStructuredText (composeText _output); + +displayUpdate _uiOnTextureDisplay; \ No newline at end of file diff --git a/addons/armaos/functions/fnc_terminal_updateBatteryStatus.sqf b/addons/armaos/functions/fnc_terminal_updateBatteryStatus.sqf index fb5df285..c8fb2be9 100644 --- a/addons/armaos/functions/fnc_terminal_updateBatteryStatus.sqf +++ b/addons/armaos/functions/fnc_terminal_updateBatteryStatus.sqf @@ -23,14 +23,14 @@ uiNamespace setVariable ["AE3_ConsoleOutput", _outputCtrl]; _handle = [ { - (_this select 0) params ["_battery", "_batteryCtrl"]; + (_this select 0) params ["_computer", "_battery", "_batteryCtrl"]; // We have to use 'spawn' inside 'perFrameEventHandler' because this is a scheduled environment, // but 'getRemoteVar' in 'getBatteryLevel' needs unscheduled environment to work properly. // Otherwise throwing "suspending not allowd in this context" error. - [_battery, _batteryCtrl] spawn + [_computer, _battery, _batteryCtrl] spawn { - params ["_battery", "_batteryCtrl"]; + params ["_computer", "_battery", "_batteryCtrl"]; private _params = [_battery] call AE3_power_fnc_getBatteryLevel; @@ -47,11 +47,25 @@ _handle = _value = (floor (_batteryLevelPercent / 25)) * 25; }; - _batteryCtrl ctrlSetText format ["\z\ae3\addons\armaos\images\AE3_battery_%1_percent.paa", _value]; + private _oldValue = ctrlText _batteryCtrl; + private _newValue = format ["\z\ae3\addons\armaos\images\AE3_battery_%1_percent.paa", _value]; + + _batteryCtrl ctrlSetText _newValue; + + /* ------------- UI on Texture ------------ */ + + if ((AE3_UiOnTexture) && !(_oldValue isEqualTo _newValue)) then + { + private _playersInRange = [3, _computer] call AE3_main_fnc_getPlayersInRange; + + [_computer, _value] remoteExec ["AE3_armaos_fnc_terminal_uiOnTex_updateBatteryStatus", _playersInRange]; + }; + + /* ---------------------------------------- */ }; }, 60, - [_battery, _batteryCtrl] + [_computer, _battery, _batteryCtrl] ] call CBA_fnc_addPerFrameHandler; _handle; \ No newline at end of file diff --git a/addons/armaos/functions/fnc_terminal_updateOutput.sqf b/addons/armaos/functions/fnc_terminal_updateOutput.sqf index 0e4e893d..3103b3c1 100644 --- a/addons/armaos/functions/fnc_terminal_updateOutput.sqf +++ b/addons/armaos/functions/fnc_terminal_updateOutput.sqf @@ -29,4 +29,15 @@ private _output = []; _outputControl ctrlSetStructuredText (composeText _output); ctrlSetFocus _outputControl; -_computer setVariable ["AE3_terminal", _terminal]; \ No newline at end of file +_computer setVariable ["AE3_terminal", _terminal]; + +/* ------------- UI on Texture ------------ */ + +if (AE3_UiOnTexture) then +{ + private _playersInRange = [3, _computer] call AE3_main_fnc_getPlayersInRange; + + [_computer, _output] remoteExec ["AE3_armaos_fnc_terminal_uiOnTex_updateOutput", _playersInRange]; +}; + +/* ---------------------------------------- */ \ No newline at end of file diff --git a/addons/armaos/stringtable.xml b/addons/armaos/stringtable.xml index e4990aa8..42558c5e 100644 --- a/addons/armaos/stringtable.xml +++ b/addons/armaos/stringtable.xml @@ -1324,6 +1324,24 @@ Détermine la vitesse en lignes de la fonction de défilement de la molette de la souris pour le terminal. Determina la velocità in linee per la funzionalità di scroll della rotellina del mouse. + + UI on texture + UI on texture + UI auf Textur + UI on texture + UI on texture + UI on texture + UI on texture + + + If enabled, surrounding players can see the armaOS interface on the computers texture. + If enabled, surrounding players can see the armaOS interface on the computers texture. + Wenn aktiviert, können Spieler in der Nähe das armaOS Interface auf der Textur des Computers sehen. + If enabled, surrounding players can see the armaOS interface on the computers texture. + If enabled, surrounding players can see the armaOS interface on the computers texture. + If enabled, surrounding players can see the armaOS interface on the computers texture. + If enabled, surrounding players can see the armaOS interface on the computers texture. + 1 line 1 line diff --git a/addons/main/XEH_PREP.hpp b/addons/main/XEH_PREP.hpp index dea3d2c3..97d167c0 100644 --- a/addons/main/XEH_PREP.hpp +++ b/addons/main/XEH_PREP.hpp @@ -16,3 +16,6 @@ PREP(3den_checkConnection); PREP(3den_doNetworkConnection); PREP(3den_doPowerConnection); PREP(killDebugOverlay); + +// Misc +PREP(getPlayersInRange); diff --git a/addons/main/functions/fnc_getPlayersInRange.sqf b/addons/main/functions/fnc_getPlayersInRange.sqf new file mode 100644 index 00000000..903b720f --- /dev/null +++ b/addons/main/functions/fnc_getPlayersInRange.sqf @@ -0,0 +1,18 @@ +/** + * Returns all players within a radius around the given object. + * + * Arguments: + * 0: Range + * 1: Object + * + * Return: + * Nothing + */ + +params ["_range", "_object"]; + +private _allPlayers = [] call BIS_fnc_listPlayers; // Only players, not headless clients + +private _playersInRange = _allPlayers select {(_x distance _object) < _range}; + +_playersInRange; \ No newline at end of file