Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
windows.c File Reference

Go to the source code of this file.

Data Structures

struct  SimpleWindowUpdateData
 
struct  WindowGroup
 

Enumerations

enum  SimpleWindowUpdateFlags { SIMPLE_WINDOW_UPDATE_1 = 0x1 , SIMPLE_WINDOW_UPDATE_OPACITY = 0x2 , SIMPLE_WINDOW_UPDATE_DARKENING = 0x4 }
 

Functions

void clear_windows (void)
 
void update_windows (void)
 
void basic_window_update (s32 windowID, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
 
void basic_hidden_window_update (s32 windowID, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
 
void unused_main_menu_window_darkening (s32 windowID, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
 
void render_windows (s32 *windowsArray, s32 parent, s32 flags, s32 baseX, s32 baseY, s32 opacity, s32 darkening, f32(*rotScaleMtx)[4])
 
void render_window_root (void)
 
void set_window_properties (s32 windowID, s32 posX, s32 posY, s32 width, s32 height, u8 priority, void *fpDrawContents, void *drawContentsArg0, s8 parent)
 
void update_window_hierarchy (s32 windowID, u8 priority)
 
void replace_window_update (s32 windowID, s8 priority, WindowUpdateFunc pendingFunc)
 
void set_window_update (s32 windowID, s32 func)
 
void set_windows_visible (s32 groupIdx)
 
void setup_pause_menu_tab (MenuWindowBP *bp, s32 count)
 

Variables

Window gWindows [64]
 
WindowStyle gWindowStyles [64]
 
SimpleWindowUpdateData gSimpleWindowUpdates []
 
u8 gWindowAppearScales [] = { 50, 80, 100, 105, 100 }
 
u8 gWindowAppearFlags [] = { DRAW_FLAG_ROTSCALE, DRAW_FLAG_ROTSCALE, DRAW_FLAG_ROTSCALE, DRAW_FLAG_ROTSCALE, 0}
 
u8 gWindowDisappearScales [] = { 105, 100, 77, 57, 40, 27, 16, 8, 3, 0 }
 
u8 gWindowDisappearFlags []
 
WindowGroup gWindowGroups []
 

Data Structure Documentation

◆ SimpleWindowUpdateData

struct SimpleWindowUpdateData
Data Fields
u8 flags
u8 windowFlagsSet
u8 windowFlagsUnset
u8 darkening
u8 opacity

◆ WindowGroup

struct WindowGroup
Data Fields
u8 min
u8 max

Enumeration Type Documentation

◆ SimpleWindowUpdateFlags

Enumerator
SIMPLE_WINDOW_UPDATE_1 
SIMPLE_WINDOW_UPDATE_OPACITY 
SIMPLE_WINDOW_UPDATE_DARKENING 

Definition at line 4 of file windows.c.

4 {
8};
@ SIMPLE_WINDOW_UPDATE_OPACITY
Definition windows.c:6
@ SIMPLE_WINDOW_UPDATE_DARKENING
Definition windows.c:7
@ SIMPLE_WINDOW_UPDATE_1
Definition windows.c:5

Function Documentation

◆ clear_windows()

void clear_windows ( void )

Definition at line 135 of file windows.c.

135 {
136 s32 i;
137
138 for (i = 0; i < ARRAY_COUNT(gWindows); i++) {
139 gWindows[i].flags = 0;
140 }
141}
#define ARRAY_COUNT(arr)
Definition macros.h:40
Window gWindows[64]
Definition windows.c:23

Referenced by load_engine_data(), state_step_startup(), and state_step_title_screen().

◆ update_windows()

void update_windows ( void )

Definition at line 143 of file windows.c.

143 {
144 s32 i;
145
146 for (i = 0; i < ARRAY_COUNT(gWindows); i++) {
147 u8 flags = gWindows[i].flags;
148
149 if (!flags || (flags & WINDOW_FLAG_DISABLED)) {
150 continue;
151 }
152
156 gWindows[i].updateCounter = 0;
157 }
158 }
159}
BSS s32 PopupMenu_SelectedIndex
s8 flags
Definition demo_api.c:15
@ WINDOW_FLAG_DISABLED
Not updated or rendered.
Definition enums.h:4997
@ WINDOW_FLAG_FPUPDATE_CHANGED
Definition enums.h:4993
WindowUpdateFunc fpPending
WindowUpdateFunc fpUpdate

Referenced by step_game_loop().

◆ basic_window_update()

void basic_window_update ( s32 windowID,
s32 * flags,
s32 * posX,
s32 * posY,
s32 * posZ,
f32 * scaleX,
f32 * scaleY,
f32 * rotX,
f32 * rotY,
f32 * rotZ,
s32 * darkening,
s32 * opacity )

Definition at line 161 of file windows.c.

162 {
163 Window* window = &gWindows[windowID];
165
166 if (counter == 0) {
167 window->flags &= ~WINDOW_FLAG_HIDDEN;
168 }
169
170 if (counter <= 4) {
172 *scaleX = (f32)gWindowAppearScales[counter] * 0.01;
173 *scaleY = (f32)gWindowAppearScales[counter] * 0.01;
174 *rotZ = (4 - counter) * 3;
175 } else {
177 *scaleX = 1.0f;
178 *scaleY = 1.0f;
179 *rotZ = 0.0f;
181 }
182}
u8 gWindowAppearScales[]
Definition windows.c:121
u8 gWindowAppearFlags[]
Definition windows.c:122

Referenced by draw_shop_items(), func_800F16CC(), pause_tabs_update(), popup_menu_update(), show_coin_counter(), and update_item_entity_pickup().

◆ basic_hidden_window_update()

void basic_hidden_window_update ( s32 windowID,
s32 * flags,
s32 * posX,
s32 * posY,
s32 * posZ,
f32 * scaleX,
f32 * scaleY,
f32 * rotX,
f32 * rotY,
f32 * rotZ,
s32 * darkening,
s32 * opacity )

Definition at line 184 of file windows.c.

185 {
186 Window* window = &gWindows[windowID];
188
189 if (counter <= 9) {
191 *scaleX = (f32)gWindowDisappearScales[counter] * 0.01;
192 *scaleY = (f32)gWindowDisappearScales[counter] * 0.01;
193 *rotZ = -counter;
194 } else {
196 *scaleX = 0.0f;
197 *scaleY = 0.0f;
198 *rotZ = 0.0f;
200 window->flags |= WINDOW_FLAG_HIDDEN;
201 }
202}
@ WINDOW_FLAG_HIDDEN
Updated but not rendered.
Definition enums.h:4994
u8 gWindowDisappearScales[]
Definition windows.c:123
u8 gWindowDisappearFlags[]
Definition windows.c:124

Referenced by draw_shop_items(), hide_popup_menu(), update_coin_counter(), and update_item_entity_pickup().

◆ unused_main_menu_window_darkening()

void unused_main_menu_window_darkening ( s32 windowID,
s32 * flags,
s32 * posX,
s32 * posY,
s32 * posZ,
f32 * scaleX,
f32 * scaleY,
f32 * rotX,
f32 * rotY,
f32 * rotZ,
s32 * darkening,
s32 * opacity )

Definition at line 204 of file windows.c.

205 {
206 Window* window = &gWindows[windowID];
208
209 if (counter < 10) {
210 *darkening = (counter + 1) * 16;
211 } else {
212 *darkening = 160;
214 }
215}
@ WINDOW_FLAG_INITIAL_ANIMATION
Definition enums.h:4995

◆ render_windows()

void render_windows ( s32 * windowsArray,
s32 parent,
s32 flags,
s32 baseX,
s32 baseY,
s32 opacity,
s32 darkening,
f32(*) rotScaleMtx[4] )

Definition at line 217 of file windows.c.

217 {
218 Window* window;
220 s32 i;
221 s32 childWindowID;
222 s32 counter;
224 f32 (*outMtx)[4];
225 s32 childFlags;
226 s32 posX, posY, posZ;
227 f32 scaleX, scaleY, rotX, rotY, rotZ;
229 s32 boxFlags;
230 s32 boxTranslateX;
231 s32 boxTranslateY;
232 s32 fpUpdateIdx;
233 s32 width, height;
234 s32 (*fpUpdateFunc)(s32 windowIndex, s32* flags, s32* posX, s32* posY, s32* posZ, f32* scaleX, f32* scaleY,
235 f32* rotX, f32* rotY, f32* rotZ, s32* darkening, s32* opacity);
237 void* fpDrawContents;
238 void* drawContentsArg0;
239
240 for (i = 0; i < ARRAY_COUNT(gWindows); i++) {
241 window = &gWindows[parent];
243
244 if (childWindowID < 0) {
245 continue;
246 }
247
249 if (childWindow->flags == 0 || (childWindow->flags & WINDOW_FLAG_DISABLED)) {
250 continue;
251 }
252
254 if (fpUpdateIdx == 0 || childWindow->parent != parent) {
255 continue;
256 }
257
258 counter = childWindow->updateCounter;
259 posX = childWindow->pos.x;
260 posY = childWindow->pos.y;
261 posZ = 0;
262 childFlags = 0;
263 rotX = rotY = rotZ = 0.0f;
264 scaleY = scaleX = 1.0f;
265 childDarkening = 0;
266 childOpacity = 255;
267 width = childWindow->width;
268 height = childWindow->height;
269
270 if (fpUpdateIdx > 0 && fpUpdateIdx < 14) {
272 childWindow->flags |= updateData->windowFlagsSet;
273 childWindow->flags &= ~updateData->windowFlagsUnset;
274
275 if (counter == 0 && (updateData->flags & SIMPLE_WINDOW_UPDATE_1)) {
277 }
279 childDarkening = updateData->darkening;
280 }
282 childOpacity = updateData->opacity;
283 }
284 } else {
285 //type conversion needed for matching
286 fpUpdateFunc = (s32 (*)(s32 windowIndex, s32* flags, s32* posX, s32* posY, s32* posZ, f32* scaleX, f32* scaleY,
287 f32* rotX, f32* rotY, f32* rotZ, s32* darkening, s32* opacity))(childWindow->fpUpdate.func);
288 fpUpdateFunc(childWindowID, &childFlags, &posX, &posY, &posZ, &scaleX, &scaleY, &rotX, &rotY, &rotZ, &childDarkening, &childOpacity);
289 }
290
291 if (childWindow->fpUpdate.i) {
292 if (childWindow->updateCounter < 255) {
293 childWindow->updateCounter++;
294 }
295 }
296
297 if (scaleX == 0 || scaleY == 0 || (childWindow->flags & WINDOW_FLAG_HIDDEN)) {
298 continue;
299 }
300
301 childDarkening += darkening;
302 childOpacity = childOpacity * opacity / 255;
303 fpDrawContents = childWindow->fpDrawContents;
304 drawContentsArg0 = childWindow->drawContentsArg0;
306 outMtx = matrix;
307
308 if (childDarkening > 255) {
309 childDarkening = 255;
310 }
311 childFlags |= flags;
312 if (!(flags & DRAW_FLAG_ROTSCALE)) {
313 posX += baseX;
314 posY += baseY;
315 }
316
317 if (parent == WIN_NONE) {
319 } else {
320 boxTranslateX = window->width;
321 }
322
324 if (parent != WIN_NONE) {
325 boxTranslateY = window->height;
326 }
327
329 if (childWindow->flags & WINDOW_FLAG_40) {
331 }
332
333 if (draw_box(boxFlags, windowStyle, posX, posY, posZ, width, height, childOpacity, childDarkening,
334 scaleX, scaleY, rotX, rotY, rotZ, fpDrawContents, drawContentsArg0, rotScaleMtx,
336 if (childFlags == 0 && rotScaleMtx == 0) {
337 outMtx = NULL;
338 }
339
342 }
343 }
344 }
345}
f32 Matrix4f[4][4]
#define draw_box
@ DRAW_FLAG_ROTSCALE
Definition enums.h:5002
@ DRAW_FLAG_ANIMATED_BACKGROUND
Definition enums.h:5003
@ WINDOW_FLAG_HAS_CHILDREN
Definition enums.h:4996
@ WINDOW_FLAG_40
Definition enums.h:4998
@ WIN_NONE
Definition enums.h:5239
#define SCREEN_WIDTH
Definition macros.h:109
#define SCREEN_HEIGHT
Definition macros.h:110
void update_window_hierarchy(s32 windowID, u8 priority)
Definition windows.c:393
WindowStyle gWindowStyles[64]
Definition windows.c:25
SimpleWindowUpdateData gSimpleWindowUpdates[]
Definition windows.c:44
void render_windows(s32 *windowsArray, s32 parent, s32 flags, s32 baseX, s32 baseY, s32 opacity, s32 darkening, f32(*rotScaleMtx)[4])
Definition windows.c:217

