• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

Panel Disconnect

Messages
158
Country
us-northcarolina
This may be common knowledge but it just bit me and I finally figured it out.

In order to clean up when my gauge is closed I have various shutdowns of sounds and such in PANEL_SERVICE_DISCONNECT. Logical, eh? And in FS9 this works well. FS9 only calls PANEL_SERVICE_DISCONNECT when you would expect -- when the panel is being disconnected due to the flight being ended, or a crash, etc.

Ah, but FSX - FSX calls PANEL_SERVICE_DISCONNECT every time the gauge is re-sized! This means when a user resizes his gauge I close up everything -- close keyboard direct input, any music or sounds playing, even shut down SimConnect -- needless to say a disaster.

The alternative (not to close up shop) leaves potentially music and sound effects playing even after the user has ended his flight. Can't do that.

So, does anyone know if there's another PANEL_SERVICE that FSX triggers when it's shutting the flight down but not when the gauge is re-sized?
PANEL_CLOSE isn't it -- that happens when the user makes the gauge disappear. PANEL_KILL isn't it either, it's called whenever the gauge is re-sized or when it's closed. I don't have much hope for this there isn't any likely candidate in gauges.h.

Alternatively, is there some tidbit of info anywhere in FSX that would let me distinguish between a re-sizing and actual shutdown?

Dutch
 
You should't use the PANEL_SERVICE_* functions to do global initialization because, as you found out, the behaviour is not guaranteed to be the same between FS9 and FSX.

The correct way of doing this, is to use the module_init() and module_deinit() callbacks.

The module_init() is guaranteed to be called only ONCE, when the AIRPLANE that contains *any* reference in *any* panel (even those that are closed at start) of your gauge, is loaded. So is the module_deinit(), called only once, when the airplane is unloaded.

They are defined inside the GAUGE_TABLE_BEGIN macro as being empty, but you are not forced to use that macro, you can simply write the same code, and take away the module_init() and module_deinit() functions, and fill them with your code.

Yes, module_init() is the perfect place to place any initialization code, like opening Simconnect, initializing sound code (directsound, etc.), initializing any variables, etc. And, of course, the module_deinit() it's the best place to do the opposite, closing Simconnect, clean up everything, etc...
 
Ah, yes, it simply never occurred to me that I could override the definition those in a gauge. Obvious!

Thanks a lot! This does solve a goodly number of issues that I have clumsy workarounds in place to handle now.

Dutch
 
Back
Top