mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-23 09:42:53 +02:00
CORPORATION: adding prevState and changed state display in the warehouse UI (#861)
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { Terminal } from "../Terminal";
|
||||
|
||||
const deprecatedWarningsGiven = new Set();
|
||||
export function setDeprecatedProperties(
|
||||
obj: object,
|
||||
properties: Record<string, { identifier: string; message: string; value: any }>,
|
||||
) {
|
||||
for (const [name, info] of Object.entries(properties)) {
|
||||
Object.defineProperty(obj, name, {
|
||||
get: () => {
|
||||
deprecationWarning(info.identifier, info.message);
|
||||
return info.value;
|
||||
},
|
||||
set: (value: any) => (info.value = value),
|
||||
enumerable: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
export function deprecationWarning(identifier: string, message: string) {
|
||||
if (!deprecatedWarningsGiven.has(identifier)) {
|
||||
deprecatedWarningsGiven.add(identifier);
|
||||
Terminal.warn(`Accessed deprecated function or property: ${identifier}`);
|
||||
Terminal.warn(`This is no longer supported usage and will be removed in a later version.`);
|
||||
Terminal.warn(message);
|
||||
Terminal.info(`This message can also appear for object properties when the object's values are iterated.`);
|
||||
Terminal.info(`This message will only be shown once per game session for each deprecated item accessed.`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user