123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- import { _decorator, assetManager, Component, ImageAsset, Label, Node, Sprite, SpriteFrame, Texture2D, Toggle } from 'cc';
- import { event_item, event_item_show_question_select_item, ui_att_item } from '../../../data/data';
- import { tools } from '../../tools';
- import { Attributes } from '../Attributes';
- const { ccclass, property } = _decorator;
- @ccclass('show_question_select_item')
- export class show_question_select_item extends Component {
- private m_data:ui_att_item = null;
- @property(Node) img_icon:Node = null;
- @property(Node) btn_add_event:Node = null;
- @property(Node) lab_cur_event_id:Node = null;
- @property(Node) toggle_is_right:Node = null;
- private m_event_item_show_question_select_item:event_item_show_question_select_item = null;
- public initView(data:ui_att_item,event_data:event_item_show_question_select_item){
- this.m_data = data;
- this.m_event_item_show_question_select_item = event_data;
- if(this.m_data.res.length>0){
- assetManager.loadRemote<ImageAsset>(this.m_data.res, (err, imageAsset2)=>{
- if (!err && imageAsset2) {
- const texture = new Texture2D();
- texture.image = imageAsset2;
- let spFrame2 = new SpriteFrame();
- spFrame2.texture = texture;
- this.img_icon.getComponent(Sprite).spriteFrame = spFrame2
- }
- });
- }
- this.btn_add_event.on(Node.EventType.TOUCH_END,()=>{
- let list = Attributes.Singleton.getEventList()
- tools.show_select_evele_list(list,(data:event_item)=>{
- this.m_event_item_show_question_select_item.binding_event_id = data.event_id;
- this.updateStatus()
- })
- })
- // this.toggle_is_right.on(Node.EventType.TOUCH_END,()=>{
- // this.m_event_item_show_question_select_item.isRight = this.toggle_is_right.getComponent(Toggle).isChecked
- // })
- this.updateStatus()
- }
- updateStatus(){
- // this.toggle_is_right.getComponent(Toggle).isChecked = this.m_event_item_show_question_select_item.isRight
- if(this.m_event_item_show_question_select_item.binding_event_id==-1){
- this.lab_cur_event_id.getComponent(Label).string = "添加事件"
- }else{
- this.lab_cur_event_id.getComponent(Label).string = `事件ID:${this.m_event_item_show_question_select_item.binding_event_id}`
- }
- }
- }
|