Procházet zdrojové kódy

Upload files to ''

master
rodič
revize
91beba35b0
  1. 21
      LICENSE
  2. 506
      j2d.js
  3. 19
      run.bat

21
LICENSE

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 DevDiego
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

506
j2d.js

@ -0,0 +1,506 @@
const fs = require('fs');
if (fs.existsSync("./input.json") && fs.existsSync("./inputmoves.json")) {
console.log("[INFO] jsonInput.json and inputmoves.json found.")
} else {
return console.log("[ERROR] One or both inputs was/were not found. Please make sure you have both inputs where this file is located with the names of 'input' and 'inputmoves'.")
}
let input = require('./input.json');
console.log('[INFO] input.json loaded.')
let movesInp = require('./inputmoves.json')
console.log('[INFO] inputmoves.json loaded.')
let movesObj = JSON.stringify(movesInp);
let movesPar = JSON.parse(movesObj);
var jsonObj = JSON.stringify(input);
var jsonPar = JSON.parse(jsonObj);
let newMapName = process.argv[2];
//Variables
const {
lyrics,
pictos,
beats,
MapName,
AudioPreview,
Title,
Artist
} = jsonPar;
// division calculator
let divisionInput = Math.floor(2502.66305525460462 / (60000 / (beats[3] - beats[2])))
//dTape ogTape
let dtape = {
"__class": "Tape",
"Clips": [],
"TapeClock": 0,
"TapeBarCount": 1,
"FreeResourcesAfterPlay": 0,
"MapName": newMapName,
"SoundwichEvent": ""
};
//kTape ogTape
let ktape = {
"__class": "Tape",
"Clips": [],
"TapeClock": 0,
"FreeResourcesAfterPlay": 0,
"MapName": newMapName,
"SoundwichEvent": ""
};
//Musictrack ogTape
let musictrack = {
"__class": "Actor_Template",
"WIP": 0,
"LOWUPDATE": 0,
"UPDATE_LAYER": 0,
"PROCEDURAL": 0,
"STARTPAUSED": 0,
"FORCEISENVIRONMENT": 0,
"COMPONENTS": [{
"__class": "MusicTrackComponent_Template",
"trackData": {
"__class": "MusicTrackData",
"structure": {
"__class": "MusicTrackStructure",
"markers": [],
"signatures": [{
"__class": "MusicSignature",
"marker": 1,
"beats": 3
}, {
"__class": "MusicSignature",
"marker": 4,
"beats": 4
}, {
"__class": "MusicSignature",
"marker": 21.24,
"beats": 3
}, {
"__class": "MusicSignature",
"marker": 21.27,
"beats": 4
}],
"sections": [{
"__class": "MusicSection",
"marker": 1,
"sectionType": 6,
"comment": ""
}, {
"__class": "MusicSection",
"marker": 21.2,
"sectionType": 1,
"comment": ""
}, {
"__class": "MusicSection",
"marker": 52,
"sectionType": 7,
"comment": ""
}, {
"__class": "MusicSection",
"marker": 68,
"sectionType": 3,
"comment": ""
}, {
"__class": "MusicSection",
"marker": 84,
"sectionType": 7,
"comment": ""
}, {
"__class": "MusicSection",
"marker": 100,
"sectionType": 1,
"comment": ""
}, {
"__class": "MusicSection",
"marker": 132,
"sectionType": 7,
"comment": ""
}, {
"__class": "MusicSection",
"marker": 148,
"sectionType": 3,
"comment": ""
}, {
"__class": "MusicSection",
"marker": 164,
"sectionType": 7,
"comment": ""
}, {
"__class": "MusicSection",
"marker": 21.20,
"sectionType": 3,
"comment": ""
}, {
"__class": "MusicSection",
"marker": 196,
"sectionType": 2,
"comment": ""
}, {
"__class": "MusicSection",
"marker": 21.24,
"sectionType": 6,
"comment": ""
}, {
"__class": "MusicSection",
"marker": 259,
"sectionType": 3,
"comment": ""
}, {
"__class": "MusicSection",
"marker": 275,
"sectionType": 7,
"comment": ""
}, {
"__class": "MusicSection",
"marker": 291,
"sectionType": 7,
"comment": ""
}],
"startBeat": 0,
"endBeat": beats.length,
"videoStartTime": 0,
"previewEntry": AudioPreview.coverflow.startbeat,
"previewLoopStart": AudioPreview.coverflow.startbeat,
"previewLoopEnd": 196,
"volume": 0
},
"path": "world/maps/" + newMapName.toLowerCase() + "/audio/" + newMapName.toLowerCase() + ".wav",
"url": "jmcs://jd-contents/" + newMapName + "/" + newMapName + ".ogg"
}
}]
}
//dTape creator --Start
for (i = 0; i < pictos.length; i++) {
var pictoDuration = pictos[i].duration;
var pictoTime = pictos[i].time;
var newPictoDuration = Math.floor(pictoDuration / divisionInput);
var newPictoTime = Math.floor(pictoTime / divisionInput);
var pictoPath = `world/maps/${MapName.toLowerCase()}/timeline/pictos/${pictos[i].name}.png`;
dtape.Clips.push({
"__class": "PictogramClip",
"Id": i,
"TrackId": 0,
"IsActive": 1,
"StartTime": newPictoTime,
"Duration": newPictoDuration,
"PictoPath": pictoPath,
"MontagePath": "",
"AtlIndex": 4294967295,
"CoachCount": 4294967295
})
}
for (i = 0; i < movesPar.length; i++) {
var newMoveDuration = Math.floor(movesPar[i].duration / divisionInput);
var MoveDurationRound = Math.round(newMoveDuration);
var newMoveTime = Math.floor(movesPar[i].time / divisionInput);
var MoveTimeRound = Math.round(newMoveTime);
let goldEffectId = pictos.length + movesPar.length + movesPar.length;
let goldenmovetime = Math.floor(movesPar[i].duration + movesPar[i].time);
let goldenmovediv = Math.floor(goldenmovetime / divisionInput);
let goldenmoveround = Math.round(goldenmovediv);
let goldenmove = movesPar[i].goldMove || movesPar[i].GoldMove;
let ClassifierPath = `world/maps/${MapName.toLowerCase()}/timeline/moves/${movesPar[i].name}.msm`;
let id = i + pictos.length;
dtape.Clips.push({
"__class": "MotionClip",
"Id": id,
"TrackId": 0,
"IsActive": 1,
"StartTime": MoveTimeRound,
"Duration": MoveDurationRound,
"ClassifierPath": ClassifierPath,
"GoldMove": goldenmove,
"CoachId": 0,
"MoveType": 0,
"Color": [1, 0.988235, 0.670588, 0.870588],
"MotionPlatformSpecifics": {
"X360": {
"__class": "MotionPlatformSpecific",
"ScoreScale": 1,
"ScoreSmoothing": 0,
"ScoringMode": 0
},
"ORBIS": {
"__class": "MotionPlatformSpecific",
"ScoreScale": 1,
"ScoreSmoothing": 0,
"ScoringMode": 0
},
"DURANGO": {
"__class": "MotionPlatformSpecific",
"ScoreScale": 1,
"ScoreSmoothing": 0,
"ScoringMode": 0
}
}
})
if (goldenmove === 1) {
dtape.Clips.push({
"__class": "GoldEffectClip",
"Id": goldEffectId++,
"TrackId": 0,
"IsActive": 1,
"StartTime": goldenmoveround,
"Duration": MoveDurationRound,
"EffectType": 1
});
}
}
if (fs.existsSync("./inputmoves1.json")) {
let moves1 = require("./inputmoves1.json");
console.log("[INFO] Song has a second coach, inputmoves1 found and loaded.");
let moves1Obj = JSON.stringify(moves1);
let moves1Par = JSON.parse(moves1Obj);
for (i = 0; i < moves1Par.length; i++) {
var newMove1Duration = Math.floor(moves1Par[i].duration / divisionInput);
var Move1DurationRound = Math.round(newMove1Duration);
var newMove1Time = Math.floor(moves1Par[i].time / divisionInput);
var Move1TimeRound = Math.round(newMove1Time);
var goldEffectId1 = pictos.length + movesPar.length + moves1Par.length;
let goldenmove1time = Math.floor(moves1Par[i].duration + moves1Par[i].time);
let goldenmove1div = Math.floor(goldenmove1time / divisionInput);
let goldenmove1round = Math.round(goldenmove1div);
let goldenmove1 = moves1Par[i].goldMove || moves1Par[i].GoldMove;
let ClassifierPath1 = `world/maps/${MapName.toLowerCase()}/timeline/moves/${moves1Par[i].name}.msm`;
let id1 = i + pictos.length + movesPar.length;
dtape.Clips.push({
"__class": "MotionClip",
"Id": id1,
"TrackId": 0,
"IsActive": 1,
"StartTime": Move1TimeRound,
"Duration": Move1DurationRound,
"ClassifierPath": ClassifierPath1,
"GoldMove": goldenmove1,
"CoachId": 1,
"MoveType": 0,
"Color": [1, 0.988235, 0.670588, 0.870588],
"MotionPlatformSpecifics": {
"X360": {
"__class": "MotionPlatformSpecific",
"ScoreScale": 1,
"ScoreSmoothing": 0,
"ScoringMode": 0
},
"ORBIS": {
"__class": "MotionPlatformSpecific",
"ScoreScale": 1,
"ScoreSmoothing": 0,
"ScoringMode": 0
},
"DURANGO": {
"__class": "MotionPlatformSpecific",
"ScoreScale": 1,
"ScoreSmoothing": 0,
"ScoringMode": 0
}
}
})
if (goldenmove1 === 1) {
dtape.Clips.push({
"__class": "GoldEffectClip",
"Id": goldEffectId1++,
"TrackId": 0,
"IsActive": 1,
"StartTime": goldenmove1round,
"Duration": Move1DurationRound,
"EffectType": 1
});
}
}
} else {
console.log("[INFO] Song doesn't have a second coach")
}
if (fs.existsSync("./inputmoves2.json")) {
let moves1 = require("./inputmoves1.json");
let moves2 = require("./inputmoves2.json");
console.log("[INFO] Song has a third coach, inputmoves2 found and loaded.");
let moves1Obj = JSON.stringify(moves1);
let moves1Par = JSON.parse(moves1Obj);
let moves2Obj = JSON.stringify(moves2);
let moves2Par = JSON.parse(moves2Obj);
for (i = 0; i < moves2Par.length; i++) {
var newMove2Duration = Math.floor(moves2Par[i].duration / divisionInput);
var Move2DurationRound = Math.round(newMove2Duration);
var newMove2Time = Math.floor(moves2Par[i].time / divisionInput);
var Move2TimeRound = Math.round(newMove2Time);
var goldEffectId2 = pictos.length + movesPar.length + moves1Par.length + moves2Par.length;
let goldenmove2time = Math.floor(moves2Par[i].duration + moves2Par[i].time);
let goldenmove2div = Math.floor(goldenmove2time / divisionInput);
let goldenmove2round = Math.round(goldenmove2div);
let goldenmove2 = moves2Par[i].goldMove || moves2Par[i].GoldMove;
let ClassifierPath2 = `world/maps/${MapName.toLowerCase()}/timeline/moves/${moves2Par[i].name}.msm`;
let id2 = i + pictos.length + movesPar.length + moves1Par.length;
dtape.Clips.push({
"__class": "MotionClip",
"Id": id2,
"TrackId": 0,
"IsActive": 1,
"StartTime": Move2TimeRound,
"Duration": Move2DurationRound,
"ClassifierPath": ClassifierPath2,
"GoldMove": goldenmove2,
"CoachId": 2,
"MoveType": 0,
"Color": [1, 0.988235, 0.670588, 0.870588],
"MotionPlatformSpecifics": {
"X360": {
"__class": "MotionPlatformSpecific",
"ScoreScale": 1,
"ScoreSmoothing": 0,
"ScoringMode": 0
},
"ORBIS": {
"__class": "MotionPlatformSpecific",
"ScoreScale": 1,
"ScoreSmoothing": 0,
"ScoringMode": 0
},
"DURANGO": {
"__class": "MotionPlatformSpecific",
"ScoreScale": 1,
"ScoreSmoothing": 0,
"ScoringMode": 0
}
}
})
if (goldenmove2 === 1) {
dtape.Clips.push({
"__class": "GoldEffectClip",
"Id": goldEffectId2++,
"TrackId": 0,
"IsActive": 1,
"StartTime": Move2TimeRound,
"Duration": Move2DurationRound,
"EffectType": 1
});
}
}
} else {
console.log("[INFO] Song doesn't have a third coach")
}
if (fs.existsSync("./inputmoves3.json")) {
let moves1 = require("./inputmoves1.json");
let moves2 = require("./inputmoves2.json");
let moves3 = require("./inputmoves3.json");
console.log("[INFO] Song has a fourth coach, inputmoves3 found and loaded.");
let moves1Obj = JSON.stringify(moves1);
let moves1Par = JSON.parse(moves1Obj);
let moves2Obj = JSON.stringify(moves2);
let moves2Par = JSON.parse(moves2Obj);
let moves3Obj = JSON.stringify(moves3);
let moves3Par = JSON.parse(moves3Obj);
for (i = 0; i < moves3Par.length; i++) {
var newMove3Duration = Math.floor(moves3Par[i].duration / divisionInput);
var Move3DurationRound = Math.round(newMove3Duration);
var newMove3Time = Math.floor(moves3Par[i].time / divisionInput);
var Move3TimeRound = Math.round(newMove3Time);
var goldEffectId3 = pictos.length + moves3Par.length;
let goldenmove3time = Math.floor(moves3Par[i].duration + moves3Par[i].time);
let goldenmove3div = Math.floor(goldenmove3time / divisionInput);
let goldenmove3round = Math.round(goldenmove3div);
let goldenmove3 = moves3Par[i].goldMove || moves3Par[i].GoldMove;
let ClassifierPath3 = `world/maps/${MapName.toLowerCase()}/timeline/moves/${moves3Par[i].name}.msm`;
let id3 = i + pictos.length + movesPar.length + moves1Par.length + moves2Par.length;
dtape.Clips.push({
"__class": "MotionClip",
"Id": id3,
"TrackId": 0,
"IsActive": 1,
"StartTime": Move3TimeRound,
"Duration": Move3DurationRound,
"ClassifierPath": ClassifierPath3,
"GoldMove": goldenmove3,
"CoachId": 3,
"MoveType": 0,
"Color": [1, 0.988235, 0.670588, 0.870588],
"MotionPlatformSpecifics": {
"X360": {
"__class": "MotionPlatformSpecific",
"ScoreScale": 1,
"ScoreSmoothing": 0,
"ScoringMode": 0
},
"ORBIS": {
"__class": "MotionPlatformSpecific",
"ScoreScale": 1,
"ScoreSmoothing": 0,
"ScoringMode": 0
},
"DURANGO": {
"__class": "MotionPlatformSpecific",
"ScoreScale": 1,
"ScoreSmoothing": 0,
"ScoringMode": 0
}
}
})
if (goldenmove3 === 1) {
dtape.Clips.push({
"__class": "GoldEffectClip",
"Id": goldEffectId3++,
"TrackId": 0,
"IsActive": 1,
"StartTime": Move3TimeRound,
"Duration": Move3DurationRound,
"EffectType": 1
});
}
}
} else {
console.log("[INFO] Song doesn't have a fourth coach")
}
fs.writeFile(newMapName.toLowerCase() + "_tml_dance.dtape.ckd", JSON.stringify(dtape), function(err) {
if (err) {
console.log(err);
}
});
console.log("[INFO] dTape created.")
//dTape creator --End
//musictrack creator --Start
let musictrackBeats = beats.map(function(x) {
return Math.floor(x * 48)
});
musictrack.COMPONENTS[0].trackData.structure.markers = (musictrackBeats);
fs.writeFile(newMapName.toLowerCase() + "_musictrack.tpl.ckd", JSON.stringify(musictrack), function(err) {
if (err) {
console.log(err);
}
});
console.log("[INFO] musictrack created.")
//musictrack creator --End
//kTape creator --Start
for (i = 0; i < lyrics.length; i++) {
var lyricsDuration = lyrics[i].duration;
var lyricsTime = lyrics[i].time;
var newLyricsDuration = Math.floor(lyricsDuration / divisionInput);
var newLyricsTime = Math.floor(lyricsTime / divisionInput);
ktape.Clips.push({
"__class": "KaraokeClip",
"Id": i,
"TrackId": 0,
"IsActive": 1,
"StartTime": newLyricsTime,
"Duration": newLyricsDuration,
"Pitch": 8.661958,
"Lyrics": lyrics[i].text,
"IsEndOfLine": lyrics[i].isLineEnding,
"ContentType": 0,
"StartTimeTolerance": 4,
"EndTimeTolerance": 4,
"SemitoneTolerance": 5
})
}
fs.writeFile(newMapName.toLowerCase() + "_tml_karaoke.ktape.ckd", JSON.stringify(ktape), function(err) {
if (err) {
console.log(err);
}
});
console.log("[INFO] kTape created.")
//kTape creator --End
console.log("[INFO] Finished:")
console.log("Title: " + Title);
console.log("Artist: " + Artist);

19
run.bat

@ -0,0 +1,19 @@
@shift /0
@echo off
title JSON2DTAPE [v.0.1] by DevDiego
color 00
:mainmenu
cd ./
cls
echo Welcome to JSON2DTAPE [v.0.1] by DevDiego
echo.
echo Make sure you have all the files you need for the song in the same folder the js is located on.
echo (input.json and inputmoves.json / optional: inputmoves1.json, inputmoves2.json, inputmoves3.json).
echo If you don't have input.json and inputmoves.json the code will return an error.
echo.
echo Input the codename you're modding the new song on. (if left empty an error will popup)
set /p codename=">"
echo.
node j2d %codename%
timeout /t 10
goto :mainmenu
Načítá se…
Zrušit
Uložit