Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
filemenu_main.c
Go to the documentation of this file.
1#include "common.h"
2#include "filemenu.h"
3#include "hud_element.h"
4#include "audio/public.h"
5#include "fio.h"
6#include "game_modes.h"
7#include "dx/config.h"
8#include "dx/utils.h"
9
30
31#if VERSION_PAL
32extern u8 D_filemenu_802508D0[4];
33extern u8 D_filemenu_802508D4[4];
34extern u8 D_filemenu_802508D8[4];
35extern u8 D_filemenu_802508DC[4];
36extern u8 D_filemenu_802508E0[4];
37extern u8 D_filemenu_802508E4[4];
38extern u8 D_filemenu_802508E8[4];
39extern u8 D_filemenu_802508EC[4];
40extern u8 D_filemenu_802508F0[4];
41extern u8 D_filemenu_802508F4[4];
42extern u8 D_filemenu_80250938[4];
43extern u8 D_filemenu_8025093C[4];
44#define COPY_OFFSET_X (D_filemenu_8025093C[gCurrentLanguage])
45#define SAVE_OFFSET_X (D_filemenu_80250938[gCurrentLanguage])
46#else
47#define SAVE_OFFSET_X 25
48#define COPY_OFFSET_X 16
49#endif
50
52
53#define LOCALE_FILE_NUMBER_X 33
54//TODO ifdef for LOCALE_DE/ES/FR/JP/CN ...
55
56#if VERSION_IQUE
57#define OFFSET_WIDTH 5
58#define DELETE_OFFSET_X 9
59#define CENTER_CANCEL_X 30
60#define RIGHT_CANCEL_X 24
61#define FILE_X 4
62#define FILE_NUMBER_X 36
63#define FILE_NAME_X 48
64#define NUMBER_OFFSET_Y 1
65#else
66#define OFFSET_WIDTH 0
67#define DELETE_OFFSET_X 8
68#define CENTER_CANCEL_X 18
69#define RIGHT_CANCEL_X 20
70#define FILE_X 5
71#define FILE_NUMBER_X 33
72#define FILE_NAME_X 46
73#define NUMBER_OFFSET_Y 0
74#endif
75
88
96 },
97#if VERSION_PAL
98 [LANGUAGE_DE] = {
104 },
105 [LANGUAGE_FR] = {
111 },
112 [LANGUAGE_ES] = {
118 }
119#endif
120};
121
123 0, 0, 1, 2, 2, 3, 4, 5, 6,
124 0, 0, 1, 2, 2, 3, 6, 6, 6,
125 0, 0, 1, 2, 2, 3, 6, 6, 6,
126 0, 0, 1, 2, 2, 3, 6, 6, 6,
127#if !VERSION_PAL
128 0, 0, 1, 2, 2, 3, 6, 6, 6,
129#endif
130};
131
133 {
135 .unk_01 = 0,
136 .pos = { .x = 0, .y = 0 },
137 .width = 0,
138 .height = 0,
139 .priority = WINDOW_PRIORITY_0,
140 .fpDrawContents = &filemenu_draw_contents_title,
141 .tab = NULL,
142 .parentID = WIN_FILES_MAIN,
143 .fpUpdate = { .func = &filemenu_update_show_title },
144 .extraFlags = 0,
145 .style = { .customStyle = &filemenu_windowStyles[3] }
146 },
147 {
148 .windowID = WIN_FILES_STEREO,
149 .unk_01 = 0,
150 .pos = { .x = -2, .y = 6 },
151 .width = 68,
152 .height = 20,
153 .priority = WINDOW_PRIORITY_0,
154 .fpDrawContents = &filemenu_draw_contents_stereo,
155 .tab = NULL,
156 .parentID = WIN_FILES_MAIN,
157 .fpUpdate = { .func = &filemenu_update_show_options_left },
158 .extraFlags = 0,
159 .style = { .customStyle = &filemenu_windowStyles[2] }
160 },
161 {
162 .windowID = WIN_FILES_MONO,
163 .unk_01 = 0,
164 .pos = { .x = 221, .y = 6 },
165 .width = 68,
166 .height = 20,
167 .priority = WINDOW_PRIORITY_0,
168 .fpDrawContents = &filemenu_draw_contents_mono,
169 .tab = NULL,
170 .parentID = WIN_FILES_MAIN,
171 .fpUpdate = { .func = &filemenu_update_show_options_right },
172 .extraFlags = 0,
173 .style = { .customStyle = &filemenu_windowStyles[2] }
174 },
175 {
176 .windowID = WIN_FILES_OPTION_LEFT,
177 .unk_01 = 0,
178 .pos = { .x = 5, .y = 171 },
179 .width = 88,
180 .height = 16,
181 .priority = WINDOW_PRIORITY_0,
182 .fpDrawContents = &filemenu_draw_contents_option_left,
183 .tab = NULL,
184 .parentID = WIN_FILES_MAIN,
185 .fpUpdate = { .func = &filemenu_update_show_options_bottom },
186 .extraFlags = 0,
187 .style = { .customStyle = &filemenu_windowStyles[4] }
188 },
189 {
190 .windowID = WIN_FILES_OPTION_CENTER,
191 .unk_01 = 0,
192 .pos = { .x = 0, .y = 171 },
193 .width = 88,
194 .height = 16,
195 .priority = WINDOW_PRIORITY_0,
196 .fpDrawContents = &filemenu_draw_contents_option_center,
197 .tab = NULL,
198 .parentID = WIN_FILES_MAIN,
199 .fpUpdate = { .func = &filemenu_update_show_options_bottom },
200 .extraFlags = 0,
201 .style = { .customStyle = &filemenu_windowStyles[5] }
202 },
203 {
204 .windowID = WIN_FILES_OPTION_RIGHT,
205 .unk_01 = 0,
206 .pos = { .x = 195, .y = 171 },
207 .width = 88,
208 .height = 16,
209 .priority = WINDOW_PRIORITY_0,
210 .fpDrawContents = &filemenu_draw_contents_option_right,
211 .tab = NULL,
212 .parentID = WIN_FILES_MAIN,
213 .fpUpdate = { .func = &filemenu_update_show_options_bottom },
214 .extraFlags = 0,
215 .style = { .customStyle = &filemenu_windowStyles[6] }
216 },
217 {
218 .windowID = WIN_FILES_SLOT3_BODY,
219 .unk_01 = 0,
220 .pos = { .x = 9, .y = 110 },
221 .width = 130,
222 .height = 54,
223 .priority = WINDOW_PRIORITY_0,
224 .fpDrawContents = &filemenu_draw_contents_file_2_info,
225 .tab = NULL,
226 .parentID = WIN_FILES_MAIN,
227 .fpUpdate = { .func = &filemenu_update_show_options_left },
228 .extraFlags = 0,
229 .style = { .customStyle = &filemenu_windowStyles[9] }
230 },
231 {
232 .windowID = WIN_FILES_SLOT3_TITLE,
233 .unk_01 = 0,
234 .pos = { .x = 3, .y = -8 },
235 .width = 124 + OFFSET_WIDTH,
236 .height = 15,
237 .priority = WINDOW_PRIORITY_0,
238 .fpDrawContents = &filemenu_draw_contents_file_2_title,
239 .tab = NULL,
240 .parentID = WIN_FILES_SLOT3_BODY,
241 .fpUpdate = { WINDOW_UPDATE_SHOW },
242 .extraFlags = 0,
243 .style = { .customStyle = &filemenu_windowStyles[13] }
244 },
245 {
246 .windowID = WIN_FILES_SLOT4_BODY,
247 .unk_01 = 0,
248 .pos = { .x = 149, .y = 110 },
249 .width = 130,
250 .height = 54,
251 .priority = WINDOW_PRIORITY_0,
252 .fpDrawContents = &filemenu_draw_contents_file_3_info,
253 .tab = NULL,
254 .parentID = WIN_FILES_MAIN,
255 .fpUpdate = { .func = &filemenu_update_show_options_right },
256 .extraFlags = 0,
257 .style = { .customStyle = &filemenu_windowStyles[10] }
258 },
259 {
260 .windowID = WIN_FILES_SLOT4_TITLE,
261 .unk_01 = 0,
262 .pos = { .x = 3, .y = -8 },
263 .width = 124 + OFFSET_WIDTH,
264 .height = 15,
265 .priority = WINDOW_PRIORITY_0,
266 .fpDrawContents = &filemenu_draw_contents_file_3_title,
267 .tab = NULL,
268 .parentID = WIN_FILES_SLOT4_BODY,
269 .fpUpdate = { WINDOW_UPDATE_SHOW },
270 .extraFlags = 0,
271 .style = { .customStyle = &filemenu_windowStyles[14] }
272 },
273 {
274 .windowID = WIN_FILES_SLOT1_BODY,
275 .unk_01 = 0,
276 .pos = { .x = 9, .y = 41 },
277 .width = 130 + OFFSET_WIDTH,
278 .height = 54,
279 .priority = WINDOW_PRIORITY_0,
280 .fpDrawContents = &filemenu_draw_contents_file_0_info,
281 .tab = NULL,
282 .parentID = WIN_FILES_MAIN,
283 .fpUpdate = { .func = &filemenu_update_show_options_left },
284 .extraFlags = 0,
285 .style = { .customStyle = &filemenu_windowStyles[7] }
286 },
287 {
288 .windowID = WIN_FILES_SLOT1_TITLE,
289 .unk_01 = 0,
290 .pos = { .x = 3, .y = -8 },
291 .width = 124 + OFFSET_WIDTH,
292 .height = 15,
293 .priority = WINDOW_PRIORITY_0,
294 .fpDrawContents = &filemenu_draw_contents_file_0_title,
295 .tab = NULL,
296 .parentID = WIN_FILES_SLOT1_BODY,
297 .fpUpdate = { WINDOW_UPDATE_SHOW },
298 .extraFlags = 0,
299 .style = { .customStyle = &filemenu_windowStyles[11] }
300 },
301 {
302 .windowID = WIN_FILES_SLOT2_BODY,
303 .unk_01 = 0,
304 .pos = { .x = 149, .y = 41 },
305 .width = 130,
306 .height = 54,
307 .priority = WINDOW_PRIORITY_0,
308 .fpDrawContents = &filemenu_draw_contents_file_1_info,
309 .tab = NULL,
310 .parentID = WIN_FILES_MAIN,
311 .fpUpdate = { .func = &filemenu_update_show_options_right },
312 .extraFlags = 0,
313 .style = { .customStyle = &filemenu_windowStyles[8] }
314 },
315 {
316 .windowID = WIN_FILES_SLOT2_TITLE,
317 .unk_01 = 0,
318 .pos = { .x = 3, .y = -8 },
319 .width = 124 + OFFSET_WIDTH,
320 .height = 15,
321 .priority = WINDOW_PRIORITY_0,
322 .fpDrawContents = &filemenu_draw_contents_file_1_title,
323 .tab = NULL,
324 .parentID = WIN_FILES_SLOT2_BODY,
325 .fpUpdate = { WINDOW_UPDATE_SHOW },
326 .extraFlags = 0,
327 .style = { .customStyle = &filemenu_windowStyles[12] }
328 },
329};
330
332 .initialized = FALSE,
333 .col = 0,
334 .row = 0,
335 .selected = 0,
336 .state = 0,
337 .numCols = 3,
338 .numRows = 3,
339 .numPages = 0,
340 .gridData = filemenu_main_gridData,
341 .fpInit = &filemenu_main_init,
342 .fpHandleInput = &filemenu_main_handle_input,
343 .fpUpdate = &filemenu_main_update,
344 .fpCleanup = &filemenu_main_cleanup
345};
346
348 MenuPanel* menu,
349 s32 baseX, s32 baseY,
350 s32 width, s32 height,
351 s32 opacity, s32 darkening
352) {
353 char strBuf[64];
354 u8 msgBuf[64];
355 s32 msgWidth;
356 s32 msgIdx;
357 s32 xOffset;
358 s32 yOffset;
359
360 switch (menu->state) {
361 default:
364 xOffset = 9;
365 yOffset = 4;
366 break;
369 xOffset = DELETE_OFFSET_X;
370 yOffset = 4;
371 break;
374 xOffset = SAVE_OFFSET_X;
375 yOffset = 4;
376 break;
379 xOffset = COPY_OFFSET_X;
380 yOffset = 4;
381 break;
382 }
383
384 filemenu_draw_message(filemenu_get_menu_message(msgIdx), baseX + xOffset, baseY + yOffset, 255, 0, 0);
385
386 sprintf(strBuf, "%s (v%d.%d.%d)", DX_MOD_NAME, DX_MOD_VER_MAJOR, DX_MOD_VER_MINOR, DX_MOD_VER_PATCH);
387 dx_string_to_msg(msgBuf, strBuf);
388 msgWidth = get_msg_width(msgBuf, 0);
389 filemenu_draw_message(msgBuf, (SCREEN_WIDTH - msgWidth) / 2, 245 - baseY, 255, 0, 0);
390}
391
393 MenuPanel* menu,
394 s32 baseX, s32 baseY,
395 s32 width, s32 height,
396 s32 opacity, s32 darkening
397) {
399 hud_element_set_render_pos(filemenu_hudElemIDs[18], baseX + 34, baseY + 10);
401 } else {
402 hud_element_set_render_pos(filemenu_hudElemIDs[19], baseX + 34, baseY + 10);
404 }
405}
406
408 MenuPanel* menu,
409 s32 baseX, s32 baseY,
410 s32 width, s32 height,
411 s32 opacity, s32 darkening
412) {
414 hud_element_set_render_pos(filemenu_hudElemIDs[16], baseX + 34, baseY + 10);
416 } else {
417 hud_element_set_render_pos(filemenu_hudElemIDs[17], baseX + 34, baseY + 10);
419 }
420}
421
423 MenuPanel* menu,
424 s32 baseX, s32 baseY,
425 s32 width, s32 height,
426 s32 opacity, s32 darkening
427) {
428 if (menu->col == 0 && menu->row == 2) {
430 }
432}
433
434#if VERSION_PAL
436 MenuPanel* menu,
437 s32 baseX, s32 baseY,
438 s32 width, s32 height,
439 s32 opacity, s32 darkening
440) {
441 s32 msgIdx;
442 s32 xOffset;
443 s32 yOffset;
444
445 switch (menu->state) {
446 case 1:
447 case 2:
448 case 3:
449 msgIdx = FILE_MESSAGE_CANCEL;
450 xOffset = D_filemenu_802508F4[gCurrentLanguage];
451 yOffset = 0;
452 if (menu->col == 1 && menu->row == 2) {
453 filemenu_set_cursor_goal_pos(WIN_FILES_OPTION_CENTER, baseX + xOffset - 10, baseY + 8);
454 }
455 break;
456 default:
457 msgIdx = FILE_MESSAGE_COPY_FILE;
458 xOffset = D_filemenu_802508EC[gCurrentLanguage];
459 yOffset = 0;
460 if (menu->col == 1 && menu->row == 2) {
461 filemenu_set_cursor_goal_pos(WIN_FILES_OPTION_CENTER, baseX + xOffset - 10, baseY + 8);
462 }
463 break;
464 }
465
466 filemenu_draw_message(filemenu_get_menu_message(msgIdx), baseX + xOffset, baseY + yOffset + 2, 255, 0, 1);
467}
468#else
470 MenuPanel* menu,
471 s32 baseX, s32 baseY,
472 s32 width, s32 height,
473 s32 opacity, s32 darkening
474) {
475 s32 msgIdx;
476 s32 xOffset;
477 s32 yOffset;
478
479 switch (menu->state) {
480 case 1:
481 case 2:
482 case 3:
483 case 4:
484 msgIdx = FILE_MESSAGE_CANCEL;
485 xOffset = CENTER_CANCEL_X;
486 yOffset = 0;
487 if (menu->col == 1 && menu->row == 2) {
489 }
490 break;
491 default:
492 msgIdx = FILE_MESSAGE_COPY_FILE;
493 xOffset = 14;
494 yOffset = 0;
495 if (menu->col == 1 && menu->row == 2) {
497 }
498 break;
499 }
500
501 filemenu_draw_message(filemenu_get_menu_message(msgIdx), baseX + xOffset, baseY + yOffset + 2, 255, 0, 1);
502}
503#endif
504
506 MenuPanel* menu,
507 s32 baseX, s32 baseY,
508 s32 width, s32 height,
509 s32 opacity, s32 darkening
510) {
511 if (menu->col == 2 && menu->row == 2) {
513 }
515}
516
518 MenuPanel* menu,
519 s32 baseX, s32 baseY,
520 s32 width, s32 height,
521 s32 opacity, s32 darkening
522) {
523 s32 xOffset;
524 s32 temp_s0_3;
525 s32 temp_s1_2;
526 s32 temp_s3_2;
527 s32 temp_s3;
528 s32 id;
529 s32 i;
530 const int MAX_DISPLAYED_TIME = 100*60*60*60 - 1; // 100 hours minus one frame at 60 fps
531
532 if (!gSaveSlotMetadata[fileIdx].hasData) {
533#if VERSION_PAL
534 xOffset = D_filemenu_802508E0[gCurrentLanguage];
535#else
536 xOffset = 50;
537#endif
538 filemenu_draw_message(filemenu_get_menu_message(FILE_MESSAGE_NEW), baseX + xOffset, baseY + 20, 255, 0xA, 0);
539 return;
540 }
541
542 // do not show file summary from mods that don't match the current one
543 if (!gSaveSlotMetadata[fileIdx].validData) {
544 char buf[32];
545 if (gSaveSlotMetadata[fileIdx].modName[0] == '\0') {
546 dx_string_to_msg(&buf, "Paper Mario");
547 } else {
548 dx_string_to_msg(&buf, gSaveSlotMetadata[fileIdx].modName);
549 }
550 xOffset = 66 - get_msg_width(&buf, 0) / 2;
551 filemenu_draw_message(&buf, baseX + xOffset, baseY + 20, 255, MSG_PAL_RED, 0);
552 return;
553 }
554
555 if (gSaveSlotSummary[fileIdx].timePlayed == 0) {
556#if VERSION_PAL
557 xOffset = D_filemenu_802508E4[gCurrentLanguage];
558#else
559 xOffset = 30;
560#endif
561 filemenu_draw_message(filemenu_get_menu_message(FILE_MESSAGE_FIRST_PLAY), baseX + xOffset, baseY + 20, 255, 0xA, 0);
562 return;
563 }
564
565#if VERSION_PAL
566 xOffset = D_filemenu_802508D8[gCurrentLanguage];
567#else
568 xOffset = 34;
569#endif
570 filemenu_draw_message(filemenu_get_menu_message(FILE_MESSAGE_LEVEL), baseX + xOffset, baseY + 10, 255, 0xA, 1);
571 temp_s3_2 = gSaveSlotSummary[fileIdx].level;
572 temp_s3 = temp_s3_2;
575#if VERSION_PAL
576 xOffset = D_filemenu_802508DC[gCurrentLanguage];
577#else
578 xOffset = 11;
579#endif
580 filemenu_draw_message(filemenu_get_menu_message(FILE_MESSAGE_PLAY_TIME), baseX + xOffset, baseY + 24, 255, 0xA, 1);
581
582 temp_s3_2 = gSaveSlotSummary[fileIdx].timePlayed;
583 if (temp_s3_2 > MAX_DISPLAYED_TIME) {
584 temp_s3_2 = MAX_DISPLAYED_TIME;
585 }
586
587 draw_number((temp_s3_2 / 2160000) % 10, baseX + 76, baseY + 24 + NUMBER_OFFSET_Y, DRAW_NUMBER_CHARSET_THIN, MSG_PAL_STANDARD, 255, DRAW_NUMBER_STYLE_MONOSPACE);
588 temp_s1_2 = temp_s3_2 / 216000;
589 draw_number(temp_s1_2 - ((temp_s3_2 / 2160000) * 10), baseX + 85, baseY + 24 + NUMBER_OFFSET_Y, DRAW_NUMBER_CHARSET_THIN, MSG_PAL_STANDARD, 255, DRAW_NUMBER_STYLE_MONOSPACE);
590 filemenu_draw_message(filemenu_get_menu_message(FILE_MESSAGE_PERIOD_13), baseX + 95, baseY + 23, 255, 0xA, 1);
591 filemenu_draw_message(filemenu_get_menu_message(FILE_MESSAGE_PERIOD_13), baseX + 95, baseY + 18, 255, 0xA, 1);
592 temp_s0_3 = temp_s3_2 / 36000;
593 draw_number(temp_s0_3 - (temp_s1_2 * 6), baseX + 100, baseY + 24 + NUMBER_OFFSET_Y, DRAW_NUMBER_CHARSET_THIN, MSG_PAL_STANDARD, 255, DRAW_NUMBER_STYLE_MONOSPACE);
594 draw_number((temp_s3_2 / 3600) - (temp_s0_3 * 10), baseX + 109, baseY + 24 + NUMBER_OFFSET_Y, DRAW_NUMBER_CHARSET_THIN, MSG_PAL_STANDARD, 255, DRAW_NUMBER_STYLE_MONOSPACE);
595
596 for (i = 0; i < 7; i++) {
597 if (i < gSaveSlotSummary[fileIdx].spiritsRescued) {
598 id = filemenu_hudElemIDs[i];
599 } else {
600 id = filemenu_hudElemIDs[i + 7];
601 }
602 hud_element_set_render_pos(id, baseX + 17 + (i * 16), baseY + 44);
603 if (i == 0) {
605 } else {
607 }
608 }
609}
610
611#if VERSION_PAL
613 s32 fileIdx,
614 MenuPanel* menu,
615 s32 baseX, s32 baseY,
616 s32 width, s32 height,
617 s32 opacity, s32 darkening)
618{
619 if (filemenu_currentMenu == FILE_MENU_MAIN && menu->selected == fileIdx) {
620 filemenu_set_cursor_goal_pos(fileIdx + 60, baseX - 3, baseY + 8);
621 }
622
624
625 if (!gSaveSlotHasData[fileIdx]) {
626 filemenu_draw_message(filemenu_get_menu_message(fileIdx + FILE_MESSAGE_BASE_UNK),
627 baseX + D_filemenu_802508D0[gCurrentLanguage], baseY + 1, 255, 0, 1);
628 } else {
629 s32 tmp = D_filemenu_802508D0[gCurrentLanguage];
630
631 filemenu_draw_message(filemenu_get_menu_message(fileIdx + FILE_MESSAGE_BASE_UNK),
632 baseX + tmp, baseY + 1, 255, 0, 1);
633
634 tmp += D_filemenu_802508D4[gCurrentLanguage];
635 tmp += 6;
637 gSaveSlotSummary[fileIdx].filename,
638 ARRAY_COUNT(gSaveSlotSummary[fileIdx].filename),
639 baseX + tmp,
640 baseY + 1, 255, 0, 1, 9);
641 }
642}
643#else
645 s32 fileIdx,
646 MenuPanel* menu,
647 s32 baseX, s32 baseY,
648 s32 width, s32 height,
649 s32 opacity, s32 darkening)
650{
651 if (filemenu_currentMenu == FILE_MENU_MAIN && menu->selected == fileIdx) {
652 filemenu_set_cursor_goal_pos(fileIdx + 60, baseX - 3, baseY + 8);
653 }
654
656
657 if (!gSaveSlotMetadata[fileIdx].hasData) {
659 } else {
662 gSaveSlotSummary[fileIdx].filename,
663 ARRAY_COUNT(gSaveSlotSummary[fileIdx].filename),
664 baseX + FILE_NAME_X, baseY + 1, 255, 0, 1, 9);
665 }
666}
667#endif
668
670 MenuPanel* menu,
671 s32 baseX, s32 baseY,
672 s32 width, s32 height,
673 s32 opacity, s32 darkening
674) {
675 filemenu_draw_contents_file_info(0, menu, baseX, baseY, width, height, opacity, darkening);
676}
677
679 MenuPanel* menu,
680 s32 baseX, s32 baseY,
681 s32 width, s32 height,
682 s32 opacity, s32 darkening
683) {
684 filemenu_draw_contents_file_info(1, menu, baseX, baseY, width, height, opacity, darkening);
685}
686
688 MenuPanel* menu,
689 s32 baseX, s32 baseY,
690 s32 width, s32 height,
691 s32 opacity, s32 darkening
692) {
693 filemenu_draw_contents_file_info(2, menu, baseX, baseY, width, height, opacity, darkening);
694}
695
697 MenuPanel* menu,
698 s32 baseX, s32 baseY,
699 s32 width, s32 height,
700 s32 opacity, s32 darkening
701) {
702 filemenu_draw_contents_file_info(3, menu, baseX, baseY, width, height, opacity, darkening);
703}
704
706 MenuPanel* menu,
707 s32 baseX, s32 baseY,
708 s32 width, s32 height,
709 s32 opacity, s32 darkening
710) {
711 filemenu_draw_contents_file_title(0, menu, baseX, baseY, width, height, opacity, darkening);
712}
713
715 MenuPanel* menu,
716 s32 baseX, s32 baseY,
717 s32 width, s32 height,
718 s32 opacity, s32 darkening
719) {
720 filemenu_draw_contents_file_title(1, menu, baseX, baseY, width, height, opacity, darkening);
721}
722
724 MenuPanel* menu,
725 s32 baseX, s32 baseY,
726 s32 width, s32 height,
727 s32 opacity, s32 darkening
728) {
729 filemenu_draw_contents_file_title(2, menu, baseX, baseY, width, height, opacity, darkening);
730}
731
733 MenuPanel* menu,
734 s32 baseX, s32 baseY,
735 s32 width, s32 height,
736 s32 opacity, s32 darkening
737) {
738 filemenu_draw_contents_file_title(3, menu, baseX, baseY, width, height, opacity, darkening);
739}
740
771
773 s32 originalSelected = menu->selected;
774 s32 i;
775
777 while (TRUE) {
778 menu->col--;
779 if (menu->col < 0) {
780 menu->col = 0;
781 break;
782 }
783 if (menu->selected != MENU_PANEL_SELECTED_GRID_DATA(menu)) {
784 break;
785 }
786 }
787 }
788
790 while (TRUE) {
791 menu->col++;
792 if (menu->col >= menu->numCols) {
793 menu->col = menu->numCols - 1;
794 break;
795 }
796
797 if (menu->selected != MENU_PANEL_SELECTED_GRID_DATA(menu)) {
798 break;
799 }
800 }
801 }
802
804 menu->row--;
805 if (menu->row < 0) {
806 menu->row = 0;
807 }
808 }
809
811 menu->row++;
812 if (menu->row >= menu->numRows) {
813 menu->row = menu->numRows - 1;
814 }
815 }
816
817 switch (menu->state) {
819 // force selection to column 0 when navigating up from bottom row
820 if (menu->col == 1 && (u8) menu->row < 2) {
821 menu->col = 0;
822 }
823 break;
827 // force selection to column 0 when navigating up from bottom row
828 if (menu->col == 1 && (u8) menu->row < 2) {
829 menu->col = 0;
830 }
831 // force selection to column 1 when navigating down to bottom row
832 if (menu->row == 2) {
833 menu->col = 1;
834 }
835 break;
836 }
837
839 if (originalSelected != menu->selected) {
841 }
842
843 if (menu->state == FM_MAIN_SELECT_FILE) {
844 s32 originalOutputMode = gGameStatusPtr->soundOutputMode;
845
848 }
851 }
852
853 if (originalOutputMode != gGameStatusPtr->soundOutputMode) {
857 } else {
859 }
860 }
861 }
862
865 }
866
868 switch (menu->state) {
871 // selected a file with no data
872 for (i = 0; i < ARRAY_COUNT(filemenu_filename); i++) {
874 }
893 break;
894 }
895
896 if (menu->selected == FM_MAIN_OPT_CANCEL) {
897 // selected "Cancel" button
910 } else if (menu->selected == FM_MAIN_OPT_DELETE) {
911 // selected "Delete File" button
914 filemenu_set_selected(menu, 1, 2);
919 } else if (menu->selected == FM_MAIN_OPT_COPY) {
920 // selected "Copy File" button
923 filemenu_set_selected(menu, 1, 2);
928 } else if (menu->selected <= FM_MAIN_OPT_FILE_4) {
929 // selected a file
945
950
955
960 } else {
962 }
963 }
964 break;
966 if (menu->selected == FM_MAIN_OPT_CANCEL) {
967 // selected "Cancel" button
974 filemenu_set_selected(menu, 0, 2);
975 } else if (menu->selected <= FM_MAIN_OPT_FILE_4) {
976 // selected a file
980
985
990
994 } else {
996 }
997 }
998 break;
1000 if (menu->selected == FM_MAIN_OPT_CANCEL) {
1001 // selected "Cancel" button
1003 menu->state = FM_MAIN_SELECT_FILE;
1008 filemenu_set_selected(menu, 0, 1);
1009 } else if (menu->selected <= FM_MAIN_OPT_FILE_4) {
1010 // selected a file
1011 if (gSaveSlotMetadata[menu->selected].hasData) {
1015 } else {
1017 }
1018 }
1019 break;
1021 if (menu->selected == FM_MAIN_OPT_CANCEL) {
1022 // selected "Cancel" button
1025 filemenu_set_selected(menu, 0, 2);
1026 } else if (menu->selected <= FM_MAIN_OPT_FILE_4) {
1027 // selected a file
1028 if (filemenu_CopyFromFileIdx == menu->selected) {
1030 } else {
1032 if (!gSaveSlotMetadata[menu->selected].hasData) {
1040
1047 } else {
1054
1059
1063 }
1064 }
1065 }
1066 break;
1067 }
1068 }
1069
1071 switch (menu->state) {
1073 filemenu_set_selected(menu, 2, 2);
1074 break;
1076 filemenu_set_selected(menu, 1, 2);
1077 break;
1079 filemenu_set_selected(menu, 1, 2);
1080 break;
1082 filemenu_set_selected(menu, 1, 2);
1083 break;
1084 }
1085
1086 switch (menu->state) {
1100 break;
1102 menu->state = FM_MAIN_SELECT_FILE;
1103 filemenu_set_selected(menu, 0, 2);
1109 break;
1111 menu->state = FM_MAIN_SELECT_FILE;
1112 filemenu_set_selected(menu, 1, 2);
1118 break;
1123 break;
1124 }
1125 }
1126}
1127
1129 // set default styles for all file slot panels
1138
1139 // modify style for selected file slot panel to add highlight
1140 switch (menu->selected) {
1141 case FM_MAIN_OPT_FILE_1:
1144 break;
1145 case FM_MAIN_OPT_FILE_2:
1148 break;
1149 case FM_MAIN_OPT_FILE_3:
1152 break;
1153 case FM_MAIN_OPT_FILE_4:
1156 break;
1157 }
1158
1159 // alsoadd highlight to "copy to" target
1161 switch (filemenu_CopyFromFileIdx) {
1162 case FM_MAIN_OPT_FILE_1:
1165 return;
1166 case FM_MAIN_OPT_FILE_2:
1169 return;
1170 case FM_MAIN_OPT_FILE_3:
1173 return;
1174 case FM_MAIN_OPT_FILE_4:
1177 return;
1178 }
1179 }
1180}
1181
1183 s32 i;
1184
1185 for (i = 0; i < ARRAY_COUNT(filemenu_hudElemIDs); i++) {
1187 }
1188}
void audio_set_stereo(void)
Definition 30450.c:839
void audio_set_mono(void)
Definition 30450.c:844
WindowStyleCustom * customStyle
#define DX_MOD_VER_MAJOR
Definition config.h:8
#define DX_MOD_NAME
Creates the version string that appears on the file select menu.
Definition config.h:7
#define DX_MOD_VER_PATCH
Definition config.h:10
#define DX_MOD_VER_MINOR
Definition config.h:9
#define get_msg_width
@ DRAW_NUMBER_STYLE_MONOSPACE
Definition enums.h:5394
@ BUTTON_A
Definition enums.h:2790
@ BUTTON_START
Definition enums.h:2787
@ BUTTON_R
Definition enums.h:2781
@ BUTTON_STICK_UP
Definition enums.h:2791
@ BUTTON_STICK_DOWN
Definition enums.h:2792
@ BUTTON_STICK_LEFT
Definition enums.h:2793
@ BUTTON_STICK_RIGHT
Definition enums.h:2794
@ BUTTON_B
Definition enums.h:2789
@ BUTTON_Z
Definition enums.h:2788
@ LANGUAGE_DE
Definition enums.h:6401
@ LANGUAGE_ES
Definition enums.h:6403
@ LANGUAGE_FR
Definition enums.h:6402
@ WINDOW_PRIORITY_0
Definition enums.h:3182
@ MSG_PAL_WHITE
Definition enums.h:5405
@ MSG_PAL_STANDARD
Definition enums.h:5415
@ MSG_PAL_RED
Definition enums.h:5412
@ WINDOW_UPDATE_SHOW
Definition enums.h:5311
@ WINDOW_UPDATE_HIDE
Definition enums.h:5312
@ SOUND_OUT_MONO
Definition enums.h:277
@ SOUND_OUT_STEREO
Definition enums.h:278
@ DRAW_NUMBER_CHARSET_THIN
Definition enums.h:5401
#define LANGUAGE_DEFAULT
Definition enums.h:6398
@ FILE_MESSAGE_SELECT_FILE_TO_START
Definition enums.h:5337
@ FILE_MESSAGE_FILE_26
Definition enums.h:5364
@ FILE_MESSAGE_COPY_WHICH_FILE
Definition enums.h:5342
@ FILE_MESSAGE_NEW
Definition enums.h:5344
@ FILE_MESSAGE_PERIOD_13
Definition enums.h:5351
@ FILE_MESSAGE_DELETE_FILE
Definition enums.h:5347
@ FILE_MESSAGE_LEVEL
Definition enums.h:5345
@ FILE_MESSAGE_COPY_FILE
Definition enums.h:5349
@ FILE_MESSAGE_PLAY_TIME
Definition enums.h:5346
@ FILE_MESSAGE_COPY_TO_WHICH_FILE
Definition enums.h:5343
@ FILE_MESSAGE_FIRST_PLAY
Definition enums.h:5350
@ FILE_MESSAGE_CANCEL
Definition enums.h:5348
@ FILE_MESSAGE_OK
Definition enums.h:5359
@ FILE_MESSAGE_SELECT_FILE_TO_DELETE
Definition enums.h:5338
@ SOUND_MENU_BACK
Definition enums.h:701
@ SOUND_FILE_MENU_MOVE_CURSOR
Definition enums.h:1539
@ SOUND_MENU_CHANGE_TAB
Definition enums.h:699
@ SOUND_MENU_NEXT
Definition enums.h:700
@ SOUND_FILE_MENU_OUT
Definition enums.h:711
@ SOUND_MENU_ERROR
Definition enums.h:933
@ MSG_CHAR_READ_SPACE
Definition enums.h:6050
@ WIN_FILES_SLOT3_BODY
Definition enums.h:5302
@ WIN_FILES_MESSAGE
Definition enums.h:5291
@ WIN_FILES_MAIN
Definition enums.h:5288
@ WIN_FILES_SLOT2_TITLE
Definition enums.h:5305
@ WIN_FILES_TITLE
Definition enums.h:5289
@ WIN_FILES_SLOT3_TITLE
Definition enums.h:5306
@ WIN_FILES_OPTION_CENTER
Definition enums.h:5298
@ WIN_FILES_OPTION_RIGHT
Definition enums.h:5299
@ WIN_FILES_STEREO
Definition enums.h:5295
@ WIN_FILES_OPTION_LEFT
Definition enums.h:5297
@ WIN_FILES_SLOT4_TITLE
Definition enums.h:5307
@ WIN_FILES_INPUT_FIELD
Definition enums.h:5292
@ WIN_FILES_SLOT1_BODY
Definition enums.h:5300
@ WIN_FILES_SLOT1_TITLE
Definition enums.h:5304
@ WIN_FILES_SLOT2_BODY
Definition enums.h:5301
@ WIN_FILES_INPUT_KEYBOARD
Definition enums.h:5293
@ WIN_FILES_MONO
Definition enums.h:5296
@ WIN_FILES_CONFIRM_PROMPT
Definition enums.h:5290
@ WIN_FILES_CONFIRM_OPTIONS
Definition enums.h:5294
@ WIN_FILES_SLOT4_BODY
Definition enums.h:5303
WindowStyleCustom filemenu_windowStyles[]
void filemenu_draw_file_name(u8 *, s32, s32, s32, s32, s32, s32, s32)
@ FM_MESSAGE_COPIED
Definition filemenu.h:35
@ FM_MAIN_SELECT_FILE
Definition filemenu.h:24
@ FM_CONFIRM_START
Definition filemenu.h:32
@ FM_CONFIRM_COPY
Definition filemenu.h:31
@ FM_MAIN_SELECT_COPY_TO
Definition filemenu.h:27
@ FM_MAIN_SELECT_DELETE
Definition filemenu.h:25
@ FM_INPUT_CHARSET_A
Definition filemenu.h:38
@ FM_MAIN_SELECT_COPY_FROM
Definition filemenu.h:26
@ FM_CONFIRM_DELETE
Definition filemenu.h:29
void filemenu_update_hidden_with_rotation(s32 windowIdx, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
@ FM_MAIN_OPT_DELETE
Definition filemenu.h:47
@ FM_MAIN_OPT_COPY
Definition filemenu.h:48
@ FM_MAIN_OPT_FILE_1
Definition filemenu.h:43
@ FM_MAIN_OPT_FILE_3
Definition filemenu.h:45
@ FM_MAIN_OPT_FILE_4
Definition filemenu.h:46
@ FM_MAIN_OPT_CANCEL
Definition filemenu.h:49
@ FM_MAIN_OPT_FILE_2
Definition filemenu.h:44
void filemenu_update_hidden_options_left(s32 windowIdx, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
s8 filemenu_currentMenu
void filemenu_draw_message(u8 *, s32, s32, s32, s32, u32)
s32 filemenu_heldButtons
#define CENTER_WINDOW_X(id)
Definition filemenu.h:6
MenuPanel * filemenu_menus[]
s32 filemenu_CopyFromFileIdx
void filemenu_update_hidden_options_bottom(s32 windowIdx, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
void filemenu_update_show_options_left(s32 windowIdx, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
void filemenu_update_hidden_title(s32 windowIdx, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
void filemenu_update_show_options_right(s32 windowIdx, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
void filemenu_update_show_name_confirm(s32 windowIdx, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
void filemenu_update_select_file(s32 windowIdx, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
void filemenu_update_hidden_options_right(s32 windowIdx, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
s32 filemenu_CopyToFileIdx
@ FILE_MENU_INPUT_NAME
Definition filemenu.h:20
@ FILE_MENU_CONFIRM
Definition filemenu.h:18
@ FILE_MENU_MESSAGE
Definition filemenu.h:19
@ FILE_MENU_MAIN
Definition filemenu.h:17
s8 filemenu_filename_pos
void filemenu_update_show_options_bottom(s32 windowIdx, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
void filemenu_update_show_name_input(s32 windowIdx, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
#define CENTER_WINDOW_Y(id)
Definition filemenu.h:11
s32 filemenu_hudElemIDs[20]
void filemenu_update_show_title(s32 windowIdx, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
s32 filemenu_pressedButtons
HudScript HES_OptionMonoOn_es
HudScript HES_Spirit6Missing
void filemenu_draw_contents_file_2_info(MenuPanel *menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening)
HudScript HES_OptionStereoOn_fr
HudScript HES_Spirit1Missing
#define NUMBER_OFFSET_Y
HudScript HES_Spirit5Missing
void filemenu_draw_contents_file_info(s32 fileIdx, MenuPanel *menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening)
HudScript HES_Spirit4Missing
HudScript HES_OptionMonoOff
HudScript HES_OptionStereoOn_es
HudScript HES_Spirit5
HudScript HES_Spirit3Missing
#define OFFSET_WIDTH
#define RIGHT_CANCEL_X
#define FILE_NUMBER_X
HudScript HES_JpFile
void filemenu_draw_contents_file_3_title(MenuPanel *menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening)
#define FILE_NAME_X
void filemenu_draw_contents_option_left(MenuPanel *menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening)
void filemenu_draw_contents_file_1_info(MenuPanel *menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening)
#define SAVE_OFFSET_X
void filemenu_draw_contents_option_right(MenuPanel *menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening)
MenuPanel filemenu_main_menuBP
HudScript HES_Spirit2
void filemenu_main_cleanup(MenuPanel *menu)
HudScript HES_Spirit7
void filemenu_draw_contents_file_0_title(MenuPanel *menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening)
#define DELETE_OFFSET_X
void filemenu_draw_contents_file_title(s32 fileIdx, MenuPanel *menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening)
HudScript HES_Spirit3
HudScript HES_Spirit2Missing
HudScript HES_Spirit6
HudScript HES_OptionStereoOn_de
HudScript HES_Spirit1
HudScript HES_OptionStereoOff_fr
BSS u8 filemenu_filename[8]
void filemenu_draw_contents_stereo(MenuPanel *menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening)
HudScript HES_Spirit4
void filemenu_draw_contents_file_2_title(MenuPanel *menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening)
HudScript HES_OptionStereoOff_es
HudScript HES_OptionMonoOn
HudScript HES_OptionMonoOff_de
MenuWindowBP filemenu_main_windowBPs[]
void filemenu_draw_contents_option_center(MenuPanel *menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening)
void filemenu_draw_contents_title(MenuPanel *menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening)
void filemenu_draw_contents_file_0_info(MenuPanel *menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening)
void filemenu_main_handle_input(MenuPanel *menu)
#define COPY_OFFSET_X
HudScript HES_OptionStereoOn
void filemenu_main_init(MenuPanel *menu)
HudScript HES_JpFileDisabled
void filemenu_draw_contents_file_1_title(MenuPanel *menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening)
#define FILE_X
HudScript HES_OptionMonoOff_es
HudScript HES_OptionStereoOff_de
void filemenu_main_update(MenuPanel *menu)
HudScript HES_OptionMonoOn_fr
void filemenu_draw_contents_mono(MenuPanel *menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening)
u8 filemenu_main_gridData[]
HudScript HES_OptionMonoOn_de
#define CENTER_CANCEL_X
HudScript * filemenu_main_hudElemScripts[][20]
HudScript HES_Spirit7Missing
HudScript HES_OptionMonoOff_fr
HudScript HES_OptionStereoOff
void filemenu_draw_contents_file_3_info(MenuPanel *menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening)
b32 fio_load_game(s32 saveSlot)
Definition fio.c:167
void fio_save_game(s32 saveSlot)
Definition fio.c:184
SaveFileSummary gSaveSlotSummary[4]
SaveSlotMetadata gSaveSlotMetadata[4]
void set_window_update(s32 panelID, s32)
Definition windows.c:434
void filemenu_set_cursor_goal_pos(s32 windowIndex, s32 posX, s32 posY)
void setup_pause_menu_tab(MenuWindowBP *bpArray, s32 arraySize)
Definition windows.c:461
u8 * filemenu_get_menu_message(s32 idx)
void filemenu_set_selected(MenuPanel *menu, s32 col, s32 row)
void draw_number(s32 value, s32 x, s32 y, s32 variableWidthChars, s32 palette, s32 opacity, u16 style)
Definition msg.c:2223
void set_game_mode(s32 modeID)
Definition game_modes.c:127
@ GAME_MODE_END_FILE_SELECT
Definition game_modes.h:20
void hud_element_draw_without_clipping(s32 id)
void hud_element_draw_next(s32 id)
void hud_element_set_render_pos(s32 id, s32 x, s32 y)
s32 hud_element_create(HudScript *anim)
Creates a new HUD element and returns its ID.
void hud_element_set_flags(s32 id, s32 flags)
Turns on the given flags.
void hud_element_free(s32 id)
@ HUD_ELEMENT_FLAG_80
Definition hud_element.h:80
s32 HudScript[]
Definition hud_element.h:9
void sfx_play_sound(s32 soundID)
Definition sfx.c:517
#define SCREEN_WIDTH
Definition macros.h:105
#define BSS
Definition macros.h:7
#define ARRAY_COUNT(arr)
Definition macros.h:40
#define MENU_PANEL_SELECTED_GRID_DATA(panel)
Definition macros.h:76
MenuPanel * tab
u8 * dx_string_to_msg(u8 *msg, const u8 *str)
Definition utils.c:16
#define gCurrentLanguage
Definition variables.h:115
GameStatus * gGameStatusPtr
Definition main_loop.c:32
WindowStyle gWindowStyles[]
Definition windows.c:25
Window gWindows[64]
Definition windows.c:23