RuleUI.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /** @format */
  2. import {BaseUI} from '../BaseUI'
  3. import {UI} from '../../enums/UI'
  4. import {node, observer} from '../../mobx/observer'
  5. import {Mgr} from '../../GameControl'
  6. import {FunctionsConfig} from '../../config/FunctionsConfig'
  7. import {ccUtils} from '../../utils/ccUtils'
  8. import {IRule} from '../../interface/UIInterface'
  9. import {LANGUAGE_TYPE} from '../../enums/Enum'
  10. const {ccclass, property} = cc._decorator
  11. @ccclass
  12. @observer
  13. export class RuleUI extends BaseUI {
  14. @node('scrollView/view/content/lb')
  15. ruleText: cc.Node
  16. fixedWidth: number = 1200
  17. onShow(args: UI | IRule, fromUI: number) {
  18. let ruleStr = ''
  19. ccUtils.setLabel(LANGUAGE_TYPE.rules, this.node, 'title/lb')
  20. if (args) {
  21. if (typeof args == 'number') {
  22. ruleStr = Mgr.i18n.getLabel(FunctionsConfig[args]?.rule)
  23. } else {
  24. ccUtils.setLabel(args.title, this.node, 'title/lb')
  25. ruleStr = Mgr.i18n.getLabel(args.content)
  26. }
  27. }
  28. //ccUtils.setLabel(FunctionsConfig[args]?.rule, this.ruleText)
  29. let linesArray = ruleStr.split('\n')
  30. let labelNode = ccUtils.instantChildren(this.ruleText, linesArray.length)
  31. for (let i = 0; i < linesArray.length; i++) {
  32. ccUtils.setLabel(linesArray[i], labelNode[i])
  33. }
  34. }
  35. onHide(): any {}
  36. //UI或者其他函数=======================================
  37. //网络事件=======================================
  38. // 点击事件=======================================
  39. }