SSBM Decomp
Loading...
Searching...
No Matches
mndiagram2.c File Reference
#include "mndiagram2.h"
#include "mndiagram2.static.h"
#include "baselib/forward.h"
#include <stdbool.h>
#include <baselib/gobj.h>
#include <baselib/gobjgxlink.h>
#include <baselib/gobjobject.h>
#include <baselib/gobjplink.h>
#include <baselib/gobjproc.h>
#include <baselib/gobjuserdata.h>
#include <baselib/jobj.h>
#include <baselib/memory.h>
#include <baselib/sislib.h>
#include <melee/gm/gm_1601.h>
#include <melee/gm/gmmain_lib.h>
#include <melee/lb/lb_00B0.h>
#include <melee/lb/lb_00F9.h>
#include <melee/lb/lbaudio_ax.h>
#include <melee/mn/mndiagram.h>
#include <melee/mn/mndiagram3.h>
#include <melee/mn/mnmain.h>
#include <melee/mn/mnname.h>

Data Structures

union  mnDiagram2_SortEntry
 
struct  JObjContainer
 Container struct with JObj at offset 0x10. More...
 
struct  Diagram2DetailView
 User data for detail view GObj (used in mnDiagram2_ClearDetailView). More...
 
struct  mnDiagram2_AnimCompleteData
 

Macros

#define mnDiagram_GetNameByIndex_s(x)   ((int) mnDiagram_GetNameByIndex(x))
 
#define mnDiagram_GetFighterByIndex_s(x)   ((int) mnDiagram_GetFighterByIndex(x))
 
#define mnDiagram_GetFighterByIndex_BBC(x)   mnDiagram_GetFighterByIndex_s(x)
 

Functions

static u8 mnDiagram_GetEntityByIndex (u8 is_name_mode, u8 idx)
 Gets entity index based on mode (name or fighter).
 
bool mnDiagram2_IsTimeStat (u8 stat_type)
 Checks if stat type uses time format (H:MM:SS).
 
bool mnDiagram2_IsDistanceStat (u8 stat_type)
 Checks if stat type is a distance stat (shown in feet).
 
bool mnDiagram2_IsPercentageStat (u8 stat_type)
 Checks if stat type is a percentage stat.
 
bool mnDiagram2_IsIconOnlyStat (u8 stat_type)
 Checks if stat type displays as icon only (no numeric value).
 
void mnDiagram2_ClearStatRows (HSD_GObj *gobj)
 Clears all stat row text objects and icon JObjs.
 
void mnDiagram2_UpdateHeader (HSD_GObj *gobj, u8 is_name_mode, u8 entity_idx)
 Updates the header display with fighter/name icon and text.
 
static void mnDiagram2_RefreshStatRows (void)
 Clears and repopulates stat rows based on current selection.
 
void mnDiagram2_HandleInput (HSD_GObj *gobj)
 Handles input for the VS Records character details page.
 
int mnDiagram2_GetStatValue (int is_name_mode, u8 stat_type, u8 entity_idx)
 Retrieves a stat value for a fighter or name entry.
 
void mnDiagram2_CreateStatRow (HSD_GObj *gobj, u8 is_name_mode, u8 stat_type, u8 row_idx, u8 entity_idx)
 Creates a single stat row entry in the VS Records display.
 
void mnDiagram2_PopulateStatRows (HSD_GObj *gobj, u8 scroll_offset, u8 is_name_mode, u8 entity_idx)
 Populates all 10 visible stat rows in the diagram.
 
void mnDiagram2_OnAnimComplete (HSD_GObj *gobj)
 Animation completion callback - destroys GObj when animation ends.
 
void mnDiagram2_UpdateScrollArrows (HSD_GObj *gobj)
 Updates navigation arrow visibility based on scroll/selection state.
 
void mnDiagram2_Think (HSD_GObj *gobj)
 Per-frame callback that updates scroll arrows or starts exit animation.
 
void mnDiagram2_FreeUserData (Diagram2 *data)
 GObj destructor callback that frees user data.
 
void mnDiagram2_InitUserData (void *arg, int unused)
 Initializes user data fields to default values.
 
void mnDiagram2_Create (int arg0)
 Creates the VS Records diagram GObj and populates initial stat rows.
 
void mnDiagram2_Init (void)
 Entry point for VS Records page 2 - initializes diagram and input handler.
 
