PreloadLobbyState.ts 835 B

1234567891011121314151617181920212223242526
  1. import { SceneId } from '../../../framework/scene/SceneNavigator';
  2. import { LaunchContext, LaunchState, LaunchStateId } from './LaunchState';
  3. export class PreloadLobbyState implements LaunchState {
  4. readonly id = LaunchStateId.PreloadLobby;
  5. async enter(context: LaunchContext): Promise<LaunchStateId> {
  6. context.progress({ state: this.id, title: '预加载资源' });
  7. try {
  8. await context.kernel.scenes.preload(SceneId.Lobby);
  9. } catch (error) {
  10. context.error = error;
  11. const retry = await context.dialog({
  12. title: "",
  13. message: '加载失败,是否重试',
  14. lblOK: "重试",
  15. });
  16. if (retry) {
  17. return LaunchStateId.CheckVersion;
  18. }
  19. throw error;
  20. }
  21. context.progress({ state: this.id, progress: 0.9 });
  22. return LaunchStateId.EnterLobby;
  23. }
  24. }