Activate log.
parent
102eda3c97
commit
0ae2767bda
|
@ -5,6 +5,7 @@
|
|||
* that can be found at http://live2d.com/eula/live2d-open-software-license-agreement_en.html.
|
||||
*/
|
||||
|
||||
/// <reference path="../Core/live2dcubismcore.d.ts" />
|
||||
import {Live2DCubismFramework as cubismjson} from "./utils/cubismjson";
|
||||
import {Live2DCubismFramework as cubismidmanager} from "./id/cubismidmanager";
|
||||
import {Live2DCubismFramework as cubismrenderer} from "./rendering/cubismrenderer";
|
||||
|
@ -98,7 +99,7 @@ export namespace Live2DCubismFramework
|
|||
{
|
||||
if(s_isStarted)
|
||||
{
|
||||
CubismLogInfo("CubismFramework::StartUp() is already done.");
|
||||
CubismLogInfo("CubismFramework.startUp() is already done.");
|
||||
return s_isStarted;
|
||||
}
|
||||
|
||||
|
@ -106,7 +107,7 @@ export namespace Live2DCubismFramework
|
|||
|
||||
if(s_option != null)
|
||||
{
|
||||
// TODO Core::csmSetLogFunction(s_option->LogFunction);
|
||||
Live2DCubismCore.Logging.csmSetLogFunction(s_option.logFunction);
|
||||
}
|
||||
|
||||
s_isStarted = true;
|
||||
|
@ -114,16 +115,21 @@ export namespace Live2DCubismFramework
|
|||
// Live2D Cubism Coreバージョン情報を表示
|
||||
if(s_isStarted)
|
||||
{
|
||||
const version: number = 1; // TODO Core::csmGetVersion()
|
||||
const version: number = Live2DCubismCore.Version.csmGetVersion();
|
||||
const major: number = ((version & 0xFF000000) >> 24);
|
||||
const minor: number = ((version & 0x00FF0000) >> 16);
|
||||
const patch: number = ((version & 0x0000FFFF));
|
||||
const versionNumber: number = version;
|
||||
|
||||
CubismLogInfo("Live2D Cubism Core version: %02d.%02d.%04d (%d)", major, minor, patch, versionNumber);
|
||||
CubismLogInfo(`Live2D Cubism Core version: {0}.{1}.{2} ({3})`,
|
||||
('00' + major).slice(-2),
|
||||
('00' + minor).slice(-2),
|
||||
('0000' + patch).slice(-4),
|
||||
versionNumber
|
||||
);
|
||||
}
|
||||
|
||||
CubismLogInfo("CubismFramework::StartUp() is complete.");
|
||||
CubismLogInfo("CubismFramework.startUp() is complete.");
|
||||
|
||||
return s_isStarted;
|
||||
}
|
||||
|
@ -158,7 +164,7 @@ export namespace Live2DCubismFramework
|
|||
// 再度Initialize()するには先にDispose()を実行する必要がある。
|
||||
if (s_isInitialized)
|
||||
{
|
||||
CubismLogWarning("CubismFramework::Initialize() skipped, already initialized.");
|
||||
CubismLogWarning("CubismFramework.initialize() skipped, already initialized.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -169,7 +175,7 @@ export namespace Live2DCubismFramework
|
|||
|
||||
s_isInitialized = true;
|
||||
|
||||
CubismLogInfo("CubismFramework::Initialize() is complete.");
|
||||
CubismLogInfo("CubismFramework.initialize() is complete.");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -190,7 +196,7 @@ export namespace Live2DCubismFramework
|
|||
// dispose()するには先にinitialize()を実行する必要がある。
|
||||
if(!s_isInitialized) // false...リソース未確保の場合
|
||||
{
|
||||
CubismLogWarning("CubismFramework::Dispose() skipped, not initialized.");
|
||||
CubismLogWarning("CubismFramework.dispose() skipped, not initialized.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -204,9 +210,44 @@ export namespace Live2DCubismFramework
|
|||
|
||||
s_isInitialized = false;
|
||||
|
||||
CubismLogInfo("CubismFramework::Dispose() is complete.");
|
||||
CubismLogInfo("CubismFramework.dispose() is complete.");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Cubism FrameworkのAPIを使用する準備が完了したかどうか
|
||||
* @return APIを使用する準備が完了していればtrueが返ります。
|
||||
*/
|
||||
public static isStarted(): boolean
|
||||
{
|
||||
return s_isStarted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cubism Frameworkのリソース初期化がすでに行われているかどうか
|
||||
* @return リソース確保が完了していればtrueが返ります
|
||||
*/
|
||||
public static isInitialized(): boolean
|
||||
{
|
||||
return s_isInitialized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Core APIにバインドしたログ関数を実行する
|
||||
*
|
||||
* @praram message ログメッセージ
|
||||
*/
|
||||
public static coreLogFunction(message: string): void
|
||||
{
|
||||
// Return if logging not possible.
|
||||
if(!Live2DCubismCore.Logging.csmGetLogFunction())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Live2DCubismCore.Logging.csmGetLogFunction()(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 現在のログ出力レベル設定の値を返す。
|
||||
*
|
||||
|
@ -221,24 +262,6 @@ export namespace Live2DCubismFramework
|
|||
return LogLevel.LogLevel_Off;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cubism FrameworkのAPIを使用する準備が完了したかどうか
|
||||
* @return APIを使用する準備が完了していればtrueが返ります。
|
||||
*/
|
||||
public static isStarted(): boolean
|
||||
{
|
||||
return s_isStarted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cubism Frameworkのリソース初期化がすでに行われているかどうか
|
||||
* @return リソース確保が完了していればtrueが返ります
|
||||
*/
|
||||
public static isInitialized(): boolean
|
||||
{
|
||||
return s_isInitialized;
|
||||
}
|
||||
|
||||
/**
|
||||
* IDマネージャのインスタンスを取得する
|
||||
* @return CubismManagerクラスのインスタンス
|
||||
|
@ -261,6 +284,7 @@ export namespace Live2DCubismFramework
|
|||
|
||||
export class Option
|
||||
{
|
||||
logFunction: Live2DCubismCore.csmLogFunction; // ログ出力の関数オブジェクト
|
||||
loggingLevel: LogLevel; // ログ出力レベルの設定
|
||||
}
|
||||
|
||||
|
|
|
@ -5,16 +5,16 @@
|
|||
* that can be found at http://live2d.com/eula/live2d-open-software-license-agreement_en.html.
|
||||
*/
|
||||
|
||||
import {Live2DCubismFramework as live2dcubismframework, LogLevel} from "../live2dcubismframework";
|
||||
import CubismFramework = live2dcubismframework.CubismFramework;
|
||||
import { CSM_LOG_LEVEL, CSM_LOG_LEVEL_VERBOSE, CSM_LOG_LEVEL_DEBUG, CSM_LOG_LEVEL_INFO, CSM_LOG_LEVEL_WARNING, CSM_LOG_LEVEL_ERROR } from "../cubismframeworkconfig";
|
||||
import {Live2DCubismFramework as cubismframework, LogLevel} from "../live2dcubismframework";
|
||||
import {CSM_LOG_LEVEL, CSM_LOG_LEVEL_VERBOSE, CSM_LOG_LEVEL_DEBUG, CSM_LOG_LEVEL_INFO, CSM_LOG_LEVEL_WARNING, CSM_LOG_LEVEL_ERROR} from "../cubismframeworkconfig";
|
||||
|
||||
export const CubismLogPrint = (level: LogLevel, fmt: string, ... args: any[]) =>
|
||||
|
||||
export const CubismLogPrint = (level: LogLevel, fmt: string, args: any[]) =>
|
||||
{
|
||||
Live2DCubismFramework.CubismDebug.print(level, "[CSM]" + fmt, args);
|
||||
}
|
||||
|
||||
export const CubismLogPrintIn = (level: LogLevel, fmt: string, ... args: any[]) =>
|
||||
export const CubismLogPrintIn = (level: LogLevel, fmt: string, args: any[]) =>
|
||||
{
|
||||
CubismLogPrint(level, fmt + "\n", args);
|
||||
}
|
||||
|
@ -133,32 +133,30 @@ export namespace Live2DCubismFramework
|
|||
*
|
||||
* @param logLevel ログレベルの設定
|
||||
* @param format 書式付き文字列
|
||||
* @param ... args 可変長引数
|
||||
* @param args 可変長引数
|
||||
*/
|
||||
public static print(logLevel: LogLevel, format: string, ... args: any[]): void
|
||||
public static print(logLevel: LogLevel, format: string, args?: any[]): void
|
||||
{
|
||||
// オプションで設定されたログ出力レベルを下回る場合はログに出さない
|
||||
// if(logLevel < CubismFramework.getLoggingLevel())
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// TODO
|
||||
// const Core::csmLogFunction logPrint = CubismFramework::CoreLogFunction;
|
||||
if(logLevel < cubismframework.CubismFramework.getLoggingLevel())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// if (!logPrint)
|
||||
// return;
|
||||
const logPrint: Live2DCubismCore.csmLogFunction = cubismframework.CubismFramework.coreLogFunction;
|
||||
|
||||
let buffer: string = format;
|
||||
buffer = buffer.replace(
|
||||
/\{(\d+)\}/g,
|
||||
(m, k) => // m="{0}", k="0"
|
||||
{
|
||||
return args[k];
|
||||
}
|
||||
);
|
||||
|
||||
// logPrint(buffer);
|
||||
if (!logPrint)
|
||||
return;
|
||||
|
||||
let buffer: string =
|
||||
format.replace(
|
||||
/\{(\d+)\}/g,
|
||||
(m, k) =>
|
||||
{
|
||||
return args[k];
|
||||
}
|
||||
);
|
||||
logPrint(buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -175,7 +173,7 @@ export namespace Live2DCubismFramework
|
|||
{
|
||||
if (i % 16 == 0 && i > 0) this.print(logLevel, "\n");
|
||||
else if (i % 8 == 0 && i > 0) this.print(logLevel, " ");
|
||||
this.print(logLevel, "{0} ", (data[i] & 0xFF));
|
||||
this.print(logLevel, "{0} ", [(data[i] & 0xFF)]);
|
||||
}
|
||||
|
||||
this.print(logLevel, "\n");
|
||||
|
|
|
@ -1,18 +1,19 @@
|
|||
/*
|
||||
* 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 http://live2d.com/eula/live2d-open-software-license-agreement_en.html.
|
||||
*/
|
||||
* 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 http://live2d.com/eula/live2d-open-software-license-agreement_en.html.
|
||||
*/
|
||||
|
||||
import {Live2DCubismFramework as live2dcubismframework, Option as Csm_Option} from "../../../../Framework/live2dcubismframework";
|
||||
import {Live2DCubismFramework as cubismmatrix44} from "../../../../Framework/math/cubismmatrix44";
|
||||
import Csm_CubismMatrix44 = cubismmatrix44.CubismMatrix44;
|
||||
import Csm_CubismFramework = live2dcubismframework.CubismFramework;
|
||||
import { LAppView } from "./lappview";
|
||||
import { LAppPal } from "./lapppal";
|
||||
import { LAppTextureManager } from "./lapptexturemanager";
|
||||
import { LAppLive2DManager } from "./lapplive2dmanager";
|
||||
import {LAppView} from "./lappview";
|
||||
import {LAppPal} from "./lapppal";
|
||||
import {LAppTextureManager} from "./lapptexturemanager";
|
||||
import {LAppLive2DManager} from "./lapplive2dmanager";
|
||||
import {LAppDefine} from "./lappdefine";
|
||||
|
||||
export let canvas: HTMLCanvasElement = null;
|
||||
export let s_instance: LAppDelegate = null;
|
||||
|
@ -271,7 +272,9 @@ export class LAppDelegate
|
|||
public initializeCubism(): void
|
||||
{
|
||||
// setup cubism
|
||||
Csm_CubismFramework.startUp();
|
||||
this._cubismOption.logFunction = LAppPal.printMessage;
|
||||
this._cubismOption.loggingLevel = LAppDefine.CubismLoggingLevel;
|
||||
Csm_CubismFramework.startUp(this._cubismOption);
|
||||
|
||||
// initialize cubism
|
||||
Csm_CubismFramework.initialize();
|
||||
|
|
|
@ -79,7 +79,7 @@ export class LAppPal
|
|||
/\{(\d+)\}/g,
|
||||
(m, k) =>
|
||||
{
|
||||
return args[k];
|
||||
return args[k];
|
||||
}
|
||||
)
|
||||
);
|
||||
|
@ -91,7 +91,7 @@ export class LAppPal
|
|||
*/
|
||||
public static printMessage(message: string): void
|
||||
{
|
||||
this.printLog(message);
|
||||
LAppPal.printLog(message);
|
||||
}
|
||||
|
||||
static lastUpdate = Date.now();
|
||||
|
|
Loading…
Reference in New Issue