Referenced by render_window_root(), and render_windows().

◆ render_window_root()

◆ set_window_properties()

void set_window_properties ( s32 windowID,
s32 posX,
s32 posY,
s32 width,
s32 height,
u8 priority,
void * fpDrawContents,
void * drawContentsArg0,
s8 parent )

Definition at line 373 of file windows.c.

373 {
374 Window* window = &gWindows[windowID];
375 u8 priorityCopy = priority;
376
378 window->pos.x = posX;
379 window->pos.y = posY;
380 window->width = width;
381 window->fpUpdate.i = 0;
382 window->parent = parent;
383 window->height = height;
384 window->fpDrawContents = fpDrawContents;
385 window->drawContentsArg0 = drawContentsArg0;
386 if (parent >= 0) {
388 }
390 window->originalPriority = priority;
391}
@ WINDOW_FLAG_INITIALIZED
Definition enums.h:4992

Referenced by btl_show_message_popup(), btl_state_update_celebration(), btl_submenu_moves_update(), btl_update_strats_menu(), draw_merlee_message(), func_801363A0(), popup_menu_update(), setup_pause_menu_tab(), and show_coin_counter().

◆ update_window_hierarchy()

void update_window_hierarchy ( s32 windowID,
u8 priority )

Definition at line 393 of file windows.c.

