• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Dialog Pages

This bundle is marked as pending. It has not been reviewed by a staff member yet.
  • Like
Reactions: QuantumMatter
  • Create a dialog with automatic pages
  • Optionally show an index page
  • Automatic Next/Previous/Back/Cancel buttons
API:
JASS:
//  *   NOTES:
//          - dialogId refers to handle id
//          - buttonId and pageId refer to zero-indexed id
//
boolean DialogPDisplay(player plr, integer dialogId, boolean display)
//          - Display/Hide dialog
//          - If displayed when dialog is already displayed, it will be updated
//          - Returns false if the dialog wasn't found
//
integer DialogPCreate(string message, boolean showIndex)
//          - Create a new dialog
//          - Returns dialog handle id (dialogId)
//
boolean DialogPDestroy(integer dialogId)
//          - Destroy dialog
//          - Returns false if the dialog wasn't found
//
boolean DialogPSetPage(integer dialogId, integer pageId)
//          - Set dialog page
//          - Set to 0 if pageId < 0 or to maximum pageId if pageId > maximum pageId
//          - Returns false if the dialog wasn't found
//
boolean DialogPSetMessage  (integer dialogId, string message)
boolean DialogPSetButtonsPP(integer dialogId, integer buttonsPP)
//          - Set dialog message/buttons per page
//          - Returns false if the dialog wasn't found
//
boolean DialogPSetButtonsText  (integer dialogId, string  next, string  previous, string  back, string  cancel)
boolean DialogPSetButtonsHotkey(integer dialogId, integer next, integer previous, integer back, integer cancel)
boolean DialogPDisplayButtons  (integer dialogId, boolean next, boolean previous, boolean back, boolean cancel)
//          - Set browse buttons text/hotkey/visibility
//          - Returns false if the dialog wasn't found
//
dialog DialogPGetHandle(integer dialogId)
//          - Get dialog handle
//          - Returns null if the dialog wasn't found
//
trigger DialogPGetTrigger(integer dialogId)
//          - Get dialog trigger
//          - Executed/Evaluated when the dialog is clicked
//          - Execution of actions prevented when Next, Previous, Back, Cancel and index page buttons are clicked
//          - Returns null if the dialog wasn't found
//
integer DialogPGetClickedId(integer dialogId)
//          - Get dialog last clicked buttonId
//          - Returns DP_BROWSED for Next, Previous, Back and index page buttons
//          - Returns DP_CANCELED for Cancel button
//          - Returns DP_NONE if no button has been clicked yet
//          - Returns DP_NOT_FOUND if the dialog wasn't found
//
//      * BUTTONS *
//      -----------
integer DialogPAddButton    (integer dialogId, string text, integer hotkey)
integer DialogPAddQuitButton(integer dialogId, boolean doScoreScreen, string text, integer hotkey)
//          - Add (quit) button to dialog
//          - Returns buttonId (not a handle id)
//          - Returns DP_NOT_FOUND if the dialog wasn't found
//
boolean DialogPSetButton    (integer dialogId, integer buttonId, string text, integer hotkey)
boolean DialogPSetQuitButton(integer dialogId, integer buttonId, boolean doScoreScreen, string text, integer hotkey)
//          - Set (quit) button (doScoreScreen), text and hotkey
//          - Can both be used on regular and quit buttons
//          -- Using SetQuitButton on a regular button will turn it into a quit button
//          - Returns false if the dialog or button wasn't found
//
string DialogPGetButtonText(integer dialogId, integer buttonId)
//          - Get button text
//          - Returns null if the dialog or button wasn't found
//
//      * INDEX *
//      ---------
boolean DialogPEnableIndex(integer diagId, boolean enable)
//          - Enable/Disable index and set page to 0
//          - If enabled, also opens index
//          - Index is only shown when number of buttons > buttons per page
//          - Returns false if the dialog wasn't found
//
boolean DialogPSetIndexPage(integer dialogId, integer pageId)
//          - Set dialog index page
//          - Set to 0 if pageId < 0 or to maximum pageId if pageId > maximum pageId
//          - Returns false if the dialog wasn't found
//
//      * INDEX BUTTONS *
//      -----------------
boolean DialogPSetIndexButton(integer dialogId, integer pageId, string text, integer hotkey)
//          - Set index button text and hotkey
//          - Text and hotkey will be saved even if page doesn't (yet) exist
//          - Returns false if the dialog wasn't found
//
//      * CONFIG VARIABLES *
//      --------------------
integer DP_btnsPP
//          - Default number of buttons to show per page
//          - Does not include Next, Previous, Back or Cancel buttons
//          - Default: 5
//
string  DP_strNext,  DP_strPrev,  DP_strBack,  DP_strCancel
integer DP_hkNext,   DP_hkPrev,   DP_hkBack,   DP_hkCancel
boolean DP_showNext, DP_showPrev, DP_showBack, DP_showCancel
//          - Default settings for Next, Previous, Back and Cancel buttons
//          - Text: "Next >", "< Previous", "< Back", "Cancel"
//          - Hotkeys: 0 (all)
//          - Visibility: true (all)
//          -- When index is enabled, Next and Previous buttons are on index pages, Back button is on normal pages
//          -- When there are 2 pages, Previous button on first page and Next button on second page are always hidden
//          -- When there are less than 2 pages, Next and Previous buttons are always hidden
Contents

Dialog Pages (Map)

Reviews
MyPad
Code Review: Suggestions: The Dialog Page System should be struct-based. This is based on the structure of the functions themselves, which appear to be functionality-based, yet support OOP-syntax. The function API can be kept as wrappers to the...

Code Review:


Suggestions:
The Dialog Page System should be struct-based. This is based on the structure of the functions themselves, which appear to be functionality-based, yet support OOP-syntax. The function API can be kept as wrappers to the methods in the Dialog Page struct.

The system suffers a bit from having to use up dynamically instantiated hashtables (due to the maximum limit of 255 hashtables per map), though that is going to be a very rare scenario from the user's end.​
 
Top