diff --git a/data/specials.inc b/data/specials.inc index 4d2bea3d33..edb839c422 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -554,3 +554,5 @@ gSpecials:: def_special Script_GetChosenMonOffensiveIVs def_special Script_GetChosenMonDefensiveIVs def_special UseBlankMessageToCancelPokemonPic + def_special EnterCode + def_special GetCodeFeedback diff --git a/include/constants/global.h b/include/constants/global.h index 3476bd3680..bfa660b939 100644 --- a/include/constants/global.h +++ b/include/constants/global.h @@ -122,6 +122,7 @@ #define TYPE_NAME_LENGTH 8 #define ABILITY_NAME_LENGTH 16 #define TRAINER_NAME_LENGTH 10 +#define CODE_NAME_LENGTH 11 #define MAX_STAMP_CARD_STAMPS 7 diff --git a/include/naming_screen.h b/include/naming_screen.h index 93527640e5..a0cd3cf74b 100644 --- a/include/naming_screen.h +++ b/include/naming_screen.h @@ -9,6 +9,7 @@ enum { NAMING_SCREEN_CAUGHT_MON, NAMING_SCREEN_NICKNAME, NAMING_SCREEN_WALDA, + NAMING_SCREEN_CODE, }; void DoNamingScreen(u8 templateNum, u8 *destBuffer, u16 monSpecies, u16 monGender, u32 monPersonality, MainCallback returnCallback); diff --git a/src/field_specials.c b/src/field_specials.c index e04a8011fe..247894602c 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -70,6 +70,7 @@ #include "constants/metatile_labels.h" #include "palette.h" #include "battle_util.h" +#include "naming_screen.h" #define TAG_ITEM_ICON 5500 @@ -4344,3 +4345,16 @@ void UseBlankMessageToCancelPokemonPic(void) AddTextPrinterParameterized(0, FONT_NORMAL, &t, 0, 1, 0, NULL); ScriptMenu_HidePokemonPic(); } + +void EnterCode(void) +{ + DoNamingScreen(NAMING_SCREEN_CODE, gStringVar2, 0, 0, 0, CB2_ReturnToFieldContinueScript); +} +void GetCodeFeedback(void) +{ + static const u8 sText_SampleCode[] = _("TestText"); + if (!StringCompare(gStringVar2, sText_SampleCode)) + gSpecialVar_Result = 1; + else + gSpecialVar_Result = 0; +} diff --git a/src/naming_screen.c b/src/naming_screen.c index 118d91cfb4..f5f780ed1c 100644 --- a/src/naming_screen.c +++ b/src/naming_screen.c @@ -1373,6 +1373,7 @@ static void NamingScreen_CreatePlayerIcon(void); static void NamingScreen_CreatePCIcon(void); static void NamingScreen_CreateMonIcon(void); static void NamingScreen_CreateWaldaDadIcon(void); +static void NamingScreen_CreateCodeIcon(void); static void (*const sIconFunctions[])(void) = { @@ -1381,6 +1382,7 @@ static void (*const sIconFunctions[])(void) = NamingScreen_CreatePCIcon, NamingScreen_CreateMonIcon, NamingScreen_CreateWaldaDadIcon, + NamingScreen_CreateCodeIcon, }; static void CreateInputTargetIcon(void) @@ -1431,6 +1433,13 @@ static void NamingScreen_CreateWaldaDadIcon(void) StartSpriteAnim(&gSprites[spriteId], ANIM_STD_GO_SOUTH); } +static void NamingScreen_CreateCodeIcon(void) +{ + u8 spriteId; + spriteId = CreateObjectGraphicsSprite(OBJ_EVENT_GFX_MYSTERY_GIFT_MAN, SpriteCallbackDummy, 56, 37, 0); + gSprites[spriteId].oam.priority = 3; +} + //-------------------------------------------------- // Keyboard handling //-------------------------------------------------- @@ -1744,6 +1753,7 @@ static void (*const sDrawTextEntryBoxFuncs[])(void) = [NAMING_SCREEN_CAUGHT_MON] = DrawMonTextEntryBox, [NAMING_SCREEN_NICKNAME] = DrawMonTextEntryBox, [NAMING_SCREEN_WALDA] = DrawNormalTextEntryBox, + [NAMING_SCREEN_CODE] = DrawNormalTextEntryBox, }; static void DrawTextEntryBox(void) @@ -2146,6 +2156,18 @@ static const struct NamingScreenTemplate sWaldaWordsScreenTemplate = .title = gText_TellHimTheWords, }; +static const u8 sText_EnterCode[] = _("Enter code:"); +static const struct NamingScreenTemplate sCodeScreenTemplate = +{ + .copyExistingString = FALSE, + .maxChars = CODE_NAME_LENGTH, + .iconFunction = 5, + .addGenderIcon = FALSE, + .initialPage = KBPAGE_LETTERS_UPPER, + .unused = 35, + .title = sText_EnterCode, +}; + static const struct NamingScreenTemplate *const sNamingScreenTemplates[] = { [NAMING_SCREEN_PLAYER] = &sPlayerNamingScreenTemplate, @@ -2153,6 +2175,7 @@ static const struct NamingScreenTemplate *const sNamingScreenTemplates[] = [NAMING_SCREEN_CAUGHT_MON] = &sMonNamingScreenTemplate, [NAMING_SCREEN_NICKNAME] = &sMonNamingScreenTemplate, [NAMING_SCREEN_WALDA] = &sWaldaWordsScreenTemplate, + [NAMING_SCREEN_CODE] = &sCodeScreenTemplate, }; static const struct OamData sOam_8x8 =