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
13s32 D_8024A18C = -4;
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 = NULL,
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 = NULL,
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
77 s32 windowIdx,
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) {
85 Window* window = &gWindows[windowIdx];
86
87 if (window->updateCounter == 8) {
88 window->flags &= ~WINDOW_FLAG_INITIAL_ANIMATION;
90 }
91}
92
94 MenuPanel* menu,
95 s32 baseX, s32 baseY,
96 s32 width, s32 height,
97 s32 opacity, s32 darkening
98) {
99#if VERSION_PAL
100 s32 temp_s2 = D_filemenu_8025095C[gCurrentLanguage]; // 36
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;
111 hud_element_set_render_pos(filemenu_createfile_hudElems[1], baseX + xOffset, baseY + yOffset);
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;
126 hud_element_set_render_pos(filemenu_createfile_hudElems[0], baseX + xOffset, baseY + yOffset);
128 }
129#else
130 s32 xOffset;
131 s32 yOffset;
132 s32 i;
133
135 filemenu_draw_file_name(filemenu_filename, 8, baseX + 36, baseY + 22, 255, 0, 0, 11);
136 xOffset = 41;
137
138 for (i = 0; i < ARRAY_COUNT(filemenu_filename); i++) {
139 hud_element_set_render_pos(filemenu_createfile_hudElems[1], baseX + 42 + (i * 11), baseY + xOffset);
140 if (i == 0) {
142 } else {
144 }
145 }
146
148 s32 phi_v0 = 122;
149
150 if (filemenu_filename_pos != 8) {
151 phi_v0 = (filemenu_filename_pos * 11) + 45;
152 }
153 hud_element_set_render_pos(filemenu_createfile_hudElems[0], baseX + phi_v0, baseY + 45);
155 }
156#endif
157}
158
159#if VERSION_PAL
160INCLUDE_ASM(void, "filemenu/filemenu_createfile", filemenu_draw_contents_choose_name);
161#else
162s32 msg_get_print_char_width(s32 character, s32 charset, s32 variation, f32 msgScale, s32 overrideCharWidth, u8 flags);
163
164#if VERSION_PAL
165#define KEYBOARD_ROW_HEIGHT 15
166#define FILEMENU_C9_OFFSET 16
167#else
168#define KEYBOARD_ROW_HEIGHT 17
169#define FILEMENU_C9_OFFSET 5
170#endif
171#define KEYBOARD_COL_WIDTH 19
172
174 MenuPanel* menu,
175 s32 baseX, s32 baseY,
176 s32 width, s32 height,
177 s32 opacity, s32 darkening
178) {
179 s32 changeLayoutOffset;
180 s32 currentPage;
181 s32 previousPage;
182 s32 page;
183 s32 row, col;
184 s32 xOffset, yOffset;
185 s32 c, specialChar;
186 s32 layer;
187 s32 flags;
188 s32 color;
189 s32 xNudge;
191
193 changeLayoutOffset = window->updateCounter * 2;
194 currentPage = menu->state;
195 previousPage = menu->state != 1;
196 if (changeLayoutOffset > 16) {
197 changeLayoutOffset = 16;
198 }
199
200 for (row = 0; row < menu->numRows; row++) {
201 for (layer = 0; layer < 2; layer++) {
202 yOffset = 15 * row + 4;
203 if (layer == 0) {
204 page = currentPage;
205 gDPSetScissor(gMainGfxPos++, G_SC_NON_INTERLACE,
206 baseX,
207 baseY + yOffset,
208 baseX + width,
209 baseY + yOffset + changeLayoutOffset);
210 } else {
211 page = previousPage;
212 gDPSetScissor(gMainGfxPos++, G_SC_NON_INTERLACE,
213 baseX,
214 baseY + yOffset + changeLayoutOffset,
215 baseX + width,
216 baseY + yOffset + 16);
217 }
218
219 for (col = 0; col < menu->numCols; col++) {
220 c = menu->gridData[page * menu->numCols * menu->numRows + menu->numCols * row + col];
221 if (c != MSG_CHAR_MENU_SPACE) {
222 if (col == menu->col && row == menu->row) {
223 flags = 8;
224 color = 0;
225 } else {
226 flags = 0;
227 color = 10;
228 }
229 xOffset = KEYBOARD_COL_WIDTH * col + 12;
230 yOffset = KEYBOARD_ROW_HEIGHT * row + 5;
231#if VERSION_PAL
232 xNudge = msg_get_print_char_width(c, 0, 0, 1.0f, 0, 1);
233#endif
234 specialChar = c;
235 if (c >= 0xA2 && c < 0xF0) {
236 if (c >= MSG_CHAR_MENU_SPACE) {
237 hud_element_set_render_pos(filemenu_createfile_hudElems[2], baseX + xOffset + 22, baseY + yOffset + 8);
239 flags = 0;
240 }
241 }
242 if (specialChar == MSG_CHAR_MENU_SPACE) {
243 xOffset -= 1;
244 }
245 if (specialChar == MSG_CHAR_MENU_BACK) {
246#if VERSION_PAL
247 xOffset += 16;
248#else
249 xOffset += 5;
250#endif
251 }
252 if (specialChar == MSG_CHAR_MENU_END) {
253#if VERSION_PAL
255 xOffset += 4;
256 } else {
257 xOffset += 8;
258 }
259#else
260 xOffset += 8;
261#endif
262 }
263 if (specialChar == MSG_CHAR_MENU_SPACE || specialChar == MSG_CHAR_MENU_BACK || specialChar == MSG_CHAR_MENU_END) {
264 yOffset -= 1;
265 xNudge = 9;
266 }
267#if VERSION_PAL
268 filemenu_draw_message((u8*)c, baseX + xOffset + ((8 - xNudge) / 2), baseY + yOffset, 255, color, flags);
269#else
270 filemenu_draw_message((u8*)c, baseX + xOffset, baseY + yOffset, 255, color, flags);
271#endif
272 }
273 }
274 }
275 }
276 gDPSetScissor(gMainGfxPos++, G_SC_NON_INTERLACE, baseX, baseY, baseX + width, baseY + height);
277 } else {
278 for (col = 0; col < menu->numCols; col++) {
279 for (row = 0; row < menu->numRows; row++) {
280 c = menu->gridData[menu->state * menu->numCols * menu->numRows + menu->numCols * row + col];
281 if (c != MSG_CHAR_MENU_SPACE) {
282 if (col == menu->col && row == menu->row) {
283 flags = 8;
284 color = 0;
285 } else {
286 flags = 0;
287 color = 10;
288 }
289 xOffset = col * KEYBOARD_COL_WIDTH + 12;
290 yOffset = row * KEYBOARD_ROW_HEIGHT + 5;
291#if VERSION_PAL
292 xNudge = msg_get_print_char_width(c, 0, 0, 1.0f, 0, 1);
293#endif
294 specialChar = c;
295 if (c >= 0xA2 && c < 0xF0) {
296 if (c >= MSG_CHAR_MENU_SPACE) {
297 hud_element_set_render_pos(filemenu_createfile_hudElems[2], baseX + xOffset + 22, baseY + yOffset + 8);
299 flags = 0;
300 }
301 }
302 if (specialChar == MSG_CHAR_MENU_SPACE) {
303 xOffset -= 1;
304 }
305 if (specialChar == MSG_CHAR_MENU_BACK) {
306 xOffset += FILEMENU_C9_OFFSET;
307 }
308 if (specialChar == MSG_CHAR_MENU_END) {
309#if VERSION_PAL
311 xOffset += 4;
312 } else {
313 xOffset += 8;
314 }
315#else
316 xOffset += 8;
317#endif
318 }
319 if (specialChar == MSG_CHAR_MENU_SPACE || specialChar == MSG_CHAR_MENU_BACK || specialChar == MSG_CHAR_MENU_END) {
320 yOffset -= 1;
321 xNudge = 9;
322 }
323#if VERSION_PAL
324 filemenu_draw_message((u8*)c, baseX + xOffset + ((8 - xNudge) / 2), baseY + yOffset, 255, color, flags);
325#else
326 filemenu_draw_message((u8*)c, baseX + xOffset, baseY + yOffset, 255, color, flags);
327#endif
328 }
329 }
330 }
331 }
332
335 D_8024A18C = -4;
336 }
337 D_8024A18C++;
339 baseX + 2 + menu->col * KEYBOARD_COL_WIDTH,
340 baseY + 13 + menu->row * KEYBOARD_ROW_HEIGHT);
341 }
342}
343#endif
344
365
367 s32 prevSelected = menu->selected;
368 s32 i;
369
370#if VERSION_PAL
373#endif
374
376 menu->col--;
377 if (menu->col < 0) {
378 menu->col = menu->numCols - 1;
379 }
381 menu->col++;
382 if (menu->col >= menu->numCols) {
383 menu->col = 0;
384 }
385 if (menu->row == menu->numRows - 1) {
386 if (menu->col > 10) {
387 menu->col = 0;
388 } else if (menu->col == 8 || menu->col == 9) {
389 menu->col = 10;
390 }
391#if !VERSION_PAL
392 else if (menu->col == 5 || menu->col == 6) {
393 menu->col = 7;
394 }
395#endif
396 }
397 }
398
400 menu->row--;
401 if (menu->row < 0) {
402 menu->row = menu->numRows - 1;
403 }
405 menu->row++;
406 if (menu->row >= menu->numRows) {
407 menu->row = 0;
408 }
409 }
410
411 if (menu->row == menu->numRows - 1) {
412 if (menu->col > 10) {
413 menu->col = 10;
414 } else if (menu->col == 8 || menu->col == 9) {
415 menu->col = 7;
416 }
417#if !VERSION_PAL
418 else if (menu->col == 5 || menu->col == 6) {
419 menu->col = 4;
420 }
421#endif
422 }
423
425 if (prevSelected != menu->selected) {
427 }
428
430 switch (menu->selected) {
435 }
440 }
441 break;
443 if (menu->state != FM_INPUT_CHARSET_B) {
446 filemenu_set_selected(menu, menu->col, menu->row);
448 }
449 break;
451 if (menu->state != FM_INPUT_CHARSET_A) {
454 filemenu_set_selected(menu, menu->col, menu->row);
456 }
457 break;
459 // handled later to combine with B-input detection
460 break;
462 for (i = 0; i < ARRAY_COUNT(filemenu_filename); i++) {
464 break;
465 }
466 }
467 if (i == ARRAY_COUNT(filemenu_filename)) {
469 break;
470 }
471
478
479#if VERSION_PAL
481#else
483#endif
487
491 return;
492 default:
495 filemenu_filename[7] = menu->selected;
496 } else {
501 }
502 }
503 break;
504 }
505
508 && menu->selected != MSG_CHAR_MENU_BACK
510 ) {
511 filemenu_set_selected(menu, menu->numCols - 3, menu->numRows - 1);
512 }
513 }
514
518 if (filemenu_filename_pos < 0) {
534 return;
535 }
536
539 }
540 }
541
543 for (i = 0; i < ARRAY_COUNT(filemenu_filename); i++) {
545 break;
546 }
547 }
548 if (i == ARRAY_COUNT(filemenu_filename)) {
550 return;
551
552 }
553
556
561
562#if VERSION_PAL
564#else
566#endif
570
574 }
575}
576
579
581 s32 i;
582
583 for (i = 0; i < 3; i++) {
585 }
586}
s8 flags
Definition demo_api.c:15
@ BUTTON_A
Definition enums.h:2790
@ BUTTON_START
Definition enums.h:2787
@ 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
@ LANGUAGE_DE
Definition enums.h:6401
@ WINDOW_PRIORITY_64
Definition enums.h:3188
@ WINDOW_UPDATE_SHOW
Definition enums.h:5311
@ WINDOW_UPDATE_HIDE
Definition enums.h:5312
@ WINDOW_FLAG_INITIAL_ANIMATION
Definition enums.h:4996
@ FILE_MESSAGE_ENTER_A_FILE_NAME
Definition enums.h:5375
@ SOUND_CREATE_FILE_MOVE_CURSOR
Definition enums.h:1540
@ SOUND_CREATE_FILE_BACKSPACE
Definition enums.h:1542
@ SOUND_CREATE_FILE_CHANGE_CHARSET
Definition enums.h:1543
@ SOUND_MENU_NEXT
Definition enums.h:700
@ SOUND_CREATE_FILE_SET_CHARACTER
Definition enums.h:1541
@ SOUND_MENU_ERROR
Definition enums.h:933
@ MSG_CHAR_MENU_USE_CHARSET_B
Definition enums.h:6037
@ MSG_CHAR_READ_SPACE
Definition enums.h:6050
@ MSG_CHAR_MENU_SPACE
Definition enums.h:6036
@ MSG_CHAR_MENU_BACK
Definition enums.h:6039
@ MSG_CHAR_MENU_USE_CHARSET_A
Definition enums.h:6038
@ MSG_CHAR_MENU_END
Definition enums.h:6040
@ WIN_FILES_SLOT3_BODY
Definition enums.h:5302
@ WIN_FILES_MAIN
Definition enums.h:5288
@ WIN_FILES_TITLE
Definition enums.h:5289
@ 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_INPUT_FIELD
Definition enums.h:5292
@ WIN_FILES_SLOT1_BODY
Definition enums.h:5300
@ 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_INPUT_CHARSET_A
Definition filemenu.h:38
@ FM_CONFIRM_CREATE
Definition filemenu.h:30
@ FM_INPUT_CHARSET_B
Definition filemenu.h:39
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_createfile_hudElems[4]
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)
@ FILE_MENU_INPUT_NAME
Definition filemenu.h:20
@ FILE_MENU_CONFIRM
Definition filemenu.h:18
@ FILE_MENU_MAIN
Definition filemenu.h:17
s8 filemenu_filename_pos
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)
HudScript * filemenu_createfile_hudElemScripts[]
#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:1578
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
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)
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
#define INCLUDE_ASM(TYPE, FOLDER, NAME, ARGS...)
Definition include_asm.h:21
void sfx_play_sound(s32 soundID)
Definition sfx.c:517
#define ARRAY_COUNT(arr)
Definition macros.h:40
#define MENU_PANEL_SELECTED_GRID_DATA(panel)
Definition macros.h:76
MenuPanel * tab
WindowUpdateFunc fpUpdate
void(* func)(s32 windowIndex, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
#define gCurrentLanguage
Definition variables.h:115
Gfx * gMainGfxPos
Definition cam_main.c:15
Window gWindows[64]
Definition windows.c:23