LoadingView.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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.root.setSize(fgui.GRoot.inst.width,fgui.GRoot.inst.height);
  24. this.progressBar=progressBar;
  25. this.label=label;
  26. if(this.progressBar!=null){
  27. this.progressBar.min=0;
  28. this.progressBar.max=1;
  29. }
  30. }
  31. /**
  32. * 更新进度
  33. * @param progress
  34. */
  35. UpdateProgress(progress:number):void{
  36. if(this.progressBar!=null){
  37. this.progressBar.value=progress;
  38. }
  39. }
  40. /**
  41. * 更新文本
  42. * @param label
  43. */
  44. UpdateLabel(label:string):void{
  45. if(this.label!=null){
  46. this.label.text=label;
  47. }
  48. }
  49. Show():void{
  50. LayerManager.single.AddToLayer(9,this.root);
  51. }
  52. Hide():void{
  53. LayerManager.single.RemoveFormeLayer(9,this.root);
  54. }
  55. private static instance:LoadingView;
  56. public static get single(){
  57. if(this.instance==null){
  58. this.instance=new LoadingView();
  59. }
  60. return this.instance;
  61. }
  62. }