This repository was archived by the owner on Apr 29, 2024. It is now read-only.
forked from EpicGames/PixelStreamingInfrastructure
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathActionOverlay.ts
More file actions
57 lines (50 loc) · 1.63 KB
/
ActionOverlay.ts
File metadata and controls
57 lines (50 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright Epic Games, Inc. All Rights Reserved.
import { Logger } from '@epicgames-ps/lib-pixelstreamingfrontend-ue5.2';
import { OverlayBase } from './BaseOverlay';
/**
* Class for the base action overlay structure
*/
export class ActionOverlay extends OverlayBase {
onActionCallback: (...args: []) => void;
/**
* Construct an action overlay
* @param rootDiv the root element this overlay will be inserted into
* @param rootElement the root element that is the overlay
* @param contentElement an element that contains text for the action overlay
*/
public constructor(
rootDiv: HTMLElement,
rootElement: HTMLElement,
contentElement: HTMLElement
) {
super(rootDiv, rootElement, contentElement);
this.onActionCallback = () => {
/* do nothing */ Logger.Info(
Logger.GetStackTrace(),
'Did you forget to set the onAction callback in your overlay?'
);
};
}
/**
* Update the text overlays inner text
* @param text the update text to be inserted into the overlay
*/
public update(text: string): void {
if (text != null || text != undefined) {
this.textElement.innerHTML = text;
}
}
/**
* Set a method as an event emitter callback
* @param callBack the method that is to be called when the event is emitted
*/
onAction(callBack: (...args: []) => void) {
this.onActionCallback = callBack;
}
/**
* Activate an event that is attached to the event emitter
*/
activate() {
this.onActionCallback();
}
}