LoadingView.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import LayerManager from "../gui/layers/LayerManager";
  2. export default class LoadingView{
  3. /**
  4. * 进度条
  5. */
  6. private progressBar:fgui.GProgressBar;
  7. /**
  8. * label
  9. */
  10. private label:fgui.GLabel;
  11. /**
  12. * 根节点
  13. */
  14. private root:fgui.GComponent;
  15. /**
  16. * 初始化
  17. * @param root
  18. * @param progressBar
  19. * @param label
  20. */
  21. Init(root:fgui.GComponent,progressBar:fgui.GProgressBar,label?:fgui.GLabel):void{
  22. this.root=root;
  23. this.progressBar=progressBar;
  24. this.label=label;
  25. if(this.progressBar!=null){
  26. this.progressBar.min=0;
  27. this.progressBar.max=1;
  28. }
  29. }
  30. /**
  31. * 更新进度
  32. * @param progress
  33. */
  34. UpdateProgress(progress:number):void{
  35. if(this.progressBar!=null){
  36. this.progressBar.value=progress;
  37. }
  38. }
  39. /**
  40. * 更新文本
  41. * @param label
  42. */
  43. UpdateLabel(label:string):void{
  44. if(this.label!=null){
  45. this.label.text=label;
  46. }
  47. }
  48. Show():void{
  49. LayerManager.single.AddToLayer(9,this.root);
  50. }
  51. Hide():void{
  52. LayerManager.single.RemoveFormeLayer(9,this.root);
  53. }
  54. private static instance:LoadingView;
  55. public static get single(){
  56. if(this.instance==null){
  57. this.instance=new LoadingView();
  58. }
  59. return this.instance;
  60. }
  61. }