u8 mnDiagram2_GetRankedFighter (u8 stat_type, u8 rank)
 Returns the fighter at rank N for a given stat type.
 
u8 mnDiagram2_GetRankedName (u8 stat_type, u8 rank)
 Returns the name entry at rank N for a given stat type.
 
void mnDiagram2_GetAggregatedFighterRank (u8 *out, u8 type, u8 idx)
 Computes aggregated fighter ranking across all saved names for icon stats.
 
void mnDiagram2_ClearDetailView (HSD_GObj *gobj)
 Clears the detail view by freeing text objects and removing JObj.
 

Macro Definition Documentation

◆ mnDiagram_GetNameByIndex_s

#define mnDiagram_GetNameByIndex_s (   x)    ((int) mnDiagram_GetNameByIndex(x))

◆ mnDiagram_GetFighterByIndex_s

#define mnDiagram_GetFighterByIndex_s (   x)    ((int) mnDiagram_GetFighterByIndex(x))

◆ mnDiagram_GetFighterByIndex_BBC

#define mnDiagram_GetFighterByIndex_BBC (   x)    mnDiagram_GetFighterByIndex_s(x)

Function Documentation

◆ mnDiagram_GetEntityByIndex()

static u8 mnDiagram_GetEntityByIndex ( u8  is_name_mode,
u8  idx 
)
inlinestatic

Gets entity index based on mode (name or fighter).

◆ mnDiagram2_IsTimeStat()

bool mnDiagram2_IsTimeStat ( u8  stat_type)

Checks if stat type uses time format (H:MM:SS).

Parameters
stat_typeThe stat type index (VSRecordsStatType)
Returns
true if stat should display as time

Only VSSTAT_PLAY_TIME (0x0B) uses time display format.

◆ mnDiagram2_IsDistanceStat()

bool mnDiagram2_IsDistanceStat ( u8  stat_type)

Checks if stat type is a distance stat (shown in feet).

Parameters
stat_typeThe stat type index (VSRecordsStatType)
Returns
true if stat shows distance in ft.

Distance stats: Walk, Run, Fall, Peak Height (0x0E-0x11).

◆ mnDiagram2_IsPercentageStat()

bool mnDiagram2_IsPercentageStat ( u8  stat_type)

Checks if stat type is a percentage stat.

Parameters
stat_typeThe stat type index (VSRecordsStatType)
Returns
true if stat displays with decimal percentage

Percentage stats: Hit %, Play %, Avg Players (0x03, 0x0C, 0x0D).

◆ mnDiagram2_IsIconOnlyStat()

bool mnDiagram2_IsIconOnlyStat ( u8  stat_type)

Checks if stat type displays as icon only (no numeric value).

Parameters
stat_typeThe stat type index (VSRecordsStatType)
Returns
true if stat displays character icons only

Icon-only stats: Most/2nd/Least played fighter (0x15-0x17). These are only shown in Name mode and display a character icon.

◆ mnDiagram2_ClearStatRows()

void mnDiagram2_ClearStatRows ( HSD_GObj gobj)

Clears all stat row text objects and icon JObjs.

Parameters
gobjThe diagram GObj

◆ mnDiagram2_UpdateHeader()

void mnDiagram2_UpdateHeader ( HSD_GObj gobj,
u8  is_name_mode,
u8  entity_idx 
)

Updates the header display with fighter/name icon and text.

Parameters
gobjThe diagram GObj
is_name_mode0 = Fighter mode, 1 = Name mode
entity_idxFighter or Name selection index

◆ mnDiagram2_RefreshStatRows()

static void mnDiagram2_RefreshStatRows ( void  )
inlinestatic

Clears and repopulates stat rows based on current selection.

Reads is_name_mode to determine which entity index to use.

◆ mnDiagram2_HandleInput()

void mnDiagram2_HandleInput ( HSD_GObj gobj)

Handles input for the VS Records character details page.

Parameters
gobjThe diagram GObj (unused, uses global mnDiagram2_804D6C18)

Input mapping:

  • Up/Down: Scroll stat rows
  • Left/Right: Change character/name selection
  • B: Exit to main menu
  • L/R shoulder: Cycle to prev/next VS Records page
  • L/R triggers: Toggle Fighter/Name mode

◆ mnDiagram2_GetStatValue()

int mnDiagram2_GetStatValue ( int  is_name_mode,
u8  stat_type,
u8  entity_idx 
)

