TwinFan / XPMP2

Multiplayer library for X-Plane 11/12 with instancing, TCAS override, and sound
https://twinfan.github.io/XPMP2/
Other
24 stars 16 forks source link

Add command for "Active" state toggle, and change menu to use XPLMAppendMenuItemWithCommand #28

Closed slgoldberg closed 3 years ago

slgoldberg commented 3 years ago

Current Situation / Problem

Currently, XPMP2 Remote Client has a menu item in the Plugins menu that shows "Active"/inactive state, but that also serves as a toggle (i.e., which users can click on to change the state to inactivate the concentrator, while leaving the plugin enabled).

In fact, the only way to toggle the plugin's "active" state, is to use the menu. (There is no command or other way to trigger this functionality otherwise.)

This results in several (albeit minor) problems:

Suggested Solution

  1. Refactor existing menu handler to pull out the Active-state toggle into its own XPLM command handler. (est. < 10 minutes of work)
  2. Register a command handler for e.g. "XPMP2_Remote_Client/Aircrafts/Display" (analog to version in LT).
    • n.b.: "Aircrafts" is a misnomer, since it should be "Aircraft" (uncountable); however, this is proposed for consistency with LiveTraffic's command equivalent, but renaming commands such as "fixing" LiveTraffic is not worth the effort
  3. Replace XPLMAppendMenuItem invocation for activate/deactivate toggle, with XPLMAppendMenuItemWithCommand referencing the new command registered above.

Alternatives

Benefits

Additional context (None; this is scoped only to the XPMP2 Remote Client plugin.)

Understanding this is a slippery slope that could lead to extra work that I do not intend, such as persistent settings and other commands -- this is very low-hanging fruit and is really all I think users need. Therefore, I believe a lot could be accomplished using this suggested behavior, for very little work (registering a command, changing the current toggle to be inside a command handler, and changing XPLMAppendMenuItem to ...WithCommand.

Thanks for considering this.