mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-13 01:07:38 +02:00
Integration of Jukebox Library (#451)
* add Jukebox library todo: - saving / loading of new format - inferrence of unknown data like past versions - move the temporary float casts to proper use of double - make sound related functions take double for timing - inform people that the Jukebox sound player was renamed to SoundByte lol * make sound, input scheduling, and super curve use double precision * successfully load charts * editor works again v1 riqs can be saved and loaded * first tempo and volume markers are unmovable fix loading of charts' easing values * use gsync / freesync * update Jukebox refs to SoundByte * game events use double part 1 Air Rally - Glee Club converted * don't load song if chart load fails * finish conversion of all minigames * remove editor waveform toggle * timeline now respects added song offset length clear cache files on app close prepped notes for dsp sync * update timeline length when offset changed * update to latest Jukebox * make error panel object in global game manager * improve conductor music scheduling * added error message box fix first game events sometimes not playing
This commit is contained in:
@ -9,6 +9,8 @@ using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Audio;
|
||||
|
||||
using Jukebox;
|
||||
|
||||
namespace HeavenStudio
|
||||
{
|
||||
public class GameInitializer : MonoBehaviour
|
||||
@ -34,9 +36,6 @@ namespace HeavenStudio
|
||||
public bool playOnStart = false;
|
||||
public bool fromCmd = false;
|
||||
|
||||
string json = "";
|
||||
string ext = "";
|
||||
|
||||
private void Start()
|
||||
{
|
||||
string input = "";
|
||||
@ -98,11 +97,8 @@ namespace HeavenStudio
|
||||
|
||||
if (editorGO == null)
|
||||
{
|
||||
OpenCmdRemix(input);
|
||||
Debug.Log(json);
|
||||
gameManager.txt = json;
|
||||
gameManager.ext = ext;
|
||||
gameManager.Init();
|
||||
bool success = OpenCmdRemix(input);
|
||||
gameManager.Init(success);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -110,44 +106,18 @@ namespace HeavenStudio
|
||||
}
|
||||
}
|
||||
|
||||
public void OpenCmdRemix(string path)
|
||||
public bool OpenCmdRemix(string path)
|
||||
{
|
||||
if (path == string.Empty) return;
|
||||
if (!File.Exists(path)) return;
|
||||
byte[] MusicBytes;
|
||||
bool loadedMusic = false;
|
||||
string extension = path.GetExtension();
|
||||
|
||||
using var zipFile = File.Open(path, FileMode.Open);
|
||||
using var archive = new ZipArchive(zipFile, ZipArchiveMode.Read);
|
||||
|
||||
foreach (var entry in archive.Entries)
|
||||
switch (entry.Name)
|
||||
{
|
||||
case "remix.json":
|
||||
{
|
||||
using var stream = entry.Open();
|
||||
using var reader = new StreamReader(stream);
|
||||
json = reader.ReadToEnd();
|
||||
ext = extension;
|
||||
break;
|
||||
}
|
||||
case "song.ogg":
|
||||
{
|
||||
using var stream = entry.Open();
|
||||
using var memoryStream = new MemoryStream();
|
||||
stream.CopyTo(memoryStream);
|
||||
MusicBytes = memoryStream.ToArray();
|
||||
Conductor.instance.musicSource.clip = OggVorbis.VorbisPlugin.ToAudioClip(MusicBytes, "music");
|
||||
loadedMusic = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!loadedMusic)
|
||||
try
|
||||
{
|
||||
Conductor.instance.musicSource.clip = null;
|
||||
MusicBytes = null;
|
||||
string tmpDir = RiqFileHandler.ExtractRiq(path);
|
||||
Debug.Log("Imported RIQ successfully!");
|
||||
return true;
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.Log($"Error importing RIQ: {e.Message}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user