Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various Bugfixes and Minor Enhancements #391

Merged
merged 13 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions addons/armaos/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,46 @@
false // Setting will be marked as needing mission restart after being changed. (optional, default false) <BOOL>
] call CBA_fnc_addSetting;

/* ================================================================================ */

[
"AE3_MaxTerminalBufferLines",
"EDITBOX",
["STR_AE3_Main_CbaSettings_MaxTerminalBufferLinesName", "STR_AE3_Main_CbaSettings_MaxTerminalBufferLinesTooltip"],
"STR_AE3_ArmaOS_CbaSettings_ArmaOSCategoryName",
"100",
nil, // "_isGlobal" flag. Set this to true to always have this setting synchronized between all clients in multiplayer
{
params ["_value"];

// use an editbox to manage a number

// string to number
_value = parseNumber _value;

// float to int
_value = round _value;

// ignore negative values; -1 means "no limit"
if (_value < -1) then { _value = 100; };

// if 0 then reset to default
if (_value == 0) then { _value = 100; };

// write/sync changed value back to CBA settings
if (!isMultiplayer || (isServer && hasInterface)) then
{
// In singeplayer or as host in a multiplayer session
["AE3_MaxTerminalBufferLines", str _value, 0, "server", true] call CBA_settings_fnc_set;
}
else
{
// As client in a multiplayer session
["AE3_MaxTerminalBufferLines", str _value, 0, "client", true] call CBA_settings_fnc_set;
};

}, // 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) <BOOL>
] call CBA_fnc_addSetting;

/* ================================================================================ */
17 changes: 10 additions & 7 deletions addons/armaos/functions/fnc_terminal_addEventHandler.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,16 @@ private _result = _consoleDialog displayAddEventHandler
private _terminal = _computer getVariable "AE3_terminal";
private _filepointer = _computer getVariable "AE3_filepointer";

// crop terminal buffer to max lines
private _maxLines = 100;
private _terminalBuffer = _terminal get "AE3_terminalBuffer";
private _terminalBufferCount = count _terminalBuffer;
if (_terminalBufferCount <= _maxLines) then { _maxLines = _terminalBufferCount; };
_terminalBuffer = _terminalBuffer select [(count _terminalBuffer) - _maxLines, _maxLines];
_terminal set ["AE3_terminalBuffer", _terminalBuffer];
// crop terminal buffer to max lines; -1 means 'no limit'
if (!(AE3_MaxTerminalBufferLines isEqualTo "-1")) then
{
private _maxLines = parseNumber AE3_MaxTerminalBufferLines;
private _terminalBuffer = _terminal get "AE3_terminalBuffer";
private _terminalBufferCount = count _terminalBuffer;
if (_terminalBufferCount <= _maxLines) then { _maxLines = _terminalBufferCount; };
_terminalBuffer = _terminalBuffer select [(count _terminalBuffer) - _maxLines, _maxLines];
_terminal set ["AE3_terminalBuffer", _terminalBuffer];
};

// adjust cursor line and position
_terminal set ["AE3_terminalCursorLine", (count _terminalBuffer) - 1];
Expand Down
4 changes: 2 additions & 2 deletions addons/armaos/functions/fnc_terminal_init.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ params ["_computer"];
// because the mutex variable is not removed in this case, because the event handler to remove it
// on closing the dialog can't be created because of missing dialog variables

hint "Please be patient while the computer initializes ...";
hintSilent "Please be patient while the computer initializes ...";

/* ---------------------------------------- */

Expand Down Expand Up @@ -184,4 +184,4 @@ _consoleDialog setVariable ["AE3_handleUpdateUiOnTexture", _handleUpdateUiOnText
/* ---------------------------------------- */

// clear the previously set "be patient" message
hint "";
hintSilent "";
7 changes: 1 addition & 6 deletions addons/armaos/functions/fnc_terminal_setKeyboardLayout.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,7 @@ _computer setVariable ["AE3_terminal", _terminal];

if (AE3_UiOnTexture) then
{
private _playersInRange = [3, _computer] call AE3_main_fnc_getPlayersInRange;

if ((count _playersInRange) > 0) then
{
[_computer, _terminalKeyboardLayout] remoteExec ["AE3_armaos_fnc_terminal_uiOnTex_setKeyboardLayout", _playersInRange];
};
[3, _computer, "AE3_armaos_fnc_terminal_uiOnTex_setKeyboardLayout", [_computer, _terminalKeyboardLayout]] call AE3_main_fnc_executeForPlayersInRange;
};

/* ---------------------------------------- */
7 changes: 2 additions & 5 deletions addons/armaos/functions/fnc_terminal_setTerminalDesign.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,9 @@ if (AE3_UiOnTexture) then
{
private _computer = _consoleOutput getVariable "AE3_computer";

private _playersInRange = [3, _computer] call AE3_main_fnc_getPlayersInRange;
private _args = [_computer, _bgColorHeader, _bgColorConsole, _fontColorHeader, _fontColorConsole];

if ((count _playersInRange) > 0) then
{
[_computer, _bgColorHeader, _bgColorConsole, _fontColorHeader, _fontColorConsole] remoteExec ["AE3_armaos_fnc_terminal_uiOnTex_setTerminalDesign", _playersInRange];
};
[3, _computer, "AE3_armaos_fnc_terminal_uiOnTex_setTerminalDesign", _args] call AE3_main_fnc_executeForPlayersInRange;
};

/* ---------------------------------------- */
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,29 @@ _handle =

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;

if ((count _playersInRange) > 0) then
{
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 _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 _terminal = _computer getVariable "AE3_terminal";
private _terminalBufferVisible = _terminal get "AE3_terminalBufferVisible";
private _size = _terminal get "AE3_terminalSize";

private _terminalBufferVisible = _terminal get "AE3_terminalBufferVisible";
private _size = _terminal get "AE3_terminalSize";
private _args = [_computer, _terminalBufferVisible, _size, _terminalKeyboardLayout, _bgColorHeader, _bgColorConsole, _fontColorHeader, _fontColorConsole, _value];

[_computer, _terminalBufferVisible, _size, _terminalKeyboardLayout, _bgColorHeader, _bgColorConsole, _fontColorHeader, _fontColorConsole, _value] remoteExec ["AE3_armaos_fnc_terminal_uiOnTex_updateAll", _playersInRange];
};
[3, _computer, "AE3_armaos_fnc_terminal_uiOnTex_updateAll", _args] call AE3_main_fnc_executeForPlayersInRange;
}
else
{
Expand Down
4 changes: 1 addition & 3 deletions addons/armaos/functions/fnc_terminal_updateBatteryStatus.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ _handle =

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];
[3, _computer, "AE3_armaos_fnc_terminal_uiOnTex_updateBatteryStatus", [_computer, _value]] call AE3_main_fnc_executeForPlayersInRange;
};

