| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- import { GameUILayers, gui, ui_base } from "../../core/ui/ui";
- import { ModuleDef } from "../../Script/ModuleDef";
- import { Layout_UIWaiting } from "./Layout_UIWaiting";
- const loadingTxtArr = ['.', '..', '...'];
- let _inst: UIWaiting = null;
- export class UIWaiting extends ui_base {
- private _contentStr: string = 'Loading';
- constructor(){
- super(ModuleDef.BASIC,'ui_waiting/UI_Waiting',GameUILayers.LOADING,Layout_UIWaiting);
- }
- protected onCreated(): void {
- }
-
- public static show(contentStr?: string): UIWaiting {
- if (!_inst) {
- gui.show(UIWaiting).then((ui)=>{
- _inst=ui;
- });
- }
- _inst._contentStr = contentStr || 'Loading';
- return _inst;
- }
- public static hide(): void {
- if (_inst) {
- _inst.close();
- _inst = null;
- }
- }
- protected onUpdate() {
- let layout = this.layout as Layout_UIWaiting;
- if (layout.loadingIcon) {
- let euler = layout.loadingIcon.eulerAngles;
- let rot = (Date.now() / 1000) * 90;
- layout.loadingIcon.setRotationFromEuler(euler.x, euler.y, rot);
- }
- if (layout.loadingTxt) {
- let idx = Math.floor(Date.now() / 500) % 3;
- layout.loadingTxt.string = this._contentStr + loadingTxtArr[idx];
- }
- }
- onDispose() {
- _inst = null;
- }
- }
|