393 {
395 s32 curPriority;
396 s32 i;
397
398 if (priority > ARRAY_COUNT(gWindows)) {
399 priority = ARRAY_COUNT(gWindows);
400 }
401
402 for (i = 0; i < ARRAY_COUNT(priorityArray); i++) {
403 priorityArray[i] = -1;
404 }
405 priorityArray[priority] = windowID;
406
407 for (i = 0; i < ARRAY_COUNT(gWindows); i++) {
408 if (gWindows[i].flags && i != windowID) {
410 if (curPriority >= priority) {
411 curPriority++;
412 }
414 }
415 }
416
417 curPriority = 0;
418 for (i = 0; i < ARRAY_COUNT(priorityArray); i++) {
419 s32 windowIdx = priorityArray[i];
420 if (windowIdx != WIN_NONE) {
422 }
423 }
424}

Referenced by filemenu_init(), pause_init(), pause_update_tab_active(), pause_update_tab_inactive(), render_windows(), and set_window_properties().

◆ replace_window_update()

void replace_window_update ( s32 windowID,
s8 priority,
WindowUpdateFunc pendingFunc )

Definition at line 426 of file windows.c.

426 {
427 if (gWindows[windowID].flags & WINDOW_FLAG_INITIALIZED) {
429 gWindows[windowID].fpPending = pendingFunc;
430 gWindows[windowID].originalPriority = priority;
431 }
432}
u8 originalPriority

