From 2cae1549773fc4ba1ecdd5078033ee5f921227a2 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Sun, 7 Aug 2022 13:06:47 -0600 Subject: [PATCH] Update MenuModule docs slightly --- core/scanner_tossers/ftn_bso.js | 2 +- docs/_docs/modding/menu-modules.md | 39 +++++++++++++++++++++++++++--- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/core/scanner_tossers/ftn_bso.js b/core/scanner_tossers/ftn_bso.js index 8b936368..e3d148bc 100644 --- a/core/scanner_tossers/ftn_bso.js +++ b/core/scanner_tossers/ftn_bso.js @@ -2775,7 +2775,7 @@ FTNMessageScanTossModule.prototype.startup = function (cb) { delete: '-', exists: '=', }[e] || ''; - return `Import/toss due to @watch (${indicator}): ${paths.basename( + return `Import/toss due to @watch [${indicator}]: ${paths.basename( path )}`; }; diff --git a/docs/_docs/modding/menu-modules.md b/docs/_docs/modding/menu-modules.md index 77f431e6..7f9c9c31 100644 --- a/docs/_docs/modding/menu-modules.md +++ b/docs/_docs/modding/menu-modules.md @@ -3,12 +3,45 @@ layout: page title: Menu Modules --- ## Menu Modules -Menu entries found within `menu.hjson` are backed by *menu modules*. +All menu entries found within `menu.hjson` are backed by *menu modules*. Menus are any screen or sectionin within the system. A main menu, a door launcher, and MRC chat are all examples of menus. For basic menus, a standard handler is implemented requiring no code. However, if you would like to create a menu that has custom handling, simply inherit from `MenuModule`. More on this below. + +> :information_source: Remember that ENiGMA does not impose any stucture to your system! The "flow" of all `menu.hjson` entries is up to you! ## Creating a New Module -TODO +At the highest level, to create a new custom menu or mod, inherit from `MenuModule` and expose it via the `getModule` exported method: + +```javascript +// my_fancy_module.js +exports.getModule = class MyFancyModule extends MenuModule { + constructor(options) { + super(options); + } +}; +``` + +## Lifecycle +Below is a very high level diagram showing the basic lifecycle of a menu. -### Lifecycle ![Basic Menu Lifecycle](../../assets/images/basic_menu_lifecycle.png) +Methods indicated above with `()` in their name such as `enter()` are overridable when inheriting form `MenuModule`. +## MenuModule Helper Methods +Many helper methods exist and are available to code inheriting from `MenuModule`. Below are some examples. Poke around at [menu_module.js](../../../core/menu_module.js) to discover more! + +* `displayAsset()` +* `prepViewController()` +* `prepViewControllerWithArt()` +* `promptForInput()` +* `displayArtAndPrepViewController()` +* `setViewText()` +* `getView()` +* `updateCustomViewTextsWithFilter()` +* `refreshPredefinedMciViewsByCode()` +* `validateMCIByViewIds()` +* `validateConfigFields()` +* `getDateFormat()` +* `getTimeFormat()` +* `getDateTimeFormat()` + +> :information_source: Search the code for the above methods to see how they are used in the base system!