import BaseController from './base-controller.js';
import AssetManager from '../managers/asset-manager.js';

export default class PreloadController extends BaseController
{
    constructor(app, view, name)
    {
        super(app, view, name);
    }

    //----------------------------------------------------------
    // Overridden methods
    //----------------------------------------------------------

    initialize()
    {
        super.initialize();

        // Show view
        this.showView();

        // Preload map assets
        AssetManager.onAssetsLoadCompleteCallback = () => { this.onMapAssetsLoadComplete(); }
        AssetManager.loadMapAssets();
    }

    destroy()
    {
        super.destroy();
    }

    removeSmartFoxListeners()
    {
        // Nohing to do
    }

    onMapAssetsLoadComplete()
    {
        this.app.trace('Map assets preloading completed');

        // Show login view
        this.app.goToView('login');
    }
}