@amxts/menu-core 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PAWN.md +2 -2
- package/PAWN.ru.md +2 -2
- package/README.md +8 -5
- package/README.ru.md +8 -5
- package/package.json +3 -3
- package/prebuilt/linux/menu-core.aot +0 -0
- package/prebuilt/manifest.json +15 -14
- package/prebuilt/windows/menu-core.aot +0 -0
- package/scripts/docs/src/menus.ts +18 -2
- package/scripts/docs/src/types.ts +4 -4
- package/src/internal.ts +4 -0
- package/src/menu-file.ts +13 -5
- package/src/menus.ts +54 -15
- package/src/natives.ts +1 -1
- package/src/types.ts +4 -4
package/PAWN.md
CHANGED
|
@@ -22,8 +22,8 @@ A plugin compiled against it gets a tag warning for a bare number where `MenuPro
|
|
|
22
22
|
- `mc_get_menu_property_string(idx, MP_SECTION)` gives the menu's section.
|
|
23
23
|
- A condition filter applies wherever the condition is asked.
|
|
24
24
|
- A restriction's `message` is shown beside an item it greys out when the item has no message of its own.
|
|
25
|
-
- `IS_ALIVE`, `IS_DEAD`, `TEAM_<team>`, `IS_BOT`, `IS_ADMIN` and `FLAG_<letters>` are built-in conditions, answered while no plugin registers the name. A plugin that registers one of them answers instead.
|
|
26
|
-
- `ADMIN` and `ACCESS_ADMIN
|
|
25
|
+
- `IS_ALIVE`, `IS_DEAD`, `TEAM_<team>`, `IS_BOT`, `IS_ADMIN`, `ADMIN`, `ACCESS_ADMIN` and `FLAG_<letters>` are built-in conditions, answered while no plugin registers the name. A plugin that registers one of them answers instead.
|
|
26
|
+
- `ADMIN` and `ACCESS_ADMIN`, as conditions and as restrictions, hold for ban, rcon, admin or menu access (`FLAG_dluy`), as in the Pawn menu_core.
|
|
27
27
|
- A restriction `NAME:text` takes the rest of the line, spaces and all, as its text; names before it are restrictions of their own.
|
|
28
28
|
- Closing a menu because another opens over it tells the close callbacks its name.
|
|
29
29
|
- A locked menu greys out the items of any menu, not only list rows.
|
package/PAWN.ru.md
CHANGED
|
@@ -22,8 +22,8 @@ Pawn-плагины пишут `#include <menu_core>`; в пакете лежи
|
|
|
22
22
|
- `mc_get_menu_property_string(idx, MP_SECTION)` отдаёт секцию меню.
|
|
23
23
|
- Фильтр условия применяется везде, где спрашивают условие.
|
|
24
24
|
- `message` ограничения показывается рядом с посеревшим пунктом, если у пункта нет своего сообщения.
|
|
25
|
-
- `IS_ALIVE`, `IS_DEAD`, `TEAM_<команда>`, `IS_BOT`, `IS_ADMIN` и `FLAG_<буквы>` — встроенные условия, на них отвечает Menu Core, пока имя не регистрирует ни один плагин. Плагин, который регистрирует такое имя, отвечает вместо него.
|
|
26
|
-
- `ADMIN` и `ACCESS_ADMIN`
|
|
25
|
+
- `IS_ALIVE`, `IS_DEAD`, `TEAM_<команда>`, `IS_BOT`, `IS_ADMIN`, `ADMIN`, `ACCESS_ADMIN` и `FLAG_<буквы>` — встроенные условия, на них отвечает Menu Core, пока имя не регистрирует ни один плагин. Плагин, который регистрирует такое имя, отвечает вместо него.
|
|
26
|
+
- `ADMIN` и `ACCESS_ADMIN` — и как условия, и как ограничения — выполняются при доступе ban, rcon, admin или menu (`FLAG_dluy`), как в Pawn menu_core.
|
|
27
27
|
- Ограничение `NAME:текст` забирает остаток строки вместе с пробелами как свой текст; имена перед ним — отдельные ограничения.
|
|
28
28
|
- Когда меню закрывается, потому что поверх открылось другое, колбэки закрытия получают его имя.
|
|
29
29
|
- Заблокированное меню делает серыми пункты любого меню, а не только строки списков.
|
package/README.md
CHANGED
|
@@ -123,7 +123,7 @@ const vote = menus.create("LIST_MAPS", { title: "Next map" });
|
|
|
123
123
|
vote.setListSource(() => maps.map((map, index) => menus.listRow(index, map)));
|
|
124
124
|
vote.addItem({
|
|
125
125
|
title: ({ row }) => maps[row],
|
|
126
|
-
onSelect: ({ player, row }) => print(
|
|
126
|
+
onSelect: ({ player, row }) => player.print(`You vote for ${maps[row]}`),
|
|
127
127
|
});
|
|
128
128
|
```
|
|
129
129
|
|
|
@@ -138,6 +138,9 @@ In code a requirement is a function. Names — `IS_ALIVE`, `FLAG_d`, a restricti
|
|
|
138
138
|
|
|
139
139
|
Keys: **1–7** choose, **8** is the next page, **9** the previous page or back to the menu this one was opened from, **0** closes.
|
|
140
140
|
|
|
141
|
+
> [!WARNING]
|
|
142
|
+
> **Showing the menu a player is on:** from a command or a timer, `show()` opens it anew, at its first page. From one of its own items it stays on its page — and after an item's action the menu is drawn again by itself. `setPage(player, page)` is the page the next `show()` draws.
|
|
143
|
+
|
|
141
144
|
Text colours are written as tags, the same letters as in chat: `!y` yellow, `!r` red, `!d` grey, `!w` white, `!R` aligns right. Chat's own `!g`, `!b` and `!t` are dropped from a menu.
|
|
142
145
|
|
|
143
146
|
### API
|
|
@@ -161,9 +164,9 @@ Its fields — `title`, `time`, `hideBack`, `hideExit`, `locked`, `sharedTimer`
|
|
|
161
164
|
| Function | What it does |
|
|
162
165
|
| --- | --- |
|
|
163
166
|
| `create(name, options?)` | A menu in code, or the existing one with that name. A name starting with `LIST_` makes a list menu. Options: `title` (text or a function), `time`, `hideBack`, `hideExit`, `locked`, `activeWhen`. |
|
|
164
|
-
| `find(name)` · `register(
|
|
167
|
+
| `find(name)` · `register(...names)` | A menu by its name; `register` reads them from the file ahead of time: `register("MAIN_MENU", "ADMIN_MENU")`. |
|
|
165
168
|
| `show(player, name, options?)` · `close(player)` · `activeMenu(player)` · `lock(player)` | The player's menu, whichever it is. |
|
|
166
|
-
| `addCondition(name, test)` · `addAction(name, handler)` · `addPlaceholder(name, value)` · `addRestriction(name, test, message?)` | What menu files and Pawn plugins name, answered by functions — `%name%` in their text is a placeholder. An action, a placeholder and a restriction get the menu's context and the `name` they are asked by; a condition, `(player, viewer, name)`, is asked of the row's player in a list menu. A restriction's `message` is said beside an item it greys out, unless the item or the requirement has its own. `menu.addPlaceholder(name, value)` gives one to a single menu. |
|
|
169
|
+
| `addCondition(name, test)` · `addAction(name, handler)` · `addPlaceholder(name, value)` · `addRestriction(name, test, message?)` · `addActions({ NAME: handler })` · `addPlaceholders({ name: value })` | What menu files and Pawn plugins name, answered by functions — `%name%` in their text is a placeholder; `addActions` and `addPlaceholders` take several at once. An action or a placeholder is a function of the player, `(player) => ...`, or of the menu's context. An action, a placeholder and a restriction get the menu's context and the `name` they are asked by; a condition, `(player, viewer, name)`, is asked of the row's player in a list menu. A restriction's `message` is said beside an item it greys out, unless the item or the requirement has its own. `menu.addPlaceholder(name, value)` gives one to a single menu. |
|
|
167
170
|
| `setListSource(name, rows)` · `refresh("A B")` · `conditionChanged(name)` · `addEventListener(type, listener)` | The same for menus by name, and every menu's events. |
|
|
168
171
|
|
|
169
172
|
## Menus in a file
|
|
@@ -280,7 +283,7 @@ VIEW = {
|
|
|
280
283
|
|
|
281
284
|
| YAML, JSON | INI | What it is |
|
|
282
285
|
| --- | --- | --- |
|
|
283
|
-
| `chatPrefix` | `[MAIN]` `PREFIX` | The chat prefix of Menu Core's messages. |
|
|
286
|
+
| `chatPrefix` | `[MAIN]` `PREFIX` | The chat prefix of Menu Core's messages. The Pawn menu_core's `[Основное]` is read as `[MAIN]`. |
|
|
284
287
|
| `labels`: `exit`, `back`, `next`, `number`, `disabled`, `page`, `time` | `[MAIN]` `KEY = { ... }` | The words of the buttons, the page and the countdown. |
|
|
285
288
|
| `menus`: `{ NAME: menu }` | `[NAME]` | The menus; a name starting with `LIST_` is a list menu. |
|
|
286
289
|
| `title` | `TITLE` | The title; a menu has one. |
|
|
@@ -317,6 +320,7 @@ A `visible`, `when`, `enabled`, `activeOn`, `action` or `onTimeout` is a name, s
|
|
|
317
320
|
| `TEAM_CT` · `TEAM_TERRORIST` · `TEAM_SPECTATOR` · `TEAM_UNASSIGNED` | is in that team |
|
|
318
321
|
| `IS_BOT` | is a bot |
|
|
319
322
|
| `IS_ADMIN` | has any access but a plain user's `z` — AMX Mod X's `is_user_admin` |
|
|
323
|
+
| `ADMIN` · `ACCESS_ADMIN` | has ban, rcon, admin or menu access — `FLAG_dluy`, as the Pawn menu_core answered them |
|
|
320
324
|
| `FLAG_<letters>` | has any of those `users.ini` letters: `FLAG_ab` |
|
|
321
325
|
|
|
322
326
|
In a list menu, a condition of the view or a filter is asked of the row's player, and a restriction gets the row as its target. The names are case-insensitive.
|
|
@@ -332,7 +336,6 @@ A `visible`, `when`, `enabled`, `activeOn`, `action` or `onTimeout` is a name, s
|
|
|
332
336
|
> - **An item's name in YAML or JSON is not split on `|`:** its faces are written with `variants`.
|
|
333
337
|
> - **Colours** are tags in a menu file too: `!y`, `!r`, `!d`, `!w`, `!R`. Pawn's codes (`\y`, `\r`) are warned of, with the tag to write, and left out. Text from Pawn — a Pawn plugin's items and titles, a lang dictionary — keeps its codes, and Menu Core reads them as the tags.
|
|
334
338
|
> - **`%time%` and `%target%` are lower case:** `%TIME%` and `%s` are left as written.
|
|
335
|
-
> - **`ADMIN` and `ACCESS_ADMIN` are not built in:** a plugin registers them, or the file writes `IS_ADMIN` (any admin) or `FLAG_<letters>` (`FLAG_d`).
|
|
336
339
|
|
|
337
340
|
### INI's columns
|
|
338
341
|
|
package/README.ru.md
CHANGED
|
@@ -123,7 +123,7 @@ const vote = menus.create("LIST_MAPS", { title: "Следующая карта"
|
|
|
123
123
|
vote.setListSource(() => maps.map((map, index) => menus.listRow(index, map)));
|
|
124
124
|
vote.addItem({
|
|
125
125
|
title: ({ row }) => maps[row],
|
|
126
|
-
onSelect: ({ player, row }) => print(
|
|
126
|
+
onSelect: ({ player, row }) => player.print(`Ты голосуешь за ${maps[row]}`),
|
|
127
127
|
});
|
|
128
128
|
```
|
|
129
129
|
|
|
@@ -138,6 +138,9 @@ vote.addItem({
|
|
|
138
138
|
|
|
139
139
|
Клавиши: **1–7** выбирают, **8** — следующая страница, **9** — предыдущая страница или назад, в меню, из которого открыли это, **0** закрывает.
|
|
140
140
|
|
|
141
|
+
> [!WARNING]
|
|
142
|
+
> **Показ меню, в котором игрок уже находится:** из команды или таймера `show()` открывает его заново, с первой страницы. Из его собственного пункта меню остаётся на своей странице — а после действия пункта меню и так рисуется снова. `setPage(player, page)` — страница, которую нарисует следующий `show()`.
|
|
143
|
+
|
|
141
144
|
Цвета в тексте пишутся метками, теми же буквами, что в чате: `!y` жёлтый, `!r` красный, `!d` серый, `!w` белый, `!R` — выравнивание вправо. Метки только для чата — `!g`, `!b` и `!t` — из меню убираются.
|
|
142
145
|
|
|
143
146
|
### API
|
|
@@ -161,9 +164,9 @@ vote.addItem({
|
|
|
161
164
|
| Функция | Что делает |
|
|
162
165
|
| --- | --- |
|
|
163
166
|
| `create(name, options?)` | Меню в коде или уже существующее с таким именем. Имя с `LIST_` делает меню-список. Опции: `title` (текст или функция), `time`, `hideBack`, `hideExit`, `locked`, `activeWhen`. |
|
|
164
|
-
| `find(name)` · `register(
|
|
167
|
+
| `find(name)` · `register(...names)` | Меню по имени; `register` заранее читает их из файла: `register("MAIN_MENU", "ADMIN_MENU")`. |
|
|
165
168
|
| `show(player, name, options?)` · `close(player)` · `activeMenu(player)` · `lock(player)` | Меню игрока, какое бы оно ни было. |
|
|
166
|
-
| `addCondition(name, test)` · `addAction(name, handler)` · `addPlaceholder(name, value)` · `addRestriction(name, test, message?)` | То, что называют файлы меню и Pawn-плагины, — ответы функциями; `%name%` в их тексте —
|
|
169
|
+
| `addCondition(name, test)` · `addAction(name, handler)` · `addPlaceholder(name, value)` · `addRestriction(name, test, message?)` · `addActions({ NAME: handler })` · `addPlaceholders({ name: value })` | То, что называют файлы меню и Pawn-плагины, — ответы функциями; `%name%` в их тексте — плейсхолдер; `addActions` и `addPlaceholders` принимают несколько сразу. Действие или плейсхолдер — функция игрока, `(player) => ...`, или контекста меню. Действие, плейсхолдер и ограничение получают контекст меню и имя `name`, по которому их спросили; условие, `(player, viewer, name)`, в меню-списке спрашивается об игроке строки. `message` ограничения пишется рядом с пунктом, который оно гасит, если у пункта или требования нет своего. `menu.addPlaceholder(name, value)` задаёт его одному меню. |
|
|
167
170
|
| `setListSource(name, rows)` · `refresh("A B")` · `conditionChanged(name)` · `addEventListener(type, listener)` | То же для меню по имени и события всех меню. |
|
|
168
171
|
|
|
169
172
|
## Меню в файле
|
|
@@ -280,7 +283,7 @@ VIEW = {
|
|
|
280
283
|
|
|
281
284
|
| YAML, JSON | INI | Что это |
|
|
282
285
|
| --- | --- | --- |
|
|
283
|
-
| `chatPrefix` | `[MAIN]` `PREFIX` | Префикс сообщений Menu Core в чате. |
|
|
286
|
+
| `chatPrefix` | `[MAIN]` `PREFIX` | Префикс сообщений Menu Core в чате. `[Основное]` из Pawn-модуля menu_core читается как `[MAIN]`. |
|
|
284
287
|
| `labels`: `exit`, `back`, `next`, `number`, `disabled`, `page`, `time` | `[MAIN]` `KEY = { ... }` | Слова кнопок, страницы и отсчёта. |
|
|
285
288
|
| `menus`: `{ NAME: меню }` | `[NAME]` | Меню; имя на `LIST_` — меню-список. |
|
|
286
289
|
| `title` | `TITLE` | Заголовок; он у меню обязателен. |
|
|
@@ -317,6 +320,7 @@ VIEW = {
|
|
|
317
320
|
| `TEAM_CT` · `TEAM_TERRORIST` · `TEAM_SPECTATOR` · `TEAM_UNASSIGNED` | в этой команде |
|
|
318
321
|
| `IS_BOT` | бот |
|
|
319
322
|
| `IS_ADMIN` | имеет любой доступ, кроме `z` простого игрока, — `is_user_admin` AMX Mod X |
|
|
323
|
+
| `ADMIN` · `ACCESS_ADMIN` | имеет доступ ban, rcon, admin или menu — `FLAG_dluy`, как отвечал Pawn menu_core |
|
|
320
324
|
| `FLAG_<буквы>` | имеет любую из этих букв `users.ini`: `FLAG_ab` |
|
|
321
325
|
|
|
322
326
|
В меню-списке условие вида или фильтра спрашивается у игрока строки, а ограничение получает строку как цель. Регистр в именах не важен.
|
|
@@ -332,7 +336,6 @@ VIEW = {
|
|
|
332
336
|
> - **Имя пункта в YAML или JSON не делится по `|`:** его варианты пишутся через `variants`.
|
|
333
337
|
> - **Цвета** и в файле меню пишутся метками: `!y`, `!r`, `!d`, `!w`, `!R`. На коды Pawn (`\y`, `\r`) будет предупреждение с меткой, которую писать, и они выбрасываются. Текст из Pawn — пункты и заголовки Pawn-плагина, словарь lang — сохраняет свои коды, и Menu Core читает их как метки.
|
|
334
338
|
> - **`%time%` и `%target%` пишутся строчными:** `%TIME%` и `%s` остаются как написаны.
|
|
335
|
-
> - **`ADMIN` и `ACCESS_ADMIN` не встроены:** их регистрирует плагин, или файл пишет `IS_ADMIN` (любой админ) или `FLAG_<буквы>` (`FLAG_d`).
|
|
336
339
|
|
|
337
340
|
### Столбцы INI
|
|
338
341
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amxts/menu-core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"description": "Menus for amxts plugins, from ini files or code: conditions, placeholders, lists - and the mc_* natives for Pawn plugins.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "kukson777",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"lint:fix": "oxfmt && oxlint --fix --silent || oxlint --fix --silent || oxlint --fix"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@amxts/config-core": "^0.
|
|
53
|
-
"@amxts/core": "^0.
|
|
52
|
+
"@amxts/config-core": "^0.2.0",
|
|
53
|
+
"@amxts/core": "^0.3.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@e18e/eslint-plugin": "^0.8.1",
|
|
Binary file
|
package/prebuilt/manifest.json
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
{
|
|
2
|
-
"format":
|
|
2
|
+
"format": 2,
|
|
3
3
|
"module": "@amxts/menu-core",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"from": {
|
|
6
6
|
"@amxts/core": {
|
|
7
|
-
"version": "0.
|
|
8
|
-
"hash": "
|
|
7
|
+
"version": "0.3.0",
|
|
8
|
+
"hash": "1930bb0d9b7e1fa4857f2a6a4a011df0fbcb63ca",
|
|
9
|
+
"abi": "0.3.0+abi.1ff73017\nArrayCreate (ii)i\nArrayDestroy (i)i [1>\nArrayGetArray (iiii)i v,v,[a3>,v\nArrayPushArray (iii)i v,[a2,v\nArraySize (i)i\nGetLangTransKey (i)i s leaf\nLookupLangKey (iiii)i t,v,s,[1 leaf\nabort (iiii)\namxts_owner (ii)i\namxts_rpc (iiii)i\namxts_rpc_reply (ii)\namxts_rpc_result (i)\namxts_rpc_take (i)\namxts_serve (ii)\narg (i)i\narg_array (iii)i\narg_string (iii)i\narg_text (iii)i\nargc ()i\ncall (iiii)i\ncaller ()i\ncallfunc_begin_i (ii)i\ncallfunc_buffer (ii)i\ncallfunc_finish ()i\ncallfunc_push_int (i)i\ncallfunc_text (i)i\nconsole.error (i)\nconsole.info (i)\nconsole.warn (i)\ncreate_cvar (iiiiiiii)i s,s,v,s,v,v,v,v\ncvar_hook (ii)i\nemit_local (iiii)\nexport (ii)i\nget_cvar_pointer (i)i s leaf\nget_func_id (ii)i s,v\nget_maxplayers ()i\nget_name (iii)i\nget_players (iiii)i [32>,[1>,s,s\nget_user_flags (ii)i\nget_user_msgid (i)i s leaf\nham (iiii)i\nhook_on (ii)\nis_user_alive (i)i\nis_user_bot (i)i\nis_user_connected (i)i\nmember_get (iii)i\nmember_slot (ii)i\nmsg_hook (ii)i\non (iii)\non_direct (iiiiii)\noutcome (i)\nplayer_data_set (iiF)\nplayer_names (i)\nplayer_slots (i)\nplugin (iiii)\nprecache_generic (i)i s\nprecache_model (i)i s\nprecache_sound (i)i s\nread_flags (i)i s leaf\nregister_menucmd (iii)i v,v,s\nregister_menuid (ii)i s,v\nsay_text (iii)\nset_arg_text (iii)i\nshow_menu (iiiii)i v,v,s,v,s\nslot (iiii)i\nstack_frames (ii)i\nstop_task (i)i\ntag (i)\ntask (iii)i"
|
|
9
10
|
},
|
|
10
11
|
"@amxts/config-core": {
|
|
11
|
-
"version": "0.
|
|
12
|
-
"hash": "
|
|
12
|
+
"version": "0.2.0",
|
|
13
|
+
"hash": "fc3b2c2731f6044d4ce8dab8fe1471b4441ad8c9"
|
|
13
14
|
},
|
|
14
15
|
"@amxts/menu-core": {
|
|
15
|
-
"version": "0.
|
|
16
|
-
"hash": "
|
|
16
|
+
"version": "0.3.0",
|
|
17
|
+
"hash": "bacd6b942fd000d79efbb809de7e4724f96ac3c3"
|
|
17
18
|
}
|
|
18
19
|
},
|
|
19
20
|
"options": {
|
|
@@ -694,18 +695,18 @@
|
|
|
694
695
|
"systems": {
|
|
695
696
|
"windows": {
|
|
696
697
|
"file": "prebuilt/windows/menu-core.aot",
|
|
697
|
-
"size":
|
|
698
|
-
"sha256": "
|
|
698
|
+
"size": 1194156,
|
|
699
|
+
"sha256": "c6883d6548da2d06b254a070f4902c6a63e8e50ed22b1c2a2d673afacd58ba92"
|
|
699
700
|
},
|
|
700
701
|
"linux": {
|
|
701
702
|
"file": "prebuilt/linux/menu-core.aot",
|
|
702
|
-
"size":
|
|
703
|
-
"sha256": "
|
|
703
|
+
"size": 1202952,
|
|
704
|
+
"sha256": "d7721e2f624c6259375559d95502ad9af3dc73e11042e800f6ec211a4de8869e"
|
|
704
705
|
}
|
|
705
706
|
},
|
|
706
707
|
"surface": {
|
|
707
|
-
"proxy": "// GENERATED by scripts/shared-modules.ts: ~/modules/menu-core in a plugin that does not own it.\n// Each function runs in menu-core.aot, the one instance on the server.\nimport { Reader as __Reader, Writer as __Writer, beginCallback as __beginCallback, callBack as __callBack, receiveFunction as __receiveFunction, remoteTarget as __remoteTarget, sendFunction as __sendFunction, Service as __Service } from \"~/remote\";\nimport { Player as __Player } from \"~/facade\";\nimport { Player, lang } from \"~/facade\";\n\nexport class MenuEvent {\n\t/** A mark of `preventDefault()`: `true` once it was called. */\n\tdefaultPrevented = false;\n\n\tconstructor(\n\t\t/** The player whose menu it is. */\n\t\tpublic player: Player,\n\t\t/** The menu the event is about. */\n\t\tpublic menu: Menu,\n\t\t/** On `\"close\"`: `true` when the menu closed because its time ran out. */\n\t\tpublic timeout: boolean,\n\t) {}\n\n\t/** On `\"show\"`: keeps the menu from opening. */\n\tpreventDefault() {\n\t\tthis.defaultPrevented = true;\n\t}\n}\n\nexport type MenuListener = (event: MenuEvent) => void;\n\nexport type MenuKind = \"items\" | \"list\";\n\nexport interface MenuContext {\n\t/** The player the menu is shown to: who looks at it, and who chooses. */\n\tplayer: Player;\n\t/** The player the menu is about: the row's in a list menu, the one `show()` was given as `target` in an items menu; `player` himself when there is none. */\n\ttarget: Player;\n\t/** The row's number in a list menu, as `listRow()` gave it - e.g. an entity or an index of the source's own; a player's `id` in a list of players. In an items menu, the `id` of the menu's target, `0` without one. */\n\trow: number;\n\t/** The menu the function is asked for. */\n\tmenu: Menu;\n}\n\nexport interface NamedContext extends MenuContext {\n\t/** The name it is asked by: an action's or a placeholder's, a restriction's whole token - `\"NAME:param\"` included; for an action check, the item's action. */\n\tname: string;\n}\n\nexport type MenuText = string | ((context: MenuContext) => string);\n\nexport interface ListRow {\n\t/** The row's kind, one of `\"item\"` (a row to choose) or `\"text\"` (a line of text, not a choice). */\n\tkind: \"item\" | \"text\";\n\t/** The row's number, `row` of the context its item's functions get: e.g. a player's `id`, an entity or an index of the source's own; `0` for a line of text. */\n\ttarget: number;\n\t/** The row's text, put for `%name%` in the menu's row template. */\n\ttext: string;\n\t/** Action names of the row's own, run instead of the template's; `\"\"` for the template's. */\n\taction: string;\n\t/** Restriction names, space-separated: the row is greyed out unless each passes. */\n\trestriction: string;\n\t/** The text beside the row while it is greyed out; `\"\"` for the restriction's own message. */\n\trestrictionMessage: string;\n}\n\nexport interface MenuOptions {\n\t/** The menu's title: the text - a lang key too - or a function that gives it for the menu's context; left out, the menu's name. */\n\ttitle?: MenuText;\n\t/** Seconds on the countdown when the menu opens, e.g. `10`; left out, none. */\n\ttime?: number;\n\t/** Hiding of the `\"Back\"` button: `true` leaves it out. */\n\thideBack?: boolean;\n\t/** Hiding of the `\"Exit\"` button: `true` leaves it out. */\n\thideExit?: boolean;\n\t/** A lock on the menu: while `true`, items cannot be chosen and no other menu replaces this one. */\n\tlocked?: boolean;\n\t/** A test the menu opens under: while it says no, the menu does not open for the player. */\n\tactiveWhen?: (context: MenuContext) => boolean;\n}\n\nexport interface MenuShowOptions {\n\t/** Seconds on the countdown; left out, the countdown running goes on, or the menu's own starts. */\n\ttime?: number;\n\t/** The player the menu is about: `target` of the context its functions get, and `%target%`. */\n\ttarget?: Player;\n\t/** A new way back: `true` forgets the menus this one was opened from. */\n\tresetHistory?: boolean;\n\t/** Opening over a menu that holds on - a countdown, a lock: `true` opens anyway. */\n\tforce?: boolean;\n\t/** Leaving the menu out of the way back: `true` does not remember it. */\n\tskipHistory?: boolean;\n}\n\nexport interface MenuItemOptions {\n\t/** The item's text - a lang key too - or a function that gives it for the menu's context. */\n\ttitle: MenuText;\n\t/** The function run when the item is chosen; the menu is drawn again after it, while it stays open. */\n\tonSelect?: (context: MenuContext) => void;\n\t/** A test the item is shown under: while it says no, the item is left out and takes no slot. */\n\tvisible?: (context: MenuContext) => boolean;\n\t/**\n\t * A test the item can be chosen under - while it says no, the item is\n\t * greyed out with `message` beside it; or a list of requirements, each with\n\t * a message of its own - the first that fails gives its message.\n\t *\n\t * enabled: [\n\t * { when: ({ player }) => player.frags >= 5, message: \"5 frags needed\" },\n\t * { when: ({ player }) => player.armor < 100, message: ({ player }) => `(${player.armor} already)` },\n\t * ],\n\t */\n\tenabled?: ((context: MenuContext) => boolean) | Requirement[];\n\t/** The text beside the item while `enabled` greys it out, for a requirement without a message of its own: the text, e.g. `\"(full)\"`, or a function that gives it for the menu's context. */\n\tmessage?: MenuText;\n\t/** The text after the item's title, for items of menu files and Pawn plugins, placeholders and all, e.g. `\"%hp%\"`; in code the title is a function instead. */\n\tplaceholder?: string;\n\t/** Action names from `addAction()` run when the item is chosen, or a built-in one: `\"SHOW_<MENU>\"`, `\"CLOSE_MENU\"`. */\n\taction?: string;\n\t/** The item's place among the items, from `0`; left out, the end. */\n\tat?: number;\n\t/** Blank lines before the item. */\n\tspaceBefore?: number;\n\t/** Blank lines after the item. */\n\tspaceAfter?: number;\n}\n\nexport interface Requirement {\n\t/** A test the requirement holds under, given the menu's context. */\n\twhen: (context: MenuContext) => boolean;\n\t/** The text beside the item while `when` says no: the text, a lang key, or a function that gives it for the menu's context; left out, the item's `message`. */\n\tmessage?: MenuText;\n}\n\nexport type ConditionTest = (player: Player, viewer: Player, name: string) => boolean;\n\nexport type ActionHandler = (context: NamedContext) => void;\n\nexport type PlaceholderValue = (context: NamedContext) => string;\n\nexport type RestrictionTest = (context: NamedContext) => boolean;\n\nexport type ActionTest = (context: NamedContext) => boolean;\n\nexport type ConditionFilter = (player: Player, viewer: Player, name: string, value: boolean) => boolean;\n\nexport type RowTest = (context: MenuContext) => boolean;\n\nexport type ListSource = (context: MenuContext) => ListRow[] | null;\n\nexport type MenuEventType = \"open\" | \"close\" | \"show\";\n\nexport interface MenuCoreOptions {\n\t/** The menu file, from `configs/`: e.g. `\"menu\"` is `configs/menu.ini`, `menu.yaml`, `menu.yml`, `menu.json` or `menu.jsonc` - the first that is there; `\"myserver/menu.yaml\"` is that file. */\n\tfile: string;\n\t/** The file read instead when `file` is empty or not there, e.g. `\"menu\"` for `configs/menu.ini` or `menu.yaml`; `\"\"` is none. */\n\tfallback: string;\n}\n\n/** Menu in menu-core's plugin: each field is read and written there, each method runs there. */\nexport class Menu {\n\tconstructor(public __handle: i32) {}\n\n\tget kind(): string {\n\t\tconst w = __service.begin(27);\n\t\tw.i32(this.__handle);\n\t\treturn __r0(__service.call(w));\n\t}\n\n\tget hideBack(): bool {\n\t\tconst w = __service.begin(28);\n\t\tw.i32(this.__handle);\n\t\treturn __r1(__service.call(w));\n\t}\n\tset hideBack(value: bool) {\n\t\tconst w = __service.begin(29);\n\t\tw.i32(this.__handle);\n\t\t__w1(w, value);\n\t\t__service.call(w);\n\t}\n\n\tget hideExit(): bool {\n\t\tconst w = __service.begin(30);\n\t\tw.i32(this.__handle);\n\t\treturn __r1(__service.call(w));\n\t}\n\tset hideExit(value: bool) {\n\t\tconst w = __service.begin(31);\n\t\tw.i32(this.__handle);\n\t\t__w1(w, value);\n\t\t__service.call(w);\n\t}\n\n\tget locked(): bool {\n\t\tconst w = __service.begin(32);\n\t\tw.i32(this.__handle);\n\t\treturn __r1(__service.call(w));\n\t}\n\tset locked(value: bool) {\n\t\tconst w = __service.begin(33);\n\t\tw.i32(this.__handle);\n\t\t__w1(w, value);\n\t\t__service.call(w);\n\t}\n\n\tget sharedTimer(): bool {\n\t\tconst w = __service.begin(34);\n\t\tw.i32(this.__handle);\n\t\treturn __r1(__service.call(w));\n\t}\n\tset sharedTimer(value: bool) {\n\t\tconst w = __service.begin(35);\n\t\tw.i32(this.__handle);\n\t\t__w1(w, value);\n\t\t__service.call(w);\n\t}\n\n\tget time(): f64 {\n\t\tconst w = __service.begin(36);\n\t\tw.i32(this.__handle);\n\t\treturn __r2(__service.call(w));\n\t}\n\tset time(value: f64) {\n\t\tconst w = __service.begin(37);\n\t\tw.i32(this.__handle);\n\t\t__w2(w, value);\n\t\t__service.call(w);\n\t}\n\n\tget onTimeout(): string {\n\t\tconst w = __service.begin(38);\n\t\tw.i32(this.__handle);\n\t\treturn __r0(__service.call(w));\n\t}\n\tset onTimeout(value: string) {\n\t\tconst w = __service.begin(39);\n\t\tw.i32(this.__handle);\n\t\t__w0(w, value);\n\t\t__service.call(w);\n\t}\n\n\tget activeOn(): string {\n\t\tconst w = __service.begin(40);\n\t\tw.i32(this.__handle);\n\t\treturn __r0(__service.call(w));\n\t}\n\tset activeOn(value: string) {\n\t\tconst w = __service.begin(41);\n\t\tw.i32(this.__handle);\n\t\t__w0(w, value);\n\t\t__service.call(w);\n\t}\n\n\tget countdown(): f64 {\n\t\tconst w = __service.begin(42);\n\t\tw.i32(this.__handle);\n\t\treturn __r2(__service.call(w));\n\t}\n\tset countdown(value: f64) {\n\t\tconst w = __service.begin(43);\n\t\tw.i32(this.__handle);\n\t\t__w2(w, value);\n\t\t__service.call(w);\n\t}\n\n\tget name(): string {\n\t\tconst w = __service.begin(44);\n\t\tw.i32(this.__handle);\n\t\treturn __r0(__service.call(w));\n\t}\n\n\tget title(): (a0: MenuContext) => string {\n\t\tconst w = __service.begin(45);\n\t\tw.i32(this.__handle);\n\t\treturn __r3(__service.call(w));\n\t}\n\tset title(value: string | ((context: MenuContext) => string)) {\n\t\tconst w = __service.begin(46);\n\t\tw.i32(this.__handle);\n\t\t__w3(w, value);\n\t\t__service.call(w);\n\t}\n\n\taddItem(item: MenuItemOptions): void {\n\t\tconst __w = __service.begin(47);\n\t\t__w.i32(this.__handle);\n\t\t__w4(__w, item);\n\t\tconst __r = __service.call(__w);\n\t}\n\n\taddFixedItem(slot: number, item: MenuItemOptions): void {\n\t\tconst __w = __service.begin(48);\n\t\t__w.i32(this.__handle);\n\t\t__w2(__w, slot);\n\t\t__w4(__w, item);\n\t\tconst __r = __service.call(__w);\n\t}\n\n\tclearItems(): void {\n\t\tconst __w = __service.begin(49);\n\t\t__w.i32(this.__handle);\n\t\tconst __r = __service.call(__w);\n\t}\n\n\taddFilter(test: RowTest, message?: string): void {\n\t\tconst __w = __service.begin(50);\n\t\t__w.i32(this.__handle);\n\t\t__w8(__w, test);\n\t\t__w13(__w, message);\n\t\tconst __r = __service.call(__w);\n\t}\n\n\taddPlaceholder(name: string, value: PlaceholderValue): void {\n\t\tconst __w = __service.begin(51);\n\t\t__w.i32(this.__handle);\n\t\t__w0(__w, name);\n\t\t__w14(__w, value);\n\t\tconst __r = __service.call(__w);\n\t}\n\n\tsetListSource(rows: ListSource): void {\n\t\tconst __w = __service.begin(52);\n\t\t__w.i32(this.__handle);\n\t\t__w15(__w, rows);\n\t\tconst __r = __service.call(__w);\n\t}\n\n\taddEventListener(type: MenuEventType, listener: MenuListener): void {\n\t\tconst __w = __service.begin(53);\n\t\t__w.i32(this.__handle);\n\t\t__w0(__w, type);\n\t\t__w16(__w, listener);\n\t\tconst __r = __service.call(__w);\n\t}\n\n\tshow(player: Player, options: MenuShowOptions = {}): bool {\n\t\tconst __w = __service.begin(54);\n\t\t__w.i32(this.__handle);\n\t\t__w17(__w, player);\n\t\t__w18(__w, options);\n\t\tconst __r = __service.call(__w);\n\t\treturn __r1(__r);\n\t}\n\n\trunActions(player: Player, line: string, target?: Player): void {\n\t\tconst __w = __service.begin(55);\n\t\t__w.i32(this.__handle);\n\t\t__w17(__w, player);\n\t\t__w0(__w, line);\n\t\t__w19(__w, target);\n\t\tconst __r = __service.call(__w);\n\t}\n\n\trefresh(): f64 {\n\t\tconst __w = __service.begin(56);\n\t\t__w.i32(this.__handle);\n\t\tconst __r = __service.call(__w);\n\t\treturn __r2(__r);\n\t}\n\n\tclose(): void {\n\t\tconst __w = __service.begin(57);\n\t\t__w.i32(this.__handle);\n\t\tconst __r = __service.call(__w);\n\t}\n\n\tsetTimer(seconds: number): bool {\n\t\tconst __w = __service.begin(58);\n\t\t__w.i32(this.__handle);\n\t\t__w2(__w, seconds);\n\t\tconst __r = __service.call(__w);\n\t\treturn __r1(__r);\n\t}\n\n\tcancelTimer(): bool {\n\t\tconst __w = __service.begin(59);\n\t\t__w.i32(this.__handle);\n\t\tconst __r = __service.call(__w);\n\t\treturn __r1(__r);\n\t}\n}\n\n\n\nconst __service = new __Service(\"menu-core\", 1989640665);\n\nfunction __w0(w: __Writer, v: string): void { w.str(v); }\n\nfunction __r0(r: __Reader): string { return r.str(); }\n\nfunction __w1(w: __Writer, v: bool): void { w.bool(v); }\n\nfunction __r1(r: __Reader): bool { return r.bool(); }\n\nfunction __w2(w: __Writer, v: f64): void { w.f64(<f64>v); }\n\nfunction __r2(r: __Reader): f64 { return <f64>r.f64(); }\n\nfunction __w3(w: __Writer, v: (a0: MenuContext) => string): void { w.i32(__sendFunction(changetype<usize>(v), 0, __invoke)); }\n\nfunction __r3(r: __Reader): (a0: MenuContext) => string { return changetype<(a0: MenuContext) => string>(__receiveFunction(r, changetype<usize>(__stub0))); }\n\nfunction __w6(w: __Writer, v: (a0: MenuContext) => void): void { w.i32(__sendFunction(changetype<usize>(v), 9, __invoke)); }\n\nfunction __r6(r: __Reader): (a0: MenuContext) => void { return changetype<(a0: MenuContext) => void>(__receiveFunction(r, changetype<usize>(__stub9))); }\n\nfunction __w5(w: __Writer, v: ((a0: MenuContext) => void) | null): void {\n\tif (v == null) {\n\t\tw.bool(false);\n\t\treturn;\n\t}\n\tw.bool(true);\n\t__w6(w, v!);\n}\n\nfunction __r5(r: __Reader): ((a0: MenuContext) => void) | null {\n\tif (!r.bool()) return null;\n\treturn __r6(r);\n}\n\nfunction __w8(w: __Writer, v: (a0: MenuContext) => bool): void { w.i32(__sendFunction(changetype<usize>(v), 1, __invoke)); }\n\nfunction __r8(r: __Reader): (a0: MenuContext) => bool { return changetype<(a0: MenuContext) => bool>(__receiveFunction(r, changetype<usize>(__stub1))); }\n\nfunction __w7(w: __Writer, v: ((a0: MenuContext) => bool) | null): void {\n\tif (v == null) {\n\t\tw.bool(false);\n\t\treturn;\n\t}\n\tw.bool(true);\n\t__w8(w, v!);\n}\n\nfunction __r7(r: __Reader): ((a0: MenuContext) => bool) | null {\n\tif (!r.bool()) return null;\n\treturn __r8(r);\n}\n\nfunction __w12(w: __Writer, v: ((a0: MenuContext) => string) | null): void {\n\tif (v == null) {\n\t\tw.bool(false);\n\t\treturn;\n\t}\n\tw.bool(true);\n\t__w3(w, v!);\n}\n\nfunction __r12(r: __Reader): ((a0: MenuContext) => string) | null {\n\tif (!r.bool()) return null;\n\treturn __r3(r);\n}\n\nfunction __w11(w: __Writer, v: Requirement): void {\n\t__w8(w, v.when);\n\t__w12(w, v.message);\n}\n\nfunction __u11(r: __Reader, o: Requirement): void {\n\to.when = __r8(r);\n\to.message = __r12(r);\n}\n\nfunction __r11(r: __Reader): Requirement {\n\tconst o = changetype<Requirement>(__new(offsetof<Requirement>(), idof<Requirement>()));\n\t__u11(r, o);\n\treturn o;\n}\n\nfunction __w10(w: __Writer, v: Array<Requirement>): void {\n\tw.i32(v.length);\n\tfor (let i: i32 = 0; i < v.length; i++) __w11(w, v[i]);\n}\n\nfunction __r10(r: __Reader): Array<Requirement> {\n\tconst count = r.i32();\n\tconst list = new Array<Requirement>();\n\tfor (let i: i32 = 0; i < count; i++) list.push(__r11(r));\n\treturn list;\n}\n\nfunction __w9(w: __Writer, v: Array<Requirement> | null): void {\n\tif (v == null) {\n\t\tw.bool(false);\n\t\treturn;\n\t}\n\tw.bool(true);\n\t__w10(w, v!);\n}\n\nfunction __r9(r: __Reader): Array<Requirement> | null {\n\tif (!r.bool()) return null;\n\treturn __r10(r);\n}\n\nfunction __w13(w: __Writer, v: string | null): void {\n\tif (v == null) {\n\t\tw.bool(false);\n\t\treturn;\n\t}\n\tw.bool(true);\n\t__w0(w, v!);\n}\n\nfunction __r13(r: __Reader): string | null {\n\tif (!r.bool()) return null;\n\treturn __r0(r);\n}\n\nfunction __w4(w: __Writer, v: MenuItemOptions): void {\n\t__w3(w, v.title);\n\t__w5(w, v.onSelect);\n\t__w7(w, v.visible);\n\t__w9(w, v.enabled);\n\t__w12(w, v.message);\n\t__w13(w, v.placeholder);\n\t__w13(w, v.action);\n\t__w2(w, v.at);\n\t__w2(w, v.spaceBefore);\n\t__w2(w, v.spaceAfter);\n}\n\nfunction __u4(r: __Reader, o: MenuItemOptions): void {\n\to.title = __r3(r);\n\to.onSelect = __r5(r);\n\to.visible = __r7(r);\n\to.enabled = __r9(r);\n\to.message = __r12(r);\n\to.placeholder = __r13(r);\n\to.action = __r13(r);\n\to.at = __r2(r);\n\to.spaceBefore = __r2(r);\n\to.spaceAfter = __r2(r);\n}\n\nfunction __r4(r: __Reader): MenuItemOptions {\n\tconst o = changetype<MenuItemOptions>(__new(offsetof<MenuItemOptions>(), idof<MenuItemOptions>()));\n\t__u4(r, o);\n\treturn o;\n}\n\nfunction __w14(w: __Writer, v: (a0: NamedContext) => string): void { w.i32(__sendFunction(changetype<usize>(v), 4, __invoke)); }\n\nfunction __r14(r: __Reader): (a0: NamedContext) => string { return changetype<(a0: NamedContext) => string>(__receiveFunction(r, changetype<usize>(__stub4))); }\n\nfunction __w15(w: __Writer, v: (a0: MenuContext) => Array<ListRow> | null): void { w.i32(__sendFunction(changetype<usize>(v), 7, __invoke)); }\n\nfunction __r15(r: __Reader): (a0: MenuContext) => Array<ListRow> | null { return changetype<(a0: MenuContext) => Array<ListRow> | null>(__receiveFunction(r, changetype<usize>(__stub7))); }\n\nfunction __w16(w: __Writer, v: (a0: MenuEvent) => void): void { w.i32(__sendFunction(changetype<usize>(v), 8, __invoke)); }\n\nfunction __r16(r: __Reader): (a0: MenuEvent) => void { return changetype<(a0: MenuEvent) => void>(__receiveFunction(r, changetype<usize>(__stub8))); }\n\nfunction __w17(w: __Writer, v: __Player): void { w.i32(<i32>v.id); }\n\nfunction __r17(r: __Reader): __Player { return new __Player(r.i32()); }\n\nfunction __w19(w: __Writer, v: __Player | null): void {\n\tif (v == null) {\n\t\tw.bool(false);\n\t\treturn;\n\t}\n\tw.bool(true);\n\t__w17(w, v!);\n}\n\nfunction __r19(r: __Reader): __Player | null {\n\tif (!r.bool()) return null;\n\treturn __r17(r);\n}\n\nfunction __w18(w: __Writer, v: MenuShowOptions): void {\n\t__w2(w, v.time);\n\t__w19(w, v.target);\n\tw.bool(v.resetHistory !== undefined);\n\tif (v.resetHistory !== undefined) __w1(w, v.resetHistory);\n\tw.bool(v.force !== undefined);\n\tif (v.force !== undefined) __w1(w, v.force);\n\tw.bool(v.skipHistory !== undefined);\n\tif (v.skipHistory !== undefined) __w1(w, v.skipHistory);\n}\n\nfunction __u18(r: __Reader, o: MenuShowOptions): void {\n\to.time = __r2(r);\n\to.target = __r19(r);\n\tif (r.bool()) o.resetHistory = __r1(r);\n\telse o.resetHistory = undefined;\n\tif (r.bool()) o.force = __r1(r);\n\telse o.force = undefined;\n\tif (r.bool()) o.skipHistory = __r1(r);\n\telse o.skipHistory = undefined;\n}\n\nfunction __r18(r: __Reader): MenuShowOptions {\n\tconst o = changetype<MenuShowOptions>(__new(offsetof<MenuShowOptions>(), idof<MenuShowOptions>()));\n\t__u18(r, o);\n\treturn o;\n}\n\nconst __h21 = new Map<i32, Menu>();\n\nfunction __w21(w: __Writer, v: Menu): void { w.i32(v.__handle); }\n\nfunction __r21(r: __Reader): Menu {\n\tconst id = r.i32();\n\tif (__h21.has(id)) return __h21.get(id);\n\tconst o = new Menu(id);\n\t__h21.set(id, o);\n\treturn o;\n}\n\nfunction __w20(w: __Writer, v: Menu | null): void {\n\tif (v == null) {\n\t\tw.bool(false);\n\t\treturn;\n\t}\n\tw.bool(true);\n\t__w21(w, v!);\n}\n\nfunction __r20(r: __Reader): Menu | null {\n\tif (!r.bool()) return null;\n\treturn __r21(r);\n}\n\nfunction __w22(w: __Writer, v: i32): void { w.f64(<f64>v); }\n\nfunction __r22(r: __Reader): i32 { return <i32>r.f64(); }\n\nfunction __w23(w: __Writer, v: MenuOptions): void {\n\t__w12(w, v.title);\n\t__w2(w, v.time);\n\tw.bool(v.hideBack !== undefined);\n\tif (v.hideBack !== undefined) __w1(w, v.hideBack);\n\tw.bool(v.hideExit !== undefined);\n\tif (v.hideExit !== undefined) __w1(w, v.hideExit);\n\tw.bool(v.locked !== undefined);\n\tif (v.locked !== undefined) __w1(w, v.locked);\n\t__w7(w, v.activeWhen);\n}\n\nfunction __u23(r: __Reader, o: MenuOptions): void {\n\to.title = __r12(r);\n\to.time = __r2(r);\n\tif (r.bool()) o.hideBack = __r1(r);\n\telse o.hideBack = undefined;\n\tif (r.bool()) o.hideExit = __r1(r);\n\telse o.hideExit = undefined;\n\tif (r.bool()) o.locked = __r1(r);\n\telse o.locked = undefined;\n\to.activeWhen = __r7(r);\n}\n\nfunction __r23(r: __Reader): MenuOptions {\n\tconst o = changetype<MenuOptions>(__new(offsetof<MenuOptions>(), idof<MenuOptions>()));\n\t__u23(r, o);\n\treturn o;\n}\n\nfunction __w24(w: __Writer, v: (a0: __Player, a1: __Player, a2: string) => bool): void { w.i32(__sendFunction(changetype<usize>(v), 2, __invoke)); }\n\nfunction __r24(r: __Reader): (a0: __Player, a1: __Player, a2: string) => bool { return changetype<(a0: __Player, a1: __Player, a2: string) => bool>(__receiveFunction(r, changetype<usize>(__stub2))); }\n\nfunction __w25(w: __Writer, v: (a0: NamedContext) => void): void { w.i32(__sendFunction(changetype<usize>(v), 3, __invoke)); }\n\nfunction __r25(r: __Reader): (a0: NamedContext) => void { return changetype<(a0: NamedContext) => void>(__receiveFunction(r, changetype<usize>(__stub3))); }\n\nfunction __w26(w: __Writer, v: (a0: NamedContext) => bool): void { w.i32(__sendFunction(changetype<usize>(v), 5, __invoke)); }\n\nfunction __r26(r: __Reader): (a0: NamedContext) => bool { return changetype<(a0: NamedContext) => bool>(__receiveFunction(r, changetype<usize>(__stub5))); }\n\nfunction __w27(w: __Writer, v: (a0: __Player, a1: __Player, a2: string, a3: bool) => bool): void { w.i32(__sendFunction(changetype<usize>(v), 6, __invoke)); }\n\nfunction __r27(r: __Reader): (a0: __Player, a1: __Player, a2: string, a3: bool) => bool { return changetype<(a0: __Player, a1: __Player, a2: string, a3: bool) => bool>(__receiveFunction(r, changetype<usize>(__stub6))); }\n\nfunction __w28(w: __Writer, v: ListRow): void {\n\t__w0(w, v.kind);\n\t__w2(w, v.target);\n\t__w0(w, v.text);\n\t__w0(w, v.action);\n\t__w0(w, v.restriction);\n\t__w0(w, v.restrictionMessage);\n}\n\nfunction __u28(r: __Reader, o: ListRow): void {\n\to.kind = __r0(r);\n\to.target = __r2(r);\n\to.text = __r0(r);\n\to.action = __r0(r);\n\to.restriction = __r0(r);\n\to.restrictionMessage = __r0(r);\n}\n\nfunction __r28(r: __Reader): ListRow {\n\tconst o = changetype<ListRow>(__new(offsetof<ListRow>(), idof<ListRow>()));\n\t__u28(r, o);\n\treturn o;\n}\n\nfunction __w29(w: __Writer, v: MenuContext): void {\n\t__w17(w, v.player);\n\t__w17(w, v.target);\n\t__w2(w, v.row);\n\t__w21(w, v.menu);\n}\n\nfunction __u29(r: __Reader, o: MenuContext): void {\n\to.player = __r17(r);\n\to.target = __r17(r);\n\to.row = __r2(r);\n\to.menu = __r21(r);\n}\n\nfunction __r29(r: __Reader): MenuContext {\n\tconst o = changetype<MenuContext>(__new(offsetof<MenuContext>(), idof<MenuContext>()));\n\t__u29(r, o);\n\treturn o;\n}\n\nfunction __w30(w: __Writer, v: NamedContext): void {\n\t__w17(w, v.player);\n\t__w17(w, v.target);\n\t__w2(w, v.row);\n\t__w21(w, v.menu);\n\t__w0(w, v.name);\n}\n\nfunction __u30(r: __Reader, o: NamedContext): void {\n\to.player = __r17(r);\n\to.target = __r17(r);\n\to.row = __r2(r);\n\to.menu = __r21(r);\n\to.name = __r0(r);\n}\n\nfunction __r30(r: __Reader): NamedContext {\n\tconst o = changetype<NamedContext>(__new(offsetof<NamedContext>(), idof<NamedContext>()));\n\t__u30(r, o);\n\treturn o;\n}\n\nfunction __w32(w: __Writer, v: Array<ListRow>): void {\n\tw.i32(v.length);\n\tfor (let i: i32 = 0; i < v.length; i++) __w28(w, v[i]);\n}\n\nfunction __r32(r: __Reader): Array<ListRow> {\n\tconst count = r.i32();\n\tconst list = new Array<ListRow>();\n\tfor (let i: i32 = 0; i < count; i++) list.push(__r28(r));\n\treturn list;\n}\n\nfunction __w31(w: __Writer, v: Array<ListRow> | null): void {\n\tif (v == null) {\n\t\tw.bool(false);\n\t\treturn;\n\t}\n\tw.bool(true);\n\t__w32(w, v!);\n}\n\nfunction __r31(r: __Reader): Array<ListRow> | null {\n\tif (!r.bool()) return null;\n\treturn __r32(r);\n}\n\nfunction __w33(w: __Writer, v: MenuEvent): void {\n\t__w1(w, v.defaultPrevented);\n\t__w17(w, v.player);\n\t__w21(w, v.menu);\n\t__w1(w, v.timeout);\n}\n\nfunction __u33(r: __Reader, o: MenuEvent): void {\n\to.defaultPrevented = __r1(r);\n\to.player = __r17(r);\n\to.menu = __r21(r);\n\to.timeout = __r1(r);\n}\n\nfunction __r33(r: __Reader): MenuEvent {\n\tconst o = changetype<MenuEvent>(__new(offsetof<MenuEvent>(), idof<MenuEvent>()));\n\t__u33(r, o);\n\treturn o;\n}\n\nfunction __stub0(a0: MenuContext): string {\n\tconst target = __remoteTarget();\n\tconst w = __beginCallback(target);\n\t__w29(w, a0);\n\tconst r = __callBack(target, w);\n\treturn __r0(r);\n}\n\nfunction __stub1(a0: MenuContext): bool {\n\tconst target = __remoteTarget();\n\tconst w = __beginCallback(target);\n\t__w29(w, a0);\n\tconst r = __callBack(target, w);\n\treturn __r1(r);\n}\n\nfunction __stub2(a0: __Player, a1: __Player, a2: string): bool {\n\tconst target = __remoteTarget();\n\tconst w = __beginCallback(target);\n\t__w17(w, a0);\n\t__w17(w, a1);\n\t__w0(w, a2);\n\tconst r = __callBack(target, w);\n\treturn __r1(r);\n}\n\nfunction __stub3(a0: NamedContext): void {\n\tconst target = __remoteTarget();\n\tconst w = __beginCallback(target);\n\t__w30(w, a0);\n\tconst r = __callBack(target, w);\n}\n\nfunction __stub4(a0: NamedContext): string {\n\tconst target = __remoteTarget();\n\tconst w = __beginCallback(target);\n\t__w30(w, a0);\n\tconst r = __callBack(target, w);\n\treturn __r0(r);\n}\n\nfunction __stub5(a0: NamedContext): bool {\n\tconst target = __remoteTarget();\n\tconst w = __beginCallback(target);\n\t__w30(w, a0);\n\tconst r = __callBack(target, w);\n\treturn __r1(r);\n}\n\nfunction __stub6(a0: __Player, a1: __Player, a2: string, a3: bool): bool {\n\tconst target = __remoteTarget();\n\tconst w = __beginCallback(target);\n\t__w17(w, a0);\n\t__w17(w, a1);\n\t__w0(w, a2);\n\t__w1(w, a3);\n\tconst r = __callBack(target, w);\n\treturn __r1(r);\n}\n\nfunction __stub7(a0: MenuContext): Array<ListRow> | null {\n\tconst target = __remoteTarget();\n\tconst w = __beginCallback(target);\n\t__w29(w, a0);\n\tconst r = __callBack(target, w);\n\treturn __r31(r);\n}\n\nfunction __stub8(a0: MenuEvent): void {\n\tconst target = __remoteTarget();\n\tconst w = __beginCallback(target);\n\t__w33(w, a0);\n\tconst r = __callBack(target, w);\n\t__u33(r, a0);\n}\n\nfunction __stub9(a0: MenuContext): void {\n\tconst target = __remoteTarget();\n\tconst w = __beginCallback(target);\n\t__w29(w, a0);\n\tconst r = __callBack(target, w);\n}\n\nfunction __invoke(fn: usize, sig: i32, r: __Reader, w: __Writer): void {\n\tswitch (sig) {\n\t\tcase 0: {\n\t\t\tconst a0 = __r29(r);\n\t\t\tconst f = changetype<(a0: MenuContext) => string>(fn);\n\t\t\tconst result = f(a0);\n\t\t\t__w0(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 1: {\n\t\t\tconst a0 = __r29(r);\n\t\t\tconst f = changetype<(a0: MenuContext) => bool>(fn);\n\t\t\tconst result = f(a0);\n\t\t\t__w1(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 2: {\n\t\t\tconst a0 = __r17(r);\n\t\t\tconst a1 = __r17(r);\n\t\t\tconst a2 = __r0(r);\n\t\t\tconst f = changetype<(a0: __Player, a1: __Player, a2: string) => bool>(fn);\n\t\t\tconst result = f(a0, a1, a2);\n\t\t\t__w1(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 3: {\n\t\t\tconst a0 = __r30(r);\n\t\t\tconst f = changetype<(a0: NamedContext) => void>(fn);\n\t\t\tf(a0);\n\t\t\tbreak;\n\t\t}\n\t\tcase 4: {\n\t\t\tconst a0 = __r30(r);\n\t\t\tconst f = changetype<(a0: NamedContext) => string>(fn);\n\t\t\tconst result = f(a0);\n\t\t\t__w0(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 5: {\n\t\t\tconst a0 = __r30(r);\n\t\t\tconst f = changetype<(a0: NamedContext) => bool>(fn);\n\t\t\tconst result = f(a0);\n\t\t\t__w1(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 6: {\n\t\t\tconst a0 = __r17(r);\n\t\t\tconst a1 = __r17(r);\n\t\t\tconst a2 = __r0(r);\n\t\t\tconst a3 = __r1(r);\n\t\t\tconst f = changetype<(a0: __Player, a1: __Player, a2: string, a3: bool) => bool>(fn);\n\t\t\tconst result = f(a0, a1, a2, a3);\n\t\t\t__w1(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 7: {\n\t\t\tconst a0 = __r29(r);\n\t\t\tconst f = changetype<(a0: MenuContext) => Array<ListRow> | null>(fn);\n\t\t\tconst result = f(a0);\n\t\t\t__w31(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 8: {\n\t\t\tconst a0 = __r33(r);\n\t\t\tconst f = changetype<(a0: MenuEvent) => void>(fn);\n\t\t\tf(a0);\n\t\t\t__w33(w, a0);\n\t\t\tbreak;\n\t\t}\n\t\tcase 9: {\n\t\t\tconst a0 = __r29(r);\n\t\t\tconst f = changetype<(a0: MenuContext) => void>(fn);\n\t\t\tf(a0);\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\nexport function setConfigFile(file: string, fallback?: string): void {\n\tconst __w = __service.begin(0);\n\t__w0(__w, file);\n\t__w13(__w, fallback);\n\tconst __r = __service.call(__w);\n}\n\nexport function find(name: string): Menu | null {\n\tconst __w = __service.begin(1);\n\t__w0(__w, name);\n\tconst __r = __service.call(__w);\n\treturn __r20(__r);\n}\n\nexport function indexOf(menu: Menu | null): i32 {\n\tconst __w = __service.begin(2);\n\t__w20(__w, menu);\n\tconst __r = __service.call(__w);\n\treturn __r22(__r);\n}\n\nexport function menuAt(index: number): Menu | null {\n\tconst __w = __service.begin(3);\n\t__w2(__w, index);\n\tconst __r = __service.call(__w);\n\treturn __r20(__r);\n}\n\nexport function register(name: string): Menu | null {\n\tconst __w = __service.begin(4);\n\t__w0(__w, name);\n\tconst __r = __service.call(__w);\n\treturn __r20(__r);\n}\n\nexport function create(name: string, options: MenuOptions = {}): Menu {\n\tconst __w = __service.begin(5);\n\t__w0(__w, name);\n\t__w23(__w, options);\n\tconst __r = __service.call(__w);\n\treturn __r21(__r);\n}\n\nexport function addCondition(name: string, test: ConditionTest): i32 {\n\tconst __w = __service.begin(6);\n\t__w0(__w, name);\n\t__w24(__w, test);\n\tconst __r = __service.call(__w);\n\treturn __r22(__r);\n}\n\nexport function addAction(name: string, run: ActionHandler): i32 {\n\tconst __w = __service.begin(7);\n\t__w0(__w, name);\n\t__w25(__w, run);\n\tconst __r = __service.call(__w);\n\treturn __r22(__r);\n}\n\nexport function addPlaceholder(name: string, value: PlaceholderValue): i32 {\n\tconst __w = __service.begin(8);\n\t__w0(__w, name);\n\t__w14(__w, value);\n\tconst __r = __service.call(__w);\n\treturn __r22(__r);\n}\n\nexport function addRestriction(name: string, test: RestrictionTest, message?: string): i32 {\n\tconst __w = __service.begin(9);\n\t__w0(__w, name);\n\t__w26(__w, test);\n\t__w13(__w, message);\n\tconst __r = __service.call(__w);\n\treturn __r22(__r);\n}\n\nexport function addActionCheck(menu: string, action: string, test: ActionTest): i32 {\n\tconst __w = __service.begin(10);\n\t__w0(__w, menu);\n\t__w0(__w, action);\n\t__w26(__w, test);\n\tconst __r = __service.call(__w);\n\treturn __r22(__r);\n}\n\nexport function addConditionFilter(name: string, filter: ConditionFilter): i32 {\n\tconst __w = __service.begin(11);\n\t__w0(__w, name);\n\t__w27(__w, filter);\n\tconst __r = __service.call(__w);\n\treturn __r22(__r);\n}\n\nexport function setListSource(menu: string, rows: ListSource): i32 {\n\tconst __w = __service.begin(12);\n\t__w0(__w, menu);\n\t__w15(__w, rows);\n\tconst __r = __service.call(__w);\n\treturn __r22(__r);\n}\n\nexport function addEventListener(type: MenuEventType, listener: MenuListener): i32 {\n\tconst __w = __service.begin(13);\n\t__w0(__w, type);\n\t__w16(__w, listener);\n\tconst __r = __service.call(__w);\n\treturn __r22(__r);\n}\n\nexport function listRow(target: number, text: string, action?: string, restriction?: string, restrictionMessage?: string): ListRow {\n\tconst __w = __service.begin(14);\n\t__w2(__w, target);\n\t__w0(__w, text);\n\t__w13(__w, action);\n\t__w13(__w, restriction);\n\t__w13(__w, restrictionMessage);\n\tconst __r = __service.call(__w);\n\treturn __r28(__r);\n}\n\nexport function textRow(text: string, centered = false): ListRow {\n\tconst __w = __service.begin(15);\n\t__w0(__w, text);\n\t__w1(__w, centered);\n\tconst __r = __service.call(__w);\n\treturn __r28(__r);\n}\n\nexport function show(player: Player, name: string, options: MenuShowOptions = {}): bool {\n\tconst __w = __service.begin(16);\n\t__w17(__w, player);\n\t__w0(__w, name);\n\t__w18(__w, options);\n\tconst __r = __service.call(__w);\n\treturn __r1(__r);\n}\n\nexport function close(player: Player, timeout = false): void {\n\tconst __w = __service.begin(17);\n\t__w17(__w, player);\n\t__w1(__w, timeout);\n\tconst __r = __service.call(__w);\n}\n\nexport function refresh(names: string): f64 {\n\tconst __w = __service.begin(18);\n\t__w0(__w, names);\n\tconst __r = __service.call(__w);\n\treturn __r2(__r);\n}\n\nexport function conditionChanged(name: string): void {\n\tconst __w = __service.begin(19);\n\t__w0(__w, name);\n\tconst __r = __service.call(__w);\n}\n\nexport function activeMenu(player: Player): Menu | null {\n\tconst __w = __service.begin(20);\n\t__w17(__w, player);\n\tconst __r = __service.call(__w);\n\treturn __r20(__r);\n}\n\nexport function shownText(player: Player): string {\n\tconst __w = __service.begin(21);\n\t__w17(__w, player);\n\tconst __r = __service.call(__w);\n\treturn __r0(__r);\n}\n\nexport function lock(player: Player, locked = true): void {\n\tconst __w = __service.begin(22);\n\t__w17(__w, player);\n\t__w1(__w, locked);\n\tconst __r = __service.call(__w);\n}\n\nexport function isLocked(player: Player): bool {\n\tconst __w = __service.begin(23);\n\t__w17(__w, player);\n\tconst __r = __service.call(__w);\n\treturn __r1(__r);\n}\n\nexport function setPage(player: Player, page: number): void {\n\tconst __w = __service.begin(24);\n\t__w17(__w, player);\n\t__w2(__w, page);\n\tconst __r = __service.call(__w);\n}\n\nexport function hasAction(name: string): bool {\n\tconst __w = __service.begin(25);\n\t__w0(__w, name);\n\tconst __r = __service.call(__w);\n\treturn __r1(__r);\n}\n\nexport function hasText(name: string): bool {\n\tconst __w = __service.begin(26);\n\t__w0(__w, name);\n\tconst __r = __service.call(__w);\n\treturn __r1(__r);\n}\n",
|
|
708
|
-
"serve": "// GENERATED by scripts/shared-modules.ts: ~/modules/menu-core, run by this plugin for every other.\nimport { Reader as __Reader, Writer as __Writer, beginCallback as __beginCallback, callBack as __callBack, receiveFunction as __receiveFunction, remoteTarget as __remoteTarget, sendFunction as __sendFunction, Handles as __Handles, serve as __serve } from \"~/remote\";\nimport * as __m from \"~/modules/menu-core\";\nimport { Player as __Player } from \"~/facade\";\nimport { Menu as __M_Menu, MenuContext as __M_MenuContext, MenuOptions as __M_MenuOptions, NamedContext as __M_NamedContext, ListRow as __M_ListRow, MenuEvent as __M_MenuEvent, MenuShowOptions as __M_MenuShowOptions, MenuItemOptions as __M_MenuItemOptions, Requirement as __M_Requirement } from \"~/modules/menu-core\";\n\nconst __handles = new __Handles();\n// The exported objects are handles 1, 2, ... - the numbers the proxies have.\n\nfunction __dispatch(op: i32, r: __Reader, w: __Writer): void {\n\tswitch (op) {\n\t\tcase 0: {\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst a1 = __r1(r);\n\t\t\t__m.setConfigFile(a0, a1);\n\t\t\tbreak;\n\t\t}\n\t\tcase 1: {\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst result = __m.find(a0);\n\t\t\t__w2(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 2: {\n\t\t\tconst a0 = __r2(r);\n\t\t\tconst result = __m.indexOf(a0);\n\t\t\t__w4(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 3: {\n\t\t\tconst a0 = __r5(r);\n\t\t\tconst result = __m.menuAt(a0);\n\t\t\t__w2(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 4: {\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst result = __m.register(a0);\n\t\t\t__w2(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 5: {\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst a1 = __r6(r);\n\t\t\tconst result = __m.create(a0, a1);\n\t\t\t__w3(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 6: {\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst a1 = __r12(r);\n\t\t\tconst result = __m.addCondition(a0, a1);\n\t\t\t__w4(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 7: {\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst a1 = __r13(r);\n\t\t\tconst result = __m.addAction(a0, a1);\n\t\t\t__w4(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 8: {\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst a1 = __r14(r);\n\t\t\tconst result = __m.addPlaceholder(a0, a1);\n\t\t\t__w4(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 9: {\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst a1 = __r15(r);\n\t\t\tconst a2 = __r1(r);\n\t\t\tconst result = __m.addRestriction(a0, a1, a2);\n\t\t\t__w4(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 10: {\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst a1 = __r0(r);\n\t\t\tconst a2 = __r15(r);\n\t\t\tconst result = __m.addActionCheck(a0, a1, a2);\n\t\t\t__w4(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 11: {\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst a1 = __r16(r);\n\t\t\tconst result = __m.addConditionFilter(a0, a1);\n\t\t\t__w4(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 12: {\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst a1 = __r17(r);\n\t\t\tconst result = __m.setListSource(a0, a1);\n\t\t\t__w4(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 13: {\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst a1 = __r18(r);\n\t\t\tconst result = __m.addEventListener(a0, a1);\n\t\t\t__w4(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 14: {\n\t\t\tconst a0 = __r5(r);\n\t\t\tconst a1 = __r0(r);\n\t\t\tconst a2 = __r1(r);\n\t\t\tconst a3 = __r1(r);\n\t\t\tconst a4 = __r1(r);\n\t\t\tconst result = __m.listRow(a0, a1, a2, a3, a4);\n\t\t\t__w19(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 15: {\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst a1 = __r9(r);\n\t\t\tconst result = __m.textRow(a0, a1);\n\t\t\t__w19(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 16: {\n\t\t\tconst a0 = __r20(r);\n\t\t\tconst a1 = __r0(r);\n\t\t\tconst a2 = __r21(r);\n\t\t\tconst result = __m.show(a0, a1, a2);\n\t\t\t__w9(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 17: {\n\t\t\tconst a0 = __r20(r);\n\t\t\tconst a1 = __r9(r);\n\t\t\t__m.close(a0, a1);\n\t\t\tbreak;\n\t\t}\n\t\tcase 18: {\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst result = __m.refresh(a0);\n\t\t\t__w5(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 19: {\n\t\t\tconst a0 = __r0(r);\n\t\t\t__m.conditionChanged(a0);\n\t\t\tbreak;\n\t\t}\n\t\tcase 20: {\n\t\t\tconst a0 = __r20(r);\n\t\t\tconst result = __m.activeMenu(a0);\n\t\t\t__w2(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 21: {\n\t\t\tconst a0 = __r20(r);\n\t\t\tconst result = __m.shownText(a0);\n\t\t\t__w0(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 22: {\n\t\t\tconst a0 = __r20(r);\n\t\t\tconst a1 = __r9(r);\n\t\t\t__m.lock(a0, a1);\n\t\t\tbreak;\n\t\t}\n\t\tcase 23: {\n\t\t\tconst a0 = __r20(r);\n\t\t\tconst result = __m.isLocked(a0);\n\t\t\t__w9(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 24: {\n\t\t\tconst a0 = __r20(r);\n\t\t\tconst a1 = __r5(r);\n\t\t\t__m.setPage(a0, a1);\n\t\t\tbreak;\n\t\t}\n\t\tcase 25: {\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst result = __m.hasAction(a0);\n\t\t\t__w9(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 26: {\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst result = __m.hasText(a0);\n\t\t\t__w9(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 27: {\n\t\t\tconst o = __r3(r);\n\t\t\t__w0(w, o.kind);\n\t\t\tbreak;\n\t\t}\n\t\tcase 28: {\n\t\t\tconst o = __r3(r);\n\t\t\t__w9(w, o.hideBack);\n\t\t\tbreak;\n\t\t}\n\t\tcase 29: {\n\t\t\tconst o = __r3(r);\n\t\t\to.hideBack = __r9(r);\n\t\t\tbreak;\n\t\t}\n\t\tcase 30: {\n\t\t\tconst o = __r3(r);\n\t\t\t__w9(w, o.hideExit);\n\t\t\tbreak;\n\t\t}\n\t\tcase 31: {\n\t\t\tconst o = __r3(r);\n\t\t\to.hideExit = __r9(r);\n\t\t\tbreak;\n\t\t}\n\t\tcase 32: {\n\t\t\tconst o = __r3(r);\n\t\t\t__w9(w, o.locked);\n\t\t\tbreak;\n\t\t}\n\t\tcase 33: {\n\t\t\tconst o = __r3(r);\n\t\t\to.locked = __r9(r);\n\t\t\tbreak;\n\t\t}\n\t\tcase 34: {\n\t\t\tconst o = __r3(r);\n\t\t\t__w9(w, o.sharedTimer);\n\t\t\tbreak;\n\t\t}\n\t\tcase 35: {\n\t\t\tconst o = __r3(r);\n\t\t\to.sharedTimer = __r9(r);\n\t\t\tbreak;\n\t\t}\n\t\tcase 36: {\n\t\t\tconst o = __r3(r);\n\t\t\t__w5(w, o.time);\n\t\t\tbreak;\n\t\t}\n\t\tcase 37: {\n\t\t\tconst o = __r3(r);\n\t\t\to.time = __r5(r);\n\t\t\tbreak;\n\t\t}\n\t\tcase 38: {\n\t\t\tconst o = __r3(r);\n\t\t\t__w0(w, o.onTimeout);\n\t\t\tbreak;\n\t\t}\n\t\tcase 39: {\n\t\t\tconst o = __r3(r);\n\t\t\to.onTimeout = __r0(r);\n\t\t\tbreak;\n\t\t}\n\t\tcase 40: {\n\t\t\tconst o = __r3(r);\n\t\t\t__w0(w, o.activeOn);\n\t\t\tbreak;\n\t\t}\n\t\tcase 41: {\n\t\t\tconst o = __r3(r);\n\t\t\to.activeOn = __r0(r);\n\t\t\tbreak;\n\t\t}\n\t\tcase 42: {\n\t\t\tconst o = __r3(r);\n\t\t\t__w5(w, o.countdown);\n\t\t\tbreak;\n\t\t}\n\t\tcase 43: {\n\t\t\tconst o = __r3(r);\n\t\t\to.countdown = __r5(r);\n\t\t\tbreak;\n\t\t}\n\t\tcase 44: {\n\t\t\tconst o = __r3(r);\n\t\t\t__w0(w, o.name);\n\t\t\tbreak;\n\t\t}\n\t\tcase 45: {\n\t\t\tconst o = __r3(r);\n\t\t\t__w8(w, o.title);\n\t\t\tbreak;\n\t\t}\n\t\tcase 46: {\n\t\t\tconst o = __r3(r);\n\t\t\to.title = __r8(r);\n\t\t\tbreak;\n\t\t}\n\t\tcase 47: {\n\t\t\tconst o = __r3(r);\n\t\t\tconst a0 = __r23(r);\n\t\t\to.addItem(a0);\n\t\t\tbreak;\n\t\t}\n\t\tcase 48: {\n\t\t\tconst o = __r3(r);\n\t\t\tconst a0 = __r5(r);\n\t\t\tconst a1 = __r23(r);\n\t\t\to.addFixedItem(a0, a1);\n\t\t\tbreak;\n\t\t}\n\t\tcase 49: {\n\t\t\tconst o = __r3(r);\n\t\t\to.clearItems();\n\t\t\tbreak;\n\t\t}\n\t\tcase 50: {\n\t\t\tconst o = __r3(r);\n\t\t\tconst a0 = __r11(r);\n\t\t\tconst a1 = __r1(r);\n\t\t\to.addFilter(a0, a1);\n\t\t\tbreak;\n\t\t}\n\t\tcase 51: {\n\t\t\tconst o = __r3(r);\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst a1 = __r14(r);\n\t\t\to.addPlaceholder(a0, a1);\n\t\t\tbreak;\n\t\t}\n\t\tcase 52: {\n\t\t\tconst o = __r3(r);\n\t\t\tconst a0 = __r17(r);\n\t\t\to.setListSource(a0);\n\t\t\tbreak;\n\t\t}\n\t\tcase 53: {\n\t\t\tconst o = __r3(r);\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst a1 = __r18(r);\n\t\t\to.addEventListener(a0, a1);\n\t\t\tbreak;\n\t\t}\n\t\tcase 54: {\n\t\t\tconst o = __r3(r);\n\t\t\tconst a0 = __r20(r);\n\t\t\tconst a1 = __r21(r);\n\t\t\tconst result = o.show(a0, a1);\n\t\t\t__w9(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 55: {\n\t\t\tconst o = __r3(r);\n\t\t\tconst a0 = __r20(r);\n\t\t\tconst a1 = __r0(r);\n\t\t\tconst a2 = __r22(r);\n\t\t\to.runActions(a0, a1, a2);\n\t\t\tbreak;\n\t\t}\n\t\tcase 56: {\n\t\t\tconst o = __r3(r);\n\t\t\tconst result = o.refresh();\n\t\t\t__w5(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 57: {\n\t\t\tconst o = __r3(r);\n\t\t\to.close();\n\t\t\tbreak;\n\t\t}\n\t\tcase 58: {\n\t\t\tconst o = __r3(r);\n\t\t\tconst a0 = __r5(r);\n\t\t\tconst result = o.setTimer(a0);\n\t\t\t__w9(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 59: {\n\t\t\tconst o = __r3(r);\n\t\t\tconst result = o.cancelTimer();\n\t\t\t__w9(w, result);\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\nfunction __stub0(a0: __M_MenuContext): string {\n\tconst target = __remoteTarget();\n\tconst w = __beginCallback(target);\n\t__w29(w, a0);\n\tconst r = __callBack(target, w);\n\treturn __r0(r);\n}\n\nfunction __stub1(a0: __M_MenuContext): bool {\n\tconst target = __remoteTarget();\n\tconst w = __beginCallback(target);\n\t__w29(w, a0);\n\tconst r = __callBack(target, w);\n\treturn __r9(r);\n}\n\nfunction __stub2(a0: __Player, a1: __Player, a2: string): bool {\n\tconst target = __remoteTarget();\n\tconst w = __beginCallback(target);\n\t__w20(w, a0);\n\t__w20(w, a1);\n\t__w0(w, a2);\n\tconst r = __callBack(target, w);\n\treturn __r9(r);\n}\n\nfunction __stub3(a0: __M_NamedContext): void {\n\tconst target = __remoteTarget();\n\tconst w = __beginCallback(target);\n\t__w30(w, a0);\n\tconst r = __callBack(target, w);\n}\n\nfunction __stub4(a0: __M_NamedContext): string {\n\tconst target = __remoteTarget();\n\tconst w = __beginCallback(target);\n\t__w30(w, a0);\n\tconst r = __callBack(target, w);\n\treturn __r0(r);\n}\n\nfunction __stub5(a0: __M_NamedContext): bool {\n\tconst target = __remoteTarget();\n\tconst w = __beginCallback(target);\n\t__w30(w, a0);\n\tconst r = __callBack(target, w);\n\treturn __r9(r);\n}\n\nfunction __stub6(a0: __Player, a1: __Player, a2: string, a3: bool): bool {\n\tconst target = __remoteTarget();\n\tconst w = __beginCallback(target);\n\t__w20(w, a0);\n\t__w20(w, a1);\n\t__w0(w, a2);\n\t__w9(w, a3);\n\tconst r = __callBack(target, w);\n\treturn __r9(r);\n}\n\nfunction __stub7(a0: __M_MenuContext): Array<__M_ListRow> | null {\n\tconst target = __remoteTarget();\n\tconst w = __beginCallback(target);\n\t__w29(w, a0);\n\tconst r = __callBack(target, w);\n\treturn __r31(r);\n}\n\nfunction __stub8(a0: __M_MenuEvent): void {\n\tconst target = __remoteTarget();\n\tconst w = __beginCallback(target);\n\t__w33(w, a0);\n\tconst r = __callBack(target, w);\n\t__u33(r, a0);\n}\n\nfunction __stub9(a0: __M_MenuContext): void {\n\tconst target = __remoteTarget();\n\tconst w = __beginCallback(target);\n\t__w29(w, a0);\n\tconst r = __callBack(target, w);\n}\n\nfunction __invoke(fn: usize, sig: i32, r: __Reader, w: __Writer): void {\n\tswitch (sig) {\n\t\tcase 0: {\n\t\t\tconst a0 = __r29(r);\n\t\t\tconst f = changetype<(a0: __M_MenuContext) => string>(fn);\n\t\t\tconst result = f(a0);\n\t\t\t__w0(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 1: {\n\t\t\tconst a0 = __r29(r);\n\t\t\tconst f = changetype<(a0: __M_MenuContext) => bool>(fn);\n\t\t\tconst result = f(a0);\n\t\t\t__w9(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 2: {\n\t\t\tconst a0 = __r20(r);\n\t\t\tconst a1 = __r20(r);\n\t\t\tconst a2 = __r0(r);\n\t\t\tconst f = changetype<(a0: __Player, a1: __Player, a2: string) => bool>(fn);\n\t\t\tconst result = f(a0, a1, a2);\n\t\t\t__w9(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 3: {\n\t\t\tconst a0 = __r30(r);\n\t\t\tconst f = changetype<(a0: __M_NamedContext) => void>(fn);\n\t\t\tf(a0);\n\t\t\tbreak;\n\t\t}\n\t\tcase 4: {\n\t\t\tconst a0 = __r30(r);\n\t\t\tconst f = changetype<(a0: __M_NamedContext) => string>(fn);\n\t\t\tconst result = f(a0);\n\t\t\t__w0(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 5: {\n\t\t\tconst a0 = __r30(r);\n\t\t\tconst f = changetype<(a0: __M_NamedContext) => bool>(fn);\n\t\t\tconst result = f(a0);\n\t\t\t__w9(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 6: {\n\t\t\tconst a0 = __r20(r);\n\t\t\tconst a1 = __r20(r);\n\t\t\tconst a2 = __r0(r);\n\t\t\tconst a3 = __r9(r);\n\t\t\tconst f = changetype<(a0: __Player, a1: __Player, a2: string, a3: bool) => bool>(fn);\n\t\t\tconst result = f(a0, a1, a2, a3);\n\t\t\t__w9(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 7: {\n\t\t\tconst a0 = __r29(r);\n\t\t\tconst f = changetype<(a0: __M_MenuContext) => Array<__M_ListRow> | null>(fn);\n\t\t\tconst result = f(a0);\n\t\t\t__w31(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 8: {\n\t\t\tconst a0 = __r33(r);\n\t\t\tconst f = changetype<(a0: __M_MenuEvent) => void>(fn);\n\t\t\tf(a0);\n\t\t\t__w33(w, a0);\n\t\t\tbreak;\n\t\t}\n\t\tcase 9: {\n\t\t\tconst a0 = __r29(r);\n\t\t\tconst f = changetype<(a0: __M_MenuContext) => void>(fn);\n\t\t\tf(a0);\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\nfunction __w0(w: __Writer, v: string): void { w.str(v); }\n\nfunction __r0(r: __Reader): string { return r.str(); }\n\nfunction __w1(w: __Writer, v: string | null): void {\n\tif (v == null) {\n\t\tw.bool(false);\n\t\treturn;\n\t}\n\tw.bool(true);\n\t__w0(w, v!);\n}\n\nfunction __r1(r: __Reader): string | null {\n\tif (!r.bool()) return null;\n\treturn __r0(r);\n}\n\nfunction __w3(w: __Writer, v: __M_Menu): void { w.i32(__handles.id(changetype<usize>(v))); }\n\nfunction __r3(r: __Reader): __M_Menu { return changetype<__M_Menu>(__handles.at(r.i32())); }\n\nfunction __w2(w: __Writer, v: __M_Menu | null): void {\n\tif (v == null) {\n\t\tw.bool(false);\n\t\treturn;\n\t}\n\tw.bool(true);\n\t__w3(w, v!);\n}\n\nfunction __r2(r: __Reader): __M_Menu | null {\n\tif (!r.bool()) return null;\n\treturn __r3(r);\n}\n\nfunction __w4(w: __Writer, v: i32): void { w.f64(<f64>v); }\n\nfunction __r4(r: __Reader): i32 { return <i32>r.f64(); }\n\nfunction __w5(w: __Writer, v: f64): void { w.f64(<f64>v); }\n\nfunction __r5(r: __Reader): f64 { return <f64>r.f64(); }\n\nfunction __w8(w: __Writer, v: (a0: __M_MenuContext) => string): void { w.i32(__sendFunction(changetype<usize>(v), 0, __invoke)); }\n\nfunction __r8(r: __Reader): (a0: __M_MenuContext) => string { return changetype<(a0: __M_MenuContext) => string>(__receiveFunction(r, changetype<usize>(__stub0))); }\n\nfunction __w7(w: __Writer, v: ((a0: __M_MenuContext) => string) | null): void {\n\tif (v == null) {\n\t\tw.bool(false);\n\t\treturn;\n\t}\n\tw.bool(true);\n\t__w8(w, v!);\n}\n\nfunction __r7(r: __Reader): ((a0: __M_MenuContext) => string) | null {\n\tif (!r.bool()) return null;\n\treturn __r8(r);\n}\n\nfunction __w9(w: __Writer, v: bool): void { w.bool(v); }\n\nfunction __r9(r: __Reader): bool { return r.bool(); }\n\nfunction __w11(w: __Writer, v: (a0: __M_MenuContext) => bool): void { w.i32(__sendFunction(changetype<usize>(v), 1, __invoke)); }\n\nfunction __r11(r: __Reader): (a0: __M_MenuContext) => bool { return changetype<(a0: __M_MenuContext) => bool>(__receiveFunction(r, changetype<usize>(__stub1))); }\n\nfunction __w10(w: __Writer, v: ((a0: __M_MenuContext) => bool) | null): void {\n\tif (v == null) {\n\t\tw.bool(false);\n\t\treturn;\n\t}\n\tw.bool(true);\n\t__w11(w, v!);\n}\n\nfunction __r10(r: __Reader): ((a0: __M_MenuContext) => bool) | null {\n\tif (!r.bool()) return null;\n\treturn __r11(r);\n}\n\nfunction __w6(w: __Writer, v: __M_MenuOptions): void {\n\t__w7(w, v.title);\n\t__w5(w, v.time);\n\tw.bool(v.hideBack !== undefined);\n\tif (v.hideBack !== undefined) __w9(w, v.hideBack);\n\tw.bool(v.hideExit !== undefined);\n\tif (v.hideExit !== undefined) __w9(w, v.hideExit);\n\tw.bool(v.locked !== undefined);\n\tif (v.locked !== undefined) __w9(w, v.locked);\n\t__w10(w, v.activeWhen);\n}\n\nfunction __u6(r: __Reader, o: __M_MenuOptions): void {\n\to.title = __r7(r);\n\to.time = __r5(r);\n\tif (r.bool()) o.hideBack = __r9(r);\n\telse o.hideBack = undefined;\n\tif (r.bool()) o.hideExit = __r9(r);\n\telse o.hideExit = undefined;\n\tif (r.bool()) o.locked = __r9(r);\n\telse o.locked = undefined;\n\to.activeWhen = __r10(r);\n}\n\nfunction __r6(r: __Reader): __M_MenuOptions {\n\tconst o = changetype<__M_MenuOptions>(__new(offsetof<__M_MenuOptions>(), idof<__M_MenuOptions>()));\n\t__u6(r, o);\n\treturn o;\n}\n\nfunction __w12(w: __Writer, v: (a0: __Player, a1: __Player, a2: string) => bool): void { w.i32(__sendFunction(changetype<usize>(v), 2, __invoke)); }\n\nfunction __r12(r: __Reader): (a0: __Player, a1: __Player, a2: string) => bool { return changetype<(a0: __Player, a1: __Player, a2: string) => bool>(__receiveFunction(r, changetype<usize>(__stub2))); }\n\nfunction __w13(w: __Writer, v: (a0: __M_NamedContext) => void): void { w.i32(__sendFunction(changetype<usize>(v), 3, __invoke)); }\n\nfunction __r13(r: __Reader): (a0: __M_NamedContext) => void { return changetype<(a0: __M_NamedContext) => void>(__receiveFunction(r, changetype<usize>(__stub3))); }\n\nfunction __w14(w: __Writer, v: (a0: __M_NamedContext) => string): void { w.i32(__sendFunction(changetype<usize>(v), 4, __invoke)); }\n\nfunction __r14(r: __Reader): (a0: __M_NamedContext) => string { return changetype<(a0: __M_NamedContext) => string>(__receiveFunction(r, changetype<usize>(__stub4))); }\n\nfunction __w15(w: __Writer, v: (a0: __M_NamedContext) => bool): void { w.i32(__sendFunction(changetype<usize>(v), 5, __invoke)); }\n\nfunction __r15(r: __Reader): (a0: __M_NamedContext) => bool { return changetype<(a0: __M_NamedContext) => bool>(__receiveFunction(r, changetype<usize>(__stub5))); }\n\nfunction __w16(w: __Writer, v: (a0: __Player, a1: __Player, a2: string, a3: bool) => bool): void { w.i32(__sendFunction(changetype<usize>(v), 6, __invoke)); }\n\nfunction __r16(r: __Reader): (a0: __Player, a1: __Player, a2: string, a3: bool) => bool { return changetype<(a0: __Player, a1: __Player, a2: string, a3: bool) => bool>(__receiveFunction(r, changetype<usize>(__stub6))); }\n\nfunction __w17(w: __Writer, v: (a0: __M_MenuContext) => Array<__M_ListRow> | null): void { w.i32(__sendFunction(changetype<usize>(v), 7, __invoke)); }\n\nfunction __r17(r: __Reader): (a0: __M_MenuContext) => Array<__M_ListRow> | null { return changetype<(a0: __M_MenuContext) => Array<__M_ListRow> | null>(__receiveFunction(r, changetype<usize>(__stub7))); }\n\nfunction __w18(w: __Writer, v: (a0: __M_MenuEvent) => void): void { w.i32(__sendFunction(changetype<usize>(v), 8, __invoke)); }\n\nfunction __r18(r: __Reader): (a0: __M_MenuEvent) => void { return changetype<(a0: __M_MenuEvent) => void>(__receiveFunction(r, changetype<usize>(__stub8))); }\n\nfunction __w19(w: __Writer, v: __M_ListRow): void {\n\t__w0(w, v.kind);\n\t__w5(w, v.target);\n\t__w0(w, v.text);\n\t__w0(w, v.action);\n\t__w0(w, v.restriction);\n\t__w0(w, v.restrictionMessage);\n}\n\nfunction __u19(r: __Reader, o: __M_ListRow): void {\n\to.kind = __r0(r);\n\to.target = __r5(r);\n\to.text = __r0(r);\n\to.action = __r0(r);\n\to.restriction = __r0(r);\n\to.restrictionMessage = __r0(r);\n}\n\nfunction __r19(r: __Reader): __M_ListRow {\n\tconst o = changetype<__M_ListRow>(__new(offsetof<__M_ListRow>(), idof<__M_ListRow>()));\n\t__u19(r, o);\n\treturn o;\n}\n\nfunction __w20(w: __Writer, v: __Player): void { w.i32(<i32>v.id); }\n\nfunction __r20(r: __Reader): __Player { return new __Player(r.i32()); }\n\nfunction __w22(w: __Writer, v: __Player | null): void {\n\tif (v == null) {\n\t\tw.bool(false);\n\t\treturn;\n\t}\n\tw.bool(true);\n\t__w20(w, v!);\n}\n\nfunction __r22(r: __Reader): __Player | null {\n\tif (!r.bool()) return null;\n\treturn __r20(r);\n}\n\nfunction __w21(w: __Writer, v: __M_MenuShowOptions): void {\n\t__w5(w, v.time);\n\t__w22(w, v.target);\n\tw.bool(v.resetHistory !== undefined);\n\tif (v.resetHistory !== undefined) __w9(w, v.resetHistory);\n\tw.bool(v.force !== undefined);\n\tif (v.force !== undefined) __w9(w, v.force);\n\tw.bool(v.skipHistory !== undefined);\n\tif (v.skipHistory !== undefined) __w9(w, v.skipHistory);\n}\n\nfunction __u21(r: __Reader, o: __M_MenuShowOptions): void {\n\to.time = __r5(r);\n\to.target = __r22(r);\n\tif (r.bool()) o.resetHistory = __r9(r);\n\telse o.resetHistory = undefined;\n\tif (r.bool()) o.force = __r9(r);\n\telse o.force = undefined;\n\tif (r.bool()) o.skipHistory = __r9(r);\n\telse o.skipHistory = undefined;\n}\n\nfunction __r21(r: __Reader): __M_MenuShowOptions {\n\tconst o = changetype<__M_MenuShowOptions>(__new(offsetof<__M_MenuShowOptions>(), idof<__M_MenuShowOptions>()));\n\t__u21(r, o);\n\treturn o;\n}\n\nfunction __w25(w: __Writer, v: (a0: __M_MenuContext) => void): void { w.i32(__sendFunction(changetype<usize>(v), 9, __invoke)); }\n\nfunction __r25(r: __Reader): (a0: __M_MenuContext) => void { return changetype<(a0: __M_MenuContext) => void>(__receiveFunction(r, changetype<usize>(__stub9))); }\n\nfunction __w24(w: __Writer, v: ((a0: __M_MenuContext) => void) | null): void {\n\tif (v == null) {\n\t\tw.bool(false);\n\t\treturn;\n\t}\n\tw.bool(true);\n\t__w25(w, v!);\n}\n\nfunction __r24(r: __Reader): ((a0: __M_MenuContext) => void) | null {\n\tif (!r.bool()) return null;\n\treturn __r25(r);\n}\n\nfunction __w28(w: __Writer, v: __M_Requirement): void {\n\t__w11(w, v.when);\n\t__w7(w, v.message);\n}\n\nfunction __u28(r: __Reader, o: __M_Requirement): void {\n\to.when = __r11(r);\n\to.message = __r7(r);\n}\n\nfunction __r28(r: __Reader): __M_Requirement {\n\tconst o = changetype<__M_Requirement>(__new(offsetof<__M_Requirement>(), idof<__M_Requirement>()));\n\t__u28(r, o);\n\treturn o;\n}\n\nfunction __w27(w: __Writer, v: Array<__M_Requirement>): void {\n\tw.i32(v.length);\n\tfor (let i: i32 = 0; i < v.length; i++) __w28(w, v[i]);\n}\n\nfunction __r27(r: __Reader): Array<__M_Requirement> {\n\tconst count = r.i32();\n\tconst list = new Array<__M_Requirement>();\n\tfor (let i: i32 = 0; i < count; i++) list.push(__r28(r));\n\treturn list;\n}\n\nfunction __w26(w: __Writer, v: Array<__M_Requirement> | null): void {\n\tif (v == null) {\n\t\tw.bool(false);\n\t\treturn;\n\t}\n\tw.bool(true);\n\t__w27(w, v!);\n}\n\nfunction __r26(r: __Reader): Array<__M_Requirement> | null {\n\tif (!r.bool()) return null;\n\treturn __r27(r);\n}\n\nfunction __w23(w: __Writer, v: __M_MenuItemOptions): void {\n\t__w8(w, v.title);\n\t__w24(w, v.onSelect);\n\t__w10(w, v.visible);\n\t__w26(w, v.enabled);\n\t__w7(w, v.message);\n\t__w1(w, v.placeholder);\n\t__w1(w, v.action);\n\t__w5(w, v.at);\n\t__w5(w, v.spaceBefore);\n\t__w5(w, v.spaceAfter);\n}\n\nfunction __u23(r: __Reader, o: __M_MenuItemOptions): void {\n\to.title = __r8(r);\n\to.onSelect = __r24(r);\n\to.visible = __r10(r);\n\to.enabled = __r26(r);\n\to.message = __r7(r);\n\to.placeholder = __r1(r);\n\to.action = __r1(r);\n\to.at = __r5(r);\n\to.spaceBefore = __r5(r);\n\to.spaceAfter = __r5(r);\n}\n\nfunction __r23(r: __Reader): __M_MenuItemOptions {\n\tconst o = changetype<__M_MenuItemOptions>(__new(offsetof<__M_MenuItemOptions>(), idof<__M_MenuItemOptions>()));\n\t__u23(r, o);\n\treturn o;\n}\n\nfunction __w29(w: __Writer, v: __M_MenuContext): void {\n\t__w20(w, v.player);\n\t__w20(w, v.target);\n\t__w5(w, v.row);\n\t__w3(w, v.menu);\n}\n\nfunction __u29(r: __Reader, o: __M_MenuContext): void {\n\to.player = __r20(r);\n\to.target = __r20(r);\n\to.row = __r5(r);\n\to.menu = __r3(r);\n}\n\nfunction __r29(r: __Reader): __M_MenuContext {\n\tconst o = changetype<__M_MenuContext>(__new(offsetof<__M_MenuContext>(), idof<__M_MenuContext>()));\n\t__u29(r, o);\n\treturn o;\n}\n\nfunction __w30(w: __Writer, v: __M_NamedContext): void {\n\t__w20(w, v.player);\n\t__w20(w, v.target);\n\t__w5(w, v.row);\n\t__w3(w, v.menu);\n\t__w0(w, v.name);\n}\n\nfunction __u30(r: __Reader, o: __M_NamedContext): void {\n\to.player = __r20(r);\n\to.target = __r20(r);\n\to.row = __r5(r);\n\to.menu = __r3(r);\n\to.name = __r0(r);\n}\n\nfunction __r30(r: __Reader): __M_NamedContext {\n\tconst o = changetype<__M_NamedContext>(__new(offsetof<__M_NamedContext>(), idof<__M_NamedContext>()));\n\t__u30(r, o);\n\treturn o;\n}\n\nfunction __w32(w: __Writer, v: Array<__M_ListRow>): void {\n\tw.i32(v.length);\n\tfor (let i: i32 = 0; i < v.length; i++) __w19(w, v[i]);\n}\n\nfunction __r32(r: __Reader): Array<__M_ListRow> {\n\tconst count = r.i32();\n\tconst list = new Array<__M_ListRow>();\n\tfor (let i: i32 = 0; i < count; i++) list.push(__r19(r));\n\treturn list;\n}\n\nfunction __w31(w: __Writer, v: Array<__M_ListRow> | null): void {\n\tif (v == null) {\n\t\tw.bool(false);\n\t\treturn;\n\t}\n\tw.bool(true);\n\t__w32(w, v!);\n}\n\nfunction __r31(r: __Reader): Array<__M_ListRow> | null {\n\tif (!r.bool()) return null;\n\treturn __r32(r);\n}\n\nfunction __w33(w: __Writer, v: __M_MenuEvent): void {\n\t__w9(w, v.defaultPrevented);\n\t__w20(w, v.player);\n\t__w3(w, v.menu);\n\t__w9(w, v.timeout);\n}\n\nfunction __u33(r: __Reader, o: __M_MenuEvent): void {\n\to.defaultPrevented = __r9(r);\n\to.player = __r20(r);\n\to.menu = __r3(r);\n\to.timeout = __r9(r);\n}\n\nfunction __r33(r: __Reader): __M_MenuEvent {\n\tconst o = changetype<__M_MenuEvent>(__new(offsetof<__M_MenuEvent>(), idof<__M_MenuEvent>()));\n\t__u33(r, o);\n\treturn o;\n}\n\n__serve(\"menu-core\", 1989640665, __dispatch);\n",
|
|
708
|
+
"proxy": "// GENERATED by scripts/shared-modules.ts: ~/modules/menu-core in a plugin that does not own it.\n// Each function runs in menu-core.aot, the one instance on the server.\nimport { Reader as __Reader, Writer as __Writer, beginCallback as __beginCallback, callBack as __callBack, receiveFunction as __receiveFunction, remoteTarget as __remoteTarget, sendFunction as __sendFunction, Service as __Service } from \"~/remote\";\nimport { Player as __Player } from \"~/facade\";\nimport { Player, lang } from \"~/facade\";\n\nexport class MenuEvent {\n\t/** A mark of `preventDefault()`: `true` once it was called. */\n\tdefaultPrevented = false;\n\n\tconstructor(\n\t\t/** The player whose menu it is. */\n\t\tpublic player: Player,\n\t\t/** The menu the event is about. */\n\t\tpublic menu: Menu,\n\t\t/** On `\"close\"`: `true` when the menu closed because its time ran out. */\n\t\tpublic timeout: boolean,\n\t) {}\n\n\t/** On `\"show\"`: keeps the menu from opening. */\n\tpreventDefault() {\n\t\tthis.defaultPrevented = true;\n\t}\n}\n\nexport type MenuListener = (event: MenuEvent) => void;\n\nexport type MenuKind = \"items\" | \"list\";\n\nexport interface MenuContext {\n\t/** The player the menu is shown to: who looks at it, and who chooses. */\n\tplayer: Player;\n\t/** The player the menu is about: the row's in a list menu, the one `show()` was given as `target` in an items menu; `player` himself when there is none. */\n\ttarget: Player;\n\t/** The row's number in a list menu, as `listRow()` gave it - e.g. an entity or an index of the source's own; a player's `id` in a list of players. In an items menu, the `id` of the menu's target, `0` without one. */\n\trow: number;\n\t/** The menu the function is asked for. */\n\tmenu: Menu;\n}\n\nexport interface NamedContext extends MenuContext {\n\t/** The name it is asked by: an action's or a placeholder's, a restriction's whole token - `\"NAME:param\"` included; for an action check, the item's action. */\n\tname: string;\n}\n\nexport type MenuText = string | ((context: MenuContext) => string);\n\nexport interface ListRow {\n\t/** The row's kind, one of `\"item\"` (a row to choose) or `\"text\"` (a line of text, not a choice). */\n\tkind: \"item\" | \"text\";\n\t/** The row's number, `row` of the context its item's functions get: e.g. a player's `id`, an entity or an index of the source's own; `0` for a line of text. */\n\ttarget: number;\n\t/** The row's text, put for `%name%` in the menu's row template. */\n\ttext: string;\n\t/** Action names of the row's own, run instead of the template's; `\"\"` for the template's. */\n\taction: string;\n\t/** Restriction names, space-separated: the row is greyed out unless each passes. */\n\trestriction: string;\n\t/** The text beside the row while it is greyed out; `\"\"` for the restriction's own message. */\n\trestrictionMessage: string;\n}\n\nexport interface MenuOptions {\n\t/** The menu's title: the text - a lang key too - or a function that gives it for the menu's context; left out, the menu's name. */\n\ttitle?: MenuText;\n\t/** Seconds on the countdown when the menu opens, e.g. `10`; left out, none. */\n\ttime?: number;\n\t/** Hiding of the `\"Back\"` button: `true` leaves it out. */\n\thideBack?: boolean;\n\t/** Hiding of the `\"Exit\"` button: `true` leaves it out. */\n\thideExit?: boolean;\n\t/** A lock on the menu: while `true`, items cannot be chosen and no other menu replaces this one. */\n\tlocked?: boolean;\n\t/** A test the menu opens under: while it says no, the menu does not open for the player. */\n\tactiveWhen?: (context: MenuContext) => boolean;\n}\n\nexport interface MenuShowOptions {\n\t/** Seconds on the countdown; left out, the countdown running goes on, or the menu's own starts. */\n\ttime?: number;\n\t/** The player the menu is about: `target` of the context its functions get, and `%target%`. */\n\ttarget?: Player;\n\t/** A new way back: `true` forgets the menus this one was opened from. */\n\tresetHistory?: boolean;\n\t/** Opening over a menu that holds on - a countdown, a lock: `true` opens anyway. */\n\tforce?: boolean;\n\t/** Leaving the menu out of the way back: `true` does not remember it. */\n\tskipHistory?: boolean;\n}\n\nexport interface MenuItemOptions {\n\t/** The item's text - a lang key too - or a function that gives it for the menu's context. */\n\ttitle: MenuText;\n\t/** The function run when the item is chosen; the menu is drawn again after it, while it stays open. */\n\tonSelect?: (context: MenuContext) => void;\n\t/** A test the item is shown under: while it says no, the item is left out and takes no slot. */\n\tvisible?: (context: MenuContext) => boolean;\n\t/**\n\t * A test the item can be chosen under - while it says no, the item is\n\t * greyed out with `message` beside it; or a list of requirements, each with\n\t * a message of its own - the first that fails gives its message.\n\t *\n\t * enabled: [\n\t * { when: ({ player }) => player.frags >= 5, message: \"5 frags needed\" },\n\t * { when: ({ player }) => player.armor < 100, message: ({ player }) => `(${player.armor} already)` },\n\t * ],\n\t */\n\tenabled?: ((context: MenuContext) => boolean) | Requirement[];\n\t/** The text beside the item while `enabled` greys it out, for a requirement without a message of its own: the text, e.g. `\"(full)\"`, or a function that gives it for the menu's context. */\n\tmessage?: MenuText;\n\t/** The text after the item's title, for items of menu files and Pawn plugins, placeholders and all, e.g. `\"%hp%\"`; in code the title is a function instead. */\n\tplaceholder?: string;\n\t/** Action names from `addAction()` run when the item is chosen, or a built-in one: `\"SHOW_<MENU>\"`, `\"CLOSE_MENU\"`. */\n\taction?: string;\n\t/** The item's place among the items, from `0`; left out, the end. */\n\tat?: number;\n\t/** Blank lines before the item. */\n\tspaceBefore?: number;\n\t/** Blank lines after the item. */\n\tspaceAfter?: number;\n}\n\nexport interface Requirement {\n\t/** A test the requirement holds under, given the menu's context. */\n\twhen: (context: MenuContext) => boolean;\n\t/** The text beside the item while `when` says no: the text, a lang key, or a function that gives it for the menu's context; left out, the item's `message`. */\n\tmessage?: MenuText;\n}\n\nexport type ConditionTest = (player: Player, viewer: Player, name: string) => boolean;\n\nexport type ActionHandler = (context: NamedContext & Player) => void;\n\nexport type PlaceholderValue = (context: NamedContext & Player) => string;\n\nexport type RestrictionTest = (context: NamedContext) => boolean;\n\nexport type ActionTest = (context: NamedContext) => boolean;\n\nexport type ConditionFilter = (player: Player, viewer: Player, name: string, value: boolean) => boolean;\n\nexport type RowTest = (context: MenuContext) => boolean;\n\nexport type ListSource = (context: MenuContext) => ListRow[] | null;\n\nexport type MenuEventType = \"open\" | \"close\" | \"show\";\n\nexport interface MenuCoreOptions {\n\t/** The menu file, from `configs/`: e.g. `\"menu\"` is `configs/menu.ini`, `menu.yaml`, `menu.yml`, `menu.json` or `menu.jsonc` - the first that is there; `\"myserver/menu.yaml\"` is that file. */\n\tfile: string;\n\t/** The file read instead when `file` is empty or not there, e.g. `\"menu\"` for `configs/menu.ini` or `menu.yaml`; `\"\"` is none. */\n\tfallback: string;\n}\n\n/** Menu in menu-core's plugin: each field is read and written there, each method runs there. */\nexport class Menu {\n\tconstructor(public __handle: i32) {}\n\n\tget kind(): string {\n\t\tconst w = __service.begin(29);\n\t\tw.i32(this.__handle);\n\t\treturn __r0(__service.call(w));\n\t}\n\n\tget hideBack(): bool {\n\t\tconst w = __service.begin(30);\n\t\tw.i32(this.__handle);\n\t\treturn __r1(__service.call(w));\n\t}\n\tset hideBack(value: bool) {\n\t\tconst w = __service.begin(31);\n\t\tw.i32(this.__handle);\n\t\t__w1(w, value);\n\t\t__service.call(w);\n\t}\n\n\tget hideExit(): bool {\n\t\tconst w = __service.begin(32);\n\t\tw.i32(this.__handle);\n\t\treturn __r1(__service.call(w));\n\t}\n\tset hideExit(value: bool) {\n\t\tconst w = __service.begin(33);\n\t\tw.i32(this.__handle);\n\t\t__w1(w, value);\n\t\t__service.call(w);\n\t}\n\n\tget locked(): bool {\n\t\tconst w = __service.begin(34);\n\t\tw.i32(this.__handle);\n\t\treturn __r1(__service.call(w));\n\t}\n\tset locked(value: bool) {\n\t\tconst w = __service.begin(35);\n\t\tw.i32(this.__handle);\n\t\t__w1(w, value);\n\t\t__service.call(w);\n\t}\n\n\tget sharedTimer(): bool {\n\t\tconst w = __service.begin(36);\n\t\tw.i32(this.__handle);\n\t\treturn __r1(__service.call(w));\n\t}\n\tset sharedTimer(value: bool) {\n\t\tconst w = __service.begin(37);\n\t\tw.i32(this.__handle);\n\t\t__w1(w, value);\n\t\t__service.call(w);\n\t}\n\n\tget time(): f64 {\n\t\tconst w = __service.begin(38);\n\t\tw.i32(this.__handle);\n\t\treturn __r2(__service.call(w));\n\t}\n\tset time(value: f64) {\n\t\tconst w = __service.begin(39);\n\t\tw.i32(this.__handle);\n\t\t__w2(w, value);\n\t\t__service.call(w);\n\t}\n\n\tget onTimeout(): string {\n\t\tconst w = __service.begin(40);\n\t\tw.i32(this.__handle);\n\t\treturn __r0(__service.call(w));\n\t}\n\tset onTimeout(value: string) {\n\t\tconst w = __service.begin(41);\n\t\tw.i32(this.__handle);\n\t\t__w0(w, value);\n\t\t__service.call(w);\n\t}\n\n\tget activeOn(): string {\n\t\tconst w = __service.begin(42);\n\t\tw.i32(this.__handle);\n\t\treturn __r0(__service.call(w));\n\t}\n\tset activeOn(value: string) {\n\t\tconst w = __service.begin(43);\n\t\tw.i32(this.__handle);\n\t\t__w0(w, value);\n\t\t__service.call(w);\n\t}\n\n\tget countdown(): f64 {\n\t\tconst w = __service.begin(44);\n\t\tw.i32(this.__handle);\n\t\treturn __r2(__service.call(w));\n\t}\n\tset countdown(value: f64) {\n\t\tconst w = __service.begin(45);\n\t\tw.i32(this.__handle);\n\t\t__w2(w, value);\n\t\t__service.call(w);\n\t}\n\n\tget name(): string {\n\t\tconst w = __service.begin(46);\n\t\tw.i32(this.__handle);\n\t\treturn __r0(__service.call(w));\n\t}\n\n\tget title(): (a0: MenuContext) => string {\n\t\tconst w = __service.begin(47);\n\t\tw.i32(this.__handle);\n\t\treturn __r3(__service.call(w));\n\t}\n\tset title(value: string | ((context: MenuContext) => string)) {\n\t\tconst w = __service.begin(48);\n\t\tw.i32(this.__handle);\n\t\t__w3(w, value);\n\t\t__service.call(w);\n\t}\n\n\taddItem(item: MenuItemOptions): void {\n\t\tconst __w = __service.begin(49);\n\t\t__w.i32(this.__handle);\n\t\t__w4(__w, item);\n\t\tconst __r = __service.call(__w);\n\t}\n\n\taddFixedItem(slot: number, item: MenuItemOptions): void {\n\t\tconst __w = __service.begin(50);\n\t\t__w.i32(this.__handle);\n\t\t__w2(__w, slot);\n\t\t__w4(__w, item);\n\t\tconst __r = __service.call(__w);\n\t}\n\n\tclearItems(): void {\n\t\tconst __w = __service.begin(51);\n\t\t__w.i32(this.__handle);\n\t\tconst __r = __service.call(__w);\n\t}\n\n\taddFilter(test: RowTest, message?: string): void {\n\t\tconst __w = __service.begin(52);\n\t\t__w.i32(this.__handle);\n\t\t__w8(__w, test);\n\t\t__w13(__w, message);\n\t\tconst __r = __service.call(__w);\n\t}\n\n\taddPlaceholder(name: string, value: PlaceholderValue): void {\n\t\tconst __w = __service.begin(53);\n\t\t__w.i32(this.__handle);\n\t\t__w0(__w, name);\n\t\t__w14(__w, value);\n\t\tconst __r = __service.call(__w);\n\t}\n\n\tsetListSource(rows: ListSource): void {\n\t\tconst __w = __service.begin(54);\n\t\t__w.i32(this.__handle);\n\t\t__w15(__w, rows);\n\t\tconst __r = __service.call(__w);\n\t}\n\n\taddEventListener(type: MenuEventType, listener: MenuListener): void {\n\t\tconst __w = __service.begin(55);\n\t\t__w.i32(this.__handle);\n\t\t__w0(__w, type);\n\t\t__w16(__w, listener);\n\t\tconst __r = __service.call(__w);\n\t}\n\n\tshow(player: Player, options: MenuShowOptions = {}): bool {\n\t\tconst __w = __service.begin(56);\n\t\t__w.i32(this.__handle);\n\t\t__w17(__w, player);\n\t\t__w18(__w, options);\n\t\tconst __r = __service.call(__w);\n\t\treturn __r1(__r);\n\t}\n\n\trunActions(player: Player, line: string, target?: Player): void {\n\t\tconst __w = __service.begin(57);\n\t\t__w.i32(this.__handle);\n\t\t__w17(__w, player);\n\t\t__w0(__w, line);\n\t\t__w19(__w, target);\n\t\tconst __r = __service.call(__w);\n\t}\n\n\trefresh(): f64 {\n\t\tconst __w = __service.begin(58);\n\t\t__w.i32(this.__handle);\n\t\tconst __r = __service.call(__w);\n\t\treturn __r2(__r);\n\t}\n\n\tclose(): void {\n\t\tconst __w = __service.begin(59);\n\t\t__w.i32(this.__handle);\n\t\tconst __r = __service.call(__w);\n\t}\n\n\tsetTimer(seconds: number): bool {\n\t\tconst __w = __service.begin(60);\n\t\t__w.i32(this.__handle);\n\t\t__w2(__w, seconds);\n\t\tconst __r = __service.call(__w);\n\t\treturn __r1(__r);\n\t}\n\n\tcancelTimer(): bool {\n\t\tconst __w = __service.begin(61);\n\t\t__w.i32(this.__handle);\n\t\tconst __r = __service.call(__w);\n\t\treturn __r1(__r);\n\t}\n}\n\n\n\nconst __service = new __Service(\"menu-core\", 184891291);\n\nfunction __w0(w: __Writer, v: string): void { w.str(v); }\n\nfunction __r0(r: __Reader): string { return r.str(); }\n\nfunction __w1(w: __Writer, v: bool): void { w.bool(v); }\n\nfunction __r1(r: __Reader): bool { return r.bool(); }\n\nfunction __w2(w: __Writer, v: f64): void { w.f64(<f64>v); }\n\nfunction __r2(r: __Reader): f64 { return <f64>r.f64(); }\n\nfunction __w3(w: __Writer, v: (a0: MenuContext) => string): void { w.i32(__sendFunction(changetype<usize>(v), 0, __invoke)); }\n\nfunction __r3(r: __Reader): (a0: MenuContext) => string { return changetype<(a0: MenuContext) => string>(__receiveFunction(r, changetype<usize>(__stub0))); }\n\nfunction __w6(w: __Writer, v: (a0: MenuContext) => void): void { w.i32(__sendFunction(changetype<usize>(v), 9, __invoke)); }\n\nfunction __r6(r: __Reader): (a0: MenuContext) => void { return changetype<(a0: MenuContext) => void>(__receiveFunction(r, changetype<usize>(__stub9))); }\n\nfunction __w5(w: __Writer, v: ((a0: MenuContext) => void) | null): void {\n\tif (v == null) {\n\t\tw.bool(false);\n\t\treturn;\n\t}\n\tw.bool(true);\n\t__w6(w, v!);\n}\n\nfunction __r5(r: __Reader): ((a0: MenuContext) => void) | null {\n\tif (!r.bool()) return null;\n\treturn __r6(r);\n}\n\nfunction __w8(w: __Writer, v: (a0: MenuContext) => bool): void { w.i32(__sendFunction(changetype<usize>(v), 1, __invoke)); }\n\nfunction __r8(r: __Reader): (a0: MenuContext) => bool { return changetype<(a0: MenuContext) => bool>(__receiveFunction(r, changetype<usize>(__stub1))); }\n\nfunction __w7(w: __Writer, v: ((a0: MenuContext) => bool) | null): void {\n\tif (v == null) {\n\t\tw.bool(false);\n\t\treturn;\n\t}\n\tw.bool(true);\n\t__w8(w, v!);\n}\n\nfunction __r7(r: __Reader): ((a0: MenuContext) => bool) | null {\n\tif (!r.bool()) return null;\n\treturn __r8(r);\n}\n\nfunction __w12(w: __Writer, v: ((a0: MenuContext) => string) | null): void {\n\tif (v == null) {\n\t\tw.bool(false);\n\t\treturn;\n\t}\n\tw.bool(true);\n\t__w3(w, v!);\n}\n\nfunction __r12(r: __Reader): ((a0: MenuContext) => string) | null {\n\tif (!r.bool()) return null;\n\treturn __r3(r);\n}\n\nfunction __w11(w: __Writer, v: Requirement): void {\n\t__w8(w, v.when);\n\t__w12(w, v.message);\n}\n\nfunction __u11(r: __Reader, o: Requirement): void {\n\to.when = __r8(r);\n\to.message = __r12(r);\n}\n\nfunction __r11(r: __Reader): Requirement {\n\tconst o = changetype<Requirement>(__new(offsetof<Requirement>(), idof<Requirement>()));\n\t__u11(r, o);\n\treturn o;\n}\n\nfunction __w10(w: __Writer, v: Array<Requirement>): void {\n\tw.i32(v.length);\n\tfor (let i: i32 = 0; i < v.length; i++) __w11(w, v[i]);\n}\n\nfunction __r10(r: __Reader): Array<Requirement> {\n\tconst count = r.i32();\n\tconst list = new Array<Requirement>();\n\tfor (let i: i32 = 0; i < count; i++) list.push(__r11(r));\n\treturn list;\n}\n\nfunction __w9(w: __Writer, v: Array<Requirement> | null): void {\n\tif (v == null) {\n\t\tw.bool(false);\n\t\treturn;\n\t}\n\tw.bool(true);\n\t__w10(w, v!);\n}\n\nfunction __r9(r: __Reader): Array<Requirement> | null {\n\tif (!r.bool()) return null;\n\treturn __r10(r);\n}\n\nfunction __w13(w: __Writer, v: string | null): void {\n\tif (v == null) {\n\t\tw.bool(false);\n\t\treturn;\n\t}\n\tw.bool(true);\n\t__w0(w, v!);\n}\n\nfunction __r13(r: __Reader): string | null {\n\tif (!r.bool()) return null;\n\treturn __r0(r);\n}\n\nfunction __w4(w: __Writer, v: MenuItemOptions): void {\n\t__w3(w, v.title);\n\t__w5(w, v.onSelect);\n\t__w7(w, v.visible);\n\t__w9(w, v.enabled);\n\t__w12(w, v.message);\n\t__w13(w, v.placeholder);\n\t__w13(w, v.action);\n\t__w2(w, v.at);\n\t__w2(w, v.spaceBefore);\n\t__w2(w, v.spaceAfter);\n}\n\nfunction __u4(r: __Reader, o: MenuItemOptions): void {\n\to.title = __r3(r);\n\to.onSelect = __r5(r);\n\to.visible = __r7(r);\n\to.enabled = __r9(r);\n\to.message = __r12(r);\n\to.placeholder = __r13(r);\n\to.action = __r13(r);\n\to.at = __r2(r);\n\to.spaceBefore = __r2(r);\n\to.spaceAfter = __r2(r);\n}\n\nfunction __r4(r: __Reader): MenuItemOptions {\n\tconst o = changetype<MenuItemOptions>(__new(offsetof<MenuItemOptions>(), idof<MenuItemOptions>()));\n\t__u4(r, o);\n\treturn o;\n}\n\nfunction __w14(w: __Writer, v: (a0: NamedContext) => string): void { w.i32(__sendFunction(changetype<usize>(v), 4, __invoke)); }\n\nfunction __r14(r: __Reader): (a0: NamedContext) => string { return changetype<(a0: NamedContext) => string>(__receiveFunction(r, changetype<usize>(__stub4))); }\n\nfunction __w15(w: __Writer, v: (a0: MenuContext) => Array<ListRow> | null): void { w.i32(__sendFunction(changetype<usize>(v), 7, __invoke)); }\n\nfunction __r15(r: __Reader): (a0: MenuContext) => Array<ListRow> | null { return changetype<(a0: MenuContext) => Array<ListRow> | null>(__receiveFunction(r, changetype<usize>(__stub7))); }\n\nfunction __w16(w: __Writer, v: (a0: MenuEvent) => void): void { w.i32(__sendFunction(changetype<usize>(v), 8, __invoke)); }\n\nfunction __r16(r: __Reader): (a0: MenuEvent) => void { return changetype<(a0: MenuEvent) => void>(__receiveFunction(r, changetype<usize>(__stub8))); }\n\nfunction __w17(w: __Writer, v: __Player): void { w.i32(<i32>v.id); }\n\nfunction __r17(r: __Reader): __Player { return new __Player(r.i32()); }\n\nfunction __w19(w: __Writer, v: __Player | null): void {\n\tif (v == null) {\n\t\tw.bool(false);\n\t\treturn;\n\t}\n\tw.bool(true);\n\t__w17(w, v!);\n}\n\nfunction __r19(r: __Reader): __Player | null {\n\tif (!r.bool()) return null;\n\treturn __r17(r);\n}\n\nfunction __w18(w: __Writer, v: MenuShowOptions): void {\n\t__w2(w, v.time);\n\t__w19(w, v.target);\n\tw.bool(v.resetHistory !== undefined);\n\tif (v.resetHistory !== undefined) __w1(w, v.resetHistory);\n\tw.bool(v.force !== undefined);\n\tif (v.force !== undefined) __w1(w, v.force);\n\tw.bool(v.skipHistory !== undefined);\n\tif (v.skipHistory !== undefined) __w1(w, v.skipHistory);\n}\n\nfunction __u18(r: __Reader, o: MenuShowOptions): void {\n\to.time = __r2(r);\n\to.target = __r19(r);\n\tif (r.bool()) o.resetHistory = __r1(r);\n\telse o.resetHistory = undefined;\n\tif (r.bool()) o.force = __r1(r);\n\telse o.force = undefined;\n\tif (r.bool()) o.skipHistory = __r1(r);\n\telse o.skipHistory = undefined;\n}\n\nfunction __r18(r: __Reader): MenuShowOptions {\n\tconst o = changetype<MenuShowOptions>(__new(offsetof<MenuShowOptions>(), idof<MenuShowOptions>()));\n\t__u18(r, o);\n\treturn o;\n}\n\nconst __h21 = new Map<i32, Menu>();\n\nfunction __w21(w: __Writer, v: Menu): void { w.i32(v.__handle); }\n\nfunction __r21(r: __Reader): Menu {\n\tconst id = r.i32();\n\tif (__h21.has(id)) return __h21.get(id);\n\tconst o = new Menu(id);\n\t__h21.set(id, o);\n\treturn o;\n}\n\nfunction __w20(w: __Writer, v: Menu | null): void {\n\tif (v == null) {\n\t\tw.bool(false);\n\t\treturn;\n\t}\n\tw.bool(true);\n\t__w21(w, v!);\n}\n\nfunction __r20(r: __Reader): Menu | null {\n\tif (!r.bool()) return null;\n\treturn __r21(r);\n}\n\nfunction __w22(w: __Writer, v: i32): void { w.f64(<f64>v); }\n\nfunction __r22(r: __Reader): i32 { return <i32>r.f64(); }\n\nfunction __w23(w: __Writer, v: Array<string>): void {\n\tw.i32(v.length);\n\tfor (let i: i32 = 0; i < v.length; i++) __w0(w, v[i]);\n}\n\nfunction __r23(r: __Reader): Array<string> {\n\tconst count = r.i32();\n\tconst list = new Array<string>();\n\tfor (let i: i32 = 0; i < count; i++) list.push(__r0(r));\n\treturn list;\n}\n\nfunction __w24(w: __Writer, v: MenuOptions): void {\n\t__w12(w, v.title);\n\t__w2(w, v.time);\n\tw.bool(v.hideBack !== undefined);\n\tif (v.hideBack !== undefined) __w1(w, v.hideBack);\n\tw.bool(v.hideExit !== undefined);\n\tif (v.hideExit !== undefined) __w1(w, v.hideExit);\n\tw.bool(v.locked !== undefined);\n\tif (v.locked !== undefined) __w1(w, v.locked);\n\t__w7(w, v.activeWhen);\n}\n\nfunction __u24(r: __Reader, o: MenuOptions): void {\n\to.title = __r12(r);\n\to.time = __r2(r);\n\tif (r.bool()) o.hideBack = __r1(r);\n\telse o.hideBack = undefined;\n\tif (r.bool()) o.hideExit = __r1(r);\n\telse o.hideExit = undefined;\n\tif (r.bool()) o.locked = __r1(r);\n\telse o.locked = undefined;\n\to.activeWhen = __r7(r);\n}\n\nfunction __r24(r: __Reader): MenuOptions {\n\tconst o = changetype<MenuOptions>(__new(offsetof<MenuOptions>(), idof<MenuOptions>()));\n\t__u24(r, o);\n\treturn o;\n}\n\nfunction __w25(w: __Writer, v: (a0: __Player, a1: __Player, a2: string) => bool): void { w.i32(__sendFunction(changetype<usize>(v), 2, __invoke)); }\n\nfunction __r25(r: __Reader): (a0: __Player, a1: __Player, a2: string) => bool { return changetype<(a0: __Player, a1: __Player, a2: string) => bool>(__receiveFunction(r, changetype<usize>(__stub2))); }\n\nfunction __w26(w: __Writer, v: (a0: NamedContext) => void): void { w.i32(__sendFunction(changetype<usize>(v), 3, __invoke)); }\n\nfunction __r26(r: __Reader): (a0: NamedContext) => void { return changetype<(a0: NamedContext) => void>(__receiveFunction(r, changetype<usize>(__stub3))); }\n\nfunction __w27(w: __Writer, v: Record<string, (a0: NamedContext) => void>): void {\n\tconst keys = Object.keys(v);\n\tw.i32(keys.length);\n\tfor (let i: i32 = 0; i < keys.length; i++) {\n\t\tw.str(keys[i]);\n\t\t__w26(w, v[keys[i]]);\n\t}\n}\n\nfunction __r27(r: __Reader): Record<string, (a0: NamedContext) => void> {\n\tconst count = r.i32();\n\tconst record: Record<string, (a0: NamedContext) => void> = {};\n\tfor (let i: i32 = 0; i < count; i++) {\n\t\tconst key = r.str();\n\t\trecord[key] = __r26(r);\n\t}\n\treturn record;\n}\n\nfunction __w28(w: __Writer, v: Record<string, (a0: NamedContext) => string>): void {\n\tconst keys = Object.keys(v);\n\tw.i32(keys.length);\n\tfor (let i: i32 = 0; i < keys.length; i++) {\n\t\tw.str(keys[i]);\n\t\t__w14(w, v[keys[i]]);\n\t}\n}\n\nfunction __r28(r: __Reader): Record<string, (a0: NamedContext) => string> {\n\tconst count = r.i32();\n\tconst record: Record<string, (a0: NamedContext) => string> = {};\n\tfor (let i: i32 = 0; i < count; i++) {\n\t\tconst key = r.str();\n\t\trecord[key] = __r14(r);\n\t}\n\treturn record;\n}\n\nfunction __w29(w: __Writer, v: (a0: NamedContext) => bool): void { w.i32(__sendFunction(changetype<usize>(v), 5, __invoke)); }\n\nfunction __r29(r: __Reader): (a0: NamedContext) => bool { return changetype<(a0: NamedContext) => bool>(__receiveFunction(r, changetype<usize>(__stub5))); }\n\nfunction __w30(w: __Writer, v: (a0: __Player, a1: __Player, a2: string, a3: bool) => bool): void { w.i32(__sendFunction(changetype<usize>(v), 6, __invoke)); }\n\nfunction __r30(r: __Reader): (a0: __Player, a1: __Player, a2: string, a3: bool) => bool { return changetype<(a0: __Player, a1: __Player, a2: string, a3: bool) => bool>(__receiveFunction(r, changetype<usize>(__stub6))); }\n\nfunction __w31(w: __Writer, v: ListRow): void {\n\t__w0(w, v.kind);\n\t__w2(w, v.target);\n\t__w0(w, v.text);\n\t__w0(w, v.action);\n\t__w0(w, v.restriction);\n\t__w0(w, v.restrictionMessage);\n}\n\nfunction __u31(r: __Reader, o: ListRow): void {\n\to.kind = __r0(r);\n\to.target = __r2(r);\n\to.text = __r0(r);\n\to.action = __r0(r);\n\to.restriction = __r0(r);\n\to.restrictionMessage = __r0(r);\n}\n\nfunction __r31(r: __Reader): ListRow {\n\tconst o = changetype<ListRow>(__new(offsetof<ListRow>(), idof<ListRow>()));\n\t__u31(r, o);\n\treturn o;\n}\n\nfunction __w32(w: __Writer, v: MenuContext): void {\n\t__w17(w, v.player);\n\t__w17(w, v.target);\n\t__w2(w, v.row);\n\t__w21(w, v.menu);\n}\n\nfunction __u32(r: __Reader, o: MenuContext): void {\n\to.player = __r17(r);\n\to.target = __r17(r);\n\to.row = __r2(r);\n\to.menu = __r21(r);\n}\n\nfunction __r32(r: __Reader): MenuContext {\n\tconst o = changetype<MenuContext>(__new(offsetof<MenuContext>(), idof<MenuContext>()));\n\t__u32(r, o);\n\treturn o;\n}\n\nfunction __w33(w: __Writer, v: NamedContext): void {\n\t__w17(w, v.player);\n\t__w17(w, v.target);\n\t__w2(w, v.row);\n\t__w21(w, v.menu);\n\t__w0(w, v.name);\n}\n\nfunction __u33(r: __Reader, o: NamedContext): void {\n\to.player = __r17(r);\n\to.target = __r17(r);\n\to.row = __r2(r);\n\to.menu = __r21(r);\n\to.name = __r0(r);\n}\n\nfunction __r33(r: __Reader): NamedContext {\n\tconst o = changetype<NamedContext>(__new(offsetof<NamedContext>(), idof<NamedContext>()));\n\t__u33(r, o);\n\treturn o;\n}\n\nfunction __w35(w: __Writer, v: Array<ListRow>): void {\n\tw.i32(v.length);\n\tfor (let i: i32 = 0; i < v.length; i++) __w31(w, v[i]);\n}\n\nfunction __r35(r: __Reader): Array<ListRow> {\n\tconst count = r.i32();\n\tconst list = new Array<ListRow>();\n\tfor (let i: i32 = 0; i < count; i++) list.push(__r31(r));\n\treturn list;\n}\n\nfunction __w34(w: __Writer, v: Array<ListRow> | null): void {\n\tif (v == null) {\n\t\tw.bool(false);\n\t\treturn;\n\t}\n\tw.bool(true);\n\t__w35(w, v!);\n}\n\nfunction __r34(r: __Reader): Array<ListRow> | null {\n\tif (!r.bool()) return null;\n\treturn __r35(r);\n}\n\nfunction __w36(w: __Writer, v: MenuEvent): void {\n\t__w1(w, v.defaultPrevented);\n\t__w17(w, v.player);\n\t__w21(w, v.menu);\n\t__w1(w, v.timeout);\n}\n\nfunction __u36(r: __Reader, o: MenuEvent): void {\n\to.defaultPrevented = __r1(r);\n\to.player = __r17(r);\n\to.menu = __r21(r);\n\to.timeout = __r1(r);\n}\n\nfunction __r36(r: __Reader): MenuEvent {\n\tconst o = changetype<MenuEvent>(__new(offsetof<MenuEvent>(), idof<MenuEvent>()));\n\t__u36(r, o);\n\treturn o;\n}\n\nfunction __stub0(a0: MenuContext): string {\n\tconst target = __remoteTarget();\n\tconst w = __beginCallback(target);\n\t__w32(w, a0);\n\tconst r = __callBack(target, w);\n\treturn __r0(r);\n}\n\nfunction __stub1(a0: MenuContext): bool {\n\tconst target = __remoteTarget();\n\tconst w = __beginCallback(target);\n\t__w32(w, a0);\n\tconst r = __callBack(target, w);\n\treturn __r1(r);\n}\n\nfunction __stub2(a0: __Player, a1: __Player, a2: string): bool {\n\tconst target = __remoteTarget();\n\tconst w = __beginCallback(target);\n\t__w17(w, a0);\n\t__w17(w, a1);\n\t__w0(w, a2);\n\tconst r = __callBack(target, w);\n\treturn __r1(r);\n}\n\nfunction __stub3(a0: NamedContext): void {\n\tconst target = __remoteTarget();\n\tconst w = __beginCallback(target);\n\t__w33(w, a0);\n\tconst r = __callBack(target, w);\n}\n\nfunction __stub4(a0: NamedContext): string {\n\tconst target = __remoteTarget();\n\tconst w = __beginCallback(target);\n\t__w33(w, a0);\n\tconst r = __callBack(target, w);\n\treturn __r0(r);\n}\n\nfunction __stub5(a0: NamedContext): bool {\n\tconst target = __remoteTarget();\n\tconst w = __beginCallback(target);\n\t__w33(w, a0);\n\tconst r = __callBack(target, w);\n\treturn __r1(r);\n}\n\nfunction __stub6(a0: __Player, a1: __Player, a2: string, a3: bool): bool {\n\tconst target = __remoteTarget();\n\tconst w = __beginCallback(target);\n\t__w17(w, a0);\n\t__w17(w, a1);\n\t__w0(w, a2);\n\t__w1(w, a3);\n\tconst r = __callBack(target, w);\n\treturn __r1(r);\n}\n\nfunction __stub7(a0: MenuContext): Array<ListRow> | null {\n\tconst target = __remoteTarget();\n\tconst w = __beginCallback(target);\n\t__w32(w, a0);\n\tconst r = __callBack(target, w);\n\treturn __r34(r);\n}\n\nfunction __stub8(a0: MenuEvent): void {\n\tconst target = __remoteTarget();\n\tconst w = __beginCallback(target);\n\t__w36(w, a0);\n\tconst r = __callBack(target, w);\n\t__u36(r, a0);\n}\n\nfunction __stub9(a0: MenuContext): void {\n\tconst target = __remoteTarget();\n\tconst w = __beginCallback(target);\n\t__w32(w, a0);\n\tconst r = __callBack(target, w);\n}\n\nfunction __invoke(fn: usize, sig: i32, r: __Reader, w: __Writer): void {\n\tswitch (sig) {\n\t\tcase 0: {\n\t\t\tconst a0 = __r32(r);\n\t\t\tconst f = changetype<(a0: MenuContext) => string>(fn);\n\t\t\tconst result = f(a0);\n\t\t\t__w0(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 1: {\n\t\t\tconst a0 = __r32(r);\n\t\t\tconst f = changetype<(a0: MenuContext) => bool>(fn);\n\t\t\tconst result = f(a0);\n\t\t\t__w1(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 2: {\n\t\t\tconst a0 = __r17(r);\n\t\t\tconst a1 = __r17(r);\n\t\t\tconst a2 = __r0(r);\n\t\t\tconst f = changetype<(a0: __Player, a1: __Player, a2: string) => bool>(fn);\n\t\t\tconst result = f(a0, a1, a2);\n\t\t\t__w1(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 3: {\n\t\t\tconst a0 = __r33(r);\n\t\t\tconst f = changetype<(a0: NamedContext) => void>(fn);\n\t\t\tf(a0);\n\t\t\tbreak;\n\t\t}\n\t\tcase 4: {\n\t\t\tconst a0 = __r33(r);\n\t\t\tconst f = changetype<(a0: NamedContext) => string>(fn);\n\t\t\tconst result = f(a0);\n\t\t\t__w0(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 5: {\n\t\t\tconst a0 = __r33(r);\n\t\t\tconst f = changetype<(a0: NamedContext) => bool>(fn);\n\t\t\tconst result = f(a0);\n\t\t\t__w1(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 6: {\n\t\t\tconst a0 = __r17(r);\n\t\t\tconst a1 = __r17(r);\n\t\t\tconst a2 = __r0(r);\n\t\t\tconst a3 = __r1(r);\n\t\t\tconst f = changetype<(a0: __Player, a1: __Player, a2: string, a3: bool) => bool>(fn);\n\t\t\tconst result = f(a0, a1, a2, a3);\n\t\t\t__w1(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 7: {\n\t\t\tconst a0 = __r32(r);\n\t\t\tconst f = changetype<(a0: MenuContext) => Array<ListRow> | null>(fn);\n\t\t\tconst result = f(a0);\n\t\t\t__w34(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 8: {\n\t\t\tconst a0 = __r36(r);\n\t\t\tconst f = changetype<(a0: MenuEvent) => void>(fn);\n\t\t\tf(a0);\n\t\t\t__w36(w, a0);\n\t\t\tbreak;\n\t\t}\n\t\tcase 9: {\n\t\t\tconst a0 = __r32(r);\n\t\t\tconst f = changetype<(a0: MenuContext) => void>(fn);\n\t\t\tf(a0);\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\nexport function setConfigFile(file: string, fallback?: string): void {\n\tconst __w = __service.begin(0);\n\t__w0(__w, file);\n\t__w13(__w, fallback);\n\tconst __r = __service.call(__w);\n}\n\nexport function find(name: string): Menu | null {\n\tconst __w = __service.begin(1);\n\t__w0(__w, name);\n\tconst __r = __service.call(__w);\n\treturn __r20(__r);\n}\n\nexport function indexOf(menu: Menu | null): i32 {\n\tconst __w = __service.begin(2);\n\t__w20(__w, menu);\n\tconst __r = __service.call(__w);\n\treturn __r22(__r);\n}\n\nexport function menuAt(index: number): Menu | null {\n\tconst __w = __service.begin(3);\n\t__w2(__w, index);\n\tconst __r = __service.call(__w);\n\treturn __r20(__r);\n}\n\nexport function register(...names: string[]): Menu | null {\n\tconst __w = __service.begin(4);\n\t__w23(__w, names);\n\tconst __r = __service.call(__w);\n\treturn __r20(__r);\n}\n\nexport function create(name: string, options: MenuOptions = {}): Menu {\n\tconst __w = __service.begin(5);\n\t__w0(__w, name);\n\t__w24(__w, options);\n\tconst __r = __service.call(__w);\n\treturn __r21(__r);\n}\n\nexport function addCondition(name: string, test: ConditionTest): i32 {\n\tconst __w = __service.begin(6);\n\t__w0(__w, name);\n\t__w25(__w, test);\n\tconst __r = __service.call(__w);\n\treturn __r22(__r);\n}\n\nexport function addAction(name: string, run: ActionHandler): i32 {\n\tconst __w = __service.begin(7);\n\t__w0(__w, name);\n\t__w26(__w, run);\n\tconst __r = __service.call(__w);\n\treturn __r22(__r);\n}\n\nexport function addActions(actions: Record<string, ActionHandler>): void {\n\tconst __w = __service.begin(8);\n\t__w27(__w, actions);\n\tconst __r = __service.call(__w);\n}\n\nexport function addPlaceholders(placeholders: Record<string, PlaceholderValue>): void {\n\tconst __w = __service.begin(9);\n\t__w28(__w, placeholders);\n\tconst __r = __service.call(__w);\n}\n\nexport function addPlaceholder(name: string, value: PlaceholderValue): i32 {\n\tconst __w = __service.begin(10);\n\t__w0(__w, name);\n\t__w14(__w, value);\n\tconst __r = __service.call(__w);\n\treturn __r22(__r);\n}\n\nexport function addRestriction(name: string, test: RestrictionTest, message?: string): i32 {\n\tconst __w = __service.begin(11);\n\t__w0(__w, name);\n\t__w29(__w, test);\n\t__w13(__w, message);\n\tconst __r = __service.call(__w);\n\treturn __r22(__r);\n}\n\nexport function addActionCheck(menu: string, action: string, test: ActionTest): i32 {\n\tconst __w = __service.begin(12);\n\t__w0(__w, menu);\n\t__w0(__w, action);\n\t__w29(__w, test);\n\tconst __r = __service.call(__w);\n\treturn __r22(__r);\n}\n\nexport function addConditionFilter(name: string, filter: ConditionFilter): i32 {\n\tconst __w = __service.begin(13);\n\t__w0(__w, name);\n\t__w30(__w, filter);\n\tconst __r = __service.call(__w);\n\treturn __r22(__r);\n}\n\nexport function setListSource(menu: string, rows: ListSource): i32 {\n\tconst __w = __service.begin(14);\n\t__w0(__w, menu);\n\t__w15(__w, rows);\n\tconst __r = __service.call(__w);\n\treturn __r22(__r);\n}\n\nexport function addEventListener(type: MenuEventType, listener: MenuListener): i32 {\n\tconst __w = __service.begin(15);\n\t__w0(__w, type);\n\t__w16(__w, listener);\n\tconst __r = __service.call(__w);\n\treturn __r22(__r);\n}\n\nexport function listRow(target: number, text: string, action?: string, restriction?: string, restrictionMessage?: string): ListRow {\n\tconst __w = __service.begin(16);\n\t__w2(__w, target);\n\t__w0(__w, text);\n\t__w13(__w, action);\n\t__w13(__w, restriction);\n\t__w13(__w, restrictionMessage);\n\tconst __r = __service.call(__w);\n\treturn __r31(__r);\n}\n\nexport function textRow(text: string, centered = false): ListRow {\n\tconst __w = __service.begin(17);\n\t__w0(__w, text);\n\t__w1(__w, centered);\n\tconst __r = __service.call(__w);\n\treturn __r31(__r);\n}\n\nexport function show(player: Player, name: string, options: MenuShowOptions = {}): bool {\n\tconst __w = __service.begin(18);\n\t__w17(__w, player);\n\t__w0(__w, name);\n\t__w18(__w, options);\n\tconst __r = __service.call(__w);\n\treturn __r1(__r);\n}\n\nexport function close(player: Player, timeout = false): void {\n\tconst __w = __service.begin(19);\n\t__w17(__w, player);\n\t__w1(__w, timeout);\n\tconst __r = __service.call(__w);\n}\n\nexport function refresh(names: string): f64 {\n\tconst __w = __service.begin(20);\n\t__w0(__w, names);\n\tconst __r = __service.call(__w);\n\treturn __r2(__r);\n}\n\nexport function conditionChanged(name: string): void {\n\tconst __w = __service.begin(21);\n\t__w0(__w, name);\n\tconst __r = __service.call(__w);\n}\n\nexport function activeMenu(player: Player): Menu | null {\n\tconst __w = __service.begin(22);\n\t__w17(__w, player);\n\tconst __r = __service.call(__w);\n\treturn __r20(__r);\n}\n\nexport function shownText(player: Player): string {\n\tconst __w = __service.begin(23);\n\t__w17(__w, player);\n\tconst __r = __service.call(__w);\n\treturn __r0(__r);\n}\n\nexport function lock(player: Player, locked = true): void {\n\tconst __w = __service.begin(24);\n\t__w17(__w, player);\n\t__w1(__w, locked);\n\tconst __r = __service.call(__w);\n}\n\nexport function isLocked(player: Player): bool {\n\tconst __w = __service.begin(25);\n\t__w17(__w, player);\n\tconst __r = __service.call(__w);\n\treturn __r1(__r);\n}\n\nexport function setPage(player: Player, page: number): void {\n\tconst __w = __service.begin(26);\n\t__w17(__w, player);\n\t__w2(__w, page);\n\tconst __r = __service.call(__w);\n}\n\nexport function hasAction(name: string): bool {\n\tconst __w = __service.begin(27);\n\t__w0(__w, name);\n\tconst __r = __service.call(__w);\n\treturn __r1(__r);\n}\n\nexport function hasText(name: string): bool {\n\tconst __w = __service.begin(28);\n\t__w0(__w, name);\n\tconst __r = __service.call(__w);\n\treturn __r1(__r);\n}\n",
|
|
709
|
+
"serve": "// GENERATED by scripts/shared-modules.ts: ~/modules/menu-core, run by this plugin for every other.\nimport { Reader as __Reader, Writer as __Writer, beginCallback as __beginCallback, callBack as __callBack, receiveFunction as __receiveFunction, remoteTarget as __remoteTarget, sendFunction as __sendFunction, Handles as __Handles, serve as __serve } from \"~/remote\";\nimport * as __m from \"~/modules/menu-core\";\nimport { Player as __Player } from \"~/facade\";\nimport { Menu as __M_Menu, MenuContext as __M_MenuContext, MenuOptions as __M_MenuOptions, NamedContext as __M_NamedContext, ListRow as __M_ListRow, MenuEvent as __M_MenuEvent, MenuShowOptions as __M_MenuShowOptions, MenuItemOptions as __M_MenuItemOptions, Requirement as __M_Requirement } from \"~/modules/menu-core\";\n\nconst __handles = new __Handles();\n// The exported objects are handles 1, 2, ... - the numbers the proxies have.\n\nfunction __dispatch(op: i32, r: __Reader, w: __Writer): void {\n\tswitch (op) {\n\t\tcase 0: {\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst a1 = __r1(r);\n\t\t\t__m.setConfigFile(a0, a1);\n\t\t\tbreak;\n\t\t}\n\t\tcase 1: {\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst result = __m.find(a0);\n\t\t\t__w2(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 2: {\n\t\t\tconst a0 = __r2(r);\n\t\t\tconst result = __m.indexOf(a0);\n\t\t\t__w4(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 3: {\n\t\t\tconst a0 = __r5(r);\n\t\t\tconst result = __m.menuAt(a0);\n\t\t\t__w2(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 4: {\n\t\t\tconst a0 = __r6(r);\n\t\t\tconst result = __m.register(...a0);\n\t\t\t__w2(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 5: {\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst a1 = __r7(r);\n\t\t\tconst result = __m.create(a0, a1);\n\t\t\t__w3(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 6: {\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst a1 = __r13(r);\n\t\t\tconst result = __m.addCondition(a0, a1);\n\t\t\t__w4(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 7: {\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst a1 = __r14(r);\n\t\t\tconst result = __m.addAction(a0, a1);\n\t\t\t__w4(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 8: {\n\t\t\tconst a0 = __r15(r);\n\t\t\t__m.addActions(a0);\n\t\t\tbreak;\n\t\t}\n\t\tcase 9: {\n\t\t\tconst a0 = __r16(r);\n\t\t\t__m.addPlaceholders(a0);\n\t\t\tbreak;\n\t\t}\n\t\tcase 10: {\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst a1 = __r17(r);\n\t\t\tconst result = __m.addPlaceholder(a0, a1);\n\t\t\t__w4(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 11: {\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst a1 = __r18(r);\n\t\t\tconst a2 = __r1(r);\n\t\t\tconst result = __m.addRestriction(a0, a1, a2);\n\t\t\t__w4(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 12: {\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst a1 = __r0(r);\n\t\t\tconst a2 = __r18(r);\n\t\t\tconst result = __m.addActionCheck(a0, a1, a2);\n\t\t\t__w4(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 13: {\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst a1 = __r19(r);\n\t\t\tconst result = __m.addConditionFilter(a0, a1);\n\t\t\t__w4(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 14: {\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst a1 = __r20(r);\n\t\t\tconst result = __m.setListSource(a0, a1);\n\t\t\t__w4(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 15: {\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst a1 = __r21(r);\n\t\t\tconst result = __m.addEventListener(a0, a1);\n\t\t\t__w4(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 16: {\n\t\t\tconst a0 = __r5(r);\n\t\t\tconst a1 = __r0(r);\n\t\t\tconst a2 = __r1(r);\n\t\t\tconst a3 = __r1(r);\n\t\t\tconst a4 = __r1(r);\n\t\t\tconst result = __m.listRow(a0, a1, a2, a3, a4);\n\t\t\t__w22(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 17: {\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst a1 = __r10(r);\n\t\t\tconst result = __m.textRow(a0, a1);\n\t\t\t__w22(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 18: {\n\t\t\tconst a0 = __r23(r);\n\t\t\tconst a1 = __r0(r);\n\t\t\tconst a2 = __r24(r);\n\t\t\tconst result = __m.show(a0, a1, a2);\n\t\t\t__w10(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 19: {\n\t\t\tconst a0 = __r23(r);\n\t\t\tconst a1 = __r10(r);\n\t\t\t__m.close(a0, a1);\n\t\t\tbreak;\n\t\t}\n\t\tcase 20: {\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst result = __m.refresh(a0);\n\t\t\t__w5(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 21: {\n\t\t\tconst a0 = __r0(r);\n\t\t\t__m.conditionChanged(a0);\n\t\t\tbreak;\n\t\t}\n\t\tcase 22: {\n\t\t\tconst a0 = __r23(r);\n\t\t\tconst result = __m.activeMenu(a0);\n\t\t\t__w2(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 23: {\n\t\t\tconst a0 = __r23(r);\n\t\t\tconst result = __m.shownText(a0);\n\t\t\t__w0(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 24: {\n\t\t\tconst a0 = __r23(r);\n\t\t\tconst a1 = __r10(r);\n\t\t\t__m.lock(a0, a1);\n\t\t\tbreak;\n\t\t}\n\t\tcase 25: {\n\t\t\tconst a0 = __r23(r);\n\t\t\tconst result = __m.isLocked(a0);\n\t\t\t__w10(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 26: {\n\t\t\tconst a0 = __r23(r);\n\t\t\tconst a1 = __r5(r);\n\t\t\t__m.setPage(a0, a1);\n\t\t\tbreak;\n\t\t}\n\t\tcase 27: {\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst result = __m.hasAction(a0);\n\t\t\t__w10(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 28: {\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst result = __m.hasText(a0);\n\t\t\t__w10(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 29: {\n\t\t\tconst o = __r3(r);\n\t\t\t__w0(w, o.kind);\n\t\t\tbreak;\n\t\t}\n\t\tcase 30: {\n\t\t\tconst o = __r3(r);\n\t\t\t__w10(w, o.hideBack);\n\t\t\tbreak;\n\t\t}\n\t\tcase 31: {\n\t\t\tconst o = __r3(r);\n\t\t\to.hideBack = __r10(r);\n\t\t\tbreak;\n\t\t}\n\t\tcase 32: {\n\t\t\tconst o = __r3(r);\n\t\t\t__w10(w, o.hideExit);\n\t\t\tbreak;\n\t\t}\n\t\tcase 33: {\n\t\t\tconst o = __r3(r);\n\t\t\to.hideExit = __r10(r);\n\t\t\tbreak;\n\t\t}\n\t\tcase 34: {\n\t\t\tconst o = __r3(r);\n\t\t\t__w10(w, o.locked);\n\t\t\tbreak;\n\t\t}\n\t\tcase 35: {\n\t\t\tconst o = __r3(r);\n\t\t\to.locked = __r10(r);\n\t\t\tbreak;\n\t\t}\n\t\tcase 36: {\n\t\t\tconst o = __r3(r);\n\t\t\t__w10(w, o.sharedTimer);\n\t\t\tbreak;\n\t\t}\n\t\tcase 37: {\n\t\t\tconst o = __r3(r);\n\t\t\to.sharedTimer = __r10(r);\n\t\t\tbreak;\n\t\t}\n\t\tcase 38: {\n\t\t\tconst o = __r3(r);\n\t\t\t__w5(w, o.time);\n\t\t\tbreak;\n\t\t}\n\t\tcase 39: {\n\t\t\tconst o = __r3(r);\n\t\t\to.time = __r5(r);\n\t\t\tbreak;\n\t\t}\n\t\tcase 40: {\n\t\t\tconst o = __r3(r);\n\t\t\t__w0(w, o.onTimeout);\n\t\t\tbreak;\n\t\t}\n\t\tcase 41: {\n\t\t\tconst o = __r3(r);\n\t\t\to.onTimeout = __r0(r);\n\t\t\tbreak;\n\t\t}\n\t\tcase 42: {\n\t\t\tconst o = __r3(r);\n\t\t\t__w0(w, o.activeOn);\n\t\t\tbreak;\n\t\t}\n\t\tcase 43: {\n\t\t\tconst o = __r3(r);\n\t\t\to.activeOn = __r0(r);\n\t\t\tbreak;\n\t\t}\n\t\tcase 44: {\n\t\t\tconst o = __r3(r);\n\t\t\t__w5(w, o.countdown);\n\t\t\tbreak;\n\t\t}\n\t\tcase 45: {\n\t\t\tconst o = __r3(r);\n\t\t\to.countdown = __r5(r);\n\t\t\tbreak;\n\t\t}\n\t\tcase 46: {\n\t\t\tconst o = __r3(r);\n\t\t\t__w0(w, o.name);\n\t\t\tbreak;\n\t\t}\n\t\tcase 47: {\n\t\t\tconst o = __r3(r);\n\t\t\t__w9(w, o.title);\n\t\t\tbreak;\n\t\t}\n\t\tcase 48: {\n\t\t\tconst o = __r3(r);\n\t\t\to.title = __r9(r);\n\t\t\tbreak;\n\t\t}\n\t\tcase 49: {\n\t\t\tconst o = __r3(r);\n\t\t\tconst a0 = __r26(r);\n\t\t\to.addItem(a0);\n\t\t\tbreak;\n\t\t}\n\t\tcase 50: {\n\t\t\tconst o = __r3(r);\n\t\t\tconst a0 = __r5(r);\n\t\t\tconst a1 = __r26(r);\n\t\t\to.addFixedItem(a0, a1);\n\t\t\tbreak;\n\t\t}\n\t\tcase 51: {\n\t\t\tconst o = __r3(r);\n\t\t\to.clearItems();\n\t\t\tbreak;\n\t\t}\n\t\tcase 52: {\n\t\t\tconst o = __r3(r);\n\t\t\tconst a0 = __r12(r);\n\t\t\tconst a1 = __r1(r);\n\t\t\to.addFilter(a0, a1);\n\t\t\tbreak;\n\t\t}\n\t\tcase 53: {\n\t\t\tconst o = __r3(r);\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst a1 = __r17(r);\n\t\t\to.addPlaceholder(a0, a1);\n\t\t\tbreak;\n\t\t}\n\t\tcase 54: {\n\t\t\tconst o = __r3(r);\n\t\t\tconst a0 = __r20(r);\n\t\t\to.setListSource(a0);\n\t\t\tbreak;\n\t\t}\n\t\tcase 55: {\n\t\t\tconst o = __r3(r);\n\t\t\tconst a0 = __r0(r);\n\t\t\tconst a1 = __r21(r);\n\t\t\to.addEventListener(a0, a1);\n\t\t\tbreak;\n\t\t}\n\t\tcase 56: {\n\t\t\tconst o = __r3(r);\n\t\t\tconst a0 = __r23(r);\n\t\t\tconst a1 = __r24(r);\n\t\t\tconst result = o.show(a0, a1);\n\t\t\t__w10(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 57: {\n\t\t\tconst o = __r3(r);\n\t\t\tconst a0 = __r23(r);\n\t\t\tconst a1 = __r0(r);\n\t\t\tconst a2 = __r25(r);\n\t\t\to.runActions(a0, a1, a2);\n\t\t\tbreak;\n\t\t}\n\t\tcase 58: {\n\t\t\tconst o = __r3(r);\n\t\t\tconst result = o.refresh();\n\t\t\t__w5(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 59: {\n\t\t\tconst o = __r3(r);\n\t\t\to.close();\n\t\t\tbreak;\n\t\t}\n\t\tcase 60: {\n\t\t\tconst o = __r3(r);\n\t\t\tconst a0 = __r5(r);\n\t\t\tconst result = o.setTimer(a0);\n\t\t\t__w10(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 61: {\n\t\t\tconst o = __r3(r);\n\t\t\tconst result = o.cancelTimer();\n\t\t\t__w10(w, result);\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\nfunction __stub0(a0: __M_MenuContext): string {\n\tconst target = __remoteTarget();\n\tconst w = __beginCallback(target);\n\t__w32(w, a0);\n\tconst r = __callBack(target, w);\n\treturn __r0(r);\n}\n\nfunction __stub1(a0: __M_MenuContext): bool {\n\tconst target = __remoteTarget();\n\tconst w = __beginCallback(target);\n\t__w32(w, a0);\n\tconst r = __callBack(target, w);\n\treturn __r10(r);\n}\n\nfunction __stub2(a0: __Player, a1: __Player, a2: string): bool {\n\tconst target = __remoteTarget();\n\tconst w = __beginCallback(target);\n\t__w23(w, a0);\n\t__w23(w, a1);\n\t__w0(w, a2);\n\tconst r = __callBack(target, w);\n\treturn __r10(r);\n}\n\nfunction __stub3(a0: __M_NamedContext): void {\n\tconst target = __remoteTarget();\n\tconst w = __beginCallback(target);\n\t__w33(w, a0);\n\tconst r = __callBack(target, w);\n}\n\nfunction __stub4(a0: __M_NamedContext): string {\n\tconst target = __remoteTarget();\n\tconst w = __beginCallback(target);\n\t__w33(w, a0);\n\tconst r = __callBack(target, w);\n\treturn __r0(r);\n}\n\nfunction __stub5(a0: __M_NamedContext): bool {\n\tconst target = __remoteTarget();\n\tconst w = __beginCallback(target);\n\t__w33(w, a0);\n\tconst r = __callBack(target, w);\n\treturn __r10(r);\n}\n\nfunction __stub6(a0: __Player, a1: __Player, a2: string, a3: bool): bool {\n\tconst target = __remoteTarget();\n\tconst w = __beginCallback(target);\n\t__w23(w, a0);\n\t__w23(w, a1);\n\t__w0(w, a2);\n\t__w10(w, a3);\n\tconst r = __callBack(target, w);\n\treturn __r10(r);\n}\n\nfunction __stub7(a0: __M_MenuContext): Array<__M_ListRow> | null {\n\tconst target = __remoteTarget();\n\tconst w = __beginCallback(target);\n\t__w32(w, a0);\n\tconst r = __callBack(target, w);\n\treturn __r34(r);\n}\n\nfunction __stub8(a0: __M_MenuEvent): void {\n\tconst target = __remoteTarget();\n\tconst w = __beginCallback(target);\n\t__w36(w, a0);\n\tconst r = __callBack(target, w);\n\t__u36(r, a0);\n}\n\nfunction __stub9(a0: __M_MenuContext): void {\n\tconst target = __remoteTarget();\n\tconst w = __beginCallback(target);\n\t__w32(w, a0);\n\tconst r = __callBack(target, w);\n}\n\nfunction __invoke(fn: usize, sig: i32, r: __Reader, w: __Writer): void {\n\tswitch (sig) {\n\t\tcase 0: {\n\t\t\tconst a0 = __r32(r);\n\t\t\tconst f = changetype<(a0: __M_MenuContext) => string>(fn);\n\t\t\tconst result = f(a0);\n\t\t\t__w0(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 1: {\n\t\t\tconst a0 = __r32(r);\n\t\t\tconst f = changetype<(a0: __M_MenuContext) => bool>(fn);\n\t\t\tconst result = f(a0);\n\t\t\t__w10(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 2: {\n\t\t\tconst a0 = __r23(r);\n\t\t\tconst a1 = __r23(r);\n\t\t\tconst a2 = __r0(r);\n\t\t\tconst f = changetype<(a0: __Player, a1: __Player, a2: string) => bool>(fn);\n\t\t\tconst result = f(a0, a1, a2);\n\t\t\t__w10(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 3: {\n\t\t\tconst a0 = __r33(r);\n\t\t\tconst f = changetype<(a0: __M_NamedContext) => void>(fn);\n\t\t\tf(a0);\n\t\t\tbreak;\n\t\t}\n\t\tcase 4: {\n\t\t\tconst a0 = __r33(r);\n\t\t\tconst f = changetype<(a0: __M_NamedContext) => string>(fn);\n\t\t\tconst result = f(a0);\n\t\t\t__w0(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 5: {\n\t\t\tconst a0 = __r33(r);\n\t\t\tconst f = changetype<(a0: __M_NamedContext) => bool>(fn);\n\t\t\tconst result = f(a0);\n\t\t\t__w10(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 6: {\n\t\t\tconst a0 = __r23(r);\n\t\t\tconst a1 = __r23(r);\n\t\t\tconst a2 = __r0(r);\n\t\t\tconst a3 = __r10(r);\n\t\t\tconst f = changetype<(a0: __Player, a1: __Player, a2: string, a3: bool) => bool>(fn);\n\t\t\tconst result = f(a0, a1, a2, a3);\n\t\t\t__w10(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 7: {\n\t\t\tconst a0 = __r32(r);\n\t\t\tconst f = changetype<(a0: __M_MenuContext) => Array<__M_ListRow> | null>(fn);\n\t\t\tconst result = f(a0);\n\t\t\t__w34(w, result);\n\t\t\tbreak;\n\t\t}\n\t\tcase 8: {\n\t\t\tconst a0 = __r36(r);\n\t\t\tconst f = changetype<(a0: __M_MenuEvent) => void>(fn);\n\t\t\tf(a0);\n\t\t\t__w36(w, a0);\n\t\t\tbreak;\n\t\t}\n\t\tcase 9: {\n\t\t\tconst a0 = __r32(r);\n\t\t\tconst f = changetype<(a0: __M_MenuContext) => void>(fn);\n\t\t\tf(a0);\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\nfunction __w0(w: __Writer, v: string): void { w.str(v); }\n\nfunction __r0(r: __Reader): string { return r.str(); }\n\nfunction __w1(w: __Writer, v: string | null): void {\n\tif (v == null) {\n\t\tw.bool(false);\n\t\treturn;\n\t}\n\tw.bool(true);\n\t__w0(w, v!);\n}\n\nfunction __r1(r: __Reader): string | null {\n\tif (!r.bool()) return null;\n\treturn __r0(r);\n}\n\nfunction __w3(w: __Writer, v: __M_Menu): void { w.i32(__handles.id(changetype<usize>(v))); }\n\nfunction __r3(r: __Reader): __M_Menu { return changetype<__M_Menu>(__handles.at(r.i32())); }\n\nfunction __w2(w: __Writer, v: __M_Menu | null): void {\n\tif (v == null) {\n\t\tw.bool(false);\n\t\treturn;\n\t}\n\tw.bool(true);\n\t__w3(w, v!);\n}\n\nfunction __r2(r: __Reader): __M_Menu | null {\n\tif (!r.bool()) return null;\n\treturn __r3(r);\n}\n\nfunction __w4(w: __Writer, v: i32): void { w.f64(<f64>v); }\n\nfunction __r4(r: __Reader): i32 { return <i32>r.f64(); }\n\nfunction __w5(w: __Writer, v: f64): void { w.f64(<f64>v); }\n\nfunction __r5(r: __Reader): f64 { return <f64>r.f64(); }\n\nfunction __w6(w: __Writer, v: Array<string>): void {\n\tw.i32(v.length);\n\tfor (let i: i32 = 0; i < v.length; i++) __w0(w, v[i]);\n}\n\nfunction __r6(r: __Reader): Array<string> {\n\tconst count = r.i32();\n\tconst list = new Array<string>();\n\tfor (let i: i32 = 0; i < count; i++) list.push(__r0(r));\n\treturn list;\n}\n\nfunction __w9(w: __Writer, v: (a0: __M_MenuContext) => string): void { w.i32(__sendFunction(changetype<usize>(v), 0, __invoke)); }\n\nfunction __r9(r: __Reader): (a0: __M_MenuContext) => string { return changetype<(a0: __M_MenuContext) => string>(__receiveFunction(r, changetype<usize>(__stub0))); }\n\nfunction __w8(w: __Writer, v: ((a0: __M_MenuContext) => string) | null): void {\n\tif (v == null) {\n\t\tw.bool(false);\n\t\treturn;\n\t}\n\tw.bool(true);\n\t__w9(w, v!);\n}\n\nfunction __r8(r: __Reader): ((a0: __M_MenuContext) => string) | null {\n\tif (!r.bool()) return null;\n\treturn __r9(r);\n}\n\nfunction __w10(w: __Writer, v: bool): void { w.bool(v); }\n\nfunction __r10(r: __Reader): bool { return r.bool(); }\n\nfunction __w12(w: __Writer, v: (a0: __M_MenuContext) => bool): void { w.i32(__sendFunction(changetype<usize>(v), 1, __invoke)); }\n\nfunction __r12(r: __Reader): (a0: __M_MenuContext) => bool { return changetype<(a0: __M_MenuContext) => bool>(__receiveFunction(r, changetype<usize>(__stub1))); }\n\nfunction __w11(w: __Writer, v: ((a0: __M_MenuContext) => bool) | null): void {\n\tif (v == null) {\n\t\tw.bool(false);\n\t\treturn;\n\t}\n\tw.bool(true);\n\t__w12(w, v!);\n}\n\nfunction __r11(r: __Reader): ((a0: __M_MenuContext) => bool) | null {\n\tif (!r.bool()) return null;\n\treturn __r12(r);\n}\n\nfunction __w7(w: __Writer, v: __M_MenuOptions): void {\n\t__w8(w, v.title);\n\t__w5(w, v.time);\n\tw.bool(v.hideBack !== undefined);\n\tif (v.hideBack !== undefined) __w10(w, v.hideBack);\n\tw.bool(v.hideExit !== undefined);\n\tif (v.hideExit !== undefined) __w10(w, v.hideExit);\n\tw.bool(v.locked !== undefined);\n\tif (v.locked !== undefined) __w10(w, v.locked);\n\t__w11(w, v.activeWhen);\n}\n\nfunction __u7(r: __Reader, o: __M_MenuOptions): void {\n\to.title = __r8(r);\n\to.time = __r5(r);\n\tif (r.bool()) o.hideBack = __r10(r);\n\telse o.hideBack = undefined;\n\tif (r.bool()) o.hideExit = __r10(r);\n\telse o.hideExit = undefined;\n\tif (r.bool()) o.locked = __r10(r);\n\telse o.locked = undefined;\n\to.activeWhen = __r11(r);\n}\n\nfunction __r7(r: __Reader): __M_MenuOptions {\n\tconst o = changetype<__M_MenuOptions>(__new(offsetof<__M_MenuOptions>(), idof<__M_MenuOptions>()));\n\t__u7(r, o);\n\treturn o;\n}\n\nfunction __w13(w: __Writer, v: (a0: __Player, a1: __Player, a2: string) => bool): void { w.i32(__sendFunction(changetype<usize>(v), 2, __invoke)); }\n\nfunction __r13(r: __Reader): (a0: __Player, a1: __Player, a2: string) => bool { return changetype<(a0: __Player, a1: __Player, a2: string) => bool>(__receiveFunction(r, changetype<usize>(__stub2))); }\n\nfunction __w14(w: __Writer, v: (a0: __M_NamedContext) => void): void { w.i32(__sendFunction(changetype<usize>(v), 3, __invoke)); }\n\nfunction __r14(r: __Reader): (a0: __M_NamedContext) => void { return changetype<(a0: __M_NamedContext) => void>(__receiveFunction(r, changetype<usize>(__stub3))); }\n\nfunction __w15(w: __Writer, v: Record<string, (a0: __M_NamedContext) => void>): void {\n\tconst keys = Object.keys(v);\n\tw.i32(keys.length);\n\tfor (let i: i32 = 0; i < keys.length; i++) {\n\t\tw.str(keys[i]);\n\t\t__w14(w, v[keys[i]]);\n\t}\n}\n\nfunction __r15(r: __Reader): Record<string, (a0: __M_NamedContext) => void> {\n\tconst count = r.i32();\n\tconst record: Record<string, (a0: __M_NamedContext) => void> = {};\n\tfor (let i: i32 = 0; i < count; i++) {\n\t\tconst key = r.str();\n\t\trecord[key] = __r14(r);\n\t}\n\treturn record;\n}\n\nfunction __w17(w: __Writer, v: (a0: __M_NamedContext) => string): void { w.i32(__sendFunction(changetype<usize>(v), 4, __invoke)); }\n\nfunction __r17(r: __Reader): (a0: __M_NamedContext) => string { return changetype<(a0: __M_NamedContext) => string>(__receiveFunction(r, changetype<usize>(__stub4))); }\n\nfunction __w16(w: __Writer, v: Record<string, (a0: __M_NamedContext) => string>): void {\n\tconst keys = Object.keys(v);\n\tw.i32(keys.length);\n\tfor (let i: i32 = 0; i < keys.length; i++) {\n\t\tw.str(keys[i]);\n\t\t__w17(w, v[keys[i]]);\n\t}\n}\n\nfunction __r16(r: __Reader): Record<string, (a0: __M_NamedContext) => string> {\n\tconst count = r.i32();\n\tconst record: Record<string, (a0: __M_NamedContext) => string> = {};\n\tfor (let i: i32 = 0; i < count; i++) {\n\t\tconst key = r.str();\n\t\trecord[key] = __r17(r);\n\t}\n\treturn record;\n}\n\nfunction __w18(w: __Writer, v: (a0: __M_NamedContext) => bool): void { w.i32(__sendFunction(changetype<usize>(v), 5, __invoke)); }\n\nfunction __r18(r: __Reader): (a0: __M_NamedContext) => bool { return changetype<(a0: __M_NamedContext) => bool>(__receiveFunction(r, changetype<usize>(__stub5))); }\n\nfunction __w19(w: __Writer, v: (a0: __Player, a1: __Player, a2: string, a3: bool) => bool): void { w.i32(__sendFunction(changetype<usize>(v), 6, __invoke)); }\n\nfunction __r19(r: __Reader): (a0: __Player, a1: __Player, a2: string, a3: bool) => bool { return changetype<(a0: __Player, a1: __Player, a2: string, a3: bool) => bool>(__receiveFunction(r, changetype<usize>(__stub6))); }\n\nfunction __w20(w: __Writer, v: (a0: __M_MenuContext) => Array<__M_ListRow> | null): void { w.i32(__sendFunction(changetype<usize>(v), 7, __invoke)); }\n\nfunction __r20(r: __Reader): (a0: __M_MenuContext) => Array<__M_ListRow> | null { return changetype<(a0: __M_MenuContext) => Array<__M_ListRow> | null>(__receiveFunction(r, changetype<usize>(__stub7))); }\n\nfunction __w21(w: __Writer, v: (a0: __M_MenuEvent) => void): void { w.i32(__sendFunction(changetype<usize>(v), 8, __invoke)); }\n\nfunction __r21(r: __Reader): (a0: __M_MenuEvent) => void { return changetype<(a0: __M_MenuEvent) => void>(__receiveFunction(r, changetype<usize>(__stub8))); }\n\nfunction __w22(w: __Writer, v: __M_ListRow): void {\n\t__w0(w, v.kind);\n\t__w5(w, v.target);\n\t__w0(w, v.text);\n\t__w0(w, v.action);\n\t__w0(w, v.restriction);\n\t__w0(w, v.restrictionMessage);\n}\n\nfunction __u22(r: __Reader, o: __M_ListRow): void {\n\to.kind = __r0(r);\n\to.target = __r5(r);\n\to.text = __r0(r);\n\to.action = __r0(r);\n\to.restriction = __r0(r);\n\to.restrictionMessage = __r0(r);\n}\n\nfunction __r22(r: __Reader): __M_ListRow {\n\tconst o = changetype<__M_ListRow>(__new(offsetof<__M_ListRow>(), idof<__M_ListRow>()));\n\t__u22(r, o);\n\treturn o;\n}\n\nfunction __w23(w: __Writer, v: __Player): void { w.i32(<i32>v.id); }\n\nfunction __r23(r: __Reader): __Player { return new __Player(r.i32()); }\n\nfunction __w25(w: __Writer, v: __Player | null): void {\n\tif (v == null) {\n\t\tw.bool(false);\n\t\treturn;\n\t}\n\tw.bool(true);\n\t__w23(w, v!);\n}\n\nfunction __r25(r: __Reader): __Player | null {\n\tif (!r.bool()) return null;\n\treturn __r23(r);\n}\n\nfunction __w24(w: __Writer, v: __M_MenuShowOptions): void {\n\t__w5(w, v.time);\n\t__w25(w, v.target);\n\tw.bool(v.resetHistory !== undefined);\n\tif (v.resetHistory !== undefined) __w10(w, v.resetHistory);\n\tw.bool(v.force !== undefined);\n\tif (v.force !== undefined) __w10(w, v.force);\n\tw.bool(v.skipHistory !== undefined);\n\tif (v.skipHistory !== undefined) __w10(w, v.skipHistory);\n}\n\nfunction __u24(r: __Reader, o: __M_MenuShowOptions): void {\n\to.time = __r5(r);\n\to.target = __r25(r);\n\tif (r.bool()) o.resetHistory = __r10(r);\n\telse o.resetHistory = undefined;\n\tif (r.bool()) o.force = __r10(r);\n\telse o.force = undefined;\n\tif (r.bool()) o.skipHistory = __r10(r);\n\telse o.skipHistory = undefined;\n}\n\nfunction __r24(r: __Reader): __M_MenuShowOptions {\n\tconst o = changetype<__M_MenuShowOptions>(__new(offsetof<__M_MenuShowOptions>(), idof<__M_MenuShowOptions>()));\n\t__u24(r, o);\n\treturn o;\n}\n\nfunction __w28(w: __Writer, v: (a0: __M_MenuContext) => void): void { w.i32(__sendFunction(changetype<usize>(v), 9, __invoke)); }\n\nfunction __r28(r: __Reader): (a0: __M_MenuContext) => void { return changetype<(a0: __M_MenuContext) => void>(__receiveFunction(r, changetype<usize>(__stub9))); }\n\nfunction __w27(w: __Writer, v: ((a0: __M_MenuContext) => void) | null): void {\n\tif (v == null) {\n\t\tw.bool(false);\n\t\treturn;\n\t}\n\tw.bool(true);\n\t__w28(w, v!);\n}\n\nfunction __r27(r: __Reader): ((a0: __M_MenuContext) => void) | null {\n\tif (!r.bool()) return null;\n\treturn __r28(r);\n}\n\nfunction __w31(w: __Writer, v: __M_Requirement): void {\n\t__w12(w, v.when);\n\t__w8(w, v.message);\n}\n\nfunction __u31(r: __Reader, o: __M_Requirement): void {\n\to.when = __r12(r);\n\to.message = __r8(r);\n}\n\nfunction __r31(r: __Reader): __M_Requirement {\n\tconst o = changetype<__M_Requirement>(__new(offsetof<__M_Requirement>(), idof<__M_Requirement>()));\n\t__u31(r, o);\n\treturn o;\n}\n\nfunction __w30(w: __Writer, v: Array<__M_Requirement>): void {\n\tw.i32(v.length);\n\tfor (let i: i32 = 0; i < v.length; i++) __w31(w, v[i]);\n}\n\nfunction __r30(r: __Reader): Array<__M_Requirement> {\n\tconst count = r.i32();\n\tconst list = new Array<__M_Requirement>();\n\tfor (let i: i32 = 0; i < count; i++) list.push(__r31(r));\n\treturn list;\n}\n\nfunction __w29(w: __Writer, v: Array<__M_Requirement> | null): void {\n\tif (v == null) {\n\t\tw.bool(false);\n\t\treturn;\n\t}\n\tw.bool(true);\n\t__w30(w, v!);\n}\n\nfunction __r29(r: __Reader): Array<__M_Requirement> | null {\n\tif (!r.bool()) return null;\n\treturn __r30(r);\n}\n\nfunction __w26(w: __Writer, v: __M_MenuItemOptions): void {\n\t__w9(w, v.title);\n\t__w27(w, v.onSelect);\n\t__w11(w, v.visible);\n\t__w29(w, v.enabled);\n\t__w8(w, v.message);\n\t__w1(w, v.placeholder);\n\t__w1(w, v.action);\n\t__w5(w, v.at);\n\t__w5(w, v.spaceBefore);\n\t__w5(w, v.spaceAfter);\n}\n\nfunction __u26(r: __Reader, o: __M_MenuItemOptions): void {\n\to.title = __r9(r);\n\to.onSelect = __r27(r);\n\to.visible = __r11(r);\n\to.enabled = __r29(r);\n\to.message = __r8(r);\n\to.placeholder = __r1(r);\n\to.action = __r1(r);\n\to.at = __r5(r);\n\to.spaceBefore = __r5(r);\n\to.spaceAfter = __r5(r);\n}\n\nfunction __r26(r: __Reader): __M_MenuItemOptions {\n\tconst o = changetype<__M_MenuItemOptions>(__new(offsetof<__M_MenuItemOptions>(), idof<__M_MenuItemOptions>()));\n\t__u26(r, o);\n\treturn o;\n}\n\nfunction __w32(w: __Writer, v: __M_MenuContext): void {\n\t__w23(w, v.player);\n\t__w23(w, v.target);\n\t__w5(w, v.row);\n\t__w3(w, v.menu);\n}\n\nfunction __u32(r: __Reader, o: __M_MenuContext): void {\n\to.player = __r23(r);\n\to.target = __r23(r);\n\to.row = __r5(r);\n\to.menu = __r3(r);\n}\n\nfunction __r32(r: __Reader): __M_MenuContext {\n\tconst o = changetype<__M_MenuContext>(__new(offsetof<__M_MenuContext>(), idof<__M_MenuContext>()));\n\t__u32(r, o);\n\treturn o;\n}\n\nfunction __w33(w: __Writer, v: __M_NamedContext): void {\n\t__w23(w, v.player);\n\t__w23(w, v.target);\n\t__w5(w, v.row);\n\t__w3(w, v.menu);\n\t__w0(w, v.name);\n}\n\nfunction __u33(r: __Reader, o: __M_NamedContext): void {\n\to.player = __r23(r);\n\to.target = __r23(r);\n\to.row = __r5(r);\n\to.menu = __r3(r);\n\to.name = __r0(r);\n}\n\nfunction __r33(r: __Reader): __M_NamedContext {\n\tconst o = changetype<__M_NamedContext>(__new(offsetof<__M_NamedContext>(), idof<__M_NamedContext>()));\n\t__u33(r, o);\n\treturn o;\n}\n\nfunction __w35(w: __Writer, v: Array<__M_ListRow>): void {\n\tw.i32(v.length);\n\tfor (let i: i32 = 0; i < v.length; i++) __w22(w, v[i]);\n}\n\nfunction __r35(r: __Reader): Array<__M_ListRow> {\n\tconst count = r.i32();\n\tconst list = new Array<__M_ListRow>();\n\tfor (let i: i32 = 0; i < count; i++) list.push(__r22(r));\n\treturn list;\n}\n\nfunction __w34(w: __Writer, v: Array<__M_ListRow> | null): void {\n\tif (v == null) {\n\t\tw.bool(false);\n\t\treturn;\n\t}\n\tw.bool(true);\n\t__w35(w, v!);\n}\n\nfunction __r34(r: __Reader): Array<__M_ListRow> | null {\n\tif (!r.bool()) return null;\n\treturn __r35(r);\n}\n\nfunction __w36(w: __Writer, v: __M_MenuEvent): void {\n\t__w10(w, v.defaultPrevented);\n\t__w23(w, v.player);\n\t__w3(w, v.menu);\n\t__w10(w, v.timeout);\n}\n\nfunction __u36(r: __Reader, o: __M_MenuEvent): void {\n\to.defaultPrevented = __r10(r);\n\to.player = __r23(r);\n\to.menu = __r3(r);\n\to.timeout = __r10(r);\n}\n\nfunction __r36(r: __Reader): __M_MenuEvent {\n\tconst o = changetype<__M_MenuEvent>(__new(offsetof<__M_MenuEvent>(), idof<__M_MenuEvent>()));\n\t__u36(r, o);\n\treturn o;\n}\n\n__serve(\"menu-core\", 184891291, __dispatch);\n",
|
|
709
710
|
"callbacks": true
|
|
710
711
|
}
|
|
711
712
|
}
|
|
Binary file
|
|
@@ -204,8 +204,16 @@ export default {
|
|
|
204
204
|
ru: `Меню с этим номером среди всех — обратное к \`indexOf()\`; \`null\`, если такого нет.`,
|
|
205
205
|
},
|
|
206
206
|
"register": {
|
|
207
|
-
en: `
|
|
208
|
-
|
|
207
|
+
en: `
|
|
208
|
+
The menus of those names in the menu file, read now if they are not yet:
|
|
209
|
+
\`menus.register("SHOP", "SHOP_GUNS")\`. Returns the first one's menu;
|
|
210
|
+
\`null\` when the file has no such menu, or no items in it.
|
|
211
|
+
`,
|
|
212
|
+
ru: `
|
|
213
|
+
Меню с этими именами из файла меню, прочитанные сейчас, если ещё не
|
|
214
|
+
прочитаны: \`menus.register("SHOP", "SHOP_GUNS")\`. Возвращает меню первого;
|
|
215
|
+
\`null\`, если такого меню в файле нет или в нём нет пунктов.
|
|
216
|
+
`,
|
|
209
217
|
},
|
|
210
218
|
"create": {
|
|
211
219
|
en: `
|
|
@@ -225,6 +233,14 @@ export default {
|
|
|
225
233
|
en: `Registers an action by name, for menu files and Pawn plugins; \`SHOW_<MENU>\` and \`CLOSE_MENU\` are built in.`,
|
|
226
234
|
ru: `Регистрирует действие по имени — для файлов меню и Pawn-плагинов; \`SHOW_<MENU>\` и \`CLOSE_MENU\` встроены.`,
|
|
227
235
|
},
|
|
236
|
+
"addActions": {
|
|
237
|
+
en: `Registers actions by name, for menu files and Pawn plugins: \`menus.addActions({ SHOP_HEAL: heal, SHOP_ARMOR: (player) => player.armor = 100 })\`.`,
|
|
238
|
+
ru: `Регистрирует действия по именам — для файлов меню и Pawn-плагинов: \`menus.addActions({ SHOP_HEAL: heal, SHOP_ARMOR: (player) => player.armor = 100 })\`.`,
|
|
239
|
+
},
|
|
240
|
+
"addPlaceholders": {
|
|
241
|
+
en: `Registers placeholders for menu files and Pawn plugins: \`menus.addPlaceholders({ nick: (player) => player.name })\`. A name registered twice keeps the first.`,
|
|
242
|
+
ru: `Регистрирует плейсхолдеры для файлов меню и Pawn-плагинов: \`menus.addPlaceholders({ nick: (player) => player.name })\`. Если имя зарегистрировано дважды, остаётся первое.`,
|
|
243
|
+
},
|
|
228
244
|
"addPlaceholder": {
|
|
229
245
|
en: `Registers a placeholder for menu files and Pawn plugins: the text \`%name%\` stands for in titles and items. A name registered twice keeps the first. In code the text is a function instead.`,
|
|
230
246
|
ru: `Регистрирует плейсхолдер для файлов меню и Pawn-плагинов: текст, которым заменяется \`%name%\` в заголовках и пунктах. Если имя зарегистрировано дважды, остаётся первое. В коде текст — функция.`,
|
|
@@ -270,12 +270,12 @@ export default {
|
|
|
270
270
|
ru: `Проверка условия, как её регистрирует \`addCondition()\`. В меню-списке \`player\` — игрок строки, \`viewer\` — тот, кто смотрит.`,
|
|
271
271
|
},
|
|
272
272
|
"ActionHandler": {
|
|
273
|
-
en: `An action, as \`addAction()\` registers it: run with the context of the item chosen
|
|
274
|
-
ru: `Действие, как его регистрирует \`addAction()\`: выполняется с контекстом выбранного пункта и именем
|
|
273
|
+
en: `An action, as \`addAction()\` registers it: run with the context of the item chosen and the action's name - \`({ player, menu }) => ...\` - or with the player who chose it, \`(player) => ...\`.`,
|
|
274
|
+
ru: `Действие, как его регистрирует \`addAction()\`: выполняется с контекстом выбранного пункта и именем действия — \`({ player, menu }) => ...\` — или с игроком, который его выбрал, \`(player) => ...\`.`,
|
|
275
275
|
},
|
|
276
276
|
"PlaceholderValue": {
|
|
277
|
-
en: `A placeholder's value: the text \`%name%\` stands for, given the context of the text it is in
|
|
278
|
-
ru: `Значение плейсхолдера: текст, которым заменяется \`%name%\`, по контексту текста, в котором он
|
|
277
|
+
en: `A placeholder's value: the text \`%name%\` stands for, given the context of the text it is in - \`({ player, target }) => ...\` - or the player who reads it, \`(player) => ...\`.`,
|
|
278
|
+
ru: `Значение плейсхолдера: текст, которым заменяется \`%name%\`, по контексту текста, в котором он стоит, — \`({ player, target }) => ...\` — или по игроку, который его читает, \`(player) => ...\`.`,
|
|
279
279
|
},
|
|
280
280
|
"RestrictionTest": {
|
|
281
281
|
en: `A restriction's test, as \`addRestriction()\` registers it; \`name\` is the whole token, \`"NAME:param"\` included.`,
|
package/src/internal.ts
CHANGED
|
@@ -308,6 +308,10 @@ export interface Viewer {
|
|
|
308
308
|
/** The name of the menu he looks at; "" for none. */
|
|
309
309
|
menu: string;
|
|
310
310
|
page: number;
|
|
311
|
+
/** The page setPage() asked for, drawn at the next show; -1 for none. */
|
|
312
|
+
nextPage: number;
|
|
313
|
+
/** The menu whose item he chose, while its action runs; "" otherwise. */
|
|
314
|
+
choosing: string;
|
|
311
315
|
target: number;
|
|
312
316
|
history: HistoryStep[];
|
|
313
317
|
slots: ShownSlot[];
|
package/src/menu-file.ts
CHANGED
|
@@ -597,7 +597,7 @@ function iniMenu(section: ConfigNode) {
|
|
|
597
597
|
const content = section.has("ITEMS") || section.has("VIEW") || section.has("FIXED_ITEMS");
|
|
598
598
|
|
|
599
599
|
if (title.length == 0) {
|
|
600
|
-
|
|
600
|
+
warn(whereOf(section), content ? `[${name}] has no TITLE, so it is not a menu` : `[${name}] is not a menu: it has no TITLE, ITEMS or VIEW`);
|
|
601
601
|
return null;
|
|
602
602
|
}
|
|
603
603
|
|
|
@@ -633,12 +633,20 @@ function iniMenu(section: ConfigNode) {
|
|
|
633
633
|
return withItems(menu, whereOf(section));
|
|
634
634
|
}
|
|
635
635
|
|
|
636
|
-
|
|
636
|
+
// The Pawn menu_core reads its words from [Основное]: a file written for it is read as it is.
|
|
637
|
+
const INI_MAIN_SECTIONS = ["MAIN", "Основное"];
|
|
638
|
+
|
|
639
|
+
/** Whether a section of an INI menu file is the one with the words. */
|
|
640
|
+
function isMainSection(section: ConfigNode) {
|
|
641
|
+
return INI_MAIN_SECTIONS.includes(section.key) || section.key.toUpperCase() == "MAIN";
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
/** An INI menu file: [MAIN] (or the Pawn menu_core's [Основное]) with the words, a [section] a menu. */
|
|
637
645
|
function readIni(root: ConfigNode, file: MenuFile) {
|
|
638
|
-
const main = root.
|
|
646
|
+
const main = root.values().find(isMainSection);
|
|
639
647
|
|
|
640
648
|
if (main != null && main.kind == "object") {
|
|
641
|
-
checkKeys(main, INI_MAIN_KEYS,
|
|
649
|
+
checkKeys(main, INI_MAIN_KEYS, `[${main.key}]`, true);
|
|
642
650
|
file.labels.prefix = fileText(first(main.get("PREFIX")), whereOf(main));
|
|
643
651
|
const key = main.get("KEY");
|
|
644
652
|
if (key != null && key.kind == "object") checkKeys(key, INI_LABEL_KEYS, "KEY", true);
|
|
@@ -646,7 +654,7 @@ function readIni(root: ConfigNode, file: MenuFile) {
|
|
|
646
654
|
}
|
|
647
655
|
|
|
648
656
|
for (const section of root.values()) {
|
|
649
|
-
if (section
|
|
657
|
+
if (isMainSection(section) || section.kind != "object") continue;
|
|
650
658
|
const menu = iniMenu(section);
|
|
651
659
|
if (menu != null) file.menus.push(menu);
|
|
652
660
|
}
|
package/src/menus.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Menu Core's menus: the Menu object, the functions of the module, and how a
|
|
3
3
|
* menu is drawn and chosen from.
|
|
4
4
|
*/
|
|
5
|
-
import { accessOf, Forward, Player, clearInterval, lang,
|
|
5
|
+
import { accessOf, Forward, Player, clearInterval, lang, server, setInterval, setTimeout } from "@amxts/core";
|
|
6
6
|
import { callingPlugin, onPluginStop, publicFor, showMenu } from "@amxts/core/kit";
|
|
7
7
|
import { GetLangTransKey, get_maxplayers, register_menucmd, register_menuid } from "@amxts/core/natives";
|
|
8
8
|
import { ActionHandler, ActionTest, ConditionFilter, ConditionTest, ListRow, ListSource, MenuContext, MenuEventType, MenuItemOptions, MenuKind, MenuOptions, MenuShowOptions, NamedContext, PlaceholderValue, RestrictionTest, RowTest } from "./types";
|
|
@@ -207,7 +207,9 @@ const PAGE_SLOTS = 7;
|
|
|
207
207
|
const MAX_DEPTH = 5;
|
|
208
208
|
const ALL_KEYS = 1023;
|
|
209
209
|
/** The conditions Menu Core answers itself while nobody registered them - TEAM_<team> and FLAG_<letters> besides. */
|
|
210
|
-
const BUILT_IN_CONDITIONS = ["IS_ALIVE", "IS_DEAD", "IS_BOT", "IS_ADMIN"];
|
|
210
|
+
const BUILT_IN_CONDITIONS = ["IS_ALIVE", "IS_DEAD", "IS_BOT", "IS_ADMIN", "ADMIN", "ACCESS_ADMIN"];
|
|
211
|
+
/** ADMIN and ACCESS_ADMIN, as the Pawn menu_core answered them: ban, rcon, admin or menu access. */
|
|
212
|
+
const ADMIN_FLAGS = "FLAG_dluy";
|
|
211
213
|
/** The teams of TEAM_<team>: the names of `player.team`. */
|
|
212
214
|
const TEAMS = ["CT", "TERRORIST", "SPECTATOR", "UNASSIGNED"];
|
|
213
215
|
const KEY_LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";
|
|
@@ -272,6 +274,7 @@ server.addEventListener("putInServer", (event) => {
|
|
|
272
274
|
viewer.menu = "";
|
|
273
275
|
viewer.history = [];
|
|
274
276
|
viewer.page = 0;
|
|
277
|
+
viewer.nextPage = -1;
|
|
275
278
|
viewer.locked = false;
|
|
276
279
|
});
|
|
277
280
|
|
|
@@ -310,8 +313,18 @@ export function menuAt(index: number) {
|
|
|
310
313
|
return find(menus[index].name);
|
|
311
314
|
}
|
|
312
315
|
|
|
313
|
-
/**
|
|
314
|
-
|
|
316
|
+
/**
|
|
317
|
+
* The menus of those names in the menu file, read now if they are not yet:
|
|
318
|
+
* `menus.register("SHOP", "SHOP_GUNS")`. Returns the first one's menu;
|
|
319
|
+
* `null` when the file has no such menu, or no items in it.
|
|
320
|
+
*/
|
|
321
|
+
export function register(...names: string[]) {
|
|
322
|
+
const found = names.map(registerOne);
|
|
323
|
+
return found.length > 0 ? found[0] : null;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/** The menu of that name in the menu file, read now if it is not yet; `null` when the file has none. */
|
|
327
|
+
function registerOne(name: string) {
|
|
315
328
|
const known = find(name);
|
|
316
329
|
if (known != null) return known;
|
|
317
330
|
const spec = loadedFile().menus.find(each => each.name == name);
|
|
@@ -388,6 +401,16 @@ export function addAction(name: string, run: ActionHandler) {
|
|
|
388
401
|
return actions.length - 1;
|
|
389
402
|
}
|
|
390
403
|
|
|
404
|
+
/** Registers actions by name, for menu files and Pawn plugins: `menus.addActions({ SHOP_HEAL: heal, SHOP_ARMOR: (player) => player.armor = 100 })`. */
|
|
405
|
+
export function addActions(actions: Record<string, ActionHandler>) {
|
|
406
|
+
for (const [name, run] of Object.entries(actions)) addAction(name, run);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/** Registers placeholders for menu files and Pawn plugins: `menus.addPlaceholders({ nick: (player) => player.name })`. A name registered twice keeps the first. */
|
|
410
|
+
export function addPlaceholders(placeholders: Record<string, PlaceholderValue>) {
|
|
411
|
+
for (const [name, value] of Object.entries(placeholders)) addPlaceholder(name, value);
|
|
412
|
+
}
|
|
413
|
+
|
|
391
414
|
/** Registers a placeholder for menu files and Pawn plugins: the text `%name%` stands for in titles and items. A name registered twice keeps the first. In code the text is a function instead. */
|
|
392
415
|
export function addPlaceholder(name: string, value: PlaceholderValue) {
|
|
393
416
|
const known = placeholders.findIndex(entry => entry.name == name);
|
|
@@ -453,11 +476,18 @@ export function textRow(text: string, centered = false) {
|
|
|
453
476
|
* it is not active, or the player's menu holds on.
|
|
454
477
|
*/
|
|
455
478
|
export function show(player: Player, name: string, options: MenuShowOptions = {}) {
|
|
456
|
-
|
|
479
|
+
const viewer = viewerOf(player.id);
|
|
480
|
+
// The menu he is on, shown from anywhere but its own item - a command, a
|
|
481
|
+
// timer - opens anew, at its first page; from its item it stays on its page.
|
|
482
|
+
const anew = viewer.menu == name && viewer.choosing != name;
|
|
483
|
+
return open(player, name, options, options.target?.id ?? 0, anew);
|
|
457
484
|
}
|
|
458
485
|
|
|
459
|
-
/**
|
|
460
|
-
|
|
486
|
+
/**
|
|
487
|
+
* Shows a menu about `target`, a number: a player's `id`, or what a Pawn
|
|
488
|
+
* plugin gave - `0` for none. `anew`: the menu he is on starts at its first page.
|
|
489
|
+
*/
|
|
490
|
+
function open(player: Player, name: string, options: MenuShowOptions, target: number, anew = false) {
|
|
461
491
|
if (!player.isConnected) return false;
|
|
462
492
|
const viewer = viewerOf(player.id);
|
|
463
493
|
const menu = menuNamed(name);
|
|
@@ -485,7 +515,7 @@ function open(player: Player, name: string, options: MenuShowOptions, target: nu
|
|
|
485
515
|
|
|
486
516
|
if (viewer.depth >= MAX_DEPTH) return false;
|
|
487
517
|
viewer.depth++;
|
|
488
|
-
const shown = draw(player, viewer, menu, options, target);
|
|
518
|
+
const shown = draw(player, viewer, menu, options, target, anew);
|
|
489
519
|
viewer.depth--;
|
|
490
520
|
return shown;
|
|
491
521
|
}
|
|
@@ -558,7 +588,7 @@ export function isLocked(player: Player) {
|
|
|
558
588
|
|
|
559
589
|
/** Sets the page the player's menu is drawn at next, from `0`. */
|
|
560
590
|
export function setPage(player: Player, page: number) {
|
|
561
|
-
viewerOf(player.id).
|
|
591
|
+
viewerOf(player.id).nextPage = page;
|
|
562
592
|
}
|
|
563
593
|
|
|
564
594
|
/** Whether an action of that name is registered. */
|
|
@@ -593,7 +623,8 @@ function contextOf(player: Player, target: number, menu: Menu) {
|
|
|
593
623
|
/** The context a function registered by name gets: the menu's, and the name it is asked by. */
|
|
594
624
|
function namedContextOf(player: Player, target: number, menu: Menu, name: string) {
|
|
595
625
|
const context: NamedContext = { player, target: playerOr(target, player), row: target, menu, name };
|
|
596
|
-
|
|
626
|
+
// What an action or a placeholder takes: the context, or its player for a function of the player - the compiler hands it that.
|
|
627
|
+
return context as NamedContext & Player;
|
|
597
628
|
}
|
|
598
629
|
|
|
599
630
|
/** The player a target numbers; `fallback` for none. */
|
|
@@ -953,7 +984,7 @@ function usesCondition(menu: Menu, name: string) {
|
|
|
953
984
|
|
|
954
985
|
function viewerOf(id: number) {
|
|
955
986
|
if (!viewers.has(id)) {
|
|
956
|
-
const made: Viewer = { menu: "", page: 0, target: 0, history: [], slots: [], rows: 0, text: "", locked: false, timer: 0, ticker: 0, depth: 0 };
|
|
987
|
+
const made: Viewer = { menu: "", page: 0, nextPage: -1, choosing: "", target: 0, history: [], slots: [], rows: 0, text: "", locked: false, timer: 0, ticker: 0, depth: 0 };
|
|
957
988
|
viewers.set(id, made);
|
|
958
989
|
}
|
|
959
990
|
|
|
@@ -966,7 +997,7 @@ function menuOf(viewer: Viewer) {
|
|
|
966
997
|
}
|
|
967
998
|
|
|
968
999
|
function menuNamed(name: string) {
|
|
969
|
-
return find(name) ??
|
|
1000
|
+
return find(name) ?? registerOne(name);
|
|
970
1001
|
}
|
|
971
1002
|
|
|
972
1003
|
function lookingAt(menu: Menu) {
|
|
@@ -1002,7 +1033,7 @@ function isVisible(item: MenuItem, player: Player, target: number, menu: Menu) {
|
|
|
1002
1033
|
return check == null || passes(check, player, player.id, target, menu);
|
|
1003
1034
|
}
|
|
1004
1035
|
|
|
1005
|
-
function draw(player: Player, viewer: Viewer, menu: Menu, options: MenuShowOptions, target: number) {
|
|
1036
|
+
function draw(player: Player, viewer: Viewer, menu: Menu, options: MenuShowOptions, target: number, anew: boolean) {
|
|
1006
1037
|
// A list menu nobody is left in does not open, and nothing of the viewer's changes.
|
|
1007
1038
|
const listing = menu.kind == "list" ? listOf(player, menu, target) : noListing();
|
|
1008
1039
|
|
|
@@ -1039,7 +1070,12 @@ function draw(player: Player, viewer: Viewer, menu: Menu, options: MenuShowOptio
|
|
|
1039
1070
|
if (!given) timer = menu.countdown > 0 ? menu.countdown : viewer.timer;
|
|
1040
1071
|
if (timer <= 0) timer = menu.time;
|
|
1041
1072
|
|
|
1042
|
-
if (
|
|
1073
|
+
if (viewer.nextPage >= 0) {
|
|
1074
|
+
viewer.page = viewer.nextPage;
|
|
1075
|
+
viewer.nextPage = -1;
|
|
1076
|
+
} else if (anew || (!returning && !options.skipHistory && back < 0)) {
|
|
1077
|
+
viewer.page = 0;
|
|
1078
|
+
}
|
|
1043
1079
|
|
|
1044
1080
|
const items = menu.kind == "list" ? noItems() : shownItems(player, viewer, menu);
|
|
1045
1081
|
const total = menu.kind == "list" ? listing.count : items.length;
|
|
@@ -1412,7 +1448,7 @@ function sayEmpty(player: Player, menu: Menu) {
|
|
|
1412
1448
|
}
|
|
1413
1449
|
|
|
1414
1450
|
function say(player: Player, message: string) {
|
|
1415
|
-
print(
|
|
1451
|
+
player.print(`${ui(player.id, labels.prefix, DEFAULTS.prefix)} ${translate(player.id, message)}`);
|
|
1416
1452
|
}
|
|
1417
1453
|
|
|
1418
1454
|
function pressed(player: Player, key: number) {
|
|
@@ -1442,7 +1478,9 @@ function pressed(player: Player, key: number) {
|
|
|
1442
1478
|
|
|
1443
1479
|
const slot = viewer.slots[key];
|
|
1444
1480
|
if (slot.action.length == 0) return;
|
|
1481
|
+
viewer.choosing = menu.name;
|
|
1445
1482
|
run(player, slot.action, slot.target, menu);
|
|
1483
|
+
viewer.choosing = "";
|
|
1446
1484
|
if (viewer.menu == menu.name) open(player, menu.name, {}, viewer.target);
|
|
1447
1485
|
}
|
|
1448
1486
|
|
|
@@ -1569,6 +1607,7 @@ function builtInHolds(player: Player, name: string) {
|
|
|
1569
1607
|
if (upper == "IS_DEAD") return !player.isAlive;
|
|
1570
1608
|
if (upper == "IS_BOT") return player.isBot;
|
|
1571
1609
|
if (upper == "IS_ADMIN") return isAdmin(player);
|
|
1610
|
+
if (upper == "ADMIN" || upper == "ACCESS_ADMIN") return hasAccess(player, ADMIN_FLAGS);
|
|
1572
1611
|
if (upper.startsWith("TEAM_")) return player.team == upper.slice(5);
|
|
1573
1612
|
return hasAccess(player, name);
|
|
1574
1613
|
}
|
package/src/natives.ts
CHANGED
|
@@ -19,7 +19,7 @@ import * as menus from "./index";
|
|
|
19
19
|
import { addNamedFilter, iniItem, insertItem, stateOf } from "./internal";
|
|
20
20
|
import { MenuShowOptions } from "./types";
|
|
21
21
|
|
|
22
|
-
plugin({ name: "Menu Core", version: "0.
|
|
22
|
+
plugin({ name: "Menu Core", version: "0.3.0", author: "kukson777", description: "Menus from ini files: the mc_* natives" });
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Menu properties: mc_set_menu_property takes MP_LOCKED .. MP_HIDE_EXIT,
|
package/src/types.ts
CHANGED
|
@@ -155,10 +155,10 @@ export interface Requirement {
|
|
|
155
155
|
|
|
156
156
|
/** A condition's test, as `addCondition()` registers it. In a list menu `player` is the row's player and `viewer` whoever looks. */
|
|
157
157
|
export type ConditionTest = (player: Player, viewer: Player, name: string) => boolean;
|
|
158
|
-
/** An action, as `addAction()` registers it: run with the context of the item chosen
|
|
159
|
-
export type ActionHandler = (context: NamedContext) => void;
|
|
160
|
-
/** A placeholder's value: the text `%name%` stands for, given the context of the text it is in
|
|
161
|
-
export type PlaceholderValue = (context: NamedContext) => string;
|
|
158
|
+
/** An action, as `addAction()` registers it: run with the context of the item chosen and the action's name - `({ player, menu }) => ...` - or with the player who chose it, `(player) => ...`. */
|
|
159
|
+
export type ActionHandler = (context: NamedContext & Player) => void;
|
|
160
|
+
/** A placeholder's value: the text `%name%` stands for, given the context of the text it is in - `({ player, target }) => ...` - or the player who reads it, `(player) => ...`. */
|
|
161
|
+
export type PlaceholderValue = (context: NamedContext & Player) => string;
|
|
162
162
|
/** A restriction's test, as `addRestriction()` registers it; `name` is the whole token, `"NAME:param"` included. */
|
|
163
163
|
export type RestrictionTest = (context: NamedContext) => boolean;
|
|
164
164
|
/** A test of an item's action, as `addActionCheck()` registers it: `name` is the action, and `false` greys the item out. */
|