mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-27 08:27:32 +01:00
convert unclickable inside the react tree
This commit is contained in:
parent
125e9484f7
commit
d49fea4cbc
20
src/Exploits/Unclickable.tsx
Normal file
20
src/Exploits/Unclickable.tsx
Normal file
@ -0,0 +1,20 @@
|
||||
import React from "react";
|
||||
import { use } from "../ui/Context";
|
||||
import { Exploit } from "./Exploit";
|
||||
|
||||
export function Unclickable(): React.ReactElement {
|
||||
const player = use.Player();
|
||||
|
||||
function unclickable(event: React.MouseEvent<HTMLDivElement>): void {
|
||||
if (!event.target || !(event.target instanceof Element)) return;
|
||||
const display = window.getComputedStyle(event.target as Element).display;
|
||||
const visibility = window.getComputedStyle(event.target as Element).visibility;
|
||||
if (display === "none" && visibility === "hidden" && event.isTrusted) player.giveExploit(Exploit.Unclickable);
|
||||
}
|
||||
|
||||
return (
|
||||
<div id="unclickable" onClick={unclickable} style={{ display: "none", visibility: "hidden" }}>
|
||||
Click on this to upgrade your Source-File -1!
|
||||
</div>
|
||||
);
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
import { Player } from "../Player";
|
||||
import { Exploit } from "./Exploit";
|
||||
|
||||
export function startUnclickable(): void {
|
||||
function clickTheUnclickable(event: MouseEvent): void {
|
||||
if (!event.target || !(event.target instanceof Element)) return;
|
||||
const display = window.getComputedStyle(event.target as Element).display;
|
||||
if (display === "none" && event.isTrusted) Player.giveExploit(Exploit.Unclickable);
|
||||
}
|
||||
|
||||
function targetElement(): void {
|
||||
const elem = document.getElementById("unclickable");
|
||||
if (elem == null) {
|
||||
console.error("Could not find the unclickable elem for the related exploit.");
|
||||
return;
|
||||
}
|
||||
elem.addEventListener("click", clickTheUnclickable);
|
||||
document.removeEventListener("DOMContentLoaded", targetElement);
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", targetElement);
|
||||
}
|
@ -46,7 +46,6 @@ import { dialogBoxCreate } from "../utils/DialogBox";
|
||||
import { exceptionAlert } from "../utils/helpers/exceptionAlert";
|
||||
|
||||
import { startTampering } from "./Exploits/tampering";
|
||||
import { startUnclickable } from "./Exploits/unclickable";
|
||||
|
||||
import React from "react";
|
||||
|
||||
@ -270,7 +269,6 @@ const Engine: {
|
||||
|
||||
load: function (saveString) {
|
||||
startTampering();
|
||||
startUnclickable();
|
||||
// Load game from save or create new game
|
||||
if (loadGame(saveString)) {
|
||||
ThemeEvents.emit();
|
||||
|
@ -46,9 +46,6 @@
|
||||
<p id="status-text"></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="modal-portal"></div>
|
||||
<div id="unclickable" style="display: none">Click on this to upgrade your Source-File -1!</div>
|
||||
</body>
|
||||
|
||||
<script src="src/ThirdParty/raphael.min.js"></script>
|
||||
|
@ -65,6 +65,7 @@ import { BitverseRoot } from "../BitNode/ui/BitverseRoot";
|
||||
import { CharacterOverview } from "./React/CharacterOverview";
|
||||
import { BladeburnerCinematic } from "../Bladeburner/ui/BladeburnerCinematic";
|
||||
import { workerScripts } from "../Netscript/WorkerScripts";
|
||||
import { Unclickable } from "../Exploits/Unclickable";
|
||||
|
||||
import { enterBitNode } from "../RedPill";
|
||||
import { Context } from "./Context";
|
||||
@ -390,6 +391,7 @@ export function GameRoot({ player, engine, terminal }: IProps): React.ReactEleme
|
||||
</Box>
|
||||
</Box>
|
||||
)}
|
||||
<Unclickable />
|
||||
</Context.Router.Provider>
|
||||
</Context.Player.Provider>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user