UNPKG

@osbjs/osbjs

Version:

a minimalist osu! storyboarding framework

31 lines (30 loc) 1.77 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DiffSpecificStoryboard = void 0; const chalk_1 = require("chalk"); const fs_1 = require("fs"); const Storyboard_1 = require("./Storyboard"); const path_1 = require("path"); class DiffSpecificStoryboard extends Storyboard_1.Storyboard { constructor(filename, path) { super(filename, path); } getOsbString() { const { bg, fg, f, p, s, ov } = this._extractEachLayerOsbString(); let str = `//Storyboard Layer 0 (Background)\n${bg}//Storyboard Layer 1 (Fail)\n${f}//Storyboard Layer 2 (Pass)\n${p}//Storyboard Layer 3 (Foreground)\n${fg}//Storyboard Layer 4 (Overlay)\n${ov}//Storyboard Sound Samples\n${s}`; return str; } /** * Generate storyboard. Call this after every component is registered. */ generate() { if (!(0, fs_1.existsSync)(this.path) || !(0, fs_1.existsSync)((0, path_1.join)(this.path, this.filename))) throw new Error("Beatmap doesn't exists"); let beatmap = (0, fs_1.readFileSync)((0, path_1.join)(this.path, this.filename), 'utf-8'); let pattern = /\/\/Storyboard Layer 0 \(Background\)\n(.*\n*)\/\/Storyboard Layer 1 \(Fail\)\n(.*\n*)\/\/Storyboard Layer 2 \(Pass\)\n(.*\n*)\/\/Storyboard Layer 3 \(Foreground\)\n(.*\n*)\/\/Storyboard Layer 4 \(Overlay\)\n(.*\n*)\/\/Storyboard Sound Samples\n(.*\n*)/g; beatmap = beatmap.replace(pattern, this.getOsbString()); (0, fs_1.writeFileSync)((0, path_1.join)(this.path, this.filename), beatmap); console.log((0, chalk_1.green) `Storyboard generated in ${(0, path_1.join)(this.path, this.filename)}`); } } exports.DiffSpecificStoryboard = DiffSpecificStoryboard;