chat_text_cell.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { _decorator, Component, Node, Label, Color } from 'cc';
  2. import { ClientEvent } from '../clientEvent';
  3. import { Constant } from '../constant';
  4. import { GameMng } from '../GameMng';
  5. import { UIButton } from '../gcommon/UIButton';
  6. import { msgManager } from '../socket/msgManager';
  7. const { ccclass, property } = _decorator;
  8. @ccclass('chat_text_cell')
  9. export class chat_text_cell extends Component {
  10. @property(Node)
  11. lab_str: Node = null; //
  12. text:string = ""
  13. id:string = ""
  14. start() {
  15. UIButton.BindClick(this.node,()=>{
  16. if( this.id !=""){
  17. msgManager.send_chat(this.id,this.text)
  18. ClientEvent.dispatchEvent(Constant.UI_EVENT.UI_MSG_BTN_HIDE_CHAT)
  19. }
  20. },this)
  21. }
  22. show(id:string,str:string){
  23. let user_name = str.split(":")[0];
  24. var color = new Color()
  25. if(user_name===GameMng._userData.user_name){
  26. this.lab_str.getComponent(Label).color = color.fromHEX("#FFFFFF")
  27. }else{
  28. this.lab_str.getComponent(Label).color = color.fromHEX("#9BA3DD")
  29. }
  30. this.text = str;
  31. this.id = id;
  32. this.lab_str.getComponent(Label).string = str;
  33. }
  34. update(deltaTime: number) {
  35. }
  36. }