Legacy HTML/JS access of UI View Listeners

**Version: *** 1.4.10.0 *****

Frequency: Consistently

Severity: Blocker

Context: Legacy FS2020-style HTML/JS access of UI View Listeners

Bug description: Since SU2b, the UI code updates have removed the legacy FS2020 backwards-compatible View Listener accessibility (including events and triggers), e.g. via Common.js, Coherent.js, Weather.js. While we can add the legacy common.js (and coherent.js) to the html, the registration, events and triggers no longer work. This breaks compatibility with ASFS and several other add-ons that access these legacy listeners to interact with the UI in certain ways, such as getting the current preset, changing preset, or getting customer weather settings.

Repro steps: Attempt access/registration of any legacy view listener, observe no events/callbacks/apparent functionality.

Notes:

This looks to be part of a general refactor/cleanup of the code, but this does break things significantly and there appears to be no alternative to access similar functionality. Any guidance regarding if this might be “fixed” with a future update to re-establish backwards compatibility, if a new alternative is available or forthcoming, would be much appreciated.

Without a resolution, many add-ons including ASFS will no longer be FS2024 compatible, after they were previously compatible prior to SU2.

2 Likes

If you explicitly add the old Coherent.js as well in your HTML, do the previously available RegisterViewListener global functions work?

Thanks,
Matt

1 Like

No, unfortunately. Report updated.

Hello @LateAura49

For optimization purposes, the legacy components are no longer initialized everywhere.
Your addon falls in a very specific case, because you declare a panel but you do not really create it, bypassing the legacy initialization we had anticipated for in-game panel backwards compatibility.

To address this and allow a bit more flexibility, starting from the next SU2 beta build, we have added the ability to explicitly initialize legacy components by adding a window.legacyInit() call

(async function () {
        await window.legacyInit();

        Load_js("/pages/ToolBar/toolbar_interop.js", () => {
            if (window.toolbar_interop) {
                Initialize();
            } else {
                document.addEventListener("toolbar_interop_ready", Initialize);
            }
    });
})();

Doing so should revert your addon behavior to what it was on SU1.

Regards,
Sylvain

3 Likes

Thanks, Sylvain!

Update 1.4.13.0: The registration is working great now, thank you!

Had had some issues getting things to operate correctly since several Weather Listener functions changed (namely, the updatePreset function and new ASK_UPDATE_PRESET trigger), but this is workable of course. Thanks again.

1 Like