Skip to content

Commit

Permalink
曲専用に曲時間に合わせたシーンチェンジをできるようにした
Browse files Browse the repository at this point in the history
  • Loading branch information
rynan4818 committed May 19, 2022
1 parent 6da9d07 commit 2fb11db
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 8 deletions.
81 changes: 73 additions & 8 deletions js/obs-control.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ let obs_end_event = '';
let obs;
let obs_timeout_id;
let obs_full_combo = true;
let song_scene_list = false;
let song_scene = false;
let song_scene_next_time = false;
let song_scene_next_name = "";
let song_scene_start_change = true;
let song_scene_end_change = true;
const obs_not_rec_audio = new Audio(obs_not_rec_sound);

function obs_connect() {
Expand Down Expand Up @@ -90,17 +96,74 @@ function obs_start_scene_change() {
}
}

if (typeof song_scene_json !== "undefined"){
song_scene_list = JSON.parse(song_scene_json);
}

function song_scene_check(data) {
if (song_scene_list === false) return;
for(let i = 0; i < song_scene_list.length; i++){
if (data.status.beatmap.songHash.toUpperCase() === song_scene_list[i].hash.toUpperCase()){
song_scene = song_scene_list[i].timelist;
song_scene_start_change = song_scene_list[i].startchange;
song_scene_end_change = song_scene_list[i].endchange;
song_scene_next();
return;
}
}
song_scene_start_change = true;
song_scene_end_change = true;
}

function time_msce_cnv(str) {
let sec = 0;
let msec = 0;
let min = str.split(':', 2)
if (typeof min[1] !== 'undefined') {
sec = min[1].split('.', 2)
if (typeof sec[1] !== 'undefined') {
msec = parseInt(sec[1], 10);
}
sec = parseInt(sec[0], 10) * 1000;
}
min = parseInt(min[0], 10) * 60 * 1000;
return min + sec + msec;
}

function song_scene_next(){
let next_scene = song_scene.shift();
if (typeof next_scene === "undefined"){
song_scene_next_time = false;
song_scene_next_name = "";
} else {
song_scene_next_time = time_msce_cnv(next_scene.time);
song_scene_next_name = next_scene.scene;
}
}

ex_timer_update.push((time, delta, progress, percentage) => {
if (song_scene === false) return;
if (song_scene_next_time === false) return;
if (delta >= song_scene_next_time){
obs_scene_change(song_scene_next_name);
song_scene_next();
}
});

ex_songStart.push((data) => {
obs_end_event = '';
obs_full_combo = true;
if (obs_bs_menu_flag) {
clearTimeout(obs_timeout_id);
obs_bs_menu_flag = false;
obs_rec_check();
if (obs_game_event_delay > 0) {
obs_timeout_id = setTimeout(obs_start_scene_change, obs_game_event_delay);
} else {
obs_start_scene_change();
song_scene_check(data);
if (song_scene_start_change) {
if (obs_game_event_delay > 0) {
obs_timeout_id = setTimeout(obs_start_scene_change, obs_game_event_delay);
} else {
obs_start_scene_change();
}
}
}
});
Expand Down Expand Up @@ -135,10 +198,12 @@ function obs_menu_event() {
if (!obs_bs_menu_flag) {
clearTimeout(obs_timeout_id);
obs_bs_menu_flag = true;
if (obs_menu_event_delay > 0) {
obs_timeout_id = setTimeout(obs_end_scene_change, obs_menu_event_delay);
} else {
obs_end_scene_change();
if (song_scene_end_change){
if (obs_menu_event_delay > 0) {
obs_timeout_id = setTimeout(obs_end_scene_change, obs_menu_event_delay);
} else {
obs_end_scene_change();
}
}
}
}
Expand Down
34 changes: 34 additions & 0 deletions js/song-scene.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const song_scene_json = `
[
{
"hash": "6D1FA74C517A03EA76170345789C85F9077DC7A4",
"startchange": false,
"endchange": false,
"timelist": [
{
"time": "0:00",
"scene": "TEST1"
},
{
"time": "0:10.550",
"scene": "TEST2"
}
]
},
{
"hash": "02D18079CE5C7D0179DADD9D77A3D8C729D8C1D8",
"startchange": false,
"endchange": true,
"timelist": [
{
"time": "0:10.500",
"scene": "TEST3"
},
{
"time": "0:20",
"scene": "TEST1"
}
]
}
]
`;

0 comments on commit 2fb11db

Please sign in to comment.