12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- import { GameUILayers, gui, ui_base } from "../../core/ui/ui";
- import { ModuleDef } from "../../scripts/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;
- }
- }
|