Change to compatible syntax without namaspace

This commit is contained in:
Jun Koyama
2020-10-05 23:45:01 +09:00
parent 572cb01ec8
commit 6a61a4c349
41 changed files with 13528 additions and 13418 deletions

View File

@ -5,114 +5,117 @@
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/
import { Live2DCubismFramework as csmvector } from '../type/csmvector';
import { Live2DCubismFramework as cubismid } from './cubismid';
import { Live2DCubismFramework as csmstring } from '../type/csmstring';
import csmString = csmstring.csmString;
import CubismId = cubismid.CubismId;
import csmVector = csmvector.csmVector;
import { csmString } from '../type/csmstring';
import { csmVector } from '../type/csmvector';
import { CubismId } from './cubismid';
export namespace Live2DCubismFramework {
/**
* ID名の管理
*
* ID名を管理する。
*/
export class CubismIdManager {
/**
* ID名の管理
*
* ID名を管理する。
* コンストラクタ
*/
export class CubismIdManager {
/**
* コンストラクタ
*/
public constructor() {
this._ids = new csmVector<CubismId>();
}
/**
* デストラクタ相当の処理
*/
public release(): void {
for (let i = 0; i < this._ids.getSize(); ++i) {
this._ids.set(i, void 0);
}
this._ids = null;
}
/**
* ID名をリストから登録
*
* @param ids ID名リスト
* @param count IDの個数
*/
public registerIds(ids: string[] | csmString[]): void {
for (let i = 0; i < ids.length; i++) {
this.registerId(ids[i]);
}
}
/**
* ID名を登録
*
* @param id ID名
*/
public registerId(id: string | csmString): CubismId {
let result: CubismId = null;
if ('string' == typeof id) {
if ((result = this.findId(id)) != null) {
return result;
}
result = new CubismId(id);
this._ids.pushBack(result);
} else {
return this.registerId(id.s);
}
return result;
}
/**
* ID名からIDを取得する
*
* @param id ID名
*/
public getId(id: csmString | string): CubismId {
return this.registerId(id);
}
/**
* ID名からIDの確認
*
* @return true 存在する
* @return false 存在しない
*/
public isExist(id: csmString | string): boolean {
if ('string' == typeof id) {
return this.findId(id) != null;
}
return this.isExist(id.s);
}
/**
* ID名からIDを検索する。
*
* @param id ID名
* @return 登録されているID。なければNULL。
*/
private findId(id: string): CubismId {
for (let i = 0; i < this._ids.getSize(); ++i) {
if (
this._ids
.at(i)
.getString()
.isEqual(id)
) {
return this._ids.at(i);
}
}
return null;
}
private _ids: csmVector<CubismId>; // 登録されているIDのリスト
public constructor() {
this._ids = new csmVector<CubismId>();
}
/**
* デストラクタ相当の処理
*/
public release(): void {
for (let i = 0; i < this._ids.getSize(); ++i) {
this._ids.set(i, void 0);
}
this._ids = null;
}
/**
* ID名をリストから登録
*
* @param ids ID名リスト
* @param count IDの個数
*/
public registerIds(ids: string[] | csmString[]): void {
for (let i = 0; i < ids.length; i++) {
this.registerId(ids[i]);
}
}
/**
* ID名を登録
*
* @param id ID名
*/
public registerId(id: string | csmString): CubismId {
let result: CubismId = null;
if ('string' == typeof id) {
if ((result = this.findId(id)) != null) {
return result;
}
result = new CubismId(id);
this._ids.pushBack(result);
} else {
return this.registerId(id.s);
}
return result;
}
/**
* ID名からIDを取得する
*
* @param id ID名
*/
public getId(id: csmString | string): CubismId {
return this.registerId(id);
}
/**
* ID名からIDの確認
*
* @return true 存在する
* @return false 存在しない
*/
public isExist(id: csmString | string): boolean {
if ('string' == typeof id) {
return this.findId(id) != null;
}
return this.isExist(id.s);
}
/**
* ID名からIDを検索する。
*
* @param id ID名
* @return 登録されているID。なければNULL。
*/
private findId(id: string): CubismId {
for (let i = 0; i < this._ids.getSize(); ++i) {
if (
this._ids
.at(i)
.getString()
.isEqual(id)
) {
return this._ids.at(i);
}
}
return null;
}
private _ids: csmVector<CubismId>; // 登録されているIDのリスト
}
// Namespace definition for compatibility.
import * as $ from './cubismidmanager';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Live2DCubismFramework {
export const CubismIdManager = $.CubismIdManager;
export type CubismIdManager = $.CubismIdManager;
}