Commit ae4bc527 authored by 任建锋's avatar 任建锋

update some code

parent 1f26f494
import {AnimationGui} from "../others/AnimationGui";
import {SceneManager} from "../manager/SceneManager";
import {GuiCreate} from "../others/GuiCreate";
import { YtLang } from '../util/YtLang';
/**
*Created by cuiliqiang on 2018/3/1
* 组件基类
*/
import {GuiManager} from "../manager/GuiManager";
export class Module {
private timeoutId;
protected view:any;
protected parent:any;
//事件
protected doEvents=[];
//面板隐藏显示实例
protected panelsAn=new AnimationGui(SceneManager.ins.scene,GuiManager.ins.fullscreenUI)
//规则元素
protected section: any;
/**
* 显示对象(皮肤)
*/
protected display: any;
/**
* 是否初始化完成
*/
protected isInit: boolean;
/**
* 点击事件回调池
*/
private clickCallbackBindPool: any;
constructor() {
this.initModel();
this.clickCallbackBindPool = {};
// var skinClass: any = eval(this.module.skinName);
// this.display = new skinClass();
// this.clickCallbackPool = {};
}
/**
* 初始化数据
*/
protected initModel(): void {
}
/**
* 初始化UI
*/
protected initUI(): void {
}
/**
* 显示
*/
protected show(...args): void {
this.removeEvent();
this.updateData(...args)
this.addEvent();
GuiManager.ins.changeGui(this.parent);
}
/**
* 隐藏
*/
protected hide(): void {
this.removeEvent();
GuiManager.ins.removeGui(this.parent);
}
/**
* 添加事件
*/
protected addEvent(): void {
}
/**
* 移除事件
*/
protected removeEvent(): void {
}
/**
* 更新页面
* @param args
*/
public updateData(...args): void {
if (!this.isInit) {
this.initUI();
this.isInit = true;
}
}
/**
* 添加点击事件
* @param display
*
* @param callback
*/
protected addClick(display: any, callback: Function) {
this.doEvents[display.name] = display.onPointerUpObservable.add(callback);
}
/**
* 移除点击事件
* @param display
* @param callback
*/
protected removeClick(display: any): void {
display.onPointerUpObservable.remove(this.doEvents[display.name]);
}
/**
* 延时启用点击事件
* @param display 显示对象
* @param {number} delay 延时事件
*/
protected delayEnable(display: any, delay?: number): void {
display.mouseEnable = display.mouseChildren = false;
//如果已经禁用事件重新计算
if (this.timeoutId) {
clearTimeout(this.timeoutId);
}
this.timeoutId = setTimeout(function () {
this.timeoutId = 0;
display.mouseEnable = display.mouseChildren = true;
}, delay ? delay : 500);
}
//dom模板
protected viewNode;
//页面HTML模板
protected listTemplateHtml(data,config){
}
//html页面对象
protected htmlView;
protected htmlCreate(config,data){
this.listTemplateHtml(data,config)
document.body.appendChild(this.viewNode);
GuiCreate.ins.preventDefault(this.viewNode)
}
public dispose(): void {
}
/**
* 鼠标事件
* @param enable
*/
protected enableMouseEvt(enable: boolean): void {
let viewList
for(viewList in this.view){
// console.log(viewList)
if(this.view[viewList]["mouseEnable"]==1||this.view[viewList]["mouseEnable"]==undefined){
this.view[viewList].isHitTestVisible=enable;
}
}
}
/**
* 单个元件鼠标事件
* @param enable
*/
protected enableMouseEvtView(view:BABYLON.GUI.Control,enable: boolean): void {
view.isHitTestVisible=enable;
if(enable==true){
view["mouseEnable"]=1;
}else{
view["mouseEnable"]=2;
}
}
}
\ No newline at end of file
{"version":3,"file":"Module.js","sourceRoot":"","sources":["../../src/module/Module.ts"],"names":[],"mappings":";;AACA,uDAAoD;AACpD,wDAAqD;AACrD,iDAA8C;AAE9C;;;GAGG;AACH,oDAAiD;AAEjD;IAgCI;QAtBC,IAAI;QACM,aAAQ,GAAC,EAAE,CAAC;QAEpB,UAAU;QACH,aAAQ,GAAC,IAAI,2BAAY,CAAC,2BAAY,CAAC,GAAG,CAAC,KAAK,EAAC,uBAAU,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;QAmBnF,IAAI,CAAC,SAAS,EAAE,CAAC;QACjB,IAAI,CAAC,qBAAqB,GAAG,EAAE,CAAC;QAClC,oDAAoD;QACnD,kCAAkC;QAClC,+BAA+B;IAClC,CAAC;IAEC;;KAEC;IACO,0BAAS,GAAnB;IAEA,CAAC;IAED;;OAEG;IACO,uBAAM,GAAhB;IAEA,CAAC;IAEJ;;aAES;IACI,qBAAI,GAAd;QAAe,cAAO;aAAP,UAAO,EAAP,qBAAO,EAAP,IAAO;YAAP,yBAAO;;QAClB,IAAI,CAAC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C,CAAA;QAClC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACzC,qBAAS,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAC/C,CAAC;IAIM,wBAAO,GAAd;IAEA,CAAC;IAEC;;;KAGC;IACO,+BAAc,GAAxB,UAAyB,MAAe;QACpC,IAAI,QAAQ,CAAA;QACZ,KAAI,QAAQ,IAAI,IAAI,CAAC,IAAI,EAAC;YACvB,wBAAwB;YACxB,IAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,aAAa,CAAC,IAAE,CAAC,IAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,aAAa,CAAC,IAAE,SAAS,EAAC;gBACrF,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,gBAAgB,GAAC,MAAM,CAAC;aAC9C;SACH;IACL,CAAC;IAGC;;;KAGC;IACO,mCAAkB,GAA5B,UAA6B,IAAwB,EAAC,MAAe;QACjE,IAAI,CAAC,gBAAgB,GAAC,MAAM,CAAC;QAC7B,IAAG,MAAM,IAAE,IAAI,EAAC;YACZ,IAAI,CAAC,aAAa,CAAC,GAAC,CAAC,CAAC;SACzB;aAAI;YACD,IAAI,CAAC,aAAa,CAAC,GAAC,CAAC,CAAC;SACzB;IACL,CAAC;IACL,aAAC;AAAD,CAAC,AAzLD,IAyLC;AAzLY,wBAAM"}
\ No newline at end of file \ No newline at end of file
...@@ -152,12 +152,17 @@ export class Module { ...@@ -152,12 +152,17 @@ export class Module {
} }
//html页面对象
protected htmlView;
protected htmlCreate(config,data){ protected htmlCreate(config,data){
this.listTemplateHtml(data,config) this.listTemplateHtml(data,config)
document.body.appendChild(this.viewNode); document.body.appendChild(this.viewNode);
GuiCreate.ins.preventDefault(this.viewNode) GuiCreate.ins.preventDefault(this.viewNode)
} }
public dispose(): void { public dispose(): void {
} }
......
...@@ -69,6 +69,7 @@ export declare class Module { ...@@ -69,6 +69,7 @@ export declare class Module {
protected delayEnable(display: any, delay?: number): void; protected delayEnable(display: any, delay?: number): void;
protected viewNode: any; protected viewNode: any;
protected listTemplateHtml(data: any, config: any): void; protected listTemplateHtml(data: any, config: any): void;
protected htmlView: any;
protected htmlCreate(config: any, data: any): void; protected htmlCreate(config: any, data: any): void;
dispose(): void; dispose(): void;
/** /**
......
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