public XPCK(String filename) { Stream input; using (BinaryReaderX xpckBr = new BinaryReaderX(File.OpenRead(filename))) { if (xpckBr.ReadString(4) == "XPCK") { xpckBr.BaseStream.Position = 0; input = new MemoryStream(xpckBr.ReadBytes((int)xpckBr.BaseStream.Length)); } else { xpckBr.BaseStream.Position = 0; byte[] decomp = CriWare.GetDecompressedBytes(xpckBr.BaseStream); input = new MemoryStream(decomp); } } using (BinaryReaderX xpckBr = new BinaryReaderX(input)) { //Header var header = xpckBr.ReadStruct <Header>(); int fileCount = header.fileInfoSize / 0xc; //fileInfo var entries = new List <Entry>(); entries.AddRange(xpckBr.ReadMultiple <Entry>(fileCount).OrderBy(e => e.fileOffset)); //nameList var nameList = new List <String>(); byte[] uncompressedNameList = CriWare.GetDecompressedBytes(new MemoryStream(xpckBr.ReadBytes(header.filenameTableSize))); using (BinaryReaderX nlBr = new BinaryReaderX(new MemoryStream(uncompressedNameList))) for (int i = 0; i < fileCount; i++) { nameList.Add(nlBr.ReadCStringA()); } for (int i = 0; i < fileCount; i++) { xpckBr.BaseStream.Position = header.dataOffset + entries[i].fileOffset; Files.Add(new XPCKFileInfo() { Entry = entries[i], FileName = nameList[i], FileData = new MemoryStream(xpckBr.ReadBytes(entries[i].fileSize)), State = ArchiveFileState.Archived }); } } }
public byte[] Identify(BinaryReaderX br) { //possible identifications: PCK, cfg.bin, XPCK-Archive //if cfg.bin br.BaseStream.Position = 0x18; uint t1 = br.ReadUInt32(); br.BaseStream.Position = 0x24; uint t2 = br.ReadUInt32(); br.BaseStream.Position = 0; if (t1 == 0x0 && t2 == 0x14) { type = 1; return(null); } //if PCK int entryCount = br.ReadInt32(); br.BaseStream.Position = 0x8; if (entryCount * 3 * 4 + 4 == br.ReadInt32()) { type = 2; return(null); } br.BaseStream.Position = 0; //if XPCK if (br.ReadString(4) == "XPCK") { type = 3; return(null); } else { br.BaseStream.Position = 0; byte[] result = CriWare.GetDecompressedBytes(new MemoryStream(br.ReadBytes((int)br.BaseStream.Length))); using (BinaryReaderX br2 = new BinaryReaderX(new MemoryStream(result))) { if (br2.ReadString(4) == "XPCK") { type = 3; return(result); } } } return(null); }
/* オブジェクト作成時の処理 */ void Awake() { /* 現在のランタイムのバージョンが正しいかチェック */ CriWare.CheckBinaryVersionCompatibility(); if (dontInitializeOnAwake) { /* フラグが立っていた場合はAwakeでは初期化を行わない */ return; } /* プラグインの初期化 */ this.Initialize(); }
public bool Identify(string filename) { using (var br = new BinaryReaderX(File.OpenRead(filename))) { //possible identifications: PCK, cfg.bin, XPCK-Archive //if cfg.bin br.BaseStream.Position = 0x18; uint t1 = br.ReadUInt32(); br.BaseStream.Position = 0x24; uint t2 = br.ReadUInt32(); if (t1 == 0x0 && t2 == 0x14) { return(true); } br.BaseStream.Position = 0; //if PCK int entryCount = br.ReadInt32(); br.BaseStream.Position = 0x8; if (entryCount * 3 * 4 + 4 == br.ReadInt32()) { return(true); } br.BaseStream.Position = 0; //if XPCK if (br.ReadString(4) == "XPCK") { return(true); } else { br.BaseStream.Position = 0; byte[] result = CriWare.GetDecompressedBytes(new MemoryStream(br.ReadBytes((int)br.BaseStream.Length))); using (BinaryReaderX br2 = new BinaryReaderX(new MemoryStream(result))) { if (br2.ReadString(4) == "XPCK") { br2.BaseStream.Position = 0; return(true); } } } return(false); } }
private IEnumerator LoadAcbFileCoroutine(CriAtomCueSheet cueSheet, CriFsBinder binder, string acbPath, string awbPath, bool loadAwbOnMemory) { cueSheet.loaderStatus = CriAtomExAcbLoader.Status.Loading; if ((binder == null) && CriWare.IsStreamingAssetsPath(acbPath)) { acbPath = Path.Combine(CriWare.streamingAssetsPath, acbPath); } if (!String.IsNullOrEmpty(awbPath)) { if ((binder == null) && CriWare.IsStreamingAssetsPath(awbPath)) { awbPath = Path.Combine(CriWare.streamingAssetsPath, awbPath); } } while (this.acfIsLoading) { yield return(new WaitForEndOfFrame()); } using (var asyncLoader = CriAtomExAcbLoader.LoadAcbFileAsync(binder, acbPath, awbPath, loadAwbOnMemory)) { if (asyncLoader == null) { cueSheet.loaderStatus = CriAtomExAcbLoader.Status.Error; yield break; } while (true) { var status = asyncLoader.GetStatus(); cueSheet.loaderStatus = status; if (status == CriAtomExAcbLoader.Status.Complete) { cueSheet.acb = asyncLoader.MoveAcb(); break; } else if (status == CriAtomExAcbLoader.Status.Error) { break; } yield return(new WaitForEndOfFrame()); } } }
public bool Identify(string filename) { using (var br = new BinaryReaderX(File.OpenRead(filename))) { if (br.BaseStream.Length < 4) { return(false); } if (br.ReadString(4) == "XPCK") { return(true); } br.BaseStream.Position = 0; byte[] decomp; try { decomp = CriWare.Decompress(br.BaseStream); } catch { return(false); } return(new BinaryReaderX(new MemoryStream(decomp)).ReadString(4) == "XPCK"); } }
private CriAtomExAcb LoadAcbData(byte[] acbData, CriFsBinder binder, string awbFile) { if (acbData == null) { return(null); } string awbPath = awbFile; if (!String.IsNullOrEmpty(awbPath)) { if ((binder == null) && CriWare.IsStreamingAssetsPath(awbPath)) { awbPath = Path.Combine(CriWare.streamingAssetsPath, awbPath); } } return(CriAtomExAcb.LoadAcbData(acbData, binder, awbPath)); }
/** * <summary>ACBファイルのロード</summary> * <param name="binder">バインダオブジェクト</param> * <param name="acbPath">ACBファイルのパス</param> * <param name="awbPath">AWBファイルのパス</param> * <returns>CriAtomExAcbオブジェクト</returns> * \par 説明: * ACBファイルをロードし、キュー再生に必要な情報を取り込みます。<br/> * <br/> * 第2引数の acbPath にはオンメモリ再生用のACBファイルのパスを、 * 第3引数の awbPath にはストリーム再生用のAWBファイルのパスを、それぞれ指定します。<br/> * (オンメモリ再生のみのACBデータをロードする場合、 * awbPath にセットした値は無視されます。)<br/> * <br/> * ACBファイルとAWBファイルを一つのCPKファイルにパッキングしている場合、 * 第1引数( binder )にCPKファイルをバインドしたCriFsBinderオブジェクトを指定する必要があります。<br/> * <br/> * ACBファイルをロードすると、ACBデータにアクセスするためのCriAtomExAcbオブジェクト * ( ::CriAtomExAcb )が返されます。<br/> * AtomExプレーヤに対し、 ::CriAtomExPlayer::SetCue 関数でACBハンドル、 * および再生するキュー名を指定することで、 * ACBファイル内のキューを再生することが可能です。<br/> * <br/> * リードエラー等によりACBファイルのロードに失敗した場合、 * 本関数は戻り値として null を返します。<br/> * \attention * 本関数を実行する前に、ライブラリを初期化しておく必要があります。<br/> * <br/> * ACBハンドルは内部的にバインダ( CriFsBinder )を確保します。<br/> * ACBファイルをロードする場合、 * ACBファイル数分のバインダが確保できる設定でライブラリを初期化する必要があります。<br/> * <br/> * 本関数は完了復帰型の関数です。<br/> * ACBファイルのロードにかかる時間は、プラットフォームによって異なります。<br/> * ゲームループ等の画面更新が必要なタイミングで本関数を実行するとミリ秒単位で * 処理がブロックされ、フレーム落ちが発生する恐れがあります。<br/> * ACBファイルのロードは、シーンの切り替わり等、負荷変動を許容できる * タイミングで行うようお願いいたします。<br/> * \sa criAtomExAcb_CalculateWorkSizeForLoadAcbFile, CriAtomExAcbHn, criAtomExPlayer_SetCueId */ public static CriAtomExAcb LoadAcbFile(CriFsBinder binder, string acbPath, string awbPath) { /* バージョン番号が不正なライブラリではキューシートをロードしない */ /* 備考)不正に差し替えられたsoファイルを使用している可能性あり。 */ bool isCorrectVersion = CriWare.CheckBinaryVersionCompatibility(); if (isCorrectVersion == false) { return(null); } IntPtr binderHandle = (binder != null) ? binder.nativeHandle : IntPtr.Zero; IntPtr handle = criAtomExAcb_LoadAcbFile( binderHandle, acbPath, binderHandle, awbPath, IntPtr.Zero, 0); if (handle == IntPtr.Zero) { return(null); } return(new CriAtomExAcb(handle, null)); }
private string PluginVersionsString() { string[] moduleInfoStrings = ModuleInfosToAlignedString( (from item in pluginInfos select item.info).ToList() ).Split(new string[] { System.Environment.NewLine }, System.StringSplitOptions.None); int platformLength = pluginInfos.Max(item => (item != null) ? item.platform.Length : 0); string platformFormat = string.Format("{{0,-{0}}} ", platformLength); string s = ""; s += "CRIWARE Unity Plugin Script Version" + System.Environment.NewLine + " Ver." + CriWare.GetScriptVersionString() + System.Environment.NewLine + System.Environment.NewLine + "CRIWARE Unity Plugin Binary Version" + System.Environment.NewLine; for (int i = 0; i < pluginInfos.Count; i++) { s += " " + string.Format(platformFormat, pluginInfos[i].platform) + moduleInfoStrings[i] + System.Environment.NewLine; } return(s); }
public bool Identify(string filename) { //Console.WriteLine(Crc32.Create(new byte[] { 0x30, 0x30, 0x30, 0x2e, 0x61, 0x74, 0x72 })); //return false; using (var br = new BinaryReaderX(File.OpenRead(filename))) { if (br.BaseStream.Length < 4) { return(false); } if (br.ReadString(4) == "XPCK") { return(true); } br.BaseStream.Position = 0; byte[] decomp; try { decomp = CriWare.GetDecompressedBytes(br.BaseStream); } catch { return(false); } return(new BinaryReaderX(new MemoryStream(decomp)).ReadString(4) == "XPCK"); } }
private IEnumerator LoadAcbFileCoroutine(CriAtomCueSheet cueSheet, CriFsBinder binder, string acbPath, string awbPath) { if ((binder == null) && CriWare.IsStreamingAssetsPath(acbPath)) { acbPath = Path.Combine(CriWare.streamingAssetsPath, acbPath); } if (!String.IsNullOrEmpty(awbPath)) { if ((binder == null) && CriWare.IsStreamingAssetsPath(awbPath)) { awbPath = Path.Combine(CriWare.streamingAssetsPath, awbPath); } } while (this.acfIsLoading) { yield return(new WaitForEndOfFrame()); } using (var async = CriAtomExAcbAsync.LoadAcbFile(binder, acbPath, awbPath)) { cueSheet.async = async; while (true) { var status = async.GetStatus(); if (status == CriAtomExAcbAsync.Status.Complete) { cueSheet.acb = async.MoveAcb(); break; } else if (status == CriAtomExAcbAsync.Status.Error) { break; } yield return(new WaitForEndOfFrame()); } cueSheet.async = null; } }
public static void ReSetup(bool useEmb) { if (!MyCriManager.sInit) { MyCriManager.Setup(useEmb); } else { MyCriManager.AcfFileName = !useEmb ? (!GameUtility.Config_UseAssetBundles.Value ? Path.Combine(CriWare.get_streamingAssetsPath(), MyCriManager.AcfFileNameAB) : MyCriManager.GetLoadFileName(MyCriManager.AcfFileNameAB)) : Path.Combine(CriWare.get_streamingAssetsPath(), MyCriManager.AcfFileNameEmb); CriWareInitializer criWareInitializer = !Object.op_Equality((Object)MyCriManager.sCriWareInitializer, (Object)null) ? (CriWareInitializer)MyCriManager.sCriWareInitializer.GetComponent <CriWareInitializer>() : (CriWareInitializer)null; if (Object.op_Inequality((Object)criWareInitializer, (Object)null) && criWareInitializer.decrypterConfig != null) { ulong num = ((string)((CriWareDecrypterConfig)criWareInitializer.decrypterConfig).key).Length != 0 ? Convert.ToUInt64((string)((CriWareDecrypterConfig)criWareInitializer.decrypterConfig).key) : 0UL; string path2 = !useEmb?MyCriManager.GetLoadFileName(MyCriManager.DatFileNameAB) : MyCriManager.DatFileNameEmb; if (CriWare.IsStreamingAssetsPath(path2)) { path2 = Path.Combine(CriWare.get_streamingAssetsPath(), path2); } CriWare.criWareUnity_SetDecryptionKey(num, path2, (bool)((CriWareDecrypterConfig)criWareInitializer.decrypterConfig).enableAtomDecryption, (bool)((CriWareDecrypterConfig)criWareInitializer.decrypterConfig).enableManaDecryption); } MyCriManager.UsingEmb = useEmb; } }
public static bool InitializeAtom(CriAtomConfig config) { /* CRI Atomライブラリの初期化 */ if (CriAtomPlugin.IsLibraryInitialized() == false) { /* 初期化処理の実行 */ CriAtomPlugin.SetConfigParameters( (int)Math.Max(config.maxVirtualVoices, CriAtomPlugin.GetRequiredMaxVirtualVoices(config)), config.maxVoiceLimitGroups, config.maxCategories, config.maxSequenceEventsPerFrame, config.maxBeatSyncCallbacksPerFrame, config.standardVoicePoolConfig.memoryVoices, config.standardVoicePoolConfig.streamingVoices, config.hcaMxVoicePoolConfig.memoryVoices, config.hcaMxVoicePoolConfig.streamingVoices, config.outputSamplingRate, config.asrOutputChannels, config.usesInGamePreview, config.serverFrequency, config.maxParameterBlocks, config.categoriesPerPlayback, config.maxBuses, config.vrMode); CriAtomPlugin.SetConfigAdditionalParameters_PC( config.pcBufferingTime ); CriAtomPlugin.SetConfigAdditionalParameters_IOS( (uint)Math.Max(config.iosBufferingTime, 16), config.iosOverrideIPodMusic ); /* Android 固有の初期化パラメータを登録 */ { /* Ver.2.03.03 以前は 0 がデフォルト値だったことの互換性維持のための処理 */ if (config.androidBufferingTime == 0) { config.androidBufferingTime = (int)(4 * 1000.0 / config.serverFrequency); } if (config.androidStartBufferingTime == 0) { config.androidStartBufferingTime = (int)(3 * 1000.0 / config.serverFrequency); } IntPtr android_context = IntPtr.Zero; #if !UNITY_EDITOR && UNITY_ANDROID if (config.androidUsesAndroidFastMixer) { AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject activity = jc.GetStatic <AndroidJavaObject>("currentActivity"); android_context = activity.GetRawObject(); } CriAtomEx.androidDefaultSoundRendererType = config.androidForceToUseAsrForDefaultPlayback ? CriAtomEx.SoundRendererType.Asr : CriAtomEx.SoundRendererType.Default; #endif CriAtomPlugin.SetConfigAdditionalParameters_ANDROID( config.androidLowLatencyStandardVoicePoolConfig.memoryVoices, config.androidLowLatencyStandardVoicePoolConfig.streamingVoices, config.androidBufferingTime, config.androidStartBufferingTime, android_context); } CriAtomPlugin.InitializeLibrary(); if (config.useRandomSeedWithTime == true) { /* 時刻を乱数種に設定 */ CriAtomEx.SetRandomSeed((uint)System.DateTime.Now.Ticks); } /* ACFファイル指定時は登録 */ if (config.acfFileName.Length != 0) { string acfPath = config.acfFileName; if (CriWare.IsStreamingAssetsPath(acfPath)) { acfPath = Path.Combine(CriWare.streamingAssetsPath, acfPath); } CriAtomEx.RegisterAcf(null, acfPath); } return(true); } else { return(false); } }
/** * <summary>プラグインの初期化(手動初期化用)</summary> * \par 説明: * プラグインの初期化を行います。<br/> * デフォルトでは本関数はAwake関数内で自動的に呼び出されるので、アプリケーションが直接呼び出す必要はありません。<br/> * <br/> * 初期化パラメタをスクリプトから動的に変更して初期化を行いたい場合、本関数を使用してください。<br/> * \par 注意: * 本関数を使用する場合は、 自動初期化を無効にするため、 ::CriWareInitializer::dontInitializeOnAwake プロパティをインスペクタ上でチェックしてください。<br/> * また、本関数を呼び出すタイミングは全てのプラグインAPIよりも前に呼び出す必要があります。Script Execution Orderが高いスクリプト上で行ってください。 * */ public void Initialize() { /* 初期化カウンタの更新 */ initializationCount++; if (initializationCount != 1) { /* CriWareInitializer自身による多重初期化は許可しない */ GameObject.Destroy(this); return; } /* CRI File Systemライブラリの初期化 */ if (initializesFileSystem) { CriFsPlugin.SetConfigParameters( fileSystemConfig.numberOfLoaders, fileSystemConfig.numberOfBinders, fileSystemConfig.numberOfInstallers, (fileSystemConfig.installBufferSize * 1024), fileSystemConfig.maxPath, fileSystemConfig.minimizeFileDescriptorUsage ); { /* Ver.2.03.03 以前は 0 がデフォルト値だったことの互換性維持のための処理 */ if (fileSystemConfig.androidDeviceReadBitrate == 0) { fileSystemConfig.androidDeviceReadBitrate = CriFsConfig.defaultAndroidDeviceReadBitrate; } } CriFsPlugin.SetConfigAdditionalParameters_ANDROID(fileSystemConfig.androidDeviceReadBitrate); CriFsPlugin.InitializeLibrary(); if (fileSystemConfig.userAgentString.Length != 0) { CriFsUtility.SetUserAgentString(fileSystemConfig.userAgentString); } } /* CRI Atomライブラリの初期化 */ if (initializesAtom) { /* 初期化処理の実行 */ CriAtomPlugin.SetConfigParameters( (int)Math.Max(atomConfig.maxVirtualVoices, CriAtomPlugin.GetRequiredMaxVirtualVoices(atomConfig)), atomConfig.standardVoicePoolConfig.memoryVoices, atomConfig.standardVoicePoolConfig.streamingVoices, atomConfig.hcaMxVoicePoolConfig.memoryVoices, atomConfig.hcaMxVoicePoolConfig.streamingVoices, atomConfig.outputSamplingRate, atomConfig.usesInGamePreview, atomConfig.serverFrequency); CriAtomPlugin.SetConfigAdditionalParameters_IOS( (uint)Math.Max(atomConfig.iosBufferingTime, 16), atomConfig.iosOverrideIPodMusic ); { /* Ver.2.03.03 以前は 0 がデフォルト値だったことの互換性維持のための処理 */ if (atomConfig.androidBufferingTime == 0) { atomConfig.androidBufferingTime = (int)(4 * 1000.0 / atomConfig.serverFrequency); } if (atomConfig.androidStartBufferingTime == 0) { atomConfig.androidStartBufferingTime = (int)(3 * 1000.0 / atomConfig.serverFrequency); } } CriAtomPlugin.SetConfigAdditionalParameters_ANDROID( atomConfig.androidLowLatencyStandardVoicePoolConfig.memoryVoices, atomConfig.androidLowLatencyStandardVoicePoolConfig.streamingVoices, atomConfig.androidBufferingTime, atomConfig.androidStartBufferingTime); CriAtomPlugin.InitializeLibrary(); if (atomConfig.useRandomSeedWithTime == true) { /* 時刻を乱数種に設定 */ CriAtomEx.SetRandomSeed((uint)System.DateTime.Now.Ticks); } /* ACFファイル指定時は登録 */ if (atomConfig.acfFileName.Length != 0) { string acfPath = atomConfig.acfFileName; if (CriWare.IsStreamingAssetsPath(acfPath)) { acfPath = Path.Combine(CriWare.streamingAssetsPath, acfPath); } CriAtomEx.RegisterAcf(null, acfPath); } } /* CRI Manaライブラリの初期化 */ if (initializesMana) { CriManaPlugin.SetConfigParameters(manaConfig.graphicsMultiThreaded, manaConfig.numberOfDecoders, manaConfig.numberOfMaxEntries); CriManaPlugin.InitializeLibrary(); } /* シーンチェンジ後もオブジェクトを維持するかどうかの設定 */ if (dontDestroyOnLoad) { DontDestroyOnLoad(transform.gameObject); DontDestroyOnLoad(CriWare.managerObject); } }
/** * <summary>プラグインの初期化(手動初期化用)</summary> * \par 説明: * プラグインの初期化を行います。<br/> * デフォルトでは本関数はAwake関数内で自動的に呼び出されるので、アプリケーションが直接呼び出す必要はありません。<br/> * <br/> * 初期化パラメタをスクリプトから動的に変更して初期化を行いたい場合、本関数を使用してください。<br/> * \par 注意: * 本関数を使用する場合は、 自動初期化を無効にするため、 ::CriWareInitializer::dontInitializeOnAwake プロパティをインスペクタ上でチェックしてください。<br/> * また、本関数を呼び出すタイミングは全てのプラグインAPIよりも前に呼び出す必要があります。Script Execution Orderが高いスクリプト上で行ってください。 * */ public void Initialize() { /* 初期化カウンタの更新 */ initializationCount++; if (initializationCount != 1) { /* CriWareInitializer自身による多重初期化は許可しない */ GameObject.Destroy(this); return; } /* CRI File Systemライブラリの初期化 */ if (initializesFileSystem) { CriFsPlugin.SetConfigParameters( fileSystemConfig.numberOfLoaders, fileSystemConfig.numberOfBinders, fileSystemConfig.numberOfInstallers, (fileSystemConfig.installBufferSize * 1024), fileSystemConfig.maxPath, fileSystemConfig.minimizeFileDescriptorUsage ); { /* Ver.2.03.03 以前は 0 がデフォルト値だったことの互換性維持のための処理 */ if (fileSystemConfig.androidDeviceReadBitrate == 0) { fileSystemConfig.androidDeviceReadBitrate = CriFsConfig.defaultAndroidDeviceReadBitrate; } } CriFsPlugin.SetConfigAdditionalParameters_ANDROID(fileSystemConfig.androidDeviceReadBitrate); CriFsPlugin.InitializeLibrary(); if (fileSystemConfig.userAgentString.Length != 0) { CriFsUtility.SetUserAgentString(fileSystemConfig.userAgentString); } } /* CRI Atomライブラリの初期化 */ if (initializesAtom) { /* 初期化処理の実行 */ CriAtomPlugin.SetConfigParameters( (int)Math.Max(atomConfig.maxVirtualVoices, CriAtomPlugin.GetRequiredMaxVirtualVoices(atomConfig)), atomConfig.maxVoiceLimitGroups, atomConfig.maxCategories, atomConfig.standardVoicePoolConfig.memoryVoices, atomConfig.standardVoicePoolConfig.streamingVoices, atomConfig.hcaMxVoicePoolConfig.memoryVoices, atomConfig.hcaMxVoicePoolConfig.streamingVoices, atomConfig.outputSamplingRate, atomConfig.asrOutputChannels, atomConfig.usesInGamePreview, atomConfig.serverFrequency, atomConfig.maxParameterBlocks, atomConfig.categoriesPerPlayback, atomConfig.maxBuses, atomConfig.vrMode); CriAtomPlugin.SetConfigAdditionalParameters_PC( atomConfig.pcBufferingTime ); CriAtomPlugin.SetConfigAdditionalParameters_IOS( (uint)Math.Max(atomConfig.iosBufferingTime, 16), atomConfig.iosOverrideIPodMusic ); /* Android 固有の初期化パラメータを登録 */ { /* Ver.2.03.03 以前は 0 がデフォルト値だったことの互換性維持のための処理 */ if (atomConfig.androidBufferingTime == 0) { atomConfig.androidBufferingTime = (int)(4 * 1000.0 / atomConfig.serverFrequency); } if (atomConfig.androidStartBufferingTime == 0) { atomConfig.androidStartBufferingTime = (int)(3 * 1000.0 / atomConfig.serverFrequency); } IntPtr android_context = IntPtr.Zero; #if !UNITY_EDITOR && UNITY_ANDROID if (atomConfig.androidUsesAndroidFastMixer) { AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject activity = jc.GetStatic <AndroidJavaObject>("currentActivity"); android_context = activity.GetRawObject(); } #endif CriAtomPlugin.SetConfigAdditionalParameters_ANDROID( atomConfig.androidLowLatencyStandardVoicePoolConfig.memoryVoices, atomConfig.androidLowLatencyStandardVoicePoolConfig.streamingVoices, atomConfig.androidBufferingTime, atomConfig.androidStartBufferingTime, android_context); } CriAtomPlugin.SetConfigAdditionalParameters_VITA( atomConfig.vitaAtrac9VoicePoolConfig.memoryVoices, atomConfig.vitaAtrac9VoicePoolConfig.streamingVoices, (initializesMana) ? manaConfig.numberOfDecoders : 0); { /* VR Mode が有効なときも useAudio3D を True にする */ atomConfig.ps4Audio3dConfig.useAudio3D |= atomConfig.vrMode; CriAtomPlugin.SetConfigAdditionalParameters_PS4( atomConfig.ps4Atrac9VoicePoolConfig.memoryVoices, atomConfig.ps4Atrac9VoicePoolConfig.streamingVoices, atomConfig.ps4Audio3dConfig.useAudio3D, atomConfig.ps4Audio3dConfig.voicePoolConfig.memoryVoices, atomConfig.ps4Audio3dConfig.voicePoolConfig.streamingVoices); } CriAtomPlugin.SetConfigAdditionalParameters_WEBGL( atomConfig.webglWebAudioVoicePoolConfig.voices); CriAtomPlugin.InitializeLibrary(); if (atomConfig.useRandomSeedWithTime == true) { /* 時刻を乱数種に設定 */ CriAtomEx.SetRandomSeed((uint)System.DateTime.Now.Ticks); } /* ACFファイル指定時は登録 */ if (atomConfig.acfFileName.Length != 0) { string acfPath = atomConfig.acfFileName; if (CriWare.IsStreamingAssetsPath(acfPath)) { acfPath = Path.Combine(CriWare.streamingAssetsPath, acfPath); } CriAtomEx.RegisterAcf(null, acfPath); } } #if UNITY_EDITOR || (!UNITY_PS3) /* CRI Manaライブラリの初期化 */ if (initializesMana) { CriManaPlugin.SetConfigParameters(manaConfig.graphicsMultiThreaded, manaConfig.numberOfDecoders, manaConfig.numberOfMaxEntries); CriManaPlugin.SetConfigAdditonalParameters_ANDROID(true); #if UNITY_PSP2 CriWareVITA.EnableManaH264Playback(manaConfig.vitaH264PlaybackConfig.useH264Playback); CriWareVITA.SetManaH264DecoderMaxSize(manaConfig.vitaH264PlaybackConfig.maxWidth, manaConfig.vitaH264PlaybackConfig.maxHeight); CriWareVITA.EnableManaH264DecoderGetDisplayMemoryFromUnityTexture(manaConfig.vitaH264PlaybackConfig.getMemoryFromTexture); #endif CriManaPlugin.InitializeLibrary(); } #endif /*JP< CRI Ware Decrypterの設定 */ if (useDecrypter) { ulong decryptionKey = (decrypterConfig.key.Length == 0) ? 0 : Convert.ToUInt64(decrypterConfig.key); string authenticationPath = decrypterConfig.authenticationFile; if (CriWare.IsStreamingAssetsPath(authenticationPath)) { authenticationPath = Path.Combine(CriWare.streamingAssetsPath, authenticationPath); } #if !UNITY_EDITOR && UNITY_WEBGL CriWare.criWareUnity_SetDecryptionKey_EMSCRIPTEN( decryptionKey ); #else CriWare.criWareUnity_SetDecryptionKey( decryptionKey, authenticationPath, decrypterConfig.enableAtomDecryption, decrypterConfig.enableManaDecryption ); #endif } else { #if !UNITY_EDITOR && UNITY_WEBGL CriWare.criWareUnity_SetDecryptionKey_EMSCRIPTEN(0); #else CriWare.criWareUnity_SetDecryptionKey(0, "", false, false); #endif } /* シーンチェンジ後もオブジェクトを維持するかどうかの設定 */ if (dontDestroyOnLoad) { DontDestroyOnLoad(transform.gameObject); DontDestroyOnLoad(CriWare.managerObject); } }
public static byte[] Decomp(BinaryReaderX br) { // above to be restored eventually with some changes to Cetera return(CriWare.GetDecompressedBytes(br.BaseStream)); }
/** * <summary>プラグインの初期化(手動初期化用)</summary> * \par 説明: * プラグインの初期化を行います。<br/> * デフォルトでは本関数はAwake関数内で自動的に呼び出されるので、アプリケーションが直接呼び出す必要はありません。<br/> * <br/> * 初期化パラメタをスクリプトから動的に変更して初期化を行いたい場合、本関数を使用してください。<br/> * \par 注意: * 本関数を使用する場合は、 自動初期化を無効にするため、 ::CriWareInitializer::dontInitializeOnAwake プロパティをインスペクタ上でチェックしてください。<br/> * また、本関数を呼び出すタイミングは全てのプラグインAPIよりも前に呼び出す必要があります。Script Execution Orderが高いスクリプト上で行ってください。 * */ public void Initialize() { /* 初期化カウンタの更新 */ initializationCount++; if (initializationCount != 1) { /* CriWareInitializer自身による多重初期化は許可しない */ GameObject.Destroy(this); return; } /* CRI File Systemライブラリの初期化 */ if (initializesFileSystem) { CriFsPlugin.SetConfigParameters( fileSystemConfig.numberOfLoaders, fileSystemConfig.numberOfBinders, fileSystemConfig.numberOfInstallers, (fileSystemConfig.installBufferSize * 1024), fileSystemConfig.maxPath, fileSystemConfig.minimizeFileDescriptorUsage ); { /* Ver.2.03.03 以前は 0 がデフォルト値だったことの互換性維持のための処理 */ if (fileSystemConfig.androidDeviceReadBitrate == 0) { fileSystemConfig.androidDeviceReadBitrate = CriFsConfig.defaultAndroidDeviceReadBitrate; } } CriFsPlugin.SetConfigAdditionalParameters_ANDROID(fileSystemConfig.androidDeviceReadBitrate); CriFsPlugin.InitializeLibrary(); if (fileSystemConfig.userAgentString.Length != 0) { CriFsUtility.SetUserAgentString(fileSystemConfig.userAgentString); } } /* CRI Atomライブラリの初期化 */ if (initializesAtom) { /* 初期化処理の実行 */ CriAtomPlugin.SetConfigParameters( (int)Math.Max(atomConfig.maxVirtualVoices, CriAtomPlugin.GetRequiredMaxVirtualVoices(atomConfig)), atomConfig.maxVoiceLimitGroups, atomConfig.maxCategories, atomConfig.standardVoicePoolConfig.memoryVoices, atomConfig.standardVoicePoolConfig.streamingVoices, atomConfig.hcaMxVoicePoolConfig.memoryVoices, atomConfig.hcaMxVoicePoolConfig.streamingVoices, atomConfig.outputSamplingRate, atomConfig.asrOutputChannels, atomConfig.usesInGamePreview, atomConfig.serverFrequency, atomConfig.maxParameterBlocks, atomConfig.categoriesPerPlayback, atomConfig.maxBuses, false); CriAtomPlugin.SetConfigAdditionalParameters_PC( atomConfig.pcBufferingTime ); CriAtomPlugin.SetConfigAdditionalParameters_IOS( (uint)Math.Max(atomConfig.iosBufferingTime, 16), atomConfig.iosOverrideIPodMusic ); /* Android 固有の初期化パラメータを登録 */ { /* Ver.2.03.03 以前は 0 がデフォルト値だったことの互換性維持のための処理 */ if (atomConfig.androidBufferingTime == 0) { atomConfig.androidBufferingTime = (int)(4 * 1000.0 / atomConfig.serverFrequency); } if (atomConfig.androidStartBufferingTime == 0) { atomConfig.androidStartBufferingTime = (int)(3 * 1000.0 / atomConfig.serverFrequency); } IntPtr android_context = IntPtr.Zero; #if !UNITY_EDITOR && UNITY_ANDROID if (atomConfig.androidUsesAndroidFastMixer) { AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject activity = jc.GetStatic <AndroidJavaObject>("currentActivity"); android_context = activity.GetRawObject(); } #endif CriAtomPlugin.SetConfigAdditionalParameters_ANDROID( atomConfig.androidLowLatencyStandardVoicePoolConfig.memoryVoices, atomConfig.androidLowLatencyStandardVoicePoolConfig.streamingVoices, atomConfig.androidBufferingTime, atomConfig.androidStartBufferingTime, android_context); } CriAtomPlugin.InitializeLibrary(); if (atomConfig.useRandomSeedWithTime == true) { /* 時刻を乱数種に設定 */ CriAtomEx.SetRandomSeed((uint)System.DateTime.Now.Ticks); } /* ACFファイル指定時は登録 */ if (atomConfig.acfFileName.Length != 0) { string acfPath = atomConfig.acfFileName; if (CriWare.IsStreamingAssetsPath(acfPath)) { acfPath = Path.Combine(CriWare.streamingAssetsPath, acfPath); } CriAtomEx.RegisterAcf(null, acfPath); } } /* CRI Manaライブラリの初期化 */ if (initializesMana) { CriManaPlugin.SetConfigParameters(manaConfig.graphicsMultiThreaded, manaConfig.numberOfDecoders, manaConfig.numberOfMaxEntries); CriManaPlugin.InitializeLibrary(); } /* シーンチェンジ後もオブジェクトを維持するかどうかの設定 */ if (dontDestroyOnLoad) { DontDestroyOnLoad(transform.gameObject); DontDestroyOnLoad(CriWare.managerObject); } }
public static void Setup(bool useEmb = false) { if (MyCriManager.sInit) { return; } if (CriWareInitializer.IsInitialized()) { DebugUtility.LogError("[MyCriManager] CriWareInitializer already initialized. if you added it or CriAtomSource in scene, remove it."); } else if (Object.op_Inequality(Object.FindObjectOfType(typeof(CriWareInitializer)), (Object)null)) { DebugUtility.LogError("[MyCriManager] CriWareInitializer already exist. if you added it in scene, remove it."); } else if (Object.op_Inequality(Object.FindObjectOfType(typeof(CriAtom)), (Object)null)) { DebugUtility.LogError("[MyCriManager] CriAtom already exist. if you added it in scene, remove it."); } else { GameObject gameObject = (GameObject)Object.Instantiate(Resources.Load("CriWareLibraryInitializer"), Vector3.get_zero(), Quaternion.get_identity()); if (Object.op_Inequality((Object)gameObject, (Object)null)) { CriWareInitializer component = (CriWareInitializer)gameObject.GetComponent <CriWareInitializer>(); if (Object.op_Inequality((Object)component, (Object)null)) { if (useEmb) { MyCriManager.AcfFileName = Path.Combine(CriWare.get_streamingAssetsPath(), MyCriManager.AcfFileNameEmb); ((CriWareDecrypterConfig)component.decrypterConfig).authenticationFile = (__Null)MyCriManager.DatFileNameEmb; } else { MyCriManager.AcfFileName = Path.Combine(CriWare.get_streamingAssetsPath(), MyCriManager.AcfFileNameAB); ((CriWareDecrypterConfig)component.decrypterConfig).authenticationFile = (__Null)MyCriManager.DatFileNameAB; } ((CriAtomConfig)component.atomConfig).acfFileName = (__Null)string.Empty; DebugUtility.LogWarning("[MyCriManager] Init with EMB:" + (object)useEmb + " acf:" + MyCriManager.AcfFileName + " dat:" + (object)((CriWareDecrypterConfig)component.decrypterConfig).authenticationFile); MyCriManager.sCriWareInitializer = gameObject; MyCriManager.UsingEmb = useEmb; AndroidJavaClass androidJavaClass = new AndroidJavaClass("android.os.Build"); string str = androidJavaClass != null ? (string)((AndroidJavaObject)androidJavaClass).GetStatic <string>("MODEL") : (string)null; if (!string.IsNullOrEmpty(str)) { if (str.CompareTo("F-05D") == 0) { ((CriAtomConfig)component.atomConfig).androidBufferingTime = (__Null)200; ((CriAtomConfig)component.atomConfig).androidStartBufferingTime = (__Null)150; } if (str.CompareTo("T-01D") == 0) { ((CriAtomConfig)component.atomConfig).androidBufferingTime = (__Null)200; ((CriAtomConfig)component.atomConfig).androidStartBufferingTime = (__Null)150; } if (str.CompareTo("AT200") == 0) { ((CriAtomConfig)component.atomConfig).androidBufferingTime = (__Null)220; ((CriAtomConfig)component.atomConfig).androidStartBufferingTime = (__Null)220; } if (str.CompareTo("F-04E") == 0) { ((CriAtomConfig)component.atomConfig).androidBufferingTime = (__Null)220; ((CriAtomConfig)component.atomConfig).androidStartBufferingTime = (__Null)220; } if (str.CompareTo("F-11D") == 0) { ((CriAtomConfig)component.atomConfig).androidBufferingTime = (__Null)400; ((CriAtomConfig)component.atomConfig).androidStartBufferingTime = (__Null)400; } if (str.CompareTo("IS15SH") == 0) { ((CriAtomConfig)component.atomConfig).androidBufferingTime = (__Null)400; ((CriAtomConfig)component.atomConfig).androidStartBufferingTime = (__Null)400; } if (str.CompareTo("IS17SH") == 0) { ((CriAtomConfig)component.atomConfig).androidBufferingTime = (__Null)400; ((CriAtomConfig)component.atomConfig).androidStartBufferingTime = (__Null)400; } if (str.CompareTo("ISW13F") == 0) { ((CriAtomConfig)component.atomConfig).androidBufferingTime = (__Null)220; ((CriAtomConfig)component.atomConfig).androidStartBufferingTime = (__Null)220; } DebugUtility.Log("MODEL:" + str); } component.Initialize(); } } MyCriManager.sInit = true; } }
private void OnGUI() { EditorGUILayout.BeginVertical(); { { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Copy To Clipboard", GUILayout.Width(180))) { EditorGUIUtility.systemCopyBuffer = PluginVersionsString(); GUI.FocusControl(""); } if (GUILayout.Button("Reload", GUILayout.Width(80))) { Reload(); GUI.FocusControl(""); } EditorGUILayout.EndHorizontal(); } /* スクリプトバージョン表示 */ { EditorGUILayout.LabelField("Script Version"); EditorGUI.indentLevel++; EditorGUILayout.LabelField("Ver." + CriWare.GetScriptVersionString()); EditorGUI.indentLevel--; } EditorGUILayout.Space(); /* バイナリバージョン表示 */ { EditorGUILayout.LabelField("Binary Version"); } EditorGUI.indentLevel++; /* プラットフォーム別プラグインバイナリバージョン表示 */ { EditorGUILayout.BeginVertical(); GUILayoutOption platformColumnWidth = GUILayout.Width(80); GUILayoutOption targetColumnWidth = GUILayout.Width(120); GUILayoutOption versionColumnWidth = GUILayout.Width(140); GUILayoutOption buildDateColumnWidth = GUILayout.Width(200); GUILayoutOption appendixColumnWidth = GUILayout.Width(200); GUILayoutOption pathColumnWidth = GUILayout.Width(400); if (pluginInfos != null) { foreach (var info in pluginInfos) { EditorGUILayout.BeginHorizontal(); { if (GUILayout.Button(info.platform, EditorStyles.radioButton, platformColumnWidth)) { /* 表示の制限のため表示可能な文字数で切り出す */ detailVersionsString = ModuleInfosToAlignedString(info.moduleVersionInfos); detailVersionsStrings = SplitTextAreaMaxLength(detailVersionsString); scrollPosition = new Vector2(0.0f, 0.0f); GUI.FocusControl(""); } if (info.info != null) { EditorGUILayout.LabelField((info.target ?? "--"), targetColumnWidth); EditorGUILayout.LabelField((info.info.version ?? "--"), versionColumnWidth); EditorGUILayout.LabelField((info.info.buildDate ?? "--"), buildDateColumnWidth); EditorGUILayout.LabelField((info.info.appendix ?? "--"), appendixColumnWidth); } else { EditorGUILayout.LabelField("--", targetColumnWidth); EditorGUILayout.LabelField("--", versionColumnWidth); EditorGUILayout.LabelField("--", buildDateColumnWidth); EditorGUILayout.LabelField("--", appendixColumnWidth); } EditorGUILayout.LabelField(info.path, pathColumnWidth); } EditorGUILayout.EndHorizontal(); } } EditorGUILayout.EndVertical(); } EditorGUI.indentLevel--; /* 詳細バージョン情報表示 */ { if (GUILayout.Button("Copy Detail To Clipboard", GUILayout.Width(180))) { EditorGUIUtility.systemCopyBuffer = detailVersionsString; GUI.FocusControl(""); } scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition); EditorGUILayout.BeginVertical(); foreach (var item in detailVersionsStrings) { EditorGUILayout.TextArea(item); } EditorGUILayout.EndVertical(); EditorGUILayout.EndScrollView(); } } EditorGUILayout.EndVertical(); }
public static void Decompress(object sender, EventArgs e) { var tsi = sender as ToolStripMenuItem; if (!PrepareFiles("Open a " + tsi.Tag.ToString() + " compressed file...", "Save your decompressed file...", ".decomp", out FileStream openFile, out FileStream saveFile)) { return; } try { using (openFile) using (var outFs = new BinaryWriterX(saveFile)) switch (tsi.Tag) { case Compression.CriWare: outFs.Write(CriWare.Decompress(openFile)); break; case Compression.GZip: outFs.Write(GZip.Decompress(openFile)); break; case Compression.Huff4: outFs.Write(Huffman.Decompress(openFile, 4)); break; case Compression.Huff8: outFs.Write(Huffman.Decompress(openFile, 8)); break; case Compression.LZ10: outFs.Write(LZ10.Decompress(openFile)); break; case Compression.LZ11: outFs.Write(LZ11.Decompress(openFile)); break; case Compression.LZ77: outFs.Write(LZ77.Decompress(openFile)); break; /*case Compression.LZSS: * outFs.Write(LZSS.Decompress(openFile, LZSS.GetDecompressedSize(openFile))); * break;*/ case Compression.RevLZ77: outFs.Write(RevLZ77.Decompress(openFile)); break; case Compression.RLE: outFs.Write(RLE.Decompress(openFile)); break; case Compression.ZLib: outFs.Write(ZLib.Decompress(openFile)); break; } } catch (Exception ex) { MessageBox.Show(ex.ToString(), tsi?.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } MessageBox.Show($"Successfully decompressed {Path.GetFileName(openFile.Name)}.", tsi?.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); }