import { GComponent } from '@popiplay/fairygui-dom-fork';

/** FairyGUI scene wrapper that keeps the root scaled to the viewport. */
export default class FairyScene extends GComponent
{
    private readonly resizeHandler = (): void =>
    {
        this.resize();
    };

    constructor()
    {
        super();
        window.addEventListener('resize', this.resizeHandler);
    }

    /** Resizes the scene to fill the available screen. */
    resize(): void
    {
        this.makeFullScreen();
    }

    /** Removes global listeners prior to disposal. */
    //@ts-expect-error fairy gui piece of shit
    override destroy(): void
    {
        window.removeEventListener('resize', this.resizeHandler);
    }
}
