Skip to content

Commit

Permalink
added CBA setting for max terminal buffer lines
Browse files Browse the repository at this point in the history
  • Loading branch information
y0014984 committed Aug 22, 2023
1 parent 150dffc commit 41a2b3c
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 7 deletions.
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
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

0 comments on commit 41a2b3c

Please sign in to comment.