BasicView.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import EventManager from "../Event/EventManager";
  2. import { EventName } from "../Event/EventName";
  3. import Tool from "../Tool/Tool";
  4. import BasicObject from "./BasicObject";
  5. /**
  6. * 基础视窗 - 表现层
  7. */
  8. export default abstract class BasicView extends BasicObject {
  9. /**资源路径 */
  10. public static readonly resPath: string;
  11. /**fgui节点 */
  12. public fgui: fgui.GComponent;
  13. /**初始化视窗 */
  14. public initView (fgui: fgui.GComponent, data: any): void {
  15. this.fgui = fgui;
  16. this.customData = data;
  17. this.resize();
  18. this._initView();
  19. EventManager.onEvent(EventName.Time.Time_Pause, this, this.pauseView);
  20. EventManager.onEvent(EventName.Time.Time_Resume, this, this.resumeView);
  21. }
  22. /**刷新视窗,创建时不会调佣 */
  23. public refreshView (): void{
  24. this._refreshView();
  25. }
  26. /**清理视窗 */
  27. public clearView (): void{
  28. this._clearView();
  29. }
  30. /**初始化视窗 */
  31. protected abstract _initView (): void;
  32. /**刷新视窗,创建时不会调佣 */
  33. protected abstract _refreshView (): void;
  34. /**清理视窗 */
  35. protected abstract _clearView (): void;
  36. /**暂停窗口 */
  37. protected pauseView (): void {
  38. }
  39. /**恢复窗口 */
  40. protected resumeView (): void {
  41. }
  42. /**适配窗口 */
  43. protected resize () {
  44. }
  45. _destroy (): void {
  46. Tool.Tool2D.Button.removeEvent(null, this.fgui.id);
  47. super._destroy();
  48. this.node.destroy();
  49. }
  50. }