diff options
| author | stonedDiscord <Tukz@gmx.de> | 2022-09-23 18:07:22 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-23 18:07:22 +0200 |
| commit | 82983e0c38383ec2602b4f41327342d1c8d0a8fd (patch) | |
| tree | 2c6af046c350e594143ddd5950f1fd373bfe6dda /webAO/viewport/utils/initTestimonyUpdater.ts | |
| parent | a732a654c058842e39917210e47ca7476fa7ef68 (diff) | |
| parent | c3bde03911eb41bb768d1f01c0857d69300e36b8 (diff) | |
Merge pull request #175 from caleb-mabry/more-function-removal-viewport
More function removal from viewport
Diffstat (limited to 'webAO/viewport/utils/initTestimonyUpdater.ts')
| -rw-r--r-- | webAO/viewport/utils/initTestimonyUpdater.ts | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/webAO/viewport/utils/initTestimonyUpdater.ts b/webAO/viewport/utils/initTestimonyUpdater.ts new file mode 100644 index 0000000..e6f6e9d --- /dev/null +++ b/webAO/viewport/utils/initTestimonyUpdater.ts @@ -0,0 +1,31 @@ +import { Testimony } from '../interfaces/Testimony' +import { client, UPDATE_INTERVAL } from '../../client' +/** + * Intialize testimony updater + */ +export const initTestimonyUpdater = () => { + const testimonyFilenames: Testimony = { + 1: "witnesstestimony", + 2: "crossexamination", + 3: "notguilty", + 4: "guilty", + }; + + const testimony = testimonyFilenames[client.testimonyID]; + if (!testimony) { + console.warn(`Invalid testimony ID ${client.testimonyID}`); + return; + } + + client.viewport.testimonyAudio.src = client.resources[testimony].sfx; + client.viewport.testimonyAudio.play(); + + const testimonyOverlay = <HTMLImageElement>( + document.getElementById("client_testimony") + ); + testimonyOverlay.src = client.resources[testimony].src; + testimonyOverlay.style.opacity = "1"; + + client.viewport.setTestimonyTimer(0); + client.viewport.setTestimonyUpdater(setTimeout(() => client.viewport.updateTestimony(), UPDATE_INTERVAL)); +};
\ No newline at end of file |
