github joncampbell123/dosbox-x dosbox-x-wip-20180506-1805
DOSBox-X menu rewrite WIP BETA 2018-05-06 17:54

pre-release6 years ago

This is a WIP release. This contains a lot of new code concerning the menu layout.

The menu handling system is being changed from one that loads a static Windows menu resource (IDR_MENU) to one that constructs a menu in a platform-independent manner.

The code is brand new and may have some bugs.

The menu framework concept:

  • Components create a menu item by name, as an individual component
  • The mapper automatically creates a menu item for each mapper shortcut registered at startup
  • Lists of popup menus is defined by the menu item name
  • Each menu list can refer to popup menus by name to enable levels of popups
  • The final layout is defined in menu.cpp by name
  • Components can change text, enable, checked, and shortcut text at any time, which is then reflected in the menu
  • Windows builds map this to the Windows menu system
  • Systems where menu support is not implemented, simply do not show a menu, but the menu is in memory anyway
  • Menu items are then connected to a callback function, a mapper shortcut, or both

Look in menu.cpp for the char*[] string arrays that define menu layout by name. It's fairly straightforward.

Another additional feature, connected to the mapper, is that the mapper system automatically updates the menu item for a mapper shortcut when the key binding changes.

This eliminates the problem with DOSBox and DOSBox-X where the shortcut shown in the menu is only correct if the mapper shortcut is left at default.

In the new code, changing the key binding for a mapper shortcut should automatically update the menu.

A quick way to test this:

  • Bring up the mapper
  • Pick a menu item with a shortcut
  • Locate the same shortcut in the mapper UI
  • Click on the shortcut, to edit the binding
  • Note the shortcut shown in the menu
  • Change the binding modifiers
  • Note the shortcut shown in the menu now, it should reflect your changes
  • Delete the binding
  • Note the shortcut shown in the menu, there should no longer be any shortcut
  • Add a binding
  • Note the shortcut shown in the menu, it should show your new binding.

Since menu item order is now defined in menu.cpp, rearranging the menu should be simple now and it should be possible to submit simple patches to do so.

The code only works with Windows at this time. The next major development step for this code is to try and produce identical menus under Mac OS X.

Mac OS X builds would benefit from having proper menus instead of the minimal and useless default provided by SDL.

Have fun. Please use the comments section of the commit this is assigned to for comments.

Don't miss a new dosbox-x release

NewReleases is sending notifications on new releases.