maidraw 0.9.5 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/themes/chunithm/best/luminousLandscape/new/manifest.json +58 -32
- package/assets/themes/chunithm/best/luminousLandscape/recents/manifest.json +57 -31
- package/assets/themes/chunithm/best/luminousPlusLandscape/new/manifest.json +57 -31
- package/assets/themes/chunithm/best/luminousPlusLandscape/recents/manifest.json +57 -31
- package/assets/themes/chunithm/best/verseLandscape/new/manifest.json +57 -31
- package/assets/themes/chunithm/best/verseLandscape/recents/manifest.json +57 -31
- package/assets/themes/chunithm/chart/jp/verse/manifest.json +73 -71
- package/assets/themes/maimai/best50/cn/2024Landscape/manifest.json +90 -54
- package/assets/themes/maimai/best50/cn/2024Portrait/manifest.json +89 -53
- package/assets/themes/maimai/best50/cn/2025Landscape/manifest.json +90 -54
- package/assets/themes/maimai/best50/cn/2025Portrait/manifest.json +89 -53
- package/assets/themes/maimai/best50/common/prism/plus/background.png +0 -0
- package/assets/themes/maimai/best50/jp/buddiesLandscape/manifest.json +89 -53
- package/assets/themes/maimai/best50/jp/buddiesPlusLandscape/manifest.json +89 -53
- package/assets/themes/maimai/best50/jp/buddiesPlusPortrait/manifest.json +89 -53
- package/assets/themes/maimai/best50/jp/buddiesPortrait/manifest.json +89 -53
- package/assets/themes/maimai/best50/jp/finaleLandscape/manifest.json +89 -53
- package/assets/themes/maimai/best50/jp/finalePortrait/manifest.json +89 -53
- package/assets/themes/maimai/best50/jp/prismLandscape/manifest.json +90 -54
- package/assets/themes/maimai/best50/jp/prismPlusLandscape/manifest.json +90 -54
- package/assets/themes/maimai/best50/jp/prismPlusPortrait/manifest.json +92 -55
- package/assets/themes/maimai/best50/jp/prismPortrait/manifest.json +89 -53
- package/assets/themes/maimai/best50/salt/2026landscape/manifest.json +89 -53
- package/assets/themes/maimai/chart/jp/prism/manifest.json +100 -96
- package/assets/themes/ongeki/jp/brightMemoryLandscape/classic/manifest.json +101 -30
- package/assets/themes/ongeki/jp/brightMemoryLandscape/refresh/manifest.json +78 -30
- package/assets/themes/ongeki/jp/refreshLandscape/classic/manifest.json +101 -2
- package/assets/themes/ongeki/jp/refreshLandscape/refresh/manifest.json +78 -30
- package/dist/chu/index.d.ts +14 -4
- package/dist/chu/index.js +16 -4
- package/dist/chu/index.js.map +1 -1
- package/dist/chu/lib/{index.d.ts → adapter/index.d.ts} +1 -1
- package/dist/chu/lib/{index.js → adapter/index.js} +1 -1
- package/dist/chu/lib/adapter/index.js.map +1 -0
- package/dist/chu/lib/{kamaiTachi → adapter/kamaiTachi}/index.d.ts +1 -1
- package/dist/chu/lib/{kamaiTachi → adapter/kamaiTachi}/index.js +5 -5
- package/dist/chu/lib/adapter/kamaiTachi/index.js.map +1 -0
- package/dist/chu/lib/{lxns → adapter/lxns}/index.d.ts +1 -1
- package/dist/chu/lib/{lxns → adapter/lxns}/index.js +4 -4
- package/dist/chu/lib/adapter/lxns/index.js.map +1 -0
- package/dist/chu/{chart → lib}/database.d.ts +3 -3
- package/dist/chu/{chart → lib}/database.js +2 -2
- package/dist/chu/lib/database.js.map +1 -0
- package/dist/chu/lib/util.d.ts +149 -0
- package/dist/chu/lib/util.js +270 -0
- package/dist/chu/lib/util.js.map +1 -0
- package/dist/chu/painter/best50/index.d.ts +120 -0
- package/dist/chu/painter/best50/index.js +158 -0
- package/dist/chu/painter/best50/index.js.map +1 -0
- package/dist/chu/painter/chart/index.d.ts +170 -0
- package/dist/chu/painter/chart/index.js +116 -0
- package/dist/chu/painter/chart/index.js.map +1 -0
- package/dist/chu/painter/index.d.ts +194 -0
- package/dist/chu/painter/index.js +1105 -0
- package/dist/chu/painter/index.js.map +1 -0
- package/dist/geki/index.d.ts +10 -4
- package/dist/geki/index.js +12 -4
- package/dist/geki/index.js.map +1 -1
- package/dist/geki/lib/adapter/index.js.map +1 -0
- package/dist/geki/lib/adapter/kamaiTachi/index.js.map +1 -0
- package/dist/geki/{chart → lib}/database.d.ts +1 -1
- package/dist/geki/{chart → lib}/database.js +2 -2
- package/dist/geki/lib/database.js.map +1 -0
- package/dist/geki/painter/best50/index.d.ts +122 -0
- package/dist/geki/painter/best50/index.js +197 -0
- package/dist/geki/painter/best50/index.js.map +1 -0
- package/dist/geki/painter/index.d.ts +88 -0
- package/dist/geki/painter/index.js +448 -0
- package/dist/geki/painter/index.js.map +1 -0
- package/dist/lib/cache.d.ts +1 -0
- package/dist/lib/cache.js +6 -1
- package/dist/lib/cache.js.map +1 -1
- package/dist/lib/painter.d.ts +100 -0
- package/dist/lib/painter.js +216 -0
- package/dist/lib/painter.js.map +1 -0
- package/dist/lib/util.d.ts +6 -282
- package/dist/lib/util.js +50 -540
- package/dist/lib/util.js.map +1 -1
- package/dist/mai/index.d.ts +22 -6
- package/dist/mai/index.js +24 -6
- package/dist/mai/index.js.map +1 -1
- package/dist/mai/lib/{divingFish → adapter/divingFish}/index.d.ts +6 -6
- package/dist/mai/lib/{divingFish → adapter/divingFish}/index.js +29 -30
- package/dist/mai/lib/adapter/divingFish/index.js.map +1 -0
- package/dist/mai/lib/{index.d.ts → adapter/index.d.ts} +11 -11
- package/dist/mai/lib/{index.js → adapter/index.js} +2 -2
- package/dist/{geki/bests/lib → mai/lib/adapter}/index.js.map +1 -1
- package/dist/mai/lib/{kamaiTachi → adapter/kamaiTachi}/index.d.ts +84 -42
- package/dist/mai/lib/{kamaiTachi → adapter/kamaiTachi}/index.js +36 -29
- package/dist/mai/lib/adapter/kamaiTachi/index.js.map +1 -0
- package/dist/mai/lib/{lxns → adapter/lxns}/index.d.ts +12 -12
- package/dist/mai/lib/{lxns → adapter/lxns}/index.js +29 -30
- package/dist/mai/lib/adapter/lxns/index.js.map +1 -0
- package/dist/mai/lib/{maishift → adapter/maishift}/index.d.ts +4 -4
- package/dist/mai/lib/{maishift → adapter/maishift}/index.js +20 -20
- package/dist/mai/lib/adapter/maishift/index.js.map +1 -0
- package/dist/mai/{chart → lib}/database.d.ts +3 -3
- package/dist/mai/{chart → lib}/database.js +2 -2
- package/dist/mai/lib/database.js.map +1 -0
- package/dist/mai/lib/util.d.ts +134 -0
- package/dist/mai/lib/util.js +264 -0
- package/dist/mai/lib/util.js.map +1 -0
- package/dist/mai/painter/best50/index.d.ts +140 -0
- package/dist/mai/painter/best50/index.js +176 -0
- package/dist/mai/painter/best50/index.js.map +1 -0
- package/dist/mai/painter/chart/index.d.ts +195 -0
- package/dist/mai/painter/chart/index.js +115 -0
- package/dist/mai/painter/chart/index.js.map +1 -0
- package/dist/mai/painter/index.d.ts +237 -0
- package/dist/mai/painter/index.js +1431 -0
- package/dist/mai/painter/index.js.map +1 -0
- package/dist/mai/painter/level50/index.d.ts +28 -0
- package/dist/mai/painter/level50/index.js +129 -0
- package/dist/mai/painter/level50/index.js.map +1 -0
- package/dist/mai/type.d.ts +110 -0
- package/dist/mai/type.js +73 -1
- package/dist/mai/type.js.map +1 -1
- package/package.json +56 -55
- package/dist/chu/bests/best50.d.ts +0 -37
- package/dist/chu/bests/best50.js +0 -742
- package/dist/chu/bests/best50.js.map +0 -1
- package/dist/chu/bests/index.d.ts +0 -1
- package/dist/chu/bests/index.js +0 -6
- package/dist/chu/bests/index.js.map +0 -1
- package/dist/chu/bests/type.d.ts +0 -122
- package/dist/chu/bests/type.js +0 -3
- package/dist/chu/bests/type.js.map +0 -1
- package/dist/chu/chart/database.js.map +0 -1
- package/dist/chu/chart/index.d.ts +0 -212
- package/dist/chu/chart/index.js +0 -1064
- package/dist/chu/chart/index.js.map +0 -1
- package/dist/chu/lib/index.js.map +0 -1
- package/dist/chu/lib/kamaiTachi/index.js.map +0 -1
- package/dist/chu/lib/lxns/index.js.map +0 -1
- package/dist/geki/bests/best50.d.ts +0 -35
- package/dist/geki/bests/best50.js +0 -821
- package/dist/geki/bests/best50.js.map +0 -1
- package/dist/geki/bests/index.d.ts +0 -1
- package/dist/geki/bests/index.js +0 -6
- package/dist/geki/bests/index.js.map +0 -1
- package/dist/geki/bests/lib/kamaiTachi/index.js.map +0 -1
- package/dist/geki/bests/type.d.ts +0 -122
- package/dist/geki/bests/type.js +0 -3
- package/dist/geki/bests/type.js.map +0 -1
- package/dist/geki/chart/database.js.map +0 -1
- package/dist/geki/chart/index.d.ts +0 -4
- package/dist/geki/chart/index.js +0 -32
- package/dist/geki/chart/index.js.map +0 -1
- package/dist/mai/best50/index.d.ts +0 -271
- package/dist/mai/best50/index.js +0 -915
- package/dist/mai/best50/index.js.map +0 -1
- package/dist/mai/chart/database.js.map +0 -1
- package/dist/mai/chart/index.d.ts +0 -238
- package/dist/mai/chart/index.js +0 -1281
- package/dist/mai/chart/index.js.map +0 -1
- package/dist/mai/level50/index.d.ts +0 -28
- package/dist/mai/level50/index.js +0 -774
- package/dist/mai/level50/index.js.map +0 -1
- package/dist/mai/lib/divingFish/index.js.map +0 -1
- package/dist/mai/lib/index.js.map +0 -1
- package/dist/mai/lib/kamaiTachi/index.js.map +0 -1
- package/dist/mai/lib/lxns/index.js.map +0 -1
- package/dist/mai/lib/maishift/index.js.map +0 -1
- /package/dist/geki/{bests/lib → lib/adapter}/index.d.ts +0 -0
- /package/dist/geki/{bests/lib → lib/adapter}/index.js +0 -0
- /package/dist/geki/{bests/lib → lib/adapter}/kamaiTachi/index.d.ts +0 -0
- /package/dist/geki/{bests/lib → lib/adapter}/kamaiTachi/index.js +0 -0
package/dist/chu/chart/index.js
DELETED
|
@@ -1,1064 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.Chart = void 0;
|
|
30
|
-
const sharp_1 = __importDefault(require("sharp"));
|
|
31
|
-
const type_1 = require("../type");
|
|
32
|
-
const database = __importStar(require("./database"));
|
|
33
|
-
const util_1 = require("../../lib/util");
|
|
34
|
-
const canvas_1 = require("canvas");
|
|
35
|
-
const color_1 = __importDefault(require("color"));
|
|
36
|
-
const glob_1 = require("glob");
|
|
37
|
-
const upath_1 = __importDefault(require("upath"));
|
|
38
|
-
const fs_1 = __importDefault(require("fs"));
|
|
39
|
-
const string_template_1 = __importDefault(require("string-template"));
|
|
40
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
41
|
-
class Chart {
|
|
42
|
-
static JPN_LATEST = 230;
|
|
43
|
-
static INT_LATEST = 140;
|
|
44
|
-
static CHN_LATEST = 120;
|
|
45
|
-
static CHUNITHM_VERSIONS = [
|
|
46
|
-
240, 230, 225, 220, 215, 210, 205, 200, 150, 145, 140, 135, 130, 125,
|
|
47
|
-
120, 115, 110, 105, 100,
|
|
48
|
-
];
|
|
49
|
-
static CHUNITHM_INT_VERSIONS = [
|
|
50
|
-
140, 135, 130, 125, 120, 115, 110, 105, 100,
|
|
51
|
-
];
|
|
52
|
-
static ZHONGERJIEZOU_VERSIONS = [120, 110, 100];
|
|
53
|
-
static findVersion(v, region) {
|
|
54
|
-
const target = (() => {
|
|
55
|
-
switch (region) {
|
|
56
|
-
case "INT":
|
|
57
|
-
return this.CHUNITHM_INT_VERSIONS;
|
|
58
|
-
case "CHN":
|
|
59
|
-
return this.ZHONGERJIEZOU_VERSIONS;
|
|
60
|
-
case "JPN":
|
|
61
|
-
default:
|
|
62
|
-
return this.CHUNITHM_VERSIONS;
|
|
63
|
-
}
|
|
64
|
-
})();
|
|
65
|
-
for (const version of target) {
|
|
66
|
-
if (v >= version)
|
|
67
|
-
return version;
|
|
68
|
-
}
|
|
69
|
-
return -1;
|
|
70
|
-
}
|
|
71
|
-
static DEFAULT_THEME = "jp-verse";
|
|
72
|
-
static primaryTheme = null;
|
|
73
|
-
static get assetsPath() {
|
|
74
|
-
return upath_1.default.join(__dirname, "..", "..", "..", "assets");
|
|
75
|
-
}
|
|
76
|
-
static themes = {};
|
|
77
|
-
static hasTheme(name) {
|
|
78
|
-
return !!this.themes[name];
|
|
79
|
-
}
|
|
80
|
-
static {
|
|
81
|
-
const manifests = (0, glob_1.globSync)(upath_1.default.join(this.assetsPath, "themes", "chunithm", "chart", "**", "manifest.json"));
|
|
82
|
-
for (const manifestPath of manifests) {
|
|
83
|
-
const manifest = JSON.parse(fs_1.default.readFileSync(manifestPath, "utf-8"));
|
|
84
|
-
if (this.validateManifest(manifest, upath_1.default.dirname(manifestPath))) {
|
|
85
|
-
this.themes[manifest.name] = upath_1.default.dirname(manifestPath);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
const loadThemeResult = this.loadTheme(this.DEFAULT_THEME);
|
|
89
|
-
if (!loadThemeResult) {
|
|
90
|
-
console.error("Failed to load default theme.");
|
|
91
|
-
}
|
|
92
|
-
(0, canvas_1.registerFont)(upath_1.default.join(this.assetsPath, "fonts", "gen-jyuu-gothic", "GenJyuuGothic-Bold.ttf"), {
|
|
93
|
-
family: "standard-font-title-jp",
|
|
94
|
-
});
|
|
95
|
-
(0, canvas_1.registerFont)(upath_1.default.join(this.assetsPath, "fonts", "comfortaa", "Comfortaa-Bold.ttf"), {
|
|
96
|
-
family: "standard-font-title-latin",
|
|
97
|
-
weight: "regular",
|
|
98
|
-
});
|
|
99
|
-
(0, canvas_1.registerFont)(upath_1.default.join(this.assetsPath, "fonts", "seurat-db", "FOT-Seurat Pro DB.otf"), {
|
|
100
|
-
family: "standard-font-username",
|
|
101
|
-
weight: "regular",
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
static validateManifest(payload, path) {
|
|
105
|
-
function assert(obj, path, condition) {
|
|
106
|
-
const deepValue = (o, p) => p.split(".").reduce((a, v) => a[v], o);
|
|
107
|
-
const payload = deepValue(obj, path);
|
|
108
|
-
const result = condition(payload);
|
|
109
|
-
if (result === true)
|
|
110
|
-
return true;
|
|
111
|
-
throw `Manifest validation failed at ${path}.${result == false ? "" : ` ${result}`}`;
|
|
112
|
-
}
|
|
113
|
-
function isFileExist(object, objectPath) {
|
|
114
|
-
return assert(object, objectPath, (p) => {
|
|
115
|
-
const filePath = upath_1.default.join(path, p);
|
|
116
|
-
if (typeof p == "string") {
|
|
117
|
-
if (fs_1.default.existsSync(filePath)) {
|
|
118
|
-
return true;
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
return `${filePath} does not exist.`;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
else
|
|
125
|
-
return false;
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
function isOneOf(object, path, optional = false, args) {
|
|
129
|
-
return assert(object, path, (p) => args.includes(p) || (optional && p === undefined));
|
|
130
|
-
}
|
|
131
|
-
function isString(object, path, optional = false) {
|
|
132
|
-
return assert(object, path, (p) => typeof p == "string" || (optional && p === undefined));
|
|
133
|
-
}
|
|
134
|
-
function isNumber(object, path, optional = false) {
|
|
135
|
-
return assert(object, path, (p) => typeof p == "number" || (optional && p === undefined));
|
|
136
|
-
}
|
|
137
|
-
function isArray(object, path, optional = false) {
|
|
138
|
-
return assert(object, path, (p) => Array.isArray(p) || (optional && p === undefined));
|
|
139
|
-
}
|
|
140
|
-
function isObject(object, path, optional = false) {
|
|
141
|
-
return assert(object, path, (p) => typeof p == "object" || (optional && p === undefined));
|
|
142
|
-
}
|
|
143
|
-
function isHexColor(object, path, optional = false) {
|
|
144
|
-
return assert(object, path, (p) => {
|
|
145
|
-
if (typeof p == "string")
|
|
146
|
-
return (/^(?:#[0-9A-F]{6}|#[0-9A-F]{8})$/i.test(p) ||
|
|
147
|
-
(optional && p === undefined));
|
|
148
|
-
else
|
|
149
|
-
return optional && p === undefined;
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
function isBoolean(object, path, optional = false) {
|
|
153
|
-
return assert(object, path, (p) => typeof p == "boolean" || (optional && p === undefined));
|
|
154
|
-
}
|
|
155
|
-
if (isString(payload, "displayName") &&
|
|
156
|
-
isString(payload, "name") &&
|
|
157
|
-
isNumber(payload, "width") &&
|
|
158
|
-
isNumber(payload, "height") &&
|
|
159
|
-
isObject(payload, "sprites") &&
|
|
160
|
-
isObject(payload, "sprites.achievement") &&
|
|
161
|
-
isFileExist(payload, "sprites.achievement.d") &&
|
|
162
|
-
isFileExist(payload, "sprites.achievement.c") &&
|
|
163
|
-
isFileExist(payload, "sprites.achievement.b") &&
|
|
164
|
-
isFileExist(payload, "sprites.achievement.bb") &&
|
|
165
|
-
isFileExist(payload, "sprites.achievement.bbb") &&
|
|
166
|
-
isFileExist(payload, "sprites.achievement.a") &&
|
|
167
|
-
isFileExist(payload, "sprites.achievement.aa") &&
|
|
168
|
-
isFileExist(payload, "sprites.achievement.aaa") &&
|
|
169
|
-
isFileExist(payload, "sprites.achievement.s") &&
|
|
170
|
-
isFileExist(payload, "sprites.achievement.sp") &&
|
|
171
|
-
isFileExist(payload, "sprites.achievement.ss") &&
|
|
172
|
-
isFileExist(payload, "sprites.achievement.ssp") &&
|
|
173
|
-
isFileExist(payload, "sprites.achievement.sss") &&
|
|
174
|
-
isFileExist(payload, "sprites.achievement.sssp") &&
|
|
175
|
-
isObject(payload, "sprites.milestone") &&
|
|
176
|
-
isFileExist(payload, "sprites.milestone.aj") &&
|
|
177
|
-
isFileExist(payload, "sprites.milestone.ajc") &&
|
|
178
|
-
isFileExist(payload, "sprites.milestone.fc") &&
|
|
179
|
-
isFileExist(payload, "sprites.milestone.none") &&
|
|
180
|
-
isObject(payload, "sprites.profile") &&
|
|
181
|
-
isFileExist(payload, "sprites.profile.icon") &&
|
|
182
|
-
isFileExist(payload, "sprites.profile.nameplate") &&
|
|
183
|
-
isFileExist(payload, "sprites.ratingNumberMap") &&
|
|
184
|
-
isObject(payload, "sprites.versions") &&
|
|
185
|
-
isObject(payload, "sprites.versions.JPN") &&
|
|
186
|
-
isFileExist(payload, "sprites.versions.JPN.100") &&
|
|
187
|
-
isFileExist(payload, "sprites.versions.JPN.105") &&
|
|
188
|
-
isFileExist(payload, "sprites.versions.JPN.110") &&
|
|
189
|
-
isFileExist(payload, "sprites.versions.JPN.115") &&
|
|
190
|
-
isFileExist(payload, "sprites.versions.JPN.120") &&
|
|
191
|
-
isFileExist(payload, "sprites.versions.JPN.125") &&
|
|
192
|
-
isFileExist(payload, "sprites.versions.JPN.130") &&
|
|
193
|
-
isFileExist(payload, "sprites.versions.JPN.135") &&
|
|
194
|
-
isFileExist(payload, "sprites.versions.JPN.140") &&
|
|
195
|
-
isFileExist(payload, "sprites.versions.JPN.145") &&
|
|
196
|
-
isFileExist(payload, "sprites.versions.JPN.150") &&
|
|
197
|
-
isFileExist(payload, "sprites.versions.JPN.155") &&
|
|
198
|
-
isFileExist(payload, "sprites.versions.JPN.200") &&
|
|
199
|
-
isFileExist(payload, "sprites.versions.JPN.205") &&
|
|
200
|
-
isFileExist(payload, "sprites.versions.JPN.210") &&
|
|
201
|
-
isFileExist(payload, "sprites.versions.JPN.215") &&
|
|
202
|
-
isFileExist(payload, "sprites.versions.JPN.220") &&
|
|
203
|
-
isFileExist(payload, "sprites.versions.JPN.225") &&
|
|
204
|
-
isFileExist(payload, "sprites.versions.JPN.230") &&
|
|
205
|
-
isFileExist(payload, "sprites.versions.JPN.240") &&
|
|
206
|
-
isObject(payload, "sprites.versions.INT") &&
|
|
207
|
-
isFileExist(payload, "sprites.versions.INT.100") &&
|
|
208
|
-
isFileExist(payload, "sprites.versions.INT.105") &&
|
|
209
|
-
isFileExist(payload, "sprites.versions.INT.110") &&
|
|
210
|
-
isFileExist(payload, "sprites.versions.INT.115") &&
|
|
211
|
-
isFileExist(payload, "sprites.versions.INT.120") &&
|
|
212
|
-
isFileExist(payload, "sprites.versions.INT.125") &&
|
|
213
|
-
isFileExist(payload, "sprites.versions.INT.130") &&
|
|
214
|
-
isFileExist(payload, "sprites.versions.INT.135") &&
|
|
215
|
-
isFileExist(payload, "sprites.versions.INT.140") &&
|
|
216
|
-
isObject(payload, "sprites.versions.CHN") &&
|
|
217
|
-
isFileExist(payload, "sprites.versions.CHN.100") &&
|
|
218
|
-
isFileExist(payload, "sprites.versions.CHN.110") &&
|
|
219
|
-
isFileExist(payload, "sprites.versions.CHN.120") &&
|
|
220
|
-
// isFileExist(payload, "sprites.versions.CHN.130") && // Ignore the yet to release 中二节奏2026
|
|
221
|
-
isArray(payload, "elements")) {
|
|
222
|
-
for (const element of payload.elements) {
|
|
223
|
-
if (isNumber(element, "x") && isNumber(element, "y")) {
|
|
224
|
-
switch (element.type) {
|
|
225
|
-
case "image": {
|
|
226
|
-
if (isNumber(element, "width") &&
|
|
227
|
-
isNumber(element, "height") &&
|
|
228
|
-
isFileExist(element, "path")) {
|
|
229
|
-
continue;
|
|
230
|
-
}
|
|
231
|
-
else
|
|
232
|
-
return false;
|
|
233
|
-
}
|
|
234
|
-
case "chart-grid": {
|
|
235
|
-
if (isNumber(element, "width") &&
|
|
236
|
-
isNumber(element, "height") &&
|
|
237
|
-
isNumber(element, "margin") &&
|
|
238
|
-
isNumber(element, "gap") &&
|
|
239
|
-
isObject(element, "bubble") &&
|
|
240
|
-
isHexColor(element, "bubble.color.basic") &&
|
|
241
|
-
isHexColor(element, "bubble.color.advanced") &&
|
|
242
|
-
isHexColor(element, "bubble.color.expert") &&
|
|
243
|
-
isHexColor(element, "bubble.color.master") &&
|
|
244
|
-
isHexColor(element, "bubble.color.ultima") &&
|
|
245
|
-
isHexColor(element, "bubble.color.worldsEnd") &&
|
|
246
|
-
isObject(element, "color") &&
|
|
247
|
-
isHexColor(element, "color.card")) {
|
|
248
|
-
continue;
|
|
249
|
-
}
|
|
250
|
-
else
|
|
251
|
-
return false;
|
|
252
|
-
}
|
|
253
|
-
case "profile": {
|
|
254
|
-
if (isNumber(element, "height")) {
|
|
255
|
-
continue;
|
|
256
|
-
}
|
|
257
|
-
else
|
|
258
|
-
return false;
|
|
259
|
-
}
|
|
260
|
-
case "detail-info": {
|
|
261
|
-
if (isNumber(element, "width") &&
|
|
262
|
-
isNumber(element, "height") &&
|
|
263
|
-
isNumber(element, "margin") &&
|
|
264
|
-
isObject(element, "color") &&
|
|
265
|
-
isHexColor(element, "color.card") &&
|
|
266
|
-
isString(element, "font", true)) {
|
|
267
|
-
continue;
|
|
268
|
-
}
|
|
269
|
-
else
|
|
270
|
-
return false;
|
|
271
|
-
}
|
|
272
|
-
case "text": {
|
|
273
|
-
if (isNumber(element, "size") &&
|
|
274
|
-
isString(element, "content") &&
|
|
275
|
-
isNumber(element, "width", true) &&
|
|
276
|
-
isNumber(element, "height", true) &&
|
|
277
|
-
isBoolean(element, "linebreak", true) &&
|
|
278
|
-
isOneOf(element, "align", true, [
|
|
279
|
-
"left",
|
|
280
|
-
"center",
|
|
281
|
-
"right",
|
|
282
|
-
]) &&
|
|
283
|
-
isString(element, "color", true) &&
|
|
284
|
-
isString(element, "borderColor", true) &&
|
|
285
|
-
isString(element, "font", true)) {
|
|
286
|
-
continue;
|
|
287
|
-
}
|
|
288
|
-
else
|
|
289
|
-
return false;
|
|
290
|
-
}
|
|
291
|
-
default:
|
|
292
|
-
throw `Manifest validation failed at elements.type. Unsupported element type ${element.type}.`;
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
return true;
|
|
297
|
-
}
|
|
298
|
-
else
|
|
299
|
-
return false;
|
|
300
|
-
}
|
|
301
|
-
static loadTheme(path) {
|
|
302
|
-
const theme = this.getTheme(path);
|
|
303
|
-
if (theme) {
|
|
304
|
-
this.primaryTheme = theme;
|
|
305
|
-
return true;
|
|
306
|
-
}
|
|
307
|
-
else
|
|
308
|
-
return false;
|
|
309
|
-
}
|
|
310
|
-
static getTheme(path) {
|
|
311
|
-
if (!fs_1.default.existsSync(upath_1.default.join(path, "manifest.json"))) {
|
|
312
|
-
path = this.themes[path] ?? "";
|
|
313
|
-
}
|
|
314
|
-
else
|
|
315
|
-
path = upath_1.default.join(this.assetsPath, path);
|
|
316
|
-
if (fs_1.default.existsSync(upath_1.default.join(path, "manifest.json"))) {
|
|
317
|
-
const manifest = JSON.parse(fs_1.default.readFileSync(upath_1.default.join(path, "manifest.json"), "utf-8"));
|
|
318
|
-
if (this.validateManifest(manifest, path)) {
|
|
319
|
-
return { manifest, path };
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
return null;
|
|
323
|
-
}
|
|
324
|
-
static getThemeFile(path, themePath) {
|
|
325
|
-
if (typeof path == "string" &&
|
|
326
|
-
fs_1.default.existsSync(upath_1.default.join(themePath ?? this.primaryTheme?.path ?? "", path)))
|
|
327
|
-
return fs_1.default.readFileSync(upath_1.default.join(themePath ?? this.primaryTheme?.path, path));
|
|
328
|
-
else
|
|
329
|
-
return Buffer.from([]);
|
|
330
|
-
}
|
|
331
|
-
/* Begin Draw Tools*/
|
|
332
|
-
static async drawImageModule(ctx, theme, element) {
|
|
333
|
-
const img = new canvas_1.Image();
|
|
334
|
-
img.src = this.getThemeFile(element.path, theme.path);
|
|
335
|
-
ctx.drawImage(img, element.x, element.y, element.width, element.height);
|
|
336
|
-
}
|
|
337
|
-
static async drawChartGridCard(ctx, theme, element, chart, difficulty, x, y, width, height, isShort, targetRegion = "JPN", score) {
|
|
338
|
-
let curColor = "#FFFFFF";
|
|
339
|
-
switch (difficulty) {
|
|
340
|
-
case type_1.EDifficulty.BASIC:
|
|
341
|
-
curColor = element.bubble.color.basic;
|
|
342
|
-
break;
|
|
343
|
-
case type_1.EDifficulty.ADVANCED:
|
|
344
|
-
curColor = element.bubble.color.advanced;
|
|
345
|
-
break;
|
|
346
|
-
case type_1.EDifficulty.EXPERT:
|
|
347
|
-
curColor = element.bubble.color.expert;
|
|
348
|
-
break;
|
|
349
|
-
case type_1.EDifficulty.MASTER:
|
|
350
|
-
curColor = element.bubble.color.master;
|
|
351
|
-
break;
|
|
352
|
-
case type_1.EDifficulty.ULTIMA:
|
|
353
|
-
curColor = element.bubble.color.ultima;
|
|
354
|
-
break;
|
|
355
|
-
case type_1.EDifficulty.WORLDS_END:
|
|
356
|
-
curColor = element.bubble.color.worldsEnd;
|
|
357
|
-
break;
|
|
358
|
-
}
|
|
359
|
-
/** Begin Card Draw */
|
|
360
|
-
ctx.save();
|
|
361
|
-
ctx.fillStyle = new color_1.default(curColor).lighten(0.4).hexa();
|
|
362
|
-
ctx.beginPath();
|
|
363
|
-
ctx.roundRect(x, y, width, height, (height * 0.806) / 7);
|
|
364
|
-
ctx.strokeStyle = new color_1.default(curColor).darken(0.3).hexa();
|
|
365
|
-
ctx.lineWidth = element.bubble.margin / 4;
|
|
366
|
-
ctx.stroke();
|
|
367
|
-
ctx.fill();
|
|
368
|
-
ctx.beginPath();
|
|
369
|
-
ctx.roundRect(x, y, width, height, (height * 0.806) / 7);
|
|
370
|
-
ctx.clip();
|
|
371
|
-
/** Begin Main Content Draw */
|
|
372
|
-
{
|
|
373
|
-
ctx.save();
|
|
374
|
-
ctx.beginPath();
|
|
375
|
-
ctx.rect(x, y, width, height);
|
|
376
|
-
ctx.clip();
|
|
377
|
-
ctx.fillStyle = curColor;
|
|
378
|
-
ctx.fill();
|
|
379
|
-
const titleSize = height * (47 / 256);
|
|
380
|
-
/** Begin Difficulty Text & Separation Line Draw */
|
|
381
|
-
{
|
|
382
|
-
let difficultiy = "";
|
|
383
|
-
switch (chart.difficulty) {
|
|
384
|
-
case type_1.EDifficulty.BASIC:
|
|
385
|
-
difficultiy = "BASIC";
|
|
386
|
-
break;
|
|
387
|
-
case type_1.EDifficulty.ADVANCED:
|
|
388
|
-
difficultiy = "ADVANCED";
|
|
389
|
-
break;
|
|
390
|
-
case type_1.EDifficulty.EXPERT:
|
|
391
|
-
difficultiy = "EXPERT";
|
|
392
|
-
break;
|
|
393
|
-
case type_1.EDifficulty.MASTER:
|
|
394
|
-
difficultiy = "MASTER";
|
|
395
|
-
break;
|
|
396
|
-
case type_1.EDifficulty.ULTIMA:
|
|
397
|
-
difficultiy = "ULTIMA";
|
|
398
|
-
break;
|
|
399
|
-
case type_1.EDifficulty.WORLDS_END:
|
|
400
|
-
difficultiy = "WORLD'S END";
|
|
401
|
-
break;
|
|
402
|
-
}
|
|
403
|
-
const levelTextSize = titleSize * (5 / 8);
|
|
404
|
-
util_1.Util.drawText(ctx, difficultiy, x + element.bubble.margin, y +
|
|
405
|
-
element.bubble.margin +
|
|
406
|
-
titleSize -
|
|
407
|
-
element.bubble.margin * (1 / 4), titleSize, height * 0.806 * 0.04, Infinity, "left", "white", new color_1.default(curColor).darken(0.3).hexa());
|
|
408
|
-
const difficultyTextWidth = util_1.Util.measureText(ctx, difficultiy, titleSize, Infinity).width;
|
|
409
|
-
util_1.Util.drawText(ctx, `Lv. ${util_1.Util.truncate(chart.events
|
|
410
|
-
.filter((v) => v.version.region == targetRegion)
|
|
411
|
-
.reverse()
|
|
412
|
-
.find((v) => v.type == "existence")?.data.level ||
|
|
413
|
-
0, 1)}${score ? ` +${util_1.Util.truncate(score.rating, 1)}` : ""}`, x + element.bubble.margin * 2 + difficultyTextWidth, y +
|
|
414
|
-
element.bubble.margin +
|
|
415
|
-
titleSize -
|
|
416
|
-
element.bubble.margin * (1 / 4), levelTextSize, height * 0.806 * 0.04, Infinity, "left", "white", new color_1.default(curColor).darken(0.3).hexa());
|
|
417
|
-
ctx.beginPath();
|
|
418
|
-
ctx.roundRect(x + element.bubble.margin, y +
|
|
419
|
-
element.bubble.margin +
|
|
420
|
-
titleSize +
|
|
421
|
-
element.bubble.margin * (1 / 4), height * 2 - element.bubble.margin * 2, height * 0.806 * 0.02, height * 0.806 * 0.16);
|
|
422
|
-
ctx.fillStyle = new color_1.default(curColor).darken(0.3).hex();
|
|
423
|
-
ctx.fill();
|
|
424
|
-
}
|
|
425
|
-
/** End Difficulty Text & Separation Line Draw */
|
|
426
|
-
/** Begin Achievement Rate Draw */
|
|
427
|
-
{
|
|
428
|
-
const scoreSize = height * 0.806 * 0.208;
|
|
429
|
-
util_1.Util.drawText(ctx, score ? util_1.Util.truncate(score.score, 0) : "NO RECORD", x +
|
|
430
|
-
height * 2 -
|
|
431
|
-
element.bubble.margin -
|
|
432
|
-
height * 0.806 * 0.02, y +
|
|
433
|
-
element.bubble.margin +
|
|
434
|
-
titleSize +
|
|
435
|
-
element.bubble.margin * (5 / 8) +
|
|
436
|
-
scoreSize, scoreSize, height * 0.806 * 0.04, Infinity, "right", "white", new color_1.default(curColor).darken(0.3).hexa());
|
|
437
|
-
}
|
|
438
|
-
/** End Achievement Rate Draw */
|
|
439
|
-
/** Begin Achievement Rank Draw */
|
|
440
|
-
{
|
|
441
|
-
if (score) {
|
|
442
|
-
let rankImg;
|
|
443
|
-
switch (score.rank) {
|
|
444
|
-
case type_1.EAchievementTypes.D:
|
|
445
|
-
rankImg = this.getThemeFile(theme.manifest.sprites.achievement.d, theme.path);
|
|
446
|
-
break;
|
|
447
|
-
case type_1.EAchievementTypes.C:
|
|
448
|
-
rankImg = this.getThemeFile(theme.manifest.sprites.achievement.c, theme.path);
|
|
449
|
-
break;
|
|
450
|
-
case type_1.EAchievementTypes.B:
|
|
451
|
-
rankImg = this.getThemeFile(theme.manifest.sprites.achievement.b, theme.path);
|
|
452
|
-
break;
|
|
453
|
-
case type_1.EAchievementTypes.BB:
|
|
454
|
-
rankImg = this.getThemeFile(theme.manifest.sprites.achievement.bb, theme.path);
|
|
455
|
-
break;
|
|
456
|
-
case type_1.EAchievementTypes.BBB:
|
|
457
|
-
rankImg = this.getThemeFile(theme.manifest.sprites.achievement.bbb, theme.path);
|
|
458
|
-
break;
|
|
459
|
-
case type_1.EAchievementTypes.A:
|
|
460
|
-
rankImg = this.getThemeFile(theme.manifest.sprites.achievement.a, theme.path);
|
|
461
|
-
break;
|
|
462
|
-
case type_1.EAchievementTypes.AA:
|
|
463
|
-
rankImg = this.getThemeFile(theme.manifest.sprites.achievement.aa, theme.path);
|
|
464
|
-
break;
|
|
465
|
-
case type_1.EAchievementTypes.AAA:
|
|
466
|
-
rankImg = this.getThemeFile(theme.manifest.sprites.achievement.aaa, theme.path);
|
|
467
|
-
break;
|
|
468
|
-
case type_1.EAchievementTypes.S:
|
|
469
|
-
rankImg = this.getThemeFile(theme.manifest.sprites.achievement.s, theme.path);
|
|
470
|
-
break;
|
|
471
|
-
case type_1.EAchievementTypes.SP:
|
|
472
|
-
rankImg = this.getThemeFile(theme.manifest.sprites.achievement.sp, theme.path);
|
|
473
|
-
break;
|
|
474
|
-
case type_1.EAchievementTypes.SS:
|
|
475
|
-
rankImg = this.getThemeFile(theme.manifest.sprites.achievement.ss, theme.path);
|
|
476
|
-
break;
|
|
477
|
-
case type_1.EAchievementTypes.SSP:
|
|
478
|
-
rankImg = this.getThemeFile(theme.manifest.sprites.achievement.ssp, theme.path);
|
|
479
|
-
break;
|
|
480
|
-
case type_1.EAchievementTypes.SSS:
|
|
481
|
-
rankImg = this.getThemeFile(theme.manifest.sprites.achievement.sss, theme.path);
|
|
482
|
-
break;
|
|
483
|
-
default:
|
|
484
|
-
rankImg = this.getThemeFile(theme.manifest.sprites.achievement.sssp, theme.path);
|
|
485
|
-
}
|
|
486
|
-
const blockHeight = height * 0.806 * 0.3 * 0.85, blockWidth = blockHeight * (540 / 180);
|
|
487
|
-
const img = new canvas_1.Image();
|
|
488
|
-
img.src = rankImg;
|
|
489
|
-
ctx.drawImage(img, x + element.bubble.margin * (1 / 2), y +
|
|
490
|
-
element.bubble.margin +
|
|
491
|
-
titleSize +
|
|
492
|
-
element.bubble.margin * (1 / 2), blockWidth, blockHeight);
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
/** End Achievement Rank Draw */
|
|
496
|
-
/** Begin Milestone Draw */
|
|
497
|
-
{
|
|
498
|
-
const blockWidth = height * 0.806 * 0.32 * 3, blockHeight = (blockWidth * 40) / 268;
|
|
499
|
-
const curX = x - blockWidth + height * 2 - element.bubble.margin, curY = y + element.bubble.margin * 2 + titleSize * 2;
|
|
500
|
-
ctx.fillStyle = "#e8eaec";
|
|
501
|
-
ctx.roundRect(curX, curY, blockWidth, blockHeight, blockWidth / 56);
|
|
502
|
-
ctx.fill();
|
|
503
|
-
if (score) {
|
|
504
|
-
let comboImg;
|
|
505
|
-
switch (score.combo) {
|
|
506
|
-
case type_1.EComboTypes.NONE:
|
|
507
|
-
comboImg = this.getThemeFile(theme.manifest.sprites.milestone.none, theme.path);
|
|
508
|
-
break;
|
|
509
|
-
case type_1.EComboTypes.FULL_COMBO:
|
|
510
|
-
comboImg = this.getThemeFile(theme.manifest.sprites.milestone.fc, theme.path);
|
|
511
|
-
break;
|
|
512
|
-
case type_1.EComboTypes.ALL_JUSTICE:
|
|
513
|
-
comboImg = this.getThemeFile(theme.manifest.sprites.milestone.aj, theme.path);
|
|
514
|
-
break;
|
|
515
|
-
case type_1.EComboTypes.ALL_JUSTICE_CRITICAL:
|
|
516
|
-
comboImg = this.getThemeFile(theme.manifest.sprites.milestone.ajc, theme.path);
|
|
517
|
-
break;
|
|
518
|
-
}
|
|
519
|
-
const combo = new canvas_1.Image();
|
|
520
|
-
combo.src = comboImg;
|
|
521
|
-
ctx.drawImage(combo, curX, curY, blockWidth, blockHeight);
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
/** End Milestone Draw */
|
|
525
|
-
/** Begin Version Draw */
|
|
526
|
-
{
|
|
527
|
-
const version = {
|
|
528
|
-
region: "JPN",
|
|
529
|
-
version: undefined,
|
|
530
|
-
};
|
|
531
|
-
const VER = chart.difficulty == type_1.EDifficulty.ULTIMA
|
|
532
|
-
? chart.events.find((v) => v.type == "existence" &&
|
|
533
|
-
v.version.region == targetRegion)?.version
|
|
534
|
-
: chart.addVersion;
|
|
535
|
-
version.version = VER;
|
|
536
|
-
version.region = targetRegion;
|
|
537
|
-
const versionImageHeight = (height - element.bubble.margin * 2) *
|
|
538
|
-
(isShort ? 9 / 16 : 1 / 2);
|
|
539
|
-
const versionImageWidth = (versionImageHeight / 160) * 201;
|
|
540
|
-
const curx = x + width - element.bubble.margin, cury = y + element.bubble.margin;
|
|
541
|
-
if (version.version) {
|
|
542
|
-
const rawVersion = this.findVersion(util_1.Util.Chunithm.getNumberVersion(version.version), targetRegion);
|
|
543
|
-
const versionImage = this.getThemeFile(theme.manifest.sprites.versions[version.region][rawVersion]);
|
|
544
|
-
try {
|
|
545
|
-
(0, sharp_1.default)(versionImage);
|
|
546
|
-
if (versionImage) {
|
|
547
|
-
const versionImg = new canvas_1.Image();
|
|
548
|
-
versionImg.src = versionImage;
|
|
549
|
-
ctx.drawImage(versionImg, curx - versionImageWidth, cury, versionImageWidth, versionImageHeight);
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
catch { }
|
|
553
|
-
}
|
|
554
|
-
/** End Version Draw */
|
|
555
|
-
/** Begin Note Count Draw */
|
|
556
|
-
const noteCountTexts = Object.entries(chart.meta.notes).map(([k, v]) => `${util_1.Util.capitalize(k)}: ${v}`);
|
|
557
|
-
const noteCountTextSize = (height - element.bubble.margin * 4) /
|
|
558
|
-
noteCountTexts.length;
|
|
559
|
-
let noteCountLength = 0;
|
|
560
|
-
noteCountTexts.forEach((v, i) => {
|
|
561
|
-
util_1.Util.drawText(ctx, v, x + element.bubble.margin * (3 / 2) + height * 2, y +
|
|
562
|
-
element.bubble.margin +
|
|
563
|
-
noteCountTextSize +
|
|
564
|
-
(noteCountTextSize +
|
|
565
|
-
(element.bubble.margin * 2) /
|
|
566
|
-
(noteCountTexts.length - 1)) *
|
|
567
|
-
i, noteCountTextSize, height * 0.806 * 0.04, Infinity, "left", "white", new color_1.default(curColor).darken(0.3).hexa());
|
|
568
|
-
const length = util_1.Util.measureText(ctx, v, noteCountTextSize, Infinity).width;
|
|
569
|
-
if (length > noteCountLength)
|
|
570
|
-
noteCountLength = length;
|
|
571
|
-
});
|
|
572
|
-
/** End Note Count Draw */
|
|
573
|
-
/** Begin Internal Level Trend Draw */
|
|
574
|
-
if (!isShort) {
|
|
575
|
-
const CURRENT_VER = (() => {
|
|
576
|
-
switch (targetRegion) {
|
|
577
|
-
case "INT":
|
|
578
|
-
return this.INT_LATEST;
|
|
579
|
-
case "CHN":
|
|
580
|
-
return this.CHN_LATEST;
|
|
581
|
-
case "JPN":
|
|
582
|
-
default:
|
|
583
|
-
return this.JPN_LATEST;
|
|
584
|
-
}
|
|
585
|
-
})();
|
|
586
|
-
const maxWidth = width -
|
|
587
|
-
height * 2 -
|
|
588
|
-
element.bubble.margin * 4 -
|
|
589
|
-
noteCountLength -
|
|
590
|
-
versionImageWidth;
|
|
591
|
-
const maxFitTrendCount = Math.trunc(maxWidth / versionImageWidth);
|
|
592
|
-
const trendEvents = chart.events.filter((v) => v.type == "existence" &&
|
|
593
|
-
v.version.region == targetRegion);
|
|
594
|
-
let actualEvents = lodash_1.default.uniqWith(trendEvents, (a, b) => {
|
|
595
|
-
return lodash_1.default.isEqual(a.data.level, b.data.level);
|
|
596
|
-
});
|
|
597
|
-
if (actualEvents.length == maxFitTrendCount) {
|
|
598
|
-
}
|
|
599
|
-
else if (actualEvents.length > maxFitTrendCount) {
|
|
600
|
-
while (actualEvents.length > maxFitTrendCount)
|
|
601
|
-
actualEvents.shift();
|
|
602
|
-
actualEvents.shift();
|
|
603
|
-
actualEvents.shift();
|
|
604
|
-
actualEvents.unshift(trendEvents[0]);
|
|
605
|
-
actualEvents.push(trendEvents[trendEvents.length - 1]);
|
|
606
|
-
}
|
|
607
|
-
else if (trendEvents.length > maxFitTrendCount) {
|
|
608
|
-
actualEvents = lodash_1.default.filter(actualEvents, (v) => !(lodash_1.default.isEqual(v.version.gameVersion, trendEvents[0].version.gameVersion) ||
|
|
609
|
-
lodash_1.default.isEqual(v.version.gameVersion, trendEvents[trendEvents.length - 1]
|
|
610
|
-
.version.gameVersion)));
|
|
611
|
-
for (let i = trendEvents.length - 2; i > 0 && actualEvents.length < maxFitTrendCount - 2; --i) {
|
|
612
|
-
const event = trendEvents[i];
|
|
613
|
-
if (event)
|
|
614
|
-
actualEvents.push(event);
|
|
615
|
-
actualEvents = lodash_1.default.uniqWith(actualEvents, (a, b) => {
|
|
616
|
-
return (lodash_1.default.isEqual(a.version.gameVersion.major, b.version.gameVersion.major) &&
|
|
617
|
-
lodash_1.default.isEqual(a.version.gameVersion.minor, b.version.gameVersion.minor));
|
|
618
|
-
});
|
|
619
|
-
}
|
|
620
|
-
actualEvents.unshift(trendEvents[0]);
|
|
621
|
-
actualEvents.push(trendEvents[trendEvents.length - 1]);
|
|
622
|
-
actualEvents = lodash_1.default.uniqWith(actualEvents, (a, b) => {
|
|
623
|
-
return (lodash_1.default.isEqual(a.version.gameVersion.major, b.version.gameVersion.major) &&
|
|
624
|
-
lodash_1.default.isEqual(a.version.gameVersion.minor, b.version.gameVersion.minor));
|
|
625
|
-
});
|
|
626
|
-
actualEvents = lodash_1.default.sortBy(actualEvents, (v) => util_1.Util.Chunithm.getNumberVersion(v.version));
|
|
627
|
-
if (trendEvents.length > 1) {
|
|
628
|
-
if (actualEvents.length >= maxFitTrendCount)
|
|
629
|
-
actualEvents.pop();
|
|
630
|
-
actualEvents.push(trendEvents[trendEvents.length - 1]);
|
|
631
|
-
}
|
|
632
|
-
const removalEvent = chart.events.find((v) => v.type == "removal" &&
|
|
633
|
-
v.version.region == targetRegion);
|
|
634
|
-
if (removalEvent) {
|
|
635
|
-
actualEvents.pop();
|
|
636
|
-
actualEvents.push(removalEvent);
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
else {
|
|
640
|
-
actualEvents = [...trendEvents];
|
|
641
|
-
}
|
|
642
|
-
if (util_1.Util.Chunithm.getNumberVersion(actualEvents[actualEvents.length - 1].version) < CURRENT_VER) {
|
|
643
|
-
while (actualEvents.length >= maxFitTrendCount)
|
|
644
|
-
actualEvents.pop();
|
|
645
|
-
actualEvents.push({
|
|
646
|
-
type: "removal",
|
|
647
|
-
version: util_1.Util.Chunithm.Version.toEventVersion(util_1.Util.Chunithm.Version.getNextVersion(trendEvents[trendEvents.length - 1].version)),
|
|
648
|
-
});
|
|
649
|
-
}
|
|
650
|
-
actualEvents = lodash_1.default.uniqWith(actualEvents, (a, b) => {
|
|
651
|
-
return (lodash_1.default.isEqual(a.version.gameVersion.major, b.version.gameVersion.major) &&
|
|
652
|
-
lodash_1.default.isEqual(a.version.gameVersion.minor, b.version.gameVersion.minor) &&
|
|
653
|
-
lodash_1.default.isEqual(a.type, b.type));
|
|
654
|
-
});
|
|
655
|
-
let positionAdjustment = 0;
|
|
656
|
-
let addGap = (maxWidth - actualEvents.length * versionImageWidth) /
|
|
657
|
-
(actualEvents.length - 1);
|
|
658
|
-
if (addGap > maxWidth / 5) {
|
|
659
|
-
addGap = maxWidth / 5;
|
|
660
|
-
positionAdjustment =
|
|
661
|
-
(maxWidth -
|
|
662
|
-
(addGap * (actualEvents.length - 1) +
|
|
663
|
-
versionImageWidth * actualEvents.length)) /
|
|
664
|
-
2;
|
|
665
|
-
}
|
|
666
|
-
for (let i = 0, curx = x +
|
|
667
|
-
positionAdjustment +
|
|
668
|
-
height * 2 +
|
|
669
|
-
element.bubble.margin * (5 / 2) +
|
|
670
|
-
noteCountLength, cury = y +
|
|
671
|
-
element.bubble.margin +
|
|
672
|
-
versionImageHeight * (1 / 2); i < actualEvents.length; ++i) {
|
|
673
|
-
const event = actualEvents[i];
|
|
674
|
-
const rawVersion = this.findVersion(util_1.Util.Chunithm.getNumberVersion(event.version), targetRegion);
|
|
675
|
-
const versionImage = this.getThemeFile(theme.manifest.sprites.versions[targetRegion][rawVersion]);
|
|
676
|
-
try {
|
|
677
|
-
(0, sharp_1.default)(versionImage);
|
|
678
|
-
if (versionImage) {
|
|
679
|
-
const versionImg = new canvas_1.Image();
|
|
680
|
-
versionImg.src = versionImage;
|
|
681
|
-
ctx.drawImage(versionImg, curx, cury, versionImageWidth, versionImageHeight);
|
|
682
|
-
if (event.type == "existence") {
|
|
683
|
-
let symbol = "";
|
|
684
|
-
if (i != 0) {
|
|
685
|
-
const lastEvent = actualEvents[i - 1];
|
|
686
|
-
if (lastEvent.type == "existence") {
|
|
687
|
-
if (lastEvent.data.level <
|
|
688
|
-
event.data.level)
|
|
689
|
-
symbol = "↑";
|
|
690
|
-
else if (lastEvent.data.level >
|
|
691
|
-
event.data.level)
|
|
692
|
-
symbol = "↓";
|
|
693
|
-
else if (lastEvent.data.level ==
|
|
694
|
-
event.data.level)
|
|
695
|
-
symbol = "→";
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
|
-
util_1.Util.drawText(ctx, `${symbol}${util_1.Util.truncate(event.data.level, 1)}`, curx + versionImageWidth / 2, cury +
|
|
699
|
-
versionImageHeight +
|
|
700
|
-
noteCountTextSize, noteCountTextSize, height * 0.806 * 0.04, Infinity, "center", "white", new color_1.default(curColor).darken(0.3).hexa());
|
|
701
|
-
}
|
|
702
|
-
else if (event.type == "removal") {
|
|
703
|
-
util_1.Util.drawText(ctx, `❌`, curx + versionImageWidth / 2, cury +
|
|
704
|
-
versionImageHeight +
|
|
705
|
-
noteCountTextSize, noteCountTextSize, height * 0.806 * 0.04, Infinity, "center", "white", new color_1.default(curColor).darken(0.3).hexa());
|
|
706
|
-
}
|
|
707
|
-
curx += versionImageWidth + addGap;
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
catch { }
|
|
711
|
-
}
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
|
-
/** End Internal Level Trend Draw */
|
|
715
|
-
ctx.restore();
|
|
716
|
-
}
|
|
717
|
-
/** End Main Content Draw */
|
|
718
|
-
ctx.fillStyle = new color_1.default(curColor).lighten(0.4).hexa();
|
|
719
|
-
ctx.beginPath();
|
|
720
|
-
ctx.roundRect(x, y + height * 0.742, height * 2, height * (1 - 0.742), [
|
|
721
|
-
0,
|
|
722
|
-
(height * 0.806) / 7,
|
|
723
|
-
0,
|
|
724
|
-
(height * 0.806) / 7,
|
|
725
|
-
]);
|
|
726
|
-
ctx.fill();
|
|
727
|
-
/** Begin Difficulty & DX Rating Draw */
|
|
728
|
-
{
|
|
729
|
-
ctx.save();
|
|
730
|
-
ctx.clip();
|
|
731
|
-
util_1.Util.drawText(ctx, chart.designer || "-", x + element.bubble.margin, y + height * (0.806 + (1 - 0.806) / 2), height * 0.806 * 0.128, height * 0.806 * 0.04, Infinity, "left", "white", new color_1.default(curColor).darken(0.3).hexa());
|
|
732
|
-
ctx.restore();
|
|
733
|
-
// Util.drawText(
|
|
734
|
-
// ctx,
|
|
735
|
-
// `${score ? `${score.dxScore}/` : "MAX DX SCR: "}${chart.meta.maxDXScore}`,
|
|
736
|
-
// x + height * 2 - element.bubble.margin,
|
|
737
|
-
// y + height - element.bubble.margin * 3.1,
|
|
738
|
-
// height * 0.806 * 0.128,
|
|
739
|
-
// height * 0.806 * 0.04,
|
|
740
|
-
// Infinity,
|
|
741
|
-
// "right",
|
|
742
|
-
// "white",
|
|
743
|
-
// new Color(curColor).darken(0.3).hexa()
|
|
744
|
-
// );
|
|
745
|
-
}
|
|
746
|
-
/** End Difficulty & DX Rating Draw */
|
|
747
|
-
ctx.restore();
|
|
748
|
-
/** End Card Draw */
|
|
749
|
-
}
|
|
750
|
-
static async drawDetailInfoModule(ctx, theme, element, chartId) {
|
|
751
|
-
const jacketMargin = element.margin;
|
|
752
|
-
const textMargin = element.margin;
|
|
753
|
-
const chart = Chart.Database.getLocalChart(chartId, type_1.EDifficulty.BASIC);
|
|
754
|
-
const jacket = await Chart.Database.fecthJacket(chartId);
|
|
755
|
-
/* Begin Background Draw */
|
|
756
|
-
ctx.beginPath();
|
|
757
|
-
ctx.roundRect(element.x, element.y, element.width, element.height, Math.min(theme.manifest.width, theme.manifest.height) * (3 / 128));
|
|
758
|
-
ctx.fillStyle = element.color.card;
|
|
759
|
-
ctx.strokeStyle = new color_1.default(element.color.card).darken(0.6).hex();
|
|
760
|
-
ctx.lineWidth =
|
|
761
|
-
Math.min(theme.manifest.width, theme.manifest.height) * (3 / 512);
|
|
762
|
-
ctx.stroke();
|
|
763
|
-
ctx.fill();
|
|
764
|
-
/* End Background Draw */
|
|
765
|
-
/* Begin jacket draw */
|
|
766
|
-
if (jacket) {
|
|
767
|
-
const jacketImage = new canvas_1.Image();
|
|
768
|
-
const roundRadius = Math.min(theme.manifest.width, theme.manifest.height) *
|
|
769
|
-
(3 / 128);
|
|
770
|
-
jacketImage.src = jacket;
|
|
771
|
-
ctx.beginPath();
|
|
772
|
-
ctx.roundRect(element.x + jacketMargin, element.y + jacketMargin, element.width - jacketMargin * 2, element.width - jacketMargin * 2, [roundRadius, roundRadius, 0, 0]);
|
|
773
|
-
ctx.save();
|
|
774
|
-
ctx.clip();
|
|
775
|
-
ctx.drawImage(jacketImage, element.x + jacketMargin, element.y + jacketMargin, element.width - jacketMargin * 2, element.width - jacketMargin * 2);
|
|
776
|
-
ctx.restore();
|
|
777
|
-
}
|
|
778
|
-
/* End jacket draw */
|
|
779
|
-
/* Begin Detail Draw */
|
|
780
|
-
if (chart) {
|
|
781
|
-
const textSizeTitle = element.width * (1 / 16);
|
|
782
|
-
const textSizeSecondary = element.width * (1 / 24);
|
|
783
|
-
const { actualBoundingBoxAscent: ascent, actualBoundingBoxDescent: decent, } = util_1.Util.measureText(ctx, chart.name, textSizeTitle, Infinity);
|
|
784
|
-
const titleActualHeight = Math.abs(ascent - decent);
|
|
785
|
-
const textLineWidth = element.width * (7 / 512);
|
|
786
|
-
const textColor = new color_1.default(element.color.card).darken(0.5).hex();
|
|
787
|
-
const textTitleMaxWidth = element.width - textMargin * 2;
|
|
788
|
-
const titleMetrics = util_1.Util.measureText(ctx, chart.name, textSizeTitle, textTitleMaxWidth);
|
|
789
|
-
util_1.Util.drawText(ctx, chart.name, element.x + textMargin, element.y +
|
|
790
|
-
jacketMargin +
|
|
791
|
-
textMargin * (1 / 2) +
|
|
792
|
-
(element.width - jacketMargin * 2) +
|
|
793
|
-
textSizeTitle, textSizeTitle, textLineWidth, textTitleMaxWidth, "left", "white", textColor);
|
|
794
|
-
util_1.Util.drawText(ctx, chart.artist, element.x + textMargin, element.y +
|
|
795
|
-
jacketMargin +
|
|
796
|
-
textMargin * (1 / 2) +
|
|
797
|
-
(element.width - jacketMargin * 2) +
|
|
798
|
-
textSizeTitle * 2, textSizeSecondary, textLineWidth, element.width - textMargin * 2, "left", "white", textColor);
|
|
799
|
-
function getBpmRange(bpms) {
|
|
800
|
-
const uniqueBpms = lodash_1.default.uniq(bpms);
|
|
801
|
-
if (uniqueBpms.length <= 0)
|
|
802
|
-
return "0";
|
|
803
|
-
else if (uniqueBpms.length == 1)
|
|
804
|
-
return `${uniqueBpms[0]}`;
|
|
805
|
-
else {
|
|
806
|
-
const minBpm = Math.min(...uniqueBpms);
|
|
807
|
-
const maxBpm = Math.max(...uniqueBpms);
|
|
808
|
-
return `${minBpm}-${maxBpm}`;
|
|
809
|
-
}
|
|
810
|
-
}
|
|
811
|
-
util_1.Util.drawText(ctx, `#${chart.id} BPM: ${getBpmRange(chart.bpms)}`, element.x + textMargin, element.y +
|
|
812
|
-
jacketMargin +
|
|
813
|
-
textMargin * (1 / 2) +
|
|
814
|
-
(element.width - jacketMargin * 2) +
|
|
815
|
-
textSizeTitle * 3, textSizeSecondary, textLineWidth, element.width - textMargin * 2, "left", "white", textColor);
|
|
816
|
-
const EVENT_JPN = chart.events
|
|
817
|
-
.filter((v) => v.version.region == "JPN" &&
|
|
818
|
-
util_1.Util.Chunithm.getNumberVersion(v.version) >=
|
|
819
|
-
Chart.JPN_LATEST)
|
|
820
|
-
.map((v) => v.type);
|
|
821
|
-
const EVENT_INT = chart.events
|
|
822
|
-
.filter((v) => v.version.region == "INT" &&
|
|
823
|
-
util_1.Util.Chunithm.getNumberVersion(v.version) >=
|
|
824
|
-
Chart.INT_LATEST)
|
|
825
|
-
.map((v) => v.type);
|
|
826
|
-
const EVENT_CHN = chart.events
|
|
827
|
-
.filter((v) => v.version.region == "CHN" &&
|
|
828
|
-
util_1.Util.Chunithm.getNumberVersion(v.version) >=
|
|
829
|
-
Chart.CHN_LATEST)
|
|
830
|
-
.map((v) => v.type);
|
|
831
|
-
const EXIST_JPN = EVENT_JPN.includes("existence") &&
|
|
832
|
-
!EVENT_JPN.includes("removal")
|
|
833
|
-
? "🇯🇵"
|
|
834
|
-
: "";
|
|
835
|
-
const EXIST_INT = EVENT_INT.includes("existence") &&
|
|
836
|
-
!EVENT_INT.includes("removal")
|
|
837
|
-
? "🌏"
|
|
838
|
-
: "";
|
|
839
|
-
const EXIST_CHN = EVENT_CHN.includes("existence") &&
|
|
840
|
-
!EVENT_CHN.includes("removal")
|
|
841
|
-
? "🇨🇳"
|
|
842
|
-
: "";
|
|
843
|
-
const title = [];
|
|
844
|
-
if (EXIST_JPN)
|
|
845
|
-
title.push(EXIST_JPN);
|
|
846
|
-
if (EXIST_INT)
|
|
847
|
-
title.push(EXIST_INT);
|
|
848
|
-
if (EXIST_CHN)
|
|
849
|
-
title.push(EXIST_CHN);
|
|
850
|
-
await util_1.Util.drawEmojiOrGlyph(ctx, title.join(" "), element.x + element.width - textMargin, element.y +
|
|
851
|
-
jacketMargin +
|
|
852
|
-
textMargin * (1 / 2) +
|
|
853
|
-
(element.width - jacketMargin * 2) +
|
|
854
|
-
textSizeTitle * 3, textSizeSecondary * (9 / 8), element.width - textMargin * 2, "right", "white", textColor);
|
|
855
|
-
}
|
|
856
|
-
/* End Detail Draw */
|
|
857
|
-
}
|
|
858
|
-
static async drawChartGridModule(ctx, theme, element, chartId, scores, region = "JPN") {
|
|
859
|
-
/* Begin Background Draw */
|
|
860
|
-
ctx.roundRect(element.x, element.y, element.width, element.height, Math.min(theme.manifest.width, theme.manifest.height) * (3 / 128));
|
|
861
|
-
ctx.fillStyle = element.color.card;
|
|
862
|
-
ctx.strokeStyle = new color_1.default(element.color.card).darken(0.6).hex();
|
|
863
|
-
ctx.lineWidth =
|
|
864
|
-
Math.min(theme.manifest.width, theme.manifest.height) * (3 / 512);
|
|
865
|
-
ctx.stroke();
|
|
866
|
-
ctx.fill();
|
|
867
|
-
/* End Background Draw */
|
|
868
|
-
const difficulties = [];
|
|
869
|
-
for (let i = type_1.EDifficulty.BASIC; i <= type_1.EDifficulty.ULTIMA; ++i) {
|
|
870
|
-
const chart = Chart.Database.getLocalChart(chartId, i);
|
|
871
|
-
if (chart)
|
|
872
|
-
difficulties.push(chart);
|
|
873
|
-
}
|
|
874
|
-
const cardWidth = element.width - element.margin * 2;
|
|
875
|
-
const cardHeight = (element.height - element.margin * 2 - element.gap * 3) / 4;
|
|
876
|
-
for (let y = element.y + element.margin, i = 0; i < difficulties.length; ++i, y += cardHeight + element.gap) {
|
|
877
|
-
const chart = difficulties[i];
|
|
878
|
-
if (chart)
|
|
879
|
-
if (difficulties.length > 4 && i == 0) {
|
|
880
|
-
await this.drawChartGridCard(ctx, theme, element, chart, i, element.x + element.margin, y, (cardWidth - element.margin) / 2, cardHeight, true, region, scores[i]);
|
|
881
|
-
i++;
|
|
882
|
-
const chartA = difficulties[i];
|
|
883
|
-
if (chartA)
|
|
884
|
-
await this.drawChartGridCard(ctx, theme, element, chartA, i, element.x +
|
|
885
|
-
element.margin +
|
|
886
|
-
(cardWidth + element.margin) / 2, y, (cardWidth - element.margin) / 2, cardHeight, true, region, scores[i]);
|
|
887
|
-
}
|
|
888
|
-
else {
|
|
889
|
-
await this.drawChartGridCard(ctx, theme, element, chart, i, element.x + element.margin, y, cardWidth, cardHeight, false, region, scores[i]);
|
|
890
|
-
}
|
|
891
|
-
}
|
|
892
|
-
}
|
|
893
|
-
static async drawProfileModule(ctx, theme, element, username, rating, profilePicture) {
|
|
894
|
-
const nameplate = new canvas_1.Image();
|
|
895
|
-
nameplate.src = this.getThemeFile(theme.manifest.sprites.profile.nameplate, theme.path);
|
|
896
|
-
ctx.drawImage(nameplate, element.x, element.y, element.height * 2.526, element.height);
|
|
897
|
-
/* Begin Profile Picture Draw */
|
|
898
|
-
{
|
|
899
|
-
ctx.save();
|
|
900
|
-
ctx.beginPath();
|
|
901
|
-
ctx.roundRect(element.x + element.height * 2.0, element.y + element.height * 0.3, element.height * 0.45, element.height * 0.45, 0);
|
|
902
|
-
ctx.clip();
|
|
903
|
-
ctx.fillStyle = "white";
|
|
904
|
-
ctx.fill();
|
|
905
|
-
const icon = new canvas_1.Image();
|
|
906
|
-
try {
|
|
907
|
-
(0, sharp_1.default)(profilePicture);
|
|
908
|
-
}
|
|
909
|
-
catch {
|
|
910
|
-
// Unknown profile picture binary
|
|
911
|
-
profilePicture = undefined;
|
|
912
|
-
}
|
|
913
|
-
const pfp = profilePicture ||
|
|
914
|
-
this.getThemeFile(theme.manifest.sprites.profile.icon, theme.path);
|
|
915
|
-
const { dominant } = await (0, sharp_1.default)(pfp).stats();
|
|
916
|
-
icon.src = await (0, sharp_1.default)(pfp).png().toBuffer();
|
|
917
|
-
const cropSize = Math.min(icon.width, icon.height);
|
|
918
|
-
ctx.drawImage(icon, (icon.width - cropSize) / 2, (icon.height - cropSize) / 2, cropSize, cropSize, element.x + element.height * 2.0, element.y + element.height * 0.3, element.height * 0.45, element.height * 0.45);
|
|
919
|
-
if (profilePicture) {
|
|
920
|
-
ctx.beginPath();
|
|
921
|
-
ctx.roundRect(element.x + element.height * 2.0, element.y + element.height * 0.3, element.height * 0.45, element.height * 0.45, 0);
|
|
922
|
-
ctx.strokeStyle = color_1.default.rgb(dominant).darken(0.3).hex();
|
|
923
|
-
ctx.lineWidth = element.height / 128;
|
|
924
|
-
ctx.stroke();
|
|
925
|
-
}
|
|
926
|
-
ctx.restore();
|
|
927
|
-
}
|
|
928
|
-
/* End Profile Picture Draw */
|
|
929
|
-
/* Begin Username Draw */
|
|
930
|
-
{
|
|
931
|
-
ctx.beginPath();
|
|
932
|
-
ctx.roundRect(element.x + element.height * (21 / 32), element.y + element.height * (11 / 32), element.height * (85 / 64), element.height * (13 / 32), 0);
|
|
933
|
-
ctx.fillStyle = "rgba(255, 255, 255, 0.45)";
|
|
934
|
-
ctx.fill();
|
|
935
|
-
// const ratingImgBuffer = await this.getRatingNumber(rating, theme);
|
|
936
|
-
// if (ratingImgBuffer) {
|
|
937
|
-
// const { width, height } =
|
|
938
|
-
// await sharp(ratingImgBuffer).metadata();
|
|
939
|
-
// if (width && height) {
|
|
940
|
-
// const aspectRatio = width / height;
|
|
941
|
-
// const image = new Image();
|
|
942
|
-
// image.src = ratingImgBuffer;
|
|
943
|
-
// const drawHeight = (element.height * 7) / 32;
|
|
944
|
-
// ctx.drawImage(
|
|
945
|
-
// image,
|
|
946
|
-
// element.x + element.height * 2.0,
|
|
947
|
-
// element.y + element.height * 0.3,
|
|
948
|
-
// drawHeight * aspectRatio * 0.8,
|
|
949
|
-
// drawHeight
|
|
950
|
-
// );
|
|
951
|
-
// }
|
|
952
|
-
// }
|
|
953
|
-
util_1.Util.drawText(ctx, "Lv.", element.x + element.height * (43 / 64), element.y + element.height * (0.3 + 1 / 4), (element.height * 1) / 16, 0, ((element.height / 3) * 5.108 * 3.1) / 5, "left", "black", "black", "standard-font-username");
|
|
954
|
-
util_1.Util.drawText(ctx, "99", element.x + element.height * (49 / 64), element.y + element.height * (0.3 + 1 / 4), (element.height * 1) / 11, 0, ((element.height / 3) * 5.108 * 3.1) / 5, "left", "black", "black", "standard-font-username");
|
|
955
|
-
util_1.Util.drawText(ctx, util_1.Util.HalfFullWidthConvert.toFullWidth(username), element.x + element.height * (56 / 64), element.y + element.height * (0.3 + 1 / 4), (element.height * 1) / 8, 0, element.height * (65 / 64), "left", "black", "black", "standard-font-username");
|
|
956
|
-
util_1.Util.drawText(ctx, "RATING", element.x + element.height * (43 / 64), element.y + element.height * (47 / 64), (element.height * 7) / 88, 0, ((element.height / 3) * 5.108 * 3.1) / 5, "left", "black", "black", "standard-font-username");
|
|
957
|
-
util_1.Util.drawText(ctx, util_1.Util.truncate(rating, 2), element.x + element.height * (67 / 64), element.y + element.height * (47 / 64), (element.height * 5) / 44, 0, ((element.height / 3) * 5.108 * 3.1) / 5, "left", "black", "black", "standard-font-username");
|
|
958
|
-
}
|
|
959
|
-
/* End Username Draw*/
|
|
960
|
-
}
|
|
961
|
-
static async drawTextModule(ctx, theme, element, variables = {}) {
|
|
962
|
-
let naiveLines = (0, string_template_1.default)(element.content, variables).split("\n");
|
|
963
|
-
let lines = [];
|
|
964
|
-
if (element.linebreak) {
|
|
965
|
-
for (let originalContent of naiveLines) {
|
|
966
|
-
while (originalContent.length) {
|
|
967
|
-
const line = util_1.Util.findMaxFitString(ctx, originalContent, element.width || Infinity, "");
|
|
968
|
-
originalContent = originalContent.replace(line, "").trim();
|
|
969
|
-
lines.push(line.trim());
|
|
970
|
-
}
|
|
971
|
-
}
|
|
972
|
-
}
|
|
973
|
-
else {
|
|
974
|
-
for (const originalContent of naiveLines) {
|
|
975
|
-
lines.push(util_1.Util.findMaxFitString(ctx, originalContent, element.width || Infinity));
|
|
976
|
-
}
|
|
977
|
-
}
|
|
978
|
-
for (let i = 0; i < lines.length; ++i) {
|
|
979
|
-
const line = lines[i];
|
|
980
|
-
util_1.Util.drawText(ctx, line, element.x, element.y + i * element.size * 1.3, element.size, element.size / 3.5, element.width || Infinity, element.align, element.color || "#FFFFFF", element.borderColor
|
|
981
|
-
? element.borderColor
|
|
982
|
-
: color_1.default.rgb(element.color || "#FFFFFF")
|
|
983
|
-
.darken(0.3)
|
|
984
|
-
.hex(), element.font, element.linebreak ? "" : "...");
|
|
985
|
-
}
|
|
986
|
-
}
|
|
987
|
-
/* End Draw Tools*/
|
|
988
|
-
static async draw(name, rating, chartId, scores, type = "recents", options = {}) {
|
|
989
|
-
let currentTheme = this.primaryTheme;
|
|
990
|
-
if (options?.theme) {
|
|
991
|
-
const theme = this.getTheme(options.theme);
|
|
992
|
-
if (theme) {
|
|
993
|
-
currentTheme = theme;
|
|
994
|
-
}
|
|
995
|
-
}
|
|
996
|
-
const chart = Chart.Database.getLocalChart(chartId, type_1.EDifficulty.BASIC);
|
|
997
|
-
if (!chart)
|
|
998
|
-
return null;
|
|
999
|
-
if (currentTheme) {
|
|
1000
|
-
await Chart.Database.cacheJackets([chartId]);
|
|
1001
|
-
const canvas = new canvas_1.Canvas(currentTheme.manifest.width * (options?.scale ?? 1), currentTheme.manifest.height * (options?.scale ?? 1));
|
|
1002
|
-
const ctx = canvas.getContext("2d");
|
|
1003
|
-
if (options?.scale)
|
|
1004
|
-
ctx.scale(options.scale, options.scale);
|
|
1005
|
-
ctx.imageSmoothingEnabled = true;
|
|
1006
|
-
for (const element of currentTheme.manifest.elements) {
|
|
1007
|
-
switch (element.type) {
|
|
1008
|
-
case "image": {
|
|
1009
|
-
await this.drawImageModule(ctx, currentTheme, element);
|
|
1010
|
-
break;
|
|
1011
|
-
}
|
|
1012
|
-
case "chart-grid": {
|
|
1013
|
-
await this.drawChartGridModule(ctx, currentTheme, element, chartId, scores, options?.region);
|
|
1014
|
-
break;
|
|
1015
|
-
}
|
|
1016
|
-
case "detail-info": {
|
|
1017
|
-
await this.drawDetailInfoModule(ctx, currentTheme, element, chartId);
|
|
1018
|
-
break;
|
|
1019
|
-
}
|
|
1020
|
-
case "profile": {
|
|
1021
|
-
await this.drawProfileModule(ctx, currentTheme, element, name, rating, options?.profilePicture);
|
|
1022
|
-
break;
|
|
1023
|
-
}
|
|
1024
|
-
case "text": {
|
|
1025
|
-
await this.drawTextModule(ctx, currentTheme, element, {
|
|
1026
|
-
username: util_1.Util.HalfFullWidthConvert.toFullWidth(name),
|
|
1027
|
-
rating: util_1.Util.truncate(rating, 0),
|
|
1028
|
-
});
|
|
1029
|
-
break;
|
|
1030
|
-
}
|
|
1031
|
-
}
|
|
1032
|
-
}
|
|
1033
|
-
return canvas.toBuffer();
|
|
1034
|
-
}
|
|
1035
|
-
else
|
|
1036
|
-
return null;
|
|
1037
|
-
}
|
|
1038
|
-
static async drawWithScoreSource(source, username, chartId, type = "recents", options = {}) {
|
|
1039
|
-
const profile = await source.getPlayerInfo(username, type);
|
|
1040
|
-
const score = await source.getPlayerScore(username, chartId);
|
|
1041
|
-
if (!profile || !score)
|
|
1042
|
-
return null;
|
|
1043
|
-
return this.draw(profile.name, profile.rating, chartId, [
|
|
1044
|
-
score.basic,
|
|
1045
|
-
score.advanced,
|
|
1046
|
-
score.expert,
|
|
1047
|
-
score.master,
|
|
1048
|
-
score.ultima,
|
|
1049
|
-
score.worldsEnd,
|
|
1050
|
-
], type, {
|
|
1051
|
-
...options,
|
|
1052
|
-
profilePicture: options?.profilePicture === null
|
|
1053
|
-
? undefined
|
|
1054
|
-
: options?.profilePicture ||
|
|
1055
|
-
(await source.getPlayerProfilePicture(username)) ||
|
|
1056
|
-
undefined,
|
|
1057
|
-
});
|
|
1058
|
-
}
|
|
1059
|
-
}
|
|
1060
|
-
exports.Chart = Chart;
|
|
1061
|
-
(function (Chart) {
|
|
1062
|
-
Chart.Database = database.Database;
|
|
1063
|
-
})(Chart || (exports.Chart = Chart = {}));
|
|
1064
|
-
//# sourceMappingURL=index.js.map
|