Menu API: Difference between revisions

From fCraft Wiki
Jump to navigation Jump to search
Created page with "Influenced by SourceMod menu, allows to display menus, votes, options, confirmation prompts, alerts, and other interactive dialogs/menus. =MenuItemType enumeration= # '''Spacer'..."
 
No edit summary
Line 51: Line 51:
* byte '''OpCode'''
* byte '''OpCode'''
* sbyte '''ButtonIndex'''
* sbyte '''ButtonIndex'''
{{Category:Protocol Extensions}}

Revision as of 03:59, 9 July 2011

Influenced by SourceMod menu, allows to display menus, votes, options, confirmation prompts, alerts, and other interactive dialogs/menus.

MenuItemType enumeration

  1. Spacer = empty space
  2. PlainText = plain white text (cannot be selected)
  3. Button = button that can be selected
  4. DisabledButton = grayed-out button that cannot be selected

Button Index Codes

-2 = Menu was closed by MenuClose packet
-1 = Menu was closed by user hitting Escape
0 = Last button (bottom-most)
1, 2, 3.. = Other buttons, starting with the top button.

Packets (Server -> Client)

Notification

Notice concept
Notice fallback

Simple plain-text message with a "close" button. Usable for showing server rules, world descriptions, global notifications, etc - any kind of information that the user just needs to read through and close.

  • byte OpCode
  • string Message
  • string CloseButtonLabel


Vote dialog concept
Vote dialog fallback

A plain-text message with two buttons - one for "Yes", and one for "No". Can be used for votes or confirmation prompts.

  • byte OpCode
  • string Message
  • string YesButtonLabel
  • string NoButtonLabel
  • byte SelectedIndex


Complex menu concept

Fully-featured way to construct menus. Allows customizing each line if the menu.

  • byte OpCode
  • vstring Message
  • byte MenuItemCount
    • byte MenuItemType
    • string MenuItemLabel
  • string CloseButtonLabel
  • byte SelectedIndex

Forces any open menu to close. Client is still required to send a MenuClosed event, with a special ButtonIndex code (see above).

  • byte OpCode

Packets (Client -> Server)

  • byte OpCode
  • sbyte ButtonIndex

Data Types

  • sbyte = signed byte
  • byte = unsigned byte (extension)
  • short = signed 16-bit int, big-endian
  • ushort = unsigned 16-bit int, big-endian (extension)
  • RGB = red-green-blue triplet. 1 unsigned byte per channel, 3 bytes total (extension)
  • RGBA = red-green-blue triplet + alpha. 1 unsigned byte per channel, 4 bytes total (extension)