Activate log.

translate
cubism-dev 2019-01-16 17:07:13 +09:00
parent 102eda3c97
commit 0ae2767bda
4 changed files with 91 additions and 66 deletions

View File

@ -5,6 +5,7 @@
* that can be found at http://live2d.com/eula/live2d-open-software-license-agreement_en.html. * 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 cubismjson} from "./utils/cubismjson";
import {Live2DCubismFramework as cubismidmanager} from "./id/cubismidmanager"; import {Live2DCubismFramework as cubismidmanager} from "./id/cubismidmanager";
import {Live2DCubismFramework as cubismrenderer} from "./rendering/cubismrenderer"; import {Live2DCubismFramework as cubismrenderer} from "./rendering/cubismrenderer";
@ -98,7 +99,7 @@ export namespace Live2DCubismFramework
{ {
if(s_isStarted) if(s_isStarted)
{ {
CubismLogInfo("CubismFramework::StartUp() is already done."); CubismLogInfo("CubismFramework.startUp() is already done.");
return s_isStarted; return s_isStarted;
} }
@ -106,7 +107,7 @@ export namespace Live2DCubismFramework
if(s_option != null) if(s_option != null)
{ {
// TODO Core::csmSetLogFunction(s_option->LogFunction); Live2DCubismCore.Logging.csmSetLogFunction(s_option.logFunction);
} }
s_isStarted = true; s_isStarted = true;
@ -114,16 +115,21 @@ export namespace Live2DCubismFramework
// Live2D Cubism Coreバージョン情報を表示 // Live2D Cubism Coreバージョン情報を表示
if(s_isStarted) if(s_isStarted)
{ {
const version: number = 1; // TODO Core::csmGetVersion() const version: number = Live2DCubismCore.Version.csmGetVersion();
const major: number = ((version & 0xFF000000) >> 24); const major: number = ((version & 0xFF000000) >> 24);
const minor: number = ((version & 0x00FF0000) >> 16); const minor: number = ((version & 0x00FF0000) >> 16);
const patch: number = ((version & 0x0000FFFF)); const patch: number = ((version & 0x0000FFFF));
const versionNumber: number = version; 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; return s_isStarted;
} }
@ -158,7 +164,7 @@ export namespace Live2DCubismFramework
// 再度Initialize()するには先にDispose()を実行する必要がある。 // 再度Initialize()するには先にDispose()を実行する必要がある。
if (s_isInitialized) if (s_isInitialized)
{ {
CubismLogWarning("CubismFramework::Initialize() skipped, already initialized."); CubismLogWarning("CubismFramework.initialize() skipped, already initialized.");
return; return;
} }
@ -169,7 +175,7 @@ export namespace Live2DCubismFramework
s_isInitialized = true; s_isInitialized = true;
CubismLogInfo("CubismFramework::Initialize() is complete."); CubismLogInfo("CubismFramework.initialize() is complete.");
} }
/** /**
@ -190,7 +196,7 @@ export namespace Live2DCubismFramework
// dispose()するには先にinitialize()を実行する必要がある。 // dispose()するには先にinitialize()を実行する必要がある。
if(!s_isInitialized) // false...リソース未確保の場合 if(!s_isInitialized) // false...リソース未確保の場合
{ {
CubismLogWarning("CubismFramework::Dispose() skipped, not initialized."); CubismLogWarning("CubismFramework.dispose() skipped, not initialized.");
return; return;
} }
@ -204,9 +210,44 @@ export namespace Live2DCubismFramework
s_isInitialized = false; s_isInitialized = false;
CubismLogInfo("CubismFramework::Dispose() is complete."); CubismLogInfo("CubismFramework.dispose() is complete.");
} }
/**
* Cubism FrameworkAPI使
* @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; return LogLevel.LogLevel_Off;
} }
/**
* Cubism FrameworkAPI使
* @return API使true
*/
public static isStarted(): boolean
{
return s_isStarted;
}
/**
* Cubism Framework
* @return true
*/
public static isInitialized(): boolean
{
return s_isInitialized;
}
/** /**
* ID * ID
* @return CubismManager * @return CubismManager
@ -261,6 +284,7 @@ export namespace Live2DCubismFramework
export class Option export class Option
{ {
logFunction: Live2DCubismCore.csmLogFunction; // ログ出力の関数オブジェクト
loggingLevel: LogLevel; // ログ出力レベルの設定 loggingLevel: LogLevel; // ログ出力レベルの設定
} }

View File

@ -5,16 +5,16 @@
* that can be found at http://live2d.com/eula/live2d-open-software-license-agreement_en.html. * that can be found at http://live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/ */
import {Live2DCubismFramework as live2dcubismframework, LogLevel} from "../live2dcubismframework"; import {Live2DCubismFramework as cubismframework, 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 { 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); 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); CubismLogPrint(level, fmt + "\n", args);
} }
@ -133,32 +133,30 @@ export namespace Live2DCubismFramework
* *
* @param logLevel * @param logLevel
* @param format * @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()) if(logLevel < cubismframework.CubismFramework.getLoggingLevel())
// { {
// return; return;
// } }
// TODO
// const Core::csmLogFunction logPrint = CubismFramework::CoreLogFunction;
// if (!logPrint) const logPrint: Live2DCubismCore.csmLogFunction = cubismframework.CubismFramework.coreLogFunction;
// return;
let buffer: string = format; if (!logPrint)
buffer = buffer.replace( return;
/\{(\d+)\}/g,
(m, k) => // m="{0}", k="0" let buffer: string =
{ format.replace(
return args[k]; /\{(\d+)\}/g,
} (m, k) =>
); {
return args[k];
// logPrint(buffer); }
);
logPrint(buffer);
} }
/** /**
@ -175,7 +173,7 @@ export namespace Live2DCubismFramework
{ {
if (i % 16 == 0 && i > 0) this.print(logLevel, "\n"); if (i % 16 == 0 && i > 0) this.print(logLevel, "\n");
else if (i % 8 == 0 && i > 0) this.print(logLevel, " "); 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"); this.print(logLevel, "\n");

View File

@ -1,18 +1,19 @@
/* /*
* Copyright(c) Live2D Inc. All rights reserved. * Copyright(c) Live2D Inc. All rights reserved.
* *
* Use of this source code is governed by the Live2D Open Software license * 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. * 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 live2dcubismframework, Option as Csm_Option} from "../../../../Framework/live2dcubismframework";
import {Live2DCubismFramework as cubismmatrix44} from "../../../../Framework/math/cubismmatrix44"; import {Live2DCubismFramework as cubismmatrix44} from "../../../../Framework/math/cubismmatrix44";
import Csm_CubismMatrix44 = cubismmatrix44.CubismMatrix44; import Csm_CubismMatrix44 = cubismmatrix44.CubismMatrix44;
import Csm_CubismFramework = live2dcubismframework.CubismFramework; import Csm_CubismFramework = live2dcubismframework.CubismFramework;
import { LAppView } from "./lappview"; import {LAppView} from "./lappview";
import { LAppPal } from "./lapppal"; import {LAppPal} from "./lapppal";
import { LAppTextureManager } from "./lapptexturemanager"; import {LAppTextureManager} from "./lapptexturemanager";
import { LAppLive2DManager } from "./lapplive2dmanager"; import {LAppLive2DManager} from "./lapplive2dmanager";
import {LAppDefine} from "./lappdefine";
export let canvas: HTMLCanvasElement = null; export let canvas: HTMLCanvasElement = null;
export let s_instance: LAppDelegate = null; export let s_instance: LAppDelegate = null;
@ -271,7 +272,9 @@ export class LAppDelegate
public initializeCubism(): void public initializeCubism(): void
{ {
// setup cubism // setup cubism
Csm_CubismFramework.startUp(); this._cubismOption.logFunction = LAppPal.printMessage;
this._cubismOption.loggingLevel = LAppDefine.CubismLoggingLevel;
Csm_CubismFramework.startUp(this._cubismOption);
// initialize cubism // initialize cubism
Csm_CubismFramework.initialize(); Csm_CubismFramework.initialize();

View File

@ -79,7 +79,7 @@ export class LAppPal
/\{(\d+)\}/g, /\{(\d+)\}/g,
(m, k) => (m, k) =>
{ {
return args[k]; return args[k];
} }
) )
); );
@ -91,7 +91,7 @@ export class LAppPal
*/ */
public static printMessage(message: string): void public static printMessage(message: string): void
{ {
this.printLog(message); LAppPal.printLog(message);
} }
static lastUpdate = Date.now(); static lastUpdate = Date.now();