-
Notifications
You must be signed in to change notification settings - Fork 0
/
Navigation.js
57 lines (47 loc) · 1.58 KB
/
Navigation.js
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
let currentlyTrackedModule;
let playbarProgress = document.getElementById('progress');
let header = document.getElementById('navheader');
let subtext = document.getElementById('navsub');
let restartBtn;
let playbarActive = false;
function setupRestartBtn()
{
restartBtn = createImg("assets/images/restartButton_white.png", "restart");
restartBtn.hide();
restartBtn.size(50, 50);
restartBtn.position(width * 0.7, height * 0.05);
restartBtn.mousePressed(highlightRestartBtn);
restartBtn.touchStarted(highlightRestartBtn);
restartBtn.mouseClicked(restartCurrentModule);
restartBtn.touchEnded(restartCurrentModule);
}
function highlightRestartBtn()
{
restartBtn.attribute('src', "assets/images/restartButton_highlight.png");
}
function restartCurrentModule()
{
currentlyTrackedModule.restart();
restartBtn.attribute('src', "assets/images/restartButton_white.png");
}
function setCurrentModule(module, newHeader, newSubText, isIntro)
{
currentlyTrackedModule = module;
header.innerHTML = newHeader;
subtext.innerHTML = newSubText;
playbarActive = true;
let navigation = document.getElementById('nav');;
navigation.style.visibility = 'visible';
if(!isIntro)
restartBtn.show();
}
function updatePlaybar()
{
if(playbarActive)
{
let progress = (currentlyTrackedModule.story.seek() / currentlyTrackedModule.story.duration()) * 100;
if(currentlyTrackedModule.story.seek() == 0 && currentlyTrackedModule.storyEnding)
progress = 100;
playbarProgress.style.width = progress + "%";
}
}