Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// <reference path='../index.d.ts'/>
- import {ResourcesQueue} from "../resources/mainGame/ResourcesQueue";
- import {C} from "../C";
- import {RecamelCore} from "../../src.framework/net/retrocade/camel/core/RecamelCore";
- import {TStatePreloader} from "../game/states/TStatePreloader";
- import {DROD} from "../game/global/DROD";
- import {RecamelLang} from "../../src.framework/net/retrocade/camel/RecamelLang";
- import {Core} from "../game/global/Core";
- import {TStateInitialize} from "../game/states/TStateInitialize";
- import {PlatformOptions} from "../platform/PlatformOptions";
- import {Gfx} from "../game/global/Gfx";
- import {TStateTitle} from "../game/states/TStateTitle";
- import {Achievements} from "../game/achievements/Achievements";
- import {RecamelTooltip} from "../../src.framework/net/retrocade/camel/core/RecamelTooltip";
- import {Make} from "../game/global/Make";
- import {DrodInput} from "../game/global/DrodInput";
- import {TWidgetScroll} from "../game/widgets/TWidgetScroll";
- import {TWidgetLevelName} from "../game/widgets/TWidgetLevelName";
- import {TWidgetClock} from "../game/widgets/TWidgetClock";
- import {TWidgetMoveCounter} from "../game/widgets/TWidgetMoveCounter";
- import {Helper} from "../game/global/Helper";
- import {NutkaLayer} from "../../src.evidently_audio/NutkaLayer";
- import {Sfx} from "../game/global/Sfx";
- import {Progress} from "../game/global/Progress";
- import {RecamelSave} from "../../src.framework/net/retrocade/camel/core/RecamelSave";
- import {S} from "../S";
- import {TEffectTarSplatter} from "../game/objects/effects/TEffectTarSplatter";
- import {TEffectSwordSwing} from "../game/objects/effects/TEffectSwordSwing";
- import {TEffectBlood} from "../game/objects/effects/TEffectBlood";
- import {TEffectCheckpoint} from "../game/objects/effects/TEffectCheckpoint";
- import {TEffectDebris} from "../game/objects/effects/TEffectDebris";
- import {TEffectEvilEyeGaze} from "../game/objects/effects/TEffectEvilEyeGaze";
- import {TEffectOrbHit} from "../game/objects/effects/TEffectOrbHit";
- import {TEffectVermin} from "../game/objects/effects/TEffectVermin";
- require('../assets/font/toms-new-roman.css');
- export class Bootstrap {
- public static async bootstrap(init: (musicLayer: NutkaLayer) => void) {
- init(DROD.nutkaLayerMusic);
- RecamelLang.initialize();
- RecamelSave.setStorage(S.saveStorageName);
- await Promise.all([
- Bootstrap.loadPreloaderBackground(),
- Bootstrap.loadLocale(),
- Bootstrap.waitForFontsToLoad(),
- ]);
- await Bootstrap.initRecamel();
- await Bootstrap.fadeOutPrePreloader();
- DROD.resize()
- await Promise.all([
- Bootstrap.startLoadingAllResources(),
- Bootstrap.showPreloader(),
- ]);
- await Bootstrap.initCore();
- await Bootstrap.unpackHold();
- await Progress.loadFromDisk();
- await Bootstrap.initializeGraphics();
- await Bootstrap.initializeGameClasses();
- await Bootstrap.showInitialize();
- Bootstrap.startGame();
- }
- private static async loadPreloaderBackground() {
- await ResourcesQueue.loadResource(C.RES_PRELOADER_BG);
- }
- private static async loadLocale() {
- await Promise.all([
- ResourcesQueue.loadResource(C.RES_LANG_CREDITS),
- ResourcesQueue.loadResource(C.RES_LANG_COMMON_EN),
- ResourcesQueue.loadResource(C.RES_LANG_COMMON_NL),
- ResourcesQueue.loadResource(C.RES_LANG_COMMON_DE),
- ResourcesQueue.loadResource(C.RES_LANG_COMMON_FI),
- ResourcesQueue.loadResource(C.RES_LANG_COMMON_ES),
- ResourcesQueue.loadResource(C.RES_LANG_COMMON_PT),
- ResourcesQueue.loadResource(C.RES_LANG_COMMON_FR),
- ResourcesQueue.loadResource(C.RES_LANG_COMMON_RU),
- ResourcesQueue.loadResource(C.RES_LANG_COMMON_PL),
- ResourcesQueue.loadResource(C.RES_LANG_HOLD_EN),
- ResourcesQueue.loadResource(C.RES_LANG_HOLD_NL),
- ResourcesQueue.loadResource(C.RES_LANG_HOLD_DE),
- ResourcesQueue.loadResource(C.RES_LANG_HOLD_FI),
- ResourcesQueue.loadResource(C.RES_LANG_HOLD_ES),
- ResourcesQueue.loadResource(C.RES_LANG_HOLD_PT),
- ResourcesQueue.loadResource(C.RES_LANG_HOLD_FR),
- ResourcesQueue.loadResource(C.RES_LANG_HOLD_RU),
- ResourcesQueue.loadResource(C.RES_LANG_HOLD_PL),
- ]);
- const credits = ResourcesQueue.getText(C.RES_LANG_CREDITS);
- RecamelLang.loadLanguageFile(credits, 'en');
- RecamelLang.loadLanguageFile(credits, 'nl');
- RecamelLang.loadLanguageFile(credits, 'de');
- RecamelLang.loadLanguageFile(credits, 'fi');
- RecamelLang.loadLanguageFile(credits, 'es');
- RecamelLang.loadLanguageFile(credits, 'pt');
- RecamelLang.loadLanguageFile(credits, 'fr');
- RecamelLang.loadLanguageFile(credits, 'ru');
- RecamelLang.loadLanguageFile(credits, 'pl');
- RecamelLang.loadLanguageFile(ResourcesQueue.getText(C.RES_LANG_COMMON_EN), 'en');
- RecamelLang.loadLanguageFile(ResourcesQueue.getText(C.RES_LANG_COMMON_NL), 'nl');
- RecamelLang.loadLanguageFile(ResourcesQueue.getText(C.RES_LANG_COMMON_DE), 'de');
- RecamelLang.loadLanguageFile(ResourcesQueue.getText(C.RES_LANG_COMMON_FI), 'fi');
- RecamelLang.loadLanguageFile(ResourcesQueue.getText(C.RES_LANG_COMMON_ES), 'es');
- RecamelLang.loadLanguageFile(ResourcesQueue.getText(C.RES_LANG_COMMON_PT), 'pt');
- RecamelLang.loadLanguageFile(ResourcesQueue.getText(C.RES_LANG_COMMON_FR), 'fr');
- RecamelLang.loadLanguageFile(ResourcesQueue.getText(C.RES_LANG_COMMON_RU), 'ru');
- RecamelLang.loadLanguageFile(ResourcesQueue.getText(C.RES_LANG_COMMON_PL), 'pl');
- RecamelLang.loadLanguageFile(ResourcesQueue.getText(C.RES_LANG_HOLD_EN), 'en');
- RecamelLang.loadLanguageFile(ResourcesQueue.getText(C.RES_LANG_HOLD_NL), 'nl');
- RecamelLang.loadLanguageFile(ResourcesQueue.getText(C.RES_LANG_HOLD_DE), 'de');
- RecamelLang.loadLanguageFile(ResourcesQueue.getText(C.RES_LANG_HOLD_FI), 'fi');
- RecamelLang.loadLanguageFile(ResourcesQueue.getText(C.RES_LANG_HOLD_ES), 'es');
- RecamelLang.loadLanguageFile(ResourcesQueue.getText(C.RES_LANG_HOLD_PT), 'pt');
- RecamelLang.loadLanguageFile(ResourcesQueue.getText(C.RES_LANG_HOLD_FR), 'fr');
- RecamelLang.loadLanguageFile(ResourcesQueue.getText(C.RES_LANG_HOLD_RU), 'ru');
- RecamelLang.loadLanguageFile(ResourcesQueue.getText(C.RES_LANG_HOLD_PL), 'pl');
- }
- private static async waitForFontsToLoad() {
- if ((document as any).fonts) {
- await (document as any).fonts.ready;
- } else {
- // @todo add some other detection in the future or hope for the best
- }
- document.getElementById('tomloader')!.remove();
- }
- private static async initRecamel() {
- RecamelCore.init(DROD.app, DROD.app.stage);
- }
- private static async startLoadingAllResources() {
- return ResourcesQueue.startLoadingAll();
- }
- private static async fadeOutPrePreloader() {
- const prepreloader = document.getElementById('prepreloader')!;
- prepreloader.style.opacity = '0';
- return new Promise<void>(resolve => {
- setTimeout(() => {
- DROD.app.view.style.opacity = '1';
- prepreloader.remove();
- resolve();
- }, 600);
- });
- }
- private static async showPreloader() {
- return new Promise<void>(resolve => {
- RecamelCore.setState(new TStatePreloader(resolve));
- if (PlatformOptions.isDebug) {
- resolve();
- }
- });
- }
- private static async initCore() {
- Gfx.initialize();
- Core.init();
- }
- private static async unpackHold() {
- Core.unpackHold(ResourcesQueue.getBinary(C.RES_HOLD));
- }
- private static async initializeGameClasses() {
- Achievements.init();
- DrodInput.init();
- RecamelTooltip.setBackground(Make.tooltipGrid9());
- RecamelTooltip.setSize(14);
- RecamelTooltip.setPadding(5, 10, 5, 10);
- RecamelTooltip.setShadow(45, 4, 5, 1, 0.5, 0);
- TWidgetScroll.init();
- TWidgetLevelName.init();
- TWidgetClock.init();
- TWidgetMoveCounter.init();
- Helper.init();
- Sfx.initialize();
- }
- private static async showInitialize() {
- return new Promise<void>(resolve => {
- RecamelCore.setState(new TStateInitialize(resolve));
- });
- }
- private static startGame() {
- TStateTitle.show();
- }
- private static async initializeGraphics() {
- TEffectBlood.initialize();
- TEffectCheckpoint.initialize();
- TEffectDebris.initialize();
- TEffectEvilEyeGaze.initialize();
- TEffectOrbHit.initialize();
- TEffectSwordSwing.initialize();
- TEffectTarSplatter.initialize();
- TEffectVermin.initialize();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment