AnimaEngine  1.0.0
Nintendo DS Pokemon Black, White, Black 2, and White 2 sprite extraction and preview toolchain
Data Structures | Macros | Typedefs | Enumerations | Functions
gui_state.h File Reference

GUI global state tracking, rendering options, and control flow wrappers. More...

#include <stddef.h>
#include "gui_platform.h"
#include "anima_backend.h"
#include "pokemon_catalog.h"

Go to the source code of this file.

Data Structures

struct  GuiPreview
 Texture and temporal data cache for animating species previews. More...
 
struct  GuiState
 State variables and option flags for the main immediate-mode GUI editor. More...
 

Macros

#define GUI_TEXT_CAPACITY   4096
 
#define GUI_SEARCH_CAPACITY   128
 
#define GUI_STATUS_CAPACITY   512
 
#define GUI_OUTPUT_ROOT   "out"
 
#define GUI_GIF_DELAY_MIN_CS   1
 
#define GUI_GIF_DELAY_MAX_CS   50
 
#define GUI_GIF_DELAY_DEFAULT_CS   5
 

Typedefs

typedef enum GuiPreviewMode GuiPreviewMode
 Categorization of current preview viewport drawing state. More...
 
typedef struct GuiPreview GuiPreview
 Texture and temporal data cache for animating species previews. More...
 
typedef struct GuiState GuiState
 State variables and option flags for the main immediate-mode GUI editor. More...
 

Enumerations

enum  GuiPreviewMode {
  PREVIEW_GIF , PREVIEW_SPRITESHEET , PREVIEW_STATIC_IDLE , PREVIEW_IDLE_BREAK ,
  PREVIEW_COMPOSED , PREVIEW_NMAR_ANIMATION , PREVIEW_NMCR_MAP
}
 Categorization of current preview viewport drawing state. More...
 

Functions

void GuiState_Init (GuiState *state)
 Initializes default options inside a GuiState structure. More...
 
int GuiState_LoadAndValidateRom (GuiState *state, const char *path)
 Validates NDS ROM header and initializes internal directory mappings. More...
 
void GuiState_SetStatus (GuiState *state, const char *text)
 Sets statusbar notification message. More...
 
void GuiState_CopyText (char *dst, size_t dst_size, const char *src)
 Helper utility to safely copy a string with bounding limit constraints. More...
 
const char * GuiState_BaseName (const char *path)
 Extracts file basename from full absolute or relative path. More...
 
void GuiState_SanitizePath (const char *name, char *out, size_t out_size)
 Sanitizes folder name by stripping out illegal character blocks. More...
 
void GuiState_BuildOutputDir (const PokemonCatalogEntry *entry, char *buf, size_t sz)
 Builds directory path where current species assets will be written. More...
 
int GuiState_EntryMatchesQuery (const PokemonCatalogEntry *entry, const char *query)
 Checks if a Pokemon species matches the search filtering text query. More...
 
const PokemonCatalogEntryGuiState_SelectedEntry (int dex_id)
 Retrieves the species catalog entry matching index. More...
 
int GuiState_GetFormCount (const GuiState *state, int dex_id)
 Retrieves form count for a species. More...
 
const char * GuiState_GetFormName (const GuiState *state, int dex_id, int form_idx)
 Retrieves user-friendly label name of alternate form index. More...
 
void GuiState_UpdatePreview (GuiPreview *p)
 Advances active viewport frame index based on real-world elapsed frame delta time. More...
 
void GuiState_UnloadPreview (GuiPreview *p)
 Deallocates texture cache and color frames stored inside preview struct. More...
 
int GuiState_GifDelayCs (const GuiState *state)
 Retrieves the current custom GIF frame delay. More...
 
void GuiState_SetGifDelayCs (GuiState *state, int delay_cs)
 Sets the custom GIF frame delay. More...
 
int GuiState_TryLoadPreview (GuiState *state, const PokemonCatalogEntry *entry)
 Attempts to load the preview for a Pokemon catalog entry. More...
 
int GuiState_RefreshAssets (GuiState *state, const PokemonCatalogEntry *entry)
 Scans ROM files to discover all asset variants for selected species. More...
 
void GuiState_RunExport (GuiState *state, const PokemonCatalogEntry *entry, int export_spritesheets, int export_static, int export_gif, int export_idle_break, int export_composed)
 Performs batch export run for currently selected Pokemon. More...
 
void GuiState_ExportCurrent (GuiState *state, const PokemonCatalogEntry *entry)
 Exports the currently active preview asset view to its default output file path. More...
 
void GuiState_ExportDsFiles (GuiState *state, const PokemonCatalogEntry *entry)
 Raw dumps individual compressed Nitro NARC blocks for selected species to disk. More...
 
void GuiState_ExportAllAssets (GuiState *state, const PokemonCatalogEntry *entry)
 Recursively renders and writes all assets discovered for species. More...
 

Detailed Description

GUI global state tracking, rendering options, and control flow wrappers.

Macro Definition Documentation

◆ GUI_GIF_DELAY_DEFAULT_CS

#define GUI_GIF_DELAY_DEFAULT_CS   5

Fallback default GIF frame duration in centiseconds.

◆ GUI_GIF_DELAY_MAX_CS

#define GUI_GIF_DELAY_MAX_CS   50

Upper bound constraint for custom GIF frame duration.

◆ GUI_GIF_DELAY_MIN_CS

#define GUI_GIF_DELAY_MIN_CS   1

Lower bound constraint for custom GIF frame duration.

◆ GUI_OUTPUT_ROOT

#define GUI_OUTPUT_ROOT   "out"

Default root output directory relative to project root.

◆ GUI_SEARCH_CAPACITY

#define GUI_SEARCH_CAPACITY   128

Maximum size for species search filter queries.

◆ GUI_STATUS_CAPACITY

#define GUI_STATUS_CAPACITY   512

Maximum size for GUI footer messages.

◆ GUI_TEXT_CAPACITY

#define GUI_TEXT_CAPACITY   4096

Maximum size for ROM path storage.

Typedef Documentation

◆ GuiPreview

typedef struct GuiPreview GuiPreview

Texture and temporal data cache for animating species previews.

◆ GuiPreviewMode

Categorization of current preview viewport drawing state.

◆ GuiState

typedef struct GuiState GuiState

State variables and option flags for the main immediate-mode GUI editor.

Enumeration Type Documentation

◆ GuiPreviewMode

Categorization of current preview viewport drawing state.

Enumerator
PREVIEW_GIF 

Standard animated battle idle GIF loop.

PREVIEW_SPRITESHEET 

Grid spritesheet composite.

PREVIEW_STATIC_IDLE 

High-quality static preview (first frame).

PREVIEW_IDLE_BREAK 

Rarely triggered secondary animation sequence.

PREVIEW_COMPOSED 

Combined timeline loop merging idle + break.

PREVIEW_NMAR_ANIMATION 

Direct play of selected NMAR timeline record.

PREVIEW_NMCR_MAP 

Direct draw of chosen NMCR frame layout map.

Function Documentation

◆ GuiState_BaseName()

const char* GuiState_BaseName ( const char *  path)

Extracts file basename from full absolute or relative path.

Parameters
pathFile path.
Returns
Pointer to start of basename within path string.

◆ GuiState_BuildOutputDir()

void GuiState_BuildOutputDir ( const PokemonCatalogEntry entry,
char *  buf,
size_t  sz 
)

Builds directory path where current species assets will be written.

Parameters
entryPointer to Pokemon catalog entry.
bufOutput path buffer.
szSize of output path buffer.

◆ GuiState_CopyText()

void GuiState_CopyText ( char *  dst,
size_t  dst_size,
const char *  src 
)

Helper utility to safely copy a string with bounding limit constraints.

Parameters
dstDestination buffer.
dst_sizeDestination capacity limit in bytes.
srcSource string.

◆ GuiState_EntryMatchesQuery()

int GuiState_EntryMatchesQuery ( const PokemonCatalogEntry entry,
const char *  query 
)

Checks if a Pokemon species matches the search filtering text query.

Parameters
entryPointer to Pokemon catalog entry.
querySearch query text filter.
Returns
1 on match; 0 otherwise.

◆ GuiState_ExportAllAssets()

void GuiState_ExportAllAssets ( GuiState state,
const PokemonCatalogEntry entry 
)

Recursively renders and writes all assets discovered for species.

Parameters
stateGlobal GUI state.
entryCatalog entry.

◆ GuiState_ExportCurrent()

void GuiState_ExportCurrent ( GuiState state,
const PokemonCatalogEntry entry 
)

Exports the currently active preview asset view to its default output file path.

Parameters
stateGlobal GUI state.
entryCatalog entry.

◆ GuiState_ExportDsFiles()

void GuiState_ExportDsFiles ( GuiState state,
const PokemonCatalogEntry entry 
)

Raw dumps individual compressed Nitro NARC blocks for selected species to disk.

Parameters
stateGlobal GUI state.
entryCatalog entry.

◆ GuiState_GetFormCount()

int GuiState_GetFormCount ( const GuiState state,
int  dex_id 
)

Retrieves form count for a species.

Parameters
stateGlobal GUI state pointer.
dex_idNational Dex ID.
Returns
Amount of alternative forms (at least 1).

◆ GuiState_GetFormName()

const char* GuiState_GetFormName ( const GuiState state,
int  dex_id,
int  form_idx 
)

Retrieves user-friendly label name of alternate form index.

Parameters
stateGlobal GUI state pointer.
dex_idNational Dex ID.
form_idxForm index.
Returns
Read-only form name label.

◆ GuiState_GifDelayCs()

int GuiState_GifDelayCs ( const GuiState state)

Retrieves the current custom GIF frame delay.

Parameters
stateGlobal GUI state pointer.
Returns
Delay in centiseconds.

◆ GuiState_Init()

void GuiState_Init ( GuiState state)

Initializes default options inside a GuiState structure.

Parameters
statePointer to state to initialize.

◆ GuiState_LoadAndValidateRom()

int GuiState_LoadAndValidateRom ( GuiState state,
const char *  path 
)

Validates NDS ROM header and initializes internal directory mappings.

Parameters
stateGlobal GUI state pointer.
pathPath to NDS ROM file.
Returns
0 on success; negative value on validation or load error.

◆ GuiState_RefreshAssets()

int GuiState_RefreshAssets ( GuiState state,
const PokemonCatalogEntry entry 
)

Scans ROM files to discover all asset variants for selected species.

Parameters
stateGlobal GUI state pointer.
entryPokemon catalog entry.
Returns
0 on success; negative value on error.

◆ GuiState_RunExport()

void GuiState_RunExport ( GuiState state,
const PokemonCatalogEntry entry,
int  export_spritesheets,
int  export_static,
int  export_gif,
int  export_idle_break,
int  export_composed 
)

Performs batch export run for currently selected Pokemon.

Parameters
stateGlobal GUI state.
entryCatalog entry.
export_spritesheets1 to generate sheets.
export_static1 to generate static first-frame.
export_gif1 to write standard GIF.
export_idle_break1 to write break GIF.
export_composed1 to write merged loop.

◆ GuiState_SanitizePath()

void GuiState_SanitizePath ( const char *  name,
char *  out,
size_t  out_size 
)

Sanitizes folder name by stripping out illegal character blocks.

Parameters
nameSource directory folder name.
outDestination buffer.
out_sizeSize of destination buffer.

◆ GuiState_SelectedEntry()

const PokemonCatalogEntry* GuiState_SelectedEntry ( int  dex_id)

Retrieves the species catalog entry matching index.

Parameters
dex_idNational Dex ID (1 to 649).
Returns
Catalog entry pointer.

◆ GuiState_SetGifDelayCs()

void GuiState_SetGifDelayCs ( GuiState state,
int  delay_cs 
)

Sets the custom GIF frame delay.

Parameters
stateGlobal GUI state pointer.
delay_csCustom delay in centiseconds.

◆ GuiState_SetStatus()

void GuiState_SetStatus ( GuiState state,
const char *  text 
)

Sets statusbar notification message.

Parameters
stateGlobal GUI state pointer.
textFormat string.

◆ GuiState_TryLoadPreview()

int GuiState_TryLoadPreview ( GuiState state,
const PokemonCatalogEntry entry 
)

Attempts to load the preview for a Pokemon catalog entry.

Parameters
stateGlobal GUI state pointer.
entryPokemon catalog entry.
Returns
0 on success; negative value on failure.

◆ GuiState_UnloadPreview()

void GuiState_UnloadPreview ( GuiPreview p)

Deallocates texture cache and color frames stored inside preview struct.

Parameters
pPointer to preview struct.

◆ GuiState_UpdatePreview()

void GuiState_UpdatePreview ( GuiPreview p)

Advances active viewport frame index based on real-world elapsed frame delta time.

Parameters
pPointer to active preview structure to advance.