/* ---------------------------------------- */
Expand Down
7 changes: 1 addition & 6 deletions addons/armaos/functions/fnc_terminal_updateOutput.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,7 @@ _computer setVariable ["AE3_terminal", _terminal];

if (AE3_UiOnTexture) then
{
private _playersInRange = [3, _computer] call AE3_main_fnc_getPlayersInRange;

if ((count _playersInRange) > 0) then
{
[_computer, _output] remoteExec ["AE3_armaos_fnc_terminal_uiOnTex_updateOutput", _playersInRange];
};
[3, _computer, "AE3_armaos_fnc_terminal_uiOnTex_updateOutput", [_computer, _output]] call AE3_main_fnc_executeForPlayersInRange;
};

/* ---------------------------------------- */
18 changes: 18 additions & 0 deletions addons/armaos/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1409,6 +1409,24 @@
<French>Si activé, les joueurs environnants peuvent voir l'interface armaOS sur la texture de l'ordinateur.</French>
<Italian>Se abilitato, i giocatori vicini possono vedere l'interfaccia di armaOS nella texture del computer.</Italian>
</Key>
<Key ID="STR_AE3_Main_CbaSettings_MaxTerminalBufferLinesName">
<Original>Max Terminal Buffer Lines</Original>
<English>Max Terminal Buffer Lines</English>
<German>Maximale Terminal-Buffer-Zeilen</German>
<Chinesesimp>Max Terminal Buffer Lines</Chinesesimp>
<Russian>Max Terminal Buffer Lines</Russian>
<French>Max Terminal Buffer Lines</French>
<Italian>Max Terminal Buffer Lines</Italian>
</Key>
<Key ID="STR_AE3_Main_CbaSettings_MaxTerminalBufferLinesTooltip">
<Original>Determines the amount of terminal output buffer lines that is stored when leaving the computer. While using it the amount is not restricted. A value of -1 means 'no storing limit'.</Original>
<English>Determines the amount of terminal output buffer lines that is stored when leaving the computer. While using it the amount is not restricted. A value of -1 means 'no storing limit'.</English>
<German>Legt die Anzahl der Terminal-Output-Buffer-Zeilen fest, die nach verlassen des Computers gespeichert werden. Während der Nutzung ist die Anzahl nicht begrenzt. Ein Wert von -1 bedeutet, 'keine Speicherbegrenzung'.</German>
<Chinesesimp>Determines the amount of terminal output buffer lines that is stored when leaving the computer. While using it the amount is not restricted. A value of -1 means 'no storing limit'.</Chinesesimp>
<Russian>Determines the amount of terminal output buffer lines that is stored when leaving the computer. While using it the amount is not restricted. A value of -1 means 'no storing limit'.</Russian>
<French>Determines the amount of terminal output buffer lines that is stored when leaving the computer. While using it the amount is not restricted. A value of -1 means 'no storing limit'.</French>
<Italian>Determines the amount of terminal output buffer lines that is stored when leaving the computer. While using it the amount is not restricted. A value of -1 means 'no storing limit'.</Italian>
</Key>
<Key ID="STR_AE3_Main_CbaSettings_1line">
<Original>1 line</Original>
<English>1 line</English>
Expand Down
1 change: 1 addition & 0 deletions addons/main/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ PREP(3den_checkConnection);

/* Misc */
PREP(getPlayersInRange);
PREP(executeForPlayersInRange);

/* Terminate */
PREP(terminateDevice);
Expand Down
31 changes: 31 additions & 0 deletions addons/main/functions/fnc_executeForPlayersInRange.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Gets all players within a radius around the given object and executes a given function, command or script with arguments on these clients.
*
* Arguments:
* 0: Range <NUMBER>
* 1: Object <OBJECT>
* 2: Function <STRING> or <CODE>
* 3: Arguments <ANY>
*
* Return:
* Nothing
*/

params ["_range", "_object", "_fnc", "_args"];

private _playersInRange = [_range, _object] call AE3_main_fnc_getPlayersInRange;

// using remoteExec on a zero sized array leads to RPT spam warnings
if ((count _playersInRange) == 0) exitWith {};

// use remoteExec if _fnc is type "string"
y0014984 marked this conversation as resolved.
Show resolved Hide resolved
if ((typeName _fnc) isEqualTo "STRING") then
{
_args remoteExec [_fnc, _playersInRange];
};

// use a remote executed "call" if _fnc is type "code"
if ((typeName _fnc) isEqualTo "CODE") then
{
[_args, _fnc] remoteExec ["call", _playersInRange];
y0014984 marked this conversation as resolved.
Show resolved Hide resolved
};