| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257 |
- cc.Class({
- extends: cc.BaseControl,
- properties: {
- m_HOOK: cc.Component,
- m_ResponseNode: cc.Node,
- m_ResponseComName: cc.String,
- m_WoShiFenGeXian: cc.String,
- ////////////////////////////////////////////
- m_LabCustom: [cc.Label],
- m_Label: cc.Label,
- m_EditBox: cc.EditBox,
- m_WoShiFenGeXian1: cc.String,
- ////////////////////////////////////////////
- m_btClose: cc.Button,
- m_btOK: cc.Button,
- m_btNO: cc.Button,
- m_btNoClick: cc.Button,
- m_WoShiFenGeXian2: cc.String,
- ////////////////////////////////////////////
- m_SwitchToggleNode: cc.Node,
- m_SwitchToggleArray: [cc.Toggle],
- m_SwitchButtonNode: cc.Node,
- m_SwitchButtonArray: [cc.Button],
- m_SwitchPageNode: cc.Node,
- m_PageArray: [cc.Node],
- },
- ctor: function () {},
- onLoad: function () {
- },
- start: function () {
- var cbIndex = 0;
- if (this.m_SwitchToggleNode) {
- this.m_SwitchToggleArray = new Array();
- this.TraverseNode({
- ContentArray: this.m_SwitchToggleArray,
- SouceNode: this.m_SwitchToggleNode,
- SearchCom: cc.Toggle,
- HandlerComponet: null,
- HandlerFunc: null,
- CustomData: null,
- });
- }
- for (var i = 0; i < this.m_SwitchToggleArray.length; ++i) {
- this.AddClickHandler(this.m_SwitchToggleArray[i], this.node, 'CustomPage', 'OnButtonClickedSwitchPage', cbIndex);
- ++cbIndex;
- }
- if (this.m_SwitchButtonNode) {
- this.m_SwitchButtonArray = new Array();
- this.TraverseNode({
- ContentArray: this.m_SwitchButtonArray,
- SouceNode: this.m_SwitchButtonNode,
- SearchCom: cc.Button,
- HandlerComponet: null,
- HandlerFunc: null,
- CustomData: null,
- });
- }
- for (var i = 0; i < this.m_SwitchButtonArray.length; ++i) {
- this.AddClickHandler(this.m_SwitchButtonArray[i], this.node, 'CustomPage', 'OnButtonClickedSwitchPage', cbIndex);
- ++cbIndex;
- }
- if (this.m_SwitchPageNode) {
- this.m_PageArray = new Array();
- for (var i = 0; i < this.m_SwitchPageNode.childrenCount; ++i) {
- this.m_PageArray[i] = this.m_SwitchPageNode.getChildByName('' + i);
- }
- }
- if (this.m_SwitchToggleArray.length > 0) this.UpdateSwitchPage(0, 0);
- if (this.m_SwitchButtonArray.length > 0) this.UpdateSwitchPage(0, 0);
- },
- SetAttribute2: function () {
- // SetOK: {
- // _active: true,
- // _enable: true,
- // _valid: true,
- // _hook: this,
- // _callback: null,
- // _event: {
- // _target: null,
- // _component: null,
- // _handler: null,
- // _CustomData: null
- // }
- // },
- if (this.m_btClose) {
- if (this.m_Attribute.SetClose) {
- this.AddClickHandler(this.m_btClose, this.node, 'CustomPage', 'OnButtonClickedClose');
- if (this.m_Attribute.SetClose._event && this.m_Attribute.SetClose._event._target &&
- this.m_Attribute.SetClose._event._component && this.m_Attribute.SetClose._event._handler) {
- this.AddClickHandler(this.m_btClose, this.m_Attribute.SetClose._event._target,
- this.m_Attribute.SetClose._event._component, this.m_Attribute.SetClose._event._handler);
- }
- if (this.m_Attribute.SetClose._active) this.m_btClose.node.active = true;
- else this.m_btClose.node.active = false;
- } else {}
- }
- if (this.m_btOK) {
- if (this.m_Attribute.SetOK) {
- this.AddClickHandler(this.m_btOK, this.node, 'CustomPage', 'OnButtonClickedOK');
- if (this.m_Attribute.SetOK._event && this.m_Attribute.SetOK._event._target &&
- this.m_Attribute.SetOK._event._component && this.m_Attribute.SetOK._event._handler) {
- this.AddClickHandler(this.m_btOK, this.m_Attribute.SetOK._event._target,
- this.m_Attribute.SetOK._event._component, this.m_Attribute.SetOK._event._handler,
- this.m_Attribute.SetOK._event._customData
- );
- }
- if (this.m_Attribute.SetOK._active) this.m_btOK.node.active = true;
- else
- this.m_btOK.node.active = false;
- } else {}
- }
- if (this.m_btNO) {
- if (this.m_Attribute.SetNO) {
- this.AddClickHandler(this.m_btNO, this.node, 'CustomPage', 'OnButtonClickedNO');
- if (this.m_Attribute.SetNO._event && this.m_Attribute.SetNO._event._target &&
- this.m_Attribute.SetNO._event._component && this.m_Attribute.SetNO._event._handler) {
- this.AddClickHandler(this.m_btNO, this.m_Attribute.SetNO._event._target,
- this.m_Attribute.SetNO._event._component, this.m_Attribute.SetNO._event._handler);
- }
- if (this.m_Attribute.SetNO._active) this.m_btNO.node.active = true;
- else this.m_btNO.node.active = false;
- } else {}
- }
- if (this.m_btNoClick) {
- if (this.m_Attribute.SetBGClose) {
- this.m_btNoClick.node.active = true;
- this.AddClickHandler(this.m_btNoClick, this.node, 'CustomPage', 'OnButtonClickedBG');
- if (this.m_Attribute.SetBGClose._event && this.m_Attribute.SetBGClose._event._target &&
- this.m_Attribute.SetBGClose._event._component && this.m_Attribute.SetBGClose._event._handler) {
- this.AddClickHandler(this.m_btNoClick, this.m_Attribute.SetBGClose._event._target,
- this.m_Attribute.SetBGClose._event._component, this.m_Attribute.SetNO._event._handler);
- }
- if (this.m_Attribute.SetBGClose._active) this.m_btNoClick.node.active = true;
- else this.m_btNoClick.node.active = false;
- } else {
- }
- }
- },
- SetString: function (szText) {
- console.log(szText);
- this.m_Label.string = szText;
- },
- GetEditBoxString: function () {
- if (this.m_EditBox) return this.m_EditBox.string;
- return '';
- },
- OnButtonClickedClose: function () {
- this.HidePage();
- },
- OnButtonClickedOK: function () {
- if(this.m_Attribute.SetOK._valid) this.HidePage();
- if (this.m_HOOK && this.m_HOOK.OnOKCallback) {
- this.m_HOOK.OnOKCallback(this);
- }
- if (this.m_Attribute.SetOK._hook && this.m_Attribute.SetOK._hook[this.m_Attribute.SetOK._callback]) {
- this.m_Attribute.SetOK._hook[this.m_Attribute.SetOK._callback](this);
- }
- },
- OnButtonClickedNO: function () {
- this.HidePage();
- },
- OnButtonClickedBG: function (event, customData) {
- if (customData == 1 || this.m_Attribute.SetBGClose._valid) {
- this.HidePage();
- }
- },
- HidePage: function () {
- if (this.m_ResponseNode instanceof cc.Node) {
- var pCom = this.$('@' + this.m_ResponseComName, this.m_ResponseNode);
- if(pCom && pCom.HideView) pCom.HideView();
- else this.m_ResponseNode.active = false;
- } else {
- this.node.active = false;
- }
- },
- ///////////////////////////////////////////////////
- SetCustomText: function (szText, ColorArray, ActiveArray) {
- if (!this.m_LabCustom) return;
- for (var i = 0; i < this.m_LabCustom.length; ++i) {
- this.m_LabCustom[i].string = ''
- if (Array.isArray(szText)) this.m_LabCustom[i].string = szText[i];
- else this.m_LabCustom[i].string = szText;
- if (ColorArray && ColorArray[i]) {
- this.m_LabCustom[i].node.color = ColorArray[i];
- }
- if (ActiveArray) {
- this.m_LabCustom[i].node.active = ActiveArray[i];
- }
- }
- },
- ///////////////////////////////////////////////////
- OnButtonClickedSwitchPage: function (event, customData) {
- this.UpdateSwitchPage(event, customData);
- },
- UpdateSwitchPage: function (event, customData) {
- if (!this.m_PageArray || !Array.isArray(this.m_PageArray)) return;
- for (var i = 0; i < this.m_PageArray.length; ++i) {
- if (this.m_PageArray[i]) {
- if (customData == i) {
- this.m_PageArray[i].active = true;
- this.ButtonCheck(event.target, true);
- if(this.m_HOOK && this.m_HOOK.OnChangePage) this.m_HOOK.OnChangePage(i, this.m_PageArray[i]);
- } else {
- this.m_PageArray[i].active = false;
- this.ButtonCheck(event.target, false);
- }
- }
- }
- },
- ButtonCheck: function(target, bCheck) {
- for(var i in this.m_SwitchButtonArray) {
- if (this.m_SwitchButtonArray[i] && this.m_SwitchButtonArray[i].node == target) {
- var pCheck = this.m_SwitchButtonArray[i].node.getChildByName('check');
- if (pCheck) pCheck.active = bCheck;
- }
- }
- },
- ///////////////////////////////////////////////////
- });
|