Referenced by pause_tabs_handle_input().

◆ set_window_update()

◆ set_windows_visible()

void set_windows_visible ( s32 groupIdx)

Definition at line 445 of file windows.c.

445 {
448 s32 i;
449
450 for (i = 0; i < ARRAY_COUNT(gWindows); i++) {
452 if (i < min || i > max) {
454 } else {
456 }
457 }
458 }
459}
WindowGroup gWindowGroups[]
Definition windows.c:128

Referenced by btl_state_update_end_battle(), btl_state_update_end_demo_battle(), initialize_battle(), state_init_pause(), state_step_exit_file_select(), state_step_file_select(), and state_step_unpause().

◆ setup_pause_menu_tab()

void setup_pause_menu_tab ( MenuWindowBP * bp,
s32 count )

Definition at line 461 of file windows.c.

461 {
462 s32 i;
463
464 for (i = 0; i < count; i++) {
465 set_window_properties(bp->windowID, bp->pos.x, bp->pos.y, bp->width, bp->height, bp->priority,
466 bp->fpDrawContents, bp->tab, bp->parentID);
467 if (bp->style.defaultStyleID != -1) {
468 gWindowStyles[bp->windowID] = bp->style;
469 }
470 set_window_update(bp->windowID, bp->fpUpdate.i);
471 gWindows[bp->windowID].flags |= bp->extraFlags;
472 bp++;
473 }
474}
void set_window_properties(s32 windowID, s32 posX, s32 posY, s32 width, s32 height, u8 priority, void *fpDrawContents, void *drawContentsArg0, s8 parent)
Definition windows.c:373
void set_window_update(s32 windowID, s32 func)
Definition windows.c:434

