2024-05-21 17:59:04 +00:00
|
|
|
import { ConfigTypes } from "@spt/models/enums/ConfigTypes";
|
|
|
|
import { ICoreConfig } from "@spt/models/spt/config/ICoreConfig";
|
|
|
|
import { LogTextColor } from "@spt/models/spt/logging/LogTextColor";
|
|
|
|
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
|
|
|
import { ConfigServer } from "@spt/servers/ConfigServer";
|
|
|
|
import { LocalisationService } from "@spt/services/LocalisationService";
|
2024-07-23 11:12:53 -04:00
|
|
|
import { inject, injectable } from "tsyringe";
|
2023-03-03 15:23:46 +00:00
|
|
|
|
|
|
|
@injectable()
|
2024-07-23 11:12:53 -04:00
|
|
|
export class WatermarkLocale {
|
Updated dependencies + A few other things (!150)
Initially this was going to be an update to dependencies but it seems i got a little carried away!
Anyways this PR removes 2 unused dependencies (`jshint` and `utf-8-validate`), and 2 other, `del` and `fs-extra` that were replaced by the built-in `fs/promises`.
It also renames all `tsconfig` and `Dockerfile` files, in a way that when viewed in a file tree sorted alphabetically they will be next to each other.
It also updates the typescript target to `ES2022`, and changes moduleResolution from `Node` to `Node10` (this isn't an update, they are the same thing but `Node` is now deprecated).
It also adds the `node:` discriminator to every import from built-in modules.
It also has major changes to the build script, `del` and `fs-extra` were only being used in the build script, it's now using `fs/promises` instead, cleaned up the code from some functions, adds better documentation to a few functions, and renames some gulp tasks and npm scripts to better represent what they actually do.
And finally it updates dependencies, except for `atomically` which can't be updated unless the project switches to ESM.
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/150
Co-authored-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
Co-committed-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
2023-10-14 09:01:41 +00:00
|
|
|
protected description: string[];
|
|
|
|
protected warning: string[];
|
|
|
|
protected modding: string[];
|
|
|
|
|
2024-07-23 11:12:53 -04:00
|
|
|
constructor(@inject("LocalisationService") protected localisationService: LocalisationService) {
|
Updated dependencies + A few other things (!150)
Initially this was going to be an update to dependencies but it seems i got a little carried away!
Anyways this PR removes 2 unused dependencies (`jshint` and `utf-8-validate`), and 2 other, `del` and `fs-extra` that were replaced by the built-in `fs/promises`.
It also renames all `tsconfig` and `Dockerfile` files, in a way that when viewed in a file tree sorted alphabetically they will be next to each other.
It also updates the typescript target to `ES2022`, and changes moduleResolution from `Node` to `Node10` (this isn't an update, they are the same thing but `Node` is now deprecated).
It also adds the `node:` discriminator to every import from built-in modules.
It also has major changes to the build script, `del` and `fs-extra` were only being used in the build script, it's now using `fs/promises` instead, cleaned up the code from some functions, adds better documentation to a few functions, and renames some gulp tasks and npm scripts to better represent what they actually do.
And finally it updates dependencies, except for `atomically` which can't be updated unless the project switches to ESM.
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/150
Co-authored-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
Co-committed-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
2023-10-14 09:01:41 +00:00
|
|
|
this.description = [
|
2023-03-03 15:23:46 +00:00
|
|
|
this.localisationService.getText("watermark-discord_url"),
|
|
|
|
"",
|
|
|
|
this.localisationService.getText("watermark-free_of_charge"),
|
|
|
|
this.localisationService.getText("watermark-paid_scammed"),
|
2023-11-15 20:35:05 -05:00
|
|
|
this.localisationService.getText("watermark-commercial_use_prohibited"),
|
Updated dependencies + A few other things (!150)
Initially this was going to be an update to dependencies but it seems i got a little carried away!
Anyways this PR removes 2 unused dependencies (`jshint` and `utf-8-validate`), and 2 other, `del` and `fs-extra` that were replaced by the built-in `fs/promises`.
It also renames all `tsconfig` and `Dockerfile` files, in a way that when viewed in a file tree sorted alphabetically they will be next to each other.
It also updates the typescript target to `ES2022`, and changes moduleResolution from `Node` to `Node10` (this isn't an update, they are the same thing but `Node` is now deprecated).
It also adds the `node:` discriminator to every import from built-in modules.
It also has major changes to the build script, `del` and `fs-extra` were only being used in the build script, it's now using `fs/promises` instead, cleaned up the code from some functions, adds better documentation to a few functions, and renames some gulp tasks and npm scripts to better represent what they actually do.
And finally it updates dependencies, except for `atomically` which can't be updated unless the project switches to ESM.
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/150
Co-authored-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
Co-committed-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
2023-10-14 09:01:41 +00:00
|
|
|
];
|
|
|
|
this.warning = [
|
2023-03-03 15:23:46 +00:00
|
|
|
"",
|
|
|
|
this.localisationService.getText("watermark-testing_build"),
|
|
|
|
this.localisationService.getText("watermark-no_support"),
|
|
|
|
"",
|
|
|
|
`${this.localisationService.getText("watermark-report_issues_to")}:`,
|
|
|
|
this.localisationService.getText("watermark-issue_tracker_url"),
|
|
|
|
"",
|
2023-11-15 20:35:05 -05:00
|
|
|
this.localisationService.getText("watermark-use_at_own_risk"),
|
Updated dependencies + A few other things (!150)
Initially this was going to be an update to dependencies but it seems i got a little carried away!
Anyways this PR removes 2 unused dependencies (`jshint` and `utf-8-validate`), and 2 other, `del` and `fs-extra` that were replaced by the built-in `fs/promises`.
It also renames all `tsconfig` and `Dockerfile` files, in a way that when viewed in a file tree sorted alphabetically they will be next to each other.
It also updates the typescript target to `ES2022`, and changes moduleResolution from `Node` to `Node10` (this isn't an update, they are the same thing but `Node` is now deprecated).
It also adds the `node:` discriminator to every import from built-in modules.
It also has major changes to the build script, `del` and `fs-extra` were only being used in the build script, it's now using `fs/promises` instead, cleaned up the code from some functions, adds better documentation to a few functions, and renames some gulp tasks and npm scripts to better represent what they actually do.
And finally it updates dependencies, except for `atomically` which can't be updated unless the project switches to ESM.
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/150
Co-authored-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
Co-committed-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
2023-10-14 09:01:41 +00:00
|
|
|
];
|
|
|
|
this.modding = [
|
2023-03-03 15:23:46 +00:00
|
|
|
"",
|
|
|
|
this.localisationService.getText("watermark-modding_disabled"),
|
|
|
|
"",
|
|
|
|
this.localisationService.getText("watermark-not_an_issue"),
|
2023-11-15 20:35:05 -05:00
|
|
|
this.localisationService.getText("watermark-do_not_report"),
|
Updated dependencies + A few other things (!150)
Initially this was going to be an update to dependencies but it seems i got a little carried away!
Anyways this PR removes 2 unused dependencies (`jshint` and `utf-8-validate`), and 2 other, `del` and `fs-extra` that were replaced by the built-in `fs/promises`.
It also renames all `tsconfig` and `Dockerfile` files, in a way that when viewed in a file tree sorted alphabetically they will be next to each other.
It also updates the typescript target to `ES2022`, and changes moduleResolution from `Node` to `Node10` (this isn't an update, they are the same thing but `Node` is now deprecated).
It also adds the `node:` discriminator to every import from built-in modules.
It also has major changes to the build script, `del` and `fs-extra` were only being used in the build script, it's now using `fs/promises` instead, cleaned up the code from some functions, adds better documentation to a few functions, and renames some gulp tasks and npm scripts to better represent what they actually do.
And finally it updates dependencies, except for `atomically` which can't be updated unless the project switches to ESM.
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/150
Co-authored-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
Co-committed-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
2023-10-14 09:01:41 +00:00
|
|
|
];
|
|
|
|
}
|
2023-03-03 15:23:46 +00:00
|
|
|
|
2024-07-23 11:12:53 -04:00
|
|
|
public getDescription(): string[] {
|
Updated dependencies + A few other things (!150)
Initially this was going to be an update to dependencies but it seems i got a little carried away!
Anyways this PR removes 2 unused dependencies (`jshint` and `utf-8-validate`), and 2 other, `del` and `fs-extra` that were replaced by the built-in `fs/promises`.
It also renames all `tsconfig` and `Dockerfile` files, in a way that when viewed in a file tree sorted alphabetically they will be next to each other.
It also updates the typescript target to `ES2022`, and changes moduleResolution from `Node` to `Node10` (this isn't an update, they are the same thing but `Node` is now deprecated).
It also adds the `node:` discriminator to every import from built-in modules.
It also has major changes to the build script, `del` and `fs-extra` were only being used in the build script, it's now using `fs/promises` instead, cleaned up the code from some functions, adds better documentation to a few functions, and renames some gulp tasks and npm scripts to better represent what they actually do.
And finally it updates dependencies, except for `atomically` which can't be updated unless the project switches to ESM.
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/150
Co-authored-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
Co-committed-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
2023-10-14 09:01:41 +00:00
|
|
|
return this.description;
|
2023-03-03 15:23:46 +00:00
|
|
|
}
|
|
|
|
|
2024-07-23 11:12:53 -04:00
|
|
|
public getWarning(): string[] {
|
Updated dependencies + A few other things (!150)
Initially this was going to be an update to dependencies but it seems i got a little carried away!
Anyways this PR removes 2 unused dependencies (`jshint` and `utf-8-validate`), and 2 other, `del` and `fs-extra` that were replaced by the built-in `fs/promises`.
It also renames all `tsconfig` and `Dockerfile` files, in a way that when viewed in a file tree sorted alphabetically they will be next to each other.
It also updates the typescript target to `ES2022`, and changes moduleResolution from `Node` to `Node10` (this isn't an update, they are the same thing but `Node` is now deprecated).
It also adds the `node:` discriminator to every import from built-in modules.
It also has major changes to the build script, `del` and `fs-extra` were only being used in the build script, it's now using `fs/promises` instead, cleaned up the code from some functions, adds better documentation to a few functions, and renames some gulp tasks and npm scripts to better represent what they actually do.
And finally it updates dependencies, except for `atomically` which can't be updated unless the project switches to ESM.
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/150
Co-authored-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
Co-committed-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
2023-10-14 09:01:41 +00:00
|
|
|
return this.warning;
|
2023-03-03 15:23:46 +00:00
|
|
|
}
|
|
|
|
|
2024-07-23 11:12:53 -04:00
|
|
|
public getModding(): string[] {
|
Updated dependencies + A few other things (!150)
Initially this was going to be an update to dependencies but it seems i got a little carried away!
Anyways this PR removes 2 unused dependencies (`jshint` and `utf-8-validate`), and 2 other, `del` and `fs-extra` that were replaced by the built-in `fs/promises`.
It also renames all `tsconfig` and `Dockerfile` files, in a way that when viewed in a file tree sorted alphabetically they will be next to each other.
It also updates the typescript target to `ES2022`, and changes moduleResolution from `Node` to `Node10` (this isn't an update, they are the same thing but `Node` is now deprecated).
It also adds the `node:` discriminator to every import from built-in modules.
It also has major changes to the build script, `del` and `fs-extra` were only being used in the build script, it's now using `fs/promises` instead, cleaned up the code from some functions, adds better documentation to a few functions, and renames some gulp tasks and npm scripts to better represent what they actually do.
And finally it updates dependencies, except for `atomically` which can't be updated unless the project switches to ESM.
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/150
Co-authored-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
Co-committed-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
2023-10-14 09:01:41 +00:00
|
|
|
return this.modding;
|
2023-03-03 15:23:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@injectable()
|
2024-07-23 11:12:53 -04:00
|
|
|
export class Watermark {
|
2024-05-21 17:59:04 +00:00
|
|
|
protected sptConfig: ICoreConfig;
|
2023-10-28 20:36:48 +01:00
|
|
|
protected text: string[] = [];
|
|
|
|
protected versionLabel = "";
|
2023-03-03 15:23:46 +00:00
|
|
|
|
|
|
|
constructor(
|
2024-05-28 14:04:20 +00:00
|
|
|
@inject("PrimaryLogger") protected logger: ILogger,
|
2023-03-03 15:23:46 +00:00
|
|
|
@inject("ConfigServer") protected configServer: ConfigServer,
|
|
|
|
@inject("LocalisationService") protected localisationService: LocalisationService,
|
2024-05-27 16:05:16 +00:00
|
|
|
@inject("WatermarkLocale") protected watermarkLocale: WatermarkLocale,
|
2024-07-23 11:12:53 -04:00
|
|
|
) {
|
2024-05-21 17:59:04 +00:00
|
|
|
this.sptConfig = this.configServer.getConfig<ICoreConfig>(ConfigTypes.CORE);
|
2023-03-03 15:23:46 +00:00
|
|
|
}
|
|
|
|
|
2024-07-23 11:12:53 -04:00
|
|
|
public initialize(): void {
|
2023-03-03 15:23:46 +00:00
|
|
|
const description = this.watermarkLocale.getDescription();
|
|
|
|
const warning = this.watermarkLocale.getWarning();
|
|
|
|
const modding = this.watermarkLocale.getModding();
|
|
|
|
const versionTag = this.getVersionTag();
|
|
|
|
|
2024-05-21 17:59:04 +00:00
|
|
|
this.versionLabel = `${this.sptConfig.projectName} ${versionTag}`;
|
2023-03-03 15:23:46 +00:00
|
|
|
|
|
|
|
this.text = [this.versionLabel];
|
|
|
|
this.text = [...this.text, ...description];
|
|
|
|
|
2024-07-23 11:12:53 -04:00
|
|
|
if (globalThis.G_DEBUG_CONFIGURATION) {
|
2023-03-03 15:23:46 +00:00
|
|
|
this.text = this.text.concat([...warning]);
|
|
|
|
}
|
2024-07-23 11:12:53 -04:00
|
|
|
if (!globalThis.G_MODS_ENABLED) {
|
2023-03-03 15:23:46 +00:00
|
|
|
this.text = this.text.concat([...modding]);
|
|
|
|
}
|
2023-10-28 20:36:48 +01:00
|
|
|
|
2024-07-23 11:12:53 -04:00
|
|
|
if (this.sptConfig.customWatermarkLocaleKeys) {
|
|
|
|
if (this.sptConfig.customWatermarkLocaleKeys.length > 0) {
|
|
|
|
for (const key of this.sptConfig.customWatermarkLocaleKeys) {
|
2024-05-27 16:05:16 +00:00
|
|
|
this.text.push(...["", this.localisationService.getText(key)]);
|
|
|
|
}
|
2024-05-23 21:40:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-28 20:36:48 +01:00
|
|
|
this.setTitle();
|
|
|
|
this.resetCursor();
|
|
|
|
this.draw();
|
2023-03-03 15:23:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a version string (x.x.x) or (x.x.x-BLEEDINGEDGE) OR (X.X.X (18xxx))
|
|
|
|
* @param withEftVersion Include the eft version this spt version was made for
|
|
|
|
* @returns string
|
|
|
|
*/
|
2024-07-23 11:12:53 -04:00
|
|
|
public getVersionTag(withEftVersion = false): string {
|
2024-05-21 17:59:04 +00:00
|
|
|
const sptVersion = globalThis.G_SPTVERSION || this.sptConfig.sptVersion;
|
2024-05-07 23:57:08 -04:00
|
|
|
const versionTag = globalThis.G_DEBUG_CONFIGURATION
|
2024-05-21 17:59:04 +00:00
|
|
|
? `${sptVersion} - ${this.localisationService.getText("bleeding_edge_build")}`
|
|
|
|
: sptVersion;
|
2023-03-03 15:23:46 +00:00
|
|
|
|
2024-07-23 11:12:53 -04:00
|
|
|
if (withEftVersion) {
|
2024-05-21 17:59:04 +00:00
|
|
|
const tarkovVersion = this.sptConfig.compatibleTarkovVersion.split(".").pop();
|
2023-03-03 15:23:46 +00:00
|
|
|
return `${versionTag} (${tarkovVersion})`;
|
|
|
|
}
|
|
|
|
|
|
|
|
return versionTag;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-07-15 14:49:25 +01:00
|
|
|
* Handle singleplayer/settings/version
|
2023-03-03 15:23:46 +00:00
|
|
|
* Get text shown in game on screen, can't be translated as it breaks bsgs client when certian characters are used
|
|
|
|
* @returns string
|
|
|
|
*/
|
2024-07-23 11:12:53 -04:00
|
|
|
public getInGameVersionLabel(): string {
|
2024-05-21 17:59:04 +00:00
|
|
|
const sptVersion = globalThis.G_SPTVERSION || this.sptConfig.sptVersion;
|
2024-05-07 23:57:08 -04:00
|
|
|
const versionTag = globalThis.G_DEBUG_CONFIGURATION
|
2024-05-21 17:59:04 +00:00
|
|
|
? `${sptVersion} - BLEEDINGEDGE ${globalThis.G_COMMIT?.slice(0, 6) ?? ""}`
|
|
|
|
: `${sptVersion} - ${globalThis.G_COMMIT?.slice(0, 6) ?? ""}`;
|
2023-03-03 15:23:46 +00:00
|
|
|
|
2024-05-21 17:59:04 +00:00
|
|
|
return `${this.sptConfig.projectName} ${versionTag}`;
|
2023-03-03 15:23:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Set window title */
|
2024-07-23 11:12:53 -04:00
|
|
|
protected setTitle(): void {
|
2023-03-03 15:23:46 +00:00
|
|
|
process.title = this.versionLabel;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Reset console cursor to top */
|
2024-07-23 11:12:53 -04:00
|
|
|
protected resetCursor(): void {
|
2023-03-03 15:23:46 +00:00
|
|
|
process.stdout.write("\u001B[2J\u001B[0;0f");
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Draw the watermark */
|
2024-07-23 11:12:53 -04:00
|
|
|
protected draw(): void {
|
2024-05-27 16:05:16 +00:00
|
|
|
const result: string[] = [];
|
2023-03-03 15:23:46 +00:00
|
|
|
|
2024-03-18 21:07:47 +00:00
|
|
|
// Calculate size, add 10% for spacing to the right
|
2024-07-23 11:12:53 -04:00
|
|
|
const longestLength =
|
|
|
|
this.text.reduce((a, b) => {
|
2024-05-17 15:32:41 -04:00
|
|
|
return a.length > b.length ? a : b;
|
|
|
|
}).length * 1.1;
|
2023-03-03 15:23:46 +00:00
|
|
|
|
2024-03-18 21:07:47 +00:00
|
|
|
// Create line of - to add top/bottom of watermark
|
2023-03-03 15:23:46 +00:00
|
|
|
let line = "";
|
2024-07-23 11:12:53 -04:00
|
|
|
for (let i = 0; i < longestLength; ++i) {
|
2023-03-03 15:23:46 +00:00
|
|
|
line += "─";
|
|
|
|
}
|
|
|
|
|
2024-03-18 21:07:47 +00:00
|
|
|
// Opening line
|
2023-03-03 15:23:46 +00:00
|
|
|
result.push(`┌─${line}─┐`);
|
|
|
|
|
2024-03-18 21:07:47 +00:00
|
|
|
// Add content of watermark to screen
|
2024-07-23 11:12:53 -04:00
|
|
|
for (const watermarkText of this.text) {
|
2024-03-18 21:07:47 +00:00
|
|
|
const spacingSize = longestLength - watermarkText.length;
|
|
|
|
let textWithRightPadding = watermarkText;
|
2023-03-03 15:23:46 +00:00
|
|
|
|
2024-07-23 11:12:53 -04:00
|
|
|
for (let i = 0; i < spacingSize; ++i) {
|
2024-03-18 21:07:47 +00:00
|
|
|
textWithRightPadding += " ";
|
2023-03-03 15:23:46 +00:00
|
|
|
}
|
|
|
|
|
2024-03-18 21:07:47 +00:00
|
|
|
result.push(`│ ${textWithRightPadding} │`);
|
2023-03-03 15:23:46 +00:00
|
|
|
}
|
|
|
|
|
2024-03-18 21:07:47 +00:00
|
|
|
// Closing line
|
2023-03-03 15:23:46 +00:00
|
|
|
result.push(`└─${line}─┘`);
|
|
|
|
|
2024-03-18 21:07:47 +00:00
|
|
|
// Log watermark to screen
|
2024-07-23 11:12:53 -04:00
|
|
|
for (const text of result) {
|
2023-03-03 15:23:46 +00:00
|
|
|
this.logger.logWithColor(text, LogTextColor.YELLOW);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|