@amxts/menu-core 0.1.0 → 0.2.1
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 +4 -2
- package/PAWN.ru.md +4 -2
- package/README.md +69 -27
- package/README.ru.md +70 -28
- package/package.json +3 -3
- package/prebuilt/linux/menu-core.aot +0 -0
- package/prebuilt/manifest.json +40 -32
- package/prebuilt/windows/menu-core.aot +0 -0
- package/scripts/docs/src/{index.ts → menus.ts} +35 -21
- package/scripts/docs/src/types.ts +102 -52
- package/src/index.ts +3 -1598
- package/src/internal.ts +350 -328
- package/src/menus.ts +1744 -0
- package/src/natives.ts +411 -411
- package/src/types.ts +69 -39
|
@@ -5,24 +5,62 @@ export default {
|
|
|
5
5
|
en: `A menu's kind, one of \`"items"\` (a list of items) or \`"list"\` (a row per player, or per row of a list source).`,
|
|
6
6
|
ru: `Вид меню, одно из \`"items"\` (список пунктов) или \`"list"\` (строка на игрока или на строку источника).`,
|
|
7
7
|
},
|
|
8
|
+
"MenuContext": {
|
|
9
|
+
en: `
|
|
10
|
+
A menu's context, which its functions get: the player who looks, who or
|
|
11
|
+
what the menu is about, and the menu.
|
|
12
|
+
|
|
13
|
+
shop.addItem({ title: ({ player }) => \`Heal (\${player.health} HP)\`, onSelect: ({ player }) => heal(player) });
|
|
14
|
+
`,
|
|
15
|
+
ru: `
|
|
16
|
+
Контекст меню, который получают его функции: игрок, который смотрит, о ком
|
|
17
|
+
или о чём меню и само меню.
|
|
18
|
+
|
|
19
|
+
shop.addItem({ title: ({ player }) => \`Heal (\${player.health} HP)\`, onSelect: ({ player }) => heal(player) });
|
|
20
|
+
`,
|
|
21
|
+
},
|
|
22
|
+
"MenuContext.player": {
|
|
23
|
+
en: `The player the menu is shown to: who looks at it, and who chooses.`,
|
|
24
|
+
ru: `Игрок, которому показано меню: тот, кто его смотрит и выбирает.`,
|
|
25
|
+
},
|
|
26
|
+
"MenuContext.target": {
|
|
27
|
+
en: `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.`,
|
|
28
|
+
ru: `Игрок, о котором меню: игрок строки в меню-списке, тот, кого передали \`show()\` в \`target\`, в меню пунктов; сам \`player\`, если такого нет.`,
|
|
29
|
+
},
|
|
30
|
+
"MenuContext.row": {
|
|
31
|
+
en: `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.`,
|
|
32
|
+
ru: `Номер строки в меню-списке, как его дал \`listRow()\`, — например, сущность или индекс самого источника; в списке игроков — \`id\` игрока. В меню пунктов — \`id\` цели меню, \`0\`, если её нет.`,
|
|
33
|
+
},
|
|
34
|
+
"MenuContext.menu": {
|
|
35
|
+
en: `The menu the function is asked for.`,
|
|
36
|
+
ru: `Меню, для которого вызвана функция.`,
|
|
37
|
+
},
|
|
38
|
+
"NamedContext": {
|
|
39
|
+
en: `The context of a function registered by name - an action, a placeholder, a restriction, an action check: the menu's context, and the name it is asked by.`,
|
|
40
|
+
ru: `Контекст функции, зарегистрированной по имени, — действия, плейсхолдера, ограничения, проверки действия: контекст меню и имя, по которому её спросили.`,
|
|
41
|
+
},
|
|
42
|
+
"NamedContext.name": {
|
|
43
|
+
en: `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.`,
|
|
44
|
+
ru: `Имя, по которому её спросили: имя действия или плейсхолдера, токен ограничения целиком — вместе с \`"NAME:param"\`; для проверки действия — действие пункта.`,
|
|
45
|
+
},
|
|
8
46
|
"MenuText": {
|
|
9
47
|
en: `
|
|
10
48
|
Text of a menu - a title, an item, a message: the text itself, or a
|
|
11
|
-
function that gives it for the
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
49
|
+
function that gives it for the menu's context. A lang key is translated
|
|
50
|
+
either way. Colour tags are chat's letters: \`!y\` yellow, \`!r\` red, \`!d\`
|
|
51
|
+
grey, \`!w\` white, \`!R\` to the right edge; chat's own \`!g\`, \`!b\` and \`!t\`
|
|
52
|
+
are dropped.
|
|
15
53
|
|
|
16
|
-
menus.create("SHOP", { title: (player) => \`Shop for \${player.name}\` });
|
|
54
|
+
menus.create("SHOP", { title: ({ player }) => \`Shop for \${player.name}\` });
|
|
17
55
|
`,
|
|
18
56
|
ru: `
|
|
19
57
|
Текст меню — заголовок, пункт, сообщение: сам текст или функция, которая
|
|
20
|
-
даёт его
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
58
|
+
даёт его по контексту меню. Ключ словаря переводится в обоих случаях.
|
|
59
|
+
Цветовые метки — буквы чата: \`!y\` жёлтый, \`!r\` красный, \`!d\`
|
|
60
|
+
серый, \`!w\` белый, \`!R\` — к правому краю; метки только для чата \`!g\`, \`!b\` и \`!t\`
|
|
61
|
+
убираются.
|
|
24
62
|
|
|
25
|
-
menus.create("SHOP", { title: (player) => \`Shop for \${player.name}\` });
|
|
63
|
+
menus.create("SHOP", { title: ({ player }) => \`Shop for \${player.name}\` });
|
|
26
64
|
`,
|
|
27
65
|
},
|
|
28
66
|
"ListRow": {
|
|
@@ -34,8 +72,8 @@ export default {
|
|
|
34
72
|
ru: `Вид строки, одно из \`"item"\` (строка для выбора) или \`"text"\` (строка текста, не выбор).`,
|
|
35
73
|
},
|
|
36
74
|
"ListRow.target": {
|
|
37
|
-
en: `The row's
|
|
38
|
-
ru:
|
|
75
|
+
en: `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.`,
|
|
76
|
+
ru: `Номер строки, \`row\` в контексте, который получают функции её пункта: например, \`id\` игрока, сущность или индекс самого источника; \`0\` у строки текста.`,
|
|
39
77
|
},
|
|
40
78
|
"ListRow.text": {
|
|
41
79
|
en: `The row's text, put for \`%name%\` in the menu's row template.`,
|
|
@@ -57,17 +95,17 @@ export default {
|
|
|
57
95
|
en: `
|
|
58
96
|
The options of a menu made with \`create()\`. Every field may be left out:
|
|
59
97
|
|
|
60
|
-
menus.create("SHOP", { title: "Shop", time: 30, activeWhen: player => player.isAlive });
|
|
98
|
+
menus.create("SHOP", { title: "Shop", time: 30, activeWhen: ({ player }) => player.isAlive });
|
|
61
99
|
`,
|
|
62
100
|
ru: `
|
|
63
101
|
Настройки меню, сделанного через \`create()\`. Любое поле можно не задавать:
|
|
64
102
|
|
|
65
|
-
menus.create("SHOP", { title: "Shop", time: 30, activeWhen: player => player.isAlive });
|
|
103
|
+
menus.create("SHOP", { title: "Shop", time: 30, activeWhen: ({ player }) => player.isAlive });
|
|
66
104
|
`,
|
|
67
105
|
},
|
|
68
106
|
"MenuOptions.title": {
|
|
69
|
-
en: `The menu's title: the text - a lang key too - or a function that gives it for the
|
|
70
|
-
ru: `Заголовок меню: сам текст — или ключ словаря — либо функция, которая даёт его
|
|
107
|
+
en: `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.`,
|
|
108
|
+
ru: `Заголовок меню: сам текст — или ключ словаря — либо функция, которая даёт его по контексту меню; если не задан — имя меню.`,
|
|
71
109
|
},
|
|
72
110
|
"MenuOptions.time": {
|
|
73
111
|
en: `Seconds on the countdown when the menu opens, e.g. \`10\`; left out, none.`,
|
|
@@ -86,8 +124,8 @@ export default {
|
|
|
86
124
|
ru: `Блокировка меню: пока \`true\`, пункты нельзя выбрать и другое меню не заменяет это.`,
|
|
87
125
|
},
|
|
88
126
|
"MenuOptions.activeWhen": {
|
|
89
|
-
en: `A test the menu opens under: while it says no
|
|
90
|
-
ru: `Проверка, при которой меню открывается: пока она отвечает
|
|
127
|
+
en: `A test the menu opens under: while it says no, the menu does not open for the player.`,
|
|
128
|
+
ru: `Проверка, при которой меню открывается: пока она отвечает «нет», меню игроку не открывается.`,
|
|
91
129
|
},
|
|
92
130
|
"MenuShowOptions": {
|
|
93
131
|
en: `
|
|
@@ -106,8 +144,8 @@ export default {
|
|
|
106
144
|
ru: `Секунды отсчёта; если не заданы, идущий отсчёт продолжается или начинается собственный отсчёт меню.`,
|
|
107
145
|
},
|
|
108
146
|
"MenuShowOptions.target": {
|
|
109
|
-
en: `The player the menu is about
|
|
110
|
-
ru: `Игрок, о котором
|
|
147
|
+
en: `The player the menu is about: \`target\` of the context its functions get, and \`%target%\`.`,
|
|
148
|
+
ru: `Игрок, о котором меню: \`target\` в контексте, который получают его функции, и \`%target%\`.`,
|
|
111
149
|
},
|
|
112
150
|
"MenuShowOptions.resetHistory": {
|
|
113
151
|
en: `A new way back: \`true\` forgets the menus this one was opened from.`,
|
|
@@ -123,25 +161,37 @@ export default {
|
|
|
123
161
|
},
|
|
124
162
|
"MenuItemOptions": {
|
|
125
163
|
en: `
|
|
126
|
-
|
|
164
|
+
An item: its title, when it is shown and can be chosen, and what choosing
|
|
165
|
+
it does. Every field but \`title\` may be left out:
|
|
127
166
|
|
|
128
|
-
shop.addItem(
|
|
129
|
-
|
|
130
|
-
|
|
167
|
+
shop.addItem({
|
|
168
|
+
title: ({ player }) => \`Heal (\${player.health} HP)\`,
|
|
169
|
+
visible: ({ player }) => player.health < 100,
|
|
170
|
+
onSelect: ({ player }) => {
|
|
171
|
+
player.health = 100;
|
|
172
|
+
},
|
|
131
173
|
});
|
|
132
174
|
`,
|
|
133
175
|
ru: `
|
|
134
|
-
|
|
176
|
+
Пункт: его заголовок, когда он показан и когда его можно выбрать и что
|
|
177
|
+
делает выбор. Любое поле, кроме \`title\`, можно не задавать:
|
|
135
178
|
|
|
136
|
-
shop.addItem(
|
|
137
|
-
|
|
138
|
-
|
|
179
|
+
shop.addItem({
|
|
180
|
+
title: ({ player }) => \`Heal (\${player.health} HP)\`,
|
|
181
|
+
visible: ({ player }) => player.health < 100,
|
|
182
|
+
onSelect: ({ player }) => {
|
|
183
|
+
player.health = 100;
|
|
184
|
+
},
|
|
139
185
|
});
|
|
140
186
|
`,
|
|
141
187
|
},
|
|
188
|
+
"MenuItemOptions.title": {
|
|
189
|
+
en: `The item's text - a lang key too - or a function that gives it for the menu's context.`,
|
|
190
|
+
ru: `Текст пункта — или ключ словаря — либо функция, которая даёт его по контексту меню.`,
|
|
191
|
+
},
|
|
142
192
|
"MenuItemOptions.onSelect": {
|
|
143
|
-
en: `The function run when the item is chosen
|
|
144
|
-
ru: `Функция, которая выполняется при выборе
|
|
193
|
+
en: `The function run when the item is chosen; the menu is drawn again after it, while it stays open.`,
|
|
194
|
+
ru: `Функция, которая выполняется при выборе пункта; после неё меню перерисовывается, если осталось открытым.`,
|
|
145
195
|
},
|
|
146
196
|
"MenuItemOptions.visible": {
|
|
147
197
|
en: `A test the item is shown under: while it says no, the item is left out and takes no slot.`,
|
|
@@ -154,8 +204,8 @@ export default {
|
|
|
154
204
|
a message of its own - the first that fails gives its message.
|
|
155
205
|
|
|
156
206
|
enabled: [
|
|
157
|
-
{ when: (player) => player.frags >= 5, message: "5 frags needed" },
|
|
158
|
-
{ when: (player) => player.armor < 100, message: (player) => \`(\${player.armor} already)\` },
|
|
207
|
+
{ when: ({ player }) => player.frags >= 5, message: "5 frags needed" },
|
|
208
|
+
{ when: ({ player }) => player.armor < 100, message: ({ player }) => \`(\${player.armor} already)\` },
|
|
159
209
|
],
|
|
160
210
|
`,
|
|
161
211
|
ru: `
|
|
@@ -164,18 +214,18 @@ export default {
|
|
|
164
214
|
сообщение, — первое невыполненное даёт своё.
|
|
165
215
|
|
|
166
216
|
enabled: [
|
|
167
|
-
{ when: (player) => player.frags >= 5, message: "5 frags needed" },
|
|
168
|
-
{ when: (player) => player.armor < 100, message: (player) => \`(\${player.armor} already)\` },
|
|
217
|
+
{ when: ({ player }) => player.frags >= 5, message: "5 frags needed" },
|
|
218
|
+
{ when: ({ player }) => player.armor < 100, message: ({ player }) => \`(\${player.armor} already)\` },
|
|
169
219
|
],
|
|
170
220
|
`,
|
|
171
221
|
},
|
|
172
222
|
"MenuItemOptions.message": {
|
|
173
|
-
en: `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
|
|
174
|
-
ru: `Текст рядом с пунктом, пока его гасит \`enabled\`, — для требования без своего сообщения: сам текст, например \`"(full)"\`, или функция, которая даёт его
|
|
223
|
+
en: `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.`,
|
|
224
|
+
ru: `Текст рядом с пунктом, пока его гасит \`enabled\`, — для требования без своего сообщения: сам текст, например \`"(full)"\`, или функция, которая даёт его по контексту меню.`,
|
|
175
225
|
},
|
|
176
226
|
"MenuItemOptions.placeholder": {
|
|
177
|
-
en: `The text after the item's
|
|
178
|
-
ru: `Текст после
|
|
227
|
+
en: `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.`,
|
|
228
|
+
ru: `Текст после заголовка пункта — для пунктов файлов меню и Pawn-плагинов, с плейсхолдерами, например \`"%hp%"\`; в коде заголовок — функция.`,
|
|
179
229
|
},
|
|
180
230
|
"MenuItemOptions.action": {
|
|
181
231
|
en: `Action names from \`addAction()\` run when the item is chosen, or a built-in one: \`"SHOW_<MENU>"\`, \`"CLOSE_MENU"\`.`,
|
|
@@ -198,50 +248,50 @@ export default {
|
|
|
198
248
|
A requirement of an item, in the list \`enabled\` takes: while \`when\` says
|
|
199
249
|
no, the item is greyed out with \`message\` beside it.
|
|
200
250
|
|
|
201
|
-
{ when: (player) => player.frags >= 5, message: "5 frags needed" }
|
|
251
|
+
{ when: ({ player }) => player.frags >= 5, message: "5 frags needed" }
|
|
202
252
|
`,
|
|
203
253
|
ru: `
|
|
204
254
|
Требование пункта в списке, который принимает \`enabled\`: пока \`when\`
|
|
205
255
|
отвечает «нет», пункт погашен, а рядом \`message\`.
|
|
206
256
|
|
|
207
|
-
{ when: (player) => player.frags >= 5, message: "5 frags needed" }
|
|
257
|
+
{ when: ({ player }) => player.frags >= 5, message: "5 frags needed" }
|
|
208
258
|
`,
|
|
209
259
|
},
|
|
210
260
|
"Requirement.when": {
|
|
211
|
-
en: `A test the requirement holds under
|
|
212
|
-
ru: `Проверка, при которой требование
|
|
261
|
+
en: `A test the requirement holds under, given the menu's context.`,
|
|
262
|
+
ru: `Проверка, при которой требование выполнено, по контексту меню.`,
|
|
213
263
|
},
|
|
214
264
|
"Requirement.message": {
|
|
215
|
-
en: `The text beside the item while \`when\` says no: the text, a lang key, or a function that gives it for the
|
|
216
|
-
ru: `Текст рядом с пунктом, пока \`when\` отвечает «нет»: сам текст, ключ словаря или функция, которая даёт его
|
|
265
|
+
en: `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\`.`,
|
|
266
|
+
ru: `Текст рядом с пунктом, пока \`when\` отвечает «нет»: сам текст, ключ словаря или функция, которая даёт его по контексту меню; если не задан — \`message\` пункта.`,
|
|
217
267
|
},
|
|
218
268
|
"ConditionTest": {
|
|
219
269
|
en: `A condition's test, as \`addCondition()\` registers it. In a list menu \`player\` is the row's player and \`viewer\` whoever looks.`,
|
|
220
270
|
ru: `Проверка условия, как её регистрирует \`addCondition()\`. В меню-списке \`player\` — игрок строки, \`viewer\` — тот, кто смотрит.`,
|
|
221
271
|
},
|
|
222
272
|
"ActionHandler": {
|
|
223
|
-
en: `An action, as \`addAction()\` registers it:
|
|
224
|
-
ru: `Действие, как его регистрирует \`addAction()\`:
|
|
273
|
+
en: `An action, as \`addAction()\` registers it: run with the context of the item chosen, and the action's name.`,
|
|
274
|
+
ru: `Действие, как его регистрирует \`addAction()\`: выполняется с контекстом выбранного пункта и именем действия.`,
|
|
225
275
|
},
|
|
226
276
|
"PlaceholderValue": {
|
|
227
|
-
en: `A placeholder's value: the text \`%name%\` stands for.`,
|
|
228
|
-
ru: `Значение плейсхолдера: текст, которым заменяется \`%name
|
|
277
|
+
en: `A placeholder's value: the text \`%name%\` stands for, given the context of the text it is in.`,
|
|
278
|
+
ru: `Значение плейсхолдера: текст, которым заменяется \`%name%\`, по контексту текста, в котором он стоит.`,
|
|
229
279
|
},
|
|
230
280
|
"RestrictionTest": {
|
|
231
281
|
en: `A restriction's test, as \`addRestriction()\` registers it; \`name\` is the whole token, \`"NAME:param"\` included.`,
|
|
232
282
|
ru: `Проверка ограничения, как её регистрирует \`addRestriction()\`; \`name\` — токен целиком, вместе с \`"NAME:param"\`.`,
|
|
233
283
|
},
|
|
234
284
|
"ActionTest": {
|
|
235
|
-
en: `A test of an item's action, as \`addActionCheck()\` registers it: \`false\` greys the item out.`,
|
|
236
|
-
ru: `Проверка действия пункта, как её регистрирует \`addActionCheck()\`: \`false\` гасит пункт.`,
|
|
285
|
+
en: `A test of an item's action, as \`addActionCheck()\` registers it: \`name\` is the action, and \`false\` greys the item out.`,
|
|
286
|
+
ru: `Проверка действия пункта, как её регистрирует \`addActionCheck()\`: \`name\` — действие, а \`false\` гасит пункт.`,
|
|
237
287
|
},
|
|
238
288
|
"ConditionFilter": {
|
|
239
289
|
en: `A filter over a condition someone else registered: gets its value and returns the one to use.`,
|
|
240
290
|
ru: `Фильтр над условием, которое зарегистрировал кто-то другой: получает его значение и возвращает то, что будет использовано.`,
|
|
241
291
|
},
|
|
242
292
|
"RowTest": {
|
|
243
|
-
en: `A test of a row of a list menu, as \`addFilter()\` takes it: \`
|
|
244
|
-
ru: `Проверка строки меню-списка, как её принимает \`addFilter()\`: \`
|
|
293
|
+
en: `A test of a row of a list menu, as \`addFilter()\` takes it: \`target\` is the row's player, \`player\` whoever looks.`,
|
|
294
|
+
ru: `Проверка строки меню-списка, как её принимает \`addFilter()\`: \`target\` — игрок строки, \`player\` — тот, кто смотрит.`,
|
|
245
295
|
},
|
|
246
296
|
"ListSource": {
|
|
247
297
|
en: `A list source: the rows of a list menu for the player who looks; \`null\` lists the players instead.`,
|