Referenced by filemenu_choose_name_init(), filemenu_info_init(), filemenu_init(), filemenu_main_init(), filemenu_yesno_init(), pause_badges_init(), pause_init(), pause_items_init(), pause_map_init(), pause_partners_init(), pause_spirits_init(), pause_stats_init(), and pause_tabs_init().

Variable Documentation

◆ gWindows

Window gWindows[64]

Definition at line 23 of file windows.c.

Referenced by basic_hidden_window_update(), basic_window_update(), btl_update_message_popup(), clear_windows(), filemenu_choose_name_handle_input(), filemenu_choose_name_init(), filemenu_cleanup(), filemenu_draw_contents_choose_name(), filemenu_main_handle_input(), filemenu_main_init(), filemenu_set_cursor_goal_pos(), filemenu_update(), filemenu_update_change_layout(), filemenu_update_cursor(), filemenu_update_deselect_file(), filemenu_update_hidden_name_confirm(), filemenu_update_hidden_name_input(), filemenu_update_hidden_options_bottom(), filemenu_update_hidden_options_left(), filemenu_update_hidden_options_right(), filemenu_update_hidden_title(), filemenu_update_hidden_with_rotation(), filemenu_update_select_file(), filemenu_update_show_name_confirm(), filemenu_update_show_name_input(), filemenu_update_show_options_bottom(), filemenu_update_show_options_left(), filemenu_update_show_options_right(), filemenu_update_show_title(), filemenu_update_show_with_rotation(), filemenu_yesno_handle_input(), func_80242FBC(), func_802430E4(), func_8024313C(), func_8024330C(), func_802435C4(), pause_init(), pause_partners_handle_input(), pause_partners_init(), pause_set_cursor_pos(), pause_set_cursor_pos_immediate(), pause_tabs_handle_input(), pause_tabs_init(), pause_tabs_update(), pause_update_page_active_1(), pause_update_page_active_2(), pause_update_page_inactive_1(), pause_update_page_inactive_2(), pause_update_tab_active(), pause_update_tab_default(), pause_update_tab_inactive(), render_window_root(), render_windows(), replace_window_update(), set_window_properties(), set_window_update(), set_windows_visible(), setup_pause_menu_tab(), state_step_exit_file_select(), unused_main_menu_window_darkening(), update_item_entity_pickup(), update_window_hierarchy(), and update_windows().

◆ gWindowStyles

WindowStyle gWindowStyles[64]
Initial value:
= {
}
@ WINDOW_STYLE_13
Definition enums.h:6382
@ WINDOW_STYLE_0
Definition enums.h:6369
@ WINDOW_STYLE_7
Definition enums.h:6376
@ WINDOW_STYLE_12
Definition enums.h:6381
@ WINDOW_STYLE_14
Definition enums.h:6383
@ WINDOW_STYLE_9
Definition enums.h:6378
@ WINDOW_STYLE_21
Definition enums.h:6390
@ WINDOW_STYLE_10
Definition enums.h:6379
@ WINDOW_STYLE_8
Definition enums.h:6377
@ WINDOW_STYLE_11
Definition enums.h:6380
@ WINDOW_STYLE_3
Definition enums.h:6372
@ WINDOW_STYLE_1
Definition enums.h:6370

