Debian Codegraph @

src/weapon_menu.c

raw symbols SCIP
1 /*
2 C-Dogs SDL
3 A port of the legendary (and fun) action/arcade cdogs.
4
5 Copyright (c) 2013-2015, 2018, 2020-2023 Cong Xu
6 All rights reserved.
7
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions are met:
10
11 Redistributions of source code must retain the above copyright notice, this
12 list of conditions and the following disclaimer.
13 Redistributions in binary form must reproduce the above copyright notice,
14 this list of conditions and the following disclaimer in the documentation
15 and/or other materials provided with the distribution.
16
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 POSSIBILITY OF SUCH DAMAGE.
28 */
29 #include "weapon_menu.h"
30
31 #include <assert.h>
32
33 #include <cdogs/ai_coop.h>
34 #include <cdogs/draw/draw_actor.h>
35 #include <cdogs/draw/drawtools.h>
36 #include <cdogs/draw/nine_slice.h>
37 #include <cdogs/font.h>
38
39 #include "equip_menu.h"
40
41 #define NO_GUN_LABEL "(None)"
42 #define EQUIP_MENU_SLOT_HEIGHT 40
43 #define WEAPON_MENU_MAX_ROWS 4
44 #define GUN_BG_W 40
45 #define GUN_BG_H 25
46 #define SCROLL_H 12
47 #define SLOT_BORDER 3
48 #define AMMO_LEVEL_W 2
49
50 static bool InSlot(const WeaponClass *wc, const int slot)
51 {
52 int slotStart, slotEnd;
53 GunTypeGetSlotStartEnd(wc->Type, &slotStart, &slotEnd);
54 return slot >= slotStart && slot <= slotEnd;
55 }
56
57 static const WeaponClass *GetSelectedGun(const WeaponMenu *menu)
58 {
59 if (menu->idx >= (int)menu->weaponIndices.size)
60 {
61 return NULL;
62 }
63 const int idx = *(int *)CArrayGet(&menu->weaponIndices, menu->idx);
64 return *(const WeaponClass **)CArrayGet(menu->weapons, idx);
65 }
66
67 static int EquipCostDiff(
68 const WeaponClass *wc, const PlayerData *p, const int slot)
69 {
70 if (!gCampaign.Setting.BuyAndSell)
71 return 0;
72 if (PlayerHasWeapon(p, wc))
73 {
74 return 0;
75 }
76 const int cost1 = WeaponClassFullPrice(wc);
77 const WeaponClass *wc2 = p->guns[slot];
78 const int cost2 = WeaponClassFullPrice(wc2);
79 return cost1 - cost2;
80 }
81
82 int WeaponMenuSelectedCostDiff(const WeaponMenu *menu)
83 {
84 const PlayerData *pData = PlayerDataGetByUID(menu->PlayerUID);
85 const WeaponClass *wc = GetSelectedGun(menu);
86 if (wc)
87 {
88 return EquipCostDiff(wc, pData, menu->slot);
89 }
90 return 0;
91 }
92
93 static void WeaponSelect(menu_t *menu, int cmd, void *data)
94 {
95 UNUSED(menu);
96 WeaponMenu *d = data;
97
98 if (Button1(cmd))
99 {
100 // Add the selected item
101 const PlayerData *p = PlayerDataGetByUID(d->PlayerUID);
102 const WeaponClass *selectedGun = GetSelectedGun(d);
103 if (gCampaign.Setting.BuyAndSell &&
104 WeaponMenuSelectedCostDiff(d) > p->Totals.Score)
105 {
106 // Can't afford
107 SoundPlay(&gSoundDevice, StrSound("ammo_none"));
108 return;
109 }
110 d->SelectResult = WEAPON_MENU_SELECT;
111 if (selectedGun != NULL)
112 {
113 SoundPlay(&gSoundDevice, selectedGun->SwitchSound);
114 }
115 else
116 {
117 MenuPlaySound(MENU_SOUND_SWITCH);
118 }
119 }
120 else if (Button2(cmd))
121 {
122 d->SelectResult = WEAPON_MENU_CANCEL;
123 MenuPlaySound(MENU_SOUND_BACK);
124 }
125 }
126
127 static int ClampScroll(const WeaponMenu *menu)
128 {
129 // Update menu scroll based on selected gun
130 const int selectedRow = menu->idx / menu->cols;
131 const int lastRow = (int)menu->weaponIndices.size / menu->cols;
132 int minRow = MAX(0, selectedRow - WEAPON_MENU_MAX_ROWS + 1);
133 int maxRow = MIN(
134 selectedRow,
135 MAX(0, DIV_ROUND_UP((int)menu->weaponIndices.size + 1, menu->cols) -
136 WEAPON_MENU_MAX_ROWS));
137 // If the selected row is the last row on screen, and we can still
138 // scroll down (i.e. show the scroll down button), scroll down
139 if (selectedRow - menu->scroll == WEAPON_MENU_MAX_ROWS - 1 &&
140 selectedRow < lastRow)
141 {
142 minRow++;
143 }
144 else if (selectedRow == menu->scroll && selectedRow > 0)
145 {
146 maxRow--;
147 }
148 return CLAMP(menu->scroll, minRow, maxRow);
149 }
150
151 void DrawWeaponAmmo(
152 GraphicsDevice *g, const PlayerData *p, const WeaponClass *wc,
153 const color_t mask, const struct vec2i pos, const struct vec2i slotSize)
154 {
155 if (!gCampaign.Setting.Ammo || !wc)
156 {
157 return;
158 }
159
160 CPicDrawContext c = CPicDrawContextNew();
161 c.Mask = mask;
162 const int numBarrels = WeaponClassNumBarrels(wc);
163 for (int i = 0; i < numBarrels; i++)
164 {
165 const int ammoId = WC_BARREL_ATTR(*wc, AmmoId, i);
166 if (ammoId < 0)
167 {
168 continue;
169 }
170 const Ammo *a = AmmoGetById(&gAmmo, ammoId);
171 // Draw ammo level
172 const int amount = PlayerGetAmmoAmount(p, ammoId);
173 const int ammoMax = a->Max ? a->Max : amount;
174 if (ammoMax > 0)
175 {
176 const int dx =
177 slotSize.x - SLOT_BORDER - AMMO_LEVEL_W * (numBarrels - i);
178 const int h = amount * (slotSize.y - 2 * SLOT_BORDER) / ammoMax;
179 if (AmmoIsLow(a, amount))
180 {
181 DrawRectangle(
182 g, svec2i_add(pos, svec2i(dx, SLOT_BORDER)),
183 svec2i(AMMO_LEVEL_W, slotSize.y - 2 * SLOT_BORDER),
184 ColorMult(colorRed, mask), true);
185 }
186 if (amount > 0)
187 {
188 DrawRectangle(
189 g,
190 svec2i_add(pos, svec2i(dx, slotSize.y - SLOT_BORDER - h)),
191 svec2i(AMMO_LEVEL_W, h), ColorMult(colorBlue, mask), true);
192 }
193 }
194
195 // Draw ammo icon
196 CPicDraw(
197 g, &a->Pic,
198 svec2i_subtract(
199 svec2i_add(pos, slotSize),
200 svec2i(16 - (numBarrels - i) * 4, 18)),
201 &c);
202 }
203 }
204
205 static menu_t *CreateMenu(WeaponMenu *data);
206 void WeaponMenuCreate(
207 WeaponMenu *menu, const CArray *weapons, const CArray *weaponIsNew,
208 const int playerUID, const int slot, const struct vec2i pos,
209 const struct vec2i size, EventHandlers *handlers, GraphicsDevice *graphics)
210 {
211 menu->PlayerUID = playerUID;
212 menu->menuBGSprites = PicManagerGetSprites(&gPicManager, "hud/gun_bg");
213 menu->weapons = weapons;
214 menu->weaponIsNew = weaponIsNew;
215 menu->slot = slot;
216 WeaponMenuReset(menu);
217
218 const Pic *bg = CArrayGet(&menu->menuBGSprites->pics, 0);
219 menu->cols = CLAMP(menu->size.x * 3 / (bg->size.x + 2) / 4, 2, 4);
220
221 MenuSystemInit(&menu->ms, handlers, graphics, pos, size);
222 menu->ms.align = MENU_ALIGN_LEFT;
223 menu->ms.root = menu->ms.current = CreateMenu(menu);
224 MenuSystemAddCustomDisplay(
225 &menu->ms, MenuDisplayPlayerControls, &menu->PlayerUID);
226 }
227 static void DrawMenu(
228 const menu_t *menu, GraphicsDevice *g, const struct vec2i pos,
229 const struct vec2i size, const void *data);
230 static int HandleInputMenu(int cmd, void *data);
231 static menu_t *CreateMenu(WeaponMenu *data)
232 {
233 menu_t *menu = MenuCreateCustom("", DrawMenu, HandleInputMenu, data);
234
235 MenuSetPostInputFunc(menu, WeaponSelect, data);
236
237 return menu;
238 }
239 static void DrawGun(
240 const WeaponMenu *data, GraphicsDevice *g, const int idx,
241 const WeaponClass *wc, const DrawGunMeta meta, const struct vec2i pos,
242 const struct vec2i bgSize);
243 static void DrawMenu(
244 const menu_t *menu, GraphicsDevice *g, const struct vec2i pos,
245 const struct vec2i size, const void *data)
246 {
247 UNUSED(menu);
248 const WeaponMenu *d = data;
249 const int weaponsHeight = EQUIP_MENU_SLOT_HEIGHT * 2 + FontH();
250 const int weaponsY = CENTER_Y(pos, size, weaponsHeight) - 12;
251 const color_t color = d->Active ? colorWhite : colorGray;
252 // Allow space for price if buy/sell enabled
253 const int h = GUN_BG_H + (gCampaign.Setting.BuyAndSell ? FontH() : 0);
254 const struct vec2i bgSize = svec2i(GUN_BG_W, h);
255 const struct vec2i scrollSize = svec2i(d->cols * GUN_BG_W - 2, SCROLL_H);
256 bool scrollDown = false;
257
258 // Draw guns: red if selected, yellow if equipped
259 CA_FOREACH(const int, idx, d->weaponIndices)
260 const int row = _ca_index / d->cols;
261 if (row >= d->scroll && row < d->scroll + WEAPON_MENU_MAX_ROWS)
262 {
263 const DrawGunMeta *meta = CArrayGet(&d->weaponMeta, *idx);
264 const WeaponClass **wc = CArrayGet(d->weapons, *idx);
265 DrawGun(
266 d, g, _ca_index, *wc, *meta, svec2i(pos.x, pos.y + weaponsY),
267 bgSize);
268 }
269 if (_ca_index / d->cols == d->scroll + WEAPON_MENU_MAX_ROWS)
270 {
271 scrollDown = true;
272 break;
273 }
274 CA_FOREACH_END()
275
276 // Draw scroll buttons
277 const Pic *gradient = PicManagerGetPic(&gPicManager, "hud/gradient");
278 if (d->scroll > 0)
279 {
280 const Pic *scrollPic = CArrayGet(&d->menuBGSprites->pics, 0);
281 const Rect2i scrollRect =
282 Rect2iNew(svec2i(pos.x + 3, pos.y + 1 + weaponsY), scrollSize);
283 PicRender(
284 gradient, g->gameWindow.renderer,
285 svec2i(
286 scrollRect.Pos.x + scrollSize.x / 2,
287 pos.y + gradient->size.y / 2 + weaponsY + scrollSize.y - 1),
288 colorBlack, 0, svec2((float)scrollSize.x, 1), SDL_FLIP_NONE,
289 Rect2iZero());
290 Draw9Slice(
291 g, scrollPic, scrollRect, 3, 3, 3, 3, true, color, SDL_FLIP_NONE);
292 FontOpts fopts = FontOptsNew();
293 fopts.Area = scrollRect.Size;
294 fopts.HAlign = ALIGN_CENTER;
295 fopts.VAlign = ALIGN_CENTER;
296 fopts.Mask = color;
297 FontStrOpt(ARROW_UP, scrollRect.Pos, fopts);
298 }
299 if (scrollDown)
300 {
301 const Pic *scrollPic = CArrayGet(&d->menuBGSprites->pics, 0);
302 const Rect2i scrollRect = Rect2iNew(
303 svec2i(
304 pos.x + 3, pos.y - 1 + weaponsY +
305 bgSize.y * WEAPON_MENU_MAX_ROWS - SCROLL_H),
306 scrollSize);
307 PicRender(
308 gradient, g->gameWindow.renderer,
309 svec2i(
310 scrollRect.Pos.x + scrollSize.x / 2,
311 pos.y - gradient->size.y / 2 + weaponsY +
312 bgSize.y * WEAPON_MENU_MAX_ROWS - SCROLL_H -
313 gradient->size.y / 2 + 1),
314 colorBlack, 0, svec2((float)scrollSize.x, 1), SDL_FLIP_VERTICAL,
315 Rect2iZero());
316 Draw9Slice(
317 g, scrollPic, scrollRect, 3, 3, 3, 3, true, color, SDL_FLIP_NONE);
318 FontOpts fopts = FontOptsNew();
319 fopts.Area = scrollRect.Size;
320 fopts.HAlign = ALIGN_CENTER;
321 fopts.VAlign = ALIGN_CENTER;
322 fopts.Mask = color;
323 FontStrOpt(ARROW_DOWN, scrollRect.Pos, fopts);
324 }
325 else
326 {
327 // Draw "none" gun which can be used to unequip this slot
328 DrawGun(
329 d, g, (int)d->weaponIndices.size, NULL, false,
330 svec2i(pos.x, pos.y + weaponsY), bgSize);
331 }
332 }
333 static void DrawGun(
334 const WeaponMenu *data, GraphicsDevice *g, const int idx,
335 const WeaponClass *wc, const DrawGunMeta meta, const struct vec2i pos,
336 const struct vec2i bgSize)
337 {
338 const bool selected = data->idx == idx;
339 const PlayerData *pData = PlayerDataGetByUID(data->PlayerUID);
340 const bool equipped = wc && PlayerHasWeapon(pData, wc);
341 const int bgSpriteIndex = (int)selected;
342 const Pic *bg = CArrayGet(&data->menuBGSprites->pics, bgSpriteIndex);
343 const struct vec2i bgPos = svec2i(
344 pos.x + 2 + (idx % data->cols) * GUN_BG_W,
345 pos.y + (idx / data->cols - data->scroll) * bgSize.y);
346 const int costDiff = EquipCostDiff(wc, pData, data->slot);
347 const bool enabled = data->Active && (!gCampaign.Setting.BuyAndSell ||
348 costDiff <= pData->Totals.Score);
349 color_t color = enabled ? colorWhite : colorGray;
350 const color_t mask = color;
351 if (selected && data->Active)
352 {
353 DrawRectangle(g, bgPos, bgSize, colorSelectedBG, true);
354 color = colorRed;
355 }
356 else if (equipped)
357 {
358 color = colorYellow;
359 }
360
361 Draw9Slice(
362 g, bg,
363 Rect2iNew(
364 svec2i(bgPos.x + 1, bgPos.y + 1),
365 svec2i(GUN_BG_W - 2, bgSize.y - 2)),
366 3, 3, 3, 3, true, mask, SDL_FLIP_NONE);
367
368 // Draw icon at center of slot
369 const Pic *gunIcon =
370 wc ? wc->Icon : PicManagerGetPic(&gPicManager, "peashooter");
371 const struct vec2i gunPos = svec2i_subtract(
372 svec2i_add(bgPos, svec2i_scale_divide(bgSize, 2)),
373 svec2i_scale_divide(gunIcon->size, 2));
374 PicRender(
375 gunIcon, g->gameWindow.renderer, gunPos, wc ? mask : colorBlack, 0,
376 svec2_one(), SDL_FLIP_NONE, Rect2iZero());
377
378 DrawWeaponAmmo(g, pData, wc, mask, bgPos, svec2i(bgSize.x - 1, bgSize.y));
379
380 // Draw price
381 if (gCampaign.Setting.BuyAndSell && wc && wc->Price != 0)
382 {
383 const FontOpts foptsP = {
384 ALIGN_CENTER, ALIGN_START, bgSize, svec2i(2, 2),
385 enabled ? (selected ? colorRed : colorGray) : colorDarkGray};
386 char buf[256];
387 sprintf(buf, "$%d", wc->Price);
388 FontStrOpt(buf, bgPos, foptsP);
389 }
390
391 const Pic *arrow = PicManagerGetPic(&gPicManager, "hud/arrow");
392 const struct vec2i metaPos = svec2i(bgPos.x + GUN_BG_W - 6, bgPos.y + 5);
393 const struct vec2i arrowPos = svec2i(metaPos.x - 4, metaPos.y);
394 switch (meta)
395 {
396 case META_NONE:
397 break;
398 case META_NEW:
399 DrawCross(g, metaPos, colorGreen);
400 break;
401 case META_UPGRADE:
402 PicRender(
403 arrow, g->gameWindow.renderer, arrowPos, colorGreen, 0,
404 svec2_one(), SDL_FLIP_NONE, Rect2iZero());
405 break;
406 case META_DOWNGRADE:
407 PicRender(
408 arrow, g->gameWindow.renderer, arrowPos, colorRed, 0, svec2_one(),
409 SDL_FLIP_VERTICAL, Rect2iZero());
410 break;
411 default:
412 CASSERT(false, "unexpected");
413 break;
414 }
415
416 const FontOpts fopts = {
417 ALIGN_CENTER, ALIGN_END, bgSize, svec2i(2, 2), color};
418 const char *gunName = wc ? wc->name : NO_GUN_LABEL;
419 FontStrOpt(gunName, bgPos, fopts);
420 }
421
422 static int HandleInputMenu(int cmd, void *data)
423 {
424 WeaponMenu *d = data;
425 PlayerData *p = PlayerDataGetByUID(d->PlayerUID);
426
427 const int numGuns = (int)d->weaponIndices.size;
428
429 if (Button1(cmd))
430 {
431 if (gCampaign.Setting.BuyAndSell)
432 {
433 const int costDiff = WeaponMenuSelectedCostDiff(d);
434 if (costDiff > 0 && costDiff > p->Totals.Score)
435 {
436 // Can't afford
437 return 0;
438 }
439 }
440 return 1;
441 }
442 else if (Button2(cmd))
443 {
444 return 1;
445 }
446 else if (Left(cmd))
447 {
448 if ((d->idx % d->cols) > 0)
449 {
450 d->idx--;
451 MenuPlaySound(MENU_SOUND_SWITCH);
452 }
453 }
454 else if (Right(cmd))
455 {
456 if ((d->idx % d->cols) < d->cols - 1 && numGuns > 0)
457 {
458 d->idx++;
459 if (d->idx > numGuns)
460 {
461 d->idx = MAX(0, d->idx - d->cols);
462 }
463 MenuPlaySound(MENU_SOUND_SWITCH);
464 }
465 }
466 else if (Up(cmd))
467 {
468 if (d->idx >= d->cols)
469 {
470 d->idx -= d->cols;
471 MenuPlaySound(MENU_SOUND_SWITCH);
472 }
473 }
474 else if (Down(cmd))
475 {
476 if ((d->idx + d->cols) < DIV_ROUND_UP(numGuns + 1, d->cols) * d->cols)
477 {
478 d->idx = MIN(numGuns, d->idx + d->cols);
479 MenuPlaySound(MENU_SOUND_SWITCH);
480 }
481 }
482
483 d->scroll = ClampScroll(d);
484
485 return 0;
486 }
487
488 void WeaponMenuTerminate(WeaponMenu *menu)
489 {
490 MenuSystemTerminate(&menu->ms);
491 CArrayTerminate(&menu->weaponIndices);
492 CArrayTerminate(&menu->weaponMeta);
493 }
494
495 void WeaponMenuReset(WeaponMenu *menu)
496 {
497 const PlayerData *pData = PlayerDataGetByUID(menu->PlayerUID);
498 menu->idx = 0;
499 const WeaponClass *equipped = pData->guns[menu->slot];
500
501 // Find out which weapons are new/upgrades/downgrades
502 CArrayTerminate(&menu->weaponMeta);
503 CArrayInit(&menu->weaponMeta, sizeof(DrawGunMeta));
504 CA_FOREACH(const WeaponClass *, wc, *menu->weapons)
505 const bool isNew = *(const bool *)CArrayGet(menu->weaponIsNew, _ca_index);
506 DrawGunMeta meta = isNew ? META_NEW : META_NONE;
507 if (equipped != NULL)
508 {
509 // Check if this slot has an upgrade/downgrade
510 if (equipped == WeaponClassGetPrerequisite(*wc))
511 {
512 meta = META_UPGRADE;
513 }
514 else if (WeaponClassGetPrerequisite(equipped) == *wc)
515 {
516 meta = META_DOWNGRADE;
517 }
518 }
519 CArrayPushBack(&menu->weaponMeta, &meta);
520 CA_FOREACH_END()
521
522 // Get the weapon indices available for this slot
523 CArrayTerminate(&menu->weaponIndices);
524 CArrayInit(&menu->weaponIndices, sizeof(int));
525
526 // Add the equipped weapon's upgrades and downgrades first
527 if (equipped != NULL)
528 {
529 CA_FOREACH(const WeaponClass *, wc, *menu->weapons)
530 if (WeaponClassGetPrerequisite(*wc) == equipped)
531 {
532 CArrayPushBack(&menu->weaponIndices, &_ca_index);
533 }
534 CA_FOREACH_END()
535 CA_FOREACH(const WeaponClass *, wc, *menu->weapons)
536 if (WeaponClassGetPrerequisite(equipped) == *wc)
537 {
538 CArrayPushBack(&menu->weaponIndices, &_ca_index);
539 }
540 CA_FOREACH_END()
541 }
542
543 CA_FOREACH(const WeaponClass *, wc, *menu->weapons)
544 if (!InSlot(*wc, menu->slot))
545 {
546 continue;
547 }
548 // Pre-select the equipped gun for the slot
549 if (*wc == equipped)
550 {
551 menu->idx = (int)menu->weaponIndices.size;
552 }
553 else if (WeaponClassesAreRelated(*wc, equipped))
554 {
555 // Don't add other related weapons
556 continue;
557 }
558 else if (
559 WeaponClassGetPrerequisite(*wc) != NULL &&
560 !PlayerHasWeapon(pData, *wc))
561 {
562 // Don't add weapons that are upgrades and the player doesn't have
563 continue;
564 }
565 CArrayPushBack(&menu->weaponIndices, &_ca_index);
566 CA_FOREACH_END()
567 }
568 void WeaponMenuActivate(WeaponMenu *menu)
569 {
570 menu->Active = true;
571 menu->SelectResult = WEAPON_MENU_NONE;
572 }
573
574 void WeaponMenuUpdate(WeaponMenu *menu, const int cmd)
575 {
576 PlayerData *p = PlayerDataGetByUID(menu->PlayerUID);
577 MenuProcessCmd(&menu->ms, cmd);
578 switch (menu->SelectResult)
579 {
580 case WEAPON_MENU_NONE:
581 break;
582 case WEAPON_MENU_SELECT: {
583 const WeaponClass *selectedGun = GetSelectedGun(menu);
584 PlayerAddWeaponToSlot(p, selectedGun, menu->slot);
585 }
586 // fallthrough
587 case WEAPON_MENU_CANCEL:
588 menu->ms.current = menu->ms.root;
589 // Switch back to equip menu
590 menu->Active = false;
591 break;
592 default:
593 CASSERT(false, "unhandled case");
594 break;
595 }
596 }
597
598 void WeaponMenuDraw(const WeaponMenu *menu)
599 {
600 MenuDisplay(&menu->ms);
601 }