Dev:Source/UI/Menu Format Cleanup

提供: wiki
移動先: 案内検索

Introduction

The function pupmenu, meant for quickly creating popup menus, suffers from some annoying limitations. The function works by constructing a menu from a format string, formatted as such:

"[title]%t|[menu entry]%xn+1"

The format is basically a "|"-seperated list, which three special "commands": %x, %t, and %i.  %t denotes a menu entry as the menu title.  %x assigns a value to a menu entry, which is return by pupmenu (it cannot be 0).  %i assigns an icon to a menu entry; the icon code for each %i command is passed in a variable-length function argument list (like printf).

Proposal

The proposed changes to the menu format are:

  • Add submenu support
  • Add support for inlining icon codes with %i

Submenu support

Submenu support would be added by closing a set of entries in brackets. The submenu's entry on the parent menu would be defined by the entry above it. An example of this format might be: "Menu%t|Entry1%x1|Entry2%x2|Entry3|{Entry4%x4|Entry5%x5}".