Skip to content

GUI Functions

Chris Feger edited this page Sep 29, 2019 · 6 revisions

Below you'll find all the API functions that provide a GUI for user interaction, whether it be simply showing the user a message or getting input from the user.

// in PKSM v7.0.1 and below
void gui_warn(char* lineOne, char* lineTwo);

// After PKSM v7.0.1
void gui_warn(char* warning);

gui_warn is for showing users a simple message

  • only allows the user to exit with A.
  • In PKSM v7.0.1 and below, use of newlines (\n) is not advised in the arguments of this function.
  • After PKSM v7.0.1, newlines (\n) are allowed but testing of looks should be done if using more than one.

"Warn" is somewhat of a misnomer -- it was originally made to warn users that something wrong or unexpected happened, but can be used to show any simple information to the user

gui_warn

// in PKSM v7.0.1 and below
int gui_choice(char* lineOne, char* lineTwo);

// After PKSM v7.0.1
int gui_choice(char* message);

gui_choice is for providing the user with a simple binary choice

  • returns 1 if the user exits with A or it returns 0 if the user exits with B
  • In PKSM v7.0.1and below, use of newlines (\n) is not advised in the arguments of this function.
  • After PKSM v7.0.1, newlines (\n) are allowed but testing of looks should be done if using more than one.

gui_choice

int gui_menu_6x5(char* question, int options, char** labels, struct pkx* pokemon, enum Generation generation);

gui_menu_6x5 brings up a grid of Pokémon sprites for the user to choose from.

  • char* question: Text shown on the bottom screen. Newlines (\n) are allowed
  • int options: Total number of options to be displayed to the user
  • char** labels: Array of strings to use as text labels for the options
  • enum Generation generation: Which generation of species info and sprites should be used in the display (some species have different forms in different generations, like Pikachu)
  • struct pkx* pokemon: Array of pkx structs
struct pkx {
    int species;
    int form;
};
  • int species is the National Dex number of the Pokémon you want to display. 0 results in an egg
  • int form is always necessary, even if all the species you're working with do not have alternate forms. If you're not trying to display a certain alternate form, set form to 0.

gui_menu_6x5

int gui_menu_20x2(char* question, int options, char** labels);
  • char* question: Text shown on the bottom screen. Newlines (\n) are allowed
  • int options: Total number of options to be displayed to the user
  • char** labels: Array of strings to use as text labels for the options

gui_menu_20x2

void gui_numpad(unsigned int* out, char* hint, int maxDigits);

Brings up the numpad to allow user input.

  • unsigned int* out: pointer to an existing unsigned int variable to hold the user's input
  • char* hint: string to be shown if the user clicks on the What? button in the bottom left. Newlines (\n) are allowed but testing of looks should be done if using more than one.
  • int maxDigits: max length of the number provided by user

gui_numpad gui_numpad hint

void gui_keyboard(char* out, char* hint, int maxChars);

Brings up the keyboard to allow user input.

  • char* out: pointer to an existing string variable that should be large enough to hold whatever you're prompting the user for, including the NULL terminator
  • char* hint: string shown in input box when it's empty. Newlines (\n) are allowed, but only the first and last lines will be visible to the user.
  • int maxChars: The number of UTF-16 codepoints allowed to be input, including the null terminator. The data written to out is UTF-8 encoded

gui_keyboard

int gui_boxes(int* fromStorage, int* box, int* slot, int doCrypt);
  • All arguments except doCrypt should be pointers to existing variables
  • fromStorage: whether or not the user's selection is in PKSM's storage (1) or save's PC (0)
  • box, slot: Box and slot numbers of user's selection
  • doCrypt: whether this should (1) or should not (0) it should decrypt and encrypt the boxes itself
    • If you use gui_boxes after sav_box_decrypt, make sure this is 0
  • Returns 0 if a selection was successfully made

gui_boxes

void bank_select();

Brings up the same bank selection screen as seen when changing banks in Storage.

bank_select added after v7.0.1