Commit 8bd346c5 authored by rockyl's avatar rockyl

DataInput修复

parent 88b0d47d
...@@ -45,6 +45,7 @@ declare const args: any; ...@@ -45,6 +45,7 @@ declare const args: any;
declare const props: any; declare const props: any;
declare const target: engine.Container; declare const target: engine.Container;
declare const global: any; declare const global: any;
declare const vm: engine.VM;
declare function next(type: string, payload?: any); declare function next(type: string, payload?: any);
......
...@@ -608,6 +608,10 @@ export class DisplayObject extends EventDispatcher { ...@@ -608,6 +608,10 @@ export class DisplayObject extends EventDispatcher {
* 更新方法,帧循环的监听事件放在这 * 更新方法,帧循环的监听事件放在这
*/ */
public update(deltaTime: number) { public update(deltaTime: number) {
//监听的
if (this.hasEventListener(Event.ENTER_FRAME)) {
this.dispatchEvent(Event.ENTER_FRAME, deltaTime);
}
} }
} }
/** /**
......
...@@ -92,9 +92,10 @@ export class Process { ...@@ -92,9 +92,10 @@ export class Process {
let metaConfig = this._meta; let metaConfig = this._meta;
if (metaConfig) { if (metaConfig) {
if (metaConfig.script) { if (metaConfig.script) {
let func = new Function('args', 'props', 'target', 'global', warpAsyncScript(metaConfig.script)); let func = new Function('args', 'props', 'target', 'global', 'vm', warpAsyncScript(metaConfig.script));
this.updateProps(payload); this.updateProps(payload);
result = await func(payload, this._config.props, this._target, this._vm.getGlobalContext()); let globalContext = this._vm.globalContext;
result = await func(payload, this._config.props, this._target, globalContext, this._vm);
} }
} else { } else {
console.warn(`process meta [${meta}] not found`) console.warn(`process meta [${meta}] not found`)
...@@ -173,7 +174,8 @@ export class Process { ...@@ -173,7 +174,8 @@ export class Process {
updateProps(args) { updateProps(args) {
if (this._originProps) { if (this._originProps) {
let props = this._config.props; let props = this._config.props;
for (let key in props) { let propsConfig = this._meta.props;
for (let key in propsConfig) {
let value = this._originProps[key]; let value = this._originProps[key];
const valueType = typeof value; const valueType = typeof value;
if (valueType == 'object') { if (valueType == 'object') {
...@@ -191,15 +193,20 @@ export class Process { ...@@ -191,15 +193,20 @@ export class Process {
props[key] = args ? getDataByPath(args, value.value) : undefined; props[key] = args ? getDataByPath(args, value.value) : undefined;
break; break;
case 'data-center': case 'data-center':
props[key] = dataCenter.getDataByPath(value.value); let nameValue = dataCenter.getDataByName(value.value);
props[key] = nameValue !== undefined ? nameValue : dataCenter.getDataByPath(value.value);
break; break;
} }
} else if (value && value.indexOf && value.indexOf(nodeScheme) === 0) { } else if (value && value.indexOf && value.indexOf(nodeScheme) === 0) {
let uuid = value.replace(nodeScheme, ''); let uuid = value.replace(nodeScheme, '');
if (uuid) { if (uuid) {
props[key] = findNodeByUUID(this._vm.getGlobalContext().gameStage, uuid); props[key] = findNodeByUUID(this._vm.globalContext.gameStage, uuid);
} }
} }
if(props[key] === undefined && propsConfig[key].hasOwnProperty('default')){
props[key] = propsConfig[key]['default'];
}
} }
} }
} }
......
...@@ -5,10 +5,13 @@ ...@@ -5,10 +5,13 @@
import {Process} from "./Process"; import {Process} from "./Process";
import {arrayFind} from "../utils"; import {arrayFind} from "../utils";
let ID_INK = 0;
export class VM { export class VM {
_processMetaLibs; _processMetaLibs;
_globalContext; _globalContext;
_target; _target;
_id;
setup(context) { setup(context) {
const {processMetaLibs, globalContext, target} = context; const {processMetaLibs, globalContext, target} = context;
...@@ -16,6 +19,7 @@ export class VM { ...@@ -16,6 +19,7 @@ export class VM {
this._processMetaLibs = processMetaLibs; this._processMetaLibs = processMetaLibs;
this._globalContext = globalContext; this._globalContext = globalContext;
this._target = target; this._target = target;
this._id = ID_INK++;
} }
async executeProcess(sequence, id, parentProcess, args) { async executeProcess(sequence, id, parentProcess, args) {
...@@ -40,7 +44,11 @@ export class VM { ...@@ -40,7 +44,11 @@ export class VM {
} }
} }
getGlobalContext(){ get globalContext() {
return this._globalContext; return this._globalContext;
} }
get id() {
return this._id;
}
} }
...@@ -38,9 +38,9 @@ export class GameStage extends Container { ...@@ -38,9 +38,9 @@ export class GameStage extends Container {
let blackLayer = this._blackLayer = new Rect(); let blackLayer = this._blackLayer = new Rect();
this.addChild(this._sceneContainer = new StackContainer(false)); this.addChild(this._sceneContainer = new StackContainer());
this.addChild(blackLayer); this.addChild(blackLayer);
this.addChild(this._popupContainer = new StackContainer()); this.addChild(this._popupContainer = new StackContainer(false));
blackLayer['percentWidth'] = 100; blackLayer['percentWidth'] = 100;
blackLayer['percentHeight'] = 100; blackLayer['percentHeight'] = 100;
......
...@@ -52,6 +52,16 @@ export class DataCenter extends EventDispatcher { ...@@ -52,6 +52,16 @@ export class DataCenter extends EventDispatcher {
return getDataByPath(this.store, path, throwException); return getDataByPath(this.store, path, throwException);
} }
/**
* 根据绑定名获取数据
* @param name
* @param throwException
*/
getDataByName(name, throwException?) {
let watcher = this.getWatcher(name);
return getDataByPath(this.store, watcher.path, throwException);
}
/** /**
* 填充数据 * 填充数据
* @param str * @param str
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment