mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-18 20:25:45 +01:00
UI: 'Disable Text Effects' setting applies to "corrupted text" (#944)
This commit is contained in:
parent
e7b68676f5
commit
ccf0aa4771
@ -118,7 +118,7 @@ export function AchievementList({ achievements, playerAchievements }: IProps): J
|
||||
<Typography color="secondary" sx={{ mt: 1 }}>
|
||||
{secret.map((item) => (
|
||||
<span key={`secret_${item.achievement.ID}`}>
|
||||
<CorruptableText content={item.achievement.ID}></CorruptableText>
|
||||
<CorruptableText content={item.achievement.ID} spoiler={true}></CorruptableText>
|
||||
<br />
|
||||
</span>
|
||||
))}
|
||||
|
@ -30,7 +30,7 @@ export function BlackOpPage(props: IProps): React.ReactElement {
|
||||
</Typography>
|
||||
{props.bladeburner.blackops[BlackOperationName.OperationDaedalus] ? (
|
||||
<Button sx={{ my: 1, p: 1 }} onClick={() => Router.toPage(Page.BitVerse, { flume: false, quick: false })}>
|
||||
<CorruptableText content="Destroy w0rld_d34mon"></CorruptableText>
|
||||
<CorruptableText content="Destroy w0rld_d34mon" spoiler={false}></CorruptableText>
|
||||
</Button>
|
||||
) : (
|
||||
<BlackOpList bladeburner={props.bladeburner} />
|
||||
|
@ -136,7 +136,7 @@ const FactionElement = (props: FactionElementProps): React.ReactElement => {
|
||||
) : (
|
||||
<Tooltip title={"Rumored Faction"}>
|
||||
<span style={{ overflow: "hidden", whiteSpace: "nowrap", textOverflow: "ellipsis" }}>
|
||||
<CorruptableText content={props.faction.name} />
|
||||
<CorruptableText content={props.faction.name} spoiler={false} />
|
||||
</span>
|
||||
</Tooltip>
|
||||
)}
|
||||
|
@ -21,8 +21,6 @@ import { CasinoLocation } from "./CasinoLocation";
|
||||
import { Location } from "../Location";
|
||||
import { LocationType } from "@enums";
|
||||
|
||||
import { Settings } from "../../Settings/Settings";
|
||||
|
||||
import { isBackdoorInstalled } from "../../Server/ServerHelpers";
|
||||
import { GetServer } from "../../Server/AllServers";
|
||||
|
||||
@ -97,10 +95,10 @@ export function GenericLocation({ loc }: IProps): React.ReactElement {
|
||||
<>
|
||||
<Button onClick={() => Router.toPage(Page.City)}>Return to World</Button>
|
||||
<Typography variant="h4" sx={{ mt: 1 }}>
|
||||
{backdoorInstalled && !Settings.DisableTextEffects ? (
|
||||
<Tooltip title={`Backdoor installed on ${loc.name}.`}>
|
||||
{backdoorInstalled ? (
|
||||
<Tooltip title={`Backdoor installed on ${serverMeta.hostname}.`}>
|
||||
<span>
|
||||
<CorruptableText content={loc.name} />
|
||||
<CorruptableText content={loc.name} spoiler={false} />
|
||||
</span>
|
||||
</Tooltip>
|
||||
) : (
|
||||
|
@ -303,7 +303,7 @@ export function SpecialLocation(props: SpecialLocationProps): React.ReactElement
|
||||
return (
|
||||
<>
|
||||
<Typography>
|
||||
<CorruptableText content={"An eerie aura surrounds this area. You feel you should leave."} />
|
||||
<CorruptableText content={"An eerie aura surrounds this area. You feel you should leave."} spoiler={false} />
|
||||
</Typography>
|
||||
</>
|
||||
);
|
||||
|
@ -28,7 +28,7 @@ export const A = (props: React.PropsWithChildren<{ href?: string }>): React.Reac
|
||||
cursor: "pointer",
|
||||
}}
|
||||
>
|
||||
<CorruptableText content={props.children + ""} />
|
||||
<CorruptableText content={props.children + ""} spoiler={true} />
|
||||
</span>
|
||||
);
|
||||
return (
|
||||
|
@ -1,4 +1,5 @@
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { Settings } from "../../Settings/Settings";
|
||||
|
||||
function replace(str: string, i: number, char: string): string {
|
||||
return str.substring(0, i) + char + str.substring(i + 1);
|
||||
@ -6,13 +7,18 @@ function replace(str: string, i: number, char: string): string {
|
||||
|
||||
interface CorruptableTextProps {
|
||||
content: string;
|
||||
spoiler: boolean;
|
||||
}
|
||||
|
||||
function randomize(char: string): string {
|
||||
function randomize(char: string, obfuscate: boolean): string {
|
||||
const randFrom = (str: string): string => str[Math.floor(Math.random() * str.length)];
|
||||
const classes = ["abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "1234567890", " _", "()[]{}<>"];
|
||||
const other = `!@#$%^&*()_+|\\';"/.,?\`~`;
|
||||
|
||||
if (obfuscate && Math.random() < 0.75) {
|
||||
return randFrom(other);
|
||||
}
|
||||
|
||||
for (const c of classes) {
|
||||
if (c.includes(char)) return randFrom(c);
|
||||
}
|
||||
@ -24,6 +30,10 @@ export function CorruptableText(props: CorruptableTextProps): JSX.Element {
|
||||
const [content, setContent] = useState(props.content);
|
||||
|
||||
useEffect(() => {
|
||||
if (Settings.DisableTextEffects) {
|
||||
return;
|
||||
}
|
||||
|
||||
let counter = 5;
|
||||
const timers: number[] = [];
|
||||
const intervalId = setInterval(() => {
|
||||
@ -32,7 +42,7 @@ export function CorruptableText(props: CorruptableTextProps): JSX.Element {
|
||||
counter = Math.random() * 5;
|
||||
const index = Math.random() * props.content.length;
|
||||
const letter = props.content.charAt(index);
|
||||
setContent((content) => replace(content, index, randomize(letter)));
|
||||
setContent((content) => replace(content, index, randomize(letter, false)));
|
||||
timers.push(
|
||||
window.setTimeout(() => {
|
||||
setContent((content) => replace(content, index, letter));
|
||||
@ -46,5 +56,10 @@ export function CorruptableText(props: CorruptableTextProps): JSX.Element {
|
||||
};
|
||||
}, [props.content]);
|
||||
|
||||
if (Settings.DisableTextEffects) {
|
||||
const spoileredContent = content.replaceAll(/./g, (c) => randomize(c, true));
|
||||
return <span>{props.spoiler ? spoileredContent : content}</span>;
|
||||
}
|
||||
|
||||
return <span>{content}</span>;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user