Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
filemenu_createfile.c
Go to the documentation of this file.
1#include "common.h"
2#include "filemenu.h"
3#include "hud_element.h"
4
8
12
14
15#if VERSION_PAL
16#define WINDOW_1_Y (0)
17#define WINDOW_2_Y (55)
18#define WINDOW_2_HEIGHT (133)
19#define ROWS (8)
20extern u8 D_filemenu_80250958[];
21extern u8 D_filemenu_80250960[];
22#else
23#define WINDOW_1_Y (10)
24#define WINDOW_2_Y (67)
25#define WINDOW_2_HEIGHT (113)
26#define ROWS (6)
27#endif
28
30 {
32 .unk_01 = 0,
33 .pos = { .x = 68, .y = WINDOW_1_Y },
34 .width = 164,
35 .height = 46,
36 .priority = WINDOW_PRIORITY_64,
38 .tab = nullptr,
39 .parentID = WIN_FILES_MAIN,
40 .fpUpdate = { WINDOW_UPDATE_HIDE },
41 .extraFlags = 0,
42 .style = { .customStyle = &filemenu_windowStyles[21] }
43 },
44 {
45 .windowID = WIN_FILES_INPUT_KEYBOARD,
46 .unk_01 = 0,
47 .pos = { .x = 12, .y = WINDOW_2_Y },
48 .width = 262,
49 .height = WINDOW_2_HEIGHT,
50 .priority = WINDOW_PRIORITY_64,
51 .fpDrawContents = &filemenu_draw_contents_choose_name,
52 .tab = nullptr,
53 .parentID = WIN_FILES_MAIN,
54 .fpUpdate = { WINDOW_UPDATE_HIDE },
55 .extraFlags = 0,
56 .style = { .customStyle = &filemenu_windowStyles[22] }
57 },
58};
59
61 .initialized = false,
62 .col = 0,
63 .row = 0,
64 .selected = 0,
65 .state = 0,
66 .numCols = 13,
67 .numRows = ROWS,
68 .numPages = 0,
71 .fpHandleInput = &filemenu_choose_name_handle_input,
72 .fpUpdate = &filemenu_choose_name_update,
74};
75
78 s32* flags,
79 s32* posX, s32* posY, s32* posZ,
80 f32* scaleX, f32* scaleY,
81 f32* rotX, f32* rotY, f32* rotZ,
82 s32* darkening,
83 s32* opacity
84) {
86
87 if (window->updateCounter == 8) {
90 }
91}
92
96 s32 width, s32 height,
97 s32 opacity, s32 darkening
98) {
99#if VERSION_PAL
101 s32 yOffset;
102 s32 xOffset;
103 s32 i;
104
106 filemenu_draw_file_name(filemenu_filename, 8, baseX + temp_s2 + 2, baseY + 22, 255, 0, 0, 11);
107 yOffset = 41;
108
109 for (i = 0; i < ARRAY_COUNT(filemenu_filename); i++) {
110 xOffset = temp_s2 + 6 + i * 11;
112 if (i == 0) {
114 } else {
116 }
117 }
118
120 if (filemenu_filename_pos == 8) {
121 xOffset = temp_s2 + 86;
122 } else {
123 xOffset = temp_s2 + 9 + filemenu_filename_pos * 11;
124 }
125 yOffset = 45;
128 }
129#else
130 s32 xOffset;
131 s32 i;
132
134 filemenu_draw_file_name(filemenu_filename, 8, baseX + 36, baseY + 22, 255, 0, 0, 11);
135 xOffset = 41;
136
137 for (i = 0; i < ARRAY_COUNT(filemenu_filename); i++) {
138 hud_element_set_render_pos(filemenu_createfile_HIDs[1], baseX + 42 + (i * 11), baseY + xOffset);
139 if (i == 0) {
141 } else {
143 }
144 }
145
147 s32 phi_v0 = 122;
148
149 if (filemenu_filename_pos != 8) {
150 phi_v0 = (filemenu_filename_pos * 11) + 45;
151 }
154 }
155#endif
156}
157
158#if VERSION_PAL
159INCLUDE_ASM(void, "filemenu/filemenu_createfile", filemenu_draw_contents_choose_name);
160#else
162
163#if VERSION_PAL
164#define KEYBOARD_ROW_HEIGHT 15
165#define FILEMENU_C9_OFFSET 16
166#else
167#define KEYBOARD_ROW_HEIGHT 17
168#define FILEMENU_C9_OFFSET 5
169#endif
170#define KEYBOARD_COL_WIDTH 19
171
175 s32 width, s32 height,
176 s32 opacity, s32 darkening
177) {
181 s32 page;
182 s32 row, col;
183 s32 xOffset, yOffset;
185 s32 layer;
186 s32 flags;
187 s32 color;
188 s32 xNudge;
190
191 if ((window->flags & WINDOW_FLAG_INITIAL_ANIMATION) && window->fpUpdate.func == filemenu_update_change_layout) {
193 currentPage = menu->state;
194 previousPage = menu->state != 1;
195 if (changeLayoutOffset > 16) {
197 }
198
199 for (row = 0; row < menu->numRows; row++) {
200 for (layer = 0; layer < 2; layer++) {
201 yOffset = 15 * row + 4;
202 if (layer == 0) {
205 baseX,
206 baseY + yOffset,
207 baseX + width,
208 baseY + yOffset + changeLayoutOffset);
209 } else {
212 baseX,
213 baseY + yOffset + changeLayoutOffset,
214 baseX + width,
215 baseY + yOffset + 16);
216 }
217
218 for (col = 0; col < menu->numCols; col++) {
219 c = menu->gridData[page * menu->numCols * menu->numRows + menu->numCols * row + col];
220 if (c != MSG_CHAR_MENU_SPACE) {
221 if (col == menu->col && row == menu->row) {
222 flags = 8;
223 color = 0;
224 } else {
225 flags = 0;
226 color = 10;
227 }
228 xOffset = KEYBOARD_COL_WIDTH * col + 12;
229 yOffset = KEYBOARD_ROW_HEIGHT * row + 5;
230#if VERSION_PAL
231 xNudge = msg_get_print_char_width(c, 0, 0, 1.0f, 0, 1);
232#endif
233 specialChar = c;
234 if (c >= 0xA2 && c < 0xF0) {
235 if (c >= MSG_CHAR_MENU_SPACE) {
236 hud_element_set_render_pos(filemenu_createfile_HIDs[2], baseX + xOffset + 22, baseY + yOffset + 8);
238 flags = 0;
239 }
240 }
242 xOffset--;
243 }
245#if VERSION_PAL
246 xOffset += 16;
247#else
248 xOffset += 5;
249#endif
250 }
252#if VERSION_PAL
254 xOffset += 4;
255 } else {
256 xOffset += 8;
257 }
258#else
259 xOffset += 8;
260#endif
261 }
263 yOffset--;
264 xNudge = 9;
265 }
266#if VERSION_PAL
267 filemenu_draw_message((u8*)c, baseX + xOffset + ((8 - xNudge) / 2), baseY + yOffset, 255, color, flags);
268#else
269 filemenu_draw_message((u8*)c, baseX + xOffset, baseY + yOffset, 255, color, flags);
270#endif
271 }
272 }
273 }
274 }
276 } else {
277 for (col = 0; col < menu->numCols; col++) {
278 for (row = 0; row < menu->numRows; row++) {
279 c = menu->gridData[menu->state * menu->numCols * menu->numRows + menu->numCols * row + col];
280 if (c != MSG_CHAR_MENU_SPACE) {
281 if (col == menu->col && row == menu->row) {
282 flags = 8;
283 color = 0;
284 } else {
285 flags = 0;
286 color = 10;
287 }
288 xOffset = col * KEYBOARD_COL_WIDTH + 12;
289 yOffset = row * KEYBOARD_ROW_HEIGHT + 5;
290#if VERSION_PAL
291 xNudge = msg_get_print_char_width(c, 0, 0, 1.0f, 0, 1);
292#endif
293 specialChar = c;
294 if (c >= 0xA2 && c < 0xF0) {
295 if (c >= MSG_CHAR_MENU_SPACE) {
296 hud_element_set_render_pos(filemenu_createfile_HIDs[2], baseX + xOffset + 22, baseY + yOffset + 8);
298 flags = 0;
299 }
300 }
302 xOffset--;
303 }
305 xOffset += FILEMENU_C9_OFFSET;
306 }
308#if VERSION_PAL
310 xOffset += 4;
311 } else {
312 xOffset += 8;
313 }
314#else
315 xOffset += 8;
316#endif
317 }
319 yOffset--;
320 xNudge = 9;
321 }
322#if VERSION_PAL
323 filemenu_draw_message((u8*)c, baseX + xOffset + ((8 - xNudge) / 2), baseY + yOffset, 255, color, flags);
324#else
325 filemenu_draw_message((u8*)c, baseX + xOffset, baseY + yOffset, 255, color, flags);
326#endif
327 }
328 }
329 }
330 }
331
334 D_8024A18C = -4;
335 }
336 D_8024A18C++;
338 baseX + 2 + menu->col * KEYBOARD_COL_WIDTH,
339 baseY + 13 + menu->row * KEYBOARD_ROW_HEIGHT);
340 }
341}
342#endif
343
363
365 s32 prevSelected = menu->selected;
366 s32 i;
367
368#if VERSION_PAL
371#endif
372
374 menu->col--;
375 if (menu->col < 0) {
376 menu->col = menu->numCols - 1;
377 }
379 menu->col++;
380 if (menu->col >= menu->numCols) {
381 menu->col = 0;
382 }
383 if (menu->row == menu->numRows - 1) {
384 if (menu->col > 10) {
385 menu->col = 0;
386 } else if (menu->col == 8 || menu->col == 9) {
387 menu->col = 10;
388 }
389#if !VERSION_PAL
390 else if (menu->col == 5 || menu->col == 6) {
391 menu->col = 7;
392 }
393#endif
394 }
395 }
396
398 menu->row--;
399 if (menu->row < 0) {
400 menu->row = menu->numRows - 1;
401 }
403 menu->row++;
404 if (menu->row >= menu->numRows) {
405 menu->row = 0;
406 }
407 }
408
409 if (menu->row == menu->numRows - 1) {
410 if (menu->col > 10) {
411 menu->col = 10;
412 } else if (menu->col == 8 || menu->col == 9) {
413 menu->col = 7;
414 }
415#if !VERSION_PAL
416 else if (menu->col == 5 || menu->col == 6) {
417 menu->col = 4;
418 }
419#endif
420 }
421
423 if (prevSelected != menu->selected) {
425 }
426
428 switch (menu->selected) {
433 }
438 }
439 break;
441 if (menu->state != FM_INPUT_CHARSET_B) {
443 menu->state = FM_INPUT_CHARSET_B;
444 filemenu_set_selected(menu, menu->col, menu->row);
446 }
447 break;
449 if (menu->state != FM_INPUT_CHARSET_A) {
451 menu->state = FM_INPUT_CHARSET_A;
452 filemenu_set_selected(menu, menu->col, menu->row);
454 }
455 break;
457 // handled later to combine with B-input detection
458 break;
460 for (i = 0; i < ARRAY_COUNT(filemenu_filename); i++) {
462 break;
463 }
464 }
465 if (i == ARRAY_COUNT(filemenu_filename)) {
467 break;
468 }
469
476
477#if VERSION_PAL
479#else
481#endif
485
489 return;
490 default:
493 filemenu_filename[7] = menu->selected;
494 } else {
499 }
500 }
501 break;
502 }
503
504 if (menu->selected != MSG_CHAR_MENU_USE_CHARSET_A
505 && menu->selected != MSG_CHAR_MENU_USE_CHARSET_B
506 && menu->selected != MSG_CHAR_MENU_BACK
508 ) {
509 filemenu_set_selected(menu, menu->numCols - 3, menu->numRows - 1);
510 }
511 }
512
516 if (filemenu_filename_pos < 0) {
532 return;
533 }
534
537 }
538 }
539
541 for (i = 0; i < ARRAY_COUNT(filemenu_filename); i++) {
543 break;
544 }
545 }
546 if (i == ARRAY_COUNT(filemenu_filename)) {
548 return;
549
550 }
551
554
559
560#if VERSION_PAL
562#else
564#endif
568
572 }
573}
574
577
579 s32 i;
580
581 for (i = 0; i < 3; i++) {
583 }
584}
BSS s32 PopupMenu_SelectedIndex
s8 flags
Definition demo_api.c:15
@ BUTTON_A
Definition enums.h:2776
@ BUTTON_START
Definition enums.h:2773
@ BUTTON_STICK_UP
Definition enums.h:2777
@ BUTTON_STICK_DOWN
Definition enums.h:2778
@ BUTTON_STICK_LEFT
Definition enums.h:2779
@ BUTTON_STICK_RIGHT
Definition enums.h:2780
@ BUTTON_B
Definition enums.h:2775
@ LANGUAGE_DE
Definition enums.h:5992
@ WINDOW_PRIORITY_64
Definition enums.h:3222
@ WINDOW_UPDATE_SHOW
Definition enums.h:4896
@ WINDOW_UPDATE_HIDE
Definition enums.h:4897
@ WINDOW_FLAG_INITIAL_ANIMATION
Definition enums.h:4581
@ FILE_MESSAGE_ENTER_A_FILE_NAME
Definition enums.h:4960
@ SOUND_CREATE_FILE_MOVE_CURSOR
Definition enums.h:1543
@ SOUND_CREATE_FILE_BACKSPACE
Definition enums.h:1545
@ SOUND_CREATE_FILE_CHANGE_CHARSET
Definition enums.h:1546
@ SOUND_MENU_NEXT
Definition enums.h:703
@ SOUND_CREATE_FILE_SET_CHARACTER
Definition enums.h:1544
@ SOUND_MENU_ERROR
Definition enums.h:936
@ MSG_CHAR_MENU_USE_CHARSET_B
Definition enums.h:5622
@ MSG_CHAR_READ_SPACE
Definition enums.h:5635
@ MSG_CHAR_MENU_SPACE
Definition enums.h:5621
@ MSG_CHAR_MENU_BACK
Definition enums.h:5624
@ MSG_CHAR_MENU_USE_CHARSET_A
Definition enums.h:5623
@ MSG_CHAR_MENU_END
Definition enums.h:5625
@ WIN_FILES_SLOT3_BODY
Definition enums.h:4887
@ WIN_FILES_MAIN
Definition enums.h:4873
@ WIN_FILES_TITLE
Definition enums.h:4874
@ WIN_FILES_OPTION_CENTER
Definition enums.h:4883
@ WIN_FILES_OPTION_RIGHT
Definition enums.h:4884
@ WIN_FILES_STEREO
Definition enums.h:4880
@ WIN_FILES_OPTION_LEFT
Definition enums.h:4882
@ WIN_FILES_INPUT_FIELD
Definition enums.h:4877
@ WIN_FILES_SLOT1_BODY
Definition enums.h:4885
@ WIN_FILES_SLOT2_BODY
Definition enums.h:4886
@ WIN_FILES_INPUT_KEYBOARD
Definition enums.h:4878
@ WIN_FILES_MONO
Definition enums.h:4881
@ WIN_FILES_CONFIRM_PROMPT
Definition enums.h:4875
@ WIN_FILES_CONFIRM_OPTIONS
Definition enums.h:4879
@ WIN_FILES_SLOT4_BODY
Definition enums.h:4888
WindowStyleCustom filemenu_windowStyles[]
void filemenu_draw_file_name(u8 *, s32, s32, s32, s32, s32, s32, s32)
@ FILE_MENU_INPUT_NAME
Definition filemenu.h:21
@ FILE_MENU_CONFIRM
Definition filemenu.h:19
@ FILE_MENU_MAIN
Definition filemenu.h:18
@ FM_INPUT_CHARSET_A
Definition filemenu.h:39
@ FM_CONFIRM_CREATE
Definition filemenu.h:31
@ FM_INPUT_CHARSET_B
Definition filemenu.h:40
s8 filemenu_currentMenu
void filemenu_draw_message(u8 *, s32, s32, s32, s32, u32)
s32 filemenu_heldButtons
#define CENTER_WINDOW_X(id)
Definition filemenu.h:7
MenuPanel * filemenu_menus[]
u8 filemenu_filename[8]
void filemenu_update_show_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)
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)
s8 filemenu_filename_pos
HudElemID filemenu_createfile_HIDs[4]
u8 filemenu_createfile_gridData[]
void filemenu_update_hidden_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)
s32 filemenu_pressedButtons
void filemenu_draw_contents_file_create_header(MenuPanel *menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening)
#define ROWS
#define WINDOW_2_HEIGHT
#define KEYBOARD_ROW_HEIGHT
s32 msg_get_print_char_width(s32 character, s32 charset, s32 variation, f32 msgScale, s32 overrideCharWidth, u8 flags)
Definition msg.c:1580
HudScript HES_FilenameCaret
void filemenu_draw_contents_choose_name(MenuPanel *menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening)
MenuWindowBP filemenu_createfile_windowBPs[]
void filemenu_choose_name_update(MenuPanel *menu)
#define FILEMENU_C9_OFFSET
HudScript * filemenu_createfile_hudScripts[]
MenuPanel filemenu_createfile_menuBP
void filemenu_update_change_layout(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 KEYBOARD_COL_WIDTH
#define WINDOW_2_Y
void filemenu_choose_name_cleanup(MenuPanel *menu)
void filemenu_choose_name_init(MenuPanel *menu)
s32 D_8024A18C
HudScript HES_134F60_135120
void filemenu_choose_name_handle_input(MenuPanel *menu)
#define WINDOW_1_Y
HudScript HES_FilenameSpace
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 hud_element_draw_without_clipping(s32 id)
void hud_element_draw_next(s32 id)
HudElemID hud_element_create(HudScript *anim)
Creates a new HUD element and returns its ID.
void hud_element_set_render_pos(s32 id, s32 x, s32 y)
void hud_element_set_flags(s32 id, s32 flags)
Turns on the given flags.
void hud_element_free(s32 id)
@ HUD_ELEMENT_FLAG_MANUAL_RENDER
Definition hud_element.h:78
s32 HudScript[]
Definition hud_element.h:9
void sfx_play_sound(s32 soundID)
#define ARRAY_COUNT(arr)
Definition macros.h:39
#define MENU_PANEL_SELECTED_GRID_DATA(panel)
Definition macros.h:75
MenuPanel * tab
#define gCurrentLanguage
Definition variables.h:119
Gfx * gMainGfxPos
Definition cam_main.c:14
Window gWindows[64]
Definition windows.c:23