Definition at line 25 of file windows.c.

Referenced by filemenu_main_update(), render_windows(), and setup_pause_menu_tab().

◆ gSimpleWindowUpdates

SimpleWindowUpdateData gSimpleWindowUpdates[]

Definition at line 44 of file windows.c.

44 {
45 {
46 .flags = 0,
47 .windowFlagsSet = 0,
48 .windowFlagsUnset = WINDOW_FLAG_INITIAL_ANIMATION,
49 .darkening = 0,
50 .opacity = 0
51 },
52 {
53 .flags = 0,
54 .windowFlagsSet = 0,
56 .darkening = 0,
57 .opacity = 0
58 },
59 {
60 .flags = 0,
61 .windowFlagsSet = WINDOW_FLAG_HIDDEN,
62 .windowFlagsUnset = WINDOW_FLAG_INITIAL_ANIMATION,
63 .darkening = 0,
64 .opacity = 0
65 },
66 {
68 .windowFlagsSet = 0,
69 .windowFlagsUnset = WINDOW_FLAG_INITIAL_ANIMATION,
70 .darkening = 0,
71 .opacity = 0
72 },
73 {
75 .windowFlagsSet = 0,
76 .windowFlagsUnset = WINDOW_FLAG_INITIAL_ANIMATION,
77 .darkening = 100,
78 .opacity = 0
79 },
80 {
82 .windowFlagsSet = 0,
83 .windowFlagsUnset = WINDOW_FLAG_INITIAL_ANIMATION,
84 .darkening = 0,
85 .opacity = 0
86 },
87 {
89 .windowFlagsSet = 0,
90 .windowFlagsUnset = WINDOW_FLAG_INITIAL_ANIMATION,
91 .darkening = 0,
92 .opacity = 184
93 },
94 {
96 .windowFlagsSet = 0,
97 .windowFlagsUnset = WINDOW_FLAG_INITIAL_ANIMATION,
98 .darkening = 0,
99 .opacity = 255
100 },
101 {
103 .windowFlagsSet = 0,
105 .darkening = 0,
106 .opacity = 184
107 },
108 {
110 .windowFlagsSet = 0,
112 .darkening = 100,
113 .opacity = 0
114 },
115 {},
116 {},
117 {},
118 {}
119};

Referenced by render_windows().

◆ gWindowAppearScales

u8 gWindowAppearScales[] = { 50, 80, 100, 105, 100 }

Definition at line 121 of file windows.c.

121{ 50, 80, 100, 105, 100 };

Referenced by basic_window_update().

◆ gWindowAppearFlags

◆ gWindowDisappearScales

u8 gWindowDisappearScales[] = { 105, 100, 77, 57, 40, 27, 16, 8, 3, 0 }

Definition at line 123 of file windows.c.

123{ 105, 100, 77, 57, 40, 27, 16, 8, 3, 0 };

Referenced by basic_hidden_window_update().

◆ gWindowDisappearFlags

◆ gWindowGroups

WindowGroup gWindowGroups[]
Initial value:
= {
}
@ WINDOW_GROUP_FILES
Definition enums.h:5325
@ WINDOW_GROUP_BATTLE
Definition enums.h:5323
@ WINDOW_GROUP_ALL
Definition enums.h:5322
@ WINDOW_GROUP_PAUSE
Definition enums.h:5324
@ WIN_UNUSED_0
Definition enums.h:5240
@ WIN_FILES_MAIN
Definition enums.h:5287
@ WIN_PAUSE_TAB_INVIS
Definition enums.h:5285
@ WIN_BTL_POPUP
Definition enums.h:5249
@ WIN_FILES_SLOT4_TITLE
Definition enums.h:5306
@ WIN_PAUSE_MAIN
Definition enums.h:5262
@ WIN_BTL_DESC_BOX
Definition enums.h:5248

Definition at line 128 of file windows.c.

Referenced by set_windows_visible().