-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ continued to replacce register by Observable
- Loading branch information
1 parent
92b19f3
commit ee88ec5
Showing
11 changed files
with
183 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<div id="pauseMask"> | ||
|
||
</div> | ||
|
||
<div id="pauseMenu"> | ||
<h1>Paused</h1> | ||
|
||
<div class="buttons"> | ||
|
||
<div id="screenshotButton" class="button">Take Screenshot</div> | ||
|
||
<div id="shareButton" class="button">Share System</div> | ||
|
||
<div id="resumeButton" class="button">Resume</div> | ||
|
||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#pauseMask { | ||
z-index: 9; | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
bottom: 0; | ||
right: 0; | ||
background: rgba(0, 0, 0, 0.5); | ||
backdrop-filter: blur(5px); | ||
} | ||
|
||
#pauseMenu { | ||
position: absolute; | ||
width: 300px; | ||
height: 300px; | ||
top: calc(50% - 150px); | ||
left: calc(50% - 150px); | ||
background: rgba(0, 0, 0, 0.9); | ||
|
||
z-index: 10; | ||
|
||
display: grid; | ||
grid-template-rows: 100px auto; | ||
|
||
padding-bottom: 20px; | ||
|
||
box-shadow: 0 0 50px rgba(255, 255, 255, 0.8); | ||
|
||
font-family: sans-serif; | ||
|
||
h1 { | ||
color: white; | ||
text-align: center; | ||
} | ||
|
||
.buttons { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: flex-end; | ||
row-gap: 10px; | ||
|
||
.button { | ||
text-align: center; | ||
padding: 10px 20px; | ||
background: white; | ||
color: black; | ||
width: 120px; | ||
cursor: pointer; | ||
transition: .2s; | ||
|
||
&:hover { | ||
background: darken(white, 20%); | ||
color: black; | ||
} | ||
|
||
&:active { | ||
background: darken(white, 40%); | ||
color: black; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Observable } from "@babylonjs/core/Misc/observable"; | ||
import pauseMenuHTML from "../../html/pauseMenu.html"; | ||
|
||
export class PauseMenu { | ||
private readonly rootNode: HTMLElement; | ||
private readonly mask: HTMLElement; | ||
|
||
private readonly screenshotButton: HTMLElement; | ||
private readonly shareButton: HTMLElement; | ||
private readonly resumeButton: HTMLElement; | ||
|
||
readonly onScreenshot = new Observable<void>(); | ||
readonly onShare = new Observable<void>(); | ||
readonly onResume = new Observable<void>(); | ||
|
||
constructor() { | ||
document.body.insertAdjacentHTML("beforeend", pauseMenuHTML); | ||
this.rootNode = document.getElementById("pauseMenu") as HTMLElement; | ||
this.mask = document.getElementById("pauseMask") as HTMLElement; | ||
|
||
this.screenshotButton = document.getElementById("screenshotButton") as HTMLElement; | ||
this.screenshotButton.addEventListener("click", () => this.onScreenshot.notifyObservers()); | ||
|
||
this.shareButton = document.getElementById("shareButton") as HTMLElement; | ||
this.shareButton.addEventListener("click", () => this.onShare.notifyObservers()); | ||
|
||
this.resumeButton = document.getElementById("resumeButton") as HTMLElement; | ||
this.resumeButton.addEventListener("click", () => this.onResume.notifyObservers()); | ||
|
||
this.setVisibility(false); | ||
} | ||
|
||
public setVisibility(visible: boolean) { | ||
this.rootNode.style.display = visible ? "grid" : "none"; | ||
this.mask.style.display = visible ? "block" : "none"; | ||
} | ||
|
||
public isVisible(): boolean { | ||
return this.rootNode.style.visibility !== "none"; | ||
} | ||
} |