/**
 * Copyright(c) Live2D Inc. All rights reserved.
 *
 * Use of this source code is governed by the Live2D Open Software license
 * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
 */ import { CubismIdHandle } from '../id/cubismid' ; import { CubismFramework } from '../live2dcubismframework' ; import { csmString } from '../type/csmstring' ; import { csmVector } from '../type/csmvector' ; import { CubismModelUserDataJson } from './cubismmodeluserdatajson' ; const ArtMesh = 'ArtMesh' ; /**
 * ユーザーデータインターフェース
 *
 * Jsonから読み込んだユーザーデータを記録しておくための構造体
 */ export class CubismModelUserDataNode { targetType : CubismIdHandle ; targetId : CubismIdHandle ; value : csmString ; } /**
 * ユーザデータの管理クラス
 *
 * ユーザデータをロード、管理、検索インターフェイス、解放までを行う。
 */ export class CubismModelUserData { param buffer param size return public static create ( buffer , size ) { const ret = new CubismModelUserData ( ) ; ret . parseUserData ( buffer , size ) ; return ret ; } param modelUserData public static delete ( modelUserData ) { if ( modelUserData != null ) { modelUserData . release ( ) ; modelUserData = null ; } } return public getArtMeshUserDatas ( ) { return this . _artMeshUserDataNode ; } param buffer param size public parseUserData ( buffer , size ) { let json = new CubismModelUserDataJson ( buffer , size ) ; const typeOfArtMesh = CubismFramework . getIdManager ( ) . getId ( ArtMesh ) ; const nodeCount = json . getUserDataCount ( ) ; for ( let i = 0 ; i < nodeCount ; i ++ ) { const addNode = new CubismModelUserDataNode ( ) ; addNode . targetId = json . getUserDataId ( i ) ; addNode . targetType = CubismFramework . getIdManager ( ) . getId ( json . getUserDataTargetType ( i ) ) ; addNode . value = new csmString ( json . getUserDataValue ( i ) ) ; this . _userDataNodes . pushBack ( addNode ) ; if ( addNode . targetType == typeOfArtMesh ) { this . _artMeshUserDataNode . pushBack ( addNode ) ; } } json . release ( ) ; json = void 0 ; } /**
     * コンストラクタ
     */ public constructor ( ) { this . _userDataNodes = new csmVector < CubismModelUserDataNode > ( ) ; this . _artMeshUserDataNode = new csmVector < CubismModelUserDataNode > ( ) ; } /**
     * デストラクタ相当の処理
     *
     * ユーザーデータ構造体配列を解放する
     */ public release ( ) { for ( let i = 0 ; i < this . _userDataNodes . getSize ( ) ; ++ i ) { this . _userDataNodes . set ( i , null ) ; } this . _userDataNodes = null ; } private _userDataNodes : csmVector < CubismModelUserDataNode > ; private _artMeshUserDataNode : csmVector < CubismModelUserDataNode > ; } import * as $ from './cubismmodeluserdata' ; export namespace Live2DCubismFramework { export const CubismModelUserData = $ . CubismModelUserData ; export type CubismModelUserData = $ . CubismModelUserData ; export const CubismModelUserDataNode = $ . CubismModelUserDataNode ; export type CubismModelUserDataNode = $ . CubismModelUserDataNode ; }