Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

Commit

Permalink
feat: config
Browse files Browse the repository at this point in the history
update config structure
  • Loading branch information
xiazeyu committed Jan 1, 2018
1 parent 5f13a2b commit 62118e1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/cLive2DApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
ParamID
} from './lib/live2d.min';*/
import './lib/live2d.min.js';
import { config }from './lib/configManager.js';
import { createCanvas, initCanvas } from "./lib/canvasManager";
import { device } from 'current-device';
import { L2DTargetPoint, L2DViewMatrix, L2DMatrix44 } from "./lib/Live2DFramework";
Expand All @@ -40,8 +41,7 @@ let opacityDefault = 0.7;
let opacityHover = 1;

export default () => {
console.log('Finally!~');
Live2D.init();
console.log(config);
/*
headPos = typeof iHeadPos === 'undefined' ? 0.5 : iHeadPos;
opacityDefault = typeof iOpacityDefault === 'undefined' ? 0.7 : iOpacityDefault;
Expand Down
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
'use strict';

import device from 'current-device';
import config from './lib/configManager.js';
import { config, applyConfig }from './lib/configManager.js';

/**
* The public entry point
Expand All @@ -26,12 +26,12 @@ export function init(userConfig){
console.log('Hey that, you are now in DEV MODE.');
}
try{
config.applyConfig(userConfig);
applyConfig(userConfig);
}catch(err){
console.error(err);
}

if((!config.options.mobile.show)&&(device.mobile())){
if((!config.mobile.show)&&(device.mobile())){
return;
}

Expand Down
18 changes: 6 additions & 12 deletions src/lib/configManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,20 @@ const defaultOptions = {
debug: {
log: false,
mouseLog: false,
mouseFunc: () => {console.log('(undefined) ┑( ̄Д  ̄)┍');}, // only works when debug.mouseLog is on
mouseFunc: (x, y) => {console.log(`MouseFunc: ${x},${x}`);}, // only works when debug.mouseLog is on
},
checked: false,
checked: true,
}

function applyConfig(inUserConfig){
checkUserConfig(inUserConfig);
currConfig = Object.assign(
{},
defaultOptions,
inUserConfign,
);
if (!!!inUserConfig.checked) checkUserConfig(inUserConfig);
// TBD.
}

function checkUserConfig(inUserConfig){
if(( this.position != 'left' ) && ( this.position != 'right' )){
console.error('L2D: Invalid position setting');
}
// TBD.
}
export {
applyConfig,
currConfig,
currConfig as config,
}

0 comments on commit 62118e1

Please sign in to comment.