-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
UI on texture #340
UI on texture #340
Changes from all commits
f9a801e
ec00e33
1060f2a
fe007c9
4440f49
ef24ce9
c5625d9
c9f62ff
3dad392
464ef1e
80078c0
a378028
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <OBJECT> | ||
* 2: Console <DIALOG> | ||
* | ||
* Results: | ||
* None | ||
*/ | ||
|
||
params ["_computer", "_consoleDialog"]; | ||
|
||
private _updateInterval = 5; | ||
|
||
_handle = | ||
[ | ||
{ | ||
(_this select 0) params ["_computer", "_consoleDialog"]; | ||
|
||
if (AE3_UiOnTexture) then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why apply the per frame handler, if the feature is disabled? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
{ | ||
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; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* Initializes the texture on the given object for the "UI on texture" feature. | ||
* | ||
* Arguments: | ||
* 1: Computer <OBJECT> | ||
* | ||
* 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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* Updates the keyboard layout of the terminal for the "UI on texture" feature. | ||
* | ||
* Arguments: | ||
* 1: Computer <OBJECT> | ||
* 2: Keyboard Layout <STRING> | ||
* | ||
* 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; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* Updates the design of the terminal for the "UI on texture" feature. | ||
* | ||
* Arguments: | ||
* 1: Computer <OBJECT> | ||
* 2: Background Color Header <COLOR> | ||
* 3: Background Color Console <COLOR> | ||
* 4: Font Color Header <COLOR> | ||
* 5: Font Color Console <COLOR> | ||
* | ||
* 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; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/** | ||
* Updates all content of the terminal for the "UI on texture" feature. | ||
* | ||
* Arguments: | ||
* 1: Computer <OBJECT> | ||
* 2: Terminal Buffer Visable <ARRAY> | ||
* 3: Size <NUMBER> | ||
* 4: Keyboard Layout <STRING> | ||
* 5: Background Color Header <COLOR> | ||
* 6: Background Color Console <COLOR> | ||
* 7: Font Color Header <COLOR> | ||
* 8: Font Color Console <COLOR> | ||
* 9: Battery Symbol Path <STRING> | ||
* | ||
* 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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to update regularly? Isn't everything pushed when it changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, everything is pushed, but if player A uses the Terminal and only reads it without any interaction, there is nothing to push. If player B enters the circle, he won't see the actual content/interface. Imagine a player is not sitting in front of his real life computer and blocking the laptop, or thinking very long about the next command or perhaps unconciousness. That's why there will be an auto-push-interval.