Retrieves a stat value for a fighter or name entry.

Parameters
is_name_mode0 = Fighter mode, 1 = Name mode
stat_typeStat category (0x00-0x17), passed as HSD_GObj* due to ABI
entity_idxFighter or Name index
Returns
The stat value for the given category and entity

◆ mnDiagram2_CreateStatRow()

void mnDiagram2_CreateStatRow ( HSD_GObj gobj,
u8  is_name_mode,
u8  stat_type,
u8  row_idx,
u8  entity_idx 
)

Creates a single stat row entry in the VS Records display.

Parameters
gobjThe diagram GObj
is_name_mode0 = Fighter mode, 1 = Name mode
stat_typeStat category index (0-23)
row_idxRow position (0-9, 10 visible rows)
entity_idxFighter or Name index for stat lookup

◆ mnDiagram2_PopulateStatRows()

void mnDiagram2_PopulateStatRows ( HSD_GObj gobj,
u8  scroll_offset,
u8  is_name_mode,
u8  entity_idx 
)

Populates all 10 visible stat rows in the diagram.

Parameters
gobjThe diagram GObj
scroll_offsetCurrent scroll position (stat type offset)
is_name_mode0 = Fighter mode, 1 = Name mode
entity_idxFighter or Name selection index

◆ mnDiagram2_OnAnimComplete()

void mnDiagram2_OnAnimComplete ( HSD_GObj gobj)

Animation completion callback - destroys GObj when animation ends.

◆ mnDiagram2_UpdateScrollArrows()

void mnDiagram2_UpdateScrollArrows ( HSD_GObj gobj)

Updates navigation arrow visibility based on scroll/selection state.

Parameters
gobjThe diagram GObj

Shows/hides arrows:

  • down_arrow (x34): hidden when at bottom
  • up_arrow (x38): hidden when scroll_offset == 0
  • left_arrow (x3C): hidden when at first selection
  • right_arrow (x40): hidden when at last selection

◆ mnDiagram2_Think()

void mnDiagram2_Think ( HSD_GObj gobj)

Per-frame callback that updates scroll arrows or starts exit animation.

Parameters
gobjThe diagram GObj

◆ mnDiagram2_FreeUserData()

void mnDiagram2_FreeUserData ( Diagram2 data)

GObj destructor callback that frees user data.

Parameters
dataThe user data to free

◆ mnDiagram2_InitUserData()

void mnDiagram2_InitUserData ( void *  arg,
int  unused 
)

Initializes user data fields to default values.

Parameters
argThe user data struct to initialize

◆ mnDiagram2_Create()

void mnDiagram2_Create ( int  arg0)

Creates the VS Records diagram GObj and populates initial stat rows.

Parameters
arg0Unused parameter

◆ mnDiagram2_Init()

void mnDiagram2_Init ( void  )

Entry point for VS Records page 2 - initializes diagram and input handler.

◆ mnDiagram2_GetRankedFighter()

u8 mnDiagram2_GetRankedFighter ( u8  stat_type,
u8  rank 
)

Returns the fighter at rank N for a given stat type.

Parameters
stat_typeThe stat type to rank by
rankThe rank to retrieve (0 = highest, 1 = second highest, etc.)
Returns
Fighter ID at the given rank, or 25 if no data

◆ mnDiagram2_GetRankedName()

u8 mnDiagram2_GetRankedName ( u8  stat_type,
u8  rank 
)

Returns the name entry at rank N for a given stat type.

Parameters
stat_typeThe stat type to rank by
rankThe rank to retrieve (0 = highest, 1 = second highest, etc.)
Returns
Name ID at the given rank, or 0x78 if rank exceeds name count

◆ mnDiagram2_GetAggregatedFighterRank()

void mnDiagram2_GetAggregatedFighterRank ( u8 out,
u8  type,
u8  idx 
)

Computes aggregated fighter ranking across all saved names for icon stats.

Parameters
outOutput buffer (cast to SortEntry*) for result
typeStat type (0x15=Most Played, 0x16=2nd Most, 0x17=Least Played)
idxRank index to retrieve

◆ mnDiagram2_ClearDetailView()

void mnDiagram2_ClearDetailView ( HSD_GObj gobj)

Clears the detail view by freeing text objects and removing JObj.

Parameters
gobjThe GObj containing the detail view data